Redo SFX engine & speed curves.

This commit is contained in:
Randy Thiemann 2023-10-24 13:35:51 +02:00
parent c6f5cf66b9
commit f46488e19d
9 changed files with 1468 additions and 335 deletions

View File

@ -107,6 +107,9 @@ sOption3::
db "NONE" db "NONE"
sOption4:: sOption4::
db "DMGT" db "DMGT"
db "TGM1"
db "DEAT"
db "SHIR"
sOption5:: sOption5::
db " NO" db " NO"
db " YES" db " YES"
@ -136,6 +139,158 @@ sPieceYOffsets:: ; How to draw each piece. Y-offsets of the sprites.
db 0, 7, 0, 7 ; O db 0, 7, 0, 7 ; O
db 0, 0, 7, 0 ; T db 0, 0, 7, 0 ; T
sTGM1SpeedCurve::
dw $0000, 0, $0100
db 1, 64
db 30, 16, 30, 41
dw $0030, 30, $0100
db 1, 42
db 30, 16, 30, 41
dw $0035, 35, $0100
db 1, 32
db 30, 16, 30, 41
dw $0040, 40, $0100
db 1, 25
db 30, 16, 30, 41
dw $0060, 60, $0100
db 1, 16
db 30, 16, 30, 41
dw $0070, 70, $0100
db 1, 8
db 30, 16, 30, 41
dw $0080, 80, $0100
db 1, 5
db 30, 16, 30, 41
dw $0100, 100, $0200
db 1, 3
db 30, 16, 30, 41
dw $0160, 160, $0200
db 1, 2
db 30, 16, 30, 41
dw $0200, 200, $0300
db 1, 64
db 30, 16, 30, 41
dw $0220, 220, $0300
db 1, 8
db 30, 16, 30, 41
dw $0230, 230, $0300
db 1, 4
db 30, 16, 30, 41
dw $0233, 233, $0300
db 1, 3
db 30, 16, 30, 41
dw $0236, 236, $0300
db 1, 2
db 30, 16, 30, 41
dw $0251, 251, $0300
db 1, 1
db 30, 16, 30, 41
dw $0300, 300, $0400
db 2, 1
db 30, 16, 30, 41
dw $0330, 330, $0400
db 3, 1
db 30, 16, 30, 41
dw $0360, 360, $0400
db 4, 1
db 30, 16, 30, 41
dw $0400, 400, $0500
db 5, 1
db 30, 16, 30, 41
dw $0420, 420, $0500
db 4, 1
db 30, 16, 30, 41
dw $0450, 450, $0500
db 3, 1
db 30, 16, 30, 41
dw $0500, 500, $0600
db 20, 1
db 30, 16, 30, 41
sTGM1SpeedCurveEnd::
dw $FFFF
sDEATSpeedCurve::
dw $0000, 0, $0100
db 20, 1
db 18, 12, 30, 12
dw $0100, 0, $0200
db 20, 1
db 14, 12, 25, 6
dw $0200, 0, $0300
db 20, 1
db 14, 11, 20, 6
dw $0300, 0, $0400
db 20, 1
db 8, 10, 18, 6
dw $0400, 0, $0500
db 20, 1
db 7, 8, 14, 5
dw $0500, 0, $0600
db 20, 1
db 6, 8, 14, 4
sDEATSpeedCurveEnd::
dw $FFFF
sSHIRSpeedCurve::
dw $0000, 0, $0100
db 20, 1
db 12, 10, 18, 6
dw $0100, 100, $0200
db 20, 1
db 12, 8, 18, 5
dw $0200, 200, $0300
db 20, 1
db 12, 8, 16, 4
dw $0300, 300, $0400
db 20, 1
db 6, 8, 14, 4
dw $0500, 500, $0600
db 20, 1
db 6, 6, 12, 2
dw $1100, 1100, $1200
db 20, 1
db 6, 6, 10, 2
dw $1200, 1200, $1300
db 20, 1
db 6, 6, 8, 2
sSHIRSpeedCurveEnd::
dw $FFFF
sSpeedCurve:: ; Speed curve of the game. sSpeedCurve:: ; Speed curve of the game.
dw $0000, 0, $0100 ; Level 0000 dw $0000, 0, $0100 ; Level 0000
db 1, 16 ; 1G every 16 frames db 1, 16 ; 1G every 16 frames

