Skip to content

Commit 518dd8c

Browse files
committed
Merge branch 'master' of github.com:kirjavascript/TetrisGYM
2 parents dbdb9af + b0bb52b commit 518dd8c

23 files changed

+256
-96
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
* Famicom Keyboard support
88
* Fixed Floor-0 disabled burns
99
* MMC3 Support
10+
* MMC5 Support
11+
* Fixed CNROM legal screen CHR bank
12+
* Fixed CNROM legal to title flicker
13+
* Block Tool pieces wrap around
14+
* Added hidden score option
15+
* Added marathon mode
16+
* 0001 seeds are ignored
1017

1118
## [v5 tournament]
1219
* Linecap Menu (from CTM Masters September 2022)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ Puts you ten lines before transition. The value given will be added to your scor
193193

194194
Setting the value to G causes the mode to act identical to the game genie code `SXTOKL`
195195

196+
### Marathon
197+
198+
Play as long as you are able to surive at a consistent speed. While the level will increase normally, the drop rate and the points rewarded will remain fixed based on the starting level.
199+
196200
### Garbage
197201

198202
![Garbage](./assets/screens/garbage.png)
@@ -306,6 +310,12 @@ __Capped__
306310

307311
Cap your score at 999999.
308312

313+
__Hidden__
314+
315+
![Hidden](./assets/screens/score-hidden.png)
316+
317+
Hides score until game over.
318+
309319
## Hz Display
310320

311321
![Hz Display](./assets/screens/hz.png)

assets/screens/score-hidden.png

56.3 KB
Loading

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ while getopts "vm:askh" flag; do
1616
case "${flag}" in
1717
v) set -x ;;
1818
m)
19-
if ! [[ "${OPTARG}" =~ ^[134]$ ]]; then
20-
echo "Valid INES_MAPPER (-m) options are 1, 3 or 4"
19+
if ! [[ "${OPTARG}" =~ ^[1345]$ ]]; then
20+
echo "Valid INES_MAPPER (-m) options are 1, 3, 4 or 5"
2121
exit 1
2222
fi
2323
compile_flags+=("-D INES_MAPPER=${OPTARG}")

src/constants.asm

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
INES_MAPPER := 1 ; supports 1, 3 and 4 (MMC1 / CNROM / MMC3)
33
.endif
44

5-
HAS_MMC = INES_MAPPER = 1 || INES_MAPPER = 4
5+
HAS_MMC = INES_MAPPER = 1 || INES_MAPPER = 4 || INES_MAPPER = 5
66

77
.ifndef SAVE_HIGHSCORES
88
SAVE_HIGHSCORES := 1
@@ -52,46 +52,50 @@ BUTTON_SELECT := $20
5252
BUTTON_START := $10
5353
BUTTON_DPAD := BUTTON_UP | BUTTON_DOWN | BUTTON_LEFT | BUTTON_RIGHT
5454

55-
MODE_TETRIS := 0
56-
MODE_TSPINS := 1
57-
MODE_SEED := 2
58-
MODE_PARITY := 3
59-
MODE_PACE := 4
60-
MODE_PRESETS := 5
61-
MODE_TYPEB := 6
62-
MODE_FLOOR := 7
63-
MODE_CRUNCH := 8
64-
MODE_TAP := 9
65-
MODE_TRANSITION := 10
66-
MODE_TAPQTY := 11
67-
MODE_CHECKERBOARD := 12
68-
MODE_GARBAGE := 13
69-
MODE_DROUGHT := 14
70-
MODE_DAS := 15
71-
MODE_KILLX2 := 16
72-
MODE_INVISIBLE := 17
73-
MODE_HARDDROP := 18
74-
MODE_SPEED_TEST := 19
75-
MODE_SCORE_DISPLAY := 20
76-
MODE_HZ_DISPLAY := 21
77-
MODE_INPUT_DISPLAY := 22
78-
MODE_DISABLE_FLASH := 23
79-
MODE_DISABLE_PAUSE := 24
80-
MODE_GOOFY := 25
81-
MODE_DEBUG := 26
82-
MODE_LINECAP := 27
83-
MODE_DASONLY := 28
84-
MODE_QUAL := 29
85-
MODE_PAL := 30
86-
87-
MODE_QUANTITY := 31
88-
MODE_GAME_QUANTITY := 19
55+
.enum
56+
MODE_TETRIS
57+
MODE_TSPINS
58+
MODE_SEED
59+
MODE_PARITY
60+
MODE_PACE
61+
MODE_PRESETS
62+
MODE_TYPEB
63+
MODE_FLOOR
64+
MODE_CRUNCH
65+
MODE_TAP
66+
MODE_TRANSITION
67+
MODE_MARATHON
68+
MODE_TAPQTY
69+
MODE_CHECKERBOARD
70+
MODE_GARBAGE
71+
MODE_DROUGHT
72+
MODE_DAS
73+
MODE_KILLX2
74+
MODE_INVISIBLE
75+
MODE_HARDDROP
76+
MODE_SPEED_TEST
77+
MODE_SCORE_DISPLAY
78+
MODE_HZ_DISPLAY
79+
MODE_INPUT_DISPLAY
80+
MODE_DISABLE_FLASH
81+
MODE_DISABLE_PAUSE
82+
MODE_GOOFY
83+
MODE_DEBUG
84+
MODE_LINECAP
85+
MODE_DASONLY
86+
MODE_QUAL
87+
MODE_PAL
88+
.endenum
89+
90+
MODE_QUANTITY = MODE_PAL + 1
91+
MODE_GAME_QUANTITY = MODE_HARDDROP + 1
8992

