Skip to content

Commit e33e217

Browse files
committed
Safer debug mode
1 parent 03edee3 commit e33e217

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

src/gamemodestate/pause.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ pause:
9696
lda newlyPressedButtons_player1
9797
cmp #$10
9898
beq @resume
99+
@stayPaused:
99100
jsr updateAudioWaitForNmiAndResetOamStaging
100101
jmp @pauseLoop
101102

102103
@resume:
104+
; Stay paused if invalid debug position
105+
lda debugFlag
106+
beq @validPosition
107+
jsr isPositionValid
108+
beq @validPosition
109+
jmp @stayPaused
110+
@validPosition:
103111
lda #$1E
104112
sta PPUMASK
105113
lda #$00

src/modes/debug.asm

100644100755
Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ debugSelectMenuControls:
3939
lda debugLevelEdit
4040
eor #1
4141
sta debugLevelEdit
42+
; Don't switch if invalid position
43+
bne @skipDebugType
44+
jsr isPositionValid
45+
beq @skipDebugType
46+
inc debugLevelEdit
4247
@skipDebugType:
4348

4449
jsr checkSaveStateControlsDebug
@@ -108,21 +113,37 @@ debugContinue:
108113
jsr menuThrottle
109114
beq @notPressedUp
110115
dec tetriminoY
116+
bpl @notPressedUp
117+
lda #$13
118+
sta tetriminoY
111119
@notPressedUp:
112120
lda #BUTTON_DOWN
113121
jsr menuThrottle
114122
beq @notPressedDown
115123
inc tetriminoY
124+
lda tetriminoY
125+
cmp #$14
126+
bne @notPressedDown
127+
lda #$00
128+
sta tetriminoY
116129
@notPressedDown:
117130
lda #BUTTON_LEFT
118131
jsr menuThrottle
119132
beq @notPressedLeft
120133
dec tetriminoX
134+
bpl @notPressedLeft
135+
lda #$09
136+
sta tetriminoX
121137
@notPressedLeft:
122138
lda #BUTTON_RIGHT
123139
jsr menuThrottle
124140
beq @notPressedRight
125141
inc tetriminoX
142+
lda tetriminoX
143+
cmp #$0A
144+
bne @notPressedRight
145+
lda #$00
146+
sta tetriminoX
126147
@notPressedRight:
127148

128149
; check mode
@@ -152,19 +173,21 @@ debugContinue:
152173
lda newlyPressedButtons_player1
153174
and #BUTTON_B
154175
beq @notPressedB
155-
lda currentPiece
156-
cmp #$1
157-
bmi @notPressedB
158176
dec currentPiece
177+
bpl @notPressedB
178+
lda #$12
179+
sta currentPiece
159180
@notPressedB:
160181

161182
lda newlyPressedButtons_player1
162183
and #BUTTON_A
163184
beq @notPressedA
164-
lda currentPiece
165-
cmp #$12
166-
bpl @notPressedA
167185
inc currentPiece
186+
lda currentPiece
187+
cmp #$13
188+
bne @notPressedA
189+
lda #$00
190+
sta currentPiece
168191
@notPressedA:
169192

170193
; handle piece

0 commit comments

Comments
 (0)