305 lines
7.4 KiB
PHP
305 lines
7.4 KiB
PHP
; screen variables shared with screencardread
|
|
PUSHS UNION "Screen Variables", WRAM0[SCREEN_VARS_START]
|
|
ds 32 ; why are we putting this so far in? i don't remember but whatever
|
|
vPrintJobState: db ; start, wait til ready, top row, row a, wait, printing, bottom row
|
|
vPrintingRow: db
|
|
vExposureSetting: db
|
|
POPS
|
|
|
|
ScreenCardBrowse:
|
|
dw CardBrowseSetup
|
|
dw CardBrowseUpdate
|
|
dw CardBrowseDraw
|
|
dw CardBrowseTeardown
|
|
|
|
CardBrowseSetup:
|
|
ld a, 1
|
|
ld [vBlocked], a
|
|
ld [vTooBusyForPrinter], a
|
|
|
|
; make sure working oam is clear
|
|
ld hl, ZEROES
|
|
ld de, MY_OAM
|
|
ld bc, $100
|
|
call CopyRange
|
|
|
|
ld hl, .asyncTask
|
|
call Async_Spawn_HL
|
|
|
|
call CheckForPrinter
|
|
ret
|
|
|
|
.asyncTask:
|
|
ld hl, CardBrowse.UITilemap ; origin
|
|
ld de, _SCRN0 ; destination
|
|
ld b, 18 ; height
|
|
ld c, 20 ; width
|
|
call CopyTilesToMap
|
|
|
|
ld hl, CardBrowse.PrinterTiles
|
|
ld de, _VRAM + $1000 - $10*16
|
|
ld bc, CardBrowse.PrinterTilesEnd - CardBrowse.PrinterTiles
|
|
call CopyRange
|
|
|
|
ld a, 0
|
|
ld [vBlocked], a
|
|
|
|
call RefreshCardTask
|
|
|
|
ret
|
|
|
|
CardBrowseUpdate:
|
|
ld a, [vPrinterStart]
|
|
cp a, 0
|
|
call z, CardUpdate
|
|
|
|
call ScrollBackgroundTile
|
|
|
|
ld a, [vTooBusyForPrinter]
|
|
cp a, 0
|
|
jp nz, .donePrinter
|
|
|
|
.checkForPrinter
|
|
ld a, [vPrinterStart]
|
|
cp a, 0
|
|
call z, CheckForPrinter
|
|
.updatePrintUI
|
|
ld a, [vPrinterStart]
|
|
cp a, 0
|
|
call z, CardBrowse.UpdatePrintUI
|
|
.runPrintJob
|
|
ld a, [vPrinterStart]
|
|
cp a, 0
|
|
call nz, RunPrintJob
|
|
|
|
.printButton
|
|
ld hl, rMYBTNP
|
|
bit 6, [hl] ; check select?
|
|
jp z, .donePrinter
|
|
|
|
ld a, [vPrinterState]
|
|
cp a, PS_READY
|
|
jp nz, .donePrinter
|
|
|
|
call KickOffPrintJob
|
|
ret
|
|
.donePrinter
|
|
|
|
ld hl, rMYBTNP
|
|
bit 5, [hl]
|
|
jp z, .doneWithB
|
|
ld hl, ScreenMainMenu
|
|
call ChangeScene
|
|
ret
|
|
.doneWithB
|
|
|
|
ld a, [vSelectedCardIndex]
|
|
ld hl, rMYBTNP
|
|
bit 0, [hl]
|
|
jp z, :+ ; skip the following code if left is not pressed
|
|
inc a
|
|
:
|
|
bit 1, [hl]
|
|
jp z, :+ ; skip the following code if right is not pressed
|
|
dec a
|
|
:
|
|
ld [vSelectedCardIndex], a
|
|
ld hl, Cards
|
|
call ArrayClampLooping
|
|
ld [vSelectedCardIndex], a
|
|
|
|
ld a, [vSelectedCardIndex]
|
|
ld hl, vPreviousCardIndex
|
|
cp a, [hl]
|
|
ret z ; if the selected card diddn't change, nothing to do
|
|
|
|
ld a, [vBlocked]
|
|
cp a, 0
|
|
ret nz
|
|
|
|
ld a, 1
|
|
ld [vTooBusyForPrinter], a
|
|
ld hl, RefreshCardTask
|
|
call Async_Spawn_HL
|
|
|
|
; make sure working oam is clear
|
|
ld hl, ZEROES
|
|
ld de, MY_OAM
|
|
ld bc, $100
|
|
call CopyRange
|
|
|
|
ret
|
|
|
|
|
|
CardBrowseDraw:
|
|
ld a, [vCurrentBackgroundTile]
|
|
ld l, a
|
|
ld a, [vCurrentBackgroundTile+1]
|
|
ld h, a
|
|
ld de, _VRAM + $1000 + 1*16
|
|
call CopyOneTileData
|
|
|
|
call CardDraw
|
|
|
|
ld de, SAFE_DMA_LOCATION
|
|
ld a, HIGH(MY_OAM)
|
|
call RunDMA
|
|
|
|
ret
|
|
|
|
|
|
|
|
RefreshCardTask:
|
|
ld a, [vSelectedCardIndex]
|
|
ld [vPreviousCardIndex], a
|
|
|
|
call DrawDeckMinimap
|
|
call LoadCardData
|
|
call CardBrowse.UpdatePrintUIImmediate
|
|
|
|
ld a, 0
|
|
ld [vTooBusyForPrinter], a
|
|
ret
|
|
|
|
DrawDeckMinimap:
|
|
ld hl, Cards
|
|
ld c, [hl] ; count of cards
|
|
srl c
|
|
set 0, c
|
|
|
|
ld hl, vSelectedCardIndex
|
|
ld d, [hl] ; selected card!
|
|
ld b, $ff ; start at -1 lol
|
|
ld hl, _SCRN0 + 32 + 11
|
|
|
|
.loop
|
|
inc b
|
|
ld a, b
|
|
cp a, 5
|
|
jp nz, .noNewLine
|
|
ld [hl], $13
|
|
ld hl, _SCRN0 + 32*2 + 11
|
|
.noNewLine
|
|
ld a, b
|
|
cp a, c
|
|
jp nc, .doneDrawing
|
|
ld a, d
|
|
srl a
|
|
cp a, b
|
|
jp z, .drawSelectedCard
|
|
.drawUnselectedCards
|
|
ld [hl], $12
|
|
inc hl
|
|
jp .loop
|
|
.drawSelectedCard
|
|
bit 0, d
|
|
jp nz, .drawSelectedSecond
|
|
ld [hl], $14
|
|
inc hl
|
|
jp .loop
|
|
.drawSelectedSecond
|
|
ld [hl], $15
|
|
inc hl
|
|
jp .loop
|
|
.doneDrawing
|
|
ld [hl], $13
|
|
ret
|
|
|
|
CardBrowse.UpdatePrintUI:
|
|
ld a, [vPrinterState]
|
|
ld hl, vPreviousPrinterState
|
|
cp a, [hl]
|
|
ret z ; if the printer state has not changed, return.
|
|
; otherwise updae previous printer state and continue to change ui
|
|
ld [hl], a
|
|
|
|
ld hl, CardBrowse.UpdatePrintUIImmediate
|
|
call Async_Spawn_HL
|
|
ret
|
|
|
|
CardBrowse.UpdatePrintUIImmediate:
|
|
ld a, [vPrinterState]
|
|
|
|
ld hl, CardBrowse.PrinterNotDetected
|
|
cp a, PS_NONE
|
|
jp z, .setIt
|
|
|
|
ld hl, CardBrowse.PrinterAvailable
|
|
cp a, PS_READY
|
|
jp z, .setIt
|
|
|
|
ld hl, CardBrowse.PrinterFull
|
|
cp a, PS_FULL
|
|
jp z, .setIt
|
|
|
|
ld hl, CardBrowse.PrinterPrinting
|
|
cp a, PS_PRINTING
|
|
jp z, .setIt
|
|
|
|
ld hl, CardBrowse.PrinterError
|
|
cp a, PS_ERROR
|
|
jp z, .setIt
|
|
|
|
.setIt
|
|
ld de, _SCRN0 + 32*1 + 17
|
|
ld b, 2
|
|
ld c, 2
|
|
call CopyTilesToMap
|
|
ret
|
|
|
|
CardBrowse.PrinterNotDetected:
|
|
db $00, $00
|
|
db $13, $00
|
|
CardBrowse.PrinterAvailable:
|
|
db $f1, $f2
|
|
db $f3, $f4
|
|
CardBrowse.PrinterFull:
|
|
db $f1, $f2
|
|
db $f9, $fa
|
|
CardBrowse.PrinterPrinting:
|
|
db $f1, $f2
|
|
db $f7, $f8
|
|
CardBrowse.PrinterError:
|
|
db $f1, $f2
|
|
db $f5, $f6
|
|
|
|
CardBrowseTeardown:
|
|
ret
|
|
|
|
|
|
CardBrowse.PrinterTiles:
|
|
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
|
db $00,$1c,$00,$0e,$38,$3f,$64,$7f,$7f,$7f,$7f,$40,$7f,$40,$3f,$3f
|
|
db $00,$00,$00,$00,$00,$00,$06,$b6,$ff,$ff,$ff,$11,$ff,$11,$fe,$fe
|
|
db $00,$00,$00,$80,$0e,$8e,$12,$9e,$24,$bc,$38,$b8,$00,$80,$00,$00
|
|
db $00,$00,$00,$00,$5a,$5a,$92,$92,$5a,$5a,$52,$52,$9b,$9b,$00,$00
|
|
db $00,$00,$18,$98,$18,$98,$18,$98,$18,$98,$00,$80,$18,$98,$00,$00
|
|
db $00,$00,$00,$00,$d8,$d8,$94,$94,$d8,$d8,$94,$94,$d2,$d2,$00,$00
|
|
db $00,$00,$00,$80,$19,$99,$15,$95,$19,$99,$11,$91,$11,$91,$00,$00
|
|
db $00,$00,$00,$00,$92,$92,$5a,$5a,$96,$96,$52,$52,$52,$52,$00,$00
|
|
db $00,$00,$00,$80,$1d,$9d,$11,$91,$19,$99,$11,$91,$11,$91,$00,$00
|
|
db $00,$00,$00,$00,$52,$52,$52,$52,$52,$52,$52,$52,$db,$db,$00,$00
|
|
CardBrowse.PrinterTilesEnd: ; $22
|
|
|
|
|
|
CardBrowse.UITilemap:
|
|
db $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0f, $09, $02, $02, $02, $02, $02, $02, $02, $02, $08
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $03, $00, $00, $00, $00, $00, $00, $00, $00, $04
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $06, $05, $05, $05, $05, $05, $05, $05, $05, $07
|
|
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, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $0b, $00, $00, $00, $00, $00, $00, $00, $00, $0c, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
db $11, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $0d, $10, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
|
|
CardBrowse.UITilemapEnd:
|