fixed some bugs on the spread select screen and unified style some

This commit is contained in:
Shoofle 2025-01-14 23:48:23 -05:00
parent 0b04436b3d
commit e29a7d47e4
9 changed files with 248 additions and 160 deletions

View File

@ -8,7 +8,7 @@ def vAsyncAfter equ $ff8c
def vAsyncProgress equ $ff8e def vAsyncProgress equ $ff8e
def SAFE_ASYNC_START EQU 146 def SAFE_ASYNC_START EQU 146
def SAFE_ASYNC_END EQU 151 def SAFE_ASYNC_END EQU 153
DoInAsyncVBlank: DoInAsyncVBlank:
di di

View File

@ -4,24 +4,24 @@ Spreads:
db 5 ; length db 5 ; length
.nospread .nospread
db 0 db 0
db 20, " Nothing " db 18, " Nothing "
db 20, " This is no spread. " db 18, "This is no spread."
.onecard .onecard
db 1, $21 db 1, $21
db 20, " One Card Spread " db 18, " One Card Spread "
db 20, " Draw a single card." db 18, " Draw one card. "
.tencard .tencard
db 10, $00, $10, $20, $30, $40, $02, $12, $22, $32, $42 db 10, $00, $10, $20, $30, $40, $02, $12, $22, $32, $42
db 20, " Ten Card Spread " db 18, " Ten Card Spread "
db 20, "Throw more cards on." db 18, " More cards! "
.fivecard .fivecard
db 5, $11, $20, $22, $31, $41 db 5, $11, $20, $22, $31, $41
db 20, " Horizontal Cross " db 18, " Horizontal Cross "
db 20, " A little spicy. " db 18, " A little spicy. "
.threecard .threecard
db 3, $01, $21, $41 db 3, $01, $21, $41
db 20, " Three Card Spread " db 18, "Three Card Spread "
db 20, " Old reliable. " db 18, " Old reliable. "
.end .end
Cards: Cards:

View File

@ -253,4 +253,6 @@ CopyRangeUnsafeBy8s:
ld a, b ld a, b
or a, c ; check if bc is zero or a, c ; check if bc is zero
jp nz, CopyRangeUnsafeBy8s jp nz, CopyRangeUnsafeBy8s
nop
nop
ret ret

View File

@ -287,4 +287,8 @@ CopyTilesToMapThreadsafe:
ld a, b ld a, b
cp a, 0 cp a, 0
jp nz, CopyTilesToMapThreadsafe jp nz, CopyTilesToMapThreadsafe
ei
nop
nop
ret ret

View File

