Poke_Transporter_GB/source/multiboot_upload.cpp
Philippe Symons 93a6c0f3fe Add functionality to upload Poke Transporter GB to another gba after it has started on the current one [EZ Flash Omega]
The reason for this functionality is that some flashcarts *cough* EZ Flash Omega (DE) *cough* can't be hotswapped IN. When you try this, they will trigger a reset of the gba.
This is only relevant for the use case in which you first launch the rom from a flashcart in the first place.

I suppose this can only be relevant for flashcarts which offer "single cart mode". (mode B for EZ Flash Omega).

So, I added an option to upload the rom to another GBA from the "game_load_error" screen if you press the SELECT button.

So, with this change, you could

- launch Poke Transporter GB on GBA 1 from a flashcart.
- eject the flashcart on GBA 1
- make sure the EZ Flash Omega or other "single cart mode/mode B" capable flashcart is set to this mode.
- insert this flashcart into GBA 2
- connect GBA link cable (narrow plug on GBA 1, wide plug on GBA 2)
- Power on GBA 2 and press both SELECT and START while the gameboy logo is still shown
- On GBA 1, in the "game_load_error" screen, press SELECT
- On GBA 1, now press A -> The multiboot upload will now start
- Once finished, GBA 2 will now be running Poke Transporter GB as well
- GBA 2 will recognize the gen III save!
- You can now disconnect the GBA link cable and turn off GBA 1. (you may use it later for the GBC game alongside a GBC link cable to start the actual PKMN transfer)
2025-04-03 23:31:24 +02:00

70 lines
1.5 KiB
C++

#include <tonc.h>
#include "global_frame_controller.h"
#include "background_engine.h"
#include "libraries/gba-link-connection/LinkCableMultiboot.hpp"
static void clear_textbox()
{
tte_erase_screen();
tte_set_pos(40, 32);
tte_set_margins(40, 24, 206, 104);
set_textbox_large();
}
void multiboot_upload_screen()
{
LinkCableMultiboot linkCableMultiboot;
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(1);
REG_BG2VOFS = 0;
clear_textbox();
tte_write("#{cx:0xF000}To upload this app\nto another GBA,\nconnect a GBA link\ncable.\n\nPress A to upload.\nPress B to cancel.");
// wait for key press
do
{
global_next_frame();
}
while(!key_hit(KEY_A) && !key_hit(KEY_B));
if(key_hit(KEY_B))
{
// cancel
return;
}
// start upload
clear_textbox();
tte_set_pos(80, 56);
tte_write("#{cx:0xF000}Uploading...");
global_next_frame();
const u32 romSize = 256 * 1024; // EWRAM = 256 KB
LinkCableMultiboot::Result multibootResult = linkCableMultiboot.sendRom(
((const u8*)MEM_EWRAM),
romSize,
[]() {
u16 keys = ~REG_KEYS & KEY_ANY;
return keys & KEY_B;
// (when this returns true, the transfer will be canceled)
}
);
// show result
clear_textbox();
if(multibootResult == LinkCableMultiboot::Result::SUCCESS)
{
tte_write("#{cx:0xF000}Upload Successful!\n\nPress A to continue.");
}
else
{
tte_write("#{cx:0xF000}Upload Failed...\n\nPress A to continue.");
}
// wait for keypress again.
do
{
global_next_frame();
}
while(!key_hit(KEY_A));
}