Subversion Repositories Kolibri OS

Rev

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