Removed joy_masks array.
So far the joy_masks array allowed several joystick drivers for a single target to each have different joy_read return values. However this meant that every call to joy_read implied an additional joy_masks lookup to post-process the return value. Given that almost all targets only come with a single joystick driver this seems an inappropriate overhead. Therefore now the target header files contain constants matching the return value of the joy_read of the joystick driver(s) on that target. If there indeed are several joystick drivers for a single target they must agree on a common return value for joy_read. In some cases this was alredy the case as there's a "natural" return value for joy_read. However a few joystick drivers need to be adjusted. This may cause some overhead inside the driver. But that is for sure smaller than the overhead introduced by the joy_masks lookup before. !!! ToDo !!! The following three joystick drivers become broken with this commit and need to be adjusted: - atrmj8.s - c64-numpad.s - vic20-stdjoy.s
This commit is contained in:
@@ -19,8 +19,6 @@
|
||||
.bss
|
||||
_joy_drv: .res 2 ; Pointer to driver
|
||||
|
||||
_joy_masks: .res .sizeof(JOY_HDR::MASKS)
|
||||
|
||||
; Jump table for the driver functions.
|
||||
.data
|
||||
joy_vectors:
|
||||
@@ -65,38 +63,28 @@ _joy_install:
|
||||
lda #>joy_libref
|
||||
sta (ptr1),y
|
||||
|
||||
; Copy the mask array
|
||||
|
||||
ldy #JOY_HDR::MASKS + .sizeof(JOY_HDR::MASKS) - 1
|
||||
ldx #.sizeof(JOY_HDR::MASKS)-1
|
||||
@L1: lda (ptr1),y
|
||||
sta _joy_masks,x
|
||||
dey
|
||||
dex
|
||||
bpl @L1
|
||||
|
||||
; Copy the jump vectors
|
||||
|
||||
ldy #JOY_HDR::JUMPTAB
|
||||
ldx #0
|
||||
@L2: inx ; Skip the JMP opcode
|
||||
@L1: inx ; Skip the JMP opcode
|
||||
jsr copy ; Copy one byte
|
||||
jsr copy ; Copy one byte
|
||||
cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB))
|
||||
bne @L2
|
||||
bne @L1
|
||||
|
||||
jsr joy_install ; Call driver install routine
|
||||
tay ; Test error code
|
||||
bne @L3 ; Bail out if install had errors
|
||||
bne @L2 ; Bail out if install had errors
|
||||
|
||||
; Install the IRQ vector if the driver needs it. A/X contains the error code
|
||||
; from joy_install, so don't use it.
|
||||
|
||||
ldy joy_irq+2 ; Check high byte of IRQ vector
|
||||
beq @L3 ; Jump if vector invalid
|
||||
beq @L2 ; Jump if vector invalid
|
||||
ldy #$4C ; JMP opcode
|
||||
sty joy_irq ; Activate IRQ routine
|
||||
@L3: rts
|
||||
@L2: rts
|
||||
|
||||
; Driver signature invalid
|
||||
|
||||
|
||||
Reference in New Issue
Block a user