Compare commits
No commits in common. "9b347b9e76778ac2ead0ea712d73f1068c51ccbf" and "384a8fa80111fb681be0ca5f280ce45f09ba2a4f" have entirely different histories.
9b347b9e76
...
384a8fa801
302
src/field.asm
302
src/field.asm
|
@ -53,7 +53,6 @@ hComboCt: ds 1
|
||||||
hLockDelayForce: ds 1
|
hLockDelayForce: ds 1
|
||||||
hHighestStack: ds 1
|
hHighestStack: ds 1
|
||||||
hDownFrames: ds 1
|
hDownFrames: ds 1
|
||||||
hStalePiece: ds 1
|
|
||||||
|
|
||||||
|
|
||||||
SECTION "Field Functions", ROM0
|
SECTION "Field Functions", ROM0
|
||||||
|
@ -503,7 +502,6 @@ ForceSpawnPiece::
|
||||||
TrySpawnPiece::
|
TrySpawnPiece::
|
||||||
; Always reset these for a new piece.
|
; Always reset these for a new piece.
|
||||||
xor a, a
|
xor a, a
|
||||||
ldh [hStalePiece], a
|
|
||||||
ldh [hDownFrames], a
|
ldh [hDownFrames], a
|
||||||
ldh [hLockDelayForce], a
|
ldh [hLockDelayForce], a
|
||||||
ldh a, [hCurrentLockDelay]
|
ldh a, [hCurrentLockDelay]
|
||||||
|
@ -662,7 +660,7 @@ FindMaxG:
|
||||||
ldh a, [hCurrentPieceX]
|
ldh a, [hCurrentPieceX]
|
||||||
call XYToSFieldPtr
|
call XYToSFieldPtr
|
||||||
|
|
||||||
;DEF EXPERIMENTAL_OPTIMIZATION EQU 1
|
DEF EXPERIMENTAL_OPTIMIZATION EQU 1
|
||||||
IF DEF(EXPERIMENTAL_OPTIMIZATION)
|
IF DEF(EXPERIMENTAL_OPTIMIZATION)
|
||||||
; The stack height marker gives a lower bound to how far the piece can fall.
|
; The stack height marker gives a lower bound to how far the piece can fall.
|
||||||
ldh a, [hHighestStack]
|
ldh a, [hHighestStack]
|
||||||
|
@ -688,6 +686,7 @@ IF DEF(EXPERIMENTAL_OPTIMIZATION)
|
||||||
jr .try
|
jr .try
|
||||||
ENDC
|
ENDC
|
||||||
|
|
||||||
|
|
||||||
.unoptimized
|
.unoptimized
|
||||||
push hl
|
push hl
|
||||||
ld a, 1
|
ld a, 1
|
||||||
|
@ -724,30 +723,128 @@ FieldProcess::
|
||||||
ldh [hYPosAtStartOfFrame], a
|
ldh [hYPosAtStartOfFrame], a
|
||||||
call FromShadowField
|
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 a, [hCurrentPieceX]
|
||||||
ldh [hWantX], a
|
ldh [hWantX], a
|
||||||
ldh a, [hCurrentPieceRotationState]
|
ldh a, [hCurrentPieceRotationState]
|
||||||
ldh [hWantRotation], a
|
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
|
; HANDLE ROTATION
|
||||||
|
@ -1135,122 +1232,10 @@ FieldProcess::
|
||||||
ldh [hCurrentPieceX], a
|
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
|
; HANDLE LOCKING
|
||||||
; Are we grounded?
|
; Are we grounded?
|
||||||
.postgrav
|
.donemanipulating
|
||||||
.nograv
|
|
||||||
ldh a, [hCurrentPieceY]
|
ldh a, [hCurrentPieceY]
|
||||||
inc a
|
inc a
|
||||||
ld b, a
|
ld b, a
|
||||||
|
@ -1264,57 +1249,42 @@ FieldProcess::
|
||||||
jr z, .notgrounded
|
jr z, .notgrounded
|
||||||
|
|
||||||
; We're grounded.
|
; We're grounded.
|
||||||
.grounded
|
; If the y position changed, play a sound.
|
||||||
ldh a, [hCurrentPieceY]
|
ldh a, [hCurrentPieceY]
|
||||||
ld b, a
|
ld b, a
|
||||||
ldh a, [hYPosAtStartOfFrame]
|
ldh a, [hYPosAtStartOfFrame]
|
||||||
cp a, b
|
cp a, b
|
||||||
jr z, .postcheckforfirmdropsound ; Never play the sound if we didn't change rows.
|
jr z, :+
|
||||||
ldh a, [hDownState]
|
ldh a, [hDownState]
|
||||||
cp a, 0
|
cp a, 0
|
||||||
jr nz, .postcheckforfirmdropsound ; Don't play the sound if we're holding down.
|
jr nz, :+
|
||||||
|
|
||||||
; Play the firm drop sound.
|
|
||||||
.playfirmdropsound
|
|
||||||
call SFXKill
|
call SFXKill
|
||||||
ld a, SFX_MOVE
|
ld a, SFX_MOVE
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
|
|
||||||
; If the down button is held, lock.
|
; If the down button is held, lock.
|
||||||
.postcheckforfirmdropsound
|
: ldh a, [hDownState]
|
||||||
ldh a, [hDownState]
|
|
||||||
cp a, 0
|
cp a, 0
|
||||||
jr z, .dontforcelock
|
jr z, :+
|
||||||
|
ld a, 1
|
||||||
; Set the lock delay to 0 and save it.
|
|
||||||
.forcelock
|
|
||||||
ld a, 0
|
|
||||||
ldh [hCurrentLockDelayRemaining], a
|
ldh [hCurrentLockDelayRemaining], a
|
||||||
jr .checklockdelay
|
: ldh a, [hCurrentLockDelayRemaining]
|
||||||
|
|
||||||
; Load the lock delay.
|
|
||||||
; Decrement it by one and save it.
|
|
||||||
.dontforcelock
|
|
||||||
ldh a, [hCurrentLockDelayRemaining]
|
|
||||||
dec a
|
dec a
|
||||||
ldh [hCurrentLockDelayRemaining], a
|
ldh [hCurrentLockDelayRemaining], a
|
||||||
|
; If we're out of lock delay, play a sound.
|
||||||
; Are we out of lock delay?
|
|
||||||
.checklockdelay
|
|
||||||
cp a, 0
|
cp a, 0
|
||||||
jr nz, .checkfortgm3lockexception ; If not, check if the TGM3 exception applies.
|
jr nz, .forcelockmaybe
|
||||||
jr .dolock ; Otherwise, lock!
|
call SFXKill
|
||||||
|
ld a, SFX_LOCK
|
||||||
|
call SFXEnqueue
|
||||||
|
jr .draw
|
||||||
|
|
||||||
; TGM3 sometimes forces a piece to immediately lock.
|
; TGM3 sometimes forces a piece to immediately lock.
|
||||||
.checkfortgm3lockexception
|
.forcelockmaybe
|
||||||
ldh a, [hLockDelayForce]
|
ldh a, [hLockDelayForce]
|
||||||
cp a, $FF
|
cp a, $FF
|
||||||
jr nz, .draw ; It's not forced, so go to drawing.
|
jr nz, .draw
|
||||||
xor a, a ; It is forced, so force it!
|
xor a, a
|
||||||
ldh [hCurrentLockDelayRemaining], a
|
ldh [hCurrentLockDelayRemaining], a
|
||||||
|
|
||||||
; Play the locking sound and draw the piece.
|
|
||||||
.dolock
|
|
||||||
call SFXKill
|
call SFXKill
|
||||||
ld a, SFX_LOCK
|
ld a, SFX_LOCK
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
|
|
26
src/main.asm
26
src/main.asm
|
@ -28,17 +28,9 @@ INCLUDE "res/title_map.inc"
|
||||||
SECTION "High Globals", HRAM
|
SECTION "High Globals", HRAM
|
||||||
hGameState:: ds 1
|
hGameState:: ds 1
|
||||||
hSwapAB:: ds 1
|
hSwapAB:: ds 1
|
||||||
|
hInitialA:: ds 1
|
||||||
hSimulationMode:: 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
|
SECTION "Stack", WRAM0
|
||||||
wStack::
|
wStack::
|
||||||
|
@ -48,20 +40,8 @@ wStackEnd::
|
||||||
|
|
||||||
SECTION "Code Entry Point", ROM0
|
SECTION "Code Entry Point", ROM0
|
||||||
Main::
|
Main::
|
||||||
; Load the initial registers. For reasons.
|
; Load the initial A register. For reasons.
|
||||||
ld [wInitialA], a
|
ldh [hInitialA], 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
|
|
||||||
|
|
||||||
; Turn off LCD during initialization.
|
; Turn off LCD during initialization.
|
||||||
wait_vram
|
wait_vram
|
||||||
|
|
|
@ -555,7 +555,6 @@ DoHold:
|
||||||
ldh [hCurrentPieceRotationState], a
|
ldh [hCurrentPieceRotationState], a
|
||||||
ld a, SFX_IRS
|
ld a, SFX_IRS
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
jr .doHoldOperation
|
|
||||||
|
|
||||||
.checkIRSHB
|
.checkIRSHB
|
||||||
ldh a, [hSwapAB]
|
ldh a, [hSwapAB]
|
||||||
|
|
|
@ -39,7 +39,7 @@ SwitchToTitle::
|
||||||
call UnsafeMemCopy
|
call UnsafeMemCopy
|
||||||
|
|
||||||
; Little easter egg.
|
; Little easter egg.
|
||||||
ld a, [wInitialA]
|
ldh a, [hInitialA]
|
||||||
cp a, $FF
|
cp a, $FF
|
||||||
jr nz, :+
|
jr nz, :+
|
||||||
ld de, sEaster0
|
ld de, sEaster0
|
||||||
|
|
Loading…
Reference in New Issue