Skip to content

Commit

Permalink
Build the Virtual Console patch with make yellow_vc (pret#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
vulcandth authored Mar 27, 2022
1 parent a178c57 commit fbaa5c9
Show file tree
Hide file tree
Showing 30 changed files with 1,288 additions and 42 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 @@ -12,6 +12,7 @@
# compiled roms
*.gbc
*.gb
*.patch

# rgbds extras
*.map
Expand Down
63 changes: 48 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
roms := pokeyellow.gbc pokeyellow_debug.gbc
roms := \
pokeyellow.gbc \
pokeyellow_debug.gbc
patches := \
pokeyellow.patch

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

pokeyellow_obj := $(rom_obj)
pokeyellow_debug_obj := $(rom_obj:.o=_debug.o)
pokeyellow_vc_obj := $(rom_obj:.o=_vc.o)


### Build tools
Expand Down Expand Up @@ -42,16 +47,34 @@ RGBLINK ?= $(RGBDS)rgblink
all: $(roms)
yellow: pokeyellow.gbc
yellow_debug: pokeyellow_debug.gbc
yellow_vc: pokeyellow.patch

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

tidy:
$(RM) $(roms) $(pokeyellow_obj) $(pokeyellow_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) \
$(pokeyellow_obj) \
$(pokeyellow_vc_obj) \
$(pokeyellow_debug_obj) \
rgbdscheck.o
$(MAKE) clean -C tools/

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

tools:
Expand All @@ -65,6 +88,10 @@ RGBASMFLAGS += -E
endif

$(pokeyellow_debug_obj): RGBASMFLAGS += -D _DEBUG
$(pokeyellow_vc_obj): RGBASMFLAGS += -D _YELLOW_VC

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

rgbdscheck.o: rgbdscheck.asm
$(RGBASM) -o $@ $<
Expand All @@ -86,6 +113,11 @@ $(info $(shell $(MAKE) -C tools))
# Dependencies for objects
$(foreach obj, $(pokeyellow_obj), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
$(foreach obj, $(pokeyellow_debug_obj), $(eval $(call DEP,$(obj),$(obj:_debug.o=.asm))))
$(foreach obj, $(pokeyellow_vc_obj), $(eval $(call DEP,$(obj),$(obj:_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 @@ -95,6 +127,7 @@ endif

pokeyellow_pad = 0x00
pokeyellow_debug_pad = 0xff
pokeyellow_vc_pad = 0x00

opts = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 -t "POKEMON YELLOW"

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ It builds the following ROMs:

- Pokemon Yellow (UE) [C][!].gbc `sha1: cc7d03262ebfaf2f06772c1a480c7d9d5f4a38e1`
- YELLMONS.GB (debug build) `sha1: d44e96eddfbdad633cbe4e6e64915e9e198974b0`
- Dmgapse0.h08.patch `sha1: f3346a5559d52c296b8feab0cdbbfb0e250ac161`

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

Expand Down
2 changes: 1 addition & 1 deletion audio.asm
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ INCLUDE "audio/music/yellowunusedsong.asm"
INCLUDE "audio/music/meetjessiejames.asm"

IF !DEF(_DEBUG)
INCBIN "garbage/bank20.bin"
INCBIN "garbage/bank20.bin"
ENDC


Expand Down
2 changes: 1 addition & 1 deletion data/pikachu/pikachu_pic_objects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ PikaPicAnimBGFrames_33:
pikaframeend

PikaPicAnimBGFrames_34:
pikaframedelay 12
pikaframedelay 12
pikaframe PikaAnimTilemap_9, 12
pikaframedelay 12
pikaframe PikaAnimTilemap_9, 100
Expand Down
10 changes: 10 additions & 0 deletions data/text/text_8.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ _CableClubNPCPleaseWaitText::
text_end

_CableClubNPCLinkClosedBecauseOfInactivityText::
vc_patch Change_MSG
IF DEF(_YELLOW_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
21 changes: 21 additions & 0 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ PlayAnimation:
ld h, [hl]
ld l, a
.animationLoop
vc_hook FPA_005_End
ld a, [hli]
vc_hook FPA_001_End
cp -1
jr z, .AnimationOver
cp FIRST_SE_ID ; is this subanimation or a special effect?
Expand Down Expand Up @@ -277,12 +279,17 @@ PlayAnimation:
call LoadSubanimation
call PlaySubanimation
pop af
vc_hook FPA_007_End
ldh [rOBP0], a
vc_hook FPA_011_End
call UpdateGBCPal_OBP0
.nextAnimationCommand
vc_hook FPA_002_End
pop hl
vc_hook FPA_003_End
jr .animationLoop
.AnimationOver
vc_hook FPA_004_End
ret

LoadSubanimation:
Expand All @@ -294,18 +301,26 @@ LoadSubanimation:
ld e, a
ld a, [hl]
ld d, a ; de = address of subanimation
vc_hook FPA_005_Begin
ld a, [de]
vc_hook FPA_003_Begin
ld b, a
vc_hook FPA_002_Begin
and %00011111
vc_hook FPA_001_Begin
ld [wSubAnimCounter], a ; number of frame blocks
vc_hook FPA_004_Begin
ld a, b
vc_hook FPA_007_Begin
and %11100000
cp SUBANIMTYPE_ENEMY << 5
vc_hook FPA_009_Begin
jr nz, .isNotType5
.isType5
call GetSubanimationTransform2
jr .saveTransformation
.isNotType5
vc_hook FPA_010_Begin
call GetSubanimationTransform1
.saveTransformation
; place the upper 3 bits of a into bits 0-2 of a before storing
Expand Down Expand Up @@ -336,6 +351,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_011_Begin
ld b, a
ldh a, [hWhoseTurn]
and a
Expand Down Expand Up @@ -428,10 +444,12 @@ MoveAnimation:
ld c, 30
call DelayFrames
.next4
vc_hook FPA_009_End
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
.animationFinished
call WaitForSoundToFinish
xor a
vc_hook FPA_008_End
ld [wSubAnimSubEntryAddr], a
ld [wUnusedD09B], a
ld [wSubAnimTransform], a
Expand Down Expand Up @@ -469,6 +487,7 @@ ShareMoveAnimations:
PlayApplyingAttackAnimation:
; Generic animation that shows after the move's individual animation
; Different animation depending on whether the move has an additional effect and on whose turn it is
vc_hook FPA_010_End
ld a, [wAnimationType]
and a
ret z
Expand Down Expand Up @@ -558,8 +577,10 @@ SetAnimationPalette:
ld b, $f0
.next
ld a, b
vc_hook FPA_006_Begin
ldh [rOBP0], a
ld a, $6c
vc_hook FPA_008_Begin
ldh [rOBP1], a
call UpdateGBCPal_OBP0
call UpdateGBCPal_OBP1
Expand Down
23 changes: 23 additions & 0 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3192,25 +3192,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(_YELLOW_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(_YELLOW_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 @@ -6844,7 +6860,14 @@ BattleRandom:
ld a, [hl]
pop bc
pop hl
vc_hook fight_ret_c
vc_patch fight_ret
IF DEF(_YELLOW_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
1 change: 1 addition & 0 deletions engine/gfx/palettes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ CheckSGB:
SendMltReq1Packet:
ld hl, MltReq1Packet
call SendSGBPacket
vc_hook Network_RESET
jp Wait7000

CopyGfxToSuperNintendoVRAM:
Expand Down
3 changes: 3 additions & 0 deletions engine/link/cable_club.asm
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ CableClub_DoBattleOrTradeAgain:
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 @@ -866,6 +868,7 @@ TradeCenter_Trade:
ld de, TradeCompleted
call PlaceString
predef SaveSAVtoSRAM2
vc_hook save_game_end
ld c, 50
call DelayFrames
xor a
Expand Down
4 changes: 4 additions & 0 deletions engine/link/cable_club_npc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CableClubNPC::
xor a
ldh [hSerialReceiveData], a
ld a, START_TRANSFER_EXTERNAL_CLOCK
vc_hook linkCable_fake_begin
ldh [rSC], a
ld a, [wLinkTimeoutCounter]
dec a
Expand Down Expand Up @@ -57,6 +58,7 @@ CableClubNPC::
ld a, [wCurrentMenuItem]
and a
jr nz, .choseNo
vc_hook linkCable_block_input
callfar SaveSAVtoSRAM
call WaitForSoundToFinish
ld a, SFX_SAVE
Expand All @@ -70,7 +72,9 @@ CableClubNPC::
ld [hl], a
ldh [hSerialReceivedNewData], a
ld [wSerialExchangeNybbleSendData], a
vc_hook linkCable_fake_end
call Serial_SyncAndExchangeNybble
vc_hook Network_RECHECK
ld hl, wUnknownSerialCounter
ld a, [hli]
inc a
Expand Down
2 changes: 2 additions & 0 deletions engine/menus/link_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,11 @@ LinkMenu:
call Delay3
callfar CloseLinkConnection
ld hl, ColosseumCanceledText
vc_hook Network_STOP
call PrintText
ld hl, wd72e
res 6, [hl]
vc_hook Network_END
ret

.asm_f5963
Expand Down
Loading

0 comments on commit fbaa5c9

Please sign in to comment.