From: notaz Date: Wed, 21 Nov 2007 22:04:59 +0000 (+0000) Subject: bugfixes in sram memhandlers X-Git-Tag: v1.85~617 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dc09829192f73f5d0502c8b312a39863bca60d3;p=picodrive.git bugfixes in sram memhandlers git-svn-id: file:///home/notaz/opt/svn/PicoDrive@301 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/Memory.c b/Pico/Memory.c index a3372d60..ecc34c25 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -141,16 +141,33 @@ static u32 SRAMRead(u32 a) { unsigned int sreg = Pico.m.sram_reg; - if(!(sreg & 0x10) && (sreg & 1) && a > 0x200001) { // not yet detected SRAM + if (!(sreg & 0x10) && (sreg & 1) && a > 0x200001) { // not yet detected SRAM elprintf(EL_SRAMIO, "normal sram detected."); Pico.m.sram_reg|=0x10; // should be normal SRAM } - if(sreg & 4) // EEPROM read + if (sreg & 4) // EEPROM read return SRAMReadEEPROM(); else // if(sreg & 1) // (sreg&5) is one of prerequisites return *(u8 *)(SRam.data-SRam.start+a); } +#ifndef _ASM_MEMORY_C +static +#endif +u32 SRAMRead16(u32 a) +{ + u32 d; + if (Pico.m.sram_reg & 4) { + d = SRAMReadEEPROM(); + d |= d << 8; + } else { + u8 *pm=(u8 *)(SRam.data-SRam.start+a); + d =*pm++ << 8; + d|=*pm++; + } + return d; +} + static void SRAMWrite(u32 a, u32 d) { unsigned int sreg = Pico.m.sram_reg; @@ -363,8 +380,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a) #ifndef EMU_CORE_DEBUG // sram if (a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { - d = SRAMRead(a); - d |= d<<8; + d = SRAMRead16(a); elprintf(EL_SRAMIO, "sram r16 [%06x] %04x @ %06x", a, d, SekPc); goto end; } @@ -400,8 +416,7 @@ PICO_INTERNAL_ASM u32 PicoRead32(u32 a) // sram if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { - d = (SRAMRead(a)<<16)|SRAMRead(a+2); - d |= d<<8; + d = (SRAMRead16(a)<<16)|SRAMRead16(a+2); elprintf(EL_SRAMIO, "sram r32 [%06x] %08x @ %06x", a, d, SekPc); goto end; } diff --git a/Pico/Memory.s b/Pico/Memory.s index 7e163849..7f3c2cb4 100644 --- a/Pico/Memory.s +++ b/Pico/Memory.s @@ -502,8 +502,7 @@ m_read16_rom4: @ 0x200000 - 0x27ffff, SRAM area (NBA Live 95) tst r1, #5 beq m_read16_nosram stmfd sp!,{lr} - bl SRAMRead - orr r0, r0, r0, lsl #8 + bl SRAMRead16 ldmfd sp!,{pc} m_read16_nosram: ldr r1, [r3, #4] @ romsize @@ -593,8 +592,7 @@ m_read16_above_rom: tst r1, #5 beq m_read16_ar_nosram stmfd sp!,{lr} - bl SRAMRead - orr r0, r0, r0, lsl #8 + bl SRAMRead16 ldmfd sp!,{pc} m_read16_ar_nosram: mov r1, #16 @@ -647,14 +645,13 @@ m_read32_rom4: @ 0x200000 - 0x27ffff, SRAM area (does any game do long reads?) tst r1, #5 beq m_read32_nosram stmfd sp!,{r0,lr} - bl SRAMRead + bl SRAMRead16 ldmfd sp!,{r1,lr} stmfd sp!,{r0,lr} add r0, r1, #2 - bl SRAMRead + bl SRAMRead16 ldmfd sp!,{r1,lr} orr r0, r0, r1, lsl #16 - orr r0, r0, r0, lsl #8 bx lr m_read32_nosram: ldr r1, [r3, #4] @ romsize diff --git a/Pico/MemoryCmn.c b/Pico/MemoryCmn.c index 145a7e68..b49eaf2b 100644 --- a/Pico/MemoryCmn.c +++ b/Pico/MemoryCmn.c @@ -217,7 +217,7 @@ void OtherWrite16(u32 a,u32 d) #ifndef _CD_MEMORY_C if (a >= SRam.start && a <= SRam.end) { elprintf(EL_SRAMIO, "sram w16 [%06x] %04x @ %06x", a, d, SekPc); - if ((a&0x16)==0x10) { // detected, not EEPROM, write not disabled + if ((Pico.m.sram_reg&0x16)==0x10) { // detected, not EEPROM, write not disabled u8 *pm=(u8 *)(SRam.data-SRam.start+a); *pm++=d>>8; *pm++=d; diff --git a/Pico/Memory_amips.s b/Pico/Memory_amips.s index b5ec0995..0c18f4b7 100644 --- a/Pico/Memory_amips.s +++ b/Pico/Memory_amips.s @@ -260,29 +260,27 @@ m_read_neg1: j SRAMRead nop .elseif \size == 16 + sw $ra, -4($sp) + jal SRAMRead16 addiu $sp, -4 - jal SRAMRead - sw $ra, 0($sp) lw $ra, 0($sp) - addiu $sp, 4 jr $ra - ins $v0, $v0, 8, 8 + addiu $sp, 4 .else addiu $sp, -8 - sw $a0, 4($sp) - jal SRAMRead sw $ra, 0($sp) + sw $a0, 4($sp) + jal SRAMRead16 + nop lw $a0, 4($sp) sw $v0, 4($sp) - jal SRAMRead + jal SRAMRead16 addiu $a0, 2 lw $v1, 4($sp) lw $ra, 0($sp) addiu $sp, 8 - ins $v0, $v1, 16, 16 - sll $t0, $v0, 8 jr $ra - or $v0, $t0 + ins $v0, $v1, 16, 16 .endif # m_read_nosram: 1: diff --git a/platform/psp/emu.c b/platform/psp/emu.c index c63c00b5..4006d9ff 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -21,7 +21,7 @@ #include "../common/lprintf.h" #include "../../Pico/PicoInt.h" -#define OSD_FPS_X 424 +#define OSD_FPS_X 432 // additional pspaudio imports, credits to crazyc int sceAudio_38553111(unsigned short samples, unsigned short freq, char unknown); // play with conversion?