home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / DISKMAGS / IMPHOB_8.ZIP / IMP8_EX!.ZIP / FLATMODE.ZIP / FIRE.ASM next >
Encoding:
Assembly Source File  |  1994-08-19  |  4.0 KB  |  329 lines

  1.     .model tiny
  2.     .stack 100h
  3.     .code
  4.     .data
  5.     .386P
  6.  
  7. enable_c32=1
  8. use_NMI=0
  9.  
  10. include mem32.inc
  11.  
  12.     .data
  13.  
  14. start_GDT
  15. GDT_seg code16 c16
  16. GDT_seg code32 c32
  17. GDT_seg data16 d16
  18. GDT_seg data32 d32
  19. end_GDT dgroup
  20.  
  21. palette db 768 dup(0)
  22. pal_name db 'palette.bin',0
  23.  
  24. code32 segment use32
  25. r_table dw 256 dup(0)
  26. r_table_ptr dw 0
  27. fire_flag db 0
  28. table equ this byte
  29. num=0
  30. rept 256/2
  31. if (num-7)/4 ge 0
  32.     db (num-7)/4
  33. else
  34.     db 0
  35. endif
  36. num=num+1
  37. if num ge 4
  38.     db (num+8)/4
  39. else
  40.     db 0
  41. endif
  42. num=num+1
  43. endm
  44. ends
  45. virtscreen segment para use32
  46.     db 65536 dup(?)
  47. ends
  48. bigseg segment para use32
  49.     db 2*65536 dup(?)
  50. ends
  51.     .code
  52.     locals
  53.  
  54. debut:
  55.  
  56.     mov ax,code32
  57.     mov ds,ax
  58.     mov es,ax
  59.     mov di,offset r_table
  60. @@b:
  61.     call random1
  62.     mov ah,bh
  63.     stosw
  64.     cmp di,offset r_table+512
  65.     jb @@b
  66.     mov ax,bigseg
  67.     mov es,ax
  68.     xor di,di
  69.     mov cx,32768
  70.     xor dx,dx
  71.     mov bx,offset table
  72. @@b1:
  73.     mov ax,dx
  74.     xlat
  75.     xchg al,ah
  76.     xlat
  77.     xchg al,ah
  78.     stosw
  79.     inc dx
  80.     loop @@b1
  81.     mov ax,bigseg+4096
  82.     mov es,ax
  83.     mov cx,dx
  84. @@b2:
  85.     mov ax,dx
  86.     xlat
  87.     xchg al,ah
  88.     xlat
  89.     xchg al,ah
  90.     stosw
  91.     inc dx
  92.     loop @@b2
  93.  
  94.     mov ax,13h
  95.     int 10h
  96.     mov ax,cs
  97.     mov ds,ax
  98.     mov es,ax
  99.     Mov Dx, offset pal_name
  100.     Mov Ax,3D00H
  101.     Int 21H
  102.     Push Ax
  103.     Pop Bx
  104.     Mov Ax,3F00H
  105.     Mov Cx,768
  106.     Mov Dx,offset palette
  107.     Int 21H
  108.     Mov Ax,3E00H
  109.     Int 21H
  110.     Mov Ax,1012H
  111.     Xor Bx,Bx
  112.     Mov Cx,256
  113.     Mov Dx,offset palette
  114.     Int 10H
  115.  
  116.     mov ax,cs
  117.     mov ds,ax
  118.     mov es,ax
  119.     init_GDT
  120.     init_GDT_base_addr code16
  121.  
  122.     mov ax,code32
  123.     init_GDT_base_seg code32
  124.  
  125.     mov ax,virtscreen
  126.     mov ds,ax
  127.     mov es,ax
  128.     xor di,di
  129.     xor ax,ax
  130.     mov cx,32768
  131.     rep stosw
  132.     mov ax,0a000h
  133.     mov es,ax
  134.  
  135. boucle:
  136.  
  137.     disable_interrupts
  138.     push ax
  139.     switch_prot code32,@@pmode
  140.  
  141. code32 segment
  142. assume cs:code32
  143. @@pmode:
  144.     mov ax,mem32_ptr_GDT_data32
  145.     mov gs,ax
  146.     switch_real code32,@@rmode
  147. @@rmode:
  148.  
  149.     mov ax,bigseg
  150.     mov gs,ax
  151.  
  152. flat:
  153.  
  154.     mov dx,3dah
  155. @@b0:
  156.     in al,dx
  157.     test al,8
  158.     jnz @@b0
  159. @@b1:
  160.     in al,dx
  161.     test al,8
  162.     jz @@b1
  163.  
  164.     mov dx,3c8h
  165.     xor al,al
  166.     out dx,al
  167.     inc dx
  168.     dec al
  169.     out dx,al
  170.     out dx,al
  171.     out dx,al
  172.  
  173.     push es
  174.     push ds
  175.     pop es
  176.  
  177.     mov edi,64000-3*320
  178. @@boucle:
  179.     call random2
  180.     sar al,1;8
  181.     shr al,3;2
  182.     add al,fire_flag
  183.     jns @@ok
  184.     xor al,al
  185. @@ok:
  186.     mov ah,al
  187.     shl eax,8
  188.     mov al,ah
  189.     shl eax,8
  190.     mov al,ah
  191.     stosd
  192.     cmp di,64000
  193.     jb @@boucle
  194.  
  195. @@fin_random:
  196.  
  197.     pop es
  198.  
  199.     mov dx,3c8h
  200.     xor al,al
  201.     out dx,al
  202.     inc dx
  203.     mov al,16
  204.     out dx,al
  205.     out dx,al
  206.     out dx,al
  207.  
  208.     xor edi,edi
  209.     mov ecx,200
  210.     xor ebx,ebx
  211.     jmp short @@debile
  212. align 4
  213. @@debile:
  214. rept 80
  215.     mov eax,[di+320]
  216.     add eax,[di+319]
  217.     add eax,[di+641]
  218.     add eax,[di+960]
  219.     mov bx,ax
  220.     shr eax,16
  221.     mov ax,gs:[eax*2]
  222.     shl eax,16
  223.     mov ax,gs:[ebx*2]
  224.     mov [edi],eax
  225.     stosd
  226. endm
  227.     dec ecx
  228.     jnz @@debile
  229.  
  230.     mov dx,3c8h
  231.     xor al,al
  232.     out dx,al
  233.     inc dx
  234.     out dx,al
  235.     out dx,al
  236.     out dx,al
  237.  
  238.     switch_prot code16,@@pmode
  239. ends
  240. assume cs:_text
  241. @@pmode:
  242.     mov ax,mem32_ptr_GDT_data16
  243.     mov gs,ax
  244.     switch_real _text,@@rmode
  245. @@rmode:
  246.  
  247.     pop ax
  248.     mov al,ah
  249.     enable_interrupts
  250.  
  251.     mov ah,1
  252.     int 16h
  253.     jz boucle
  254.     xor ah,ah
  255.     int 16h
  256.     cmp al,27
  257.     je fin
  258.     push es
  259.     mov bx,code32
  260.     mov es,bx
  261. assume es:code32
  262.     cmp al,' '
  263.     jne not0
  264.     neg es:fire_flag
  265.     jmp short ok
  266. not0:
  267.     cmp al,'+'
  268.     jne not1
  269.     cmp es:fire_flag,31
  270.     je ok
  271.     inc es:fire_flag
  272.     jmp short ok
  273. not1:
  274.     cmp al,'-'
  275.     jne ok
  276.     cmp es:fire_flag,-32
  277.     je ok
  278.     dec es:fire_flag
  279. ok:
  280.     pop es
  281.     jmp boucle
  282.  
  283. fin:
  284.     mov ax,3
  285.     int 10h
  286.  
  287.     mov ax,4c00h
  288.     int 21h
  289.  
  290. lowr dw 1
  291. highr dw 657
  292. random1:
  293.     mov ax,16807    ;multiplie seed par a
  294.     mul cs:lowr
  295.     mov bx,ax
  296.     mov cx,dx
  297.     mov ax,16807
  298.     mul cs:highr
  299.     add ax,cx        ;calcule le reste du produit divisé par m
  300.     adc dx,0
  301.     shl ax,1
  302.     rcl dx,1
  303.     shr ax,1
  304.     add bx,dx
  305.     adc ax,0
  306.     test ax,32768
  307.     jnz increm
  308. pas_increm:
  309.     mov cs:lowr,bx    ;c'est fait !
  310.     mov cs:highr,ax
  311.     ret            ;bye bye random !
  312. increm:
  313.     inc bx
  314.     xor ax,ax
  315.     jmp pas_increm
  316.  
  317. code32 segment
  318. assume cs:code32
  319. random2:
  320.     mov bx,cs:r_table_ptr
  321.     mov ax,cs:r_table[bx+73]
  322.     xor cs:r_table[bx],ax
  323.     xor cs:r_table[bx+256],ax
  324.     add cs:r_table_ptr,2
  325.     and cs:r_table_ptr,255
  326.     ret
  327. ends
  328.  
  329.     end debut