Skip to content

Commit 66a187f

Browse files
committed
Remove input.asm from title screen and put it in main, update build
1 parent 4315f14 commit 66a187f

File tree

3 files changed

+45
-49
lines changed

3 files changed

+45
-49
lines changed

unbricked/title-screen/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/sh
22

33
rgbasm -o main.o main.asm
4-
rgbasm -o input.o input.asm
5-
rgblink -o unbricked.gb main.o input.o
4+
rgblink -o unbricked.gb main.o
65
rgbfix -v -p 0xFF unbricked.gb

unbricked/title-screen/input.asm

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

unbricked/title-screen/main.asm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,44 @@ Memcopy:
115115
ret
116116
; ANCHOR_END: memcpy
117117

118+
; ANCHOR: input-routine
119+
UpdateKeys:
120+
; Poll half the controller
121+
ld a, JOYP_GET_BUTTONS
122+
call .onenibble
123+
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons
124+
125+
; Poll the other half
126+
ld a, JOYP_GET_CTRL_PAD
127+
call .onenibble
128+
swap a ; A7-4 = unpressed directions; A3-0 = 1
129+
xor a, b ; A = pressed buttons + directions
130+
ld b, a ; B = pressed buttons + directions
131+
132+
; And release the controller
133+
ld a, JOYP_GET_NONE
134+
ldh [rJOYP], a
135+
136+
; Combine with previous wCurKeys to make wNewKeys
137+
ld a, [wCurKeys]
138+
xor a, b ; A = keys that changed state
139+
and a, b ; A = keys that changed to pressed
140+
ld [wNewKeys], a
141+
ld a, b
142+
ld [wCurKeys], a
143+
ret
144+
145+
.onenibble
146+
ldh [rJOYP], a ; switch the key matrix
147+
call .knownret ; burn 10 cycles calling a known ret
148+
ldh a, [rJOYP] ; ignore value while waiting for the key matrix to settle
149+
ldh a, [rJOYP]
150+
ldh a, [rJOYP] ; this read counts
151+
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
152+
.knownret
153+
ret
154+
; ANCHOR_END: input-routine
155+
118156
Tiles:
119157
dw `33333333
120158
dw `33333333
@@ -337,3 +375,9 @@ Unbricked_Title_Screen_Map_Begin:
337375
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
338376
DB $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
339377
Unbricked_Title_Screen_Map_End:
378+
379+
; ANCHOR: vars
380+
SECTION "Input Variables", WRAM0
381+
wCurKeys: db
382+
wNewKeys: db
383+
; ANCHOR_END: vars

0 commit comments

Comments
 (0)