diff options
Diffstat (limited to 'extras')
-rw-r--r-- | extras/crystal.py | 17 | ||||
-rw-r--r-- | extras/gfx.py | 34 | ||||
-rw-r--r-- | extras/pksv.py | 9 |
3 files changed, 44 insertions, 16 deletions
diff --git a/extras/crystal.py b/extras/crystal.py index ee7b94ae8..8a2b337f6 100644 --- a/extras/crystal.py +++ b/extras/crystal.py @@ -1549,12 +1549,12 @@ class ScriptPointerLabelBeforeBank(PointerLabelBeforeBank): pass class ScriptPointerLabelAfterBank(PointerLabelAfterBank): pass -def _parse_script_pointer_bytes(self): +def _parse_script_pointer_bytes(self, debug = False): PointerLabelParam.parse(self) - print "_parse_script_pointer_bytes - calculating the pointer located at " + hex(self.address) + if debug: print "_parse_script_pointer_bytes - calculating the pointer located at " + hex(self.address) address = calculate_pointer_from_bytes_at(self.address, bank=self.bank) if address != None and address > 0x4000: - print "_parse_script_pointer_bytes - the pointer is: " + hex(address) + if debug: print "_parse_script_pointer_bytes - the pointer is: " + hex(address) self.script = parse_script_engine_script_at(address, debug=self.debug, force=self.force, map_group=self.map_group, map_id=self.map_id) ScriptPointerLabelParam.parse = _parse_script_pointer_bytes ScriptPointerLabelBeforeBank.parse = _parse_script_pointer_bytes @@ -2817,6 +2817,7 @@ pksv_crystal_more = { 0x4F: ["loadmenudata", ["data", MenuDataPointerParam]], 0x50: ["writebackup"], 0x51: ["jumptextfaceplayer", ["text_pointer", RawTextPointerLabelParam]], + 0x52: ["3jumptext", ["text_pointer", PointerLabelBeforeBank]], 0x53: ["jumptext", ["text_pointer", RawTextPointerLabelParam]], 0x54: ["closetext"], 0x55: ["keeptextopen"], @@ -3160,12 +3161,12 @@ class Script: """ global command_classes, rom, script_parse_table current_address = start_address - print "Script.parse address="+hex(self.address) +" map_group="+str(map_group)+" map_id="+str(map_id) + if debug: print "Script.parse address="+hex(self.address) +" map_group="+str(map_group)+" map_id="+str(map_id) if start_address in stop_points and force == False: - print "script parsing is stopping at stop_point=" + hex(start_address) + " at map_group="+str(map_group)+" map_id="+str(map_id) + if debug: print "script parsing is stopping at stop_point=" + hex(start_address) + " at map_group="+str(map_group)+" map_id="+str(map_id) return None if start_address < 0x4000 and start_address not in [0x26ef, 0x114, 0x1108]: - print "address is less than 0x4000.. address is: " + hex(start_address) + if debug: print "address is less than 0x4000.. address is: " + hex(start_address) sys.exit(1) if is_script_already_parsed_at(start_address) and not force and not force_top: raise Exception, "this script has already been parsed before, please use that instance ("+hex(start_address)+")" @@ -3198,7 +3199,7 @@ class Script: # no matching command found (not implemented yet)- just end this script # NOTE: might be better to raise an exception and end the program? if scripting_command_class == None: - print "parsing script; current_address is: " + hex(current_address) + if debug: print "parsing script; current_address is: " + hex(current_address) current_address += 1 asm_output = "\n".join([command.to_asm() for command in commands]) end = True @@ -3231,7 +3232,7 @@ class Script: script_parse_table[start_address:current_address] = self asm_output = "\n".join([command.to_asm() for command in commands]) - print "--------------\n"+asm_output + if debug: print "--------------\n"+asm_output # store the script self.commands = commands diff --git a/extras/gfx.py b/extras/gfx.py index f36b944d7..70c657c15 100644 --- a/extras/gfx.py +++ b/extras/gfx.py @@ -1283,6 +1283,28 @@ def get_uncompressed_gfx(start, num_tiles, filename): +def hex_to_rgb(word): + red = word & 0b11111 + word >>= 5 + green = word & 0b11111 + word >>= 5 + blue = word & 0b11111 + return (red, green, blue) + +def grab_palettes(address, length = 0x80): + output = '' + for word in range(length/2): + color = ord(rom[address+1])*0x100 + ord(rom[address]) + address += 2 + color = hex_to_rgb(color) + red = str(color[0]).zfill(2) + green = str(color[1]).zfill(2) + blue = str(color[2]).zfill(2) + output += '\tRGB '+red+', '+green+', '+blue + output += '\n' + return output + + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('cmd', nargs='?', metavar='cmd', type=str) @@ -1317,7 +1339,11 @@ if __name__ == "__main__": # python gfx.py un [address] [num_tiles] [filename] get_uncompressed_gfx(int(args.arg1,16), int(args.arg2), args.arg3) - else: - # python gfx.py - decompress_all() - if debug: print 'decompressed known gfx to ../gfx/!' + elif args.cmd == 'pal': + # python gfx.py pal [address] [length] + print grab_palettes(int(args.arg1,16), int(args.arg2)) + + #else: + ## python gfx.py + #decompress_all() + #if debug: print 'decompressed known gfx to ../gfx/!' diff --git a/extras/pksv.py b/extras/pksv.py index 8f4bafeeb..a73e16db7 100644 --- a/extras/pksv.py +++ b/extras/pksv.py @@ -34,7 +34,7 @@ pksv_gs = { 0x21: "checkitem", 0x22: "givemoney", 0x23: "takemoney", - 0x24: "checkmonkey", + 0x24: "checkmoney", 0x25: "givecoins", 0x26: "takecoins", 0x27: "checkcoins", @@ -179,7 +179,7 @@ pksv_crystal = { 0x21: "checkitem", 0x22: "givemoney", 0x23: "takemoney", - 0x24: "checkmonkey", + 0x24: "checkmoney", 0x25: "givecoins", 0x26: "takecoins", 0x27: "checkcoins", @@ -292,8 +292,9 @@ pksv_crystal = { } #these cause the script to end; used in create_command_classes -pksv_crystal_more_enders = [0x03, 0x04, 0x05, 0x0C, 0x51, 0x53, - 0x8D, 0x8F, 0x90, 0x91, 0x92, 0x9B, +pksv_crystal_more_enders = [0x03, 0x04, 0x05, 0x0C, 0x51, 0x52, + 0x53, 0x8D, 0x8F, 0x90, 0x91, 0x92, + 0x9B, 0xB2, #maybe? 0xCC, #maybe? ] |