Compare commits

..

No commits in common. "9b347b9e76778ac2ead0ea712d73f1068c51ccbf" and "384a8fa80111fb681be0ca5f280ce45f09ba2a4f" have entirely different histories.

4 changed files with 140 additions and 191 deletions

View File

@ -53,7 +53,6 @@ hComboCt: ds 1
hLockDelayForce: ds 1
hHighestStack: ds 1
hDownFrames: ds 1
hStalePiece: ds 1
SECTION "Field Functions", ROM0
@ -503,7 +502,6 @@ ForceSpawnPiece::
TrySpawnPiece::
; Always reset these for a new piece.
xor a, a
ldh [hStalePiece], a
ldh [hDownFrames], a
ldh [hLockDelayForce], a
ldh a, [hCurrentLockDelay]
@ -662,7 +660,7 @@ FindMaxG:
ldh a, [hCurrentPieceX]
call XYToSFieldPtr
;DEF EXPERIMENTAL_OPTIMIZATION EQU 1
DEF EXPERIMENTAL_OPTIMIZATION EQU 1
IF DEF(EXPERIMENTAL_OPTIMIZATION)
; The stack height marker gives a lower bound to how far the piece can fall.
ldh a, [hHighestStack]
@ -688,6 +686,7 @@ IF DEF(EXPERIMENTAL_OPTIMIZATION)
jr .try
ENDC
.unoptimized
push hl
ld a, 1
@ -724,30 +723,128 @@ FieldProcess::
ldh [hYPosAtStartOfFrame], a
call FromShadowField
; Cleanup from last frame.
; Check if we're about to hold. Return if so.
ldh a, [hSelectState]
cp a, 1
jr nz, :+
ldh a, [hHoldSpent]
cp a, $FF
ret nz
; How deep can we go?
: call FindMaxG
; **************************************************************
; HANDLE UP
; Is a hard/sonic drop requested?
ldh a, [hUpState]
cp a, 1
jr nz, .postdrop
; What kind, if any?
ldh a, [hSimulationMode]
cp a, MODE_TGM1
jr z, .postdrop
cp a, MODE_HELL
jr z, .postdrop
cp a, MODE_TGW2
jr z, .harddrop
cp a, MODE_TGW3
jr z, .harddrop
cp a, MODE_EAWY
jr z, .harddrop
; Sonic drop.
.sonicdrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, 20
ldh [hWantedG], a
ldh a, [hTicksUntilG]
dec a
ldh [hTicksUntilG], a
jr nz, .grav
ldh a, [hCurrentFramesPerGravityTick]
ldh [hTicksUntilG], a
jr .grav
; Hard drop.
.harddrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, 20
ld b, a
ldh a, [hActualG]
cp a, b
jr nc, :+
ld b, a
: ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
xor a, a
ldh [hCurrentLockDelayRemaining], a
call SFXKill
ld a, SFX_LOCK
call SFXEnqueue
jp .draw
; If we press down, we want to do a soft drop.
.postdrop
ldh a, [hDownState]
cp a, 0
jr z, :+
ldh a, [hDownFrames]
inc a
ldh [hDownFrames], a
ld a, 1
ldh [hTicksUntilG], a
; Gravity?
: ldh a, [hTicksUntilG]
dec a
ldh [hTicksUntilG], a
jr nz, .nograv
ldh a, [hCurrentFramesPerGravityTick]
ldh [hTicksUntilG], a
ldh a, [hCurrentGravityPerTick]
ldh [hWantedG], a
; Can we drop the full requested distance?
.grav
ldh a, [hWantedG]
ld b, a
ldh a, [hActualG]
cp a, b
jr c, .smallg
; Yes. Do it.
.bigg
ldh a, [hWantedG]
ld b, a
ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
jr .nograv
; No. Smaller distance.
.smallg
ldh a, [hActualG]
ld b, a
ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
; No gravity, or post gravity.
.nograv
ldh a, [hCurrentPieceX]
ldh [hWantX], a
ldh a, [hCurrentPieceRotationState]
ldh [hWantRotation], a
; Is this the first frame of the piece?
ldh a, [hStalePiece]
cp a, 0
ld a, $FF
ldh [hStalePiece], a
jp z, .skipmovement
; **************************************************************
; HANDLE SELECT
; Check if we're about to hold. Return if so.
ldh a, [hSelectState]
cp a, 1
jr nz, .wantrotccw
ldh a, [hHoldSpent]
cp a, $FF
ret nz
; **************************************************************
; HANDLE ROTATION
@ -1135,122 +1232,10 @@ FieldProcess::
ldh [hCurrentPieceX], a
; **************************************************************
; HANDLE MAXIMUM FALL
; This little maneuver is going to cost us 51 years.
.skipmovement
.donemanipulating
: call FindMaxG
; **************************************************************
; HANDLE UP
; Is a hard/sonic drop requested?
ldh a, [hUpState]
cp a, 0
jr z, .postdrop
; What kind, if any?
ldh a, [hSimulationMode]
cp a, MODE_TGM1
jr z, .postdrop
cp a, MODE_HELL
jr z, .postdrop
cp a, MODE_TGW2
jr z, .harddrop
cp a, MODE_TGW3
jr z, .harddrop
cp a, MODE_EAWY
jr z, .harddrop
; Sonic drop.
.sonicdrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, 20
ldh [hWantedG], a
ldh a, [hTicksUntilG]
dec a
ldh [hTicksUntilG], a
jr nz, .grav
ldh a, [hCurrentFramesPerGravityTick]
ldh [hTicksUntilG], a
jr .grav
; Hard drop.
.harddrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, 20
ld b, a
ldh a, [hActualG]
cp a, b
jr nc, :+
ld b, a
: ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
xor a, a
ldh [hCurrentLockDelayRemaining], a
call SFXKill
ld a, SFX_LOCK
call SFXEnqueue
jp .draw
; If we press down, we want to do a soft drop.
.postdrop
ldh a, [hDownState]
cp a, 0
jr z, :+
ldh a, [hDownFrames]
inc a
ldh [hDownFrames], a
ld a, 1
ldh [hTicksUntilG], a
; Gravity?
: ldh a, [hTicksUntilG]
dec a
ldh [hTicksUntilG], a
jr nz, .nograv
ldh a, [hCurrentFramesPerGravityTick]
ldh [hTicksUntilG], a
ldh a, [hCurrentGravityPerTick]
ldh [hWantedG], a
; Can we drop the full requested distance?
.grav
ldh a, [hWantedG]
ld b, a
ldh a, [hActualG]
cp a, b
jr c, .smallg
; Yes. Do it.
.bigg
ldh a, [hWantedG]
ld b, a
ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
jr .postgrav
; No. Smaller distance.
.smallg
ldh a, [hActualG]
ld b, a
ldh a, [hCurrentPieceY]
add a, b
ldh [hCurrentPieceY], a
; **************************************************************
; HANDLE LOCKING
; Are we grounded?
.postgrav
.nograv
.donemanipulating
ldh a, [hCurrentPieceY]
inc a
ld b, a
@ -1264,57 +1249,42 @@ FieldProcess::
jr z, .notgrounded
; We're grounded.
.grounded
; If the y position changed, play a sound.
ldh a, [hCurrentPieceY]
ld b, a
ldh a, [hYPosAtStartOfFrame]
cp a, b
jr z, .postcheckforfirmdropsound ; Never play the sound if we didn't change rows.
jr z, :+
ldh a, [hDownState]
cp a, 0
jr nz, .postcheckforfirmdropsound ; Don't play the sound if we're holding down.
; Play the firm drop sound.
.playfirmdropsound
jr nz, :+
call SFXKill
ld a, SFX_MOVE
call SFXEnqueue
; If the down button is held, lock.
.postcheckforfirmdropsound
ldh a, [hDownState]
: ldh a, [hDownState]
cp a, 0
jr z, .dontforcelock
; Set the lock delay to 0 and save it.
.forcelock
ld a, 0
jr z, :+
ld a, 1
ldh [hCurrentLockDelayRemaining], a
jr .checklockdelay
; Load the lock delay.
; Decrement it by one and save it.
.dontforcelock
ldh a, [hCurrentLockDelayRemaining]
: ldh a, [hCurrentLockDelayRemaining]
dec a
ldh [hCurrentLockDelayRemaining], a
; Are we out of lock delay?
.checklockdelay
; If we're out of lock delay, play a sound.
cp a, 0
jr nz, .checkfortgm3lockexception ; If not, check if the TGM3 exception applies.
jr .dolock ; Otherwise, lock!
jr nz, .forcelockmaybe
call SFXKill
ld a, SFX_LOCK
call SFXEnqueue
jr .draw
; TGM3 sometimes forces a piece to immediately lock.
.checkfortgm3lockexception
.forcelockmaybe
ldh a, [hLockDelayForce]
cp a, $FF
jr nz, .draw ; It's not forced, so go to drawing.
xor a, a ; It is forced, so force it!
jr nz, .draw
xor a, a
ldh [hCurrentLockDelayRemaining], a
; Play the locking sound and draw the piece.
.dolock
call SFXKill
ld a, SFX_LOCK
call SFXEnqueue

View File

@ -28,17 +28,9 @@ INCLUDE "res/title_map.inc"
SECTION "High Globals", HRAM
hGameState:: ds 1
hSwapAB:: ds 1
hInitialA:: ds 1
hSimulationMode:: ds 1
SECTION "Globals", WRAM0
wInitialA:: ds 1
wInitialB:: ds 1
wInitialC:: ds 1
wInitialD:: ds 1
wInitialE:: ds 1
wInitialH:: ds 1
wInitialL:: ds 1
SECTION "Stack", WRAM0
wStack::
@ -48,20 +40,8 @@ wStackEnd::
SECTION "Code Entry Point", ROM0
Main::
; Load the initial registers. For reasons.
ld [wInitialA], a
ld a, b
ld [wInitialB], a
ld a, c
ld [wInitialC], a
ld a, d
ld [wInitialD], a
ld a, e
ld [wInitialE], a
ld a, h
ld [wInitialH], a
ld a, l
ld [wInitialL], a
; Load the initial A register. For reasons.
ldh [hInitialA], a
; Turn off LCD during initialization.
wait_vram

View File

@ -555,7 +555,6 @@ DoHold:
ldh [hCurrentPieceRotationState], a
ld a, SFX_IRS
call SFXEnqueue
jr .doHoldOperation
.checkIRSHB
ldh a, [hSwapAB]

View File

@ -39,7 +39,7 @@ SwitchToTitle::
call UnsafeMemCopy
; Little easter egg.
ld a, [wInitialA]
ldh a, [hInitialA]
cp a, $FF
jr nz, :+
ld de, sEaster0