Skip to content

Commit

Permalink
Merge pull request #456 from Rangi42/master
Browse files Browse the repository at this point in the history
OAM data documentation; move more content into data/; move palettes into gfx/; more code+script constants; consistent map naming
  • Loading branch information
yenatch authored Jan 22, 2018
2 parents f27f794 + 7fba864 commit c60f133
Show file tree
Hide file tree
Showing 1,232 changed files with 20,377 additions and 19,687 deletions.
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## What is pokecrystal11.gbc?

Version 1.1 of Pokémon Crystal, which fixed some issues with the initial international release. `make crystal11` defines `CRYSTAL11` so the assembly builds the changed version.
Version 1.1 of Pokémon Crystal, which fixed some issues with the initial international release. `make crystal11` defines `_CRYSTAL11` so the assembly builds the changed version.


## Can't build ROM; "ERROR: `UNION` already defined"
Expand Down
43 changes: 26 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ crystal_obj := \
audio.o \
home.o \
main.o \
maps.o \
wram.o \
data/common_text/common_text.o \
data/maps/maps.o \
data/pokemon/dex_entries.o \
data/pokemon/egg_moves.o \
data/pokemon/evos_attacks.o \
engine/credits.o \
engine/events.o \
gfx/pics.o \
gfx/sprites.o \
lib/mobile/main.o \
text/common_text.o
lib/mobile/main.o

crystal11_obj := $(crystal_obj:.o=11.o)

Expand All @@ -52,7 +52,8 @@ tools:
$(MAKE) -C tools/


$(crystal11_obj): RGBASMFLAGS = -D CRYSTAL11
$(crystal_obj): RGBASMFLAGS = -D _CRYSTAL
$(crystal11_obj): RGBASMFLAGS = -D _CRYSTAL -D _CRYSTAL11

# The dep rules have to be explicit or else missing files won't be reported.
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
Expand All @@ -77,12 +78,12 @@ endif
pokecrystal11.gbc: $(crystal11_obj) pokecrystal.link
$(RGBLINK) -n pokecrystal11.sym -m pokecrystal11.map -l pokecrystal.link -o $@ $(crystal11_obj)
$(RGBFIX) -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -n 1 -p 0 -r 3 -t PM_CRYSTAL $@
sort pokecrystal11.sym -o pokecrystal11.sym
tools/sort_symfile.sh pokecrystal11.sym

pokecrystal.gbc: $(crystal_obj) pokecrystal.link
$(RGBLINK) -n pokecrystal.sym -m pokecrystal.map -l pokecrystal.link -o $@ $(crystal_obj)
$(RGBFIX) -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
sort pokecrystal.sym -o pokecrystal.sym
tools/sort_symfile.sh pokecrystal.sym


# For files that the compressor can't match, there will be a .lz file suffixed with the md5 hash of the correct uncompressed file.
Expand Down Expand Up @@ -119,10 +120,12 @@ gfx/pokemon/girafarig/front.animated.tilemap: gfx/pokemon/girafarig/front.2bpp g

### Pokemon pic graphics rules

gfx/pokemon/%/normal.gbcpal: gfx/pokemon/%/front.png
$(RGBGFX) -p $@ $<
gfx/pokemon/%/front.dimensions: gfx/pokemon/%/front.png
tools/png_dimensions $< $@
gfx/pokemon/%/normal.pal: gfx/pokemon/%/normal.gbcpal
tools/palette -p $< > $@
gfx/pokemon/%/normal.gbcpal: gfx/pokemon/%/front.png
$(RGBGFX) -p $@ $<
gfx/pokemon/%/back.2bpp: gfx/pokemon/%/back.png
$(RGBGFX) -h -o $@ $<
gfx/pokemon/%/bitmask.asm: gfx/pokemon/%/front.animated.tilemap gfx/pokemon/%/front.dimensions
Expand All @@ -133,19 +136,18 @@ gfx/pokemon/%/front.animated.2bpp: gfx/pokemon/%/front.2bpp gfx/pokemon/%/front.
tools/pokemon_animation_graphics -o $@ $^
gfx/pokemon/%/front.animated.tilemap: gfx/pokemon/%/front.2bpp gfx/pokemon/%/front.dimensions
tools/pokemon_animation_graphics -t $@ $^
# Don't use -h, pokemon_animation_graphics takes care of it
#gfx/pokemon/%/front.2bpp: gfx/pokemon/%/front.png
# $(RGBGFX) -o $@ $<


### Misc file-specific graphics rules

gfx/shrink/shrink1.2bpp: rgbgfx += -h
gfx/shrink/shrink2.2bpp: rgbgfx += -h
gfx/new_game/shrink1.2bpp: rgbgfx += -h
gfx/new_game/shrink2.2bpp: rgbgfx += -h

