Compare commits

..

No commits in common. "2c5ee3049be717a8289d4bb34be11070b615f7ae" and "c6032fb55c9019470f2487161929fe986e063966" have entirely different histories.

10 changed files with 98 additions and 167 deletions

1
.vscode/launch.json vendored
View File

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

Binary file not shown.

View File

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

View File

@ -460,7 +460,7 @@ GBCGameplayInit::
ldh [rOCPD], a ldh [rOCPD], a
; Pal 2 (purple, S) ; Pal 2 (purple, S)
ld bc, R2 | B3 ld bc, R3 | B3
ld a, c ld a, c
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
@ -468,7 +468,7 @@ GBCGameplayInit::
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
ld bc, R1 | B2 ld bc, R2 | B2
ld a, c ld a, c
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
@ -476,7 +476,7 @@ GBCGameplayInit::
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
ld bc, R0 | B1 ld bc, R1 | B1
ld a, c ld a, c
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
@ -734,44 +734,16 @@ GBCGameplayProcess::
cp a, $11 cp a, $11
ret nz ret nz
; Color based on mode. ; 20G?
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] ldh a, [hCurrentGravityPerTick]
cp a, 20 cp a, 20
jr nz, .colorfield jr nz, :+
; Strobe the frame.
ld a, $00 ld a, $00
ld d, a jr .colorfield
: ld a, $03
.colorfield .colorfield
ld d, a
ld hl, wShadowTileAttrs ld hl, wShadowTileAttrs
ld bc, 32-12 ld bc, 32-12
@ -889,45 +861,6 @@ GBCGameplayProcess::
dec a dec a
ld [wOuterReps], a ld [wOuterReps], a
jr nz, .outer2 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 ret

View File

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

View File

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

View File

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

Binary file not shown.

View File

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

View File

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