Skip to content

Commit

Permalink
Build the Virtual Console patches with make red_vc and `make blue_v…
Browse files Browse the repository at this point in the history
…c` (#351)
  • Loading branch information
vulcandth committed Mar 26, 2022
1 parent 07df4a5 commit fe8d3c5
Show file tree
Hide file tree
Showing 24 changed files with 1,752 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
*.wav binary
*.blk binary
*.pic binary

# Declare files that will always have CRLF line endings on checkout.
*.patch.template text eol=crlf linguist-language=INI
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# compiled roms
*.gbc
*.gb
*.patch

# rgbds extras
*.map
Expand Down
68 changes: 55 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
roms := pokered.gbc pokeblue.gbc pokeblue_debug.gbc
roms := \
pokered.gbc \
pokeblue.gbc \
pokeblue_debug.gbc
patches := \
pokered.patch \
pokeblue.patch

rom_obj := \
audio.o \
home.o \
main.o \
maps.o \
text.o \
wram.o \
gfx/pics.o \
gfx/sprites.o \
gfx/tilesets.o
audio.o \
home.o \
main.o \
maps.o \
text.o \
wram.o \
gfx/pics.o \
gfx/sprites.o \
gfx/tilesets.o

pokered_obj := $(rom_obj:.o=_red.o)
pokeblue_obj := $(rom_obj:.o=_blue.o)
pokeblue_debug_obj := $(rom_obj:.o=_blue_debug.o)
pokered_vc_obj := $(rom_obj:.o=_red_vc.o)
pokeblue_vc_obj := $(rom_obj:.o=_blue_vc.o)


### Build tools
Expand Down Expand Up @@ -43,15 +51,34 @@ all: $(roms)
red: pokered.gbc
blue: pokeblue.gbc
blue_debug: pokeblue_debug.gbc
red_vc: pokered.patch
blue_vc: pokeblue.patch

clean: tidy
find gfx \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -delete
find gfx \
\( -iname '*.1bpp' \
-o -iname '*.2bpp' \
-o -iname '*.pic' \) \
-delete

tidy:
$(RM) $(roms) $(pokered_obj) $(pokeblue_obj) $(pokeblue_debug_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o
$(RM) $(roms) \
$(roms:.gbc=.sym) \
$(roms:.gbc=.map) \
$(patches) \
$(patches:.patch=_vc.gbc) \
$(patches:.patch=_vc.sym) \
$(patches:.patch=_vc.map) \
$(patches:%.patch=vc/%.constants.sym) \
$(pokered_obj) \
$(pokeblue_obj) \
$(pokered_vc_obj) \
$(pokeblue_vc_obj) \
$(pokeblue_debug_obj) \
rgbdscheck.o
$(MAKE) clean -C tools/

compare: $(roms)
compare: $(roms) $(patches)
@$(SHA1) -c roms.sha1

tools:
Expand All @@ -67,6 +94,11 @@ endif
$(pokered_obj): RGBASMFLAGS += -D _RED
$(pokeblue_obj): RGBASMFLAGS += -D _BLUE
$(pokeblue_debug_obj): RGBASMFLAGS += -D _BLUE -D _DEBUG
$(pokered_vc_obj): RGBASMFLAGS += -D _RED -D _RED_VC
$(pokeblue_vc_obj): RGBASMFLAGS += -D _BLUE -D _BLUE_VC

%.patch: vc/%.constants.sym %_vc.gbc %.gbc vc/%.patch.template
tools/make_patch $*_vc.sym $^ $@

rgbdscheck.o: rgbdscheck.asm
$(RGBASM) -o $@ $<
Expand All @@ -89,6 +121,12 @@ $(info $(shell $(MAKE) -C tools))
$(foreach obj, $(pokered_obj), $(eval $(call DEP,$(obj),$(obj:_red.o=.asm))))
$(foreach obj, $(pokeblue_obj), $(eval $(call DEP,$(obj),$(obj:_blue.o=.asm))))
$(foreach obj, $(pokeblue_debug_obj), $(eval $(call DEP,$(obj),$(obj:_blue_debug.o=.asm))))
$(foreach obj, $(pokered_vc_obj), $(eval $(call DEP,$(obj),$(obj:_red_vc.o=.asm))))
$(foreach obj, $(pokeblue_vc_obj), $(eval $(call DEP,$(obj),$(obj:_blue_vc.o=.asm))))

# Dependencies for VC files that need to run scan_includes
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | rgbdscheck.o
$(RGBASM) $< > $@

endif

Expand All @@ -98,11 +136,15 @@ endif

pokered_pad = 0x00
pokeblue_pad = 0x00
pokered_vc_pad = 0x00
pokeblue_vc_pad = 0x00
pokeblue_debug_pad = 0xff

pokered_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON RED"
pokeblue_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
pokeblue_debug_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
pokered_vc_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON RED"
pokeblue_vc_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"

%.gbc: $$(%_obj) layout.link
$(RGBLINK) -p $($*_pad) -d -m $*.map -n $*.sym -l layout.link -o $@ $(filter %.o,$^)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ It builds the following ROMs:
- Pokemon Red (UE) [S][!].gb `sha1: ea9bcae617fdf159b045185467ae58b2e4a48b9a`
- Pokemon Blue (UE) [S][!].gb `sha1: d7037c83e1ae5b39bde3c30787637ba1d4c48ce2`
- BLUEMONS.GB (debug build) `sha1: 5b1456177671b79b263c614ea0e7cc9ac542e9c4`
- dmgapae0.e69.patch `sha1: 0fb5f743696adfe1dbb2e062111f08f9bc5a293a`
- dmgapee0.e68.patch `sha1: ed4be94dc29c64271942c87f2157bca9ca1019c7`

To set up the repository, see [**INSTALL.md**](INSTALL.md).

Expand Down
10 changes: 10 additions & 0 deletions data/text/text_4.asm
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,19 @@ _CableClubNPCPleaseWaitText::
text_end

_CableClubNPCLinkClosedBecauseOfInactivityText::
vc_patch Change_MSG
IF DEF(_RED_VC) || DEF(_BLUE_VC)
text "Please come again!"
done
text_start
text "sed because of"
cont "inactivity."
ELSE
text "The link has been"
line "closed because of"
cont "inactivity."
ENDC
vc_patch_end

para "Please contact"
line "your friend and"
Expand Down
29 changes: 29 additions & 0 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ PlayAnimation:
ld h, [hl]
ld l, a
.animationLoop
vc_hook FPA_Thunderbolt_End
ld a, [hli]
vc_hook_red FPA_007_End
vc_hook_blue FPA_009_End
cp -1
vc_hook_blue FPA_008_End
jr z, .AnimationOver
cp FIRST_SE_ID ; is this subanimation or a special effect?
jr c, .playSubanimation
Expand Down Expand Up @@ -246,37 +250,55 @@ PlayAnimation:
ld a, [wAnimPalette]
ldh [rOBP0], a
call LoadAnimationTileset
vc_hook FPA_001_Begin
call LoadSubanimation
call PlaySubanimation
vc_hook FPA_001_End
pop af
vc_hook_red FPA_008_End
ldh [rOBP0], a
.nextAnimationCommand
vc_hook FPA_005_End
pop hl
vc_hook FPA_002_End
jr .animationLoop
.AnimationOver
ret

LoadSubanimation:
vc_hook FPA_002_Begin
ld a, [wSubAnimAddrPtr + 1]
vc_hook FPA_003_Begin
ld h, a
vc_hook_red FPA_131_Begin
ld a, [wSubAnimAddrPtr]
vc_hook_red FPA_56_Begin
ld l, a
ld a, [hli]
ld e, a
vc_hook FPA_76_Begin
ld a, [hl]
vc_hook FPA_Thunderbolt_Begin
ld d, a ; de = address of subanimation
ld a, [de]
vc_hook_blue FPA_012_Begin
ld b, a
vc_hook FPA_Spore_Begin
and %00011111
vc_hook FPA_Bubblebeam_Begin
ld [wSubAnimCounter], a ; number of frame blocks
vc_hook_red FPA_010_Begin
vc_hook_blue FPA_009_Begin
ld a, b
and %11100000
cp SUBANIMTYPE_ENEMY << 5
vc_hook_blue FPA_004_Begin
jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
jr .saveTransformation
.isNotType5
vc_hook FPA_Hyper_Beam_Begin
call GetSubanimationTransform1
.saveTransformation
; place the upper 3 bits of a into bits 0-2 of a before storing
Expand Down Expand Up @@ -307,6 +329,7 @@ LoadSubanimation:
; sets the transform to SUBANIMTYPE_NORMAL if it's the player's turn
; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1:
vc_hook FPA_Reflect_Begin
ld b, a
ldh a, [hWhoseTurn]
and a
Expand Down Expand Up @@ -399,11 +422,15 @@ MoveAnimation:
jr nz, .animationsDisabled
call ShareMoveAnimations
call PlayAnimation
vc_hook_red FPA_004_End
vc_hook_blue FPA_011_End
jr .next4
.animationsDisabled
ld c, 30
call DelayFrames
.next4
vc_hook_red FPA_010_End
vc_hook_blue FPA_012_End
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
.animationFinished
call WaitForSoundToFinish
Expand Down Expand Up @@ -541,6 +568,7 @@ SetAnimationPalette:
.notSGB
ld a, $e4
ld [wAnimPalette], a
vc_hook FPA_Dream_Eater_Begin
ldh [rOBP0], a
ld a, $6c
ldh [rOBP1], a
Expand Down Expand Up @@ -956,6 +984,7 @@ AnimationFlashScreenLong:
ld [wFlashScreenLongCounter], a
pop hl
jr nz, .loop
vc_hook_red FPA_phy_End
ret

; BG palettes
Expand Down
25 changes: 25 additions & 0 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3023,25 +3023,41 @@ LinkBattleExchangeData:
ld a, b
.doExchange
ld [wSerialExchangeNybbleSendData], a
vc_hook send_byt2
callfar PrintWaitingText
.syncLoop1
call Serial_ExchangeNybble
call DelayFrame
ld a, [wSerialExchangeNybbleReceiveData]
inc a
jr z, .syncLoop1
vc_hook send_byt2_ret
vc_patch FIGHT
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ld b, 26
ELSE
ld b, 10
ENDC
vc_patch_end
.syncLoop2
call DelayFrame
call Serial_ExchangeNybble
dec b
jr nz, .syncLoop2
vc_hook send_dummy
vc_patch FIGHT2
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ld b, 26
ELSE
ld b, 10
ENDC
vc_patch_end
.syncLoop3
call DelayFrame
call Serial_SendZeroByte
dec b
jr nz, .syncLoop3
vc_hook send_dummy_end
ret

ExecutePlayerMove:
Expand Down Expand Up @@ -6661,7 +6677,14 @@ BattleRandom:
ld a, [hl]
pop bc
pop hl
vc_hook fight_ret_c
vc_patch fight_ret
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ret
ELSE
ret c
ENDC
vc_patch_end

; if we picked the last seed, we need to recalculate the nine seeds
push hl
Expand Down Expand Up @@ -6726,7 +6749,9 @@ HandleExplodingAnimation:

PlayMoveAnimation:
ld [wAnimationID], a
vc_hook_red FPA_conf_Begin
call Delay3
vc_hook_red FPA_phy_Begin
predef_jump MoveAnimation

InitBattle::
Expand Down
1 change: 1 addition & 0 deletions engine/gfx/palettes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ CheckSGB:
ldh a, [rJOYP]
ldh a, [rJOYP]
call Wait7000
vc_hook Network_RESET
call Wait7000
ld a, $30
ldh [rJOYP], a
Expand Down
4 changes: 4 additions & 0 deletions engine/link/cable_club.asm
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,21 @@ CableClub_DoBattleOrTradeAgain:
ld hl, wSerialRandomNumberListBlock
ld de, wSerialOtherGameboyRandomNumberListBlock
ld bc, $11
vc_hook Network17
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wSerialPlayerDataBlock
ld de, wSerialEnemyDataBlock
ld bc, $1a8
vc_hook Network424
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
ld hl, wSerialPartyMonsPatchList
ld de, wSerialEnemyMonsPatchList
ld bc, $c8
vc_hook Network200
call Serial_ExchangeBytes
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
ldh [rIE], a
Expand Down Expand Up @@ -859,6 +862,7 @@ TradeCenter_Trade:
ld de, TradeCompleted
call PlaceString
predef SaveSAVtoSRAM2
vc_hook save_game_end
ld c, 50
call DelayFrames
xor a
Expand Down
Loading

0 comments on commit fe8d3c5

Please sign in to comment.