Skip to content

Commit

Permalink
gbapatcher: Remove unused data
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 2, 2024
1 parent e8ea50f commit f0a807f
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 1,508 deletions.
42 changes: 0 additions & 42 deletions gbapatcher/arm9/source/nds_loader_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,8 @@
#include "common/tonccpy.h"
#include "load_bin.h"

#ifndef _NO_BOOTSTUB_
#include "bootstub_bin.h"
#endif

#include "nds_loader_arm9.h"
#define LCDC_BANK_C (u16*)0x06840000
#define STORED_FILE_CLUSTER (*(((u32*)LCDC_BANK_C) + 1))
#define INIT_DISC (*(((u32*)LCDC_BANK_C) + 2))
#define WANT_TO_PATCH_DLDI (*(((u32*)LCDC_BANK_C) + 3))


/*
b startUp
storedFileCluster:
.word 0x0FFFFFFF @ default BOOT.NDS
initDisc:
.word 0x00000001 @ init the disc by default
wantToPatchDLDI:
.word 0x00000001 @ by default patch the DLDI section of the loaded NDS
@ Used for passing arguments to the loaded app
argStart:
.word _end - _start
argSize:
.word 0x00000000
dldiOffset:
.word _dldi_start - _start
dsiSD:
.word 0
dsiMode:
.word 0
*/

#define STORED_FILE_CLUSTER_OFFSET 4
#define INIT_DISC_OFFSET 8
#define WANT_TO_PATCH_DLDI_OFFSET 12
#define ARG_START_OFFSET 16
#define ARG_SIZE_OFFSET 20
#define HAVE_DSISD_OFFSET 28
#define DSIMODE_OFFSET 32
#define CLEAR_MASTER_BRIGHT_OFFSET 36
#define DSMODE_SWITCH_OFFSET 40
#define LOADFROMRAM_OFFSET 44


int runNds (const void* loader, u32 loaderSize)
{
Expand Down
4 changes: 0 additions & 4 deletions gbapatcher/arm9/source/nds_loader_arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ extern "C" {

#define LOAD_DEFAULT_NDS 0

int runNds (const void* loader, u32 loaderSize);

int runNdsFile (void);

bool installBootStub(bool havedsiSD);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion gbapatcher/bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CFLAGS := -g -Wall -O2 \
-flto \
$(ARCH)

CFLAGS += $(INCLUDE) $(EXTRA_CFLAGS) -DARM7 -DNO_SDMMC
CFLAGS += $(INCLUDE) $(EXTRA_CFLAGS) -DARM7

ASFLAGS := -g $(ARCH) -flto $(EXTRA_CFLAGS) $(INCLUDE)
LDFLAGS = -nostartfiles -T $(TOPDIR)/load.ld -g $(ARCH) -Wl,-Map,$(TARGET).map
Expand Down
13 changes: 0 additions & 13 deletions gbapatcher/bootloader/source/bios.s

This file was deleted.

76 changes: 1 addition & 75 deletions gbapatcher/bootloader/source/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Helpful information:
#include <nds/arm7/audio.h>
#include <nds/arm7/codec.h>
#include "common/tonccpy.h"
#include "i2c.h"
#include "fat.h"
#include "dldi_patcher.h"
#include "card.h"
#include "boot.h"

void arm7clearRAM();
Expand All @@ -64,51 +60,6 @@ void arm7clearRAM();
#define TEMP_ARM9_START_ADDRESS (*(vu32*)0x02FFFFF4)


const char* bootName = "BOOT.NDS";

extern unsigned long _start;
extern unsigned long storedFileCluster;
extern unsigned long initDisc;
extern unsigned long wantToPatchDLDI;
extern unsigned long argStart;
extern unsigned long argSize;
extern unsigned long dsiSD;
extern unsigned long dsiMode;
extern unsigned long clearMasterBright;
extern unsigned long dsMode;
extern unsigned long loadFromRam;

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

#define FW_READ 0x03

void boot_readFirmware (uint32 address, uint8 * buffer, uint32 size) {
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;
}


static inline void copyLoop (u32* dest, const u32* src, u32 size) {
size = (size +3) & ~3;
do {
Expand All @@ -130,8 +81,6 @@ Modified by Chishm:
void resetMemory_ARM7 (void)
{
int i;
u8 settings1, settings2;
u32 settingsOffset = 0;

REG_IME = 0;

Expand Down Expand Up @@ -160,33 +109,14 @@ void resetMemory_ARM7 (void)

arm7clearRAM();
// clear most of EWRAM - except after RAM end - 0xc000, which has the bootstub
toncset((void*)0x02004000, 0, dsiMode&&!dsMode ? 0xFF0000 : 0x3F0000);
toncset((void*)0x02004000, 0, 0x3F0000);
*(u32*)(0x2FFFD9C) = 0; // Clear exception handler

REG_IE = 0;
REG_IF = ~0;
(*(vu32*)(0x04000000-4)) = 0; //IRQ_HANDLER ARM7 version
(*(vu32*)(0x04000000-8)) = ~0; //VBLANK_INTR_WAIT_FLAGS, ARM7 version
REG_POWERCNT = 1; //turn off power to stuff

// Get settings location
boot_readFirmware((u32)0x00020, (u8*)&settingsOffset, 0x2);
settingsOffset *= 8;

// Reload DS Firmware settings
boot_readFirmware(settingsOffset + 0x070, &settings1, 0x1);
boot_readFirmware(settingsOffset + 0x170, &settings2, 0x1);

if ((settings1 & 0x7F) == ((settings2+1) & 0x7F)) {
boot_readFirmware(settingsOffset + 0x000, (u8*)0x02FFFC80, 0x70);
} else {
boot_readFirmware(settingsOffset + 0x100, (u8*)0x02FFFC80, 0x70);
}

((vu32*)0x040044f0)[2] = 0x202DDD1D;
((vu32*)0x040044f0)[3] = 0xE1A00005;
while ((*(vu32*)0x04004400) & 0x2000000);

}


Expand Down Expand Up @@ -239,10 +169,6 @@ void mpu_reset();
void mpu_reset_end();

int main (void) {
#ifdef NO_DLDI
dsiSD = true;
dsiMode = true;
#endif
// ARM9 clears its memory part 2
// copy ARM9 function to RAM, and make the ARM9 jump to it
copyLoop((void*)TEMP_MEM, (void*)resetMemory2_ARM9, resetMemory2_ARM9_size);
Expand Down
45 changes: 0 additions & 45 deletions gbapatcher/bootloader/source/card.h

This file was deleted.

82 changes: 0 additions & 82 deletions gbapatcher/bootloader/source/disc_io.h

This file was deleted.

Loading

0 comments on commit f0a807f

Please sign in to comment.