#MSG Hamlin V1.1 #CONFIG ARMOR=2 #CONFIG SCANNER=4 #CONFIG ENGINE=4 #CONFIG MINES=0 #CONFIG SHIELD=0 #CONFIG WEAPON=2 #CONFIG HEATSINKS=0 #DEF Arrival mov ax, 1 ; (AX) = Keepshift status. int 3 ; Turn Keepshift on. opo 20, 450 ; Set shutdown level to 450 BTU's. :0001 mov dx, 64 ; (DX) = 64; scan arc will extend the full ; 128 degree half of the radius of the scan ; range. :0004 opo 17, dx ; Set the scan arc via scanner port 17. opo 11, 100 ; Reset throttle, just in case we stopped for some reason. :0006 ipo 7, ax ; (AX) = range to nearest target. cmp ax, 7FFFh ; Valid range? je 0012 ; No. Modify turret position and try again. ipo 8, bx ; (BX) = accuracy rating of last scan. call 0007 ipo 2, ax ; (AX) = Current heat level. cmp ax, 400 ; Heat under 400 BTUs? jge 0005 ; No. Let the heat dissipate for a bit before ; firing again, or turning on the shield. cmp dx, 32 ; How's that accuracy? ja 0005 ; Shitty. Don't waste the heat on plasma. opo 15, bx ; Fire! :0005 mov fx, dx ; (FX) = scan width. mpy fx, bx ; (FX) = scanwidth*accuracy. sar fx, 1 ; (FX) = scanwidth*accruacy/2 opo 12, fx ; Rotate turret to new offset for improved ; chances of accuracy. cmp dx, 2 ; Scan arc 2 or less? jbe 0006 ; Yes. Do not adjust further. shr dx, 1 ; Adjust scan arc down to zero in on target. jmp 0004 ; Repeat. :0012 opo 12, 128 ; Rotate turret by additive. jmp 0001 ; Repeat. ;----------------------------------------------------------------------------- :0007 push ax ; Preserve AX register. push bx ; Preserve BX register. push cx ; Preserve CX register. push dx ; Preserve DX register. cmp Arrival, 0 jne 0010 ipo 5, ax ; (AX) = Turret heading. ipo 3, dx ; (DX) = Robot heading. cmp ax, dx ; (Turret heading greater than Robot heading? ja 0008 ; Yes. Resolve new heading: (AX - DX). sub dx, ax ; No. Resolve new heading: (DX - AX). mov ax, dx ; (AX) = New heading additive. :0009 opo 14, ax ; Set new heading. mov Arrival, 9 :0010 dec Arrival pop dx ; Restore DX register. pop cx ; Restore CX register. pop bx ; Restore BX register. pop ax ; Restore AX register. ret ; Return to caller. :0008 sub ax, dx ; (AX) = New heading additive. jmp 0009 ; Go set it up.