Level counting and updating of speed curve as required.
This commit is contained in:
parent
b6a703e0b2
commit
6bb4a72c76
|
@ -191,6 +191,8 @@ sSpeedCurve:: ; Speed curve of the game.
|
||||||
db 20, 1 ; 20G
|
db 20, 1 ; 20G
|
||||||
db 1, 1, 1, 1 ; ARE, DAS, LOCK, LINECLEAR
|
db 1, 1, 1, 1 ; ARE, DAS, LOCK, LINECLEAR
|
||||||
|
|
||||||
|
dw $FFFF ; End.
|
||||||
|
|
||||||
sPieceRotationStates:: ; How each piece is rotated.
|
sPieceRotationStates:: ; How each piece is rotated.
|
||||||
; I
|
; I
|
||||||
db %0000
|
db %0000
|
||||||
|
|
230
src/level.asm
230
src/level.asm
|
@ -9,6 +9,17 @@ SECTION "Level Variables", WRAM0
|
||||||
wCLevel:: ds 4
|
wCLevel:: ds 4
|
||||||
wNLevel:: ds 6 ; The extra 2 bytes will be clobbered by the sprite drawing functions.
|
wNLevel:: ds 6 ; The extra 2 bytes will be clobbered by the sprite drawing functions.
|
||||||
|
|
||||||
|
SECTION "Critical Level Variables", HRAM
|
||||||
|
hCurrentDAS:: ds 1
|
||||||
|
hCurrentARE:: ds 1
|
||||||
|
hCurrentLockDelay:: ds 1
|
||||||
|
hCurrentLineClearDelay:: ds 1
|
||||||
|
hCurrentGravityPerTick:: ds 1
|
||||||
|
hCurrentFramesPerGravityTick:: ds 1
|
||||||
|
hNextSpeedUp:: ds 2
|
||||||
|
hSpeedCurvePtr:: ds 2
|
||||||
|
hRequiresLineClear:: ds 1
|
||||||
|
|
||||||
|
|
||||||
SECTION "Level Functions", ROM0
|
SECTION "Level Functions", ROM0
|
||||||
LevelInit::
|
LevelInit::
|
||||||
|
@ -20,9 +31,228 @@ LevelInit::
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
ld hl, wNLevel
|
ld hl, wNLevel
|
||||||
ld [hl+], a
|
ld [hl+], a
|
||||||
|
inc a
|
||||||
|
ld [hl+], a
|
||||||
|
dec a
|
||||||
|
ld [hl+], a
|
||||||
|
ld [hl], a
|
||||||
|
ldh [hRequiresLineClear], a
|
||||||
|
|
||||||
|
ld hl, sSpeedCurve+2
|
||||||
|
ld a, l
|
||||||
|
ldh [hSpeedCurvePtr], a
|
||||||
|
ld a, h
|
||||||
|
ldh [hSpeedCurvePtr+1], a
|
||||||
|
|
||||||
|
call DoSpeedUp
|
||||||
|
ret
|
||||||
|
|
||||||
|
; Increment level and speed up if necessary. Level increment in E.
|
||||||
|
; Levels may only increment by single digits.
|
||||||
|
LevelUp::
|
||||||
|
; Return if we're maxed out.
|
||||||
|
ld hl, wCLevel
|
||||||
|
ld a, $09
|
||||||
|
and a, [hl]
|
||||||
|
inc hl
|
||||||
|
and a, [hl]
|
||||||
|
inc hl
|
||||||
|
and a, [hl]
|
||||||
|
inc hl
|
||||||
|
and a, [hl]
|
||||||
|
ld c, [hl]
|
||||||
|
cp a, $09
|
||||||
|
ret z
|
||||||
|
|
||||||
|
; Increment LSD.
|
||||||
|
ld a, [hl]
|
||||||
|
add a, e
|
||||||
|
ld [hl], a
|
||||||
|
cp a, $0A
|
||||||
|
jr c, .checknlevel
|
||||||
|
sub a, 10
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; Carry the one...
|
||||||
|
dec hl
|
||||||
|
ld a, [hl]
|
||||||
|
inc a
|
||||||
|
ld [hl], a
|
||||||
|
cp a, $0A
|
||||||
|
jr c, .checknlevel
|
||||||
|
xor a, a
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; Again...
|
||||||
|
dec hl
|
||||||
|
ld a, [hl]
|
||||||
|
inc a
|
||||||
|
ld [hl], a
|
||||||
|
cp a, $0A
|
||||||
|
jr c, .checknlevel
|
||||||
|
xor a, a
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; Once more...
|
||||||
|
dec hl
|
||||||
|
ld a, [hl]
|
||||||
|
inc a
|
||||||
|
ld [hl], a
|
||||||
|
cp a, $0A
|
||||||
|
jr c, .checknlevel
|
||||||
|
|
||||||
|
; We're maxed out. Both levels should be set to 9999.
|
||||||
|
ld a, 9
|
||||||
|
ld [hl-], a
|
||||||
|
ld [hl-], a
|
||||||
|
ld [hl-], a
|
||||||
|
ld [hl], a
|
||||||
|
call DoSpeedUp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.checknlevel
|
||||||
|
; Make wNLevel make sense.
|
||||||
|
ld hl, wCLevel
|
||||||
|
ld a, $09
|
||||||
|
and a, [hl]
|
||||||
|
inc hl
|
||||||
|
and a, [hl]
|
||||||
|
cp a, $09
|
||||||
|
; If wCLevel begins 99, wNLevel should be 9999.
|
||||||
|
jr nz, :+
|
||||||
|
ld a, 9
|
||||||
|
ld hl, wNLevel
|
||||||
|
ld [hl+], a
|
||||||
ld [hl+], a
|
ld [hl+], a
|
||||||
ld [hl+], a
|
ld [hl+], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
; If the last two digits of wCLevel are 98, play the bell.
|
||||||
|
ld hl, wCLevel+2
|
||||||
|
ld a, [hl+]
|
||||||
|
cp a, 9
|
||||||
|
jr nz, .checkspeedup
|
||||||
|
ld a, [hl]
|
||||||
|
cp a, 8
|
||||||
|
jr nz, .checkspeedup
|
||||||
|
ld a, SFX_BELL
|
||||||
|
call SFXEnqueue
|
||||||
|
jr .checkspeedup
|
||||||
|
|
||||||
|
; Otherwise check the second digit of wCLevel.
|
||||||
|
: ld hl, wCLevel+1
|
||||||
|
ld a, [hl]
|
||||||
|
; If it's 9, wNLevel should be y0xx. With y being the first digit of wCLevel+1
|
||||||
|
cp a, 9
|
||||||
|
jr nz, :+
|
||||||
|
ld hl, wNLevel+1
|
||||||
|
xor a, a
|
||||||
|
ld [hl], a
|
||||||
|
ld hl, wCLevel
|
||||||
|
ld a, [hl]
|
||||||
|
inc a
|
||||||
|
ld hl, wNLevel
|
||||||
|
ld [hl], a
|
||||||
|
jr .bellmaybe
|
||||||
|
|
||||||
|
; Otherwise just set the second digit of wNLevel to the second digit of wCLevel + 1.
|
||||||
|
: ld hl, wCLevel+1
|
||||||
|
ld a, [hl]
|
||||||
|
inc a
|
||||||
|
ld hl, wNLevel+1
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
.bellmaybe
|
||||||
|
; If the last two digits of wCLevel are 99, play the bell.
|
||||||
|
ld hl, wCLevel+2
|
||||||
|
ld a, [hl+]
|
||||||
|
and a, [hl]
|
||||||
|
cp a, 9
|
||||||
|
jr nz, .checkspeedup
|
||||||
|
ld a, SFX_BELL
|
||||||
|
call SFXEnqueue
|
||||||
|
|
||||||
|
.checkspeedup
|
||||||
|
ldh a, [hNextSpeedUp]
|
||||||
|
and a, $F0
|
||||||
|
jr z, :+
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
ld hl, wCLevel
|
||||||
|
cp a, [hl]
|
||||||
|
ret nc
|
||||||
|
|
||||||
|
: ldh a, [hNextSpeedUp]
|
||||||
|
and a, $0F
|
||||||
|
jr z, :+
|
||||||
|
ld hl, wCLevel+1
|
||||||
|
cp a, [hl]
|
||||||
|
jr z, :+
|
||||||
|
ret nc
|
||||||
|
|
||||||
|
: ldh a, [hNextSpeedUp+1]
|
||||||
|
and a, $F0
|
||||||
|
jr z, :+
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
rrc a
|
||||||
|
ld hl, wCLevel+2
|
||||||
|
cp a, [hl]
|
||||||
|
jr z, :+
|
||||||
|
ret nc
|
||||||
|
|
||||||
|
: ldh a, [hNextSpeedUp+1]
|
||||||
|
and a, $0F
|
||||||
|
jr z, :+
|
||||||
|
ld hl, wCLevel+3
|
||||||
|
cp a, [hl]
|
||||||
|
jr z, :+
|
||||||
|
ret nc
|
||||||
|
|
||||||
|
ldh a, [hNextSpeedUp+0]
|
||||||
|
ldh a, [hNextSpeedUp+1]
|
||||||
|
|
||||||
|
ld a, [wCLevel+0]
|
||||||
|
ld a, [wCLevel+1]
|
||||||
|
ld a, [wCLevel+2]
|
||||||
|
ld a, [wCLevel+3]
|
||||||
|
|
||||||
|
: call DoSpeedUp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
DoSpeedUp:
|
||||||
|
; Load curve ptr.
|
||||||
|
ldh a, [hSpeedCurvePtr]
|
||||||
|
ld l, a
|
||||||
|
ldh a, [hSpeedCurvePtr+1]
|
||||||
|
ld h, a
|
||||||
|
|
||||||
|
; Get all the new data.
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentGravityPerTick], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentFramesPerGravityTick], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentARE], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentDAS], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentLockDelay], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hCurrentLineClearDelay], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hNextSpeedUp+1], a
|
||||||
|
ld a, [hl+]
|
||||||
|
ldh [hNextSpeedUp], a
|
||||||
|
|
||||||
|
; Save the new pointer.
|
||||||
|
ld a, l
|
||||||
|
ldh [hSpeedCurvePtr], a
|
||||||
|
ld a, h
|
||||||
|
ldh [hSpeedCurvePtr+1], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -15,8 +15,13 @@ DEF MODE_SPAWN_PIECE EQU 4
|
||||||
SECTION "Gameplay Variables", WRAM0
|
SECTION "Gameplay Variables", WRAM0
|
||||||
wMode: ds 1
|
wMode: ds 1
|
||||||
wModeCounter: ds 1
|
wModeCounter: ds 1
|
||||||
wCurrentPiece: ds 1
|
|
||||||
wHeldPiece: ds 1
|
SECTION "Critical Gameplay Variables", HRAM
|
||||||
|
hCurrentPiece: ds 1
|
||||||
|
hCurrentPieceX: ds 1
|
||||||
|
hCurrentPieceY: ds 1
|
||||||
|
hCurrentPieceRotationState: ds 1
|
||||||
|
hHeldPiece: ds 1
|
||||||
|
|
||||||
|
|
||||||
SECTION "Gameplay Functions", ROM0
|
SECTION "Gameplay Functions", ROM0
|
||||||
|
@ -47,13 +52,9 @@ SwitchToGameplay::
|
||||||
call LevelInit
|
call LevelInit
|
||||||
call FieldInit
|
call FieldInit
|
||||||
|
|
||||||
; Next level is 0100.
|
|
||||||
ld a, 1
|
|
||||||
ld [wNLevel+1], a
|
|
||||||
|
|
||||||
; We don't start with a held piece.
|
; We don't start with a held piece.
|
||||||
ld a, PIECE_NONE
|
ld a, PIECE_NONE
|
||||||
ld [wHeldPiece], a
|
ldh [hHeldPiece], a
|
||||||
|
|
||||||
; Leady mode.
|
; Leady mode.
|
||||||
ld a, MODE_LEADY
|
ld a, MODE_LEADY
|
||||||
|
@ -138,7 +139,7 @@ postGoMode:
|
||||||
; Fetch the next piece.
|
; Fetch the next piece.
|
||||||
fetchPieceMode:
|
fetchPieceMode:
|
||||||
ld a, [wNextPiece]
|
ld a, [wNextPiece]
|
||||||
ld [wCurrentPiece], a
|
ldh [hCurrentPiece], a
|
||||||
call GetNextPiece
|
call GetNextPiece
|
||||||
|
|
||||||
; Check if IRS is charged.
|
; Check if IRS is charged.
|
||||||
|
@ -160,6 +161,9 @@ fetchPieceMode:
|
||||||
spawnPieceMode:
|
spawnPieceMode:
|
||||||
; todo
|
; todo
|
||||||
|
|
||||||
|
ld e, 1
|
||||||
|
call LevelUp
|
||||||
|
|
||||||
ld a, [hUpState]
|
ld a, [hUpState]
|
||||||
cp a, 1
|
cp a, 1
|
||||||
jr nz, :+
|
jr nz, :+
|
||||||
|
@ -192,7 +196,7 @@ drawStaticInfo:
|
||||||
: ld a, [wNextPiece]
|
: ld a, [wNextPiece]
|
||||||
call ApplyNext
|
call ApplyNext
|
||||||
|
|
||||||
ld a, [wHeldPiece]
|
ldh a, [hHeldPiece]
|
||||||
call ApplyHold
|
call ApplyHold
|
||||||
|
|
||||||
ld hl, wSPRScore1
|
ld hl, wSPRScore1
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#Emulicious settings file
|
#Emulicious settings file
|
||||||
#Tue Oct 17 07:59:30 CEST 2023
|
#Tue Oct 17 13:52:17 CEST 2023
|
||||||
WindowEventViewerWindowHeight=861
|
WindowEventViewerWindowHeight=861
|
||||||
WindowEventViewerWindowDivider=309
|
WindowEventViewerWindowDivider=309
|
||||||
WindowMemoryTracerWindowY=631
|
WindowMemoryTracerWindowY=631
|
||||||
|
@ -52,7 +52,7 @@ Key20=-1
|
||||||
MemoryTracer=true
|
MemoryTracer=true
|
||||||
Key19=72
|
Key19=72
|
||||||
Key18=71
|
Key18=71
|
||||||
DebuggerMemorySelectedAddress=4
|
DebuggerMemorySelectedAddress=7
|
||||||
SMSGamepadBKeyboard=false
|
SMSGamepadBKeyboard=false
|
||||||
Key17=76
|
Key17=76
|
||||||
Key16=74
|
Key16=74
|
||||||
|
@ -117,6 +117,7 @@ Key9=40
|
||||||
Key8=38
|
Key8=38
|
||||||
Key7=83
|
Key7=83
|
||||||
Key6=87
|
Key6=87
|
||||||
|
HighlightingPreference=-1
|
||||||
Key5=65
|
Key5=65
|
||||||
Key4=68
|
Key4=68
|
||||||
Key3=10
|
Key3=10
|
||||||
|
@ -174,7 +175,7 @@ DebuggerHideToolbar=false
|
||||||
Gamepad0Key21=-1
|
Gamepad0Key21=-1
|
||||||
WindowDebuggerWidth=1481
|
WindowDebuggerWidth=1481
|
||||||
Gamepad0Key20=-1
|
Gamepad0Key20=-1
|
||||||
DebuggerSouthPanelSelectedTab=0
|
DebuggerSouthPanelSelectedTab=1
|
||||||
WindowEmuliciousWidth=816
|
WindowEmuliciousWidth=816
|
||||||
WindowVideoViewerWidth=980
|
WindowVideoViewerWidth=980
|
||||||
WindowMemoryEditorY=827
|
WindowMemoryEditorY=827
|
||||||
|
@ -198,8 +199,8 @@ GameBoyErrorBreakpointMessage32=
|
||||||
InterruptBreakpointCondition=
|
InterruptBreakpointCondition=
|
||||||
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
|
Recent0=C\:\\workspace\\dmgtris\\bin\\out.gb
|
||||||
GameBoyErrorBreakpointMessage20=
|
GameBoyErrorBreakpointMessage20=
|
||||||
WindowEmuliciousY=316
|
WindowEmuliciousY=513
|
||||||
WindowEmuliciousX=619
|
WindowEmuliciousX=97
|
||||||
GameBoyErrorBreakpointEnabled9=false
|
GameBoyErrorBreakpointEnabled9=false
|
||||||
GameBoyErrorBreakpointEnabled8=false
|
GameBoyErrorBreakpointEnabled8=false
|
||||||
GameBoyErrorBreakpointEnabled7=false
|
GameBoyErrorBreakpointEnabled7=false
|
||||||
|
@ -263,8 +264,8 @@ Gamepad0Key3=-1
|
||||||
Gamepad0Key2=-1
|
Gamepad0Key2=-1
|
||||||
Gamepad0Key1=-1
|
Gamepad0Key1=-1
|
||||||
Gamepad0Key0=-1
|
Gamepad0Key0=-1
|
||||||
WindowDebuggerY=170
|
WindowDebuggerY=369
|
||||||
WindowDebuggerX=1172
|
WindowDebuggerX=830
|
||||||
InterruptBreakpointSuspend=true
|
InterruptBreakpointSuspend=true
|
||||||
SMSGamepadAKeyboard=false
|
SMSGamepadAKeyboard=false
|
||||||
GameBoyErrorBreakpointSuspend32=true
|
GameBoyErrorBreakpointSuspend32=true
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
wCLevel 4 Hexadecimal
|
Loading…
Reference in New Issue