2002-12-20 20:59:11 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2002-12-20
|
|
|
|
;
|
|
|
|
; Common functions of the joystick API.
|
|
|
|
;
|
|
|
|
|
2013-05-31 22:36:08 +00:00
|
|
|
.import joy_libref
|
2002-12-20 20:59:11 +00:00
|
|
|
.importzp ptr1
|
|
|
|
|
|
|
|
.include "joy-kernel.inc"
|
|
|
|
.include "joy-error.inc"
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Variables
|
|
|
|
|
|
|
|
|
|
|
|
.bss
|
2013-05-09 11:56:54 +00:00
|
|
|
_joy_drv: .res 2 ; Pointer to driver
|
2002-12-20 20:59:11 +00:00
|
|
|
|
|
|
|
; Jump table for the driver functions.
|
|
|
|
.data
|
|
|
|
joy_vectors:
|
2013-05-09 11:56:54 +00:00
|
|
|
joy_install: jmp $0000
|
|
|
|
joy_uninstall: jmp $0000
|
2002-12-20 20:59:11 +00:00
|
|
|
joy_count: jmp $0000
|
|
|
|
joy_read: jmp $0000
|
|
|
|
|
|
|
|
; Driver header signature
|
|
|
|
.rodata
|
2013-05-09 11:56:54 +00:00
|
|
|
joy_sig: .byte $6A, $6F, $79, JOY_API_VERSION ; "joy", version
|
2002-12-20 20:59:11 +00:00
|
|
|
|
|
|
|
|
2006-03-31 20:07:43 +00:00
|
|
|
.code
|
2002-12-20 20:59:11 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; unsigned char __fastcall__ joy_install (void* driver);
|
|
|
|
; /* Install the driver once it is loaded */
|
|
|
|
|
|
|
|
|
|
|
|
_joy_install:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta _joy_drv
|
|
|
|
sta ptr1
|
|
|
|
stx _joy_drv+1
|
|
|
|
stx ptr1+1
|
2002-12-20 20:59:11 +00:00
|
|
|
|
|
|
|
; Check the driver signature
|
|
|
|
|
2003-12-16 22:38:12 +00:00
|
|
|
ldy #.sizeof(joy_sig)-1
|
2002-12-20 20:59:11 +00:00
|
|
|
@L0: lda (ptr1),y
|
|
|
|
cmp joy_sig,y
|
|
|
|
bne inv_drv
|
|
|
|
dey
|
|
|
|
bpl @L0
|
|
|
|
|
2013-05-31 22:36:08 +00:00
|
|
|
; Set the library reference
|
|
|
|
|
|
|
|
ldy #JOY_HDR::LIBREF
|
|
|
|
lda #<joy_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
|
|
|
lda #>joy_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
|
2002-12-20 20:59:11 +00:00
|
|
|
; Copy the jump vectors
|
|
|
|
|
2003-12-16 22:38:12 +00:00
|
|
|
ldy #JOY_HDR::JUMPTAB
|
2002-12-20 20:59:11 +00:00
|
|
|
ldx #0
|
2017-08-19 17:11:28 +00:00
|
|
|
@L1: inx ; Skip the JMP opcode
|
2002-12-20 20:59:11 +00:00
|
|
|
jsr copy ; Copy one byte
|
|
|
|
jsr copy ; Copy one byte
|
2003-12-16 22:38:12 +00:00
|
|
|
cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB))
|
2017-08-19 17:11:28 +00:00
|
|
|
bne @L1
|
2002-12-20 20:59:11 +00:00
|
|
|
|
2018-02-01 21:38:36 +00:00
|
|
|
jmp joy_install ; Call driver install routine
|
2002-12-20 20:59:11 +00:00
|
|
|
|
|
|
|
; Driver signature invalid
|
|
|
|
|
|
|
|
inv_drv:
|
|
|
|
lda #JOY_ERR_INV_DRIVER
|
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
; Copy one byte from the jump vectors
|
|
|
|
|
|
|
|
copy: lda (ptr1),y
|
|
|
|
iny
|
2014-11-29 14:35:20 +00:00
|
|
|
sta joy_vectors,x
|
2002-12-20 20:59:11 +00:00
|
|
|
inx
|
|
|
|
rts
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
2012-03-04 13:08:54 +00:00
|
|
|
; unsigned char joy_uninstall (void);
|
2003-02-10 22:11:12 +00:00
|
|
|
; /* Uninstall the currently loaded driver. Note: This call does not free
|
2014-06-30 09:10:35 +00:00
|
|
|
; ** allocated memory.
|
|
|
|
; */
|
2003-02-10 22:11:12 +00:00
|
|
|
|
|
|
|
_joy_uninstall:
|
|
|
|
jsr joy_uninstall ; Call the driver routine
|
2002-12-20 20:59:11 +00:00
|
|
|
|
2006-06-04 10:15:18 +00:00
|
|
|
_joy_clear_ptr: ; External entry point
|
2003-02-10 22:11:12 +00:00
|
|
|
lda #0
|
|
|
|
sta _joy_drv
|
|
|
|
sta _joy_drv+1 ; Clear the driver pointer
|
|
|
|
|
|
|
|
tax ; Return zero
|
|
|
|
rts
|