working on wiring up the cardread screen

This commit is contained in:
Shoofle 2025-01-15 19:32:01 -05:00
parent e29a7d47e4
commit ac1e531619
10 changed files with 1200 additions and 482 deletions

View File

@ -1,27 +1,128 @@
SECTION "Card Data", ROMX
Spreads:
db 5 ; length
.nospread
db 0
db 18, " Nothing "
db 18, "This is no spread."
db 8 ; length
.onecard
db 1, $21
db 18, " One Card Spread "
db 1, $31
db 8, "Answer "
db 8, "to query"
db 18, " One Card "
db 18, " Draw one card. "
.tencard
db 10, $00, $10, $20, $30, $40, $02, $12, $22, $32, $42
db 18, " Ten Card Spread "
db 18, " More cards! "
.fivecard
db 5, $11, $20, $22, $31, $41
db 18, " Horizontal Cross "
db 18, " A little spicy. "
.threecard
db 3, $01, $21, $41
db 3, $11, $31, $51
db 8, "Past "
db 8, " "
db 8, "Present "
db 8, " "
db 8, "Future "
db 8, " "
db 18, "Three Card Spread "
db 18, " Old reliable. "
.threecardB
db 3, $12, $52, $30
db 8, "Mind "
db 8, " "
db 8, "Body "
db 8, " "
db 8, "Spirit "
db 8, " "
db 18, "Three Card Spread "
db 18, " Many variations. "
.fivecardSituation
db 5, $10, $50, $12, $52, $31
db 8, "Scenario"
db 8, " "
db 8, "Things "
db 8, "at play "
db 8, "Dangers "
db 8, "afoot "
db 8, "Outcome "
db 8, " "
db 8, "Theme "
db 8, " "
db 18, "Situation reading "
db 18, "What's going on? "
.fivecardRelationship
db 5, $01, $61, $20, $31, $42
db 8, "Querent "
db 8, " "
db 8, "Other "
db 8, "person "
db 8, "Past "
db 8, "history "
db 8, "Present "
db 8, "moment "
db 8, "Future "
db 8, "outcomes"
db 18, " Relationships "
db 18, "5 cards, 2 people."
.sixcard
db 6, $11, $21, $30, $32, $41, $51
db 8, "Querent " ; 01
db 8, " "
db 8, "Problem " ; 11
db 8, " "
db 8, "Logic " ; 20
db 8, "view "
db 8, "Emotion " ; 22
db 8, "view "
db 8, "Path of " ; 31
db 8, "action "
db 8, "Outcome " ; 41
db 8, " "
db 18, " Horizontal Cross "
db 18, "For facing issues."
.alexNine
db 9, $01, $10, $12, $20, $22, $30, $32, $41, $61
db 8, "Querent "
db 8, "role "
db 8, "Problems"
db 8, "you know"
db 8, "Problems"
db 8, "hidden "
db 8, "Strength"
db 8, "you know"
db 8, "Strength"
db 8, "unknown "
db 8, "Weakness"
db 8, "you know"
db 8, "Weakness"
db 8, "ignored "
db 8, "Advice "
db 8, " "
db 8, "Outcome "
db 8, " "
db 18, " Eight Plus One "
db 18, " What faces you? "
.twelvecard
db 12, $00, $10, $20, $40, $50, $60, $02, $12, $22, $42, $52, $62
db 8, "This " ; 00
db 8, "month "
db 8, "Next " ; 10
db 8, "month "
db 8, "Third " ; 20
db 8, "month "
db 8, "Fourth " ; 30
db 8, "month "
db 8, "Fifth " ; 40
db 8, "month "
db 8, "Sixth " ; 02
db 8, "month "
db 8, "Seventh " ; 12
db 8, "month "
db 8, "Eighth " ; 22
db 8, "month "
db 8, "Ninth " ; 32
db 8, "month "
db 8, "Tenth " ; 42
db 8, "month "
db 8, "Eleventh" ; 42
db 8, "month "
db 8, "Twelfth " ; 42
db 8, "month "
db 18, " One Year Spread "
db 18, " Month by month "
.end
Cards:

View File

@ -218,6 +218,10 @@ CopyRangeUnsafe: ; this is threadsafe but not vblank safe
ld a, b
or a, c ; check if bc is zero
jp nz, CopyRangeUnsafe
di
nop
nop
ret
CopyRangeUnsafeBy8s:

View File

@ -269,6 +269,7 @@ CopyTilesToMapThreadsafe:
jp nz, .copyTile
.doneWithLine
pop bc
ei
ld a, e
add a, 32
@ -287,7 +288,7 @@ CopyTilesToMapThreadsafe:
ld a, b
cp a, 0
jp nz, CopyTilesToMapThreadsafe
ei
di
nop
nop

View File

@ -5,15 +5,22 @@ KeyArtTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa
db $00,$ff,$ff,$ff,$ff,$ff,$03,$ff,$fb,$ff,$5b,$af,$ab,$5f,$5b,$af
db $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80
db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa
db $00,$ff,$fe,$ff,$fe,$ff,$06,$ff,$f6,$ff,$56,$bf,$b6,$5f,$56,$bf
db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa
db $ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af
db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff
db $ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$fb,$ff,$03,$ff,$ff,$ff
db $7f,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $ff,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$80,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa
db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf
db $6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff
db $aa,$55,$55,$aa,$aa,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff
db $b6,$5f,$56,$bf,$b6,$5f,$f6,$ff,$06,$ff,$fe,$ff,$fe,$ff,$00,$ff
db $ff,$00,$80,$7f,$80,$7f,$9f,$7f,$9f,$7f,$98,$78,$99,$79,$9a,$7a
db $ff,$00,$01,$fe,$01,$fe,$f9,$fe,$f9,$fe,$19,$1e,$19,$1e,$d9,$de
db $9a,$7a,$99,$79,$98,$78,$9c,$78,$99,$78,$9b,$79,$9b,$7a,$9b,$7a
db $d9,$de,$99,$9e,$d9,$de,$f9,$de,$99,$9e,$d9,$9e,$d9,$9e,$d9,$5e
db $98,$78,$98,$7b,$99,$7a,$9a,$7c,$9f,$7b,$99,$79,$99,$79,$98,$78
db $59,$5e,$19,$fe,$f9,$1e,$19,$1e,$d9,$de,$d9,$de,$59,$5e,$19,$1e
db $98,$79,$98,$79,$98,$78,$9f,$7f,$9f,$7f,$80,$7f,$80,$7f,$ff,$00
db $19,$9e,$19,$9e,$19,$1e,$f9,$fe,$f9,$fe,$01,$fe,$01,$fe,$ff,$00
@ -21,11 +28,11 @@ BackgroundCopy:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $01, $02, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $04, $05, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $04, $05, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $06, $07, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $08, $09, $0a, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $01, $02, $03, $0a, $0b, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $04, $05, $06, $0c, $0d, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $04, $05, $06, $0e, $0f, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $04, $05, $06, $10, $11, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $07, $08, $09, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00

470
ScreenCardBrowse.inc Normal file
View File