@ -31,65 +31,65 @@ MainMenuSetup_ScreenOff:
ld a, 0 ld a, 0
ldh [rLCDC], a ldh [rLCDC], a
ld hl, MainMenuUITiles
ld de, $8000
ld bc, (MainMenuUITilesEnd - MainMenuUITiles)
call CopyRangeUnsafe
ld hl, SquaresTileset8 ld hl, SquaresTileset8
ld de, $8010 ld de, $8010
ld bc, (SquaresTilesetEnd - SquaresTileset8) ld bc, (SquaresTilesetEnd - SquaresTileset8)
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, MainMenuUITiles
ld de, $8000 + 152*16
ld bc, (MainMenuUITilesEnd - MainMenuUITiles)
call CopyRangeUnsafe
ld hl, CardBackSprites24 ; source ld hl, CardBackSprites24 ; source
def TileStartCardBackSprites24 equ $6 def TileStartCardBackSprites24 equ $a
ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy
ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites23 ld hl, CardBackSprites23
def TileStartCardBackSprites23 equ $18 def TileStartCardBackSprites23 equ $1c
ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy
ld bc, CardBackSprites23End - CardBackSprites23 ld bc, CardBackSprites23End - CardBackSprites23
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites22 ld hl, CardBackSprites22
def TileStartCardBackSprites22 equ $2a def TileStartCardBackSprites22 equ $2e
ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy
ld bc, CardBackSprites22End - CardBackSprites22 ld bc, CardBackSprites22End - CardBackSprites22
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites21 ld hl, CardBackSprites21
def TileStartCardBackSprites21 equ $3c def TileStartCardBackSprites21 equ $40
ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy
ld bc, CardBackSprites21End - CardBackSprites21 ld bc, CardBackSprites21End - CardBackSprites21
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites20 ld hl, CardBackSprites20
def TileStartCardBackSprites20 equ $4e def TileStartCardBackSprites20 equ $52
ld de, $8000 + TileStartCardBackSprites20*$10 ld de, $8000 + TileStartCardBackSprites20*$10
ld bc, CardBackSprites20End - CardBackSprites20 ld bc, CardBackSprites20End - CardBackSprites20
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites19 ld hl, CardBackSprites19
def TileStartCardBackSprites19 equ $60 def TileStartCardBackSprites19 equ $64
ld de, $8000 + TileStartCardBackSprites19*$10 ld de, $8000 + TileStartCardBackSprites19*$10
ld bc, CardBackSprites19End - CardBackSprites19 ld bc, CardBackSprites19End - CardBackSprites19
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites18 ld hl, CardBackSprites18
def TileStartCardBackSprites18 equ $72 def TileStartCardBackSprites18 equ $76
ld de, $8000 + TileStartCardBackSprites18*$10 ld de, $8000 + TileStartCardBackSprites18*$10
ld bc, CardBackSprites18End - CardBackSprites18 ld bc, CardBackSprites18End - CardBackSprites18
call CopyRangeUnsafe call CopyRangeUnsafe
ld hl, CardBackSprites17 ld hl, CardBackSprites17
def TileStartCardBackSprites17 equ $84 def TileStartCardBackSprites17 equ $88
ld de, $8000 + TileStartCardBackSprites17*$10 ld de, $8000 + TileStartCardBackSprites17*$10
ld bc, CardBackSprites17End - CardBackSprites17 ld bc, CardBackSprites17End - CardBackSprites17
call CopyRangeUnsafe call CopyRangeUnsafe
def TileStartCardBackSprites16 equ $90 def TileStartCardBackSprites16 equ $9a
ld hl, SquaresTilemap ld hl, SquaresTilemap
ld de, $9800 ld de, $9800
@ -962,64 +962,34 @@ SquaresTiles:
dw SquaresTileset8 dw SquaresTileset8
SquaresTileset1: SquaresTileset1:
db $20,$00,$00,$00,$02,$00,$00,$00,$80,$00,$00,$00,$08,$00,$00,$00
db $aa,$00,$00,$00,$82,$00,$00,$00,$82,$00,$00,$00,$aa,$00,$00,$00
db $28,$00,$00,$00,$82,$00,$00,$00,$82,$00,$00,$00,$28,$00,$00,$00
db $ba,$00,$00,$00,$82,$00,$82,$00,$82,$00,$00,$00,$ba,$00,$00,$00
db $fe,$00,$82,$00,$82,$00,$82,$00,$82,$00,$82,$00,$fe,$00,$00,$00 db $fe,$00,$82,$00,$82,$00,$82,$00,$82,$00,$82,$00,$fe,$00,$00,$00
SquaresTileset2: SquaresTileset2:
db $00,$00,$10,$00,$00,$00,$01,$00,$00,$00,$40,$00,$00,$00,$04,$00
db $00,$00,$14,$00,$00,$00,$41,$00,$00,$00,$41,$00,$00,$00,$14,$00
db $00,$00,$55,$00,$00,$00,$41,$00,$00,$00,$41,$00,$00,$00,$55,$00
db $00,$00,$5d,$00,$00,$00,$41,$00,$41,$00,$41,$00,$00,$00,$5d,$00
db $00,$00,$7f,$00,$41,$00,$41,$00,$41,$00,$41,$00,$41,$00,$7f,$00 db $00,$00,$7f,$00,$41,$00,$41,$00,$41,$00,$41,$00,$41,$00,$7f,$00
SquaresTileset3: SquaresTileset3:
db $02,$00,$00,$00,$08,$00,$00,$00,$80,$00,$00,$00,$20,$00,$00,$00
db $0a,$00,$00,$00,$0a,$00,$00,$00,$a0,$00,$00,$00,$a0,$00,$00,$00
db $aa,$00,$00,$00,$aa,$00,$00,$00,$a0,$00,$00,$00,$a0,$00,$00,$00
db $ae,$00,$00,$00,$ae,$00,$00,$00,$a0,$00,$a0,$00,$a0,$00,$00,$00
db $bf,$00,$00,$00,$bf,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00 db $bf,$00,$00,$00,$bf,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00
SquaresTileset4: SquaresTileset4:
db $00,$00,$01,$00,$00,$00,$04,$00,$00,$00,$40,$00,$00,$00,$10,$00
db $00,$00,$05,$00,$00,$00,$05,$00,$00,$00,$50,$00,$00,$00,$50,$00
db $00,$00,$55,$00,$00,$00,$55,$00,$00,$00,$50,$00,$00,$00,$50,$00
db $00,$00,$57,$00,$00,$00,$57,$00,$00,$00,$50,$00,$50,$00,$50,$00
db $50,$00,$df,$00,$00,$00,$df,$00,$50,$00,$50,$00,$50,$00,$50,$00 db $50,$00,$df,$00,$00,$00,$df,$00,$50,$00,$50,$00,$50,$00,$50,$00
SquaresTileset5: SquaresTileset5:
db $08,$00,$00,$00,$80,$00,$00,$00,$02,$00,$00,$00,$20,$00,$00,$00
db $28,$00,$00,$00,$82,$00,$00,$00,$82,$00,$00,$00,$28,$00,$00,$00
db $28,$00,$00,$00,$aa,$00,$00,$00,$aa,$00,$00,$00,$28,$00,$00,$00
db $28,$00,$00,$00,$ab,$00,$00,$00,$ab,$00,$00,$00,$28,$00,$28,$00
db $28,$00,$28,$00,$ef,$00,$00,$00,$ef,$00,$28,$00,$28,$00,$28,$00 db $28,$00,$28,$00,$ef,$00,$00,$00,$ef,$00,$28,$00,$28,$00,$28,$00
SquaresTileset6: SquaresTileset6:
db $00,$00,$04,$00,$00,$00,$40,$00,$00,$00,$01,$00,$00,$00,$10,$00
db $00,$00,$14,$00,$00,$00,$41,$00,$00,$00,$41,$00,$00,$00,$14,$00
db $00,$00,$14,$00,$00,$00,$55,$00,$00,$00,$55,$00,$00,$00,$14,$00
db $14,$00,$14,$00,$00,$00,$d5,$00,$00,$00,$d5,$00,$00,$00,$14,$00
db $14,$00,$14,$00,$14,$00,$f7,$00,$00,$00,$f7,$00,$14,$00,$14,$00 db $14,$00,$14,$00,$14,$00,$f7,$00,$00,$00,$f7,$00,$14,$00,$14,$00
SquaresTileset7: SquaresTileset7:
db $08,$00,$00,$00,$02,$00,$00,$00,$20,$00,$00,$00,$80,$00,$00,$00
db $0a,$00,$00,$00,$0a,$00,$00,$00,$a0,$00,$00,$00,$a0,$00,$00,$00
db $0a,$00,$00,$00,$0a,$00,$00,$00,$aa,$00,$00,$00,$aa,$00,$00,$00
db $0a,$00,$0a,$00,$0a,$00,$00,$00,$ea,$00,$00,$00,$ea,$00,$00,$00
db $0a,$00,$0a,$00,$0a,$00,$0a,$00,$fb,$00,$00,$00,$fb,$00,$0a,$00 db $0a,$00,$0a,$00,$0a,$00,$0a,$00,$fb,$00,$00,$00,$fb,$00,$0a,$00
SquaresTileset8: SquaresTileset8:
db $00,$00,$04,$00,$00,$00,$01,$00,$00,$00,$10,$00,$00,$00,$40,$00
db $00,$00,$05,$00,$00,$00,$05,$00,$00,$00,$50,$00,$00,$00,$50,$00
db $00,$00,$05,$00,$00,$00,$05,$00,$00,$00,$55,$00,$00,$00,$55,$00
db $00,$00,$05,$00,$05,$00,$05,$00,$00,$00,$75,$00,$00,$00,$75,$00
db $05,$00,$05,$00,$05,$00,$05,$00,$05,$00,$fd,$00,$00,$00,$fd,$00 db $05,$00,$05,$00,$05,$00,$05,$00,$05,$00,$fd,$00,$00,$00,$fd,$00
SquaresTilesetEnd: SquaresTilesetEnd:
MainMenuUITiles: 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 $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 $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 $0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17,$0e,$17
@ -1031,23 +1001,23 @@ MainMenuUITiles:
MainMenuUITilesEnd: MainMenuUITilesEnd:
SquaresTilemap: SquaresTilemap:
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $05, $05, $9f, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $9e, $05, $05 db $01, $01, $09, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $08, $01, $01
db $05, $05, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $05, $05 db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
db $05, $05, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $05, $05 db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
db $05, $05, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $05, $05 db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
db $05, $05, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $05, $05 db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
db $05, $05, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $05, $05 db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
db $05, $05, $9c, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9d, $05, $05 db $01, $01, $06, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $07, $01, $01
db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
SquaresTilemapEnd: SquaresTilemapEnd:

