; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
;
; PTV-4 Player joystick driver for the C128
-;
+;
; Ullrich von Bassewitz, 2003-09-28, using the C64 driver from
; Groepaz/Hitmen, 2002-12-23, which is
; obviously based on Ullrichs driver :)
; Driver signature
- .byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte $6A, $6F, $79 ; "joy"
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
; Jump table.
.word INSTALL
- .word DEINSTALL
+ .word UNINSTALL
.word COUNT
.word READ
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
-; DEINSTALL routine. Is called before the driver is removed from memory.
+; UNINSTALL routine. Is called before the driver is removed from memory.
; Can do cleanup or whatever. Must not return anything.
;
-DEINSTALL:
+UNINSTALL:
rts
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
ldy #$00 ; port b direction
sty $dd03 ; => input
-; ldy #$00
sty $dd05 ; cia2 timer a highbyte
sty $dc05 ; cia1 timer a highbyte
iny
-; lda #$01
sty $dd04 ; cia2 timer a lowbyte
sty $dc04 ; cia1 timer a lowbyte
; serial port: input
; cia 1 setup
-
-; lda #%00000001
-; sty $dc0d ; irq ctrl reg
-
lda #%01010001
sta $dc0e ; control register a
; timer: start
; read directions 3
-
lda $dd01 ;read cia 2 port b
and #$0f
sta temp3
; read button 3
-
lda $dd02 ;cia 2 port a
and #%11111011 ;data direction
sta $dd02 ;=> bit 2 input
sta temp3
; read directions 4
-
lda $dd01 ;read cia 2 port b
lsr a
lsr a
sta temp4
; read button 4
-
ldx #$ff ;serial data register
stx $dc0c;=> writing $ff causes
;cia to output some
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
; Jump table.
.word INSTALL
- .word DEINSTALL
+ .word UNINSTALL
.word COUNT
.word READ
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
-; DEINSTALL routine. Is called before the driver is removed from memory.
+; UNINSTALL routine. Is called before the driver is removed from memory.
; Can do cleanup or whatever. Must not return anything.
;
-DEINSTALL:
+UNINSTALL:
rts
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
.export _joy_install, _joy_uninstall, _joy_masks
.export joy_clear_ptr
-
+
.importzp ptr1
.include "joy-kernel.inc"
.bss
_joy_drv: .res 2 ; Pointer to driver
-_joy_masks: .res JOY_MASK_COUNT
+_joy_masks: .res .sizeof(JOY_HDR::MASKS)
; Jump table for the driver functions.
.data
; Driver header signature
.rodata
-joy_sig: .byte $6A, $6F, $79, $00 ; "joy", version
-joy_sig_len = * - joy_sig
+joy_sig: .byte $6A, $6F, $79, JOY_API_VERSION ; "joy", version
;----------------------------------------------------------------------------
; Check the driver signature
- ldy #joy_sig_len-1
+ ldy #.sizeof(joy_sig)-1
@L0: lda (ptr1),y
cmp joy_sig,y
bne inv_drv
; Copy the mask array
- ldy #JOY_MASKS + JOY_MASK_COUNT - 1
- ldx #JOY_MASK_COUNT-1
+ ldy #JOY_HDR::MASKS + .sizeof(JOY_HDR::MASKS) - 1
+ ldx #.sizeof(JOY_HDR::MASKS)-1
@L1: lda (ptr1),y
sta _joy_masks,x
dey
; Copy the jump vectors
- ldy #JOY_HDR_JUMPTAB
+ ldy #JOY_HDR::JUMPTAB
ldx #0
@L2: inx ; Skip the JMP opcode
jsr copy ; Copy one byte
jsr copy ; Copy one byte
- cpx #(JOY_HDR_JUMPCOUNT*3)
+ cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB))
bne @L2
jmp joy_install ; Call driver install routine
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
.word READ
; ------------------------------------------------------------------------
-; Constants
+; Constants
JOY_COUNT = 2 ; Number of joysticks we support
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Driver signature
.byte $6A, $6F, $79 ; "joy"
- .byte $00 ; Driver API version number
+ .byte JOY_API_VERSION ; Driver API version number
; Button state masks (8 values)
INSTALL:
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
-
-; rts ; Run into DEINSTALL instead
+; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.