home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIA_SNW.ZIP / SNOW.ASM < prev   
Assembly Source File  |  1997-06-14  |  9KB  |  346 lines

  1. ;=========================================================
  2. ; The snowfield simulator.
  3. ;=========================================================
  4. ;  Hope you like.  if you use this code in one of you
  5. ; demos or something then please credit me, failing that
  6. ; just send me a copy of you program to peruse.
  7. ;
  8. ; If the instructions in the code look in a really wierd
  9. ; order it is becase they have been aranged to take
  10. ; advantage of the 486+ Pipeline.  If you think my code
  11. ; is a bit slack then tell me why.
  12. ;
  13. ; Code By Jar Jam of TIA
  14. ;=========================================================
  15. ;          _____   _       ___
  16. ;         |_   _| | |     / _ \
  17. ;           | |   | |    | |_| |
  18. ;           | |   | |    |  _  |
  19. ;           |_|HE |_|NFO |_| |_|SYMILATORS
  20. ;
  21. ; If you can code, draw, write decent music or can do
  22. ; anything else that may be of use to us then apply within
  23. ;
  24. ;        Temporary EMail: JARJAM@AXS.COM.AU
  25. ;
  26. ;=========================================================
  27.  
  28.   .386
  29.  
  30. ;---------------------------------------------------------
  31. sstack segment stack use16
  32.   STACKDATA dw 100 dup (0)
  33. sstack ends
  34.  
  35. ;---------------------------------------------------------
  36. ddata segment use16 public
  37.  include     pal.dat
  38.  max_flake = 40
  39.  THE_MESSAGE DB 'The snowfield simulator.  Not just a sideways starfield :) '
  40.              DB 13,10,'Code: Jacob "JAR JAM" Rhoden, 14/6/97.',13,10,10,10
  41.              DB 10,10,10,10,10,10,10,10,10,10,10,10,10,10
  42.              DB '  _____   _       ___',13,10
  43.              DB ' |_   _| | |     / _ \',13,10
  44.              DB '   | |   | |    | |_| |',13,10
  45.              DB '   | |   | |    |  _  |',13,10
  46.              db '   |_|HE |_|NFO |_| |_|SYMILATORS',13,10
  47.              db '$'
  48.  layer1_xpos dw 010,020,070,040,260,060,070,280,090,100
  49.              dw 110,120,140,160,170,180,190,200,220,310
  50.              dw 010,003,140,096,317,204,109,156,191,057
  51.              dw 008,123,177,162,033,233,298,250,225,311
  52.  layer1_ypos db 010,0, 004,1, 000,2, 024,3, 050,1
  53.              db 050,2, 140,2, 130,3, 146,1, 020,0
  54.              db 070,3, 170,2, 040,1, 158,1, 164,3
  55.              db 002,2, 000,2, 112,3, 004,1, 028,0
  56.              db 010,3, 124,2, 054,1, 062,1, 152,3
  57.              db 050,2, 174,2, 162,3, 038,1, 132,0
  58.              db 080,3, 172,2, 128,1, 076,1, 138,3
  59.              db 088,1, 182,0, 146,3, 022,2, 166,1
  60.  layer2_xpos dw 010,020,030,040,050,060,070,080,090,100
  61.              dw 110,120,130,140,150,160,170,180,190,200
  62.              dw 210,220,230,240,250,260,270,280,290,300
  63.              dw 310,003,056,075,125,145,196,154,205,304
  64.  layer2_ypos db 010,1, 004,0, 000,2, 024,0, 050,3
  65.              db 070,3, 180,2, 040,0, 170,1, 160,1
  66.              db 002,0, 000,3, 112,1, 004,3, 028,2
  67.              db 010,1, 124,0, 054,2, 062,0, 164,3
  68.              db 050,2, 140,1, 130,3, 150,1, 020,0
  69.              db 050,2, 184,1, 160,3, 038,1, 132,0
  70.              db 080,3, 164,2, 128,0, 076,2, 142,1
  71.              db 088,0, 180,3, 142,1, 022,3, 166,2
  72.  layer3_xpos dw 010,020,070,040,260,060,070,280,090,100
  73.              dw 110,120,140,160,170,180,190,200,220,310
  74.              dw 010,003,140,096,317,204,109,156,191,057
  75.              dw 008,123,177,162,033,233,298,256,225,311
  76.  layer3_ypos db 012,1, 004,0, 000,2, 024,0, 052,3
  77.              db 072,3, 168,2, 040,0, 168,2, 152,1
  78.              db 004,0, 000,3, 112,1, 004,3, 028,2
  79.              db 012,1, 124,0, 056,2, 060,0, 160,3
  80.              db 048,2, 140,1, 128,3, 148,1, 020,0
  81.              db 052,2, 184,1, 164,3, 036,1, 132,0
  82.              db 080,3, 172,2, 128,0, 076,2, 140,1
  83.              db 088,0, 184,3, 140,1, 024,3, 164,2
  84. label looky word
  85.  include look.dat
  86.  pallete db 0,0,10
  87.  parra   db 00,03,63,00,07,63,00,15,63,00,31,63
  88.          db 00,31,63,00,15,63,00,07,63,00,03,63
  89. ddata ends
  90.  
  91. ccode segment use16
  92.   assume cs:ccode, ds:ddata, ss:sstack
  93.  
  94. WAIT_RETRACE PROC NEAR
  95.   PUSH DX
  96.   MOV DX,3DAH
  97. WR_START:
  98.   in al,dx
  99.   test al,8
  100.   jz WR_START                    ;wait until Verticle Retrace starts
  101. WR_END:
  102.   in al,dx
  103.   test al,8
  104.   jnz WR_END                   ;wait until Verticle Retrace Ends
  105.   POP DX
  106.   RET
  107. WAIT_RETRACE ENDP
  108.  
  109. show_state3 proc near
  110.   mov si,0
  111. show_all3:
  112.   mov di,[layer3_xpos+si]
  113.   mov bl,[layer3_ypos+si]
  114.   mov dl,[layer3_ypos+si+1]
  115.   inc dl
  116.   cmp dl,4
  117.   jne _reanimate3
  118.   xor dl,dl
  119. _reanimate3:
  120.   add bl,4
  121.   cmp bl,188
  122.   jne no_refall3
  123.   xor bl,bl
  124. no_refall3:
  125.   mov [layer3_ypos+si+1],dl
  126.   mov [layer3_ypos+si],bl
  127.   
  128.   xor bh,bh
  129.   shl bx,1
  130.   add di,[looky+bx]
  131.   mov ax,1f1fh
  132.   cmp dl,1
  133.   je do_13
  134.   cmp dl,2
  135.   je do_23
  136.   cmp dl,3
  137.   je do_33
  138. do_03:
  139.   mov es:[(320*4)+di+0],ax       ;1- 110
  140.   mov es:[(320*5)+di+1],ax       ;2- 011
  141.   mov ax,0ffffh
  142.   mov es:[(320*1)+di+0],al       ;0- 000
  143.   mov es:[(320*1)+di+1],ax       ;1- 111
  144.   jmp short shown_flake3
  145. do_13:
  146.   mov es:[(320*5)+di+0],al       ;1- 000
  147.   mov es:[(320*5)+di+1],ax       ;2- 111
  148.   mov ax,0ffffh
  149.   mov es:[(320*0)+di+0],ax       ;0- 110
  150.   mov es:[(320*1)+di+1],ax       ;1- 011
  151.   jmp short shown_flake3
  152. do_23:
  153.   mov es:[(320*4)+di+1],ax       ;1- 011
  154.   mov es:[(320*5)+di+0],ax       ;2- 110
  155.   mov ax,0ffffh
  156.   mov es:[(320*1)+di+2],al       ;0- 000
  157.   mov es:[(320*1)+di+0],ax       ;1- 111
  158.   jmp short shown_flake3
  159. do_33:
  160.   mov es:[(320*5)+di+0],al       ;1- 000
  161.   mov es:[(320*5)+di+1],ax       ;2- 111
  162.   mov ax,0ffffh
  163.   mov es:[(320*0)+di+1],ax       ;0- 011
  164.   mov es:[(320*1)+di+0],ax       ;1- 110
  165. shown_flake3:
  166.   add si,2
  167.   cmp si, max_flake*2
  168.   jne show_all3
  169.   ret
  170. show_state3 endp
  171.  
  172. show_state proc near
  173.   mov si,0
  174. show_all:
  175.   mov di,[layer1_xpos+si]
  176.   mov bl,[layer1_ypos+si]
  177.   mov dl,[layer1_ypos+si+1]
  178.   inc dl
  179.   cmp dl,4
  180.   jne _reanimate
  181.   xor dl,dl
  182. _reanimate:
  183.   add bl,2
  184.   cmp bl,188
  185.   jne no_refall
  186.   xor bl,bl
  187. no_refall:
  188.   mov [layer1_ypos+si+1],dl
  189.   mov [layer1_ypos+si],bl
  190.   
  191.   xor bh,bh
  192.   shl bx,1
  193.   add di,[looky+bx]
  194.   mov ax,1a1ah
  195.   cmp dl,1
  196.   je do_1
  197.   cmp dl,2
  198.   je do_2
  199.   cmp dl,3
  200.   je do_3
  201. do_0:
  202.   mov es:[(320*2)+di+0],ax       ;1- 110
  203.   mov es:[(320*3)+di+1],ax       ;2- 011
  204.   mov ax,0ffffh
  205.   mov es:[(320*1)+di+0],al       ;0- 000
  206.   mov es:[(320*1)+di+1],ax       ;1- 111
  207.   jmp short shown_flake
  208. do_1:
  209.   mov es:[(320*3)+di+0],al       ;1- 000
  210.   mov es:[(320*3)+di+1],ax       ;2- 111
  211.   mov ax,0ffffh
  212.   mov es:[(320*0)+di+0],ax       ;0- 110
  213.   mov es:[(320*1)+di+1],ax       ;1- 011
  214.   jmp short shown_flake
  215. do_2:
  216.   mov es:[(320*2)+di+1],ax       ;1- 011
  217.   mov es:[(320*3)+di+0],ax       ;2- 110
  218.   mov ax,0ffffh
  219.   mov es:[(320*1)+di+2],al       ;0- 000
  220.   mov es:[(320*1)+di+0],ax       ;1- 111
  221.   jmp short shown_flake
  222. do_3:
  223.   mov es:[(320*3)+di+0],al       ;1- 000
  224.   mov es:[(320*3)+di+1],ax       ;2- 111
  225.   mov ax,0ffffh
  226.   mov es:[(320*0)+di+1],ax       ;0- 011
  227.   mov es:[(320*1)+di+0],ax       ;1- 110
  228. shown_flake:
  229.   add si,2
  230.   cmp si, max_flake*2
  231.   jne show_all
  232.   ret
  233. show_state endp
  234.  
  235. show_state2 proc near
  236.   mov si,0
  237. show_all2:
  238.   mov di,[layer2_xpos+si]
  239.   mov bl,[layer2_ypos+si]
  240.   mov dl,[layer2_ypos+si+1]
  241.   inc dl
  242.   cmp dl,4
  243.   jne _reanimate2
  244.   xor dl,dl
  245. _reanimate2:
  246.   inc bl
  247.   cmp bl,188
  248.   jne no_refall2
  249.   xor bl,bl
  250. no_refall2:
  251.   mov [layer2_ypos+si+1],dl
  252.   mov [layer2_ypos+si],bl
  253.   
  254.   xor bh,bh
  255.   shl bx,1
  256.   add di,[looky+bx]
  257.   mov ax,1515h
  258.   cmp dl,1
  259.   je do_12
  260.   cmp dl,2
  261.   je do_22
  262.   cmp dl,3
  263.   je do_32
  264. do_02:
  265.   mov es:[(320*1)+di+0],ax       ;1- 110
  266.   mov es:[(320*2)+di+1],ax       ;2- 011
  267.   mov ax,0ffffh
  268. ; mov es:[(320*1)+di+0],al       ;0- 000
  269.   mov es:[(320*1)+di+2],al       ;1- 111
  270.   jmp short shown_flake2
  271. do_12:
  272.   mov es:[(320*2)+di+0],al       ;1- 000
  273.   mov es:[(320*2)+di+1],ax       ;2- 111
  274.   mov ax,0ffffh
  275.   mov es:[(320*0)+di+0],ax       ;0- 110
  276.   mov es:[(320*1)+di+1],ax       ;1- 011
  277.   jmp short shown_flake2
  278. do_22:
  279.   mov es:[(320*1)+di+1],ax       ;1- 011
  280.   mov es:[(320*2)+di+0],ax       ;2- 110
  281.   mov ax,0ffffh
  282. ; mov es:[(320*1)+di+0],al       ;0- 000
  283.   mov es:[(320*1)+di+0],al       ;1- 111
  284.   jmp short shown_flake2
  285. do_32:
  286.   mov es:[(320*2)+di+0],al       ;1- 000
  287.   mov es:[(320*2)+di+1],ax       ;2- 111
  288.   mov ax,0ffffh
  289.   mov es:[(320*0)+di+1],ax       ;0- 011
  290.   mov es:[(320*1)+di+0],ax       ;1- 110
  291. shown_flake2:
  292.   add si,2
  293.   cmp si, max_flake*2
  294.   jne show_all2
  295.   ret
  296. show_state2 endp
  297.  
  298. start proc near
  299.   mov ax,ddata
  300.   mov ds,ax
  301.   mov es,ax
  302.   mov ax,013h
  303.   int 010h
  304.  
  305.   mov si,0a000h
  306.   MOV DX,OFFSET PALLETE       ; ES:DX pooint to palette data
  307.   MOV AX,01012h               ; WRITE palette 
  308.   MOV BX,0ffh                 ; do colour 255
  309.   MOV CX,1                   ; and write 1 colour
  310.   INT 10h
  311.   mov es,si
  312.  
  313.   xor di,di
  314.   mov cx,160*190
  315.   mov ax,0ffffh
  316.   rep stosw
  317.   mov di,320*190
  318.   mov cx,160*12
  319.   mov ax,0202h
  320.   rep stosw
  321. MAIN_loop:
  322.   CALL WAIT_RETRACE
  323.   call show_state2
  324.   CALL WAIT_RETRACE
  325.   call show_state
  326.   CALL WAIT_RETRACE
  327.   call show_state3
  328.   mov ah,1
  329.   int 016h
  330.   jnz _exit
  331.   jmp main_loop
  332. _EXIT:
  333.   XOR AX,AX
  334.   INT 016h
  335.   MOV AX,03
  336.   INT 010h
  337.   MOV DX,OFFSET THE_MESSAGE
  338.   MOV AH,9
  339.   INT 021h
  340.   MOV AX,04C00h
  341.   INT 021h
  342. START ENDP
  343.  
  344. ccode ends
  345. end start
  346.