emulate expanded memory a little more accurately, but for no reason other than that i got an expand memory pak and was playing with it

This commit is contained in:
zeromus 2010-08-13 02:02:21 +00:00
parent 8c0cc33773
commit e28f34a6d9
1 changed files with 30 additions and 21 deletions

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2009 CrazyMax /* Copyright (C) 2009-2010 DeSmuME team
Copyright (C) 2009 DeSmuME team
This file is part of DeSmuME This file is part of DeSmuME
@ -54,7 +53,6 @@ static void ExpMemory_close(void)
static void ExpMemory_config(void) {} static void ExpMemory_config(void) {}
static void ExpMemory_write08(u32 adr, u8 val) static void ExpMemory_write08(u32 adr, u8 val)
{ {
if (adr >= 0x09000000) if (adr >= 0x09000000)
{ {
u32 offs = (adr - 0x09000000); u32 offs = (adr - 0x09000000);
@ -65,7 +63,6 @@ static void ExpMemory_write08(u32 adr, u8 val)
} }
static void ExpMemory_write16(u32 adr, u16 val) static void ExpMemory_write16(u32 adr, u16 val)
{ {
if (adr >= 0x09000000) if (adr >= 0x09000000)
{ {
u32 offs = (adr - 0x09000000); u32 offs = (adr - 0x09000000);
@ -85,50 +82,62 @@ static void ExpMemory_write32(u32 adr, u32 val)
} }
EXPINFO("ExpMemory: write 32 at 0x%08X = 0x%08X\n", adr, val); EXPINFO("ExpMemory: write 32 at 0x%08X = 0x%08X\n", adr, val);
} }
static u8 header_0x00B0[] =
{ 0xFF, 0xFF, 0x96, 0x00, //this 0x96 is strange. it can't be read from the pak when it boots, it must appear later
0x00, 0x24, 0x24, 0x24,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x7F
};
static u8 ExpMemory_read08(u32 adr) static u8 ExpMemory_read08(u32 adr)
{ {
if (adr == 0x080000B2) return(0x96); EXPINFO("ExpMemory: read 08 at 0x%08X\n", adr);
if(adr>=0x080000B0 && adr<0x080000C0)
return T1ReadByte(header_0x00B0,adr-0x080000B0);
if (adr >= 0x09000000) if (adr >= 0x09000000)
{ {
u32 offs = (adr - 0x09000000); u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return (0xFF); if (offs >= expMemSize) return (0xFF);
return (T1ReadByte(expMemory, offs)); return T1ReadByte(expMemory, offs);
} }
EXPINFO("ExpMemory: read 08 at 0x%08X\n", adr); return 0xFF;
return (0);
} }
static u16 ExpMemory_read16(u32 adr) static u16 ExpMemory_read16(u32 adr)
{ {
if (adr == 0x080000B6) return(0x2424); if(adr>=0x080000B0 && adr<0x080000C0)
if (adr == 0x080000BC) return(0x7FFF); return T1ReadWord(header_0x00B0,adr-0x080000B0);
if (adr == 0x080000BE) return(0x0096);
if (adr == 0x0801FFFC) return(0x7FFF); if (adr == 0x0801FFFC) return 0x7FFF;
if (adr == 0x08240002) return 0; //this can't be 0xFFFF. dunno why, we just guessed 0
if (adr >= 0x09000000) if (adr >= 0x09000000)
{ {
u32 offs = (adr - 0x09000000); u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return (0xFFFF); if (offs >= expMemSize) return (0xFFFF);
return (T1ReadWord(expMemory, offs)); return T1ReadWord(expMemory, offs);
} }
EXPINFO("ExpMemory: read 16 at 0x%08X\n", adr); EXPINFO("ExpMemory: read 16 at 0x%08X\n", adr);
return (0); return 0xFFFF;
} }
static u32 ExpMemory_read32(u32 adr) static u32 ExpMemory_read32(u32 adr)
{ {
if (adr == 0x080000AC) return(0x027FFC30); if(adr>=0x080000B0 && adr<0x080000C0)
return T1ReadLong(header_0x00B0,adr-0x080000B0);
if (adr >= 0x09000000) if (adr >= 0x09000000)
{ {
u32 offs = (adr - 0x09000000); u32 offs = (adr - 0x09000000);
if (offs >= expMemSize) return (0xFFFFFFFF); if (offs >= expMemSize) return 0xFFFFFFFF;
return (T1ReadLong(expMemory, offs)); return T1ReadLong(expMemory, offs);
} }
EXPINFO("ExpMemory: read 32 at 0x%08X\n", adr); EXPINFO("ExpMemory: read 32 at 0x%08X\n", adr);
return (0); return 0xFFFFFFFF;
} }
static void ExpMemory_info(char *info) { strcpy(info, "Memory Expansion Pak"); } static void ExpMemory_info(char *info) { strcpy(info, "Memory Expansion Pak"); }