* allow 128KB firmwares (DSi/3DS dumps)

* document firmware sizes better
This commit is contained in:
StapleButter 2017-08-05 19:13:55 +02:00
parent 4a899ebe3f
commit 0106406aff
2 changed files with 38 additions and 9 deletions

View File

@ -13,11 +13,16 @@ How to use:
melonDS requires BIOS/firmware copies from a DS. Files required: melonDS requires BIOS/firmware copies from a DS. Files required:
* bios7.bin, 16KB: ARM7 BIOS * bios7.bin, 16KB: ARM7 BIOS
* bios9.bin, 4KB: ARM9 BIOS * bios9.bin, 4KB: ARM9 BIOS
* firmware.bin, 256KB: firmware * firmware.bin, 128/256/512KB: firmware
Firmware boot requires a firmware dump from an original DS or DS Lite. Firmware boot requires a firmware dump from an original DS or DS Lite.
DS firmwares dumped from a DSi or 3DS aren't bootable and only contain configuration data, thus they are only suitable when booting games directly. DS firmwares dumped from a DSi or 3DS aren't bootable and only contain configuration data, thus they are only suitable when booting games directly.
Possible firmware sizes:
* 128KB: DSi/3DS DS-mode firmware (reduced size due to lacking bootcode)
* 256KB: regular DS firmware
* 512KB: iQue DS firmware
DS BIOS dumps from a 3DS can be used with no compatibility issues. DSi BIOS dumps should be usable too, provided they were dumped properly. DS BIOS dumps from a 3DS can be used with no compatibility issues. DSi BIOS dumps should be usable too, provided they were dumped properly.
As for the rest, the interface should be pretty straightforward. If you have a question, don't hesitate to ask, though! As for the rest, the interface should be pretty straightforward. If you have a question, don't hesitate to ask, though!

View File

@ -100,10 +100,23 @@ void Reset()
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
FirmwareLength = (u32)ftell(f); FirmwareLength = (u32)ftell(f);
if (FirmwareLength != 0x40000 && FirmwareLength != 0x80000) if (FirmwareLength != 0x20000 && FirmwareLength != 0x40000 && FirmwareLength != 0x80000)
{ {
printf("Bad firmware size %d, assuming 256K\n", FirmwareLength); printf("Bad firmware size %d, ", FirmwareLength);
FirmwareLength = 0x40000;
// pick the nearest power-of-two length
FirmwareLength |= (FirmwareLength >> 1);
FirmwareLength |= (FirmwareLength >> 2);
FirmwareLength |= (FirmwareLength >> 4);
FirmwareLength |= (FirmwareLength >> 8);
FirmwareLength |= (FirmwareLength >> 16);
FirmwareLength++;
// ensure it's a sane length
if (FirmwareLength > 0x80000) FirmwareLength = 0x80000;
else if (FirmwareLength < 0x20000) FirmwareLength = 0x20000;
printf("assuming %d\n", FirmwareLength);
} }
Firmware = new u8[FirmwareLength]; Firmware = new u8[FirmwareLength];
@ -352,7 +365,7 @@ u8 Read()
} }
void Write(u8 val, u32 hold) void Write(u8 val, u32 hold)
{ {printf("SPI powerman %02X %d\n", val, hold?1:0);
if (!hold) if (!hold)
{ {
Hold = 0; Hold = 0;
@ -369,15 +382,26 @@ void Write(u8 val, u32 hold)
if (DataPos == 1) if (DataPos == 1)
{ {
u32 regid = Index & 0x07;
if (Index & 0x80) if (Index & 0x80)
{ {
Data = Registers[Index & 0x07]; Data = Registers[regid];
} }
else else
{ {
Registers[Index & 0x07] = Registers[regid] = (Registers[regid] & ~RegMasks[regid]) | (val & RegMasks[regid]);
(Registers[Index & 0x07] & ~RegMasks[Index & 0x07]) |
(val & RegMasks[Index & 0x07]); switch (regid)
{
case 0:
if (val & 0x40) printf("DS shutdown\n");
printf("power %02X\n", val);
break;
case 4:
printf("brightness %02X\n", val);
break;
}
} }
} }
else else