* make direct boot less shitty.

* add main RAM mirror at 0x02800000 for ARM7.
This commit is contained in:
StapleButter 2017-02-01 21:35:00 +01:00
parent 64f9822db6
commit 282dcdece3
6 changed files with 34 additions and 31 deletions

37
NDS.cpp
View File

@ -134,19 +134,11 @@ void Init()
Reset();
}
// temp
void LoadROM()
void SetupDirectBoot()
{
FILE* f;
//f = fopen("rom/armwrestler.nds", "rb");
//f = fopen("rom/zorp.nds", "rb");
//f = fopen("rom/hello_world.nds", "rb");
f = fopen("rom/mkds.nds", "rb");
u32 bootparams[8];
fseek(f, 0x20, SEEK_SET);
fread(bootparams, 8, 4, f);
memcpy(bootparams, &NDSCart::CartROM[0x20], 8*4);
printf("ARM9: offset=%08X entry=%08X RAM=%08X size=%08X\n",
bootparams[0], bootparams[1], bootparams[2], bootparams[3]);
@ -155,32 +147,24 @@ void LoadROM()
MapSharedWRAM(3);
fseek(f, bootparams[0], SEEK_SET);
for (u32 i = 0; i < bootparams[3]; i+=4)
{
u32 tmp;
fread(&tmp, 4, 1, f);
u32 tmp = *(u32*)&NDSCart::CartROM[bootparams[0]+i];
ARM9Write32(bootparams[2]+i, tmp);
}
fseek(f, bootparams[4], SEEK_SET);
for (u32 i = 0; i < bootparams[7]; i+=4)
{
u32 tmp;
fread(&tmp, 4, 1, f);
u32 tmp = *(u32*)&NDSCart::CartROM[bootparams[4]+i];
ARM7Write32(bootparams[6]+i, tmp);
}
fseek(f, 0, SEEK_SET);
for (u32 i = 0; i < 0x170; i+=4)
{
u32 tmp;
fread(&tmp, 4, 1, f);
u32 tmp = *(u32*)&NDSCart::CartROM[i];
ARM9Write32(0x027FFE00+i, tmp);
}
fclose(f);
ARM9Write32(0x027FF800, 0x00001FC2);
ARM9Write32(0x027FF804, 0x00001FC2);
ARM9Write32(0x027FFC00, 0x00001FC2);
@ -287,8 +271,7 @@ void Reset()
// test
//LoadROM();
//LoadFirmware();
NDSCart::LoadROM("rom/nsmb.nds");
LoadROM();
NDSCart::LoadROM("rom/mkds.nds");
Running = true; // hax
}
@ -1004,6 +987,7 @@ u8 ARM7Read8(u32 addr)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
return *(u8*)&MainRAM[addr & 0x3FFFFF];
case 0x03000000:
@ -1042,6 +1026,7 @@ u16 ARM7Read16(u32 addr)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
return *(u16*)&MainRAM[addr & 0x3FFFFF];
case 0x03000000:
@ -1088,6 +1073,7 @@ u32 ARM7Read32(u32 addr)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
return *(u32*)&MainRAM[addr & 0x3FFFFF];
case 0x03000000:
@ -1120,6 +1106,7 @@ void ARM7Write8(u32 addr, u8 val)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
*(u8*)&MainRAM[addr & 0x3FFFFF] = val;
return;
@ -1155,6 +1142,7 @@ void ARM7Write16(u32 addr, u16 val)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
*(u16*)&MainRAM[addr & 0x3FFFFF] = val;
return;
@ -1194,6 +1182,7 @@ void ARM7Write32(u32 addr, u32 val)
switch (addr & 0xFF800000)
{
case 0x02000000:
case 0x02800000:
*(u32*)&MainRAM[addr & 0x3FFFFF] = val;
return;

2
NDS.h
View File

@ -115,6 +115,8 @@ extern u8 ARM7BIOS[0x4000];
void Init();
void Reset();
void SetupDirectBoot();
void RunFrame();
void PressKey(u32 key);

View File

@ -347,6 +347,8 @@ void LoadROM(char* path)
fclose(f);
//CartROM = f;
NDS::SetupDirectBoot();
CartInserted = true;
// generate a ROM ID

View File

@ -33,6 +33,9 @@ extern u32 ROMDataOut;
extern u8 EncSeed0[5];
extern u8 EncSeed1[5];
extern u8* CartROM;
extern u32 CartROMSize;
void Init();
void Reset();

View File

@ -48,6 +48,13 @@ LRESULT CALLBACK derpo(HWND window, UINT msg, WPARAM wparam, LPARAM lparam)
fwrite(&blarg, 4, 1, f);
}
fclose(f);
f = fopen("mainram.bin", "wb");
for (u32 i = 0x2000000; i < 0x2400000; i+=4)
{
u32 blarg = NDS::ARM9Read32(i);
fwrite(&blarg, 4, 1, f);
}
fclose(f);
}
PostQuitMessage(0);
return 0;

View File

@ -1,16 +1,16 @@
# depslib dependency file v1.0
1485901373 source:c:\documents\sources\melonds\main.cpp
1485974193 source:c:\documents\sources\melonds\main.cpp
<stdio.h>
<windows.h>
"NDS.h"
"GPU.h"
1485901230 c:\documents\sources\melonds\nds.h
1485981187 c:\documents\sources\melonds\nds.h
"types.h"
1481161027 c:\documents\sources\melonds\types.h
1485973806 source:c:\documents\sources\melonds\nds.cpp
1485981206 source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
@ -24,7 +24,7 @@
"RTC.h"
"Wifi.h"
1485973712 source:c:\documents\sources\melonds\arm.cpp
1485979545 source:c:\documents\sources\melonds\arm.cpp
<stdio.h>
"NDS.h"
"ARM.h"
@ -65,7 +65,7 @@
1485795628 c:\documents\sources\melonds\arminterpreter_loadstore.h
1485830927 source:c:\documents\sources\melonds\arminterpreter_loadstore.cpp
1485977845 source:c:\documents\sources\melonds\arminterpreter_loadstore.cpp
<stdio.h>
"ARM.h"
@ -134,10 +134,10 @@
<string.h>
"RTC.h"
1485878561 c:\documents\sources\melonds\ndscart.h
1485980863 c:\documents\sources\melonds\ndscart.h
"types.h"
1485880110 source:c:\documents\sources\melonds\ndscart.cpp
1485981191 source:c:\documents\sources\melonds\ndscart.cpp
<stdio.h>
<string.h>
"NDS.h"