pokecrystal/engine/card_flip.asm

1685 lines
27 KiB
NASM
Raw Normal View History

2015-12-11 16:33:14 +00:00
CARDFLIP_LIGHT_OFF EQU $ef
CARDFLIP_LIGHT_ON EQU $f5
2015-12-11 21:59:40 +00:00
CARDFLIP_DECK_SIZE EQU 4 * 6
2015-12-11 16:33:14 +00:00
2015-11-12 04:38:57 +00:00
_CardFlip: ; e00ee (38:40ee)
ld hl, Options
set 4, [hl]
call ClearBGPalettes
call ClearTileMap
call ClearSprites
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
call DisableLCD
call LoadStandardFont
call LoadFontsExtra
2015-12-11 13:17:38 +00:00
ld hl, CardFlipLZ01
2017-12-28 12:32:33 +00:00
ld de, vTiles2 tile $00
2015-11-12 04:38:57 +00:00
call Decompress
2015-12-11 13:17:38 +00:00
ld hl, CardFlipLZ02
2017-12-28 12:32:33 +00:00
ld de, vTiles2 tile $3e
2015-11-12 04:38:57 +00:00
call Decompress
2015-12-11 13:17:38 +00:00
ld hl, CardFlipLZ03
2017-12-28 12:32:33 +00:00
ld de, vTiles0 tile $00
2015-11-12 04:38:57 +00:00
call Decompress
2015-12-11 13:17:38 +00:00
ld hl, CardFlipOffButtonGFX
2017-12-28 12:32:33 +00:00
ld de, vTiles1 tile $6f
2015-12-11 13:17:38 +00:00
ld bc, 1 tiles
2015-11-12 04:38:57 +00:00
call CopyBytes
2015-12-11 13:17:38 +00:00
ld hl, CardFlipOnButtonGFX
2017-12-28 12:32:33 +00:00
ld de, vTiles1 tile $75
2015-12-11 13:17:38 +00:00
ld bc, 1 tiles
2015-11-12 04:38:57 +00:00
call CopyBytes
2015-12-11 13:17:38 +00:00
call CardFlip_ShiftDigitsLeftTwoPixels
2015-12-11 21:59:40 +00:00
call CardFlip_InitTilemap
call CardFlip_InitAttrPals
2015-11-12 04:38:57 +00:00
call EnableLCD
2015-12-11 21:59:40 +00:00
call WaitBGMap2
2015-11-12 04:38:57 +00:00
ld a, $e4
call DmgToCgbBGPals
ld de, $e4e4
call DmgToCgbObjPals
call DelayFrame
xor a
ld [wJumptableIndex], a
ld a, $2
2015-12-11 21:59:40 +00:00
ld [wCardFlipCursorY], a
ld [wCardFlipCursorX], a
2015-11-12 04:38:57 +00:00
ld de, MUSIC_GAME_CORNER
call PlayMusic
.MasterLoop:
2015-11-12 04:38:57 +00:00
ld a, [wJumptableIndex]
bit 7, a
jr nz, .leavethegame
call .CardFlip
jr .MasterLoop
.leavethegame
call WaitSFX
ld de, SFX_QUIT_SLOTS
call PlaySFX
call WaitSFX
call ClearBGPalettes
ld hl, Options
res 4, [hl]
ret
.CardFlip: ; e0191 (38:4191)
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
2015-11-12 04:38:57 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-12 04:38:57 +00:00
; e01a0 (38:41a0)
.Jumptable: ; e01a0
2015-12-27 02:59:03 +00:00
dw .AskPlayWithThree
dw .DeductCoins
dw .ChooseACard
dw .PlaceYourBet
dw .CheckTheCard
dw .TabulateTheResult
dw .PlayAgain
dw .Quit
2015-11-12 04:38:57 +00:00
; e01b0
.Increment: ; e01b0
ld hl, wJumptableIndex
inc [hl]
ret
; e01b5
.AskPlayWithThree: ; e01b5
ld hl, .PlayWithThreeCoinsText
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
call YesNoBox
jr c, .SaidNo
2015-12-11 13:17:38 +00:00
call CardFlip_ShuffleDeck
2015-11-12 04:38:57 +00:00
call .Increment
ret
.SaidNo:
2015-12-27 02:59:03 +00:00
ld a, 7
2015-11-12 04:38:57 +00:00
ld [wJumptableIndex], a
ret
; e01cd
.PlayWithThreeCoinsText: ; 0xe01cd
; Play with three coins?
text_jump UnknownText_0x1c5793
db "@"
; 0xe01d2
.DeductCoins: ; e01d2
ld a, [Coins]
ld h, a
ld a, [Coins + 1]
ld l, a
ld a, h
and a
jr nz, .deduct ; You have at least 256 coins.
ld a, l
cp 3
jr nc, .deduct ; You have at least 3 coins.
ld hl, .NotEnoughCoinsText
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-12-27 02:59:03 +00:00
ld a, 7
2015-11-12 04:38:57 +00:00
ld [wJumptableIndex], a
ret
.deduct
ld de, -3
add hl, de
ld a, h
ld [Coins], a
ld a, l
ld [Coins + 1], a
ld de, SFX_TRANSACTION
call PlaySFX
xor a
ld [hBGMapMode], a
2015-12-11 13:17:38 +00:00
call CardFlip_PrintCoinBalance
2015-11-12 04:38:57 +00:00
ld a, $1
ld [hBGMapMode], a
call WaitSFX
call .Increment
ret
; e0212
.NotEnoughCoinsText: ; 0xe0212
; Not enough coins…
text_jump UnknownText_0x1c57ab
db "@"
; 0xe0217
.ChooseACard: ; e0217
xor a
ld [hBGMapMode], a
hlcoord 0, 0
lb bc, 12, 9
2015-12-11 13:17:38 +00:00
call CardFlip_FillGreenBox
2015-11-12 04:38:57 +00:00
hlcoord 9, 0
ld bc, SCREEN_WIDTH
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipNumCardsPlayed]
2015-11-12 04:38:57 +00:00
call AddNTimes
2015-12-11 16:33:14 +00:00
ld [hl], CARDFLIP_LIGHT_ON
2015-11-12 04:38:57 +00:00
ld a, $1
ld [hBGMapMode], a
ld c, 20
call DelayFrames
hlcoord 2, 0
2015-12-11 21:59:40 +00:00
call PlaceCardFaceDown
2015-11-12 04:38:57 +00:00
ld a, $1
ld [hBGMapMode], a
ld c, 20
call DelayFrames
hlcoord 2, 6
2015-12-11 21:59:40 +00:00
call PlaceCardFaceDown
2015-11-12 04:38:57 +00:00
call WaitBGMap
ld hl, .ChooseACardText
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
xor a
2015-12-11 21:59:40 +00:00
ld [wCardFlipWhichCard], a
2015-11-12 04:38:57 +00:00
.loop
call JoyTextDelay
ld a, [hJoyLast]
and A_BUTTON
jr nz, .next
ld de, SFX_KINESIS
call PlaySFX
2015-12-11 21:59:40 +00:00
call PlaceOAMCardBorder
2015-11-12 04:38:57 +00:00
ld c, 4
call DelayFrames
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipWhichCard
2015-11-12 04:38:57 +00:00
ld a, [hl]
xor $1
ld [hl], a
jr .loop
.next
ld de, SFX_SLOT_MACHINE_START
call PlaySFX
ld a, $3
.loop2
push af
2015-12-11 21:59:40 +00:00
call PlaceOAMCardBorder
2015-11-12 04:38:57 +00:00
ld c, 4
call DelayFrames
call ClearSprites
ld c, 4
call DelayFrames
pop af
dec a
jr nz, .loop2
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipWhichCard
2015-11-12 04:38:57 +00:00
ld a, [hl]
push af
xor $1
ld [hl], a
2015-12-11 21:59:40 +00:00
call GetCoordsOfChosenCard
2015-11-12 04:38:57 +00:00
lb bc, 6, 5
2015-12-11 13:17:38 +00:00
call CardFlip_FillGreenBox
2015-11-12 04:38:57 +00:00
pop af
2015-12-11 21:59:40 +00:00
ld [wCardFlipWhichCard], a
2015-11-12 04:38:57 +00:00
call .Increment
ret
; e02b2
.ChooseACardText: ; 0xe02b2
; Choose a card.
text_jump UnknownText_0x1c57be
db "@"
; 0xe02b7
.PlaceYourBet: ; e02b7
ld hl, .PlaceYourBetText
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
.betloop
call JoyTextDelay
ld a, [hJoyLast]
and A_BUTTON
jr nz, .betdone
2015-12-11 21:59:40 +00:00
call ChooseCard_HandleJoypad
call CardFlip_UpdateCursorOAM
2015-11-12 04:38:57 +00:00
call DelayFrame
jr .betloop
.betdone
call .Increment
ret
; e02d5
.PlaceYourBetText: ; 0xe02d5
; Place your bet.
text_jump UnknownText_0x1c57ce
db "@"
; 0xe02da
.CheckTheCard: ; e02da
xor a
ld [hVBlankCounter], a
2015-12-11 21:59:40 +00:00
call CardFlip_UpdateCursorOAM
2015-11-12 04:38:57 +00:00
call WaitSFX
ld de, SFX_CHOOSE_A_CARD
call PlaySFX
call WaitSFX
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipNumCardsPlayed]
2015-11-12 04:38:57 +00:00
ld e, a
ld d, 0
2015-12-11 13:17:38 +00:00
ld hl, wDeck
2015-11-12 04:38:57 +00:00
add hl, de
add hl, de
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipWhichCard]
2015-11-12 04:38:57 +00:00
ld e, a
add hl, de
ld a, [hl]
2015-12-11 21:59:40 +00:00
ld [wCardFlipFaceUpCard], a
2015-11-12 04:38:57 +00:00
ld e, a
2015-12-11 21:59:40 +00:00
ld hl, wDiscardPile
2015-11-12 04:38:57 +00:00
add hl, de
2015-12-11 21:59:40 +00:00
ld [hl], TRUE
call GetCoordsOfChosenCard
2015-12-11 13:17:38 +00:00
call CardFlip_DisplayCardFaceUp
2015-12-11 21:59:40 +00:00
call WaitBGMap2
2015-11-12 04:38:57 +00:00
call .Increment
ret
; e0314
.TabulateTheResult: ; e0314
2015-12-11 21:59:40 +00:00
call CardFlip_CheckWinCondition
2015-11-12 04:38:57 +00:00
call WaitPressAorB_BlinkCursor
call .Increment
ret
; e031e
.PlayAgain: ; e031e
call ClearSprites
ld hl, .PlayAgainText
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
call YesNoBox
jr nc, .Continue
call .Increment
ret
.Continue:
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipNumCardsPlayed]
2015-11-12 04:38:57 +00:00
inc a
2015-12-11 21:59:40 +00:00
ld [wCardFlipNumCardsPlayed], a
cp 12
2015-11-12 04:38:57 +00:00
jr c, .KeepTheCurrentDeck
2015-12-11 21:59:40 +00:00
call CardFlip_InitTilemap
2015-11-12 04:38:57 +00:00
ld a, $1
ld [hBGMapMode], a
2015-12-11 13:17:38 +00:00
call CardFlip_ShuffleDeck
2015-11-12 04:38:57 +00:00
ld hl, .CardsShuffledText
call PrintText
jr .LoopAround
.KeepTheCurrentDeck:
2015-12-11 21:59:40 +00:00
call CardFlip_BlankDiscardedCardSlot
2015-11-12 04:38:57 +00:00
.LoopAround:
2015-12-27 02:59:03 +00:00
ld a, 1
2015-11-12 04:38:57 +00:00
ld [wJumptableIndex], a
ret
; e0356
.PlayAgainText: ; 0xe0356
; Want to play again?
text_jump UnknownText_0x1c57df
db "@"
; 0xe035b
.CardsShuffledText: ; 0xe035b
; The cards have been shuffled.
text_jump UnknownText_0x1c57f4
db "@"
; 0xe0360
.Quit: ; e0360
ld hl, wJumptableIndex
set 7, [hl]
ret
; e0366
2015-12-11 13:17:38 +00:00
CardFlip_ShuffleDeck: ; e0366
ld hl, wDeck
2015-12-11 21:59:40 +00:00
ld bc, CARDFLIP_DECK_SIZE
2015-11-12 04:38:57 +00:00
xor a
call ByteFill
2015-12-11 13:17:38 +00:00
ld de, wDeck
2015-12-11 21:59:40 +00:00
ld c, CARDFLIP_DECK_SIZE - 1
2015-12-11 13:17:38 +00:00
.loop
2015-11-12 04:38:57 +00:00
call Random
and $1f
2015-12-11 21:59:40 +00:00
cp CARDFLIP_DECK_SIZE
2015-12-11 13:17:38 +00:00
jr nc, .loop
2015-11-12 04:38:57 +00:00
ld l, a
ld h, $0
add hl, de
ld a, [hl]
and a
2015-12-11 13:17:38 +00:00
jr nz, .loop
2015-11-12 04:38:57 +00:00
ld [hl], c
dec c
2015-12-11 13:17:38 +00:00
jr nz, .loop
2015-11-12 04:38:57 +00:00
xor a
2015-12-11 21:59:40 +00:00
ld [wCardFlipNumCardsPlayed], a
ld hl, wDiscardPile
ld bc, CARDFLIP_DECK_SIZE
2015-11-12 04:38:57 +00:00
call ByteFill
ret
; e0398
2015-12-11 21:59:40 +00:00
CollapseCursorPosition: ; e0398
2015-11-12 04:38:57 +00:00
ld hl, 0
ld bc, 6
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipCursorY]
2015-11-12 04:38:57 +00:00
call AddNTimes
ld b, $0
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipCursorX]
2015-11-12 04:38:57 +00:00
ld c, a
add hl, bc
ret
; e03ac
2015-12-11 21:59:40 +00:00
GetCoordsOfChosenCard: ; e03ac
ld a, [wCardFlipWhichCard]
2015-11-12 04:38:57 +00:00
and a
2015-12-11 21:59:40 +00:00
jr nz, .BottomCard
2015-11-12 04:38:57 +00:00
hlcoord 2, 0
2015-12-11 21:59:40 +00:00
bcpixel 2, 3
jr .done
2015-11-12 04:38:57 +00:00
.BottomCard:
2015-11-12 04:38:57 +00:00
hlcoord 2, 6
2015-12-11 21:59:40 +00:00
bcpixel 8, 3
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.done
2015-11-12 04:38:57 +00:00
ret
; e03c1
2015-12-11 21:59:40 +00:00
PlaceCardFaceDown: ; e03c1
2015-11-12 04:38:57 +00:00
xor a
ld [hBGMapMode], a
2015-12-11 21:59:40 +00:00
ld de, .FaceDownCardTilemap
2015-11-12 04:38:57 +00:00
lb bc, 6, 5
2015-12-11 21:59:40 +00:00
call CardFlip_CopyToBox
2015-11-12 04:38:57 +00:00
ret
; e03ce
2015-12-11 21:59:40 +00:00
.FaceDownCardTilemap: ; e03ce
2015-11-12 04:38:57 +00:00
db $08, $09, $09, $09, $0a
db $0b, $28, $2b, $28, $0c
db $0b, $2c, $2d, $2e, $0c
db $0b, $2f, $30, $31, $0c
db $0b, $32, $33, $34, $0c
db $0d, $0e, $0e, $0e, $0f
; e03ec
2015-12-11 13:17:38 +00:00
CardFlip_DisplayCardFaceUp: ; e03ec
2015-11-12 04:38:57 +00:00
xor a
ld [hBGMapMode], a
push hl
push hl
2015-12-11 21:59:40 +00:00
; Flip the card face up.
ld de, .FaceUpCardTilemap
2015-11-12 04:38:57 +00:00
lb bc, 6, 5
2015-12-11 21:59:40 +00:00
call CardFlip_CopyToBox
; Get the level and species of the upturned card.
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
ld e, a
ld d, 0
2015-12-11 13:17:38 +00:00
ld hl, .Deck
2015-11-12 04:38:57 +00:00
add hl, de
add hl, de
2015-11-12 04:38:57 +00:00
ld a, [hli]
ld e, a
ld d, [hl]
2015-12-11 21:59:40 +00:00
; Place the level.
2015-11-12 04:38:57 +00:00
pop hl
2015-12-11 21:59:40 +00:00
ld bc, 3 + SCREEN_WIDTH
2015-11-12 04:38:57 +00:00
add hl, bc
ld [hl], e
2015-12-11 21:59:40 +00:00
; Place the Pokepic.
2015-11-12 04:38:57 +00:00
ld bc, SCREEN_HEIGHT
add hl, bc
ld a, d
ld de, SCREEN_WIDTH
2015-12-11 21:59:40 +00:00
ld b, 3
.row
2015-11-12 04:38:57 +00:00
push hl
2015-12-11 21:59:40 +00:00
ld c, 3
.col
2015-11-12 04:38:57 +00:00
ld [hli], a
inc a
dec c
2015-12-11 21:59:40 +00:00
jr nz, .col
2015-11-12 04:38:57 +00:00
pop hl
add hl, de
dec b
2015-12-11 21:59:40 +00:00
jr nz, .row
2015-11-12 04:38:57 +00:00
pop hl
2015-12-11 21:59:40 +00:00
; Pointless CGB check
2015-11-12 04:38:57 +00:00
ld a, [hCGB]
and a
ret z
2015-12-11 21:59:40 +00:00
; Set the attributes
2015-11-12 04:38:57 +00:00
ld de, AttrMap - TileMap
add hl, de
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and 3
inc a
lb bc, 6, 5
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-11-12 04:38:57 +00:00
ret
; e043b
2015-12-11 21:59:40 +00:00
.FaceUpCardTilemap: ; e043b
2015-11-12 04:38:57 +00:00
db $18, $19, $19, $19, $1a
db $1b, $35, $7f, $7f, $1c
db $0b, $28, $28, $28, $0c
db $0b, $28, $28, $28, $0c
db $0b, $28, $28, $28, $0c
db $1d, $1e, $1e, $1e, $1f
; e0459
2015-12-11 13:17:38 +00:00
.Deck: ; e0459
2015-12-11 21:59:40 +00:00
; level, pic anchor (3x3)
db "1", $4e, "1", $57, "1", $69, "1", $60
db "2", $4e, "2", $57, "2", $69, "2", $60
db "3", $4e, "3", $57, "3", $69, "3", $60
db "4", $4e, "4", $57, "4", $69, "4", $60
db "5", $4e, "5", $57, "5", $69, "5", $60
db "6", $4e, "6", $57, "6", $69, "6", $60
2015-11-12 04:38:57 +00:00
; e0489
2015-12-11 13:17:38 +00:00
CardFlip_UpdateCoinBalanceDisplay: ; e0489
2015-11-12 04:38:57 +00:00
push hl
hlcoord 0, 12
2015-12-11 13:17:38 +00:00
ld b, 4
ld c, SCREEN_WIDTH - 2
2015-11-12 04:38:57 +00:00
call TextBox
pop hl
call PrintTextBoxText
2015-12-11 13:17:38 +00:00
call CardFlip_PrintCoinBalance
2015-11-12 04:38:57 +00:00
ret
; e049c
2015-12-11 13:17:38 +00:00
CardFlip_PrintCoinBalance: ; e049c
2015-11-12 04:38:57 +00:00
hlcoord 9, 15
2015-12-11 13:17:38 +00:00
ld b, 1
ld c, 9
2015-11-12 04:38:57 +00:00
call TextBox
hlcoord 10, 16
2015-12-11 13:17:38 +00:00
ld de, .CoinStr
2015-11-12 04:38:57 +00:00
call PlaceString
hlcoord 15, 16
ld de, Coins
lb bc, PRINTNUM_LEADINGZEROS | 2, 4
call PrintNum
ret
; e04bc
2015-12-11 13:17:38 +00:00
.CoinStr:
2015-11-12 04:38:57 +00:00
db "COIN@"
; e04c1
2015-12-11 21:59:40 +00:00
CardFlip_InitTilemap: ; e04c1 (38:44c1)
2015-11-12 04:38:57 +00:00
xor a
ld [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, $29
call ByteFill
hlcoord 9, 0
2015-12-11 21:59:40 +00:00
ld de, CardFlipTilemap
2015-11-12 04:38:57 +00:00
lb bc, 12, 11
2015-12-11 21:59:40 +00:00
call CardFlip_CopyToBox
2015-11-12 04:38:57 +00:00
hlcoord 0, 12
lb bc, 4, 18
call TextBox
ret
; e04e5 (38:44e5)
2015-12-11 13:17:38 +00:00
CardFlip_FillGreenBox: ; e04e5
2015-11-12 04:38:57 +00:00
ld a, $29
2015-12-11 13:17:38 +00:00
CardFlip_FillBox: ; e04e7 (38:44e7)
.row
2015-11-12 04:38:57 +00:00
push bc
push hl
2015-12-11 13:17:38 +00:00
.col
2015-11-12 04:38:57 +00:00
ld [hli], a
dec c
2015-12-11 13:17:38 +00:00
jr nz, .col
2015-11-12 04:38:57 +00:00
pop hl
2015-12-11 13:17:38 +00:00
ld bc, SCREEN_WIDTH
2015-11-12 04:38:57 +00:00
add hl, bc
pop bc
dec b
2015-12-11 13:17:38 +00:00
jr nz, .row
2015-11-12 04:38:57 +00:00
ret
2015-12-11 21:59:40 +00:00
CardFlip_CopyToBox: ; e04f7 (38:44f7)
.row
2015-11-12 04:38:57 +00:00
push bc
push hl
2015-12-11 21:59:40 +00:00
.col
2015-11-12 04:38:57 +00:00
ld a, [de]
inc de
ld [hli], a
dec c
2015-12-11 21:59:40 +00:00
jr nz, .col
2015-11-12 04:38:57 +00:00
pop hl
2015-12-11 21:59:40 +00:00
ld bc, SCREEN_WIDTH
2015-11-12 04:38:57 +00:00
add hl, bc
pop bc
dec b
2015-12-11 21:59:40 +00:00
jr nz, .row
2015-11-12 04:38:57 +00:00
ret
; e0509 (38:4509)
2015-12-11 21:59:40 +00:00
CardFlip_CopyOAM: ; e0509
2015-11-12 04:38:57 +00:00
ld de, Sprites
ld a, [hli]
2015-12-11 13:17:38 +00:00
.loop
2015-11-12 04:38:57 +00:00
push af
ld a, [hli]
add b
ld [de], a
inc de
ld a, [hli]
add c
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
pop af
dec a
2015-12-11 13:17:38 +00:00
jr nz, .loop
2015-11-12 04:38:57 +00:00
ret
; e0521
2015-12-11 13:17:38 +00:00
CardFlip_ShiftDigitsLeftTwoPixels: ; e0521 (38:4521)
2017-12-28 12:32:33 +00:00
ld de, vTiles1 tile ("0" & $7f)
ld hl, vTiles1 tile ("0" & $7f) + 2
2015-12-11 13:17:38 +00:00
ld bc, 10 tiles - 2
2015-11-12 04:38:57 +00:00
call CopyBytes
2017-12-28 12:32:33 +00:00
ld hl, vTiles1 tile $7f + 1 tiles - 2
2015-11-12 04:38:57 +00:00
xor a
ld [hli], a
ld [hl], a
ret
; e0534 (38:4534)
2015-12-11 21:59:40 +00:00
CardFlip_BlankDiscardedCardSlot: ; e0534
2015-11-12 04:38:57 +00:00
xor a
ld [hBGMapMode], a
2015-12-11 21:59:40 +00:00
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
ld e, a
ld d, 0
2015-12-11 21:59:40 +00:00
and 3 ; get mon
2015-11-12 04:38:57 +00:00
ld c, a
ld b, 0
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
ld a, e
2015-12-11 21:59:40 +00:00
and $1c ; get level
2015-11-12 04:38:57 +00:00
srl a
add LOW(.Jumptable)
2015-11-12 04:38:57 +00:00
ld l, a
ld a, 0
adc HIGH(.Jumptable)
2015-11-12 04:38:57 +00:00
ld h, a
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-12 04:38:57 +00:00
; e0553
2015-12-11 13:17:38 +00:00
.Jumptable: ; e0553
2015-12-27 02:59:03 +00:00
dw .Level1
dw .Level2
dw .Level3
dw .Level4
dw .Level5
dw .Level6
2015-11-12 04:38:57 +00:00
; e055f
2015-12-11 21:59:40 +00:00
.Level1: ; e055f
ld hl, wDiscardPile + 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded2
2015-11-12 04:38:57 +00:00
hlcoord 13, 3
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $37
ret
2015-12-11 21:59:40 +00:00
.discarded2
2015-11-12 04:38:57 +00:00
hlcoord 13, 3
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3d
ret
; e0583
2015-12-11 21:59:40 +00:00
.Level2: ; e0583
ld hl, wDiscardPile - 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded1
2015-11-12 04:38:57 +00:00
hlcoord 13, 4
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3b
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
2015-12-11 21:59:40 +00:00
.discarded1
2015-11-12 04:38:57 +00:00
hlcoord 13, 4
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3d
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
; e05a7
2015-12-11 21:59:40 +00:00
.Level3: ; e05a7
ld hl, wDiscardPile + 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded4
2015-11-12 04:38:57 +00:00
hlcoord 13, 6
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $38
ret
2015-12-11 21:59:40 +00:00
.discarded4
2015-11-12 04:38:57 +00:00
hlcoord 13, 6
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3d
ret
; e05cb
2015-12-11 21:59:40 +00:00
.Level4: ; e05cb
ld hl, wDiscardPile - 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded3
2015-11-12 04:38:57 +00:00
hlcoord 13, 7
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3c
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
2015-12-11 21:59:40 +00:00
.discarded3
2015-11-12 04:38:57 +00:00
hlcoord 13, 7
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3d
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
; e05ef
2015-12-11 21:59:40 +00:00
.Level5: ; e05ef
ld hl, wDiscardPile + 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded6
2015-11-12 04:38:57 +00:00
hlcoord 13, 9
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $39
ret
2015-12-11 21:59:40 +00:00
.discarded6
2015-11-12 04:38:57 +00:00
hlcoord 13, 9
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $36
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3d
ret
; e0613
2015-12-11 21:59:40 +00:00
.Level6: ; e0613
ld hl, wDiscardPile - 4
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hl]
and a
2015-12-11 21:59:40 +00:00
jr nz, .discarded5
2015-11-12 04:38:57 +00:00
hlcoord 13, 10
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3c
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
2015-12-11 21:59:40 +00:00
.discarded5
2015-11-12 04:38:57 +00:00
hlcoord 13, 10
add hl, bc
add hl, bc
2015-11-12 04:38:57 +00:00
ld [hl], $3d
ld bc, SCREEN_WIDTH
add hl, bc
ld [hl], $3a
ret
; e0637
2015-12-11 21:59:40 +00:00
CardFlip_CheckWinCondition: ; e0637
call CollapseCursorPosition
2015-11-12 04:38:57 +00:00
add hl, hl
2015-12-11 13:17:38 +00:00
ld de, .Jumptable
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-12 04:38:57 +00:00
; e0643
2015-12-11 13:17:38 +00:00
.Jumptable: ; e0643
2015-12-27 02:59:03 +00:00
dw .Impossible
dw .Impossible
dw .PikaJiggly
dw .PikaJiggly
dw .PoliOddish
dw .PoliOddish
dw .Impossible
dw .Impossible
dw .Pikachu
dw .Jigglypuff
dw .Poliwag
dw .Oddish
dw .OneTwo
dw .One
dw .PikaOne
dw .JigglyOne
dw .PoliOne
dw .OddOne
dw .OneTwo
dw .Two
dw .PikaTwo
dw .JigglyTwo
dw .PoliTwo
dw .OddTwo
dw .ThreeFour
dw .Three
dw .PikaThree
dw .JigglyThree
dw .PoliThree
dw .OddThree
dw .ThreeFour
dw .Four
dw .PikaFour
dw .JigglyFour
dw .PoliFour
dw .OddFour
dw .FiveSix
dw .Five
dw .PikaFive
dw .JigglyFive
dw .PoliFive
dw .OddFive
dw .FiveSix
dw .Six
dw .PikaSix
dw .JigglySix
dw .PoliSix
dw .OddSix
2015-11-12 04:38:57 +00:00
; e06a3
2015-12-11 21:59:40 +00:00
.Impossible: ; e06a3
jp .Lose
2015-11-12 04:38:57 +00:00
; e06a6
2015-12-11 21:59:40 +00:00
.PikaJiggly: ; e06a6
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $2
2015-12-11 21:59:40 +00:00
jp nz, .Lose
jr .WinSix
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliOddish: ; e06b0
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $2
2015-12-11 21:59:40 +00:00
jr nz, .WinSix
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.WinSix: ; e06ba
2015-11-12 04:38:57 +00:00
ld c, $6
ld de, SFX_2ND_PLACE
2015-12-11 21:59:40 +00:00
jp .Payout
2015-11-12 04:38:57 +00:00
; e06c2
2015-12-11 21:59:40 +00:00
.OneTwo: ; e06c2
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $18
2015-12-11 21:59:40 +00:00
jr z, .WinNine
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.ThreeFour: ; e06cc
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $18
cp $8
2015-12-11 21:59:40 +00:00
jr z, .WinNine
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.FiveSix: ; e06d8
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $18
cp $10
2015-12-11 21:59:40 +00:00
jr z, .WinNine
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.WinNine: ; e06e4
2015-11-12 04:38:57 +00:00
ld c, $9
ld de, SFX_2ND_PLACE
2015-12-11 21:59:40 +00:00
jp .Payout
2015-11-12 04:38:57 +00:00
; e06ec
2015-12-11 21:59:40 +00:00
.Pikachu: ; e06ec
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $3
2015-12-11 21:59:40 +00:00
jr z, .WinTwelve
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Jigglypuff: ; e06f6
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $3
cp $1
2015-12-11 21:59:40 +00:00
jr z, .WinTwelve
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Poliwag: ; e0702
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $3
cp $2
2015-12-11 21:59:40 +00:00
jr z, .WinTwelve
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Oddish: ; e070e
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $3
cp $3
2015-12-11 21:59:40 +00:00
jr z, .WinTwelve
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.WinTwelve: ; e071a
2015-11-12 04:38:57 +00:00
ld c, $c
ld de, SFX_2ND_PLACE
2015-12-11 21:59:40 +00:00
jp .Payout
2015-11-12 04:38:57 +00:00
; e0722
2015-12-11 21:59:40 +00:00
.One: ; e0722
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Two: ; e072c
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
cp $4
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Three: ; e0738
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
cp $8
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Four: ; e0744
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
cp $c
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Five: ; e0750
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
cp $10
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Six: ; e075c
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
and $1c
cp $14
2015-12-11 21:59:40 +00:00
jr z, .WinEighteen
jp .Lose
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.WinEighteen: ; e0768
2015-11-12 04:38:57 +00:00
ld c, $12
ld de, SFX_2ND_PLACE
2015-12-11 21:59:40 +00:00
jp .Payout
2015-11-12 04:38:57 +00:00
; e0770
2015-12-11 21:59:40 +00:00
.PikaOne: ; e0770
2015-11-12 04:38:57 +00:00
ld e, $0
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglyOne: ; e0774
2015-11-12 04:38:57 +00:00
ld e, $1
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliOne: ; e0778
2015-11-12 04:38:57 +00:00
ld e, $2
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddOne: ; e077c
2015-11-12 04:38:57 +00:00
ld e, $3
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PikaTwo: ; e0780
2015-11-12 04:38:57 +00:00
ld e, $4
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglyTwo: ; e0784
2015-11-12 04:38:57 +00:00
ld e, $5
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliTwo: ; e0788
2015-11-12 04:38:57 +00:00
ld e, $6
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddTwo: ; e078c
2015-11-12 04:38:57 +00:00
ld e, $7
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PikaThree: ; e0790
2015-11-12 04:38:57 +00:00
ld e, $8
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglyThree: ; e0794
2015-11-12 04:38:57 +00:00
ld e, $9
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliThree: ; e0798
2015-11-12 04:38:57 +00:00
ld e, $a
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddThree: ; e079c
2015-11-12 04:38:57 +00:00
ld e, $b
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PikaFour: ; e07a0
2015-11-12 04:38:57 +00:00
ld e, $c
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglyFour: ; e07a4
2015-11-12 04:38:57 +00:00
ld e, $d
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliFour: ; e07a8
2015-11-12 04:38:57 +00:00
ld e, $e
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddFour: ; e07ac
2015-11-12 04:38:57 +00:00
ld e, $f
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PikaFive: ; e07b0
2015-11-12 04:38:57 +00:00
ld e, $10
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglyFive: ; e07b4
2015-11-12 04:38:57 +00:00
ld e, $11
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliFive: ; e07b8
2015-11-12 04:38:57 +00:00
ld e, $12
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddFive: ; e07bc
2015-11-12 04:38:57 +00:00
ld e, $13
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PikaSix: ; e07c0
2015-11-12 04:38:57 +00:00
ld e, $14
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.JigglySix: ; e07c4
2015-11-12 04:38:57 +00:00
ld e, $15
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.PoliSix: ; e07c8
2015-11-12 04:38:57 +00:00
ld e, $16
2015-12-11 21:59:40 +00:00
jr .CheckWin72
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.OddSix: ; e07cc
2015-11-12 04:38:57 +00:00
ld e, $17
2015-12-11 21:59:40 +00:00
.CheckWin72: ; e07ce
ld a, [wCardFlipFaceUpCard]
2015-11-12 04:38:57 +00:00
cp e
2015-12-11 21:59:40 +00:00
jr nz, .Lose
ld c, 72
2015-11-12 04:38:57 +00:00
ld de, SFX_2ND_PLACE
2015-12-11 21:59:40 +00:00
jr .Payout
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.Lose: ; e07db
2015-11-12 04:38:57 +00:00
ld de, SFX_WRONG
call PlaySFX
2015-12-11 21:59:40 +00:00
ld hl, .Text_Darn
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
call WaitSFX
ret
2015-12-11 21:59:40 +00:00
.Payout: ; e07eb
2015-11-12 04:38:57 +00:00
push bc
push de
2015-12-11 21:59:40 +00:00
ld hl, .Text_Yeah
2015-12-11 13:17:38 +00:00
call CardFlip_UpdateCoinBalanceDisplay
2015-11-12 04:38:57 +00:00
pop de
call PlaySFX
call WaitSFX
pop bc
2015-12-11 21:59:40 +00:00
.loop
2015-11-12 04:38:57 +00:00
push bc
2015-12-11 21:59:40 +00:00
call .IsCoinCaseFull
jr c, .full
call .AddCoinPlaySFX
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.full
2015-12-11 13:17:38 +00:00
call CardFlip_PrintCoinBalance
2015-11-12 04:38:57 +00:00
ld c, 2
call DelayFrames
pop bc
dec c
2015-12-11 21:59:40 +00:00
jr nz, .loop
2015-11-12 04:38:57 +00:00
ret
; e0811
2015-12-11 21:59:40 +00:00
.Text_Yeah: ; 0xe0811
2015-11-12 04:38:57 +00:00
; Yeah!
text_jump UnknownText_0x1c5813
db "@"
; 0xe0816
2015-12-11 21:59:40 +00:00
.Text_Darn: ; 0xe0816
2015-11-12 04:38:57 +00:00
; Darn…
text_jump UnknownText_0x1c581a
db "@"
; 0xe081b
2015-12-11 21:59:40 +00:00
.AddCoinPlaySFX: ; e081b
2015-11-12 04:38:57 +00:00
ld a, [Coins]
ld h, a
ld a, [Coins + 1]
ld l, a
inc hl
ld a, h
ld [Coins], a
ld a, l
ld [Coins + 1], a
ld de, SFX_PAY_DAY
call PlaySFX
ret
; e0833
2015-12-11 21:59:40 +00:00
.IsCoinCaseFull: ; e0833
2015-11-12 04:38:57 +00:00
ld a, [Coins]
cp HIGH(MAX_COINS)
2015-12-11 21:59:40 +00:00
jr c, .less
jr z, .check_low
jr .more
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.check_low
2015-11-12 04:38:57 +00:00
ld a, [Coins + 1]
cp LOW(MAX_COINS)
2015-12-11 21:59:40 +00:00
jr c, .less
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.more
2015-11-12 04:38:57 +00:00
scf
ret
2015-12-11 21:59:40 +00:00
.less
2015-11-12 04:38:57 +00:00
and a
ret
; e0849
2015-12-11 21:59:40 +00:00
PlaceOAMCardBorder: ; e0849
call GetCoordsOfChosenCard
ld hl, .SpriteData
call CardFlip_CopyOAM
2015-11-12 04:38:57 +00:00
ret
; e0853
2015-12-11 21:59:40 +00:00
.SpriteData: ; e0853
2015-11-12 04:38:57 +00:00
db 18
2015-12-11 21:59:40 +00:00
dsprite 0, 0, 0, 0, $04, $00
dsprite 0, 0, 1, 0, $06, $00
dsprite 0, 0, 2, 0, $06, $00
dsprite 0, 0, 3, 0, $06, $00
dsprite 0, 0, 4, 0, $04, $20
dsprite 1, 0, 0, 0, $05, $00
dsprite 1, 0, 4, 0, $05, $20
dsprite 2, 0, 0, 0, $05, $00
dsprite 2, 0, 4, 0, $05, $20
dsprite 3, 0, 0, 0, $05, $00
dsprite 3, 0, 4, 0, $05, $20
dsprite 4, 0, 0, 0, $05, $00
dsprite 4, 0, 4, 0, $05, $20
dsprite 5, 0, 0, 0, $04, $40
dsprite 5, 0, 1, 0, $06, $40
dsprite 5, 0, 2, 0, $06, $40
dsprite 5, 0, 3, 0, $06, $40
dsprite 5, 0, 4, 0, $04, $60
2015-11-12 04:38:57 +00:00
; e089c
2015-12-11 21:59:40 +00:00
ChooseCard_HandleJoypad: ; e089c
2015-11-12 04:38:57 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_LEFT
2015-12-11 21:59:40 +00:00
jp nz, .d_left
2015-11-12 04:38:57 +00:00
ld a, [hl]
and D_RIGHT
2015-12-11 21:59:40 +00:00
jp nz, .d_right
2015-11-12 04:38:57 +00:00
ld a, [hl]
and D_UP
2015-12-11 21:59:40 +00:00
jp nz, .d_up
2015-11-12 04:38:57 +00:00
ld a, [hl]
and D_DOWN
2015-12-11 21:59:40 +00:00
jp nz, .d_down
2015-11-12 04:38:57 +00:00
ret
; e08b8
.d_left ; e08b8
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipCursorX
ld a, [wCardFlipCursorY]
2015-11-12 04:38:57 +00:00
and a
2015-12-11 21:59:40 +00:00
jr z, .mon_pair_left
2015-11-12 04:38:57 +00:00
cp $1
2015-12-11 21:59:40 +00:00
jr z, .mon_group_left
2015-11-12 04:38:57 +00:00
ld a, [hl]
and a
ret z
dec [hl]
2015-12-11 21:59:40 +00:00
jp .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.mon_group_left
2015-11-12 04:38:57 +00:00
ld a, [hl]
cp $3
2015-12-11 21:59:40 +00:00
jr c, .left_to_number_gp
2015-11-12 04:38:57 +00:00
dec [hl]
2015-12-11 21:59:40 +00:00
jp .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.mon_pair_left
2015-11-12 04:38:57 +00:00
ld a, [hl]
and $e
ld [hl], a
cp $3
2015-12-11 21:59:40 +00:00
jr c, .left_to_number_gp
2015-11-12 04:38:57 +00:00
dec [hl]
dec [hl]
2015-12-11 21:59:40 +00:00
jp .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.left_to_number_gp
2015-11-12 04:38:57 +00:00
ld a, $2
2015-12-11 21:59:40 +00:00
ld [wCardFlipCursorY], a
2015-11-12 04:38:57 +00:00
ld a, $1
2015-12-11 21:59:40 +00:00
ld [wCardFlipCursorX], a
jp .play_sound
2015-11-12 04:38:57 +00:00
; e08ef
.d_right ; e08ef
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipCursorX
ld a, [wCardFlipCursorY]
2015-11-12 04:38:57 +00:00
and a
2015-12-11 21:59:40 +00:00
jr z, .mon_pair_right
2015-11-12 04:38:57 +00:00
ld a, [hl]
cp $5
ret nc
inc [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.mon_pair_right
2015-11-12 04:38:57 +00:00
ld a, [hl]
and $e
ld [hl], a
cp $4
ret nc
inc [hl]
inc [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
.d_up ; e090a
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipCursorY
ld a, [wCardFlipCursorX]
2015-11-12 04:38:57 +00:00
and a
2015-12-11 21:59:40 +00:00
jr z, .num_pair_up
2015-11-12 04:38:57 +00:00
cp $1
2015-12-11 21:59:40 +00:00
jr z, .num_gp_up
2015-11-12 04:38:57 +00:00
ld a, [hl]
and a
ret z
dec [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.num_gp_up
2015-11-12 04:38:57 +00:00
ld a, [hl]
cp $3
2015-12-11 21:59:40 +00:00
jr c, .up_to_mon_group
2015-11-12 04:38:57 +00:00
dec [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.num_pair_up
2015-11-12 04:38:57 +00:00
ld a, [hl]
and $e
ld [hl], a
cp $3
2015-12-11 21:59:40 +00:00
jr c, .up_to_mon_group
2015-11-12 04:38:57 +00:00
dec [hl]
dec [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.up_to_mon_group
2015-11-12 04:38:57 +00:00
ld a, $1
2015-12-11 21:59:40 +00:00
ld [wCardFlipCursorY], a
2015-11-12 04:38:57 +00:00
ld a, $2
2015-12-11 21:59:40 +00:00
ld [wCardFlipCursorX], a
jr .play_sound
2015-11-12 04:38:57 +00:00
.d_down ; e093d
2015-12-11 21:59:40 +00:00
ld hl, wCardFlipCursorY
ld a, [wCardFlipCursorX]
2015-11-12 04:38:57 +00:00
and a
2015-12-11 21:59:40 +00:00
jr z, .num_pair_down
ld hl, wCardFlipCursorY
2015-11-12 04:38:57 +00:00
ld a, [hl]
cp $7
ret nc
inc [hl]
2015-12-11 21:59:40 +00:00
jr .play_sound
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
.num_pair_down
2015-11-12 04:38:57 +00:00
ld a, [hl]
and $e
ld [hl], a
cp $6
ret nc
inc [hl]
inc [hl]
2015-11-12 04:38:57 +00:00
.play_sound ; e0959
2015-11-12 04:38:57 +00:00
ld de, SFX_POKEBALLS_PLACED_ON_TABLE
call PlaySFX
ret
; e0960
2015-12-11 21:59:40 +00:00
CardFlip_UpdateCursorOAM: ; e0960
2015-11-12 04:38:57 +00:00
call ClearSprites
ld a, [hCGB]
and a
2015-12-11 13:17:38 +00:00
jr nz, .skip
2015-11-12 04:38:57 +00:00
ld a, [hVBlankCounter]
and $4
ret nz
2015-12-11 13:17:38 +00:00
.skip
2015-12-11 21:59:40 +00:00
call CollapseCursorPosition
2015-11-12 04:38:57 +00:00
add hl, hl
add hl, hl
2015-12-11 21:59:40 +00:00
ld de, .OAMData
2015-11-12 04:38:57 +00:00
add hl, de
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
2015-12-11 21:59:40 +00:00
call CardFlip_CopyOAM
2015-11-12 04:38:57 +00:00
ret
; e0981
2015-12-11 21:59:40 +00:00
.OAMData: ; e0981
cardflip_cursor: MACRO
if _NARG >= 5
dbpixel \1, \2, \3, \4
dw \5
else
dbpixel \1, \2
dw \3
endc
2017-12-28 21:31:16 +00:00
ENDM
2015-12-11 21:59:40 +00:00
cardflip_cursor 11, 2, .Impossible
cardflip_cursor 12, 2, .Impossible
cardflip_cursor 13, 2, .PokeGroupPair
cardflip_cursor 13, 2, .PokeGroupPair
cardflip_cursor 17, 2, .PokeGroupPair
cardflip_cursor 17, 2, .PokeGroupPair
cardflip_cursor 11, 3, .Impossible
cardflip_cursor 12, 3, .Impossible
cardflip_cursor 13, 3, .PokeGroup
cardflip_cursor 15, 3, .PokeGroup
cardflip_cursor 17, 3, .PokeGroup
cardflip_cursor 19, 3, .PokeGroup
cardflip_cursor 11, 5, .NumGroupPair
cardflip_cursor 12, 5, .NumGroup
cardflip_cursor 13, 5, .SingleTile
cardflip_cursor 15, 5, .SingleTile
cardflip_cursor 17, 5, .SingleTile
cardflip_cursor 19, 5, .SingleTile
cardflip_cursor 11, 5, .NumGroupPair
cardflip_cursor 12, 6, 0, 4, .NumGroup
cardflip_cursor 13, 6, 0, 4, .SingleTile
cardflip_cursor 15, 6, 0, 4, .SingleTile
cardflip_cursor 17, 6, 0, 4, .SingleTile
cardflip_cursor 19, 6, 0, 4, .SingleTile
cardflip_cursor 11, 8, .NumGroupPair
cardflip_cursor 12, 8, .NumGroup
cardflip_cursor 13, 8, .SingleTile
cardflip_cursor 15, 8, .SingleTile
cardflip_cursor 17, 8, .SingleTile
cardflip_cursor 19, 8, .SingleTile
cardflip_cursor 11, 8, .NumGroupPair
cardflip_cursor 12, 9, 0, 4, .NumGroup
cardflip_cursor 13, 9, 0, 4, .SingleTile
cardflip_cursor 15, 9, 0, 4, .SingleTile
cardflip_cursor 17, 9, 0, 4, .SingleTile
cardflip_cursor 19, 9, 0, 4, .SingleTile
cardflip_cursor 11, 11, .NumGroupPair
cardflip_cursor 12, 11, .NumGroup
cardflip_cursor 13, 11, .SingleTile
cardflip_cursor 15, 11, .SingleTile
cardflip_cursor 17, 11, .SingleTile
cardflip_cursor 19, 11, .SingleTile
cardflip_cursor 11, 11, .NumGroupPair
cardflip_cursor 12, 12, 0, 4, .NumGroup
cardflip_cursor 13, 12, 0, 4, .SingleTile
cardflip_cursor 15, 12, 0, 4, .SingleTile
cardflip_cursor 17, 12, 0, 4, .SingleTile
cardflip_cursor 19, 12, 0, 4, .SingleTile
2015-11-12 04:38:57 +00:00
; e0a41
2015-12-11 21:59:40 +00:00
.SingleTile: ; e0a41
2015-11-12 04:38:57 +00:00
db 6
2015-12-11 21:59:40 +00:00
dsprite 0, 0, -1, 7, $00, $80
dsprite 0, 0, 0, 0, $02, $80
dsprite 0, 0, 1, 0, $03, $80
dsprite 0, 5, -1, 7, $00, $c0
dsprite 0, 5, 0, 0, $02, $c0
dsprite 0, 5, 1, 0, $03, $80
.PokeGroup: ; e0a5a
2015-11-12 04:38:57 +00:00
db 26
2015-12-11 21:59:40 +00:00
dsprite 0, 0, -1, 7, $00, $80
dsprite 0, 0, 0, 0, $02, $80
dsprite 0, 0, 1, 0, $00, $a0
dsprite 1, 0, -1, 7, $01, $80
dsprite 1, 0, 1, 0, $01, $a0
dsprite 2, 0, -1, 7, $01, $80
dsprite 2, 0, 1, 0, $03, $80
dsprite 3, 0, -1, 7, $01, $80
dsprite 3, 0, 1, 0, $03, $80
dsprite 4, 0, -1, 7, $01, $80
dsprite 4, 0, 1, 0, $03, $80
dsprite 5, 0, -1, 7, $01, $80
dsprite 5, 0, 1, 0, $03, $80
dsprite 6, 0, -1, 7, $01, $80
dsprite 6, 0, 1, 0, $03, $80
dsprite 7, 0, -1, 7, $01, $80
dsprite 7, 0, 1, 0, $03, $80
dsprite 8, 0, -1, 7, $01, $80
dsprite 8, 0, 1, 0, $03, $80
dsprite 9, 0, -1, 7, $01, $80
dsprite 9, 0, 1, 0, $03, $80
dsprite 10, 0, -1, 7, $01, $80
dsprite 10, 0, 1, 0, $03, $80
dsprite 10, 1, -1, 7, $00, $c0
dsprite 10, 1, 0, 0, $02, $c0
dsprite 10, 1, 1, 0, $03, $80
.NumGroup: ; e0ac3
2015-11-12 04:38:57 +00:00
db 20
2015-12-11 21:59:40 +00:00
dsprite 0, 0, -1, 7, $00, $80
dsprite 0, 0, 0, 0, $02, $80
dsprite 0, 0, 1, 0, $02, $80
dsprite 0, 0, 2, 0, $03, $80
dsprite 0, 0, 3, 0, $02, $80
dsprite 0, 0, 4, 0, $03, $80
dsprite 0, 0, 5, 0, $02, $80
dsprite 0, 0, 6, 0, $03, $80
dsprite 0, 0, 7, 0, $02, $80
dsprite 0, 0, 8, 0, $03, $80
dsprite 0, 5, -1, 7, $00, $c0
dsprite 0, 5, 0, 0, $02, $c0
dsprite 0, 5, 1, 0, $02, $c0
dsprite 0, 5, 2, 0, $03, $80
dsprite 0, 5, 3, 0, $02, $c0
dsprite 0, 5, 4, 0, $03, $80
dsprite 0, 5, 5, 0, $02, $c0
dsprite 0, 5, 6, 0, $03, $80
dsprite 0, 5, 7, 0, $02, $c0
dsprite 0, 5, 8, 0, $03, $80
.NumGroupPair: ; e0b14
2015-11-12 04:38:57 +00:00
db 30
2015-12-11 21:59:40 +00:00
dsprite 0, 0, 0, 0, $00, $80
dsprite 0, 0, 1, 0, $02, $80
dsprite 0, 0, 2, 0, $02, $80
dsprite 0, 0, 3, 0, $03, $80
dsprite 0, 0, 4, 0, $02, $80
dsprite 0, 0, 5, 0, $03, $80
dsprite 0, 0, 6, 0, $02, $80
dsprite 0, 0, 7, 0, $03, $80
dsprite 0, 0, 8, 0, $02, $80
dsprite 0, 0, 9, 0, $03, $80
dsprite 1, 0, 0, 0, $01, $80
dsprite 1, 0, 3, 0, $03, $80
dsprite 1, 0, 5, 0, $03, $80
dsprite 1, 0, 7, 0, $03, $80
dsprite 1, 0, 9, 0, $03, $80
dsprite 2, 0, 0, 0, $01, $80
dsprite 2, 0, 3, 0, $03, $80
dsprite 2, 0, 5, 0, $03, $80
dsprite 2, 0, 7, 0, $03, $80
dsprite 2, 0, 9, 0, $03, $80
dsprite 2, 1, 0, 0, $00, $c0
dsprite 2, 1, 1, 0, $02, $c0
dsprite 2, 1, 2, 0, $02, $c0
dsprite 2, 1, 3, 0, $03, $80
dsprite 2, 1, 4, 0, $03, $80
dsprite 2, 1, 5, 0, $03, $80
dsprite 2, 1, 6, 0, $03, $80
dsprite 2, 1, 7, 0, $03, $80
dsprite 2, 1, 8, 0, $03, $80
dsprite 2, 1, 9, 0, $03, $80
.PokeGroupPair: ; e0b8d
2015-11-12 04:38:57 +00:00
db 38
2015-12-11 21:59:40 +00:00
dsprite 0, 0, -1, 7, $00, $80
dsprite 0, 0, 3, 0, $00, $a0
dsprite 1, 0, -1, 7, $01, $80
dsprite 1, 0, 3, 0, $01, $a0
dsprite 2, 0, -1, 7, $01, $80
dsprite 2, 0, 3, 0, $01, $a0
dsprite 3, 0, -1, 7, $01, $80
dsprite 3, 0, 1, 0, $03, $80
dsprite 3, 0, 3, 0, $03, $80
dsprite 4, 0, -1, 7, $01, $80
dsprite 4, 0, 1, 0, $03, $80
dsprite 4, 0, 3, 0, $03, $80
dsprite 5, 0, -1, 7, $01, $80
dsprite 5, 0, 1, 0, $03, $80
dsprite 5, 0, 3, 0, $03, $80
dsprite 6, 0, -1, 7, $01, $80
dsprite 6, 0, 1, 0, $03, $80
dsprite 6, 0, 3, 0, $03, $80
dsprite 7, 0, -1, 7, $01, $80
dsprite 7, 0, 1, 0, $03, $80
dsprite 7, 0, 3, 0, $03, $80
dsprite 8, 0, -1, 7, $01, $80
dsprite 8, 0, 1, 0, $03, $80
dsprite 8, 0, 3, 0, $03, $80
dsprite 9, 0, -1, 7, $01, $80
dsprite 9, 0, 1, 0, $03, $80
dsprite 9, 0, 3, 0, $03, $80
dsprite 10, 0, -1, 7, $01, $80
dsprite 10, 0, 1, 0, $03, $80
dsprite 10, 0, 3, 0, $03, $80
dsprite 11, 0, -1, 7, $01, $80
dsprite 11, 0, 1, 0, $03, $80
dsprite 11, 0, 3, 0, $03, $80
dsprite 11, 1, -1, 7, $00, $c0
dsprite 11, 1, 0, 0, $02, $c0
dsprite 11, 1, 1, 0, $03, $c0
dsprite 11, 1, 2, 0, $02, $c0
dsprite 11, 1, 3, 0, $03, $e0
.Impossible: ; e0c26
2015-11-12 04:38:57 +00:00
db 4
2015-12-11 21:59:40 +00:00
dsprite 0, 0, 0, 0, $00, $80
dsprite 0, 0, 1, 0, $00, $a0
dsprite 1, 0, 0, 0, $00, $c0
dsprite 1, 0, 1, 0, $00, $e0
2015-11-12 04:38:57 +00:00
; e0c37
2015-12-11 21:59:40 +00:00
CardFlip_InitAttrPals: ; e0c37 (38:4c37)
2015-11-12 04:38:57 +00:00
ld a, [hCGB]
and a
ret z
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 0, 0, AttrMap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 12, 1, AttrMap
lb bc, 2, 2
ld a, $1
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 14, 1, AttrMap
lb bc, 2, 2
ld a, $2
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 16, 1, AttrMap
lb bc, 2, 2
ld a, $3
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 18, 1, AttrMap
lb bc, 2, 2
ld a, $4
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
hlcoord 9, 0, AttrMap
lb bc, 12, 1
ld a, $1
2015-12-11 13:17:38 +00:00
call CardFlip_FillBox
2015-12-11 21:59:40 +00:00
2015-11-12 04:38:57 +00:00
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
2015-12-11 21:59:40 +00:00
ld hl, .palettes
2018-01-01 14:08:21 +00:00
ld de, wBGPals1
2015-12-11 21:59:40 +00:00
ld bc, 9 palettes
2015-11-12 04:38:57 +00:00
call CopyBytes
pop af
ld [rSVBK], a
ret
; e0c93 (38:4c93)
.palettes ; e0c93
2017-12-16 03:36:33 +00:00
INCLUDE "data/palettes/card_flip.pal"
2015-11-12 04:38:57 +00:00
; e0cdb
2015-12-11 13:17:38 +00:00
CardFlipLZ03: ; e0cdb
INCBIN "gfx/card_flip/card_flip_3.2bpp.lz"
2015-11-12 04:38:57 +00:00
2015-12-11 13:17:38 +00:00
CardFlipOffButtonGFX: ; e0cf6
INCBIN "gfx/card_flip/off.2bpp"
2015-11-12 04:38:57 +00:00
2015-12-11 13:17:38 +00:00
CardFlipOnButtonGFX: ; e0d06
INCBIN "gfx/card_flip/on.2bpp"
2015-11-12 04:38:57 +00:00
2015-12-11 13:17:38 +00:00
CardFlipLZ01: ; e0d16
INCBIN "gfx/card_flip/card_flip_1.2bpp.lz"
2015-11-12 04:38:57 +00:00
2015-12-11 13:17:38 +00:00
CardFlipLZ02: ; e0ea8
INCBIN "gfx/card_flip/card_flip_2.2bpp.lz"
2015-11-12 04:38:57 +00:00
2015-12-11 21:59:40 +00:00
CardFlipTilemap: ; e110c
2017-12-16 03:36:33 +00:00
INCBIN "gfx/card_flip/card_flip.tilemap"
2015-11-12 04:38:57 +00:00
; e1190