From 4577af01deccd9d66d9e236c24ed7cb9e6e3430a Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 18 Jun 2013 03:56:07 -0400 Subject: [PATCH 01/10] updated install instructions --- INSTALL.md | 115 ++++++++++++++++++++++++++++++++++++++++------------- README.md | 24 ++++++----- 2 files changed, 100 insertions(+), 39 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0443412f0..76a4d7dad 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,21 +1,97 @@ # Getting Started -Compiling requires a certain Pokemon Crystal ROM: +Compiling **pokecrystal.gbc** requires a certain **Pokemon Crystal** rom: ``` Pokemon - Crystal Version (UE) (V1.0) [C][!].gbc md5: 9f2922b235a5eeb78d65594e82ef5dde ``` -Save it as `baserom.gbc` in the repository. +Save it as **baserom.gbc** in the repository. -Feel free to ask us on nucleus.kafuka.org #skeetendo if something goes wrong (remember to tell where)! +Feel free to ask us on **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** if something goes wrong! -Don't know how to use IRC? Try [mibbit](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo). +# Windows + +If you are on Windows and can't install Linux, **Cygwin** is a great alternative. + +## Installing Cygwin + +Cygwin provides a virtual Linux environment on Windows systems. Just get **setup.exe**. + +**http://cygwin.com/install.html** + +During the install: + +* Keep the defaults. + +* Most mirrors are molasses. Use **http://mirrors.kernel.org**. -## Linux +## Using Cygwin + +Launch the **Cygwin terminal**. Maybe you know your way around the Linux terminal, **bash**. If not, a crash course: +```bash +# list files in current directory +ls + +# show current directory +pwd + +# change directory +cd /away/we/go +``` + + +## Getting up and running + +We need a couple more things. + +```bash +apt-cyg install python make git wget +``` + +**rgbds** will let you compile Game Boy roms. + +```bash +# download rgbds binaries +wget http://diyhpl.us/~bryan/irc/pokered/rgbds/rgbds.zip +unzip rgbds.zip +rm rgbds.zip + +# make rgbds accessible for all time +export PATH=$PATH:`pwd`/rgbds +echo "export PATH=$PATH" >> ~/.bashrc +``` + +Set up the **pokecrystal** repository: + +```bash +cd ~ +git clone https://github.com/kanzure/pokecrystal +cd pokecrystal + +# install python requirements +pip install -r requirements.txt + +# use hexdump to diff binary files +git config diff.hex.textconv hexdump + +# download the base rom +``` + +Now you should be able to build **pokecrystal.gbc** for the first time. +``` +make clean && make +``` + +This ought to 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! + + +# Linux ```bash sudo apt-get install make gcc bison git python python-setuptools @@ -46,36 +122,19 @@ pip install -r requirements.txt git config diff.hex.textconv hexdump ``` -To compile the ROM from ASM source: +To compile the rom from asm source: ``` make clean && make ``` -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! +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! -## Windows +# Now what? -Set up [GitHub for Windows](http://windows.github.com/) and clone this repository. +* **Can't find something?** Contribute! -If you haven't already, get [Python 2.7](http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi) ([64-bit](http://www.python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi)). +* **Do your own thing!** The asm source is hack-friendly, and the supplementary scripts in extras/ can be used for other projects. -Extract the following files from the [RGBDS](https://github.com/downloads/bentley/rgbds/rgbds-0.0.1.zip) package into the repository: -`rgbasm.exe` -`rgbds.exe` -`rgbfix.exe` -`rgblink.exe` - -Install [make](http://gnuwin32.sourceforge.net/downlinks/make.php) for Windows. - -To compile the ROM from ASM source, run `pokecrystal.bat`. - -That will take between 3 and 15 seconds, depending on your computer. If you see -`FC: no differences encountered`, the build was successful! Rejoice! - -Now you may try messing around with `main.asm`, or just do whatever you wanted to. - - -# Contributions are welcome! +* We'll be happy to answer any **questions** at **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** diff --git a/README.md b/README.md index f8b59dddd..d55a5a7b5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The source code in this project successfully converts back into a ROM image. All ## Base ROM -The following ROM is required for compiling: +The following rom is required for compiling: ``` Pokemon - Crystal Version (UE) (V1.0) [C][!].gbc @@ -17,16 +17,18 @@ md5: 9f2922b235a5eeb78d65594e82ef5dde Eventually this will not be necessary. -## See also - -* disassembly of [Pokémon Red](http://bitbucket.org/iimarckus/pokered). - - -## Contributing - -* Hang out with us on IRC: `nucleus.kafuka.org #skeetendo` (for example, by -using [mibbit](http://chat.mibbit.com/)). +## What can I do? * Are we missing something? Make a pull request! Contributions are welcome. -* Tackle some [issues](https://github.com/kanzure/pokecrystal/issues)! +* Take a look at some of the disasm tools in **extras/**. Most of the scripts are generalized enough to take apart other Game Boy games. + +* Tackle some **[issues](https://github.com/kanzure/pokecrystal/issues)**! + + +## See also + +* Hang out with us on IRC: **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** + +* Disassembly of **[Pokémon Red](http://bitbucket.org/iimarckus/pokered)**. + From f3340de6dc30fb1c889421bdb8a3d22c1b64fa24 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 18 Jun 2013 21:54:40 -0400 Subject: [PATCH 02/10] make clean is no longer required to compile --- INSTALL.md | 8 ++++---- Makefile | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 76a4d7dad..83ad97564 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -82,8 +82,8 @@ git config diff.hex.textconv hexdump ``` Now you should be able to build **pokecrystal.gbc** for the first time. -``` -make clean && make +```bash +make ``` This ought to take between **3 and 15 seconds**, depending on your computer. @@ -123,8 +123,8 @@ git config diff.hex.textconv hexdump ``` To compile the rom from asm source: -``` -make clean && make +```bash +make ``` 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! diff --git a/Makefile b/Makefile index 15fa7f5c1..eb75fad6a 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,10 @@ clean: pokecrystal.o: pokecrystal.asm constants.asm wram.asm ${TEXTFILES} lzs rgbasm -o pokecrystal.o pokecrystal.asm +pokecrystal.asm: depend +depend: + @touch main.asm + .asm.tx: python preprocessor.py < $< > $@ From e733c4234c0064102f9732f23ed869660c847d31 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 21 Jun 2013 00:58:35 -0400 Subject: [PATCH 03/10] preprocess asm files individually this fixes a lot of previous hacks first off, rgbds requires that labels from includes be marked as globals. instead, 3626ddeb stuffed includes into the parent file in the preprocessor. this meant one huge file got preprocessed every time, adding an additional ten seconds to compile time. running the preprocessor once for each file would create too much overhead, so a list is fed into prequeue.py, which then makes calls to preprocessor.py. this paves the way for compiling source files separately some day. next, compiling previously required `make clean` to be executed first. f3340de6 touched main.asm to force a fresh compile instead. this behavior has been reverted. now, `make all` will only attempt to recompile if a source file has changed. preprocessor.py has some marginal changes. prequeue.py is created to keep the original functionality of preprocessor.py intact. so many files are preprocessed on first compile (1951 as of this commit) that the prequeue call has been hidden. compile time is reduced to 15-30 seconds on first compile, and 5-10 seconds subsequently. the majority of this time is spent in rgbasm. --- Makefile | 32 ++++------- preprocessor.py | 148 ++++++++++++++++-------------------------------- prequeue.py | 11 ++++ 3 files changed, 72 insertions(+), 119 deletions(-) create mode 100644 prequeue.py diff --git a/Makefile b/Makefile index eb75fad6a..e133b4002 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,23 @@ .SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz -TEXTFILES = \ - text/sweethoney.tx \ - text/phone/bill.tx \ - text/phone/elm.tx \ - text/phone/mom.tx \ - text/phone/trainers1.tx \ - text/common.tx \ - text/common_2.tx \ - text/common_3.tx \ - main.tx +TEXTFILES := $(shell find ./ -type f -name '*.asm' | grep -v pokecrystal.asm | grep -v constants.asm | grep -v gbhw.asm | grep -v hram.asm | grep -v constants | grep -v wram.asm) +TEXTQUEUE := -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') +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 $< clean: - rm -f main.tx pokecrystal.o pokecrystal.gbc ${TEXTFILES} -pokecrystal.o: pokecrystal.asm constants.asm wram.asm ${TEXTFILES} lzs + rm -f pokecrystal.o pokecrystal.gbc + @echo rm -f $$\(TEXTFILES:.asm=.tx\) + @rm -f $(TEXTFILES:.asm=.tx) +pokecrystal.o: $(TEXTFILES:.asm=.tx) pokecrystal.asm constants.asm wram.asm lzs + python prequeue.py $(TEXTQUEUE) rgbasm -o pokecrystal.o pokecrystal.asm - -pokecrystal.asm: depend -depend: - @touch main.asm - .asm.tx: - python preprocessor.py < $< > $@ + $(eval TEXTQUEUE := $(TEXTQUEUE) $<) pokecrystal.gbc: pokecrystal.o rgblink -o $@ $< diff --git a/preprocessor.py b/preprocessor.py index 18e96dff0..bf9220a83 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -310,24 +310,14 @@ def separate_comment(l): """ Separates asm and comments on a single line. """ - - asm = "" - comment = None in_quotes = False - - # token either belongs to the line or to the comment - for token in l: - if comment: - comment += token - else: - if not in_quotes: - if token == ";": - comment = ";" - continue - if token == "\"": - in_quotes = not in_quotes - asm += token - return asm, comment + for i in xrange(len(l)): + if not in_quotes: + if l[i] == ";": + break + if l[i] == "\"": + in_quotes = not in_quotes + return i def quote_translator(asm): """ @@ -335,63 +325,50 @@ def quote_translator(asm): """ # split by quotes - asms = asm.split("\"") + asms = asm.split('"') # skip asm that actually does use ASCII in quotes - lowasm = asms[0].lower() - - if "section" in lowasm \ - or "incbin" in lowasm: - sys.stdout.write(asm) - return + if "SECTION" in asms[0]\ + or "INCBIN" in asms[0]\ + or "INCLUDE" in asms[0]: + return asm print_macro = False if asms[0].strip() == 'print': asms[0] = asms[0].replace('print','db 0,') print_macro = True - output = "" + output = '' even = False - i = 0 for token in asms: - i = i + 1 - if even: characters = [] # token is a string to convert to byte values while len(token): # read a single UTF-8 codepoint char = token[0] - if ord(char) >= 0xFC: - char = char + token[1:6] - token = token[6:] - elif ord(char) >= 0xF8: - char = char + token[1:5] - token = token[5:] - elif ord(char) >= 0xF0: - char = char + token[1:4] - token = token[4:] - elif ord(char) >= 0xE0: - char = char + token[1:3] - token = token[3:] - elif ord(char) >= 0xC0: + if ord(char) < 0xc0: + token = token[1:] + # certain apostrophe-letter pairs are considered a single character + if char == "'" and token: + if token[0] in 'dlmrstv': + char += token[0] + token = token[1:] + elif ord(char) < 0xe0: char = char + token[1:2] token = token[2:] + elif ord(char) < 0xf0: + char = char + token[1:3] + token = token[3:] + elif ord(char) < 0xf8: + char = char + token[1:4] + token = token[4:] + elif ord(char) < 0xfc: + char = char + token[1:5] + token = token[5:] else: - token = token[1:] - - # certain apostrophe-letter pairs are only a single byte - if char == "'" and len(token) > 0 and \ - (token[0] == "d" or \ - token[0] == "l" or \ - token[0] == "m" or \ - token[0] == "r" or \ - token[0] == "s" or \ - token[0] == "t" or \ - token[0] == "v"): - char = char + token[0] - token = token[1:] - + char = char + token[1:6] + token = token[6:] characters += [char] if print_macro: @@ -421,32 +398,26 @@ def quote_translator(asm): output += ", ".join(["${0:02X}".format(chars[char]) for char in characters]) - # if not even else: - output += (token) + output += token even = not even - sys.stdout.write(output) - - return + return output def extract_token(asm): - token = asm.split(" ")[0].replace("\t", "").replace("\n", "") - return token + return asm.split(" ")[0].strip() def make_macro_table(): - return dict([(macro.macro_name, macro) for macro in macros]) + return dict(((macro.macro_name, macro) for macro in macros)) macro_table = make_macro_table() def macro_test(asm): """ Returns a matching macro, or None/False. """ - # macros are determined by the first symbol on the line token = extract_token(asm) - # check against all names if token in macro_table: return (macro_table[token], token) @@ -600,64 +571,45 @@ def macro_translator(macro, token, line): sys.stdout.write(output) -def include_file(asm): - """This is more reliable than rgbasm/rgbds including files on its own.""" - - prefix = asm.split("INCLUDE \"")[0] + '\n' - filename = asm.split("\"")[1] - suffix = asm.split("\"")[2] - - read_line(prefix) - - lines = open(filename, "r").readlines() - - for line in lines: - read_line(line) - - read_line(suffix) - def read_line(l): """Preprocesses a given line of asm.""" - # strip and store any comment on this line - if ";" in l: - asm, comment = separate_comment(l) - else: - asm = l - comment = None + # strip comments + asm, comment = l[:separate_comment(l)], l[separate_comment(l):] - # handle INCLUDE as a special case - if "INCLUDE \"" in l: - include_file(asm) + # export all labels + if ':' in asm[:asm.find('"')]: + sys.stdout.write('GLOBAL ' + asm.split(':')[0] + '\n') + + # expect preprocessed .asm files + if "INCLUDE" in asm: + asm = asm.replace('.asm','.tx') + sys.stdout.write(asm) # ascii string macro preserves the bytes as ascii (skip the translator) - elif len(asm) > 6 and "\tascii " in [asm[:7], "\t" + asm[:6]]: + elif len(asm) > 6 and "ascii " == asm[:6] or "\tascii " == asm[:7]: asm = asm.replace("ascii", "db", 1) sys.stdout.write(asm) # convert text to bytes when a quote appears (not in a comment) elif "\"" in asm: - quote_translator(asm) + sys.stdout.write(quote_translator(asm)) # check against other preprocessor features else: macro, token = macro_test(asm) - if macro: macro_translator(macro, token, asm) else: sys.stdout.write(asm) - - # show line comment - if comment != None: - sys.stdout.write(comment) + sys.stdout.write(comment) def preprocess(lines=None): """Main entry point for the preprocessor.""" if not lines: # read each line from stdin - lines = sys.stdin + lines = (sys.stdin.readlines()) elif not isinstance(lines, list): # split up the input into individual lines lines = lines.split("\n") diff --git a/prequeue.py b/prequeue.py new file mode 100644 index 000000000..991db7eb8 --- /dev/null +++ b/prequeue.py @@ -0,0 +1,11 @@ +import os +import sys +import preprocessor + +if __name__ == '__main__': + for source in sys.argv[1:]: + dest = os.path.splitext(source)[0] + '.tx' + sys.stdin = open(source, 'r') + sys.stdout = open(dest, 'w') + preprocessor.preprocess() + From 01954388eab1d0bf8d3d0e42ef93b2fb58fe18d4 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 21 Jun 2013 23:23:22 -0400 Subject: [PATCH 04/10] make: don't recompile if it's not necessary the preprocessor queue was preventing files from being recognized as out-of-date this highlights similar errors with graphics targets, which need to be fixed anyway --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e133b4002..37e9aef4f 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,14 @@ all: pokecrystal.gbc cmp baserom.gbc $< clean: rm -f pokecrystal.o pokecrystal.gbc - @echo rm -f $$\(TEXTFILES:.asm=.tx\) + @echo 'rm -f $(TEXTFILES:.asm=.tx)' @rm -f $(TEXTFILES:.asm=.tx) -pokecrystal.o: $(TEXTFILES:.asm=.tx) pokecrystal.asm constants.asm wram.asm lzs +pokecrystal.o: $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX) python prequeue.py $(TEXTQUEUE) rgbasm -o pokecrystal.o pokecrystal.asm .asm.tx: $(eval TEXTQUEUE := $(TEXTQUEUE) $<) + @rm $@ pokecrystal.gbc: pokecrystal.o rgblink -o $@ $< @@ -27,6 +28,7 @@ pngs: cd extras && python gfx.py mass-decompress && python gfx.py dump-pngs lzs: $(LZ_GFX) $(TWOBPP_GFX) + @: gfx/pics/%/front.lz: gfx/pics/%/front.png gfx/pics/%/tiles.2bpp python extras/gfx.py png-to-lz --front $^ From 3d0314b562ba5bf35e2b17c3d32b421e50c19ae1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 19:05:43 -0400 Subject: [PATCH 05/10] replace broken mibbit links with kiwiirc --- INSTALL.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 83ad97564..a1e15aa67 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -10,7 +10,7 @@ md5: 9f2922b235a5eeb78d65594e82ef5dde Save it as **baserom.gbc** in the repository. -Feel free to ask us on **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** if something goes wrong! +Feel free to ask us on **[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)** if something goes wrong! # Windows @@ -136,5 +136,5 @@ That will take between 3 and 15 seconds, depending on your computer. If you see * **Do your own thing!** The asm source is hack-friendly, and the supplementary scripts in extras/ can be used for other projects. -* We'll be happy to answer any **questions** at **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** +* We'll be happy to answer any **questions** on **[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)**. diff --git a/README.md b/README.md index d55a5a7b5..6adb65625 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Eventually this will not be necessary. ## See also -* Hang out with us on IRC: **[nucleus.kafuka.org #skeetendo](http://chat.mibbit.com/?server=nucleus.kafuka.org&channel=#skeetendo)** +* Hang out with us on irc: **[nucleus.kafuka.org #skeetendo](https://kiwiirc.com/client/irc.nolimitzone.com/?#skeetendo)** * Disassembly of **[Pokémon Red](http://bitbucket.org/iimarckus/pokered)**. From 03b407a0c4bb58b85c5403c01ce995f40c46e79f Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 19:51:04 -0400 Subject: [PATCH 06/10] install: get pip and be less vague about the base rom --- INSTALL.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a1e15aa67..689a7cf8b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -46,15 +46,20 @@ cd /away/we/go ## Getting up and running -We need a couple more things. +We need a couple more things to be able to compile. + +If you're feeling lazy, just paste these commands into your terminal. ```bash -apt-cyg install python make git wget +apt-cyg install make git wget python python-setuptools +easy_install pip ``` **rgbds** will let you compile Game Boy roms. ```bash +cd ~ + # download rgbds binaries wget http://diyhpl.us/~bryan/irc/pokered/rgbds/rgbds.zip unzip rgbds.zip @@ -68,27 +73,29 @@ echo "export PATH=$PATH" >> ~/.bashrc Set up the **pokecrystal** repository: ```bash -cd ~ git clone https://github.com/kanzure/pokecrystal cd pokecrystal # install python requirements pip install -r requirements.txt - -# use hexdump to diff binary files -git config diff.hex.textconv hexdump - -# download the base rom ``` +## Don't forget baserom.gbc!! + +Make sure you downloaded a base rom. Name it **baserom.gbc**. + Now you should be able to build **pokecrystal.gbc** for the first time. + +This compiles a new rom from the source code, with any patches filled in from the base rom. ```bash make ``` -This ought to take between **3 and 15 seconds**, depending on your computer. +This ought to 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! +If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was successful! + +Your first compile processes every source file at once. After that, only modified source files have to be reprocessed, so compiling again should be a few seconds faster. # Linux From fdf1070dff66e5fffda76286f2dbc823fcdc2789 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 21:19:09 -0400 Subject: [PATCH 07/10] install: elaborate on make targets --- INSTALL.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 689a7cf8b..a35fe72ef 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -97,6 +97,14 @@ If you see `cmp baserom.gbc pokecrystal.gbc` as the last line, the build was suc Your first compile processes every source file at once. After that, only modified source files have to be reprocessed, so compiling again should be a few seconds faster. +Other make targets that may come in handy: + +`make clean` deletes any preprocessed source files (.tx), rgbds object files and the compiled rom, 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 compressed to lz without any additional work. + # Linux From 8d2df72cb8d09d7cf4ea839199ad8a50230ea6b2 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 21:24:09 -0400 Subject: [PATCH 08/10] pre: restore separate_comment's behavior --- preprocessor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/preprocessor.py b/preprocessor.py index bf9220a83..468ae41a5 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -317,7 +317,7 @@ def separate_comment(l): break if l[i] == "\"": in_quotes = not in_quotes - return i + return l[:i], l[i:] or None def quote_translator(asm): """ @@ -574,8 +574,8 @@ def macro_translator(macro, token, line): def read_line(l): """Preprocesses a given line of asm.""" - # strip comments - asm, comment = l[:separate_comment(l)], l[separate_comment(l):] + # strip comments from asm + asm, comment = separate_comment(l) # export all labels if ':' in asm[:asm.find('"')]: @@ -602,7 +602,8 @@ def read_line(l): macro_translator(macro, token, asm) else: sys.stdout.write(asm) - sys.stdout.write(comment) + + if comment: sys.stdout.write(comment) def preprocess(lines=None): """Main entry point for the preprocessor.""" From 44571dc23645d4bdf7492efb236fc80c0537e460 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 21:28:25 -0400 Subject: [PATCH 09/10] give prequeue a reason to exist --- prequeue.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prequeue.py b/prequeue.py index 991db7eb8..156d3e942 100644 --- a/prequeue.py +++ b/prequeue.py @@ -1,3 +1,9 @@ +# coding: utf-8 + +# Starting a new python process to preprocess each source file +# creates too much overhead. Instead, a list of files to preprocess +# is fed into a script run from a single process. + import os import sys import preprocessor From 859c70ff42588a9de354063c42f6665e5d174299 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 25 Jun 2013 22:03:48 -0400 Subject: [PATCH 10/10] install: less abrasive outro --- INSTALL.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a35fe72ef..68d5c09b8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -95,15 +95,15 @@ This ought to 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! -Your first compile processes every source file at once. After that, only modified source files have to be reprocessed, so compiling again should be a few seconds faster. +Your first compile processes every source file at once. After that, **only modified source files have to be reprocessed**, so compiling again should be a few seconds faster. -Other make targets that may come in handy: +Other **make targets** that may come in handy: -`make clean` deletes any preprocessed source files (.tx), rgbds object files and the compiled rom, in case something goes wrong. +`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 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 compressed to lz without any additional work. +`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. # Linux @@ -147,7 +147,9 @@ That will take between 3 and 15 seconds, depending on your computer. If you see # Now what? -* **Can't find something?** Contribute! +**main.asm** is a good starting point. The structure of the source is laid out here. + +* **Can't find something?** Anyone can add to the source. There's lots to be uncovered. * **Do your own thing!** The asm source is hack-friendly, and the supplementary scripts in extras/ can be used for other projects.