View File

@ -14,7 +14,9 @@ SpreadSelectSetup:
ldh [vPreviousSpreadIndex], a ldh [vPreviousSpreadIndex], a
ldh [vSelectedSpreadIndex], a ldh [vSelectedSpreadIndex], a
ld hl, ZEROES call UpdateCurrentSpread
ld hl, SpreadSelectTilemap
ld de, $9800 ld de, $9800
ld b, 18 ld b, 18
ld c, 20 ld c, 20
@ -29,9 +31,6 @@ SpreadSelectSetup:
ld [vAsyncAfter+1], a ld [vAsyncAfter+1], a
call DoInAsyncVBlank call DoInAsyncVBlank
ld a, HIGH(ZEROES)
ld de, $ffc0
call RunDMA
ret ret
.loadUITiles .loadUITiles
@ -43,10 +42,26 @@ SpreadSelectSetup:
ld [vAsyncNext], a ld [vAsyncNext], a
ld a, HIGH(CopyRangeUnsafe) ld a, HIGH(CopyRangeUnsafe)
ld [vAsyncNext+1], a 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 a, LOW(DrawSpreadAsync)
ld [vAsyncAfter], a ld [vAsyncAfter], a
ld a, HIGH(DrawSpreadAsync) ld a, HIGH(DrawSpreadAsync)
ld [vAsyncAfter+1], a ld [vAsyncAfter+1], a
ld a, HIGH(ZEROES)
ld de, $ffc0 ; arguments to the first following async call
ret ret
SpreadSelectUpdate: SpreadSelectUpdate:
@ -71,10 +86,41 @@ SpreadSelectUpdate:
call ArrayClampLooping call ArrayClampLooping
ldh [vSelectedSpreadIndex], a ; load current selected tile index ldh [vSelectedSpreadIndex], a ; load current selected tile index
ld hl, vTime
ldh a, [rDELTAT]
ld b, a
ldh a, [vTime]
add a, b
ldh [vTime], a
ldh a, [vTime+1]
adc a, 0
ldh [vTime+1], a ; increment time. when the 16bit time register is greater
; than 4096 ($10_00) then one second has passed. so that's satisfied when
; vTime+1 is equal to or greater than $10
ldh a, [vTime+1]
cp a, $01
jp c, .doneUpdate ; if the timer is less than $0100, skip to end
;otherwise reset the timer
ld a, 0
ldh [vTime], a
ldh [vTime+1], a
ld hl, SquaresTiles
ldh a, [vFrameCountSquares]
inc a
call ArrayClampLooping
ldh [vFrameCountSquares], a
ldh a, [vSelectedSpreadIndex]
ld hl, vPreviousSpreadIndex ld hl, vPreviousSpreadIndex
cp a, [hl] cp a, [hl]
ret z ; we're done if previous index is same as new index ret z ; we're done if previous index is same as new index
call UpdateCurrentSpread
; execute an async call to DrawSpreadAsync. ; execute an async call to DrawSpreadAsync.
ld a, LOW(DrawSpreadAsync) ld a, LOW(DrawSpreadAsync)
ld [vAsyncNext], a ld [vAsyncNext], a
@ -82,12 +128,11 @@ SpreadSelectUpdate:
ld [vAsyncNext+1], a ld [vAsyncNext+1], a
call DoInAsyncVBlank call DoInAsyncVBlank
.doneUpdate
ret ; return from main thread. go back to looping. ret ; return from main thread. go back to looping.
DrawSpreadAsync: UpdateCurrentSpread:
ldh a, [vSelectedSpreadIndex]
ldh [vPreviousSpreadIndex], a
; find the correct spread address ; find the correct spread address
ld hl, Spreads ld hl, Spreads
inc hl ; skip length of spreads inc hl ; skip length of spreads
@ -116,9 +161,14 @@ DrawSpreadAsync:
ld [vCurrentSpread], a ld [vCurrentSpread], a
ld a, h ld a, h
ld [vCurrentSpread+1], a ; save the current spread (hl) into vcurrentspread. ld [vCurrentSpread+1], a ; save the current spread (hl) into vcurrentspread.
ret
ld de, $9800 + 32*4 + 3 DrawSpreadAsync:
ld hl, ZEROES ldh a, [vSelectedSpreadIndex]
ldh [vPreviousSpreadIndex], a
ld de, $9800 + 32*5 + 5
ld hl, ONES
ld b, 8 ld b, 8
ld c, 10 ld c, 10
@ -143,7 +193,7 @@ DrawSpreadAsync:
ld e, [hl] ld e, [hl]
inc e inc e
add hl, de add hl, de
ld de, $9800 + 32 ld de, $9800 + 32 + 1
ld a, LOW(PrintString) ld a, LOW(PrintString)
ld [vAsyncNext], a ld [vAsyncNext], a
ld a, HIGH(PrintString) ld a, HIGH(PrintString)
@ -155,7 +205,7 @@ DrawSpreadAsync:
ret ret
.afterTitle .afterTitle
ld de, $9800 + (32*2) ld de, $9800 + (32*2) + 1
ld a, LOW(PrintString) ld a, LOW(PrintString)
ld [vAsyncNext], a ld [vAsyncNext], a
ld a, HIGH(PrintString) ld a, HIGH(PrintString)
@ -168,7 +218,7 @@ DrawSpreadAsync:
.afterDescription .afterDescription
ld hl, $9800 + 32*4 + 3 ld hl, $9800 + 32*5 + 5
ldh a, [vSelectedSpreadCard] ldh a, [vSelectedSpreadCard]
ld e, a ; e contains the selected index ld e, a ; e contains the selected index
@ -192,7 +242,67 @@ DrawSpreadAsync:
ret ret
SpreadSelectDraw: SpreadSelectDraw:
ret di
ld hl, SquaresTiles + 1
ld b, 0
ldh a, [vFrameCountSquares]
ld c, a
add hl, bc
add hl, bc
ld c, [hl]
inc hl
ld b, [hl]
ld h, b
ld l, c
ld de, $8010
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
inc de
ld a, [hl+]
ld [de], a
reti
SpreadSelectTeardown: SpreadSelectTeardown:
ret ret
@ -207,12 +317,13 @@ DrawSpreadBigAndThreadsafe:
ld b, a ld b, a
ld a, [bc] ld a, [bc]
cp a, 0 ; length of spread cp a, 0 ; length of spread
ret z ; return early if the spread is empty jp z, .doneDrawingSpread ; return early if the spread is empty
ld d, a ; length of spread in d ld d, a ; length of spread in d
inc d inc d
.drawCards .drawCards
ei ei
nop nop
nop
di di
dec d dec d
jp z, .doneWithSpread ; if we're drawing zero remaining cards, stop drawing jp z, .doneWithSpread ; if we're drawing zero remaining cards, stop drawing
@ -245,49 +356,14 @@ DrawSpreadBigAndThreadsafe:
ei ei
nop nop
di di
nop
nop
call DrawBigCardSelected call DrawBigCardSelected
.doneDrawingSpread
ei ei
ret nop
nop
DrawSpreadBig:
; hl for location on screen
; bc for current spread address
; e for index of selected card
ld a, [bc]
cp a, 0 ; length of spread
ret z ; return early if the spread is empty
push bc
ld d, a ; length of spread in d
inc d
.drawCards
dec d
jp z, .doneWithSpread ; if we're drawing zero remaining cards, stop drawing
inc bc ; step forward
push hl ; need this bc drawsmallcard changes hl
ld a, [bc]
call DrawBigCard
pop hl
jp .drawCards
.doneWithSpread
; stack has spread address
; d is zero
; e should have currently selected index
ld b, h
ld c, l ; stash hl in bc for a mo; this should be a location in vram
pop hl ; put bc from stack into hl, this is the spread address
inc e ; skip the tiles length
add hl, de
ld a, [hl]
ld h, b
ld l, c; retrieve
;call DrawBigCardSelected
ret ret
DrawBigCard: ; starting from screen location hl, draw a card at DrawBigCard: ; starting from screen location hl, draw a card at
@ -314,19 +390,19 @@ DrawBigCard: ; starting from screen location hl, draw a card at
jp nz, .stepDown jp nz, .stepDown
.drawCard .drawCard
ld de, 32 ld de, 32
ld [hl], $12 ld [hl], $a
inc hl inc hl
ld [hl], $1e ld [hl], $e
add hl, de add hl, de
ld [hl], $1f ld [hl], $f
dec hl dec hl
ld [hl], $13 ld [hl], $b
add hl, de add hl, de
ld [hl], $13 ld [hl], $b
inc hl inc hl
ld [hl], $1f ld [hl], $f
add hl, de add hl, de
ld [hl], $23 ld [hl], $1b
dec hl dec hl
ld [hl], $17 ld [hl], $17
@ -445,3 +521,24 @@ DrawSmallCard: ; starting from screen location hl, draw a card at
pop de pop de
ret ret
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
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
SpreadSelectTilemapEnd:

