Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions unbricked/input/input.asm

This file was deleted.

60 changes: 30 additions & 30 deletions unbricked/input/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -122,40 +122,40 @@ Right:

; ANCHOR: input-routine
UpdateKeys:
; Poll half the controller
ld a, JOYP_GET_BUTTONS
call .onenibble
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons
; Poll half the controller
ld a, JOYP_GET_BUTTONS
call .onenibble
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons

; Poll the other half
ld a, JOYP_GET_CTRL_PAD
call .onenibble
swap a ; A7-4 = unpressed directions; A3-0 = 1
xor a, b ; A = pressed buttons + directions
ld b, a ; B = pressed buttons + directions
; Poll the other half
ld a, JOYP_GET_CTRL_PAD
call .onenibble
swap a ; A7-4 = unpressed directions; A3-0 = 1
xor a, b ; A = pressed buttons + directions
ld b, a ; B = pressed buttons + directions

; And release the controller
ld a, JOYP_GET_NONE
ldh [rJOYP], a
; And release the controller
ld a, JOYP_GET_NONE
ldh [rJOYP], a

; Combine with previous wCurKeys to make wNewKeys
ld a, [wCurKeys]
xor a, b ; A = keys that changed state
and a, b ; A = keys that changed to pressed
ld [wNewKeys], a
ld a, b
ld [wCurKeys], a
ret
; Combine with previous wCurKeys to make wNewKeys
ld a, [wCurKeys]
xor a, b ; A = keys that changed state
and a, b ; A = keys that changed to pressed
ld [wNewKeys], a
ld a, b
ld [wCurKeys], a
ret

.onenibble
ldh [rJOYP], a ; switch the key matrix
call .knownret ; burn 10 cycles calling a known ret
ldh a, [rJOYP] ; ignore value while waiting for the key matrix to settle
ldh a, [rJOYP]
ldh a, [rJOYP] ; this read counts
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
.knownret
ret
.onenibble
ldh [rJOYP], a ; switch the key matrix
call .knownret ; burn 10 cycles calling a known ret
ldh a, [rJOYP] ; ignore value while waiting for the key matrix to settle
ldh a, [rJOYP]
ldh a, [rJOYP] ; this read counts
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
.knownret
ret
; ANCHOR_END: input-routine

; ANCHOR: memcpy
Expand Down
3 changes: 1 addition & 2 deletions unbricked/title-screen/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

rgbasm -o main.o main.asm
rgbasm -o input.o input.asm
rgblink -o unbricked.gb main.o input.o
rgblink -o unbricked.gb main.o
rgbfix -v -p 0xFF unbricked.gb
47 changes: 0 additions & 47 deletions unbricked/title-screen/input.asm

This file was deleted.

44 changes: 44 additions & 0 deletions unbricked/title-screen/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,44 @@ Memcopy:
ret
; ANCHOR_END: memcpy

; ANCHOR: input-routine
UpdateKeys:
; Poll half the controller
ld a, JOYP_GET_BUTTONS
call .onenibble
ld b, a ; B7-4 = 1; B3-0 = unpressed buttons

; Poll the other half
ld a, JOYP_GET_CTRL_PAD
call .onenibble
swap a ; A7-4 = unpressed directions; A3-0 = 1
xor a, b ; A = pressed buttons + directions
ld b, a ; B = pressed buttons + directions

; And release the controller
ld a, JOYP_GET_NONE
ldh [rJOYP], a

; Combine with previous wCurKeys to make wNewKeys
ld a, [wCurKeys]
xor a, b ; A = keys that changed state
and a, b ; A = keys that changed to pressed
ld [wNewKeys], a
ld a, b
ld [wCurKeys], a
ret

.onenibble
ldh [rJOYP], a ; switch the key matrix
call .knownret ; burn 10 cycles calling a known ret
ldh a, [rJOYP] ; ignore value while waiting for the key matrix to settle
ldh a, [rJOYP]
ldh a, [rJOYP] ; this read counts
or a, $F0 ; A7-4 = 1; A3-0 = unpressed keys
.knownret
ret
; ANCHOR_END: input-routine

Tiles:
dw `33333333
dw `33333333
Expand Down Expand Up @@ -337,3 +375,9 @@ Unbricked_Title_Screen_Map_Begin:
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
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
Unbricked_Title_Screen_Map_End:

; ANCHOR: vars
SECTION "Input Variables", WRAM0
wCurKeys: db
wNewKeys: db
; ANCHOR_END: vars