1178
|
1 ********************************************************************
|
|
2 * JoyStk - Joystick Subroutine Module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 1 Created for Coyota project BGP 98/??/??
|
|
9
|
|
10 nam JoyStk
|
|
11 ttl Joystick Subroutine Module
|
0
|
12
|
|
13 ifp1
|
|
14 use os9defs
|
|
15 endc
|
|
16
|
1178
|
17 edition set 1
|
|
18
|
0
|
19 mod eom,name,Sbrtn+Objct,Reent+0,Joy,size
|
|
20
|
|
21 size equ .
|
|
22
|
|
23 name fcs /JoyStk/
|
1178
|
24 fcb edition
|
0
|
25
|
|
26 * Joystick Read Routine
|
|
27 *
|
|
28 * Entry:
|
|
29 * X = $0000 for Right, $0001 for Left
|
|
30 *
|
|
31 * Exit:
|
|
32 * 2,s = param count (should be 4)
|
|
33 * 4,s = addr of 1st param (joystick number)
|
|
34 * 6,s = size of 1st param
|
|
35 * 8,s = addr of 2nd param (joystick X)
|
|
36 * 10,s = size of 2nd param
|
|
37 * 12,s = addr of 3rd param (joystick Y)
|
|
38 * 14,s = size of 3rd param
|
|
39 * 16,s = addr of 4th param (joystick button)
|
|
40 * 18,s = size of 4th param
|
|
41
|
|
42 Joy ldd 2,s get param count
|
|
43 cmpd #4 4 params?
|
|
44 bne error
|
|
45 ldd [4,s] get joystick num.
|
|
46 * fix up joystick value
|
|
47 lslb shift left 3 times
|
|
48 lslb
|
|
49 lslb
|
|
50 pshs b
|
|
51 lda #$00 fetch X value
|
|
52 bsr JoyPoll
|
|
53 std [9,s] save in param addr
|
|
54 lda #$08 fetch Y value
|
|
55 ldb ,s+ get joystick selector
|
|
56 bsr JoyPoll
|
|
57 std [12,s]
|
|
58 * get button value
|
|
59 clra
|
|
60 ldb #$FF
|
|
61 stb $FF02
|
|
62 ldb $FF00
|
|
63 clr $FF02
|
|
64 comb
|
|
65 tst [5,s]
|
|
66 beq BtnLft
|
|
67 andb #$05
|
|
68 bra BtnCnt
|
|
69 BtnLft andb #$0A
|
|
70 lsrb
|
|
71 BtnCnt lsrb
|
|
72 bcc BtnCnt2
|
|
73 orb #$01
|
|
74 BtnCnt2 std [16,s] save button
|
|
75 clrb no error
|
|
76 rts
|
|
77 error coma
|
|
78 ldb #E$IllArg
|
|
79 rts
|
|
80
|
|
81
|
|
82 * Joystick read routine
|
|
83 *
|
|
84 * Entry:
|
|
85 * A = value to place in $FF01 (00 for X, 08 for Y)
|
|
86 * B = value to place in $FF03 (00 for Right, 08 for Left)
|
|
87 *
|
|
88 * Exit:
|
|
89 * D = value
|
|
90
|
|
91 JoyPoll pshs a
|
|
92 lda $FF01
|
|
93 anda #$F7
|
|
94 ora ,s+
|
|
95 sta $FF01 select X or Y
|
|
96
|
|
97 pshs b
|
|
98 lda $FF03
|
|
99 anda #$F7
|
|
100 ora ,s+
|
|
101 sta $FF03 select Right or Left
|
|
102
|
|
103 * Low res binary tree search for joystick value
|
|
104 lda #$7F DAC value
|
|
105 ldb #$40
|
|
106 bra L0122
|
|
107
|
|
108 L0117 lsrb reset DAC offset value
|
|
109 cmpb #$01
|
|
110 bhi L0122
|
|
111 lsra
|
|
112 lsra
|
|
113 tfr a,b
|
|
114 clra
|
|
115 rts
|
|
116 L0122 pshs b
|
|
117 sta $FF20
|
|
118 tst $FF00
|
|
119 bpl L012F
|
|
120 adda ,s+
|
|
121 bra L0117
|
|
122 L012F suba ,s+
|
|
123 bra L0117
|
|
124
|
|
125 emod
|
|
126 eom equ *
|
|
127 end
|