Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
v2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
lifehackerhansol committed Mar 18, 2024
1 parent 9384e6a commit cbfedc1
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 16 deletions.
Binary file removed BootLoader/loader.bin
Binary file not shown.
61 changes: 47 additions & 14 deletions BootLoader/source/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,37 @@ Helpful information:
#define STORED_FILE_SECTOR (*(vu32*)0x027FFFF8)
const char* bootName = "_BOOT_MP.NDS";


//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Firmware stuff

#define FW_READ 0x03

void readFirmware(uint32 address, uint32 size, uint8 * buffer) {
uint32 index;

// Read command
while (REG_SPICNT & SPI_BUSY);
REG_SPICNT = SPI_ENABLE | SPI_CONTINUOUS | SPI_DEVICE_NVRAM;
REG_SPIDATA = FW_READ;
while (REG_SPICNT & SPI_BUSY);

// Set the address
REG_SPIDATA = (address>>16) & 0xFF;
while (REG_SPICNT & SPI_BUSY);
REG_SPIDATA = (address>>8) & 0xFF;
while (REG_SPICNT & SPI_BUSY);
REG_SPIDATA = (address) & 0xFF;
while (REG_SPICNT & SPI_BUSY);

for (index = 0; index < size; index++) {
REG_SPIDATA = 0;
while (REG_SPICNT & SPI_BUSY);
buffer[index] = REG_SPIDATA & 0xFF;
}
REG_SPICNT = 0;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CF card stuff
//#define _CF_USE_DMA
Expand Down Expand Up @@ -907,6 +938,8 @@ Modified by Chishm:
void __attribute__ ((long_call)) resetMemory_ARM7 (void)
{
int i;
u8 settings1, settings2;

REG_IME = 0;

for (i=0; i<16; i++) {
Expand Down Expand Up @@ -956,7 +989,7 @@ void __attribute__ ((long_call)) resetMemory_ARM7 (void)

// clear most of EWRAM - except after 0x023FF800, which has DS settings
"mov r8, #0x02000000 \n" // Start address part 1
"orr r8, r8, #0x4000 \n" // Start address part 2
"orr r8, r8, #0x8000 \n" // Start address part 2
"mov r9, #0x02300000 \n" // End address part 1
"orr r9, r9, #0xff000 \n" // End address part 2
"orr r9, r9, #0x00800 \n" // End address part 3
Expand All @@ -974,6 +1007,16 @@ void __attribute__ ((long_call)) resetMemory_ARM7 (void)
(*(vu32*)(0x04000000-4)) = 0; //IRQ_HANDLER ARM7 version
(*(vu32*)(0x04000000-8)) = ~0; //VBLANK_INTR_WAIT_FLAGS, ARM7 version
POWER_CR = 1; //turn off power to stuffs

// Reload DS Firmware settings
readFirmware((u32)0x03FE70, 0x1, &settings1);
readFirmware((u32)0x03FF70, 0x1, &settings2);

if (settings1 > settings2) {
readFirmware((u32)0x03FE00, 0x70, (u8*)0x027FFC80);
} else {
readFirmware((u32)0x03FF00, 0x70, (u8*)0x027FFC80);
}
}


Expand Down Expand Up @@ -1004,21 +1047,11 @@ void __attribute__ ((long_call)) loadBinary_ARM7 (u32 fileCluster)
} else {
fileRead(ARM7_DST, fileCluster, ARM7_SRC, ARM7_LEN);
}
if (((u32)ndsHeader[0x050>>2]) != 0)
if (((ndsHeader[0x070>>2]) != 0) && ((ndsHeader[0x04c>>2]) != 0))
{
__asm volatile ("swi 0x00");
}

/* Not needed for WMB demos
//mirrored header CRC
(*(vu16*)0x027FF808) = ndsHeader[0x15E>>2];
(*(vu16*)0x027FFC08) = ndsHeader[0x15E>>2];
//mirrored secure area CRC
(*(vu16*)0x027FF80A) = ndsHeader[0x06C>>2];
(*(vu16*)0x027FFC0A) = ndsHeader[0x06C>>2];
*/

// first copy the header to its proper location, excluding
// the ARM9 start address, so as not to start it
TEMP_ARM9_START_ADDRESS = ndsHeader[0x024>>2]; // Store for later
Expand Down Expand Up @@ -1183,11 +1216,11 @@ int main (void) {

// Load the NDS file
loadBinary_ARM7(fileCluster);

// Store start cluster and sector of loaded file, in case the loaded NDS wants it
STORED_FILE_CLUSTER = fileCluster;
STORED_FILE_SECTOR = FAT_ClustToSect(fileCluster);

// ARM7 moved out of SIWRAM to clear it, then start binaries
// copy ARM7 function to location just after ARM9 start function,
// and make the ARM7 jump to it
Expand Down
Binary file modified Flasher/data/loader.bin
Binary file not shown.
Binary file modified Flasher/ndsmp_gba/ndsmp_mb.gba
Binary file not shown.
2 changes: 1 addition & 1 deletion Flasher/ndsmp_nds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DEPENDS := $(OFILES:.o=.d)
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds : $(OUTPUT).arm9
@ndstool -c $@ -9 $< -b $(CURDIR)/../icon.bmp "NDS MP;GBAMP NDS Firmware Hack Version 2.0;By Chishm"
@ndstool -c $@ -9 $< -b $(CURDIR)/../icon.bmp "NDS MP;GBAMP NDS Firmware Hack Version 2.11;By Chishm"

$(OUTPUT).arm9 : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
Expand Down
2 changes: 1 addition & 1 deletion Flasher/source/flashapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void FlashApp()
{
xprintf("GBA Movie Player flasher v1.2\n");
xprintf(" by Rafael Vuijk (DarkFader) \n");
xprintf("NDSMP - GBAMP FW Hack v2.03 \n");
xprintf("NDSMP - GBAMP FW Hack v2.11 \n");
xprintf(" NDS support for GBAMP \n");
xprintf(" by Michael Chisholm (Chishm)\n");
xprintf("\n");
Expand Down

0 comments on commit cbfedc1

Please sign in to comment.