gb

Support for Game Boy ROMs, split into banks.

ROMs are extracted and repacked as a set of bank_xx.bin files, one per bank, with xx being the bank number in hex. ASM patches are applied by calling the wla-gb and wlalink executables externally.

hacktools.gb.extractRom(romfile, extractfolder, workfolder='', banksize=16384)[source]

Extract a Game Boy ROM to a folder, splitting it into banks.

Parameters:
  • romfile (str) – Path of the ROM file.

  • extractfolder (str) – Path of the folder to extract to.

  • workfolder (str) – Optional path of a work folder the extracted files are copied to.

  • banksize (int) – Size of a single bank.

Return type:

None

hacktools.gb.repackRom(romfile, rompatch, workfolder, patchfile='', banksize=16384)[source]

Repack a Game Boy ROM from the bank files in a folder.

The global checksum in the ROM header is recalculated after the banks are joined.

Parameters:
  • romfile (str) – Path of the original ROM file.

  • rompatch (str) – Path of the output ROM file.

  • workfolder (str) – Path of the folder with the bank files.

  • patchfile (str) – Path of the xdelta patch to create, an ips patch is also created next to it. No patches are created if empty.

  • banksize (int) – Size of a single bank.

Return type:

None

hacktools.gb.asmPatch(file, workfolder, banks=[0], banksize=16384)[source]

Apply an ASM patch with wla-gb, then extract the patched banks.

The asm file is compiled with wla-gb and linked with wlalink into a temporary patched ROM, and the given banks are extracted from it into the work folder. If a .txt file with the same name as the asm file exists, it’s used as the linkfile, otherwise a temporary one is created.

Parameters:
  • file (str) – Path of the asm file.

  • workfolder (str) – Path of the folder the patched banks are extracted to.

  • banks (list[int]) – List of bank numbers the patch is expected to change.

  • banksize (int) – Size of a single bank.

Return type:

None