adds a third card and cleans up some code
This commit is contained in:
parent
2edbb942f4
commit
a8cd39d587
120
KeyArtTiles.asm
Normal file
120
KeyArtTiles.asm
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
; original export script by gabriel reis, modified by shoofle
|
||||||
|
|
||||||
|
|
||||||
|
KeyArtTiles:
|
||||||
|
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$ff,$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,$04
|
||||||
|
db $00,$3f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$f8,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$40,$00,$ff,$00,$42,$00,$42,$00,$42,$00,$42,$00,$42
|
||||||
|
db $00,$42,$00,$42,$00,$42,$00,$42,$00,$42,$00,$42,$00,$42,$00,$42
|
||||||
|
db $10,$00,$00,$10,$00,$10,$80,$10,$40,$10,$40,$10,$20,$18,$10,$28
|
||||||
|
db $00,$28,$00,$28,$00,$24,$00,$24,$00,$e4,$00,$22,$00,$a2,$00,$41
|
||||||
|
db $00,$00,$00,$00,$00,$01,$00,$06,$00,$99,$00,$20,$00,$00,$00,$fc
|
||||||
|
db $00,$40,$00,$c0,$00,$20,$00,$60,$00,$60,$00,$60,$00,$50,$00,$50
|
||||||
|
db $00,$07,$00,$00,$00,$00,$00,$00,$00,$ff,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$c2,$00,$62,$00,$52,$00,$8a,$00,$06,$00,$02,$00,$02
|
||||||
|
db $00,$48,$00,$44,$00,$43,$00,$40,$00,$40,$00,$5f,$00,$20,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$c0,$00,$30,$00,$88,$00,$08,$00,$04
|
||||||
|
db $00,$03,$00,$03,$00,$01,$00,$01,$00,$01,$00,$03,$00,$03,$00,$06
|
||||||
|
db $00,$04,$00,$04,$00,$02,$00,$02,$00,$02,$00,$02,$00,$04,$00,$18
|
||||||
|
db $00,$08,$00,$10,$00,$20,$00,$20,$00,$40,$00,$80,$00,$80,$00,$80
|
||||||
|
db $00,$00,$00,$03,$00,$04,$00,$04,$00,$04,$00,$04,$00,$03,$00,$00
|
||||||
|
db $00,$20,$00,$c0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f8
|
||||||
|
db $00,$00,$00,$01,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$80,$00,$00,$00,$00,$00,$80,$00,$78,$00,$06,$00,$01,$00,$00
|
||||||
|
db $00,$31,$00,$31,$00,$11,$00,$11,$00,$11,$00,$11,$00,$11,$00,$91
|
||||||
|
db $00,$07,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$e0,$00,$1f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$9f,$00,$60,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $41,$00,$20,$00,$10,$00,$08,$00,$04,$00,$02,$00,$01,$00,$00,$01
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7e,$00,$81,$00,$01
|
||||||
|
db $00,$42,$00,$44,$00,$44,$00,$22,$00,$21,$00,$18,$00,$06,$00,$01
|
||||||
|
db $00,$82,$00,$82,$00,$05,$00,$08,$00,$f0,$00,$80,$00,$00,$00,$00
|
||||||
|
db $00,$10,$80,$10,$80,$10,$80,$10,$00,$30,$00,$1f,$00,$78,$00,$94
|
||||||
|
db $02,$08,$01,$08,$00,$08,$00,$08,$00,$08,$00,$e8,$00,$1f,$00,$08
|
||||||
|
db $01,$00,$00,$00,$80,$00,$40,$00,$20,$00,$10,$00,$08,$80,$04,$40
|
||||||
|
db $80,$06,$80,$08,$80,$10,$40,$10,$40,$10,$20,$10,$20,$10,$10,$00
|
||||||
|
db $02,$30,$01,$08,$00,$04,$00,$02,$00,$02,$00,$01,$00,$00,$00,$80
|
||||||
|
db $08,$04,$04,$00,$80,$04,$40,$04,$00,$04,$00,$08,$00,$88,$00,$88
|
||||||
|
db $00,$00,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$41
|
||||||
|
db $00,$80,$00,$40,$00,$40,$00,$40,$00,$40,$00,$40,$00,$41,$00,$41
|
||||||
|
db $00,$88,$00,$88,$00,$88,$00,$88,$00,$88,$00,$88,$20,$08,$10,$08
|
||||||
|
db $00,$80,$00,$40,$00,$20,$00,$18,$00,$07,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$08,$00,$e8,$00,$30,$00,$c0,$00,$00,$00,$02,$00,$01,$00,$00
|
||||||
|
db $08,$00,$00,$08,$00,$88,$00,$48,$00,$28,$00,$78,$00,$98,$00,$88
|
||||||
|
db $00,$f8,$00,$a8,$00,$a8,$00,$a8,$00,$a8,$00,$a8,$00,$a9,$00,$a9
|
||||||
|
db $00,$29,$00,$31,$00,$31,$00,$31,$00,$31,$00,$31,$00,$31,$00,$31
|
||||||
|
db $00,$28,$00,$24,$00,$24,$00,$24,$00,$24,$00,$27,$00,$27,$00,$2e
|
||||||
|
db $00,$2d,$00,$26,$00,$25,$00,$25,$00,$25,$00,$25,$00,$25,$00,$25
|
||||||
|
db $00,$25,$00,$25,$00,$25,$00,$25,$00,$15,$00,$15,$00,$15,$00,$15
|
||||||
|
db $00,$15,$00,$15,$00,$15,$00,$15,$00,$11,$00,$02,$00,$02,$00,$02
|
||||||
|
db $00,$02,$00,$02,$00,$02,$00,$04,$00,$04,$00,$08,$00,$08,$00,$00
|
||||||
|
db $00,$a9,$00,$a9,$00,$a9,$00,$a9,$00,$a9,$00,$a9,$00,$a9,$00,$a9
|
||||||
|
db $02,$00,$02,$00,$80,$03,$40,$04,$20,$08,$00,$10,$00,$10,$00,$10
|
||||||
|
db $01,$00,$00,$00,$00,$e0,$00,$10,$00,$10,$00,$08,$00,$08,$0c,$00
|
||||||
|
db $00,$0b,$00,$08,$00,$04,$00,$03,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$01,$00,$03,$00,$0c,$01,$f4,$00,$04
|
||||||
|
db $00,$04,$00,$04,$00,$24,$00,$24,$02,$24,$02,$24,$01,$24,$01,$24
|
||||||
|
db $00,$78,$00,$80,$00,$00,$00,$60,$00,$18,$00,$07,$00,$00,$00,$00
|
||||||
|
db $00,$60,$00,$1c,$00,$03,$00,$00,$00,$01,$00,$fe,$00,$00,$00,$00
|
||||||
|
db $02,$40,$01,$20,$00,$f8,$00,$78,$00,$88,$00,$08,$00,$08,$00,$10
|
||||||
|
db $08,$20,$06,$40,$01,$80,$10,$00,$08,$00,$04,$00,$02,$00,$81,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$1f,$00,$e7
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$07,$00,$00,$00,$00,$00,$fe,$00,$81
|
||||||
|
db $00,$20,$00,$40,$00,$80,$00,$00,$00,$00,$00,$00,$04,$00,$04,$80
|
||||||
|
db $00,$00,$00,$02,$00,$02,$00,$02,$00,$02,$00,$02,$00,$02,$00,$06
|
||||||
|
db $00,$22,$00,$22,$00,$22,$00,$22,$00,$22,$00,$02,$00,$02,$00,$02
|
||||||
|
db $00,$02,$00,$02,$00,$02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $02,$28,$02,$28,$01,$28,$00,$28,$00,$28,$00,$28,$00,$28,$00,$28
|
||||||
|
db $00,$0a,$00,$0a,$00,$0a,$00,$0a,$00,$0a,$00,$0a,$00,$0a,$00,$0a
|
||||||
|
db $00,$12,$00,$12,$00,$12,$00,$22,$00,$22,$00,$22,$00,$22,$00,$22
|
||||||
|
db $00,$22,$00,$22,$00,$22,$00,$22,$00,$22,$00,$22,$00,$22,$00,$22
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7f,$00,$00
|
||||||
|
db $00,$0c,$00,$18,$80,$0c,$40,$0b,$20,$04,$10,$04,$08,$02,$00,$02
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$fc,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$01,$a0,$00,$70,$00,$10,$00,$08,$00,$04,$00,$02,$00,$01,$00
|
||||||
|
db $00,$00,$00,$80,$00,$80,$00,$40,$00,$3f,$00,$04,$00,$04,$00,$04
|
||||||
|
db $00,$80,$00,$40,$00,$20,$00,$18,$00,$06,$00,$01,$00,$00,$00,$03
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$80,$00,$3f,$00,$c0
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f8,$00,$00,$00,$00
|
||||||
|
db $00,$04,$80,$04,$80,$04,$40,$04,$20,$04,$20,$04,$10,$04,$10,$04
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$00,$00,$00,$84,$00,$44
|
||||||
|
db $00,$48,$00,$88,$00,$88,$00,$88,$00,$88,$00,$88,$00,$08,$00,$08
|
||||||
|
db $00,$44,$00,$44,$00,$44,$00,$44,$00,$44,$00,$44,$00,$44,$00,$44
|
||||||
|
db $00,$08,$00,$08,$00,$08,$00,$08,$00,$08,$00,$08,$00,$08,$00,$08
|
||||||
|
db $00,$08,$00,$08,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$02,$00,$0c,$00,$10
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$78,$00,$86,$00,$01,$00,$00,$00,$00
|
||||||
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$fc,$00,$02,$00,$01
|
||||||
|
db $00,$28,$00,$28,$00,$28,$00,$28,$00,$28,$00,$28,$08,$20,$04,$28
|
||||||
|
db $00,$00,$01,$00,$00,$00,$00,$00,$40,$00,$20,$00,$10,$00,$08,$00
|
||||||
|
db $04,$00,$03,$00,$c0,$00,$20,$00,$10,$00,$10,$00,$08,$00,$04,$00
|
||||||
|
db $02,$00,$01,$00,$80,$00,$40,$00,$20,$00,$20,$00,$18,$00,$06,$00
|
||||||
|
db $00,$00,$80,$00,$40,$00,$20,$00,$10,$00,$08,$00,$04,$00,$04,$00
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BackgroundCopy:
|
||||||
|
db $00, $00, $57, $58, $59, $00, $00, $00
|
||||||
|
db $3e, $3f, $40, $5b, $5e, $4e, $4f, $50
|
||||||
|
db $3a, $3b, $3c, $5c, $5d, $49, $4a, $4b
|
||||||
|
db $48, $38, $3d, $35, $36, $4c, $4d, $52
|
||||||
|
db $41, $39, $1d, $21, $22, $23, $51, $54
|
||||||
|
db $45, $5a, $24, $37, $2b, $25, $26, $54
|
||||||
|
db $46, $44, $09, $27, $1e, $28, $29, $54
|
||||||
|
db $47, $2f, $0a, $1f, $0b, $20, $2c, $54
|
||||||
|
db $47, $30, $0c, $2a, $0d, $0e, $2d, $53
|
||||||
|
db $47, $31, $0f, $10, $00, $11, $34, $55
|
||||||
|
db $47, $32, $00, $12, $00, $13, $2e, $55
|
||||||
|
db $42, $33, $14, $15, $16, $17, $18, $55
|
||||||
|
db $43, $00, $00, $19, $1a, $1b, $1c, $56
|
||||||
|
db $00, $00, $01, $02, $07, $02, $00, $00
|
||||||
|
db $00, $00, $00, $00, $08, $03, $00, $00
|
||||||
|
db $00, $00, $00, $04, $05, $06, $00, $00
|
355
tarot.asm
355
tarot.asm
@ -23,8 +23,9 @@ DEF vPreviousCardIndex EQU $FFA0+3
|
|||||||
DEF vSafeCopySource EQU $FFA0+4
|
DEF vSafeCopySource EQU $FFA0+4
|
||||||
DEF vSafeCopyDest EQU vSafeCopySource + 2
|
DEF vSafeCopyDest EQU vSafeCopySource + 2
|
||||||
DEF vSafeCopyCount EQU vSafeCopyDest + 2 ; check this for safe transfer being complete
|
DEF vSafeCopyCount EQU vSafeCopyDest + 2 ; check this for safe transfer being complete
|
||||||
|
DEF vSafeCopyOriginalCount EQU vSafeCopyCount + 2
|
||||||
; stash previous interrupt state before using the interrupts
|
; stash previous interrupt state before using the interrupts
|
||||||
DEF vSafeCopyLYC EQU vSafeCopyCount + 2 ; stashes $FF45, the LYC register
|
DEF vSafeCopyLYC EQU vSafeCopyOriginalCount + 2 ; stashes $FF45, the LYC register
|
||||||
DEF vSafeCopySTAT EQU vSafeCopyLYC + 1 ; stashes $FF41, the STAT register
|
DEF vSafeCopySTAT EQU vSafeCopyLYC + 1 ; stashes $FF41, the STAT register
|
||||||
DEF vSafeCopyInterruptFirst EQU vSafeCopySTAT + 1 ; stashes $0048 the STAT interrupt
|
DEF vSafeCopyInterruptFirst EQU vSafeCopySTAT + 1 ; stashes $0048 the STAT interrupt
|
||||||
DEF vSafeCopyInterruptSecond EQU vSafeCopyInterruptFirst + 1
|
DEF vSafeCopyInterruptSecond EQU vSafeCopyInterruptFirst + 1
|
||||||
@ -141,15 +142,12 @@ Loop:
|
|||||||
ld a, b
|
ld a, b
|
||||||
ld [rMYBTN], a
|
ld [rMYBTN], a
|
||||||
|
|
||||||
di
|
|
||||||
call SCENE_UPDATE - 1
|
call SCENE_UPDATE - 1
|
||||||
ei
|
|
||||||
ld b, 144
|
ld b, 144
|
||||||
call AwaitLine
|
call AwaitLine
|
||||||
|
|
||||||
di
|
|
||||||
call SCENE_DRAW - 1
|
call SCENE_DRAW - 1
|
||||||
ei
|
|
||||||
jp Loop
|
jp Loop
|
||||||
|
|
||||||
|
|
||||||
@ -169,22 +167,16 @@ CardReadSetup:
|
|||||||
ld bc, LetterTilesEnd - LetterTiles
|
ld bc, LetterTilesEnd - LetterTiles
|
||||||
call CopyRangeUnsafe
|
call CopyRangeUnsafe
|
||||||
|
|
||||||
ld hl, BigLetterTiles
|
ld hl, UITilemap ; origin
|
||||||
ld de, $8000 + (128 + 16 + 32)*16
|
ld de, $9800 ; destination
|
||||||
ld bc, BigLetterTilesEnd - BigLetterTiles
|
|
||||||
; call CopyRangeUnsafe
|
|
||||||
|
|
||||||
ld de, UITilemap ; origin
|
|
||||||
ld hl, $9800 ; destination
|
|
||||||
ld b, 18 ; height
|
ld b, 18 ; height
|
||||||
ld c, 20 ; width
|
ld c, 20 ; width
|
||||||
call CopyTilesToMap
|
call CopyTilesToMapUnsafe
|
||||||
|
|
||||||
ld de, BigLetters
|
;ld hl, FoolTiles
|
||||||
ld hl, $9800 + 32*1 + 10
|
;ld de, $8000
|
||||||
ld b, 2
|
;ld bc, FoolTilesEnd - FoolTiles
|
||||||
ld c, 8
|
;call CopyRangeUnsafe
|
||||||
call CopyTilesToMap
|
|
||||||
|
|
||||||
; Turn the LCD on
|
; Turn the LCD on
|
||||||
ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON
|
ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON
|
||||||
@ -205,73 +197,83 @@ CardReadSetup:
|
|||||||
CardReadUpdate:
|
CardReadUpdate:
|
||||||
ldh a, [rMYBTNP]
|
ldh a, [rMYBTNP]
|
||||||
and a, %0000_1000 ; select the down key
|
and a, %0000_1000 ; select the down key
|
||||||
jp z, CardReadUpdateDoneDown
|
jp z, :+ ; skip the following code if down is not pressed
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex]
|
||||||
inc a ; increment when they press down because the stack has card 0 at the top
|
inc a ; increment when they press down because the deck has card 0 at the top
|
||||||
ldh [vSelectedTileIndex], a
|
ldh [vSelectedTileIndex], a
|
||||||
CardReadUpdateDoneDown:
|
:
|
||||||
ldh a, [rMYBTNP]
|
ldh a, [rMYBTNP]
|
||||||
and a, %0000_0100 ; select the up key
|
and a, %0000_0100 ; select the up key
|
||||||
jp z, CardReadUpdateDoneUp
|
jp z, :+ ; skip the following code if up is not pressed
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex]
|
||||||
dec a ; decrement when they press up because the stack has card 0 at the top
|
dec a ; decrement when they press up because the deck has card 0 at the top
|
||||||
ldh [vSelectedTileIndex], a
|
ldh [vSelectedTileIndex], a
|
||||||
CardReadUpdateDoneUp:
|
:
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex] ; load current selected tile index
|
||||||
cp a, 2
|
ld hl, Cards ; deck length
|
||||||
jp nz, CardReadUpdateDoneZero
|
cp a, [hl] ; ddoes the index equal the deck length?
|
||||||
ld a, 0
|
jp nz, :+
|
||||||
|
ld a, 0 ; if the index equals the deck length replace it with zero
|
||||||
ldh [vSelectedTileIndex], a
|
ldh [vSelectedTileIndex], a
|
||||||
CardReadUpdateDoneZero:
|
:
|
||||||
cp a, $FF
|
cp a, $FF ; if the tile index is $FF (underflowed from dec)
|
||||||
jp nz, CardReadUpdateReturn
|
jp nz, :+
|
||||||
ld a, 1
|
ld a, [hl]
|
||||||
|
dec a ;replace with deck length - 1
|
||||||
ldh [vSelectedTileIndex], a
|
ldh [vSelectedTileIndex], a
|
||||||
CardReadUpdateReturn:
|
:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
CardReadDraw:
|
CardReadDraw:
|
||||||
ld b, 1 ; 11 rows, and we stop before drawing row zero
|
; this function mostly just refreshes the deck view on the right side
|
||||||
|
; should probably be factored out into its own thing?
|
||||||
|
; it's also not vblank-safe; this could be up to 22 iterations of a loop...
|
||||||
|
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 hl, $9800+32*4+19 ; start point
|
||||||
ld de, 32 ; stride
|
ld de, 32 ; stride
|
||||||
CardReadDrawCopyTile:
|
CardReadDrawCopyTile:
|
||||||
ld a, $81
|
ld [hl], $81 ; load the tile for "unselected pair of tiles"
|
||||||
ld [hl], a
|
add hl, de ; step forward by stride (de is the address we're drawing to on screen)
|
||||||
add hl, de
|
dec b ; sets zero flag because it's an 8-bit register
|
||||||
dec b
|
jp nz, CardReadDrawCopyTile ; repeat if there's more cards in the deck to draw
|
||||||
jp nz, CardReadDrawCopyTile
|
ld [hl], $87 ; draw the cap at the end
|
||||||
ld a, $87
|
|
||||||
ld [hl], a ; draw the cap at the end
|
; the rest of this stuff deals with drawing the set-out card for the current
|
||||||
|
; selected card
|
||||||
CardReadDrawSelectedTile:
|
CardReadDrawSelectedTile:
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex]
|
||||||
|
srl a
|
||||||
ld b, a
|
ld b, a
|
||||||
srl b
|
|
||||||
ld hl, $9800+32*4+19 ; start point
|
ld hl, $9800+32*4+19 ; start point
|
||||||
ld de, 32 ; stride
|
ld de, 32 ; stride
|
||||||
|
; if the card we need to draw is in the zeroth spot, jump straight to drawing.
|
||||||
jp z, CardReadDrawDrawSelectedTile
|
jp z, CardReadDrawDrawSelectedTile
|
||||||
CardReadDrawCountDownTile:
|
CardReadDrawCountDownTile:
|
||||||
|
; otherwise, decrement b until we're there
|
||||||
add hl, de
|
add hl, de
|
||||||
dec b
|
dec b
|
||||||
jp nz, CardReadDrawCountDownTile
|
jp nz, CardReadDrawCountDownTile
|
||||||
CardReadDrawDrawSelectedTile:
|
CardReadDrawDrawSelectedTile:
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex]
|
||||||
and a, 1
|
and a, 1
|
||||||
jp z, CardReadDraw_PickTileWithTop
|
; if we're on an odd tile, draw the tile with the top card selected.
|
||||||
ld a, $90
|
; no other tile needs to change.
|
||||||
ld [hl], a
|
ld [hl], $82
|
||||||
add hl, de
|
|
||||||
ld a, $81
|
|
||||||
cp a, [hl]
|
|
||||||
ld a, $91
|
|
||||||
ld [hl], a
|
|
||||||
jp z, CardReadDrawReturn
|
jp z, CardReadDrawReturn
|
||||||
ld a, $92
|
; otherwise we need to draw the tile with the bottom card selected.
|
||||||
ld [hl], a
|
; this is more complicated because the tile underneath needs to change as well.
|
||||||
jp CardReadDrawReturn
|
ld [hl], $90 ; draw the "bottom card is selected"
|
||||||
CardReadDraw_PickTileWithTop:
|
add hl, de ; look down one tile (de has stride, remember)
|
||||||
ld a, $82
|
ld a, $81
|
||||||
ld [hl], a
|
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:
|
CardReadDrawReturn:
|
||||||
|
; check if the current selected tile is different from the previous;
|
||||||
|
; if it is different, then load new card data
|
||||||
ldh a, [vSelectedTileIndex]
|
ldh a, [vSelectedTileIndex]
|
||||||
ld hl, vPreviousCardIndex
|
ld hl, vPreviousCardIndex
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
@ -287,7 +289,6 @@ LoadCardData:
|
|||||||
|
|
||||||
ld b, 144
|
ld b, 144
|
||||||
call AwaitLine ; wait for vblank before starting to work
|
call AwaitLine ; wait for vblank before starting to work
|
||||||
LoadCardData_DoneTurningOff:
|
|
||||||
ld a, [vSelectedTileIndex]
|
ld a, [vSelectedTileIndex]
|
||||||
ld b, 0
|
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. coming into this we have the number of the card in the card array in a
|
||||||
@ -332,14 +333,26 @@ LoadCardData_DoneTurningOff:
|
|||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld d, a ; de has source of tile range copy
|
ld d, a ; de has source of tile range copy
|
||||||
push hl ; save the pointer to the next bit of card data (tile map)
|
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
|
||||||
|
|
||||||
ld h, d
|
ei
|
||||||
ld l, e ; hl takes the source
|
WaitForSafeCopy:
|
||||||
|
ld b, 140
|
||||||
ld de, $8000 ; always load tile data into the same spot in vram
|
call AwaitLine
|
||||||
|
ldh a, [vSafeCopyCount]
|
||||||
call CopyRangeSafe
|
ld b, a
|
||||||
|
ldh a, [vSafeCopyCount+1]
|
||||||
|
or a, b
|
||||||
|
jp nz, WaitForSafeCopy
|
||||||
|
di
|
||||||
|
|
||||||
pop hl
|
pop hl
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld c, a
|
ld c, a
|
||||||
@ -350,15 +363,24 @@ LoadCardData_DoneTurningOff:
|
|||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld d, a ; de has source of tile range copy
|
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 h, d
|
||||||
ld l, e ; hl takes the source
|
ld l, e ; hl takes the source
|
||||||
|
|
||||||
; push hl ; we don't need to keep track of hl at this point and our stack is clean.
|
ld de, $8000 ; always load tile data into the same spot in vram
|
||||||
ld hl, $9800 + 32 + 1 ; destination
|
call CopyRangeSafe
|
||||||
ld b, 16 ; height
|
|
||||||
ld c, 8 ; width
|
ei
|
||||||
call CopyTilesToMap
|
WaitForSafeCopy2:
|
||||||
|
ld b, 140
|
||||||
|
call AwaitLine
|
||||||
|
ldh a, [vSafeCopyCount]
|
||||||
|
ld b, a
|
||||||
|
ldh a, [vSafeCopyCount+1]
|
||||||
|
or a, b
|
||||||
|
jp nz, WaitForSafeCopy2
|
||||||
|
di
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -402,168 +424,16 @@ CopyRangeUnsafe:
|
|||||||
jp nz, CopyRangeUnsafe
|
jp nz, CopyRangeUnsafe
|
||||||
ret
|
ret
|
||||||
|
|
||||||
CopyRangeSafe:
|
INCLUDE "CopyRangeSafe.inc"
|
||||||
; hl is source
|
|
||||||
; de is destination
|
|
||||||
; bc is length to copy
|
|
||||||
; copy an array of bytes to a destination in memory.
|
|
||||||
; this is completely different from CopyRangeUnsafe.
|
|
||||||
; this initiates an asynchronous, interrupt-driven copy of BC bytes of memory
|
|
||||||
; from HL to DE.
|
|
||||||
; it may return a memory address to look at for progress of the transfer,
|
|
||||||
; or else it's just going to do it with a hard-coded address.
|
|
||||||
; check the transfer status address for zero; when it's zero, the transfer is done!
|
|
||||||
; this works by using the STAT interrupt in LYC mode to interrupt its own execution at
|
|
||||||
; two scanlines inside the vblank interval to know when to start and stop.
|
|
||||||
; stash arguments in memory
|
|
||||||
di
|
|
||||||
ld a, l
|
|
||||||
ldh [vSafeCopySource], a
|
|
||||||
ld a, h
|
|
||||||
ldh [vSafeCopySource+1], a
|
|
||||||
ld a, e
|
|
||||||
ldh [vSafeCopyDest], a
|
|
||||||
ld a, d
|
|
||||||
ldh [vSafeCopyDest+1], a
|
|
||||||
ld a, c
|
|
||||||
ldh [vSafeCopyCount], a
|
|
||||||
ld a, b
|
|
||||||
ldh [vSafeCopyCount+1], a
|
|
||||||
|
|
||||||
; stash interrupt state in memory
|
|
||||||
ldh a, [$ff41]
|
|
||||||
ldh [vSafeCopySTAT], a ; stashes $FF41, the STAT register
|
|
||||||
ldh a, [$ff45]
|
|
||||||
ldh [vSafeCopyLYC], a ; stashes $FF45, the LYC register
|
|
||||||
ld a, [INTERRUPT_LCD]
|
|
||||||
ld [vSafeCopyInterruptFirst], a
|
|
||||||
ld a, [INTERRUPT_LCD + 1]
|
|
||||||
ld [vSafeCopyInterruptSecond], a ; stashes $0048 the STAT interrupt handler
|
|
||||||
ld a, [$ffff]
|
|
||||||
and a, %0000_0010
|
|
||||||
ld [vSafeCopyInterruptEnable], a ; stashes whether LCD interrupt are enabled
|
|
||||||
|
|
||||||
ld a, 148 ; adjust this to change timing of copy
|
|
||||||
ld [$ff45], a
|
|
||||||
|
|
||||||
ld hl, CopyRangeSafe_EnterSafeMode
|
|
||||||
ld a, l
|
|
||||||
ld [INTERRUPT_LCD], a
|
|
||||||
ld a, h
|
|
||||||
ld [INTERRUPT_LCD + 1], a; set interrupt handler to "ENTER SAFE MODE"
|
|
||||||
ld a, 148 ; CHANGE ME TO ADJUST SAFE TRANSFER TIMING
|
|
||||||
ld [$ff45], a
|
|
||||||
ld hl, $ffff
|
|
||||||
set 1, [hl]
|
|
||||||
ld a, %0100_0000
|
|
||||||
ld [$ff41], a
|
|
||||||
|
|
||||||
ld hl, vSafeCopyCount
|
|
||||||
ei
|
|
||||||
ret ; return address of bytes remaining to copy
|
|
||||||
|
|
||||||
CopyRangeSafe_EnterSafeMode:
|
CopyTilesToMapUnsafe:
|
||||||
ld hl, CopyRangeSafe_ExitSafeMode
|
|
||||||
ld a, l
|
|
||||||
ld [INTERRUPT_LCD], a
|
|
||||||
ld a, h
|
|
||||||
ld [INTERRUPT_LCD+1], a
|
|
||||||
ld a, 153 ; CHANGE ME TO ADJUST SAFE TRANSFER TIMING
|
|
||||||
ld [$ff45], a ; set lcd interrupt handler to EXIT SAFE MODE on line 153
|
|
||||||
ldh a, [vSafeCopySource]
|
|
||||||
ld l, a
|
|
||||||
ldh a, [vSafeCopySource+1]
|
|
||||||
ld h, a ; fetch the source
|
|
||||||
ldh a, [vSafeCopyDest]
|
|
||||||
ld e, a
|
|
||||||
ldh a, [vSafeCopyDest+1]
|
|
||||||
ld d, a ; fetch the dest
|
|
||||||
ldh a, [vSafeCopyCount]
|
|
||||||
ld c, a
|
|
||||||
ldh a, [vSafeCopyCount+1]
|
|
||||||
ld b, a ; fetch the count
|
|
||||||
|
|
||||||
|
|
||||||
; before starting transfer, make sure the zero flag is false.
|
|
||||||
ld a, 1
|
|
||||||
cp a, 0
|
|
||||||
CopyRangeSafe_TransferLoop:
|
|
||||||
ei
|
|
||||||
nop ; ei only sets the flag one instruction later apparently. safety nop!
|
|
||||||
nop
|
|
||||||
di ; process interrupts
|
|
||||||
jp z, CopyRangeSafe_CleanUp ; zero flag will only be set if the exitsafemode handler fired
|
|
||||||
ld a, [hl+]
|
|
||||||
ld [de], a ;
|
|
||||||
inc de
|
|
||||||
dec bc
|
|
||||||
ld a, b
|
|
||||||
or a, c
|
|
||||||
jp nz, CopyRangeSafe_TransferLoop
|
|
||||||
jp CopyRangeSafe_Done
|
|
||||||
|
|
||||||
CopyRangeSafe_ExitSafeMode:
|
|
||||||
ld a, 0
|
|
||||||
cp a, 0 ; set the zero flag, which we're using as a signal to stop transferring
|
|
||||||
reti ; set a to zero and set the zero flag true. now the transfer loop will end
|
|
||||||
|
|
||||||
CopyRangeSafe_CleanUp:
|
|
||||||
ld a, l
|
|
||||||
ldh [vSafeCopySource], a
|
|
||||||
ld a, h
|
|
||||||
ldh [vSafeCopySource+1], a ; store new source
|
|
||||||
ld a, e
|
|
||||||
ldh [vSafeCopyDest], a
|
|
||||||
ld a, d
|
|
||||||
ldh [vSafeCopyDest+1], a ; store new dest
|
|
||||||
ld a, c
|
|
||||||
ldh [vSafeCopyCount], a
|
|
||||||
ld a, b
|
|
||||||
ldh [vSafeCopyCount+1], a ; store new count
|
|
||||||
|
|
||||||
ld hl, CopyRangeSafe_EnterSafeMode
|
|
||||||
ld a, l
|
|
||||||
ld [INTERRUPT_LCD], a
|
|
||||||
ld a, h
|
|
||||||
ld [INTERRUPT_LCD+1], a
|
|
||||||
ld a, 148 ; CHANGE ME TO ADJUST SAFE TRANSFER TIMING
|
|
||||||
ld [$ff45], a ; set lcd interrupt handler to ENTER SAFE MODE on line 148
|
|
||||||
reti ; we're done with this memcpy cycle so we return from interrupt.
|
|
||||||
|
|
||||||
CopyRangeSafe_Done: ; called when the complete transfer is finished,
|
|
||||||
; this restores interrupts to how they were.
|
|
||||||
; stash interrupt state in memory
|
|
||||||
ldh a, [vSafeCopySTAT]
|
|
||||||
ldh [$ff41], a
|
|
||||||
ldh a, [vSafeCopyLYC]
|
|
||||||
ldh [$ff45], a
|
|
||||||
ldh a, [vSafeCopyInterruptFirst]
|
|
||||||
ld [INTERRUPT_LCD], a
|
|
||||||
ldh a, [vSafeCopyInterruptSecond]
|
|
||||||
ldh [INTERRUPT_LCD+1], a
|
|
||||||
|
|
||||||
ld hl, $ffff
|
|
||||||
ld a, [hl]
|
|
||||||
cpl
|
|
||||||
set 1, a
|
|
||||||
cpl ; turn off the lcd interrupt enable
|
|
||||||
ld [hl], a
|
|
||||||
|
|
||||||
ld a, [vSafeCopyInterruptEnable]
|
|
||||||
cp a, 0 ; if the stashed enable was 0 return. if the stashed enable was 1 then turn it on
|
|
||||||
jp z, CopyRangeSafe_Return
|
|
||||||
set 1, [hl] ; turn on the lcd interrupt
|
|
||||||
CopyRangeSafe_Return:
|
|
||||||
ret
|
|
||||||
|
|
||||||
CopyTilesToMap:
|
|
||||||
; copy tiles from where they are linearly packed at an origin (de)
|
; copy tiles from where they are linearly packed at an origin (de)
|
||||||
; to a rectangle in the tilemap in vram (hl)
|
; to a rectangle in the tilemap in vram (hl)
|
||||||
; assuming it has height in b and width in c.
|
; assuming it has height in b and width in c.
|
||||||
push bc
|
push bc
|
||||||
CopyTile:
|
CopyTile:
|
||||||
ld a, [de] ; load from the tile map into a
|
ld a, [hl] ; load from the tile map into a
|
||||||
ld [hl], a ; load from a into the destination
|
ld [de], a ; load from a into the destination
|
||||||
inc hl ; this is slower than using hli but i'm trying to work with this here
|
inc hl ; this is slower than using hli but i'm trying to work with this here
|
||||||
inc de
|
inc de
|
||||||
dec c
|
dec c
|
||||||
@ -574,22 +444,27 @@ CopyTile:
|
|||||||
DoneWithLine:
|
DoneWithLine:
|
||||||
pop bc
|
pop bc
|
||||||
|
|
||||||
ld a, l
|
ld a, e
|
||||||
add a, 32
|
add a, 32
|
||||||
ld l, a
|
ld e, a
|
||||||
ld a, h
|
ld a, d
|
||||||
adc a, 0
|
adc a, 0
|
||||||
ld h, a
|
ld d, a
|
||||||
ld a, l
|
ld a, e
|
||||||
sub a, c
|
sub a, c
|
||||||
ld l, a
|
ld e, a
|
||||||
ld a, h
|
ld a, d
|
||||||
sbc a, 0
|
sbc a, 0
|
||||||
ld h, a
|
ld d, a
|
||||||
|
|
||||||
dec b
|
dec b
|
||||||
jp nz, CopyTilesToMap
|
ld a, b
|
||||||
|
cp a, 0
|
||||||
|
jp nz, CopyTilesToMapUnsafe
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
INCLUDE "CopyTilesSafe.inc"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Card Data", ROM0
|
SECTION "Card Data", ROM0
|
||||||
|
|
||||||
@ -610,10 +485,10 @@ TheFool:
|
|||||||
db 9, "-begin "
|
db 9, "-begin "
|
||||||
db 9, "-leap "
|
db 9, "-leap "
|
||||||
db 9, "-naivete "
|
db 9, "-naivete "
|
||||||
dw FoolTilesEnd - FoolTiles
|
|
||||||
dw FoolTiles
|
|
||||||
dw FoolMapEnd - FoolMap
|
dw FoolMapEnd - FoolMap
|
||||||
dw FoolMap
|
dw FoolMap
|
||||||
|
dw FoolTilesEnd - FoolTiles
|
||||||
|
dw FoolTiles
|
||||||
FoolTiles:
|
FoolTiles:
|
||||||
db $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
|
||||||
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$01,$00,$02
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$01,$00,$02
|
||||||
@ -710,10 +585,10 @@ TheMagician:
|
|||||||
db 9, "-capacity"
|
db 9, "-capacity"
|
||||||
db 9, "-knowing "
|
db 9, "-knowing "
|
||||||
db 9, "-manifest"
|
db 9, "-manifest"
|
||||||
dw MagicianTilesEnd - MagicianTiles
|
|
||||||
dw MagicianTiles
|
|
||||||
dw MagicianMapEnd - MagicianMap
|
dw MagicianMapEnd - MagicianMap
|
||||||
dw MagicianMap
|
dw MagicianMap
|
||||||
|
dw MagicianTilesEnd - MagicianTiles
|
||||||
|
dw MagicianTiles
|
||||||
|
|
||||||
MagicianTiles:
|
MagicianTiles:
|
||||||
db $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
|
||||||
|
BIN
thehighpriestess.aseprite
Normal file
BIN
thehighpriestess.aseprite
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user