Skip to content

Commit c27f019

Browse files
committed
Merge branch 'master' of github.com:kirjavascript/TetrisGYM into readme_v6
2 parents 824ccee + 0e7add4 commit c27f019

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1955
-922
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
* Crunch Mode
66
* Marathon Mode
77
* Hidden Score Mode
8+
* Dark Mode
9+
* Low Stack Mode
810
* M Score changed to Classic Scoring + Millions counter
911
* Invisible linecap turns entire playfield invisible
1012
* Invisible mode preserves original piece colors
13+
* Added "negative delay" to the hz display
1114
* Block Tool pieces wrap around
1215
* Always Next Box removed
1316
* 0001 seeds are ignored
@@ -21,7 +24,10 @@
2124
* Fixed crashes in garbage mode 4
2225
* Fixed line clearing happening on pause
2326
* Fixed PAL colours
27+
* Keep hz display enabled when topped out
2428
* Famicom Keyboard support
29+
* Autodetect MMC1/CNROM
30+
* NROM Support
2531
* MMC3 Support
2632
* MMC5 Support
2733

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,4 @@ This project descends from the TAUS disassembly of NES Tetris and has been heavi
463463

464464
* [https://github.com/ejona86/taus](https://github.com/ejona86/taus)
465465
* [https://github.com/CelestialAmber/TetrisNESDisasm](https://github.com/CelestialAmber/TetrisNESDisasm)
466+
* [https://github.com/pinobatch/holy-mapperel](https://github.com/pinobatch/holy-mapperel)

assets/screens/lowstack.png

4.76 KB
Loading

build.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ console.log('TetrisGYM buildscript');
66
console.time('build');
77

88
const mappers = { // https://www.nesdev.org/wiki/Mapper
9+
0: 'NROM',
910
1: 'MMC1',
1011
3: 'CNROM',
1112
4: 'MMC3',
1213
5: 'MMC5',
14+
1000: 'Autodetect MMC1/CNROM',
1315
};
1416

1517
// options handling
@@ -25,6 +27,7 @@ if (args.includes('-h')) {
2527
-k Famicom Keyboard support
2628
-w force WASM compiler
2729
-c force PNG to CHR conversion
30+
-o override autodetect mmc1 header with cnrom
2831
-t run tests (requires cargo)
2932
-h you are here
3033
`);
@@ -47,7 +50,7 @@ console.log(`using ${nativeCC65 ? 'system' : 'wasm'} ca65/ld65`);
4750

4851
// mapper options
4952

50-
const mapper = args.find((d) => d.startsWith('-m'))?.slice(2) ?? 1;
53+
const mapper = args.find((d) => d.startsWith('-m'))?.slice(2) ?? 1000;
5154

5255
if (!mappers[mapper]) {
5356
console.error(
@@ -79,6 +82,11 @@ if (args.includes('-s')) {
7982
console.log('highscore saving disabled');
8083
}
8184

85+
if (args.includes('-o')) {
86+
compileFlags.push('-D', 'CNROM_OVERRIDE=1');
87+
console.log('cnrom override for autodetect');
88+
}
89+
8290
console.log();
8391

8492
// build / compress nametables

src/boot.asm

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
ldy #$06
2-
sty tmp2
3-
ldy #$00
4-
sty tmp1
5-
lda #$00
6-
@zeroOutPages:
7-
sta (tmp1),y
8-
dey
9-
bne @zeroOutPages
10-
dec tmp2
11-
bpl @zeroOutPages
1+
; $0000 through $06FF cleared during vblank wait
122
lda initMagic
133
cmp #$54
144
bne @coldBoot

src/chr.asm

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
.segment "CHR"
2-
3-
.if HAS_MMC
2+
; CHRBankSet0:
43
.incbin "chr/title_menu_tileset.chr"
54
.incbin "chr/game_tileset.chr"
5+
; CHRBankSet1:
6+
.if INES_MAPPER <> 0 ; exclude for NROM
67
.incbin "chr/rocket_tileset.chr"
7-
.elseif INES_MAPPER = 3
8-
.incbin "chr/rocket_tileset.chr"
9-
.repeat $1000
10-
.byte $0
11-
.endrepeat
12-
.incbin "chr/title_menu_tileset.chr"
13-
.incbin "chr/game_tileset.chr"
148
.endif

src/chr/game_tileset.png

-21.2 KB
Loading

src/chr/title_menu_tileset.png

-19.3 KB
Loading

src/constants.asm

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.ifndef INES_MAPPER ; is set via ca65 flags
2-
INES_MAPPER := 1 ; supports 1, 3 and 4 (MMC1 / CNROM / MMC3)
2+
INES_MAPPER := 1000 ; 0 (NROM), 1 (MMC1), 3 (CNROM), 4 (MMC3), 5 (MMC5), and 1000 (autodetect 1/3)
33
.endif
44

5-
HAS_MMC = INES_MAPPER = 1 || INES_MAPPER = 4 || INES_MAPPER = 5
6-
75
.ifndef SAVE_HIGHSCORES
86
SAVE_HIGHSCORES := 1
97
.endif
@@ -17,6 +15,10 @@ AUTO_WIN := 0
1715
KEYBOARD := 0
1816
.endif
1917

18+
.ifndef CNROM_OVERRIDE
19+
CNROM_OVERRIDE := 0
20+
.endif
21+
2022
NO_MUSIC := 1
2123

2224
; dev flags
@@ -34,6 +36,7 @@ BTYPE_START_LINES := $25 ; bcd
3436
MENU_HIGHLIGHT_COLOR := $12 ; $12 in gym, $16 in original
3537
BLOCK_TILES := $7B
3638
EMPTY_TILE := $EF
39+
LOW_STACK_LINE := $DF
3740
TETRIMINO_X_HIDE := $EF
3841

3942
PAUSE_SPRITE_X := $74
@@ -78,16 +81,19 @@ MODE_CHECKERBOARD
7881
MODE_GARBAGE
7982
MODE_DROUGHT
8083
MODE_DAS
84+
MODE_LOWSTACK
8185
MODE_KILLX2
8286
MODE_INVISIBLE
8387
MODE_HARDDROP
8488
MODE_SPEED_TEST
8589
MODE_SCORE_DISPLAY
8690
MODE_CRASH
91+
MODE_STRICT
8792
MODE_HZ_DISPLAY
8893
MODE_INPUT_DISPLAY
8994
MODE_DISABLE_FLASH
9095
MODE_DISABLE_PAUSE
96+
MODE_DARK
9197
MODE_GOOFY
9298
MODE_DEBUG
9399
MODE_LINECAP
@@ -111,16 +117,16 @@ LINECAP_FLOOR := 2
111117
LINECAP_INVISIBLE := 3
112118
LINECAP_HALT := 4
113119

114-
CRASH_SHOW := 0
115-
CRASH_TOPOUT := 1
116-
CRASH_CRASH := 2
117-
CRASH_OFF := 3
120+
CRASH_OFF := 0
121+
CRASH_SHOW := 1
122+
CRASH_TOPOUT := 2
123+
CRASH_CRASH := 3
118124

119125
LINECAP_WHEN_STRING_OFFSET := $10
120126
LINECAP_HOW_STRING_OFFSET := $12
121127

122128
MENU_SPRITE_Y_BASE := $47
123-
MENU_MAX_Y_SCROLL := $80
129+
MENU_MAX_Y_SCROLL := $A0
124130
MENU_TOP_MARGIN_SCROLL := 7 ; in blocks
125131

126132
; menuConfigSizeLookup
@@ -143,16 +149,19 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks
143149
.byte $4 ; MODE_GARBAGE
144150
.byte $12 ; MODE_DROUGHT
145151
.byte $10 ; MODE_DAS
152+
.byte $0F ; MODE_LOWSTACK
146153
.byte $0 ; MODE_KILLX2
147154
.byte $0 ; MODE_INVISIBLE
148155
.byte $0 ; MODE_HARDDROP
149156
.byte $0 ; MODE_SPEED_TEST
150157
.byte $5 ; MODE_SCORE_DISPLAY
151158
.byte $3 ; MODE_CRASH
159+
.byte $1 ; MODE_STRICT
152160
.byte $1 ; MODE_HZ_DISPLAY
153161
.byte $1 ; MODE_INPUT_DISPLAY
154162
.byte $1 ; MODE_DISABLE_FLASH
155163
.byte $1 ; MODE_DISABLE_PAUSE
164+
.byte $1 ; MODE_DARK
156165
.byte $1 ; MODE_GOOFY
157166
.byte $1 ; MODE_DEBUG
158167
.byte $1 ; MODE_LINECAP
@@ -179,6 +188,7 @@ MENU_TOP_MARGIN_SCROLL := 7 ; in blocks
179188
.byte "GARBGE"
180189
.byte "LOBARS"
181190
.byte "DASDLY"
191+
.byte "LOWSTK"
182192
.byte "KILLX2"
183193
.byte "INVZBL"
184194
.byte "HRDDRP"

src/gamemode/gametypemenu/menu.asm

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,6 @@ gameMode_gameTypeMenu:
1010
sta menuScrollY
1111
lda #0
1212
sta hideNextPiece
13-
RESET_MMC1
14-
.if HAS_MMC
15-
; switch to blank charmap
16-
; (stops glitching when resetting)
17-
lda #$03
18-
jsr changeCHRBank1
19-
.endif
20-
.if INES_MAPPER = 4
21-
; Horizontal mirroring
22-
lda #$1
23-
sta MMC3_MIRRORING
24-
.elseif INES_MAPPER = 5
25-
; Horizontal mirroring
26-
lda #$50
27-
sta MMC5_NT_MAPPING
28-
.endif
29-
lda #%10011 ; used to be $10 (enable horizontal mirroring)
30-
jsr setMMC1Control
3113
lda #$1
3214
sta renderMode
3315
jsr updateAudioWaitForNmiAndDisablePpuRendering
@@ -40,15 +22,12 @@ gameMode_gameTypeMenu:
4022
sta tmp3
4123
jsr copyRleNametableToPpuOffset
4224
.addr game_type_menu_nametable_extra
43-
lda #$00
44-
jsr changeCHRBank0
45-
lda #$00
46-
jsr changeCHRBank1
47-
.if INES_MAPPER = 3
48-
CNROM_CHR_MENU:
49-
lda #1
50-
sta CNROM_CHR_MENU+1
25+
.if INES_MAPPER <> 0
26+
lda #CHRBankSet0
27+
jsr changeCHRBanks
5128
.endif
29+
lda #NMIEnable
30+
sta currentPpuCtrl
5231
jsr waitForVBlankAndEnableNmi
5332
jsr updateAudioWaitForNmiAndResetOamStaging
5433
jsr updateAudioWaitForNmiAndEnablePpuRendering
@@ -72,8 +51,6 @@ gameTypeLoopCheckStart:
7251
lda practiseType
7352
cmp #MODE_KILLX2
7453
bne @checkSpeedTest
75-
lda #$10
76-
jsr setMMC1Control
7754
lda #29
7855
sta startLevel
7956
sta levelNumber
@@ -555,9 +532,9 @@ menuYTmp := tmp2
555532
lda crashModifier
556533
cmp #CRASH_OFF
557534
bne @notOff
558-
lda #$F1
535+
lda #$F3
559536
@notOff:
560-
adc #$16
537+
adc #$14
561538
sta spriteIndexInOamContentLookup
562539
lda #(MODE_CRASH*8) + MENU_SPRITE_Y_BASE + 1
563540
sec

0 commit comments

Comments
 (0)