#msg thought creates #def scan_w out p_throttle 100 set ax 1 int i_keepshift ; maintain turret facing ;--------------------------------------------------------------------- !start call !do_scan !turn_random in p_random ax ; Get random number and ax 0xFF ; now it is 0-255. !go call !turn jmp !start ;--------------------------------------------------------------------- !check_boundary int i_locate ;puts x,y in ex, fx cmp ex 900 ;are we near the right side? ja !turnl ;if so, turn left cmp ex 100 ;are we near the left side jb !turnr ;if so, turn right cmp fx 900 ;are we near the bottom ja !turnu ;if so, turn up cmp fx 100 ; are we near the top jb !turnd ;if so, tun down ret !turnl in p_random ax ; random number and ax 0x40 ; now it is 0-63. add ax 0xA0 ; now it is 160-223 call !turn ; turn to that heading. ret !turnr in p_random ax ; random number and ax 0x40 ; now it is 0-63. add ax 0x20 ; now it is 32-95 call !turn ; turn to that heading. ret !turnu in p_random ax ; random number and ax 0x40 ; now it is 0-63. add ax 0E0h ; now it is 224-287. and ax 255 ; now it is 224-255 or 0-31. call !turn ; turn to that heading. ret !turnd in p_random ax ; random number and ax 0x40 ; now it is 0-63. add ax 0x60 ; now it is 96-159 call !turn ; turn to that heading. ret ;--------------------------------------------------------------------- ;set course to heading thats in AX. !turn mov bx @1 ; get current desired heading ; (not actual heading) sub ax bx ; get number of degrees to turn. out p_steering ax ; turn! !not_turned in p_compass bx ; bx = heading cmp bx @1 ; is heading equal to desired heading? jne !not_turned ; if not, wait until it is. out p_throttle 100 ; Throttle to 100% ret ;--------------------------------------------------------------------- ;scan for targets... !do_scan out p_scanarc scan_w ; change scan arc in p_scan ax ; do the scan call !check_boundary cmp ax 1500 ; did we find a target? jb !shrink_arc ; if so, shrink arc so we can pinpoint target set scan_w 64 ; see none? keep arc at widest till we do out p_trotate 0x80 ; flip turret = scan angle ret ;--------------------------------------------------------------------- ; shrinks the scan arc by 1/2 !shrink_arc out p_throttle 25 cmp @3 1 je !one ja !two cmp @3 -1 je !negone jb !negtwo shr scan_w 2 call !shoot ret !one shr scan_w 1 ; adjust arc out p_trotate scan_w ; rotate turret shr scan_w 1 ret !two out p_trotate scan_w ; rotate turret shr scan_w 2 ; adjust arc ret !negone shr scan_w 1 ; adjust arc neg scan_w out p_trotate scan_w ; rotate turret neg scan_w shr scan_w 1 ret !negtwo neg scan_w out p_trotate scan_w ; rotate turret neg scan_w shr scan_w -2 ; adjust arc ret ;--------------------------------------------------------------------- !shoot cmp scan_w 2 ja !endshoot in p_damage ax cmp ax 25 ja !sh int i_overburn !sh out p_fire out p_fire in p_heat bx cmp bx 300 jae !speedup out p_fire out p_fire !speedup set scan_w 8 out p_throttle 100 !endshoot ret ;--------------------------------------------------------------------- #end