From f3bc2ccc9e94e814ed72bf7483acd9e7850654b9 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 16:05:00 -0600 Subject: remove debug print line hg-commit-id: 9eac2d93fe88 --- extras/analyze_incbins.py | 1 - 1 file changed, 1 deletion(-) (limited to 'extras') diff --git a/extras/analyze_incbins.py b/extras/analyze_incbins.py index c47ac522..4f193d60 100644 --- a/extras/analyze_incbins.py +++ b/extras/analyze_incbins.py @@ -115,7 +115,6 @@ def split_incbin_line_into_three(line, start_address, byte_count): third = (start_address + byte_count, end - (start_address + byte_count)) output = "" - print "third end is: " + str(third[1]) if first: output += "INCBIN \"baserom.gbc\",$" + hex(first[0])[2:] + ",$" + hex(first[1])[2:] + " - $" + hex(first[2])[2:] + "\n" -- cgit v1.3.1-sl0p From e93230600f36516139d34bfc3b935c3f1fd6f368 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 16:09:16 -0600 Subject: remove bank id output in pretty_map_headers, it's wrong anyway hg-commit-id: d6a22efde56f --- extras/pretty_map_headers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extras') diff --git a/extras/pretty_map_headers.py b/extras/pretty_map_headers.py index 2c038fd4..867c65a5 100644 --- a/extras/pretty_map_headers.py +++ b/extras/pretty_map_headers.py @@ -159,7 +159,7 @@ def map_header_pretty_printer(map_header): #formatting: hex(y)[2:].zill(2) or "%02x" % (y,) - output = asm_name + ": ; " + address + " to " + hex(int(address, base) + byte_size) + " (" + str(byte_size) + " bytes) (bank=" + str(int(bank, base)) + ") (id=" + str(id) + ")\n" + output = asm_name + ": ; " + address + " to " + hex(int(address, base) + byte_size) + " (" + str(byte_size) + " bytes) (id=" + str(id) + ")\n" output += spacing + "db $" + str(tileset).zfill(2) + " ; tileset\n" output += spacing + "db $" + hex(y)[2:].zfill(2) + ", $" + hex(x)[2:].zfill(2) + " ; dimensions (y, x)\n" output += spacing + "dw $" + map_pointer + ", $" + texts_pointer + ", $" + script_pointer + " ; blocks, texts, scripts\n" -- cgit v1.3.1-sl0p From 36fb1f3ce01084ef505da576794c82ff1e72e8d7 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 16:46:26 -0600 Subject: don't print extra comments about connections for zero connections hg-commit-id: 1e41d5f9c62d --- extras/pretty_map_headers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'extras') diff --git a/extras/pretty_map_headers.py b/extras/pretty_map_headers.py index 867c65a5..819b665a 100644 --- a/extras/pretty_map_headers.py +++ b/extras/pretty_map_headers.py @@ -164,9 +164,12 @@ def map_header_pretty_printer(map_header): output += spacing + "db $" + hex(y)[2:].zfill(2) + ", $" + hex(x)[2:].zfill(2) + " ; dimensions (y, x)\n" output += spacing + "dw $" + map_pointer + ", $" + texts_pointer + ", $" + script_pointer + " ; blocks, texts, scripts\n" output += spacing + "db " + connection_line(connection_byte) + " ; connections\n\n" - output += spacing + "; connections data\n\n" - output += connection_pretty_printer(connections) - output += spacing + "; end connection data\n\n" + + if len(connections) > 0: + output += spacing + "; connections data\n\n" + output += connection_pretty_printer(connections) + output += spacing + "; end connection data\n\n" + output += spacing + "dw $" + object_data_pointer + " ; objects\n" return output -- cgit v1.3.1-sl0p From 7207000776c097d3aef086a9059b1867048bcba4 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 17:13:46 -0600 Subject: analyze_incbins now applies map header asm patches hg-commit-id: aec68677b92a --- extras/analyze_incbins.py | 81 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 10 deletions(-) (limited to 'extras') diff --git a/extras/analyze_incbins.py b/extras/analyze_incbins.py index 4f193d60..fcbf627d 100644 --- a/extras/analyze_incbins.py +++ b/extras/analyze_incbins.py @@ -5,7 +5,8 @@ import sys, os from copy import copy, deepcopy import subprocess -from extract_maps import rom, assert_rom, load_rom, calculate_pointer +from extract_maps import rom, assert_rom, load_rom, calculate_pointer, load_map_pointers, read_all_map_headers, map_headers +from pretty_map_headers import map_header_pretty_printer, map_name_cleaner #store each line of source code here asm = None @@ -57,9 +58,9 @@ def process_incbins(): partial_interval = incbin[21:].split(",")[1] partial_interval = partial_interval.replace(";", "#") - partial_interval = partial_interval.replace("$", "0x") + partial_interval = partial_interval.replace("$", "0x").replace("0xx", "0x") interval = eval(partial_interval) - interval_hex = hex(interval).replace("0x", "$") + interval_hex = hex(interval).replace("0x", "$").replace("x", "") end = start + interval end_hex = hex(end).replace("0x", "$") @@ -77,14 +78,19 @@ def process_incbins(): def find_incbin_to_replace_for(address): """returns a line number for which incbin to edit if you were to insert bytes into pokered.asm""" - if type(address) == str: int(address, 16) + if type(address) == str: address = int(address, 16) for incbin_key in processed_incbins.keys(): incbin = processed_incbins[incbin_key] start = incbin["start"] end = incbin["end"] - + + print "start is: " + str(start) + print "end is: " + str(end) + print "address is: " + str(type(address)) + print "checking.... " + hex(start) + " <= " + hex(address) + " <= " + hex(end) + if start <= address <= end: return incbin_key return None @@ -140,7 +146,7 @@ def generate_diff_insert(line_number, newline): newfile_fh.close() try: - diffcontent = subprocess.check_output("diff -u " + original_filename + " " + newfile_filename, shell=True) + diffcontent = subprocess.check_output("diff -u ../pokered.asm " + newfile_filename, shell=True) except Exception, exc: diffcontent = exc.output @@ -149,13 +155,68 @@ def generate_diff_insert(line_number, newline): return diffcontent +def insert_map_header_asm(map_id): + map = map_headers[map_id] + line_number = find_incbin_to_replace_for(map["address"]) + if line_number == None: # or map_name_cleaner(map["name"], 0) in "\n".join(line for line in asm): + print "i think map id=" + str(map_id) + " has previously been added." + return #this map has already been added i bet + newlines = split_incbin_line_into_three(line_number, map["address"], 12 + (11 * len(map["connections"]))) + + map_header_asm = map_header_pretty_printer(map_headers[map_id]) + + newlines = newlines.split("\n") + if len(newlines) == 2: index = 0 + elif len(newlines) == 3: + index = 1 + newlines[0] += "\n" #spacing is a nice thing to have + newlines[index] = map_header_asm + newlines = "\n".join(line for line in newlines) + + diff = generate_diff_insert(line_number, newlines) + + print diff + print "... Applying diff." + + #write the diff to a file + fh = open("temp.patch", "w") + fh.write(diff) + fh.close() + + #apply the patch + os.system("patch ../pokered.asm temp.patch") + + #remove the patch + os.system("rm temp.patch") + +def wrapper_insert_map_header_asm(map_id): + "reload the asm because it has changed (probably)" + load_asm() + isolate_incbins() + process_incbins() + insert_map_header_asm(map_id) + +def dump_all_remaining_maps(): + for map_id in map_headers: + print "Inserting map id=" + str(map_id) + wrapper_insert_map_header_asm(map_id) + if __name__ == "__main__": + #load map headers + load_rom() + load_map_pointers() + read_all_map_headers() + + #load incbins (mandatory) load_asm() isolate_incbins() process_incbins() #print processed_incbins - line_number = find_incbin_to_replace_for(0x492c3) - newlines = split_incbin_line_into_three(line_number, 0x492c3, 12) - diff = generate_diff_insert(line_number, newlines) - print diff + #line_number = find_incbin_to_replace_for(0x492c3) + #newlines = split_incbin_line_into_three(line_number, 0x492c3, 12) + #diff = generate_diff_insert(line_number, newlines) + #print diff + + insert_map_header_asm(81) + #dump_all_remaining_maps() -- cgit v1.3.1-sl0p From b945ae8fe6e8f9ceda025babc94b16a16b785a6c Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 17:15:14 -0600 Subject: Route11Gate_h map header asm hg-commit-id: 6c4ccdd3e56a --- extras/analyze_incbins.py | 2 +- pokered.asm | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'extras') diff --git a/extras/analyze_incbins.py b/extras/analyze_incbins.py index fcbf627d..6e6e5007 100644 --- a/extras/analyze_incbins.py +++ b/extras/analyze_incbins.py @@ -217,6 +217,6 @@ if __name__ == "__main__": #diff = generate_diff_insert(line_number, newlines) #print diff - insert_map_header_asm(81) + insert_map_header_asm(84) #dump_all_remaining_maps() diff --git a/pokered.asm b/pokered.asm index f6690553..1c90e77c 100644 --- a/pokered.asm +++ b/pokered.asm @@ -13387,7 +13387,17 @@ RockTunnelPokecenter_h: ; 0x493ae to 0x493ba (12 bytes) (id=81) dw $53d4 ; objects -INCBIN "baserom.gbc",$493ba,$2c46 +INCBIN "baserom.gbc",$493ba,$49400 - $493ba + +Route11Gate_h: ; 0x49400 to 0x4940c (12 bytes) (id=84) + db $0c ; tileset + db $05, $04 ; dimensions (y, x) + dw $40c7, $540f, $540c ; blocks, texts, scripts + db $00 ; connections + + dw $5416 ; objects + +INCBIN "baserom.gbc",$4940c,$2bf4 SECTION "bank13",DATA,BANK[$13] -- cgit v1.3.1-sl0p From be36119c58ff5ac360df0135446b9d7a6030acc6 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Tue, 3 Jan 2012 17:15:42 -0600 Subject: Route11GateUpstairs_h map header asm hg-commit-id: 8638c4221e05 --- extras/analyze_incbins.py | 2 +- pokered.asm | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'extras') diff --git a/extras/analyze_incbins.py b/extras/analyze_incbins.py index 6e6e5007..70842f48 100644 --- a/extras/analyze_incbins.py +++ b/extras/analyze_incbins.py @@ -217,6 +217,6 @@ if __name__ == "__main__": #diff = generate_diff_insert(line_number, newlines) #print diff - insert_map_header_asm(84) + insert_map_header_asm(86) #dump_all_remaining_maps() diff --git a/pokered.asm b/pokered.asm index 1c90e77c..90c79ea7 100644 --- a/pokered.asm +++ b/pokered.asm @@ -13397,7 +13397,17 @@ Route11Gate_h: ; 0x49400 to 0x4940c (12 bytes) (id=84) dw $5416 ; objects -INCBIN "baserom.gbc",$4940c,$2bf4 +INCBIN "baserom.gbc",$4940c,$49448 - $4940c + +Route11GateUpstairs_h: ; 0x49448 to 0x49454 (12 bytes) (id=86) + db $0c ; tileset + db $04, $04 ; dimensions (y, x) + dw $40db, $5457, $5454 ; blocks, texts, scripts + db $00 ; connections + + dw $54da ; objects + +INCBIN "baserom.gbc",$49454,$2bac SECTION "bank13",DATA,BANK[$13] -- cgit v1.3.1-sl0p