Skip to content

Commit

Permalink
Alternate joystick detection method should make diagonal detection po…
Browse files Browse the repository at this point in the history
…ssible, but don't have up and down working, just left and right #3
  • Loading branch information
lucasw committed Jun 21, 2018
1 parent 196cbd6 commit b271f13
Showing 1 changed file with 51 additions and 15 deletions.
66 changes: 51 additions & 15 deletions source.asm
Original file line number Diff line number Diff line change
Expand Up @@ -220,35 +220,71 @@ mainloop:
; debug command, use w 0 100 2 to set a breakpoint here
clr.w $100

move.w #0,d2
move.w #0,d3
; detect joystick left/right
move.w #0,d1
; move.l #%100000010,d2
; and.l JOY1DAT,d2
move.w JOY1DAT,d2
btst.l #9,d2
; move.w JOY1DAT,d2
; btst.l #9,d2
; bne move_left
; btst.l #1,d2
; bne move_right
; bra done_joy
; jmp done_joy_left_right

; http://eab.abime.net/showthread.php?t=75779&page=3
move.l JOY0DAT,d0
move.l d0,d1
add.l d1,d1
eor.l d0,d1
btst.l #9,d0 ; left
bne move_left
btst.l #1,d2
btst.l #1,d0 ; right
bne move_right
; bra done_joy
jmp done_joy
bra joy_up_down
move_left:
move.w #-1,d1
bra done_joy
move.w #-1,d2
bra joy_up_down
move_right:
move.w #1,d1
move.w #1,d2
joy_up_down:

btst.l #9,d1 ; up
bne move_up
btst.l #1,d1 ; down
bne move_down
bra done_joy
move_up:
bra done_joy
move_down:
move.w #$100,d3
done_joy:
move.w #-$100,d3

ship_update:
; animate the sprite
; first load the current x position (from ship address) into a data register
move.w SHIP_DST,d0
; add 1
add.w d1,d0
add.w d2,d0
andi.w #$00ff,d0
; AND with 0xff00?
; then write it back to the the ship address - it is the first word
and.w #$ff00,SHIP_DST
and.w #$ff00,SHIP_DST ; first zero the bits to be used for the new position
or.w d0,SHIP_DST

bra skip
; move vertically
move.w SHIP_DST,d0
add.l d3,d0
andi.l #$ff00,d0
and.l #$00ff,SHIP_DST
or.l d0,SHIP_DST

move.w SHIP_DST+1,d0
add.l d3,d0
andi.l #$ff00,d0
and.l #$00ff,SHIP_DST+1
or.l d0,SHIP_DST+1
skip:

; if mousebutton/joystick 1 or 2 pressed then exit
; mouse/joy button 1
btst.b #6,CIAAPRA
Expand Down

0 comments on commit b271f13

Please sign in to comment.