AetiasHax / ds-rom

Library/CLI for extracting and building DS ROMs
6 stars 0 forks source link

Panic when extracting Gyakuten Kenji 2 #5

Open PhoenixBound opened 1 week ago

PhoenixBound commented 1 week ago

When extracting the game Gyakuten Kenji 2 (BXOJ), the tool panics writing the arm9.bin out to the filesystem:

[2024-09-21T00:59:48Z INFO  ds_rom::rom::rom] Saving ROM to path ./gk2-extracted
[2024-09-21T00:59:48Z INFO  ds_rom::rom::rom] Decompressing ARM9 program
thread 'main' panicked at .\lib\src\rom\rom.rs:359:47:
unknown autoload block
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Since this code is related to separating ITCM and DTCM data from everything else, I'm guessing it's because of an extra entry at the end of the file that says "copy 0 bytes of data and 0 bytes of zeroes to $2400000":

image

AetiasHax commented 6 days ago

2400000 is also the end of the main memory on the original DS so there couldn't possibly be anything there. Though as you pointed out, nothing is being copied there anyway. Very strange 🤔

It looks like ds-rom needs a way to store arbitrary autoload blocks somewhere, since it's hardcoded to only know about ITCM and DTCM right now.

PhoenixBound commented 6 days ago

Yeah I dunno... I think I read somewhere that debug models of the DS had more RAM, but that doesn't help much with guessing what its contents would be/why this autoload entry exists in a retail game.

The arbitrary autoload config thing would probably be a good futureproofing measure, if nothing else.