Add rom2: support (Fix Chinese Bios) (#3439)

* Add rom2 support

* Add rom2 support on IOP

* Valid memory range for rom2

* Add rom2 support to IopMem.cpp
This commit is contained in:
kozarovv 2020-08-08 21:59:46 +02:00 committed by GitHub
parent 60e075d6c9
commit 6794bbbd6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View File

@ -96,6 +96,11 @@ void iopMemoryReserve::Reset()
psxMemWLUT[i + 0x2000 + 0x1e00] = (uptr)&eeMem->ROM1[i << 16];
}
for (int i = 0; i < 0x0008; i++)
{
psxMemWLUT[i + 0x2000 + 0x1e40] = (uptr)&eeMem->ROM2[i << 16];
}
// sif!! (which is read only? (air))
psxMemWLUT[0x2000 + 0x1d00] = (uptr)iopMem->Sif;
//psxMemWLUT[0x1bd00] = (uptr)iopMem->Sif;

View File

@ -81,14 +81,14 @@ static __fi void ZeroQWC( u128& dest )
#define psR1u32(mem) (*(u32*)&eeMem->ROM1[(mem) & 0x3ffff])
#define psR1u64(mem) (*(u64*)&eeMem->ROM1[(mem) & 0x3ffff])
#define psR2s8(mem) (*(s8 *)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2s16(mem) (*(s16*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2s32(mem) (*(s32*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2s64(mem) (*(s64*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2u8(mem) (*(u8 *)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2u16(mem) (*(u16*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2u32(mem) (*(u32*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2u64(mem) (*(u64*)&eeMem->ROM2[(mem) & 0x3ffff])
#define psR2s8(mem) (*(s8 *)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2s16(mem) (*(s16*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2s32(mem) (*(s32*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2s64(mem) (*(s64*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2u8(mem) (*(u8 *)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2u16(mem) (*(u16*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2u32(mem) (*(u32*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psR2u64(mem) (*(u64*)&eeMem->ROM2[(mem) & 0x7ffff])
#define psERs8(mem) (*(s8 *)&eeMem->EROM[(mem) & 0x3ffff])
#define psERs16(mem) (*(s16*)&eeMem->EROM[(mem) & 0x3ffff])

View File

@ -55,6 +55,7 @@ static RecompiledCodeReserve* recMem = NULL;
static BASEBLOCK *recRAM = NULL; // and the ptr to the blocks here
static BASEBLOCK *recROM = NULL; // and here
static BASEBLOCK *recROM1 = NULL; // also here
static BASEBLOCK *recROM2 = NULL; // also here
static BaseBlocks recBlocks;
static u8 *recPtr = NULL;
u32 psxpc; // recompiler psxpc
@ -622,7 +623,7 @@ static uptr m_ConfiguredCacheReserve = 32;
static u8* m_recBlockAlloc = NULL;
static const uint m_recBlockAllocSize =
(((Ps2MemSize::IopRam + Ps2MemSize::Rom + Ps2MemSize::Rom1) / 4) * sizeof(BASEBLOCK));
(((Ps2MemSize::IopRam + Ps2MemSize::Rom + Ps2MemSize::Rom1 + Ps2MemSize::Rom2) / 4) * sizeof(BASEBLOCK));
static void recReserveCache()
{
@ -664,6 +665,8 @@ static void recAlloc()
recRAM = (BASEBLOCK*)curpos; curpos += (Ps2MemSize::IopRam / 4) * sizeof(BASEBLOCK);
recROM = (BASEBLOCK*)curpos; curpos += (Ps2MemSize::Rom / 4) * sizeof(BASEBLOCK);
recROM1 = (BASEBLOCK*)curpos; curpos += (Ps2MemSize::Rom1 / 4) * sizeof(BASEBLOCK);
recROM2 = (BASEBLOCK*)curpos; curpos += (Ps2MemSize::Rom2 / 4) * sizeof(BASEBLOCK);
if( s_pInstCache == NULL )
{
@ -687,7 +690,7 @@ void recResetIOP()
recMem->Reset();
iopClearRecLUT((BASEBLOCK*)m_recBlockAlloc,
(((Ps2MemSize::IopRam + Ps2MemSize::Rom + Ps2MemSize::Rom1) / 4)));
(((Ps2MemSize::IopRam + Ps2MemSize::Rom + Ps2MemSize::Rom1 + Ps2MemSize::Rom2) / 4)));
for (int i = 0; i < 0x10000; i++)
recLUT_SetPage(psxRecLUT, 0, 0, 0, i, 0);
@ -721,6 +724,13 @@ void recResetIOP()
recLUT_SetPage(psxRecLUT, psxhwLUT, recROM1, 0xa000, i, i - 0x1fc0);
}
for (int i = 0x1e40; i < 0x1e48; i++)
{
recLUT_SetPage(psxRecLUT, psxhwLUT, recROM2, 0x0000, i, i - 0x1fc0);
recLUT_SetPage(psxRecLUT, psxhwLUT, recROM2, 0x8000, i, i - 0x1fc0);
recLUT_SetPage(psxRecLUT, psxhwLUT, recROM2, 0xa000, i, i - 0x1fc0);
}
if( s_pInstCache )
memset( s_pInstCache, 0, sizeof(EEINST)*s_nInstCacheSize );

