This commit is contained in:
PikalaxALT 2016-03-01 22:31:28 -05:00
commit f31da089bb
17 changed files with 79 additions and 83 deletions

View File

@ -7,8 +7,7 @@ These instructions explain how to set up the tools required to build.
Python 2.7 is required.
```bash
sudo apt-get install make gcc bison git python python-pip
pip install pypng
sudo apt-get install make gcc bison git python
git clone https://github.com/bentley/rgbds
cd rgbds
@ -32,7 +31,6 @@ In **Terminal**, run:
```bash
xcode-select --install
sudo easy_install pypng
git clone https://github.com/bentley/rgbds
cd rgbds
@ -54,7 +52,7 @@ make
To build on Windows, use [**Cygwin**](http://cygwin.com/install.html). Use the default settings.
In the installer, select the following packages: `make` `git` `python` `python-setuptools` `gcc-core` `libsasl2-3` `ca-certificates`
In the installer, select the following packages: `make` `git` `python` `gettext`
Then get the most recent version of [**rgbds**](https://github.com/bentley/rgbds/releases/).
Extract the archive and put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\cygwin\usr\local\bin`.
@ -62,8 +60,6 @@ Extract the archive and put `rgbasm.exe`, `rgblink.exe` and `rgbfix.exe` in `C:\
In the **Cygwin terminal**:
```bash
lynx -source bootstrap.pypa.io/get-pip.py | python
pip install pypng
git clone --recursive https://github.com/pret/pokecrystal
cd pokecrystal
@ -74,3 +70,7 @@ To build **pokecrystal.gbc**:
```bash
make
```
## notes
- If `gettext` no longer exists, grab `libsasl2-3` `ca-certificates`.

View File

@ -1,8 +1,9 @@
PYTHON := python
MD5 := md5sum -c --quiet
.SUFFIXES: .asm .o .gbc .png .2bpp .1bpp .lz .pal .bin .blk .tilemap
.PHONY: all clean crystal crystal11 pngs
.SUFFIXES:
.SUFFIXES: .2bpp
.PHONY: all clean crystal crystal11
.SECONDEXPANSION:
poketools := extras/pokemontools
@ -10,61 +11,45 @@ gfx := $(PYTHON) gfx.py
includes := $(PYTHON) $(poketools)/scan_includes.py
crystal11_obj := \
wram11.o \
crystal11.o \
lib/mobile/main.o \
home.o \
audio.o \
maps_crystal.o \
engine/events_crystal.o \
engine/credits_crystal.o \
data/egg_moves_crystal.o \
data/evos_attacks_crystal.o \
data/pokedex/entries_crystal.o \
misc/crystal_misc.o \
text/common_text.o \
gfx/pics.o
crystal_obj := \
wram.o \
main.o \
lib/mobile/main.o \
home.o \
audio.o \
maps_crystal.o \
engine/events_crystal.o \
engine/credits_crystal.o \
data/egg_moves_crystal.o \
data/evos_attacks_crystal.o \
data/pokedex/entries_crystal.o \
maps.o \
engine/events.o \
engine/credits.o \
data/egg_moves.o \
data/evos_attacks.o \
data/pokedex/entries.o \
misc/crystal_misc.o \
text/common_text.o \
gfx/pics.o
all_obj := $(crystal_obj) crystal11.o wram11.o
# object dependencies
$(foreach obj, $(all_obj), \
$(eval $(obj:.o=)_dep := $(shell $(includes) $(obj:.o=.asm))) \
)
crystal11_obj := $(crystal_obj:.o=11.o)
roms := pokecrystal.gbc
all: $(roms)
crystal: pokecrystal.gbc
crystal11: pokecrystal11.gbc
clean:
rm -f $(roms) $(all_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
compare: pokecrystal.gbc pokecrystal11.gbc
@$(MD5) roms.md5
%.asm: ;
$(all_obj): $$*.asm $$($$*_dep)
%11.o: dep = $(shell $(includes) $(@D)/$*.asm)
%11.o: %.asm $$(dep)
rgbasm -D CRYSTAL11 -o $@ $<
%.o: dep = $(shell $(includes) $(@D)/$*.asm)
%.o: %.asm $$(dep)
rgbasm -o $@ $<
pokecrystal11.gbc: $(crystal11_obj)
@ -76,12 +61,7 @@ pokecrystal.gbc: $(crystal_obj)
rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
pngs:
find . -iname "*.lz" -exec $(gfx) unlz {} +
find . -iname "*.[12]bpp" -exec $(gfx) png {} +
find . -iname "*.[12]bpp" -exec touch {} \;
find . -iname "*.lz" -exec touch {} \;
%.png: ;
%.2bpp: %.png ; $(gfx) 2bpp $<
%.1bpp: %.png ; $(gfx) 1bpp $<
%.lz: % ; $(gfx) lz $<

View File

@ -1,4 +0,0 @@
CRYSTAL11 = 1
CORRUPT_TILES = 1
INCLUDE "main.asm"

View File

@ -1,2 +0,0 @@
INCLUDE "pokecrystal.asm"
INCLUDE "data/egg_moves.asm"

View File

@ -1,2 +0,0 @@
INCLUDE "pokecrystal.asm"
INCLUDE "data/evos_attacks.asm"

View File

@ -1,2 +0,0 @@
INCLUDE "pokecrystal.asm"
INCLUDE "engine/credits.asm"

View File

@ -1,2 +0,0 @@
INCLUDE "pokecrystal.asm"
INCLUDE "engine/events.asm"

View File

@ -169,7 +169,7 @@ GetCaughtLevel: ; 4f18c
jr z, .unknown
cp 1 ; hatched from an egg
jr nz, .print
ld a, 5 ; egg hatch level
ld a, EGG_LEVEL ; egg hatch level
.print
ld [wSeerCaughtLevel], a

2
extras

@ -1 +1 @@
Subproject commit adbc204d741bec7a68c1e6cd67751f226d0347cb
Subproject commit 68edf51f1070b056c281471242220f9c6142e1b6

63
gfx.py
View File

@ -12,37 +12,59 @@ pics = [
'gfx/shrink2',
]
def recursive_read(filename):
def recurse(filename_):
lines = []
for line in open(filename_):
if 'include "' in line.lower():
lines += recurse(line.split('"')[1])
else:
lines += [line]
return lines
lines = recurse(filename)
return ''.join(lines)
base_stats = None
def get_base_stats():
global base_stats
if not base_stats:
base_stats = open('data/base_stats.asm').read()
base_stats = recursive_read('data/base_stats.asm')
return base_stats
def get_pokemon_dimensions(name):
if name == 'egg':
return 5, 5
if name.startswith('unown_'):
name = 'unown'
base_stats = get_base_stats()
start = base_stats.find(name.title() + 'BaseData:')
start = base_stats.find('\tdn ', start)
end = base_stats.find('\n', start)
line = base_stats[start:end].replace(',', ' ')
w, h = map(int, line.split()[1:3])
return w, h
try:
if name == 'egg':
return 5, 5
if name == 'questionmark':
return 7, 7
if name.startswith('unown_'):
name = 'unown'
base_stats = get_base_stats()
start = base_stats.find('\tdb ' + name.upper())
start = base_stats.find('\tdn ', start)
end = base_stats.find('\n', start)
line = base_stats[start:end].replace(',', ' ')
w, h = map(int, line.split()[1:3])
return w, h
except:
return 7, 7
def filepath_rules(filepath):
"""Infer attributes of certain graphics by their location in the filesystem."""
args = {}
filedir, filename = os.path.split(filepath)
if filedir.startswith('./'):
filedir = filedir[2:]
name, ext = os.path.splitext(filename)
if ext == '.lz':
name, ext = os.path.splitext(name)
pokemon_name = ''
if 'gfx/pics/' in filedir:
pokemon_name = filedir.split('/')[3]
pokemon_name = filedir.split('/')[-1]
if pokemon_name.startswith('unown_'):
index = filedir.find(pokemon_name)
if index != -1:
@ -84,22 +106,31 @@ def filepath_rules(filepath):
def to_1bpp(filename, **kwargs):
_, ext = os.path.splitext(filename)
name, ext = os.path.splitext(filename)
if ext == '.1bpp': pass
elif ext == '.2bpp': gfx.export_2bpp_to_1bpp(filename, **kwargs)
elif ext == '.png': gfx.export_png_to_1bpp(filename, **kwargs)
elif ext == '.lz':
decompress(filename, **kwargs)
to_1bpp(name, **kwargs)
def to_2bpp(filename, **kwargs):
_, ext = os.path.splitext(filename)
name, ext = os.path.splitext(filename)
if ext == '.1bpp': gfx.export_1bpp_to_2bpp(filename, **kwargs)
elif ext == '.2bpp': pass
elif ext == '.png': gfx.export_png_to_2bpp(filename, **kwargs)
elif ext == '.lz':
decompress(filename, **kwargs)
to_2bpp(name, **kwargs)
def to_png(filename, **kwargs):
_, ext = os.path.splitext(filename)
name, ext = os.path.splitext(filename)
if ext == '.1bpp': gfx.export_1bpp_to_png(filename, **kwargs)
elif ext == '.2bpp': gfx.export_2bpp_to_png(filename, **kwargs)
elif ext == '.png': pass
elif ext == '.lz':
decompress(filename, **kwargs)
to_png(name, **kwargs)
def compress(filename, **kwargs):
data = open(filename, 'rb').read()

View File

@ -50,6 +50,7 @@ hStringCmpString2 EQU $ffb5
hDividend EQU $ffb3 ; length in b register, before 'call Divide' (max 4 bytes)
hDivisor EQU $ffb7 ; 1 byte long
hQuotient EQU $ffb4 ; result (3 bytes long)
hRemainder EQU $ffb7
hMultiplicand EQU $ffb4 ; 3 bytes long
hMultiplier EQU $ffb7 ; 1 byte long

View File

@ -1,2 +1,3 @@
INCLUDE "version.asm"
INCLUDE "contents.asm"
INCLUDE "constants.asm"

View File

@ -1,2 +0,0 @@
INCLUDE "pokecrystal.asm"
INCLUDE "maps.asm"

View File

@ -1805,8 +1805,8 @@ Function48d94: ; 48d94 (12:4d94)
ld [hDivisor], a
ld b, 2
call Divide
ld a, [hDivisor]
ld c, $a
ld a, [hRemainder]
ld c, 10
call SimpleDivide
sla b
sla b

View File

@ -934,7 +934,7 @@ GFX_172f1f:
INCBIN "gfx/unknown/172f1f.2bpp"
Tilemap_1733af:
IF DEF(CORRUPT_TILES)
IF DEF(CRYSTAL11)
INCBIN "gfx/unknown/1733af_corrupt.tilemap"
ELSE
INCBIN "gfx/unknown/1733af.tilemap"

View File

@ -1,3 +0,0 @@
CRYSTAL11 = 1
INCLUDE "wram.asm"