]> git.sur5r.net Git - cc65/commitdiff
Rename the standard joystick driver for the Apple ][.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 2 May 2003 11:53:21 +0000 (11:53 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 2 May 2003 11:53:21 +0000 (11:53 +0000)
Rewrite the driver code to make it shorter.

git-svn-id: svn://svn.cc65.org/cc65/trunk@2117 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/Makefile
libsrc/apple2/apple2-stdjoy.s

index dd8e789718559f4e0cc06cf417dfa8f3386238fd..2118b65f81b4e40039efec5cf97005ec2d8f7c60 100644 (file)
@@ -48,7 +48,7 @@ apple2lib:
            $(AR) a apple2.lib $$i/*.o;\
        done
        mv apple2/crt0.o apple2.o
-       cp apple2/*.joy .
+       cp apple2/apple2-stdjoy.joy a2-stdjoy.joy
 
 #-----------------------------------------------------------------------------
 # Atari
index ae0f4342eebadc51ee14aacd90574aef59cce94b..14bb5fd83d5de3819932d6bd8638811424abbcc2 100644 (file)
 ; ------------------------------------------------------------------------
 ; Constants
 
-JOY_UP          = $01
-JOY_DOWN        = $02
-JOY_LEFT        = $04
-JOY_RIGHT       = $08
-JOY_FIRE        = $10
-
 OFFS            = 10
 
 ; ------------------------------------------------------------------------
@@ -38,11 +32,11 @@ OFFS            = 10
 
 ; Button state masks (8 values)
 
-        .byte   JOY_UP
-        .byte   JOY_DOWN
-        .byte   JOY_LEFT
-        .byte   JOY_RIGHT
-        .byte   JOY_FIRE
+        .byte   $40
+        .byte   $80
+        .byte   $10
+        .byte   $20
+        .byte   $08
         .byte   $00                     ; Future expansion
         .byte   $00                     ; Future expansion
         .byte   $00                     ; Future expansion
@@ -108,38 +102,28 @@ READJOY:
 
 ; Read joystick
 
-        lda     #$00            ; Clear result
-        ldy     OPEN_APPLE,x    ; Check fire button
-        bpl     @nofire
-        ora     #JOY_FIRE       ; Fire button pressed
+        lda     OPEN_APPLE,x    ; Check fire button
+        and     #$80            ; BTN 0 0 0 0 0 0 0
 
-@nofire:
         pha
         jsr     PREAD           ; Read first paddle value
         pla
         cpy     #127-OFFS
-        bcc     @left
+        ror     a               ; /LEFT BTN 0 0 0 0 0 0
         cpy     #127+OFFS
-        bcc     @nextpaddle
-        ora     #JOY_RIGHT
-        .byte   $2c
-@left:  ora     #JOY_LEFT
+        ror     a               ; RIGHT /LEFT BTN 0 0 0 0 0
 
-@nextpaddle:
         inx
         pha
-        jsr     PREAD
+        jsr     PREAD           ; Read second paddle
         pla
         cpy     #127-OFFS
-        bcc     @up
+        ror     a               ; /UP RIGHT /LEFT BTN 0 0 0 0
         cpy     #127+OFFS
-        bcc     @done
-        ora     #JOY_DOWN
-        .byte   $2c
-@up:    ora     #JOY_UP
+        ror     a               ; DOWN /UP RIGHT /LEFT BTN 0 0 0
+        eor     #%01010000      ; DOWN UP RIGHT LEFT BTN 0 0 0
 
-@done:  ldx     #0              ; fix X
+        ldx     #0              ; fix X
         rts
 
 
-