@ -0,0 +1,470 @@
; screen variables
DEF vSelectedCardIndex EQU VARIABLES_START
DEF vPreviousCardIndex EQU vSelectedCardIndex + 1
ScreenCardRead:
dw CardReadSetup
dw CardReadUpdate
dw CardReadDraw
dw CardReadTeardown
CardReadSetup:
; Turn the LCD off
ld hl, rLCDC
bit 7, [hl]
jp z, .screenOff
.busyWait
ld a, [rLY]
cp a, 143
jp c, .busyWait
ld [hl], 0
.screenOff
ld hl, UITiles ; source
ld de, $8000 + $80*16; destination of copy
ld bc, UITilesEnd - UITiles ; length to copy
call CopyRangeUnsafe
ld hl, LetterTiles ; map the small font into vram at ascii locations
ld de, $8000 + (127 + $21)*16
ld bc, LetterTilesEnd - LetterTiles
call CopyRangeUnsafe
ld hl, UITilemap ; origin
ld de, $9800 ; destination
ld b, 18 ; height
ld c, 10 ; width
call CopyTilesToMapUnsafe
ld hl, ZEROES
ld de, $9800 + 10
ld b, 18
ld c, 10
call CopyTilesToMapUnsafe
; set LCD and display registers
ld a, %11100100
ld [rBGP], a
ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON
ld [rLCDC], a
; arguments for the screen
ld a, 0
ldh [vSelectedSpreadCard], a
; vCurrentSpread is set by the calling context.
ld a, $FF
ldh [vPreviousCardIndex], a
ld a, 0
ldh [vSelectedCardIndex], a
call LoadCardData
ei
ret ; return from cardreadsetup
CardReadUpdate:
ld hl, rMYBTNP
bit 4, [hl]
jp z, .doneWithB
ld hl, ScreenMainMenu
call ChangeScene
ret
.doneWithB
ldh a, [vSelectedCardIndex]
bit 3, [hl] ; select the down key
jp z, :+ ; skip the following code if down is not pressed
inc a ; increment when they press down because the deck has card 0 at the top
:
bit 2, [hl] ; select up key %0000_0100
jp z, :+ ; skip the following code if up is not pressed
dec a ; decrement when they press up because the deck has card 0 at the top
:
ld hl, Cards
call ArrayClampLooping
ldh [vSelectedCardIndex], a ; load current selected tile index
ldh 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
:
ldh [vSelectedSpreadCard], a
ldh a, [vCurrentSpread]
ld l, a
ldh a, [vCurrentSpread+1]
ld h, a
ldh a, [vSelectedSpreadCard]
call ArrayClampLooping
ldh [vSelectedSpreadCard], a
ret
CardReadDraw:
; first, we draw the spread minimap
ldh a, [vCurrentSpread]
ld c, a
ldh a, [vCurrentSpread+1]
ld b, a
ld hl, $9800 + (32*12)+11
ldh a, [vSelectedCardInSpread]
call DrawSpreadMinimap
; okay now we draw the deck minimap
ld a, [Cards]
srl a ; divide by two because we're drawing icons for pairs of cards
ld b, a ; length of the cards data
ld hl, $9800+32*4+19 ; start point
ld de, 32 ; stride
CardReadDrawCopyTile:
ld [hl], $81 ; load the tile for "unselected pair of tiles"
add hl, de ; step forward by stride (hl is the address we're drawing to on screen)
dec b ; sets zero flag because it's an 8-bit register
jp nz, CardReadDrawCopyTile ; repeat if there's more cards in the deck to draw
ld [hl], $87 ; draw the cap at the end
; the rest of this stuff deals with drawing the set-out card for the current
; selected card
CardReadDrawSelectedTile:
ldh a, [vSelectedCardIndex]
srl a
ld b, a
ld hl, $9800+32*4+19 ; start point
ld de, 32 ; stride
; if the card we need to draw is in the zeroth spot, jump straight to drawing.
jp z, CardReadDrawDrawSelectedTile
CardReadDrawCountDownTile:
; otherwise, decrement b until we're there
add hl, de
dec b
jp nz, CardReadDrawCountDownTile
CardReadDrawDrawSelectedTile:
ldh a, [vSelectedCardIndex]
and a, 1
; if we're on an odd tile, draw the tile with the top card selected.
; no other tile needs to change.
ld [hl], $82
jp z, CardReadDrawReturn
; otherwise we need to draw the tile with the bottom card selected.
; this is more complicated because the tile underneath needs to change as well.
ld [hl], $90 ; draw the "bottom card is selected"
add hl, de ; look down one tile (de has stride, remember)
ld a, $81
cp a, [hl] ; check if the existing tile at that spot is $81 (cards) or not (end cap)
ld [hl], $91 ; draw the tile of "cards but the card above is selected"
jp z, CardReadDrawReturn ; if that was right, then jump to the end
ld [hl], $92 ; if that was wrong, draw "end cap but the card above is selected"
CardReadDrawReturn:
; check if the current selected tile is different from the previous;
; if it is different, then load new card data
ldh a, [vSelectedCardIndex]
ld hl, vPreviousCardIndex
cp a, [hl]
call nz, LoadCardData ; only load new card data if the selected card has changed
ret
CardReadTeardown:
ret
LoadCardData:
ld a, [vSelectedCardIndex]
ld [vPreviousCardIndex], a
ld b, 144
call AwaitLine ; wait for vblank before starting to work
ld a, [vSelectedCardIndex]
ld b, 0
ld c, a ; load bc from a. coming into this we have the number of the card in the card array in a
ld hl, Cards + 1 ; skip the length prefix
add hl, bc
add hl, bc ; add this twice to double the offset because it's two bytes per address
; follow the pointer we're looking at
ld a, [hl+]
ld c, a
ld a, [hl+]
ld b, a
ld h, b
ld l, c ; hl now contains the address of the card data.
; hl points to a card struct.
; card struct starts with a sequence of length-prefixed strings in memory
; so when we're done writing one, hl will be correctly placed to read the next
; length-prefixed print doesn't require passing a length
; so all we have to set is the destination for each
ld de, $9800 + 32*1 + 10
call PrintString
ld de, $9800 + 32*2 + 10
call PrintString
ld de, $9800 + 32*6 + 10
call PrintString
ld de, $9800 + 32*7 + 10
call PrintString
ld de, $9800 + 32*8 + 10
call PrintString
; hl now contains the address after all the strings.
; [hl+] and [hl+] read the length first, into bc
ld a, [hl+]
ld c, a
ld a, [hl+]
ld b, a ; bc has length
ld a, [hl+]
ld e, a
ld a, [hl+]
ld d, a ; de has source of tile range copy
push hl ; save the pointer to the next bit of card data (tile map)
ld h, d
ld l, e ; source
ld de, $9800 + 32 + 1 ; destination
ld b, 16 ; height
ld c, 8 ; width
call CopyTilesSafe
ei
WaitForSafeCopy:
ld b, 140
call AwaitLine
ldh a, [vSafeCopyCount]
ld b, a
ldh a, [vSafeCopyCount+1]
or a, b
jp nz, WaitForSafeCopy
di
pop hl
ld a, [hl+]
ld c, a
ld a, [hl+]
ld b, a ; bc has length
ld a, [hl+]
ld e, a
ld a, [hl+]
ld d, a ; de has source of tile range copy
; push hl ; we don't need to keep track of hl at this point and our stack is clean.
ld h, d
ld l, e ; hl takes the source
ld de, $8000 ; always load tile data into the same spot in vram
call CopyRangeSafe
ei
WaitForSafeCopy2:
ld b, 140
call AwaitLine
ldh a, [vSafeCopyCount]
ld b, a
ldh a, [vSafeCopyCount+1]
or a, b
jp nz, WaitForSafeCopy2
di
ret
INCLUDE "CopyRangeSafe.inc"
INCLUDE "CopyTilesSafe.inc"
UITiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $0f,$0f,$10,$10,$10,$10,$10,$10,$0f,$0f,$10,$10,$10,$10,$10,$10
db $7f,$7f,$80,$80,$80,$80,$80,$80,$7f,$7f,$10,$10,$10,$10,$10,$10
db $00,$3c,$3c,$7e,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3
db $42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$3c,$7e,$00,$3c
db $00,$3c,$3c,$7e,$42,$c3,$5a,$db,$5a,$db,$5a,$db,$5a,$db,$5a,$db
db $5a,$db,$5a,$db,$5a,$db,$5a,$db,$5a,$db,$42,$c3,$3c,$7e,$00,$3c
db $0f,$0f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $ce,$f0,$c6,$f8,$0e,$f0,$16,$e8,$5e,$a0,$fe,$00,$fc,$00,$00,$00
db $ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8
db $00,$00,$fc,$00,$fe,$00,$ae,$50,$1e,$e0,$06,$f8,$ce,$f0,$c6,$f8
db $00,$00,$3f,$00,$7f,$00,$7a,$05,$68,$17,$70,$0f,$63,$1f,$73,$0f
db $63,$1f,$73,$0f,$60,$1f,$78,$07,$75,$0a,$7f,$00,$3f,$00,$00,$00
db $00,$00,$ff,$00,$ff,$00,$aa,$55,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff
db $63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f
db $ff,$ff,$ff,$ff,$00,$ff,$00,$ff,$55,$aa,$ff,$00,$ff,$00,$00,$00
db $0f,$0f,$10,$10,$10,$10,$10,$10,$7f,$7f,$80,$80,$80,$80,$80,$80
db $7f,$7f,$10,$10,$10,$10,$10,$10,$0f,$0f,$10,$10,$10,$10,$10,$10
db $7f,$7f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
UITilesEnd:
LetterTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $03,$03,$07,$07,$0f,$0f,$0e,$0e,$1c,$1c,$30,$30,$c0,$c0,$c0,$c0
db $24,$24,$6c,$6c,$6c,$6c,$48,$48,$00,$00,$00,$00,$00,$00,$00,$00
db $1a,$1a,$1a,$1a,$7f,$7f,$34,$34,$34,$34,$fe,$fe,$68,$68,$68,$68
db $08,$08,$3c,$3c,$6a,$6a,$68,$68,$3c,$3c,$0a,$0a,$6a,$6a,$3c,$3c
db $63,$63,$a6,$a6,$ac,$ac,$d8,$d8,$1b,$1b,$35,$35,$65,$65,$c6,$c6
db $18,$18,$24,$24,$28,$28,$18,$18,$2c,$2c,$66,$66,$67,$67,$39,$39
db $18,$18,$18,$18,$18,$18,$30,$30,$00,$00,$00,$00,$00,$00,$00,$00
db $04,$04,$0c,$0c,$18,$18,$10,$10,$10,$10,$18,$18,$0c,$0c,$04,$04
db $20,$20,$30,$30,$18,$18,$08,$08,$08,$08,$18,$18,$30,$30,$20,$20
db $00,$00,$08,$08,$28,$28,$1e,$1e,$78,$78,$14,$14,$10,$10,$00,$00
db $00,$00,$00,$00,$18,$18,$18,$18,$7e,$7e,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$00,$00,$1c,$1c,$38,$38,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$18,$00,$00
db $04,$04,$0c,$0c,$0c,$0c,$18,$18,$18,$18,$30,$30,$30,$30,$20,$20
db $00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$64,$64,$64,$64,$38,$38
db $08,$08,$18,$18,$38,$38,$18,$18,$18,$18,$18,$18,$18,$18,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$0c,$0c,$0c,$0c,$18,$18,$30,$30,$7c,$7c
db $00,$00,$3c,$3c,$06,$06,$06,$06,$1c,$1c,$06,$06,$06,$06,$3c,$3c
db $00,$00,$04,$04,$26,$26,$26,$26,$3e,$3e,$06,$06,$06,$06,$04,$04
db $00,$00,$7c,$7c,$64,$64,$60,$60,$78,$78,$44,$44,$04,$04,$38,$38
db $00,$00,$20,$20,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$7c,$7c,$4c,$4c,$0c,$0c,$3e,$3e,$18,$18,$30,$30,$20,$20
db $00,$00,$78,$78,$64,$64,$64,$64,$38,$38,$64,$64,$64,$64,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$18,$18,$18,$18,$00,$00,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$0c,$0c,$0c,$0c,$00,$00,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$0c,$0c,$18,$18,$30,$30,$60,$60,$30,$30,$18,$18,$0c,$0c
db $00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$3c,$3c,$3c,$3c,$00,$00
db $00,$00,$30,$30,$18,$18,$0c,$0c,$06,$06,$0c,$0c,$18,$18,$30,$30
db $38,$38,$6c,$6c,$24,$24,$0c,$0c,$18,$18,$18,$18,$00,$00,$18,$18
db $3c,$3c,$62,$62,$59,$59,$45,$45,$5d,$5d,$5d,$5d,$63,$63,$38,$38
db $00,$00,$38,$38,$34,$34,$32,$32,$3e,$3e,$32,$32,$32,$32,$32,$32
db $00,$00,$7c,$7c,$32,$32,$32,$32,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$3c,$3c,$72,$72,$62,$62,$60,$60,$60,$60,$62,$62,$3c,$3c
db $00,$00,$f8,$f8,$64,$64,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$20,$20
db $00,$00,$78,$78,$64,$64,$60,$60,$60,$60,$6e,$6e,$64,$64,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$7e,$7e,$62,$62,$62,$62,$22,$22
db $00,$00,$10,$10,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$08,$08,$0c,$0c,$0c,$0c,$0c,$0c,$4c,$4c,$6c,$6c,$3c,$3c
db $00,$00,$40,$40,$64,$64,$68,$68,$70,$70,$68,$68,$64,$64,$22,$22
db $00,$00,$20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$32,$32,$1e,$1e
db $00,$00,$3e,$3e,$6a,$6a,$6a,$6a,$6a,$6a,$62,$62,$62,$62,$22,$22
db $00,$00,$72,$72,$6a,$6a,$6a,$6a,$6a,$6a,$66,$66,$62,$62,$22,$22
db $00,$00,$3c,$3c,$66,$66,$62,$62,$62,$62,$62,$62,$32,$32,$1e,$1e
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$60,$60,$60,$60,$20,$20
db $00,$00,$38,$38,$64,$64,$62,$62,$62,$62,$6a,$6a,$64,$64,$3b,$3b
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$68,$68,$64,$64,$23,$23
db $00,$00,$38,$38,$64,$64,$60,$60,$38,$38,$04,$04,$64,$64,$38,$38
db $00,$00,$7e,$7e,$5a,$5a,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$24,$24,$34,$34,$18,$18
db $00,$00,$c3,$c3,$62,$62,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34
db $00,$00,$42,$42,$62,$62,$34,$34,$18,$18,$3c,$3c,$66,$66,$42,$42
db $00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$4c,$4c,$78,$78
db $00,$00,$7e,$7e,$46,$46,$0c,$0c,$18,$18,$30,$30,$62,$62,$7e,$7e
db $7c,$7c,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$7c,$7c
db $20,$20,$30,$30,$30,$30,$18,$18,$18,$18,$0c,$0c,$0c,$0c,$04,$04
db $3e,$3e,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$3e,$3e
db $18,$18,$3c,$3c,$66,$66,$42,$42,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7c,$7c,$3e,$3e
db $30,$30,$18,$18,$0c,$0c,$04,$04,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$38,$38,$0c,$0c,$3c,$3c,$4c,$4c,$3a,$3a,$00,$00
db $00,$00,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$3c,$3c,$00,$00
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$0c,$0c,$0c,$0c,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$78,$78,$60,$60,$3c,$3c,$00,$00
db $00,$00,$0e,$0e,$18,$18,$3c,$3c,$18,$18,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$60,$60,$60,$60,$78,$78,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$10,$10,$00,$00,$38,$38,$18,$18,$18,$18,$3c,$3c,$00,$00
db $00,$00,$08,$08,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$2c,$2c,$18,$18
db $00,$00,$60,$60,$68,$68,$68,$68,$70,$70,$68,$68,$64,$64,$00,$00
db $00,$00,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$18,$18,$00,$00
db $00,$00,$00,$00,$74,$74,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$38,$38,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$78,$78,$60,$60,$60,$60
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0e,$0e
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$30,$30,$00,$00
db $00,$00,$00,$00,$38,$38,$60,$60,$38,$38,$0c,$0c,$78,$78,$00,$00
db $00,$00,$30,$30,$78,$78,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$64,$64,$3c,$3c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$28,$28,$10,$10,$00,$00
db $00,$00,$00,$00,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34,$00,$00
db $00,$00,$00,$00,$64,$64,$38,$38,$18,$18,$2c,$2c,$46,$46,$00,$00
db $00,$00,$00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$00,$00,$7e,$7e,$0c,$0c,$18,$18,$30,$30,$7e,$7e,$00,$00
db $3c,$3c,$60,$60,$30,$30,$60,$60,$60,$60,$30,$30,$60,$60,$3c,$3c
db $20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$10,$10
db $3c,$3c,$06,$06,$0c,$0c,$06,$06,$06,$06,$0c,$0c,$06,$06,$3c,$3c
db $00,$00,$00,$00,$31,$31,$7b,$7b,$de,$de,$8c,$8c,$00,$00,$00,$00
db $c0,$c0,$a0,$a0,$b8,$b8,$b0,$b0,$da,$da,$12,$12,$1a,$1a,$03,$03
LetterTilesEnd:
BigLetterTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $ee,$ee,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44
db $7c,$7c,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$ee,$ee
db $10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$38,$38
db $38,$38,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10
db $70,$70,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$42,$42,$fe,$fe
db $fe,$fe,$42,$42,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40
db $48,$48,$44,$44,$44,$44,$44,$44,$44,$44,$42,$42,$42,$42,$e3,$e3
db $fc,$fc,$42,$42,$42,$42,$42,$42,$42,$42,$7c,$7c,$48,$48,$48,$48
db $42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$3c,$3c
db $3c,$3c,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42
db $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$70,$70
db $7c,$7c,$22,$22,$22,$22,$22,$22,$22,$22,$3c,$3c,$20,$20,$20,$20
db $38,$38,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$ee,$ee
db $10,$10,$28,$28,$28,$28,$28,$28,$28,$28,$28,$28,$28,$28,$28,$28
db $ce,$ce,$44,$44,$64,$64,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54
db $54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$4c,$4c,$44,$44,$e6,$e6
db $fe,$fe,$92,$92,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10
db $7e,$7e,$22,$22,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
db $38,$38,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$70,$70
db $70,$70,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
db $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$22,$22,$7e,$7e
db $42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$fc,$fc
db $f8,$f8,$44,$44,$42,$42,$42,$42,$44,$44,$78,$78,$44,$44,$42,$42
db $ee,$ee,$44,$44,$44,$44,$44,$44,$44,$44,$7c,$7c,$44,$44,$44,$44
db $44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$ee,$ee
db $7e,$7e,$22,$22,$20,$20,$20,$20,$20,$20,$38,$38,$20,$20,$20,$20
db $fe,$fe,$42,$42,$40,$40,$40,$40,$40,$40,$70,$70,$40,$40,$40,$40
db $40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$40,$42,$42,$fe,$fe
db $3c,$3c,$42,$42,$42,$42,$42,$42,$40,$40,$40,$40,$40,$40,$40,$40
db $40,$40,$40,$40,$40,$40,$40,$40,$42,$42,$42,$42,$42,$42,$3c,$3c
db $42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$44,$44,$f8,$f8
db $f8,$f8,$44,$44,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42,$42
db $80,$80,$80,$80,$8f,$8f,$8a,$8a,$82,$82,$82,$82,$44,$44,$38,$38
db $38,$38,$44,$44,$82,$82,$82,$82,$82,$82,$80,$80,$80,$80,$80,$80
db $04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$44,$44,$44,$44,$38,$38
db $0e,$0e,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04
db $ee,$ee,$44,$44,$44,$44,$48,$48,$50,$50,$60,$60,$50,$50,$48,$48
db $54,$54,$54,$54,$54,$54,$54,$54,$44,$44,$44,$44,$44,$44,$ee,$ee
db $c6,$c6,$6c,$6c,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54
db $42,$42,$42,$42,$42,$42,$42,$42,$4a,$4a,$4c,$4c,$4c,$4c,$36,$36
db $3c,$3c,$42,$42,$42,$42,$40,$40,$40,$40,$3c,$3c,$02,$02,$02,$02
db $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$42,$42,$42,$42,$3c,$3c
db $44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$28,$28,$10,$10
db $44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$44,$38,$38
db $44,$44,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$54,$28,$28
db $10,$10,$10,$10,$28,$28,$28,$28,$28,$28,$44,$44,$44,$44,$ee,$ee
db $ee,$ee,$44,$44,$44,$44,$28,$28,$28,$28,$28,$28,$10,$10,$10,$10
db $ee,$ee,$44,$44,$44,$44,$28,$28,$10,$10,$10,$10,$10,$10,$10,$10
db $fe,$fe,$82,$82,$04,$04,$04,$04,$08,$08,$08,$08,$08,$08,$10,$10
db $10,$10,$20,$20,$20,$20,$20,$20,$40,$40,$40,$40,$82,$82,$fe,$fe
BigLetterTilesEnd:
UITilemap:
db $8b, $8d, $8d, $8d, $8d, $8d, $8d, $8d, $8d, $8a
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8c, $8f, $8f, $8f, $8f, $8f, $8f, $8f, $8f, $88
UITilemapEnd:

View File

@ -1,7 +1,6 @@
; screen variables
DEF vSelectedCardIndex EQU VARIABLES_START
DEF vPreviousCardIndex EQU vSelectedCardIndex + 1
DEF vSelectedCardInSpread EQU vPreviousCardIndex + 1
DEF vPreviousCardIndex EQU VARIABLES_START
def vBlocked equ vPreviousCardIndex + 1
ScreenCardRead:
dw CardReadSetup
@ -10,186 +9,95 @@ ScreenCardRead:
dw CardReadTeardown
CardReadSetup:
; Turn the LCD off
ld hl, rLCDC
bit 7, [hl]
jp z, .screenOff
.busyWait
ld a, [rLY]
cp a, 143
jp c, .busyWait
ld [hl], 0
.screenOff
ld hl, UITiles ; source
ld de, $8000 + $80*16; destination of copy
ld bc, UITilesEnd - UITiles ; length to copy
call CopyRangeUnsafe
ld hl, LetterTiles ; map the small font into vram at ascii locations
ld de, $8000 + (127 + $21)*16
ld bc, LetterTilesEnd - LetterTiles
call CopyRangeUnsafe
ld a, 1
ldh [vBlocked], a
ld hl, UITilemap ; origin
ld de, $9800 ; destination
ld b, 18 ; height
ld c, 10 ; width
call CopyTilesToMapUnsafe
ld c, 20 ; width
ld a, LOW(CopyTilesToMapThreadsafe)
ld [vAsyncNext], a
ld a, HIGH(CopyTilesToMapThreadsafe)
ld [vAsyncNext+1], a
ld hl, ZEROES
ld de, $9800 + 10
ld b, 18
ld c, 10
call CopyTilesToMapUnsafe
; set LCD and display registers
ld a, %11100100
ld [rBGP], a
ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON
ld [rLCDC], a
; arguments for the screen
ld a, 0
ldh [vSelectedCardInSpread], a
; vCurrentSpread is set by the calling context.
ld a, $FF
ldh [vPreviousCardIndex], a
ld a, 0
ldh [vSelectedCardIndex], a
call LoadCardData
ei
ret ; return from cardreadsetup
ld a, LOW(LoadCardDataAsync)
ld [vAsyncAfter], a
ld a, HIGH(LoadCardDataAsync)
ld [vAsyncAfter+1], a
call DoInAsyncVBlank
ret
CardReadUpdate:
ld hl, rMYBTNP
bit 4, [hl]
jp z, .doneWithB
ld hl, ScreenMainMenu
ld hl, ScreenSpreadSelect
call ChangeScene
ret
.doneWithB
ldh a, [vSelectedCardIndex]
bit 3, [hl] ; select the down key
jp z, :+ ; skip the following code if down is not pressed
inc a ; increment when they press down because the deck has card 0 at the top
:
bit 2, [hl] ; select up key %0000_0100
jp z, :+ ; skip the following code if up is not pressed
dec a ; decrement when they press up because the deck has card 0 at the top
:
ld hl, Cards
call ArrayClampLooping
ldh [vSelectedCardIndex], a ; load current selected tile index
ldh a, [vSelectedSpreadCard]
ld hl, rMYBTNP
bit 1, [hl]
jp z, :+ ; skip the following code if left is not pressed
ldh a, [vSelectedCardInSpread]
dec a
ldh [vSelectedCardInSpread], a
:
bit 0, [hl]
jp z, :+ ; skip the following code if right is not pressed
ldh a, [vSelectedCardInSpread]
inc a
ldh [vSelectedCardInSpread], a
:
ldh [vSelectedSpreadCard], a
ldh a, [vCurrentSpread]
ld l, a
ldh a, [vCurrentSpread+1]
ld h, a ; fetch the spread length address into h
ldh a, [vSelectedCardInSpread]
cp a, [hl] ; ddoes the index equal the deck length?
jp nz, :+
ld a, 0 ; if the index equals the deck length replace it with zero
ldh [vSelectedCardInSpread], a
:
cp a, $FF ; if the tile index is $FF (underflowed from dec)
jp nz, :+
ld a, [hl]
dec a ;replace with deck length - 1
ldh [vSelectedCardInSpread], a
:
ld h, a
ldh a, [vSelectedSpreadCard]
call ArrayClampLooping
ldh [vSelectedSpreadCard], a
ldh [vSelectedCardIndex], a
ldh a, [vSelectedCardIndex]
ld hl, vPreviousCardIndex
cp a, [hl]
ret z ; if the selected card diddn't change, nothing to do
ldh a, [vBlocked]
cp a, 0
ret nz
ld a, LOW(LoadCardDataAsync)
ld [vAsyncAfter], a
ld a, HIGH(LoadCardDataAsync)
ld [vAsyncAfter+1], a
call DoInAsyncVBlank
ret
CardReadDraw:
; first, we draw the spread minimap
; first draw the spread minimap
ldh a, [vCurrentSpread]
ld c, a
ldh a, [vCurrentSpread+1]
ld b, a
ld hl, $9800 + (32*12)+11
ldh a, [vSelectedCardInSpread]
ld hl, $9800 + (32*1)+11
ldh a, [vSelectedSpreadCard]
call DrawSpreadMinimap
; okay now we draw the deck minimap
ld a, [Cards]
srl a ; divide by two because we're drawing icons for pairs of cards
ld b, a ; length of the cards data
ld hl, $9800+32*4+19 ; start point
ld de, 32 ; stride
CardReadDrawCopyTile:
ld [hl], $81 ; load the tile for "unselected pair of tiles"
add hl, de ; step forward by stride (hl is the address we're drawing to on screen)
dec b ; sets zero flag because it's an 8-bit register
jp nz, CardReadDrawCopyTile ; repeat if there's more cards in the deck to draw
ld [hl], $87 ; draw the cap at the end
; the rest of this stuff deals with drawing the set-out card for the current
; selected card
CardReadDrawSelectedTile:
ldh a, [vSelectedCardIndex]
srl a
ld b, a
ld hl, $9800+32*4+19 ; start point
ld de, 32 ; stride
; if the card we need to draw is in the zeroth spot, jump straight to drawing.
jp z, CardReadDrawDrawSelectedTile
CardReadDrawCountDownTile:
; otherwise, decrement b until we're there
add hl, de
dec b
jp nz, CardReadDrawCountDownTile
CardReadDrawDrawSelectedTile:
ldh a, [vSelectedCardIndex]
and a, 1
; if we're on an odd tile, draw the tile with the top card selected.
; no other tile needs to change.
ld [hl], $82
jp z, CardReadDrawReturn
; otherwise we need to draw the tile with the bottom card selected.
; this is more complicated because the tile underneath needs to change as well.
ld [hl], $90 ; draw the "bottom card is selected"
add hl, de ; look down one tile (de has stride, remember)
ld a, $81
cp a, [hl] ; check if the existing tile at that spot is $81 (cards) or not (end cap)
ld [hl], $91 ; draw the tile of "cards but the card above is selected"
jp z, CardReadDrawReturn ; if that was right, then jump to the end
ld [hl], $92 ; if that was wrong, draw "end cap but the card above is selected"
CardReadDrawReturn:
; check if the current selected tile is different from the previous;
; if it is different, then load new card data
ldh a, [vSelectedCardIndex]
ld hl, vPreviousCardIndex
cp a, [hl]
call nz, LoadCardData ; only load new card data if the selected card has changed
; the card data is loaded asynchronously, initiated in CardReadUpdate
ret
CardReadTeardown:
ret
LoadCardData:
ld a, [vSelectedCardIndex]
ld [vPreviousCardIndex], a
LoadCardDataAsync:
ld a, 1
ldh [vBlocked], a
ldh a, [vSelectedCardIndex]
ldh [vPreviousCardIndex], a
ld b, 144
call AwaitLine ; wait for vblank before starting to work
ld a, [vSelectedCardIndex]
ld b, 0
ld c, a ; load bc from a. coming into this we have the number of the card in the card array in a
ld c, a ; load bc from a, the number of the card in the cards list
ld hl, Cards + 1 ; skip the length prefix
add hl, bc
add hl, bc ; add this twice to double the offset because it's two bytes per address
@ -203,22 +111,39 @@ LoadCardData:
ld h, b
ld l, c ; hl now contains the address of the card data.
ld a, LOW(.duringDraw)
ld [vAsyncNext], a
ld a, HIGH(.duringDraw)
ld [vAsyncNext+1], a
ld a, 0
ld [vAsyncAfter], a
ld [vAsyncAfter+1], a
di
nop
nop
ret
.duringDraw
di ; these function calls should be fast so we'll disable interrupts and do them
; synchronously
; hl points to a card struct.
; card struct starts with a sequence of length-prefixed strings in memory
; so when we're done writing one, hl will be correctly placed to read the next
; length-prefixed print doesn't require passing a length
; so all we have to set is the destination for each
ld de, $9800 + 32*1 + 10
ld de, $9800 + 32*9 + 10
call PrintString
ld de, $9800 + 32*2 + 10
ld de, $9800 + 32*10 + 10
call PrintString
ld de, $9800 + 32*6 + 10
ld de, $9800 + 32*12 + 10
call PrintString
ld de, $9800 + 32*7 + 10
ld de, $9800 + 32*13 + 10
call PrintString
ld de, $9800 + 32*8 + 10
ld de, $9800 + 32*14 + 10
call PrintString
ei
; hl now contains the address after all the strings.
; [hl+] and [hl+] read the length first, into bc
ld a, [hl+]
@ -229,181 +154,95 @@ LoadCardData:
ld e, a
ld a, [hl+]
ld d, a ; de has source of tile range copy
push hl ; save the pointer to the next bit of card data (tile map)
ld h, d
ld l, e ; source
ld de, $9800 + 32 + 1 ; destination
ld b, 16 ; height
ld c, 8 ; width
call CopyTilesSafe
ei
WaitForSafeCopy:
ld b, 140
call AwaitLine
ldh a, [vSafeCopyCount]
ld b, a
ldh a, [vSafeCopyCount+1]
or a, b
jp nz, WaitForSafeCopy
ld a, LOW(CopyTilesToMapThreadsafe)
ld [vAsyncNext], a
ld a, HIGH(CopyTilesToMapThreadsafe)
ld [vAsyncNext+1], a
ld a, LOW(.afterCopyTiles)
ld [vAsyncAfter], a
ld a, HIGH(.afterCopyTiles)
ld [vAsyncAfter+1], a
di
nop
nop
ret
.afterCopyTiles
ldh a, [vSelectedCardIndex]
ldh [vPreviousCardIndex], a
pop hl
ld b, 0
ld c, a ; load bc from a, the number of the card in the cards list
ld hl, Cards + 1 ; skip the length prefix
add hl, bc
add hl, bc ; add this twice to double the offset because it's two bytes per address
; follow the pointer we're looking at
ld a, [hl+]
ld c, a
ld a, [hl+]
ld b, a ; bc has length
ld b, a
ld h, b
ld l, c ; hl now contains the address of the card data.
di
call PassList
call PassList
call PassList
call PassList
call PassList ; skip the strings
ei
inc hl
inc hl ; skip tile map width
inc hl
inc hl ; skip tile map pointer
ld a, [hl+]
ld c, a
ld a, [hl+]
ld b, a ; bc has length of tile data
ld a, [hl+]
ld e, a
ld a, [hl+]
ld d, a ; de has source of tile range copy
; push hl ; we don't need to keep track of hl at this point and our stack is clean.
ld h, d
ld l, e ; hl takes the source
ld de, $8000 ; always load tile data into the same spot in vram
call CopyRangeSafe
ei
WaitForSafeCopy2:
ld b, 140
call AwaitLine
ldh a, [vSafeCopyCount]
ld b, a
ldh a, [vSafeCopyCount+1]
or a, b
jp nz, WaitForSafeCopy2
ld de, $91b0 ; always load tile data into the same spot in vram
ld a, LOW(CopyRangeUnsafe)
ld [vAsyncNext], a
ld a, HIGH(CopyRangeUnsafe)
ld [vAsyncNext+1], a
ld a, LOW(.afterLoadingTiles)
ld [vAsyncAfter], a
ld a, HIGH(.afterLoadingTiles)
ld [vAsyncAfter+1], a
di
nop
nop
ret
.afterLoadingTiles
ld a, 0
ldh [vBlocked], a
ld a, 0
ld [vAsyncNext], a
ld [vAsyncNext+1], a
ld [vAsyncAfter], a
ld [vAsyncAfter+1], a
di
nop
nop
ret
INCLUDE "CopyRangeSafe.inc"
INCLUDE "CopyTilesSafe.inc"
UITiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $0f,$0f,$10,$10,$10,$10,$10,$10,$0f,$0f,$10,$10,$10,$10,$10,$10
db $7f,$7f,$80,$80,$80,$80,$80,$80,$7f,$7f,$10,$10,$10,$10,$10,$10
db $00,$3c,$3c,$7e,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3
db $42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$42,$c3,$3c,$7e,$00,$3c
db $00,$3c,$3c,$7e,$42,$c3,$5a,$db,$5a,$db,$5a,$db,$5a,$db,$5a,$db
db $5a,$db,$5a,$db,$5a,$db,$5a,$db,$5a,$db,$42,$c3,$3c,$7e,$00,$3c
db $0f,$0f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $ce,$f0,$c6,$f8,$0e,$f0,$16,$e8,$5e,$a0,$fe,$00,$fc,$00,$00,$00
db $ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8
db $00,$00,$fc,$00,$fe,$00,$ae,$50,$1e,$e0,$06,$f8,$ce,$f0,$c6,$f8
db $00,$00,$3f,$00,$7f,$00,$7a,$05,$68,$17,$70,$0f,$63,$1f,$73,$0f
db $63,$1f,$73,$0f,$60,$1f,$78,$07,$75,$0a,$7f,$00,$3f,$00,$00,$00
db $00,$00,$ff,$00,$ff,$00,$aa,$55,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff
db $63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f
db $ff,$ff,$ff,$ff,$00,$ff,$00,$ff,$55,$aa,$ff,$00,$ff,$00,$00,$00
db $0f,$0f,$10,$10,$10,$10,$10,$10,$7f,$7f,$80,$80,$80,$80,$80,$80
db $7f,$7f,$10,$10,$10,$10,$10,$10,$0f,$0f,$10,$10,$10,$10,$10,$10
db $7f,$7f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
UITilesEnd:
LetterTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $03,$03,$07,$07,$0f,$0f,$0e,$0e,$1c,$1c,$30,$30,$c0,$c0,$c0,$c0
db $24,$24,$6c,$6c,$6c,$6c,$48,$48,$00,$00,$00,$00,$00,$00,$00,$00
db $1a,$1a,$1a,$1a,$7f,$7f,$34,$34,$34,$34,$fe,$fe,$68,$68,$68,$68
db $08,$08,$3c,$3c,$6a,$6a,$68,$68,$3c,$3c,$0a,$0a,$6a,$6a,$3c,$3c
db $63,$63,$a6,$a6,$ac,$ac,$d8,$d8,$1b,$1b,$35,$35,$65,$65,$c6,$c6
db $18,$18,$24,$24,$28,$28,$18,$18,$2c,$2c,$66,$66,$67,$67,$39,$39
db $18,$18,$18,$18,$18,$18,$30,$30,$00,$00,$00,$00,$00,$00,$00,$00
db $04,$04,$0c,$0c,$18,$18,$10,$10,$10,$10,$18,$18,$0c,$0c,$04,$04
db $20,$20,$30,$30,$18,$18,$08,$08,$08,$08,$18,$18,$30,$30,$20,$20
db $00,$00,$08,$08,$28,$28,$1e,$1e,$78,$78,$14,$14,$10,$10,$00,$00
db $00,$00,$00,$00,$18,$18,$18,$18,$7e,$7e,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$00,$00,$1c,$1c,$38,$38,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$18,$00,$00
db $04,$04,$0c,$0c,$0c,$0c,$18,$18,$18,$18,$30,$30,$30,$30,$20,$20
db $00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$64,$64,$64,$64,$38,$38
db $08,$08,$18,$18,$38,$38,$18,$18,$18,$18,$18,$18,$18,$18,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$0c,$0c,$0c,$0c,$18,$18,$30,$30,$7c,$7c
db $00,$00,$3c,$3c,$06,$06,$06,$06,$1c,$1c,$06,$06,$06,$06,$3c,$3c
db $00,$00,$04,$04,$26,$26,$26,$26,$3e,$3e,$06,$06,$06,$06,$04,$04
db $00,$00,$7c,$7c,$64,$64,$60,$60,$78,$78,$44,$44,$04,$04,$38,$38
db $00,$00,$20,$20,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$7c,$7c,$4c,$4c,$0c,$0c,$3e,$3e,$18,$18,$30,$30,$20,$20
db $00,$00,$78,$78,$64,$64,$64,$64,$38,$38,$64,$64,$64,$64,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$18,$18,$18,$18,$00,$00,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$0c,$0c,$0c,$0c,$00,$00,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$0c,$0c,$18,$18,$30,$30,$60,$60,$30,$30,$18,$18,$0c,$0c
db $00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$3c,$3c,$3c,$3c,$00,$00
db $00,$00,$30,$30,$18,$18,$0c,$0c,$06,$06,$0c,$0c,$18,$18,$30,$30
db $38,$38,$6c,$6c,$24,$24,$0c,$0c,$18,$18,$18,$18,$00,$00,$18,$18
db $3c,$3c,$62,$62,$59,$59,$45,$45,$5d,$5d,$5d,$5d,$63,$63,$38,$38
db $00,$00,$38,$38,$34,$34,$32,$32,$3e,$3e,$32,$32,$32,$32,$32,$32
db $00,$00,$7c,$7c,$32,$32,$32,$32,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$3c,$3c,$72,$72,$62,$62,$60,$60,$60,$60,$62,$62,$3c,$3c
db $00,$00,$f8,$f8,$64,$64,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$20,$20
db $00,$00,$78,$78,$64,$64,$60,$60,$60,$60,$6e,$6e,$64,$64,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$7e,$7e,$62,$62,$62,$62,$22,$22
db $00,$00,$10,$10,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$08,$08,$0c,$0c,$0c,$0c,$0c,$0c,$4c,$4c,$6c,$6c,$3c,$3c
db $00,$00,$40,$40,$64,$64,$68,$68,$70,$70,$68,$68,$64,$64,$22,$22
db $00,$00,$20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$32,$32,$1e,$1e
db $00,$00,$3e,$3e,$6a,$6a,$6a,$6a,$6a,$6a,$62,$62,$62,$62,$22,$22
db $00,$00,$72,$72,$6a,$6a,$6a,$6a,$6a,$6a,$66,$66,$62,$62,$22,$22
db $00,$00,$3c,$3c,$66,$66,$62,$62,$62,$62,$62,$62,$32,$32,$1e,$1e
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$60,$60,$60,$60,$20,$20
db $00,$00,$38,$38,$64,$64,$62,$62,$62,$62,$6a,$6a,$64,$64,$3b,$3b
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$68,$68,$64,$64,$23,$23
db $00,$00,$38,$38,$64,$64,$60,$60,$38,$38,$04,$04,$64,$64,$38,$38
db $00,$00,$7e,$7e,$5a,$5a,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$24,$24,$34,$34,$18,$18
db $00,$00,$c3,$c3,$62,$62,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34
db $00,$00,$42,$42,$62,$62,$34,$34,$18,$18,$3c,$3c,$66,$66,$42,$42
db $00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$4c,$4c,$78,$78
db $00,$00,$7e,$7e,$46,$46,$0c,$0c,$18,$18,$30,$30,$62,$62,$7e,$7e
db $7c,$7c,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$7c,$7c
db $20,$20,$30,$30,$30,$30,$18,$18,$18,$18,$0c,$0c,$0c,$0c,$04,$04
db $3e,$3e,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$3e,$3e
db $18,$18,$3c,$3c,$66,$66,$42,$42,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7c,$7c,$3e,$3e
db $30,$30,$18,$18,$0c,$0c,$04,$04,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$38,$38,$0c,$0c,$3c,$3c,$4c,$4c,$3a,$3a,$00,$00
db $00,$00,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$3c,$3c,$00,$00
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$0c,$0c,$0c,$0c,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$78,$78,$60,$60,$3c,$3c,$00,$00
db $00,$00,$0e,$0e,$18,$18,$3c,$3c,$18,$18,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$60,$60,$60,$60,$78,$78,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$10,$10,$00,$00,$38,$38,$18,$18,$18,$18,$3c,$3c,$00,$00
db $00,$00,$08,$08,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$2c,$2c,$18,$18
db $00,$00,$60,$60,$68,$68,$68,$68,$70,$70,$68,$68,$64,$64,$00,$00
db $00,$00,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$18,$18,$00,$00
db $00,$00,$00,$00,$74,$74,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$38,$38,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$78,$78,$60,$60,$60,$60
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0e,$0e
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$30,$30,$00,$00
db $00,$00,$00,$00,$38,$38,$60,$60,$38,$38,$0c,$0c,$78,$78,$00,$00
db $00,$00,$30,$30,$78,$78,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$64,$64,$3c,$3c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$28,$28,$10,$10,$00,$00
db $00,$00,$00,$00,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34,$00,$00
db $00,$00,$00,$00,$64,$64,$38,$38,$18,$18,$2c,$2c,$46,$46,$00,$00
db $00,$00,$00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$00,$00,$7e,$7e,$0c,$0c,$18,$18,$30,$30,$7e,$7e,$00,$00
db $3c,$3c,$60,$60,$30,$30,$60,$60,$60,$60,$30,$30,$60,$60,$3c,$3c
db $20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$10,$10
db $3c,$3c,$06,$06,$0c,$0c,$06,$06,$06,$06,$0c,$0c,$06,$06,$3c,$3c
db $00,$00,$00,$00,$31,$31,$7b,$7b,$de,$de,$8c,$8c,$00,$00,$00,$00
db $c0,$c0,$a0,$a0,$b8,$b8,$b0,$b0,$da,$da,$12,$12,$1a,$1a,$03,$03
LetterTilesEnd:
BigLetterTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
@ -460,22 +299,22 @@ BigLetterTiles:
BigLetterTilesEnd:
UITilemap:
db $8b, $8d, $8d, $8d, $8d, $8d, $8d, $8d, $8d, $8a
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8e, $80, $80, $80, $80, $80, $80, $80, $80, $89
db $8c, $8f, $8f, $8f, $8f, $8f, $8f, $8f, $8f, $88
db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $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, $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, $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, $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, $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, $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, $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, $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, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $11, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $10, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
UITilemapEnd:

View File

@ -1,13 +1,19 @@
DEF vCurrentSpread EQU $ff90 ; putting global app variables at the start of HRAM.
; global variables at the start of hram
DEF vCurrentSpread EQU $ff90 ; 16bit address of current spread
DEF vSelectedSpreadIndex equ vCurrentSpread + 2
def vSelectedSpreadCard equ vSelectedSpreadIndex + 1
def vSelectedCardIndex equ vSelectedSpreadCard+1
DEF vFrameCountSquares EQU vSelectedCardIndex+1
DEF vTime EQU vFrameCountSquares+1 ; 16bit
println "after vTime is ", vTime+2
; (but after async vars!)
; they probably don't needd to be there but whatever
DEF vFrameCount1 EQU VARIABLES_START
DEF vFrameCount2 equ vFrameCount1+1
DEF vFrameCount3 EQU vFrameCount2+1
DEF vFrameCount4 EQU vFrameCount3+1
DEF vFrameCountSquares EQU vFrameCount4+1
PRINTLN "vframecount is ", vFrameCount1
DEF vTime EQU vFrameCountSquares+1 ; 16bit
DEF vMenuIndex equ vTime + 2
DEF vMenuIndex equ vFrameCount3 + 1
DEF vMenuIndexPrevious equ vMenuIndex + 1
ScreenMainMenu:
@ -31,65 +37,61 @@ MainMenuSetup_ScreenOff:
ld a, 0
ldh [rLCDC], a
ld hl, MainMenuUITiles
ld de, $8000
ld bc, (MainMenuUITilesEnd - MainMenuUITiles)
call CopyRangeUnsafe
ld hl, SquaresTileset8
ld de, $8010
ld de, $8010 + $80*16
ld bc, (SquaresTilesetEnd - SquaresTileset8)
call CopyRangeUnsafe
def spacing equ $12
ld hl, CardBackSprites24 ; source
def TileStartCardBackSprites24 equ $a
def TileStartCardBackSprites24 equ 0
ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy
ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy
call CopyRangeUnsafe
ld hl, CardBackSprites23
def TileStartCardBackSprites23 equ $1c
def TileStartCardBackSprites23 equ TileStartCardBackSprites24 + spacing
ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy
ld bc, CardBackSprites23End - CardBackSprites23
call CopyRangeUnsafe
ld hl, CardBackSprites22
def TileStartCardBackSprites22 equ $2e
def TileStartCardBackSprites22 equ TileStartCardBackSprites23 + spacing
ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy
ld bc, CardBackSprites22End - CardBackSprites22
call CopyRangeUnsafe
ld hl, CardBackSprites21
def TileStartCardBackSprites21 equ $40
def TileStartCardBackSprites21 equ TileStartCardBackSprites22 + spacing
ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy
ld bc, CardBackSprites21End - CardBackSprites21
call CopyRangeUnsafe
ld hl, CardBackSprites20
def TileStartCardBackSprites20 equ $52
def TileStartCardBackSprites20 equ TileStartCardBackSprites21 + spacing
ld de, $8000 + TileStartCardBackSprites20*$10
ld bc, CardBackSprites20End - CardBackSprites20
call CopyRangeUnsafe
ld hl, CardBackSprites19
def TileStartCardBackSprites19 equ $64
def TileStartCardBackSprites19 equ TileStartCardBackSprites20 + spacing
ld de, $8000 + TileStartCardBackSprites19*$10
ld bc, CardBackSprites19End - CardBackSprites19
call CopyRangeUnsafe
ld hl, CardBackSprites18
def TileStartCardBackSprites18 equ $76
def TileStartCardBackSprites18 equ TileStartCardBackSprites19 + spacing
ld de, $8000 + TileStartCardBackSprites18*$10
ld bc, CardBackSprites18End - CardBackSprites18
call CopyRangeUnsafe
ld hl, CardBackSprites17
def TileStartCardBackSprites17 equ $88
def TileStartCardBackSprites17 equ TileStartCardBackSprites18 + spacing
ld de, $8000 + TileStartCardBackSprites17*$10
ld bc, CardBackSprites17End - CardBackSprites17
call CopyRangeUnsafe
def TileStartCardBackSprites16 equ $9a
def TileStartCardBackSprites16 equ TileStartCardBackSprites17 + spacing
ld hl, SquaresTilemap
ld de, $9800
@ -97,11 +99,6 @@ MainMenuSetup_ScreenOff:
ld c, 20
call CopyTilesToMapUnsafe
ld hl, LetterTiles ; map the small font into vram at ascii locations
ld de, $8000 + (127 + $21)*16
ld bc, LetterTilesEnd - LetterTiles
call CopyRangeUnsafe
ld hl, StringRead
ld de, $9800 + 32*11 + 4
call PrintString
@ -130,7 +127,7 @@ MainMenuSetup_ScreenOff:
ld [rBGP], a
ld [rOBP0], a
ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16
ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16
ldh [rLCDC], a
ld a, 0
@ -183,10 +180,10 @@ MainMenuSetup_ScreenOff:
; that should be just about 2/3 of L !
ldh [vFrameCount3], a
ld hl, Coords
ld a, [hl]
srl a
ldh [vFrameCount4], a
;ld hl, Coords
;ld a, [hl]
;srl a
;ldh [vFrameCount4], a
ld a, 0
ldh [vFrameCountSquares], a
@ -289,10 +286,10 @@ MainMenuUpdate:
call ArrayClampLooping
ldh [vFrameCount3], a
ldh a, [vFrameCount4]
inc a
call ArrayClampLooping
ldh [vFrameCount4], a
;ldh a, [vFrameCount4]
;inc a
;call ArrayClampLooping
;ldh [vFrameCount4], a
ld hl, SquaresTiles
ldh a, [vFrameCountSquares]
@ -399,7 +396,7 @@ MainMenuDraw:
ld b, [hl]
ld h, b
ld l, c
ld de, $8010
ld de, $8000+$100*16 + 1*16
ld bc, (SquaresTileset8 - SquaresTileset7) / 8
call CopyRangeUnsafeBy8s
@ -987,18 +984,6 @@ SquaresTileset8:
SquaresTilesetEnd:
MainMenuUITiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $05,$00,$05,$00,$05,$00,$05,$00,$05,$00,$fd,$00,$00,$00,$fd,$00
db $00,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$ff,$00,$00,$00,$00,$00,$00
db $70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8
db $0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17
db $00,$00,$00,$00,$00,$00,$00,$ff,$ff,$00,$ff,$ff,$ff,$ff,$00,$ff
db $70,$e8,$70,$e8,$70,$e8,$70,$ef,$7f,$f0,$3f,$7f,$1f,$3f,$00,$1f
db $0e,$17,$0e,$17,$0e,$17,$0e,$f7,$fe,$0f,$fc,$fe,$f8,$fc,$00,$f8
db $00,$f8,$f8,$fc,$fc,$fe,$fe,$0f,$0e,$f7,$0e,$17,$0e,$17,$0e,$17
db $00,$1f,$1f,$3f,$3f,$7f,$7f,$f0,$70,$ef,$70,$e8,$70,$e8,$70,$e8
MainMenuUITilesEnd:
SquaresTilemap:
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01

View File

@ -1,6 +1,5 @@
DEF vSelectedSpreadIndex EQU VARIABLES_START
DEF vPreviousSpreadIndex EQU vSelectedSpreadIndex + 1
def vSelectedSpreadCard equ vPreviousSpreadIndex + 1
DEF vPreviousSpreadIndex EQU VARIABLES_START
def vPreviousSpreadCard equ vPreviousSpreadIndex + 1
ScreenSpreadSelect:
dw SpreadSelectSetup
@ -10,12 +9,31 @@ ScreenSpreadSelect:
SpreadSelectSetup:
ld a, 0
ldh [vSelectedCardInSpread], a
ldh [vPreviousSpreadIndex], a
ldh [vSelectedSpreadIndex], a
ldh [vPreviousSpreadIndex], a
ldh [vSelectedSpreadCard], a
ldh [vPreviousSpreadCard], a
call UpdateCurrentSpread
ld a, LOW(RunDMA) ; zero out the OAM
ld [vAsyncNext], a
ld a, HIGH(RunDMA)
ld [vAsyncNext+1], a
ld a, LOW(.loadUIMap)
ld [vAsyncAfter], a
ld a, HIGH(.loadUIMap)
ld [vAsyncAfter+1], a
ld a, HIGH(ZEROES)
ld de, $ffc0 ; arguments to the first async call.
call DoInAsyncVBlank
ret
.loadUIMap
ld hl, SpreadSelectTilemap
ld de, $9800
ld b, 18
@ -25,43 +43,26 @@ SpreadSelectSetup:
ld [vAsyncNext], a
ld a, HIGH(CopyTilesToMapThreadsafe)
ld [vAsyncNext+1], a
ld a, LOW(.loadUITiles)
ld a, LOW(.loadFaceCardTiles)
ld [vAsyncAfter], a
ld a, HIGH(.loadUITiles)
ld a, HIGH(.loadFaceCardTiles)
ld [vAsyncAfter+1], a
call DoInAsyncVBlank
ret
.loadUITiles
ld hl, UITiles ; source
ld de, $8000 + $80*16; destination of copy
ld bc, UITilesEnd - UITiles ; length to copy
.loadFaceCardTiles
ld hl, FaceCardTiles
ld de, $9000 + $24*16
ld bc, FaceCardTilesEnd - FaceCardTiles
ld a, LOW(CopyRangeUnsafe)
ld [vAsyncNext], a
ld a, HIGH(CopyRangeUnsafe)
ld [vAsyncNext+1], a
ld a, LOW(.zeroOutOAM)
ld [vAsyncAfter], a
ld a, HIGH(.zeroOutOAM)
ld [vAsyncAfter+1], a
ret
.zeroOutOAM
ld a, LOW(RunDMA)
ld [vAsyncNext], a
ld a, HIGH(RunDMA)
ld [vAsyncNext+1], a
ld a, LOW(DrawSpreadAsync)
ld [vAsyncAfter], a
ld a, HIGH(DrawSpreadAsync)
ld [vAsyncAfter+1], a
ld a, HIGH(ZEROES)
ld de, $ffc0 ; arguments to the first following async call
ret
SpreadSelectUpdate:
@ -72,19 +73,49 @@ SpreadSelectUpdate:
call ChangeScene
ret
.doneB
bit 5, [hl]
jp z, .doneA
ld hl, ScreenCardRead
call ChangeScene
ret
.doneA
;up and down
ld a, [vSelectedSpreadIndex]
bit 3, [hl] ; select the down key
jp z, .doneDown ; skip the following code if down is not pressed
dec a ; increment when they press down because the deck has card 0 at the top
inc a ; increment when they press down
.doneDown
bit 2, [hl] ; select up key
jp z, .doneUp ; skip the following code if up is not pressed
inc a ; decrement when they press up because the deck has card 0 at the top
dec a ; decrement when they press up because the deck has card 0 at the top
.doneUp
ld hl, Spreads
call ArrayClampLooping
ldh [vSelectedSpreadIndex], a ; load current selected tile index
ldh [vSelectedSpreadIndex], a ; save clamped index
; left and righgt
ldh a, [vSelectedSpreadCard]
ld hl, rMYBTNP
bit 1, [hl]
jp z, .doneLeft ; skip the following code if left is not pressed
dec a
.doneLeft
bit 0, [hl]
jp z, .doneRight ; skip the following code if right is not pressed
inc a
.doneRight
ld hl, vCurrentSpread
ld c, [hl]
inc hl
ld b, [hl]
ld h, b
ld l, c
; hl has current spread, a has index
call ArrayClampLooping
ldh [vSelectedSpreadCard], a
ld hl, vTime
ldh a, [rDELTAT]
@ -116,9 +147,27 @@ SpreadSelectUpdate:
ldh a, [vSelectedSpreadIndex]
ld hl, vPreviousSpreadIndex
cp a, [hl]
jp nz, .spreadChanged ; update the spread if the spread changed
ret z ; we're done if previous index is same as new index
ldh a, [vSelectedSpreadCard]
ld hl, vPreviousSpreadCard
cp a, [hl]
jp nz, .cardChanged ; update the spread if the card changed
ret
.spreadChanged
ld a, [vAsyncPC]
ld b, a
ld a, [vAsyncPC+1]
or a, b
ret nz ; early return if the async threadd is in use
ld a, [vSelectedSpreadIndex]
ld [vPreviousSpreadIndex], a
ld a, 0
ld [vSelectedSpreadCard], a
ld [vPreviousSpreadCard], a
call UpdateCurrentSpread
; execute an async call to DrawSpreadAsync.
@ -129,6 +178,32 @@ SpreadSelectUpdate:
call DoInAsyncVBlank
ret
.cardChanged
ld a, [vAsyncPC]
ld b, a
ld a, [vAsyncPC+1]
or a, b
ret nz ; early return if the async threadd is in use
ld a, [vSelectedSpreadIndex]
ld [vPreviousSpreadIndex], a
ld a, [vSelectedSpreadCard]
ld [vPreviousSpreadCard], a
call UpdateCurrentSpread
; execute an async call to DrawSpreadAsync.
ld a, LOW(DrawSpreadALittleAsync)
ld [vAsyncNext], a
ld a, HIGH(DrawSpreadALittleAsync)
ld [vAsyncNext+1], a
call DoInAsyncVBlank
ret
.doneUpdate
ret ; return from main thread. go back to looping.
@ -147,6 +222,14 @@ UpdateCurrentSpread:
inc hl
add hl, de
.skipCardDescription ; e has number of cards in spread
di
call PassList
call PassList ; one card description has two strings
dec e ; this will not work if the spreadd had zero cardss. i will overflow.
jp nz, .skipCardDescription
ei
ld e, [hl] ; skip title of spread
inc hl
add hl, de
@ -167,10 +250,10 @@ DrawSpreadAsync:
ldh a, [vSelectedSpreadIndex]
ldh [vPreviousSpreadIndex], a
ld de, $9800 + 32*5 + 5
ld de, $9800 + 32*5 + 3
ld hl, ONES
ld b, 8
ld c, 10
ld c, 14
ld a, LOW(CopyTilesToMapThreadsafe)
ld [vAsyncNext], a
@ -189,10 +272,21 @@ DrawSpreadAsync:
ld l, a
ld a, [vCurrentSpread+1]
ld h, a
ld d, 0
ld e, [hl]
inc e
add hl, de
ld e, [hl] ; e holds length of spread
di
call PassList ; step past spread layout
ei
nop
nop
.PassCardPositionDescriptions
di
call PassList ; step past one pdesc
call PassList ; step past two pdesc
ei
dec e ; we've looked at one
jp nz, .PassCardPositionDescriptions
.foundSpreadTitle
ld de, $9800 + 32 + 1
ld a, LOW(PrintString)
ld [vAsyncNext], a
@ -210,33 +304,68 @@ DrawSpreadAsync:
ld [vAsyncNext], a
ld a, HIGH(PrintString)
ld [vAsyncNext+1], a
ld a, LOW(.afterDescription)
ld a, LOW(DrawSpreadALittleAsync)
ld [vAsyncAfter], a
ld a, HIGH(.afterDescription)
ld a, HIGH(DrawSpreadALittleAsync)
ld [vAsyncAfter+1], a
ret
.afterDescription
DrawSpreadALittleAsync:
ld hl, $9800 + 32*5 + 5
ld hl, $9800 + 32*5 + 3
ldh a, [vSelectedSpreadCard]
ld d, 0
ld e, a ; e contains the selected index
ld a, LOW(DrawSpreadBigAndThreadsafe)
ld [vAsyncNext], a
ld a, HIGH(DrawSpreadBigAndThreadsafe)
ld [vAsyncNext+1], a
ld a, LOW(.finishAsyncUpdate)
ld a, LOW(.drawSpreadPositionDescription)
ld [vAsyncAfter], a
ld a, HIGH(.finishAsyncUpdate)
ld a, HIGH(.drawSpreadPositionDescription)
ld [vAsyncAfter+1], a
ret
.finishAsyncUpdate
; signal that we're done with execution of the async thread
ld a, 0
.drawSpreadPositionDescription
di
ld a, [vCurrentSpread]
ld l, a
ld a, [vCurrentSpread+1]
ld h, a ; hl points at beginning of card list
call PassList ; hl points at first card description
ld a, [vSelectedSpreadCard]
ld e, a
cp a, 0
jp z, .printIt
.stepForwardCardDescription
call PassList
call PassList
dec e
jp nz, .stepForwardCardDescription
.printIt
ei
nop
nop
.drawFirstDescription
ld de, $9800+32*15 + 6
ld a, LOW(PrintString)
ld [vAsyncNext], a
ld a, HIGH(PrintString)
ld [vAsyncNext+1], a
ld a, LOW(.drawSecondDescription)
ld [vAsyncAfter], a
ld a, HIGH(.drawSecondDescription)
ld [vAsyncAfter+1], a
ret
.drawSecondDescription
ld de, $9800+32*16 + 6
ld a, LOW(PrintString)
ld [vAsyncNext], a
ld a, HIGH(PrintString)
ld [vAsyncNext+1], a
ld a, 0
ld [vAsyncAfter], a
ld [vAsyncAfter+1], a
ret
@ -254,7 +383,7 @@ SpreadSelectDraw:
ld b, [hl]
ld h, b
ld l, c
ld de, $8010
ld de, $8000 + $1000 + $10
ld a, [hl+]
ld [de], a
inc de
@ -308,7 +437,7 @@ SpreadSelectTeardown:
DrawSpreadBigAndThreadsafe:
; hl for location on screen
; bc for current spread address ; actually holding that in vCurrentSpread
; current spread address in vCurrentSpread
; e for index of selected card
di
ld a, [vCurrentSpread]
@ -346,7 +475,11 @@ DrawSpreadBigAndThreadsafe:
ld h, a
;spread address in hl
inc e ; skip the tiles length
inc hl ; skip the tiles length
ld d, 0
ld a, [vSelectedSpreadCard]
ld e, a
add hl, de
ld a, [hl] ; load card descriptor into a
@ -430,21 +563,21 @@ DrawBigCardSelected: ; starting from screen location hl, draw a card at
jp nz, .stepDown
.drawCard
ld de, 32
ld [hl], $12
ld [hl], $24
inc hl
ld [hl], $1e
ld [hl], $25
add hl, de
ld [hl], $1f
ld [hl], $27
dec hl
ld [hl], $13
ld [hl], $26
add hl, de
ld [hl], $13
ld [hl], $28
inc hl
ld [hl], $1f
ld [hl], $29
add hl, de
ld [hl], $23
ld [hl], $2b
dec hl
ld [hl], $17
ld [hl], $2a
pop de
ret
@ -522,6 +655,16 @@ DrawSmallCard: ; starting from screen location hl, draw a card at
pop de
ret
FaceCardTiles:
db $ff,$00,$80,$7f,$80,$7f,$9f,$7f,$9f,$7f,$98,$78,$99,$79,$9a,$7a
db $ff,$00,$01,$fe,$01,$fe,$f9,$fe,$f9,$fe,$19,$1e,$19,$1e,$d9,$de
db $9a,$7a,$99,$79,$98,$78,$9c,$78,$99,$78,$9b,$79,$9b,$7a,$9b,$7a
db $d9,$de,$99,$9e,$d9,$de,$f9,$de,$99,$9e,$d9,$9e,$d9,$9e,$d9,$5e
db $98,$78,$98,$7b,$99,$7a,$9a,$7c,$9f,$7b,$99,$79,$99,$79,$98,$78
db $59,$5e,$19,$fe,$f9,$1e,$19,$1e,$d9,$de,$d9,$de,$59,$5e,$19,$1e
db $98,$79,$98,$79,$98,$78,$9f,$7f,$9f,$7f,$80,$7f,$80,$7f,$ff,$00
db $19,$9e,$19,$9e,$19,$1e,$f9,$fe,$f9,$fe,$01,$fe,$01,$fe,$ff,$00
FaceCardTilesEnd:
SpreadSelectTilemap:
db $09, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $08
db $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04
@ -537,8 +680,8 @@ SpreadSelectTilemap:
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $09, $02, $02, $02, $02, $02, $02, $02, $02, $08, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $06, $05, $05, $05, $05, $05, $05, $05, $05, $07, $01, $01, $01, $01, $01
SpreadSelectTilemapEnd:

151
main.asm
View File

@ -35,6 +35,7 @@ EntryPoint:
ld a, 0
ldh [rNR52], a ; shut down audio
ldh [rDIV], a ; reset timer just in case??
ldh [rLCDC], a ; shut down screen
ld a, 0
ld hl, ZEROES
@ -59,6 +60,16 @@ EntryPoint:
dec bc
jp nz, .buildOnes
ld hl, UITiles
ld de, $8000 + $100*16
ld bc, (UITilesEnd - UITiles)
call CopyRangeUnsafe
ld hl, LetterTiles ; map the small font into vram at ascii locations
ld de, $8000 + (127 + $21)*16
ld bc, LetterTilesEnd - LetterTiles
call CopyRangeUnsafe
; set up the scene and interrupt vectors
ld hl, Instructions
@ -231,7 +242,15 @@ ArrayClampLooping: ; loops a to be in the array, assuming hl points to the lengt
:
ret ; a is return value
PassList: ; hl has the address of a list. step past it.
ld b, 0
ld c, [hl] ; bc has length
inc hl ; step over length
add hl, bc ; step past all the entries
ret
PrintString: ; write ascii string which has been prefixed by its length. at hl
; de should be location in tile map to write
ld b, [hl]
ld a, b
cp a, 0
@ -277,7 +296,139 @@ run_dma_tail: ; This part must be in HRAM.
Instructions:
call SCENE_UPDATE + 2
ret
UITiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $05,$00,$05,$00,$05,$00,$05,$00,$05,$00,$fd,$00,$00,$00,$fd,$00
db $00,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$ff,$00,$00,$00,$00,$00,$00
db $70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8,$70,$e8
db $0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17
db $00,$00,$00,$00,$00,$00,$00,$ff,$ff,$00,$ff,$ff,$ff,$ff,$00,$ff
db $70,$e8,$70,$e8,$70,$e8,$70,$ef,$7f,$f0,$3f,$7f,$1f,$3f,$00,$1f
db $0e,$17,$0e,$17,$0e,$17,$0e,$f7,$fe,$0f,$fc,$fe,$f8,$fc,$00,$f8
db $00,$f8,$f8,$fc,$fc,$fe,$fe,$0f,$0e,$f7,$0e,$17,$0e,$17,$0e,$17
db $00,$1f,$1f,$3f,$3f,$7f,$7f,$f0,$70,$ef,$70,$e8,$70,$e8,$70,$e8
db $00,$00,$ff,$00,$ff,$00,$aa,$55,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff
db $63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f
db $ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8
db $ff,$ff,$ff,$ff,$00,$ff,$00,$ff,$55,$aa,$ff,$00,$ff,$00,$00,$00
db $00,$00,$3f,$00,$7f,$00,$7a,$05,$68,$17,$70,$0f,$63,$1f,$73,$0f
db $00,$00,$fc,$00,$fe,$00,$ae,$50,$1e,$e0,$06,$f8,$ce,$f0,$c6,$f8
db $ce,$f0,$c6,$f8,$0e,$f0,$16,$e8,$5e,$a0,$fe,$00,$fc,$00,$00,$00
db $63,$1f,$73,$0f,$60,$1f,$78,$07,$75,$0a,$7f,$00,$3f,$00,$00,$00
db $00,$0f,$00,$10,$00,$10,$00,$10,$00,$0f,$00,$10,$00,$10,$00,$10
db $00,$7f,$00,$80,$00,$80,$00,$80,$00,$7f,$00,$10,$00,$10,$00,$10
db $00,$0f,$00,$10,$00,$10,$00,$10,$00,$7f,$00,$80,$00,$80,$00,$80
db $00,$7f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$0f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$7e,$ff,$00,$ff
db $00,$ff,$7e,$ff,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3
db $99,$5a,$99,$5a,$99,$5a,$99,$5a,$99,$5a,$81,$42,$81,$7e,$ff,$00
db $ff,$00,$81,$7e,$81,$42,$99,$5a,$99,$5a,$99,$5a,$99,$5a,$99,$5a
UITilesEnd:
LetterTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $03,$03,$07,$07,$0f,$0f,$0e,$0e,$1c,$1c,$30,$30,$c0,$c0,$c0,$c0
db $24,$24,$6c,$6c,$6c,$6c,$48,$48,$00,$00,$00,$00,$00,$00,$00,$00
db $1a,$1a,$1a,$1a,$7f,$7f,$34,$34,$34,$34,$fe,$fe,$68,$68,$68,$68
db $08,$08,$3c,$3c,$6a,$6a,$68,$68,$3c,$3c,$0a,$0a,$6a,$6a,$3c,$3c
db $63,$63,$a6,$a6,$ac,$ac,$d8,$d8,$1b,$1b,$35,$35,$65,$65,$c6,$c6
db $18,$18,$24,$24,$28,$28,$18,$18,$2c,$2c,$66,$66,$67,$67,$39,$39
db $18,$18,$18,$18,$18,$18,$30,$30,$00,$00,$00,$00,$00,$00,$00,$00
db $04,$04,$0c,$0c,$18,$18,$10,$10,$10,$10,$18,$18,$0c,$0c,$04,$04
db $20,$20,$30,$30,$18,$18,$08,$08,$08,$08,$18,$18,$30,$30,$20,$20
db $00,$00,$08,$08,$28,$28,$1e,$1e,$78,$78,$14,$14,$10,$10,$00,$00
db $00,$00,$00,$00,$18,$18,$18,$18,$7e,$7e,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$00,$00,$1c,$1c,$38,$38,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$18,$00,$00
db $04,$04,$0c,$0c,$0c,$0c,$18,$18,$18,$18,$30,$30,$30,$30,$20,$20
db $00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$64,$64,$64,$64,$38,$38
db $08,$08,$18,$18,$38,$38,$18,$18,$18,$18,$18,$18,$18,$18,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$0c,$0c,$0c,$0c,$18,$18,$30,$30,$7c,$7c
db $00,$00,$3c,$3c,$06,$06,$06,$06,$1c,$1c,$06,$06,$06,$06,$3c,$3c
db $00,$00,$04,$04,$26,$26,$26,$26,$3e,$3e,$06,$06,$06,$06,$04,$04
db $00,$00,$7c,$7c,$64,$64,$60,$60,$78,$78,$44,$44,$04,$04,$38,$38
db $00,$00,$20,$20,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$7c,$7c,$4c,$4c,$0c,$0c,$3e,$3e,$18,$18,$30,$30,$20,$20
db $00,$00,$78,$78,$64,$64,$64,$64,$38,$38,$64,$64,$64,$64,$3c,$3c
db $00,$00,$38,$38,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$00,$00,$18,$18,$18,$18,$00,$00,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$0c,$0c,$0c,$0c,$00,$00,$0c,$0c,$0c,$0c,$18,$18
db $00,$00,$0c,$0c,$18,$18,$30,$30,$60,$60,$30,$30,$18,$18,$0c,$0c
db $00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$3c,$3c,$3c,$3c,$00,$00
db $00,$00,$30,$30,$18,$18,$0c,$0c,$06,$06,$0c,$0c,$18,$18,$30,$30
db $38,$38,$6c,$6c,$24,$24,$0c,$0c,$18,$18,$18,$18,$00,$00,$18,$18
db $3c,$3c,$62,$62,$59,$59,$45,$45,$5d,$5d,$5d,$5d,$63,$63,$38,$38
db $00,$00,$38,$38,$34,$34,$32,$32,$3e,$3e,$32,$32,$32,$32,$32,$32
db $00,$00,$7c,$7c,$32,$32,$32,$32,$3c,$3c,$32,$32,$32,$32,$1c,$1c
db $00,$00,$3c,$3c,$72,$72,$62,$62,$60,$60,$60,$60,$62,$62,$3c,$3c
db $00,$00,$f8,$f8,$64,$64,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$3c,$3c
db $00,$00,$fc,$fc,$60,$60,$60,$60,$78,$78,$60,$60,$60,$60,$20,$20
db $00,$00,$78,$78,$64,$64,$60,$60,$60,$60,$6e,$6e,$64,$64,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$7e,$7e,$62,$62,$62,$62,$22,$22
db $00,$00,$10,$10,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$08,$08,$0c,$0c,$0c,$0c,$0c,$0c,$4c,$4c,$6c,$6c,$3c,$3c
db $00,$00,$40,$40,$64,$64,$68,$68,$70,$70,$68,$68,$64,$64,$22,$22
db $00,$00,$20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$32,$32,$1e,$1e
db $00,$00,$3e,$3e,$6a,$6a,$6a,$6a,$6a,$6a,$62,$62,$62,$62,$22,$22
db $00,$00,$72,$72,$6a,$6a,$6a,$6a,$6a,$6a,$66,$66,$62,$62,$22,$22
db $00,$00,$3c,$3c,$66,$66,$62,$62,$62,$62,$62,$62,$32,$32,$1e,$1e
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$60,$60,$60,$60,$20,$20
db $00,$00,$38,$38,$64,$64,$62,$62,$62,$62,$6a,$6a,$64,$64,$3b,$3b
db $00,$00,$f8,$f8,$64,$64,$64,$64,$7c,$7c,$68,$68,$64,$64,$23,$23
db $00,$00,$38,$38,$64,$64,$60,$60,$38,$38,$04,$04,$64,$64,$38,$38
db $00,$00,$7e,$7e,$5a,$5a,$18,$18,$18,$18,$18,$18,$18,$18,$08,$08
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$62,$62,$62,$62,$3c,$3c
db $00,$00,$40,$40,$62,$62,$62,$62,$62,$62,$24,$24,$34,$34,$18,$18
db $00,$00,$c3,$c3,$62,$62,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34
db $00,$00,$42,$42,$62,$62,$34,$34,$18,$18,$3c,$3c,$66,$66,$42,$42
db $00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$4c,$4c,$78,$78
db $00,$00,$7e,$7e,$46,$46,$0c,$0c,$18,$18,$30,$30,$62,$62,$7e,$7e
db $7c,$7c,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$7c,$7c
db $20,$20,$30,$30,$30,$30,$18,$18,$18,$18,$0c,$0c,$0c,$0c,$04,$04
db $3e,$3e,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$06,$3e,$3e
db $18,$18,$3c,$3c,$66,$66,$42,$42,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7c,$7c,$3e,$3e
db $30,$30,$18,$18,$0c,$0c,$04,$04,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$38,$38,$0c,$0c,$3c,$3c,$4c,$4c,$3a,$3a,$00,$00
db $00,$00,$30,$30,$30,$30,$3c,$3c,$32,$32,$32,$32,$3c,$3c,$00,$00
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$0c,$0c,$0c,$0c,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$78,$78,$60,$60,$3c,$3c,$00,$00
db $00,$00,$0e,$0e,$18,$18,$3c,$3c,$18,$18,$18,$18,$18,$18,$00,$00
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$60,$60,$60,$60,$78,$78,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$10,$10,$00,$00,$38,$38,$18,$18,$18,$18,$3c,$3c,$00,$00
db $00,$00,$08,$08,$00,$00,$0c,$0c,$0c,$0c,$0c,$0c,$2c,$2c,$18,$18
db $00,$00,$60,$60,$68,$68,$68,$68,$70,$70,$68,$68,$64,$64,$00,$00
db $00,$00,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$18,$18,$00,$00
db $00,$00,$00,$00,$74,$74,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$6a,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$64,$64,$64,$64,$00,$00
db $00,$00,$00,$00,$38,$38,$64,$64,$64,$64,$64,$64,$38,$38,$00,$00
db $00,$00,$00,$00,$78,$78,$64,$64,$64,$64,$78,$78,$60,$60,$60,$60
db $00,$00,$00,$00,$3c,$3c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$0e,$0e
db $00,$00,$00,$00,$1c,$1c,$30,$30,$30,$30,$30,$30,$30,$30,$00,$00
db $00,$00,$00,$00,$38,$38,$60,$60,$38,$38,$0c,$0c,$78,$78,$00,$00
db $00,$00,$30,$30,$78,$78,$30,$30,$30,$30,$30,$30,$1c,$1c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$64,$64,$3c,$3c,$00,$00
db $00,$00,$00,$00,$64,$64,$64,$64,$64,$64,$28,$28,$10,$10,$00,$00
db $00,$00,$00,$00,$62,$62,$6a,$6a,$6a,$6a,$6a,$6a,$34,$34,$00,$00
db $00,$00,$00,$00,$64,$64,$38,$38,$18,$18,$2c,$2c,$46,$46,$00,$00
db $00,$00,$00,$00,$4c,$4c,$4c,$4c,$4c,$4c,$3c,$3c,$0c,$0c,$38,$38
db $00,$00,$00,$00,$7e,$7e,$0c,$0c,$18,$18,$30,$30,$7e,$7e,$00,$00
db $3c,$3c,$60,$60,$30,$30,$60,$60,$60,$60,$30,$30,$60,$60,$3c,$3c
db $20,$20,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$10,$10
db $3c,$3c,$06,$06,$0c,$0c,$06,$06,$06,$06,$0c,$0c,$06,$06,$3c,$3c
db $00,$00,$00,$00,$31,$31,$7b,$7b,$de,$de,$8c,$8c,$00,$00,$00,$00
db $c0,$c0,$a0,$a0,$b8,$b8,$b0,$b0,$da,$da,$12,$12,$1a,$1a,$03,$03
LetterTilesEnd:
INCLUDE "Async.inc"
INCLUDE "CopyRangeSafe.inc"
INCLUDE "CopyTilesSafe.inc"
INCLUDE "ScreenMainMenu.inc"
INCLUDE "ScreenSpreadSelect.inc"
INCLUDE "ScreenCardRead.inc"

View File

@ -13,25 +13,42 @@ tileset:
db $0e,$17,$0e,$17,$0e,$17,$0e,$f7,$fe,$0f,$fc,$fe,$f8,$fc,$00,$f8
db $00,$f8,$f8,$fc,$fc,$fe,$fe,$0f,$0e,$f7,$0e,$17,$0e,$17,$0e,$17
db $00,$1f,$1f,$3f,$3f,$7f,$7f,$f0,$70,$ef,$70,$e8,$70,$e8,$70,$e8
db $00,$00,$ff,$00,$ff,$00,$aa,$55,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff
db $63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f,$63,$1f,$73,$0f
db $ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8,$ce,$f0,$c6,$f8
db $ff,$ff,$ff,$ff,$00,$ff,$00,$ff,$55,$aa,$ff,$00,$ff,$00,$00,$00
db $00,$00,$3f,$00,$7f,$00,$7a,$05,$68,$17,$70,$0f,$63,$1f,$73,$0f
db $00,$00,$fc,$00,$fe,$00,$ae,$50,$1e,$e0,$06,$f8,$ce,$f0,$c6,$f8
db $ce,$f0,$c6,$f8,$0e,$f0,$16,$e8,$5e,$a0,$fe,$00,$fc,$00,$00,$00
db $63,$1f,$73,$0f,$60,$1f,$78,$07,$75,$0a,$7f,$00,$3f,$00,$00,$00
db $00,$0f,$00,$10,$00,$10,$00,$10,$00,$0f,$00,$10,$00,$10,$00,$10
db $00,$7f,$00,$80,$00,$80,$00,$80,$00,$7f,$00,$10,$00,$10,$00,$10
db $00,$0f,$00,$10,$00,$10,$00,$10,$00,$7f,$00,$80,$00,$80,$00,$80
db $00,$7f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$0f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$7e,$ff,$00,$ff
db $00,$ff,$7e,$ff,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3,$56,$c3,$6a,$c3
db $99,$5a,$99,$5a,$99,$5a,$99,$5a,$99,$5a,$81,$42,$81,$7e,$ff,$00
db $ff,$00,$81,$7e,$81,$42,$99,$5a,$99,$5a,$99,$5a,$99,$5a,$99,$5a
BackgroundCopyCopy:
db $09, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $08
db $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04
db $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04
db $06, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $07
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $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, $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, $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, $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, $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, $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, $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, $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, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $11, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $10, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01