9093
SCORING_CLASSIC := 0 ; for scoringModifier
9194
SCORING_LETTERS := 1
9295
SCORING_SEVENDIGIT := 2
9396
SCORING_FLOAT := 3
9497
SCORING_SCORECAP := 4
98+
SCORING_HIDDEN := 5
9599

96100
LINECAP_KILLX2 := 1
97101
LINECAP_FLOOR := 2
@@ -107,7 +111,40 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks
107111

108112
; menuConfigSizeLookup
109113
; menu ram is defined at menuRAM in ./ram.asm
110-
.define MENUSIZES $0, $0, $0, $0, $F, $7, $8, $C, $F, $20, $10, $1F, $8, $4, $12, $10, $0, $0, $0, $0, $4, $1, $1, $1, $1, $1, $1, $1, $1, $1, $1
114+
.macro MENUSIZES
115+
.byte $0 ; MODE_TETRIS
116+
.byte $0 ; MODE_TSPINS
117+
.byte $0 ; MODE_SEED
118+
.byte $0 ; MODE_PARITY
119+
.byte $F ; MODE_PACE
120+
.byte $7 ; MODE_PRESETS
121+
.byte $8 ; MODE_TYPEB
122+
.byte $C ; MODE_FLOOR
123+
.byte $F ; MODE_CRUNCH
124+
.byte $20 ; MODE_TAP
125+
.byte $10 ; MODE_TRANSITION
126+
.byte $0 ; MODE_MARATHON
127+
.byte $1F ; MODE_TAPQTY
128+
.byte $8 ; MODE_CHECKERBOARD
129+
.byte $4 ; MODE_GARBAGE
130+
.byte $12 ; MODE_DROUGHT
131+
.byte $10 ; MODE_DAS
132+
.byte $0 ; MODE_KILLX2
133+
.byte $0 ; MODE_INVISIBLE
134+
.byte $0 ; MODE_HARDDROP
135+
.byte $0 ; MODE_SPEED_TEST
136+
.byte $5 ; MODE_SCORE_DISPLAY
137+
.byte $1 ; MODE_HZ_DISPLAY
138+
.byte $1 ; MODE_INPUT_DISPLAY
139+
.byte $1 ; MODE_DISABLE_FLASH
140+
.byte $1 ; MODE_DISABLE_PAUSE
141+
.byte $1 ; MODE_GOOFY
142+
.byte $1 ; MODE_DEBUG
143+
.byte $1 ; MODE_LINECAP
144+
.byte $1 ; MODE_DASONLY
145+
.byte $1 ; MODE_QUAL
146+
.byte $1 ; MODE_PAL
147+
.endmacro
111148

112149
.macro MODENAMES
113150
.byte "TETRIS"
@@ -121,6 +158,7 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks
121158
.byte "CRUNCH"
122159
.byte "QCKTAP"
123160
.byte "TRNSTN"
161+
.byte "MARTHN"
124162
.byte "TAPQTY"
125163
.byte "CKRBRD"
126164
.byte "GARBGE"

