// (c) Copyright 2008 notaz, All rights reserved.
#include "pico_int.h"
+#include "sound/ym2612.h"
#include "debug.h"
#define bit(r, x) ((r>>x)&1)
void PDebugShowPalette(unsigned short *screen, int stride)
{
- unsigned int *spal=(void *)Pico.cram;
- unsigned int *dpal=(void *)HighPal;
- int x, y, i;
+ int x, y;
- for (i = 0x3f/2; i >= 0; i--)
-#ifdef USE_BGR555
- dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
-#else
- dpal[i] = ((spal[i]&0x000f000f)<<12)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)>>7);
-#endif
- for (i = 0x3f; i >= 0; i--)
- HighPal[0x40|i] = (unsigned short)((HighPal[i]>>1)&0x738e);
- for (i = 0x3f; i >= 0; i--) {
- int t=HighPal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
- HighPal[0x80|i] = (unsigned short)t;
- }
+ Pico.m.dirtyPal = 1;
+ if (PicoAHW & PAHW_SMS)
+ PicoDoHighPal555M4();
+ else
+ PicoDoHighPal555(1);
+ Pico.m.dirtyPal = 1;
screen += 16*stride+8;
for (y = 0; y < 8*4; y++)
for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++)
screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x80];
-
- Pico.m.dirtyPal = 1;
}
#if defined(DRAW2_OVERRIDE_LINE_WIDTH)
void PDebugDumpMem(void)
{
- dump_ram(Pico.ram, "dumps/ram.bin");
dump_ram_noswab(Pico.zram, "dumps/zram.bin");
- dump_ram(Pico.vram, "dumps/vram.bin");
dump_ram(Pico.cram, "dumps/cram.bin");
- dump_ram(Pico.vsram,"dumps/vsram.bin");
+
+ if (PicoAHW & PAHW_SMS)
+ {
+ dump_ram_noswab(Pico.vramb, "dumps/vram.bin");
+ }
+ else
+ {
+ dump_ram(Pico.ram, "dumps/ram.bin");
+ dump_ram(Pico.vram, "dumps/vram.bin");
+ dump_ram(Pico.vsram,"dumps/vsram.bin");
+ }
if (PicoAHW & PAHW_MCD)
{
}
}
+void PDebugZ80Frame(void)
+{
+ int lines, line_sample;
+
+ if (PicoAHW & PAHW_SMS)
+ return;
+
+ if (Pico.m.pal) {
+ lines = 312;
+ line_sample = 68;
+ } else {
+ lines = 262;
+ line_sample = 93;
+ }
+
+ z80_resetCycles();
+ emustatus &= ~1;
+
+ if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
+ PicoSyncZ80(line_sample*488);
+ if (ym2612.dacen && PsndDacLine <= line_sample)
+ PsndDoDAC(line_sample);
+ if (PsndOut)
+ PsndGetSamples(line_sample);
+
+ if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
+ PicoSyncZ80(224*488);
+ z80_int();
+ }
+ if (ym2612.dacen && PsndDacLine <= 224)
+ PsndDoDAC(224);
+ if (PsndOut)
+ PsndGetSamples(224);
+
+ // sync z80
+ if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
+ PicoSyncZ80(Pico.m.pal ? 151809 : 127671); // cycles adjusted for converter
+ if (PsndOut && ym2612.dacen && PsndDacLine <= lines-1)
+ PsndDoDAC(lines-1);
+
+ timers_cycle();
+}
+
+void PDebugCPUStep(void)
+{
+ if (PicoAHW & PAHW_SMS)
+ z80_run(1);
+ else
+ SekStepM68k();
+}
+