background loading for main menu

This commit is contained in:
Shoofle 2025-10-04 13:15:14 -04:00
parent 2bc8134741
commit d6c623734f
2 changed files with 98 additions and 111 deletions

View File

@ -27,120 +27,16 @@ ScreenMainMenu:
dw MainMenuTeardown
MainMenuSetup:
; Turn the LCD off
ld hl, rLCDC
bit 7, [hl]
jp z, .screenOff
.busyWait
ld a, [rLY]
cp a, 143
;jp c, .busyWait
.screenOff:
ld a, 0
ldh [rLCDC], a
call Async_Kill ; ensure we're not loading anything elsewhere
call Async_Kill
ld a, BANK("Main Menu Data")
ld [rROMB0], a
ld hl, SquaresTileset8
ld de, _VRAM + $1000 + $10
ld bc, SquaresTilesetEnd - SquaresTileset8
;println "the diff is ", SquaresTilesetEnd - SquaresTileset8
ld hl, ZEROES
ld de, MY_OAM
ld bc, $100
call CopyRange
def spacing equ $12
ld hl, CardBackSprites24 ; source
def TileStartCardBackSprites24 equ 0
ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy
ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy
call CopyRange
ld hl, CardBackSprites23
def TileStartCardBackSprites23 equ TileStartCardBackSprites24 + spacing
ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy
ld bc, CardBackSprites23End - CardBackSprites23
call CopyRange
ld hl, CardBackSprites22
def TileStartCardBackSprites22 equ TileStartCardBackSprites23 + spacing
ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy
ld bc, CardBackSprites22End - CardBackSprites22
call CopyRange
ld hl, CardBackSprites21
def TileStartCardBackSprites21 equ TileStartCardBackSprites22 + spacing
ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy
ld bc, CardBackSprites21End - CardBackSprites21
call CopyRange
ld hl, CardBackSprites20
def TileStartCardBackSprites20 equ TileStartCardBackSprites21 + spacing
ld de, $8000 + TileStartCardBackSprites20*$10
ld bc, CardBackSprites20End - CardBackSprites20
call CopyRange
ld hl, CardBackSprites19
def TileStartCardBackSprites19 equ TileStartCardBackSprites20 + spacing
ld de, $8000 + TileStartCardBackSprites19*$10
ld bc, CardBackSprites19End - CardBackSprites19
call CopyRange
ld hl, CardBackSprites18
def TileStartCardBackSprites18 equ TileStartCardBackSprites19 + spacing
ld de, $8000 + TileStartCardBackSprites18*$10
ld bc, CardBackSprites18End - CardBackSprites18
call CopyRange
ld hl, CardBackSprites17
def TileStartCardBackSprites17 equ TileStartCardBackSprites18 + spacing
ld de, $8000 + TileStartCardBackSprites17*$10
ld bc, CardBackSprites17End - CardBackSprites17
call CopyRange
def TileStartCardBackSprites16 equ TileStartCardBackSprites17 + spacing
ld hl, MainUITilemap
ld de, _SCRN0
ld b, 18
ld c, 20
call CopyTilesToMap
ld hl, StringRead
ld de, _SCRN0 + 32*11 + 4
call PrintString
ld hl, StringShuffle
ld de, _SCRN0 + 32*13 + 4
call PrintString
ld hl, StringBrowse
ld de, _SCRN0 + 32*15 + 4
call PrintString
; clear out the dma source
ld hl, MY_OAM
ld a, 0
:
ld [hl+], a
cp a, l
jp nz, :- ; this was clever. as long as a (0) doesn't equal l (low bit of address) we loop
; so this goes until l loops around to 0
ld de, SAFE_DMA_LOCATION
ld a, HIGH(MY_OAM)
call RunDMA
; set LCD and display registers
ld a, %11100100
ldh [rBGP], a
ldh [rOBP0], a
ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16
ldh [rLCDC], a
ld a, 0
ld [vFrameCount1], a ; first starts at 0
ld [vTime], a
@ -201,10 +97,94 @@ MainMenuSetup:
ld a, 0
ld [vFrameCountSquares], a
ld hl, MainMenuSetup.asyncTask
call Async_Spawn_HL
ld a, %11100100
ldh [rBGP], a
ldh [rOBP0], a
ldh a, [rLCDC]
or a, LCDCF_OBJ16 ;LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16
ldh [rLCDC], a
; load graphics into vram for deck face
; set up variables: LFSR stuff
ret
.asyncTask:
ld hl, MainUITilemap
ld de, _SCRN0
ld b, 18
ld c, 20
call CopyTilesToMap
ld hl, StringRead
ld de, _SCRN0 + 32*11 + 4
call PrintString
ld hl, StringShuffle
ld de, _SCRN0 + 32*13 + 4
call PrintString
ld hl, StringBrowse
ld de, _SCRN0 + 32*15 + 4
call PrintString
ld hl, SquaresTileset8
ld de, _VRAM + $1000 + $10
ld bc, SquaresTilesetEnd - SquaresTileset8
call CopyRange
def spacing equ $12
ld hl, CardBackSprites24 ; source
def TileStartCardBackSprites24 equ 0
ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy
ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy
call CopyRange
ld hl, CardBackSprites23
def TileStartCardBackSprites23 equ TileStartCardBackSprites24 + spacing
ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy
ld bc, CardBackSprites23End - CardBackSprites23
call CopyRange
ld hl, CardBackSprites22
def TileStartCardBackSprites22 equ TileStartCardBackSprites23 + spacing
ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy
ld bc, CardBackSprites22End - CardBackSprites22
call CopyRange
ld hl, CardBackSprites21
def TileStartCardBackSprites21 equ TileStartCardBackSprites22 + spacing
ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy
ld bc, CardBackSprites21End - CardBackSprites21
call CopyRange
ld hl, CardBackSprites20
def TileStartCardBackSprites20 equ TileStartCardBackSprites21 + spacing
ld de, $8000 + TileStartCardBackSprites20*$10
ld bc, CardBackSprites20End - CardBackSprites20
call CopyRange
ld hl, CardBackSprites19
def TileStartCardBackSprites19 equ TileStartCardBackSprites20 + spacing
ld de, $8000 + TileStartCardBackSprites19*$10
ld bc, CardBackSprites19End - CardBackSprites19
call CopyRange
ld hl, CardBackSprites18
def TileStartCardBackSprites18 equ TileStartCardBackSprites19 + spacing
ld de, $8000 + TileStartCardBackSprites18*$10
ld bc, CardBackSprites18End - CardBackSprites18
call CopyRange
ld hl, CardBackSprites17
def TileStartCardBackSprites17 equ TileStartCardBackSprites18 + spacing
ld de, $8000 + TileStartCardBackSprites17*$10
ld bc, CardBackSprites17End - CardBackSprites17
call CopyRange
def TileStartCardBackSprites16 equ TileStartCardBackSprites17 + spacing
ret
MainMenuUpdate:
; if pressing a key and unblocked:

View File

@ -260,6 +260,13 @@ EntryPoint:
ld hl, CARD_PRINT_PREP + 2
ld [hl], a
ld a, %11100100
ldh [rBGP], a
ldh [rOBP0], a
ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
ldh [rLCDC], a
; set up our scene handle
ld hl, ScreenMainMenu
call ChangeScene