From 0ffefdb8bd172c258497ce0cd14d1f2ea1358f69 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 26 Jan 2008 10:02:50 +0000 Subject: [PATCH] asm code updated, Bass Masters fix git-svn-id: file:///home/notaz/opt/svn/PicoDrive@330 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Cart.c | 3 +++ Pico/Memory.s | 21 +++++++++++++++------ Pico/MemoryCmn.c | 7 ------- Pico/Memory_amips.s | 40 ++++++++++++++++++++++++++++++++++++---- Pico/Pico.c | 14 +++++--------- Pico/Pico.h | 7 ++++--- Pico/PicoFrameHints.c | 6 +++--- Pico/PicoInt.h | 2 +- Pico/VideoPort.c | 20 +++++++++++--------- Pico/carthw/svp/svp.c | 5 +++-- Pico/cd/Memory.c | 10 ++++++++-- Pico/cd/Memory.s | 1 - platform/gp2x/Makefile | 2 ++ 13 files changed, 91 insertions(+), 47 deletions(-) diff --git a/Pico/Cart.c b/Pico/Cart.c index b641130..f82c325 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -498,10 +498,13 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize) PicoResetHook = NULL; PicoLineHook = NULL; + PicoMemReset(); + if (!(PicoMCD & 1)) PicoCartDetect(); // setup correct memory map for loaded ROM + // call PicoMemReset again due to possible memmap change if (PicoMCD & 1) PicoMemSetupCD(); else PicoMemSetup(); diff --git a/Pico/Memory.s b/Pico/Memory.s index 7f3c2cb..368b640 100644 --- a/Pico/Memory.s +++ b/Pico/Memory.s @@ -448,10 +448,13 @@ m_read8_above_rom: tst r1, #5 bne SRAMRead m_read8_ar_nosram: + ldr r2, =PicoRead16Hook stmfd sp!,{r0,lr} + ldr r2, [r2] bic r0, r0, #1 mov r1, #8 - bl OtherRead16End + mov lr, pc + bx r2 ldmfd sp!,{r1,lr} tst r1, #1 moveq r0, r0, lsr #8 @@ -595,8 +598,10 @@ m_read16_above_rom: bl SRAMRead16 ldmfd sp!,{pc} m_read16_ar_nosram: + ldr r2, =PicoRead16Hook + ldr r2, [r2] mov r1, #16 - b OtherRead16End + bx r2 .pool @@ -748,16 +753,20 @@ m_read32_ram: bx lr m_read32_above_rom: + ldr r2, =PicoRead16Hook bic r0, r0, #1 - stmfd sp!,{r0,lr} + ldr r2, [r2] mov r1, #32 - bl OtherRead16End + stmfd sp!,{r0,r2,lr} + mov lr, pc + bx r2 mov r1, r0 - ldmfd sp!,{r0} + ldmfd sp!,{r0,r2} stmfd sp!,{r1} add r0, r0, #2 mov r1, #32 - bl OtherRead16End + mov lr, pc + bx r2 ldmfd sp!,{r1,lr} orr r0, r0, r1, lsl #16 bx lr diff --git a/Pico/MemoryCmn.c b/Pico/MemoryCmn.c index dd705c0..996a5ae 100644 --- a/Pico/MemoryCmn.c +++ b/Pico/MemoryCmn.c @@ -8,13 +8,6 @@ typedef unsigned int u32; #define UTYPES_DEFINED #endif -#ifdef _ASM_MEMORY_C -u32 OtherRead16End(u32 a, int realsize); -#endif -#ifdef _ASM_CD_MEMORY_C -static void OtherWrite8End(u32 a,u32 d,int realsize); -#endif - #ifndef _ASM_MEMORY_C static diff --git a/Pico/Memory_amips.s b/Pico/Memory_amips.s index 0c18f4b..4ad7cd3 100644 --- a/Pico/Memory_amips.s +++ b/Pico/Memory_amips.s @@ -435,16 +435,28 @@ m_read8_fake_ym2612: sb $t1, %lo(Pico+0x22208)($t0) # delay slot friendly -.macro m_read8_call16 funcname +.macro m_read8_call16 funcname is_func_ptr=0 +.if \is_func_ptr + lui $t1, %hi(\funcname) + lw $t1, %lo(\funcname)($t1) +.endif andi $t0, $a0, 1 beqz $t0, 1f li $a1, 8 # not always needed, but shouln't cause problems +.if \is_func_ptr + jr $t1 +.else j \funcname # odd address +.endif nop 1: addiu $sp, -4 sw $ra, 0($sp) +.if \is_func_ptr + jalr $t1 +.else jal \funcname +.endif xori $a0, 1 lw $ra, 0($sp) addiu $sp, 4 @@ -473,7 +485,7 @@ m_read8_ram: m_read8_above_rom: # might still be SRam (Micro Machines, HardBall '95) m_read_rom_try_sram 0 8 - m_read8_call16 OtherRead16End + m_read8_call16 PicoRead16Hook 1 # ############################################################################# @@ -584,7 +596,9 @@ m_read16_ram: m_read16_above_rom: # might still be SRam m_read_rom_try_sram 0 16 - j OtherRead16End + lui $t1, %hi(PicoRead16Hook) + lw $t1, %lo(PicoRead16Hook)($t1) + jr $t1 ins $a0, $0, 0, 1 # ############################################################################# @@ -725,7 +739,25 @@ m_read32_above_rom: # might still be SRam m_read_rom_try_sram 0 32 ins $a0, $0, 0, 1 - m_read32_call16 OtherRead16End + lui $t1, %hi(PicoRead16Hook) + lw $t1, %lo(PicoRead16Hook)($t1) + addiu $sp, -4*3 + sw $ra, 0($sp) + sw $s0, 4($sp) + sw $t1, 8($sp) + jalr $t1 + move $s0, $a0 + + lw $t1, 8($sp) + addu $a0, $s0, 2 + jalr $t1 + move $s0, $v0 + + ins $v0, $s0, 16, 16 + lw $ra, 0($sp) + lw $s0, 4($sp) + jr $ra + addiu $sp, 4*3 # ############################################################################# diff --git a/Pico/Pico.c b/Pico/Pico.c index 6d9d525..93d6876 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -19,7 +19,7 @@ int PicoAutoRgnOrder = 0; int emustatus = 0; // rapid_ym2612, multi_ym_updates void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware void (*PicoResetHook)(void) = NULL; -void (*PicoLineHook)(void) = NULL; +void (*PicoLineHook)(int count) = NULL; struct PicoSRAM SRam = {0,}; int z80startCycle, z80stopCycle; // in 68k cycles @@ -364,6 +364,7 @@ static int PicoFrameSimple(void) SekRunM68k(cycles_68k_block); PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(lines_step); line=lines; } @@ -377,6 +378,7 @@ static int PicoFrameSimple(void) lines += sects*lines_step; PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(sects*lines_step); } // render screen @@ -440,6 +442,7 @@ static int PicoFrameSimple(void) SekRunM68k(cycles_68k_vblock); PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(lines_step); line=lines; sects--; @@ -450,6 +453,7 @@ static int PicoFrameSimple(void) if (sects) { lines += sects*lines_step; PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(sects*lines_step); } return 0; @@ -577,14 +581,6 @@ char *debugString(void) } #endif -#if 0 - { - FILE *f = fopen("zram", "wb"); - fwrite(Pico.zram, 1, 0x2000, f); - fclose(f); - } -#endif - return dstr; } #endif diff --git a/Pico/Pico.h b/Pico/Pico.h index cdba60b..23e9e0b 100644 --- a/Pico/Pico.h +++ b/Pico/Pico.h @@ -40,10 +40,11 @@ extern int PicoVer; extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP -int PicoInit(void); +extern int PicoSVPCycles; +int PicoInit(void); void PicoExit(void); -int PicoReset(int hard); -int PicoFrame(void); +int PicoReset(int hard); +int PicoFrame(void); void PicoFrameDrawOnly(void); extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware diff --git a/Pico/PicoFrameHints.c b/Pico/PicoFrameHints.c index 49dd37b..755ab3d 100644 --- a/Pico/PicoFrameHints.c +++ b/Pico/PicoFrameHints.c @@ -150,7 +150,7 @@ static int PicoFrameHints(void) #ifdef PICO_CD update_chips(); #else - if (PicoLineHook) PicoLineHook(); + if (PicoLineHook) PicoLineHook(1); #endif } @@ -214,7 +214,7 @@ static int PicoFrameHints(void) #ifdef PICO_CD update_chips(); #else - if (PicoLineHook) PicoLineHook(); + if (PicoLineHook) PicoLineHook(1); #endif // PAL line count might actually be 313 according to Steve Snake, but that would complicate things. @@ -239,7 +239,7 @@ static int PicoFrameHints(void) #ifdef PICO_CD update_chips(); #else - if (PicoLineHook) PicoLineHook(); + if (PicoLineHook) PicoLineHook(1); #endif } diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index 85b2579..e2ce1ad 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -410,7 +410,7 @@ extern struct PicoSRAM SRam; extern int emustatus; extern int z80startCycle, z80stopCycle; // in 68k cycles extern void (*PicoResetHook)(void); -extern void (*PicoLineHook)(void); +extern void (*PicoLineHook)(int count); PICO_INTERNAL int CheckDMA(void); // cd/Pico.c diff --git a/Pico/VideoPort.c b/Pico/VideoPort.c index 62f487a..59a57b2 100644 --- a/Pico/VideoPort.c +++ b/Pico/VideoPort.c @@ -370,19 +370,24 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) { // Register write: int num=(d>>8)&0x1f; - if(num==00) elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (pvid->reg[0]&0x10)>>4, + int dold=pvid->reg[num]; + if (num > 0x0a && !(pvid->reg[1]&4)) { + elprintf(EL_ANOMALY, "%02x written to reg %02x in SMS mode @ %06x", d, num, SekPc); + } else + pvid->reg[num]=(unsigned char)d; + if (num==00) elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4, (d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc); - if(num==01) elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (pvid->reg[1]&0x20)>>5, + if (num==01) elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5, (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc); - //if(num==01) dprintf("set_blank: %i @ %06x [%i|%i]", !((d&0x40)>>6), SekPc, Pico.m.scanline, SekCyclesDone()); - //if(num==10) dprintf("hint_set: %i @ %06x [%i|%i]", (unsigned char)d, SekPc, Pico.m.scanline, SekCyclesDone()); - pvid->reg[num]=(unsigned char)d; + if (num == 5 && (d^dold)) rendstatus|=1; + // renderers should update their palettes if sh/hi mode is changed + else if (num == 0xc && ((d^dold)&8)) Pico.m.dirtyPal = 2; #ifndef EMU_CORE_DEBUG // update IRQ level (Lemmings, Wiz 'n' Liz intro, ... ) // may break if done improperly: // International Superstar Soccer Deluxe (crash), Street Racer (logos), Burning Force (gfx), // Fatal Rewind (crash), Sesame Street Counting Cafe - if (num < 2) + else if (num < 2) { if (!SekShouldInterrupt) // hack { @@ -396,10 +401,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) if (irq) SekEndRun(24); // make it delayed } } - else #endif - if(num == 5) rendstatus|=1; - else if(num == 0xc) Pico.m.dirtyPal = 2; // renderers should update their palettes if sh/hi mode is changed pvid->type=0; // register writes clear command (else no Sega logo in Golden Axe II) } else { // High word of command: diff --git a/Pico/carthw/svp/svp.c b/Pico/carthw/svp/svp.c index 9853439..bc7cddb 100644 --- a/Pico/carthw/svp/svp.c +++ b/Pico/carthw/svp/svp.c @@ -1,6 +1,7 @@ #include "../../PicoInt.h" svp_t *svp = NULL; +int PicoSVPCycles = 800; // cycles/line static void PicoSVPReset(void) { @@ -11,12 +12,12 @@ static void PicoSVPReset(void) } -static void PicoSVPLine(void) +static void PicoSVPLine(int count) { // ??? // OSC_NTSC / 3.0 / 60.0 / 262.0 ~= 1139 // OSC_PAL / 3.0 / 50.0 / 312.0 ~= 1137 - ssp1601_run(800); + ssp1601_run(PicoSVPCycles * count); // test mode //if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff; diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index 66719a8..2d08fd4 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -376,11 +376,11 @@ void s68k_reg_write8(u32 a, u32 d) } -#ifndef _ASM_CD_MEMORY_C static u32 OtherRead16End(u32 a, int realsize) { u32 d=0; +#ifndef _ASM_CD_MEMORY_C if ((a&0xffffc0)==0xa12000) { d=m68k_reg_read16(a); goto end; @@ -403,16 +403,20 @@ static u32 OtherRead16End(u32 a, int realsize) d=Pico_mcd->m.bcram_reg; goto end; } +#endif elprintf(EL_UIO, "m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc); +#ifndef _ASM_CD_MEMORY_C end: +#endif return d; } static void OtherWrite8End(u32 a, u32 d, int realsize) { +#ifndef _ASM_CD_MEMORY_C if ((a&0xffffc0)==0xa12000) { m68k_reg_write8(a, d); return; } if ((a&0xfe0000)==0x600000) { @@ -427,15 +431,17 @@ static void OtherWrite8End(u32 a, u32 d, int realsize) Pico_mcd->m.bcram_reg=d; return; } +#endif elprintf(EL_UIO, "m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc); } +#ifndef _ASM_CD_MEMORY_C #define _CD_MEMORY_C #undef _ASM_MEMORY_C #include "../MemoryCmn.c" #include "cell_map.c" -#endif // !def _ASM_CD_MEMORY_C +#endif // ----------------------------------------------------------------- diff --git a/Pico/cd/Memory.s b/Pico/cd/Memory.s index f73f774..1b9fe96 100644 --- a/Pico/cd/Memory.s +++ b/Pico/cd/Memory.s @@ -128,7 +128,6 @@ m_s68k_decode_write_table: .extern PicoVideoRead .extern Read_CDC_Host .extern m68k_reg_write8 -.extern OtherWrite8 .extern OtherWrite16 .extern gfx_cd_read .extern s68k_reg_read16 diff --git a/platform/gp2x/Makefile b/platform/gp2x/Makefile index 8e8ff2e..5121d90 100644 --- a/platform/gp2x/Makefile +++ b/platform/gp2x/Makefile @@ -73,6 +73,8 @@ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pi ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o endif +# Pico - carthw +OBJS += ../../Pico/carthw/svp/svp.o ../../Pico/carthw/svp/Memory.o ../../Pico/carthw/svp/ssp16.o # asm stuff ifeq "$(asm_render)" "1" -- 2.39.2