Move everything to HRAM.
This commit is contained in:
parent
61ae2c524b
commit
ac28205be4
|
@ -32,7 +32,7 @@ wField:: ds (10*24)
|
||||||
wShadowField:: ds (14*26)
|
wShadowField:: ds (14*26)
|
||||||
|
|
||||||
|
|
||||||
SECTION "Field High Variables", HRAM
|
SECTION "High Field Variables", HRAM
|
||||||
hPieceDataBase: ds 2
|
hPieceDataBase: ds 2
|
||||||
hPieceDataBaseFast: ds 2
|
hPieceDataBaseFast: ds 2
|
||||||
hPieceDataOffset: ds 1
|
hPieceDataOffset: ds 1
|
||||||
|
@ -1435,9 +1435,9 @@ FieldDelay::
|
||||||
jr nz, :-
|
jr nz, :-
|
||||||
|
|
||||||
ld a, l
|
ld a, l
|
||||||
ld [wScoreIncrement], a
|
ldh [hScoreIncrement], a
|
||||||
ld a, h
|
ld a, h
|
||||||
ld [wScoreIncrement+1], a
|
ldh [hScoreIncrement+1], a
|
||||||
call IncreaseScore
|
call IncreaseScore
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -22,7 +22,7 @@ DEF INPUT_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Input Variables", HRAM
|
SECTION "High Input Variables", HRAM
|
||||||
hUpState:: ds 1
|
hUpState:: ds 1
|
||||||
hDownState:: ds 1
|
hDownState:: ds 1
|
||||||
hLeftState:: ds 1
|
hLeftState:: ds 1
|
||||||
|
|
|
@ -22,7 +22,7 @@ DEF INTERRUPTS_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Interrupt Variables", HRAM
|
SECTION "High Interrupt Variables", HRAM
|
||||||
hLCDCCtr:: ds 1
|
hLCDCCtr:: ds 1
|
||||||
|
|
||||||
|
|
||||||
|
|
112
src/level.asm
112
src/level.asm
|
@ -22,13 +22,7 @@ DEF LEVEL_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Level Variables", WRAM0
|
SECTION "High Level Variables", HRAM
|
||||||
wCLevel:: ds 4
|
|
||||||
wNLevel:: ds 6 ; The extra 2 bytes will be clobbered by the sprite drawing functions.
|
|
||||||
wPrevHundreds:: ds 1
|
|
||||||
|
|
||||||
|
|
||||||
SECTION "Critical Level Variables", HRAM
|
|
||||||
hCurrentDAS:: ds 1
|
hCurrentDAS:: ds 1
|
||||||
hCurrentARE:: ds 1
|
hCurrentARE:: ds 1
|
||||||
hCurrentLockDelay:: ds 1
|
hCurrentLockDelay:: ds 1
|
||||||
|
@ -40,6 +34,9 @@ hSpeedCurvePtr:: ds 2
|
||||||
hStartSpeed:: ds 2
|
hStartSpeed:: ds 2
|
||||||
hRequiresLineClear:: ds 1
|
hRequiresLineClear:: ds 1
|
||||||
hLevel:: ds 2
|
hLevel:: ds 2
|
||||||
|
hCLevel:: ds 4
|
||||||
|
hNLevel:: ds 6 ; The extra 2 bytes will be clobbered by the sprite drawing functions.
|
||||||
|
hPrevHundreds:: ds 1
|
||||||
|
|
||||||
|
|
||||||
SECTION "Level Functions", ROM0
|
SECTION "Level Functions", ROM0
|
||||||
|
@ -47,20 +44,18 @@ LevelInit::
|
||||||
xor a, a
|
xor a, a
|
||||||
ldh [hLevel], a
|
ldh [hLevel], a
|
||||||
ldh [hLevel+1], a
|
ldh [hLevel+1], a
|
||||||
ld hl, wCLevel
|
ldh [hCLevel], a
|
||||||
ld [hl+], a
|
ldh [hCLevel+1], a
|
||||||
ld [hl+], a
|
ldh [hCLevel+2], a
|
||||||
ld [hl+], a
|
ldh [hCLevel+3], a
|
||||||
ld [hl], a
|
ldh [hNLevel], a
|
||||||
ld hl, wNLevel
|
ldh [hNLevel+2], a ; Note +1 is inited later.
|
||||||
ld [hl+], a
|
ldh [hNLevel+3], a
|
||||||
inc a
|
|
||||||
ld [hl+], a
|
|
||||||
dec a
|
|
||||||
ld [hl+], a
|
|
||||||
ld [hl], a
|
|
||||||
ldh [hRequiresLineClear], a
|
ldh [hRequiresLineClear], a
|
||||||
|
|
||||||
|
ld a, 1
|
||||||
|
ldh [hNLevel+1], a
|
||||||
|
|
||||||
ldh a, [hStartSpeed]
|
ldh a, [hStartSpeed]
|
||||||
ld l, a
|
ld l, a
|
||||||
ldh a, [hStartSpeed+1]
|
ldh a, [hStartSpeed+1]
|
||||||
|
@ -70,19 +65,19 @@ LevelInit::
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld b, a
|
ld b, a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wCLevel+3], a
|
ldh [hCLevel+3], a
|
||||||
ld a, b
|
ld a, b
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wCLevel+2], a
|
ldh [hCLevel+2], a
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld b, a
|
ld b, a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wCLevel+1], a
|
ldh [hCLevel+1], a
|
||||||
ld a, b
|
ld a, b
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wCLevel], a
|
ldh [hCLevel], a
|
||||||
|
|
||||||
ld a, l
|
ld a, l
|
||||||
ldh [hSpeedCurvePtr], a
|
ldh [hSpeedCurvePtr], a
|
||||||
|
@ -99,19 +94,19 @@ LevelInit::
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld b, a
|
ld b, a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wNLevel+3], a
|
ldh [hNLevel+3], a
|
||||||
ld a, b
|
ld a, b
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wNLevel+2], a
|
ldh [hNLevel+2], a
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
ld b, a
|
ld b, a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wNLevel+1], a
|
ldh [hNLevel+1], a
|
||||||
ld a, b
|
ld a, b
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld [wNLevel], a
|
ldh [hNLevel], a
|
||||||
|
|
||||||
call DoSpeedUp
|
call DoSpeedUp
|
||||||
ret
|
ret
|
||||||
|
@ -120,7 +115,7 @@ LevelInit::
|
||||||
; Levels may only increment by single digits.
|
; Levels may only increment by single digits.
|
||||||
LevelUp::
|
LevelUp::
|
||||||
; Return if we're maxed out.
|
; Return if we're maxed out.
|
||||||
ld hl, wCLevel
|
ld hl, hCLevel
|
||||||
ld a, $09
|
ld a, $09
|
||||||
and a, [hl]
|
and a, [hl]
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -148,12 +143,12 @@ LevelUp::
|
||||||
ldh [hLevel], a
|
ldh [hLevel], a
|
||||||
|
|
||||||
; Save the current hundred digit.
|
; Save the current hundred digit.
|
||||||
ld a, [wCLevel+1]
|
ldh a, [hCLevel+1]
|
||||||
ld [wPrevHundreds], a
|
ldh [hPrevHundreds], a
|
||||||
|
|
||||||
; Increment LSD.
|
; Increment LSD.
|
||||||
.doit
|
.doit
|
||||||
ld hl, wCLevel+3
|
ld hl, hCLevel+3
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
add a, e
|
add a, e
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
@ -192,10 +187,10 @@ LevelUp::
|
||||||
|
|
||||||
; We're maxed out. Both levels should be set to 9999.
|
; We're maxed out. Both levels should be set to 9999.
|
||||||
ld a, 9
|
ld a, 9
|
||||||
ld [hl-], a
|
ldh [hCLevel], a
|
||||||
ld [hl-], a
|
ldh [hCLevel+1], a
|
||||||
ld [hl-], a
|
ldh [hCLevel+2], a
|
||||||
ld [hl], a
|
ldh [hCLevel+3], a
|
||||||
call DoSpeedUp
|
call DoSpeedUp
|
||||||
ld a, SFX_RANK_UP
|
ld a, SFX_RANK_UP
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
|
@ -203,7 +198,7 @@ LevelUp::
|
||||||
|
|
||||||
.checknlevel
|
.checknlevel
|
||||||
; Make wNLevel make sense.
|
; Make wNLevel make sense.
|
||||||
ld hl, wCLevel
|
ld hl, hCLevel
|
||||||
ld a, $09
|
ld a, $09
|
||||||
and a, [hl]
|
and a, [hl]
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -212,13 +207,12 @@ LevelUp::
|
||||||
; If wCLevel begins 99, wNLevel should be 9999.
|
; If wCLevel begins 99, wNLevel should be 9999.
|
||||||
jr nz, :+
|
jr nz, :+
|
||||||
ld a, 9
|
ld a, 9
|
||||||
ld hl, wNLevel
|
ldh [hNLevel], a
|
||||||
ld [hl+], a
|
ldh [hNLevel+1], a
|
||||||
ld [hl+], a
|
ldh [hNLevel+2], a
|
||||||
ld [hl+], a
|
ldh [hNLevel+3], a
|
||||||
ld [hl], a
|
|
||||||
; If the last two digits of wCLevel are 98, play the bell.
|
; If the last two digits of wCLevel are 98, play the bell.
|
||||||
ld hl, wCLevel+2
|
ld hl, hCLevel+2
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
cp a, 9
|
cp a, 9
|
||||||
jr nz, .checkspeedup
|
jr nz, .checkspeedup
|
||||||
|
@ -232,31 +226,31 @@ LevelUp::
|
||||||
jr .leveljinglemaybe
|
jr .leveljinglemaybe
|
||||||
|
|
||||||
; Otherwise check the second digit of wCLevel.
|
; Otherwise check the second digit of wCLevel.
|
||||||
: ld hl, wCLevel+1
|
: ld hl, hCLevel+1
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
; If it's 9, wNLevel should be y0xx. With y being the first digit of wCLevel+1
|
; If it's 9, wNLevel should be y0xx. With y being the first digit of wCLevel+1
|
||||||
cp a, 9
|
cp a, 9
|
||||||
jr nz, :+
|
jr nz, :+
|
||||||
ld hl, wNLevel+1
|
ld hl, hNLevel+1
|
||||||
xor a, a
|
xor a, a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
ld hl, wCLevel
|
ld hl, hCLevel
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
inc a
|
inc a
|
||||||
ld hl, wNLevel
|
ld hl, hNLevel
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
jr .bellmaybe
|
jr .bellmaybe
|
||||||
|
|
||||||
; Otherwise just set the second digit of wNLevel to the second digit of wCLevel + 1.
|
; Otherwise just set the second digit of wNLevel to the second digit of wCLevel + 1.
|
||||||
: ld hl, wCLevel+1
|
: ld hl, hCLevel+1
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
inc a
|
inc a
|
||||||
ld hl, wNLevel+1
|
ld hl, hNLevel+1
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
.bellmaybe
|
.bellmaybe
|
||||||
; If the last two digits of wCLevel are 99, play the bell.
|
; If the last two digits of wCLevel are 99, play the bell.
|
||||||
ld hl, wCLevel+2
|
ld hl, hCLevel+2
|
||||||
ld a, [hl+]
|
ld a, [hl+]
|
||||||
and a, [hl]
|
and a, [hl]
|
||||||
cp a, 9
|
cp a, 9
|
||||||
|
@ -267,9 +261,9 @@ LevelUp::
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
|
|
||||||
.leveljinglemaybe
|
.leveljinglemaybe
|
||||||
ld a, [wPrevHundreds]
|
ldh a, [hPrevHundreds]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [wCLevel+1]
|
ld a, [hCLevel+1]
|
||||||
cp a, b
|
cp a, b
|
||||||
jr z, .checkspeedup
|
jr z, .checkspeedup
|
||||||
ld a, SFX_LEVEL_UP
|
ld a, SFX_LEVEL_UP
|
||||||
|
@ -281,14 +275,14 @@ LevelUp::
|
||||||
jr z, :+
|
jr z, :+
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld hl, wCLevel
|
ld hl, hCLevel
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
ret nc
|
ret nc
|
||||||
|
|
||||||
: ldh a, [hNextSpeedUp]
|
: ldh a, [hNextSpeedUp]
|
||||||
and a, $0F
|
and a, $0F
|
||||||
jr z, :+
|
jr z, :+
|
||||||
ld hl, wCLevel+1
|
ld hl, hCLevel+1
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
ret nc
|
ret nc
|
||||||
|
@ -298,7 +292,7 @@ LevelUp::
|
||||||
jr z, :+
|
jr z, :+
|
||||||
swap a
|
swap a
|
||||||
and a, $0F
|
and a, $0F
|
||||||
ld hl, wCLevel+2
|
ld hl, hCLevel+2
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
ret nc
|
ret nc
|
||||||
|
@ -306,19 +300,11 @@ LevelUp::
|
||||||
: ldh a, [hNextSpeedUp+1]
|
: ldh a, [hNextSpeedUp+1]
|
||||||
and a, $0F
|
and a, $0F
|
||||||
jr z, :+
|
jr z, :+
|
||||||
ld hl, wCLevel+3
|
ld hl, hCLevel+3
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
jr z, :+
|
jr z, :+
|
||||||
ret nc
|
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
|
: call DoSpeedUp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ INCLUDE "res/gameplay_map.inc"
|
||||||
INCLUDE "res/title_map.inc"
|
INCLUDE "res/title_map.inc"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Globals", HRAM
|
SECTION "High Globals", HRAM
|
||||||
hGameState:: ds 1
|
hGameState:: ds 1
|
||||||
hSwapAB:: ds 1
|
hSwapAB:: ds 1
|
||||||
|
|
||||||
|
|
56
src/rng.asm
56
src/rng.asm
|
@ -22,40 +22,38 @@ DEF RNG_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "RNG Variables", WRAM0
|
SECTION "High RNG Variables", HRAM
|
||||||
wRNGSeed: ds 4
|
hRNGSeed: ds 4
|
||||||
wPieceHistory: ds 4
|
hPieceHistory: ds 4
|
||||||
wNextPiece:: ds 1
|
hNextPiece:: ds 1
|
||||||
|
|
||||||
|
|
||||||
section "RNG Functions", ROM0
|
section "RNG Functions", ROM0
|
||||||
RNGInit::
|
RNGInit::
|
||||||
; Do some bit fuckery on the seed using the gameboy's free-running timers.
|
; Do some bit fuckery on the seed using the gameboy's free-running timers.
|
||||||
ld hl, wRNGSeed
|
|
||||||
ldh a, [rDIV]
|
ldh a, [rDIV]
|
||||||
xor a, [hl]
|
xor a, [hl]
|
||||||
ld [hl+], a
|
ldh [hRNGSeed], a
|
||||||
|
|
||||||
ldh a, [rTIMA]
|
ldh a, [rTIMA]
|
||||||
xor a, [hl]
|
xor a, [hl]
|
||||||
ld [hl+], a
|
ldh [hRNGSeed+1], a
|
||||||
|
|
||||||
ldh a, [rDIV]
|
ldh a, [rDIV]
|
||||||
xor a, [hl]
|
xor a, [hl]
|
||||||
ld [hl+], a
|
ldh [hRNGSeed+2], a
|
||||||
|
|
||||||
ldh a, [rTIMA]
|
ldh a, [rTIMA]
|
||||||
xor a, [hl]
|
xor a, [hl]
|
||||||
ld [hl], a
|
ldh [hRNGSeed+3], a
|
||||||
|
|
||||||
; Initialize the next history.
|
; Initialize the next history.
|
||||||
ld hl, wPieceHistory
|
|
||||||
ld a, PIECE_Z
|
ld a, PIECE_Z
|
||||||
ld [hl+], a
|
ld [hPieceHistory], a
|
||||||
ld [hl+], a
|
ld [hPieceHistory+1], a
|
||||||
ld a, PIECE_S
|
ld a, PIECE_S
|
||||||
ld [hl+], a
|
ld [hPieceHistory+2], a
|
||||||
ld [hl], a
|
ld [hPieceHistory+3], a
|
||||||
|
|
||||||
; Get the first piece and make sure it's not Z, S or O.
|
; Get the first piece and make sure it's not Z, S or O.
|
||||||
: call NextPiece
|
: call NextPiece
|
||||||
|
@ -67,10 +65,8 @@ RNGInit::
|
||||||
jr z, :-
|
jr z, :-
|
||||||
|
|
||||||
; Store it.
|
; Store it.
|
||||||
ld hl, wPieceHistory
|
ldh [hPieceHistory], a
|
||||||
ld [hl], a
|
ld [hNextPiece], a
|
||||||
ld hl, wNextPiece
|
|
||||||
ld [hl], a
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +76,7 @@ GetNextPiece::
|
||||||
jr z, :+
|
jr z, :+
|
||||||
|
|
||||||
call NextPiece
|
call NextPiece
|
||||||
ld hl, wPieceHistory
|
ld hl, hPieceHistory
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
jr z, :-
|
jr z, :-
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -93,20 +89,16 @@ GetNextPiece::
|
||||||
cp a, [hl]
|
cp a, [hl]
|
||||||
jr z, :-
|
jr z, :-
|
||||||
|
|
||||||
: ld hl, wNextPiece
|
: ldh [hNextPiece], a
|
||||||
ld [hl], a
|
|
||||||
ld b, a
|
ld b, a
|
||||||
ld hl, wPieceHistory+2
|
ldh a, [hPieceHistory+2]
|
||||||
ld a, [hl+]
|
ldh [hPieceHistory+3], a
|
||||||
ld [hl], a
|
ldh a, [hPieceHistory+1]
|
||||||
ld hl, wPieceHistory+1
|
ldh [hPieceHistory+2], a
|
||||||
ld a, [hl+]
|
ldh a, [hPieceHistory]
|
||||||
ld [hl], a
|
ldh [hPieceHistory+1], a
|
||||||
ld hl, wPieceHistory
|
|
||||||
ld a, [hl+]
|
|
||||||
ld [hl-], a
|
|
||||||
ld a, b
|
ld a, b
|
||||||
ld [hl], a
|
ldh [hPieceHistory], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +112,7 @@ NextPiece:
|
||||||
|
|
||||||
NextByte:
|
NextByte:
|
||||||
; Load seed
|
; Load seed
|
||||||
ld hl,wRNGSeed+3
|
ld hl, hRNGSeed+3
|
||||||
ld a, [hl-]
|
ld a, [hl-]
|
||||||
ld b, a
|
ld b, a
|
||||||
ld a, [hl-]
|
ld a, [hl-]
|
||||||
|
|
|
@ -22,54 +22,50 @@ DEF SCORE_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Score Variables", WRAM0
|
SECTION "Score Variables", HRAM
|
||||||
wScore:: ds 6
|
hScore:: ds 6
|
||||||
wScoreIncrement:: ds 2
|
hScoreIncrement:: ds 2
|
||||||
wScoreIncrementBCD:: ds 6
|
hScoreIncrementBCD:: ds 6
|
||||||
wScoreIncrementHead:: ds 1
|
hScoreIncrementHead:: ds 1
|
||||||
|
|
||||||
|
|
||||||
SECTION "Score Functions", ROM0
|
SECTION "Score Functions", ROM0
|
||||||
ScoreInit::
|
ScoreInit::
|
||||||
xor a, a
|
xor a, a
|
||||||
ld hl, wScore
|
ldh [hScore], a
|
||||||
ld [hl+], a
|
ldh [hScore+1], a
|
||||||
ld [hl+], a
|
ldh [hScore+2], a
|
||||||
ld [hl+], a
|
ldh [hScore+3], a
|
||||||
ld [hl+], a
|
ldh [hScore+4], a
|
||||||
ld [hl+], a
|
ldh [hScore+5], a
|
||||||
ld [hl], a
|
ldh [hScoreIncrement], a
|
||||||
ld hl, wScoreIncrement
|
ldh [hScoreIncrement+1], a
|
||||||
ld [hl+], a
|
|
||||||
ld [hl], a
|
|
||||||
ld a, $FF
|
ld a, $FF
|
||||||
ld hl, wScoreIncrementBCD
|
ldh [hScoreIncrementBCD], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+1], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+2], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+3], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+4], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+5], a
|
||||||
ld [hl], a
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Increases the current score by the amount in wScoreIncrement.
|
; Increases the current score by the amount in wScoreIncrement.
|
||||||
IncreaseScore::
|
IncreaseScore::
|
||||||
; Wipe the old BCD score.
|
; Wipe the old BCD score.
|
||||||
ld a, $FF
|
ld a, $FF
|
||||||
ld hl, wScoreIncrementBCD
|
ldh [hScoreIncrementBCD], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+1], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+2], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+3], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+4], a
|
||||||
ld [hl+], a
|
ldh [hScoreIncrementBCD+5], a
|
||||||
ld [hl], a
|
|
||||||
|
|
||||||
; First convert to BCD.
|
; First convert to BCD.
|
||||||
ld a, [wScoreIncrement]
|
ldh a, [hScoreIncrement]
|
||||||
ld l, a
|
ld l, a
|
||||||
ld a, [wScoreIncrement+1]
|
ldh a, [hScoreIncrement+1]
|
||||||
ld h, a
|
ld h, a
|
||||||
ld de, wScoreIncrementBCD
|
ld de, hScoreIncrementBCD
|
||||||
ld bc, -10000
|
ld bc, -10000
|
||||||
call .doConvert
|
call .doConvert
|
||||||
ld bc, -1000
|
ld bc, -1000
|
||||||
|
@ -109,12 +105,12 @@ IncreaseScore::
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.postConvert
|
.postConvert
|
||||||
ld hl, wScoreIncrement
|
ld hl, hScoreIncrement
|
||||||
xor a, a
|
xor a, a
|
||||||
ld [hl+], a
|
ld [hl+], a
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
|
|
||||||
ld de, wScoreIncrementBCD+5
|
ld de, hScoreIncrementBCD+5
|
||||||
ld b, 0
|
ld b, 0
|
||||||
ld a, $FF
|
ld a, $FF
|
||||||
: cp a, b
|
: cp a, b
|
||||||
|
@ -125,22 +121,22 @@ IncreaseScore::
|
||||||
|
|
||||||
.preAddDigit
|
.preAddDigit
|
||||||
; B contains the amount of times we need to shift the BCD score to the right.
|
; B contains the amount of times we need to shift the BCD score to the right.
|
||||||
ld a, [wScoreIncrementBCD+4]
|
ldh a, [hScoreIncrementBCD+4]
|
||||||
ld [wScoreIncrementBCD+5], a
|
ldh [hScoreIncrementBCD+5], a
|
||||||
ld a, [wScoreIncrementBCD+3]
|
ldh a, [hScoreIncrementBCD+3]
|
||||||
ld [wScoreIncrementBCD+4], a
|
ldh [hScoreIncrementBCD+4], a
|
||||||
ld a, [wScoreIncrementBCD+2]
|
ldh a, [hScoreIncrementBCD+2]
|
||||||
ld [wScoreIncrementBCD+3], a
|
ldh [hScoreIncrementBCD+3], a
|
||||||
ld a, [wScoreIncrementBCD+1]
|
ldh a, [hScoreIncrementBCD+1]
|
||||||
ld [wScoreIncrementBCD+2], a
|
ldh [hScoreIncrementBCD+2], a
|
||||||
ld a, [wScoreIncrementBCD]
|
ldh a, [hScoreIncrementBCD]
|
||||||
ld [wScoreIncrementBCD+1], a
|
ldh [hScoreIncrementBCD+1], a
|
||||||
xor a, a
|
xor a, a
|
||||||
ld [wScoreIncrementBCD], a
|
ldh [hScoreIncrementBCD], a
|
||||||
dec b
|
dec b
|
||||||
jr z, :-
|
jr z, :-
|
||||||
ld hl, wScore+5
|
ld hl, hScore+5
|
||||||
ld de, wScoreIncrementBCD+5
|
ld de, hScoreIncrementBCD+5
|
||||||
|
|
||||||
; DE is now pointing to the last digit of the BCD score.
|
; DE is now pointing to the last digit of the BCD score.
|
||||||
; HL points at the last digit of the displayed score.
|
; HL points at the last digit of the displayed score.
|
||||||
|
@ -182,13 +178,13 @@ IncreaseScore::
|
||||||
jr nz, .addDigit
|
jr nz, .addDigit
|
||||||
|
|
||||||
; Check if the score has rolled over.
|
; Check if the score has rolled over.
|
||||||
ld a, [wScore]
|
ldh a, [hScore]
|
||||||
cp a, $0A
|
cp a, $0A
|
||||||
ret c
|
ret c
|
||||||
|
|
||||||
; If it has, reset the score.
|
; If it has, reset the score.
|
||||||
xor a, a
|
xor a, a
|
||||||
ld [wScore], a
|
ldh [hScore], a
|
||||||
ld a, SFX_RANK_UP
|
ld a, SFX_RANK_UP
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -1279,7 +1279,7 @@ sSFXReadyGo::
|
||||||
sSFXReadyGoEnd::
|
sSFXReadyGoEnd::
|
||||||
|
|
||||||
|
|
||||||
SECTION "SFX Variables", HRAM
|
SECTION "High SFX Variables", HRAM
|
||||||
hPlayhead:: ds 2
|
hPlayhead:: ds 2
|
||||||
hPlayQueue:: ds 4
|
hPlayQueue:: ds 4
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ DEF MODE_PRE_GAME_OVER EQU 8
|
||||||
DEF MODE_PAUSED EQU 9
|
DEF MODE_PAUSED EQU 9
|
||||||
|
|
||||||
|
|
||||||
SECTION "Critical Gameplay Variables", HRAM
|
SECTION "High Gameplay Variables", HRAM
|
||||||
hCurrentPiece:: ds 1
|
hCurrentPiece:: ds 1
|
||||||
hCurrentPieceX:: ds 1
|
hCurrentPieceX:: ds 1
|
||||||
hCurrentPieceY:: ds 1
|
hCurrentPieceY:: ds 1
|
||||||
|
@ -180,7 +180,7 @@ postGoMode:
|
||||||
|
|
||||||
; Fetch the next piece.
|
; Fetch the next piece.
|
||||||
fetchPieceMode:
|
fetchPieceMode:
|
||||||
ld a, [wNextPiece]
|
ldh a, [hNextPiece]
|
||||||
ldh [hCurrentPiece], a
|
ldh [hCurrentPiece], a
|
||||||
call GetNextPiece
|
call GetNextPiece
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ fetchPieceMode:
|
||||||
cp a, 0
|
cp a, 0
|
||||||
jr nz, .skipJingle
|
jr nz, .skipJingle
|
||||||
.playNextJingle
|
.playNextJingle
|
||||||
ld a, [wNextPiece]
|
ldh a, [hNextPiece]
|
||||||
call SFXEnqueue
|
call SFXEnqueue
|
||||||
.skipJingle
|
.skipJingle
|
||||||
ld a, MODE_SPAWN_PIECE
|
ld a, MODE_SPAWN_PIECE
|
||||||
|
@ -462,7 +462,7 @@ gameOverMode:
|
||||||
; Quit
|
; Quit
|
||||||
: ldh a, [hBState]
|
: ldh a, [hBState]
|
||||||
cp a, 1
|
cp a, 1
|
||||||
jr nz, :+
|
jp nz, drawStaticInfo
|
||||||
call SwitchToTitle
|
call SwitchToTitle
|
||||||
jp EventLoopPostHandler
|
jp EventLoopPostHandler
|
||||||
|
|
||||||
|
@ -524,22 +524,22 @@ pauseMode:
|
||||||
|
|
||||||
; Always draw the score, level, next piece, and held piece.
|
; Always draw the score, level, next piece, and held piece.
|
||||||
drawStaticInfo:
|
drawStaticInfo:
|
||||||
: ld a, [wNextPiece]
|
: ldh a, [hNextPiece]
|
||||||
call ApplyNext
|
call ApplyNext
|
||||||
|
|
||||||
ldh a, [hHeldPiece]
|
ldh a, [hHeldPiece]
|
||||||
call ApplyHold
|
call ApplyHold
|
||||||
|
|
||||||
ld hl, wSPRScore1
|
ld hl, wSPRScore1
|
||||||
ld de, wScore
|
ld de, hScore
|
||||||
call ApplyNumbers
|
call ApplyNumbers
|
||||||
|
|
||||||
ld hl, wSPRCLevel1
|
ld hl, wSPRCLevel1
|
||||||
ld de, wCLevel
|
ld de, hCLevel
|
||||||
call ApplyNumbers
|
call ApplyNumbers
|
||||||
|
|
||||||
ld hl, wSPRNLevel1
|
ld hl, wSPRNLevel1
|
||||||
ld de, wNLevel
|
ld de, hNLevel
|
||||||
call ApplyNumbers
|
call ApplyNumbers
|
||||||
|
|
||||||
jp EventLoopPostHandler
|
jp EventLoopPostHandler
|
||||||
|
@ -612,7 +612,7 @@ DoHold:
|
||||||
jr nz, :+
|
jr nz, :+
|
||||||
ldh a, [hCurrentPiece]
|
ldh a, [hCurrentPiece]
|
||||||
ldh [hHeldPiece], a
|
ldh [hHeldPiece], a
|
||||||
ld a, [wNextPiece]
|
ldh a, [hNextPiece]
|
||||||
ldh [hCurrentPiece], a
|
ldh [hCurrentPiece], a
|
||||||
call GetNextPiece
|
call GetNextPiece
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -22,7 +22,7 @@ DEF TIME_ASM EQU 1
|
||||||
INCLUDE "globals.asm"
|
INCLUDE "globals.asm"
|
||||||
|
|
||||||
|
|
||||||
SECTION "Time Variables", HRAM
|
SECTION "High Time Variables", HRAM
|
||||||
hFrameCtr:: ds 1
|
hFrameCtr:: ds 1
|
||||||
hEvenFrame:: ds 1
|
hEvenFrame:: ds 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue