Skip to content

Commit fe8d3c5

Browse files
authored
Build the Virtual Console patches with make red_vc and make blue_vc (#351)
1 parent 07df4a5 commit fe8d3c5

24 files changed

+1752
-34
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
*.wav binary
1616
*.blk binary
1717
*.pic binary
18+
19+
# Declare files that will always have CRLF line endings on checkout.
20+
*.patch.template text eol=crlf linguist-language=INI

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# compiled roms
1010
*.gbc
1111
*.gb
12+
*.patch
1213

1314
# rgbds extras
1415
*.map

Makefile

+55-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
roms := pokered.gbc pokeblue.gbc pokeblue_debug.gbc
1+
roms := \
2+
pokered.gbc \
3+
pokeblue.gbc \
4+
pokeblue_debug.gbc
5+
patches := \
6+
pokered.patch \
7+
pokeblue.patch
28

39
rom_obj := \
4-
audio.o \
5-
home.o \
6-
main.o \
7-
maps.o \
8-
text.o \
9-
wram.o \
10-
gfx/pics.o \
11-
gfx/sprites.o \
12-
gfx/tilesets.o
10+
audio.o \
11+
home.o \
12+
main.o \
13+
maps.o \
14+
text.o \
15+
wram.o \
16+
gfx/pics.o \
17+
gfx/sprites.o \
18+
gfx/tilesets.o
1319

1420
pokered_obj := $(rom_obj:.o=_red.o)
1521
pokeblue_obj := $(rom_obj:.o=_blue.o)
1622
pokeblue_debug_obj := $(rom_obj:.o=_blue_debug.o)
23+
pokered_vc_obj := $(rom_obj:.o=_red_vc.o)
24+
pokeblue_vc_obj := $(rom_obj:.o=_blue_vc.o)
1725

1826

1927
### Build tools
@@ -43,15 +51,34 @@ all: $(roms)
4351
red: pokered.gbc
4452
blue: pokeblue.gbc
4553
blue_debug: pokeblue_debug.gbc
54+
red_vc: pokered.patch
55+
blue_vc: pokeblue.patch
4656

4757
clean: tidy
48-
find gfx \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -delete
58+
find gfx \
59+
\( -iname '*.1bpp' \
60+
-o -iname '*.2bpp' \
61+
-o -iname '*.pic' \) \
62+
-delete
4963

5064
tidy:
51-
$(RM) $(roms) $(pokered_obj) $(pokeblue_obj) $(pokeblue_debug_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o
65+
$(RM) $(roms) \
66+
$(roms:.gbc=.sym) \
67+
$(roms:.gbc=.map) \
68+
$(patches) \
69+
$(patches:.patch=_vc.gbc) \
70+
$(patches:.patch=_vc.sym) \
71+
$(patches:.patch=_vc.map) \
72+
$(patches:%.patch=vc/%.constants.sym) \
73+
$(pokered_obj) \
74+
$(pokeblue_obj) \
75+
$(pokered_vc_obj) \
76+
$(pokeblue_vc_obj) \
77+
$(pokeblue_debug_obj) \
78+
rgbdscheck.o
5279
$(MAKE) clean -C tools/
5380

54-
compare: $(roms)
81+
compare: $(roms) $(patches)
5582
@$(SHA1) -c roms.sha1
5683

5784
tools:
@@ -67,6 +94,11 @@ endif
6794
$(pokered_obj): RGBASMFLAGS += -D _RED
6895
$(pokeblue_obj): RGBASMFLAGS += -D _BLUE
6996
$(pokeblue_debug_obj): RGBASMFLAGS += -D _BLUE -D _DEBUG
97+
$(pokered_vc_obj): RGBASMFLAGS += -D _RED -D _RED_VC
98+
$(pokeblue_vc_obj): RGBASMFLAGS += -D _BLUE -D _BLUE_VC
99+
100+
%.patch: vc/%.constants.sym %_vc.gbc %.gbc vc/%.patch.template
101+
tools/make_patch $*_vc.sym $^ $@
70102

71103
rgbdscheck.o: rgbdscheck.asm
72104
$(RGBASM) -o $@ $<
@@ -89,6 +121,12 @@ $(info $(shell $(MAKE) -C tools))
89121
$(foreach obj, $(pokered_obj), $(eval $(call DEP,$(obj),$(obj:_red.o=.asm))))
90122
$(foreach obj, $(pokeblue_obj), $(eval $(call DEP,$(obj),$(obj:_blue.o=.asm))))
91123
$(foreach obj, $(pokeblue_debug_obj), $(eval $(call DEP,$(obj),$(obj:_blue_debug.o=.asm))))
124+
$(foreach obj, $(pokered_vc_obj), $(eval $(call DEP,$(obj),$(obj:_red_vc.o=.asm))))
125+
$(foreach obj, $(pokeblue_vc_obj), $(eval $(call DEP,$(obj),$(obj:_blue_vc.o=.asm))))
126+
127+
# Dependencies for VC files that need to run scan_includes
128+
%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | rgbdscheck.o
129+
$(RGBASM) $< > $@
92130

93131
endif
94132

@@ -98,11 +136,15 @@ endif
98136

99137
pokered_pad = 0x00
100138
pokeblue_pad = 0x00
139+
pokered_vc_pad = 0x00
140+
pokeblue_vc_pad = 0x00
101141
pokeblue_debug_pad = 0xff
102142

103143
pokered_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON RED"
104144
pokeblue_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
105145
pokeblue_debug_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
146+
pokered_vc_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON RED"
147+
pokeblue_vc_opt = -jsv -n 0 -k 01 -l 0x33 -m 0x13 -r 03 -t "POKEMON BLUE"
106148

107149
%.gbc: $$(%_obj) layout.link
108150
$(RGBLINK) -p $($*_pad) -d -m $*.map -n $*.sym -l layout.link -o $@ $(filter %.o,$^)

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ It builds the following ROMs:
77
- Pokemon Red (UE) [S][!].gb `sha1: ea9bcae617fdf159b045185467ae58b2e4a48b9a`
88
- Pokemon Blue (UE) [S][!].gb `sha1: d7037c83e1ae5b39bde3c30787637ba1d4c48ce2`
99
- BLUEMONS.GB (debug build) `sha1: 5b1456177671b79b263c614ea0e7cc9ac542e9c4`
10+
- dmgapae0.e69.patch `sha1: 0fb5f743696adfe1dbb2e062111f08f9bc5a293a`
11+
- dmgapee0.e68.patch `sha1: ed4be94dc29c64271942c87f2157bca9ca1019c7`
1012

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

data/text/text_4.asm

+10
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,19 @@ _CableClubNPCPleaseWaitText::
211211
text_end
212212

213213
_CableClubNPCLinkClosedBecauseOfInactivityText::
214+
vc_patch Change_MSG
215+
IF DEF(_RED_VC) || DEF(_BLUE_VC)
216+
text "Please come again!"
217+
done
218+
text_start
219+
text "sed because of"
220+
cont "inactivity."
221+
ELSE
214222
text "The link has been"
215223
line "closed because of"
216224
cont "inactivity."
225+
ENDC
226+
vc_patch_end
217227

218228
para "Please contact"
219229
line "your friend and"

engine/battle/animations.asm

+29
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ PlayAnimation:
176176
ld h, [hl]
177177
ld l, a
178178
.animationLoop
179+
vc_hook FPA_Thunderbolt_End
179180
ld a, [hli]
181+
vc_hook_red FPA_007_End
182+
vc_hook_blue FPA_009_End
180183
cp -1
184+
vc_hook_blue FPA_008_End
181185
jr z, .AnimationOver
182186
cp FIRST_SE_ID ; is this subanimation or a special effect?
183187
jr c, .playSubanimation
@@ -246,37 +250,55 @@ PlayAnimation:
246250
ld a, [wAnimPalette]
247251
ldh [rOBP0], a
248252
call LoadAnimationTileset
253+
vc_hook FPA_001_Begin
249254
call LoadSubanimation
250255
call PlaySubanimation
256+
vc_hook FPA_001_End
251257
pop af
258+
vc_hook_red FPA_008_End
252259
ldh [rOBP0], a
253260
.nextAnimationCommand
261+
vc_hook FPA_005_End
254262
pop hl
263+
vc_hook FPA_002_End
255264
jr .animationLoop
256265
.AnimationOver
257266
ret
258267

259268
LoadSubanimation:
269+
vc_hook FPA_002_Begin
260270
ld a, [wSubAnimAddrPtr + 1]
271+
vc_hook FPA_003_Begin
261272
ld h, a
273+
vc_hook_red FPA_131_Begin
262274
ld a, [wSubAnimAddrPtr]
275+
vc_hook_red FPA_56_Begin
263276
ld l, a
264277
ld a, [hli]
265278
ld e, a
279+
vc_hook FPA_76_Begin
266280
ld a, [hl]
281+
vc_hook FPA_Thunderbolt_Begin
267282
ld d, a ; de = address of subanimation
268283
ld a, [de]
284+
vc_hook_blue FPA_012_Begin
269285
ld b, a
286+
vc_hook FPA_Spore_Begin
270287
and %00011111
288+
vc_hook FPA_Bubblebeam_Begin
271289
ld [wSubAnimCounter], a ; number of frame blocks
290+
vc_hook_red FPA_010_Begin
291+
vc_hook_blue FPA_009_Begin
272292
ld a, b
273293
and %11100000
274294
cp SUBANIMTYPE_ENEMY << 5
295+
vc_hook_blue FPA_004_Begin
275296
jr nz, .isNotType5
276297
.isType5
277298
call GetSubanimationTransform2
278299
jr .saveTransformation
279300
.isNotType5
301+
vc_hook FPA_Hyper_Beam_Begin
280302
call GetSubanimationTransform1
281303
.saveTransformation
282304
; place the upper 3 bits of a into bits 0-2 of a before storing
@@ -307,6 +329,7 @@ LoadSubanimation:
307329
; sets the transform to SUBANIMTYPE_NORMAL if it's the player's turn
308330
; sets the transform to the subanimation type if it's the enemy's turn
309331
GetSubanimationTransform1:
332+
vc_hook FPA_Reflect_Begin
310333
ld b, a
311334
ldh a, [hWhoseTurn]
312335
and a
@@ -399,11 +422,15 @@ MoveAnimation:
399422
jr nz, .animationsDisabled
400423
call ShareMoveAnimations
401424
call PlayAnimation
425+
vc_hook_red FPA_004_End
426+
vc_hook_blue FPA_011_End
402427
jr .next4
403428
.animationsDisabled
404429
ld c, 30
405430
call DelayFrames
406431
.next4
432+
vc_hook_red FPA_010_End
433+
vc_hook_blue FPA_012_End
407434
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
408435
.animationFinished
409436
call WaitForSoundToFinish
@@ -541,6 +568,7 @@ SetAnimationPalette:
541568
.notSGB
542569
ld a, $e4
543570
ld [wAnimPalette], a
571+
vc_hook FPA_Dream_Eater_Begin
544572
ldh [rOBP0], a
545573
ld a, $6c
546574
ldh [rOBP1], a
@@ -956,6 +984,7 @@ AnimationFlashScreenLong:
956984
ld [wFlashScreenLongCounter], a
957985
pop hl
958986
jr nz, .loop
987+
vc_hook_red FPA_phy_End
959988
ret
960989

961990
; BG palettes

engine/battle/core.asm

+25
Original file line numberDiff line numberDiff line change
@@ -3023,25 +3023,41 @@ LinkBattleExchangeData:
30233023
ld a, b
30243024
.doExchange
30253025
ld [wSerialExchangeNybbleSendData], a
3026+
vc_hook send_byt2
30263027
callfar PrintWaitingText
30273028
.syncLoop1
30283029
call Serial_ExchangeNybble
30293030
call DelayFrame
30303031
ld a, [wSerialExchangeNybbleReceiveData]
30313032
inc a
30323033
jr z, .syncLoop1
3034+
vc_hook send_byt2_ret
3035+
vc_patch FIGHT
3036+
IF DEF(_RED_VC) || DEF(_BLUE_VC)
3037+
ld b, 26
3038+
ELSE
30333039
ld b, 10
3040+
ENDC
3041+
vc_patch_end
30343042
.syncLoop2
30353043
call DelayFrame
30363044
call Serial_ExchangeNybble
30373045
dec b
30383046
jr nz, .syncLoop2
3047+
vc_hook send_dummy
3048+
vc_patch FIGHT2
3049+
IF DEF(_RED_VC) || DEF(_BLUE_VC)
3050+
ld b, 26
3051+
ELSE
30393052
ld b, 10
3053+
ENDC
3054+
vc_patch_end
30403055
.syncLoop3
30413056
call DelayFrame
30423057
call Serial_SendZeroByte
30433058
dec b
30443059
jr nz, .syncLoop3
3060+
vc_hook send_dummy_end
30453061
ret
30463062

30473063
ExecutePlayerMove:
@@ -6661,7 +6677,14 @@ BattleRandom:
66616677
ld a, [hl]
66626678
pop bc
66636679
pop hl
6680+
vc_hook fight_ret_c
6681+
vc_patch fight_ret
6682+
IF DEF(_RED_VC) || DEF(_BLUE_VC)
6683+
ret
6684+
ELSE
66646685
ret c
6686+
ENDC
6687+
vc_patch_end
66656688

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

67276750
PlayMoveAnimation:
67286751
ld [wAnimationID], a
6752+
vc_hook_red FPA_conf_Begin
67296753
call Delay3
6754+
vc_hook_red FPA_phy_Begin
67306755
predef_jump MoveAnimation
67316756

67326757
InitBattle::

engine/gfx/palettes.asm

+1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ CheckSGB:
484484
ldh a, [rJOYP]
485485
ldh a, [rJOYP]
486486
call Wait7000
487+
vc_hook Network_RESET
487488
call Wait7000
488489
ld a, $30
489490
ldh [rJOYP], a

engine/link/cable_club.asm

+4
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,21 @@ CableClub_DoBattleOrTradeAgain:
124124
ld hl, wSerialRandomNumberListBlock
125125
ld de, wSerialOtherGameboyRandomNumberListBlock
126126
ld bc, $11
127+
vc_hook Network17
127128
call Serial_ExchangeBytes
128129
ld a, SERIAL_NO_DATA_BYTE
129130
ld [de], a
130131
ld hl, wSerialPlayerDataBlock
131132
ld de, wSerialEnemyDataBlock
132133
ld bc, $1a8
134+
vc_hook Network424
133135
call Serial_ExchangeBytes
134136
ld a, SERIAL_NO_DATA_BYTE
135137
ld [de], a
136138
ld hl, wSerialPartyMonsPatchList
137139
ld de, wSerialEnemyMonsPatchList
138140
ld bc, $c8
141+
vc_hook Network200
139142
call Serial_ExchangeBytes
140143
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
141144
ldh [rIE], a
@@ -859,6 +862,7 @@ TradeCenter_Trade:
859862
ld de, TradeCompleted
860863
call PlaceString
861864
predef SaveSAVtoSRAM2
865+
vc_hook save_game_end
862866
ld c, 50
863867
call DelayFrames
864868
xor a

0 commit comments

Comments
 (0)