home *** CD-ROM | disk | FTP | other *** search
/ PC Collector 8 - Disc 1 / COLLECT8.bin / DEMOS / HIGHWAY / HIGHWAY.SAL < prev    next >
Text File  |  1996-04-02  |  3KB  |  102 lines

  1. ; Highway by Solar Designer \\ BPC 
  2.  
  3. Program Highway
  4. .186
  5.  
  6. MinY =   136       ; Only MaxY-MinY is used in this simplified version
  7. MaxY =   199       ; Also, MaxY-MinY should be equal to 63 in this version
  8. PosY =   16        ; Position at which the road is motionless
  9. MinW =   32        ; Road width at top
  10. MaxW =   MinW+256  ; Road width at bottom, should be MinW+256 in this version
  11. CosMax = 79h
  12.  
  13. mov  al,13h        ; Hope noone will run it with invalid drive as the
  14. int  10h           ; second command line parameter ;)
  15.  
  16. push 0A000h        ; Set up both ES and DS to point to the video memory
  17. pop  es            ; The shifts array at 0A000h:0FA00h is assumed to be
  18. push es            ; zeroed out when setting the video mode
  19. pop  ds
  20. mov  di,Shifts-(MaxY-MinY)*320    ; DI will point to the shifts array after
  21.                                   ; the loop below
  22.  
  23. mov  ch,78h        ; Initialize the sine generator, value in CL is not
  24.                    ; important, BX is assumed to contain zero here
  25. $Do
  26.    pusha
  27.  
  28.    mov  bx,Shifts+2*(MaxY-MinY)   ; DS:BX -> shifts array end
  29.    $Do
  30. ; Set SI to current road width divided by -2
  31.       lea  si,[bx-(Shifts + 2*(MaxY-MinY) + MinW/2)]
  32.  
  33.       mov  bp,160                 ; Screen center
  34.       add  bp,ds:[bx]             ; ...add current shift
  35.       sub  bp,ds:[Shifts+2*PosY]  ; ...subtract motionless position shift
  36.       lea  cx,[si+bp]             ; Current road left edge's position
  37.       xchg ax,si
  38.       lea  si,[di+bp]             ; Current mark's memory offset
  39.       sub  bp,ax                  ; Current road right edge's position
  40.       imul ax,-2                  ; Real current road width
  41.       push ax
  42.  
  43.       mov  al,7                   ; Draw the background's left
  44.       rep  stosb
  45.  
  46.       pop  cx
  47.       inc  ax
  48.       rep  stosb                  ; Draw one horizontal line of the road
  49.  
  50.       mov  cx,320
  51.       sub  cx,bp
  52.       dec  ax
  53.       inc  dx
  54.       test dl,8                   ; Are we drawing a mark?
  55.       $If <>0
  56.          mov  ds:[si],al          ; Draw it
  57.       $EndIf
  58.       rep  stosb                  ; Draw the background's right
  59.  
  60.       sub  bl,2                   ; Move to the next horizontal line
  61.    $EndDo =0
  62.  
  63.    mov  si,Shifts + 2             ; DI already points to the shifts array
  64.    mov  cl,MaxY-MinY
  65.    rep  movsw                     ; Move the road's shifts
  66.  
  67.    popa
  68.  
  69.    dec  dx                        ; Move the marks
  70.    push dx
  71.  
  72.    mov  ax,-39                    ; Calculate a new shift
  73.    imul cx                        ; I use a modification of sine generator
  74.    add  bx,dx                     ; by Wally/RAGE here
  75.    add  cx,bx
  76.    mov  ax,cx
  77.    sar  ax,8+2
  78.    sub  ax,CosMax shr 2           ; Make it always negative
  79.    mov  word ptr ds:[Shifts+2*(MaxY-MinY)],ax
  80.  
  81.    mov  dx,3DAh                   ; Wait for vertical retrace to make the
  82.    $Do                            ; intro run at a reasonable speed on
  83.       in   al,dx                  ; fast video cards
  84.       test al,8
  85.    $EndDo <>0
  86.  
  87.    pop  dx
  88.  
  89.    in   al,60h                    ; Read a scan code
  90.    cbw                            ; Zero out AH for use by INT 10h below
  91.    dec  ax                        ; Exit on Escape
  92. $EndDo =0
  93.  
  94. mov  al,3                         ; Restore the text mode
  95. int  10h
  96.  
  97. retn                              ; Exit
  98.  
  99. db   'Solar!'                     ;-)
  100.  
  101. Shifts = 320*200
  102.