diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d160a15..6f4f562 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,13 +4,13 @@ repos: hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 + - repo: https://github.com/pycqa/flake8 rev: 3.9.2 hooks: - id: flake8 - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: ["--profile", "black"] diff --git a/Core/Src/main.c b/Core/Src/main.c index bd4368c..9b62c13 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -11,6 +11,7 @@ #define MSP_ADDRESS 0x08000000 +#define BANK_1_STACK_2_ADDRESS 0x08020000 #define BANK_2_ADDRESS 0x08100000 #define BOOTLOADER_MAGIC 0x544F4F42 // "BOOT" #define BOOTLOADER_MAGIC_ADDRESS ((uint32_t *)0x2001FFF8) @@ -46,11 +47,6 @@ void bootloader(){ while(1); } -static inline void start_bank_2() { - set_bootloader(BANK_2_ADDRESS); - NVIC_SystemReset(); -} - #if ENABLE_SMB1_GRAPHIC_MODS #define SMB1_GRAPHIC_MODS_MAX 8 @@ -97,12 +93,17 @@ gamepad_t read_buttons() { gamepad = stock_read_buttons(); + if((gamepad & GAMEPAD_RIGHT) && (gamepad & GAMEPAD_GAME)){ + set_bootloader(BANK_1_STACK_2_ADDRESS); + NVIC_SystemReset(); + } #if CLOCK_ONLY if(gamepad & GAMEPAD_GAME){ #else if((gamepad & GAMEPAD_LEFT) && (gamepad & GAMEPAD_GAME)){ #endif - start_bank_2(); + set_bootloader(BANK_2_ADDRESS); + NVIC_SystemReset(); } #if ENABLE_SMB1_GRAPHIC_MODS diff --git a/docs/zelda.md b/docs/zelda.md index 0e6fa0c..6cbcbd4 100644 --- a/docs/zelda.md +++ b/docs/zelda.md @@ -19,16 +19,53 @@ Run the following in this repo: ```bash make clean -make PATCH_PARAMS="--device=zelda --extended --no-la --no-sleep-images --extended" flash +make PATCH_PARAMS="--device=zelda --no-la --no-sleep-images" flash ``` +### Retro-Go Command -### Retro-Go Command +```bash +make clean +make -j8 INTFLASH_BANK=2 EXTFLASH_SIZE=1794336 EXTFLASH_OFFSET=860160 ADAPTER=stlink GNW_TARGET=zelda flash +``` + + +# Bank Stacking +If you want to run additional homebrew, such as [Zelda3 (LttP)](https://github.com/marian-m12l/game-and-watch-zelda3), in Bank 2, it's possible to have *both* retro-go and the stock firmware in Bank 1. + +### Patch Command + +Run the following in this repo: + +```bash +make clean +make PATCH_PARAMS="--device=zelda --no-la --no-sleep-images" flash +``` -Run the following in the retro-go repo: +This will setup storage in the following way: +1. INTFLASH BANK 1 - First 128KB - Stock Firmware +2. INTFLASH Bank 1 - Second 128KB - Free (put Retro-Go intflash here) +3. INTFLASH BANK 2 - Full 256KB - Free (put Zelda3 intflash here) +4. EXTFLASH OFFSET 3301376; 794624 Free (put retro-go extflash here) +5. EXTFLASH OFFSET 860160; 1794336 Free (put Zelda3 extflash here) + +### Retro-go Command +Run the following in the [sylverb/game-and-watch-retro-go](https://github.com/sylverb/game-and-watch-retro-go) repo: ```bash make clean -make -j8 INTFLASH_BANK=2 EXTFLASH_SIZE=1802240 EXTFLASH_OFFSET=851968 GNW_TARGET=zelda EXTENDED=1 flash +make -j8 INTFLASH_ADDRESS=0x08020000 EXTFLASH_SIZE=794624 EXTFLASH_OFFSET=3301376 GNW_TARGET=zelda BIG_BANK=0 flash +``` + +### Zelda3 Command +In the Zelda3 repo, after copying `zelda3.sfc` to `zelda3/tables/zelda3.sfc`, run the following commands: + +```bash +cd zelda3 +make tables/zelda3_assets.dat +cd .. +python3 ./scripts/bundle_all_assets.py +python3 ./scripts/update_all_assets.py +make -j8 INTFLASH_BANK=2 EXTFLASH_SIZE=1703936 EXTFLASH_OFFSET=868352 ADAPTER=stlink GNW_TARGET=zelda flash ``` diff --git a/patches/zelda.py b/patches/zelda.py index 54f01c5..e89161e 100644 --- a/patches/zelda.py +++ b/patches/zelda.py @@ -37,13 +37,13 @@ 0xD0000 0xD2000 LoZ2 Timer stuff? -0xD2000 0x1F4C00 LA ROMs +0xD2000 0x1F4C00 LA ROMs (1,190,912 bytes) -0x1f4c00 0x288120 The 11 Backdrop Images +0x1f4c00 0x288120 The 11 Backdrop Images (603,424 bytes) 0x288120 0x325490 ??? -0x325490 0x3e8000 Empty +0x325490 0x3e8000 Empty (797,552 bytes) 0x3e8000 0x3F0000 Launched LA, didn't save. Generic GB stuff? 0x3F0000 0x400000 Empty