From 7b2e4d0c7f606ce8f5d65eef430c26e6dc95b1e0 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Thu, 4 Jun 2020 23:22:47 +0200
Subject: [PATCH] Reflect that the Apple //c supports only one joystick.
---
libsrc/apple2/joy/a2.stdjoy.s | 32 +++++++++++++++++++++++++-------
libsrc/apple2/joyref.s | 8 ++++++++
libsrc/apple2/libref.s | 3 +--
3 files changed, 34 insertions(+), 9 deletions(-)
create mode 100644 libsrc/apple2/joyref.s
diff --git a/libsrc/apple2/joy/a2.stdjoy.s b/libsrc/apple2/joy/a2.stdjoy.s
index 7e90f7b98..8aa82ba7d 100644
--- a/libsrc/apple2/joy/a2.stdjoy.s
+++ b/libsrc/apple2/joy/a2.stdjoy.s
@@ -44,25 +44,37 @@ PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
; Library reference
- .addr $0000
+libref: .addr $0000
; Jump table
.addr INSTALL
.addr UNINSTALL
.addr COUNT
- .addr READJOY
+ .addr READ
; ------------------------------------------------------------------------
- .code
+ .data
+
+maxnum: .byte $00 ; Maximum joystick number (0 or 1)
; INSTALL routine. Is called after the driver is loaded into memory. If
; possible, check if the hardware is present and determine the amount of
; memory available.
; Must return an JOY_ERR_xx code in a/x.
INSTALL:
- lda #JOY_ERR_OK
; Fall through
@@ -71,16 +83,22 @@ INSTALL:
UNINSTALL:
rts
+; ------------------------------------------------------------------------
+
+ .code
+
; COUNT: Return the total number of available joysticks in a/x.
COUNT:
- lda #$02 ; Number of joysticks we support
+ ldx maxnum
+ inx
+ txa ; Number of joysticks we support
ldx #$00
rts
; READ: Read a particular joystick passed in A.
-READJOY:
+READ:
bit $C082 ; Switch in ROM
- and #$01 ; Restrict joystick number
+ and maxnum ; Restrict joystick number
; Read horizontal paddle
asl ; Joystick number -> paddle number
diff --git a/libsrc/apple2/joyref.s b/libsrc/apple2/joyref.s
new file mode 100644
index 000000000..8a9609bd4
--- /dev/null
+++ b/libsrc/apple2/joyref.s
@@ -0,0 +1,8 @@
+;
+; Oliver Schmidt, 2020-06-04
+;
+
+ .export joy_libref
+ .import _get_ostype
+
+joy_libref := _get_ostype
diff --git a/libsrc/apple2/libref.s b/libsrc/apple2/libref.s
index fb22515bd..8aa54abab 100644
--- a/libsrc/apple2/libref.s
+++ b/libsrc/apple2/libref.s
@@ -2,11 +2,10 @@
; Oliver Schmidt, 2013-05-31
;
- .export em_libref, joy_libref, mouse_libref, ser_libref, tgi_libref
+ .export em_libref, mouse_libref, ser_libref, tgi_libref
.import _exit
em_libref := _exit
-joy_libref := _exit
mouse_libref := _exit
ser_libref := _exit
tgi_libref := _exit