Clean-ups + splitting

This commit is contained in:
earthoul 2026-02-17 23:14:23 +09:00
parent 05ec89384d
commit 43e4718671
No known key found for this signature in database
GPG Key ID: 9049439C902677E4
11 changed files with 602 additions and 597 deletions

View File

@ -181,14 +181,17 @@ DEF PRESENT_PACK EQU 7
const BOOSTER_WE_ARE_TEAM_ROCKET ; $5
const BOOSTER_TEAM_ROCKETS_AMBITION ; $6
const BOOSTER_DEBUG_10_STAR ; $7
DEF BOOSTERS_PRESENT_START EQU const_value
const BOOSTER_PRESENT_10_ENERGY ; $8
DEF BOOSTERS_PRESENT_REGULAR_START EQU const_value
const BOOSTER_PRESENT_FROM_ALL_SETS ; $9
const BOOSTER_PRESENT_FROM_NON_ROCKET_SETS ; $a
const BOOSTER_PRESENT_FROM_LATTER_4_SETS ; $b
const BOOSTER_PRESENT_FROM_ROCKET_SETS ; $c
DEF BOOSTERS_PRESENT_END EQU const_value
const BOOSTER_DEBUG_2_STAR ; $d
DEF NUM_BOOSTERS_PRESENT_REGULAR EQU BOOSTER_PRESENT_FROM_ROCKET_SETS - BOOSTER_PRESENT_10_ENERGY ; 4
DEF NUM_BOOSTERS_PRESENT_REGULAR EQU BOOSTERS_PRESENT_END - BOOSTERS_PRESENT_REGULAR_START ; 4
; real card set constants
const_def

View File

@ -77,9 +77,9 @@ DEF SLOT_MACHINE_REEL_LANDED_F EQU 7
const SLOTMACHINESYMBOL_ARTICUNO ; $8
const SLOTMACHINESYMBOL_MOLTRES ; $9
const SLOTMACHINESYMBOL_ZAPDOS ; $a
DEF NUM_SLOTMACHINESYMBOLS EQU const_value
DEF NUM_SLOT_MACHINE_SYMBOLS EQU const_value
DEF NUM_SLOTMACHINESYMBOLS_TILES EQU NUM_SLOTMACHINESYMBOLS * NUM_SLOT_MACHINE_SYMBOL_VERT_TILES ; 33
DEF NUM_SLOT_MACHINE_SYMBOLS_TILES EQU NUM_SLOT_MACHINE_SYMBOLS * NUM_SLOT_MACHINE_SYMBOL_VERT_TILES ; 33
; prize exchange
const_def

View File

@ -0,0 +1,12 @@
MACRO? gamecenter_prize
tx \1 ; name
dw \2 ; price
ENDM
GameCenterPrizeExchangeItems:
gamecenter_prize GameCenterPrizeVenusaurText, GAMECENTERPRIZE_VENUSAUR_CHIPS
gamecenter_prize GameCenterPrizeMewText, GAMECENTERPRIZE_MEW_CHIPS
gamecenter_prize GameCenterPrizeBillsComputerText, GAMECENTERPRIZE_BILLS_COMPUTER_CHIPS
gamecenter_prize GameCenterPrizeJigglypuffCoinText, GAMECENTERPRIZE_JIGGLYPUFF_COIN_CHIPS
gamecenter_prize GameCenterPrize1PresentPackText, GAMECENTERPRIZE_1_PRESENT_PACK_CHIPS
gamecenter_prize GameCenterPrize3PresentPacksText, GAMECENTERPRIZE_3_PRESENT_PACKS_CHIPS

View File

@ -62,7 +62,7 @@ WRAMToSRAMMapper_GeneralSave::
wram_sram_map wPCMenuCursorPosition, 1, $00, $ff
wram_sram_map wGameCenterChips, 2, $00, $ff
wram_sram_map wGameCenterBankedChips, 2, $00, $ff
wram_sram_map wGameCenterPrizeExchangeAltFlag, 1, $00, $ff
wram_sram_map wClaimedJigglypuffCoin, 1, $00, $ff
wram_sram_map wOWObj1Flags, 1, $00, $ff
dw NULL

View File

@ -3069,583 +3069,10 @@ _ShowReceivedCard:
pop af
ret
GameCenterPrizeExchange:
farcall HideNPCAnimsUnderDialogBox
call .PrintWelcome
call .PrintExchangePrompt
jr c, .exit
farcall ShowNPCAnimsUnderDialogBox
farcall Func_1022a
call .ShowMenu
farcall Func_10252
farcall HideNPCAnimsUnderDialogBox
.exit
call .PrintComeAgain
farcall ShowNPCAnimsUnderDialogBox
ret
INCLUDE "engine/game_center_prize_exchange.asm"
INCLUDE "data/game_center_prizes.asm"
.ShowMenu:
push af
push bc
push de
push hl
xor a
ld [wGameCenterPrizeExchangeMenuCursorPosition], a
call DrawAndHandleGameCenterPrizeExchangeMenu
pop hl
pop de
pop bc
pop af
ret
.PrintWelcome:
ldtx de, ReceptionistText
ldtx hl, GameCenterPrizeExchangeWelcomeText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
ret
.PrintComeAgain:
ldtx de, ReceptionistText
ldtx hl, GameCenterPrizeExchangeComeAgainText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
ret
.PrintExchangePrompt:
ldtx hl, GameCenterPrizeExchangePromptText
ld a, $01
farcall PrintScrollableText_WithTextBoxLabelWithYesOrNoMenu
ret
DrawAndHandleGameCenterPrizeExchangeMenu:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call DrawGameCenterPrizeExchangeMenu
farcall SetFrameFuncAndFadeFromWhite
call HandleGameCenterPrizeExchangeMenu
farcall FadeToWhiteAndUnsetFrameFunc
ret
DrawGameCenterPrizeExchangeMenu:
call LoadGameCenterPrizeExchangeItems
lb de, 0, 0
ld b, BANK(.menu_params)
ld hl, .menu_params
call LoadMenuBoxParams
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
call DrawMenuBox
; draw chip HUD
ldtx hl, PlayersChipsText
lb de, 1, 0
call Func_2c4b
lb de, 14, 0
lb bc, 5, 1
farcall FillBoxInBGMapWithZero
ldtx hl, CardsAndChipsUnitText
lb de, 18, 0
call InitTextPrinting_ProcessTextFromIDVRAM0
farcall GetGameCenterChips
lb de, 14, 0
ld h, b
ld l, c
ld a, 4
ld b, TRUE
call PrintNumber
; print available prizes
ld hl, wIndicesGameCenterPrizeExchangeItems
ld e, 2 ; y
ld c, NUM_GAME_CENTER_PRIZE_LIST_ITEMS
.loop_print_prizes
ld a, [hli]
call .PrintPrizeAndPrice
inc e
inc e
dec c
jr nz, .loop_print_prizes
ret
; print GameCenterPrizeExchangeItems[a]
.PrintPrizeAndPrice:
push af
push bc
push de
push hl
ld hl, GameCenterPrizeExchangeItems
add a
add a ; *4
ld c, a
ld b, $00
add hl, bc
; prize name
push hl
ld a, [hli]
ld h, [hl]
ld l, a
ld d, 2 ; x
call InitTextPrinting_ProcessTextFromIDVRAM0
pop hl
; prize price (+unit)
inc hl
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
ld a, 4
ld b, TRUE
ld d, 14 ; x
call PrintNumber
ld d, 18 ; x
ldtx hl, CardsAndChipsUnitText
call InitTextPrinting_ProcessTextFromIDVRAM0
pop hl
pop de
pop bc
pop af
ret
.menu_params
menubox_params TRUE, 20, 18, \
SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \
PAD_A, PAD_B, FALSE, 1, NULL, NULL
textitem 2, 2, SingleSpaceText
textitem 2, 4, SingleSpaceText
textitem 2, 6, SingleSpaceText
textitem 2, 8, SingleSpaceText
textitem 2, 10, SingleSpaceText
textitems_end
HandleGameCenterPrizeExchangeMenu:
lb de, 1, 14
ldtx hl, GameCenterPrizeExchangeChoosePrizeText
farcall PrintTextInWideTextBox
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
call HandleMenuBox
ld [wGameCenterPrizeExchangeMenuCursorPosition], a
jr c, .exit
push af
ld a, SFX_CONFIRM
call CallPlaySFX
pop af
jr .selected
.exit
push af
ld a, SFX_CANCEL
call CallPlaySFX
pop af
jr .quit_prompt
.selected
ldtx hl, GameCenterPrizeExchangeConfirmText
ld a, $01
farcall DrawWideTextBox_PrintTextWithYesOrNoMenu
jr c, .quit_prompt
call .Exchange
jr c, .quit_prompt
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call DrawGameCenterPrizeExchangeMenu
call StartFadeFromWhite
call WaitPalFading_Bank07
.quit_prompt
ldtx hl, GameCenterPrizeExchangeQuitConfirmText
ld a, $01
farcall DrawWideTextBox_PrintTextWithYesOrNoMenu
jr c, HandleGameCenterPrizeExchangeMenu ; loop
ret
.Exchange:
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
ld c, a
ld b, $00
ld hl, wIndicesGameCenterPrizeExchangeItems
add hl, bc
ld a, [hl]
ld [wSelectedGameCenterPrizeExchangeItem], a
add a
add a ; *4
ld c, a
ld b, $00
ld hl, GameCenterPrizeExchangeItems
add hl, bc
inc hl
inc hl
ld e, [hl]
inc hl
ld d, [hl]
farcall GetGameCenterChips
call CompareBCAndDE
jr c, .not_enough_chips
ld b, d
ld c, e
farcall SubtractChips
call StartFadeToWhite
call WaitPalFading_Bank07
ld a, [wSelectedGameCenterPrizeExchangeItem]
ld hl, .function_map
call CallMappedFunction
call WaitPalFading_Bank07
ret
.not_enough_chips
ldtx hl, GameCenterNotEnoughChipsText
farcall PrintScrollableText_NoTextBoxLabelVRAM0
ret
.function_map
key_func GAMECENTERPRIZE_VENUSAUR, .Venusaur
key_func GAMECENTERPRIZE_MEW, .Mew
key_func GAMECENTERPRIZE_BILLS_COMPUTER, .BillsComputer
key_func GAMECENTERPRIZE_JIGGLYPUFF_COIN, .JigglypuffCoin
key_func GAMECENTERPRIZE_1_PRESENT_PACK, .PresntPack1
key_func GAMECENTERPRIZE_3_PRESENT_PACKS, .PresentPacks3
db $ff
.Venusaur:
ld de, VENUSAUR_LV64
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.Mew:
ld de, MEW_LV15
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.BillsComputer:
ld de, BILLS_COMPUTER
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.JigglypuffCoin:
ld a, EVENT_GOT_JIGGLYPUFF_COIN
farcall MaxOutEventValue
ld a, COIN_JIGGLYPUFF
call _GiveCoin
ld a, TRUE
ld [wGameCenterPrizeExchangeAltFlag], a
ret
; BOOSTER_PRESENT_FROM_* at random
.PresntPack1:
ld a, NUM_BOOSTERS_PRESENT_REGULAR
call Random
add BOOSTER_PRESENT_FROM_ALL_SETS
ld b, FALSE
call GiveBoosterPacks
ret
; BOOSTER_PRESENT_FROM_* at random
.PresentPacks3:
ld c, 3
ld b, FALSE
.loop_present_packs
ld a, NUM_BOOSTERS_PRESENT_REGULAR
call Random
add BOOSTER_PRESENT_FROM_ALL_SETS
call GiveBoosterPacks
ld b, TRUE
dec c
jr nz, .loop_present_packs
ret
; set up wIndicesGameCenterPrizeExchangeItems
LoadGameCenterPrizeExchangeItems:
ld a, [wGameCenterPrizeExchangeAltFlag]
add a
ld c, a
ld b, $00
ld hl, .lineup_table
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wIndicesGameCenterPrizeExchangeItems
ld c, NUM_GAME_CENTER_PRIZE_LIST_ITEMS
.loop_index
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .loop_index
ret
.lineup_table
dw .HasJigglypuffCoin
dw .NoJigglypuffCoin
.HasJigglypuffCoin:
db GAMECENTERPRIZE_VENUSAUR
db GAMECENTERPRIZE_MEW
db GAMECENTERPRIZE_BILLS_COMPUTER
db GAMECENTERPRIZE_JIGGLYPUFF_COIN
db GAMECENTERPRIZE_1_PRESENT_PACK
.NoJigglypuffCoin:
db GAMECENTERPRIZE_VENUSAUR
db GAMECENTERPRIZE_MEW
db GAMECENTERPRIZE_BILLS_COMPUTER
db GAMECENTERPRIZE_3_PRESENT_PACKS
db GAMECENTERPRIZE_1_PRESENT_PACK
InitGameCenterPrizeExchangeLineup:
xor a
ld [wGameCenterPrizeExchangeAltFlag], a
ret
MACRO? gamecenter_prize
tx \1 ; name
dw \2 ; price
ENDM
GameCenterPrizeExchangeItems:
gamecenter_prize GameCenterPrizeVenusaurText, GAMECENTERPRIZE_VENUSAUR_CHIPS
gamecenter_prize GameCenterPrizeMewText, GAMECENTERPRIZE_MEW_CHIPS
gamecenter_prize GameCenterPrizeBillsComputerText, GAMECENTERPRIZE_BILLS_COMPUTER_CHIPS
gamecenter_prize GameCenterPrizeJigglypuffCoinText, GAMECENTERPRIZE_JIGGLYPUFF_COIN_CHIPS
gamecenter_prize GameCenterPrize1PresentPackText, GAMECENTERPRIZE_1_PRESENT_PACK_CHIPS
gamecenter_prize GameCenterPrize3PresentPacksText, GAMECENTERPRIZE_3_PRESENT_PACKS_CHIPS
; return a = streak
; harmless bug: also return bc = wUnusedCoinFlipGamePayout which is garbage but unused
CoinFlipGameScreen:
farcall Func_1022a
call ShowCoinFlipGame
farcall Func_10252
ret
; return a = streak
; harmless bug: also return bc = wUnusedCoinFlipGamePayout which is garbage but unused
ShowCoinFlipGame:
push de
push hl
push af
ld a, AUDVOL_HALF_VOLUME
call CallSetVolume
pop af
call PlayCoinFlipGame
push af
ld a, AUDVOL_FULL_VOLUME
call CallSetVolume
pop af
call .LoadPayout
ld hl, wUnusedCoinFlipGamePayout
ld c, [hl]
inc hl
ld b, [hl]
ld a, [wCoinFlipGameStreak]
pop hl
pop de
ret
; bug: never points to .payout and loads garbage to the buffer
.LoadPayout:
ld a, [wCoinFlipGameStreak]
add a
ld c, a
ld b, $00
; ld hl, .payout
add hl, bc
ld a, [hli]
ld [wUnusedCoinFlipGamePayout], a
ld a, [hl]
ld [wUnusedCoinFlipGamePayout + 1], a
ret
.payout
dw 0
dw 0
dw 0
dw CHIPS_COIN_FLIP_STREAK_3
dw CHIPS_COIN_FLIP_STREAK_4
dw CHIPS_COIN_FLIP_STREAK_5
dw CHIPS_COIN_FLIP_STREAK_6
dw CHIPS_COIN_FLIP_STREAK_7
dw CHIPS_COIN_FLIP_STREAK_8
dw CHIPS_COIN_FLIP_STREAK_9
dw 0
PlayCoinFlipGame:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call .DrawScreen
farcall SetFrameFuncAndFadeFromWhite
.start
ld c, 0
.loop_toss
ld a, FRAMESET_112 - FRAMESET_112
call SetAndInitCoinAnimation
.wait_input
call UpdateRNGSources
call DoFrame
ldh a, [hKeysPressed]
and PAD_A
jr z, .wait_input
call UpdateRNGSources
and HEADS
ld b, a
push af
ld a, SFX_COIN_TOSS
call CallPlaySFX
pop af
ld a, b
add 1
call SetAndInitCoinAnimation
.wait_anim
call DoFrame
call IsCoinAnimating
jr nz, .wait_anim
ld a, b
and HEADS
jr nz, .tails
push af
ld a, SFX_COIN_TOSS_POSITIVE
call CallPlaySFX
pop af
jr .toss_result
.tails
push af
ld a, SFX_COIN_TOSS_NEGATIVE
call CallPlaySFX
pop af
.toss_result
ld a, b
call .UpdateResultOnScreen
ld a, 60
call DoAFrames_WithPreCheck
ld a, b
and a
jr nz, .finish
inc c
ld a, c
cp MAX_NUM_GAMECENTER_COIN_FLIP_STREAK
jr nz, .loop_toss
.finish
ld a, c
ld [wCoinFlipGameStreak], a
cp MIN_NUM_GAMECENTER_COIN_FLIP_STREAK
jr nc, .done
call .RestartPrompt
jr nc, .start
.done
farcall FadeToWhiteAndUnsetFrameFunc
ret
.DrawScreen:
push af
push bc
push de
push hl
farcall ClearSpriteAnims
call GetSelectedCoin
lb de, 88, 88
call CreateCoinAnimation
ld a, FRAMESET_115 - FRAMESET_112
call SetAndInitCoinAnimation
lb de, 0, 12
lb bc, 20, 6
call DrawRegularTextBoxVRAM0
ldtx hl, GameCenterCoinFlipTitleText
lb de, 1, 12
call Func_2c4b
ldtx hl, GameCenterCoinFlipDialogText
lb de, 1, 14
call InitTextPrinting_ProcessTextFromIDVRAM0
lb de, 0, 0
lb bc, 20, 4
farcall FillBoxInBGMapWithZero
pop hl
pop de
pop bc
pop af
ret
.UpdateResultOnScreen:
push af
push bc
and a
jr nz, .heads
ld a, SCENE_COIN_TOSS_RESULT_1
jr .draw_result
.heads
ld a, SCENE_COIN_TOSS_RESULT_2
.draw_result
ld b, c
sla b ; *2, x
ld c, $00 ; y
call LoadScene
call FlushAllPalettes
pop bc
pop af
ret
.RestartPrompt:
lb de, 0, 0
lb bc, 8, 4
farcall FillBoxInBGMapWithZero
call DoFrame
farcall TurnOnCurChipsHUD
ldtx hl, GameCenterCoinFlipPlayAgainPromptText
ldtx de, AttendantText
ld a, $01
farcall PrintScrollableText_WithTextBoxLabelWithYesOrNoMenu
jr c, .got_decision
farcall GetGameCenterChips
ld a, b
or c
jr z, .not_enough_chips
ld bc, CHIPS_BET_COIN_FLIP
farcall DecreaseChipsSmoothly
ld a, 60
call DoAFrames_WithPreCheck
scf
ccf
.got_decision
farcall TurnOffCurChipsHUD
ret c
call .DrawScreen
ret
.not_enough_chips
ldtx hl, GameCenterCoinFlipAttendantNotEnoughChipsText
ldtx de, AttendantText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
scf
jr .got_decision
; unused
ShowCoinFlipGameDescription:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call .DrawTextBoxes
call .PrintDescription
farcall SetFrameFuncAndFadeFromWhite
call .PrintCheers
farcall FadeToWhiteAndUnsetFrameFunc
ret
.DrawTextBoxes:
lb de, 0, 0
lb bc, 20, 12
call DrawRegularTextBoxVRAM0
lb de, 0, 12
lb bc, 20, 6
call DrawRegularTextBoxVRAM0
ret
.PrintDescription:
ldtx hl, GameCenterCoinFlipTitleText
lb de, 1, 0
call Func_2c4b
ldtx hl, GameCenterCoinFlipDescriptionText
lb de, 1, 2
call InitTextPrinting_ProcessTextFromIDVRAM0
ret
.PrintCheers:
ldtx hl, GameCenterCoinFlipCheersText
farcall PrintScrollableText_NoTextBoxLabelVRAM0
ret
INCLUDE "engine/coin_flip_game.asm"
OWInteractionSlotMachine:
farcall Func_1022a
@ -8089,7 +7516,7 @@ ShowCardDungeonDescriptionScreen:
push bc
push de
push hl
ld [wCardDungeonPlayable], a
ld [wCardDungeonIsPlayable], a
call .DrawDescriptionScreen
pop hl
pop de
@ -8104,7 +7531,7 @@ ShowCardDungeonDescriptionScreen:
call StartFadeFromWhite
call WaitPalFading_Bank07
ldtx hl, GameCenterCardDungeonUnableNotEnoughChipsText
ld a, [wCardDungeonPlayable]
ld a, [wCardDungeonIsPlayable]
and a
jr z, .got_text
ldtx hl, GameCenterCardDungeonDialogText

View File

@ -5379,6 +5379,7 @@ _ListUniqueEvoCardsFromDE:
INCLUDE "engine/bills_pc.asm"
; SECTION "GBC Only Disclaimer", ROMX
INCLUDE "engine/gbc_only_disclaimer.asm"
_TossCoin::

View File

@ -0,0 +1,239 @@
; return a = streak
; harmless bug: also return bc = wUnusedCoinFlipGamePayout which is garbage but unused
CoinFlipGameScreen:
farcall Func_1022a
call ShowCoinFlipGame
farcall Func_10252
ret
; return a = streak
; harmless bug: also return bc = wUnusedCoinFlipGamePayout which is garbage but unused
ShowCoinFlipGame:
push de
push hl
push af
ld a, AUDVOL_HALF_VOLUME
call CallSetVolume
pop af
call PlayCoinFlipGame
push af
ld a, AUDVOL_FULL_VOLUME
call CallSetVolume
pop af
call .LoadPayout
ld hl, wUnusedCoinFlipGamePayout
ld c, [hl]
inc hl
ld b, [hl]
ld a, [wCoinFlipGameStreak]
pop hl
pop de
ret
; bug: never points at .payout and loads garbage to the buffer
.LoadPayout:
ld a, [wCoinFlipGameStreak]
add a
ld c, a
ld b, $00
; ld hl, .payout
add hl, bc
ld a, [hli]
ld [wUnusedCoinFlipGamePayout], a
ld a, [hl]
ld [wUnusedCoinFlipGamePayout + 1], a
ret
.payout
dw 0
dw 0
dw 0
dw CHIPS_COIN_FLIP_STREAK_3
dw CHIPS_COIN_FLIP_STREAK_4
dw CHIPS_COIN_FLIP_STREAK_5
dw CHIPS_COIN_FLIP_STREAK_6
dw CHIPS_COIN_FLIP_STREAK_7
dw CHIPS_COIN_FLIP_STREAK_8
dw CHIPS_COIN_FLIP_STREAK_9
dw 0
PlayCoinFlipGame:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call .DrawScreen
farcall SetFrameFuncAndFadeFromWhite
.start
ld c, 0
.loop_toss
ld a, FRAMESET_112 - FRAMESET_112
call SetAndInitCoinAnimation
.wait_input
call UpdateRNGSources
call DoFrame
ldh a, [hKeysPressed]
and PAD_A
jr z, .wait_input
call UpdateRNGSources
and HEADS
ld b, a
push af
ld a, SFX_COIN_TOSS
call CallPlaySFX
pop af
ld a, b
add 1
call SetAndInitCoinAnimation
.wait_anim
call DoFrame
call IsCoinAnimating
jr nz, .wait_anim
ld a, b
and HEADS
jr nz, .tails
push af
ld a, SFX_COIN_TOSS_POSITIVE
call CallPlaySFX
pop af
jr .toss_result
.tails
push af
ld a, SFX_COIN_TOSS_NEGATIVE
call CallPlaySFX
pop af
.toss_result
ld a, b
call .UpdateResultOnScreen
ld a, 60
call DoAFrames_WithPreCheck
ld a, b
and a
jr nz, .finish
inc c
ld a, c
cp MAX_NUM_GAMECENTER_COIN_FLIP_STREAK
jr nz, .loop_toss
.finish
ld a, c
ld [wCoinFlipGameStreak], a
cp MIN_NUM_GAMECENTER_COIN_FLIP_STREAK
jr nc, .done
call .RestartPrompt
jr nc, .start
.done
farcall FadeToWhiteAndUnsetFrameFunc
ret
.DrawScreen:
push af
push bc
push de
push hl
farcall ClearSpriteAnims
call GetSelectedCoin
lb de, 88, 88
call CreateCoinAnimation
ld a, FRAMESET_115 - FRAMESET_112
call SetAndInitCoinAnimation
lb de, 0, 12
lb bc, 20, 6
call DrawRegularTextBoxVRAM0
ldtx hl, GameCenterCoinFlipTitleText
lb de, 1, 12
call Func_2c4b
ldtx hl, GameCenterCoinFlipDialogText
lb de, 1, 14
call InitTextPrinting_ProcessTextFromIDVRAM0
lb de, 0, 0
lb bc, 20, 4
farcall FillBoxInBGMapWithZero
pop hl
pop de
pop bc
pop af
ret
.UpdateResultOnScreen:
push af
push bc
and a
jr nz, .heads
ld a, SCENE_COIN_TOSS_RESULT_1
jr .draw_result
.heads
ld a, SCENE_COIN_TOSS_RESULT_2
.draw_result
ld b, c
sla b ; *2, x
ld c, $00 ; y
call LoadScene
call FlushAllPalettes
pop bc
pop af
ret
.RestartPrompt:
lb de, 0, 0
lb bc, 8, 4
farcall FillBoxInBGMapWithZero
call DoFrame
farcall TurnOnCurChipsHUD
ldtx hl, GameCenterCoinFlipPlayAgainPromptText
ldtx de, AttendantText
ld a, $01
farcall PrintScrollableText_WithTextBoxLabelWithYesOrNoMenu
jr c, .got_decision
farcall GetGameCenterChips
ld a, b
or c
jr z, .not_enough_chips
ld bc, CHIPS_BET_COIN_FLIP
farcall DecreaseChipsSmoothly
ld a, 60
call DoAFrames_WithPreCheck
scf
ccf
.got_decision
farcall TurnOffCurChipsHUD
ret c
call .DrawScreen
ret
.not_enough_chips
ldtx hl, GameCenterCoinFlipAttendantNotEnoughChipsText
ldtx de, AttendantText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
scf
jr .got_decision
; unused
ShowCoinFlipGameDescription:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call .DrawTextBoxes
call .PrintDescription
farcall SetFrameFuncAndFadeFromWhite
call .PrintCheers
farcall FadeToWhiteAndUnsetFrameFunc
ret
.DrawTextBoxes:
lb de, 0, 0
lb bc, 20, 12
call DrawRegularTextBoxVRAM0
lb de, 0, 12
lb bc, 20, 6
call DrawRegularTextBoxVRAM0
ret
.PrintDescription:
ldtx hl, GameCenterCoinFlipTitleText
lb de, 1, 0
call Func_2c4b
ldtx hl, GameCenterCoinFlipDescriptionText
lb de, 1, 2
call InitTextPrinting_ProcessTextFromIDVRAM0
ret
.PrintCheers:
ldtx hl, GameCenterCoinFlipCheersText
farcall PrintScrollableText_NoTextBoxLabelVRAM0
ret

View File

@ -0,0 +1,324 @@
GameCenterPrizeExchange:
farcall HideNPCAnimsUnderDialogBox
call .PrintWelcome
call .PrintExchangePrompt
jr c, .exit
farcall ShowNPCAnimsUnderDialogBox
farcall Func_1022a
call .ShowMenu
farcall Func_10252
farcall HideNPCAnimsUnderDialogBox
.exit
call .PrintComeAgain
farcall ShowNPCAnimsUnderDialogBox
ret
.ShowMenu:
push af
push bc
push de
push hl
xor a
ld [wGameCenterPrizeExchangeMenuCursorPosition], a
call DrawAndHandleGameCenterPrizeExchangeMenu
pop hl
pop de
pop bc
pop af
ret
.PrintWelcome:
ldtx de, ReceptionistText
ldtx hl, GameCenterPrizeExchangeWelcomeText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
ret
.PrintComeAgain:
ldtx de, ReceptionistText
ldtx hl, GameCenterPrizeExchangeComeAgainText
farcall PrintScrollableText_WithTextBoxLabelVRAM0
ret
.PrintExchangePrompt:
ldtx hl, GameCenterPrizeExchangePromptText
ld a, $01
farcall PrintScrollableText_WithTextBoxLabelWithYesOrNoMenu
ret
DrawAndHandleGameCenterPrizeExchangeMenu:
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call DrawGameCenterPrizeExchangeMenu
farcall SetFrameFuncAndFadeFromWhite
call HandleGameCenterPrizeExchangeMenu
farcall FadeToWhiteAndUnsetFrameFunc
ret
DrawGameCenterPrizeExchangeMenu:
call LoadGameCenterPrizeExchangeItems
lb de, 0, 0
ld b, BANK(.menu_params)
ld hl, .menu_params
call LoadMenuBoxParams
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
call DrawMenuBox
; draw chip HUD
ldtx hl, PlayersChipsText
lb de, 1, 0
call Func_2c4b
lb de, 14, 0
lb bc, 5, 1
farcall FillBoxInBGMapWithZero
ldtx hl, CardsAndChipsUnitText
lb de, 18, 0
call InitTextPrinting_ProcessTextFromIDVRAM0
farcall GetGameCenterChips
lb de, 14, 0
ld h, b
ld l, c
ld a, 4
ld b, TRUE
call PrintNumber
; print available prizes
ld hl, wIndicesGameCenterPrizeExchangeItems
ld e, 2 ; y
ld c, NUM_GAME_CENTER_PRIZE_LIST_ITEMS
.loop_print_prizes
ld a, [hli]
call .PrintPrizeAndPrice
inc e
inc e
dec c
jr nz, .loop_print_prizes
ret
; print GameCenterPrizeExchangeItems[a]
.PrintPrizeAndPrice:
push af
push bc
push de
push hl
ld hl, GameCenterPrizeExchangeItems
add a
add a ; *4
ld c, a
ld b, $00
add hl, bc
; prize name
push hl
ld a, [hli]
ld h, [hl]
ld l, a
ld d, 2 ; x
call InitTextPrinting_ProcessTextFromIDVRAM0
pop hl
; prize price (+unit)
inc hl
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
ld a, 4
ld b, TRUE
ld d, 14 ; x
call PrintNumber
ld d, 18 ; x
ldtx hl, CardsAndChipsUnitText
call InitTextPrinting_ProcessTextFromIDVRAM0
pop hl
pop de
pop bc
pop af
ret
.menu_params
menubox_params TRUE, 20, 18, \
SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \
PAD_A, PAD_B, FALSE, 1, NULL, NULL
textitem 2, 2, SingleSpaceText
textitem 2, 4, SingleSpaceText
textitem 2, 6, SingleSpaceText
textitem 2, 8, SingleSpaceText
textitem 2, 10, SingleSpaceText
textitems_end
HandleGameCenterPrizeExchangeMenu:
lb de, 1, 14
ldtx hl, GameCenterPrizeExchangeChoosePrizeText
farcall PrintTextInWideTextBox
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
call HandleMenuBox
ld [wGameCenterPrizeExchangeMenuCursorPosition], a
jr c, .exit
push af
ld a, SFX_CONFIRM
call CallPlaySFX
pop af
jr .selected
.exit
push af
ld a, SFX_CANCEL
call CallPlaySFX
pop af
jr .quit_prompt
.selected
ldtx hl, GameCenterPrizeExchangeConfirmText
ld a, $01
farcall DrawWideTextBox_PrintTextWithYesOrNoMenu
jr c, .quit_prompt
call .Exchange
jr c, .quit_prompt
farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration
call DrawGameCenterPrizeExchangeMenu
call StartFadeFromWhite
call WaitPalFading_Bank07
.quit_prompt
ldtx hl, GameCenterPrizeExchangeQuitConfirmText
ld a, $01
farcall DrawWideTextBox_PrintTextWithYesOrNoMenu
jr c, HandleGameCenterPrizeExchangeMenu ; loop
ret
.Exchange:
ld a, [wGameCenterPrizeExchangeMenuCursorPosition]
ld c, a
ld b, $00
ld hl, wIndicesGameCenterPrizeExchangeItems
add hl, bc
ld a, [hl]
ld [wSelectedGameCenterPrizeExchangeItem], a
add a
add a ; *4
ld c, a
ld b, $00
ld hl, GameCenterPrizeExchangeItems
add hl, bc
inc hl
inc hl
ld e, [hl]
inc hl
ld d, [hl]
farcall GetGameCenterChips
call CompareBCAndDE
jr c, .not_enough_chips
ld b, d
ld c, e
farcall SubtractChips
call StartFadeToWhite
call WaitPalFading_Bank07
ld a, [wSelectedGameCenterPrizeExchangeItem]
ld hl, .function_map
call CallMappedFunction
call WaitPalFading_Bank07
ret
.not_enough_chips
ldtx hl, GameCenterNotEnoughChipsText
farcall PrintScrollableText_NoTextBoxLabelVRAM0
ret
.function_map
key_func GAMECENTERPRIZE_VENUSAUR, .Venusaur
key_func GAMECENTERPRIZE_MEW, .Mew
key_func GAMECENTERPRIZE_BILLS_COMPUTER, .BillsComputer
key_func GAMECENTERPRIZE_JIGGLYPUFF_COIN, .JigglypuffCoin
key_func GAMECENTERPRIZE_1_PRESENT_PACK, .PresentPack1
key_func GAMECENTERPRIZE_3_PRESENT_PACKS, .PresentPacks3
db $ff
.Venusaur:
ld de, VENUSAUR_LV64
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.Mew:
ld de, MEW_LV15
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.BillsComputer:
ld de, BILLS_COMPUTER
farcall GetReceivedCardText
call _ShowReceivedCard
call AddCardToCollection
ret
.JigglypuffCoin:
ld a, EVENT_GOT_JIGGLYPUFF_COIN
farcall MaxOutEventValue
ld a, COIN_JIGGLYPUFF
call _GiveCoin
ld a, TRUE
ld [wClaimedJigglypuffCoin], a
ret
; BOOSTER_PRESENT_FROM_* at random
.PresentPack1:
ld a, NUM_BOOSTERS_PRESENT_REGULAR
call Random
add BOOSTERS_PRESENT_REGULAR_START
ld b, FALSE
call GiveBoosterPacks
ret
; BOOSTER_PRESENT_FROM_* at random
.PresentPacks3:
ld c, 3
ld b, FALSE
.loop_present_packs
ld a, NUM_BOOSTERS_PRESENT_REGULAR
call Random
add BOOSTERS_PRESENT_REGULAR_START
call GiveBoosterPacks
ld b, TRUE
dec c
jr nz, .loop_present_packs
ret
; set up wIndicesGameCenterPrizeExchangeItems
LoadGameCenterPrizeExchangeItems:
ld a, [wClaimedJigglypuffCoin]
add a
ld c, a
ld b, $00
ld hl, .lineup_table
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wIndicesGameCenterPrizeExchangeItems
ld c, NUM_GAME_CENTER_PRIZE_LIST_ITEMS
.loop_index
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .loop_index
ret
.lineup_table
dw .WithJigglypuffCoin
dw .WithoutJigglypuffCoin
.WithJigglypuffCoin:
db GAMECENTERPRIZE_VENUSAUR
db GAMECENTERPRIZE_MEW
db GAMECENTERPRIZE_BILLS_COMPUTER
db GAMECENTERPRIZE_JIGGLYPUFF_COIN
db GAMECENTERPRIZE_1_PRESENT_PACK
.WithoutJigglypuffCoin:
db GAMECENTERPRIZE_VENUSAUR
db GAMECENTERPRIZE_MEW
db GAMECENTERPRIZE_BILLS_COMPUTER
db GAMECENTERPRIZE_3_PRESENT_PACKS
db GAMECENTERPRIZE_1_PRESENT_PACK
InitGameCenterPrizeExchangeLineup:
xor a
ld [wClaimedJigglypuffCoin], a
ret

