Code clean up. Special Color Tiles. Spurious bugfixes.

This commit is contained in:
Randy Thiemann 2023-10-30 14:54:06 +01:00
parent 9386c1bc98
commit b5ffdb9473
10 changed files with 4754 additions and 392 deletions

2
.gitignore vendored
View File

@ -4,6 +4,4 @@
/tools/** /tools/**
/src/res/sources/*.z80 /src/res/sources/*.z80
/src/res/sources/*.inc /src/res/sources/*.inc
/bin/*.map
/bin/*.sym
/bin/*.sav /bin/*.sav

Binary file not shown.

2220
bin/DMGTRIS.map Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

1882
bin/DMGTRIS.sym Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -92,6 +92,16 @@ Main::
ld bc, sTilesEnd - sTiles ld bc, sTilesEnd - sTiles
call SafeMemCopy call SafeMemCopy
; GBC uses a few different tiles.
ld a, [wInitialA]
cp a, $11
jr nz, .nocolortiles
ld de, sColorTiles
ld hl, _VRAM + (TILE_PIECE_0 * 16)
ld bc, sColorTilesEnd - sColorTiles
call SafeMemCopy
.nocolortiles
; Clear OAM. ; Clear OAM.
call ClearOAM call ClearOAM
call SetNumberSpritePositions call SetNumberSpritePositions

View File

@ -22,7 +22,7 @@ DEF TILES_INC EQU 1
INCLUDE "globals.asm" INCLUDE "globals.asm"
SECTION "Tile data", ROMX, BANK[BANK_OTHER] SECTION "Static Global data", ROMX, BANK[BANK_OTHER]
; Speed curve data is defined as follows: ; Speed curve data is defined as follows:
; N blocks of: ; N blocks of:
; dw BCD_START_LEVEL, START_LEVEL, BCD_NEXT_100_LEVEL_BREAKPOINT ; dw BCD_START_LEVEL, START_LEVEL, BCD_NEXT_100_LEVEL_BREAKPOINT
@ -1140,5 +1140,120 @@ sTiles::
DB $0A,$0A,$04,$04,$0A,$0A,$00,$00 DB $0A,$0A,$04,$04,$0A,$0A,$00,$00
sTilesEnd:: sTilesEnd::
sColorTiles::
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$7E,$81,$00,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $01,$FF,$7F,$81,$7F,$81,$7F,$81
DB $7F,$81,$7F,$81,$7F,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $7E,$81,$FE,$AB,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$7E,$81
DB $FE,$AB,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$7E,$81,$FE,$AB
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$7E,$81,$FE,$AB,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $00,$FF,$FE,$AB,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
DB $AA,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$00,$00
sColorTilesEnd::
ENDC ENDC

BIN
src/res/sources/tiles_c.gbr Normal file

Binary file not shown.

View File

@ -89,13 +89,14 @@ SwitchToGameplayB:
; Turn the screen off if it's on. ; Turn the screen off if it's on.
ldh a, [rLCDC] ldh a, [rLCDC]
and LCDCF_ON and LCDCF_ON
jr z, :+ ; Screen is already off. jr z, .loadtilemap ; Screen is already off.
wait_vram wait_vram
xor a, a xor a, a
ldh [rLCDC], a ldh [rLCDC], a
; Load the gameplay tilemap. ; Load the gameplay tilemap.
: ld de, sGameplayTileMap .loadtilemap
ld de, sGameplayTileMap
ld hl, $9800 ld hl, $9800
ld bc, sGameplayTileMapEnd - sGameplayTileMap ld bc, sGameplayTileMapEnd - sGameplayTileMap
call UnsafeMemCopy call UnsafeMemCopy
@ -161,58 +162,61 @@ GamePlayEventLoopHandlerB::
jp hl jp hl
.modejumps .modejumps
jp leadyMode jp .leadyMode
jp goMode jp .goMode
jp postGoMode jp .postGoMode
jp prefetchedPieceMode jp .prefetchedPieceMode
jp spawnPieceMode jp .spawnPieceMode
jp pieceInMotionMode jp .pieceInMotionMode
jp delayMode jp .delayMode
jp gameOverMode jp .gameOverMode
jp preGameOverMode jp .preGameOverMode
jp pauseMode jp .pauseMode
; Draw "READY" and wait a bit. ; Draw "READY" and wait a bit.
leadyMode: .leadyMode
ldh a, [hModeCounter] ldh a, [hModeCounter]
cp a, LEADY_TIME cp a, LEADY_TIME
jr nz, :+ jr nz, .firstleadyiterskip
call SFXKill call SFXKill
ld a, SFX_READYGO ld a, SFX_READYGO
call SFXEnqueue call SFXEnqueue
ldh a, [hModeCounter] ldh a, [hModeCounter]
: dec a .firstleadyiterskip
jr nz, :+ dec a
jr nz, .notdoneleady
ld a, MODE_GO ld a, MODE_GO
ldh [hMode], a ldh [hMode], a
ld a, GO_TIME ld a, GO_TIME
: ldh [hModeCounter], a .notdoneleady
ldh [hModeCounter], a
ld de, sLeady ld de, sLeady
ld hl, wField+(14*10) ld hl, wField+(14*10)
ld bc, 10 ld bc, 10
call UnsafeMemCopy call UnsafeMemCopy
jp drawStaticInfo jp .drawStaticInfo
; Draw "GO" and wait a bit. ; Draw "GO" and wait a bit.
goMode: .goMode
ldh a, [hModeCounter] ldh a, [hModeCounter]
dec a dec a
jr nz, :+ jr nz, .notdonego
ld a, MODE_POSTGO ld a, MODE_POSTGO
ldh [hMode], a ldh [hMode], a
xor a, a xor a, a
: ldh [hModeCounter], a .notdonego
ldh [hModeCounter], a
ld de, sGo ld de, sGo
ld hl, wField+(14*10) ld hl, wField+(14*10)
ld bc, 10 ld bc, 10
call UnsafeMemCopy call UnsafeMemCopy
jp drawStaticInfo jp .drawStaticInfo
; Clear the field, fetch the piece, ready for gameplay. ; Clear the field, fetch the piece, ready for gameplay.
postGoMode: .postGoMode
ld a, MODE_PREFETCHED_PIECE ld a, MODE_PREFETCHED_PIECE
ldh [hMode], a ldh [hMode], a
call FieldClear call FieldClear
@ -220,11 +224,11 @@ postGoMode:
ldh a, [hNextPiece] ldh a, [hNextPiece]
ldh [hCurrentPiece], a ldh [hCurrentPiece], a
call GetNextPiece call GetNextPiece
jp drawStaticInfo jp .drawStaticInfo
; Fetch the next piece. ; Fetch the next piece.
prefetchedPieceMode: .prefetchedPieceMode
; A piece will spawn in the middle, at the top of the screen, not rotated by default. ; A piece will spawn in the middle, at the top of the screen, not rotated by default.
ld a, $FF ld a, $FF
ldh [hRequestedJingle], a ldh [hRequestedJingle], a
@ -313,48 +317,50 @@ prefetchedPieceMode:
; Spawn the piece. ; Spawn the piece.
spawnPieceMode: .spawnPieceMode
call TrySpawnPiece call TrySpawnPiece
cp a, $FF cp a, $FF
jr z, :+ jr z, .canspawn
ld a, MODE_PRE_GAME_OVER ld a, MODE_PRE_GAME_OVER
ldh [hMode], a ldh [hMode], a
jp drawStaticInfo jp .drawStaticInfo
: ld a, MODE_PIECE_IN_MOTION .canspawn
ld a, MODE_PIECE_IN_MOTION
ldh [hMode], a ldh [hMode], a
; Play the next jingle... maybe! ; Play the next jingle... maybe!
ldh a, [hHoldSpent] ldh a, [hHoldSpent]
cp a, $FF cp a, $FF
jr z, pieceInMotionMode jr z, .pieceInMotionMode
ldh a, [hRequestedJingle] ldh a, [hRequestedJingle]
cp a, $FF cp a, $FF
jr z, pieceInMotionMode jr z, .pieceInMotionMode
call SFXEnqueue call SFXEnqueue
; This mode lasts for as long as the piece is in motion. ; This mode lasts for as long as the piece is in motion.
; Field will let us know when it has locked in place. ; Field will let us know when it has locked in place.
pieceInMotionMode: .pieceInMotionMode
ldh a, [hStartState] ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nopauserequested
call ToBackupField call ToBackupField
ldh a, [hMode] ldh a, [hMode]
ldh [hPrePause], a ldh [hPrePause], a
ld a, MODE_PAUSED ld a, MODE_PAUSED
ldh [hMode], a ldh [hMode], a
jp drawStaticInfo jp .drawStaticInfo
: call FieldProcess .nopauserequested
call FieldProcess
; Do we hold? ; Do we hold?
ldh a, [hSelectState] ldh a, [hSelectState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nohold
ldh a, [hHoldSpent] ldh a, [hHoldSpent]
cp a, $FF cp a, $FF
jr z, :+ jr z, .nohold
; Reset position and rotation. ; Reset position and rotation.
ld a, PIECE_SPAWN_X ld a, PIECE_SPAWN_X
ldh [hCurrentPieceX], a ldh [hCurrentPieceX], a
@ -367,39 +373,40 @@ pieceInMotionMode:
ldh [hMode], a ldh [hMode], a
; Do we go into delay state? ; Do we go into delay state?
: ldh a, [hCurrentLockDelayRemaining] .nohold
ldh a, [hCurrentLockDelayRemaining]
cp a, 0 cp a, 0
jr nz, :+ jp nz, .drawStaticInfo
ld a, MODE_DELAY ld a, MODE_DELAY
ldh [hMode], a ldh [hMode], a
; No fall through this time. ; No fall through this time.
: jp drawStaticInfo jp .drawStaticInfo
delayMode: .delayMode
ldh a, [hStartState] ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nodelaypauserequested
call ToBackupField call ToBackupField
ldh a, [hMode] ldh a, [hMode]
ldh [hPrePause], a ldh [hPrePause], a
ld a, MODE_PAUSED ld a, MODE_PAUSED
ldh [hMode], a ldh [hMode], a
jp drawStaticInfo jp .drawStaticInfo
: call FieldDelay .nodelaypauserequested
call FieldDelay
ldh a, [hRemainingDelay] ldh a, [hRemainingDelay]
cp a, 0 cp a, 0
jr nz, :+ jp nz, .drawStaticInfo
ld a, MODE_PREFETCHED_PIECE ld a, MODE_PREFETCHED_PIECE
ldh [hMode], a ldh [hMode], a
jp .drawStaticInfo
: jp drawStaticInfo
preGameOverMode: .preGameOverMode
; Spawn the failed piece. ; Spawn the failed piece.
call ForceSpawnPiece call ForceSpawnPiece
@ -501,11 +508,11 @@ preGameOverMode:
ldh [hMode], a ldh [hMode], a
gameOverMode: .gameOverMode
; Retry? ; Retry?
ldh a, [hAState] ldh a, [hAState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .noretry
call RNGInit call RNGInit
call ScoreInit call ScoreInit
call LevelInit call LevelInit
@ -516,41 +523,44 @@ gameOverMode:
ldh [hMode], a ldh [hMode], a
ld a, LEADY_TIME ld a, LEADY_TIME
ldh [hModeCounter], a ldh [hModeCounter], a
jp drawStaticInfo jp .drawStaticInfo
; Quit ; Quit
: ldh a, [hBState] .noretry
ldh a, [hBState]
cp a, 1 cp a, 1
jp nz, drawStaticInfo jp nz, .drawStaticInfo
call SwitchToTitle call SwitchToTitle
jp EventLoopPostHandler jp EventLoopPostHandler
pauseMode: .pauseMode
; Quick reset. ; Quick reset.
ldh a, [hAState] ldh a, [hAState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
ldh a, [hBState] ldh a, [hBState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
ldh a, [hSelectState] ldh a, [hSelectState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
call SwitchToTitle call SwitchToTitle
jp EventLoopPostHandler jp EventLoopPostHandler
; Unpause ; Unpause
: ldh a, [hStartState] .noqr
ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nounpause
call FromBackupField call FromBackupField
ldh a, [hPrePause] ldh a, [hPrePause]
ldh [hMode], a ldh [hMode], a
jr drawStaticInfo jr .drawStaticInfo
; Draw PAUSE all over the field. ; Draw PAUSE all over the field.
: ld de, sPause .nounpause
ld de, sPause
ld hl, wField+(4*10) ld hl, wField+(4*10)
ld bc, 20 ld bc, 20
call UnsafeMemCopy call UnsafeMemCopy
@ -590,12 +600,11 @@ pauseMode:
ld hl, wField+(22*10) ld hl, wField+(22*10)
ld bc, 20 ld bc, 20
call UnsafeMemCopy call UnsafeMemCopy
jr drawStaticInfo
; Always draw the score, level, next piece, and held piece. ; Always draw the score, level, next piece, and held piece.
drawStaticInfo: .drawStaticInfo:
: ldh a, [hNextPiece] ldh a, [hNextPiece]
call ApplyNext call ApplyNext
ldh a, [hHeldPiece] ldh a, [hHeldPiece]
@ -624,21 +633,21 @@ DoHold:
; Check if IRS is requested. ; Check if IRS is requested.
; Apply the rotation if so. ; Apply the rotation if so.
.checkIRSHA .checkIRSA
ld a, [wSwapABState] ld a, [wSwapABState]
cp a, 0 cp a, 0
jr z, .lda3 jr z, .lda3
.ldb3 .ldb3
ldh a, [hBState] ldh a, [hBState]
cp a, 0 cp a, 0
jr z, .checkIRSHB jr z, .checkIRSB
ld a, $FF ld a, $FF
ldh [hBState], a ldh [hBState], a
jr .cp3 jr .cp3
.lda3 .lda3
ldh a, [hAState] ldh a, [hAState]
cp a, 0 cp a, 0
jr z, .checkIRSHB jr z, .checkIRSB
ld a, $FF ld a, $FF
ldh [hAState], a ldh [hAState], a
.cp3 .cp3
@ -649,7 +658,7 @@ DoHold:
call SFXEnqueue call SFXEnqueue
jr .doHoldOperation jr .doHoldOperation
.checkIRSHB .checkIRSB
ld a, [wSwapABState] ld a, [wSwapABState]
cp a, 0 cp a, 0
jr z, .ldb4 jr z, .ldb4
@ -698,13 +707,14 @@ SwitchToGameplayBigB:
; Turn the screen off if it's on. ; Turn the screen off if it's on.
ldh a, [rLCDC] ldh a, [rLCDC]
and LCDCF_ON and LCDCF_ON
jr z, :+ ; Screen is already off. jr z, .loadtilemap ; Screen is already off.
wait_vram wait_vram
xor a, a xor a, a
ldh [rLCDC], a ldh [rLCDC], a
; Load the gameplay tilemap. ; Load the gameplay tilemap.
: ld de, sBigGameplayTileMap .loadtilemap
ld de, sBigGameplayTileMap
ld hl, $9800 ld hl, $9800
ld bc, sBigGameplayTileMapEnd - sBigGameplayTileMap ld bc, sBigGameplayTileMapEnd - sBigGameplayTileMap
call UnsafeMemCopy call UnsafeMemCopy
@ -785,17 +795,19 @@ GamePlayBigEventLoopHandlerB:
.leadyMode .leadyMode
ldh a, [hModeCounter] ldh a, [hModeCounter]
cp a, LEADY_TIME cp a, LEADY_TIME
jr nz, :+ jr nz, .firstleadyiterskip
call SFXKill call SFXKill
ld a, SFX_READYGO ld a, SFX_READYGO
call SFXEnqueue call SFXEnqueue
ldh a, [hModeCounter] ldh a, [hModeCounter]
: dec a .firstleadyiterskip
jr nz, :+ dec a
jr nz, .notdoneleady
ld a, MODE_GO ld a, MODE_GO
ldh [hMode], a ldh [hMode], a
ld a, GO_TIME ld a, GO_TIME
: ldh [hModeCounter], a .notdoneleady
ldh [hModeCounter], a
ld de, sBigLeady ld de, sBigLeady
ld hl, wWideBlittedField+(10*10) ld hl, wWideBlittedField+(10*10)
ld bc, 10 ld bc, 10
@ -807,11 +819,12 @@ GamePlayBigEventLoopHandlerB:
.goMode .goMode
ldh a, [hModeCounter] ldh a, [hModeCounter]
dec a dec a
jr nz, :+ jr nz, .notdonego
ld a, MODE_POSTGO ld a, MODE_POSTGO
ldh [hMode], a ldh [hMode], a
xor a, a xor a, a
: ldh [hModeCounter], a .notdonego
ldh [hModeCounter], a
ld de, sBigGo ld de, sBigGo
ld hl, wWideBlittedField+(10*10) ld hl, wWideBlittedField+(10*10)
ld bc, 10 ld bc, 10
@ -924,11 +937,12 @@ GamePlayBigEventLoopHandlerB:
.spawnPieceMode .spawnPieceMode
call BigTrySpawnPiece call BigTrySpawnPiece
cp a, $FF cp a, $FF
jr z, :+ jr z, .canspawn
ld a, MODE_PRE_GAME_OVER ld a, MODE_PRE_GAME_OVER
ldh [hMode], a ldh [hMode], a
jp .drawStaticInfo jp .drawStaticInfo
: ld a, MODE_PIECE_IN_MOTION .canspawn
ld a, MODE_PIECE_IN_MOTION
ldh [hMode], a ldh [hMode], a
; Play the next jingle... maybe! ; Play the next jingle... maybe!
@ -946,7 +960,7 @@ GamePlayBigEventLoopHandlerB:
.pieceInMotionMode .pieceInMotionMode
ldh a, [hStartState] ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nopauserequested
call BigToBackupField call BigToBackupField
ldh a, [hMode] ldh a, [hMode]
ldh [hPrePause], a ldh [hPrePause], a
@ -954,15 +968,16 @@ GamePlayBigEventLoopHandlerB:
ldh [hMode], a ldh [hMode], a
jp .drawStaticInfo jp .drawStaticInfo
: call BigFieldProcess .nopauserequested
call BigFieldProcess
; Do we hold? ; Do we hold?
ldh a, [hSelectState] ldh a, [hSelectState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nohold
ldh a, [hHoldSpent] ldh a, [hHoldSpent]
cp a, $FF cp a, $FF
jr z, :+ jr z, .nohold
; Reset position and rotation. ; Reset position and rotation.
ld a, PIECE_SPAWN_X_BIG ld a, PIECE_SPAWN_X_BIG
ldh [hCurrentPieceX], a ldh [hCurrentPieceX], a
@ -975,20 +990,19 @@ GamePlayBigEventLoopHandlerB:
ldh [hMode], a ldh [hMode], a
; Do we go into delay state? ; Do we go into delay state?
: ldh a, [hCurrentLockDelayRemaining] .nohold
ldh a, [hCurrentLockDelayRemaining]
cp a, 0 cp a, 0
jr nz, :+ jp nz, .drawStaticInfo
ld a, MODE_DELAY ld a, MODE_DELAY
ldh [hMode], a ldh [hMode], a
; No fall through this time. ; No fall through this time.
: jp .drawStaticInfo
.delayMode .delayMode
ldh a, [hStartState] ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nodelaypauserequested
call BigToBackupField call BigToBackupField
ldh a, [hMode] ldh a, [hMode]
ldh [hPrePause], a ldh [hPrePause], a
@ -996,21 +1010,20 @@ GamePlayBigEventLoopHandlerB:
ldh [hMode], a ldh [hMode], a
jp .drawStaticInfo jp .drawStaticInfo
: call BigFieldDelay .nodelaypauserequested
call BigFieldDelay
ldh a, [hRemainingDelay] ldh a, [hRemainingDelay]
cp a, 0 cp a, 0
jr nz, :+ jp nz, .drawStaticInfo
ld a, MODE_PREFETCHED_PIECE ld a, MODE_PREFETCHED_PIECE
ldh [hMode], a ldh [hMode], a
: jp .drawStaticInfo
.preGameOverMode .preGameOverMode
; Spawn the failed piece. ; Spawn the failed piece.
call BigForceSpawnPiece call BigForceSpawnPiece
call WidenField call BigWidenField
; Draw the field in grey. ; Draw the field in grey.
; Yes. This really unrolls the loop that many times. ; Yes. This really unrolls the loop that many times.
@ -1114,7 +1127,7 @@ GamePlayBigEventLoopHandlerB:
; Retry? ; Retry?
ldh a, [hAState] ldh a, [hAState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .noretry
call RNGInit call RNGInit
call ScoreInit call ScoreInit
call LevelInit call LevelInit
@ -1128,7 +1141,8 @@ GamePlayBigEventLoopHandlerB:
jp .drawStaticInfo jp .drawStaticInfo
; Quit ; Quit
: ldh a, [hBState] .noretry
ldh a, [hBState]
cp a, 1 cp a, 1
jp nz, .drawStaticInfo jp nz, .drawStaticInfo
call SwitchToTitle call SwitchToTitle
@ -1139,27 +1153,29 @@ GamePlayBigEventLoopHandlerB:
; Quick reset. ; Quick reset.
ldh a, [hAState] ldh a, [hAState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
ldh a, [hBState] ldh a, [hBState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
ldh a, [hSelectState] ldh a, [hSelectState]
cp a, 0 cp a, 0
jr z, :+ jr z, .noqr
call SwitchToTitle call SwitchToTitle
jp EventLoopPostHandler jp EventLoopPostHandler
; Unpause ; Unpause
: ldh a, [hStartState] .noqr
ldh a, [hStartState]
cp a, 1 cp a, 1
jr nz, :+ jr nz, .nounpause
call BigFromBackupField call BigFromBackupField
ldh a, [hPrePause] ldh a, [hPrePause]
ldh [hMode], a ldh [hMode], a
jr .drawStaticInfo jr .drawStaticInfo
; Draw PAUSE all over the field. ; Draw PAUSE all over the field.
: ld de, sBigPause .nounpause
ld de, sBigPause
ld hl, wWideBlittedField ld hl, wWideBlittedField
ld bc, 20 ld bc, 20
call UnsafeMemCopy call UnsafeMemCopy
@ -1199,12 +1215,11 @@ GamePlayBigEventLoopHandlerB:
ld hl, wWideBlittedField+180 ld hl, wWideBlittedField+180
ld bc, 20 ld bc, 20
call UnsafeMemCopy call UnsafeMemCopy
jr .drawStaticInfo
; Always draw the score, level, next piece, and held piece. ; Always draw the score, level, next piece, and held piece.
.drawStaticInfo .drawStaticInfo
: ldh a, [hNextPiece] ldh a, [hNextPiece]
call ApplyNext call ApplyNext
ldh a, [hHeldPiece] ldh a, [hHeldPiece]
@ -1233,21 +1248,21 @@ BigDoHold:
; Check if IRS is requested. ; Check if IRS is requested.
; Apply the rotation if so. ; Apply the rotation if so.
.checkIRSHA .checkIRSA
ld a, [wSwapABState] ld a, [wSwapABState]
cp a, 0 cp a, 0
jr z, .lda3 jr z, .lda3
.ldb3 .ldb3
ldh a, [hBState] ldh a, [hBState]
cp a, 0 cp a, 0
jr z, .checkIRSHB jr z, .checkIRSB
ld a, $FF ld a, $FF
ldh [hBState], a ldh [hBState], a
jr .cp3 jr .cp3
.lda3 .lda3
ldh a, [hAState] ldh a, [hAState]
cp a, 0 cp a, 0
jr z, .checkIRSHB jr z, .checkIRSB
ld a, $FF ld a, $FF
ldh [hAState], a ldh [hAState], a
.cp3 .cp3
@ -1258,7 +1273,7 @@ BigDoHold:
call SFXEnqueue call SFXEnqueue
jr .doHoldOperation jr .doHoldOperation
.checkIRSHB .checkIRSB
ld a, [wSwapABState] ld a, [wSwapABState]
cp a, 0 cp a, 0
jr z, .ldb4 jr z, .ldb4