; ; donkey ; #config weapon=1 ; gives 1 point #def turn_rate #def scan_angle #def scan_width mov turn_rate 8 mov scan_angle 0 mov scan_width 64 out P_ARC scan_width !begin call !scan ; scan cmp ax 0 jz !begin call !shoot jnz !begin jz !begin ;;; scanning routine ;;; ;;; pseudocode: ;;; scan ;;; if nothing found ;;; if scan width is 64, ;;; then rotate turret by 128 ;;; else ;;; widen scan width ;;; return 0 ;;; else ;;; if scan width > 2 ;;; narrow width ;;; adjust turret based on width, accuracy, direct and speed of target ;; if confidence is high, return 1, else 0 ;;; if accuracy != 0 ;;; rotate turret to (width-1) * offset ;;; return 0 ;;; return 1 !scan in P_SCAN ax ; scan cmp ax 1600 ; if nothing found jls !scan_found cmp scan_width 64 ; if scan_width is 64 jne !scan_not_64 out P_OFS_TURRET 128; rotate turret by 128 mov ax 0 ret !scan_not_64 shl scan_width 1 ; widen width by 2 out P_ARC scan_width mov ax 0 ; return 0 ret !scan_found cmp scan_width 2 ; if width > 2 jls !scan_narrow jeq !scan_narrow shr scan_width 1 ; narrow width by 1/2 out P_ARC scan_width !scan_narrow in P_ACCURACY ax cmp ax 0 ; if accuracy != 0 jnz !scan_turn mov ax 1 ret !scan_turn mov bx scan_width ; rotate turret to add bx -1 ; (width - 1) * offset mpy ax bx out P_OFS_TURRET ax mov ax 0 ret ;; shooting routine ;; shoot if the gun is not too hot !shoot in P_HEAT ax cmp ax 280 jgr !shoot_too_hot call !adjust out P_OFS_TURRET ax out P_FIRE 0 neg ax out P_OFS_TURRET ax !shoot_too_hot ret ;; adjust shot based on target motion ;; ;; @6 - direction of target ;; @7 - speed of target !adjust err @6 mov ax 0 ret #END