Files
2026-09-19 20:21:47 +02:00

36 lines
1.3 KiB
ArmAsm

; PURSUE -- point the engine at the nearest asteroid and burn.
; Crude: it makes no attempt to match velocity, so it will fly straight past.
;
.equ P_THROTTLE 0x20
.equ P_AZIMUTH 0x21
.equ P_PITCH 0x22
.equ P_SELECT 0x30
.equ P_NEAREST 0x31
.equ P_RELX 0x32
.equ P_RELY 0x33
.equ P_RELZ 0x34
.equ P_MATHX 0x80
.equ P_MATHY 0x81
.equ P_ATAN2 0x83
.equ P_HYPOT 0x84
in r1, P_NEAREST ; id of the nearest asteroid
out P_SELECT, r1 ; track it
ldi r7, 1000
out P_THROTTLE, r7 ; full power
aim: in r1, P_RELX ; where is it?
in r2, P_RELY
in r3, P_RELZ
out P_MATHX, r1
out P_MATHY, r2
in r4, P_ATAN2 ; azimuth = atan2(dy, dx)
out P_AZIMUTH, r4
in r5, P_HYPOT ; horizontal range = hypot(dx, dy)
out P_MATHX, r5
out P_MATHY, r3
in r6, P_ATAN2 ; elevation = atan2(dz, range)
out P_PITCH, r6
yield
jmp aim