; screen variables DEF vPreviousCardIndex EQU SCREEN_VARS_START+16 ScreenCardRead: dw CardReadSetup dw CardReadUpdate dw CardReadDraw dw CardReadTeardown CardReadSetup: ld a, 1 ld [vBlocked], a ld hl, CardReadSetupAsyncTask call Async_Spawn_HL ret CardReadSetupAsyncTask: ld hl, UITilemap ; origin ld de, $9800 ; destination ld b, 18 ; height ld c, 20 ; width call CopyTilesToMapUnsafe call ChangedCardTask ret CardReadUpdate: ld hl, vTime ld a, [rDELTAT] ld b, a ld a, [vTime] add a, b ld [vTime], a ld a, [vTime+1] adc a, 0 ld [vTime+1], a ; increment time. when the 16bit time register is greater ; than 4096 ($10_00) then one second has passed. so that's satisfied when ; vTime+1 is equal to or greater than $10 ld a, [vTime+1] cp a, $01 jp c, .doneTimer ; if the timer is less than $0100, skip to end ;otherwise reset the timer ld a, 0 ld [vTime], a ld [vTime+1], a ld hl, SquaresTiles ld a, [vFrameCountSquares] inc a call ArrayClampLooping ld [vFrameCountSquares], a .doneTimer ld hl, rMYBTNP bit 4, [hl] jp z, .doneWithB ld hl, ScreenSpreadSelect call ChangeScene ret .doneWithB ld a, [vSelectedSpreadCard] ld hl, rMYBTNP bit 1, [hl] jp z, :+ ; skip the following code if left is not pressed dec a : bit 0, [hl] jp z, :+ ; skip the following code if right is not pressed inc a : ld [vSelectedSpreadCard], a ld a, [vCurrentSpread] ld l, a ld a, [vCurrentSpread+1] ld h, a ld a, [vSelectedSpreadCard] call ArrayClampLooping ld [vSelectedSpreadCard], a ld hl, vPreviousSpreadCard cp a, [hl] ret z ; if the selected card diddn't change, nothing to do ld a, [vBlocked] cp a, 0 ret nz ld a, 1 ld [vBlocked], a ld hl, ChangedCardTask call Async_Spawn_HL ret CardReadDraw: ld hl, SquaresTiles inc hl ld b, 0 ld a, [vFrameCountSquares] ld c, a add hl, bc add hl, bc ld c, [hl] inc hl ld b, [hl] ld h, b ld l, c ld de, $8000+$100*16 + 1*16 ld bc, (SquaresTileset8 - SquaresTileset7) / 8 call CopyRangeUnsafeBy8s ; the card data is loaded asynchronously, initiated in CardReadUpdate ret CardReadTeardown: ret ChangedCardTask: ld a, [vSelectedSpreadCard] ld [vPreviousSpreadCard], a ld a, [vCurrentSpread] ld c, a ld a, [vCurrentSpread+1] ld b, a ; gett bc as cuurrent spread address ld hl, $9800 + (32*1)+11 ld a, [vSelectedSpreadCard] call DrawSpreadMinimap ld a, [vCurrentSpread] ld l, a ld a, [vCurrentSpread+1] ld h, a call PassList ; skip spread layout ld a, [vSelectedSpreadCard] or a, a .loopThroughSpreadPositions jp z, .foundSpreadPositionDescription call PassList call PassList dec a jp .loopThroughSpreadPositions .foundSpreadPositionDescription ld de, $9800 + 32*5 + 11 call PrintString ld de, $9800 + 32*6 + 11 call PrintString ld hl, SHUFFLED_DECK+1 ld a, [vSelectedSpreadCard] ld c, a ld b, 0 add hl, bc ld a, [hl] ld [vSelectedCardIndex], a ld [vPreviousCardIndex], a call LoadCardData ld a, 0 ld [vBlocked], a ret UITilemap: db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $09, $02, $02, $02, $02, $02, $02, $02, $08, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $04, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $06, $05, $05, $05, $05, $05, $05, $05, $07, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 db $11, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $10, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 UITilemapEnd: