Poke_Transporter_GB/loader/source/main.c
Philippe Symons c9ed32e3a1 Debug option: Write/Load Cable data to/from SRAM
This commit allows you to use the Write Cbl Data debug option and new Load Cbl Data debug option to dump a link's data to SRAM
or load it from SRAM and pretend like you got it over the link cable.

This is useful for capturing the link process on gameboy and replay + debug it later in an emulator.
2026-06-04 15:22:46 +02:00

50 lines
1.1 KiB
C

#include <tonc.h>
#include <string.h>
// This file is autogenerated from the file in the graphics folder
//#include "ptgb_logo_l.h"
//#include "ptgb_logo_r.h"
#include "multiboot_rom_bin.h"
#define SPRITE_CHAR_BLOCK 4
#define DST_EWRAM (void*)0x02000000
#define MULTIBOOT_ENTRY_POINT (void*)0x020000C0
static const char saveType[] __attribute__((used)) = "SRAM_V113";
/**
* Loads the PokeTransporter multiboot rom into EWRAM
*/
static void load_multiboot_rom(const void *src, size_t size)
{
REG_IME = 0; // Disable all interrupts
memcpy(DST_EWRAM, src, size);
REG_IME = 1;
}
/**
* Now jump to the multiboot rom address and start execution
*/
static void execute_multiboot()
{
// Function pointer to EWRAM execution entry
void (*entry)(void) = MULTIBOOT_ENTRY_POINT;
entry(); // Jump to loaded ROM
}
int main(void)
{
irq_init(NULL);
irq_enable(II_VBLANK);
tte_init_chr4c_default(0, BG_CBB(0) | BG_SBB(31));
tte_set_pos(92, 68);
REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ | DCNT_OBJ_1D;
VBlankIntrWait();
load_multiboot_rom(multiboot_rom_bin, multiboot_rom_bin_size);
execute_multiboot();
}