Exemple #1
0
 def test_calculate_pointer_from_bytes_at(self):
     addr1 = calculate_pointer_from_bytes_at(0x100, bank=False)
     self.assertEqual(addr1, 0xc300)
     addr2 = calculate_pointer_from_bytes_at(0x100, bank=True)
     self.assertEqual(addr2, 0x2ec3)
"""
Dump out asm for scripting things in bank $25. This script will modify main.asm
and insert all scripting commands.
"""

import crystal
import gbz80disasm

rom = crystal.load_rom()
roml = [ord(x) for x in rom]

script_command_table_address = 0x96cb1
script_command_count = 170

# a list of addresses for each script command
command_pointers = [crystal.calculate_pointer_from_bytes_at(script_command_table_address + (id * 2), bank=0x25) for id in range(0, 170)]

# a list of hex addresses for each script command in bank $25
command_pointers_hex = ["$%.2x" % (x % 0x4000 + 0x4000) for x in command_pointers]

commands = {}

# force data into a more usable form
for command in crystal.command_classes:
    name = "Script_" + command.macro_name
    id = command.id
    params = {}

    for (id2, param_type) in command.param_types.items():
        param = {
            "name": param_type["name"],