fixed inputs still missing sometimes, updated build script

This commit is contained in:
2019-01-06 09:39:25 +01:00
parent 07803eae64
commit 75e2589091
5 changed files with 37 additions and 29 deletions

View File

@@ -13,12 +13,9 @@ InitEdit:
ldh [SelectY], a
ret
EXPORT EditOldBuffer
SECTION "Edit old buffer", ROM0
EditOldBuffer:
call UpdateJoypad
EditOldBuffer:
ldh a, [JoypadDown]
and a, %1000
ret z

View File

@@ -1,11 +1,21 @@
INCLUDE "hardware.inc"
EXPORT JoypadDown, JoypadPressed
Section "Joypad memory", HRAM
; Bits 0..7 are A, B, Select, Start, Right, Left, Up, Down
JoypadPressed: ds 1
JoypadWasPressed: ds 1
JoypadNewlyPressed: ds 1
JoypadDown: ds 1
EXPORT InitJoypad
SECTION "Init joypad", ROM0
InitJoypad:
xor a
ldh [JoypadDown], a
ldh [JoypadPressed], a
ldh [JoypadNewlyPressed], a
ret
EXPORT ReadJoypad
SECTION "Read Joypad", ROM0
ReadJoypad:
@@ -33,9 +43,12 @@ ReadJoypad:
; complement so that active buttons read as 1
or a, b
cpl
; store currently pressed buttons
ldh [JoypadPressed], a
; add to currently pressed buttons
ld b, a
ldh a, [JoypadNewlyPressed]
or a, b
ldh [JoypadNewlyPressed], a
; reset joypad
ld a, $30
@@ -43,27 +56,23 @@ ReadJoypad:
ret
EXPORT UpdateJoypad
SECTION "Update joypad", ROM0
UpdateJoypad:
; compute & store just pressed buttons
ldh a, [JoypadPressed]
ldh a, [JoypadNewlyPressed]
ld b, a
ldh a, [JoypadWasPressed]
ldh a, [JoypadPressed]
cpl
and a, b
ldh [JoypadDown], a
; update was pressed
; update pressed
ld a, b
ldh [JoypadWasPressed], a
ldh [JoypadPressed], a
; reset newly pressed
xor a
ldh [JoypadNewlyPressed], a
ret
EXPORT InitJoypad
SECTION "Init joypad", ROM0
InitJoypad:
xor a
ldh [JoypadDown], a
ldh [JoypadPressed], a
ldh [JoypadWasPressed], a
ret

View File

@@ -86,6 +86,7 @@ ENDC
call StartRender
call UpdateAutomata
call WaitRender
call UpdateJoypad
call EditOldBuffer
call SwapBuffers
jp .mainloop