Apps/fire: Improved code style and readability

This commit is contained in:
2025-03-15 20:27:18 +02:00
committed by Max Logaev
parent 20aba254bc
commit afd07534ab
3 changed files with 62 additions and 91 deletions

View File

@@ -1,82 +1,60 @@
;
; FIRE for MENUET - Compile with FASM
; Fire for Kolibri OS - Compile with FASM
;
use32
org 0x0
org 0
db 'MENUET01' ; 8 byte id
dd 1 ; header version
dd START ; program start
dd I_END ; image size
dd image_end ; image size
dd mem_end ; reguired amount of memory
dd mem_end
dd stacktop
dd 0,0 ; no parameters, no path
include '..\..\..\macros.inc'
include '..\..\macros.inc'
include '..\..\KOSfuncs.inc'
Screen_W equ 480
START:
red:
; ************************************************
; ********* WINDOW DEFINITIONS AND DRAW **********
; ************************************************
draw_window:
mov eax,12 ; tell os about redraw
mov ebx,1
mcall
mcall SF_REDRAW, SSF_BEGIN_DRAW
xor eax,eax ; define and draw window
mov ebx,100*65536+321
mov ecx,70*65536+222
mov edx,0x01000000
mov esi,0x00000000
mov edi,0x00000000
mcall
mcall SF_CREATE_WINDOW,<100,Screen_W+1>,<70,222>,0x01000000,0,0
mcall 13,0*65536+321,0*65536+30,0
mcall ,0*65536+1 ,0*65536+222
mcall ,321*65536+1,0*65536+223
mcall ,0*65536+321,222*65536+1
mcall SF_DRAW_RECT,<0,Screen_W+1>,<0,30>,0
mcall ,<0,1>,<0,222>
mcall ,<Screen_W+1,1>,<0,223>
mcall ,<0,Screen_W+1>,<222,1>
mcall SF_DRAW_TEXT,<(Screen_W-108)/2,8>,dword 0x00FFFFFF,text,textlen-text
mov al,4 ; 'FIRE FOR KOLIBRI'
mov ebx,106*65536+8
mov ecx,dword 0x00FFFFFF
mov edx,text
mov esi,textlen-text
mcall
mov al,8
mov ebx,(321-19)*65536+12 ; button start x & size
mov ecx,5*65536+12 ; button start y & size
mov edx,1 ; button number
mov esi,0x009a0000
mcall
mcall SF_DEFINE_BUTTON,<(Screen_W+1-19),12>,<5,12>,1,0x009a0000
mov ebx,ecx ;5*65536+12
inc edx
mcall
mov ebx,18*65536+12
inc edx
mcall
mcall ,<18,12>
mov ebx,31*65536+12
inc edx
mcall
mcall ,<31,12>
mov al,12 ; tell os about redraw end
mov ebx,2
mcall
mcall SF_REDRAW, SSF_END_DRAW
sta: ; calculate fire image
mov esi, FireScreen+0x2300-80
mov ecx, 80
mov esi, FireScreen.end+Screen_W*3-Screen_W/4
mov ecx, Screen_W/4
mov eax, [FireSeed]
NEWLINE:
@@ -89,7 +67,7 @@ sta: ; calculate fire image
mov [FireSeed], eax
mov ecx, 0x2300-80
mov ecx, (Screen_W*200)/8+Screen_W*3-Screen_W/4
sub esi, ecx
xor edx, edx
xor eax, eax
@@ -103,7 +81,7 @@ sta: ; calculate fire image
add eax, edx
mov dl, [esi]
add eax, edx
mov dl, [esi + 80]
mov dl, [esi + Screen_W/4]
jmp typedone
notype1:
@@ -114,7 +92,7 @@ sta: ; calculate fire image
; mov dl, [esi - 2]
; add eax, edx
lea eax, [eax + edx*2]
mov dl, [esi + 78]
mov dl, [esi + Screen_W/4-2]
; notype2:
; type 2 is never used
@@ -124,7 +102,7 @@ sta: ; calculate fire image
; add eax, edx
; mov dl, [esi]
; add eax, edx
; mov dl, [esi + 80]
; mov dl, [esi + Screen_W/4]
; notype3:
typedone:
@@ -135,12 +113,10 @@ typedone:
ZERO:
mov [esi - 81], al
mov [esi - Screen_W/4-1], al
loop FIRELOOP
mov al, 5 ; in this moment always high 24 bits of eax are zero!
mov ebx,[delay]
mcall
mcall SF_SLEEP,[delay]
inc [calc]
cmp [calc], byte 2
@@ -169,7 +145,7 @@ typedone:
mov [edi+3],ecx
mov [edi+6],ecx
mov [edi+9],cx
lea ebx, [edi+320*3]
lea ebx, [edi+Screen_W*3]
mov [ebx+0],ecx
mov [ebx+3],ecx
mov [ebx+6],ecx
@@ -177,50 +153,43 @@ typedone:
add edi,12
inc edx
cmp edx,80
cmp edx,Screen_W/4
jnz nnl
xor edx,edx
add edi,320*3
add edi,Screen_W*3
nnl:
cmp esi,FireScreen+8000; 0x2000
cmp esi,FireScreen.end
jnz newc
mov al,7 ; display image
; high 24 bits of eax are zero!
pop ebx
mov ecx,4*80*65536+200
mov edx,1*65536+22
mcall
mcall SF_PUT_IMAGE,,<Screen_W,200>,<1,22>
nodrw:
mov eax,11 ; check if os wants to talk to us
mcall
mcall SF_CHECK_EVENT ; check if os wants to talk to us
dec eax
jz red
jz draw_window
cmp al, 3-1
jnz nob4
button: ; get button id
mov al,17
mcall
mcall SF_GET_BUTTON
shr eax, 8
dec eax
jnz noclose
or eax,-1 ; close this program
mcall
noclose:
jnz @f
mcall SF_TERMINATE_PROCESS ; close this program
@@:
dec eax ; change fire type
jnz nob2
jnz @f
xor [type], 1
nob2:
@@:
dec eax ; change delay
jnz nob3
jnz @f
xor [delay], 1
nob3:
@@:
dec eax ; change color
jnz nob4
@@ -233,7 +202,7 @@ typedone:
fcok:
mov [fcolor],eax
mov edi,ImageData
mov ecx,(320*600)/4
mov ecx,(Screen_W*200*3)/4
xor eax,eax
rep stosd
@@ -246,19 +215,23 @@ fcolor dd 2
xx db 'x'
type db 0
calc db 0
delay dd 0
delay dd 1
FireSeed dd 0x1234
text: db 'FIRE FOR KOLIBRI'
text: db 'Fire for Kolibri'
textlen:
I_END:
align 4
image_end:
FireScreen:
rb 0x2300
rb (Screen_W*200)/8 ;wisible fire
.end:
rb Screen_W*3 ;hidden fire (need for generation)
ImageData:
rb 320*200*3
rb Screen_W*200*3
; stack
align 512
align 512
rb 512
stacktop:
mem_end:

View File

@@ -1,2 +0,0 @@
@fasm fire.asm fire
@pause