ref: e7a1d887d9dddcba2d5679c27198952851271f0a
parent: 3eda472a22bc0ca68e56884d7a63020b68b7bcad
parent: 3333728b61817b0fe2b8d912eac32ae36cdd50a8
author: YamaArashi <shadow962@live.com>
date: Mon Jan 23 23:55:50 EST 2012
Merge hg-commit-id: d509fe34f171
--- a/common.asm
+++ b/common.asm
@@ -4150,7 +4150,7 @@
ld e,l
ld d,h
jr .gotPtr\@
-.otherEntries\@ ;$378d
+.otherEntries\@ ; $378d
;2-7 = OTHER ENTRIES
ld a,[$d0b7]
ld [$ffb8],a
@@ -4162,7 +4162,7 @@
ld e,a
jr nc,.skip\@
inc d
-.skip\@ ;$37a0
+.skip\@ ; $37a0
ld hl,NamePointers
add hl,de
ld a,[hli]
@@ -4192,7 +4192,7 @@
ld de,$cd6d
ld bc,$0014
call CopyData
-.gotPtr\@ ;$37cd
+.gotPtr\@ ; $37cd
ld a,e
ld [$cf8d],a
ld a,d
@@ -4406,7 +4406,7 @@
INCBIN "baserom.gbc",$3DDC,$3DED - $3DDC
-GoPAL_SET_CF1C: ; 3ded
+GoPAL_SET_CF1C: ; 3ded
ld b,$ff
GoPAL_SET: ; 3def
ld a,[$cf1b]
@@ -10833,7 +10833,7 @@
ENDC
-GetItemUse: ;$D5C7
+GetItemUse: ; $D5C7
ld a,1
ld [$cd6a],a
ld a,[$cf91] ;contains item_ID
@@ -10850,7 +10850,7 @@
ld l,a
jp [hl]
-ItemUsePtrTable: ;$D5E1
+ItemUsePtrTable: ; $D5E1
dw ItemUseBall ;$5687 masterball
dw ItemUseBall ;$5687 ultraball
dw ItemUseBall ;$5687 greatball
@@ -11396,7 +11396,7 @@
db $50
; 0xe247 + 5 bytes
-OldRodCode:
+OldRodCode: ; 0xe24c
call $62b4 ; probably sets carry if not in battle or not by water
jp c, ItemUseNotTime
ld bc, (5 << 8) | MAGIKARP
@@ -14407,8 +14407,33 @@
SilphCo4Texts: ; 0x19da0
dw SilphCo4Text1, SilphCo4Text2, SilphCo4Text3, SilphCo4Text4, SilphCo4Text5, SilphCo4Text6, SilphCo4Text7
-INCBIN "baserom.gbc",$19dae,$25
+TrainerHeader_19dae: ; 0x19dae
+ db $2 ; flag's bit
+ db ($4 << 4) ; trainer's view range
+ dw $d829 ; flag's byte
+ dw UnnamedText_19df4 ; 0x5df4 TextBeforeBattle
+ dw UnnamedText_19dfe ; 0x5dfe TextAfterBattle
+ dw UnnamedText_19df9 ; 0x5df9 TextEndBattle
+; 0x19db8
+INCBIN "baserom.gbc",$19db8,$19dba - $19db8
+
+TrainerHeader_19dba: ; 0x19dba
+INCBIN "baserom.gbc",$19dba,$19dc2 - $19dba
+
+INCBIN "baserom.gbc",$19dc2,4
+
+TrainerHeader_19dc6: ; 0x19dc6
+ db $4 ; flag's bit
+ db ($4 << 4) ; trainer's view range
+ dw $d829 ; flag's byte
+ dw UnnamedText_19e26 ; 0x5e26 TextBeforeBattle
+ dw UnnamedText_19e30 ; 0x5e30 TextAfterBattle
+ dw UnnamedText_19e2b ; 0x5e2b TextEndBattle
+; 0x19dd0
+
+INCBIN "baserom.gbc",$19dd0,$19dd3 - $19dd0
+
SilphCo4Text1: ; 0x19dd3
db $08 ; asm
ld hl, $5de0
@@ -14428,7 +14453,7 @@
SilphCo4Text2: ; 0x19dea
db $08 ; asm
- ld hl, $5dae
+ ld hl, TrainerHeader_19dae
call LoadTrainerHeader
jp TextScriptEnd
@@ -14470,7 +14495,7 @@
SilphCo4Text4: ; 0x19e1c
db $08 ; asm
- ld hl, $5dc6
+ ld hl, TrainerHeader_19dc6
call LoadTrainerHeader
jp TextScriptEnd
@@ -14548,8 +14573,27 @@
SilphCo5Texts: ; 0x19fbc
dw SilphCo5Text1, SilphCo5Text2, SilphCo5Text3, SilphCo5Text4, SilphCo5Text5, SilphCo5Text6, SilphCo5Text7, SilphCo5Text8, SilphCo5Text9, SilphCo5Text10, SilphCo5Text11
-INCBIN "baserom.gbc",$19fd2,$31
+TrainerHeader_19fd2: ; 0x19fd2
+ db $2 ; flag's bit
+ db ($1 << 4) ; trainer's view range
+ dw $d82b ; flag's byte
+ dw UnnamedText_1a024 ; 0x6024 TextBeforeBattle
+ dw UnnamedText_1a02e ; 0x602e TextAfterBattle
+ dw UnnamedText_1a029 ; 0x6029 TextEndBattle
+ dw UnnamedText_1a029 ; 0x6029 TextEndBattle
+; 0x19fde
+TrainerHeader_19fde: ; 0x19fde
+ db $3 ; flag's bit
+ db ($2 << 4) ; trainer's view range
+ dw $d82b ; flag's byte
+ dw UnnamedText_1a03d ; 0x603d TextBeforeBattle
+ dw UnnamedText_1a047 ; 0x6047 TextAfterBattle
+ dw UnnamedText_1a042 ; 0x6042 TextEndBattle
+; 0x19fe8
+
+INCBIN "baserom.gbc",$19fe8,$1a003 - $19fe8
+
SilphCo5Text1: ; 0x1a003
db $08 ; asm
ld hl, $6010
@@ -14569,7 +14613,7 @@
SilphCo5Text2: ; 0x1a01a
db $08 ; asm
- ld hl, $5fd2
+ ld hl, TrainerHeader_19fd2
call LoadTrainerHeader
jp TextScriptEnd
@@ -14590,7 +14634,7 @@
SilphCo5Text3: ; 0x1a033
db $08 ; asm
- ld hl, $5fde
+ ld hl, TrainerHeader_19fde
call LoadTrainerHeader
jp TextScriptEnd
--- a/extras/pretty_map_headers.py
+++ b/extras/pretty_map_headers.py
@@ -751,6 +751,6 @@
#prepare to pretty print tx_fars
#first you must load all_texts
- tx_fars = find_all_tx_fars()
- for entry in tx_fars:
- print tx_far_pretty_printer(entry)
+ #tx_fars = find_all_tx_fars()
+ #for entry in tx_fars:
+ # print tx_far_pretty_printer(entry)
--- /dev/null
+++ b/extras/pretty_trainer_headers.py
@@ -1,0 +1,117 @@
+#!/usr/bin/python
+#author: Bryan Bishop <kanzure@gmail.com>
+#date: 2012-01-24
+from optparse import OptionParser
+from gbz80disasm import load_labels, find_label
+from extract_maps import calculate_pointer
+import sys
+spacing = "\t"
+
+def pretty_print_trainer_header(address, label=None):
+ """make pretty text for a trainer header"""
+ output = ""
+ bank_id = 0
+ if address > 0x4000:
+ bank_id = address / 0x4000
+
+ rom = open("../baserom.gbc", "r").read()
+
+ #convert address to an integer if necessary
+ if type(address) == str:
+ if "$" in address: address = address.replace("$", "0x")
+ address = int(address, 16)
+
+ #label this section of asm
+ if label == None:
+ output += "TrainerHeader_" + hex(address)[2:] + ": ; 0x" + hex(address)[2:] + "\n"
+ else:
+ output += label + ": ; 0x" + hex(address)[2:] + "\n"
+
+ #flag's bit
+ output += spacing + "db $" + hex(ord(rom[address]))[2:] + " ; flag's bit\n"
+
+ #trainer's view range
+ view_range = ord(rom[address+1]) >> 4
+ output += spacing + "db ($" + hex(view_range)[2:] + " << 4) ; trainer's view range\n"
+
+ #flag's byte
+ pointer_byte1 = ord(rom[address+2])
+ pointer_byte2 = ord(rom[address+3])
+ partial_pointer = (pointer_byte1 + (pointer_byte2 << 8))
+ partial_pointer = "$%.2x" % partial_pointer
+ output += spacing + "dw " + partial_pointer + " ; flag's byte\n"
+
+ #TextBeforeBattle
+ pointer_byte1 = ord(rom[address+4])
+ pointer_byte2 = ord(rom[address+5])
+ partial_pointer = (pointer_byte1 + (pointer_byte2 << 8))
+ label = find_label(partial_pointer, bank_id)
+ if label == None:
+ print "label not found for (TextBeforeBattle) " + hex(calculate_pointer(partial_pointer, bank_id))
+ print ""
+ label = "$" + hex(partial_pointer)[2:]
+ #sys.exit(0)
+
+ output += spacing + "dw " + label + " ; " + hex(partial_pointer) + " TextBeforeBattle\n"
+
+ #TextAfterBattle
+ pointer_byte1 = ord(rom[address+6])
+ pointer_byte2 = ord(rom[address+7])
+ partial_pointer = (pointer_byte1 + (pointer_byte2 << 8))
+ label = find_label(partial_pointer, bank_id)
+ if label == None:
+ print "label not found for (TextAfterBattle) " + hex(calculate_pointer(partial_pointer, bank_id))
+ print ""
+ label = "$" + hex(partial_pointer)[2:]
+ #sys.exit(0)
+
+ output += spacing + "dw " + label + " ; " + hex(partial_pointer) + " TextAfterBattle\n"
+
+ #TextEndBattle
+ pointer_byte1 = ord(rom[address+8])
+ pointer_byte2 = ord(rom[address+9])
+ partial_pointer = (pointer_byte1 + (pointer_byte2 << 8))
+ label = find_label(partial_pointer, bank_id)
+ if label == None:
+ print "label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id))
+ print ""
+ label = "$" + hex(partial_pointer)[2:]
+ #sys.exit(0)
+
+ output += spacing + "dw " + label + " ; " + hex(partial_pointer) + " TextEndBattle\n"
+
+ #TextEndBattle
+ pointer_byte1 = ord(rom[address+10])
+ pointer_byte2 = ord(rom[address+11])
+ partial_pointer = (pointer_byte1 + (pointer_byte2 << 8))
+ label = find_label(partial_pointer, bank_id)
+ if label == None:
+ print "label not found for (TextEndBattle) " + hex(calculate_pointer(partial_pointer, bank_id))
+ print ""
+ label = "$" + hex(partial_pointer)[2:]
+ #sys.exit(0)
+
+ #output += spacing + "dw " + label + " ; " + hex(partial_pointer) + " TextEndBattle\n"
+
+ output += "; " + hex(address+10) + "\n"
+
+ return output
+
+def main():
+ load_labels()
+
+ usage = "usage: %prog address"
+ parser = OptionParser(usage)
+ (options, args) = parser.parse_args()
+ if len(args) == 1:
+ print "usage: python pretty_trainer_headers.py address label\n"
+ args.append("TrainerHeader_" + (args[0].replace("0x", "")))
+ elif len(args) != 2:
+ parser.error("we need both an address and a label")
+ address = int(args[0], 16)
+ label = args[1]
+
+ print pretty_print_trainer_header(address, label)
+
+if __name__ == "__main__":
+ main()