Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1546 → Rev 1547

/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