pokecrystal-board/engine/slot_machine.asm

2228 lines
33 KiB
NASM
Raw Normal View History

2015-12-10 19:26:31 -08:00
SLOTS_NOMATCH EQU -1
SLOTS_SEVEN EQU $00
SLOTS_POKEBALL EQU $04
SLOTS_CHERRY EQU $08
SLOTS_PIKACHU EQU $0c
SLOTS_SQUIRTLE EQU $10
SLOTS_STARYU EQU $14
REEL_SIZE EQU 15
2015-11-11 20:38:57 -08:00
_SlotMachine:
ld hl, Options
2016-01-04 05:43:55 -08:00
set NO_TEXT_SCROLL, [hl]
2015-12-10 19:26:31 -08:00
call .InitGFX
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-10 19:26:31 -08:00
.loop
call SlotsLoop
jr nc, .loop
2015-11-11 20:38:57 -08:00
call WaitSFX
ld de, SFX_QUIT_SLOTS
call PlaySFX
call WaitSFX
call ClearBGPalettes
callba TrainerRankings_EndSlotsWinStreak
2015-11-11 20:38:57 -08:00
ld hl, Options
2016-01-04 05:43:55 -08:00
res NO_TEXT_SCROLL, [hl]
2015-11-11 20:38:57 -08:00
ld hl, rLCDC ; $ff40
res 2, [hl]
ret
2015-12-10 19:26:31 -08:00
.InitGFX: ; 926f7 (24:66f7)
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
call ClearTileMap
call ClearSprites
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
call DisableLCD
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0
ld bc, VBGMap1 - VBGMap0
2015-11-20 12:15:32 -08:00
ld a, " "
2015-11-11 20:38:57 -08:00
call ByteFill
2015-12-28 07:57:04 -08:00
ld b, SCGB_SLOT_MACHINE
2015-11-11 20:38:57 -08:00
call GetSGBLayout
callab ClearSpriteAnims
2015-12-10 19:26:31 -08:00
ld hl, wSlots
ld bc, wSlotsDataEnd - wSlots
2015-11-11 20:38:57 -08:00
xor a
call ByteFill
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, Slots2LZ
ld de, VTiles0 tile $00
call Decompress
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, Slots3LZ
ld de, VTiles0 tile $40
call Decompress
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, Slots1LZ
ld de, VTiles2 tile $00
call Decompress
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, Slots2LZ
ld de, VTiles2 tile $25
call Decompress
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, SlotsTilemap
decoord 0, 0
2015-12-10 19:26:31 -08:00
ld bc, SCREEN_WIDTH * 12
2015-11-11 20:38:57 -08:00
call CopyBytes
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld hl, rLCDC ; $ff40
set 2, [hl]
call EnableLCD
2015-12-10 19:26:31 -08:00
ld hl, wSlots ; Alias: wTrademons
ld bc, wSlotsEnd - wSlots ; Alias: wTrademonsEnd
2015-11-11 20:38:57 -08:00
xor a
call ByteFill
2015-12-10 19:26:31 -08:00
call InitReelTiles
call Slots_GetPals
2015-11-11 20:38:57 -08:00
ld a, $7
2015-12-10 19:26:31 -08:00
ld hl, wSpriteAnimDict
2015-11-11 20:38:57 -08:00
ld [hli], a
ld [hl], $40
xor a
ld [wJumptableIndex], a
2015-12-10 19:26:31 -08:00
ld a, SLOTS_NOMATCH
ld [wSlotBias], a
2015-11-11 20:38:57 -08:00
ld de, MUSIC_GAME_CORNER
call PlayMusic
xor a
ld [wd002], a
call Random
2015-12-10 19:26:31 -08:00
and %00101010
2015-11-11 20:38:57 -08:00
ret nz
ld a, $1
ld [wd002], a
ret
2015-12-10 19:26:31 -08:00
Slots_GetPals: ; 9279b (24:679b)
ld a, %11100100
2015-11-11 20:38:57 -08:00
call DmgToCgbBGPals
lb de, %11100100, %11100100
2015-11-11 20:38:57 -08:00
ld a, [hCGB]
and a
2015-12-10 19:26:31 -08:00
jr nz, .cgb
lb de, %11000000, %11100100
2015-12-10 19:26:31 -08:00
.cgb
2015-11-11 20:38:57 -08:00
call DmgToCgbObjPals
ret
2015-12-10 19:26:31 -08:00
SlotsLoop: ; 927af (24:67af)
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
bit 7, a
2015-12-10 19:26:31 -08:00
jr nz, .stop
call SlotsJumptable
call Slots_SpinReels
2015-11-11 20:38:57 -08:00
xor a
2015-12-05 12:38:25 -08:00
ld [wCurrSpriteOAMAddr], a
callab DoNextFrameForFirst16Sprites
2015-12-10 19:26:31 -08:00
call .PrintCoinsAndPayout
call .DummyFunc
2015-11-11 20:38:57 -08:00
call DelayFrame
and a
ret
2015-12-10 19:26:31 -08:00
.stop
2015-11-11 20:38:57 -08:00
scf
ret
2015-12-10 19:26:31 -08:00
.DummyFunc: ; 927d3 (24:67d3)
; dummied out
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
ld a, [wReel1ReelAction]
2015-11-11 20:38:57 -08:00
and a
ret nz
2015-12-10 19:26:31 -08:00
ld a, [wReel2ReelAction]
2015-11-11 20:38:57 -08:00
and a
ret nz
2015-12-10 19:26:31 -08:00
ld a, [wFirstTwoReelsMatchingSevens]
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .matching_sevens
ld a, %11100100
2015-11-11 20:38:57 -08:00
call DmgToCgbBGPals
ret
2015-12-10 19:26:31 -08:00
.matching_sevens
2015-11-11 20:38:57 -08:00
ld a, [TextDelayFrames]
and $7
ret nz
ld a, [rBGP]
xor %00001100
2015-11-11 20:38:57 -08:00
call DmgToCgbBGPals
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 927f8
2015-12-10 19:26:31 -08:00
.PrintCoinsAndPayout: ; 927f8 (24:67f8)
2015-11-11 20:38:57 -08:00
hlcoord 5, 1
ld de, Coins
lb bc, PRINTNUM_LEADINGZEROS | 2, 4
call PrintNum
hlcoord 11, 1
2015-12-10 19:26:31 -08:00
ld de, wPayout
2015-11-11 20:38:57 -08:00
lb bc, PRINTNUM_LEADINGZEROS | 2, 4
call PrintNum
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92811 (24:6811)
Function92811: ; 92811
2015-12-10 19:26:31 -08:00
; unreferenced - debug function?
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
add 0
daa
ld e, a
and $f
add "0"
hlcoord 1, 0
ld [hl], a
ld a, e
swap a
and $f
add "0"
hlcoord 0, 0
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 9282c
Function9282c: ; 9282c
2015-12-10 19:26:31 -08:00
; unreferenced
; animate OAM tiles?
2015-11-11 20:38:57 -08:00
ld hl, wcf66
ld a, [hl]
inc [hl]
and $7
ret nz
2015-12-10 19:26:31 -08:00
ld hl, Sprites + 16 * 4 + 2
ld c, 40 - 16
.loop
2015-11-11 20:38:57 -08:00
ld a, [hl]
xor $20
ld [hli], a
inc hl
inc hl
inc hl
2015-11-11 20:38:57 -08:00
dec c
2015-12-10 19:26:31 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92844
2015-12-10 19:26:31 -08:00
SlotsJumptable: ; 92844 (24:6844)
2015-12-26 18:59:03 -08:00
jumptable .Jumptable, wJumptableIndex
.Jumptable:
2015-12-26 18:59:03 -08:00
dw Slots_Init ; 00
dw Slots_BetAndStart ; 01
dw Slots_WaitStart ; 02
dw Slots_WaitReel1 ; 03
dw Slots_WaitStopReel1 ; 04
dw Slots_WaitReel2 ; 05
dw Slots_WaitStopReel2 ; 06
dw Slots_WaitReel3 ; 07
dw Slots_WaitStopReel3 ; 08
dw Slots_Next ; 09
dw Slots_Next ; 0a
dw Slots_Next ; 0b
dw Slots_FlashIfWin ; 0c
dw Slots_FlashScreen ; 0d
dw Slots_GiveEarnedCoins ; 0e
dw Slots_PayoutTextAndAnim ; 0f
dw Slots_PayoutAnim ; 10
dw Slots_RestartOrQuit ; 11
dw Slots_Quit ; 12
2015-12-10 19:26:31 -08:00
Slots_Next: ; 92879 (24:6879)
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
2015-12-10 19:26:31 -08:00
Slots_Init: ; 9287e (24:687e)
call Slots_Next
2015-11-11 20:38:57 -08:00
xor a
2015-12-10 19:26:31 -08:00
ld [wFirstTwoReelsMatching], a
ld [wFirstTwoReelsMatchingSevens], a
ld a, -1
ld [wSlotMatched], a
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_BetAndStart: ; 9288e (24:688e)
call Slots_AskBet
jr nc, .proceed
2015-12-26 18:59:03 -08:00
ld a, 18
2015-11-11 20:38:57 -08:00
ld [wJumptableIndex], a
ret
2015-12-10 19:26:31 -08:00
.proceed
call Slots_Next
call Slots_IlluminateBetLights
call Slots_InitBias
ld a, 32
2015-11-11 20:38:57 -08:00
ld [wcf64], a
2015-12-26 18:59:03 -08:00
ld a, 4
2015-12-10 19:26:31 -08:00
ld [wReel1ReelAction], a
ld [wReel2ReelAction], a
ld [wReel3ReelAction], a
2015-11-11 20:38:57 -08:00
ld a, $4
ld [wReel1Slot09], a
ld [wReel2Slot09], a
ld [wReel3Slot09], a
2015-11-11 20:38:57 -08:00
call WaitSFX
ld a, SFX_SLOT_MACHINE_START
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_WaitStart: ; 928c6 (24:68c6)
2015-11-11 20:38:57 -08:00
ld hl, wcf64
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr z, .proceed
2015-11-11 20:38:57 -08:00
dec [hl]
ret
2015-12-10 19:26:31 -08:00
.proceed
call Slots_Next
2015-11-11 20:38:57 -08:00
xor a
ld [hJoypadSum], a
ret
2015-12-10 19:26:31 -08:00
Slots_WaitReel1: ; 928d6 (24:68d6)
2015-11-11 20:38:57 -08:00
ld hl, hJoypadSum ; $ffa5
ld a, [hl]
and A_BUTTON
ret z
2015-12-10 19:26:31 -08:00
call Slots_Next
call Slots_StopReel1
ld [wReel1ReelAction], a
Slots_WaitStopReel1: ; 928e6 (24:68e6)
ld a, [wReel1ReelAction]
2015-11-11 20:38:57 -08:00
cp $0
ret nz
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
ld bc, wReel1
ld de, wReel1Stopped
call Slots_LoadReelState
call Slots_Next
2015-11-11 20:38:57 -08:00
xor a
ld [hJoypadSum], a
2015-12-10 19:26:31 -08:00
Slots_WaitReel2: ; 92900 (24:6900)
2015-11-11 20:38:57 -08:00
ld hl, hJoypadSum ; $ffa5
ld a, [hl]
and A_BUTTON
ret z
2015-12-10 19:26:31 -08:00
call Slots_Next
call Slots_StopReel2
ld [wReel2ReelAction], a
Slots_WaitStopReel2: ; 92910 (24:6910)
ld a, [wReel2ReelAction]
2015-11-11 20:38:57 -08:00
cp $0
ret nz
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
ld bc, wReel2
ld de, wReel2Stopped
call Slots_LoadReelState
call Slots_Next
2015-11-11 20:38:57 -08:00
xor a
ld [hJoypadSum], a
2015-12-10 19:26:31 -08:00
Slots_WaitReel3: ; 9292a (24:692a)
2015-11-11 20:38:57 -08:00
ld hl, hJoypadSum ; $ffa5
ld a, [hl]
and A_BUTTON
ret z
2015-12-10 19:26:31 -08:00
call Slots_Next
call Slots_StopReel3
ld [wReel3ReelAction], a
Slots_WaitStopReel3: ; 9293a (24:693a)
ld a, [wReel3ReelAction]
2015-11-11 20:38:57 -08:00
cp $0
ret nz
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
ld bc, wReel3
ld de, wReel3Stopped
call Slots_LoadReelState
call Slots_Next
2015-11-11 20:38:57 -08:00
xor a
ld [hJoypadSum], a
ret
2015-12-10 19:26:31 -08:00
Slots_FlashIfWin: ; 92955 (24:6955)
ld a, [wSlotMatched]
cp -1
jr nz, .GotIt
call Slots_Next
call Slots_Next
2015-11-11 20:38:57 -08:00
ret
.GotIt:
2015-12-10 19:26:31 -08:00
call Slots_Next
ld a, 16
ld [wcf64], a
Slots_FlashScreen: ; 9296b (24:696b)
2015-11-11 20:38:57 -08:00
ld hl, wcf64
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr z, .done
2015-11-11 20:38:57 -08:00
dec [hl]
srl a
ret z
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
ld a, [rOBP0]
xor $ff
ld e, a
ld d, a
call DmgToCgbObjPals
ret
2015-12-10 19:26:31 -08:00
.done
call Slots_GetPals
call Slots_Next
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_GiveEarnedCoins: ; 92987 (24:6987)
2015-11-11 20:38:57 -08:00
xor a
2015-12-10 19:26:31 -08:00
ld [wFirstTwoReelsMatching], a
ld [wFirstTwoReelsMatchingSevens], a
ld a, %11100100
2015-11-11 20:38:57 -08:00
call DmgToCgbBGPals
2015-12-10 19:26:31 -08:00
call SlotGetPayout
2015-11-11 20:38:57 -08:00
xor a
ld [wcf64], a
2015-12-10 19:26:31 -08:00
call Slots_Next
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_PayoutTextAndAnim: ; 9299e (24:699e)
call SlotPayoutText
call Slots_Next
Slots_PayoutAnim: ; 929a4 (24:69a4)
2015-11-11 20:38:57 -08:00
ld hl, wcf64
ld a, [hl]
inc [hl]
and $1
ret z
2015-12-10 19:26:31 -08:00
ld hl, wPayout
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld d, a
or [hl]
2015-12-10 19:26:31 -08:00
jr z, .done
2015-11-11 20:38:57 -08:00
ld e, [hl]
dec de
ld [hl], e
dec hl
ld [hl], d
ld hl, Coins
ld d, [hl]
inc hl
ld e, [hl]
2015-12-10 19:26:31 -08:00
call Slot_CheckCoinCaseFull
jr c, .okay
2015-11-11 20:38:57 -08:00
inc de
2015-12-10 19:26:31 -08:00
.okay
2015-11-11 20:38:57 -08:00
ld [hl], e
dec hl
ld [hl], d
ld a, [wcf64]
and $7
2015-12-10 19:26:31 -08:00
ret z ; ret nz would be more appropriate
2015-11-11 20:38:57 -08:00
ld de, SFX_GET_COIN_FROM_SLOTS
call PlaySFX
ret
2015-12-10 19:26:31 -08:00
.done
call Slots_Next
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_RestartOrQuit: ; 929d9 (24:69d9)
call Slots_DeilluminateBetLights
2015-11-11 20:38:57 -08:00
call WaitPressAorB_BlinkCursor
2015-12-10 19:26:31 -08:00
call Slots_AskPlayAgain
jr c, .exit_slots
2015-12-26 18:59:03 -08:00
ld a, 0
2015-11-11 20:38:57 -08:00
ld [wJumptableIndex], a
ret
2015-12-10 19:26:31 -08:00
.exit_slots
2015-12-26 18:59:03 -08:00
ld a, 18
2015-11-11 20:38:57 -08:00
ld [wJumptableIndex], a
ret
2015-12-10 19:26:31 -08:00
Slots_Quit: ; 929f0 (24:69f0)
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2015-12-10 19:26:31 -08:00
Slots_LoadReelState: ; 929f6 (24:69f6)
2015-11-11 20:38:57 -08:00
push de
2015-12-10 19:26:31 -08:00
call Slots_GetCurrentReelState
2015-11-11 20:38:57 -08:00
pop de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
ret
2015-12-10 19:26:31 -08:00
Slot_CheckCoinCaseFull: ; 92a04 (24:6a04)
2015-11-11 20:38:57 -08:00
ld a, d
cp 9999 / $100
2015-12-10 19:26:31 -08:00
jr c, .not_full
2015-11-11 20:38:57 -08:00
ld a, e
cp 9999 % $100
2015-12-10 19:26:31 -08:00
jr c, .not_full
2015-11-11 20:38:57 -08:00
scf
ret
2015-12-10 19:26:31 -08:00
.not_full
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-10 19:26:31 -08:00
Slots_GetCurrentReelState: ; 92a12 (24:6a12)
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr nz, .okay
2015-11-11 20:38:57 -08:00
ld a, $f
2015-12-10 19:26:31 -08:00
.okay
2015-11-11 20:38:57 -08:00
dec a
and $f
ld e, a
ld d, $0
2015-12-10 19:26:31 -08:00
ld hl, wReel1TilemapAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
add hl, de
ret
2015-12-10 19:26:31 -08:00
Slots_StopReel1: ; 92a2b (24:6a2b)
2015-11-11 20:38:57 -08:00
ld a, $7
ret
2015-12-10 19:26:31 -08:00
Slots_StopReel2: ; 92a2e (24:6a2e)
ld a, [wSlotBet]
2015-11-11 20:38:57 -08:00
cp $2
jr c, .dont_jump
2015-12-10 19:26:31 -08:00
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr z, .skip
cp SLOTS_NOMATCH
jr nz, .dont_jump
2015-12-10 19:26:31 -08:00
.skip
call .CheckReel1ForASeven
jr nz, .dont_jump
2015-11-11 20:38:57 -08:00
call Random
2015-12-10 19:26:31 -08:00
cp $50 ; 32%
jr nc, .dont_jump
2015-11-11 20:38:57 -08:00
ld a, $a
ret
2015-12-10 19:26:31 -08:00
.dont_jump
2015-11-11 20:38:57 -08:00
ld a, $8
ret
2015-12-10 19:26:31 -08:00
.CheckReel1ForASeven: ; 92a51 (24:6a51)
ld a, [wReel1Stopped]
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-10 19:26:31 -08:00
ld a, [wReel1Stopped + 1]
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-10 19:26:31 -08:00
ld a, [wReel1Stopped + 2]
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-10 19:26:31 -08:00
Slots_StopReel3: ; 92a60 (24:6a60)
ld a, [wFirstTwoReelsMatching]
2015-11-11 20:38:57 -08:00
and a
jr z, .stop
2015-12-10 19:26:31 -08:00
ld a, [wFirstTwoReelsMatchingSevens]
2015-11-11 20:38:57 -08:00
and a
jr z, .stop
2015-12-10 19:26:31 -08:00
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .biased
2015-11-11 20:38:57 -08:00
call Random
cp 180
jr nc, .stop
2015-11-11 20:38:57 -08:00
cp 120
jr nc, .slow_advance
2015-11-11 20:38:57 -08:00
cp 60
jr nc, .golem
2015-11-11 20:38:57 -08:00
ld a, $15
ret
2015-12-10 19:26:31 -08:00
.biased
2015-11-11 20:38:57 -08:00
call Random
2015-12-10 19:26:31 -08:00
cp 160
jr nc, .stop
2015-12-10 19:26:31 -08:00
cp 80
jr nc, .slow_advance
.golem
2015-11-11 20:38:57 -08:00
ld a, $12
ret
2015-12-10 19:26:31 -08:00
.slow_advance
2015-11-11 20:38:57 -08:00
ld a, $10
ret
2015-12-10 19:26:31 -08:00
.stop
2015-11-11 20:38:57 -08:00
ld a, $9
ret
2015-12-10 19:26:31 -08:00
InitReelTiles: ; 92a98 (24:6a98)
ld bc, wReel1
ld hl, wReel1OAMAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Sprites + 16 * 4
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1TilemapAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Reel1Tilemap
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1XCoord - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld [hl], 6 * 8
call .OAM
ld bc, wReel2
ld hl, wReel1OAMAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Sprites + 24 * 4
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1TilemapAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Reel2Tilemap
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1XCoord - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld [hl], 10 * 8
call .OAM
ld bc, wReel3
ld hl, wReel1OAMAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Sprites + 32 * 4
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1TilemapAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld de, Reel3Tilemap
2015-11-11 20:38:57 -08:00
ld [hl], e
inc hl
ld [hl], d
2015-12-10 19:26:31 -08:00
ld hl, wReel1XCoord - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld [hl], 14 * 8
call .OAM
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.OAM: ; 92af9 (24:6af9)
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
2015-12-10 19:26:31 -08:00
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld [hl], REEL_SIZE - 1
ld hl, wReel1SpinDistance - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
2015-12-10 19:26:31 -08:00
call UpdateReelPositionAndOAM
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
Slots_SpinReels: ; 92b0f (24:6b0f)
ld bc, wReel1
call .SpinReel
ld bc, wReel2
call .SpinReel
ld bc, wReel3
call .SpinReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.SpinReel: ; 92b22 (24:6b22)
ld hl, wReel1SpinDistance - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and $f
2015-12-10 19:26:31 -08:00
jr nz, .skip
2015-11-11 20:38:57 -08:00
call Function92bd4
2015-12-10 19:26:31 -08:00
.skip
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
ret z
ld d, a
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinDistance - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
add [hl]
ld [hl], a
and $f
2015-12-10 19:26:31 -08:00
jr z, UpdateReelPositionAndOAM
ld hl, wReel1OAMAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld e, $8
2015-12-10 19:26:31 -08:00
.loop
2015-11-11 20:38:57 -08:00
ld a, [hl]
add d
ld [hli], a
inc hl
inc hl
inc hl
2015-11-11 20:38:57 -08:00
dec e
2015-12-10 19:26:31 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
UpdateReelPositionAndOAM: ; 92b53 (24:6b53)
ld hl, wReel1XCoord - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
2015-12-10 19:26:31 -08:00
ld [wCurrReelXCoord], a
ld a, 10 * 8
ld [wCurrReelYCoord], a
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld e, [hl]
2015-12-10 19:26:31 -08:00
ld d, 0
ld hl, wReel1TilemapAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
add hl, de
ld e, l
ld d, h
2015-12-10 19:26:31 -08:00
call .LoadOAM
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
inc a
and $f
2015-12-10 19:26:31 -08:00
cp REEL_SIZE
jr nz, .load
2015-11-11 20:38:57 -08:00
xor a
2015-12-10 19:26:31 -08:00
.load
2015-11-11 20:38:57 -08:00
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
.LoadOAM: ; 92b83 (24:6b83)
ld hl, wReel1OAMAddr - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-10 19:26:31 -08:00
.loop
ld a, [wCurrReelYCoord]
2015-11-11 20:38:57 -08:00
ld [hli], a
2015-12-10 19:26:31 -08:00
ld a, [wCurrReelXCoord]
2015-11-11 20:38:57 -08:00
ld [hli], a
ld a, [de]
ld [hli], a
srl a
srl a
set 7, a
ld [hli], a
2015-12-10 19:26:31 -08:00
ld a, [wCurrReelYCoord]
2015-11-11 20:38:57 -08:00
ld [hli], a
2015-12-10 19:26:31 -08:00
ld a, [wCurrReelXCoord]
add 1 * 8
2015-11-11 20:38:57 -08:00
ld [hli], a
ld a, [de]
inc a
2015-12-10 19:26:31 -08:00
inc a
2015-11-11 20:38:57 -08:00
ld [hli], a
srl a
srl a
set 7, a
ld [hli], a
inc de
2015-12-10 19:26:31 -08:00
ld a, [wCurrReelYCoord]
sub 2 * 8
ld [wCurrReelYCoord], a
cp 2 * 8
jr nz, .loop
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92bbe (24:6bbe)
Function92bbe: ; 92bbe
push hl
srl a
srl a
add Unknown_92bce % $100
ld l, a
ld a, 0
adc Unknown_92bce / $100
ld h, a
ld a, [hl]
pop hl
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92bce
Unknown_92bce: ; 92bce
db 0, 1, 2, 3, 4, 5
; 92bd4
Function92bd4: ; 92bd4 (24:6bd4)
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld e, [hl]
ld d, 0
2015-12-26 18:59:03 -08:00
ld hl, .dw
add hl, de
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92be4 (24:6be4)
.dw ; 92be4
2015-12-26 18:59:03 -08:00
dw ReelAction_DoNothing ; 00
dw Slots_StopReelIgnoreJoypad ; 01
dw ReelAction_QuadrupleRate ; 02
dw ReelAction_DoubleRate ; 03
dw ReelAction_NormalRate ; 04
dw ReelAction_HalfRate ; 05
dw ReelAction_QuarterRate ; 06
dw ReelAction_StopReel1 ; 07
dw ReelAction_StopReel2 ; 08
dw ReelAction_StopReel3 ; 09
dw ReelAction_SetUpReel2SkipTo7 ; 0a
dw ReelAction_WaitReel2SkipTo7 ; 0b
dw ReelAction_FastSpinReel2UntilLinedUp7s ; 0c
dw ReelAction_BoringReelDrops ; 0d
dw ReelAction_CheckDropReel ; 0e
dw ReelAction_WaitDropReel ; 0f
dw ReelAction_StartSlowAdvanceReel3 ; 10
dw ReelAction_WaitSlowAdvanceReel3 ; 11
dw ReelAction_InitGolem ; 12
dw ReelAction_WaitGolem ; 13
dw ReelAction_EndGolem ; 14
dw Slots_InitChansey ; 15
dw ReelAction_WaitChansey ; 16
dw ReelAction_WaitEgg ; 17
dw ReelAction_DropReel ; 18
2015-11-11 20:38:57 -08:00
; 92c16
2015-12-10 19:26:31 -08:00
ReelAction_DoNothing: ; 92c16
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c17
2015-12-10 19:26:31 -08:00
ReelAction_QuadrupleRate: ; 92c17
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $10
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c1e
2015-12-10 19:26:31 -08:00
ReelAction_DoubleRate: ; 92c1e
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $8
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c25
2015-12-10 19:26:31 -08:00
ReelAction_NormalRate: ; 92c25
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $4
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c2c
2015-12-10 19:26:31 -08:00
ReelAction_HalfRate: ; 92c2c
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $2
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c33
2015-12-10 19:26:31 -08:00
ReelAction_QuarterRate: ; 92c33
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $1
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c3a
2015-12-10 19:26:31 -08:00
Slots_StopReel: ; 92c3a
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $1
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0f - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $3
2015-12-10 19:26:31 -08:00
Slots_StopReelIgnoreJoypad: ; 92c4c
ld hl, wReel1Slot0f - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr z, .EndReel
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.EndReel:
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, $0
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c5e
2015-12-10 19:26:31 -08:00
ReelAction_StopReel1: ; 92c5e
ld a, [wSlotBias]
cp SLOTS_NOMATCH
jr z, .NoBias
ld hl, wReel1Slot09 - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr z, .NoBias
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-10 19:26:31 -08:00
call .CheckForBias
2015-11-11 20:38:57 -08:00
ret nz
.NoBias:
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c76
2015-12-10 19:26:31 -08:00
.CheckForBias: ; 92c76
call Slots_GetCurrentReelState
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
ld e, a
ld a, [hli]
cp e
ret z
ld a, [hli]
cp e
ret z
ld a, [hl]
cp e
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92c86
2015-12-10 19:26:31 -08:00
ReelAction_StopReel2: ; 92c86
call Slots_CheckMatchedFirstTwoReels
jr nc, .nope
ld a, [wSlotBuildingMatch]
ld hl, wSlotBias
2015-11-11 20:38:57 -08:00
cp [hl]
jr z, .NoBias
2015-12-10 19:26:31 -08:00
.nope
ld a, [wSlotBias]
cp SLOTS_NOMATCH
jr z, .NoBias
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot09 - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .NoBias
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.NoBias:
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92ca9
2015-12-10 19:26:31 -08:00
ReelAction_StopReel3: ; 92ca9
call Slots_CheckMatchedAllThreeReels
jr nc, .NoMatch
ld hl, wSlotBias
2015-11-11 20:38:57 -08:00
cp [hl]
jr z, .NoBias
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot09 - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
ret z
dec [hl]
ret
.NoMatch:
2015-12-10 19:26:31 -08:00
ld a, [wSlotBias]
cp SLOTS_NOMATCH
jr z, .NoBias
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot09 - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .NoBias
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.NoBias:
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92cd2
ReelAction_SetUpReel2SkipTo7: ; 92cd2
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedFirstTwoReels
jr nc, .no_match
ld a, [wFirstTwoReelsMatchingSevens]
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr z, .no_match
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.no_match
2015-11-11 20:38:57 -08:00
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $20
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92cf8
ReelAction_WaitReel2SkipTo7: ; 92cf8
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .asm_92d02
dec [hl]
ret
.asm_92d02
ld a, SFX_THROW_BALL
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $8
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92d13
ReelAction_FastSpinReel2UntilLinedUp7s: ; 92d13
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedFirstTwoReels
2015-11-11 20:38:57 -08:00
ret nc
2015-12-10 19:26:31 -08:00
ld a, [wFirstTwoReelsMatchingSevens]
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92d20
ReelAction_InitGolem: ; 92d20
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
ret c
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
call Slots_WaitSFX
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
call Function92fc0
push bc
push af
2015-11-18 10:01:55 -08:00
depixel 12, 13
2015-12-10 19:26:31 -08:00
ld a, SPRITE_ANIM_INDEX_SLOT_GOLEM
2015-11-13 07:48:49 -08:00
call _InitSpriteAnimStruct
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0E
2015-11-11 20:38:57 -08:00
add hl, bc
pop af
ld [hl], a
pop bc
xor a
ld [wcf64], a
ReelAction_WaitGolem: ; 92d4f
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
cp 2
jr z, .two
cp 1
jr z, .one
2015-11-11 20:38:57 -08:00
ret
.two
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
.one
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $8
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92d6e
ReelAction_EndGolem: ; 92d6e
2015-11-11 20:38:57 -08:00
xor a
ld [wcf64], a
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
dec [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92d7e
2015-12-10 19:26:31 -08:00
Slots_InitChansey: ; 92d7e
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
ret c
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
call Slots_WaitSFX
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
push bc
2015-11-18 10:01:55 -08:00
depixel 12, 0
2015-12-10 19:26:31 -08:00
ld a, SPRITE_ANIM_INDEX_SLOTS_CHANSEY
2015-11-13 07:48:49 -08:00
call _InitSpriteAnimStruct
2015-11-11 20:38:57 -08:00
pop bc
xor a
ld [wcf64], a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92da4
ReelAction_WaitChansey: ; 92da4
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
and a
ret z
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
ld a, $2
ld [wcf64], a
ReelAction_WaitEgg: ; 92db3
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
cp $4
ret c
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $10
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $11
ReelAction_DropReel: ; 92dca
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .check_match
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.check_match
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
jr nc, .EggAgain
2015-11-11 20:38:57 -08:00
and a
jr nz, .EggAgain
2015-11-11 20:38:57 -08:00
ld a, $5
ld [wcf64], a
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
.EggAgain:
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
dec [hl]
2015-12-26 18:59:03 -08:00
dec [hl]
2015-11-11 20:38:57 -08:00
ld a, $1
ld [wcf64], a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92df7
ReelAction_BoringReelDrops: ; 92df7
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
ret c
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
call Slots_WaitSFX
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
call Function92fc0
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], a
ReelAction_CheckDropReel: ; 92e10
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr nz, .spin
call Slots_CheckMatchedAllThreeReels
call Slots_StopReel
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.spin
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0b - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $20
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ReelAction_WaitDropReel: ; 92e31
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0b - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .DropReel
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.DropReel:
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
dec [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
2015-12-10 19:26:31 -08:00
ld [hl], $8 ; 2x
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92e47
ReelAction_StartSlowAdvanceReel3: ; 92e47
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
ret c
ld a, SFX_STOP_SLOT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
call Slots_WaitSFX
ld hl, wReel1SpinRate - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $1
2015-12-10 19:26:31 -08:00
ld hl, wReel1ReelAction - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $10
ReelAction_WaitSlowAdvanceReel3: ; 92e64
2015-12-10 19:26:31 -08:00
ld hl, wReel1Slot0a - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .check1
2015-11-11 20:38:57 -08:00
dec [hl]
.play_sfx
2015-11-11 20:38:57 -08:00
ld a, SFX_GOT_SAFARI_BALLS
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
ret
.check1
2015-12-10 19:26:31 -08:00
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
and a
jr nz, .check2
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
jr nc, .play_sfx
2015-11-11 20:38:57 -08:00
and a
jr nz, .play_sfx
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
call WaitSFX
ret
.check2
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
jr c, .play_sfx
2015-12-10 19:26:31 -08:00
call Slots_StopReel
2015-11-11 20:38:57 -08:00
call WaitSFX
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92e94
2015-12-10 19:26:31 -08:00
Slots_CheckMatchedFirstTwoReels: ; 92e94
2015-11-11 20:38:57 -08:00
xor a
2015-12-10 19:26:31 -08:00
ld [wFirstTwoReelsMatching], a
ld [wFirstTwoReelsMatchingSevens], a
call Slots_GetCurrentReelState
call Slots_CopyReelState
ld a, [wSlotBet]
2015-11-11 20:38:57 -08:00
and 3
ld e, a
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .Jumptable
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-26 18:59:03 -08:00
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-10 19:26:31 -08:00
ld de, .return
2015-11-11 20:38:57 -08:00
push de
jp hl
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.return
ld a, [wFirstTwoReelsMatching]
2015-11-11 20:38:57 -08:00
and a
ret z
scf
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92ebd
2015-12-10 19:26:31 -08:00
.Jumptable: ; 92ebd
2015-12-26 18:59:03 -08:00
dw .zero
dw .one
dw .two
dw .three
2015-11-11 20:38:57 -08:00
; 92ec5
.three ; 92ec5
2015-12-10 19:26:31 -08:00
call .CheckUpwardsDiag
call .CheckDownwardsDiag
2015-11-11 20:38:57 -08:00
.two ; 92ecb
2015-12-10 19:26:31 -08:00
call .CheckBottomRow
call .CheckTopRow
2015-11-11 20:38:57 -08:00
.one ; 92ed1
2015-12-10 19:26:31 -08:00
call .CheckMiddleRow
2015-11-11 20:38:57 -08:00
.zero ; 92ed4
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92ed5
2015-12-10 19:26:31 -08:00
.CheckBottomRow: ; 92ed5
ld hl, wCurrReelStopped
ld a, [wReel1Stopped]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92ee0
2015-12-10 19:26:31 -08:00
.CheckUpwardsDiag: ; 92ee0
ld hl, wCurrReelStopped + 1
ld a, [wReel1Stopped]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92eeb
2015-12-10 19:26:31 -08:00
.CheckMiddleRow: ; 92eeb
ld hl, wCurrReelStopped + 1
ld a, [wReel1Stopped + 1]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92ef6
2015-12-10 19:26:31 -08:00
.CheckDownwardsDiag: ; 92ef6
ld hl, wCurrReelStopped + 1
ld a, [wReel1Stopped + 2]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f01
2015-12-10 19:26:31 -08:00
.CheckTopRow: ; 92f01
ld hl, wCurrReelStopped + 2
ld a, [wReel1Stopped + 2]
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f0c
2015-12-10 19:26:31 -08:00
.StoreResult: ; 92f0c
ld [wSlotBuildingMatch], a
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .matching_sevens
2015-11-11 20:38:57 -08:00
ld a, $1
2015-12-10 19:26:31 -08:00
ld [wFirstTwoReelsMatchingSevens], a
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.matching_sevens
2015-11-11 20:38:57 -08:00
ld a, $1
2015-12-10 19:26:31 -08:00
ld [wFirstTwoReelsMatching], a
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f1d
2015-12-10 19:26:31 -08:00
Slots_CheckMatchedAllThreeReels: ; 92f1d
2015-11-11 20:38:57 -08:00
ld a, $ff
2015-12-10 19:26:31 -08:00
ld [wSlotMatched], a
call Slots_GetCurrentReelState
call Slots_CopyReelState
ld a, [wSlotBet]
2015-11-11 20:38:57 -08:00
and 3
ld e, a
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .Jumptable
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-26 18:59:03 -08:00
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-10 19:26:31 -08:00
ld de, .return
2015-11-11 20:38:57 -08:00
push de
jp hl
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.return
ld a, [wSlotMatched]
2015-11-11 20:38:57 -08:00
cp $ff
2015-12-10 19:26:31 -08:00
jr nz, .matched_nontrivial
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-10 19:26:31 -08:00
.matched_nontrivial
2015-11-11 20:38:57 -08:00
scf
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f48
2015-12-10 19:26:31 -08:00
.Jumptable: ; 92f48
2015-12-26 18:59:03 -08:00
dw .zero
dw .one
dw .two
dw .three
2015-11-11 20:38:57 -08:00
; 92f50
.three ; 92f50
2015-12-10 19:26:31 -08:00
call .CheckUpwardsDiag
call .CheckDownwardsDiag
2015-11-11 20:38:57 -08:00
.two ; 92f56
2015-12-10 19:26:31 -08:00
call .CheckBottomRow
call .CheckTopRow
2015-11-11 20:38:57 -08:00
.one ; 92f5c
2015-12-10 19:26:31 -08:00
call .CheckMiddleRow
2015-11-11 20:38:57 -08:00
.zero ; 92f5f
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f60
2015-12-10 19:26:31 -08:00
.CheckBottomRow: ; 92f60
ld hl, wCurrReelStopped
ld a, [wReel1Stopped]
2015-11-11 20:38:57 -08:00
cp [hl]
ret nz
2015-12-10 19:26:31 -08:00
ld hl, wReel2Stopped
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f70
2015-12-10 19:26:31 -08:00
.CheckUpwardsDiag: ; 92f70
ld hl, wCurrReelStopped + 2
ld a, [wReel1Stopped]
2015-11-11 20:38:57 -08:00
cp [hl]
ret nz
2015-12-10 19:26:31 -08:00
ld hl, wReel2Stopped + 1
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f80
2015-12-10 19:26:31 -08:00
.CheckMiddleRow: ; 92f80
ld hl, wCurrReelStopped + 1
ld a, [wReel1Stopped + 1]
2015-11-11 20:38:57 -08:00
cp [hl]
ret nz
2015-12-10 19:26:31 -08:00
ld hl, wReel2Stopped + 1
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92f90
2015-12-10 19:26:31 -08:00
.CheckDownwardsDiag: ; 92f90
ld hl, wCurrReelStopped
ld a, [wReel1Stopped + 2]
2015-11-11 20:38:57 -08:00
cp [hl]
ret nz
2015-12-10 19:26:31 -08:00
ld hl, wReel2Stopped + 1
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92fa0
2015-12-10 19:26:31 -08:00
.CheckTopRow: ; 92fa0
ld hl, wCurrReelStopped + 2
ld a, [wReel1Stopped + 2]
2015-11-11 20:38:57 -08:00
cp [hl]
ret nz
2015-12-10 19:26:31 -08:00
ld hl, wReel2Stopped + 2
2015-11-11 20:38:57 -08:00
cp [hl]
2015-12-10 19:26:31 -08:00
call z, .StoreResult
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92fb0
2015-12-10 19:26:31 -08:00
.StoreResult: ; 92fb0
ld [wSlotMatched], a
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92fb4
2015-12-10 19:26:31 -08:00
Slots_CopyReelState: ; 92fb4
ld de, wCurrReelStopped
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92fc0
Function92fc0: ; 92fc0
2015-12-10 19:26:31 -08:00
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
push af
push hl
call .Check7Bias
2015-11-11 20:38:57 -08:00
pop hl
pop af
ld [hl], a
ld a, e
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 92fcf
.Check7Bias: ; 92fcf
2015-12-10 19:26:31 -08:00
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .not_biased_to_seven
2015-11-11 20:38:57 -08:00
ld e, $0
2015-12-10 19:26:31 -08:00
.loop1
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
inc e
push de
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
pop de
2015-12-10 19:26:31 -08:00
jr nc, .loop1
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .loop1
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.not_biased_to_seven
2015-11-11 20:38:57 -08:00
call Random
and $7
cp $4 ; ((50 percent) & 7) + 1
2015-12-10 19:26:31 -08:00
jr c, .not_biased_to_seven
2015-11-11 20:38:57 -08:00
ld e, a
2015-12-10 19:26:31 -08:00
.loop2
2015-11-11 20:38:57 -08:00
ld a, e
inc e
2015-12-10 19:26:31 -08:00
ld hl, wReel1Position - wReel1
2015-11-11 20:38:57 -08:00
add hl, bc
add [hl]
ld [hl], a
push de
2015-12-10 19:26:31 -08:00
call Slots_CheckMatchedAllThreeReels
2015-11-11 20:38:57 -08:00
pop de
2015-12-10 19:26:31 -08:00
jr c, .loop2
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93002
2015-12-10 19:26:31 -08:00
Slots_InitBias: ; 93002 (24:7002)
ld a, [wSlotBias]
2015-11-11 20:38:57 -08:00
and a
ret z
2015-12-10 19:26:31 -08:00
ld hl, .Normal
2015-11-11 20:38:57 -08:00
ld a, [ScriptVar]
and a
2015-12-10 19:26:31 -08:00
jr z, .okay
ld hl, .Lucky
.okay
2015-11-11 20:38:57 -08:00
call Random
ld c, a
2015-12-10 19:26:31 -08:00
.loop
2015-11-11 20:38:57 -08:00
ld a, [hli]
cp c
2015-12-10 19:26:31 -08:00
jr nc, .done
2015-11-11 20:38:57 -08:00
inc hl
2015-12-10 19:26:31 -08:00
jr .loop
.done
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-10 19:26:31 -08:00
ld [wSlotBias], a
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93023 (24:7023)
2015-12-10 19:26:31 -08:00
.Normal: ; 93023
db $01, SLOTS_SEVEN ; 1/256
db $03, SLOTS_POKEBALL ; 1/128
db $0a, SLOTS_STARYU ; 7/256
db $14, SLOTS_SQUIRTLE ; 5/128
db $28, SLOTS_PIKACHU ; 5/64
db $30, SLOTS_CHERRY ; 1/32
db $ff, SLOTS_NOMATCH ; everything else
2015-11-11 20:38:57 -08:00
; 93031
2015-12-10 19:26:31 -08:00
.Lucky: ; 93031
db $02, SLOTS_SEVEN ; 1/128
db $03, SLOTS_POKEBALL ; 1/256
db $08, SLOTS_STARYU ; 5/256
db $10, SLOTS_SQUIRTLE ; 1/32
db $1e, SLOTS_PIKACHU ; 7/128
db $50, SLOTS_CHERRY ; 25/128
db $ff, SLOTS_NOMATCH ; everything else
2015-11-11 20:38:57 -08:00
; 9303f
2015-12-10 19:26:31 -08:00
Slots_IlluminateBetLights: ; 9303f (24:703f)
ld b, $14 ; turned on
ld a, [wSlotBet]
2015-11-11 20:38:57 -08:00
dec a
2015-12-10 19:26:31 -08:00
jr z, Slots_Lights1OnOff
2015-11-11 20:38:57 -08:00
dec a
2015-12-10 19:26:31 -08:00
jr z, Slots_Lights2OnOff
jr Slots_Lights3OnOff
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
Slots_DeilluminateBetLights: ; 9304c (24:704c)
ld b, $23 ; turned off
Slots_Lights3OnOff: ; 9304e (24:704e)
2015-11-11 20:38:57 -08:00
hlcoord 3, 2
2015-12-10 19:26:31 -08:00
call Slots_TurnLightsOnOrOff
2015-11-11 20:38:57 -08:00
hlcoord 3, 10
2015-12-10 19:26:31 -08:00
call Slots_TurnLightsOnOrOff
Slots_Lights2OnOff: ; 9305a (24:705a)
2015-11-11 20:38:57 -08:00
hlcoord 3, 4
2015-12-10 19:26:31 -08:00
call Slots_TurnLightsOnOrOff
2015-11-11 20:38:57 -08:00
hlcoord 3, 8
2015-12-10 19:26:31 -08:00
call Slots_TurnLightsOnOrOff
Slots_Lights1OnOff: ; 93066 (24:7066)
2015-11-11 20:38:57 -08:00
hlcoord 3, 6
2015-12-10 19:26:31 -08:00
Slots_TurnLightsOnOrOff: ; 93069 (24:7069)
2015-11-11 20:38:57 -08:00
ld a, b
ld [hl], a
2015-12-10 19:26:31 -08:00
ld de, SCREEN_WIDTH / 2 + 3
2015-11-11 20:38:57 -08:00
add hl, de
ld [hl], a
2015-12-10 19:26:31 -08:00
ld de, SCREEN_WIDTH / 2 - 3
2015-11-11 20:38:57 -08:00
add hl, de
inc a
ld [hl], a
2015-12-10 19:26:31 -08:00
ld de, SCREEN_WIDTH / 2 + 3
2015-11-11 20:38:57 -08:00
add hl, de
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
Slots_AskBet: ; 9307c (24:707c)
.loop
ld hl, .Text_BetHowManyCoins
2015-11-11 20:38:57 -08:00
call PrintText
2015-12-10 19:26:31 -08:00
ld hl, .MenuDataHeader
2015-11-11 20:38:57 -08:00
call LoadMenuDataHeader
2015-12-15 15:59:49 -08:00
call VerticalMenu
call CloseWindow
2015-11-11 20:38:57 -08:00
ret c
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
ld b, a
2015-12-10 19:26:31 -08:00
ld a, 4
2015-11-11 20:38:57 -08:00
sub b
2015-12-10 19:26:31 -08:00
ld [wSlotBet], a
2015-11-11 20:38:57 -08:00
ld hl, Coins
ld c, a
ld a, [hli]
and a
2015-12-10 19:26:31 -08:00
jr nz, .Start
2015-11-11 20:38:57 -08:00
ld a, [hl]
cp c
2015-12-10 19:26:31 -08:00
jr nc, .Start
ld hl, .Text_NotEnoughCoins
2015-11-11 20:38:57 -08:00
call PrintText
2015-12-10 19:26:31 -08:00
jr .loop
.Start:
2015-11-11 20:38:57 -08:00
ld hl, Coins + 1
ld a, [hl]
sub c
ld [hld], a
2015-12-10 19:26:31 -08:00
jr nc, .ok
2015-11-11 20:38:57 -08:00
dec [hl]
2015-12-10 19:26:31 -08:00
.ok
2015-11-11 20:38:57 -08:00
call WaitSFX
ld de, SFX_PAY_DAY
call PlaySFX
2015-12-10 19:26:31 -08:00
ld hl, .Text_Start
2015-11-11 20:38:57 -08:00
call PrintText
and a
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 930c7 (24:70c7)
2015-12-10 19:26:31 -08:00
.Text_BetHowManyCoins: ; 0x930c7
2015-11-11 20:38:57 -08:00
; Bet how many coins?
text_jump UnknownText_0x1c5049
db "@"
; 0x930cc
2015-12-10 19:26:31 -08:00
.Text_Start: ; 0x930cc
2015-11-11 20:38:57 -08:00
; Start!
text_jump UnknownText_0x1c505e
db "@"
; 0x930d1
2015-12-10 19:26:31 -08:00
.Text_NotEnoughCoins: ; 0x930d1
2015-11-11 20:38:57 -08:00
; Not enough coins.
text_jump UnknownText_0x1c5066
db "@"
; 0x930d6
2015-12-10 19:26:31 -08:00
.MenuDataHeader: ; 0x930d6
2015-11-11 20:38:57 -08:00
db $40 ; flags
db 10, 14 ; start coords
db 17, 19 ; end coords
2015-12-10 19:26:31 -08:00
dw .MenuData2
2015-11-11 20:38:57 -08:00
db 1 ; default option
; 0x930de
2015-12-10 19:26:31 -08:00
.MenuData2: ; 0x930de
2015-11-11 20:38:57 -08:00
db $80 ; flags
db 3 ; items
db " 3@"
db " 2@"
db " 1@"
; 0x930e9
2015-12-10 19:26:31 -08:00
Slots_AskPlayAgain: ; 930e9 (24:70e9)
2015-11-11 20:38:57 -08:00
ld hl, Coins
ld a, [hli]
or [hl]
2015-12-10 19:26:31 -08:00
jr nz, .you_have_coins
ld hl, .Text_OutOfCoins
2015-11-11 20:38:57 -08:00
call PrintText
ld c, 60
call DelayFrames
2015-12-10 19:26:31 -08:00
jr .exit_slots
.you_have_coins
ld hl, .Text_PlayAgain
2015-11-11 20:38:57 -08:00
call PrintText
call LoadMenuTextBox
lb bc, 14, 12
call PlaceYesNoBox
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
call CloseWindow
2015-11-11 20:38:57 -08:00
and a
2015-12-10 19:26:31 -08:00
jr nz, .exit_slots
2015-11-11 20:38:57 -08:00
and a
ret
2015-12-10 19:26:31 -08:00
.exit_slots
2015-11-11 20:38:57 -08:00
scf
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 9311a (24:711a)
2015-12-10 19:26:31 -08:00
.Text_OutOfCoins: ; 9311a
2015-11-11 20:38:57 -08:00
text_jump UnknownText_0x1c5079
db "@"
2015-12-10 19:26:31 -08:00
.Text_PlayAgain: ; 9311f
2015-11-11 20:38:57 -08:00
text_jump UnknownText_0x1c5092
db "@"
2015-12-10 19:26:31 -08:00
SlotGetPayout: ; 93124 (24:7124)
ld a, [wSlotMatched]
cp -1
jr z, .no_win
2015-11-11 20:38:57 -08:00
srl a
ld e, a
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .PayoutTable
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hli]
2015-12-10 19:26:31 -08:00
ld [wPayout + 1], a
2015-11-11 20:38:57 -08:00
ld e, a
ld a, [hl]
2015-12-10 19:26:31 -08:00
ld [wPayout], a
2015-11-11 20:38:57 -08:00
ld d, a
callba TrainerRankings_AddToSlotsPayouts
2015-11-11 20:38:57 -08:00
ret
.PayoutTable:
2015-12-10 19:26:31 -08:00
dw 300
dw 50
dw 6
dw 8
dw 10
dw 15
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.no_win
ld hl, wPayout
2015-11-11 20:38:57 -08:00
xor a
ld [hli], a
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
SlotPayoutText: ; 93158 (24:7158)
ld a, [wSlotMatched]
cp -1
jr nz, .MatchedSomething
ld hl, .Text_Darn
2015-11-11 20:38:57 -08:00
call PrintText
callba TrainerRankings_EndSlotsWinStreak
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
.MatchedSomething:
2015-11-11 20:38:57 -08:00
srl a
ld e, a
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .PayoutStrings
2015-11-11 20:38:57 -08:00
add hl, de
add hl, de
add hl, de
2015-11-11 20:38:57 -08:00
ld de, StringBuffer2
2015-12-10 19:26:31 -08:00
ld bc, 4
2015-11-11 20:38:57 -08:00
call CopyBytes
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-10 19:26:31 -08:00
ld de, .return
2015-11-11 20:38:57 -08:00
push de
jp hl
2015-12-10 19:26:31 -08:00
.return
ld hl, .Text_PrintPayout
2015-11-11 20:38:57 -08:00
call PrintText
callba TrainerRankings_AddToSlotsWinStreak
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93195 (24:7195)
2015-12-10 19:26:31 -08:00
.PayoutStrings: ; 93195
dbw "300@", .LinedUpSevens
dbw "50@@", .LinedUpPokeballs
dbw "6@@@", .LinedUpMonOrCherry
dbw "8@@@", .LinedUpMonOrCherry
dbw "10@@", .LinedUpMonOrCherry
dbw "15@@", .LinedUpMonOrCherry
2015-11-11 20:38:57 -08:00
; 931b9
2015-12-10 19:26:31 -08:00
.Text_PrintPayout: ; 0x931b9
2015-11-11 20:38:57 -08:00
start_asm
2015-12-10 19:26:31 -08:00
ld a, [wSlotMatched]
2015-11-11 20:38:57 -08:00
add $25
ldcoord_a 2, 13
inc a
ldcoord_a 2, 14
inc a
ldcoord_a 3, 13
inc a
ldcoord_a 3, 14
hlcoord 18, 17
2015-12-10 19:26:31 -08:00
ld [hl], "â–¼"
ld hl, .Text_LinedUpWonCoins
2015-11-11 20:38:57 -08:00
rept 4
inc bc
endr
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 931db
2015-12-10 19:26:31 -08:00
.Text_LinedUpWonCoins: ; 0x931db
2015-11-11 20:38:57 -08:00
; lined up! Won @ coins!
text_jump UnknownText_0x1c509f
db "@"
; 0x931e0
2015-12-10 19:26:31 -08:00
.Text_Darn: ; 0x931e0
2015-11-11 20:38:57 -08:00
; Darn!
text_jump UnknownText_0x1c50bb
db "@"
; 0x931e5
2015-12-10 19:26:31 -08:00
.LinedUpSevens: ; 931e5
2015-11-11 20:38:57 -08:00
ld a, SFX_2ND_PLACE
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
call WaitSFX
ld a, [wd002]
and a
jr nz, .asm_931ff
call Random
and $14
ret z
ld a, $ff
2015-12-10 19:26:31 -08:00
ld [wSlotBias], a
2015-11-11 20:38:57 -08:00
ret
.asm_931ff
call Random
and $1c
ret z
ld a, $ff
2015-12-10 19:26:31 -08:00
ld [wSlotBias], a
2015-11-11 20:38:57 -08:00
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 9320b
2015-12-10 19:26:31 -08:00
.LinedUpPokeballs: ; 9320b
2015-11-11 20:38:57 -08:00
ld a, SFX_3RD_PLACE
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
call WaitSFX
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93214
2015-12-10 19:26:31 -08:00
.LinedUpMonOrCherry: ; 93214
2015-11-11 20:38:57 -08:00
ld a, SFX_PRESENT
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
call WaitSFX
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 9321d
2015-12-10 19:26:31 -08:00
SlotMachine_AnimateGolem: ; 9321d (24:721d)
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
ld e, [hl]
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .Jumptable
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-26 18:59:03 -08:00
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.Jumptable: ; 9322d (24:722d)
2015-12-26 18:59:03 -08:00
dw .init
dw .fall
dw .roll
2015-11-11 20:38:57 -08:00
.init ; 93233 (24:7233)
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0E
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr nz, .retain
2015-11-11 20:38:57 -08:00
ld a, $2
ld [wcf64], a
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ret
2015-12-10 19:26:31 -08:00
.retain
2015-11-11 20:38:57 -08:00
dec [hl]
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $30
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
.fall ; 93259 (24:7259)
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
cp $20
2015-12-10 19:26:31 -08:00
jr c, .play_sound
2015-11-11 20:38:57 -08:00
dec [hl]
ld e, a
2015-12-10 19:26:31 -08:00
ld d, 14 * 8
callba BattleAnim_Sine_e
2015-11-11 20:38:57 -08:00
ld a, e
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_YOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], a
ret
2015-12-10 19:26:31 -08:00
.play_sound
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0D
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $2
ld a, $1
ld [wcf64], a
ld a, SFX_PLACE_PUZZLE_PIECE_DOWN
2015-12-10 19:26:31 -08:00
call Slots_PlaySFX
2015-11-11 20:38:57 -08:00
ret
.roll ; 93289 (24:7289)
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
inc [hl]
2015-12-26 18:59:03 -08:00
inc [hl]
2015-12-10 19:26:31 -08:00
cp 9 * 8
jr nc, .restart
2015-11-11 20:38:57 -08:00
and $3
ret nz
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0D
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
xor $ff
inc a
ld [hl], a
ld [hSCY], a
ret
2015-12-10 19:26:31 -08:00
.restart
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
xor a
ld [hl], a
ld [hSCY], a
ret
2015-12-10 19:26:31 -08:00
Slots_AnimateChansey: ; 932ac (24:72ac)
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
ld e, [hl]
ld d, 0
2015-12-10 19:26:31 -08:00
ld hl, .Jumptable
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-26 18:59:03 -08:00
add hl, de
2015-11-11 20:38:57 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 20:38:57 -08:00
2015-12-10 19:26:31 -08:00
.Jumptable: ; 932bc (24:72bc)
2015-12-26 18:59:03 -08:00
dw .walk
dw .one
dw .two
2015-11-11 20:38:57 -08:00
.walk ; 932c2 (24:72c2)
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
inc [hl]
2015-12-10 19:26:31 -08:00
cp 13 * 8
jr z, .limit
2015-11-11 20:38:57 -08:00
and $f
ret nz
ld de, SFX_JUMP_OVER_LEDGE
call PlaySFX
ret
2015-12-10 19:26:31 -08:00
.limit
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
ld a, $1
ld [wcf64], a
.one ; 932e0 (24:72e0)
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
cp $2
2015-12-10 19:26:31 -08:00
jr z, .retain
2015-11-11 20:38:57 -08:00
cp $5
ret nz
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ret
2015-12-10 19:26:31 -08:00
.retain
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $8
.two ; 932fc (24:72fc)
2015-12-10 19:26:31 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
2015-12-10 19:26:31 -08:00
jr z, .spawn_egg
2015-11-11 20:38:57 -08:00
dec [hl]
ret
2015-12-10 19:26:31 -08:00
.spawn_egg
2016-05-13 22:11:01 -07:00
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
dec [hl]
push bc
2015-11-18 10:01:55 -08:00
depixel 12, 13, 0, 4
2015-12-10 19:26:31 -08:00
ld a, SPRITE_ANIM_INDEX_SLOTS_EGG
2015-11-13 07:48:49 -08:00
call _InitSpriteAnimStruct
2015-11-11 20:38:57 -08:00
pop bc
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93316 (24:7316)
2015-12-10 19:26:31 -08:00
Slots_WaitSFX: ; 93316
2015-11-11 20:38:57 -08:00
push bc
ld c, 16
call DelayFrames
pop bc
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 9331e
2015-12-10 19:26:31 -08:00
Slots_PlaySFX: ; 9331e (24:731e)
2015-11-11 20:38:57 -08:00
push de
ld e, a
ld d, 0
call PlaySFX
pop de
ret
2015-12-10 19:26:31 -08:00
2015-11-11 20:38:57 -08:00
; 93327 (24:7327)
2015-12-10 19:26:31 -08:00
; The first three positions are repeated to
; avoid needing to check indices when copying.
Reel1Tilemap: ; 93327
db SLOTS_SEVEN ; 0
db SLOTS_CHERRY ; 1
db SLOTS_STARYU ; 2
db SLOTS_PIKACHU ; 3
db SLOTS_SQUIRTLE ; 4
db SLOTS_SEVEN ; 5
db SLOTS_CHERRY ; 6
db SLOTS_STARYU ; 7
db SLOTS_PIKACHU ; 8
db SLOTS_SQUIRTLE ; 9
db SLOTS_POKEBALL ; 10
db SLOTS_CHERRY ; 11
db SLOTS_STARYU ; 12
db SLOTS_PIKACHU ; 13
db SLOTS_SQUIRTLE ; 14
db SLOTS_SEVEN ; 0
db SLOTS_CHERRY ; 1
db SLOTS_STARYU ; 2
Reel2Tilemap: ; 93339
db SLOTS_SEVEN ; 0
db SLOTS_PIKACHU ; 1
db SLOTS_CHERRY ; 2
db SLOTS_SQUIRTLE ; 3
db SLOTS_STARYU ; 4
db SLOTS_POKEBALL ; 5
db SLOTS_PIKACHU ; 6
db SLOTS_CHERRY ; 7
db SLOTS_SQUIRTLE ; 8
db SLOTS_STARYU ; 9
db SLOTS_POKEBALL ; 10
db SLOTS_PIKACHU ; 11
db SLOTS_CHERRY ; 12
db SLOTS_SQUIRTLE ; 13
db SLOTS_STARYU ; 14
db SLOTS_SEVEN ; 0
db SLOTS_PIKACHU ; 1
db SLOTS_CHERRY ; 2
Reel3Tilemap: ; 9334b
db SLOTS_SEVEN ; 0
db SLOTS_PIKACHU ; 1
db SLOTS_CHERRY ; 2
db SLOTS_SQUIRTLE ; 3
db SLOTS_STARYU ; 4
db SLOTS_PIKACHU ; 5
db SLOTS_CHERRY ; 6
db SLOTS_SQUIRTLE ; 7
db SLOTS_STARYU ; 8
db SLOTS_PIKACHU ; 9
db SLOTS_POKEBALL ; 10
db SLOTS_CHERRY ; 11
db SLOTS_SQUIRTLE ; 12
db SLOTS_STARYU ; 13
db SLOTS_PIKACHU ; 14
db SLOTS_SEVEN ; 0
db SLOTS_PIKACHU ; 1
db SLOTS_CHERRY ; 2
2015-11-11 20:38:57 -08:00
; 9335d
SlotsTilemap: ; 9335d
INCBIN "gfx/slots.tilemap"
; 9344d
Slots1LZ: ; 9344d
INCBIN "gfx/slots_1.2bpp.lz"
; 935cd
Slots2LZ: ; 935cd
INCBIN "gfx/slots_2.2bpp.lz"
; 9382d
Slots3LZ: ; 9382d
INCBIN "gfx/slots_3.2bpp.lz"
; 93a3d