/[projet1]/users/twilighte/Stormlord/TestJoystickFire.s
Defence Force logotype

Contents of /users/twilighte/Stormlord/TestJoystickFire.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 412 - (show annotations)
Thu Oct 7 20:50:23 2010 UTC (8 years, 8 months ago) by dbug
File size: 3720 byte(s)
Added Stormlord
1 ;Test autodetect joystick fire routine
2 #define VIA_PORTB $0300
3 #define VIA_PORTAH $0301
4 #define VIA_DDRB $0302
5 #define VIA_DDRA $0303
6 #define VIA1_DDRA $0303
7 #define VIA_T1CL $0304
8 #define VIA_T1CH $0305
9 #define VIA_T1LL $0306
10 #define VIA_T1LH $0307
11 #define VIA_T2LL $0308
12 #define VIA_T2CH $0309
13 #define VIA_PCR $030C
14 #define VIA_IFR $030D
15 #define VIA_IER $030E
16 #define VIA_PORTA $030F
17
18 #define VIA2_PORTB $0320 ;Telestrat Only
19 #define VIA2_PORTAHS $0321
20 #define VIA2_DDRB $0322
21 #define VIA2_DDRA $0323
22 #define VIA2_T1CL $0324
23 #define VIA2_T1CH $0325
24 #define VIA2_T1LL $0326
25 #define VIA2_T1LH $0327
26 #define VIA2_T2LL $0328
27 #define VIA2_T2CH $0329
28 #define VIA2_SR $032a
29 #define VIA2_ACR $032b
30 #define VIA2_PCR $032c
31 #define VIA2_IFR $032d
32 #define VIA2_IER $032e
33 #define VIA2_PORTA $032f
34
35 ;#define CHECKSUM_V10
36 ;#define CHECKSUM_V11
37
38
39 .zero
40 *=$00
41 screen .dsb 2
42 MachineROMsChecksum .dsb 1
43
44 .text
45 *=$500
46
47 Driver jsr FetchROMChecksum
48 .(
49 loop1 nop
50 jmp loop1
51 .)
52 .(
53 loop1
54 jsr AutodetectJoystickByFire
55 bcc loop1
56 .)
57 ;X holds Joystick type or Keyboard(0)
58 lda JoyTypeText0,x
59 sta $BB80
60 lda JoyTypeText1,x
61 sta $BB81
62 lda JoyTypeText2,x
63 sta $BB82
64 .(
65 loop2 nop
66 jmp loop2
67 .)
68
69
70 JoyTypeText0
71 .byt "KTIA
72 JoyTypeText1
73 .byt "EEJL"
74 JoyTypeText2
75 .byt "YLKT"
76
77
78
79 ;Returns Controller Index (0-3) in X and Carry set if Fire was pressed
80 AutodetectJoystickByFire
81 ldx #03
82
83 ;Turn off IJK interface (Set PB4 to Output/Zero)
84 lda #%10100111
85 sta VIA_DDRB
86
87 ;Detect Altai Fire(Either joystick)
88 lda #%11000000
89 sta VIA_DDRA
90 sta VIA_PORTA
91 lda VIA_PORTA
92 eor #%10111111
93 .(
94 beq skip1
95 lda #17
96 sta $BB80
97 loop2 nop
98 jmp loop2
99 skip1 and #%00100000
100 .)
101 bne AltaiFirePressed
102
103 dex
104
105 ;Turn on IJK
106 lda #%10110111
107 sta VIA_DDRB
108 lda #%00000000
109 sta VIA_PORTB
110
111 ;Detect IJK Left Joystick fire
112 lda #%01111111
113 sta VIA_PORTA
114 lda VIA_PORTA
115 and #%00011111
116 eor #%00011111
117 and #1 ;?
118 bne IJKFirePressed
119
120 ;Detect IJK Right Joystick fire
121 lda #%10111111
122 sta VIA_PORTA
123 lda VIA_PORTA
124 and #%00011111
125 eor #%00011111
126 and #1 ;?
127 bne IJKFirePressed
128
129 dex
130
131 ;Detect Telestrat
132 lda VIA2_DDRA
133 cmp #%00010111
134 bne AvoidTelestratJoysticks
135 cmp VIA1_DDRA
136 bne AvoidTelestratJoysticks
137
138 ;Could be second VIA in Atmos so additionally get
139 ;Checksum that was calculated at game boot
140 lda MachineROMsChecksum
141 ; cmp #CHECKSUM_V10
142 beq AvoidTelestratJoysticks
143 ; cmp #CHECKSUM_V11
144 beq AvoidTelestratJoysticks
145
146 ;Detect Telestrat Joysticks
147 lda #%11000000
148 sta VIA2_PORTB
149 lda VIA2_PORTB
150 and #%00000100
151 bne TelestratFirePressed
152
153 AvoidTelestratJoysticks
154 dex
155
156 ; ;Detect Keyboard Fire
157 ; lda KeyRegister
158 ; and #%00100000
159 ; bne KeyboardFire
160
161 ;No Fire
162 clc
163 rts
164
165 AltaiFirePressed
166 IJKFirePressed
167 TelestratFirePressed
168 KeyboardFire
169 sec
170 rts
171
172 FetchROMChecksum
173 lda #<$C000
174 sta screen
175 lda #>$C000
176 sta screen+1
177 ldx #64
178 ldy #00
179 clc
180 tya
181 .(
182 loop1 adc (screen),y
183 iny
184 bne loop1
185 inc screen+1
186 dex
187 bne loop1
188 .)
189 sta MachineROMsChecksum
190 rts

  ViewVC Help
Powered by ViewVC 1.1.26