From ca61ee42d9298aeb5a5c97d9addaa1832af41d67 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 2 Dec 2007 21:12:48 +0000 Subject: [PATCH] Cyclone poll detection problem fixed git-svn-id: file:///home/notaz/opt/svn/PicoDrive@307 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Cart.c | 2 - Pico/Memory.c | 40 +++--------- Pico/MemoryCmn.c | 2 +- Pico/PicoInt.h | 6 +- Pico/cd/LC89510.c | 11 ++-- Pico/cd/Memory.c | 117 +++++++++++++----------------------- Pico/cd/Sek.c | 10 +-- Pico/cd/cd_file.c | 5 +- Pico/cd/cd_sys.c | 3 +- Pico/cd/gfx_cd.c | 2 +- platform/common/lprintf.h | 9 +-- platform/gp2x/Makefile | 2 +- platform/gp2x/emu.c | 2 +- platform/gp2x/gp2x.c | 10 +++ platform/gp2x/menu.c | 5 +- platform/gp2x/port_config.h | 2 +- platform/linux/gp2x.c | 8 +++ 17 files changed, 97 insertions(+), 139 deletions(-) diff --git a/Pico/Cart.c b/Pico/Cart.c index 6f97a423..a19dcc86 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -400,7 +400,6 @@ static int DecodeSmd(unsigned char *data,int len) static unsigned char *cd_realloc(void *old, int filesize) { unsigned char *rom; - dprintf("sizeof(mcd_state): %i", sizeof(mcd_state)); rom=realloc(old, sizeof(mcd_state)); if (rom) memset(rom+0x20000, 0, sizeof(mcd_state)-0x20000); return rom; @@ -418,7 +417,6 @@ static unsigned char *PicoCartAlloc(int filesize) alloc_size&=~0x7ffff; // use alloc size of multiples of 512K, so that memhandlers could be set up more efficiently if((filesize&0x3fff)==0x200) alloc_size+=0x200; else if(alloc_size-filesize < 4) alloc_size+=4; // padding for out-of-bound exec protection - //dprintf("alloc_size: %x\n", alloc_size); // Allocate space for the rom plus padding rom=(unsigned char *)malloc(alloc_size); diff --git a/Pico/Memory.c b/Pico/Memory.c index ecc34c25..8dc11bb5 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -1,14 +1,12 @@ // This is part of Pico Library // (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006 notaz, All rights reserved. +// (c) Copyright 2006,2007 notaz, All rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. -//#define __debug_io - #include "PicoInt.h" #include "sound/ym2612.h" @@ -357,9 +355,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a) if ((a&1)==0) d>>=8; end: -#ifdef __debug_io - dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); -#endif + elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -394,9 +390,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a) else d = OtherRead16(a, 16); end: -#ifdef __debug_io - dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -429,9 +423,7 @@ PICO_INTERNAL_ASM u32 PicoRead32(u32 a) else d = (OtherRead16(a, 32)<<16)|OtherRead16(a+2, 32); end: -#ifdef __debug_io - dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -448,9 +440,7 @@ end: #if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) { -#ifdef __debug_io - dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -465,9 +455,7 @@ PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) void PicoWrite16(u32 a,u16 d) { -#ifdef __debug_io - dprintf("w16: %06x, %04x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -482,9 +470,7 @@ void PicoWrite16(u32 a,u16 d) static void PicoWrite32(u32 a,u32 d) { -#ifdef __debug_io - dprintf("w32: %06x, %08x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -607,9 +593,7 @@ unsigned int m68k_read_memory_8(unsigned int a) if (a>8); return; } - if (a==0xa11200) { dprintf("write z80reset: %04x", d); if(!(d&0x100)) z80_reset(); return; } + if (a==0xa11200) { elprintf(EL_BUSREQ, "write z80reset: %04x", d); if(!(d&0x100)) z80_reset(); return; } if ((a&0xffffe0)==0xa10000) { IoWrite8(a, d); return; } // I/O ports if ((a&0xff4000)==0xa00000) { if(!(Pico.m.z80Run&1)) Pico.zram[a&0x1fff]=(u8)(d>>8); return; } // Z80 ram (MSB only) if ((a&0xe700f8)==0xc00010||(a&0xff7ff8)==0xa07f10) { if(PicoOpt&2) SN76496Write(d); return; } // PSG Sound diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 1a7df25f..ed97081f 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -48,6 +48,7 @@ extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k; #define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase) #define SekSetStop(x) { PicoCpuCM68k.state_flags&=~1; if (x) { PicoCpuCM68k.state_flags|=1; PicoCpuCM68k.cycles=0; } } #define SekSetStopS68k(x) { PicoCpuCS68k.state_flags&=~1; if (x) { PicoCpuCS68k.state_flags|=1; PicoCpuCS68k.cycles=0; } } +#define SekIsStoppedS68k() (PicoCpuCS68k.state_flags&1) #define SekShouldInterrupt (PicoCpuCM68k.irq > (PicoCpuCM68k.srh&7)) #define SekInterrupt(i) PicoCpuCM68k.irq=i @@ -79,6 +80,7 @@ extern M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k; PicoCpuFS68k.execinfo &= ~FM68K_HALTED; \ if (x) { PicoCpuFS68k.execinfo |= FM68K_HALTED; PicoCpuFS68k.io_cycle_counter = 0; } \ } +#define SekIsStoppedS68k() (PicoCpuFS68k.execinfo&FM68K_HALTED) #define SekShouldInterrupt fm68k_would_interrupt() #define SekInterrupt(irq) PicoCpuFM68k.interrupts[0]=irq @@ -111,6 +113,7 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k; if(x) { SET_CYCLES(0); PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \ else PicoCpuMS68k.stopped=0; \ } +#define SekIsStoppedS68k() (PicoCpuMS68k.stopped==STOP_LEVEL_STOP) #define SekShouldInterrupt (CPU_INT_LEVEL > FLAG_INT_MASK) #define SekInterrupt(irq) { \ @@ -478,7 +481,8 @@ PICO_INTERNAL void z80_exit(void); #define EL_SRAMIO 0x0200 /* sram i/o */ #define EL_EEPROM 0x0400 /* eeprom debug */ #define EL_UIO 0x0800 /* unmapped i/o */ -#define EL_IO 0x1000 /* all i/o (TODO) */ +#define EL_IO 0x1000 /* all i/o */ +#define EL_CDPOLL 0x2000 /* MCD: log poll detection */ #define EL_STATUS 0x4000 /* status messages */ #define EL_ANOMALY 0x8000 /* some unexpected conditions (during emulation) */ diff --git a/Pico/cd/LC89510.c b/Pico/cd/LC89510.c index 9abc253b..05ac5d1a 100644 --- a/Pico/cd/LC89510.c +++ b/Pico/cd/LC89510.c @@ -9,8 +9,7 @@ #include "../PicoInt.h" -#define cdprintf dprintf -//#define cdprintf(x...) +#define cdprintf(x...) #define CDC_DMA_SPEED 256 @@ -86,7 +85,7 @@ PICO_INTERNAL void Update_CDC_TRansfer(int which) if (Pico_mcd->s68k_regs[0x33] & (1<<5)) { - dprintf("cdc DTE irq 5"); + elprintf(EL_INTS, "cdc DTE irq 5"); SekInterruptS68k(5); } } @@ -139,7 +138,7 @@ PICO_INTERNAL void Update_CDC_TRansfer(int which) else if (which == 4) // PCM RAM (check: popful Mail) { dep = (DMA_Adr & 0x03FF) << 2; - dprintf("CD DMA # %04x -> PCM[%i] # %04x, len=%i", + cdprintf("CD DMA # %04x -> PCM[%i] # %04x, len=%i", Pico_mcd->cdc.DAC.N, Pico_mcd->pcm.bank, dep, length); dest = (unsigned short *) (Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank] + dep); @@ -212,7 +211,7 @@ PICO_INTERNAL_ASM unsigned short Read_CDC_Host(int is_sub) Pico_mcd->cdc.IFSTAT &= ~0x40; if (Pico_mcd->s68k_regs[0x33]&(1<<5)) { - dprintf("m68k: s68k irq 5"); + elprintf(EL_INTS, "m68k: s68k irq 5"); SekInterruptS68k(5); } @@ -510,7 +509,7 @@ PICO_INTERNAL void CDD_Export_Status(void) if (Pico_mcd->s68k_regs[0x33] & (1<<4)) { - dprintf("cdd export irq 4"); + elprintf(EL_INTS, "cdd export irq 4"); SekInterruptS68k(4); } diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index 0be0a421..b919ee88 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -3,8 +3,6 @@ // (c) Copyright 2007, Grazvydas "notaz" Ignotas -//#define __debug_io - #include "../PicoInt.h" #include "../sound/ym2612.h" @@ -20,15 +18,10 @@ typedef unsigned int u32; #define UTYPES_DEFINED #endif -//#define __debug_io -//#define __debug_io2 - //#define rdprintf dprintf #define rdprintf(...) //#define wrdprintf dprintf #define wrdprintf(...) -#define plprintf dprintf -//#define plprintf(...) #ifdef EMU_CORE_DEBUG extern u32 lastread_a, lastread_d[16], lastwrite_cyc_d[16]; @@ -71,7 +64,7 @@ static u32 m68k_reg_read16(u32 a) d = Read_CDC_Host(0); goto end; case 0xA: - dprintf("m68k FIXME: reserved read"); + elprintf(EL_UIO, "m68k FIXME: reserved read"); goto end; case 0xC: d = Pico_mcd->m.timer_stopwatch >> 16; @@ -85,11 +78,10 @@ static u32 m68k_reg_read16(u32 a) goto end; } - dprintf("m68k_regs FIXME invalid read @ %02x", a); + elprintf(EL_UIO, "m68k_regs FIXME invalid read @ %02x", a); end: - // dprintf("ret = %04x", d); return d; } #endif @@ -105,7 +97,7 @@ void m68k_reg_write8(u32 a, u32 d) switch (a) { case 0: d &= 1; - if ((d&1) && (Pico_mcd->s68k_regs[0x33]&(1<<2))) { dprintf("m68k: s68k irq 2"); SekInterruptS68k(2); } + if ((d&1) && (Pico_mcd->s68k_regs[0x33]&(1<<2))) { elprintf(EL_INTS, "m68k: s68k irq 2"); SekInterruptS68k(2); } return; case 1: d &= 3; @@ -149,7 +141,7 @@ void m68k_reg_write8(u32 a, u32 d) #ifdef USE_POLL_DETECT if ((s68k_poll_adclk&0xfe) == 2 && s68k_poll_cnt > POLL_LIMIT) { SekSetStopS68k(0); s68k_poll_adclk = 0; - plprintf("s68k poll release, a=%02x\n", a); + elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a); } #endif return; @@ -169,7 +161,7 @@ void m68k_reg_write8(u32 a, u32 d) #ifdef USE_POLL_DETECT if ((s68k_poll_adclk&0xfe) == 0xe && s68k_poll_cnt > POLL_LIMIT) { SekSetStopS68k(0); s68k_poll_adclk = 0; - plprintf("s68k poll release, a=%02x\n", a); + elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a); } #endif return; @@ -180,13 +172,13 @@ void m68k_reg_write8(u32 a, u32 d) #ifdef USE_POLL_DETECT if ((a&0xfe) == (s68k_poll_adclk&0xfe) && s68k_poll_cnt > POLL_LIMIT) { SekSetStopS68k(0); s68k_poll_adclk = 0; - plprintf("s68k poll release, a=%02x\n", a); + elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a); } #endif return; } - dprintf("m68k FIXME: invalid write? [%02x] %02x", a, d); + elprintf(EL_UIO, "m68k FIXME: invalid write? [%02x] %02x", a, d); } #ifndef _ASM_CD_MEMORY_C @@ -195,6 +187,8 @@ static u32 s68k_poll_detect(u32 a, u32 d) { #ifdef USE_POLL_DETECT + // needed mostly for Cyclone, which doesn't always check it's cycle counter + if (SekIsStoppedS68k()) return d; // polling detection if (a == (s68k_poll_adclk&0xff)) { unsigned int clkdiff = SekCyclesDoneS68k() - (s68k_poll_adclk>>8); @@ -203,7 +197,7 @@ u32 s68k_poll_detect(u32 a, u32 d) //printf("-- diff: %u, cnt = %i\n", clkdiff, s68k_poll_cnt); if (s68k_poll_cnt > POLL_LIMIT) { SekSetStopS68k(1); - plprintf("s68k poll detected @ %06x, a=%02x\n", SekPcS68k, a); + elprintf(EL_CDPOLL, "s68k poll detected @ %06x, a=%02x\n", SekPcS68k, a); } s68k_poll_adclk = (SekCyclesDoneS68k() << 8) | a; return d; @@ -374,7 +368,7 @@ void s68k_reg_write8(u32 a, u32 d) if ((a&0x1f0) == 0x10 || (a >= 0x38 && a < 0x42)) { - dprintf("s68k FIXME: invalid write @ %02x?", a); + elprintf(EL_UIO, "s68k FIXME: invalid write @ %02x?", a); return; } @@ -410,7 +404,7 @@ static u32 OtherRead16End(u32 a, int realsize) goto end; } - dprintf("m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc); + elprintf(EL_UIO, "m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc); end: return d; @@ -434,7 +428,7 @@ static void OtherWrite8End(u32 a, u32 d, int realsize) return; } - dprintf("m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc); + elprintf(EL_UIO, "m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc); } #define _CD_MEMORY_C @@ -521,9 +515,7 @@ u32 PicoReadM68k8(u32 a) } -#ifdef __debug_io - dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); -#endif + elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -608,9 +600,7 @@ static u32 PicoReadM68k16(u32 a) } -#ifdef __debug_io - dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -704,9 +694,7 @@ static u32 PicoReadM68k32(u32 a) } -#ifdef __debug_io - dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG if (a>=Pico.romsize) { lastread_a = a; @@ -725,9 +713,7 @@ void PicoWriteM68k8(u32 a,u8 d); #else void PicoWriteM68k8(u32 a,u8 d) { -#ifdef __debug_io - dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); -#endif + elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -778,9 +764,7 @@ void PicoWriteM68k16(u32 a,u16 d); #else static void PicoWriteM68k16(u32 a,u16 d) { -#ifdef __debug_io - dprintf("w16: %06x, %04x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -824,7 +808,7 @@ static void PicoWriteM68k16(u32 a,u16 d) #ifdef USE_POLL_DETECT if ((s68k_poll_adclk&0xfe) == 0xe && s68k_poll_cnt > POLL_LIMIT) { SekSetStopS68k(0); s68k_poll_adclk = 0; - plprintf("s68k poll release, a=%02x\n", a); + elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a); } #endif return; @@ -850,9 +834,7 @@ void PicoWriteM68k32(u32 a,u32 d); #else static void PicoWriteM68k32(u32 a,u32 d) { -#ifdef __debug_io - dprintf("w32: %06x, %08x", a&0xffffff, d); -#endif + elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -968,7 +950,6 @@ static u32 PicoReadS68k8(u32 a) d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff]; if (a&1) d &= 0x0f; else d >>= 4; - dprintf("FIXME: decode"); } else { // allow access in any mode, like Gens does d = Pico_mcd->word_ram2M[(a^1)&0x3ffff]; @@ -991,7 +972,7 @@ static u32 PicoReadS68k8(u32 a) // PCM if ((a&0xff8000)==0xff0000) { - dprintf("s68k_pcm r8: [%06x] @%06x", a, SekPcS68k); + elprintf(EL_IO, "s68k_pcm r8: [%06x] @%06x", a, SekPcS68k); a &= 0x7fff; if (a >= 0x2000) d = Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a>>1)&0xfff]; @@ -1000,7 +981,7 @@ static u32 PicoReadS68k8(u32 a) d = Pico_mcd->pcm.ch[a>>2].addr >> PCM_STEP_SHIFT; if (a & 2) d >>= 8; } - dprintf("ret = %02x", (u8)d); + elprintf(EL_IO, "ret = %02x", (u8)d); goto end; } @@ -1010,13 +991,11 @@ static u32 PicoReadS68k8(u32 a) goto end; } - dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k); + elprintf(EL_UIO, "s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k); end: -#ifdef __debug_io2 - dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k); #ifdef EMU_CORE_DEBUG lastread_a = ab; lastread_d[lrp_cyc++&15] = d; @@ -1064,7 +1043,6 @@ static u32 PicoReadS68k16(u32 a) int bank = (Pico_mcd->s68k_regs[3]&1)^1; d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff]; d |= d << 4; d &= ~0xf0; - dprintf("FIXME: decode"); } else { // allow access in any mode, like Gens does d = *(u16 *)(Pico_mcd->word_ram2M+(a&0x3fffe)); @@ -1110,13 +1088,11 @@ static u32 PicoReadS68k16(u32 a) goto end; } - dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); + elprintf(EL_UIO, "s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); end: -#ifdef __debug_io2 - dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); #ifdef EMU_CORE_DEBUG lastread_a = ab; lastread_d[lrp_cyc++&15] = d; @@ -1220,13 +1196,11 @@ static u32 PicoReadS68k32(u32 a) goto end; } - dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); + elprintf(EL_UIO, "s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); end: -#ifdef __debug_io2 - dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); #ifdef EMU_CORE_DEBUG if (ab > 0x78) { // not vectors and stuff lastread_a = ab; @@ -1296,9 +1270,7 @@ void PicoWriteS68k8(u32 a,u8 d); #else static void PicoWriteS68k8(u32 a,u8 d) { -#ifdef __debug_io2 - dprintf("s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k); a&=0xffffff; @@ -1366,7 +1338,7 @@ static void PicoWriteS68k8(u32 a,u8 d) return; } - dprintf("s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k); + elprintf(EL_UIO, "s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k); } #endif @@ -1376,9 +1348,7 @@ void PicoWriteS68k16(u32 a,u16 d); #else static void PicoWriteS68k16(u32 a,u16 d) { -#ifdef __debug_io2 - dprintf("s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); a&=0xfffffe; @@ -1456,7 +1426,7 @@ static void PicoWriteS68k16(u32 a,u16 d) return; } - dprintf("s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); + elprintf(EL_UIO, "s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); } #endif @@ -1466,9 +1436,7 @@ void PicoWriteS68k32(u32 a,u32 d); #else static void PicoWriteS68k32(u32 a,u32 d) { -#ifdef __debug_io2 - dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); -#endif + elprintf(EL_IO, "s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); a&=0xfffffe; @@ -1558,7 +1526,7 @@ static void PicoWriteS68k32(u32 a,u32 d) return; } - dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); + elprintf(EL_UIO, "s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); } #endif @@ -1586,7 +1554,7 @@ static __inline int PicoMemBaseM68k(u32 pc) } // Error - Program Counter is invalid - dprintf("m68k FIXME: unhandled jump to %06x", pc); + elprintf(EL_ANOMALY, "m68k FIXME: unhandled jump to %06x", pc); return (int)Pico_mcd->bios; } @@ -1617,7 +1585,7 @@ static __inline int PicoMemBaseS68k(u32 pc) } // Error - Program Counter is invalid - dprintf("s68k FIXME: unhandled jump to %06x", pc); + elprintf(EL_ANOMALY, "s68k FIXME: unhandled jump to %06x", pc); return (int)Pico_mcd->prg_ram; } @@ -1658,7 +1626,6 @@ void PicoMemResetCD(int r3) PICO_INTERNAL void PicoMemSetupCD(void) { - dprintf("PicoMemSetupCD()"); #ifdef EMU_C68K // Setup m68k memory callbacks: PicoCpuCM68k.checkpc=PicoCheckPcM68k; @@ -1757,7 +1724,7 @@ unsigned int m68k_read_pcrelative_CD8 (unsigned int a) int bank = (Pico_mcd->s68k_regs[3]&1)^1; return *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff)); } - dprintf("s68k_read_pcrelative_CD8 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD8 FIXME: can't handle %06x", a); } else { if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram if(a<0x20000) return *(u8 *)(Pico.rom+(a^1)); // Bios @@ -1769,7 +1736,7 @@ unsigned int m68k_read_pcrelative_CD8 (unsigned int a) return *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff)); } } - dprintf("m68k_read_pcrelative_CD8 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD8 FIXME: can't handle %06x", a); } return 0;//(u8) lastread_d; } @@ -1784,7 +1751,7 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a) int bank = (Pico_mcd->s68k_regs[3]&1)^1; return *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); } - dprintf("s68k_read_pcrelative_CD16 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD16 FIXME: can't handle %06x", a); } else { if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram if(a<0x20000) return *(u16 *)(Pico.rom+(a&~1)); // Bios @@ -1796,7 +1763,7 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a) return *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); } } - dprintf("m68k_read_pcrelative_CD16 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD16 FIXME: can't handle %06x", a); } return 0; } @@ -1813,7 +1780,7 @@ unsigned int m68k_read_pcrelative_CD32(unsigned int a) pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe)); return (pm[0]<<16)|pm[1]; } - dprintf("s68k_read_pcrelative_CD32 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD32 FIXME: can't handle %06x", a); } else { if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram if(a<0x20000) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; } @@ -1826,7 +1793,7 @@ unsigned int m68k_read_pcrelative_CD32(unsigned int a) return (pm[0]<<16)|pm[1]; } } - dprintf("m68k_read_pcrelative_CD32 FIXME: can't handle %06x", a); + elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD32 FIXME: can't handle %06x", a); } return 0; } diff --git a/Pico/cd/Sek.c b/Pico/cd/Sek.c index 8e5e45ff..47370dae 100644 --- a/Pico/cd/Sek.c +++ b/Pico/cd/Sek.c @@ -40,14 +40,14 @@ static int SekIntAckS68k(int level) { int level_new = new_irq_level(level); - dprintf("s68kACK %i -> %i", level, level_new); + elprintf(EL_INTS, "s68kACK %i -> %i", level, level_new); PicoCpuCS68k.irq = level_new; return CYCLONE_INT_ACK_AUTOVECTOR; } static void SekResetAckS68k(void) { - dprintf("s68k: Reset encountered @ %06x", SekPcS68k); + elprintf(EL_ANOMALY, "s68k: Reset encountered @ %06x", SekPcS68k); } static int SekUnrecognizedOpcodeS68k(void) @@ -55,7 +55,7 @@ static int SekUnrecognizedOpcodeS68k(void) unsigned int pc, op; pc = SekPcS68k; op = PicoCpuCS68k.read16(pc); - dprintf("Unrecognized Opcode %04x @ %06x", op, pc); + elprintf(EL_ANOMALY, "Unrecognized Opcode %04x @ %06x", op, pc); //exit(1); return 0; } @@ -66,7 +66,7 @@ static int SekIntAckMS68k(int level) { #ifndef EMU_CORE_DEBUG int level_new = new_irq_level(level); - dprintf("s68kACK %i -> %i", level, level_new); + elprintf(EL_INTS, "s68kACK %i -> %i", level, level_new); CPU_INT_LEVEL = level_new << 8; #else CPU_INT_LEVEL = 0; @@ -79,7 +79,7 @@ static int SekIntAckMS68k(int level) static void SekIntAckFS68k(unsigned level) { int level_new = new_irq_level(level); - dprintf("s68kACK %i -> %i", level, level_new); + elprintf(EL_INTS, "s68kACK %i -> %i", level, level_new); #ifndef EMU_CORE_DEBUG PicoCpuFS68k.interrupts[0] = level_new; #else diff --git a/Pico/cd/cd_file.c b/Pico/cd/cd_file.c index 1a4d62ae..9c898a92 100644 --- a/Pico/cd/cd_file.c +++ b/Pico/cd/cd_file.c @@ -10,8 +10,7 @@ #include "../PicoInt.h" #include "cd_file.h" -#define cdprintf dprintf -//#define cdprintf(x...) +#define cdprintf(x...) //#define cdprintf(f,...) printf(f "\n",##__VA_ARGS__) // tmp #define DEBUG_CD @@ -279,7 +278,7 @@ PICO_INTERNAL int FILE_Read_One_LBA_CDC(void) { if (Pico_mcd->s68k_regs[0x33] & (1<<5)) { - dprintf("cdc dec irq 5"); + elprintf(EL_INTS, "cdc dec irq 5"); SekInterruptS68k(5); } diff --git a/Pico/cd/cd_sys.c b/Pico/cd/cd_sys.c index 61482e15..713b995a 100644 --- a/Pico/cd/cd_sys.c +++ b/Pico/cd/cd_sys.c @@ -13,8 +13,7 @@ #include "cd_sys.h" #include "cd_file.h" -#define cdprintf dprintf -//#define cdprintf(x...) +#define cdprintf(x...) #define DEBUG_CD #define TRAY_OPEN 0x0500 // TRAY OPEN CDD status diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index 630109c9..bee0b940 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -77,7 +77,7 @@ static void gfx_completed(void) _rot_comp.Reg_64 = 0; if (Pico_mcd->s68k_regs[0x33] & (1<<1)) { - dprintf("gfx_cd irq 1"); + elprintf(EL_INTS, "gfx_cd irq 1"); SekInterruptS68k(1); } } diff --git a/platform/common/lprintf.h b/platform/common/lprintf.h index 1d304721..34ec6b70 100644 --- a/platform/common/lprintf.h +++ b/platform/common/lprintf.h @@ -1,9 +1,2 @@ -#if defined(__GP2X__) - #include - #define lprintf printf -#elif defined(PSP) - extern void lprintf(const char *fmt, ...); -#else - #include "giz.h" -#endif +extern void lprintf(const char *fmt, ...); diff --git a/platform/gp2x/Makefile b/platform/gp2x/Makefile index eeb37c7c..7c083c19 100644 --- a/platform/gp2x/Makefile +++ b/platform/gp2x/Makefile @@ -34,7 +34,7 @@ endif DEFINC = -I../.. -I. -DARM -D__GP2X__ # -DBENCHMARK COPT_COMMON = -static -Wall -Winline ifeq ($(DEBUG),) -COPT_COMMON += -O2 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math +COPT_COMMON += -O3 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math else COPT_COMMON += -ggdb endif diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 701bcd81..3f2ed3fc 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -43,7 +43,7 @@ char romFileName[PATH_MAX]; extern int crashed_940; -static short sndBuffer[2*44100/50]; +static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; static struct timeval noticeMsgTime = { 0, 0 }; // when started showing static int osd_fps_x; static int combo_keys = 0, combo_acts = 0; // keys and actions which need button combos diff --git a/platform/gp2x/gp2x.c b/platform/gp2x/gp2x.c index 4995f08b..3ed64fb3 100644 --- a/platform/gp2x/gp2x.c +++ b/platform/gp2x/gp2x.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -375,4 +376,13 @@ void gp2x_deinit(void) } } +/* lprintf */ +void lprintf(const char *fmt, ...) +{ + va_list vl; + + va_start(vl, fmt); + vprintf(fmt, vl); + va_end(vl); +} diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index 8b4968ce..ddb9d2e3 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -155,11 +155,12 @@ static void cdload_progress_cb(int percent) smalltext_out16(1, 3*10, "Processing CD image / MP3s", 0xffff); smalltext_out16_lim(1, 4*10, romFileName, 0xffff, 80); - dst += 30; + dst += 320*30; if (len > 320) len = 320; for (ln = 8; ln > 0; ln--, dst += 320) memset(dst, 0xff, len*2); + menu_flip(); cdload_called = 1; } @@ -182,7 +183,7 @@ void menu_romload_prepare(const char *rom_name) void menu_romload_end(void) { - PicoCartLoadProgressCB = NULL; + PicoCartLoadProgressCB = PicoCDLoadProgressCB = NULL; smalltext_out16(1, cdload_called ? 60 : 30, "Starting emulation...", 0xffff); menu_flip(); } diff --git a/platform/gp2x/port_config.h b/platform/gp2x/port_config.h index 5d9bf048..1503593f 100644 --- a/platform/gp2x/port_config.h +++ b/platform/gp2x/port_config.h @@ -18,7 +18,7 @@ #define CAN_HANDLE_240_LINES 1 // logging emu events -#define EL_LOGMASK 0 // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO) // xffff +#define EL_LOGMASK EL_STATUS // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO|EL_INTS|EL_CDPOLL) // xffff //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) #define dprintf(x...) diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 3b43c3d3..b89990bc 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -428,5 +428,13 @@ void spend_cycles(int c) usleep(c/200); } +/* lprintf */ +void lprintf(const char *fmt, ...) +{ + va_list vl; + va_start(vl, fmt); + vprintf(fmt, vl); + va_end(vl); +} -- 2.39.5