View File

@ -11,6 +11,7 @@ DEF SCENE_TEARDOWN EQU SCENE_DRAW + 4
DEF INTERRUPT_LCD EQU $c111 DEF INTERRUPT_LCD EQU $c111
def ZEROES equ $D000 def ZEROES equ $D000
def ONES equ $D200
DEF rMYBTN EQU $FFA8 DEF rMYBTN EQU $FFA8
DEF rMYBTNP EQU rMYBTN + 1 DEF rMYBTNP EQU rMYBTN + 1
@ -46,6 +47,18 @@ EntryPoint:
dec bc dec bc
jp nz, .buildZeros jp nz, .buildZeros
ld a, 1
ld hl, ONES
ld bc, $200
.buildOnes
ld a, 1
ld [hl+], a
ld a, b
or a, c
dec bc
jp nz, .buildOnes
; set up the scene and interrupt vectors ; set up the scene and interrupt vectors
ld hl, Instructions ld hl, Instructions
@ -171,7 +184,7 @@ Loop:
; either way it's going to eat into the update timing ; either way it's going to eat into the update timing
; at this point we want to make sure that scanline 153 has passed ; at this point we want to make sure that scanline 153 has passed
; we should check if we're past there and skip this await if necessary ; we should check if we're past there and skip this await if necessary
ld b, 5 ld b, 10
call AwaitLine call AwaitLine
jp Loop jp Loop
@ -240,6 +253,7 @@ PrintBChars: ;write ascii characters. will not respect newlines or anything like
; a should be the high byte of where we're DMAing from (ld a, $c0 in my case probably) ; a should be the high byte of where we're DMAing from (ld a, $c0 in my case probably)
; de should have the address in hram for where to paste to ; de should have the address in hram for where to paste to
RunDMA: RunDMA:
di
push de push de
push af push af
ld hl, run_dma_tail ld hl, run_dma_tail
@ -255,6 +269,7 @@ run_dma_tail: ; This part must be in HRAM.
.wait .wait
dec b dec b
jr nz, .wait jr nz, .wait
ei
ret z ; Conditional `ret` is 1 M-cycle slower, which avoids ret z ; Conditional `ret` is 1 M-cycle slower, which avoids
; reading from the stack on the last M-cycle of DMA. ; reading from the stack on the last M-cycle of DMA.
.run_dma_tail_end .run_dma_tail_end

Binary file not shown.

View File

@ -17,21 +17,21 @@ tileset:
BackgroundCopyCopy: BackgroundCopyCopy:
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $09, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $08
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $06, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $07
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $9f, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $98, $9e, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $99, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $96, $9a, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $9c, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9b, $9d, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
db $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97, $97 db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01