예제 #1
0
	def test_can_load_map_pointers(self):
		extractor = map_extractor(rom_path)
		extractor.load_rom()
		extractor.load_map_pointers()

		extract_maps.load_rom()
		extract_maps.load_map_pointers()


		self.assertEqual(extract_maps.map_pointers, extractor.map_pointers)
예제 #2
0
def main():
    parser = argparse.ArgumentParser(
        description='Read map data from Pokemon RGB.')
    parser.add_argument('rom_path', help='The game ROM to be read')
    args = parser.parse_args()

    rom_path = os.path.abspath(args.rom_path)
    print("Using rom path", rom_path)
    print("Loading rom...", extract_maps.load_rom(rom_path))
    extract_maps.load_map_pointers()
    map_headers = extract_maps.read_all_map_headers()

    rom = extract_maps.rom
    map_ids = extract_maps.maps
    maps = get_maps(rom, map_headers)

    squares = defaultdict(dict)

    for map_id, map_dict in maps.items():
        map_dict['name'] = map_ids[map_id].lower().replace(' ', '-')

        grass_blocks, water_blocks = read_map_blocks(map_dict['blocks'])
        map_dict['grass_blocks'] = grass_blocks
        map_dict['water_blocks'] = water_blocks
        grass_squares, water_squares = get_squares(map_dict)

        squares[map_id]['grass'] = grass_squares
        squares[map_id]['water'] = water_squares

        if grass_squares or water_squares:
            write_csv(map_dict['name'], squares[map_id])

    for map_id, map_dict in maps.items():
        print(map_dict['name'])

    return {}
예제 #3
0
            clean_name += "Sprite"

        byte_count = sheet_data["byte_count"]
        if byte_count > 0x40:
            byte_count = 0xc0

        output += "\n\t; " + sprite_constants[sheet_data["sprite_id"]] + "\n"
        output += spacing + "dw " + clean_name + "\n"
        output += spacing + "db $%.2x ; byte count\n" % (byte_count)
        output += spacing + "db BANK(" + clean_name + ")\n"

        used_addresses.append((address, clean_name))

    output += "; 0x17c47"
    return output


if __name__ == "__main__":
    extract_maps.load_rom()
    #extract_maps.load_map_pointers()
    #extract_maps.read_all_map_headers()

    #sprite_namer()
    #load_icons()
    #print_appearances()
    #sprite_printer()

    ptable_sheet_data = parse_sprite_sheet_pointer_table()
    print pretty_print_sheet_incbins(ptable_sheet_data)
    print pretty_print_sheet_data(ptable_sheet_data)
                shift = result / map2_width
                shift += 1
                calculated = map2_blocks_pointer + (map2_width * shift)
                output += "shift: " + str(shift) + "\n"
                formula = map2_cname + "Blocks" + " + (" + map2_cname + "Width * " + str(shift) + ")"
        
        output += "formula: " + formula + "\n"

        result = connected_pointer - calculated
        output += "result: " + str(result) + "\n"

        output += "\n\n"
    
    if in_connection_id != None:
        return formula
    if do_output == True:
        return output

if __name__ == "__main__":
    extract_maps.load_rom()
    extract_maps.load_map_pointers()
    extract_maps.read_all_map_headers()
    
    #trouble:
    #print_connections(13)
    #print_connections(15)
    
    for map_id in extract_maps.map_headers.keys():
        if map_id not in extract_maps.bad_maps:
            print print_connections(map_id, do_output=True)
예제 #5
0
import extract_maps as ex
# import extract_tileblocks

ex.load_rom()

ex.load_map_pointers()

# header attributes
###################
# connections
# address
# referenced_texts
# object_data
# bank
# id
# number_of_referenced_texts
# texts_pointer
# script_pointer
# tileset
# name
# num_connections
# object_data_pointer
# y
# x
# connection_byte
# map_pointer
################
# warp_tos
# warps
# things
# number_of_warps
import extract_maps as ex
# import extract_tileblocks

ex.load_rom()

ex.load_map_pointers()




