Commit 0106406a authored by StapleButter's avatar StapleButter
Browse files

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

* document firmware sizes better
parent 4a899ebe
......@@ -13,11 +13,16 @@ How to use:
melonDS requires BIOS/firmware copies from a DS. Files required:
* bios7.bin, 16KB: ARM7 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.
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.
As for the rest, the interface should be pretty straightforward. If you have a question, don't hesitate to ask, though!
......
......@@ -100,10 +100,23 @@ void Reset()
fseek(f, 0, SEEK_END);
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);
FirmwareLength = 0x40000;
printf("Bad firmware size %d, ", FirmwareLength);
// 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];
......@@ -352,7 +365,7 @@ u8 Read()
}
void Write(u8 val, u32 hold)
{
{printf("SPI powerman %02X %d\n", val, hold?1:0);
if (!hold)
{
Hold = 0;
......@@ -369,15 +382,26 @@ void Write(u8 val, u32 hold)
if (DataPos == 1)
{
u32 regid = Index & 0x07;
if (Index & 0x80)
{
Data = Registers[Index & 0x07];
Data = Registers[regid];
}
else
{
Registers[Index & 0x07] =
(Registers[Index & 0x07] & ~RegMasks[Index & 0x07]) |
(val & RegMasks[Index & 0x07]);
Registers[regid] = (Registers[regid] & ~RegMasks[regid]) | (val & RegMasks[regid]);
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment