Compare commits

...

2 Commits

Author SHA1 Message Date
Randy Thiemann 2c5ee3049b Fix scoring 2023-10-24 22:21:48 +02:00
Randy Thiemann 2946208ccc Move next/hold. 2023-10-24 22:21:25 +02:00
10 changed files with 167 additions and 98 deletions

1
.vscode/launch.json vendored
View File

@ -9,6 +9,7 @@
"request": "launch",
"name": "Launch in Emulicious",
"program": "${workspaceFolder}\\bin\\DMGTRIS.gbc",
"emuliciousPath": "K:\\TGM\\dmgtris\\tools",
"port": 58870,
"stopOnEntry": false,
"preLaunchTask": "buildrom"

Binary file not shown.

View File

@ -54,8 +54,8 @@ hClearedLines: ds 4
hLineClearCt: ds 1
hComboCt: ds 1
hLockDelayForce: ds 1
hHighestStack: ds 1
hDownFrames: ds 1
hAwardDownBonus: ds 1
hStalePiece: ds 1
hBravo: ds 1
@ -64,8 +64,6 @@ SECTION "Field Functions", ROM0
FieldInit::
xor a, a
ldh [hBravo], a
ld a, 23
ldh [hHighestStack], a
ld a, 1
ldh [hComboCt], a
ld hl, wField
@ -528,6 +526,7 @@ TrySpawnPiece::
xor a, a
ldh [hStalePiece], a
ldh [hDownFrames], a
ldh [hAwardDownBonus], a
ldh [hLockDelayForce], a
ldh a, [hCurrentLockDelay]
ldh [hCurrentLockDelayRemaining], a
@ -682,33 +681,6 @@ FindMaxG:
ldh a, [hCurrentPieceX]
call XYToSFieldPtr
;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]
sub a, 4
ld b, a
ld a, [hCurrentPieceY]
cp a, b
jr nc, .unoptimized ; If our piece is already past that, we can't optimize.
; But if we're NOT, that means we can assume a minimum fall distance!
.optimized
ld c, a
ld a, b
sub a, c
inc a
ldh [hActualG], a
dec a
ld de, 14
: add hl, de
dec a
jr nz, :-
push hl
jr .try
ENDC
.unoptimized
push hl
ld a, 1
ldh [hActualG], a
@ -1212,7 +1184,10 @@ FieldProcess::
; **************************************************************
; HANDLE UP
; Is a hard/sonic drop requested?
; Is a hard/sonic drop requested? Skip if in 20G mode.
ldh a, [hCurrentGravityPerTick]
cp a, 20
jr z, .postdrop
ldh a, [hUpState]
cp a, 0
jr z, .postdrop
@ -1226,9 +1201,8 @@ FieldProcess::
; Sonic drop.
.sonicdrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, $FF
ldh [hAwardDownBonus], a
ld a, 20
ldh [hWantedG], a
ldh a, [hTicksUntilG]
@ -1241,9 +1215,8 @@ FieldProcess::
; Hard drop.
.harddrop
ldh a, [hDownFrames]
add a, 10
ldh [hDownFrames], a
ld a, $FF
ldh [hAwardDownBonus], a
ld a, 20
ld b, a
ldh a, [hActualG]
@ -1423,7 +1396,7 @@ FieldProcess::
jr z, .ghost
ldh a, [hEvenFrame]
cp a, 1
jr nz, :+
jr nz, .postghost
.ghost
ldh a, [hYPosAtStartOfFrame]
@ -1444,8 +1417,8 @@ FieldProcess::
pop de
call DrawPiece
; If the lock delay is at the highest value, draw the piece normally.
.postghost
; If the lock delay is at the highest value, draw the piece normally.
ldh a, [hCurrentPiece]
ld b, TILE_PIECE_0
add a, b
@ -1463,19 +1436,10 @@ FieldProcess::
ldh [hWantedTile], a
ldh a, [hCurrentLockDelayRemaining]
cp a, 0
jr nz, :+
; Check if the stack usage went up.
ldh a, [hHighestStack]
ld b, a
ldh a, [hCurrentPieceY]
cp a, b
jr nc, .drawpiece
ldh [hHighestStack], a
jr .drawpiece
jr z, .drawpiece
; Otherwise, look it up.
: call GetTileShade
call GetTileShade
.drawpiece
ldh a, [hCurrentPieceY]
@ -1857,37 +1821,64 @@ FieldDelay::
ld c, a
xor a, a
ld b, a
; Lock bonus?
ldh a, [hAwardDownBonus]
cp a, $FF
jr nz, .premultiplier
ld a, 10
add a, c
ld c, a
; Final total pre-multipliers.
.premultiplier
add hl, bc
; Copy the running total.
; Copy the running total for multiplication.
ld b, h
ld c, l
; Get a multiplier consisting of...
xor a, a
ld d, a
ldh a, [hBravo] ; 4 if the field is empty and...
; Do we have a bravo? x4 if so.
.bravo
ldh a, [hBravo]
cp a, 0
jr nz, :+
ld a, 4
ld d, a
jr nz, .lineclears
add hl, bc
add hl, bc
add hl, bc
ld b, h
ld c, l
: ldh a, [hLineClearCt] ; The number of lines cleared and...
add a, d
ld d, a
ldh a, [hComboCt] ; The combo count.
; x line clears
.lineclears
ldh a, [hLineClearCt]
dec a
add a, d
; Multiply the running total by the multiplier.
jr z, .combo
: add hl, bc
dec a
cp a, 0
jr nz, :-
ld b, h
ld c, l
; x combo
.combo
ldh a, [hComboCt]
dec a
jr z, .applyscore
: add hl, bc
jr c, .forcemax
dec a
jr nz, :-
jr .applyscore
; Overflow = 65535
.forcemax
ld a, $FF
ld h, a
ld l, a
; And apply the score.
.applyscore
ld a, l
ldh [hScoreIncrement], a
ld a, h
@ -2078,9 +2069,6 @@ ClearLines:
; If it does, increment the clearing counter, but skip this line.
jr nz, .clear\@
ldh a, [hHighestStack]
inc a
ldh [hHighestStack], a
inc de
inc de
inc de
@ -2136,13 +2124,6 @@ ClearLines:
DEF row -= 1
ENDR
; Check if the stack marker is out of bounds.
ldh a, [hHighestStack]
cp a, 23
jr c, .fixgarbo
ld a, 23
ldh [hHighestStack], a
; Make sure there's no garbage in the top de lines.
.fixgarbo
ld hl, wField

