zladx/LADX-Disassembly

Make the source code shiftable

kemenaran opened this issue · 2 comments

ROM hacks are much easier if code can be added and removed without breaking the game.

For this, all ROM raw addresses need to be labeled. That means turning all direct ROM references (e.g. call $1234) into a label (e.g. call Func_000_1234).

(Documenting the label, e.g. call AnimateEntities is a nice-to-have, but is not strictly required.)

TODO

  • Make bank 0 shiftable
  • Make other code banks shiftable
    • Make many code banks shiftable
    • bank0.asm:88
    • music_1.asm:4
    • audio/sfx.asm:454
    • bank20.asm:80
    • credits.asm:76
    • photos.asm:42
    • bank14.asm:44
    • entities/bank36.asm:84
    • entities/bank18.asm:144
    • entities/bank19.asm:200
  • Make graphics shiftable

Progress

Progress can be tracked by running tools/stats.sh, which counts the number of remaining raw addresses that need to be labeled.

How to

  • To see which banks need to be made shiftable: tools/stats.sh --verbose.
  • To convert blobs of data-interpreted-as-code into an ASM data block with label: tools/data_to_asm.py <start address> <end address>
  • How To: make a bank shiftable

Bank 0 is now shiftable.

For the other banks:

$ tools/stats.sh -v

Number of remaining raw addresses:
   Referencing Home (0000-3FFF):
       0
   Referencing non-Home ROM banks (4000-7FFF):
    2623

The ROM is now mostly shiftable.

Some pointers to RAM data are still hardcoded, but it still allows the code to be shifted around \o/