From ebd70cb5d9b32eb6548f92e03639db5c0683100f Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 3 Oct 2017 23:02:47 +0300 Subject: [PATCH] fix various logging issues --- pico/carthw/svp/memory.c | 2 +- pico/debug.c | 23 ++++++++++++++++++++--- pico/memory.c | 8 ++++---- pico/sek.c | 12 ++++++------ pico/videoport.c | 14 +++++++------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/pico/carthw/svp/memory.c b/pico/carthw/svp/memory.c index b37985e9..c7216112 100644 --- a/pico/carthw/svp/memory.c +++ b/pico/carthw/svp/memory.c @@ -87,7 +87,7 @@ static u32 PicoRead16_svpr(u32 a) a15004_looping = 0; if (!a15004_looping) - elprintf(EL_SVP, "SVP r%i: [%06x] %04x @%06x", realsize, a, d, SekPc); + elprintf(EL_SVP, "SVP r: [%06x] %04x @%06x", a, d, SekPc); if (a == 0xa15004 && !(d&1)) { if (!a15004_looping) diff --git a/pico/debug.c b/pico/debug.c index af5241c1..eb775bf6 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -8,6 +8,7 @@ #include "pico_int.h" #include "sound/ym2612.h" +#include "memory.h" #include "debug.h" #define bit(r, x) ((r>>x)&1) @@ -42,7 +43,7 @@ char *PDebugMain(void) !!(SRam.flags & SRF_ENABLED), !!(SRam.flags & SRF_EEPROM), SRam.eeprom_type); MVP; sprintf(dstrp, "sram range: %06x-%06x, reg: %02x\n", SRam.start, SRam.end, Pico.m.sram_reg); MVP; sprintf(dstrp, "pend int: v:%i, h:%i, vdp status: %04x\n", bit(pv->pending_ints,5), bit(pv->pending_ints,4), pv->status); MVP; - sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %i\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP; + sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %u\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP; sprintf(dstrp, "M68k: PC: %06x, SR: %04x, irql: %i\n", SekPc, SekSr, SekIrqLevel); MVP; for (r = 0; r < 8; r++) { sprintf(dstrp, "d%i=%08x, a%i=%08x\n", r, SekDar(r), r, SekDar(r+8)); MVP; @@ -279,7 +280,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) pvid->debug_p = olddbg; } -#define dump_ram(ram,fname) \ +#define dump_ram_m(ram,fname,mode) \ { \ unsigned short *sram = (unsigned short *) ram; \ FILE *f; \ @@ -287,7 +288,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) \ for (i = 0; i < sizeof(ram)/2; i++) \ sram[i] = (sram[i]<<8) | (sram[i]>>8); \ - f = fopen(fname, "wb"); \ + f = fopen(fname, mode); \ if (f) { \ fwrite(ram, 1, sizeof(ram), f); \ fclose(f); \ @@ -296,6 +297,9 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) sram[i] = (sram[i]<<8) | (sram[i]>>8); \ } +#define dump_ram(ram,fname) \ + dump_ram_m(ram,fname,"wb") + #define dump_ram_noswab(ram,fname) \ { \ FILE *f; \ @@ -308,6 +312,19 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) void PDebugDumpMem(void) { +#if 0 + char buf[1 << M68K_MEM_SHIFT]; + unsigned int a; + for (a = 0; ; a++) { + uptr v = m68k_read16_map[a]; + if (map_flag_set(v)) + break; + v <<= 1; + v += a << M68K_MEM_SHIFT; + memcpy(buf, (void *)v, sizeof(buf)); + dump_ram_m(buf, "dumps/cart.bin", a ? "ab" : "wb"); + } +#endif dump_ram_noswab(Pico.zram, "dumps/zram.bin"); dump_ram(Pico.cram, "dumps/cram.bin"); diff --git a/pico/memory.c b/pico/memory.c index 5d1d25f7..858ab65f 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -341,7 +341,7 @@ static int z80_cycles_from_68k(void) void NOINLINE ctl_write_z80busreq(u32 d) { d&=1; d^=1; - elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc); + elprintf(EL_BUSREQ, "set_zrun: %i->%i [%u] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc); if (d ^ Pico.m.z80Run) { if (d) @@ -363,7 +363,7 @@ void NOINLINE ctl_write_z80busreq(u32 d) void NOINLINE ctl_write_z80reset(u32 d) { d&=1; d^=1; - elprintf(EL_BUSREQ, "set_zreset: %i->%i [%i] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc); + elprintf(EL_BUSREQ, "set_zreset: %i->%i [%u] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc); if (d ^ Pico.m.z80_reset) { if (d) @@ -593,7 +593,7 @@ u32 PicoRead8_io(u32 a) if ((a & 0xff01) == 0x1100) { // z80 busreq (verified) d |= (Pico.m.z80Run | Pico.m.z80_reset) & 1; - elprintf(EL_BUSREQ, "get_zrun: %02x [%i] @%06x", d, SekCyclesDone(), SekPc); + elprintf(EL_BUSREQ, "get_zrun: %02x [%u] @%06x", d, SekCyclesDone(), SekPc); } goto end; } @@ -628,7 +628,7 @@ u32 PicoRead16_io(u32 a) if ((a & 0xff00) == 0x1100) { // z80 busreq d |= ((Pico.m.z80Run | Pico.m.z80_reset) & 1) << 8; - elprintf(EL_BUSREQ, "get_zrun: %04x [%i] @%06x", d, SekCyclesDone(), SekPc); + elprintf(EL_BUSREQ, "get_zrun: %04x [%u] @%06x", d, SekCyclesDone(), SekPc); } goto end; } diff --git a/pico/sek.c b/pico/sek.c index 51765287..c91374bb 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -36,8 +36,8 @@ M68K_CONTEXT PicoCpuFM68k; static int SekIntAck(int level) { // try to emulate VDP's reaction to 68000 int ack - if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); } - else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); } + if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCycleCnt); } + else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCycleCnt); } PicoCpuCM68k.irq = 0; return CYCLONE_INT_ACK_AUTOVECTOR; } @@ -76,8 +76,8 @@ static int SekUnrecognizedOpcode() #ifdef EMU_M68K static int SekIntAckM68K(int level) { - if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); } - else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); } + if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCycleCnt); } + else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCycleCnt); } CPU_INT_LEVEL = 0; return M68K_INT_ACK_AUTOVECTOR; } @@ -94,11 +94,11 @@ static void SekIntAckF68K(unsigned level) { if (level == 4) { Pico.video.pending_ints = 0; - elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCyclesDone()); + elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCyclesDone()); } else if(level == 6) { Pico.video.pending_ints &= ~0x20; - elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCyclesDone()); + elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCyclesDone()); } PicoCpuFM68k.interrupts[0] = 0; } diff --git a/pico/videoport.c b/pico/videoport.c index 0af4bbcc..1f57f2d4 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -223,7 +223,7 @@ static void DmaCopy(int len) unsigned char *vr = (unsigned char *) Pico.vram; unsigned char inc=Pico.video.reg[0xf]; int source; - elprintf(EL_VDPDMA, "DmaCopy len %i [%i]", len, SekCyclesDone()); + elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone()); Pico.m.dma_xfers += len; if (Pico.m.dma_xfers < len) @@ -254,7 +254,7 @@ static NOINLINE void DmaFill(int data) int len, l; len = GetDmaLength(); - elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%i]", len, inc, SekCyclesDone()); + elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%u]", len, inc, SekCyclesDone()); Pico.m.dma_xfers += len; if (Pico.m.dma_xfers < len) // lame 16bit var @@ -430,11 +430,11 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) switch (num) { case 0x00: - elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4, + elprintf(EL_INTSW, "hint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x10)>>4, (d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc); goto update_irq; case 0x01: - elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5, + elprintf(EL_INTSW, "vint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x20)>>5, (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc); goto update_irq; case 0x05: @@ -551,7 +551,7 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) d = hcounts_40[d]; else d = hcounts_32[d]; - elprintf(EL_HVCNT, "hv: %02x %02x (%i) @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc); + elprintf(EL_HVCNT, "hv: %02x %02x [%u] @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc); return d | (Pico.video.v_counter << 8); } @@ -598,7 +598,7 @@ unsigned char PicoVideoRead8CtlL(void) unsigned char PicoVideoRead8HV_H(void) { - elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); + elprintf(EL_HVCNT, "vcounter: %02x [%u] @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); return Pico.video.v_counter; } @@ -609,7 +609,7 @@ unsigned char PicoVideoRead8HV_L(void) if (Pico.video.reg[12]&1) d = hcounts_40[d]; else d = hcounts_32[d]; - elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc); + elprintf(EL_HVCNT, "hcounter: %02x [%u] @ %06x", d, SekCyclesDone(), SekPc); return d; } -- 2.39.5