/
beamer.basm
302 lines (273 loc) · 4.52 KB
/
beamer.basm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
RAM: 0
DEVICE: 1 2 0
DEVICE: 3 4 0
DEVICE: 6 4 0
DEVICE: 2 4 0
DEVICE: 19 4 0
DEVICE: 19 4 0
DEVICE: 5 4 0
DEVICE: 5 4 0
DEVICE: 5 4 0
DEVICE: 7 4 0
DEVICE: 0 4 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
DEVICE: 0 0 0
; beamer
; 11/03/01
; core attack based on kamikaze
; please let me know if you improve this
; jane@asgard.net.au
; modified to combat revenge.bot
%CPUboot 0
:boot
;my version on arrays
$swi 900 ; scanwidth index
$swimax 906 ; max sw index
$sw 902 ; start of the scanwidth array
mov @900, 902
mov @902, 511
mov @904,127
mov @906,33
mov @908,12
$lti 920 ; left turn index
$ltimax 928 ; max index value
$leftturn 922 ; left turn array
mov @lti, leftturn
mov ax, leftturn
mov @922, 960
mov @924, 992
mov @926, 1012
mov @928, 1020
$rti 930 ; right turn index
$rtimax 938 ; max index value
$rightturn 932 ; right turn array
mov @rti, rightturn
mov ax, rightturn
mov @932, 64
mov @934, 32
mov @936, 12
mov @938, 4
$last_dist 940
$last_ping 942
$no_change 944
mov @last_dist, 65000
mov @last_ping, 0
$max_distance 60000
$too_close 5000
$straight_ahead 2
$go_slow 70
$go_real_slow 30
$go_fast 130
$lock_scale 4
$lock_left 1020
$do_it 0
$maxnofind 20
$max_no_change 20
;cli
mov cx, 0
mov @no_change, 0
out Engine0_SetThrust, go_slow
;main loop
:first
call scan_default
cmp @last_dist, max_distance
jbe found
call range_dec
inc cx
cmp cx, maxnofind
jbe first
;included the next few lines to avoid getting stuck in corners
; might be cloaked so ramp up sensitivity
mov cx, 0
out Steering0_AdjustWantedDir, 512
out Scanner0_SetSensitivity, 2
jmp first
:found
call ping_default
jmp first
:scan_default
mov bx, @swi
mov ax, @bx
out Scanner0_SetScanWidth, ax
out Scanner0_Scan, do_it
hwait
in ax, Scanner0_GetScanDistance
mov @last_dist, ax
ret
:ping_default
in ax, Scanner0_GetScanAccuracy
mov @last_ping, ax
cmp ax, straight_ahead
jz ping_ahead ; In front
jae ping_right
mov bx, @lti
mov ax, @bx
out Steering0_AdjustCurrentDir, ax
inc @no_change
cmp @no_change, max_no_change
jbe ping_end
; the next bunch of stuff is to try and get out of playing chasey
mov @no_change, 0
out Steering0_AdjustWantedDir, 512
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
jmp ping_end
:ping_right
mov bx, @rti
mov ax, @bx
out Steering0_AdjustCurrentDir, ax
inc @no_change
cmp @no_change, max_no_change
jbe ping_end
mov @no_change, 0
out Steering0_AdjustWantedDir, 512
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
hwait
jmp ping_end
;tightens the screws
:ping_ahead
cmp @last_dist, 3000
jae ping_cont
mov @swi, swimax
mov @rti, rtimax
mov @lti, ltimax
call tight_attack
:ping_cont
mov ax, @swi
cmp ax, swimax
jnz ping_inc
call tight_attack
jmp ping_check_rti
:ping_inc
add @swi, 2
:ping_check_rti
mov ax, @rti
cmp ax, rtimax
jz ping_check_lti
add @rti, 2
:ping_check_lti
mov ax, @lti
cmp ax, ltimax
jz ping_end
add @lti, 2
:ping_end
ret
:range_dec
mov ax, @swi
cmp ax, sw
jz range_dec_rti
dec @swi
dec @swi
:range_dec_rti
mov ax, @rti
cmp ax, rightturn
jz range_dec_lti
dec @rti
dec @rti
:range_dec_lti
mov ax, @lti
cmp ax, leftturn
jz range_dec_end
dec @lti
dec @lti
:range_dec_end
ret
:tight_attack
; must be at the tightest so can hardcode
; ideas based on kamikaze
out Scanner0_Scan, do_it
hwait
in ax, Scanner0_GetScanDistance
out Beam0_SetBeamDir, 0
out Beam1_SetBeamDir, 0
out Beam0_SetBeamLength, ax
out Beam1_SetBeamLength, ax
out Beam0_FireBeam, do_it
out Beam1_FireBeam, do_it
out Engine0_SetThrust, 0
hwait
out Beam0_FireBeam, do_it
out Beam1_FireBeam, do_it
cmp ax, too_close
jae tight_attack_test_dist
out Engine0_SetReverseThrust, go_slow
jmp tight_attack_scan
:tight_attack_test_dist
cmp ax, 8000
jae tight_attack_lost
sub ax, too_close
mov dx, 75
out Beam0_FireBeam, do_it
out Beam1_FireBeam, do_it
div
out Engine0_SetThrust, ax
:tight_attack_scan
in ax, Scanner0_GetScanAccuracy
cmp ax, 2
jz tight_attack
mov dx, 4
out Beam0_FireBeam, do_it
out Beam1_FireBeam, do_it
mul
add ax, 1016
out Steering0_AdjustCurrentDir, ax
jmp tight_attack
:tight_attack_lost
; lost him
; we're probably going backwards
out Engine0_SetThrust, go_slow
ret
;todo
%interrupt 0
;out Plasmagun0_Shoot, do_it
out Engine0_SetThrust, go_fast
mov ax, @leftturn
out Steering0_AdjustCurrentDir, ax
hwait
hwait
hwait
hwait
hwait
hwait
iret
%CPUstack 0
:stacklabel