src/gamemode/gametypemenu/menu.asm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ gameMode_gameTypeMenu:
2121
; Horizontal mirroring
2222
lda #$1
2323
sta MMC3_MIRRORING
24+
.elseif INES_MAPPER = 5
25+
; Horizontal mirroring
26+
lda #$50
27+
sta MMC5_NT_MAPPING
2428
.endif
2529
lda #%10011 ; used to be $10 (enable horizontal mirroring)
2630
jsr setMMC1Control
@@ -97,6 +101,7 @@ gameTypeLoopCheckStart:
97101
lda set_seed_input
98102
bne @checkSelectable
99103
lda set_seed_input+1
104+
and #$FE ; treat 0001 like 0000
100105
beq gameTypeLoopNext
101106

102107
@checkSelectable:
@@ -305,7 +310,7 @@ menuConfigControls:
305310
rts
306311

307312
menuConfigSizeLookup:
308-
.byte MENUSIZES
313+
MENUSIZES
309314

310315
assertValues:
311316
; make sure you can only have block or qual
@@ -410,6 +415,7 @@ renderMenuVars:
410415
lda set_seed_input
411416
bne @renderIndicator
412417
lda set_seed_input+1
418+
and #$FE ; treat 0001 like 0000
413419
beq @cursorFinished
414420
@renderIndicator:
415421
ldx #$E

src/gamemodestate/initbackground.asm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ gameModeState_initGameBackground:
5151
; Vertical mirroring (Prevents screen glitching)
5252
lda #$0
5353
sta MMC3_MIRRORING
54+
.elseif INES_MAPPER = 5
55+
; Single screen (Prevents screen glitching)
56+
lda #$0
57+
sta MMC5_NT_MAPPING
5458
.endif
5559
jsr resetScroll
5660
jsr waitForVBlankAndEnableNmi
@@ -80,7 +84,19 @@ scoringBackground:
8084
sta PPUADDR
8185
lda #$16
8286
sta PPUDATA
87+
jmp @noSevenDigit
8388
@noFloat:
89+
cmp #SCORING_HIDDEN
90+
bne @notHidden
91+
jsr scoreSetupPPU
92+
lda #$FF
93+
ldx #$6
94+
@hiddenScoreLoop:
95+
sta PPUDATA
96+
dex
97+
bne @hiddenScoreLoop
98+
jmp @noSevenDigit
99+
@notHidden:
84100
cmp #SCORING_SEVENDIGIT
85101
bne @noSevenDigit
86102
jsr bulkCopyToPpu

src/gamemodestate/pause.asm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ pause:
3838

3939
@pauseSetupPart2:
4040
jsr updateAudioAndWaitForNmi
41-
lda #$FF
42-
ldx #$02
43-
ldy #$02
44-
jsr memset_page
41+
jsr resetOAMStaging
4542

4643
@pauseLoop:
4744
lda qualFlag

src/io.asm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,20 @@ MMC1_CHR1 := $DFFF
4949
MMC3_BANK_SELECT := $8000
5050
MMC3_BANK_DATA := $8001
5151
MMC3_MIRRORING := $A000
52+
MMC3_PRG_RAM := $A001
53+
54+
; https://www.nesdev.org/wiki/MMC5#Configuration
55+
MMC5_PRG_MODE := $5100
56+
MMC5_CHR_MODE := $5101
57+
MMC5_RAM_PROTECT1 := $5102
58+
MMC5_RAM_PROTECT2 := $5103
59+
MMC5_NT_MAPPING := $5105 ; $50 horizontal, $44 vertical, $00 single
60+
MMC5_CHR_BANK0 := $5123 ; 4kb page index
61+
MMC5_CHR_BANK1 := $5127
5262

5363
.macro RESET_MMC1
5464
.if INES_MAPPER = 1
55-
inc $8000 ; initRam
65+
: inc :- ; increments inc ($aa), writing a negative value to prg
66+
; https://www.nesdev.org/wiki/MMC1#Reset
5667
.endif
5768
.endmacro

src/main.asm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
.segment "PRG_chunk1": absolute
1717

18+
; region code at start of page to keep cycle count consistent
19+
.include "util/check_region.asm"
20+
1821
initRam:
1922

2023
.include "boot.asm"
@@ -46,7 +49,6 @@ mainLoop:
4649
.include "highscores/entry_screen.asm"
4750

4851
.include "util/core.asm"
49-
.include "util/check_region.asm"
5052
.include "util/bytesprite.asm"
5153
.include "util/strings.asm"
5254
.include "util/math.asm"

0 commit comments

Comments
 (0)