View File

@ -1255,6 +1255,9 @@ FieldProcess::
ldh [hCurrentPieceY], a ldh [hCurrentPieceY], a
xor a, a xor a, a
ldh [hCurrentLockDelayRemaining], a ldh [hCurrentLockDelayRemaining], a
ldh a, [hCurrentGravityPerTick]
cp a, 1
jp nz, .draw
call SFXKill call SFXKill
ld a, SFX_LOCK ld a, SFX_LOCK
call SFXEnqueue call SFXEnqueue
@ -1339,8 +1342,11 @@ FieldProcess::
.playfirmdropsound .playfirmdropsound
ldh a, [hCurrentLockDelay] ldh a, [hCurrentLockDelay]
ldh [hCurrentLockDelayRemaining], a ldh [hCurrentLockDelayRemaining], a
ldh a, [hCurrentGravityPerTick]
cp a, 1
jr nz, .postcheckforfirmdropsound
call SFXKill call SFXKill
ld a, SFX_MOVE ld a, SFX_LAND
call SFXEnqueue call SFXEnqueue
; If the down button is held, lock. ; If the down button is held, lock.
@ -1385,6 +1391,9 @@ FieldProcess::
; Play the locking sound and draw the piece. ; Play the locking sound and draw the piece.
.dolock .dolock
ldh a, [hCurrentGravityPerTick]
cp a, 1
jr nz, .draw
call SFXKill call SFXKill
ld a, SFX_LOCK ld a, SFX_LOCK
call SFXEnqueue call SFXEnqueue
@ -1915,11 +1924,14 @@ FieldDelay::
ret nz ret nz
call ClearLines call ClearLines
ldh a, [hCurrentGravityPerTick]
cp a, 1
jr nz, :+
call SFXKill call SFXKill
ld a, SFX_DROP ld a, SFX_LINE_CLEAR
call SFXEnqueue call SFXEnqueue
ldh a, [hCurrentARE] : ldh a, [hCurrentARE]
ldh [hRemainingDelay], a ldh [hRemainingDelay], a

View File

@ -130,15 +130,15 @@ DEF PIECE_O EQU 5
DEF PIECE_T EQU 6 DEF PIECE_T EQU 6
DEF PIECE_NONE EQU 255 DEF PIECE_NONE EQU 255
DEF SFX_IRS EQU 7 DEF SFX_IRS EQU $80
DEF SFX_DROP EQU 8 DEF SFX_IHS EQU 10
DEF SFX_LOCK EQU 9 DEF SFX_LINE_CLEAR EQU 11
DEF SFX_BELL EQU 10 DEF SFX_LAND EQU 12
DEF SFX_MOVE EQU 11 DEF SFX_LOCK EQU 13
DEF SFX_RANK_UP EQU 12 DEF SFX_LEVELLOCK EQU 14
DEF SFX_LEVEL_UP EQU 13 DEF SFX_LEVELUP EQU 15
DEF SFX_IHS EQU 14 DEF SFX_RANKUP EQU 16
DEF SFX_READY_GO EQU 15 DEF SFX_READYGO EQU 17
DEF STACK_SIZE EQU 64 DEF STACK_SIZE EQU 64
DEF GAME_OVER_R10 EQU 133 DEF GAME_OVER_R10 EQU 133
@ -172,7 +172,10 @@ DEF DROP_MODE_NONE EQU 2
DEF DROP_MODE_COUNT EQU 3 DEF DROP_MODE_COUNT EQU 3
DEF SCURVE_DMGT EQU 0 DEF SCURVE_DMGT EQU 0
DEF SCURVE_COUNT EQU 1 DEF SCURVE_TGM1 EQU 1
DEF SCURVE_DEAT EQU 2
DEF SCURVE_SHIR EQU 3
DEF SCURVE_COUNT EQU 4
DEF TILE_HIG_MODE_BASE EQU 232 DEF TILE_HIG_MODE_BASE EQU 232
DEF HIG_MODE_OFF EQU 0 DEF HIG_MODE_OFF EQU 0

View File

@ -192,7 +192,7 @@ LevelUp::
ldh [hCLevel+2], a ldh [hCLevel+2], a
ldh [hCLevel+3], a ldh [hCLevel+3], a
call DoSpeedUp call DoSpeedUp
ld a, SFX_RANK_UP ld a, SFX_RANKUP
call SFXEnqueue call SFXEnqueue
ret ret
@ -221,7 +221,7 @@ LevelUp::
jr nz, .checkspeedup jr nz, .checkspeedup
ld a, $FF ld a, $FF
ldh [hRequiresLineClear], a ldh [hRequiresLineClear], a
ld a, SFX_BELL ld a, SFX_LEVELLOCK
call SFXEnqueue call SFXEnqueue
jr .leveljinglemaybe jr .leveljinglemaybe
@ -257,7 +257,7 @@ LevelUp::
jr nz, .leveljinglemaybe jr nz, .leveljinglemaybe
ld a, $FF ld a, $FF
ldh [hRequiresLineClear], a ldh [hRequiresLineClear], a
ld a, SFX_BELL ld a, SFX_LEVELLOCK
call SFXEnqueue call SFXEnqueue
.leveljinglemaybe .leveljinglemaybe
@ -266,7 +266,7 @@ LevelUp::
ldh a, [hCLevel+1] ldh a, [hCLevel+1]
cp a, b cp a, b
jr z, .checkspeedup jr z, .checkspeedup
ld a, SFX_LEVEL_UP ld a, SFX_LEVELUP
call SFXEnqueue call SFXEnqueue
.checkspeedup .checkspeedup

View File

@ -187,7 +187,6 @@ sfx_names = [
"sSFXLevelLock", "sSFXLevelLock",
"sSFXLevelUp", "sSFXLevelUp",
"sSFXRankUp", "sSFXRankUp",
"sSFXIHS",
"sSFXReadyGo", "sSFXReadyGo",
] ]

View File

@ -185,7 +185,7 @@ IncreaseScore::
; If it has, reset the score. ; If it has, reset the score.
xor a, a xor a, a
ldh [hScore], a ldh [hScore], a
ld a, SFX_RANK_UP ld a, SFX_RANKUP
call SFXEnqueue call SFXEnqueue
ret ret

File diff suppressed because it is too large Load Diff

View File

