Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 485 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    FIRE for MENUET  - Compile with FASM
  3. ;
  4.  
  5. use32
  6.  
  7.            org     0x0
  8.            db      'MENUET01'           ; 8 byte id
  9.            dd      1                    ; header version
  10.            dd      START                ; program start
  11.            dd      I_END                ; image size
  12.            dd      mem_end              ; reguired amount of memory
  13.            dd      mem_end
  14.            dd      0,0                  ; no parameters, no path
  15.  
  16. include 'macros.inc'
  17.  
  18. START:
  19.  
  20. red:
  21.  
  22. ; ************************************************
  23. ; ********* WINDOW DEFINITIONS AND DRAW **********
  24. ; ************************************************
  25.  
  26. draw_window:
  27.  
  28.     mov  eax,12                    ; tell os about redraw
  29.     mov  ebx,1
  30.     int  0x40
  31.  
  32.     xor  eax,eax                   ; define and draw window
  33.     mov  ebx,100*65536+321
  34.     mov  ecx,70*65536+222
  35.     mov  edx,0x00000000
  36.     mov  esi,0x00000000
  37.     mov  edi,0x00000000
  38.     int  0x40
  39.  
  40.     mov  al,4      ; 'FIRE FOR MENUET'
  41.     mov  ebx,110*65536+8
  42.     mov  ecx,dword 0x00FFFFFF
  43.     mov  edx,text
  44.     mov  esi,textlen-text
  45.     int  0x40
  46.  
  47.     mov  al,8
  48.     mov  ebx,(321-19)*65536+12     ; button start x & size
  49.     mov  ecx,5*65536+12            ; button start y & size
  50.     mov  edx,1                     ; button number
  51.     mov  esi,0x009a0000
  52.     int  0x40
  53.  
  54.     mov  ebx,ecx ;5*65536+12
  55.     inc  edx
  56.     int  0x40
  57.  
  58.     mov  ebx,18*65536+12
  59.     inc  edx
  60.     int  0x40
  61.  
  62.     mov  ebx,31*65536+12
  63.     inc  edx
  64.     int  0x40
  65.  
  66.     mov  al,12                    ; tell os about redraw end
  67.     mov  ebx,2
  68.     int  0x40
  69.  
  70. sta:                                         ; calculate fire image
  71.  
  72.     mov  esi, FireScreen+0x2300-80
  73.     mov  ecx, 80
  74.     mov  eax, [FireSeed]
  75.  
  76.   NEWLINE:
  77.  
  78.     mul  [RandSeedConst]
  79.     inc  eax
  80.     mov  [esi], dl
  81.     inc  esi
  82.     loop NEWLINE
  83.  
  84.     mov  [FireSeed], eax
  85.  
  86.     mov  ecx, 0x2300-80
  87.     sub  esi, ecx
  88.     xor  edx, edx
  89.     xor  eax, eax
  90.  
  91.   FIRELOOP:
  92.     lodsb
  93.  
  94.     cmp  [type], ah
  95.     jnz  notype1
  96.     mov  dl, [esi + 1]
  97.     add  eax, edx
  98.     mov  dl, [esi]
  99.     add  eax, edx
  100.     mov  dl, [esi + 80]
  101.     jmp  typedone
  102.   notype1:
  103.  
  104. ;    cmp  [type],1
  105. ;    jnz  notype2
  106.     mov  dl, [esi - 2]
  107. ;    add  eax, edx
  108. ;    mov  dl, [esi - 2]
  109. ;    add  eax, edx
  110.     lea  eax, [eax + edx*2]
  111.     mov  dl, [esi + 78]
  112. ;  notype2:
  113.  
  114. ; type 2 is never used
  115. ;    cmp  [type],2
  116. ;    jnz  notype3
  117. ;    mov  dl, [esi - 2]
  118. ;    add  eax, edx
  119. ;    mov  dl, [esi]
  120. ;    add  eax, edx
  121. ;    mov  dl, [esi + 80]
  122. ;  notype3:
  123.  
  124. typedone:
  125.     add  eax, edx
  126.     shr  eax, 2
  127.     jz   ZERO
  128.     dec  eax
  129.  
  130.   ZERO:
  131.  
  132.     mov  [esi - 81], al
  133.     loop FIRELOOP
  134.  
  135.     mov  al, 5              ; in this moment always high 24 bits of eax are zero!
  136.     mov  ebx,[delay]
  137.     int  0x40
  138.  
  139.     inc  [calc]
  140.     cmp  [calc], byte 2
  141.     jnz  nodrw
  142.  
  143.   pdraw:
  144.  
  145.     mov  byte [calc],ah ;byte 0
  146.  
  147.     mov  edi,ImageData
  148.     push edi     ; pointer for sysfunction 7, draw image
  149.     add  edi,[fcolor]
  150.     mov  esi,FireScreen
  151.     xor  edx,edx
  152.  
  153.   newc:
  154.     xor   eax, eax
  155.     lodsb
  156.  
  157.     mov   ecx,eax
  158.     shr   eax,1
  159.     add   cl,al
  160.     mov   ch,al
  161.  
  162.     mov  [edi+0],ecx
  163.     mov  [edi+3],ecx
  164.     mov  [edi+6],ecx
  165.     mov  [edi+9],cx
  166.     lea  ebx, [edi+320*3]
  167.     mov  [ebx+0],ecx
  168.     mov  [ebx+3],ecx
  169.     mov  [ebx+6],ecx
  170.     mov  [ebx+9],ecx
  171.  
  172.     add  edi,12
  173.     inc  edx
  174.     cmp  edx,80
  175.     jnz  nnl
  176.     xor  edx,edx
  177.     add  edi,320*3
  178.   nnl:
  179.     cmp  esi,FireScreen+8000; 0x2000
  180.     jnz  newc
  181.  
  182.     mov  al,7           ; display image
  183.                         ; high 24 bits of eax are zero!
  184.     pop  ebx
  185.     mov  ecx,4*80*65536+200
  186.     mov  edx,1*65536+22
  187.     int  0x40
  188.  
  189.   nodrw:
  190.  
  191.     mov  eax,11                  ; check if os wants to talk to us
  192.     int  0x40
  193.     dec  eax
  194.     jz   red
  195.     cmp  al, 3-1
  196.     jnz  nob4
  197.  
  198.   button:                        ; get button id
  199.     mov  al,17
  200.     int  0x40
  201.     shr  eax, 8
  202.  
  203.     dec  eax
  204.     jnz  noclose
  205.     or   eax,-1                  ; close this program
  206.     int  0x40
  207.   noclose:
  208.  
  209.     dec  eax                     ; change fire type
  210.     jnz  nob2
  211.     xor  [type], 1
  212.    nob2:
  213.  
  214.     dec  eax                     ; change delay
  215.     jnz  nob3
  216.     xor  [delay], 1
  217.   nob3:
  218.  
  219.     dec  eax                     ; change color
  220.     jnz  nob4
  221.     mov  eax,[fcolor]
  222.     inc  eax
  223. ;    cmp  al,2
  224. ;    jbe  fcok
  225.     jnp  fcok
  226.     xor  eax,eax
  227.   fcok:
  228.     mov  [fcolor],eax
  229.     mov  edi,ImageData
  230.     mov  ecx,(320*600)/4
  231.     xor  eax,eax
  232.     rep  stosd
  233.  
  234.   nob4:
  235.     jmp  sta
  236.  
  237. ; DATA SECTION
  238. RandSeedConst dd 0x8405
  239. fcolor    dd  2
  240. xx        db  'x'
  241. type      db  0
  242. calc      db  0
  243. delay     dd  0
  244. FireSeed  dd  0x1234
  245. text:     db 'FIRE FOR MENUET'
  246. textlen:
  247.  
  248. I_END:
  249.  
  250. FireScreen:
  251.           rb 0x2300
  252. ImageData:
  253.           rb 320*200*3
  254.  
  255. ; stack
  256.           align 512
  257.           rb 512
  258. mem_end:
  259.