adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 1 | |
2 | ;--------------------------------------------------------------------- | ||||
3 | |||||
4 | .import _ctk_mouse_joyx, _ctk_mouse_joyy | ||||
5 | .import _ctk_mouse_firebutton | ||||
6 | .export _ctk_mouse_asm_irq | ||||
7 | ;--------------------------------------------------------------------- | ||||
8 | .bss | ||||
9 | lastjoydy: .res 1 | ||||
10 | lastjoydx: .res 1 | ||||
11 | joydycnt: .res 1 | ||||
12 | joydxcnt: .res 1 | ||||
13 | ;--------------------------------------------------------------------- | ||||
14 | .data | ||||
15 | ;--------------------------------------------------------------------- | ||||
16 | .code | ||||
17 | _ctk_mouse_asm_irq: | ||||
18 | lda $dc00 | ||||
19 | ldy #0 | ||||
20 | ldx #0 | ||||
21 | lsr | ||||
22 | bcs nodey | ||||
23 | dey | ||||
24 | nodey: | ||||
25 | lsr | ||||
26 | bcs noiny | ||||
27 | iny | ||||
28 | noiny: | ||||
29 | lsr | ||||
30 | bcs nodex | ||||
31 | dex | ||||
32 | nodex: | ||||
33 | lsr | ||||
34 | bcs noinx | ||||
35 | inx | ||||
36 | noinx: | ||||
37 | and #1 | ||||
38 | eor #1 | ||||
39 | sta _ctk_mouse_firebutton | ||||
40 | |||||
41 | cpy lastjoydy | ||||
42 | sty lastjoydy | ||||
43 | bne noydy | ||||
44 | tya | ||||
45 | pha | ||||
46 | inc joydycnt | ||||
47 | lda joydycnt | ||||
48 | bpl nostajoydycnt | ||||
49 | lda #$80 | ||||
50 | sta joydycnt | ||||
51 | nostajoydycnt: | ||||
52 | lsr | ||||
53 | lsr | ||||
54 | lsr | ||||
55 | lsr | ||||
56 | tay | ||||
57 | pla | ||||
58 | asldeyloop: | ||||
59 | asl | ||||
60 | dey | ||||
61 | bpl asldeyloop | ||||
62 | tay | ||||
63 | jmp ydy | ||||
64 | noydy: | ||||
65 | lda #0 | ||||
66 | sta joydycnt | ||||
67 | ydy: | ||||
68 | |||||
69 | tya | ||||
70 | clc | ||||
71 | adc _ctk_mouse_joyy | ||||
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 72 | |
adamdunkels | e6f14d6 | 2003-04-11 20:24:08 +0000 | [diff] [blame^] | 73 | cmp #240 |
74 | bcc :+ | ||||
75 | lda #0 | ||||
76 | : | ||||
77 | |||||
78 | cmp #200 | ||||
79 | bcc :+ | ||||
80 | lda #199 | ||||
81 | : | ||||
82 | sta _ctk_mouse_joyy | ||||
83 | |||||
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 84 | cpx lastjoydx |
85 | stx lastjoydx | ||||
86 | bne noxdx | ||||
87 | txa | ||||
88 | pha | ||||
89 | inc joydxcnt | ||||
90 | lda joydxcnt | ||||
91 | bpl nostajoydxcnt | ||||
92 | lda #$80 | ||||
93 | sta joydxcnt | ||||
94 | nostajoydxcnt: | ||||
95 | lsr | ||||
96 | lsr | ||||
97 | lsr | ||||
98 | lsr | ||||
99 | tax | ||||
100 | pla | ||||
101 | asldexloop: | ||||
102 | asl | ||||
103 | dex | ||||
104 | bpl asldexloop | ||||
105 | tax | ||||
106 | jmp xdx | ||||
107 | noxdx: | ||||
108 | lda #0 | ||||
109 | sta joydxcnt | ||||
110 | xdx: | ||||
111 | |||||
112 | txa | ||||
113 | clc | ||||
114 | adc _ctk_mouse_joyx | ||||
115 | sta _ctk_mouse_joyx | ||||
116 | php | ||||
117 | lda #$ff | ||||
118 | cpx #0 | ||||
119 | bmi nolda02 | ||||
120 | lda #0 | ||||
121 | nolda02: | ||||
122 | plp | ||||
123 | adc _ctk_mouse_joyx+1 | ||||
adamdunkels | e6f14d6 | 2003-04-11 20:24:08 +0000 | [diff] [blame^] | 124 | and #1 |
125 | sta _ctk_mouse_joyx+1 | ||||
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 126 | |
127 | lda _ctk_mouse_joyy | ||||
128 | clc | ||||
adamdunkels | 9e5028e | 2003-04-09 09:02:05 +0000 | [diff] [blame] | 129 | adc #$32 |
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 130 | sta $d001 |
adamdunkels | 9e5028e | 2003-04-09 09:02:05 +0000 | [diff] [blame] | 131 | sta $d003 |
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 132 | |
133 | lda _ctk_mouse_joyx | ||||
134 | clc | ||||
135 | adc #$18 | ||||
136 | sta $d000 | ||||
adamdunkels | 9e5028e | 2003-04-09 09:02:05 +0000 | [diff] [blame] | 137 | sta $d002 |
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 138 | lda #0 |
139 | adc _ctk_mouse_joyx+1 | ||||
140 | and #1 | ||||
adamdunkels | e6f14d6 | 2003-04-11 20:24:08 +0000 | [diff] [blame^] | 141 | beq :+ |
142 | lda #3 | ||||
143 | : | ||||
adamdunkels | 942aabf | 2003-04-09 00:31:13 +0000 | [diff] [blame] | 144 | sta $d010 |
145 | jmp $ea31 |