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

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