View File

@ -433,7 +433,7 @@ LoadSlotMachineReels:
ret
; just 0 to 32
.enumerate_table
FOR n, NUM_SLOTMACHINESYMBOLS_TILES
FOR n, NUM_SLOT_MACHINE_SYMBOLS_TILES
db {d:n}
ENDR
@ -810,7 +810,7 @@ SetSlotMachineTeaseOffset:
ld a, [wSlotMachineBiasedSymbol]
call .CalculateDistanceToBias
ld c, 5
call DivideAByC
call DivModC
ld [hl], a
ret
@ -823,7 +823,7 @@ SetSlotMachineTeaseOffset:
call .CalculateDistanceToBias
inc a
ld c, 4
call DivideAByC
call DivModC
ld [hl], a
ret
@ -834,7 +834,7 @@ SetSlotMachineTeaseOffset:
ld a, [wSlotMachineBiasedSymbol]
call .CalculateDistanceToBias
ld c, 5
call DivideAByC
call DivModC
add 20
ld [hl], a
ld a, 3
@ -849,7 +849,7 @@ SetSlotMachineTeaseOffset:
call .CalculateDistanceToBias
inc a
ld c, 4
call DivideAByC
call DivModC
add 20
ld [hl], a
ld a, 3
@ -1077,7 +1077,7 @@ ENDR
add hl, bc
ld a, [hl]
ld c, NUM_SLOT_MACHINE_SYMBOL_VERT_TILES
call DivideAByC
call DivModC
ld a, b ; SLOTMACHINESYMBOL_*
pop hl
pop de
@ -1158,7 +1158,7 @@ HandleSlotMachinePayouts:
; bug: prize is always BOOSTER_PRESENT_10_ENERGY
; base "payout" is [0, 4] (meant for index?),
; but payout value in bc is (base) * (chips per play) anyway (< 256),
; and ld a, b (offset from BOOSTER_PRESENT_10_ENERGY) always becomes ld a, 0
; and ld a, b (offset from BOOSTERS_PRESENT_START) always becomes ld a, 0
.LegendaryHit:
call CreateSlotMachineBoosterPrizeAnimation
push af
@ -1248,7 +1248,7 @@ HandleSlotMachinePayouts:
db 3 ; SLOTMACHINESYMBOL_MOLTRES
db 4 ; SLOTMACHINESYMBOL_ZAPDOS
; a = offset from BOOSTER_PRESENT_10_ENERGY
; a = offset from BOOSTERS_PRESENT_START
; bug: input is always 0, giving BOOSTER_PRESENT_10_ENERGY
.BoosterPrize:
farcall StartFadeToWhite
@ -1263,7 +1263,7 @@ HandleSlotMachinePayouts:
ld b, 0
.loop_give_booster
ld a, [wSlotMachineBonusBoosterOffset]
add BOOSTER_PRESENT_10_ENERGY
add BOOSTERS_PRESENT_START
farcall GiveBoosterPacks
inc b
dec c

View File

@ -765,8 +765,8 @@ WaitForLCDOff::
ret
; return b = a/c, a = a%c
; but no ensuring of a being nc or c being nonzero
DivideAByC::
; assuming c != 0 and carry clear on entry (no checks)
DivModC::
ld b, 0
.loop_subtract
sbc c

View File

@ -3133,9 +3133,8 @@ wSelectedGameCenterPrizeExchangeItem:: ; db19
wIndicesGameCenterPrizeExchangeItems:: ; db1a
ds NUM_GAME_CENTER_PRIZE_LIST_ITEMS
; Jigglypuff Coin is a one-off prize
; TRUE if it's obtained and replaced by 3 Present Packs
wGameCenterPrizeExchangeAltFlag:: ; db1f
; if TRUE, replace the one-off prize with 3 Present Packs
wClaimedJigglypuffCoin:: ; db1f
ds $1
wCoinFlipGameStreak:: ; db20
@ -3554,7 +3553,7 @@ wSelectedGrandMasterCupPrizeItem2:: ; dd8f
ds $3
wCardDungeonPlayable:: ; dd93
wCardDungeonIsPlayable:: ; dd93
ds $1
wCardTilemap:: ; dd94