/programs/demos/firework/trunk/aspapi.inc |
---|
0,0 → 1,139 |
include 'proc32.inc' |
macro start_draw_window x,y,xsize,ysize,areacolor,caption;,capsize |
{ |
;pusha |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, x*65536+xsize ; [x start] *65536 + [x size] |
mov ecx, y*65536+ysize ; [y start] *65536 + [y size] |
mov edx, areacolor ; color of work area RRGGBB |
mov esi, 0x00334455 ; color of grab bar RRGGBB |
mov edi, 0x00ddeeff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
;mov eax, 4 ; function 4 : write text to window |
;mov ebx, 8*65536+8 ; [x start] *65536 + [y start] |
;mov ecx, 0x00ffffff ; color of text RRGGBB |
;mov edx, caption ; pointer to text beginning |
;mov esi, capsize ; text length |
mov eax, 71 ; function 71.1 |
mov ebx, 1 ; set window caption |
mov ecx, caption ; pointer to text |
int 0x40 |
;popa |
} |
macro end_draw_window |
{ |
mov eax, 12 ; end of redraw |
mov ebx, 2 |
int 0x40 |
} |
proc draw_button stdcall, x:dword, y:dword, xsize:dword, ysize:dword, \ |
id:dword, butcolor:dword, text:dword, textlen:byte, textcolor:dword |
;pusha |
mov ebx, dword [x] |
shl ebx, 16 |
add ebx, dword [xsize] ; [x start] *65536 + [x size] |
mov ecx, dword [y] |
shl ecx, 16 |
add ecx, dword [ysize] ; [y start] *65536 + [y size] |
mov edx, dword [id] ; button id |
mov esi, dword [butcolor] ; button color RRGGBB |
mov eax, 8 ; function 8 : define and draw button |
int 0x40 |
mov ebx, dword [x] |
add ebx, 5 |
shl ebx, 16 |
mov eax, dword [ysize] |
sub eax, 5 |
shr eax, 1 |
add ebx, eax |
add ebx, dword [y] ;mov ebx, (x+5)*65536+y+(ysize-5)/2 ; Draw button text |
mov ecx, dword [textcolor] |
mov edx, dword [text] |
xor eax, eax |
mov al, byte [textlen] |
mov esi, eax |
mov eax, 4 |
int 0x40 |
;popa |
ret |
endp |
macro outtextxy x,y,prompt,prompt_len,color |
{ |
pusha |
mov ebx, x*65536+y ; draw info text with function 4 |
mov ecx, color |
mov edx, prompt |
xor eax, eax |
mov al, prompt_len |
mov esi, eax |
mov eax, 4 |
int 0x40 |
popa |
} |
;proc bar x:dword, y:dword, xsize:dword, ysize:dword, color:dword |
macro bar x, y, xsize, ysize, color |
{ |
pusha |
mov eax, 13 |
;mov ebx, [x] |
;shl ebx, 16 |
;add ebx, [xsize] |
;mov ecx, [y] |
;shl ecx, 16 |
;add ecx, [ysize] |
;mov edx, [color] |
mov ebx, x*65536+xsize |
mov ecx, y*65536+ysize |
mov edx, color |
int 0x40 |
popa |
;ret |
;endp |
} |
macro line x1,y1,x2,y2,color |
{ |
pusha |
mov eax, 38 |
mov ebx, x1*65536+x2 |
mov ecx, y1*65536+y2 |
mov edx, color |
int 0x40 |
popa |
} |
macro rectangle x,y,xsize,ysize,color |
{ |
x2=x+xsize |
y2=y+ysize |
line x,y,x2,y,color |
line x,y,x,y2,color |
line x,y2,x2,y2,color |
line x2,y,x2,y2,color |
} |
macro putpixel x,y,color |
{ |
mov eax, 1 |
mov ebx, x |
mov ecx, y |
mov edx, color |
int 0x40 |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/firework/trunk/firework.asm |
---|
0,0 → 1,370 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; A firework demo |
; Programmed by Yaniv LEVIATHAN |
; http://yaniv.leviathanonline.com |
; Converted to DexOS, By Dex |
; Converted to KolibriOS, By Asper |
; Optimized for KolibriOS, By Diamond |
; Assemble with |
; c:fasm firework.asm firework.kex |
; NOTE: Needs MMX & SSE |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd STARTAPP ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include "aspAPI.inc" |
SCREEN_WIDTH equ 320 |
SCREEN_HEIGHT equ 200 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; Global defines |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
NUM_PARTS = 150 |
X_OFFSET = 0 |
Y_OFFSET = 4 |
X_SPEED_OFFSET = 8 |
Y_SPEED_OFFSET = 12 |
COLOR_OFFSET = 16 |
PART_SIZE = 20 |
macro draw_window |
{ |
local x, xsize, y, ysize, areacolor, caption |
x = 100 |
y = 70 |
xsize = SCREEN_WIDTH+9 |
ysize = SCREEN_HEIGHT+4 |
areacolor = 0x14224466 |
caption = labelt |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 48 |
mov ebx, 4 |
int 0x40 |
lea ecx, [y*65536+ysize+eax] |
xor eax, eax ; function 0 : define and draw window |
mov ebx, x*65536+xsize ; [x start] *65536 + [x size] |
mov edx, areacolor ; color of work area RRGGBB |
mov edi, caption |
int 0x40 |
; start_draw_window 100,70,SCREEN_WIDTH+9,SCREEN_HEIGHT+29,0x04224466,labelt;, 14;labellen-labelt |
end_draw_window |
} |
macro mmx_shade |
{ |
mov ecx, SCREEN_WIDTH*SCREEN_HEIGHT/8 |
mov edi,buffer |
movq mm1, [sub_mask] |
.lop: |
movq mm0, [edi] |
psubusb mm0, mm1 |
movq [edi], mm0 |
add edi, 8 |
loop .lop |
} |
macro mmx_blur_prepare |
{ |
mov ecx, (SCREEN_WIDTH*SCREEN_HEIGHT-330*2)/8 |
mov edi,buffer + 328 |
} |
macro mmx_blur |
{ |
local .lop |
.lop: |
movq mm0, [edi] |
movq mm1, [edi+1] |
movq mm2, [edi-1] |
movq mm3, mm0 |
movq mm4, [edi-SCREEN_WIDTH] |
movq mm5, [edi+SCREEN_WIDTH] |
pavgb mm0, mm1 ; mm0 = avg(cur,cur+1) |
pavgb mm3, mm2 ; mm3 = avg(cur,cur-1) |
pavgb mm4, mm5 ; mm4 = avg(cur+320,cur-320) |
pavgb mm3, mm4 ; mm3 = avg(avg(cur,cur-1),avg(cur+320,cur-320)) |
pavgb mm0, mm3 ; mm0 = avg(avg(cur,cur+1), |
movq [edi], mm0 |
add edi, 8 |
loop .lop |
} |
macro mmx_blur_right |
{ |
local .lop |
.lop: |
movq mm0, [edi] |
movq mm1, [edi+1] |
movq mm2, [edi+SCREEN_WIDTH] |
movq mm3, [edi+SCREEN_WIDTH+1] |
pavgb mm0, mm1 |
pavgb mm3, mm2 |
pavgb mm0, mm3 |
movq [edi], mm0 |
add edi, 8 |
loop .lop |
} |
STARTAPP: |
init_palette: |
mov edi, pal |
xor eax, eax |
red_loop: |
stosd |
stosd |
add eax, 0x040000 |
and eax, 0xFFFFFF |
jnz red_loop |
mov eax, 63*4*65536 |
@@: |
stosd |
stosd |
add ax, 0x0404 |
jnc @b |
;zero_buffer: |
mov ecx, SCREEN_WIDTH*SCREEN_HEIGHT/4 |
; mov edi,buffer |
xor eax, eax |
rep stosd |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; Main Functions |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
virtual at esp |
global_x dd ? |
global_y dd ? |
seed dd ? |
end virtual |
db 0x0f, 0x31 |
push eax ; seed |
push 100*64 ; global_y |
push 160*64 ; global_x |
jmp MAIN |
red: |
draw_window |
MAIN: |
mov ecx, NUM_PARTS |
mov ebp, particles |
.advance_particles: |
mov eax, [ebp+X_OFFSET] |
mov ebx, [ebp+Y_OFFSET] |
sar eax, 6 |
sar ebx, 6 |
cmp eax, 5 |
jb .new_particle |
cmp eax, SCREEN_WIDTH-5;315 |
jge .new_particle |
cmp ebx, 5 |
jb .new_particle |
cmp ebx, SCREEN_HEIGHT-5;195 |
jl .part_ok |
.new_particle: |
call init_particle |
jmp .advance_particles |
.part_ok: |
; mov edi, eax |
; add edi,buffer |
; mov eax, SCREEN_WIDTH |
; mul ebx |
imul edi, ebx, SCREEN_WIDTH |
mov dl, [ebp+COLOR_OFFSET] |
mov [buffer+eax+edi], dl |
; mov eax, [ebp+X_OFFSET] |
; mov ebx, [ebp+Y_OFFSET] |
; add eax, [ebp+X_SPEED_OFFSET] |
; add ebx, [ebp+Y_SPEED_OFFSET] |
; mov [ebp+X_OFFSET], eax |
; mov [ebp+Y_OFFSET], ebx |
mov eax, [ebp+X_SPEED_OFFSET] |
add [ebp+X_OFFSET], eax |
mov eax, [ebp+Y_SPEED_OFFSET] |
add [ebp+Y_OFFSET], eax |
db 0x0f, 0x31 |
and al, 0x7F |
jnz .dont_inc_y_speed |
inc dword [ebp+Y_SPEED_OFFSET] |
.dont_inc_y_speed: |
add ebp, PART_SIZE |
loop .advance_particles |
mmx_shade |
; jmp .copy_buffer_to_video |
mmx_blur_prepare |
test dword [blur_right_flag] , 0x800000 |
jnz .do_blur_right |
mmx_blur |
db 0x0f, 0x31 |
and al, 1 |
jz .blur_ok |
jmp .dont_blur |
.do_blur_right: |
mmx_blur_right |
.blur_ok: |
add dword [blur_right_flag], 0x1000 |
.dont_blur: |
.copy_buffer_to_video: |
; mov eax, 18 ;@WAITVSYNC(); |
; mov ebx, 14 |
; int 0x40 |
mov eax, 48 |
mov ebx, 4 |
int 0x40 |
lea edx, [5*65536+eax] |
mov eax, 65 ;copyfard(0xA000,0,screen,0,16000); |
mov ebx, buffer;dword [screen] |
mov ecx, SCREEN_WIDTH*65536+SCREEN_HEIGHT ;ecx = w*65536+h |
; mov edx, 5*65536+25 ;edx = x*65536+y |
push 8 |
pop esi |
;mov esi, 8 |
mov edi, pal |
xor ebp, ebp |
int 0x40 |
still: |
mov eax, 11 ; Test if there is an event in the queue. |
int 0x40 |
dec eax ; redraw request ? |
jz red |
dec eax ; key in buffer ? |
jz key |
dec eax ; button in buffer ? |
jz button |
jmp MAIN |
key: |
mov eax, 2 |
int 0x40 |
; cmp ah, 1 ; Test Esc in Scan |
; je close_app |
cmp ah, 27 ; Test Esc in ASCII |
je close_app |
jmp MAIN |
button: |
; we have only one button, close |
; mov eax, 17 ; Get pressed button code |
; int 0x40 |
; cmp ah, 1 ; Test x button |
; je close_app |
; jmp MAIN |
; fall through to close_app |
fail: |
; Type something here. |
close_app: |
mov eax,-1 ; close this program |
int 0x40 |
init_particle: |
db 0x0f, 0x31 |
and al, 0x1F |
jnz .dont_re_init_globals |
; init x |
call rand |
cdq |
;xor dx, dx |
mov ebx, SCREEN_WIDTH |
div ebx |
shl edx, 6 |
mov [4+global_x], edx |
; init y |
call rand |
cdq |
;xor dx, dx |
mov ebx, SCREEN_HEIGHT |
div ebx |
shl edx, 6 |
mov [4+global_y], edx |
.dont_re_init_globals: |
; init x |
mov eax, [4+global_x] |
mov [ebp+X_OFFSET], eax |
; init y |
mov eax, [4+global_y] |
mov [ebp+Y_OFFSET], eax |
; init x speed |
call rand |
and eax, 31 |
sub eax, 15 |
;shl ax, 6 |
mov [ebp+X_SPEED_OFFSET], eax |
; init y speed |
call rand |
and eax, 31 |
sub eax, 15 |
;shl ax, 6 |
mov [ebp+Y_SPEED_OFFSET], eax |
; init color |
; mov ax, 255 |
;call rand |
;and ax, 0xFF |
mov [ebp+COLOR_OFFSET], dword 255;ax |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; Misc. Functions |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
rand: |
mov eax, [8+seed] |
imul eax, 214013 |
add eax, 2531011 |
mov [8+seed], eax |
shr eax, 16 |
ret |
; DATA AREA |
; Application Title |
labelt db 'Firework demo',0 |
;labelt db 'Matrix demo',0 |
;seed: dd 0 |
;global_x: dd 160*64 |
;global_y: dd 100*64 |
sub_mask: dd 0x01010101, 0x01010101 |
; x, y, x_speed, y_speed, color |
particles: times NUM_PARTS dd 0, 0, 0, 0, 0 |
blur_right_flag: dd 0 |
;include 'Dex.inc' |
I_END: |
pal rb 256*4 ;dup(0) |
;pal dd 256 dup(0) |
;buffer rb 1024*64 |
buffer rb SCREEN_WIDTH*SCREEN_HEIGHT |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/firework/trunk/proc32.inc |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/unvwater/trunk/aspapi.inc |
---|
0,0 → 1,142 |
include 'proc32.inc' |
macro start_draw_window x,y,xsize,ysize,areacolor,caption;,capsize |
{ |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 48 ; function 48.4 : get skin height |
mov ebx, 4 |
int 0x40 |
push eax |
lea ecx, [y*65536+ysize+eax]; [y start] *65536 + [y size] + [skin_height] |
xor eax, eax ; function 0 : define and draw window |
mov ebx, x*65536+xsize ; [x start] *65536 + [x size] |
mov edx, areacolor ; color of work area RRGGBB |
;mov esi, 0x00334455 ; color of grab bar RRGGBB |
mov edi, caption;0x00ddeeff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
;mov eax, 4 ; function 4 : write text to window |
;mov ebx, 8*65536+8 ; [x start] *65536 + [y start] |
;mov ecx, 0x00ffffff ; color of text RRGGBB |
;mov edx, caption ; pointer to text beginning |
;mov esi, capsize ; text length |
;mov eax, 71 ; function 71.1 |
;mov ebx, 1 ; set window caption |
;mov ecx, caption ; pointer to text |
;int 0x40 |
pop eax |
} |
macro end_draw_window |
{ |
mov eax, 12 ; end of redraw |
mov ebx, 2 |
int 0x40 |
} |
proc draw_button stdcall, x:dword, y:dword, xsize:dword, ysize:dword, \ |
id:dword, butcolor:dword, text:dword, textlen:byte, textcolor:dword |
;pusha |
mov ebx, dword [x] |
shl ebx, 16 |
add ebx, dword [xsize] ; [x start] *65536 + [x size] |
mov ecx, dword [y] |
shl ecx, 16 |
add ecx, dword [ysize] ; [y start] *65536 + [y size] |
mov edx, dword [id] ; button id |
mov esi, dword [butcolor] ; button color RRGGBB |
mov eax, 8 ; function 8 : define and draw button |
int 0x40 |
mov ebx, dword [x] |
add ebx, 5 |
shl ebx, 16 |
mov eax, dword [ysize] |
sub eax, 5 |
shr eax, 1 |
add ebx, eax |
add ebx, dword [y] ;mov ebx, (x+5)*65536+y+(ysize-5)/2 ; Draw button text |
mov ecx, dword [textcolor] |
mov edx, dword [text] |
xor eax, eax |
mov al, byte [textlen] |
mov esi, eax |
mov eax, 4 |
int 0x40 |
;popa |
ret |
endp |
macro outtextxy x,y,prompt,prompt_len,color |
{ |
pusha |
mov ebx, x*65536+y ; draw info text with function 4 |
mov ecx, color |
mov edx, prompt |
xor eax, eax |
mov al, prompt_len |
mov esi, eax |
mov eax, 4 |
int 0x40 |
popa |
} |
;proc bar x:dword, y:dword, xsize:dword, ysize:dword, color:dword |
macro bar x, y, xsize, ysize, color |
{ |
pusha |
mov eax, 13 |
;mov ebx, [x] |
;shl ebx, 16 |
;add ebx, [xsize] |
;mov ecx, [y] |
;shl ecx, 16 |
;add ecx, [ysize] |
;mov edx, [color] |
mov ebx, x*65536+xsize |
mov ecx, y*65536+ysize |
mov edx, color |
int 0x40 |
popa |
;ret |
;endp |
} |
macro line x1,y1,x2,y2,color |
{ |
pusha |
mov eax, 38 |
mov ebx, x1*65536+x2 |
mov ecx, y1*65536+y2 |
mov edx, color |
int 0x40 |
popa |
} |
macro rectangle x,y,xsize,ysize,color |
{ |
x2=x+xsize |
y2=y+ysize |
line x,y,x2,y,color |
line x,y,x,y2,color |
line x,y2,x2,y2,color |
line x2,y,x2,y2,color |
} |
macro putpixel x,y,color |
{ |
mov eax, 1 |
mov ebx, x |
mov ecx, y |
mov edx, color |
int 0x40 |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/unvwater/trunk/proc32.inc |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/unvwater/trunk/unvwater.asm |
---|
0,0 → 1,159 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; A unvwater demo |
; Programmed by Octavio Vega Fernandez |
; http://octavio.vega.fernandez.googlepages.com/CV4.HTM |
; Converted to KolibriOS, By Asper |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd STARTAPP ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include "aspAPI.inc" |
SCREEN_WIDTH equ 100h |
SCREEN_HEIGHT equ 100h |
STARTAPP: |
mov eax, 18 ;Get CPU speed |
mov ebx, 5 |
int 0x40 |
shr eax, 28 |
mov dword [delay], eax |
init_palette: |
mov edi, Paleta |
;xor eax, eax |
mov eax, 0x40 |
@@: |
stosd |
inc al |
jnz @b |
MAIN: |
l1: |
xor esi, esi |
l11: |
xor ebx, ebx |
mov edx, 303h |
sub esi, 101h |
l2: |
and esi, 0xFFFF ;esi=si |
add bl, [esi+img] |
adc bh, ah |
inc esi |
dec dh |
jnz l2 |
mov dh, 3 |
add esi, 100h-3 |
dec dl |
jnz l2 |
sub esi, 1ffh |
and esi, 0xFFFF ;esi=si |
mov al, [img+esi] |
sub bx, ax |
shl ax, 2 |
sub bx, ax |
shr bx, 2 |
mov ax, bx |
shr ax, 7 |
sub bx, ax |
mov [img+esi], bl |
inc si |
jnz l11 |
call copy_buffer_to_video |
still: |
mov eax, 11 ; Test if there is an event in the queue. |
int 0x40 |
cmp al,1 ; redraw request ? |
jz red |
cmp al,2 ; key in buffer ? |
jz key |
cmp al,3 ; button in buffer ? |
jz button |
jmp MAIN |
red: |
call draw_window |
jmp MAIN |
key: |
mov eax, 2 |
int 0x40 |
cmp ah, 27 ; Test Esc in ASCII |
je close_app |
jmp MAIN |
button: |
mov eax, 17 ; Get pressed button code |
int 0x40 |
cmp ah, 1 ; Test x button |
je close_app |
jmp MAIN |
draw_window: |
start_draw_window 100,70,SCREEN_WIDTH+10,SCREEN_HEIGHT+5,0x14224466,labelt;, 14;labellen-labelt |
mov dword [skin_h], eax |
end_draw_window |
ret |
fail: |
; Type something here. |
close_app: |
mov eax, -1 ; close this program |
int 0x40 |
copy_buffer_to_video: |
pusha |
; mov eax, 18 ;@WAITVSYNC(); |
; mov ebx, 14 |
; int 0x40 |
mov eax, 5 ;delay |
mov ebx, dword [delay] |
int 0x40 |
mov eax, dword [skin_h] |
lea edx, [5*65536+eax] |
mov eax, 65 |
mov ebx, img |
mov ecx, SCREEN_WIDTH*65536+SCREEN_HEIGHT ;ecx = w*65536+h |
; mov edx, 5*65536+25 ;edx = x*65536+y |
mov esi, 8 |
mov edi, Paleta |
xor ebp, ebp |
int 0x40 |
popa |
ret |
; DATA AREA |
; Application Title |
labelt db 'UnvWater demo',0 |
delay dd 0 |
skin_h dd 25 ; Skin height. |
I_END: |
Paleta rb 1024 |
img db 1 |
rb 10000h |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |