annotate 3rdparty/subrtns/joystk.asm @ 1799:78b6ac6bba2c

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