# header attributes
###################
# connections
# address
# referenced_texts
# object_data
# bank
# id
# number_of_referenced_texts
# texts_pointer
# script_pointer
# tileset
# name
# num_connections
# object_data_pointer
# y
# x
# connection_byte
# map_pointer
################
# warp_tos
def parse_text_script(text_pointer, text_id, map_id, txfar=False):
    global total_text_commands
    offset = text_pointer
    commands = {}
    command_counter = 0

    if extract_maps.rom == None:
        extract_maps.load_rom()
    
    end = False
    while not end:
        command = {}
        command_byte = ord(extract_maps.rom[offset])
        
        print_command_debug_info(command_byte, text_id, text_pointer, map_id)
        if  command_byte == 0:
            #read until $57, $50 or $58
            jump57 = how_many_until(chr(0x57), offset)
            jump50 = how_many_until(chr(0x50), offset)
            jump58 = how_many_until(chr(0x58), offset)
            
            #whichever command comes first
            jump = min([jump57, jump50, jump58])

            end_address = offset + jump - 1 #we want the address before $57

            command = {"type": command_byte,
                       "start_address": offset,
                       "end_address": end_address,
                       "size": jump,
                       "lines": process_00_subcommands(offset+1, end_address),
                      }

            offset += jump
        elif command_byte == 0x17:
            #TX_FAR [pointer][bank]
            pointer_byte1 = ord(extract_maps.rom[offset+1])
            pointer_byte2 = ord(extract_maps.rom[offset+2])
            pointer_bank = ord(extract_maps.rom[offset+3])

            pointer = (pointer_byte1 + (pointer_byte2 << 8))
            pointer = extract_maps.calculate_pointer(pointer, pointer_bank)

            command = {"type": command_byte,
                       "start_address": offset,
                       "end_address": offset + 3, #last byte belonging to this command
                       "pointer": pointer, #parameter
                      }

            offset += 3 + 1
        elif command_byte == 0x50 or command_byte == 0x57 or command_byte == 0x58: #end text
            command = {"type": command_byte,
                       "start_address": offset,
                       "end_address": offset,
                      }

            #this byte simply indicates to end the script
            end = True
            
            #this byte simply indicates to end the script
            if command_byte == 0x50 and ord(extract_maps.rom[offset+1]) == 0x50: #$50$50 means end completely
                end = True
                commands[command_counter+1] = command

                #also save the next byte, before we quit
                commands[command_counter+1]["start_address"] += 1
                commands[command_counter+1]["end_address"] += 1
                add_command_byte_to_totals(command_byte)
            elif command_byte == 0x50: #only end if we started with $0
                if len(commands.keys()) > 0:
                    if commands[0]["type"] == 0x0: end = True
            elif command_byte == 0x57 or command_byte == 0x58: #end completely
                end = True
                offset += 1 #go past this 0x50
        elif command_byte == 0x1:
            #01 = text from RAM. [01][2-byte pointer]
            size = 3 #total size, including the command byte
            pointer_byte1 = ord(extract_maps.rom[offset+1])
            pointer_byte2 = ord(extract_maps.rom[offset+2])
            
            command = {"type": command_byte,
                       "start_address": offset+1,
                       "end_address": offset+2, #last byte belonging to this command
                       "pointer": [pointer_byte1, pointer_byte2], #RAM pointer
                      }
            
            #view near these bytes
            #subsection = extract_maps.rom[offset:offset+size+1] #peak ahead
            #for x in subsection:
            #    print hex(ord(x))
            #print "--"

            offset += 2 + 1 #go to the next byte

            #use this to look at the surrounding bytes
            if debug:
                print "next command is: " + hex(ord(extract_maps.rom[offset])) + " ... we are at command number: " + str(command_counter) + " near " + hex(offset) + " on map_id=" + str(map_id) + " for text_id=" + str(text_id) + " and txfar(recursion)=" + str(txfar)
        elif command_byte == 0x7:
            #07 = shift texts 1 row above (2nd line becomes 1st line); address for next text = 2nd line. [07]
            size = 1
            command = {"type": command_byte,
                       "start_address": offset,
                       "end_address": offset,
                      }
            offset += 1
        elif command_byte == 0x3:
            #03 = set new address in RAM for text. [03][2-byte RAM address]
            size = 3
            command = {"type": command_byte, "start_address": offset, "end_address": offset+2}
            offset += size
        elif command_byte == 0x4: #draw box
            #04 = draw box. [04][2-Byte pointer][height Y][width X]
            size = 5 #including the command
            command = {
                        "type": command_byte,
                        "start_address": offset,
                        "end_address": offset + size,
                        "pointer_bytes": [ord(extract_maps.rom[offset+1]), ord(extract_maps.rom[offset+2])],
                        "y": ord(extract_maps.rom[offset+3]),
                        "x": ord(extract_maps.rom[offset+4]),
                      }
            offset += size + 1
        elif command_byte == 0x5:
            #05 = write text starting at 2nd line of text-box. [05][text][ending command]
            #read until $57, $50 or $58
            jump57 = how_many_until(chr(0x57), offset)
            jump50 = how_many_until(chr(0x50), offset)
            jump58 = how_many_until(chr(0x58), offset)
            
            #whichever command comes first
            jump = min([jump57, jump50, jump58])

            end_address = offset + jump - 1 #we want the address before $57

            command = {"type": command_byte,
                       "start_address": offset,
                       "end_address": end_address,
                       "size": jump,
                       "lines": process_00_subcommands(offset+1, end_address),
                      }
            offset = end_address + 1
        elif command_byte == 0x6:
            #06 = wait for keypress A or B (put blinking arrow in textbox). [06]
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x7:
            #07 = shift texts 1 row above (2nd line becomes 1st line); address for next text = 2nd line. [07]
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x8:
            #08 = asm until whenever
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
            end = True
        elif command_byte == 0x9:
            #09 = write hex-to-dec number from RAM to textbox [09][2-byte RAM address][byte bbbbcccc]
            #  bbbb = how many bytes to read (read number is big-endian)
            #  cccc = how many digits display (decimal)
            #(note: max of decimal digits is 7,i.e. max number correctly displayable is 9999999)
            ram_address_byte1 = ord(extract_maps.rom[offset+1])
            ram_address_byte2 = ord(extract_maps.rom[offset+2])
            read_byte = ord(extract_maps.rom[offset+3])

            command = {
                        "type": command_byte,
                        "address": [ram_address_byte1, ram_address_byte2],
                        "read_byte": read_byte, #split this up when we make a macro for this
                      }

            offset += 4
        elif command_byte == 0xB:
            #0B = sound_86 (Hiro obtains ITEM)[same as 0F]
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xE:
            #0E = sound_91 (learnt something)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xF:
            #0F = sound_86 (given rare candy)[same as 0B]
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x10:
            #10 = sound_89 (PKMN successfully caught)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x11:
            #11 = sound_94 (Hiro gives OAK the PARCEL)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x12:
            #12 = sound_9A (successfully caught)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x13:
            #13 = sound_98 (song heard when "new data will be added for..")
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x14:
            #14 = MonCry (Nidorina)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x15:
            #14 = MonCry (Pidgeot)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x16:
            #14 = MonCry (Dewgong)
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x19:
            #19 = play a 'bump' noise
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x1F:
            #1F = play some pokemon's roar, don't know which..
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x20:
            #20 = oddish roar?
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x3F:
            #3F = some other roar
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x9D:
            #9D = a roar or some other sound, four times in quick succession
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0x76:
            #76 = another roar
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xCA:
            #CA = stop music, start this other song that i can't name
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xF6:
            #F6 = play a 'blurp blurp' noise.. like something is increasing
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xFA:
            #FA = change music to champion song?
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xFE:
            #FE = another roar, kinda glitchy?
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        elif command_byte == 0xFF:
            #FF = change music to a specific song that i don't know the name of
            command = {"type": command_byte, "start_address": offset, "end_address": offset}
            offset += 1
        else:
            #if len(commands) > 0:
            #   print "Unknown text command " + hex(command_byte) + " at " + hex(offset) + ", script began with " + hex(commands[0]["type"])
            if debug:
                print "Unknown text command at " + hex(offset) + " - command: " + hex(ord(extract_maps.rom[offset])) + " on map_id=" + str(map_id) + " text_id=" + str(text_id)
            
            #end at the first unknown command
            end = True
        add_command_byte_to_totals(command_byte)

        commands[command_counter] = command
        command_counter += 1
    total_text_commands += len(commands)
    return commands
