Skip to content

Commit

Permalink
refactoring joy
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Paris committed Jul 3, 2019
1 parent 3a98742 commit b6b80b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/joy.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct {
#define JOYPAD2 *((u8_t *)0x4017)

extern joy_t joy;
#pragma zpsym("joy1")
#pragma zpsym("joy")

void __fastcall__ joy_poll(u8_t);

Expand Down
Binary file modified lib/runtime.lib
Binary file not shown.
6 changes: 3 additions & 3 deletions src/joy/joy_poll.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ joy_poll = _joy_poll
sta joy::prev, x ; prev = curr
lda #1
sta joy::curr, x
sta JOYPAD1
sta JOYPAD1, x
lsr a
sta JOYPAD1
sta JOYPAD1, x
@loop:
lda JOYPAD1
lda JOYPAD1, x
and #3
cmp #1
rol joy::curr, x
Expand Down
22 changes: 11 additions & 11 deletions src/joy/joy_poll_safe.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ joy_poll_safe = _joy_poll_safe
.proc _joy_poll_safe
tax
lda joy::curr, x
pha ; preserve current state
jsr joypoll
tay ; Y = poll1
jsr joypoll
sta joy::prev, x ; joy::prev = poll2
jsr joypoll
pha ; preserve poll3
jsr joypoll ; A and joy::curr = poll4
pha ; preserve current state
jsr joypoll
tay ; Y = poll1
jsr joypoll
sta joy::prev, x ; joy::prev = poll2
jsr joypoll
pha ; preserve poll3
jsr joypoll ; A and joy::curr = poll4
cmp joy::prev, x ; poll4 == poll2 ?
beq @done
tya
Expand All @@ -36,11 +36,11 @@ joy_poll_safe = _joy_poll_safe
.proc joypoll
lda #1
sta joy::curr, x
sta JOYPAD1
sta JOYPAD1, x
lsr a
sta JOYPAD1
sta JOYPAD1, x
@loop:
lda JOYPAD1
lda JOYPAD1, x
and #3
cmp #1
rol joy::curr, x
Expand Down

0 comments on commit b6b80b7

Please sign in to comment.