Validating loader files

This commit is contained in:
Rodrigo Alfonso 2025-02-16 08:56:57 -03:00
parent 25fff2de3a
commit c6ca9c563b
2 changed files with 11 additions and 4 deletions

View File

@ -24,7 +24,7 @@ reliably.
Here's how games transfer their _custom e-Reader dotcode scanner_ (aka _"DLC Loader"_):
- Goes to MULTI mode and sends `0xFEFE`
- Sends 0xFEFE again and expects `0xCCC0` (*)
- Sends `0xFEFE` again and expects `0xCCC0`
* On the Japanese e-Reader, every `0xCCC0` becomes `0xCCD0`
- Sends `0xCCC0` and expects `0xCCC0`
- Switches to NORMAL32, waits 1 frame, and sends the card length as a 32-bit number (hi part is probably always `0x0000`, since there's not enough flash memory in the e-Reader)
@ -34,7 +34,7 @@ Here's how games transfer their _custom e-Reader dotcode scanner_ (aka _"DLC Loa
- Switches to MULTI mode again, waits 1 frame
- Sends `0xCCC0` and expects `0xCCC0`
- Sends `0xCCC0` and expects `0x1`
- All sends need a small wait or otherwise it'll work on mGBA but not on hardware (waiting for two VCOUNT changes work, but it's probably just 36μs)
- All sends need a small wait or otherwise it'll work on mGBA but not on hardware (waiting for two VCOUNT changes works, but it's probably just 36μs)
## Card scanning protocol

View File

@ -8,6 +8,9 @@ extern "C" {
#include "../../_lib/libgbfs/gbfs.h"
}
#define USA_LOADER "usa.loader"
#define JAP_LOADER "jap.loader"
static const GBFS_FILE* fs = find_first_gbfs_file(0);
// (1) Create a LinkCard instance
@ -28,8 +31,12 @@ int main() {
Common::log("! GBFS file not found");
while (true)
;
} else if (gbfs_get_nth_obj(fs, 0, NULL, NULL) == NULL) {
Common::log("! No files found (GBFS)");
} else if (gbfs_get_obj(fs, USA_LOADER, NULL) == NULL) {
Common::log("! usa.loader not found (GBFS)");
while (true)
;
} else if (gbfs_get_obj(fs, JAP_LOADER, NULL) == NULL) {
Common::log("! jap.loader not found (GBFS)");
while (true)
;
}