gfx/trainers/%.2bpp: rgbgfx += -h
gfx/trainers/%.pal: gfx/trainers/%.gbcpal
tools/palette -p $< > $@
gfx/trainers/%.gbcpal: gfx/trainers/%.png
$(RGBGFX) -p $@ $<

gfx/mail/dragonite.1bpp: tools/gfx += --remove-whitespace
gfx/mail/large_note.1bpp: tools/gfx += --remove-whitespace
Expand All @@ -157,6 +159,11 @@ gfx/pokedex/pokedex.2bpp: tools/gfx += --trim-whitespace
gfx/pokedex/sgb.2bpp: tools/gfx += --trim-whitespace
gfx/pokedex/slowpoke.2bpp: tools/gfx += --trim-whitespace

gfx/pokegear/pokegear.2bpp: rgbgfx += -x2
gfx/pokegear/pokegear_sprites.2bpp: tools/gfx += --trim-whitespace

gfx/mystery_gift/mystery_gift.2bpp: tools/gfx += --trim-whitespace

gfx/title/crystal.2bpp: tools/gfx += --interleave --png=$<
gfx/title/old_fg.2bpp: tools/gfx += --interleave --png=$<
gfx/title/logo.2bpp: rgbgfx += -x 4
Expand Down Expand Up @@ -194,17 +201,21 @@ gfx/player/kris_back.2bpp: rgbgfx += -h

gfx/trainer_card/chris_card.2bpp: rgbgfx += -h
gfx/trainer_card/kris_card.2bpp: rgbgfx += -h
gfx/trainer_card/leaders.2bpp: tools/gfx += --trim-whitespace

gfx/overworld/chris_fish.2bpp: tools/gfx += --trim-whitespace
gfx/overworld/kris_fish.2bpp: tools/gfx += --trim-whitespace

gfx/battle/dude.2bpp: rgbgfx += -h

gfx/font/unused_bold_font.1bpp: tools/gfx += --trim-whitespace

gfx/pokegear/pokegear.2bpp: rgbgfx += -x2
gfx/pokegear/pokegear_sprites.2bpp: tools/gfx += --trim-whitespace
gfx/sgb/sgb_border.2bpp: tools/gfx += --trim-whitespace

gfx/mobile/ascii_font.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/electro_ball.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/electro_ball_nonmatching.2bpp: tools/gfx += --remove-duplicates --remove-xflip
gfx/mobile/mobile_adapter.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/mobile_splash.2bpp: tools/gfx += --remove-duplicates --remove-xflip
gfx/mobile/pichu_animated.2bpp: tools/gfx += --trim-whitespace

Expand All @@ -228,7 +239,5 @@ gfx/unknown/unknown_egg.2bpp: rgbgfx += -h
$(RGBGFX) -t $@ $<
%.gbcpal: %.png
$(RGBGFX) -p $@ $<
%.pal: %.gbcpal
tools/palette $< > $@
%.dimensions: %.png
tools/png_dimensions $< $@
2 changes: 2 additions & 0 deletions STYLE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Style Guide

Some of the code will disagree with this guide. Older code is less likely to be correct. Use your best judgement.

When you come across an edge case that isn't referenced in this guide, please add it.
Expand Down
2 changes: 1 addition & 1 deletion audio.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
INCLUDE "includes.asm"
INCLUDE "constants.asm"


SECTION "Audio", ROMX
Expand Down
42 changes: 21 additions & 21 deletions audio/engine.asm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _MapSetup_Sound_Off:: ; e8000

ld hl, Channels ; start of channel data
ld de, ChannelsEnd - Channels ; length of area to clear (entire sound wram area)
.clearchannels ; clear Channel1-$c2bf
.clearchannels
xor a
ld [hli], a
dec de
Expand Down Expand Up @@ -408,7 +408,7 @@ UpdateChannels: ; e8125
ret

