Skip to content

Commit 8d0cd56

Browse files
committed
seed input with keyboard
1 parent 55e4e44 commit 8d0cd56

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

src/gamemode/gametypemenu/menu.asm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ seedControls:
140140
lda #BUTTON_RIGHT
141141
jsr menuThrottle
142142
beq @skipSeedRight
143+
@moveRight:
143144
lda #$01
144145
sta soundEffectSlot1Init
145146
inc menuSeedCursorIndex
@@ -151,7 +152,38 @@ seedControls:
151152
@skipSeedRight:
152153

153154
lda menuSeedCursorIndex
155+
.if KEYBOARD <> 1
154156
beq @skipSeedControl
157+
.else
158+
bne @readKeys
159+
jmp @skipSeedControl
160+
@readKeys:
161+
jsr readKbSeedEntry
162+
bmi @noKeysPressed
163+
sta generalCounter
164+
ldy menuSeedCursorIndex
165+
dey
166+
tya
167+
lsr
168+
tay ; save seed offset
169+
bcc @highByte
170+
lda set_seed_input,y
171+
and #$F0
172+
ora generalCounter
173+
sta set_seed_input,y
174+
jmp @moveRight
175+
@highByte:
176+
lda set_seed_input,y
177+
and #$0F
178+
asl generalCounter
179+
asl generalCounter
180+
asl generalCounter
181+
asl generalCounter
182+
ora generalCounter
183+
sta set_seed_input,y
184+
jmp @moveRight
185+
@noKeysPressed:
186+
.endif
155187

156188
lda menuSeedCursorIndex
157189
sbc #1

src/nmi/pollkeyboard.asm

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,47 @@ pollKeyboard:
201201
; each byte represents row, column and if shift should be read
202202
; only keys supported by the score entry routine are included
203203

204+
charToSeedMap:
205+
.byte key0
206+
.byte key1
207+
.byte key2
208+
.byte key3
209+
.byte key4
210+
.byte key5
211+
.byte key6
212+
.byte key7
213+
.byte key8
214+
.byte key9
215+
.byte keyA
216+
.byte keyB
217+
.byte keyC
218+
.byte keyD
219+
.byte keyE
220+
.byte keyF
221+
charToSeedMapEnd:
222+
223+
seedChars = <(charToSeedMapEnd - charToSeedMap) - 1
224+
225+
readKbSeedEntry:
226+
ldx #seedChars
227+
@readLoop:
228+
lda charToSeedMap,x
229+
jsr readKey
230+
bne @seedEntered
231+
dex
232+
bpl @readLoop
233+
@seedEntered:
234+
txa
235+
cmp kbHeldInput
236+
beq @noInput
237+
sta kbHeldInput
238+
lda kbHeldInput
239+
rts
240+
@noInput:
241+
lda #$FF
242+
rts
243+
244+
204245
charToKbMap:
205246
.byte keySpace
206247
.byte keyA

0 commit comments

Comments
 (0)