Skip to content

Commit

Permalink
Merge pull request #50 from BrianPugh/0x080200000-entrypoint
Browse files Browse the repository at this point in the history
0x080200000 entrypoint
  • Loading branch information
BrianPugh authored May 1, 2023
2 parents 541a1b7 + fae6864 commit a18b29b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
13 changes: 7 additions & 6 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
45 changes: 41 additions & 4 deletions docs/zelda.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
6 changes: 3 additions & 3 deletions patches/zelda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a18b29b

Please sign in to comment.