annotate 3rdparty/subrtns/joystk.asm @ 91:c10820aa211b

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