From ebcf2a87565c4a74206dcb167f96fb33faf10d2b Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 10 Jan 2012 12:47:37 -0600 Subject: implement two-byte op codes in gbz80disasm Previously, two-byte commands in gbz80disasm would not read or allow parameters. This update fixes gbz80disasm to read both the "x" and "?" parameters. x = one-byte parameter ? = two-byte parameter hg-commit-id: 1494e8a88115 --- extras/gbz80disasm.py | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index d0093436..f23a761a 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -597,12 +597,38 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): temp_maybe += ( ord(rom[offset+1]) << 8) if temp_maybe in opt_table.keys(): opstr = copy(opt_table[temp_maybe][0]) - - output += spacing + opstr.lower() #+ " ; " + hex(offset) + + if "x" in opstr: + for x in range(0, opstr.count("x")): + insertion = ord(rom[offset + 1]) + insertion = "$" + hex(insertion)[2:] + + opstr = opstr[:opstr.find("x")].lower() + insertion + opstr[opstr.find("x")+1:].lower() + + current_byte += 1 + offset += 1 + if "?" in opstr: + for y in range(0, opstr.count("?")): + byte1 = ord(rom[offset + 1]) + byte2 = ord(rom[offset + 2]) + + number = byte1 + number += byte2 << 8; + + insertion = "$%.4x" % (number) + + opstr = opstr[:opstr.find("?")].lower() + insertion + opstr[opstr.find("?")+1:].lower() + output += spacing + opstr #+ " ; " + hex(offset) + output += "\n" + + current_byte_number += 2 + offset += 2 + + output += spacing + opstr #+ " ; " + hex(offset) output += "\n" - current_byte_number += 2 - offset += 2 + current_byte_number += 1 + offset += 1 elif maybe_byte in opt_table.keys(): op_code = opt_table[maybe_byte] op_code_type = op_code[1] @@ -611,6 +637,8 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): #type = -1 when it's the E op #if op_code_type != -1: if op_code_type == 0 and ord(rom[offset]) == op_code_byte: + op_str = op_code[0].lower() + output += spacing + op_code[0].lower() #+ " ; " + hex(offset) output += "\n" -- cgit v1.2.3 From d9b994bf476246be1fca37ffebad27fb7e26a348 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 10 Jan 2012 13:42:21 -0600 Subject: fix gbz80disasm line repetition bug Certain two-byte op codes would be printed twice. hg-commit-id: 8c7650a614b7 --- extras/gbz80disasm.py | 4 +--- extras/insert_texts.py | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index f23a761a..0608980b 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -169,6 +169,7 @@ temp_opt_table = [ [ "LD A, L", 0x7d, 0 ], [ "LD A, [$FF00+C]", 0xf2, 0 ], [ "LD A, [$FF00+x]", 0xf0, 1 ], + #[ "LDH A, [x]", 0xf0, 1 ], #rgbds has trouble with this one? [ "LD A, [BC]", 0xa, 0 ], [ "LD A, [DE]", 0x1a, 0 ], [ "LD A, [HL+]", 0x2a, 0 ], @@ -221,7 +222,6 @@ temp_opt_table = [ [ "LD [$FF00+C], A", 0xe2, 0 ], [ "LD [$FF00+x], A", 0xe0, 1 ], [ "LD H, A", 0x67, 0 ], - [ "LDH A, [x]", 0xf0, 1 ], [ "LD H, B", 0x60, 0 ], [ "LD H, C", 0x61, 0 ], [ "LD H, D", 0x62, 0 ], @@ -618,8 +618,6 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000): insertion = "$%.4x" % (number) opstr = opstr[:opstr.find("?")].lower() + insertion + opstr[opstr.find("?")+1:].lower() - output += spacing + opstr #+ " ; " + hex(offset) - output += "\n" current_byte_number += 2 offset += 2 diff --git a/extras/insert_texts.py b/extras/insert_texts.py index 282f0bdc..e9f2ae8e 100644 --- a/extras/insert_texts.py +++ b/extras/insert_texts.py @@ -424,7 +424,8 @@ if __name__ == "__main__": #insert_08_asm(83, 1) #insert_all_08s() - insert_asm(0x31cc, "LoadTrainerHeader") + insert_asm(0x2f9e, "GetMonName") - print "-- FAILED ATTEMPTS --" - print str(failed_attempts) + if len(failed_attempts) > 0: + print "-- FAILED ATTEMPTS --" + print str(failed_attempts) -- cgit v1.2.3 From 76dc9b8170ad6653f5436cad3246e5a0ebd2f267 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 10 Jan 2012 13:44:54 -0600 Subject: call $2f9e -> call GetMonName hg-commit-id: 7bb690c08a4d --- extras/gbz80disasm.py | 1 + pokered.asm | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index 0608980b..f7e543b3 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -549,6 +549,7 @@ asm_commands = { "3e48": "GivePokemon", "3dd7": "Delay3", "3e2e": "GiveItem", + "2f9e": "GetMonName", } def random_asm_label(): diff --git a/pokered.asm b/pokered.asm index 75a0f6db..bd97a8a3 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1055,7 +1055,33 @@ Route2Text2: ; 0x24f4 call $3e6d jp $24d7 -INCBIN "baserom.gbc",$24fd,$ad2 +INCBIN "baserom.gbc",$24fd,$2f9e - $24fd + +GetMonName: ; 0x2f9e + push hl + ld a, [$ff00+$b8] + push af + ld a, $7 + ldh [$b8], a + ld [$2000], a + ld a, [$d11e] + dec a + ld hl, $421e + ld c, $a + ld b, $0 + call $3a87 + ld de, $cd6d + push de + ld bc, $000a + call $00b5 + ld hl, $cd77 + ld [hl], $50 + pop de + pop af + ldh [$b8], a + ld [$2000], a + pop hl + ret GetItemName: ; 2FCF ; given an item ID at [$D11E], store the name of the item into a string @@ -1360,7 +1386,7 @@ GetName: ; 376B dec a jr nz,.otherEntries\@ ;1 = MON_NAMES - call $2f9e; GetMonName + call GetMonName ld hl,11 add hl,de ld e,l -- cgit v1.2.3