/programs/demos/fire/trunk/fire.asm |
---|
0,0 → 1,259 |
; |
; FIRE for MENUET - Compile with FASM |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; header version |
dd START ; program start |
dd I_END ; image size |
dd mem_end ; reguired amount of memory |
dd mem_end |
dd 0,0 ; no parameters, no path |
;include 'lang.inc' |
include 'macros.inc' |
START: |
red: |
; ************************************************ |
; ********* WINDOW DEFINITIONS AND DRAW ********** |
; ************************************************ |
draw_window: |
mov eax,12 ; tell os about redraw |
mov ebx,1 |
int 0x40 |
xor eax,eax ; define and draw window |
mov ebx,100*65536+321 |
mov ecx,70*65536+222 |
mov edx,0x00000000 |
mov esi,0x00000000 |
mov edi,0x00000000 |
int 0x40 |
mov al,4 ; 'FIRE FOR MENUET' |
mov ebx,110*65536+8 |
mov ecx,dword 0x00FFFFFF |
mov edx,text |
mov esi,textlen-text |
int 0x40 |
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 |
int 0x40 |
mov ebx,ecx ;5*65536+12 |
inc edx |
int 0x40 |
mov ebx,18*65536+12 |
inc edx |
int 0x40 |
mov ebx,31*65536+12 |
inc edx |
int 0x40 |
mov al,12 ; tell os about redraw end |
mov ebx,2 |
int 0x40 |
sta: ; calculate fire image |
mov esi, FireScreen+0x2300-80 |
mov ecx, 80 |
mov eax, [FireSeed] |
NEWLINE: |
mul [RandSeedConst] |
inc eax |
mov [esi], dl |
inc esi |
loop NEWLINE |
mov [FireSeed], eax |
mov ecx, 0x2300-80 |
sub esi, ecx |
xor edx, edx |
xor eax, eax |
FIRELOOP: |
lodsb |
cmp [type], ah |
jnz notype1 |
mov dl, [esi + 1] |
add eax, edx |
mov dl, [esi] |
add eax, edx |
mov dl, [esi + 80] |
jmp typedone |
notype1: |
; cmp [type],1 |
; jnz notype2 |
mov dl, [esi - 2] |
; add eax, edx |
; mov dl, [esi - 2] |
; add eax, edx |
lea eax, [eax + edx*2] |
mov dl, [esi + 78] |
; notype2: |
; type 2 is never used |
; cmp [type],2 |
; jnz notype3 |
; mov dl, [esi - 2] |
; add eax, edx |
; mov dl, [esi] |
; add eax, edx |
; mov dl, [esi + 80] |
; notype3: |
typedone: |
add eax, edx |
shr eax, 2 |
jz ZERO |
dec eax |
ZERO: |
mov [esi - 81], al |
loop FIRELOOP |
mov al, 5 ; in this moment always high 24 bits of eax are zero! |
mov ebx,[delay] |
int 0x40 |
inc [calc] |
cmp [calc], byte 2 |
jnz nodrw |
pdraw: |
mov byte [calc],ah ;byte 0 |
mov edi,ImageData |
push edi ; pointer for sysfunction 7, draw image |
add edi,[fcolor] |
mov esi,FireScreen |
xor edx,edx |
newc: |
xor eax, eax |
lodsb |
mov ecx,eax |
shr eax,1 |
add cl,al |
mov ch,al |
mov [edi+0],ecx |
mov [edi+3],ecx |
mov [edi+6],ecx |
mov [edi+9],cx |
lea ebx, [edi+320*3] |
mov [ebx+0],ecx |
mov [ebx+3],ecx |
mov [ebx+6],ecx |
mov [ebx+9],ecx |
add edi,12 |
inc edx |
cmp edx,80 |
jnz nnl |
xor edx,edx |
add edi,320*3 |
nnl: |
cmp esi,FireScreen+8000; 0x2000 |
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 |
int 0x40 |
nodrw: |
mov eax,11 ; check if os wants to talk to us |
int 0x40 |
dec eax |
jz red |
cmp al, 3-1 |
jnz nob4 |
button: ; get button id |
mov al,17 |
int 0x40 |
shr eax, 8 |
dec eax |
jnz noclose |
or eax,-1 ; close this program |
int 0x40 |
noclose: |
dec eax ; change fire type |
jnz nob2 |
xor [type], 1 |
nob2: |
dec eax ; change delay |
jnz nob3 |
xor [delay], 1 |
nob3: |
dec eax ; change color |
jnz nob4 |
mov eax,[fcolor] |
inc eax |
; cmp al,2 |
; jbe fcok |
jnp fcok |
xor eax,eax |
fcok: |
mov [fcolor],eax |
mov edi,ImageData |
mov ecx,(320*600)/4 |
xor eax,eax |
rep stosd |
nob4: |
jmp sta |
; DATA SECTION |
RandSeedConst dd 0x8405 |
fcolor dd 2 |
xx db 'x' |
type db 0 |
calc db 0 |
delay dd 0 |
FireSeed dd 0x1234 |
text: db 'FIRE FOR MENUET' |
textlen: |
I_END: |
FireScreen: |
rb 0x2300 |
ImageData: |
rb 320*200*3 |
; stack |
align 512 |
rb 512 |
mem_end: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/fire/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm fire.asm fire |
@pause |
/programs/demos/fire/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm fire.asm fire |
@pause |
/programs/demos/fire/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |