Skip to content

Commit 66fb5d1

Browse files
committed
Merge branch 'master' of github.com:kirjavascript/TetrisGYM
2 parents c37f96c + aeeac59 commit 66fb5d1

File tree

9 files changed

+15
-226
lines changed

9 files changed

+15
-226
lines changed

build.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ if (!fs.existsSync('clean.nes')) {
166166
const patcher = require('./tools/patch/create');
167167
const pct = patcher('clean.nes', 'tetris.nes', 'tetris.bps');
168168
console.timeEnd('patch');
169-
console.log(`using ${pct}% of original file`);
169+
console.log(`\nusing ${pct}% of original file`);
170170
}
171171

172172
// stats
@@ -176,7 +176,11 @@ console.log();
176176
if (fs.existsSync('tetris.map')) {
177177
const memMap = fs.readFileSync('tetris.map', 'utf8');
178178

179-
console.log((memMap.match(/PRG_chunk\d+\s+0.+$/gm) || []).join('\n'));
179+
false && console.log((memMap.match(/PRG_chunk\d+\s+0.+$/gm) || []).join('\n'));
180+
181+
const used = parseInt(memMap.match(/PRG_chunk1\s+\w+\s+\w+\s+(\w+)/)?.[1]??'', 16) + 0x100; // 0x100 for reset chunk
182+
183+
console.log(`${0x8000 - used} PRG bytes free`);
180184
}
181185

182186
function hashFile(filename) {

src/audio.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ handlePausedAudio: lda audioInitialized
269269
cmp #$03
270270
bne LE212
271271
inc musicPauseSoundEffectCounter
272-
ldy #$10
272+
ldy #<unknown_sq1_data2
273273
lda musicPauseSoundEffectCounter
274274
and #$01
275275
bne LE20F
@@ -727,7 +727,7 @@ LE51B: sta DMC_LEN
727727
; Unused
728728
soundEffectSlot3_donk:
729729
lda #$02
730-
ldy #$4C
730+
ldy #<soundEffectSlot3_unknown2InitData
731731
jmp initSoundEffectShared
732732

733733
soundEffectSlot3Playing_advance:

src/data/demo.asm

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/gamemode/branch.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ branchOnGameMode:
66
.addr gameMode_gameTypeMenu
77
.addr gameMode_levelMenu
88
.addr gameMode_playAndEndingHighScore_jmp
9-
.addr gameMode_playAndEndingHighScore_jmp
9+
.addr gameMode_playAndEndingHighScore_jmp ; use to be demo
1010
.addr gameMode_playAndEndingHighScore_jmp ; used to be startDemo
1111
.addr gameMode_speedTest
1212

src/gamemodestate/initstate.asm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,8 @@ gameModeState_initGameState:
8484
sta lineClearStatsByType+2
8585
sta lineClearStatsByType+3
8686
sta allegro
87-
sta demo_heldButtons
88-
sta demo_repeats
89-
sta demoIndex
90-
sta demoButtonsAddr
9187
sta holdDownPoints
9288
sta spawnID
93-
lda #>demoButtonsTable
94-
sta demoButtonsAddr+1
9589
lda #$03
9690
sta renderMode
9791
ldx #$A0

src/main.asm

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ mainLoop:
3131
@continue:
3232
jmp mainLoop
3333

34+
.include "audio.asm"
3435
.include "nmi/nmi.asm"
3536
.include "nmi/render.asm"
3637
.include "nmi/pollcontroller.asm"
@@ -80,14 +81,6 @@ mainLoop:
8081
.include "modes/debug.asm"
8182
.include "modes/saveslots.asm"
8283
.include "modes/crash.asm"
83-
84-
.code
85-
86-
.segment "PRG_chunk2": absolute
87-
88-
.include "data/demo.asm"
89-
.include "audio.asm"
90-
9184
.include "modes/events.asm"
9285
.include "modes/controllerinput.asm"
9386
.include "modes/tapqty.asm"

src/nmi/pollcontroller.asm

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,6 @@
11
pollControllerButtons:
2-
; lda gameMode
3-
; cmp #$05
4-
; beq @demoGameMode
5-
; beq @recording
6-
jsr pollController
7-
rts
8-
9-
@demoGameMode:
10-
lda $D0
11-
cmp #$FF
12-
beq @recording
13-
jsr pollController
14-
lda newlyPressedButtons_player1
15-
cmp #$10
16-
beq @startButtonPressed
17-
lda demo_repeats
18-
beq @finishedMove
19-
dec demo_repeats
20-
jmp @moveInProgress
21-
22-
@finishedMove:
23-
ldx #$00
24-
lda (demoButtonsAddr,x)
25-
sta generalCounter
26-
jsr demoButtonsTable_indexIncr
27-
lda demo_heldButtons
28-
eor generalCounter
29-
and generalCounter
30-
sta newlyPressedButtons_player1
31-
lda generalCounter
32-
sta demo_heldButtons
33-
ldx #$00
34-
lda (demoButtonsAddr,x)
35-
sta demo_repeats
36-
jsr demoButtonsTable_indexIncr
37-
lda demoButtonsAddr+1
38-
cmp #>demoTetriminoTypeTable
39-
beq @ret
40-
jmp @holdButtons
41-
42-
@moveInProgress:
43-
lda #$00
44-
sta newlyPressedButtons_player1
45-
@holdButtons:
46-
lda demo_heldButtons
47-
sta heldButtons_player1
48-
@ret: rts
49-
50-
@startButtonPressed:
51-
lda #>demoButtonsTable
52-
sta demoButtonsAddr+1
53-
lda #$00
54-
sta frameCounter+1
55-
lda #$01
56-
sta gameMode
57-
rts
58-
59-
@recording:
60-
jsr pollController
61-
lda gameMode
62-
cmp #$05
63-
bne @ret2
64-
; lda $D0
65-
; cmp #$FF
66-
bne @ret2
67-
lda heldButtons_player1
68-
cmp demo_heldButtons
69-
beq @buttonsNotChanged
70-
ldx #$00
71-
lda demo_heldButtons
72-
sta (demoButtonsAddr,x)
73-
jsr demoButtonsTable_indexIncr
74-
lda demo_repeats
75-
sta (demoButtonsAddr,x)
76-
jsr demoButtonsTable_indexIncr
77-
lda demoButtonsAddr+1
78-
cmp #>demoTetriminoTypeTable ; check movie has ended
79-
beq @ret2
80-
lda heldButtons_player1
81-
sta demo_heldButtons
82-
lda #$00
83-
sta demo_repeats
84-
rts
85-
86-
@buttonsNotChanged:
87-
inc demo_repeats
88-
89-
@ret2: rts
90-
91-
demoButtonsTable_indexIncr:
92-
lda demoButtonsAddr
93-
clc
94-
adc #$01
95-
sta demoButtonsAddr
96-
lda #$00
97-
adc demoButtonsAddr+1
98-
sta demoButtonsAddr+1
99-
rts
2+
; demo stuff used to live here
3+
jmp pollController
1004

1015
pollController_actualRead:
1026
ldx joy1Location

src/ram.asm

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ spriteYOffset: .res 1 ; $00A1
8585
stringIndexLookup:
8686
spriteIndexInOamContentLookup: .res 1 ; $00A2
8787
renderFlags: .res 1 ; $00A3
88-
; play/demo
88+
; gameplay
8989
; Bit 0-lines 1-level 2-score 3-debug 4-hz 6-stats 7-high score entry letter
9090
; speedtest
9191
; 0 - hz
@@ -117,7 +117,7 @@ pendingGarbage: .res 1 ; $00BB ; Garbage waiting to be delive
117117
renderMode: .res 1 ; $00BD
118118
.res 1
119119
nextPiece: .res 1 ; $00BF ; Stored by its orientation ID
120-
gameMode: .res 1 ; $00C0 ; 0=legal, 1=title, 2=type menu, 3=level menu, 4=play and ending and high score, 5=demo, 6=start demo
120+
gameMode: .res 1 ; $00C0 ; see gamemode/branch.asm
121121
screenStage: .res 1 ; $00C1 ; used in gameMode_waitScreen, endingAnimation
122122
musicType: .res 1 ; $00C2 ; 0-3; 3 is off
123123
sleepCounter: .res 1 ; $00C3 ;
@@ -126,11 +126,7 @@ endingRocketCounter: .res 1 ; $00C6
126126
endingRocketX: .res 1 ; $C7
127127
endingRocketY: .res 1 ; $C8
128128
.res 5
129-
demo_heldButtons: .res 1 ; $00CE
130-
demo_repeats: .res 1 ; $00CF
131-
.res 1
132-
demoButtonsAddr: .res 2 ; $00D1 ; Current address within demoButtonsTable
133-
demoIndex: .res 1 ; $00D3
129+
.res 6 ; used to be demo stuff
134130
highScoreEntryNameOffsetForLetter: .res 1 ; $00D4 ; Relative to current row
135131
highScoreEntryRawPos: .res 1 ; $00D5 ; High score position 0=1st type A, 1=2nd... 4=1st type B... 7=4th/extra type B
136132
highScoreEntryNameOffsetForRow: .res 1 ; $00D6 ; Relative to start of table

src/tetris.nes.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ SEGMENTS {
1313
HEADER: load = HDR, type = ro;
1414
CHR: load = CHR, type = ro;
1515
PRG_chunk1: load = PRG, type = ro;
16-
PRG_chunk2: load = PRG, type = ro, start = $DD00;
1716
PRG_chunk3: load = PRG, type = ro, start = $FF00;
1817
VECTORS: load = PRG, type = ro, start = $FFFA;
1918
}

0 commit comments

Comments
 (0)