diff --git a/CardLibrary.inc b/CardLibrary.inc new file mode 100644 index 0000000..2d3db8b --- /dev/null +++ b/CardLibrary.inc @@ -0,0 +1,25 @@ +SECTION "Card Data", ROM0 + +Spreads: +.nospread + db 0 +.tencard + db 10, $00, $10, $20, $30, $40, $02, $12, $22, $32, $42 +.fivecard + db 5, $11, $20, $22, $31, $41 +.threecard + db 3, $11, $21, $31 + +Cards: + db 5 + dw TheFool + dw TheMagician + dw TheHighPriestess + dw TheEmpress + dw TheEmperor + +INCLUDE "00TheFool.inc" +INCLUDE "01TheMagician.inc" +INCLUDE "02TheHighPriestess.inc" +INCLUDE "03TheEmpress.inc" +INCLUDE "04TheEmperor.inc" diff --git a/CopyRangeSafe.inc b/CopyRangeSafe.inc index 2632d2b..434f403 100644 --- a/CopyRangeSafe.inc +++ b/CopyRangeSafe.inc @@ -1,5 +1,5 @@ ; variables for safe transfer async function -DEF vSafeCopySource EQU INTERRUPT_LCD + 3 +DEF vSafeCopySource EQU $ff80 DEF vSafeCopyDest EQU vSafeCopySource + 2 DEF vSafeCopyCount EQU vSafeCopyDest + 2 ; check this for safe transfer being complete DEF vSafeCopyOriginalCount EQU vSafeCopyCount + 2 @@ -188,7 +188,7 @@ CopyRangeSafe_Done: ; called when the complete transfer is finished, ldh a, [vSafeCopyInterrupt] ld [INTERRUPT_LCD], a ldh a, [vSafeCopyInterrupt+1] - ldh [INTERRUPT_LCD+1], a + ld [INTERRUPT_LCD+1], a ld hl, $ffff ld a, [hl] @@ -216,4 +216,39 @@ CopyRangeUnsafe: ld a, b or a, c ; check if bc is zero jp nz, CopyRangeUnsafe + ret + +CopyRangeUnsafeBy8s: + ; hl is source + ; de is destination + ; bc is length to copy + + 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 + dec bc + ld a, b + or a, c ; check if bc is zero + jp nz, CopyRangeUnsafeBy8s ret \ No newline at end of file diff --git a/CopyTilesSafe.inc b/CopyTilesSafe.inc index 4ac4614..64d4338 100644 --- a/CopyTilesSafe.inc +++ b/CopyTilesSafe.inc @@ -194,7 +194,7 @@ CopyTilesSafe_Done: ; called when the complete transfer is finished, ldh a, [vSafeCopyInterrupt] ld [INTERRUPT_LCD], a ldh a, [vSafeCopyInterrupt+1] - ldh [INTERRUPT_LCD+1], a + ld [INTERRUPT_LCD+1], a ld hl, $ffff ld a, [hl] diff --git a/CardReadScreen.inc b/ScreenCardRead.inc similarity index 94% rename from CardReadScreen.inc rename to ScreenCardRead.inc index b34b76d..574793e 100644 --- a/CardReadScreen.inc +++ b/ScreenCardRead.inc @@ -2,21 +2,25 @@ DEF vSelectedCardIndex EQU VARIABLES_START DEF vPreviousCardIndex EQU vSelectedCardIndex + 1 DEF vSelectedCardInSpread EQU vPreviousCardIndex + 1 -DEF vSelectedSpreadAddress EQU vSelectedCardInSpread + 1 +ScreenCardRead: + dw CardReadSetup + dw CardReadUpdate + dw CardReadDraw + dw CardReadTeardown + ;; CARD READ PAGE STARTS HERE CardReadSetup: ; Turn the LCD off ld hl, rLCDC bit 7, [hl] - jp z, CardReadSetup_ScreenOff -CardReadSetup_BusyWait: + jp z, .screenOff +.busyWait ld a, [rLY] cp a, 143 - jp c, CardReadSetup_BusyWait + jp c, .busyWait ld [hl], 0 - -CardReadSetup_ScreenOff: +.screenOff ld hl, UITiles ; source ld de, $8000 + $80*16; destination of copy ld bc, UITilesEnd - UITiles ; length to copy @@ -32,6 +36,23 @@ CardReadSetup_ScreenOff: ld b, 18 ; height ld c, 10 ; width call CopyTilesToMapUnsafe + + ld a, 0 + ld hl, $c000 + ld bc, 18*10 +.buildZeros + ld a, 0 + ld [hl+], a + ld a, b + or a, c + dec bc + jp nz, .buildZeros + + ld hl, $c000 + ld de, $9800 + 10 + ld b, 18 + ld c, 10 + call CopyTilesToMapUnsafe ; set LCD and display registers ld a, %11100100 @@ -43,11 +64,7 @@ CardReadSetup_ScreenOff: ; arguments for the screen ld a, 0 ldh [vSelectedCardInSpread], a - ld hl, Spreads - ld a, l - ldh [vSelectedSpreadAddress], a - ld a, h - ldh [vSelectedSpreadAddress+1], a + ; vCurrentSpread is set by the calling context. ld a, $FF ldh [vPreviousCardIndex], a ld a, 0 @@ -58,6 +75,12 @@ CardReadSetup_ScreenOff: CardReadUpdate: ld hl, rMYBTNP + bit 5, [hl] + jp z, .doneWithB + ld hl, ScreenMainMenu + call ChangeScene + ret +.doneWithB bit 3, [hl] ; select the down key jp z, :+ ; skip the following code if down is not pressed ldh a, [vSelectedCardIndex] @@ -97,9 +120,9 @@ CardReadUpdate: inc a ldh [vSelectedCardInSpread], a : - ldh a, [vSelectedSpreadAddress] + ldh a, [vCurrentSpread] ld l, a - ldh a, [vSelectedSpreadAddress+1] + 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? @@ -117,20 +140,21 @@ CardReadUpdate: CardReadDraw: ; first, we draw the spread minimap - ldh a, [vSelectedSpreadAddress] +.drawSpread + ldh a, [vCurrentSpread] ld c, a - ldh a, [vSelectedSpreadAddress+1] + ldh a, [vCurrentSpread+1] ld b, a ld a, [bc] ld e, a ld d, 0 -CardReadDraw_FoundSpread: +.foundSpread push de ; length of the spread in e! -CardReadDraw_DrawCard: +.drawCard ld a, e cp a, 0 - jp z, CardReadDraw_DoneWithSpread + jp z, .doneWithSpread inc bc ; first card of spread is after the length of the spread ld hl, $9800 + (32*12)+11 @@ -141,36 +165,34 @@ CardReadDraw_DrawCard: ld d, 0 ld e, a ; add a to hl add hl, de -CardReadDraw_DoneWithWalkRight: +.doneWithWalkRight ld a, [bc] and a, %0000_1111 ld d, 0 ld e, 32 - jp z, CardReadDraw_DoneWithWalkDown -CardReadDraw_WalkDown: + jp z, .doneWithWalkDown +.walkDown dec a add hl, de cp a, 0 - jp nz, CardReadDraw_WalkDown -CardReadDraw_DoneWithWalkDown: -CardReadDraw_DrawMiniCard: + jp nz, .walkDown +.doneWithWalkDown +.drawMiniCard ld [hl], $83 add hl, de ld [hl], $84 -CardReadDraw_DoneDrawingCard: +.doneDrawingCard pop de dec de ld a, e cp a, 0 - jp nz, CardReadDraw_FoundSpread + jp nz, .foundSpread - - -CardReadDraw_DoneWithSpread: +.doneWithSpread ; highlight the selected card - ldh a, [vSelectedSpreadAddress] + ldh a, [vCurrentSpread] ld l, a - ldh a, [vSelectedSpreadAddress+1] + ldh a, [vCurrentSpread+1] ld h, a ldh a, [vSelectedCardInSpread] @@ -272,7 +294,6 @@ LoadCardData: 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 @@ -361,32 +382,11 @@ WaitForSafeCopy2: INCLUDE "CopyRangeSafe.inc" - INCLUDE "CopyTilesSafe.inc" - -SECTION "Card Data", ROM0 - -Cards: - db 5 - dw TheFool - dw TheMagician - dw TheHighPriestess - dw TheEmpress - dw TheEmperor - -INCLUDE "00TheFool.inc" -INCLUDE "01TheMagician.inc" -INCLUDE "02TheHighPriestess.inc" -INCLUDE "03TheEmpress.inc" -INCLUDE "04TheEmperor.inc" +INCLUDE "CardLibrary.inc" SECTION "Tile data", ROM0 - -Spreads: - db 10, $00, $10, $20, $30, $40, $02, $12, $22, $32, $42 - db 5, $11, $20, $22, $31, $41 - db 3, $11, $21, $31 UITiles: db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 diff --git a/ScreenMainMenu.inc b/ScreenMainMenu.inc new file mode 100644 index 0000000..6e6cb95 --- /dev/null +++ b/ScreenMainMenu.inc @@ -0,0 +1,749 @@ +DEF vCurrentSpread EQU $ff90 ; putting global app variables at the start of HRAM. +; 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 vMenuIndexPrevious equ vMenuIndex + 1 + +ScreenMainMenu: + dw MainMenuSetup + dw MainMenuUpdate + dw MainMenuDraw + dw MainMenuTeardown + +MainMenuSetup: +; Turn the LCD off + ld hl, rLCDC + bit 7, [hl] + jp z, MainMenuSetup_ScreenOff +MainMenuSetup_BusyWait: + ld a, [rLY] + cp a, 143 + jp c, MainMenuSetup_BusyWait + ld [hl], 0 + +MainMenuSetup_ScreenOff: + ld a, 0 + ldh [rLCDC], a + + ld hl, SquaresTileset8 + ld de, $8010 + ld bc, (SquaresTilesetEnd - SquaresTileset8) + call CopyRangeUnsafe + + ld hl, CardBackSprites ; source + ld de, $8100; destination of copy + ld bc, CardBackSpritesEnd - CardBackSprites ; length to copy + call CopyRangeUnsafe + + ld hl, SquaresTilemap + ld de, $9800 + ld b, 18 + 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 + ld hl, StringShuffle + ld de, $9800 + 32*13 + 4 + call PrintString + ld hl, StringBrowse + ld de, $9800 + 32*15 + 4 + call PrintString + + + ; clear out the dma source + ld hl, $c000 + ld a, 0 +: + ld [hl+], a + cp a, l + jp nz, :- + + ld de, vTime+2 + ld a, $c0 + call RunDMA + + ; set LCD and display registers + ld a, %11100100 + ld [rBGP], a + ld [rOBP0], a + + ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16 + ldh [rLCDC], a + + ld a, 0 + ldh [vFrameCount1], a ; first starts at 0 + ldh [vTime], a + ldh [vTime+1], a + ldh [vMenuIndex], a + ldh [vMenuIndexPrevious], a + + + ; second starts at 1/3 length which is approximately L/2 - L/4 - L/8 + L/16 ? + ld hl, Coords + ld a, [hl] + ld b, a + srl b + sub a, b ; L - L/2 + srl b + sub a, b ; L - L/2 - L/4 + srl b + add a, b ; L - L/2 - L/4 + L/8 + srl b + sub a, b ; L - L/2 - L/4 + L/8 - L/16 + srl b + add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 + srl b + sub a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64 + srl b + add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64 + L/128 + ; that should be approx 1/3 of L ! + ldh [vFrameCount2], a + + ; third starts at 2/3 length which is approximately L/2 - L/4 + L/8 - L/16 ? + ld hl, Coords + ld a, [hl] + ld b, a + srl b + sub a, b ; L - L/2 + srl b + add a, b ; L - L/2 + L/4 + srl b + sub a, b ; L - L/2 + L/4 - L/8 + srl b + add a, b ; L - L/2 + L/4 - L/8 + L/16 + srl b + sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + srl b + add a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64 + srl b + sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64 - L/128 + ; that should be just about 2/3 of L ! + ldh [vFrameCount3], a + + ld hl, Coords + ld a, [hl] + srl a + ldh [vFrameCount4], a + + ld a, 0 + ldh [vFrameCountSquares], a + + + ; load graphics into vram for deck face + ; set up variables: LFSR stuff + ret ; return from cardreadsetup + +MainMenuUpdate: + ; if pressing a key and unblocked: + ; signal an animation to start + ; turn on block + ; if in animation state: + ; increment timer + ; if timer is max, turn off animation state and unblock? + ld hl, rMYBTNP + + ldh a, [vMenuIndex] + bit 3, [hl] ; select the down key + jp z, .doneWithDownInput ; skip the following code if down is not pressed + inc a +.doneWithDownInput + bit 2, [hl] ; select up key %0000_0100 + jp z, .doneWithUpInput ; skip the following code if up is not pressed + dec a +.doneWithUpInput + ld hl, MenuCount + call ArrayClampLooping + ldh [vMenuIndex], a + + + ld hl, rMYBTNP + + bit 5, [hl] ; button a pressed? + jp z, .doneWithMenuSelect + ld a, [vMenuIndex] + cp a, 0 + jp z, .option1 + cp a, 1 + jp z, .option2 + cp a, 2 + jp z, .option3 + jp .doneWithMenuSelect +.option1 + jp .doneWithMenuSelect +.option2 + jp .doneWithMenuSelect +.option3 + ld hl, vCurrentSpread + ld [hl], LOW(Spreads.threecard) + inc hl + ld [hl], HIGH(Spreads.threecard) + ld hl, ScreenCardRead + call ChangeScene + ret + jp .doneWithMenuSelect +.doneWithMenuSelect + + + + 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 + + cp a, $01 + jp c, MainMenuUpdate_Done ; 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, Coords + + ; and advance the frame counts + ldh a, [vFrameCount1] + inc a + call ArrayClampLooping + ldh [vFrameCount1], a + + ldh a, [vFrameCount2] + inc a + call ArrayClampLooping + ldh [vFrameCount2], a + + ldh a, [vFrameCount3] + inc a + call ArrayClampLooping + ldh [vFrameCount3], a + + ldh a, [vFrameCount4] + inc a + call ArrayClampLooping + ldh [vFrameCount4], a + + ld hl, SquaresTiles + ldh a, [vFrameCountSquares] + inc a + call ArrayClampLooping + ldh [vFrameCountSquares], a + + + + ld hl, Coords + inc hl + ld b, 0 + ld a, [vFrameCount1] + ld c, a + add hl, bc + add hl, bc + add hl, bc + ld a, [hl+] + ld b, a ; y coordinate + ld a, [hl+] + ld c, a ; x coordinate + ld a, [hl+] + ld e, a ; spread value + ld hl, $c000 + call DrawWholeCard + + ld hl, Coords + inc hl + ld b, 0 + ld a, [vFrameCount2] + ld c, a + add hl, bc + add hl, bc + add hl, bc + ld a, [hl+] + ld b, a ; y coordinate + ld a, [hl+] + ld c, a ; x coordinate + ld a, [hl+] + ld e, a ; spread value + ld hl, $c000 + 3*4 + ;call DrawWholeCard + + ld hl, Coords + inc hl + ld b, 0 + ld a, [vFrameCount3] + ld c, a + add hl, bc + add hl, bc + add hl, bc + ld a, [hl+] + ld b, a ; y coordinate + ld a, [hl+] + ld c, a ; x coordinate + ld a, [hl+] + ld e, a ; spread value + ld hl, $c000 + 6*4 + ;call DrawWholeCard + + ld hl, Coords + inc hl + ld b, 0 + ld a, [vFrameCount4] + ld c, a + add hl, bc + add hl, bc + add hl, bc + ld a, [hl+] + ld b, a ; y coordinate + ld a, [hl+] + ld c, a ; x coordinate + ld a, [hl+] + ld e, a ; spread value + ld hl, $c000 + 3*4 + call DrawWholeCard + +MainMenuUpdate_Done: + ret + +MainMenuDraw: + ld hl, $9800 + 32*11 + 3 - 64 + ld a, [vMenuIndexPrevious] + inc a + ld b, 0 + ld c, 32 +.findLastCaret + add hl, bc + add hl, bc + dec a + jp nz, .findLastCaret + ld [hl], $4 + + ld hl, $9800 + 32*11 + 3 - 64 + ld a, [vMenuIndex] + inc a +.findNewCaret + add hl, bc + add hl, bc + dec a + jp nz, .findNewCaret + ld [hl], $80 + $20 + $9 + + ld a, [vMenuIndex] + ld [vMenuIndexPrevious], a + + + ld de, vMenuIndexPrevious+2 + ld a, $c0 + call RunDMA + + ld hl, SquaresTiles + inc hl + 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 bc, (SquaresTileset8 - SquaresTileset7) / 8 + call CopyRangeUnsafeBy8s + + ret + +MainMenuTeardown: + ret + +DrawWholeCard: ; hl memory location, b y, c x, e step, d wiggle + ld a, e + cp a, 4 + jp z, Draw2x2Card + jp Draw3x3Card + +Draw2x2Card: +; hl memory location, b y coord, c x coord, e step, d wiggle + ; top-left + ld a, c + cp a, 88 + jp nc, :+ + cp a, 78 + jp c, :+ + jp :++ +: + ld a, $12 + call DrawTile + jp :++ +: + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a +: + + xor a, a + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + + + ld a, c + add a, e ; addd stride to x + add a, e + ld c, a + cp a, 91 + jp nc, :+ + cp a, 82 + jp c, :+ + jp :++ +: + ld a, $1e + call DrawTile + jp :++ +: + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a +: + + push bc + ld b, 0 + ld c, 6*4 + add hl, bc ; advance by 6 oam slots? + pop bc + + ld a, c + sub a, e + sub a, e + ld c, a ; subtract stridex2 from x + + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + + + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + + push bc + ld b, 0 + ld c, 6*4 + add hl, bc ; advance by 6 oam slots so the other two cards have room + pop bc + + ld a, b + add a, e + add a, e + add a, e + add a, e + ld b, a ; add stridex2 to y coord + ld a, c + cp a, 88 + jp nc, :+ + cp a, 78 + jp c, :+ + jp :++ +: + ld a, $16 + call DrawTile + jp :++ +: + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a +: + + + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + + ld a, c + add a, e + add a, e + ld c, a + cp a, 91 + jp nc, :+ + cp a, 82 + jp c, :+ + jp :++ +: + ld a, $22 + call DrawTile + jp :++ +: + ld a, 0 + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a +: + ret + +Draw3x3Card: +; hl memory location, b y coord, c x coord, e step, d wiggle + ; top-left + ld a, $12 + call DrawTile + + ld a, c + add a, e ; addd stride to x + ld c, a + ld a, $18 + call DrawTile + + ld a, c + add a, e ; add stride to x + ld c, a + ld a, $1e + call DrawTile + + push bc + ld b, 0 + ld c, 6*4 + add hl, bc ; advance by 6 oam slots? + pop bc + + ld a, b + add a, 8 + add a, 8 + ld b, a ; add 16 to y coord + ld a, c + sub a, e + sub a, e + ld c, a ; subtract stridex2 from x + ld a, $14 + call DrawTile + + + ld a, c + add a, e + ld c, a + ld a, $1a + call DrawTile + + ld a, c + add a, e + ld c, a + ld a, $20 + call DrawTile + + push bc + ld b, 0 + ld c, 6*4 + add hl, bc ; advance by 6 oam slots so the other two cards have room + pop bc + + ld a, b + sub a, 8 + sub a, 8 + add a, e + add a, e + add a, e + add a, e + ld b, a ; add stridex2 to y coord + ld a, c + sub a, e + sub a, e + ld c, a ; subtract stridex2 from x + ld a, $16 + call DrawTile + + ld a, c + add a, e + ld c, a + ld a, $1c + call DrawTile + + ld a, c + add a, e + ld c, a + ld a, $22 + call DrawTile + ret + +DrawTile: ; b: y. a: x. d: sprite. hl: location of sprite in OAM + inc hl + inc hl + ld [hl+], a + ld a, 0 + ld [hl-], a + dec hl + dec hl + + ld a, b + ld [hl+], a ; y byte + + ld a, c + ld [hl+], a ; x byte + + inc hl + inc hl + + ret + +MenuCount: + db 3 +StringRead: + db 10, "Read Cards" +StringShuffle: + db 7, "Shuffle" +StringBrowse: + db 11, "Browse Deck" +Coords: ; y, x, spread + db 255, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1e, $13, $6, $1e, $14, $6, $1e, $14, $6, $1e, $14, $6, $1e, $14, $7, $1e, $15, $7, $1e, $15, $7, $1e, $16, $7, $1e, $16, $7, $1e, $16, $7, $1e, $17, $7, $1e, $18, $7, $1e, $18, $7, $1e, $19, $7, $1e, $19, $7, $1d, $1a, $7, $1d, $1b, $7, $1d, $1c, $7, $1d, $1c, $7, $1d, $1d, $7, $1d, $1e, $7, $1d, $1f, $7, $1d, $20, $7, $1d, $21, $7, $1d, $22, $7, $1d, $23, $7, $1d, $24, $7, $1d, $25, $7, $1d, $26, $8, $1d, $27, $8, $1d, $28, $8, $1d, $29, $8, $1d, $2a, $8, $1c, $2b, $8, $1c, $2d, $8, $1c, $2e, $8, $1c, $2f, $8, $1c, $30, $8, $1c, $32, $8, $1c, $33, $8, $1c, $34, $8, $1c, $36, $8, $1c, $37, $8, $1c, $38, $8, $1c, $3a, $8, $1c, $3b, $8, $1c, $3c, $8, $1c, $3e, $8, $1c, $3f, $8, $1c, $41, $8, $1c, $42, $8, $1c, $44, $8, $1c, $45, $8, $1c, $46, $8, $1c, $48, $8, $1c, $49, $8, $1c, $4b, $8, $1c, $4c, $8, $1c, $4e, $8, $1c, $4f, $8, $1c, $51, $8, $1c, $52, $8, $1c, $54, $8, $1c, $55, $8, $1c, $57, $8, $1c, $58, $8, $1c, $5a, $8, $1c, $5b, $8, $1c, $5d, $8, $1c, $5e, $8, $1c, $5f, $8, $1c, $61, $8, $1c, $62, $8, $1c, $64, $8, $1c, $65, $8, $1c, $66, $8, $1c, $68, $8, $1c, $69, $8, $1c, $6a, $8, $1c, $6c, $8, $1c, $6d, $8, $1d, $6e, $8, $1d, $70, $8, $1d, $71, $8, $1d, $72, $8, $1d, $73, $8, $1d, $74, $8, $1d, $75, $7, $1d, $77, $7, $1d, $78, $7, $1d, $79, $7, $1d, $7a, $7, $1d, $7b, $7, $1d, $7c, $7, $1d, $7d, $7, $1d, $7e, $7, $1d, $7f, $7, $1d, $80, $7, $1d, $80, $7, $1d, $81, $7, $1e, $82, $7, $1e, $83, $7, $1e, $84, $7, $1e, $84, $7, $1e, $85, $7, $1e, $86, $7, $1e, $86, $7, $1e, $87, $7, $1e, $87, $7, $1e, $88, $7, $1e, $88, $7, $1e, $89, $6, $1e, $89, $6, $1e, $89, $6, $1f, $8a, $6, $1f, $8a, $6, $1f, $8a, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $20, $8b, $6, $20, $8a, $6, $20, $8a, $6, $20, $8a, $5, $20, $89, $5, $20, $89, $5, $20, $89, $5, $20, $88, $5, $20, $88, $5, $20, $87, $5, $20, $87, $5, $20, $86, $5, $20, $86, $5, $20, $85, $5, $21, $84, $5, $21, $84, $5, $21, $83, $5, $21, $82, $5, $21, $81, $5, $21, $80, $5, $21, $80, $5, $21, $7f, $5, $21, $7e, $5, $21, $7d, $5, $21, $7c, $5, $21, $7b, $5, $21, $7a, $5, $21, $79, $4, $21, $78, $4, $21, $77, $4, $21, $76, $4, $21, $74, $4, $21, $73, $4, $22, $72, $4, $22, $71, $4, $22, $70, $4, $22, $6e, $4, $22, $6d, $4, $22, $6c, $4, $22, $6a, $4, $22, $69, $4, $22, $68, $4, $22, $66, $4, $22, $65, $4, $22, $64, $4, $22, $62, $4, $22, $61, $4, $22, $5f, $4, $22, $5e, $4, $22, $5d, $4, $22, $5b, $4, $22, $5a, $4, $22, $58, $4, $22, $57, $4, $22, $55, $4, $22, $54, $4, $22, $52, $4, $22, $51, $4, $22, $4f, $4, $22, $4e, $4, $22, $4c, $4, $22, $4b, $4, $22, $49, $4, $22, $48, $4, $22, $47, $4, $22, $45, $4, $22, $44, $4, $22, $42, $4, $22, $41, $4, $22, $3f, $4, $22, $3e, $4, $22, $3c, $4, $22, $3b, $4, $22, $3a, $4, $22, $38, $4, $22, $37, $4, $22, $36, $4, $22, $34, $4, $22, $33, $4, $22, $32, $4, $22, $30, $4, $21, $2f, $4, $21, $2e, $4, $21, $2d, $4, $21, $2b, $4, $21, $2a, $4, $21, $29, $5, $21, $28, $5, $21, $27, $5, $21, $26, $5, $21, $25, $5, $21, $24, $5, $21, $23, $5, $21, $22, $5, $21, $21, $5, $21, $20, $5, $21, $1f, $5, $21, $1e, $5, $21, $1d, $5, $20, $1c, $5, $20, $1c, $5, $20, $1b, $5, $20, $1a, $5, $20, $19, $5, $20, $19, $5, $20, $18, $5, $20, $18, $5, $20, $17, $5, $20, $16, $5, $20, $16, $5, $20, $16, $6, $20, $15, $6, $20, $15, $6, $20, $14, $6, $1f, $14, $6, $1f, $14, $6, $1f, $14, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6 + + +CardBackSprites: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; blank + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; blank + + db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left + db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; left + db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; left + db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; left + db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; left + db $6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff ; bottom-left + + db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa ; top + db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle + db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle + db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle + db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle + db $aa,$55,$55,$aa,$aa,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff ; bottom + + db $00,$ff,$fe,$ff,$fe,$ff,$06,$ff,$f6,$ff,$56,$bf,$b6,$5f,$56,$bf ; top-right + db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; right + db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; right + db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; right + db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; right + db $b6,$5f,$56,$bf,$b6,$5f,$f6,$ff,$06,$ff,$fe,$ff,$fe,$ff,$00,$ff ; bottom-right + +CardBackSpritesEnd: + +SquaresTiles: + db 8 + dw SquaresTileset1 + dw SquaresTileset2 + dw SquaresTileset3 + dw SquaresTileset4 + dw SquaresTileset5 + dw SquaresTileset6 + dw SquaresTileset7 + dw SquaresTileset8 + +SquaresTileset1: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$aa,$00 + db $00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$01,$00,$aa,$00 + db $01,$00,$00,$00,$01,$00,$00,$00,$01,$00,$01,$00,$01,$00,$ff,$00 + db $01,$00,$01,$00,$01,$00,$01,$00,$03,$00,$01,$00,$ab,$00,$ff,$00 + db $03,$00,$01,$00,$03,$00,$01,$00,$03,$00,$01,$00,$ab,$00,$ff,$00 + +SquaresTileset2: + db $00,$00,$00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00,$80,$00 + db $00,$00,$80,$00,$00,$00,$80,$00,$00,$00,$80,$00,$00,$00,$80,$00 + db $55,$00,$80,$00,$00,$00,$80,$00,$00,$00,$81,$00,$00,$00,$d5,$00 + db $55,$00,$81,$00,$80,$00,$81,$00,$00,$00,$81,$00,$80,$00,$d5,$00 + db $ff,$00,$81,$00,$80,$00,$81,$00,$80,$00,$81,$00,$80,$00,$d5,$00 + +SquaresTileset3: + db $00,$00,$00,$00,$00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00 + db $aa,$00,$44,$00,$80,$00,$00,$00,$80,$00,$40,$00,$80,$00,$40,$00 + db $ea,$00,$55,$00,$80,$00,$40,$00,$c0,$00,$40,$00,$c0,$00,$40,$00 + db $ea,$00,$dd,$00,$c0,$00,$40,$00,$c0,$00,$40,$00,$c0,$00,$40,$00 + db $ea,$00,$ff,$00,$c0,$00,$40,$00,$c0,$00,$40,$00,$c0,$00,$40,$00 + +SquaresTileset4: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 + db $20,$00,$00,$00,$aa,$00,$00,$00,$20,$00,$40,$00,$20,$00,$00,$00 + db $20,$00,$55,$00,$aa,$00,$40,$00,$20,$00,$40,$00,$20,$00,$40,$00 + db $20,$00,$55,$00,$ff,$00,$60,$00,$20,$00,$60,$00,$20,$00,$60,$00 + db $20,$00,$75,$00,$ff,$00,$60,$00,$20,$00,$60,$00,$20,$00,$60,$00 + +SquaresTileset5: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 + db $20,$00,$00,$00,$aa,$00,$11,$00,$20,$00,$10,$00,$20,$00,$10,$00 + db $20,$00,$10,$00,$aa,$00,$55,$00,$20,$00,$10,$00,$30,$00,$10,$00 + db $30,$00,$10,$00,$ba,$00,$77,$00,$30,$00,$10,$00,$30,$00,$10,$00 + db $30,$00,$10,$00,$ba,$00,$ff,$00,$30,$00,$10,$00,$30,$00,$10,$00 + +SquaresTileset6: + db $00,$00,$00,$00,$00,$00,$00,$00,$88,$00,$00,$00,$00,$00,$00,$00 + db $08,$00,$00,$00,$08,$00,$11,$00,$aa,$00,$10,$00,$08,$00,$10,$00 + db $08,$00,$10,$00,$08,$00,$55,$00,$ff,$00,$10,$00,$08,$00,$10,$00 + db $08,$00,$18,$00,$08,$00,$55,$00,$ff,$00,$18,$00,$08,$00,$18,$00 + db $08,$00,$18,$00,$08,$00,$5d,$00,$ff,$00,$18,$00,$08,$00,$18,$00 + +SquaresTileset7: + 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,$88,$00,$00,$00,$00,$00,$00,$00 + db $08,$00,$04,$00,$08,$00,$00,$00,$aa,$00,$55,$00,$08,$00,$04,$00 + db $0c,$00,$04,$00,$08,$00,$04,$00,$ae,$00,$55,$00,$0c,$00,$04,$00 + db $0c,$00,$04,$00,$0c,$00,$04,$00,$ae,$00,$ff,$00,$0c,$00,$04,$00 + +SquaresTileset8: + db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$22,$00,$00,$00 + db $02,$00,$00,$00,$02,$00,$00,$00,$02,$00,$55,$00,$aa,$00,$04,$00 + db $02,$00,$04,$00,$02,$00,$04,$00,$02,$00,$55,$00,$ff,$00,$04,$00 + db $02,$00,$04,$00,$02,$00,$06,$00,$02,$00,$57,$00,$ff,$00,$06,$00 + db $02,$00,$06,$00,$02,$00,$06,$00,$02,$00,$57,$00,$ff,$00,$06,$00 + +SquaresTilesetEnd: + +SquaresTilemap: + 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 $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01 + db $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01 + db $02, $02, $02, $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $02, $02, $02 + db $03, $02, $02, $02, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $02, $02, $02, $03 + db $04, $03, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $04 + db $05, $04, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $05 + db $05, $05, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 +SquaresTilemapEnd: \ No newline at end of file diff --git a/ScreenSpreadSelect.inc b/ScreenSpreadSelect.inc new file mode 100644 index 0000000..e69de29 diff --git a/ShuffleDeckScreen.inc b/ShuffleDeckScreen.inc deleted file mode 100644 index 0438520..0000000 --- a/ShuffleDeckScreen.inc +++ /dev/null @@ -1,441 +0,0 @@ -DEF vFrameCount1 EQU VARIABLES_START -DEF vFrameCount2 equ vFrameCount1+1 -DEF vFrameCount3 EQU vFrameCount2+1 -PRINTLN "vframecount is ", vFrameCount1 -DEF vTime EQU vFrameCount3+1 ; 16bit - - -ShuffleDeckSetup: -; Turn the LCD off - ld hl, rLCDC - bit 7, [hl] - jp z, CardReadSetup_ScreenOff -ShuffleDeckSetup_BusyWait: - ld a, [rLY] - cp a, 143 - jp c, CardReadSetup_BusyWait - ld [hl], 0 - -ShuffleDeckSetup_ScreenOff: - ld a, 0 - ldh [rLCDC], a - - ld hl, CardBackSprites ; source - ld de, $8000; destination of copy - ld bc, CardBackSpritesEnd - CardBackSprites ; length to copy - call CopyRangeUnsafe - - ; set LCD and display registers - ld a, %11100100 - ld [rBGP], a - ld [rOBP0], a - - ld a, LCDCF_BLK01 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16 - ldh [rLCDC], a - - ld a, 0 - ldh [vFrameCount1], a ; first starts at 0 - ldh [vTime], a - ldh [vTime+1], a - - ; second starts at 1/3 length which is approximately L/2 - L/4 - L/8 + L/16 ? - ld hl, Coords - ld a, [hl] - ld b, a - srl b - sub a, b ; L - L/2 - srl b - sub a, b ; L - L/2 - L/4 - srl b - add a, b ; L - L/2 - L/4 + L/8 - srl b - sub a, b ; L - L/2 - L/4 + L/8 - L/16 - srl b - add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - srl b - sub a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64 - srl b - add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64 + L/128 - ; that should be approx 1/3 of L ! - ldh [vFrameCount2], a - - ; third starts at 2/3 length which is approximately L/2 - L/4 + L/8 - L/16 ? - ld hl, Coords - ld a, [hl] - ld b, a - srl b - sub a, b ; L - L/2 - srl b - add a, b ; L - L/2 + L/4 - srl b - sub a, b ; L - L/2 + L/4 - L/8 - srl b - add a, b ; L - L/2 + L/4 - L/8 + L/16 - srl b - sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 - srl b - add a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64 - srl b - sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64 - L/128 - ; that should be just about 2/3 of L ! - ldh [vFrameCount3], a - - - ; load graphics into vram for deck face - ; set up variables: LFSR stuff - ret ; return from cardreadsetup - -ShuffleDeckUpdate: - ; if pressing a key and unblocked: - ; signal an animation to start - ; turn on block - ; if in animation state: - ; increment timer - ; if timer is max, turn off animation state and unblock? - - 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 - - cp a, $01 - jp c, ShuffleDeckUpdate_Done ; if the timer is less than $1000, skip to end - - ;otherwise reset the timer - ld a, 0 - ldh [vTime], a - ldh [vTime+1], a - - - ld hl, Coords - - ; and advance the frame counts - ldh a, [vFrameCount1] - inc a - call ArrayClampLooping - ldh [vFrameCount1], a - - ldh a, [vFrameCount2] - inc a - call ArrayClampLooping - ldh [vFrameCount2], a - - ldh a, [vFrameCount3] - inc a - call ArrayClampLooping - ldh [vFrameCount3], a - -ShuffleDeckUpdate_Done: - ret - -ShuffleDeckDraw: - ld hl, Coords - inc hl - ld b, 0 - ld a, [vFrameCount1] - ld c, a - add hl, bc - add hl, bc - add hl, bc - ld a, [hl+] - ld b, a ; y coordinate - ld a, [hl+] - ld c, a ; x coordinate - ld a, [hl+] - ld e, a ; spread value - ld hl, $fe00 - call DrawWholeCard - - ld hl, Coords - inc hl - ld b, 0 - ld a, [vFrameCount2] - ld c, a - add hl, bc - add hl, bc - add hl, bc - ld a, [hl+] - ld b, a ; y coordinate - ld a, [hl+] - ld c, a ; x coordinate - ld a, [hl+] - ld e, a ; spread value - ld hl, $fe00 + 3*4 - call DrawWholeCard - - ld hl, Coords - inc hl - ld b, 0 - ld a, [vFrameCount3] - ld c, a - add hl, bc - add hl, bc - add hl, bc - ld a, [hl+] - ld b, a ; y coordinate - ld a, [hl+] - ld c, a ; x coordinate - ld a, [hl+] - ld e, a ; spread value - ld hl, $fe00 + 6*4 - call DrawWholeCard - - - ret - -ShuffleDeckTeardown: - ret - -DrawWholeCard: ; hl memory location, b y, c x, e step - jp Draw3x3Card -Draw2x2Card: -; hl memory location, b y coord, c x coord, e step - ; top-left - ld d, $02 - call DrawTile - - ld a, c - add a, e ; addd stride to x - ld c, a - ld a, e - cp a, 5 - ld d, $04 - call DrawTile - - ld d, $06 - ld a, c - add a, e ; add stride to x - ;sub a, 8 - ld c, a - call DrawTile - - push bc - ld b, 0 - ld c, 6*4 - add hl, bc ; advance by 6 oam slots? - pop bc - - ld d, $08 - ld a, b - add a, 8 - add a, 8 - ld b, a ; add 16 to y coord - ld a, c - sub a, e - sub a, e - ld c, a ; subtract stridex2 from x - call DrawTile - - - ld d, $0a - ld a, c - add a, e - ld c, a - call DrawTile - - ld d, $0c - ld a, c - add a, e - ld c, a - call DrawTile - - push bc - ld b, 0 - ld c, 6*4 - add hl, bc ; advance by 6 oam slots so the other two cards have room - pop bc - - ld d, $0e - ld a, b - sub a, 8 - sub a, 8 - add a, e - add a, e - add a, e - add a, e - ld b, a ; add stridex2 to y coord - ld a, c - sub a, e - sub a, e - ld c, a ; subtract stridex2 from x - call DrawTile - - ld d, $10 - ld a, c - add a, e - ld c, a - call DrawTile - - ld d, $12 - ld a, c - add a, e - ld c, a - call DrawTile - ret - -Draw3x3Card: -; hl memory location, b y coord, c x coord, e step - ; top-left - ld d, $02 - call DrawTile - - ld a, c - add a, e ; addd stride to x - ld c, a - ld a, e - cp a, 5 - ld d, $04 - call DrawTile - - ld d, $06 - ld a, c - add a, e ; add stride to x - ;sub a, 8 - ld c, a - call DrawTile - - push bc - ld b, 0 - ld c, 6*4 - add hl, bc ; advance by 6 oam slots? - pop bc - - ld d, $08 - ld a, b - add a, 8 - add a, 8 - ld b, a ; add 16 to y coord - ld a, c - sub a, e - sub a, e - ld c, a ; subtract stridex2 from x - call DrawTile - - - ld d, $0a - ld a, c - add a, e - ld c, a - call DrawTile - - ld d, $0c - ld a, c - add a, e - ld c, a - call DrawTile - - push bc - ld b, 0 - ld c, 6*4 - add hl, bc ; advance by 6 oam slots so the other two cards have room - pop bc - - ld d, $0e - ld a, b - sub a, 8 - sub a, 8 - add a, e - add a, e - add a, e - add a, e - ld b, a ; add stridex2 to y coord - ld a, c - sub a, e - sub a, e - ld c, a ; subtract stridex2 from x - call DrawTile - - ld d, $10 - ld a, c - add a, e - ld c, a - call DrawTile - - ld d, $12 - ld a, c - add a, e - ld c, a - call DrawTile - ret - -DrawTile: ; b: y. a: x. d: sprite. hl: location of sprite in OAM - ld a, b - ld [hl+], a ; y byte - - ld a, c - ld [hl+], a ; x byte - - ld a, d - ld [hl+], a ; tile index - ld a, $00 - ld [hl+], a ; attributes - ret -Coords: ; y, x, spread -db 160, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, $1f, $13, $6, -db $1e, $14, $6, $1e, $14, $6, $1e, $14, $7, $1e, $15, $7, $1e, $16, $7, $1e, $16, -db $7, $1e, $17, $7, $1e, $18, $7, $1e, $19, $7, $1d, $1a, $7, $1d, $1b, $7, $1d, $1d, -db $7, $1d, $1e, $7, $1d, $1f, $7, $1d, $21, $7, $1d, $22, $7, $1d, $24, $7, $1d, $26, -db $8, $1d, $27, $8, $1d, $29, $8, $1d, $2b, $8, $1c, $2d, $8, $1c, $2f, $8, $1c, $31, -db $8, $1c, $33, $8, $1c, $35, $8, $1c, $37, $8, $1c, $3a, $8, $1c, $3c, $8, $1c, $3e, -db $8, $1c, $40, $8, $1c, $43, $8, $1c, $45, $8, $1c, $47, $8, $1c, $4a, $8, $1c, $4c, -db $8, $1c, $4e, $8, $1c, $51, $8, $1c, $53, $8, $1c, $55, $8, $1c, $58, $8, $1c, $5a, -db $8, $1c, $5c, $8, $1c, $5f, $8, $1c, $61, $8, $1c, $63, $8, $1c, $65, $8, $1c, $68, -db $8, $1c, $6a, $8, $1c, $6c, $8, $1d, $6e, $8, $1d, $70, $8, $1d, $72, $8, $1d, $74, -db $8, $1d, $76, $7, $1d, $77, $7, $1d, $79, $7, $1d, $7b, $7, $1d, $7c, $7, $1d, $7e, -db $7, $1d, $7f, $7, $1d, $81, $7, $1e, $82, $7, $1e, $83, $7, $1e, $84, $7, $1e, $85, -db $7, $1e, $86, $7, $1e, $87, $7, $1e, $88, $7, $1e, $89, $6, $1e, $89, $6, $1f, $8a, -db $6, $1f, $8a, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, $6, $1f, $8b, -db $6, $1f, $8b, $6, $1f, $8b, $6, $20, $8a, $6, $20, $8a, $6, $20, $8a, $5, $20, $89, -db $5, $20, $88, $5, $20, $88, $5, $20, $87, $5, $20, $86, $5, $20, $85, $5, $21, $84, -db $5, $21, $83, $5, $21, $81, $5, $21, $80, $5, $21, $7f, $5, $21, $7d, $5, $21, $7c, -db $5, $21, $7a, $5, $21, $78, $4, $21, $77, $4, $21, $75, $4, $21, $73, $4, $22, $71, -db $4, $22, $6f, $4, $22, $6d, $4, $22, $6b, $4, $22, $69, $4, $22, $67, $4, $22, $64, -db $4, $22, $62, $4, $22, $60, $4, $22, $5e, $4, $22, $5b, $4, $22, $59, $4, $22, $57, -db $4, $22, $54, $4, $22, $52, $4, $22, $50, $4, $22, $4d, $4, $22, $4b, $4, $22, $49, -db $4, $22, $46, $4, $22, $44, $4, $22, $42, $4, $22, $3f, $4, $22, $3d, $4, $22, $3b, -db $4, $22, $39, $4, $22, $36, $4, $22, $34, $4, $22, $32, $4, $21, $30, $4, $21, $2e, -db $4, $21, $2c, $4, $21, $2a, $4, $21, $28, $5, $21, $27, $5, $21, $25, $5, $21, $23, -db $5, $21, $22, $5, $21, $20, $5, $21, $1f, $5, $21, $1d, $5, $20, $1c, $5, $20, $1b, -db $5, $20, $1a, $5, $20, $19, $5, $20, $18, $5, $20, $17, $5, $20, $16, $5, $20, $15, -db $6, $20, $15, $6, $1f, $14, $6, $1f, $14, $6, $1f, $13, $6, $1f, $13, $6 - - -CardBackSprites: - 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,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa - db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa - - db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa - db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa - - db $00,$ff,$fe,$ff,$fe,$ff,$06,$ff,$f6,$ff,$56,$bf,$b6,$5f,$56,$bf - db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf - - db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa - db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa - - db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa - 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 $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf - - db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa - db $6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff - - db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa - db $aa,$55,$55,$aa,$aa,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff - - db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf - db $b6,$5f,$56,$bf,$b6,$5f,$f6,$ff,$06,$ff,$fe,$ff,$fe,$ff,$00,$ff - -CardBackSpritesEnd: diff --git a/generate_animation_circling.py b/generate_animation_circling.py index 916741d..0837cbd 100644 --- a/generate_animation_circling.py +++ b/generate_animation_circling.py @@ -7,7 +7,7 @@ center = (100, 64) spread_max = 8 spread_min = 4 -frame_count = 160 +frame_count = 255 for t in range(frame_count): e = ((spread_min + spread_max)/2) + (spread_max - spread_min)*0.5*sin(2*pi*t/frame_count) diff --git a/main.asm b/main.asm index 90c0204..4faf855 100644 --- a/main.asm +++ b/main.asm @@ -3,12 +3,12 @@ ; FF82 HIGH ; FF83 RET ; pattern repeats for the first 16 bytes so we can have some call vectors for the scene system -DEF SCENE_SETUP EQU $FF81 +DEF SCENE_SETUP EQU $c101 DEF SCENE_UPDATE EQU SCENE_SETUP + 4 ; call then ret is 3+1 bytes DEF SCENE_DRAW EQU SCENE_UPDATE + 4 DEF SCENE_TEARDOWN EQU SCENE_DRAW + 4 -DEF INTERRUPT_LCD EQU $FF91 +DEF INTERRUPT_LCD EQU $c111 DEF rMYBTN EQU $FFA8 DEF rMYBTNP EQU rMYBTN + 1 @@ -33,9 +33,12 @@ EntryPoint: ld [rNR52], a ; shut down audio ldh [rDIV], a ; reset timer just in case?? - ld a, [Instructions] ; get the value of a call instruction so we can shove it into our handles + ; set up the scene and interrupt vectors + ld hl, Instructions + + ld a, [hl] ; get the value of a call instruction so we can shove it into our handles ld hl, SCENE_SETUP - 1 - ld [hl], a + ld [SCENE_SETUP - 1], a ld hl, SCENE_UPDATE - 1 ld [hl], a ld hl, SCENE_DRAW - 1 @@ -43,59 +46,60 @@ EntryPoint: ld hl, SCENE_TEARDOWN - 1 ld [hl], a ld hl, INTERRUPT_LCD - 1 - ld [hl], a - - ld a, [Instructions + 3] ; get the value of a ret instruction + ld [hl], a + + ld hl, Instructions + inc hl + + ld a, [hl] ; get the value of a call instruction so we can shove it into our handles + ld hl, SCENE_SETUP + ld [hl], a + ld hl, SCENE_UPDATE + ld [hl], a + ld hl, SCENE_DRAW + ld [hl], a + ld hl, SCENE_TEARDOWN + ld [hl], a + ld hl, INTERRUPT_LCD + ld [hl], a + + ld hl, Instructions + inc hl + inc hl + + ld a, [hl] ; get the value of a call instruction so we can shove it into our handles + ld hl, SCENE_SETUP + 1 + ld [hl], a + ld hl, SCENE_UPDATE + 1 + ld [hl], a + ld hl, SCENE_DRAW + 1 + ld [hl], a + ld hl, SCENE_TEARDOWN + 1 + ld [hl], a + ld hl, INTERRUPT_LCD + 1 + ld [hl], a + + ld hl, Instructions + inc hl + inc hl + inc hl + + ld a, [hl] ; get the value of a call instruction so we can shove it into our handles ld hl, SCENE_SETUP + 2 ld [hl], a ld hl, SCENE_UPDATE + 2 ld [hl], a ld hl, SCENE_DRAW + 2 ld [hl], a - ld hl, SCENE_TEARDOWN + 2 + ld hl, SCENE_TEARDOWN + 2 ld [hl], a ld hl, INTERRUPT_LCD + 2 - ld [hl], a + ld [hl], a ; set up our scene vectors - ld hl, SCENE_SETUP - ld de, ShuffleDeckSetup - ld a, e - ld [hl+], a - ld a, d - ld [hl+], a - ld hl, SCENE_UPDATE - ld de, ShuffleDeckUpdate - ld a, e - ld [hl+], a - ld a, d - ld [hl+], a - ld hl, SCENE_DRAW - ld de, ShuffleDeckDraw - ld a, e - ld [hl+], a - ld a, d - ld [hl+], a - ld hl, SCENE_TEARDOWN - ld de, ShuffleDeckTeardown - ld a, e - ld [hl+], a - ld a, d - ld [hl+], a + ld hl, ScreenMainMenu + call ChangeScene - ; set up the interrupt vector to just be ret. - ld hl, INTERRUPT_LCD - ld de, INTERRUPT_LCD + 2 - ld a, e - ld [hl+], a - ld a, d - ld [hl+], a - - ld b, 144 - call AwaitLine - - call SCENE_SETUP - 1 - Loop: di ; okay this is kinda sketchy. we want a delta time variable. @@ -153,7 +157,30 @@ Loop: call SCENE_DRAW - 1 ; hope this takes fewer than 9 scanlines! ; either way it's going to eat into the update timing jp Loop - +ChangeScene: ; hl should be a pointer to, in sequence, setup update draw teardown + call SCENE_TEARDOWN - 1 + + ld a, [hl+] + ld [SCENE_SETUP], a + ld a, [hl+] + ld [SCENE_SETUP+1], a + ld a, [hl+] + ld [SCENE_UPDATE], a + ld a, [hl+] + ld [SCENE_UPDATE+1], a + ld a, [hl+] + ld [SCENE_DRAW], a + ld a, [hl+] + ld [SCENE_DRAW+1], a + ld a, [hl+] + ld [SCENE_TEARDOWN], a + ld a, [hl+] + ld [SCENE_TEARDOWN+1], a + + call SCENE_SETUP - 1 + + ret + AwaitLine: ; put the line you want to reach in b ld a, [rLY] cp b @@ -186,10 +213,34 @@ PrintBChars: ;write ascii characters. will not respect newlines or anything like dec b jp nz, PrintBChars ret + +;thanks to https://gbdev.io/pandocs/OAM_DMA_Transfer.html for this routine +; 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 +RunDMA: + push de + push af + ld hl, run_dma_tail + ld bc, run_dma_tail.run_dma_tail_end - run_dma_tail + call CopyRangeUnsafe + pop af +run_dma: ; This part must be in ROM. + ld bc, $2846 ; B: wait time; C: LOW($FF46) + ret ; we pushed de before, so this should "return" to execute that (HRAM) address + +run_dma_tail: ; This part must be in HRAM. + ldh [c], a +.wait + dec b + jr nz, .wait + ret z ; Conditional `ret` is 1 M-cycle slower, which avoids + ; reading from the stack on the last M-cycle of DMA. +.run_dma_tail_end -INCLUDE "CardReadScreen.inc" -INCLUDE "ShuffleDeckScreen.inc" Instructions: - call Instructions + 2 + call SCENE_UPDATE + 2 ret +INCLUDE "ScreenMainMenu.inc" +INCLUDE "ScreenCardRead.inc" +INCLUDE "ScreenSpreadSelect.inc" \ No newline at end of file diff --git a/screendesigns.aseprite b/screendesigns.aseprite index db91f0c..8b1a975 100644 Binary files a/screendesigns.aseprite and b/screendesigns.aseprite differ diff --git a/tileset.asm b/tileset.asm new file mode 100644 index 0000000..31f814e --- /dev/null +++ b/tileset.asm @@ -0,0 +1,33 @@ + ; original export script by gabriel reis, modified by shoofle + + +tileset: + + 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,$22,$00,$00,$00 + db $02,$00,$00,$00,$02,$00,$00,$00,$02,$00,$55,$00,$aa,$00,$04,$00 + db $02,$00,$04,$00,$02,$00,$04,$00,$02,$00,$55,$00,$ff,$00,$04,$00 + db $02,$00,$04,$00,$02,$00,$06,$00,$02,$00,$57,$00,$ff,$00,$06,$00 + db $02,$00,$06,$00,$02,$00,$06,$00,$02,$00,$57,$00,$ff,$00,$06,$00 + + + +BackgroundCopyCopy: + 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 $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 $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 + db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 + db $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02 + db $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03 + db $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05 + db $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05