home *** CD-ROM | disk | FTP | other *** search
/ Más de 2,500 Juegos / CD1.iso / ZIPDAT / 0951 / 0951.ZIP / SWEEPER.AT2 < prev    next >
Encoding:
Text File  |  1997-02-24  |  2.5 KB  |  74 lines

  1. ; SWEEPER sample robot - Ed T. Toton III  02/24/97
  2. ;
  3. ; Simply a demonstration/test of some new features.
  4. ;
  5.  
  6. #msg Hi there!
  7.  
  8. ; You can now access your program data beginning at @1024
  9. ; Each instruction line (including ":" labels) takes 4 memory
  10. ; addresses. The first one is the instruction/label, the
  11. ; next two are the two operands, and the last is the microcode
  12. ; defining what each does.
  13.  
  14.  
  15.         sub     ax,     ax      ; ax = 0
  16.         mov     ax,     @1024   ; ax = sub from above line (ax = 2)
  17.         mov     ax,     !end    ; get IP position for end of program
  18.         shl     ax,     2       ; IP positions represent 4 memory locations
  19.         add     ax,     1024    ; Now we have the memory address that
  20.                                 ; marks the end of the program.
  21.         get     bx,     ax      ; Get what's there
  22. ;        err     bx              ; Should be 0! (implied NOP at end of program)
  23.  
  24.  
  25. !start
  26.         xor     ex,     ex      ; ex = 0
  27.         xor     fx,     fx      ; fx = 0
  28.         int     7               ; find angle
  29.         opo     11,     100     ; Max speed!
  30.         call    !set-course     ; Let's go!
  31.         del     2
  32.  
  33.         ipo     2,      ax      ; check our heat
  34.         cmp     ax,     50      ; is it over 50?
  35.         jgr     !start          ; if so, let's not scan just yet.
  36.  
  37. !driving
  38.         ipo     1,      ax      ; Get current speed
  39.         cmp     ax,     0       ; Are we still moving?
  40.         jgr     !driving        ; If so, we're not there yet.
  41.  
  42.         mov     ax,     224     ; ax=224
  43.         call    !set-course     ; face north-west
  44.         opo     13,     92      ; turret faces right
  45.  
  46.         mov     cx,     19      ; loop 19 times
  47. !scanloop                       ; top of loop
  48.         ipo     7,      ax      ; scan!
  49.         cmp     ax,     1500    ; find anyone?
  50.         jgr     !skipshoot      ; if not, skip along
  51.         opo     15              ; if so, fire!
  52. !skipshoot
  53.         opo     12,     4       ; turn turret right 4 degrees
  54.         loop    !scanloop       ; end of loop
  55.  
  56.         jtl     !start
  57.         jmp     !end
  58.  
  59.  
  60. ;course-setting subroutine
  61. ;set course to heading in AX.
  62. !set-course
  63.         mov     bx,     @1      ; get current desired heading
  64.                                 ; (not actual heading)
  65.         and     ax,     255     ; Fix ax into 0-255.
  66.         sub     ax,     bx      ; get number of degrees to turn.
  67.         opo     14,     ax      ; turn!
  68.         ret                     ; All done!
  69.  
  70.  
  71. !end
  72. #end
  73.  
  74.