From b16dbe030fddca4b905af1b352f1f916f25ff32c Mon Sep 17 00:00:00 2001 From: Gregory Stanke Date: Tue, 21 Jul 2026 22:17:26 -0400 Subject: [PATCH] Add Tetris Only practice mode --- src/constants.asm | 5 +- src/gamemode/gametypemenu/menu.asm | 2 +- src/nametables/game_type_menu.js | 2 +- src/playstate/updatestats.asm | 127 ++++++++++++++++++++++------- 4 files changed, 103 insertions(+), 33 deletions(-) diff --git a/src/constants.asm b/src/constants.asm index f0560c57..d810a314 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -79,6 +79,7 @@ MODE_TRANSITION MODE_MARATHON MODE_TAPQTY MODE_CHECKERBOARD +MODE_TETRISONLY MODE_GARBAGE MODE_DROUGHT MODE_DAS @@ -134,7 +135,7 @@ CRASH_CRASH := 3 LINECAP_WHEN_STRING_OFFSET := $10 LINECAP_HOW_STRING_OFFSET := $12 -MENU_SPRITE_Y_BASE := $46 +MENU_SPRITE_Y_BASE := $3E MENU_MAX_Y_SCROLL := $A0 MENU_TOP_MARGIN_SCROLL := 7 ; in blocks @@ -155,6 +156,7 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks .byte $4 ; MODE_MARATHON .byte $1F ; MODE_TAPQTY .byte $8 ; MODE_CHECKERBOARD + .byte $0 ; MODE_TETRISONLY .byte $4 ; MODE_GARBAGE .byte $12 ; MODE_DROUGHT .byte $10 ; MODE_DAS @@ -197,6 +199,7 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks .byte "MARTHN" .byte "TAPQTY" .byte "CKRBRD" + .byte "TETONL" .byte "GARBGE" .byte "LOBARS" .byte "DASDLY" diff --git a/src/gamemode/gametypemenu/menu.asm b/src/gamemode/gametypemenu/menu.asm index f4fb67b1..2d2f16b1 100644 --- a/src/gamemode/gametypemenu/menu.asm +++ b/src/gamemode/gametypemenu/menu.asm @@ -566,7 +566,7 @@ menuYTmp := tmp2 ldx crashModifier lda crashOptions, x sta spriteIndexInOamContentLookup - lda #(MODE_CRASH*8) + MENU_SPRITE_Y_BASE + 1 + lda #<((MODE_CRASH*8) + MENU_SPRITE_Y_BASE + 1) jmp @renderOption @renderDarkMode: diff --git a/src/nametables/game_type_menu.js b/src/nametables/game_type_menu.js index a12cb1a1..aecee8f4 100644 --- a/src/nametables/game_type_menu.js +++ b/src/nametables/game_type_menu.js @@ -38,7 +38,6 @@ drawTiles(buffer, lookup, ` #a d# #a d# #a d# -#a d# #a TETRIS d# #a T-SPINS d# #a SEED d# @@ -53,6 +52,7 @@ drawTiles(buffer, lookup, ` #a MARATHON d# #a TAP QUANTITY d# #a CHECKERBOARD d# +#a TETRIS ONLY d# #a GARBAGE d# #a DROUGHT d# #a DAS DELAY d# diff --git a/src/playstate/updatestats.asm b/src/playstate/updatestats.asm index 83b07592..18b4fe9e 100644 --- a/src/playstate/updatestats.asm +++ b/src/playstate/updatestats.asm @@ -186,6 +186,8 @@ addPoints: lda practiseType cmp #MODE_CHECKERBOARD beq handlePointsCheckerboard + cmp #MODE_TETRISONLY + beq handlePointsTetrisOnly cmp #MODE_TAPQTY bne @notTapQuantity lda completedLines @@ -252,6 +254,62 @@ handlePointsCheckerboard: checkerboardPoints: .byte 0, 10, 20, 30, 40 +handlePointsTetrisOnly: + jsr calcScaledLineClearPoints ; -> product24 = pointsTable[completedLines] * (level+1) + + lda completedLines + cmp #4 + beq @addPoints + + ; 1-3 lines: subtract the same scaled points a normal + ; clear would have earned, clamped at zero + sec + lda binScore + sbc product24 + sta binScore + lda binScore+1 + sbc product24+1 + sta binScore+1 + lda binScore+2 + sbc product24+2 + sta binScore+2 + lda binScore+3 + sbc #0 + sta binScore+3 + bcs @finish + lda #0 + sta binScore + sta binScore+1 + sta binScore+2 + sta binScore+3 + jmp @finish + +@addPoints: + clc + lda binScore + adc product24 + sta binScore + lda binScore+1 + adc product24+1 + sta binScore+1 + lda binScore+2 + adc product24+2 + sta binScore+2 + lda binScore+3 + adc #0 + sta binScore+3 + +@finish: + jsr setupScoreForRender + lda renderFlags + ora #RENDER_SCORE + sta renderFlags + lda #$0 + sta completedLines + lda #$0 + sta holdDownPoints + rts + ones := tmpX hundredths := tmpY low := tmpZ @@ -342,36 +400,7 @@ div16mul10: rts addLineClearPoints: - lda #0 - sta factorA24+1 - sta factorA24+2 - lda levelNumber - ldy practiseType - cpy #MODE_MARATHON - bne @notMarathon - ldy marathonModifier - cpy #3 ; Marathon modes 3 + 4 score normally - bcs @notMarathon - lda startLevel -@notMarathon: - sta factorA24+0 - inc factorA24+0 - bne @noverflow - inc factorA24+1 -@noverflow: - - lda completedLines - beq addLineClearPoints_end ; skip with 0 completed lines - asl - tax - lda pointsTable, x - sta factorB24+0 - lda pointsTable+1, x - sta factorB24+1 - lda #0 - sta factorB24+2 - - jsr unsigned_mul24 ; points to add in product24 + jsr calcScaledLineClearPoints clc lda binScore @@ -426,6 +455,44 @@ clearPoints: sta binScore+3 rts +calcScaledLineClearPoints: + lda #0 + sta factorA24+1 + sta factorA24+2 + lda levelNumber + ldy practiseType + cpy #MODE_MARATHON + bne @notMarathon + ldy marathonModifier + cpy #3 ; Marathon modes 3 + 4 score normally + bcs @notMarathon + lda startLevel +@notMarathon: + sta factorA24+0 + inc factorA24+0 + bne @noverflow + inc factorA24+1 +@noverflow: + + lda completedLines + bne @hasLines + lda #0 + sta product24 + sta product24+1 + sta product24+2 + rts +@hasLines: + asl + tax + lda pointsTable, x + sta factorB24+0 + lda pointsTable+1, x + sta factorB24+1 + lda #0 + sta factorB24+2 + + jmp unsigned_mul24 ; tail call - product24 set, rts returns to our caller + pointsTable: .word 0,40,100,300,1200 .word 1000 ; used in btype score calc