.asm_e824d
ld a, $3f
ld a, $3f ; sound length
ld [rNR31], a
xor a
ld [rNR30], a
Expand Down Expand Up @@ -1304,8 +1304,8 @@ ParseSFXOrRest: ; e8698
ld [hl], a
; are we on the last channel? (noise sampling)
ld a, [CurChannel]
and $3
cp $3
maskbits NUM_MUSIC_CHANS
cp CHAN4
ret z
; update hi frequency from next param
call GetMusicByte
Expand All @@ -1320,8 +1320,8 @@ GetNoiseSample: ; e86c5
; load ptr to sample header in NoiseSampleAddress
; are we on the last channel?
ld a, [CurChannel]
and $3
cp $3
and NUM_MUSIC_CHANS +- 1
cp CHAN4
; ret if not
ret nz
; update note duration
Expand Down Expand Up @@ -1668,7 +1668,7 @@ MusicEE; e883e
; if ????, jump
; get channel
ld a, [CurChannel]
and $3 ; ch0-3
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
; hl = Channel1JumpCondition + channel id
Expand Down Expand Up @@ -1966,8 +1966,8 @@ Music_NoteType: ; e8963
add hl, bc
ld [hl], a
ld a, [CurChannel]
and $3
cp CHAN8 & $3
maskbits NUM_MUSIC_CHANS
cp CHAN4
ret z
; intensity
call Music_Intensity
Expand Down Expand Up @@ -2414,7 +2414,7 @@ SetLRTracks: ; e8b1b
push de
; store current channel in de
ld a, [CurChannel]
and $3
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
; get this channel's lr tracks
Expand Down Expand Up @@ -2449,7 +2449,7 @@ _PlayMusic:: ; e8b30
call LoadMusicByte ; store first byte of music header in a
rlca
rlca
and $3 ; get number of channels
maskbits NUM_MUSIC_CHANS
inc a
.loop
; start playing channels
Expand All @@ -2474,7 +2474,7 @@ _PlayMusic:: ; e8b30

; e8b79

_PlayCryHeader:: ; e8b79
_PlayCry:: ; e8b79
; Play cry de using parameters:
; CryPitch
; CryLength
Expand Down Expand Up @@ -2505,7 +2505,7 @@ _PlayCryHeader:: ; e8b79
; Top 2 bits contain the number of channels
rlca
rlca
and 3
maskbits NUM_MUSIC_CHANS

; For each channel:
inc a
Expand All @@ -2530,8 +2530,8 @@ _PlayCryHeader:: ; e8b79

; No tempo for channel 4
ld a, [CurChannel]
and 3
cp 3
maskbits NUM_MUSIC_CHANS
cp CHAN4
jr nc, .start

; Tempo is effectively length
Expand Down Expand Up @@ -2669,7 +2669,7 @@ _PlaySFX:: ; e8c04
call LoadMusicByte
rlca ; top 2
rlca ; bits
and $3
maskbits NUM_MUSIC_CHANS
inc a ; # channels -> # loops
.startchannels
push af
Expand Down Expand Up @@ -2722,7 +2722,7 @@ PlayStereoSFX:: ; e8ca6
call LoadMusicByte
rlca
rlca
and 3 ; ch1-4
maskbits NUM_MUSIC_CHANS
inc a

.loop
Expand All @@ -2736,7 +2736,7 @@ PlayStereoSFX:: ; e8ca6
push de
; get tracks for this channel
ld a, [CurChannel]
and 3 ; ch1-4
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
call GetLRTracks
Expand All @@ -2749,7 +2749,7 @@ PlayStereoSFX:: ; e8ca6
add hl, bc
ld [hl], a

ld hl, Channel1Field30 - Channel1 ; $c131 - Channel1
ld hl, Channel1Field30 - Channel1
add hl, bc
ld [hl], a

Expand All @@ -2760,11 +2760,11 @@ PlayStereoSFX:: ; e8ca6
; ch3-4
ld a, [wSFXDuration]

ld hl, Channel1Field2e - Channel1 ; $c12f - Channel1
ld hl, Channel1Field2e - Channel1
add hl, bc
ld [hl], a

ld hl, Channel1Field2f - Channel1 ; $c130 - Channel1
ld hl, Channel1Field2f - Channel1
add hl, bc
ld [hl], a

Expand Down
6 changes: 3 additions & 3 deletions audio/sfx.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Sfx_PokeballsPlacedOnTable: ; f0941
musicheader 1, 5, Sfx_PokeballsPlacedOnTable_Ch5
; f0944

Sfx_BallWiggle: ; f0944
musicheader 1, 5, Sfx_BallWiggle_Ch5
Sfx_BallWobble: ; f0944
musicheader 1, 5, Sfx_BallWobble_Ch5
; f0947

Sfx_Potion: ; f0947
Expand Down Expand Up @@ -4075,7 +4075,7 @@ Sfx_PokeballsPlacedOnTable_Ch5: ; f1d21
endchannel
; f1d32

Sfx_BallWiggle_Ch5: ; f1d32
Sfx_BallWobble_Ch5: ; f1d32
dutycycle $2
soundinput $3a
sound __, 5, $f2, $0400
Expand Down
2 changes: 1 addition & 1 deletion audio/sfx_pointers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ SFX: ; e927c
dba Sfx_Encore
dba Sfx_BeatUp
dba Sfx_BatonPass
dba Sfx_BallWiggle
dba Sfx_BallWobble
dba Sfx_SweetScent
dba Sfx_SweetScent2
dba Sfx_HitEndOfExpBar
Expand Down
Loading

0 comments on commit c60f133

Please sign in to comment.