X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fc64%2Fjoy%2Fc64-hitjoy.s;h=3b4a0b9092cde9fbebac4b8c8bda830e7aedab56;hb=3afbed48e068f5c467d122229c80c48fe21063c4;hp=ae09182dc3b5f4231c35f1eb62948f1c1e8d636d;hpb=008b4c4e1d952cc71b082f121b7e6d3d9e43132c;p=cc65 diff --git a/libsrc/c64/joy/c64-hitjoy.s b/libsrc/c64/joy/c64-hitjoy.s index ae09182dc..3b4a0b909 100644 --- a/libsrc/c64/joy/c64-hitjoy.s +++ b/libsrc/c64/joy/c64-hitjoy.s @@ -12,27 +12,22 @@ .include "c64.inc" .macpack generic + .macpack module + ; ------------------------------------------------------------------------ ; Header. Includes jump table - .segment "JUMPTABLE" + module_header _c64_hitjoy_joy ; Driver signature - .byte $6A, $6F, $79 ; "joy" - .byte JOY_API_VERSION ; Driver API version number + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number -; Button state masks (8 values) +; Library reference - .byte $01 ; JOY_UP - .byte $02 ; JOY_DOWN - .byte $04 ; JOY_LEFT - .byte $08 ; JOY_RIGHT - .byte $10 ; JOY_FIRE - .byte $00 ; JOY_FIRE2 unavailable - .byte $00 ; Future expansion - .byte $00 ; Future expansion + .addr $0000 ; Jump table. @@ -40,7 +35,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr IRQ ; ------------------------------------------------------------------------ ; Constants @@ -52,8 +46,8 @@ JOY_COUNT = 4 ; Number of joysticks we support .bss -temp3: .byte 0 -temp4: .byte 0 +temp3: .byte 0 +temp4: .byte 0 .code @@ -79,13 +73,22 @@ UNINSTALL: rts ; ------------------------------------------------------------------------ -; IRQ entry point. Is called from the C layer as a subroutine in the -; interrupt. The routine MUST return carry set if the interrupt has been -; 'handled' - which means that the interrupt source is gone. Otherwise it -; MUST return carry clear. +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: lda #JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; -IRQ: ; cia 2 setup +readadapter: + sei + + ; cia 2 setup ldy #$00 ; port b direction sty $dd03 ; => input @@ -149,32 +152,24 @@ IRQ: ; cia 2 setup sta temp4 fire: - ; Default Value: $40/64 on PAL - ; $42/66 on NTSC + ; FIXME: to be really 100% correct this should restore the correct timer + ; values for the respective machine (PAL: $4025, NTSC: $4295) + ; however, this should hardly be a problem in a real world program + lda #$41 sta $dc05 - ; Default Value: $25/37 on PAL - ; $95/149 on NTSC lda #0 sta $dc04 - ; We do never "handle" the interrupt, we use it just as a timer. - clc - rts - -; ------------------------------------------------------------------------ -; COUNT: Return the total number of available joysticks in a/x. -; - -COUNT: lda #JOY_COUNT + cli rts -; ------------------------------------------------------------------------ -; READ: Read a particular joystick passed in A. -; +READ: + pha + jsr readadapter + pla -READ: tax ; Joystick number into X + tax ; Joystick number into X bne joy2 ; Read joystick 1 @@ -193,16 +188,16 @@ joy1: lda #$7F joy2: dex bne joy3 - ; ldx #0 - lda #$E0 - ldy #$FF + ; ldx #0 + lda #$E0 + ldy #$FF sei - sta CIA1_DDRA - lda CIA1_PRA - sty CIA1_DDRA + sta CIA1_DDRA + lda CIA1_PRA + sty CIA1_DDRA cli - and #$1F - eor #$1F + and #$1F + eor #$1F rts ; Read joystick 3 @@ -211,13 +206,12 @@ joy3: dex bne joy4 lda temp3 - eor #$1F + eor #$1F rts ; Read joystick 4 joy4: lda temp4 - eor #$1F + eor #$1F ldx #0 rts -