@ -41,10 +41,10 @@ hCurrentPieceY:: ds 1
hCurrentPieceRotationState:: ds 1 hCurrentPieceRotationState:: ds 1
hHeldPiece:: ds 1 hHeldPiece:: ds 1
hHoldSpent:: ds 1 hHoldSpent:: ds 1
hSkipJingle: ds 1
hMode: ds 1 hMode: ds 1
hModeCounter: ds 1 hModeCounter: ds 1
hPrePause: ds 1 hPrePause: ds 1
hRequestedJingle: ds 1
SECTION "Gameplay Functions", ROM0 SECTION "Gameplay Functions", ROM0
@ -158,7 +158,7 @@ leadyMode:
cp a, LEADY_TIME cp a, LEADY_TIME
jr nz, :+ jr nz, :+
call SFXKill call SFXKill
ld a, SFX_READY_GO ld a, SFX_READYGO
call SFXEnqueue call SFXEnqueue
ldh a, [hModeCounter] ldh a, [hModeCounter]
: dec a : dec a
@ -205,12 +205,13 @@ postGoMode:
; 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
ldh [hRequestedJingle], a
ld a, 5 ld a, 5
ldh [hCurrentPieceX], a ldh [hCurrentPieceX], a
ld a, 3 ld a, 3
ldh [hCurrentPieceY], a ldh [hCurrentPieceY], a
xor a, a xor a, a
ldh [hSkipJingle], a
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
ldh [hHoldSpent], a ldh [hHoldSpent], a
@ -219,10 +220,14 @@ prefetchedPieceMode:
.checkIHS .checkIHS
ldh a, [hSelectState] ldh a, [hSelectState]
cp a, 0 cp a, 0
jr z, .checkIRSA jr z, .loaddefaultjingle
call DoHold call DoHold
; Holding does its own IRS check. jr .postjingle
jr .checkJingle
; Enqueue the jingle.
.loaddefaultjingle
ldh a, [hNextPiece]
ldh [hRequestedJingle], a
; Check if IRS is requested. ; Check if IRS is requested.
; Apply the rotation if so. ; Apply the rotation if so.
@ -246,8 +251,12 @@ prefetchedPieceMode:
.cp1 .cp1
ld a, 3 ld a, 3
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
ldh a, [hNextPiece]
ld b, a
ld a, SFX_IRS ld a, SFX_IRS
call SFXEnqueue or a, b
ldh [hRequestedJingle], a
jr .postjingle
.checkIRSB .checkIRSB
ld a, [wSwapABState] ld a, [wSwapABState]
@ -256,33 +265,27 @@ prefetchedPieceMode:
.lda2 .lda2
ldh a, [hAState] ldh a, [hAState]
cp a, 0 cp a, 0
jr z, .checkJingle jr z, .postjingle
ld a, $FF ld a, $FF
ldh [hAState], a ldh [hAState], a
jr .cp2 jr .cp2
.ldb2 .ldb2
ldh a, [hBState] ldh a, [hBState]
cp a, 0 cp a, 0
jr z, .checkJingle jr z, .postjingle
ld a, $FF ld a, $FF
ldh [hBState], a ldh [hBState], a
.cp2 .cp2
ld a, 1 ld a, 1
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
.checkJingle
ldh a, [hSkipJingle]
cp a, 0
jr nz, .skipJingle
.playNextJingle
ldh a, [hCurrentGravityPerTick]
cp a, 1
jr nz, .skipJingle
ldh a, [hNextPiece] ldh a, [hNextPiece]
call SFXEnqueue ld b, a
.skipJingle ld a, SFX_IRS
or a, b
ldh [hRequestedJingle], a
jr .postjingle
.postjingle
ld a, MODE_SPAWN_PIECE ld a, MODE_SPAWN_PIECE
ldh [hMode], a ldh [hMode], a
; State falls through to the next. ; State falls through to the next.
@ -299,6 +302,15 @@ spawnPieceMode:
: ld a, MODE_PIECE_IN_MOTION : ld a, MODE_PIECE_IN_MOTION
ldh [hMode], a ldh [hMode], a
; Play the next jingle... maybe!
ldh a, [hHoldSpent]
cp a, $FF
jr z, pieceInMotionMode
ldh a, [hRequestedJingle]
cp a, $FF
jr z, pieceInMotionMode
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.
@ -327,8 +339,6 @@ pieceInMotionMode:
ldh [hCurrentPieceX], a ldh [hCurrentPieceX], a
ld a, 3 ld a, 3
ldh [hCurrentPieceY], a ldh [hCurrentPieceY], a
xor a, a
ldh [hSkipJingle], a
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
call DoHold call DoHold
ld a, MODE_SPAWN_PIECE ld a, MODE_SPAWN_PIECE
@ -538,8 +548,6 @@ DoHold:
; Mark hold as spent. ; Mark hold as spent.
ld a, $FF ld a, $FF
ldh [hHoldSpent], a ldh [hHoldSpent], a
ld a, SFX_IHS
call SFXEnqueue
; Check if IRS is requested. ; Check if IRS is requested.
; Apply the rotation if so. ; Apply the rotation if so.
@ -563,7 +571,8 @@ DoHold:
.cp3 .cp3
ld a, 3 ld a, 3
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS call SFXKill
ld a, SFX_IRS | SFX_IHS
call SFXEnqueue call SFXEnqueue
jr .doHoldOperation jr .doHoldOperation
@ -587,11 +596,15 @@ DoHold:
.cp4 .cp4
ld a, 1 ld a, 1
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS call SFXKill
ld a, SFX_IRS | SFX_IHS
call SFXEnqueue call SFXEnqueue
jr .doHoldOperation jr .doHoldOperation
.noRotation .noRotation
call SFXKill
ld a, SFX_IHS
call SFXEnqueue
ld a, 0 ld a, 0
ldh [hCurrentPieceRotationState], a ldh [hCurrentPieceRotationState], a
@ -602,8 +615,6 @@ DoHold:
ldh [hHeldPiece], a ldh [hHeldPiece], a
ld a, b ld a, b
ldh [hCurrentPiece], a ldh [hCurrentPiece], a
ld a, $FF
ldh [hSkipJingle], a
ret ret

View File

@ -114,6 +114,9 @@ SwitchToTitle::
; GBC init ; GBC init
call GBCTitleInit call GBCTitleInit
; Make sure the speed curve is aimed at the right place.
call InitSpeedCurve
; Install the event loop handlers. ; Install the event loop handlers.
ld a, 0 ld a, 0
ldh [hGameState], a ldh [hGameState], a
@ -261,10 +264,12 @@ DecrementOption:
dec a dec a
ld [wSpeedCurveState], a ld [wSpeedCurveState], a
ld [rSpeedCurveState], a ld [rSpeedCurveState], a
call InitSpeedCurve
jp EventLoopPostHandler jp EventLoopPostHandler
: ld a, SCURVE_COUNT-1 : ld a, SCURVE_COUNT-1
ld [wSpeedCurveState], a ld [wSpeedCurveState], a
ld [rSpeedCurveState], a ld [rSpeedCurveState], a
call InitSpeedCurve
jp EventLoopPostHandler jp EventLoopPostHandler
.opt5 .opt5
@ -372,10 +377,12 @@ IncrementOption:
inc a inc a
ld [wSpeedCurveState], a ld [wSpeedCurveState], a
ld [rSpeedCurveState], a ld [rSpeedCurveState], a
call InitSpeedCurve
jp EventLoopPostHandler jp EventLoopPostHandler
: xor a, a : xor a, a
ld [wSpeedCurveState], a ld [wSpeedCurveState], a
ld [rSpeedCurveState], a ld [rSpeedCurveState], a
call InitSpeedCurve
jp EventLoopPostHandler jp EventLoopPostHandler
.opt5 .opt5
@ -411,30 +418,96 @@ IncrementLevel:
ldh [hStartSpeed+1], a ldh [hStartSpeed+1], a
jr CheckLevelRange jr CheckLevelRange
InitSpeedCurve:
ld a, [wSpeedCurveState]
cp a, 0
jr nz, :+
ld hl, sSpeedCurve
jr .set
: cp a, 1
jr nz, :+
ld hl, sTGM1SpeedCurve
jr .set
: cp a, 2
jr nz, :+
ld hl, sDEATSpeedCurve
jr .set
: ld hl, sSHIRSpeedCurve
.set
ld a, l
ldh [hStartSpeed], a
ld a, h
ldh [hStartSpeed+1], a
ret
GetEnd:
ld a, [wSpeedCurveState]
cp a, 0
jr nz, :+
ld bc, sSpeedCurveEnd
ret
: cp a, 1
jr nz, :+
ld bc, sTGM1SpeedCurveEnd
ret
: cp a, 2
jr nz, :+
ld bc, sDEATSpeedCurveEnd
ret
: ld bc, sSHIRSpeedCurveEnd
ret
GetStart:
ld a, [wSpeedCurveState]
cp a, 0
jr nz, :+
ld hl, sSpeedCurve
ret
: cp a, 1
jr nz, :+
ld hl, sTGM1SpeedCurve
ret
: cp a, 2
jr nz, :+
ld hl, sDEATSpeedCurve
ret
: ld hl, sSHIRSpeedCurve
ret
CheckLevelRange: CheckLevelRange:
; At end? ; At end?
ld bc, sSpeedCurveEnd call GetEnd
ldh a, [hStartSpeed] ldh a, [hStartSpeed]
cp a, c cp a, c
jr nz, .notatend jr nz, .notatend
ldh a, [hStartSpeed+1] ldh a, [hStartSpeed+1]
cp a, b cp a, b
jr nz, .notatend jr nz, .notatend
ld hl, sSpeedCurve call GetStart
ld a, l ld a, l
ldh [hStartSpeed], a ldh [hStartSpeed], a
ld a, h ld a, h
ldh [hStartSpeed+1], a ldh [hStartSpeed+1], a
.notatend .notatend
ld bc, sSpeedCurve-12 ld de, -12
call GetStart
add hl, de
ldh a, [hStartSpeed] ldh a, [hStartSpeed]
cp a, c cp a, l
jr nz, .notatstart jr nz, .notatstart
ldh a, [hStartSpeed+1] ldh a, [hStartSpeed+1]
cp a, b cp a, h
jr nz, .notatstart jr nz, .notatstart
ld hl, sSpeedCurveEnd-12
call GetEnd
ld h, b
ld l, c
add hl, de
ld a, l ld a, l
ldh [hStartSpeed], a ldh [hStartSpeed], a
ld a, h ld a, h