View File

@ -75,7 +75,7 @@ static const int RECCONSTBUF_SIZE = 16384 * 2; // 64 bit consts in 32 bit units
static RecompiledCodeReserve* recMem = NULL;
static u8* recRAMCopy = NULL;
static u8* recLutReserve_RAM = NULL;
static const size_t recLutSize = Ps2MemSize::MainRam + Ps2MemSize::Rom + Ps2MemSize::Rom1;
static const size_t recLutSize = Ps2MemSize::MainRam + Ps2MemSize::Rom + Ps2MemSize::Rom1 + Ps2MemSize::Rom2;
static uptr m_ConfiguredCacheReserve = 64;
@ -83,6 +83,7 @@ static u32* recConstBuf = NULL; // 64-bit pseudo-immediates
static BASEBLOCK *recRAM = NULL; // and the ptr to the blocks here
static BASEBLOCK *recROM = NULL; // and here
static BASEBLOCK *recROM1 = NULL; // also here
static BASEBLOCK *recROM2 = NULL; // also here
static BaseBlocks recBlocks;
static u8* recPtr = NULL;
@ -515,6 +516,7 @@ static void recAlloc()
recRAM = basepos; basepos += (Ps2MemSize::MainRam / 4);
recROM = basepos; basepos += (Ps2MemSize::Rom / 4);
recROM1 = basepos; basepos += (Ps2MemSize::Rom1 / 4);
recROM2 = basepos; basepos += (Ps2MemSize::Rom2 / 4);
for (int i = 0; i < 0x10000; i++)
recLUT_SetPage(recLUT, 0, 0, 0, i, 0);
@ -545,6 +547,13 @@ static void recAlloc()
recLUT_SetPage(recLUT, hwLUT, recROM1, 0xa000, i, i - 0x1e00);
}
for (int i = 0x1e40; i < 0x1e48; i++)
{
recLUT_SetPage(recLUT, hwLUT, recROM2, 0x0000, i, i - 0x1e40);
recLUT_SetPage(recLUT, hwLUT, recROM2, 0x8000, i, i - 0x1e40);
recLUT_SetPage(recLUT, hwLUT, recROM2, 0xa000, i, i - 0x1e40);
}
if( recConstBuf == NULL )
recConstBuf = (u32*) _aligned_malloc( RECCONSTBUF_SIZE * sizeof(*recConstBuf), 16 );
@ -620,7 +629,7 @@ static void recShutdown()
recBlocks.Reset();
recRAM = recROM = recROM1 = NULL;
recRAM = recROM = recROM1 = recROM2 = NULL;
safe_aligned_free( recConstBuf );
safe_free( s_pInstCache );