View File

@ -460,7 +460,7 @@ GBCGameplayInit::
ldh [rOCPD], a
; Pal 2 (purple, S)
ld bc, R3 | B3
ld bc, R2 | B3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
@ -468,7 +468,7 @@ GBCGameplayInit::
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R2 | B2
ld bc, R1 | B2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
@ -476,7 +476,7 @@ GBCGameplayInit::
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R1 | B1
ld bc, R0 | B1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
@ -734,16 +734,44 @@ GBCGameplayProcess::
cp a, $11
ret nz
; 20G?
; Color based on mode.
ld a, [wSpeedCurveState]
cp a, SCURVE_DMGT
ld a, $03 ;Blue
jr z, .higoverride
ld a, [wSpeedCurveState]
cp a, SCURVE_TGM1
ld a, $05 ;Yellow
jr z, .higoverride
ld a, [wSpeedCurveState]
cp a, SCURVE_TGM3
ld a, $04 ;Orange
jr z, .higoverride
ld a, [wSpeedCurveState]
cp a, SCURVE_DEAT
ld a, $06 ;Cyan
jr z, .higoverride
ld a, [wSpeedCurveState]
cp a, SCURVE_SHIR
ld a, $00 ;Red
jr z, .colorfield ;Always red
ld a, [wSpeedCurveState]
cp a, SCURVE_CHIL
ld a, $01 ;Green
jr z, .higoverride
; Are we 20G?
.higoverride
ld d, a
ldh a, [hCurrentGravityPerTick]
cp a, 20
jr nz, :+
jr nz, .colorfield
; Strobe the frame.
ld a, $00
jr .colorfield
: ld a, $03
ld d, a
.colorfield
ld d, a
ld hl, wShadowTileAttrs
ld bc, 32-12
@ -861,6 +889,45 @@ GBCGameplayProcess::
dec a
ld [wOuterReps], a
jr nz, .outer2
; Maybe flash numbers.
ldh a, [hCurrentGravityPerTick]
cp a, 20
jr nz, .black
ld hl, hFrameCtr
bit 1, [hl]
jr z, .lighter
.darker
ld a, OCPSF_AUTOINC | (7*8)+(3*2)
ldh [rOCPS], a
ld bc, R2 | G2
wait_vram
ld a, c
ldh [rOCPD], a
ld a, b
ldh [rOCPD], a
ret
.lighter
ld a, OCPSF_AUTOINC | (7*8)+(3*2)
ldh [rOCPS], a
ld bc, R3 | G3
wait_vram
ld a, c
ldh [rOCPD], a
ld a, b
ldh [rOCPD], a
ret
.black
ld a, OCPSF_AUTOINC | (7*8)+(3*2)
ldh [rOCPS], a
xor a, a
wait_vram
ldh [rOCPD], a
ldh [rOCPD], a
ret

View File

