Merge pull request #3 from kanzure/proposed-yenatch-master

Proposed merge of kanzure/master into yenatch/master
This commit is contained in:
yenatch 2013-08-30 13:33:09 -07:00
commit 0b36af8da5
41 changed files with 85 additions and 19561 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "extras"]
path = extras
url = git://github.com/kanzure/pokemon-reverse-engineering-tools.git

View File

@ -9,13 +9,10 @@ md5: 9f2922b235a5eeb78d65594e82ef5dde
Save it as **baserom.gbc** in the repository.
Feel free to ask us on
**[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**
if something goes wrong.
# Windows
If you're on Windows and can't install Linux, **Cygwin** is a great alternative.
@ -39,7 +36,6 @@ During the install:
* **python-setuptools**
* **unzip**
## Using Cygwin
Launch the **Cygwin terminal**.
@ -56,7 +52,6 @@ pwd
cd /away/we/go
```
## Getting up and running
We need three things to assemble the source into a rom.
@ -65,8 +60,6 @@ We need three things to assemble the source into a rom.
2. a **pokecrystal** repository
3. a **base rom**
-
We use **rgbds** to spit out a Game Boy rom from source.
```bash
cd /usr/local/bin
@ -96,10 +89,17 @@ md5: 9f2922b235a5eeb78d65594e82ef5dde
Name it **baserom.gbc**.
-
**pokecrystal** only compiles with the use of a git submodule. To activate the submodule type:
```
git submodule init
git submodule update
```
Now you should be able to build **pokecrystal.gbc** for the first time.
This assembles a new rom from the source code.
This compiles a new rom from the source code, with any patches filled in from the base rom.
```bash
make
```
@ -112,8 +112,6 @@ Your first build processes every source file at once.
After that, **only modified source files have to be processed again**,
so compiling again should be a few seconds faster.
# Linux
```bash
@ -131,7 +129,16 @@ cd ..
# download pokecrystal
git clone git://github.com/kanzure/pokecrystal.git
cd pokecrystal
pip install -r requirements.txt
# grab extras/ which is required for compiling
git submodule init
git submodule update
# install python requirements
pip install -r extras/requirements.txt
# use hexdump to diff binary files
git config diff.hex.textconv hexdump
```
Put your base rom in the pokecrystal repository. Name it **baserom.gbc**.
@ -145,7 +152,6 @@ That will take between 3 and 15 seconds, depending on your computer.
If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was successful! Rejoice!
# Now what?
**[pokecrystal.asm](https://github.com/kanzure/pokecrystal/blob/master/pokecrystal.asm)** is a good starting point.
@ -169,3 +175,10 @@ We'll be happy to answer any **questions** on
**[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**.
Other **make targets** that may come in handy:
`make clean` deletes any preprocessed source files (.tx), rgbds object files and pokecrystal.gbc, in case something goes wrong.
`make pngs` decompresses any **lz** files in gfx/ and then exports any graphics files to **png**.
`make lzs` does the reverse. This is already part of the build process, so **modified pngs will automatically be converted to 2bpp and lz-compressed** without any additional work.

View File

@ -7,8 +7,8 @@ PNG_GFX := $(shell find gfx/ -type f -name '*.png')
LZ_GFX := $(shell find gfx/ -type f -name '*.lz')
TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp')
all: pokecrystal.gbc
cmp baserom.gbc $<
all: baserom.gbc pokecrystal.gbc
cmp baserom.gbc pokecrystal.gbc
clean:
rm -f pokecrystal.o pokecrystal.gbc
@echo 'rm -f $(TEXTFILES:.asm=.tx)'
@ -19,27 +19,30 @@ pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constan
.asm.tx:
$(eval TEXTQUEUE := $(TEXTQUEUE) $<)
@rm -f $@
baserom.gbc:
python -c "import os; assert 'baserom.gbc' in os.listdir('.'), 'Wait! Need baserom.gbc first. Check README and INSTALL for details.';"
pokecrystal.gbc: pokecrystal.o
rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<
rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
pngs:
cd extras && python gfx.py mass-decompress && python gfx.py dump-pngs
python extras/pokemontools/gfx.py mass-decompress
python extras/pokemontools/gfx.py dump-pngs
lzs: $(LZ_GFX) $(TWOBPP_GFX)
@:
gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png
python extras/gfx.py png-to-lz --front $^
python extras/pokemontools/gfx.py png-to-lz --front $^
gfx/pics/%/tiles.2bpp: gfx/pics/%/tiles.png
python extras/gfx.py png-to-2bpp $<
python extras/pokemontools/gfx.py png-to-2bpp $<
gfx/pics/%/back.lz: gfx/pics/%/back.png
python extras/gfx.py png-to-lz --vert $<
python extras/pokemontools/gfx.py png-to-lz --vert $<
gfx/trainers/%.lz: gfx/trainers/%.png
python extras/gfx.py png-to-lz --vert $<
python extras/pokemontools/gfx.py png-to-lz --vert $<
.png.lz:
python extras/gfx.py png-to-lz $<
python extras/pokemontools/gfx.py png-to-lz $<
.png.2bpp:
python extras/gfx.py png-to-lz $<
python extras/pokemontools/gfx.py png-to-lz $<

1
extras Submodule

@ -0,0 +1 @@
Subproject commit 016f0206b5029fc83a6200be29b0f980c76dfd90

View File

@ -1,255 +0,0 @@
Pokémon Crystal utilities and extras
==============================
`crystal.py` parses the ROM and provides convenient classes to dump human-readable ASM with the global `to_asm()` method. This ASM can then be compiled back into the original ROM. Currently it parses map headers, "second" map headers, map event headers, map script headers, map triggers, map "callbacks", map blockdata, xy triggers, warps, people-events, texts and scripts.
#### Simple ASM generation example
Note: throughout these examples it is possible to use `reload(crystal)` instead of `import crystal`. Once the module is loaded a first time, it must be reloaded if the file changes and the updates are desired.
```python
import crystal
# parse the ROM
crystal.run_main()
# create a new dump
asm = crystal.Asm()
# insert the first 10 maps
x = 10
asm.insert_with_dependencies(crystal.all_map_headers[:x])
# dump to extras/output.txt
asm.dump()
```
After running those lines, `cp extras/output.txt main.asm` and run `git diff main.asm` to confirm that changes to `main.asm` have occurred. To test whether or not the newly inserted ASM compiles into the same ROM, use: `make clean && make`. This will complain very loudly if something is broken.
#### Testing
Unit tests cover most of the classes.
```bash
python tests.py
```
#### Parsing a script at a known address
Here is a demo of how to investigate a particular script, starting with only an address to a known script (0x58043). In this case, the script calls the `2writetext` command to show some dialog. This dialog will be shown at the end of the example.
```python
import crystal
# parse the script at 0x58043 from the map event header at 0x584c3
# from the second map header at 0x958b8
# from the map header at 0x941ae
# for "Ruins of Alph Outside" (map_group=3 map_id=0x16)
script = Script(0x58043)
# show the script
print script.to_asm()
# what labels does it point to in the to_asm output?
# these must be present in the final asm file for rgbasm to compile the file
objdeps = script.get_dependencies()
print str(objdeps)
# the individual commands that make up the script
commands = script.commands
print str(commands)
# the 3rd command is 2writetext and points to a text
thirdcommand = script.commands[2]
print thirdcommand
# <crystal.2writetextCommand instance at 0x8ad4c0c>
# look at the command parameters
params = thirdcommand.params
print params
# {0: <crystal.RawTextPointerLabelParam instance at 0x8ad4b0c>}
# 2writetext always has a single parameter
definition_param_count = len(getattr(crystal, "2writetextCommand").param_types.keys())
current_param_count = len(params.keys())
assert definition_param_count == current_param_count, "this should never " + \
"happen: instance of a command has more parameters than the " + \
"definition of the command allows"
# get the first parameter (the text pointer)
param = params[0]
print param
# <crystal.RawTextPointerLabelParam instance at 0x8ad4b0c>
# RawTextPointerLabelParam instances point to their text
text = param.text
print text
# <crystal.TextScript instance at 0x8ad47ec>
# now investigate this text appearing in this script in "Ruins of Alph Outside"
print text.to_asm()
```
The final output will be the following text.
```asm
db $0, "Hm? That's a #-", $4f
db "DEX, isn't it?", $55
; ...
```
However, this is not how that `TextScript` object would appear in the final ASM. To see how it would appear in `main.asm` once inserted, you would run `print crystal.to_asm(text)` to get the following.
```asm
UnknownText_0x580c7: ; 0x580c7
db $0, "Hm? That's a #-", $4f
db "DEX, isn't it?", $55
db "May I see it?", $51
db "There are so many", $4f
db "kinds of #MON.", $51
db "Hm? What's this?", $51
db "What is this", $4f
db "#MON?", $51
db "It looks like the", $4f
db "strange writing on", $51
db "the walls of the", $4f
db "RUINS.", $51
db "If those drawings", $4f
db "are really #-", $55
db "MON, there should", $55
db "be many more.", $51
db "I know! Let me up-", $4f
db "grade your #-", $55
db "DEX. Follow me.", $57
; 0x581e5
```
#### Figuring out where a script appears based on a known address
Another approach is to parse the entire ROM, then check a script at a particular address. This has the advantage that the script object will have the `map_group` and `map_id` variables set.
```python
import crystal
# parse the ROM
crystal.run_main()
# get the parsed script
script = crystal.script_parse_table[0x58043]
# read its attributes to figure out map group / map id
map_group = script.map_group
map_id = script.map_id
# MapHeader is not given all the info yet
# in the mean time "map_names" contains some metadata
map_dict = crystal.map_names[map_group][map_id]
map_header = map_dict["header_new"]
print map_dict["name"]
# Ruins of Alph Outside
```
While the above doesn't show this, it turns out that the script at 0x58043 is referenced in the `MapEventHeader` as a person-event.
```python
print map_header.second_map_header.event_header.to_asm()
```
This will show a structure roughly like:
```asm
person_event $3c, 19, 15, $7, $0, 255, 255, $0, 0, UnknownScript_0x58043, $0703
```
within this:
```asm
MapEventHeader_0x584c3: ; 0x584c3
; filler
db 0, 0
; warps
db 11
warp_def $11, $2, 1, GROUP_RUINS_OF_ALPH_HO_OH_CHAMBER, MAP_RUINS_OF_ALPH_HO_OH_CHAMBER
warp_def $7, $e, 1, GROUP_RUINS_OF_ALPH_KABUTO_CHAMBER, MAP_RUINS_OF_ALPH_KABUTO_CHAMBER
warp_def $1d, $2, 1, GROUP_RUINS_OF_ALPH_OMANYTE_CHAMBER, MAP_RUINS_OF_ALPH_OMANYTE_CHAMBER
warp_def $21, $10, 1, GROUP_RUINS_OF_ALPH_AERODACTYL_CHAMBER, MAP_RUINS_OF_ALPH_AERODACTYL_CHAMBER
warp_def $d, $a, 1, GROUP_RUINS_OF_ALPH_INNER_CHAMBER, MAP_RUINS_OF_ALPH_INNER_CHAMBER
warp_def $b, $11, 1, GROUP_RUINS_OF_ALPH_RESEARCH_CENTER, MAP_RUINS_OF_ALPH_RESEARCH_CENTER
warp_def $13, $6, 1, GROUP_UNION_CAVE_B1F, MAP_UNION_CAVE_B1F
warp_def $1b, $6, 2, GROUP_UNION_CAVE_B1F, MAP_UNION_CAVE_B1F
warp_def $5, $7, 3, GROUP_ROUTE_36_RUINS_OF_ALPH_GATE, MAP_ROUTE_36_RUINS_OF_ALPH_GATE
warp_def $14, $d, 1, GROUP_ROUTE_32_RUINS_OF_ALPH_GATE, MAP_ROUTE_32_RUINS_OF_ALPH_GATE
warp_def $15, $d, 2, GROUP_ROUTE_32_RUINS_OF_ALPH_GATE, MAP_ROUTE_32_RUINS_OF_ALPH_GATE
; xy triggers
db 2
xy_trigger 1, $e, $b, $0, UnknownScript_0x58031, $0, $0
xy_trigger 1, $f, $a, $0, UnknownScript_0x5803a, $0, $0
; signposts
db 3
signpost 8, 16, $0, UnknownScript_0x580b1
signpost 16, 12, $0, UnknownScript_0x580b4
signpost 12, 18, $0, UnknownScript_0x580b7
; people-events
db 5
person_event $27, 24, 8, $6, $0, 255, 255, $2, 1, Trainer_0x58089, $ffff
person_event $3c, 19, 15, $7, $0, 255, 255, $0, 0, UnknownScript_0x58043, $0703
person_event $3a, 21, 17, $3, $0, 255, 255, $a0, 0, UnknownScript_0x58061, $078e
person_event $27, 15, 18, $2, $11, 255, 255, $b0, 0, UnknownScript_0x58076, $078f
person_event $27, 12, 16, $7, $0, 255, 255, $80, 0, UnknownScript_0x5807e, $078f
; 0x58560
```
#### Helpful ROM investigation tools
```python
import crystal
# load the bytes
crystal.load_rom()
# get a sequence of bytes
crystal.rom_interval(0x112116, 10)
# ['0x48', '0x54', '0x54', '0x50', '0x2f', '0x31', '0x2e', '0x30', '0xd', '0xa']
crystal.rom_interval(0x112116, 10, strings=False)
# [72, 84, 84, 80, 47, 49, 46, 48, 13, 10]
# get bytes until a certain byte
crystal.rom_until(0x112116, 0x50, strings=False)
# ['0x48', '0x54', '0x54']
# [72, 84, 84]
# or just look at the encoded characters directly
crystal.rom[0x112116:0x112116+10]
# 'HTTP/1.0\r\n'
# look at a text at 0x197186
text = crystal.parse_text_at2(0x197186, 601, debug=False)
print text
```
That last text at 0x197186 will look like:
```python
"""
OAK: Aha! So
you're !
I'm OAK! A #MON
researcher.
I was just visit-
ing my old friend
MR.#MON.
I heard you were
running an errand
for PROF.ELM, so I
waited here.
Oh! What's this?
A rare #MON!
...
"""
```

View File

View File

@ -1,281 +0,0 @@
# -*- coding: utf-8 -*-
from copy import copy
# this is straight out of ../preprocessor.py because i'm lazy
# (also, it's flipped)
# see jap_chars for overrides if you are in japanese mode?
chars = {
0x50: "@",
0x54: "#",
0x75: "",
0x79: "",
0x7A: "",
0x7B: "",
0x7C: "",
0x7D: "",
0x7E: "",
0x74: "",
0x7F: " ",
0x80: "A",
0x81: "B",
0x82: "C",
0x83: "D",
0x84: "E",
0x85: "F",
0x86: "G",
0x87: "H",
0x88: "I",
0x89: "J",
0x8A: "K",
0x8B: "L",
0x8C: "M",
0x8D: "N",
0x8E: "O",
0x8F: "P",
0x90: "Q",
0x91: "R",
0x92: "S",
0x93: "T",
0x94: "U",
0x95: "V",
0x96: "W",
0x97: "X",
0x98: "Y",
0x99: "Z",
0x9A: "(",
0x9B: ")",
0x9C: ":",
0x9D: ";",
0x9E: "[",
0x9F: "]",
0xA0: "a",
0xA1: "b",
0xA2: "c",
0xA3: "d",
0xA4: "e",
0xA5: "f",
0xA6: "g",
0xA7: "h",
0xA8: "i",
0xA9: "j",
0xAA: "k",
0xAB: "l",
0xAC: "m",
0xAD: "n",
0xAE: "o",
0xAF: "p",
0xB0: "q",
0xB1: "r",
0xB2: "s",
0xB3: "t",
0xB4: "u",
0xB5: "v",
0xB6: "w",
0xB7: "x",
0xB8: "y",
0xB9: "z",
0xC0: "Ä",
0xC1: "Ö",
0xC2: "Ü",
0xC3: "ä",
0xC4: "ö",
0xC5: "ü",
0xD0: "'d",
0xD1: "'l",
0xD2: "'m",
0xD3: "'r",
0xD4: "'s",
0xD5: "'t",
0xD6: "'v",
0xE0: "'",
0xE3: "-",
0xE6: "?",
0xE7: "!",
0xE8: ".",
0xE9: "&",
0xEA: "é",
0xEB: "",
0xEC: "",
0xED: "",
0xEE: "",
0xEF: "",
0xF0: "¥",
0xF1: "×",
0xF3: "/",
0xF4: ",",
0xF5: "",
0xF6: "0",
0xF7: "1",
0xF8: "2",
0xF9: "3",
0xFA: "4",
0xFB: "5",
0xFC: "6",
0xFD: "7",
0xFE: "8",
0xFF: "9",
}
#override whatever defaults for japanese symbols
jap_chars = copy(chars)
jap_chars.update({
0x05: "",
0x06: "",
0x07: "",
0x08: "",
0x09: "",
0x0A: "",
0x0B: "",
0x0C: "",
0x0D: "",
0x0E: "",
0x0F: "",
0x10: "",
0x11: "",
0x12: "",
0x13: "",
0x19: "",
0x1A: "",
0x1B: "",
0x1C: "",
0x26: "",
0x27: "",
0x28: "",
0x29: "",
0x2A: "",
0x2B: "",
0x2C: "",
0x2D: "",
0x2E: "",
0x2F: "",
0x30: "",
0x31: "",
0x32: "",
0x33: "",
0x34: "",
0x3A: "",
0x3B: "",
0x3C: "",
0x3D: "",
0x3E: "",
0x40: "",
0x41: "",
0x42: "",
0x43: "",
0x44: "",
0x45: "",
0x46: "",
0x47: "",
0x48: "",
0x80: "",
0x81: "",
0x82: "",
0x83: "",
0x84: "",
0x85: "",
0x86: "",
0x87: "",
0x88: "",
0x89: "",
0x8A: "",
0x8B: "",
0x8C: "",
0x8D: "",
0x8E: "",
0x8F: "",
0x90: "",
0x91: "",
0x92: "",
0x93: "",
0x94: "",
0x95: "",
0x96: "",
0x97: "",
0x98: "",
0x99: "",
0x9A: "",
0x9B: "",
0x9C: "",
0x9D: "",
0x9E: "",
0x9F: "",
0xA0: "",
0xA1: "",
0xA2: "",
0xA3: "",
0xA4: "",
0xA5: "",
0xA6: "",
0xA7: "",
0xA8: "",
0xA9: "",
0xAA: "",
0xAB: "",
0xAC: "",
0xAD: "",
0xAE: "",
0xAF: "",
0xB0: "",
0xB1: "",
0xB2: "",
0xB3: "",
0xB4: "",
0xB5: "",
0xB6: "",
0xB7: "",
0xB8: "",
0xB9: "",
0xBA: "",
0xBB: "",
0xBC: "",
0xBD: "",
0xBE: "",
0xBF: "",
0xC0: "",
0xC1: "",
0xC2: "",
0xC3: "",
0xC4: "",
0xC5: "",
0xC6: "",
0xC7: "",
0xC8: "",
0xC9: "",
0xCA: "",
0xCB: "",
0xCC: "",
0xCD: "",
0xCE: "",
0xCF: "",
0xD0: "",
0xD1: "",
0xD2: "",
0xD3: "",
0xD4: "",
0xD5: "",
0xD6: "",
0xD7: "",
0xD8: "",
0xD9: "",
0xDA: "",
0xDB: "",
0xDC: "",
0xDD: "",
0xDE: "",
0xDF: "",
0xE0: "",
0xE1: "",
0xE2: "",
0xE3: "",
0xE9: "",
})
#some of the japanese characters can probably fit into the english table
#without overriding any of the other mappings.
for key, value in jap_chars.items():
if key not in chars.keys():
chars[key] = value

View File

@ -1,268 +0,0 @@
# -*- coding: utf-8 -*-
"""
Find shared functions between red/crystal.
"""
from crystal import (
get_label_from_line,
get_address_from_line_comment,
AsmSection,
direct_load_rom,
direct_load_asm,
)
from romstr import (
RomStr,
AsmList,
)
def load_rom(path):
"""
Load a ROM file into an abbreviated RomStr object.
"""
return direct_load_rom(filename=path)
def load_asm(path):
"""
Load source ASM into an abbreviated AsmList object.
"""
return direct_load_asm(filename=path)
def findall_iter(sub, string):
# url: http://stackoverflow.com/a/3874760/687783
def next_index(length):
index = 0 - length
while True:
index = string.find(sub, index + length)
yield index
return iter(next_index(len(sub)).next, -1)
class Address(int):
"""
A simple int wrapper to take 0xFFFF and $FFFF addresses.
"""
def __new__(cls, x=None, *args, **kwargs):
if type(x) == str:
if "$" in x:
x = x.replace("$", "0x")
if "0x" in str:
instance = int.__new__(cls, int(x, base=16), *args, **kwargs)
else:
msg = "Address.__new__ doesn't know how to parse this string"
raise Exception, msg
else:
instance = int.__new__(cls, x, *args, **kwargs)
return instance
found_blobs = []
class BinaryBlob(object):
"""
Store a label, line number, and addresses of a function from Pokémon Red.
These details can be used to determine whether or not the function was
copied into Pokémon Crystal.
"""
start_address = None
end_address = None
label = None
line_number = None
bytes = None
bank = None
debug = False
locations = None
def __init__(self, start_address=None, end_address=None, label=None, \
debug=None, line_number=None):
if not isinstance(start_address, Address):
start_address = Address(start_address)
if not isinstance(end_address, Address):
end_address = Address(end_address)
assert label != None, "label can't be none"
assert isinstance(label, str), "label must be a string"
assert line_number != None, "line_number must be provided"
self.start_address = start_address
self.end_address = end_address
self.label = label
self.line_number = line_number
self.bytes = []
self.locations = []
self.bank = start_address / 0x4000
if debug != None:
self.debug = debug
self.parse_from_red()
# self.find_in_crystal()
self.find_by_first_bytes()
def __repr__(self):
"""
A beautiful poem.
"""
r = "BinaryBlob("
r += "label=\""+self.label+"\", "
r += "start_address="+hex(self.start_address)+", "
r += "size="+str(self.end_address - self.start_address)+", "
locnum = len(self.locations)
if locnum == 1:
r += "located="+hex(self.locations[0])
elif locnum <= 5:
r += "located="+str([hex(x) for x in self.locations])
else:
r += "located="+str(locnum)
r += ")"
return r
def __str__(self):
return self.__repr__()
def parse_from_red(self):
"""
Read bytes from Pokémon Red and stores them.
"""
self.bytes = redrom[self.start_address : self.end_address + 1]
def pretty_bytes(self):
"""
Returns a better looking range of bytes.
"""
bytes = redrom.interval(self.start_address, \
self.end_address - self.start_address, \
strings=False, debug=True)
return bytes
def find_in_crystal(self):
"""
Check whether or not the bytes appear in Pokémon Crystal.
"""
finditer = findall_iter(self.bytes, cryrom)
self.locations = [match for match in finditer]
if len(self.locations) > 0:
found_blobs.append(self)
if self.debug:
print self.label + ": found " + str(len(self.locations)) + " matches."
def find_by_first_bytes(self):
"""
Find this blob in Crystal based on the first n bytes.
"""
# how many bytes to match
first_n = 3
# no match
if len(self.bytes) <= first_n:
return
finditer = findall_iter(self.bytes[0:first_n], cryrom)
self.locations = [match for match in finditer]
# filter out locations that suck
self.locations = [i for i in self.locations if abs(self.start_address - i) <= 0x8000]
if len(self.locations) > 0:
found_blobs.append(self)
if self.debug:
print self.label + ": found " + str(len(self.locations)) + " matches."
pokecrystal_rom_path = "../baserom.gbc"
pokecrystal_src_path = "../main.asm"
pokered_rom_path = "../pokered-baserom.gbc"
pokered_src_path = "../pokered-main.asm"
cryrom = load_rom(pokecrystal_rom_path)
crysrc = load_asm(pokecrystal_src_path)
redrom = load_rom(pokered_rom_path)
redsrc = load_asm(pokered_src_path)
def scan_red_asm(bank_stop=3, debug=True):
"""
Scan the ASM from Pokémon Red. Finds labels and objects. Does things.
Uses get_label_from_line and get_address_from_line_comment.
"""
# whether or not to show the lines from redsrc
show_lines = False
line_number = 0
current_bank = 0
current_label = None
latest_label = "ignore me"
current_start_address = None
latest_start_address = 0
latest_line = ""
for line in redsrc:
if debug and show_lines:
print "processing a line from red: " + line
if line[0:7] == "SECTION":
thing = AsmSection(line)
current_bank = thing.bank_id
if debug:
print "scan_red_asm: switching to bank " + str(current_bank)
elif line[0:6] != "INCBIN":
if ":" in line and not ";XXX:" in line and not " ; XXX:" in line:
current_label = get_label_from_line(line)
current_start_address = get_address_from_line_comment(line, \
bank=current_bank)
if current_label != None and current_start_address != None and latest_start_address != None \
and current_start_address != 0 and current_start_address != latest_start_address \
and (current_start_address - latest_start_address) > 1:
if latest_label != None:
if latest_label not in ["Char52", "PokeCenterSignText", "DefaultNamesPlayer", "Unnamed_6a12"]:
blob = BinaryBlob(label=latest_label, \
start_address=latest_start_address, \
end_address=current_start_address, \
line_number=line_number)
if debug:
print "Created a new blob: " + str(blob) + " from line: " + str(latest_line)
latest_label = current_label
latest_start_address = current_start_address
latest_line = line
line_number += 1
if current_bank == bank_stop:
if debug:
print "scan_red_asm: stopping because current_bank >= " + \
str(bank_stop) + " (bank_stop)"
break
scan_red_asm(bank_stop=3)
print "================================"
for blob in found_blobs:
print blob
print "Found " + str(len(found_blobs)) + " possibly copied functions."
print [hex(x) for x in found_blobs[10].locations]

File diff suppressed because it is too large Load Diff

View File

@ -1,151 +0,0 @@
# -*- encoding: utf-8 -*-
"""
Dump out asm for scripting things in bank $25. This script will modify main.asm
and insert all scripting commands.
"""
import crystal
from gbz80disasm import output_bank_opcodes
rom = crystal.load_rom()
roml = [ord(x) for x in rom]
script_command_table_address = 0x96cb1
script_command_count = 170
# a list of addresses for each script command
command_pointers = [crystal.calculate_pointer_from_bytes_at(script_command_table_address + (id * 2), bank=0x25) for id in range(0, 170)]
# a list of hex addresses for each script command in bank $25
command_pointers_hex = ["$%.2x" % (x % 0x4000 + 0x4000) for x in command_pointers]
commands = {}
# force data into a more usable form
for command in crystal.command_classes:
name = "Script_" + command.macro_name
id = command.id
params = {}
for (id2, param_type) in command.param_types.items():
param = {
"name": param_type["name"],
"type": param_type["class"].__name__,
}
params[id2] = param
if id <= 0xa9:
commands[id] = {
"name": name,
"params": params,
"address": command_pointers[id],
}
avoid = [
0x974b0,
0x974be,
0x9754b,
0x97556,
0x97562,
0x9756e,
0x97540,
0x96f8e, # verbosegiveitem2
]
class DisassembledScriptCommand():
"""
Just a temporary object to store information about a script command's asm.
This is used by some of the infrastructure in crystal.py to automatically
insert asm into main.asm, rather than having someone do it manually.
"""
dependencies = None
def __init__(self, label=None, id=None, address=None, params=None):
self.id = id
self.label = crystal.Label(name=label, address=address, object=self)
self.address = address
self.params = params
max_byte_count = 0x4000
# Some of these scripts need to be truncated before insertion, because
# output_bank_opcodes doesn't know anything about stopping if some of
# the local labels are not resolved yet.
# Script_if_equal
if address == 0x97540:
max_byte_count = 86
# disassemble and laso get the last address
(asm, last_address, last_hl_address, last_a_address, used_3d97) = output_bank_opcodes(address, max_byte_count=max_byte_count, stop_at=command_pointers, include_last_address=False)
# remove indentation
asm = asm.replace("\n\t", "\n")
if asm[0] == "\t":
asm = asm[1:]
# remove the last two newlines
while asm[-1] == "\n":
asm = asm[:-1]
self.asm = asm
self.last_address = last_address
# make sure this gets dumped into main.asm
#if crystal.script_parse_table[self.address] == None and crystal.script_parse_table[self.last_address] == None:
crystal.script_parse_table[self.address : self.last_address] = self
#else:
# print ".. hm, something is already at " + hex(self.address) + " for " + self.label.name
def to_asm(self):
#output += self.label + ": ; " + hex(self.address) + "\n"
output = "; script command " + hex(self.id) + "\n"
if len(self.params) > 0:
output += "; parameters:\n"
for (id2, param) in self.params.items():
output += "; " + param["name"] + " (" + param["type"] + ")\n"
output += "\n"
output += self.asm
return output
def get_dependencies(*args, **kwargs):
return []
# make instances of DisassembledScriptCommand
for (id, command) in commands.items():
name = command["name"]
params = command["params"]
address = command["address"]
script_asm = DisassembledScriptCommand(label=name, id=id, address=address, params=params)
#print script_asm.to_asm()
#print crystal.to_asm(script_asm, use_asm_rules=True)
class ScriptCommandTable():
address = script_command_table_address
last_address = script_command_table_address + (2 * 170)
dependencies = None
def __init__(self):
self.label = crystal.Label(name="ScriptCommandTable", address=self.address, object=self)
# make sure this gets dumped into main.asm
crystal.script_parse_table[self.address : self.last_address] = self
def get_dependencies(*args, **kwargs):
return []
def to_asm(self):
output = ""
for (id, command) in commands.items():
output += "dw " + command["name"] + "; " + hex(command["address"]) + "\n"
if output[-1] == "\n":
output = output[:-1]
return output
script_command_table = ScriptCommandTable()
#print crystal.to_asm(script_command_table, use_asm_rules=True)
# automatic asm insertion
asm = crystal.Asm()
asm.insert_and_dump(limit=500)

View File

@ -1,14 +0,0 @@
#!/bin/bash
# This wraps dump_sections.py so that other python scripts can import the
# functions. If dump_sections.py was instead called dump_sections, then other
# python source code would be unable to use the functions via import
# statements.
# figure out the path to this script
cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# construct the path to dump_sections.py
secpath=$cwd/dump_sections.py
# run dump_sections.py
$secpath $1

View File

@ -1,130 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Use this tool to dump an asm file for a new source code or disassembly project.
usage:
from dump_sections import dump_sections
output = dump_sections("../../butt.gbc")
file_handler = open("main.asm", "w")
file_handler.write(output)
file_handler.close()
You can also use this script from the shell, where it will look for
"baserom.gbc" in the current working path or whatever file path you pass in the
first positional argument.
"""
import os
import sys
import argparse
def upper_hex(input):
"""
Converts the input to an uppercase hex string.
"""
if input in [0, "0"]:
return "0"
elif input <= 0xF:
return ("%.x" % (input)).upper()
else:
return ("%.2x" % (input)).upper()
def format_bank_number(address, bank_size=0x4000):
"""
Returns a str of the hex number of the bank based on the address.
"""
return upper_hex(address / bank_size)
def calculate_bank_quantity(path, bank_size=0x4000):
"""
Returns the number of 0x4000 banks in the file at path.
"""
return float(os.lstat(path).st_size) / bank_size
def dump_section(bank_number, separator="\n\n"):
"""
Returns a str of a section header for the asm file.
"""
output = "SECTION \""
if bank_number in [0, "0"]:
output += "bank0\",HOME"
else:
output += "bank"
output += bank_number
output += "\",DATA,BANK[$"
output += bank_number
output += "]"
output += separator
return output
def dump_incbin_for_section(address, bank_size=0x4000, baserom="baserom.gbc", separator="\n\n"):
"""
Returns a str for an INCBIN line for an entire section.
"""
output = "INCBIN \""
output += baserom
output += "\",$"
output += upper_hex(address)
output += ",$"
output += upper_hex(bank_size)
output += separator
return output
def dump_sections(path, bank_size=0x4000, initial_bank=0, last_bank=None, separator="\n\n"):
"""
Returns a str of assembly source code. The source code delineates each
SECTION and includes bytes from the file specified by baserom.
"""
if not last_bank:
last_bank = calculate_bank_quantity(path, bank_size=bank_size)
if last_bank < initial_bank:
raise Exception("last_bank must be greater than or equal to initial_bank")
baserom_name = os.path.basename(path)
output = ""
banks = range(initial_bank, last_bank)
for bank_number in banks:
address = bank_number * bank_size
# get a formatted hex number of the bank based on the address
formatted_bank_number = format_bank_number(address, bank_size=bank_size)
# SECTION
output += dump_section(formatted_bank_number, separator=separator)
# INCBIN a range of bytes from the ROM
output += dump_incbin_for_section(address, bank_size=bank_size, baserom=baserom_name, separator=separator)
# clean up newlines at the end of the output
if output[-2:] == "\n\n":
output = output[:-2]
output += "\n"
return output
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("rompath", nargs="?", metavar="rompath", type=str)
args = parser.parse_args()
# default to "baserom.gbc" in the current working directory
baserom = "baserom.gbc"
# but let the user override the default
if args.rompath:
baserom = args.rompath
# generate some asm
output = dump_sections(baserom)
# dump everything to stdout
sys.stdout.write(output)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,169 +0,0 @@
# -*- coding: utf-8 -*-
import networkx as nx
from romstr import (
RomStr,
relative_jumps,
call_commands,
relative_unconditional_jumps,
)
class RomGraph(nx.DiGraph):
"""
Graphs various functions pointing to each other.
TODO: Bank switches are nasty. They should be detected. Otherwise,
functions will point to non-functions within the same bank. Another way
to detect bankswitches is retroactively. By disassembling one function
after another within the function banks, it can be roughly assumed that
anything pointing to something else (within the same bank) is really
actually a bankswitch. An even better method to handle bankswitches
would be to just detect those situations in the asm (but I presently
forget how bankswitches are performed in pokecrystal).
"""
# some areas shouldn't be parsed as asm
exclusions = []
# where is the first function located?
start_address = 0x150
# and where is a good place to stop?
end_address = 0x4000 * 0x03 # only do the first bank? sure..
# where is the rom stored?
rompath = "../baserom.gbc"
def __init__(self, rom=None, **kwargs):
"""
Loads and parses the ROM into a function graph.
"""
# continue the initialization
nx.DiGraph.__init__(self, **kwargs)
# load the graph
if rom == None:
self.load_rom()
else:
self.rom = rom
# start parsing the ROM
self.parse()
def load_rom(self):
"""
Creates a RomStr from rompath.
"""
file_handler = open(self.rompath, "r")
self.rom = RomStr(file_handler.read())
file_handler.close()
def parse(self):
"""
Parses the ROM starting with the first function address. Each
function is disassembled and parsed to find where else it leads to.
"""
functions = {}
address = self.start_address
other_addresses = set()
count = 0
while True:
if count > 3000:
break
if address < self.end_address and (address not in functions.keys()) and address >= 0x150:
# address is okay to parse at, keep going
pass
elif len(other_addresses) > 0:
# parse some other address possibly in a remote bank
address = other_addresses.pop()
else:
# no more addresses detected- exit loop
break
# parse the asm
func = self.rom.to_asm(address)
# check if there are any nops (probably not a function)
nops = 0
for (id, command) in func.asm_commands.items():
if command.has_key("id") and command["id"] == 0x0:
nops += 1
# skip this function
if nops > 1:
address = 0
continue
# store this parsed function
functions[address] = func
# where does this function jump to?
used_addresses = set(func.used_addresses())
# add this information to the graph
for used_address in used_addresses:
# only add this remote address if it's not yet parsed
if used_address not in functions.keys():
other_addresses.update([used_address])
# add this other address to the graph
if used_address > 100:
self.add_node(used_address)
# add this as an edge between the two nodes
self.add_edge(address, used_address)
# setup the next function to be parsed
address = func.last_address
count += 1
self.functions = functions
def pretty_printer(self):
"""
Shows some text output describing which nodes point to which other
nodes.
"""
print self.edges()
def to_d3(self):
"""
Exports to d3.js because we're gangster like that.
"""
import networkx.readwrite.json_graph as json_graph
content = json_graph.dumps(self)
fh = open("crystal/crystal.json", "w")
fh.write(content)
fh.close()
def to_gephi(self):
"""
Generates a gexf file.
"""
nx.write_gexf(self, "graph.gexf")
class RedGraph(RomGraph):
"""
Not implemented. Go away.
"""
rompath = "../pokered-baserom.gbc"
class CryGraph(RomGraph):
exclusions = [
[0x000, 0x149],
]
rompath = "../baserom.gbc"
if __name__ == "__main__":
crygraph = CryGraph()
crygraph.pretty_printer()
crygraph.to_gephi()

View File

@ -1,104 +0,0 @@
# -*- coding: utf-8 -*-
from bisect import bisect_left, bisect_right
from itertools import izip
class IntervalMap(object):
"""
This class maps a set of intervals to a set of values.
>>> i = IntervalMap()
>>> i[0:5] = "hello world"
>>> i[6:10] = "hello cruel world"
>>> print i[4]
"hello world"
"""
def __init__(self):
"""initializes an empty IntervalMap"""
self._bounds = []
self._items = []
self._upperitem = None
def __setitem__(self, _slice, _value):
"""sets an interval mapping"""
assert isinstance(_slice, slice), 'The key must be a slice object'
if _slice.start is None:
start_point = -1
else:
start_point = bisect_left(self._bounds, _slice.start)
if _slice.stop is None:
end_point = -1
else:
end_point = bisect_left(self._bounds, _slice.stop)
if start_point>=0:
if start_point < len(self._bounds) and self._bounds[start_point]<_slice.start:
start_point += 1
if end_point>=0:
self._bounds[start_point:end_point] = [_slice.start, _slice.stop]
if start_point < len(self._items):
self._items[start_point:end_point] = [self._items[start_point], _value]
else:
self._items[start_point:end_point] = [self._upperitem, _value]
else:
self._bounds[start_point:] = [_slice.start]
if start_point < len(self._items):
self._items[start_point:] = [self._items[start_point], _value]
else:
self._items[start_point:] = [self._upperitem]
self._upperitem = _value
else:
if end_point>=0:
self._bounds[:end_point] = [_slice.stop]
self._items[:end_point] = [_value]
else:
self._bounds[:] = []
self._items[:] = []
self._upperitem = _value
def __getitem__(self,_point):
"""gets a value from the mapping"""
assert not isinstance(_point, slice), 'The key cannot be a slice object'
index = bisect_right(self._bounds, _point)
if index < len(self._bounds):
return self._items[index]
else:
return self._upperitem
def items(self):
"""returns an iterator with each item being
((low_bound, high_bound), value)
these items are returned in order"""
previous_bound = None
for (b, v) in izip(self._bounds, self._items):
if v is not None:
yield (previous_bound, b), v
previous_bound = b
if self._upperitem is not None:
yield (previous_bound, None), self._upperitem
def values(self):
"""returns an iterator with each item being a stored value
the items are returned in order"""
for v in self._items:
if v is not None:
yield v
if self._upperitem is not None:
yield self._upperitem
def __repr__(self):
s = []
for b,v in self.items():
if v is not None:
s.append('[%r, %r] => %r'%(
b[0],
b[1],
v
))
return '{'+', '.join(s)+'}'

View File

@ -1,241 +0,0 @@
# -*- coding: utf-8 -*-
item_constants = {
1: 'MASTER_BALL',
2: 'ULTRA_BALL',
3: 'BRIGHTPOWDER',
4: 'GREAT_BALL',
5: 'POKE_BALL',
7: 'BICYCLE',
8: 'MOON_STONE',
9: 'ANTIDOTE',
10: 'BURN_HEAL',
11: 'ICE_HEAL',
12: 'AWAKENING',
13: 'PARLYZ_HEAL',
14: 'FULL_RESTORE',
15: 'MAX_POTION',
16: 'HYPER_POTION',
17: 'SUPER_POTION',
18: 'POTION',
19: 'ESCAPE_ROPE',
20: 'REPEL',
21: 'MAX_ELIXER',
22: 'FIRE_STONE',
23: 'THUNDERSTONE',
24: 'WATER_STONE',
26: 'HP_UP',
27: 'PROTEIN',
28: 'IRON',
29: 'CARBOS',
30: 'LUCKY_PUNCH',
31: 'CALCIUM',
32: 'RARE_CANDY',
33: 'X_ACCURACY',
34: 'LEAF_STONE',
35: 'METAL_POWDER',
36: 'NUGGET',
37: 'POKE_DOLL',
38: 'FULL_HEAL',
39: 'REVIVE',
40: 'MAX_REVIVE',
41: 'GUARD_SPEC',
42: 'SUPER_REPEL',
43: 'MAX_REPEL',
44: 'DIRE_HIT',
46: 'FRESH_WATER',
47: 'SODA_POP',
48: 'LEMONADE',
49: 'X_ATTACK',
51: 'X_DEFEND',
52: 'X_SPEED',
53: 'X_SPECIAL',
54: 'COIN_CASE',
55: 'ITEMFINDER',
57: 'EXP_SHARE',
58: 'OLD_ROD',
59: 'GOOD_ROD',
60: 'SILVER_LEAF',
61: 'SUPER_ROD',
62: 'PP_UP',
63: 'ETHER',
64: 'MAX_ETHER',
65: 'ELIXER',
66: 'RED_SCALE',
67: 'SECRETPOTION',
68: 'S_S_TICKET',
69: 'MYSTERY_EGG',
70: 'CLEAR_BELL',
71: 'SILVER_WING',
72: 'MOOMOO_MILK',
73: 'QUICK_CLAW',
74: 'PSNCUREBERRY',
75: 'GOLD_LEAF',
76: 'SOFT_SAND',
77: 'SHARP_BEAK',
78: 'PRZCUREBERRY',
79: 'BURNT_BERRY',
80: 'ICE_BERRY',
81: 'POISON_BARB',
82: "KINGS_ROCK",
83: 'BITTER_BERRY',
84: 'MINT_BERRY',
85: 'RED_APRICORN',
86: 'TINYMUSHROOM',
87: 'BIG_MUSHROOM',
88: 'SILVERPOWDER',
89: 'BLU_APRICORN',
91: 'AMULET_COIN',
92: 'YLW_APRICORN',
93: 'GRN_APRICORN',
94: 'CLEANSE_TAG',
95: 'MYSTIC_WATER',
96: 'TWISTEDSPOON',
97: 'WHT_APRICORN',
98: 'BLACKBELT',
99: 'BLK_APRICORN',
101: 'PNK_APRICORN',
102: 'BLACKGLASSES',
103: 'SLOWPOKETAIL',
104: 'PINK_BOW',
105: 'STICK',
106: 'SMOKE_BALL',
107: 'NEVERMELTICE',
108: 'MAGNET',
109: 'MIRACLEBERRY',
110: 'PEARL',
111: 'BIG_PEARL',
112: 'EVERSTONE',
113: 'SPELL_TAG',
114: 'RAGECANDYBAR',
115: 'GS_BALL',
116: 'BLUE_CARD',
117: 'MIRACLE_SEED',
118: 'THICK_CLUB',
119: 'FOCUS_BAND',
121: 'ENERGYPOWDER',
122: 'ENERGY_ROOT',
123: 'HEAL_POWDER',
124: 'REVIVAL_HERB',
125: 'HARD_STONE',
126: 'LUCKY_EGG',
127: 'CARD_KEY',
128: 'MACHINE_PART',
129: 'EGG_TICKET',
130: 'LOST_ITEM',
131: 'STARDUST',
132: 'STAR_PIECE',
133: 'BASEMENT_KEY',
134: 'PASS',
138: 'CHARCOAL',
139: 'BERRY_JUICE',
140: 'SCOPE_LENS',
143: 'METAL_COAT',
144: 'DRAGON_FANG',
146: 'LEFTOVERS',
150: 'MYSTERYBERRY',
151: 'DRAGON_SCALE',
152: 'BERSERK_GENE',
156: 'SACRED_ASH',
157: 'HEAVY_BALL',
158: 'FLOWER_MAIL',
159: 'LEVEL_BALL',
160: 'LURE_BALL',
161: 'FAST_BALL',
163: 'LIGHT_BALL',
164: 'FRIEND_BALL',
165: 'MOON_BALL',
166: 'LOVE_BALL',
167: 'NORMAL_BOX',
168: 'GORGEOUS_BOX',
169: 'SUN_STONE',
170: 'POLKADOT_BOW',
172: 'UP_GRADE',
173: 'BERRY',
174: 'GOLD_BERRY',
175: 'SQUIRTBOTTLE',
177: 'PARK_BALL',
178: 'RAINBOW_WING',
180: 'BRICK_PIECE',
181: 'SURF_MAIL',
182: 'LITEBLUEMAIL',
183: 'PORTRAITMAIL',
184: 'LOVELY_MAIL',
185: 'EON_MAIL',
186: 'MORPH_MAIL',
187: 'BLUESKY_MAIL',
188: 'MUSIC_MAIL',
189: 'MIRAGE_MAIL',
191: 'TM_01',
192: 'TM_02',
193: 'TM_03',
194: 'TM_04',
196: 'TM_05',
197: 'TM_06',
198: 'TM_07',
199: 'TM_08',
200: 'TM_09',
201: 'TM_10',
202: 'TM_11',
203: 'TM_12',
204: 'TM_13',
205: 'TM_14',
206: 'TM_15',
207: 'TM_16',
208: 'TM_17',
209: 'TM_18',
210: 'TM_19',
211: 'TM_20',
212: 'TM_21',
213: 'TM_22',
214: 'TM_23',
215: 'TM_24',
216: 'TM_25',
217: 'TM_26',
218: 'TM_27',
219: 'TM_28',
221: 'TM_29',
222: 'TM_30',
223: 'TM_31',
224: 'TM_32',
225: 'TM_33',
226: 'TM_34',
227: 'TM_35',
228: 'TM_36',
229: 'TM_37',
230: 'TM_38',
231: 'TM_39',
232: 'TM_40',
233: 'TM_41',
234: 'TM_42',
235: 'TM_43',
236: 'TM_44',
237: 'TM_45',
238: 'TM_46',
239: 'TM_47',
240: 'TM_48',
241: 'TM_49',
242: 'TM_50',
243: 'HM_01',
244: 'HM_02',
245: 'HM_03',
246: 'HM_04',
247: 'HM_05',
248: 'HM_06',
249: 'HM_07',
}
def find_item_label_by_id(id):
if id in item_constants.keys():
return item_constants[id]
else: return None
def generate_item_constants():
"""make a list of items to put in constants.asm"""
output = ""
for (id, item) in item_constants.items():
val = ("$%.2x"%id).upper()
while len(item)<13: item+= " "
output += item + " EQU " + val + "\n"
return output

View File

@ -1,172 +0,0 @@
# -*- coding: utf-8 -*-
"""
Various label/line-related functions.
"""
from pointers import (
calculate_pointer,
calculate_bank,
)
def remove_quoted_text(line):
"""get rid of content inside quotes
and also removes the quotes from the input string"""
while line.count("\"") % 2 == 0 and line.count("\"") > 0:
first = line.find("\"")
second = line.find("\"", first+1)
line = line[0:first] + line[second+1:]
while line.count("\'") % 2 == 0 and line.count("'") > 0:
first = line.find("\'")
second = line.find("\'", first+1)
line = line[0:first] + line[second+1:]
return line
def line_has_comment_address(line, returnable={}, bank=None):
"""checks that a given line has a comment
with a valid address, and returns the address in the object.
Note: bank is required if you have a 4-letter-or-less address,
because otherwise there is no way to figure out which bank
is curretly being scanned."""
#first set the bank/offset to nada
returnable["bank"] = None
returnable["offset"] = None
returnable["address"] = None
#only valid characters are 0-9a-fA-F
valid = [str(x) for x in range(10)] + \
[chr(x) for x in range(ord('a'), ord('f')+1)] + \
[chr(x) for x in range(ord('A'), ord('F')+1)]
#check if there is a comment in this line
if ";" not in line:
return False
#first throw away anything in quotes
if (line.count("\"") % 2 == 0 and line.count("\"")!=0) \
or (line.count("\'") % 2 == 0 and line.count("\'")!=0):
line = remove_quoted_text(line)
#check if there is still a comment in this line after quotes removed
if ";" not in line:
return False
#but even if there's a semicolon there must be later text
if line[-1] == ";":
return False
#and just a space doesn't count
if line[-2:] == "; ":
return False
#and multiple whitespace doesn't count either
line = line.rstrip(" ").lstrip(" ")
if line[-1] == ";":
return False
#there must be more content after the semicolon
if len(line)-1 == line.find(";"):
return False
#split it up into the main comment part
comment = line[line.find(";")+1:]
#don't want no leading whitespace
comment = comment.lstrip(" ").rstrip(" ")
#split up multi-token comments into single tokens
token = comment
if " " in comment:
#use the first token in the comment
token = comment.split(" ")[0]
if token in ["0x", "$", "x", ":"]:
return False
offset = None
#process a token with a A:B format
if ":" in token: #3:3F0A, $3:$3F0A, 0x3:0x3F0A, 3:3F0A
#split up the token
bank_piece = token.split(":")[0].lower()
offset_piece = token.split(":")[1].lower()
#filter out blanks/duds
if bank_piece in ["$", "0x", "x"] \
or offset_piece in ["$", "0x", "x"]:
return False
#they can't have both "$" and "x"
if "$" in bank_piece and "x" in bank_piece:
return False
if "$" in offset_piece and "x" in offset_piece:
return False
#process the bank piece
if "$" in bank_piece:
bank_piece = bank_piece.replace("$", "0x")
#check characters for validity?
for c in bank_piece.replace("x", ""):
if c not in valid:
return False
bank = int(bank_piece, 16)
#process the offset piece
if "$" in offset_piece:
offset_piece = offset_piece.replace("$", "0x")
#check characters for validity?
for c in offset_piece.replace("x", ""):
if c not in valid:
return False
if len(offset_piece) == 0:
return None
offset = int(offset_piece, 16)
#filter out blanks/duds
elif token in ["$", "0x", "x"]:
return False
#can't have both "$" and "x" in the number
elif "$" in token and "x" in token:
return False
elif "x" in token and not "0x" in token: #it should be 0x
return False
elif "$" in token and not "x" in token:
token = token.replace("$", "0x")
offset = int(token, 16)
elif "0x" in token and not "$" in token:
offset = int(token, 16)
else: #might just be "1" at this point
token = token.lower()
#check if there are bad characters
for c in token:
if c not in valid:
return False
offset = int(token, 16)
if offset == None and bank == None:
return False
if bank == None:
bank = calculate_bank(offset)
returnable["bank"] = bank
returnable["offset"] = offset
returnable["address"] = calculate_pointer(offset, bank=bank)
return True
def get_address_from_line_comment(line, bank=None):
"""
wrapper for line_has_comment_address
"""
returnable = {}
result = line_has_comment_address(line, returnable=returnable, bank=bank)
if not result:
return False
return returnable["address"]
def line_has_label(line):
"""returns True if the line has an asm label"""
if not isinstance(line, str):
raise Exception, "can't check this type of object"
line = line.rstrip(" ").lstrip(" ")
line = remove_quoted_text(line)
if ";" in line:
line = line.split(";")[0]
if 0 <= len(line) <= 1:
return False
if ":" not in line:
return False
if line[0] == ";":
return False
if line[0] == "\"":
return False
if "::" in line:
return False
return True
def get_label_from_line(line):
"""returns the label from the line"""
#check if the line has a label
if not line_has_label(line):
return None
#split up the line
label = line.split(":")[0]
return label

View File

@ -1,484 +0,0 @@
# -*- coding: utf-8 -*-
# this is modified in crystal.py during run-time
map_names = {
1: {
0x1: {"name": "Olivine Pokémon Center 1F",
"label": "OlivinePokeCenter1F"},
0x2: {"name": "Olivine Gym"},
0x3: {"name": "Olivine Voltorb House"},
0x4: {"name": "Olivine House Beta"},
0x5: {"name": "Olivine Punishment Speech House"},
0x6: {"name": "Olivine Good Rod House"},
0x7: {"name": "Olivine Cafe"},
0x8: {"name": "Olivine Mart"},
0x9: {"name": "Route 38 Ecruteak Gate"},
0xA: {"name": "Route 39 Barn"},
0xB: {"name": "Route 39 Farmhouse"},
0xC: {"name": "Route 38"},
0xD: {"name": "Route 39"},
0xE: {"name": "Olivine City"},
},
2: {
0x1: {"name": "Mahogany Red Gyarados Speech House"},
0x2: {"name": "Mahogany Gym"},
0x3: {"name": "Mahogany Pokémon Center 1F",
"label": "MahoganyPokeCenter1F"},
0x4: {"name": "Route 42 Ecruteak Gate"},
0x5: {"name": "Route 42"},
0x6: {"name": "Route 44"},
0x7: {"name": "Mahogany Town"},
},
3: {
0x1: {"name": "Sprout Tower 1F"},
0x2: {"name": "Sprout Tower 2F"},
0x3: {"name": "Sprout Tower 3F"},
0x4: {"name": "Tin Tower 1F"},
0x5: {"name": "Tin Tower 2F"},
0x6: {"name": "Tin Tower 3F"},
0x7: {"name": "Tin Tower 4F"},
0x8: {"name": "Tin Tower 5F"},
0x9: {"name": "Tin Tower 6F"},
0xA: {"name": "Tin Tower 7F"},
0xB: {"name": "Tin Tower 8F"},
0xC: {"name": "Tin Tower 9F"},
0xD: {"name": "Burned Tower 1F"},
0xE: {"name": "Burned Tower B1F"},
0xF: {"name": "National Park"},
0x10: {"name": "National Park Bug Contest"},
0x11: {"name": "Radio Tower 1F"},
0x12: {"name": "Radio Tower 2F"},
0x13: {"name": "Radio Tower 3F"},
0x14: {"name": "Radio Tower 4F"},
0x15: {"name": "Radio Tower 5F"},
0x16: {"name": "Ruins of Alph Outside"},
0x17: {"name": "Ruins of Alph Ho-oh Chamber"},
0x18: {"name": "Ruins of Alph Kabuto Chamber"},
0x19: {"name": "Ruins of Alph Omanyte Chamber"},
0x1A: {"name": "Ruins of Alph Aerodactyl Chamber"},
0x1B: {"name": "Ruins of Alph Inner Chamber"},
0x1C: {"name": "Ruins of Alph Research Center"},
0x1D: {"name": "Ruins of Alph Ho-oh Item Room"},
0x1E: {"name": "Ruins of Alph Kabuto Item Room"},
0x1F: {"name": "Ruins of Alph Omanyte Item Room"},
0x20: {"name": "Ruins of Alph Aerodactyl Item Room"},
0x21: {"name": "Ruins of Alph Ho-Oh Word Room"},
0x22: {"name": "Ruins of Alph Kabuto Word Room"},
0x23: {"name": "Ruins of Alph Omanyte Word Room"},
0x24: {"name": "Ruins of Alph Aerodactyl Word Room"},
0x25: {"name": "Union Cave 1F"},
0x26: {"name": "Union Cave B1F"},
0x27: {"name": "Union Cave B2F"},
0x28: {"name": "Slowpoke Well B1F"},
0x29: {"name": "Slowpoke Well B2F"},
0x2A: {"name": "Olivine Lighthouse 1F"},
0x2B: {"name": "Olivine Lighthouse 2F"},
0x2C: {"name": "Olivine Lighthouse 3F"},
0x2D: {"name": "Olivine Lighthouse 4F"},
0x2E: {"name": "Olivine Lighthouse 5F"},
0x2F: {"name": "Olivine Lighthouse 6F"},
0x30: {"name": "Mahogany Mart 1F"},
0x31: {"name": "Team Rocket Base B1F"},
0x32: {"name": "Team Rocket Base B2F"},
0x33: {"name": "Team Rocket Base B3F"},
0x34: {"name": "Ilex Forest"},
0x35: {"name": "Warehouse Entrance"},
0x36: {"name": "Underground Path Switch Room Entrances"},
0x37: {"name": "Goldenrod Dept Store B1F"},
0x38: {"name": "Underground Warehouse"},
0x39: {"name": "Mount Mortar 1F Outside"},
0x3A: {"name": "Mount Mortar 1F Inside"},
0x3B: {"name": "Mount Mortar 2F Inside"},
0x3C: {"name": "Mount Mortar B1F"},
0x3D: {"name": "Ice Path 1F"},
0x3E: {"name": "Ice Path B1F"},
0x3F: {"name": "Ice Path B2F Mahogany Side"},
0x40: {"name": "Ice Path B2F Blackthorn Side"},
0x41: {"name": "Ice Path B3F"},
0x42: {"name": "Whirl Island NW"},
0x43: {"name": "Whirl Island NE"},
0x44: {"name": "Whirl Island SW"},
0x45: {"name": "Whirl Island Cave"},
0x46: {"name": "Whirl Island SE"},
0x47: {"name": "Whirl Island B1F"},
0x48: {"name": "Whirl Island B2F"},
0x49: {"name": "Whirl Island Lugia Chamber"},
0x4A: {"name": "Silver Cave Room 1"},
0x4B: {"name": "Silver Cave Room 2"},
0x4C: {"name": "Silver Cave Room 3"},
0x4D: {"name": "Silver Cave Item Rooms"},
0x4E: {"name": "Dark Cave Violet Entrance"},
0x4F: {"name": "Dark Cave Blackthorn Entrance"},
0x50: {"name": "Dragon's Den 1F"},
0x51: {"name": "Dragon's Den B1F"},
0x52: {"name": "Dragon Shrine"},
0x53: {"name": "Tohjo Falls"},
0x54: {"name": "Diglett's Cave"},
0x55: {"name": "Mount Moon"},
0x56: {"name": "Underground"},
0x57: {"name": "Rock Tunnel 1F"},
0x58: {"name": "Rock Tunnel B1F"},
0x59: {"name": "Safari Zone Fuchsia Gate Beta"},
0x5A: {"name": "Safari Zone Beta"},
0x5B: {"name": "Victory Road"},
},
4: {
0x1: {"name": "Ecruteak House"}, # passage to Tin Tower
0x2: {"name": "Wise Trio's Room"},
0x3: {"name": "Ecruteak Pokémon Center 1F",
"label": "EcruteakPokeCenter1F"},
0x4: {"name": "Ecruteak Lugia Speech House"},
0x5: {"name": "Dance Theatre"},
0x6: {"name": "Ecruteak Mart"},
0x7: {"name": "Ecruteak Gym"},
0x8: {"name": "Ecruteak Itemfinder House"},
0x9: {"name": "Ecruteak City"},
},
5: {
0x1: {"name": "Blackthorn Gym 1F"},
0x2: {"name": "Blackthorn Gym 2F"},
0x3: {"name": "Blackthorn Dragon Speech House"},
0x4: {"name": "Blackthorn Dodrio Trade House"},
0x5: {"name": "Blackthorn Mart"},
0x6: {"name": "Blackthorn Pokémon Center 1F",
"label": "BlackthornPokeCenter1F"},
0x7: {"name": "Move Deleter's House"},
0x8: {"name": "Route 45"},
0x9: {"name": "Route 46"},
0xA: {"name": "Blackthorn City"},
},
6: {
0x1: {"name": "Cinnabar Pokémon Center 1F",
"label": "CinnabarPokeCenter1F"},
0x2: {"name": "Cinnabar Pokémon Center 2F Beta",
"label": "CinnabarPokeCenter2FBeta"},
0x3: {"name": "Route 19 - Fuchsia Gate"},
0x4: {"name": "Seafoam Gym"},
0x5: {"name": "Route 19"},
0x6: {"name": "Route 20"},
0x7: {"name": "Route 21"},
0x8: {"name": "Cinnabar Island"},
},
7: {
0x1: {"name": "Cerulean Gym Badge Speech House"},
0x2: {"name": "Cerulean Police Station"},
0x3: {"name": "Cerulean Trade Speech House"},
0x4: {"name": "Cerulean Pokémon Center 1F",
"label": "CeruleanPokeCenter1F"},
0x5: {"name": "Cerulean Pokémon Center 2F Beta",
"label": "CeruleanPokeCenter2FBeta"},
0x6: {"name": "Cerulean Gym"},
0x7: {"name": "Cerulean Mart"},
0x8: {"name": "Route 10 Pokémon Center 1F",
"label": "Route10PokeCenter1F"},
0x9: {"name": "Route 10 Pokémon Center 2F Beta",
"label": "Route10PokeCenter2FBeta"},
0xA: {"name": "Power Plant"},
0xB: {"name": "Bill's House"},
0xC: {"name": "Route 4"},
0xD: {"name": "Route 9"},
0xE: {"name": "Route 10 North"},
0xF: {"name": "Route 24"},
0x10: {"name": "Route 25"},
0x11: {"name": "Cerulean City"},
},
8: {
0x1: {"name": "Azalea Pokémon Center 1F",
"label": "AzaleaPokeCenter1F"},
0x2: {"name": "Charcoal Kiln"},
0x3: {"name": "Azalea Mart"},
0x4: {"name": "Kurt's House"},
0x5: {"name": "Azalea Gym"},
0x6: {"name": "Route 33"},
0x7: {"name": "Azalea Town"},
},
9: {
0x1: {"name": "Lake of Rage Hidden Power House"},
0x2: {"name": "Lake of Rage Magikarp House"},
0x3: {"name": "Route 43 Mahogany Gate"},
0x4: {"name": "Route 43 Gate"},
0x5: {"name": "Route 43"},
0x6: {"name": "Lake of Rage"},
},
10: {
0x1: {"name": "Route 32"},
0x2: {"name": "Route 35"},
0x3: {"name": "Route 36"},
0x4: {"name": "Route 37"},
0x5: {"name": "Violet City"},
0x6: {"name": "Violet Mart"},
0x7: {"name": "Violet Gym"},
0x8: {"name": "Earl's Pokémon Academy",
"label": "EarlsPokemonAcademy"},
0x9: {"name": "Violet Nickname Speech House"},
0xA: {"name": "Violet Pokémon Center 1F",
"label": "VioletPokeCenter1F"},
0xB: {"name": "Violet Onix Trade House"},
0xC: {"name": "Route 32 Ruins of Alph Gate"},
0xD: {"name": "Route 32 Pokémon Center 1F",
"label": "Route32PokeCenter1F"},
0xE: {"name": "Route 35 Goldenrod gate"},
0xF: {"name": "Route 35 National Park gate"},
0x10: {"name": "Route 36 Ruins of Alph gate"},
0x11: {"name": "Route 36 National Park gate"},
},
11: {
0x1: {"name": "Route 34"},
0x2: {"name": "Goldenrod City"},
0x3: {"name": "Goldenrod Gym"},
0x4: {"name": "Goldenrod Bike Shop"},
0x5: {"name": "Goldenrod Happiness Rater"},
0x6: {"name": "Goldenrod Bill's House"},
0x7: {"name": "Goldenrod Magnet Train Station"},
0x8: {"name": "Goldenrod Flower Shop"},
0x9: {"name": "Goldenrod PP Speech House"},
0xA: {"name": "Goldenrod Name Rater's House"},
0xB: {"name": "Goldenrod Dept Store 1F"},
0xC: {"name": "Goldenrod Dept Store 2F"},
0xD: {"name": "Goldenrod Dept Store 3F"},
0xE: {"name": "Goldenrod Dept Store 4F"},
0xF: {"name": "Goldenrod Dept Store 5F"},
0x10: {"name": "Goldenrod Dept Store 6F"},
0x11: {"name": "Goldenrod Dept Store Elevator"},
0x12: {"name": "Goldenrod Dept Store Roof"},
0x13: {"name": "Goldenrod Game Corner"},
0x14: {"name": "Goldenrod Pokémon Center 1F",
"label": "GoldenrodPokeCenter1F"},
0x15: {"name": "Goldenrod PokéCom Center 2F Mobile",
"label": "GoldenrodPokeComCenter2FMobile"},
0x16: {"name": "Ilex Forest Azalea Gate"},
0x17: {"name": "Route 34 Ilex Forest Gate"},
0x18: {"name": "Day Care"},
},
12: {
0x1: {"name": "Route 6"},
0x2: {"name": "Route 11"},
0x3: {"name": "Vermilion City"},
0x4: {"name": "Vermilion House Fishing Speech House"},
0x5: {"name": "Vermilion Pokémon Center 1F",
"label": "VermilionPokeCenter1F"},
0x6: {"name": "Vermilion Pokémon Center 2F Beta",
"label": "VermilionPokeCenter2FBeta"},
0x7: {"name": "Pokémon Fan Club"},
0x8: {"name": "Vermilion Magnet Train Speech House"},
0x9: {"name": "Vermilion Mart"},
0xA: {"name": "Vermilion House Diglett's Cave Speech House"},
0xB: {"name": "Vermilion Gym"},
0xC: {"name": "Route 6 Saffron Gate"},
0xD: {"name": "Route 6 Underground Entrance"},
},
13: {
0x1: {"name": "Route 1"},
0x2: {"name": "Pallet Town"},
0x3: {"name": "Red's House 1F"},
0x4: {"name": "Red's House 2F"},
0x5: {"name": "Blue's House"},
0x6: {"name": "Oak's Lab"},
},
14: {
0x1: {"name": "Route 3"},
0x2: {"name": "Pewter City"},
0x3: {"name": "Pewter Nidoran Speech House"},
0x4: {"name": "Pewter Gym"},
0x5: {"name": "Pewter Mart"},
0x6: {"name": "Pewter Pokémon Center 1F",
"label": "PewterPokeCenter1F"},
0x7: {"name": "Pewter Pokémon Center 2F Beta",
"label": "PewterPokeCEnter2FBeta"},
0x8: {"name": "Pewter Snooze Speech House"},
},
15: {
0x1: {"name": "Olivine Port"},
0x2: {"name": "Vermilion Port"},
0x3: {"name": "Fast Ship 1F"},
0x4: {"name": "Fast Ship Cabins NNW, NNE, NE",
"label": "FastShipCabins_NNW_NNE_NE"},
0x5: {"name": "Fast Ship Cabins SW, SSW, NW",
"label": "FastShipCabins_SW_SSW_NW"},
0x6: {"name": "Fast Ship Cabins SE, SSE, Captain's Cabin",
"label": "FastShipCabins_SE_SSE_CaptainsCabin"},
0x7: {"name": "Fast Ship B1F"},
0x8: {"name": "Olivine Port Passage"},
0x9: {"name": "Vermilion Port Passage"},
0xA: {"name": "Mount Moon Square"},
0xB: {"name": "Mount Moon Gift Shop"},
0xC: {"name": "Tin Tower Roof"},
},
16: {
0x1: {"name": "Route 23"},
0x2: {"name": "Indigo Plateau Pokémon Center 1F",
"label": "IndigoPlateauPokeCenter1F"},
0x3: {"name": "Will's Room"},
0x4: {"name": "Koga's Room"},
0x5: {"name": "Bruno's Room"},
0x6: {"name": "Karen's Room"},
0x7: {"name": "Lance's Room"},
0x8: {"name": "Hall of Fame",
"label": "HallOfFame"},
},
17: {
0x1: {"name": "Route 13"},
0x2: {"name": "Route 14"},
0x3: {"name": "Route 15"},
0x4: {"name": "Route 18"},
0x5: {"name": "Fuchsia City"},
0x6: {"name": "Fuchsia Mart"},
0x7: {"name": "Safari Zone Main Office"},
0x8: {"name": "Fuchsia Gym"},
0x9: {"name": "Fuchsia Bill Speech House"},
0xA: {"name": "Fuchsia Pokémon Center 1F",
"label": "FuchsiaPokeCenter1F"},
0xB: {"name": "Fuchsia Pokémon Center 2F Beta",
"label": "FuchsiaPokeCenter2FBeta"},
0xC: {"name": "Safari Zone Warden's Home"},
0xD: {"name": "Route 15 Fuchsia Gate"},
},
18: {
0x1: {"name": "Route 8"},
0x2: {"name": "Route 12"},
0x3: {"name": "Route 10 South"},
0x4: {"name": "Lavender Town"},
0x5: {"name": "Lavender Pokémon Center 1F",
"label": "LavenderPokeCenter1F"},
0x6: {"name": "Lavender Pokémon Center 2F Beta",
"label": "LavenderPokeCenter2FBeta"},
0x7: {"name": "Mr. Fuji's House"},
0x8: {"name": "Lavender Town Speech House"},
0x9: {"name": "Lavender Name Rater"},
0xA: {"name": "Lavender Mart"},
0xB: {"name": "Soul House"},
0xC: {"name": "Lav Radio Tower 1F"},
0xD: {"name": "Route 8 Saffron Gate"},
0xE: {"name": "Route 12 Super Rod House"},
},
19: {
0x1: {"name": "Route 28"},
0x2: {"name": "Silver Cave Outside"},
0x3: {"name": "Silver Cave Pokémon Center 1F",
"label": "SilverCavePokeCenter1F"},
0x4: {"name": "Route 28 Famous Speech House"},
},
20: {
0x1: {"name": "Pokémon Center 2F",
"label": "PokeCenter2F"},
0x2: {"name": "Trade Center"},
0x3: {"name": "Colosseum"},
0x4: {"name": "Time Capsule"},
0x5: {"name": "Mobile Trade Room Mobile"},
0x6: {"name": "Mobile Battle Room"},
},
21: {
0x1: {"name": "Route 7"},
0x2: {"name": "Route 16"},
0x3: {"name": "Route 17"},
0x4: {"name": "Celadon City"},
0x5: {"name": "Celadon Dept Store 1F"},
0x6: {"name": "Celadon Dept Store 2F"},
0x7: {"name": "Celadon Dept Store 3F"},
0x8: {"name": "Celadon Dept Store 4F"},
0x9: {"name": "Celadon Dept Store 5F"},
0xA: {"name": "Celadon Dept Store 6F"},
0xB: {"name": "Celadon Dept Store Elevator"},
0xC: {"name": "Celadon Mansion 1F"},
0xD: {"name": "Celadon Mansion 2F"},
0xE: {"name": "Celadon Mansion 3F"},
0xF: {"name": "Celadon Mansion Roof"},
0x10: {"name": "Celadon Mansion Roof House"},
0x11: {"name": "Celadon Pokémon Center 1F",
"label": "CeladonPokeCenter1F"},
0x12: {"name": "Celadon Pokémon Center 2F Beta",
"label": "CeladonPokeCenter2FBeta"},
0x13: {"name": "Celadon Game Corner"},
0x14: {"name": "Celadon Game Corner Prize Room"},
0x15: {"name": "Celadon Gym"},
0x16: {"name": "Celadon Cafe"},
0x17: {"name": "Route 16 Fuchsia Speech House"},
0x18: {"name": "Route 16 Gate"},
0x19: {"name": "Route 7 Saffron Gate"},
0x1A: {"name": "Route 17 18 Gate"},
},
22: {
0x1: {"name": "Route 40"},
0x2: {"name": "Route 41"},
0x3: {"name": "Cianwood City"},
0x4: {"name": "Mania's House"},
0x5: {"name": "Cianwood Gym"},
0x6: {"name": "Cianwood Pokémon Center 1F",
"label": "CianwoodPokeCenter1F"},
0x7: {"name": "Cianwood Pharmacy"},
0x8: {"name": "Cianwood City Photo Studio"},
0x9: {"name": "Cianwood Lugia Speech House"},
0xA: {"name": "Poke Seer's House"},
0xB: {"name": "Battle Tower 1F"},
0xC: {"name": "Battle Tower Battle Room"},
0xD: {"name": "Battle Tower Elevator"},
0xE: {"name": "Battle Tower Hallway"},
0xF: {"name": "Route 40 Battle Tower Gate"},
0x10: {"name": "Battle Tower Outside"},
},
23: {
0x1: {"name": "Route 2"},
0x2: {"name": "Route 22"},
0x3: {"name": "Viridian City"},
0x4: {"name": "Viridian Gym"},
0x5: {"name": "Viridian Nickname Speech House"},
0x6: {"name": "Trainer House 1F"},
0x7: {"name": "Trainer House B1F"},
0x8: {"name": "Viridian Mart"},
0x9: {"name": "Viridian Pokémon Center 1F",
"label": "ViridianPokeCenter1F"},
0xA: {"name": "Viridian Pokémon Center 2F Beta",
"label": "ViridianPokeCenter2FBeta"},
0xB: {"name": "Route 2 Nugget Speech House"},
0xC: {"name": "Route 2 Gate"},
0xD: {"name": "Victory Road Gate"},
},
24: {
0x1: {"name": "Route 26"},
0x2: {"name": "Route 27"},
0x3: {"name": "Route 29"},
0x4: {"name": "New Bark Town"},
0x5: {"name": "Elm's Lab"},
0x6: {"name": "Kris's House 1F"},
0x7: {"name": "Kris's House 2F"},
0x8: {"name": "Kris's Neighbor's House"},
0x9: {"name": "Elm's House"},
0xA: {"name": "Route 26 Heal Speech House"},
0xB: {"name": "Route 26 Day of Week Siblings House"},
0xC: {"name": "Route 27 Sandstorm House"},
0xD: {"name": "Route 29 46 Gate"},
},
25: {
0x1: {"name": "Route 5"},
0x2: {"name": "Saffron City"},
0x3: {"name": "Fighting Dojo"},
0x4: {"name": "Saffron Gym"},
0x5: {"name": "Saffron Mart"},
0x6: {"name": "Saffron Pokémon Center 1F",
"label": "SaffronPokeCenter1F"},
0x7: {"name": "Saffron Pokémon Center 2F Beta",
"label": "SaffronPokeCenter2FBeta"},
0x8: {"name": "Mr. Psychic's House"},
0x9: {"name": "Saffron Train Station"},
0xA: {"name": "Silph Co. 1F"},
0xB: {"name": "Copycat's House 1F"},
0xC: {"name": "Copycat's House 2F"},
0xD: {"name": "Route 5 Underground Entrance"},
0xE: {"name": "Route 5 Saffron City Gate"},
0xF: {"name": "Route 5 Cleanse Tag Speech House"},
},
26: {
0x1: {"name": "Route 30"},
0x2: {"name": "Route 31"},
0x3: {"name": "Cherrygrove City"},
0x4: {"name": "Cherrygrove Mart"},
0x5: {"name": "Cherrygrove Pokémon Center 1F",
"label": "CherrygrovePokeCenter1F"},
0x6: {"name": "Cherrygrove Gym Speech House"},
0x7: {"name": "Guide Gent's House"},
0x8: {"name": "Cherrygrove Evolution Speech House"},
0x9: {"name": "Route 30 Berry Speech House"},
0xA: {"name": "Mr. Pokémon's House"},
0xB: {"name": "Route 31 Violet Gate"},
},
}

View File

@ -1,255 +0,0 @@
# -*- coding: utf-8 -*-
moves = {
0x01: "POUND",
0x02: "KARATE_CHOP",
0x03: "DOUBLESLAP",
0x04: "COMET_PUNCH",
0x05: "MEGA_PUNCH",
0x06: "PAY_DAY",
0x07: "FIRE_PUNCH",
0x08: "ICE_PUNCH",
0x09: "THUNDERPUNCH",
0x0A: "SCRATCH",
0x0B: "VICEGRIP",
0x0C: "GUILLOTINE",
0x0D: "RAZOR_WIND",
0x0E: "SWORDS_DANCE",
0x0F: "CUT",
0x10: "GUST",
0x11: "WING_ATTACK",
0x12: "WHIRLWIND",
0x13: "FLY",
0x14: "BIND",
0x15: "SLAM",
0x16: "VINE_WHIP",
0x17: "STOMP",
0x18: "DOUBLE_KICK",
0x19: "MEGA_KICK",
0x1A: "JUMP_KICK",
0x1B: "ROLLING_KICK",
0x1C: "SAND_ATTACK",
0x1D: "HEADBUTT",
0x1E: "HORN_ATTACK",
0x1F: "FURY_ATTACK",
0x20: "HORN_DRILL",
0x21: "TACKLE",
0x22: "BODY_SLAM",
0x23: "WRAP",
0x24: "TAKE_DOWN",
0x25: "THRASH",
0x26: "DOUBLE_EDGE",
0x27: "TAIL_WHIP",
0x28: "POISON_STING",
0x29: "TWINEEDLE",
0x2A: "PIN_MISSILE",
0x2B: "LEER",
0x2C: "BITE",
0x2D: "GROWL",
0x2E: "ROAR",
0x2F: "SING",
0x30: "SUPERSONIC",
0x31: "SONICBOOM",
0x32: "DISABLE",
0x33: "ACID",
0x34: "EMBER",
0x35: "FLAMETHROWER",
0x36: "MIST",
0x37: "WATER_GUN",
0x38: "HYDRO_PUMP",
0x39: "SURF",
0x3A: "ICE_BEAM",
0x3B: "BLIZZARD",
0x3C: "PSYBEAM",
0x3D: "BUBBLEBEAM",
0x3E: "AURORA_BEAM",
0x3F: "HYPER_BEAM",
0x40: "PECK",
0x41: "DRILL_PECK",
0x42: "SUBMISSION",
0x43: "LOW_KICK",
0x44: "COUNTER",
0x45: "SEISMIC_TOSS",
0x46: "STRENGTH",
0x47: "ABSORB",
0x48: "MEGA_DRAIN",
0x49: "LEECH_SEED",
0x4A: "GROWTH",
0x4B: "RAZOR_LEAF",
0x4C: "SOLARBEAM",
0x4D: "POISONPOWDER",
0x4E: "STUN_SPORE",
0x4F: "SLEEP_POWDER",
0x50: "PETAL_DANCE",
0x51: "STRING_SHOT",
0x52: "DRAGON_RAGE",
0x53: "FIRE_SPIN",
0x54: "THUNDERSHOCK",
0x55: "THUNDERBOLT",
0x56: "THUNDER_WAVE",
0x57: "THUNDER",
0x58: "ROCK_THROW",
0x59: "EARTHQUAKE",
0x5A: "FISSURE",
0x5B: "DIG",
0x5C: "TOXIC",
0x5D: "CONFUSION",
0x5E: "PSYCHIC_M",
0x5F: "HYPNOSIS",
0x60: "MEDITATE",
0x61: "AGILITY",
0x62: "QUICK_ATTACK",
0x63: "RAGE",
0x64: "TELEPORT",
0x65: "NIGHT_SHADE",
0x66: "MIMIC",
0x67: "SCREECH",
0x68: "DOUBLE_TEAM",
0x69: "RECOVER",
0x6A: "HARDEN",
0x6B: "MINIMIZE",
0x6C: "SMOKESCREEN",
0x6D: "CONFUSE_RAY",
0x6E: "WITHDRAW",
0x6F: "DEFENSE_CURL",
0x70: "BARRIER",
0x71: "LIGHT_SCREEN",
0x72: "HAZE",
0x73: "REFLECT",
0x74: "FOCUS_ENERGY",
0x75: "BIDE",
0x76: "METRONOME",
0x77: "MIRROR_MOVE",
0x78: "SELFDESTRUCT",
0x79: "EGG_BOMB",
0x7A: "LICK",
0x7B: "SMOG",
0x7C: "SLUDGE",
0x7D: "BONE_CLUB",
0x7E: "FIRE_BLAST",
0x7F: "WATERFALL",
0x80: "CLAMP",
0x81: "SWIFT",
0x82: "SKULL_BASH",
0x83: "SPIKE_CANNON",
0x84: "CONSTRICT",
0x85: "AMNESIA",
0x86: "KINESIS",
0x87: "SOFTBOILED",
0x88: "HI_JUMP_KICK",
0x89: "GLARE",
0x8A: "DREAM_EATER",
0x8B: "POISON_GAS",
0x8C: "BARRAGE",
0x8D: "LEECH_LIFE",
0x8E: "LOVELY_KISS",
0x8F: "SKY_ATTACK",
0x90: "TRANSFORM",
0x91: "BUBBLE",
0x92: "DIZZY_PUNCH",
0x93: "SPORE",
0x94: "FLASH",
0x95: "PSYWAVE",
0x96: "SPLASH",
0x97: "ACID_ARMOR",
0x98: "CRABHAMMER",
0x99: "EXPLOSION",
0x9A: "FURY_SWIPES",
0x9B: "BONEMERANG",
0x9C: "REST",
0x9D: "ROCK_SLIDE",
0x9E: "HYPER_FANG",
0x9F: "SHARPEN",
0xA0: "CONVERSION",
0xA1: "TRI_ATTACK",
0xA2: "SUPER_FANG",
0xA3: "SLASH",
0xA4: "SUBSTITUTE",
0xA5: "STRUGGLE",
0xA6: "SKETCH",
0xA7: "TRIPLE_KICK",
0xA8: "THIEF",
0xA9: "SPIDER_WEB",
0xAA: "MIND_READER",
0xAB: "NIGHTMARE",
0xAC: "FLAME_WHEEL",
0xAD: "SNORE",
0xAE: "CURSE",
0xAF: "FLAIL",
0xB0: "CONVERSION2",
0xB1: "AEROBLAST",
0xB2: "COTTON_SPORE",
0xB3: "REVERSAL",
0xB4: "SPITE",
0xB5: "POWDER_SNOW",
0xB6: "PROTECT",
0xB7: "MACH_PUNCH",
0xB8: "SCARY_FACE",
0xB9: "FAINT_ATTACK",
0xBA: "SWEET_KISS",
0xBB: "BELLY_DRUM",
0xBC: "SLUDGE_BOMB",
0xBD: "MUD_SLAP",
0xBE: "OCTAZOOKA",
0xBF: "SPIKES",
0xC0: "ZAP_CANNON",
0xC1: "FORESIGHT",
0xC2: "DESTINY_BOND",
0xC3: "PERISH_SONG",
0xC4: "ICY_WIND",
0xC5: "DETECT",
0xC6: "BONE_RUSH",
0xC7: "LOCK_ON",
0xC8: "OUTRAGE",
0xC9: "SANDSTORM",
0xCA: "GIGA_DRAIN",
0xCB: "ENDURE",
0xCC: "CHARM",
0xCD: "ROLLOUT",
0xCE: "FALSE_SWIPE",
0xCF: "SWAGGER",
0xD0: "MILK_DRINK",
0xD1: "SPARK",
0xD2: "FURY_CUTTER",
0xD3: "STEEL_WING",
0xD4: "MEAN_LOOK",
0xD5: "ATTRACT",
0xD6: "SLEEP_TALK",
0xD7: "HEAL_BELL",
0xD8: "RETURN",
0xD9: "PRESENT",
0xDA: "FRUSTRATION",
0xDB: "SAFEGUARD",
0xDC: "PAIN_SPLIT",
0xDD: "SACRED_FIRE",
0xDE: "MAGNITUDE",
0xDF: "DYNAMICPUNCH",
0xE0: "MEGAHORN",
0xE1: "DRAGONBREATH",
0xE2: "BATON_PASS",
0xE3: "ENCORE",
0xE4: "PURSUIT",
0xE5: "RAPID_SPIN",
0xE6: "SWEET_SCENT",
0xE7: "IRON_TAIL",
0xE8: "METAL_CLAW",
0xE9: "VITAL_THROW",
0xEA: "MORNING_SUN",
0xEB: "SYNTHESIS",
0xEC: "MOONLIGHT",
0xED: "HIDDEN_POWER",
0xEE: "CROSS_CHOP",
0xEF: "TWISTER",
0xF0: "RAIN_DANCE",
0xF1: "SUNNY_DAY",
0xF2: "CRUNCH",
0xF3: "MIRROR_COAT",
0xF4: "PSYCH_UP",
0xF5: "EXTREMESPEED",
0xF6: "ANCIENTPOWER",
0xF7: "SHADOW_BALL",
0xF8: "FUTURE_SIGHT",
0xF9: "ROCK_SMASH",
0xFA: "WHIRLPOOL",
0xFB: "BEAT_UP",
}

Some files were not shown because too many files have changed in this diff Show More