예제 #8
0
	def test_can_load_rom(self):
		extract_maps.load_rom()
		rom = extract_maps.rom
		self.assertIsNotNone(rom)		
        load_asm()
    if processed_incbins == {}:
        isolate_incbins()
        process_incbins()
    
    results = []
    ordered_keys = sorted(processed_incbins, key=lambda entry: processed_incbins[entry]["interval"])
    ordered_keys.reverse()
    for key in ordered_keys:
        results.append(processed_incbins[key])

    return results

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

    #insert_map_header_asm(86)
예제 #10
0
        process_incbins()

    results = []
    ordered_keys = sorted(
        processed_incbins,
        key=lambda entry: processed_incbins[entry]["interval"])
    ordered_keys.reverse()
    for key in ordered_keys:
        results.append(processed_incbins[key])

    return results


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

    #insert_map_header_asm(86)
예제 #11
0
def parse_text_script(text_pointer, text_id, map_id, txfar=False):
    global total_text_commands
    offset = text_pointer
    commands = {}
    command_counter = 0

    if extract_maps.rom == None:
        extract_maps.load_rom()

    end = False
    while not end:
        command = {}
        command_byte = ord(extract_maps.rom[offset])

        print_command_debug_info(command_byte, text_id, text_pointer, map_id)
        if command_byte == 0:
            #read until $57, $50 or $58
            jump57 = how_many_until(chr(0x57), offset)
            jump50 = how_many_until(chr(0x50), offset)
            jump58 = how_many_until(chr(0x58), offset)

            #whichever command comes first
            jump = min([jump57, jump50, jump58])

            end_address = offset + jump - 1  #we want the address before $57

            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": end_address,
                "size": jump,
                "lines": process_00_subcommands(offset + 1, end_address),
            }

            offset += jump
        elif command_byte == 0x17:
            #TX_FAR [pointer][bank]
            pointer_byte1 = ord(extract_maps.rom[offset + 1])
            pointer_byte2 = ord(extract_maps.rom[offset + 2])
            pointer_bank = ord(extract_maps.rom[offset + 3])

            pointer = (pointer_byte1 + (pointer_byte2 << 8))
            pointer = extract_maps.calculate_pointer(pointer, pointer_bank)

            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address":
                offset + 3,  #last byte belonging to this command
                "pointer": pointer,  #parameter
            }

            offset += 3 + 1
        elif command_byte == 0x50 or command_byte == 0x57 or command_byte == 0x58:  #end text
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset,
            }

            #this byte simply indicates to end the script
            end = True

            #this byte simply indicates to end the script
            if command_byte == 0x50 and ord(
                    extract_maps.rom[offset +
                                     1]) == 0x50:  #$50$50 means end completely
                end = True
                commands[command_counter + 1] = command

                #also save the next byte, before we quit
                commands[command_counter + 1]["start_address"] += 1
                commands[command_counter + 1]["end_address"] += 1
                add_command_byte_to_totals(command_byte)
            elif command_byte == 0x50:  #only end if we started with $0
                if len(commands.keys()) > 0:
                    if commands[0]["type"] == 0x0: end = True
            elif command_byte == 0x57 or command_byte == 0x58:  #end completely
                end = True
                offset += 1  #go past this 0x50
        elif command_byte == 0x1:
            #01 = text from RAM. [01][2-byte pointer]
            size = 3  #total size, including the command byte
            pointer_byte1 = ord(extract_maps.rom[offset + 1])
            pointer_byte2 = ord(extract_maps.rom[offset + 2])

            command = {
                "type": command_byte,
                "start_address": offset + 1,
                "end_address":
                offset + 2,  #last byte belonging to this command
                "pointer": [pointer_byte1, pointer_byte2],  #RAM pointer
            }

            #view near these bytes
            #subsection = extract_maps.rom[offset:offset+size+1] #peak ahead
            #for x in subsection:
            #    print hex(ord(x))
            #print "--"

            offset += 2 + 1  #go to the next byte

            #use this to look at the surrounding bytes
            if debug:
                print "next command is: " + hex(
                    ord(extract_maps.rom[offset])
                ) + " ... we are at command number: " + str(
                    command_counter
                ) + " near " + hex(offset) + " on map_id=" + str(
                    map_id) + " for text_id=" + str(
                        text_id) + " and txfar(recursion)=" + str(txfar)
        elif command_byte == 0x7:
            #07 = shift texts 1 row above (2nd line becomes 1st line); address for next text = 2nd line. [07]
            size = 1
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset,
            }
            offset += 1
        elif command_byte == 0x3:
            #03 = set new address in RAM for text. [03][2-byte RAM address]
            size = 3
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset + 2
            }
            offset += size
        elif command_byte == 0x4:  #draw box
            #04 = draw box. [04][2-Byte pointer][height Y][width X]
            size = 5  #including the command
            command = {
                "type":
                command_byte,
                "start_address":
                offset,
                "end_address":
                offset + size,
                "pointer_bytes": [
                    ord(extract_maps.rom[offset + 1]),
                    ord(extract_maps.rom[offset + 2])
                ],
                "y":
                ord(extract_maps.rom[offset + 3]),
                "x":
                ord(extract_maps.rom[offset + 4]),
            }
            offset += size + 1
        elif command_byte == 0x5:
            #05 = write text starting at 2nd line of text-box. [05][text][ending command]
            #read until $57, $50 or $58
            jump57 = how_many_until(chr(0x57), offset)
            jump50 = how_many_until(chr(0x50), offset)
            jump58 = how_many_until(chr(0x58), offset)

            #whichever command comes first
            jump = min([jump57, jump50, jump58])

            end_address = offset + jump - 1  #we want the address before $57

            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": end_address,
                "size": jump,
                "lines": process_00_subcommands(offset + 1, end_address),
            }
            offset = end_address + 1
        elif command_byte == 0x6:
            #06 = wait for keypress A or B (put blinking arrow in textbox). [06]
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x7:
            #07 = shift texts 1 row above (2nd line becomes 1st line); address for next text = 2nd line. [07]
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x8:
            #08 = asm until whenever
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
            end = True
        elif command_byte == 0x9:
            #09 = write hex-to-dec number from RAM to textbox [09][2-byte RAM address][byte bbbbcccc]
            #  bbbb = how many bytes to read (read number is big-endian)
            #  cccc = how many digits display (decimal)
            #(note: max of decimal digits is 7,i.e. max number correctly displayable is 9999999)
            ram_address_byte1 = ord(extract_maps.rom[offset + 1])
            ram_address_byte2 = ord(extract_maps.rom[offset + 2])
            read_byte = ord(extract_maps.rom[offset + 3])

            command = {
                "type": command_byte,
                "address": [ram_address_byte1, ram_address_byte2],
                "read_byte":
                read_byte,  #split this up when we make a macro for this
            }

            offset += 4
        elif command_byte == 0xB:
            #0B = sound_86 (Hiro obtains ITEM)[same as 0F]
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xE:
            #0E = sound_91 (learnt something)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xF:
            #0F = sound_86 (given rare candy)[same as 0B]
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x10:
            #10 = sound_89 (PKMN successfully caught)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x11:
            #11 = sound_94 (Hiro gives OAK the PARCEL)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x12:
            #12 = sound_9A (successfully caught)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x13:
            #13 = sound_98 (song heard when "new data will be added for..")
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x14:
            #14 = MonCry (Nidorina)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x15:
            #14 = MonCry (Pidgeot)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x16:
            #14 = MonCry (Dewgong)
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x19:
            #19 = play a 'bump' noise
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x1F:
            #1F = play some pokemon's roar, don't know which..
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x20:
            #20 = oddish roar?
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x3F:
            #3F = some other roar
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x9D:
            #9D = a roar or some other sound, four times in quick succession
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0x76:
            #76 = another roar
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xCA:
            #CA = stop music, start this other song that i can't name
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xF6:
            #F6 = play a 'blurp blurp' noise.. like something is increasing
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xFA:
            #FA = change music to champion song?
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xFE:
            #FE = another roar, kinda glitchy?
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        elif command_byte == 0xFF:
            #FF = change music to a specific song that i don't know the name of
            command = {
                "type": command_byte,
                "start_address": offset,
                "end_address": offset
            }
            offset += 1
        else:
            #if len(commands) > 0:
            #   print "Unknown text command " + hex(command_byte) + " at " + hex(offset) + ", script began with " + hex(commands[0]["type"])
            if debug:
                print "Unknown text command at " + hex(
                    offset) + " - command: " + hex(
                        ord(extract_maps.rom[offset])) + " on map_id=" + str(
                            map_id) + " text_id=" + str(text_id)

            #end at the first unknown command
            end = True
        add_command_byte_to_totals(command_byte)

        commands[command_counter] = command
        command_counter += 1
    total_text_commands += len(commands)
    return commands