@ -109,9 +109,9 @@ DEF PALETTE_LIGHTER_1 EQU %10010000
DEF PALETTE_LIGHTER_2 EQU %01000000
DEF PALETTE_LIGHTER_3 EQU %00000000
DEF NEXT_BASE_X EQU 120
DEF NEXT_BASE_X EQU 115
DEF NEXT_BASE_Y EQU 40
DEF HOLD_BASE_X EQU 120
DEF HOLD_BASE_X EQU 115
DEF HOLD_BASE_Y EQU 80
DEF SCORE_BASE_X EQU 112
DEF SCORE_BASE_Y EQU 115

View File

@ -137,9 +137,9 @@ LevelUp::
add a, l
ld l, a
adc a, h
sub l
sub a, l
ldh [hLevel+1], a
ld l, a
ld a, l
ldh [hLevel], a
; Save the current hundred digit.
@ -191,6 +191,11 @@ LevelUp::
ldh [hCLevel+1], a
ldh [hCLevel+2], a
ldh [hCLevel+3], a
ld hl, 9999
ld a, l
ldh [hLevel], a
ld a, h
ldh [hLevel+1], a
call DoSpeedUp
ld a, SFX_RANKUP
call SFXEnqueue

View File

@ -53,6 +53,7 @@ rRotModeState:: ds 1
rDropModeState:: ds 1
rSpeedCurveState:: ds 1
rAlways20GState:: ds 1
rSelectedStartLevel:: ds 2
SECTION "Stack", WRAM0
@ -122,7 +123,7 @@ Main::
cp a, "G"
jr nz, .nosavedata
ld a, [rMagic+3]
cp a, "0"
cp a, "1"
jr nz, .nosavedata
.savedata
@ -138,6 +139,10 @@ Main::
ld [wSpeedCurveState], a
ld a, [rAlways20GState]
ld [wAlways20GState], a
ld a, [rSelectedStartLevel]
ldh [hStartSpeed], a
ld a, [rSelectedStartLevel+1]
ldh [hStartSpeed+1], a
jr .otherinit
.nosavedata
@ -147,7 +152,7 @@ Main::
ld [rMagic+1], a
ld a, "G"
ld [rMagic+2], a
ld a, "0"
ld a, "1"
ld [rMagic+3], a
ld a, BUTTON_MODE_NORM
@ -178,12 +183,15 @@ Main::
ld [rAlways20GState], a
ld [wAlways20GState], a
.otherinit
ld hl, sSpeedCurve
ld a, l
ldh [hStartSpeed], a
ld [rSelectedStartLevel], a
ld a, h
ldh [hStartSpeed+1], a
ld [rSelectedStartLevel+1], a
.otherinit
call TimeInit
call IntrInit
call InputInit

Binary file not shown.

View File

@ -530,8 +530,8 @@ Tiles::
DB $4A,$4A,$4A,$4A,$E4,$E4,$00,$00
DB $CA,$CA,$2A,$2A,$2A,$2A,$4E,$4E
DB $82,$82,$82,$82,$E2,$E2,$00,$00
DB $FE,$FE,$06,$06,$0C,$0C,$38,$38
DB $60,$60,$C0,$C0,$FE,$FE,$00,$00
DB $FF,$FF,$81,$81,$24,$24,$3C,$3C
DB $24,$24,$81,$81,$FF,$FF,$00,$00
TilesEnd::

View File

@ -114,9 +114,6 @@ SwitchToTitle::
; GBC init
call GBCTitleInit
; Make sure the speed curve is aimed at the right place.
call InitSpeedCurve
; Install the event loop handlers.
ld a, 0
ldh [hGameState], a
@ -301,8 +298,10 @@ DecrementLevel:
add hl, bc
ld a, l
ldh [hStartSpeed], a
ld [rSelectedStartLevel], a
ld a, h
ldh [hStartSpeed+1], a
ld [rSelectedStartLevel+1], a
jp CheckLevelRange
@ -414,8 +413,10 @@ IncrementLevel:
add hl, bc
ld a, l
ldh [hStartSpeed], a
ld [rSelectedStartLevel], a
ld a, h
ldh [hStartSpeed+1], a
ld [rSelectedStartLevel+1], a
jp CheckLevelRange
InitSpeedCurve:
@ -425,8 +426,10 @@ InitSpeedCurve:
.set
ld a, l
ldh [hStartSpeed], a
ld [rSelectedStartLevel], a
ld a, h
ldh [hStartSpeed+1], a
ld [rSelectedStartLevel+1], a
ret
@ -492,8 +495,10 @@ CheckLevelRange:
jr nz, .notatend
call GetStart
ld a, l
ld [rSelectedStartLevel], a
ldh [hStartSpeed], a
ld a, h
ld [rSelectedStartLevel+1], a
ldh [hStartSpeed+1], a
.notatend
@ -513,8 +518,10 @@ CheckLevelRange:
ld l, c
add hl, de
ld a, l
ld [rSelectedStartLevel], a
ldh [hStartSpeed], a
ld a, h
ld [rSelectedStartLevel+1], a
ldh [hStartSpeed+1], a
.notatstart