/programs/build_all.bat |
---|
81,6 → 81,7 |
fasm system\ss\trunk\@ss.asm %BIN%\@ss |
fasm system\vrr\trunk\vrr.asm %BIN%\vrr |
fasm system\vrr_m\trunk\vrr_m.asm %BIN%\vrr_m |
fasm system\zkey\trunk\zkey.asm %BIN%\zkey |
echo * |
echo Building develop |
211,6 → 212,7 |
fasm demos\eyes\trunk\eyes.asm %BIN%\demos\eyes |
fasm demos\fire\trunk\fire.asm %BIN%\demos\fire |
fasm demos\fire2\trunk\fire2.asm %BIN%\demos\fire2 |
fasm demos\firework\trunk\firework.asm %BIN%\demos\firework |
fasm demos\free3d04\trunk\free3d04.asm %BIN%\3d\free3d04 |
fasm demos\magnify\trunk\magnify.asm %BIN%\magnify |
fasm demos\movback\trunk\movback.asm %BIN%\demos\movback |
220,6 → 222,7 |
fasm demos\transp\trunk\transp.asm %BIN%\demos\transp |
fasm demos\trantest\trunk\trantest.asm %BIN%\demos\trantest |
fasm demos\tube\trunk\tube.asm %BIN%\demos\tube |
fasm demos\unvwater\trunk\unvwater.asm %BIN%\demos\unvwater |
erase lang.inc |
270,6 → 273,7 |
kpack %BIN%\@ss |
kpack %BIN%\vrr |
kpack %BIN%\vrr_m |
kpack %BIN%\zkey |
echo * |
echo Compressing develop |
395,6 → 399,7 |
kpack %BIN%\demos\eyes |
kpack %BIN%\demos\fire |
kpack %BIN%\demos\fire2 |
kpack %BIN%\demos\firework |
kpack %BIN%\3d\free3d04 |
kpack %BIN%\magnify |
kpack %BIN%\demos\movback |
404,6 → 409,7 |
kpack %BIN%\demos\transp |
kpack %BIN%\demos\trantest |
kpack %BIN%\demos\tube |
kpack %BIN%\demos\unvwater |
echo * |
echo Compressing complete |
/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 |
/programs/system/zkey/trunk/ASPAPI.INC |
---|
0,0 → 1,136 |
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 |
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/system/zkey/trunk/ZKEY.ASM |
---|
0,0 → 1,456 |
; |
; ZKEY. Version 0.5. |
; Virtual keyboard for KolibriOS. |
; |
; Author: Asper |
; Date of issue: 26.08.2009 |
; Compiler: FASM |
; Target: KolibriOS |
; |
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" |
N_KEYCOLOR equ 0x00677889 ; Normal button color |
C_KEYCOLOR equ 0x00344556 ; Control button color |
L_KEYCOLOR equ 0x00258778 ; Lock button color |
TEXTCOLOR equ 0x00FFFFFF ; Button caption color |
STARTAPP: |
mov ecx, 1 ; to send scancodes. |
call set_keyboard_mode |
call reload_ascii_keymap |
call draw_window |
jmp get_zkey_window_slot_number |
draw_window: |
test byte [red_type], 1 |
jnz @f |
test byte [red_type], 2 |
jnz .draw_switch_button |
start_draw_window 100,370,600,210,0x04224466,labelt, 35;labellen-labelt |
stdcall draw_button, 15,50,23,20,2,N_KEYCOLOR,keyText,3,TEXTCOLOR ; Esc |
stdcall draw_button, 70,50,23,20,3,N_KEYCOLOR,keyText+3,2,TEXTCOLOR ; F1 |
stdcall draw_button, 95,50,23,20,4,N_KEYCOLOR,keyText+5,2,TEXTCOLOR ; F2 |
stdcall draw_button, 120,50,23,20,5,N_KEYCOLOR,keyText+7,2,TEXTCOLOR ; F3 |
stdcall draw_button, 145,50,23,20,6,N_KEYCOLOR,keyText+9,2,TEXTCOLOR ; F4 |
stdcall draw_button, 183,50,23,20,7,N_KEYCOLOR,keyText+11,2,TEXTCOLOR ; F5 |
stdcall draw_button, 208,50,23,20,8,N_KEYCOLOR,keyText+13,2,TEXTCOLOR ; F6 |
stdcall draw_button, 233,50,23,20,9,N_KEYCOLOR,keyText+15,2,TEXTCOLOR ; F7 |
stdcall draw_button, 258,50,23,20,10,N_KEYCOLOR,keyText+17,2,TEXTCOLOR ; F8 |
stdcall draw_button, 296,50,23,20,11,N_KEYCOLOR,keyText+19,2,TEXTCOLOR ; F9 |
stdcall draw_button, 321,50,23,20,12,N_KEYCOLOR,keyText+21,3,TEXTCOLOR ; F10 |
stdcall draw_button, 346,50,23,20,13,N_KEYCOLOR,keyText+24,3,TEXTCOLOR ; F11 |
stdcall draw_button, 371,50,23,20,14,N_KEYCOLOR,keyText+27,3,TEXTCOLOR ; F12 |
@@: |
stdcall draw_button, 15,80,23,20,15,N_KEYCOLOR,ascii_keymap+41,1,TEXTCOLOR ;keyText+30,2,TEXTCOLOR ; ~ð |
stdcall draw_button, 40,80,23,20,16,N_KEYCOLOR,ascii_keymap+2,1,TEXTCOLOR ;keyText+32,2,TEXTCOLOR ; 1! |
stdcall draw_button, 65,80,23,20,17,N_KEYCOLOR,ascii_keymap+3,1,TEXTCOLOR ;keyText+34,2,TEXTCOLOR ; 2@ |
stdcall draw_button, 90,80,23,20,18,N_KEYCOLOR,ascii_keymap+4,1,TEXTCOLOR ;keyText+36,2,TEXTCOLOR ; 3# |
stdcall draw_button, 115,80,23,20,19,N_KEYCOLOR,ascii_keymap+5,1,TEXTCOLOR ;keyText+38,2,TEXTCOLOR ; 4$ |
stdcall draw_button, 140,80,23,20,20,N_KEYCOLOR,ascii_keymap+6,1,TEXTCOLOR ;keyText+40,2,TEXTCOLOR ; 5% |
stdcall draw_button, 165,80,23,20,21,N_KEYCOLOR,ascii_keymap+7,1,TEXTCOLOR ;keyText+42,2,TEXTCOLOR ; 6^ |
stdcall draw_button, 190,80,23,20,22,N_KEYCOLOR,ascii_keymap+8,1,TEXTCOLOR ;keyText+44,2,TEXTCOLOR ; 7& |
stdcall draw_button, 215,80,23,20,23,N_KEYCOLOR,ascii_keymap+9,1,TEXTCOLOR ;keyText+46,2,TEXTCOLOR ; 8* |
stdcall draw_button, 240,80,23,20,24,N_KEYCOLOR,ascii_keymap+10,1,TEXTCOLOR ;keyText+48,2,TEXTCOLOR ; 9( |
stdcall draw_button, 265,80,23,20,25,N_KEYCOLOR,ascii_keymap+11,1,TEXTCOLOR ;keyText+50,2,TEXTCOLOR ; 0) |
stdcall draw_button, 290,80,23,20,26,N_KEYCOLOR,ascii_keymap+12,1,TEXTCOLOR ;keyText+52,2,TEXTCOLOR ; -_ |
stdcall draw_button, 315,80,23,20,27,N_KEYCOLOR,ascii_keymap+13,1,TEXTCOLOR ;keyText+54,2,TEXTCOLOR ; =+ |
stdcall draw_button, 340,80,23,20,28,N_KEYCOLOR,ascii_keymap+43,1,TEXTCOLOR ;keyText+56,2,TEXTCOLOR ; \| |
stdcall draw_button, 365,80,30,20,29,N_KEYCOLOR,keyText+58,4,TEXTCOLOR ; bksp |
stdcall draw_button, 15 ,103,33,20,30,N_KEYCOLOR,keyText+62,3,TEXTCOLOR ; Tab |
stdcall draw_button, 50 ,103,23,20,31,N_KEYCOLOR,ascii_keymap+16,1,TEXTCOLOR ;keyText+65,2,TEXTCOLOR ; Q |
stdcall draw_button, 75 ,103,23,20,32,N_KEYCOLOR,ascii_keymap+17,1,TEXTCOLOR ;keyText+67,2,TEXTCOLOR ; W |
stdcall draw_button, 100,103,23,20,33,N_KEYCOLOR,ascii_keymap+18,1,TEXTCOLOR ;keyText+69,2,TEXTCOLOR ; E |
stdcall draw_button, 125,103,23,20,34,N_KEYCOLOR,ascii_keymap+19,1,TEXTCOLOR ;keyText+71,2,TEXTCOLOR ; R |
stdcall draw_button, 150,103,23,20,35,N_KEYCOLOR,ascii_keymap+20,1,TEXTCOLOR ;keyText+73,2,TEXTCOLOR ; T |
stdcall draw_button, 175,103,23,20,36,N_KEYCOLOR,ascii_keymap+21,1,TEXTCOLOR ;keyText+75,2,TEXTCOLOR ; Y |
stdcall draw_button, 200,103,23,20,37,N_KEYCOLOR,ascii_keymap+22,1,TEXTCOLOR ;keyText+77,2,TEXTCOLOR ; U |
stdcall draw_button, 225,103,23,20,38,N_KEYCOLOR,ascii_keymap+23,1,TEXTCOLOR ;keyText+79,2,TEXTCOLOR ; I |
stdcall draw_button, 250,103,23,20,39,N_KEYCOLOR,ascii_keymap+24,1,TEXTCOLOR ;keyText+81,2,TEXTCOLOR ; O |
stdcall draw_button, 275,103,23,20,40,N_KEYCOLOR,ascii_keymap+25,1,TEXTCOLOR ;keyText+83,2,TEXTCOLOR ; P |
stdcall draw_button, 300,103,23,20,41,N_KEYCOLOR,ascii_keymap+26,1,TEXTCOLOR ;keyText+85,3,TEXTCOLOR ; [{ |
stdcall draw_button, 325,103,23,20,42,N_KEYCOLOR,ascii_keymap+27,1,TEXTCOLOR ;keyText+88,3,TEXTCOLOR ; ]} |
stdcall draw_button, 350,103,45,43,43,N_KEYCOLOR,keyText+91,5,TEXTCOLOR ; Enter |
stdcall draw_button, 15 ,126,43,20,44,L_KEYCOLOR,keyText+96 ,4,TEXTCOLOR ; lock |
stdcall draw_button, 60 ,126,23,20,45,N_KEYCOLOR,ascii_keymap+30,1,TEXTCOLOR ;keyText+100,2,TEXTCOLOR ; A |
stdcall draw_button, 85 ,126,23,20,46,N_KEYCOLOR,ascii_keymap+31,1,TEXTCOLOR ;keyText+102,2,TEXTCOLOR ; S |
stdcall draw_button, 110,126,23,20,47,N_KEYCOLOR,ascii_keymap+32,1,TEXTCOLOR ;keyText+104,2,TEXTCOLOR ; D |
stdcall draw_button, 135,126,23,20,48,N_KEYCOLOR,ascii_keymap+33,1,TEXTCOLOR ;keyText+106,2,TEXTCOLOR ; F |
stdcall draw_button, 160,126,23,20,49,N_KEYCOLOR,ascii_keymap+34,1,TEXTCOLOR ;keyText+108,2,TEXTCOLOR ; G |
stdcall draw_button, 185,126,23,20,50,N_KEYCOLOR,ascii_keymap+35,1,TEXTCOLOR ;keyText+110,2,TEXTCOLOR ; H |
stdcall draw_button, 210,126,23,20,51,N_KEYCOLOR,ascii_keymap+36,1,TEXTCOLOR ;keyText+112,2,TEXTCOLOR ; J |
stdcall draw_button, 235,126,23,20,52,N_KEYCOLOR,ascii_keymap+37,1,TEXTCOLOR ;keyText+114,2,TEXTCOLOR ; K |
stdcall draw_button, 260,126,23,20,53,N_KEYCOLOR,ascii_keymap+38,1,TEXTCOLOR ;keyText+116,2,TEXTCOLOR ; L |
stdcall draw_button, 285,126,23,20,54,N_KEYCOLOR,ascii_keymap+39,1,TEXTCOLOR ;keyText+118,3,TEXTCOLOR ; ;: |
stdcall draw_button, 310,126,23,20,55,N_KEYCOLOR,ascii_keymap+40,1,TEXTCOLOR ;keyText+121,3,TEXTCOLOR ; '" |
stdcall draw_button, 15 ,149,53,20,56,C_KEYCOLOR,keyText+124,5,TEXTCOLOR ; Shift |
stdcall draw_button, 70 ,149,23,20,57,N_KEYCOLOR,ascii_keymap+44,1,TEXTCOLOR ;keyText+129,2,TEXTCOLOR ; Z |
stdcall draw_button, 95 ,149,23,20,58,N_KEYCOLOR,ascii_keymap+45,1,TEXTCOLOR ;keyText+131,2,TEXTCOLOR ; X |
stdcall draw_button, 120,149,23,20,59,N_KEYCOLOR,ascii_keymap+46,1,TEXTCOLOR ;keyText+133,2,TEXTCOLOR ; C |
stdcall draw_button, 145,149,23,20,60,N_KEYCOLOR,ascii_keymap+47,1,TEXTCOLOR ;keyText+135,2,TEXTCOLOR ; V |
stdcall draw_button, 170,149,23,20,61,N_KEYCOLOR,ascii_keymap+48,1,TEXTCOLOR ;keyText+137,2,TEXTCOLOR ; B |
stdcall draw_button, 195,149,23,20,62,N_KEYCOLOR,ascii_keymap+49,1,TEXTCOLOR ;keyText+139,2,TEXTCOLOR ; N |
stdcall draw_button, 220,149,23,20,63,N_KEYCOLOR,ascii_keymap+50,1,TEXTCOLOR ;keyText+141,2,TEXTCOLOR ; M |
stdcall draw_button, 245,149,23,20,64,N_KEYCOLOR,ascii_keymap+51,1,TEXTCOLOR ;keyText+143,3,TEXTCOLOR ; ,< |
stdcall draw_button, 270,149,23,20,65,N_KEYCOLOR,ascii_keymap+52,1,TEXTCOLOR ;keyText+146,3,TEXTCOLOR ; .> |
stdcall draw_button, 295,149,23,20,66,N_KEYCOLOR,ascii_keymap+53,1,TEXTCOLOR ;keyText+149,2,TEXTCOLOR ; /? |
test byte [red_type], 1 |
jnz @f |
stdcall draw_button, 320,149,75,20,67,C_KEYCOLOR,keyText+151,5,TEXTCOLOR ; Shift |
stdcall draw_button, 15 ,172,30,20,68,C_KEYCOLOR,keyText+156,4,TEXTCOLOR ; Ctrl |
stdcall draw_button, 47 ,172,30,20,69,C_KEYCOLOR,keyText+160,3,TEXTCOLOR ; Win |
stdcall draw_button, 79 ,172,30,20,70,C_KEYCOLOR,keyText+163,3,TEXTCOLOR ; Alt |
stdcall draw_button, 111,172,156,20,71,N_KEYCOLOR,keyText+166,1,TEXTCOLOR ; Space |
stdcall draw_button, 269,172,30,20,72,C_KEYCOLOR,keyText+167,3,TEXTCOLOR ; Alt |
stdcall draw_button, 301,172,30,20,73,C_KEYCOLOR,keyText+170,3,TEXTCOLOR ; Win |
stdcall draw_button, 333,172,30,20,74,C_KEYCOLOR,keyText+173,3,TEXTCOLOR ; [=] |
stdcall draw_button, 365,172,30,20,75,C_KEYCOLOR,keyText+176,4,TEXTCOLOR ; Ctrl |
stdcall draw_button, 405,50 ,23,20,76,N_KEYCOLOR,keyText+180,3,TEXTCOLOR ; psc |
stdcall draw_button, 430,50 ,23,20,77,L_KEYCOLOR,keyText+183,3,TEXTCOLOR ; slk |
stdcall draw_button, 455,50 ,23,20,78,N_KEYCOLOR,keyText+186,3,TEXTCOLOR ; brk |
stdcall draw_button, 405,80 ,23,20,79,N_KEYCOLOR,keyText+189,3,TEXTCOLOR ; Ins |
stdcall draw_button, 430,80 ,23,20,80,N_KEYCOLOR,keyText+192,2,TEXTCOLOR ; Hm |
stdcall draw_button, 455,80 ,23,20,81,N_KEYCOLOR,keyText+194,3,TEXTCOLOR ; Pup |
stdcall draw_button, 405,103 ,23,20,82,N_KEYCOLOR,keyText+197,3,TEXTCOLOR ; Del |
stdcall draw_button, 430,103 ,23,20,83,N_KEYCOLOR,keyText+200,3,TEXTCOLOR ; End |
stdcall draw_button, 455,103 ,23,20,84,N_KEYCOLOR,keyText+203,3,TEXTCOLOR ; Pdn |
stdcall draw_button, 430,149,23,20,85,C_KEYCOLOR,keyText+206,1,TEXTCOLOR ; ^ |
stdcall draw_button, 405,172,23,20,86,C_KEYCOLOR,keyText+207,1,TEXTCOLOR ; v |
stdcall draw_button, 430,172,23,20,87,C_KEYCOLOR,keyText+208,1,TEXTCOLOR ; < |
stdcall draw_button, 455,172,23,20,88,C_KEYCOLOR,keyText+209,2,TEXTCOLOR ; > |
stdcall draw_button, 488,80 ,23,20,89,L_KEYCOLOR,keyText+211,3,TEXTCOLOR ; nlk |
stdcall draw_button, 513,80 ,23,20,90,N_KEYCOLOR,keyText+214,1,TEXTCOLOR ; / |
stdcall draw_button, 538,80 ,23,20,91,N_KEYCOLOR,keyText+215,1,TEXTCOLOR ; * |
stdcall draw_button, 563,80 ,23,20,92,N_KEYCOLOR,keyText+216,1,TEXTCOLOR ; - |
stdcall draw_button, 488,103 ,23,20,93,N_KEYCOLOR,keyText+217,1,TEXTCOLOR ; 7 |
stdcall draw_button, 513,103 ,23,20,94,N_KEYCOLOR,keyText+218,1,TEXTCOLOR ; 8 |
stdcall draw_button, 538,103 ,23,20,95,N_KEYCOLOR,keyText+219,1,TEXTCOLOR ; 9 |
stdcall draw_button, 488,126,23,20,96,N_KEYCOLOR,keyText+220,1,TEXTCOLOR ; 4 |
stdcall draw_button, 513,126,23,20,97,N_KEYCOLOR,keyText+221,1,TEXTCOLOR ; 5 |
stdcall draw_button, 538,126,23,20,98,N_KEYCOLOR,keyText+222,1,TEXTCOLOR ; 6 |
stdcall draw_button, 488,149,23,20,99,N_KEYCOLOR,keyText+223,1,TEXTCOLOR ; 1 |
stdcall draw_button, 513,149,23,20,100,N_KEYCOLOR,keyText+224,1,TEXTCOLOR ; 2 |
stdcall draw_button, 538,149,23,20,101,N_KEYCOLOR,keyText+225,1,TEXTCOLOR ; 3 |
stdcall draw_button, 488,172,48,20,102,N_KEYCOLOR,keyText+226,1,TEXTCOLOR ; 0 |
stdcall draw_button, 538,172,23,20,103,N_KEYCOLOR,keyText+227,1,TEXTCOLOR ; . |
stdcall draw_button, 563,103 ,23,43,104,N_KEYCOLOR,keyText+228,1,TEXTCOLOR ; + |
stdcall draw_button, 563,149,23,43,105,N_KEYCOLOR,keyText+229,3,TEXTCOLOR ; Ent |
.draw_switch_button: |
mov eax, 6 |
mul byte [keyboard_mode] |
add eax, SwitchText |
stdcall draw_button, 513,28,46,20,106,0x00700000,eax,6,TEXTCOLOR ; Scan/ASCII switch |
@@: |
.draw_indicators_area: |
call lights_on |
mov byte [red_type], 0 |
end_draw_window |
ret |
get_zkey_window_slot_number: |
mov eax, 18 |
mov ebx, 7 |
int 0x40 |
mov [zkey_window], eax |
set_event_mask: |
mov eax, 40 |
mov ebx, 39 |
int 0x40 |
still: |
call get_receiver_window_slot_number |
mov eax, 10 ; Wait for 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 still |
red: |
call draw_window |
jmp still |
key: |
mov eax, 2 |
int 0x40 |
; push ax |
call get_control_keys_state |
cmp [locks], ax |
je @f |
.reload: |
call reload_ascii_keymap |
mov byte [red_type], 1 |
call draw_window |
@@: |
; pop dx |
; jmp button.select_key_code |
jmp still |
button: |
mov eax, 17 ; Get pressed button code |
int 0x40 |
cmp ah, 1 ; Test x button |
je close_app |
cmp ah, 106 ; Test Scan/ASCII switch button |
jne .keyboard_keys |
mov cl, 1 |
sub cl, byte [keyboard_mode] |
call set_keyboard_mode |
mov byte [red_type], 2 |
jmp red |
.keyboard_keys: |
cmp ah, 2 ; Test if pressed buttons |
jb still ; is a ZKEY keyboard key... |
cmp ah, 106 |
jnb still ; ...so, if not then still, |
mov [butt], ah ; if yes then save pressed button ID |
.test_slot: |
mov eax, [zkey_window] ; Test is receiver ZKEY window |
mov ecx, [receiver_window] |
cmp eax, ecx |
je still ; if yes still. |
.activate_receiver_window: |
mov eax, 18 |
mov ebx, 3 |
int 0x40 |
call reload_ascii_keymap |
.read_key_scancode: |
xor edx, edx |
movzx si, byte [butt] ; Read scan code of the key from the table. |
sub si, 2 |
mov dl, [keyCodes+si] ; Set dl = scancode of the key corresponding to the pressed button. |
cmp dl, 0xA0 |
jb .select_key_code ; If not extended key then select ascii or scan to send and then send it to the receiver. |
cmp dl, 0xA6 ; Test if it's extended2 key |
jne .read_ext_key ; if not go to prepare to send simply extended key. |
mov dl, 0xE1 ; Send extended2 scancode... |
call send_key |
mov dl, 0x1D ; ...and extended scancode, |
call send_key ; |
mov dl, [keyCodes.ext2] ; (There is only one ext2 key - 'Break') |
jmp .send_key_code ; so... send it's normal scan code. |
.read_ext_key: |
sub dl, 0xA0 ; Read extended key scan code from the table. |
movzx si, dl |
mov dl, [keyCodes.ext+si] |
.send_ext: |
push dx ; Send extended scancode to the receiver's window. |
mov dl, 0xE0 |
call send_key |
pop dx |
; jmp .send_key_code |
.select_key_code: ; Select what to send ASCII or scan. |
cmp [keyboard_mode], 0 ; Test if ZKEY must send ASCII. |
jne .send_key_code |
; mov esi, ext0 ; Set esi to the beginning of the ext0 table. |
and edx, 0x7F |
; @@: |
; cmp dl, byte [esi] |
; je .send_key_code |
; inc esi |
; cmp esi, ext0end |
; jng @b |
.read_ascii: |
mov dl, byte [ascii_keymap+edx] ; Read ASCII from the keymap table. |
.send_key_code: |
call send_key ; Finally send the key to the receiver's window. |
.wait: |
mov eax, 5 |
mov ebx, 1 ; Wait 0.01 second. |
int 0x40 |
.activate_zkey_window: |
mov eax, 18 |
mov ebx, 3 |
mov ecx, [zkey_window] |
int 0x40 |
jmp still |
close_app: |
mov eax,-1 ; close this program |
int 0x40 |
;********************************** |
;* input: ecx = type of mode * |
;********************************** |
set_keyboard_mode: |
mov eax, 66 |
mov ebx, 1 ; Set keyboard mode |
int 0x40 |
mov [keyboard_mode], cl |
ret |
get_control_keys_state: ; This routine works only in Scan keyboard mode. |
mov eax, 66 |
mov ebx, 3 |
int 0x40 |
ret |
;********************************** |
;* input: ecx = type of map * |
;********************************** |
get_keyboard_map: |
mov eax, 26 |
mov ebx, 2 |
mov edx, ascii_keymap |
int 0x40 |
ret |
reload_ascii_keymap: |
call get_control_keys_state |
mov ecx, 1 |
test ax, 3 ; Shift pressed ? |
jnz @f |
test ax, 0x40 ; Caps Lock on ? |
jz .load_ascii_keymap |
@@: |
mov ecx, 2 |
.load_ascii_keymap: |
call get_keyboard_map |
ret |
get_receiver_window_slot_number: |
mov eax, 18 |
mov ebx, 7 |
int 0x40 |
mov ebx, [zkey_window] |
cmp eax, ebx |
je @f |
mov [receiver_window], eax |
@@: |
ret |
;************************************ |
;* input: edx = code of the key * |
;************************************ |
send_key: |
mov eax, 72 |
mov ebx, 1 |
mov ecx, 2 |
int 0x40 |
ret |
lights_on: |
bar 491,51,95,15,0 ; indicators area |
rectangle 490,50,96,16,TEXTCOLOR |
call get_control_keys_state |
mov [locks], ax |
test ax, 0x40 |
jz @f |
;stdcall bar, 532, 53, 10, 11, 0x0000FF00 |
bar 532, 53, 10, 11, 0x0000FF00 |
@@: |
test ax, 0x80 |
jz @f |
;stdcall bar, 500, 53, 10, 11, 0x0000FF00 |
bar 500, 53, 10, 11, 0x0000FF00 |
@@: |
test ax, 0x100 |
jz @f |
;stdcall bar, 565, 53, 10, 11, 0x0000FF00 |
bar 565, 53, 10, 11, 0x0000FF00 |
@@: |
ret |
; DATA AREA |
; Application Title |
labelt db 'ZKEY v.0.5 - keyboard for KolibriOS' |
labellen: |
SwitchText db ' ASCII SCAN ' |
;Button names |
keyText db 'EscF1F2F3F4F5F6F7F8F9F10F11F12' |
db '~ð1!2@3#4$5%6^7&8*9(0)-_=+\|bksp' |
db 'TabQWERT YUIOP{[}]Enter' |
db 'lockASDFGHJKL;:''"' |
db 'ShiftZXCVBNM,<.>/?Shift' |
db 'CtrlWinAlt AltWin[=]Ctrl' |
db 'pscslkbrkInsHmPupDelEndPdn^<v >' |
db 'nlk/*-7894561230.+Ent' |
;Key scan codes |
keyCodes: |
db 0x01, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x57, 0x58 |
db 0x29, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x2B, 0x0E |
db 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C |
db 0x3A, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28 |
db 0x2A, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 |
db 0x1D, 0xA0, 0x38, 0x39, 0xA1, 0xA2, 0xA3, 0xA4 |
db 0xA5, 0x46, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0 |
db 0x45, 0xB1, 0x37, 0x4A, 0x47, 0x48, 0x49, 0x4B, 0x4C, 0x4D, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x4E, 0xB2 |
.ext: |
db 0x5B, 0x38, 0x5C, 0x5D, 0x1D |
db 0x37, 0x00, 0x52, 0x47, 0x49, 0x53, 0x4F, 0x51, 0x48, 0x4B, 0x50, 0x4D |
db 0x35, 0x1C |
.ext2 db 0x45 ; Just Break :) |
;ext0: |
; db 0x1D, 0x29, 0x2A, 0x36, 0x37, 0x38, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40 |
; db 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D |
; db 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x57, 0x58 |
;ext0end: |
receiver_window dd 0 ; Slot number of the receiver |
zkey_window dd 0 ; Slot number of ZKEY |
butt db 0 ; Pressed button ID |
locks dw 0 ; NumLock, CapsLock, ScrollLock lights mask |
keyboard_mode db 0 ; Scan or ASCII keys to send ? 0 - ASCII , 1 - Scan |
red_type db 0 ; Type of window redraw. 0 - default , 1 - on ASCII_keymap change , 2 - Switch button pressed. |
I_END: ; End of application code and data marker |
ascii_keymap: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/zkey/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 |