Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 108 → Rev 109

/programs/demos/3dcube2/trunk/3DCUBE2.ASM
0,0 → 1,691
;
; 3D POLYGONAL CUBE - ASCL
;
; Pavlushin Evgeni
; mail: waptap@mail.ru site: www.deck4.narod.ru
;
; Create on base 3D test sample
; Mikolaj Felix mfelix@polbox.com
;
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x30000 ; memory for app
dd 0x30000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
MAX_POINTS equ 8
MAX_TRIANGLES equ 12
SCREEN_X equ 320
SCREEN_Y equ 200
 
include 'lang.inc'
include 'ascl.inc'
include 'ascgl.inc'
include 'macros.inc'
START:
call draw_window
call init_sin_cos
 
still:
; mov eax,23 ; wait for system event with 10 ms timeout
; mov ebx,1 ; wait 10 ms, then continue
; int 0x40
 
mov eax,11
int 0x40
 
dec eax
; cmp eax,1 ; window redraw request ?
jz red
dec eax
; cmp eax,2 ; key in buffer ?
jz key
dec eax
; cmp eax,3 ; button in buffer ?
jz button
 
fps 280,8,cl_White,cl_Black
 
main_loop:
 
mov esi,object
mov edi,object_rotated
mov ecx,MAX_POINTS*3
cld
rep movsw
 
mov esi,angle_x
mov edi,object_rotated
mov ecx,MAX_POINTS
call rotate_points
 
mov esi,object_rotated
mov edi,object_translated
mov ecx,MAX_POINTS
call translate_points
 
call draw_faces
 
call clear_screen_buffer
 
add [angle_x],2
add [angle_y],3
add [angle_z],1
 
jmp still
 
red:
call draw_window
jmp still
key:
mov eax,2
int 0x40
jmp still
button:
mov eax,17
int 0x40
cmp ah,1
jne still
exit:
mov eax,-1
int 0x40
 
;Draw window
draw_window:
mov eax,12 ;Start
mov ebx,1
int 0x40
 
mov eax,0 ;Draw window
mov ebx,100*65536+(SCREEN_X+9) ;x start*65536+x size
mov ecx,100*65536+(SCREEN_Y+26) ;y start*65536+y size
mov edx,0x03000000 ;0x03 use skinned window
int 0x40
 
mov eax,4 ;Out Text
mov ebx,8*65536+8 ;x start*65536+y start
mov ecx,0x00ffffff ;color White
mov edx,head_label
mov esi,hl_end-head_label
int 0x40
 
mov eax,12 ;End
mov ebx,2
int 0x40
ret
 
head_label: db "3D TEST SAMPLE FOR MENUETOS"
hl_end:
 
 
 
; Draw faces procedure
 
draw_faces:
 
mov esi,link
mov ecx,MAX_TRIANGLES
df_draw:
push ecx
mov ecx,3
mov edi,@@tx1 ;bp
df_get_point:
xor bh,bh
mov bl,byte [esi]
shl bx,2
mov ax,word [object_translated+bx]
mov word [edi],ax
mov ax,word [object_translated+bx+2]
mov word [edi+2],ax
inc esi
add edi,4
dec ecx
jnz df_get_point
 
mov ax,[@@ty1]
sub ax,[@@ty3]
mov bx,[@@tx2]
sub bx,[@@tx1]
imul bx
shl edx,16
mov dx,ax
push edx
mov ax,[@@tx1]
sub ax,[@@tx3]
mov bx,[@@ty2]
sub bx,[@@ty1]
imul bx
shl edx,16
mov dx,ax
pop ebx
sub ebx,edx
or ebx,ebx
jge df_next
 
xor ah,ah
mov al,byte [si]
mov [@@xcol],ax
 
call filled_triangle
df_next:
inc si
pop ecx
dec ecx
jnz df_draw
ret
 
;modify
;include graphlib.asm
 
clear_screen_buffer:
 
;outscrbuf
mov ebx,scrbuf
mov ecx,SCREEN_X*65536+SCREEN_Y
mov edx,5*65536+22
mov ax,7
int 0x40
 
;White background
mov edi,scrbuf
mov ecx,(SCREEN_X*SCREEN_Y*3)/4
mov eax,0xffffffff
cld
rep stosd
 
ret
 
;include triangle.asm
; Mikolaj Felix 14/5/2001
; mfelix@polbox.com
 
;filled trangle procedure
 
@@tx1 dw 0
@@ty1 dw 0
@@tx2 dw 0
@@ty2 dw 0
@@tx3 dw 0
@@ty3 dw 0
@@xcol dw 0
 
@@dx12 dw 0
@@dx13 dw 0
@@dx23 dw 0
 
filled_triangle:
 
mov ax,[@@xcol] ;trnsforming color
mov bl,al ;byte bbbggrrx
mov dl,al ;to 3 byte
mov dh,al ;bbbxxxxx ggxxxxxx rrxxxxxx
and dh,00000001b
 
and al,11100000b
and bl,00011000b
and dl,00000110b
shl bl,3
shl dl,5
 
cmp dh,1
jne no_bitup
or al,00011111b
or bl,00111111b
or dl,00111111b
no_bitup:
 
shl eax,8 ;puck colors
mov al,bl
shl eax,8
mov al,dl
mov dword [@@rgb],eax
mov eax,0 ; for 16 bit instructions
 
mov ax,[@@ty1]
cmp ax,[@@ty3]
jb ft_check1
 
xchg ax,[@@ty3]
mov [@@ty1],ax
 
mov ax,[@@tx1]
xchg ax,[@@tx3]
mov [@@tx1],ax
ft_check1:
mov ax,[@@ty2]
cmp ax,[@@ty3]
jb ft_check2
 
xchg ax,[@@ty3]
mov [@@ty2],ax
 
mov ax,[@@tx2]
xchg ax,[@@tx3]
mov [@@tx2],ax
ft_check2:
mov ax,[@@ty1]
cmp ax,[@@ty2]
jb ft_check3
 
xchg ax,[@@ty2]
mov [@@ty1],ax
 
mov ax,[@@tx1]
xchg ax,[@@tx2]
mov [@@tx1],ax
ft_check3:
 
mov bx,[@@ty2]
sub bx,[@@ty1]
jnz ft_dx12_make
 
mov [@@dx12],word 0
jmp ft_dx12_done
ft_dx12_make:
mov ax,[@@tx2]
sub ax,[@@tx1]
shl ax,7
cwd
idiv bx
mov [@@dx12],ax ; dx12 = (x2-x1)/(y2-y1)
ft_dx12_done:
 
mov bx,[@@ty3]
sub bx,[@@ty1]
jnz ft_dx13_make
 
mov [@@dx13],word 0
jmp ft_dx13_done
ft_dx13_make:
mov ax,[@@tx3]
sub ax,[@@tx1]
shl ax,7
cwd
idiv bx
mov [@@dx13],ax ; dx13 = (x3-x1)/(y3-y1)
ft_dx13_done:
 
mov bx,[@@ty3]
sub bx,[@@ty2]
jnz ft_dx23_make
 
mov [@@dx23],word 0
jmp ft_dx23_done
ft_dx23_make:
mov ax,[@@tx3]
sub ax,[@@tx2]
shl ax,7
cwd
idiv bx
mov [@@dx23],ax ; dx23 = (x3-x2)/(y3-y2)
ft_dx23_done:
 
mov ax,[@@tx1]
shl ax,7
mov bx,ax
 
mov cx,[@@ty1]
ft_loop1:
 
pushad
 
mov [@@ly],cx
mov dx,bx
shr dx,7
mov [@@lx2],dx
mov dx,ax
shr dx,7
mov [@@lx1],dx
mov ax,[@@xcol]
mov [@@lcol],ax
call horizontal_line
 
popad
 
add ax,[@@dx13]
add bx,[@@dx12]
inc cx
cmp cx,[@@ty2]
jb ft_loop1
 
mov bx,[@@tx2]
shl bx,7
mov cx,[@@ty2]
ft_loop2:
 
pushad
 
mov [@@ly],cx
mov dx,bx
shr dx,7
mov [@@lx2],dx
mov dx,ax
shr dx,7
mov [@@lx1],dx
mov ax,[@@xcol]
mov [@@lcol],ax
call horizontal_line
 
popad
 
add ax,[@@dx13]
add bx,[@@dx23]
inc ecx
cmp cx,[@@ty3]
jb ft_loop2
 
ret
 
;horizontal line subproc
 
@@lx1 dw 0
@@lx2 dw 0
@@ly dw 0
@@lcol dw 0
 
@@rgb dd 0
 
horizontal_line:
 
mov ecx,0
mov cx,[@@lx1]
cmp cx,[@@lx2]
ja x12
je ext
; ret
mov cx,[@@lx2]
sub cx,[@@lx1]
mov edi,3
jmp xx
x12:
mov cx,[@@lx1]
sub cx,[@@lx2]
mov edi,-3
jmp xx
ext:
mov ecx,-1 ;1
; sub ebp,3
xx:
mov eax,0
mov ax,[@@ly]
mov ebx,SCREEN_X ;320
mul ebx
mov ebp,0
mov bp,[@@lx1] ;for correct 16 bit size
add eax,ebp
mov ebx,3
mul ebx
mov ebp,eax
sub ebp,3 ;for delete white dots
add ecx,2
loo:
 
mov eax,dword [@@rgb]
mov bl,al
shr eax,8 ;puck colors
 
mov byte [scrbuf+ebp],ah
mov byte [scrbuf+ebp+1],al
mov byte [scrbuf+ebp+2],bl
add ebp,edi
dec ecx
jnz loo
 
ret
 
;include fixed3d.asm
; Mikolaj Felix 25/5/2001
; mfelix@polbox.com
 
;------------------------------------------------------------
; ds:si - offset to angles
; ds:di - offset to 3d points
; cx - number of points
;------------------------------------------------------------
 
@@sin_x dw 0
@@cos_x dw 0
@@sin_y dw 0
@@cos_y dw 0
@@sin_z dw 0
@@cos_z dw 0
 
@@px equ word [edi]
@@py equ word [edi+2]
@@pz equ word [edi+4]
 
rotate_points:
 
push edi
mov edi,@@sin_x
mov edx,3
rp_sin_cos:
mov bx,word [esi]
and bx,511
shl bx,1
mov ax,word [sin_table+bx]
mov word [edi],ax
mov ax,word [cos_table+bx]
mov word [edi+2],ax
 
add esi,2
add edi,4
dec edx
jnz rp_sin_cos
pop edi
 
rp_rotate:
 
; rotate around x-axis
 
mov ax,@@py
imul [@@cos_x]
mov bx,ax
mov si,dx
 
mov ax,@@pz
imul [@@sin_x]
sub bx,ax
sbb si,dx
shrd bx,si,14
push bx
 
mov ax,@@py
imul [@@sin_x]
mov bx,ax
mov si,dx
 
mov ax,@@pz
imul [@@cos_x]
add bx,ax
adc si,dx
shrd bx,si,14
 
pop @@py
mov @@pz,bx
 
; rotate around y-axis
 
mov ax,@@px
imul [@@cos_y]
mov bx,ax
mov si,dx
 
mov ax,@@pz
imul [@@sin_y]
sub bx,ax
sbb si,dx
shrd bx,si,14
push bx
 
mov ax,@@px
imul [@@sin_y]
mov bx,ax
mov si,dx
 
mov ax,@@pz
imul [@@cos_y]
add bx,ax
adc si,dx
shrd bx,si,14
 
pop @@px
mov @@pz,bx
 
; rotate around z-axis
 
mov ax,@@px
imul [@@cos_z]
mov bx,ax
mov si,dx
 
mov ax,@@py
imul [@@sin_z]
sub bx,ax
sbb si,dx
shrd bx,si,14
push bx
 
mov ax,@@px
imul [@@sin_z]
mov bx,ax
mov si,dx
 
mov ax,@@py
imul [@@cos_z]
add bx,ax
adc si,dx
shrd bx,si,14
 
pop @@px
mov @@py,bx
 
add edi,6
dec ecx
jnz rp_rotate
 
ret
 
;------------------------------------------------------------
; ds:si - offset to 3d points
; es:di - offset to 2d points
; cx - number of points
;------------------------------------------------------------
 
mx dw 0
my dw 0
 
translate_points:
pushad
mov eax,37
mov ebx,1
int 0x40
mov ebx,eax
shr eax,16
and ebx,0xffff
cmp ax,SCREEN_X
jna x_n
mov ax,0 ;SCREEN_X
x_n:
cmp bx,SCREEN_Y
jna y_n
mov bx,0 ;SCREEN_Y
y_n:
mov [mx],ax
mov [my],bx
popad
 
mov ebx,0 ;?
mov bx,word [esi+4]
mov ax,[my]
cmp ax,0
jng no_m
shl ax,3
add bx,ax
no_m:
add bx,256 ; Z factor (zoom)
 
mov eax,0 ;?
mov ax,word [esi]
shl ax,8
cwd
idiv bx; bx
add ax,(SCREEN_X/2) ;160 ;X factor (center X)
stosw
 
mov eax,0 ;?
mov ax,word [esi+2]
shl ax,8
cwd
idiv bx
add ax,(SCREEN_Y/2) ;100 ;Y factor (center Y)
stosw
 
add esi,6
dec ecx
jnz translate_points
ret
 
init_sin_cos:
finit
fldz
fstp [temp]
xor edi,edi
mov ecx,512
isc_make:
fld [temp]
fld st0
fld st0
fsin
fmul [fixed_point_const]
fistp word [sin_table+edi]
fcos
fmul [fixed_point_const]
fistp word [cos_table+edi]
 
fadd [inc_angle]
fstp [temp]
 
add edi,2
loop isc_make
ret
 
temp dd 0
 
fixed_point_const dd 16384.0
inc_angle dd 0.01227184630309 ; pi/256
 
angle_x dw 0
angle_y dw 0
angle_z dw 0
 
object dw -50,-50,-50, 50,-50,-50, 50,50,-50, -50,50,-50
dw -50,-50, 50, 50,-50, 50, 50,50, 50, -50,50, 50
 
link:
db 0,1,2,10000011b, 0,2,3,10000011b ;purpure side
db 5,4,7,00000111b, 5,7,6,00000111b ;soft-red side
db 1,5,6,00011000b, 1,6,2,00011000b ;soft-lime side
db 4,0,3,11100001b, 4,3,7,11100001b ;soft-blue side
db 4,5,1,00011111b, 1,0,4,00011111b ;yellow side
db 3,2,6,00000000b, 3,6,7,00000000b ;black side
 
sin_table:
rw 512
cos_table:
rw 512
 
object_rotated:
rw MAX_POINTS*3
object_translated:
rw MAX_POINTS*2
 
scrbuf:
I_END:
/programs/demos/3dcube2/trunk/ascgl.inc
0,0 → 1,624
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.10 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by halyavin, add at ~07.06.2004
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
mov ecx,y
mov ebx,x
shl ebx,16
add ebx,xs
shl ecx,16
add ecx,ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+30
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,5*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
 
 
; COLLIMG - Collusion image's
_ldbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,_1dbounce,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_ldbounce_count=_ldbounce_count+1
if (_ldbounce_count = 1)
_1dbounce:
cmp ebx,eax
jnae anot
add eax,esi
cmp eax,ebx
jna nbc
jmp bc
anot:
add ebx,edi
cmp ebx,eax
jna nbc
bc:
mov ecx,1
ret
nbc:
mov ecx,0
ret
end if
bounce:
mov otv,1
exit:
}
 
; SETBMP - Set bmp to window
; (SYNTAX) SETBMP dd xstart ,dd ystart ,BMP_offset,dd soi
; (SAMPLE) SETBMP dword [xt],dword [yt],I_END,dword [tsoi]
; SETBMP 15,10,I_END,dword [tsoi]
; ( NOTE ) SOI - Start of image
 
macro setbmp arg1,arg2,arg3,arg4
{
local nodi
cmp word [arg3],word 'BM'
jne nodi
mov eax,7
mov ebx,arg4 ;[soi]
mov ecx,dword [arg3+18]
shl ecx,16
add ecx,dword [arg3+22]
if (arg1 eqtype 0) & (arg2 eqtype 0)
mov edx,arg1*65536+arg2
else
mov edx,arg1
shl edx,16
add edx,arg2
end if
int 0x40
nodi:
}
 
macro setimg arg1,arg2,arg3
{
local nodi
mov eax,7
mov ebx,arg3
add ebx,8
mov ecx,dword [arg3]
shl ecx,16
add ecx,dword [arg3+4]
if (arg1 eqtype 0) & (arg2 eqtype 0)
mov edx,arg1*65536+arg2
else
mov edx,arg1
shl edx,16
add edx,arg2
end if
int 0x40
}
 
;Not optimiz
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
mov eax,xs
mov dword [imgdest],eax
mov eax,ys
mov dword [imgdest+4],eax
 
mov eax,dword [imgsrc] ;getx size
mov edi,eax
mov ebx,y
mul ebx
add eax,x
mov ebx,3
mul ebx ;eax=offset on imsrc
 
mov ecx,0
mov ebx,0
mov ebp,eax
mov esi,0
 
add esi,8
add ebp,8
 
cyc:
mov al,byte [imgsrc+ebp]
mov [imgdest+esi],al
mov al,byte [imgsrc+ebp+1]
mov [imgdest+esi+1],al
mov al,byte [imgsrc+ebp+2]
mov [imgdest+esi+2],al
add esi,3
add ebp,3
inc ecx
cmp ecx,xs
jne cyc
add ebp,edi
add ebp,edi
add ebp,edi
sub ebp,xs
sub ebp,xs
sub ebp,xs
mov ecx,0
inc ebx
cmp ebx,ys
jne cyc
 
}
 
;
macro bmptoimg bmp_off,soi,img_off
{
local nodix,conv
cmp word [bmp_off],word 'BM'
jne nodix
mov eax,dword [bmp_off+18]
mov ebx,dword [bmp_off+22]
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ecx,[eax+2*eax]
lea edi,[img_off+8]
mov esi,dword [soi]
cld
rep movsb
nodix:
}
 
macro copyimg img2_off,img1_off
{
local cop
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
 
macro convbmp bmp_load_area,bmp_soi
{
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
local noaddword
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
mov ebx,32
div ebx
test edx,edx
je noaddword
inc eax
noaddword:
mov dword [dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmp_soi],ebx ;soi-start of image area for drawing
add eax, [bmp_load_area+10]
mov dword [sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmp_soi] ;initializing
mov esi,dword [eop]
sub esi,dword [bps]
 
 
nextstring:
push edi
cmp word [bmp_load_area+28],24
jne convertno32
 
mov ecx,[dwps]
cld
rep movsd
convert1:
pop edi
sub esi,dword [bps]
sub esi,dword [bps]
cmp esi,dword [sop]
jb end_bmp;nomorestring
add edi,eax
jmp nextstring
 
; nomorestring:
; jmp end_bmp
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bps]
mov dword [eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
convert2:
pop eax
inc esi
cmp esi,dword [eos]
jae convert1
add edi,3
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
cmp edx,0xffffffff
je convert2
add edi,3
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
mov dword [edi],edx
ret
 
 
; DATA AREA
 
;status dd 0 ;bit0=1 if file thread is created
bps dd 0
dwps dd 0
;soi dd 0
sop dd 0
eop dd 0
eos dd 0
;process dd 0
 
end_bmp:
; mov eax,dword [soi]
; mov dword [bmp_soi],eax
 
}
 
 
 
 
; LOADBMP - Load bmp image from file
; (SYNTAX) LOADBMP 'file_path',temp_area(rb 0x10000),load_area,dd soi
; (SAMPLE) LOADBMP '/rd/1/menuet.bmp',temp_area,I_END,tsoi
; ( NOTE ) Macros create on Base of
; Picture browser by lisovin@26.ru & Ivan Poddubny
; SOI - Start of image
 
macro loadbmp bmp_file_name,bmp_temp_area,bmp_load_area,bmp_soi
{
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
local noaddword
;local qwe,bmpfn
 
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[bmp_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
 
; jmp qwe
;bmpfn db bmp_file_name
;qwe:
; mov eax,6
; mov ebx,bmpfn
; mov ecx,0
; mov edx,0xFFFFFF
; mov esi,bmp_load_area
; mov edi,0
; int 0x40
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
mov ebx,32
div ebx
test edx,edx
je noaddword
inc eax
noaddword:
mov dword [dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov eax,bmp_load_area
push eax
add eax, [bmp_load_area+2];file size
inc eax
mov dword [soi],eax ;soi-start of image area for drawing
pop eax
add eax, [bmp_load_area+10]
mov dword [sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
mov ebx,3
mul ebx ;3x pixels in eax
 
mov edi,dword [soi] ;initializing
mov esi,dword [eop]
sub esi,dword [bps]
 
 
nextstring:
push edi
cmp word [bmp_load_area+28],24
jne convertno32
 
mov ecx,[dwps]
cld
rep movsd
convert1:
pop edi
sub esi,dword [bps]
sub esi,dword [bps]
cmp esi,dword [sop]
jb nomorestring
add edi,eax
jmp nextstring
 
nomorestring:
jmp end_bmp
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bps]
mov dword [eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
convert2:
pop eax
inc esi
cmp esi,dword [eos]
jae convert1
add edi,3
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
cmp edx,0xffffffff
je convert2
add edi,3
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
mov dword [edi],edx
ret
 
 
; DATA AREA
 
;status dd 0 ;bit0=1 if file thread is created
bps dd 0
dwps dd 0
soi dd 0
sop dd 0
eop dd 0
eos dd 0
;process dd 0
 
; DATA AREA
fileinfo:
dd 0
dd 0
dd 1 ;number of blocks of 512 bytes
dd bmp_load_area
dd bmp_temp_area
string:
db bmp_file_name,0
db ' '
db ' '
db ' '
db ' ',0
 
 
end_bmp:
mov eax,dword [soi]
mov dword [bmp_soi],eax
 
}
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/3dcube2/trunk/ascl.inc
0,0 → 1,499
lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.09 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
 
macro opendialog redproc,openoff,erroff,path,testtime
{
local still, dlg_file, clip_file, redwait
local button, key, red, zzz, still, zzz2, incf, file_is_open, zzz3
 
mov ecx,200
zzz3:
mov byte [path+ecx-1],0
loop zzz3
 
dec byte [clip_file+7]
incf:
inc byte [clip_file+7]
mov eax,6
mov ebx,clip_file
mov ecx,0
mov edx,-1
mov esi,path
int 0x40
cmp byte [clip_file+7],'Z'
je erroff
cmp eax,0xffffffff
jne incf
 
mov ecx,200
zzz2:
mov byte [path+ecx],0
loop zzz2
 
mov ebx,clip_file
mov ecx,path
mov edx,100
mov esi,0
mov eax,33
int 0x40
 
mov ebx,dlg_file
mov ecx,clip_file
mov eax,19
int 0x40
 
still:
scevent red,key,button
cmp byte [path],0
jne file_is_open
cmp dword [redwait],testtime ;20
jnae zzz
mov eax,6
mov ebx,clip_file
mov ecx,0
mov edx,-1
mov esi,path
int 0x40
cmp eax,0xffffffff
je erroff ;errexit
mov dword [redwait],0
zzz:
delay 5
inc dword [redwait]
jmp still
 
file_is_open:
mov eax,32
mov ebx,clip_file
int 0x40
jmp openoff
 
key: ; key
int 0x40 ; read (eax=2)
jmp still
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne still
mov eax,-1 ; close this program
int 0x40
 
red:
call redproc
jmp still
 
dlg_file db 'SYSXTREE '
clip_file db 'OPENCLPACLP'
db 'O' ;Dialog type O-open S-save
db 0 ;Marker
redwait dd 0
}
 
macro savedialog redproc,openoff,erroff,path,testtime
{
local still, dlg_file, clip_file, redwait, zzz3
local button, key, red, zzz, still, zzz2, incf, file_is_open
 
mov ecx,200
zzz3:
mov byte [path+ecx-1],0
loop zzz3
 
dec byte [clip_file+7]
incf:
inc byte [clip_file+7]
mov eax,6
mov ebx,clip_file
mov ecx,0
mov edx,-1
mov esi,path
int 0x40
cmp byte [clip_file+7],'Z'
je erroff
cmp eax,0xffffffff
jne incf
 
mov ecx,200
zzz2:
mov byte [path+ecx],0
loop zzz2
 
mov ebx,clip_file
mov ecx,path
mov edx,100
mov esi,0
mov eax,33
int 0x40
 
mov ebx,dlg_file
mov ecx,clip_file
mov eax,19
int 0x40
 
still:
scevent red,key,button
cmp byte [path],0
jne file_is_open
cmp dword [redwait],testtime ;20
jnae zzz
mov eax,6
mov ebx,clip_file
mov ecx,0
mov edx,-1
mov esi,path
int 0x40
cmp eax,0xffffffff
je erroff ;errexit
mov dword [redwait],0
zzz:
delay 5
inc dword [redwait]
jmp still
 
file_is_open:
mov eax,32
mov ebx,clip_file
int 0x40
jmp openoff
 
key: ; key
int 0x40 ; read (eax=2)
jmp still
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne still
mov eax,-1 ; close this program
int 0x40
 
red:
call redproc
jmp still
 
dlg_file db 'SYSXTREE '
clip_file db 'SAVECLPACLP'
db 'S' ;Dialog type O-open S-save
db 0 ;Marker
redwait dd 0
}
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr rsx2
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,0
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro puttxt x,y,offs,size,color
{
mov ebx,x
shl ebx,16
add ebx,y
mov ecx,color
mov edx,offs
mov esi,size
mov eax,4
int 0x40
}
 
;_ equ '____'
 
;macro libtest x,y,color
;{
;if x = as dword
; mov ebx,x
;end if
; mov ecx,y
; mov edx,color
; mov eax,1
; int 0x40
;}
 
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
mov edx,x*65536+y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
mov ebx,arg1 ;arg1=y arg2=x
shl ebx,16
add ebx,arg2
mov ecx,arg4 ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040ff
cl_Cyan equ 0x0040e0ff
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/3dcube2/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm 3dcube2.asm 3dcube2
@pause
/programs/demos/3dcube2/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm 3dcube2.asm 3dcube2
@pause
/programs/demos/3dcube2/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; language for programs
lang fix ru ; ru en fr ge fi
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/3detx60b/trunk/3DETX60B.ASM
0,0 → 1,2539
;
; 3D ’…Š‘’“ˆŽ‚€›‰ „‚ˆ†ŽŠ 3D TEXTURED ENGINE
; €‚’Ž:  ¢«î設 …¢£¥­¨© AUTOR: Pavlushin Evgeni
;
; Š®¬¯¨«¨àã¥âáï á ¯®¬®éìî FASM  áᥬ¡«¥à  ¤«ï MenuetOS
; Compile with FASM assembler for MenuetOS
;
; 20.11.04 Fast point calc & triangle draw
; Little matrix no (trangle massive)
; Fast triangle, del triangle out of screen
; 16.12.04 Fast triangle with MMX
; 20.12.04 Out triangle fatal bug's deleted, "black zones" deleted
; Matrix move support
; 24.12.04 Fast keyboard scanning
; Z-ground level map work
; Texture draw correction deleted "black zones"
; 04.01.05 Moveing texture
; 05.01.05 Water dynamic texture
; 06.01.05 Texture pack (many textures in one file)
; 07.01.05 Z-sorting
; 08.01.05 Triangle good clipping calculating (speed up)
; 4 byte Z-sorting, more dynamic of water
; 09.01.05 Texture map from 256 color bmp file
; Pixel Z-buffer, good speed!
; 21.01.05 Models buffer add.
; 25.01.05 Models buffer update, Add 2 new models.
; 29.01.05 Dynamic model array
; 01.02.05 1 picture MipMap calculation
; 04.02.05 All picture MipMap calculation, proc speed up.
; Simple Triangel MipMap chose.
; 05.02.05 Normal Triangel MipMap chose.
; 12.02.05 Best QUALITY of Textured TRIANGEL!
; 13.02.05 add new models. All camera axis calculating
; 16.02.05 Simple model turning
; 17.02.05 Advanced model turning, model tmpoints massive deleted
; New map size 128, add new models.
; 25.02.05 Left side clipping bug deleted
; 26.02.05 Optimization of textured line algorythm
; 24.04.05 Test pixel z-buffer it's work. Use new textri algorythm
; 30.04.05 Fast Y-clipping
 
use32
 
SCREEN_X equ 800 ;320 ;Screen size easy change
SCREEN_Y equ 600 ;200
DSCREEN_X equ SCREEN_X-1 ;320 ;For triangle clipping
DSCREEN_Y equ SCREEN_Y-1 ;200
MATRIX_XSIZE equ 64;32;64;100 ;Ground matrix size
MATRIX_YSIZE equ 64;32;64;100
SECTOR_SIZE equ 100 ;Size of matrix sector
MAP_XSIZE equ 128 ;Rezolution of map file
MAP_YSIZE equ 128
 
org 0x0
db 'MENUET01' ; 8 ¡ ©â ¨­â¤¥ä¨ª â®à
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª 
dd START ;  ¤à¥áá ­ ç «  ª®¤ 
dd I_END ; à §¬¥à ¯à®£à ¬¬ë
dd I_END+(SCREEN_X*SCREEN_Y*3+50000) ; à §¬¥à ¯ ¬ï⨠¤«ï ¯à®££à ¬¬ë
dd I_END+(SCREEN_X*SCREEN_Y*3+10000) ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'ascgl.inc'
include 'ascl.inc'
 
START: ; ­ ç «® ¯à¨«®¦¥­¨ï
; Draw window at first
call draw_window
 
; Decoding groud texture and ground level map
gif_hash_offset = gif_hash_area
;texture's
giftoimg texpack_gif,texpack_img-8
;ground level map
giftoimg gif_file_area5,glm_img_area
 
;get 8bitmap from 256 colors bmp file
mov ebp,128;64
mov esi,0x043a+128*128-4;64*64-4
sub esi,128;64
mov edi,0
mov ecx,128;64
texmap_unp:
mov al,[bmp_texmap+esi]
mov [img_area+edi],al
inc esi
inc edi
dec ecx
jnz texmap_unp
mov ecx,128;64
sub esi,256;128
dec ebp
jnz texmap_unp
 
 
;Unpack textures
 
mov esi,texpack_img
mov edi,texture_img
mov edx,16
mov ecx,16
tpuckloop:
pushad
call unpuck
popad
add esi,32*3
add edi,4095
dec ecx
jnz tpuckloop
add esi,31*32*16*3
mov ecx,16
dec edx
jnz tpuckloop
 
;
; Unpuck one texture procendure
;
jmp skip_unpuck
unpuck:
mov ecx,32
mov edx,32
tunploop:
mov ax,[esi]
mov [edi],ax
mov al,[esi+2]
mov [edi+2],al
add esi,3
add edi,3
dec ecx
jnz tunploop
mov ecx,32
add esi,(32*16*3)-(32*3)
dec edx
jnz tunploop
ret
skip_unpuck:
 
 
;calculating all mipmaps
mov esi,texture_img
mov ecx,256 ;quantity of textures
mmaploop:
mov ebp,32 ;max mipmap texture
pusha
call texgen
popa
add esi,4095 ;next mipmap block
dec ecx
jnz mmaploop
 
jmp skip_texgen
 
;********************************
; MIPMAP TEXTURE GENERATION
;
; in put:
; esi - offset to texture
; ebp - mipmap max size (32 for this sample)
;********************************
 
texgen:
push esi
mov eax,ebp
imul eax,ebp
imul eax,3
add eax,esi
mov edi,eax
 
mov eax,ebp
shr eax,1
mov dh,al
mov dl,al
mov cl,dl
 
mov ecx,ebp
mov eax,ebp
shl eax,1
add ecx,eax
 
miploop:
; Red
xor bx,bx ;for add
xor ax,ax ;for add
mov al,[esi+0]
add bx,ax
mov al,[esi+3+0]
add bx,ax
mov al,[esi+ecx+0]
add bx,ax
mov al,[esi+ecx+3+0]
add bx,ax
shr bx,2 ;/4
mov [edi+0],bl
;Green
xor bx,bx ;for add
xor ax,ax ;for add
mov al,[esi+1]
add bx,ax
mov al,[esi+3+1]
add bx,ax
mov al,[esi+ecx+1]
add bx,ax
mov al,[esi+ecx+3+1]
add bx,ax
shr bx,2 ;/4
mov [edi+1],bl
;Blue
xor bx,bx ;for add
xor ax,ax ;for add
mov al,[esi+2]
add bx,ax
mov al,[esi+3+2]
add bx,ax
mov al,[esi+ecx+2]
add bx,ax
mov al,[esi+ecx+3+2]
add bx,ax
shr bx,2 ;/4
mov [edi+2],bl
 
add esi,6
add edi,3
dec dl
jnz miploop
mov ax,bp
shr ax,1
mov dl,al
add esi,ecx
dec dh
jnz miploop
pop esi
 
mov eax,ebp
imul eax,ebp
imul eax,3
add esi,eax
shr ebp,1
cmp ebp,1
jne texgen
ret
skip_texgen:
 
 
;Copy dynamic water texture
; ????????????
mov ecx,32*32*3
mov esi,texture_img+4095 ;32*32*3
mov edi,texture_limg
cld
rep movsb
 
; init sine wave for dynamic water texture
finit
mov edi,sinwave
mov ecx,32;256
isv_loop:
fld [angle]
fld st
fsin
fmul [mul_wave]
fistp word [edi]
fadd [d_angle]
fstp [angle]
add edi,2
dec ecx
jnz isv_loop
 
 
;Initalize keyboard
mov eax,66
mov ebx,1
mov ecx,1
int 0x40
 
mov eax,26
mov ebx,2
mov ecx,1
mov edx,keymap+100
int 0x40
 
;Build triangle matrix
mov esi,points
mov eax,-(MATRIX_XSIZE/2)*SECTOR_SIZE
mov ebx,-(MATRIX_YSIZE/2)*SECTOR_SIZE
mov ebp,img_area+8
loomat:
mov [esi],eax ;x-set
mov [esi+4],ebx ;y-set
mov [esi+8],ecx ;z-set
add ebp,3
add esi,4*3
add eax,SECTOR_SIZE
cmp eax,((MATRIX_YSIZE/2)+1)*SECTOR_SIZE
jnge loomat
mov eax,-(MATRIX_YSIZE/2)*SECTOR_SIZE
add ebx,SECTOR_SIZE
cmp ebx,((MATRIX_XSIZE/2)+1)*SECTOR_SIZE
jnge loomat
 
; Create z-ground good algorythm not already yet (64x64 map)
mov esi,glm_img_area+8
mov edi,ground_level_map
loox:
; draw_courner_points
mov eax,[esi]
call get_z
; mov [edi],eax
 
mov eax,[esi+((MATRIX_XSIZE-1)*4)]
call get_z
; mov [edi+((MATRIX_XSIZE)*4)],eax
 
mov eax,[esi+(((MATRIX_XSIZE)*(MATRIX_YSIZE-1)+1)*4)]
call get_z
; mov [edi+(((MATRIX_XSIZE+1)*(MATRIX_YSIZE)-0)*4)],eax
 
mov eax,[esi+(((MATRIX_XSIZE)*(MATRIX_YSIZE)-1)*4)]
call get_z
; mov [edi+(((MATRIX_XSIZE+1)*(MATRIX_YSIZE+1)-1)*4)],eax
 
 
jmp skip_gz
get_z:
xor ebx,ebx
xor ecx,ecx
mov bl,al
add ecx,ebx
mov bl,ah
add ecx,ebx
shr eax,16
mov bl,al
add ecx,ebx
mov eax,ecx
xor edx,edx
mov ebx,3
cdq
div ebx
neg eax
ret
skip_gz:
 
; z-ground livel facking method (65x65 map)
mov esi,glm_img_area+8
mov edi,ground_level_map
mov ebp,(MAP_XSIZE+1)*(MAP_YSIZE+1)
looglm:
mov eax,[esi]
; and eax,0x000000ff
call get_z
mov [edi],eax
add esi,3
add edi,1
dec ebp
jnz looglm
 
;Fill model massive
mov ecx,[model_mas_start]
imul ecx,8
add ecx,4
mov esi,model_mas_start
mov edi,model_mas
cld
rep movsd
 
jmp skip_moddata
model_mas_start:
dd 12 ;quantity of models
dd 0,0,-150,0,0,0,0,bunker
dd 60,-250,-190,0,0,64,0,tank
dd 0,180,-150,0,0,0,0,cannon
dd 0,480,-150,0,0,0,0,outpost
dd 260,60,-150,0,0,0,0,bunker
dd 60,260,-150,0,0,0,0,outpost
dd 210,410,-150,0,0,0,0,cannon
dd 160,260,-150,0,0,0,0,tree
dd 100,-360,-150,0,0,192,0,gqfa
dd 10,580,-150,0,0,0,0,repear
dd 460,160,-100,0,0,0,0,red_flag
dd 60,360,-170,0,0,40,0,cannon
skip_moddata:
 
 
;Main loop
still: ; ®á­®¢­®© 横«
mov eax,11 ; ¯à®¢¥àª  á®áâ®ï­¨ï ®ª­ 
int 0x40
 
cmp eax,1 ; ®ª­® ᤢ¨­ã«¨ ¥£® ­ã¦­® ¯¥à¥à¨á®¢ âì
je red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
je key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ¢ ®ª­¥
je button
 
; delay 10
; cmp [autorot],0 ;frize no fps show when autorot off
; je still
 
cycle:
call clrscr ; clear screen buffer
call clrzbuf ; clear z-buffer
call render_scene ; calculating scene
call dispimg ; show buffer
 
fps_show_frequency=0
fps 10,10,cl_White,cl_Black
 
 
;turn model on z-axis
inc dword [model_mas+4*6]
and dword [model_mas+4*6],011111111b
 
 
; Sin wave dynamic texture for water
; jmp ndt
xor edi,edi
mov dx,32
mov bp,word [sin_pos]
dp_ver:
mov cx,32 ;320
mov si,word [sin_pos]
dp_hor:
and ebp,0000ffffh
mov ax,word [sinwave+ebp]
add ax,cx
and ax,31
 
and esi,0000ffffh
mov bx,word [sinwave+esi]
add bx,dx
and bx,31
shl bx,5
add bx,ax
 
push bx
imul bx,3
and ebx,0000ffffh
mov ax,[texture_limg+ebx]
mov [texture_img2+edi],ax
mov al,[texture_limg+ebx+2]
mov [texture_img2+edi+2],al
pop bx
 
add edi,3
add si,2
and si,63;511
dec cx
jnz dp_hor
add bp,2
and bp,63;511
dec dx
jnz dp_ver
 
; update sine position for next frame
add word [sin_pos],2
and word [sin_pos],63;511
 
;Move water texture
jmp ndt
mov esi,texture_limg
mov ecx,32*32-1
loodt:
mov al,byte [esi]
mov bl,byte [esi+1]
mov dl,byte [esi+2]
mov ah,byte [esi+3]
mov bh,byte [esi+4]
mov dh,byte [esi+5]
mov byte [esi],ah
mov byte [esi+1],bh
mov byte [esi+2],dh
mov byte [esi+3],al
mov byte [esi+4],bl
mov byte [esi+5],dl
add esi,3
dec ecx
jnz loodt
ndt:
 
;Creat mipmap pack for dynamic texture
mov ebp,32
mov esi,texture_img+4095
call texgen
 
 
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x0000ff00 ; font 1 & color ( 0xF0RRGGBB )
mov edx,keymap ; pointer to text beginning
mov esi,100 ; text length
int 0x40
add edx,100
add ebx,10
mov esi,60 ; text length
mov ecx,0x00dddddd ; font 1 & color ( 0xF0RRGGBB )
int 0x40
mov edx,usemap
mov esi,60 ; text length
mov ecx,0x0000ff00
int 0x40
jmp rx
;01234567890123456789012345678901234567890123456789
usemap db ' E wer u [] asd zxc '
db ' '
rx:
 
cmp byte [keymap+1],0
je n_esc
jmp exit
n_esc:
 
cmp byte [keymap+22],0
je n_u
mov [Xangle],0
mov [Yangle],0
mov [Zangle],0
n_u:
 
; t,y - mipmap cntrol
cmp byte [keymap+20],0
je n_t
inc [mipzoom]
n_t:
cmp byte [keymap+21],0
je n_y
dec [mipzoom]
n_y:
cmp byte [keymap+23],0
je n_i
mov byte [keymap+23],0 ; reset key
cmp [mipmapwork],1
je i_1
i_0:
mov [mipmapwork],1
jmp n_i
i_1:
mov [mipmapwork],0
n_i:
 
 
cmp byte [keymap+26],0
je n_lsk
add [Xcam],1
n_lsk:
cmp byte [keymap+27],0
je n_rsk
sub [Xcam],1
n_rsk:
cmp byte [keymap+18],0
je n_e
add [Yangle],1
n_e:
cmp byte [keymap+45],0
je n_x
sub [Yangle],1
n_x:
cmp byte [keymap+31],0
je n_s
add [Xangle],1
n_s:
cmp byte [keymap+32],0
je n_d
sub [Xangle],1
n_d:
cmp byte [keymap+44],0
je n_z
add [Zangle],1
n_z:
cmp byte [keymap+46],0
je n_c
sub [Zangle],1
n_c:
cmp byte [keymap+17],0
je n_w
add [Zcam],25 ;250
n_w:
cmp byte [keymap+19],0
je n_r
sub [Zcam],25 ;250
n_r:
 
cmp byte [keymap+75],0
je n_lk
add [Zcamangle],1
and [Zcamangle],011111111b
n_lk:
cmp byte [keymap+77],0
je n_rk
sub [Zcamangle],1
and [Zcamangle],011111111b
n_rk:
 
cmp byte [keymap+79],0
je n_num1
add [Xcamangle],1
and [Xcamangle],011111111b
n_num1:
cmp byte [keymap+81],0
je n_num3
sub [Xcamangle],1
and [Xcamangle],011111111b
n_num3:
cmp byte [keymap+71],0
je n_num7
add [Ycamangle],1
and [Ycamangle],011111111b
n_num7:
cmp byte [keymap+73],0
je n_num9
sub [Ycamangle],1
and [Ycamangle],011111111b
n_num9:
 
 
 
cmp byte [keymap+30],0
je n_a
mov byte [keymap+30],0 ; reset key
cmp [autorot],1
je a_1
a_0:
mov [autorot],1
jmp n_a
a_1:
mov [autorot],0
n_a:
 
; for camera
; mov ebx,[Xcamangle]
; call GetSinCos
; mov [Xcamsin],eax
; mov [Xcamcos],ebx
 
; mov ebx,[Ycamangle]
; call GetSinCos
; mov [Ycamsin],eax
; mov [Ycamcos],ebx
 
mov ebx,[Zcamangle]
call GetSinCos
mov [Zcamsin],eax
mov [Zcamcos],ebx
 
mov eax,[Zcamsin]
mov ebx,[Zcamcos]
; mov ecx,[Xcamsin]
; mov edx,[Xcamcos]
; mov esi,[Ycamsin]
; mov edi,[Ycamcos]
 
sar eax,4
sar ebx,4
; sar ecx,4
; sar edx,4
; sar esi,4
; sar edi,4
 
cmp byte [keymap+72],0
je n_uk
sub [Xcam],eax
sub [Ycam],ebx
 
; sub [Zcam],ecx
; sub [Ycam],edx
 
; sub [Xcam],esi
; add [Zcam],edi
 
n_uk:
cmp byte [keymap+80],0
je n_dk
add [Xcam],eax
add [Ycam],ebx
 
; add [Zcam],ecx
; add [Ycam],edx
 
; add [Xcam],esi
; sub [Zcam],edi
 
n_dk:
 
xor ebp,ebp
move_test:
cmp [Xcam],-SECTOR_SIZE/2
jnl ok1
add [Xcam],SECTOR_SIZE
dec [Xmap]
jmp move_test
ok1:
cmp [Xcam],SECTOR_SIZE/2
jng ok2
sub [Xcam],SECTOR_SIZE
inc [Xmap]
jmp ok1
ok2:
cmp [Ycam],-SECTOR_SIZE/2
jnl ok3
add [Ycam],SECTOR_SIZE
dec [Ymap]
jmp ok2
ok3:
cmp [Ycam],SECTOR_SIZE/2
jng ok4
sub [Ycam],SECTOR_SIZE
inc [Ymap]
jmp ok3
ok4:
 
and [Xangle],011111111b
and [Yangle],011111111b
and [Zangle],011111111b
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
 
shr eax,8
and eax,0xff
mov ah,al
 
mov ebx,0
mov bl,ah
cmp bl,224
je noisa ; ignore Ext code
cmp bl,170
je noisa ; ignore Key Up code
cmp bl,128
ja isa
mov [keymap+ebx],byte 'X' ; set press marker to key id
jmp noisa
isa:
sub bl,128
mov [keymap+ebx],byte 0 ; reset key marker
noisa:
jmp n_a
 
jmp still ; cycle
 
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1
jz exit
jmp cycle
 
exit:
mov eax,-1
int 0x40
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
draw_window:
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,0*65536+SCREEN_X-1 ; [x start] *65536 + [x size]
mov ecx,0*65536+SCREEN_Y-1 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x005080d0 ; color of grab bar RRGGBB,8->color gl
mov edi,0x005080d0 ; 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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
ret
 
dispimg:
mov eax,7
mov ebx,I_END ;zbuffer
mov ecx,SCREEN_X*65536+SCREEN_Y
xor edx,edx ;0*65536+0
int 0x40
; ret
 
mov eax,8
mov ebx,(SCREEN_X-30)*65536+20
mov ecx,10*65536+20
mov edx,1
mov esi,0x0000aa00
int 0x40
ret
 
clrscr: ; clear screen buffer
; cld
; mov edi,I_END
; xor eax,eax
; mov ecx,SCREEN_X*SCREEN_Y*3/4
; rep stosd
; ret
 
; clear screen buffer with MMX technology +1,5 fps
mov edi,I_END
mov ecx,SCREEN_X*SCREEN_Y*3/32
xor eax,eax
movd mm0,eax
movd mm1,eax
movd mm2,eax
movd mm3,eax
csloo:
movq qword [edi],mm0
movq qword [edi+8],mm1
movq qword [edi+16],mm2
movq qword [edi+24],mm3
add edi,32
dec ecx
jnz csloo
ret
 
clrzbuf: ; clear zbuf
cld
mov edi,zbuffer
mov eax,-1
mov ecx,SCREEN_X*SCREEN_Y*3/4
rep stosd
ret
 
 
; mov [@@atx1],dword 0xffffffff
; mov [@@aty1],dword 0xffffffff
; movq mm0,qword [@@atx1]
; movq mm1,qword [@@atx1]
; movq mm2,qword [@@atx1]
; movq mm3,qword [@@atx1]
;czbloo:
; movq qword [edi],mm0
; movq qword [edi+8],mm1
; movq qword [edi+16],mm2
; movq qword [edi+24],mm3
; add edi,32
; dec ecx
; jnz czbloo
ret
 
@@atx1: dd 0
@@aty1: dd 0
 
;===========================================================================
;
; 3D-system example. Use the following formulas to rotate a point:
;
; Rotate around x-axis
; Y = Y * COS(xang) - Z * SIN(xang) / 256
; Z = Y * SIN(xang) + Z * COS(xang) / 256
;
; Rotate around y-axis
; X = X * COS(yang) - Z * SIN(yang) / 256
; Z = X * SIN(yang) + Z * COS(yang) / 256
;
; Rotate around z-axis
; X = X * COS(zang) - Y * SIN(zang) / 256
; Y = X * SIN(zang) + Y * COS(zang) / 256
;
; Divide by 256 coz we have multiplyd our sin values with 256 too.
; This example isn't too fast right now but it'll work just fine.
;
;===========================================================================
 
;***************************************************************************
; \\\ MAIN 3D LOOP ///
; ******************
render_scene:
 
;********************
; Turn matrix points
;********************
 
cmp [autorot],0
je no_autorot
call UpdateAngles ; Calculate new angles
no_autorot:
call SetRotation ; Find sine & cosine of those angles
 
mov edi,tpoints
mov esi,points
mov [mapoff],-1 ;-1 at start
mov ebp,[Ymap]
imul ebp,MAP_XSIZE+1
mov eax,[Xmap]
add ebp,eax
 
mov ecx,(MATRIX_XSIZE+1)*(MATRIX_YSIZE+1)
ShowLoop:
push ecx
push esi
mov eax,[esi]
sub eax,[Xcam]
mov [X],eax
mov eax,[esi+4]
sub eax,[Ycam]
mov [Y],eax
mov eax,[ebp+ground_level_map] ;color
and eax,0x000000ff
sub eax,[Zcam]
mov [Z],eax
push ebp
push edi
call TranslatePoint ; Rotates the point using above formulas
pop edi
mov [edi],ebp ;x
mov [edi+4],eax ;y
mov eax,[Z] ;z
add eax,[Zoff]
mov [edi+8],eax
pop ebp
pop esi
pop ecx
 
add esi,4*3 ;next in point
add edi,4*3 ;next out point
 
inc [mapoff]
cmp [mapoff],MATRIX_XSIZE+1
jne no_shift_glm
mov [mapoff],dword 0
add ebp,(MAP_XSIZE-MATRIX_XSIZE)
no_shift_glm:
add ebp,1
 
dec ecx
jnz ShowLoop
 
 
; Show, how many polygons on screen.
outcount [massize],50,10,cl_White,8*65536
 
 
;*****************
; out triangles
;*****************
 
mov [mapoff],-1 ;-1 at start
mov [massize],0 ;restet triangle massive counter
 
mov ebp,[Ymap]
imul ebp,MAP_XSIZE;64;3*64 ;MAP_XSIZE
mov eax,[Xmap]
add ebp,eax
 
mov edi,tpoints
mov ecx,MATRIX_YSIZE ;64
lootpy:
push ecx
mov ecx,MATRIX_XSIZE ;64
lootpx:
;draw four angle (two triangles)
 
Z_MAX = 10 ;maximal z range for triangles
 
; get texture offset at start
inc [mapoff]
cmp [mapoff],MATRIX_XSIZE
jne no_shift
mov [mapoff],dword 0
add ebp,(MAP_XSIZE-MATRIX_XSIZE)
no_shift:
xor eax,eax
mov al,[ebp+img_area];+8]
inc ebp
imul eax,4095;32*32*3
add eax,texture_img
mov ebx,eax
 
;first triangle
mov eax,[edi+8] ;z1
cmp eax,Z_MAX
jl no_add1
mov [@@tz1],eax
mov eax,[edi+8+12] ;z2
cmp eax,Z_MAX
jl no_add1
mov [@@tz2],eax
mov eax,[edi+8+(4*3*(MATRIX_XSIZE+2))] ;z3
cmp eax,Z_MAX
jl no_add1
mov [@@tz3],eax
 
cmp dword [edi],SCREEN_X
ja p11
cmp dword [edi+4],SCREEN_Y
jna yes_add1
p11:
cmp dword [edi+12],SCREEN_X
ja p12
cmp dword [edi+4+12],SCREEN_Y
jna yes_add1
p12:
cmp dword [edi+(4*3*(MATRIX_XSIZE+2))],SCREEN_X
ja p13
cmp dword [edi+4+(4*3*(MATRIX_XSIZE+2))],SCREEN_Y
jna yes_add1
p13:
jmp no_add1
yes_add1:
 
movq mm0,qword [edi] ;x1
movq mm1,qword [edi+12] ;x2
movq mm2,qword [edi+(4*3*(MATRIX_XSIZE+2))] ;x3
movq qword [@@tx1],mm0
movq qword [@@tx2],mm1
movq qword [@@tx3],mm2
 
mov eax,ebx;+1 shl 31;[ebp]
mov [@@tex_off],eax ;0x0000ff00
inc [massize]
pushad
mov [@@tex_x1],0
mov [@@tex_y1],0
mov [@@tex_x3],(32 shl 16) -1;128
mov [@@tex_y3],(32 shl 16) -1;128
mov [@@tex_x2],0
mov [@@tex_y2],(32 shl 16) -1;128
call textured_triangle
popad
 
no_add1:
 
 
 
;second triangle
mov eax,[edi+8] ;z1
cmp eax,Z_MAX
jl no_add2
mov [@@tz1],eax
mov eax,[edi+8+(4*3*(MATRIX_XSIZE+1))] ;z2
cmp eax,Z_MAX
jl no_add2
mov [@@tz2],eax
mov eax,[edi+8+(4*3*(MATRIX_XSIZE+2))] ;z3
cmp eax,Z_MAX
jl no_add2
mov [@@tz3],eax
 
cmp dword [edi],SCREEN_X
ja p21
cmp dword [edi+4],SCREEN_Y
jna yes_add2
p21:
cmp dword [edi+(4*3*(MATRIX_XSIZE+1))],SCREEN_X
ja p22
cmp dword [edi+4+(4*3*(MATRIX_XSIZE+1))],SCREEN_Y
jna yes_add2
p22:
cmp dword [edi+(4*3*(MATRIX_XSIZE+2))],SCREEN_X
ja p23
cmp dword [edi+4+(4*3*(MATRIX_XSIZE+2))],SCREEN_Y
jna yes_add2
p23:
jmp no_add2
yes_add2:
 
movq mm0,qword [edi] ;x1
movq mm1,qword [edi+(4*3*(MATRIX_XSIZE+1))] ;x2
movq mm2,qword [edi+(4*3*(MATRIX_XSIZE+2))] ;x3
movq qword [@@tx1],mm0
movq qword [@@tx2],mm1
movq qword [@@tx3],mm2
 
 
mov eax,ebx
mov [@@tex_off],eax ;0x0000ff00
inc [massize]
; add esi,4*10
 
pushad
mov [@@tex_x1],0
mov [@@tex_y1],0
mov [@@tex_x3],(32 shl 16) -1;128
mov [@@tex_y3],(32 shl 16) -1;128
mov [@@tex_x2],(32 shl 16) -1
mov [@@tex_y2],0
call textured_triangle
popad
 
 
no_add2:
 
add edi,4*3 ;next triangle
dec ecx
jnz lootpx
add edi,4*3 ;next string
pop ecx
dec ecx
jnz lootpy
 
;**********************************
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;**********************************
; For good models quality -5% speed
; call clrzbuf
 
jmp skip_modmas
mmcnt dd 0 ;counter of model read number
modeloff dd 0 ;offset of model structure
modelmoff dd 0 ;offset in model mas
modeltmpoff dd 0 ;tmpoints offset
; massive of models
; format: X,Y,Z coordoinats,offset to model structure
 
skip_modmas:
 
; Rendering models on map
 
mov eax,[model_mas]
mov [mmcnt],eax
 
ModelRenderLoop:
 
mov ebx,[mmcnt]
dec ebx
imul ebx,4*8
add ebx,model_mas+4
mov ebp,ebx ;edi=model offset X,Y,Z,Xturn,Yturn,Zturn,zero,modeloff
 
mov ebx,[ebp+4*3];[Xangle] ; Grab angle
call GetSinCos ; Get the sine&cosine
mov [Xsin],eax ; Save sin
mov [Xcos],ebx ; Save cos
mov ebx,[ebp+4*4];[Yangle]
call GetSinCos
mov [Ysin],eax
mov [Ycos],ebx
mov ebx,[ebp+4*5];[Zangle]
call GetSinCos
mov [Zsin],eax
mov [Zcos],ebx
 
mov ebx,[mmcnt]
imul ebx,4*8
add ebx,model_mas+4-4
mov eax,[ebx]
 
mov [modeloff],eax
sub ebx,4*7;3
mov [modelmoff],ebx
 
mov edi,modelpoints
mov esi,eax ;bunker+8
add esi,8
mov ecx,[eax] ;[bunker] ;MODEL_POINTS
 
TurnModelLoop:
push ecx
push esi
mov eax,[esi]
mov [X],eax
mov eax,[esi+4]
mov [Y],eax
mov eax,[esi+8]
mov [Z],eax
push ebp
push edi
 
;RotatePoint
 
mov esi,[Y]
mov ebx,[Xcos]
mov edi,[Z]
mov ecx,[Xsin]
call math
mov [Y],esi
mov [Z],edi
mov esi,[X]
mov ebx,[Ycos]
mov ecx,[Ysin]
call math
mov [X],esi
mov [Z],edi
mov ebx,[Zcos]
mov edi,[Y]
mov ecx,[Zsin]
call math
mov [X],esi
mov [Y],edi
 
pop edi
 
mov eax,[X]
mov [edi],eax
mov eax,[Y]
mov [edi+4],eax
 
mov eax,[Z] ;z
; add eax,[Zoff]
mov [edi+8],eax
pop ebp
pop esi
pop ecx
 
add esi,4*3 ;next in point
add edi,4*3 ;next out point
 
dec ecx
jnz TurnModelLoop
 
modxxx:
 
 
;Turn model off map
 
call SetRotation
 
mov ebx,[mmcnt]
imul ebx,4*8
add ebx,model_mas+4-4
mov eax,[ebx]
 
mov [modeloff],eax
sub ebx,4*7;3
mov [modelmoff],ebx
 
mov edi,modelpoints
mov ecx,[eax] ;[bunker] ;MODEL_POINTS
 
ShowModelLoop:
push ecx
mov eax,[edi] ;esi]
 
mov ebx,[modelmoff]
sub eax,[ebx] ;[Xmod]
 
sub eax,[Xcam]
mov ebx,[Xmap]
imul ebx,SECTOR_SIZE
sub eax,ebx
mov [X],eax
mov eax,[edi+4] ;esi+4]
 
mov ebx,[modelmoff]
sub eax,[ebx+4] ;[Ymod]
 
sub eax,[Ycam]
mov ebx,[Ymap]
imul ebx,SECTOR_SIZE
sub eax,ebx
mov [Y],eax
mov eax,[edi+8];esi+8]
 
mov ebx,[modelmoff]
sub eax,[ebx+8] ;[Zmod]
 
sub eax,[Zcam]
mov [Z],eax
push ebp
push edi
call TranslatePoint ; Rotates the point using above formulas
pop edi
mov [edi],ebp ;x
mov [edi+4],eax ;y
mov eax,[Z] ;z
add eax,[Zoff]
mov [edi+8],eax
pop ebp
pop ecx
 
add edi,4*3 ;next out point
 
dec ecx
jnz ShowModelLoop
 
 
; add [model_mas+8],dword 3
 
 
 
mov esi,[massize]
imul esi,4*10
 
mov eax,[modeloff]
mov ecx,[eax+4] ;MODEL_TRIANGELS
 
;calc tmpoints offset
mov edi,modelpoints
mov [modeltmpoff],edi
 
;calc postlink offset
mov edi,[eax]
imul edi,3*4;*2 ;X,Y,Z (3) points dd format (4) 2 masives (2)
add edi,eax
add edi,8 ;skip dd points, dd triangels
msloo:
 
mov ebx,[edi]
imul ebx,4*3
add ebx,[modeltmpoff] ;tmpoints
mov eax,[ebx]
mov [@@tx1],eax
mov eax,[ebx+4]
mov [@@ty1],eax
mov eax,[ebx+8]
mov [@@tz1],eax
 
mov ebx,[edi+4]
imul ebx,4*3
add ebx,[modeltmpoff] ;tmpoints
mov eax,[ebx]
mov [@@tx2],eax
mov eax,[ebx+4]
mov [@@ty2],eax
mov eax,[ebx+8]
mov [@@tz2],eax
 
mov ebx,[edi+8]
imul ebx,4*3
add ebx,[modeltmpoff] ;tmpoints
mov eax,[ebx]
mov [@@tx3],eax
mov eax,[ebx+4]
mov [@@ty3],eax
mov eax,[ebx+8]
mov [@@tz3],eax
 
 
cmp dword [@@tz1],Z_MAX
jl no_add
cmp dword [@@tz2],Z_MAX
jl no_add
cmp dword [@@tz3],Z_MAX
jl no_add
cmp dword [@@tx1],SCREEN_X
ja pm1
cmp dword [@@ty1],SCREEN_Y
jna yes_madd
pm1:
cmp dword [@@tx2],SCREEN_X
ja pm2
cmp dword [@@ty2],SCREEN_Y
jna yes_madd
pm2:
cmp dword [@@tx3],SCREEN_X
ja pm3
cmp dword [@@ty3],SCREEN_Y
jna yes_madd
pm3:
jmp no_add
yes_madd:
 
 
 
 
mov ebx,[edi+12]
dec ebx
js ttex
mov eax,1 shl 31
jmp posit
ttex:
add ebx,2
mov eax,0
neg ebx
posit:
imul ebx,4095;32*32*3
add ebx,texture_img
mov [@@tex_off],ebx
 
pushad
mov [@@tex_x1],0
mov [@@tex_y1],0
mov [@@tex_x3],(32 shl 16) -1;128
mov [@@tex_y3],(32 shl 16) -1;128
cmp eax,0
je nez
mov [@@tex_x2],0
mov [@@tex_y2],(32 shl 16) -1
jmp isz
nez:
mov [@@tex_x2],(32 shl 16) -1
mov [@@tex_y2],0
isz:
call textured_triangle
popad
 
; mov [esi+8+24+4],eax
; add esi,4*10
inc [massize]
no_add:
add edi,4*4; *9
dec ecx
jnz msloo
 
dec [mmcnt]
jnz ModelRenderLoop
 
 
jmp skip_mdata
 
bunker:
dd 8 ;model points
dd 10 ;model triagels
;mpoints:
dd -105,-105,0, -105,105,0, 105,105,0, 105,-105,0
dd -70,-70,-50, -70,70,-50, 70,70,-50, 70,-70,-50
 
; 4-------7 Points structure
; |\0---3/|
; | | | |
; | | | |
; |/1---2\|
; 5-------6
 
;pointslink:
;dd 0,1,2, -3, 0,3,2, 3 ;far side
dd 4,0,1, -5, 4,5,1, 5 ;left side
dd 6,2,3, -5, 6,7,3, 5 ;right side
dd 4,0,3, -5, 4,7,3, 5 ;up side
dd 5,1,2, -5, 5,6,2, 5 ;down side
dd 4,5,6, -6, 4,7,6, 6 ;far side
 
;model 2 outpost
outpost:
dd 8 ;model points
dd 10 ;model triagels
;mpoints:
dd -45,-45,0, -45,45,0, 45,45,0, 45,-45,0
dd -30,-30,-20, -30,30,-20, 30,30,-20, 30,-30,-20
;pointslink:
;dd 0,1,2, -3, 0,3,2, 3 ;far side
dd 4,0,1, -8, 4,5,1, 8 ;left side
dd 6,2,3, -8, 6,7,3, 8 ;right side
dd 4,0,3, -8, 4,7,3, 8 ;up side
dd 5,1,2, -8, 5,6,2, 8 ;down side
dd 4,5,6, -7, 4,7,6, 7 ;near side
 
;model 3 cannon
cannon:
dd 12 ;model points
dd 12 ;model triagels
;mpoints:
dd -10,-20,0, -10,20,0, 10,20,0, 10,-20,0
dd -10,-10,-15, -10,10,-15, 10,10,-15, 10,-10,-15
dd -2,15,-8, 2,15,-8, -2,45,-8, 2,45,-8
;pointslink:
;dd 0,1,2, -3, 0,3,2, 3 ;far side
dd 4,0,1, -10, 4,5,1, 10 ;left side
dd 6,2,3, -10, 6,7,3, 10 ;right side
dd 4,0,3, -10, 4,7,3, 10 ;up side
dd 5,1,2, -10, 5,6,2, 10 ;down side
dd 4,5,6, -11, 4,7,6, 11 ;near side
dd 8,9,10,-10, 9,10,11,10 ;cannon 1
 
;model 4 red flag
red_flag:
dd 12 ;model points
dd 6*2 ;model triagels
;mpoints:
dd -1,-1,0, -1,1,0, 1,1,0, 1,-1,0
dd -1,-1,-30, -1,1,-30, 1,1,-30, 1,-1,-30
dd 1,1,-30, 10,1,-30, 10,1,-20, 1,1,-20
;pointslink:
dd 4,0,1, -10, 4,5,1, 15 ;left side
dd 6,2,3, -10, 6,7,3, 15 ;right side
dd 4,0,3, -10, 4,7,3, 15 ;up side
dd 5,1,2, -10, 5,6,2, 15 ;down side
dd 4,5,6, -10, 4,7,6, 15 ;near side
dd 8,11,10,-49, 8,9,10,49 ;flag
 
repear:
dd 8 ;model points
dd 10 ;model triagels
;mpoints:
dd -45,-45,0, -45,45,0, 45,45,0, 45,-45,0
dd -30,-30,-20, -30,30,-20, 30,30,-20, 30,-30,-20
;pointslink:
dd 4,0,1, -5, 4,5,1, 5 ;left side
dd 6,2,3, -5, 6,7,3, 5 ;right side
dd 4,0,3, -5, 4,7,3, 5 ;up side
dd 5,1,2, -5, 5,6,2, 5 ;down side
dd 4,5,6, -3, 4,7,6, 3 ;far side
 
;model 5 tree (elka)
tree:
dd 16 ;model points
dd 8*2 ;model triagels
;mpoints:
dd -2,-2,0, -2,2,0, 2,2,0, 2,-2,0
dd -1,-1,-8, -1,1,-8, 1,1,-8, 1,-1,-8
dd -10,-10,-8, -10,10,-8, 10,10,-8, 10,-10,-8
dd -1,-1,-40, -1,1,-40, 1,1,-40, 1,-1,-40
;pointslink:
dd 4,0,1, -16, 4,5,1, 16 ;left side
dd 6,2,3, -16, 6,7,3, 16 ;right side
dd 4,0,3, -16, 4,7,3, 16 ;up side
dd 5,1,2, -16, 5,6,2, 16 ;down side
 
dd 12,8,9, -14, 12,13,9, 14 ;left side
dd 14,10,11, -14, 14,15,11, 14 ;right side
dd 12,8,11, -14, 12,15,11, 14 ;up side
dd 13,9,10, -14, 13,14,10, 14 ;down side
 
;model tank
tank:
dd 20 ;model points
dd 12+10 ;model triagels
;mpoints:
dd -10,-20,-10, -10,20,-10, 10,20,-10, 10,-20,-10
dd -10,-10,-20, -10,10,-20, 10,10,-20, 10,-10,-20
dd -2,15,-15, 2,15,-15, -2,45,-15, 2,45,-15
 
dd -20,-20,0, -20,20,0, 20,20,0, 20,-20,0
dd -20,-30,-10, -20,30,-10, 20,30,-10, 20,-30,-10
 
;pointslink:
;dd 0,1,2, -3, 0,3,2, 3 ;far side
dd 4,0,1, -10, 4,5,1, 10 ;left side
dd 6,2,3, -10, 6,7,3, 10 ;right side
dd 4,0,3, -10, 4,7,3, 10 ;up side
dd 5,1,2, -10, 5,6,2, 10 ;down side
dd 4,5,6, -11, 4,7,6, 11 ;near side
dd 8,9,10,-10, 9,10,11,10 ;cannon 1
 
dd 16,12,13, -11, 16,17,13, 11 ;left side
dd 18,14,15, -11, 18,19,15, 11 ;right side
dd 16,12,15, -11, 16,19,15, 11 ;up side
dd 17,13,14, -11, 17,18,14, 11 ;down side
dd 16,17,18, -11, 16,19,18, 11 ;near side
 
;Test model
gqfa: ;Good quality four angle
dd 5 ;model points
dd 4 ;model triagels
;mpoints:
;dd -45,-145,0, -45,145,0, 45,45,0, 45,-45,0
dd -0,-105,0, -0,105,0, 45,45,0, 45,-45,0
dd 30,0,0
;pointslink:
dd 1,4,0, 50 ;left side
dd 1,4,2, 51 ;right side
dd 3,4,2, -50 ;up side
dd 3,4,0, -51 ;down side
 
skip_mdata:
 
;***************
; Add new models
;***************
; jmp no_addmodel
 
random 20,eax
sub eax,10
imul eax,SECTOR_SIZE
add eax,SECTOR_SIZE/2
mov [temp1],eax
random 20,eax
sub eax,10
imul eax,SECTOR_SIZE
add eax,SECTOR_SIZE/2
mov [temp2],eax
 
mov eax,dword [model_mas]
cmp eax,40;00
jae no_addmodel
imul eax,4*8;
add eax,4+model_mas
inc dword [model_mas]
mov ebx,[temp1]
mov [eax],ebx
mov ebx,[temp2]
mov [eax+4],ebx
mov [eax+8],dword -170
mov ebx,0
mov [eax+12],ebx
mov [eax+16],ebx
mov [eax+20],ebx
mov ebx,tree;red_flag
mov [eax+28],ebx
jmp skip_mdata ;use for auto filling at start
no_addmodel:
 
ret
 
 
UpdateAngles:
; Calculates new x,y,z angles
; to autorotate around
 
mov eax,[Xangle] ; Load current angles
mov ebx,[Yangle]
mov ecx,[Zangle]
 
add eax,[DeltaX] ; Add velocity
and eax,011111111b ; Range from 0..255
mov [Xangle],eax ; Update X
add ebx,[DeltaY] ; Add velocity
and ebx,011111111b ; Range from 0..255
mov [Yangle],ebx ; Update Y
add ecx,[DeltaZ] ; Add velocity
and ecx,011111111b ; Range from 0..255
mov [Zangle],ecx ; Update Z
ret
 
GetSinCos:
; Needed : bx=angle (0..255)
; Returns: ax=Sin bx=Cos
push ebx ; Save angle (use as pointer)
shl ebx,2 ; Grab a word so bx=bx*2
mov eax,[SinCos + ebx] ; Get sine
pop ebx ; Restore pointer into bx
push eax ; Save sine on stack
add ebx,64 ; Add 64 to get cosine
and ebx,11111111b ; Range from 0..255
shl ebx,2 ; *2 coz it's a word
mov eax,[SinCos + ebx] ; Get cosine
mov ebx,eax ; Save it bx=Cos
pop eax ; Restore ax=Sin
ret
 
; Get sin & cos of x,y,z angle
SetRotation:
mov ebx,[Xangle] ; Grab angle
call GetSinCos ; Get the sine&cosine
mov [Xsin],eax ; Save sin
mov [Xcos],ebx ; Save cos
 
mov ebx,[Yangle]
call GetSinCos
mov [Ysin],eax
mov [Ycos],ebx
 
mov ebx,[Zangle]
call GetSinCos
mov [Zsin],eax
mov [Zcos],ebx
; for camera
mov ebx,[Xcamangle]
call GetSinCos
mov [Xcamsin],eax
mov [Xcamcos],ebx
 
mov ebx,[Ycamangle]
call GetSinCos
mov [Ycamsin],eax
mov [Ycamcos],ebx
 
mov ebx,[Zcamangle]
call GetSinCos
mov [Zcamsin],eax
mov [Zcamcos],ebx
 
ret
 
TranslatePoint: ; Rotates the point around x,y,z
; Gets original x,y,z values
; This can be done elsewhere
 
mov esi,[X]
mov edi,[Y]
mov ebx,[Zcamcos]
mov ecx,[Zcamsin]
call math
mov [X],esi
mov [Y],edi
 
mov esi,[Y]
mov edi,[Z]
mov ebx,[Xcamcos]
mov ecx,[Xcamsin]
call math
mov [Y],esi
mov [Z],edi
 
mov esi,[X]
mov edi,[Z]
mov ebx,[Ycamcos]
mov ecx,[Ycamsin]
call math
mov [X],esi
mov [Z],edi
 
mov esi,[Y]
mov ebx,[Xcos]
mov edi,[Z]
mov ecx,[Xsin]
call math
mov [Y],esi
mov [Z],edi
mov esi,[X]
mov ebx,[Ycos]
mov ecx,[Ysin]
call math
mov [X],esi
mov [Z],edi
mov ebx,[Zcos]
mov edi,[Y]
mov ecx,[Zsin]
call math
 
;*************
; ShowPoint
;*************
 
; Calculates screenposition and
; plots the point on the screen
mov eax,[Xoff] ; Xoff*X / Z+Zoff = screen x
mov ecx,esi
imul ecx
 
mov ebx,[Z]
add ebx,[Zoff] ; Distance
 
cmp ebx,0
je notout
idiv ebx
add eax,[Mx] ; Center on screen
mov ebp,eax ;ebp =Xp
 
mov eax,[Yoff] ; Yoff*Y / Z+Zoff = screen y
mov ecx,edi
imul ecx
 
cmp ebx,0
je notout
idiv ebx ;eax =Yp
add eax,[My] ; Center on screen
 
notout:
ret
 
math:
mov eax,esi
imul ebx ; ax = X * Cos(zang)
mov ebp,eax
mov eax,edi
imul ecx ; ax = Y * Sin(zang)
sub ebp,eax ; bp = X * Cos(zang) - Y * Sin(zang)
sar ebp,8 ; bp = X * Cos(zang) - Y * Sin(zang) / 256
 
mov eax,esi
mov esi,ebp
imul ecx ; ax = X * Sin(zang)
mov ebp,eax
mov eax,edi
imul ebx ; ax = Y * Cos(zang)
add ebp,eax ; bp = X * SIN(zang) + Y * COS(zang)
sar ebp,8 ; bp = X * SIN(zang) + Y * COS(zang) / 256
mov edi,ebp
ret
 
SinCos:
dd 0,6,13,19,25,31,38,44,50,56
dd 62,68,74,80,86,92,98,104,109,115
dd 121,126,132,137,142,147,152,157,162,167
dd 172,177,181,185,190,194,198,202,206,209
dd 213,216,220,223,226,229,231,234,237,239
dd 241,243,245,247,248,250,251,252,253,254
dd 255,255,256,256,256,256,256,255,255,254
dd 253,252,251,250,248,247,245,243,241,239
dd 237,234,231,229,226,223,220,216,213,209
dd 206,202,198,194,190,185,181,177,172,167
dd 162,157,152,147,142,137,132,126,121,115
dd 109,104,98,92,86,80,74,68,62,56
dd 50,44,38,31,25,19,13,6,0,-6
dd -13,-19,-25,-31,-38,-44,-50,-56,-62,-68
dd -74,-80,-86,-92,-98,-104,-109,-115,-121,-126
dd -132,-137,-142,-147,-152,-157,-162,-167,-172,-177
dd -181,-185,-190,-194,-198,-202,-206,-209,-213,-216
dd -220,-223,-226,-229,-231,-234,-237,-239,-241,-243
dd -245,-247,-248,-250,-251,-252,-253,-254,-255,-255
dd -256,-256,-256,-256,-256,-255,-255,-254,-253,-252
dd -251,-250,-248,-247,-245,-243,-241,-239,-237,-234
dd -231,-229,-226,-223,-220,-216,-213,-209,-206,-202
dd -198,-194,-190,-185,-181,-177,-172,-167,-162,-157
dd -152,-147,-142,-137,-132,-126,-121,-115,-109,-104
dd -98,-92,-86,-80,-74,-68,-62,-56,-50,-44
dd -38,-31,-25,-19,-13,-6
 
mipzoom dd 0
mipmapwork dd 0
temp1 dd 0
temp2 dd 0
 
; 4.24.2005 Textured triangle algorythm
; created by Pavlushin Evgeni waptap[at]mail.ru
; on base tex3 from Mikolaj Felix mfelix@polbox.com
 
align 512
@@tx1 dd 0 ;equ [bp+4]
@@ty1 dd 0 ;equ [bp+6]
align 512
@@tx2 dd 0 ;equ [bp+8]
@@ty2 dd 0 ;equ [bp+10]
align 512
@@tx3 dd 0 ;equ [bp+12]
@@ty3 dd 0 ;equ [bp+14]
 
@@tz1 dd 0
@@tz2 dd 0
@@tz3 dd 0
 
@@z_dy12 dd 0
@@z_dy13 dd 0
@@z_dy23 dd 0
 
@@tex_off dd 0 ;equ [bp+16]
@@tex_x1 dd 0 ;equ [bp+18]
@@tex_y1 dd 0 ;equ [bp+20]
@@tex_x2 dd 0 ;equ [bp+22]
@@tex_y2 dd 0 ;equ [bp+24]
@@tex_x3 dd 0 ;equ [bp+26]
@@tex_y3 dd 0 ;equ [bp+28]
 
@@dx12 dd 0 ;equ [bp-2]
@@dx13 dd 0 ;equ [bp-4]
@@dx23 dd 0 ;equ [bp-6]
 
@@tex_dx12 dd 0 ;equ [bp-8]
@@tex_dy12 dd 0 ;equ [bp-10]
@@tex_dx13 dd 0 ;equ [bp-12]
@@tex_dy13 dd 0 ;equ [bp-14]
@@tex_dx23 dd 0 ;equ [bp-16]
@@tex_dy23 dd 0 ;equ [bp-18]
 
@@scan_x1 dd 0
@@scan_y1 dd 0
@@scan_x2 dd 0
@@scan_y2 dd 0
 
@@scan_z1 dd 0
@@scan_z2 dd 0
 
SHIFT=16
 
textured_triangle:
 
mov eax,[@@ty1]
cmp eax,[@@ty3]
jle tt_check1
 
xchg eax,[@@ty3]
mov [@@ty1],eax
 
mov eax,[@@tx1]
xchg eax,[@@tx3]
mov [@@tx1],eax
 
mov eax,[@@tz1]
xchg eax,[@@tz3]
mov [@@tz1],eax
 
mov eax,[@@tex_y1]
xchg eax,[@@tex_y3]
mov [@@tex_y1],eax
 
mov eax,[@@tex_x1]
xchg eax,[@@tex_x3]
mov [@@tex_x1],eax
tt_check1:
mov eax,[@@ty2]
cmp eax,[@@ty3]
jle tt_check2
 
xchg eax,[@@ty3]
mov [@@ty2],eax
 
mov eax,[@@tx2]
xchg eax,[@@tx3]
mov [@@tx2],eax
 
mov eax,[@@tz2]
xchg eax,[@@tz3]
mov [@@tz2],eax
 
mov eax,[@@tex_y2]
xchg eax,[@@tex_y3]
mov [@@tex_y2],eax
 
mov eax,[@@tex_x2]
xchg eax,[@@tex_x3]
mov [@@tex_x2],eax
tt_check2:
mov eax,[@@ty1]
cmp eax,[@@ty2]
jle tt_check3
 
xchg eax,[@@ty2]
mov [@@ty1],eax
 
mov eax,[@@tx1]
xchg eax,[@@tx2]
mov [@@tx1],eax
 
mov eax,[@@tz1]
xchg eax,[@@tz2]
mov [@@tz1],eax
 
mov eax,[@@tex_y1]
xchg eax,[@@tex_y2]
mov [@@tex_y1],eax
 
mov eax,[@@tex_x1]
xchg eax,[@@tex_x2]
mov [@@tex_x1],eax
tt_check3:
 
mov ebx,[@@ty2]
sub ebx,[@@ty1]
jnz tt_dx12_make
 
mov [@@dx12],0
mov [@@tex_dx12],0
mov [@@tex_dy12],0
mov [@@z_dy12],0
jmp tt_dx12_done
tt_dx12_make:
mov eax,[@@tx2]
sub eax,[@@tx1]
shl eax,SHIFT
cdq
idiv ebx
mov [@@dx12],eax ; dx12 = (x2-x1)/(y2-y1)
 
mov eax,[@@tex_x2]
sub eax,[@@tex_x1]
cdq
idiv ebx
mov [@@tex_dx12],eax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
 
mov eax,[@@tex_y2]
sub eax,[@@tex_y1]
cdq
idiv ebx
mov [@@tex_dy12],eax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
 
mov eax,[@@tz2]
sub eax,[@@tz1]
shl eax,SHIFT
cdq
idiv ebx
mov [@@z_dy12],eax
 
tt_dx12_done:
 
mov ebx,[@@ty3]
sub ebx,[@@ty1]
jnz tt_dx13_make
 
mov [@@dx13],0
mov [@@tex_dx13],0
mov [@@tex_dy13],0
mov [@@z_dy13],0
jmp tt_dx13_done
tt_dx13_make:
mov eax,[@@tx3]
sub eax,[@@tx1]
shl eax,SHIFT
cdq
idiv ebx
mov [@@dx13],eax ; dx13 = (x3-x1)/(y3-y1)
 
mov eax,[@@tex_x3]
sub eax,[@@tex_x1]
cdq
idiv ebx
mov [@@tex_dx13],eax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
 
mov eax,[@@tex_y3]
sub eax,[@@tex_y1]
cdq
idiv ebx
mov [@@tex_dy13],eax ; tex_dy13 = (tex_y3-tex_x1)/(y3-y1)
 
mov eax,[@@tz3]
sub eax,[@@tz1]
shl eax,SHIFT
cdq
idiv ebx
mov [@@z_dy13],eax
tt_dx13_done:
 
mov ebx,[@@ty3]
sub ebx,[@@ty2]
jnz tt_dx23_make
 
mov [@@dx23],0
mov [@@tex_dx23],0
mov [@@tex_dy23],0
mov [@@z_dy23],0
jmp tt_dx23_done
tt_dx23_make:
mov eax,[@@tx3]
sub eax,[@@tx2]
shl eax,SHIFT
cdq
idiv ebx
mov [@@dx23],eax ; dx23 = (x3-x2)/(y3-y2)
 
mov eax,[@@tex_x3]
sub eax,[@@tex_x2]
cdq
idiv ebx
mov [@@tex_dx23],eax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
 
mov eax,[@@tex_y3]
sub eax,[@@tex_y2]
cdq
idiv ebx
mov [@@tex_dy23],eax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
 
mov eax,[@@tz3]
sub eax,[@@tz2]
shl eax,SHIFT
cdq
idiv ebx
mov [@@z_dy23],eax
tt_dx23_done:
 
 
mov eax,[@@tx1]
shl eax,SHIFT
mov ebx,eax
mov ecx,[@@ty1]
 
mov edx,[@@tz1]
shl edx,SHIFT
mov [@@scan_z1],edx
mov [@@scan_z2],edx
 
mov edx,[@@tex_x1]
mov [@@scan_x1],edx
mov [@@scan_x2],edx
mov edx,[@@tex_y1]
mov [@@scan_y1],edx
mov [@@scan_y2],edx
 
; ****************
mov edx,[@@ty1] ;skip equals
cmp [@@ty2],edx
je tt_loop1_end
 
mov ebp,[@@ty1]
cmp ebp,0
jg no_up_clip
neg ebp
mov edx,[@@ty2]
cmp edx,0
jg no_sbx
neg edx
sub ebp,edx
no_sbx:
 
mov edx,[@@tex_dx13]
imul edx,ebp
add [@@scan_x1],edx
mov edx,[@@tex_dx12]
imul edx,ebp
add [@@scan_x2],edx
mov edx,[@@tex_dy13]
imul edx,ebp
add [@@scan_y1],edx
mov edx,[@@tex_dy12]
imul edx,ebp
add [@@scan_y2],edx
 
mov edx,[@@z_dy13]
imul edx,ebp
add [@@scan_z1],edx
mov edx,[@@z_dy12]
imul edx,ebp
add [@@scan_z2],edx
 
mov edx,[@@dx13]
imul edx,ebp
add eax,edx
mov edx,[@@dx12]
imul edx,ebp
add ebx,edx
add ecx,ebp
no_up_clip:
 
cmp [@@ty2],0
jl tt_loop1_end
 
tt_loop1:
cmp ecx,SCREEN_Y
jge tt_loop2_end
 
pushad
mov edx,[@@scan_y2]
mov [@@tex_ly2],edx ;push dx
mov edx,[@@scan_x2]
mov [@@tex_lx2],edx ;push dx
mov edx,[@@scan_y1]
mov [@@tex_ly1],edx ;push dx
mov edx,[@@scan_x1]
mov [@@tex_lx1],edx ;push dx
 
mov edx,[@@scan_z1]
mov [@@lz1],edx
mov edx,[@@scan_z2]
mov [@@lz2],edx
 
mov [@@ly],ecx ;push cx
mov edx,ebx
sar edx,SHIFT
mov [@@lx2],edx ;push dx
mov edx,eax
sar edx,SHIFT
mov [@@lx1],edx ; push dx
call textured_horizontal_line
popad
 
mov edx,[@@tex_dx13]
add [@@scan_x1],edx
mov edx,[@@tex_dx12]
add [@@scan_x2],edx
mov edx,[@@tex_dy13]
add [@@scan_y1],edx
mov edx,[@@tex_dy12]
add [@@scan_y2],edx
 
mov edx,[@@z_dy13]
add [@@scan_z1],edx
mov edx,[@@z_dy12]
add [@@scan_z2],edx
 
add eax,[@@dx13]
add ebx,[@@dx12]
inc ecx
cmp ecx,[@@ty2]
jl tt_loop1
 
tt_loop1_end:
 
mov ebx,[@@tx2]
shl ebx,SHIFT
mov ecx,[@@ty2]
 
mov edx,[@@tz2]
shl edx,SHIFT
mov [@@scan_z2],edx
 
mov edx,[@@tex_x2]
mov [@@scan_x2],edx
mov edx,[@@tex_y2]
mov [@@scan_y2],edx
 
mov ebp,[@@ty2]
cmp ebp,0
jg no_down_clip
neg ebp
dec ebp
 
mov edx,[@@tex_dx13]
imul edx,ebp
add [@@scan_x1],edx
mov edx,[@@tex_dx23]
imul edx,ebp
add [@@scan_x2],edx
mov edx,[@@tex_dy13]
imul edx,ebp
add [@@scan_y1],edx
mov edx,[@@tex_dy23]
imul edx,ebp
add [@@scan_y2],edx
 
mov edx,[@@z_dy13]
imul edx,ebp
add [@@scan_z1],edx
mov edx,[@@z_dy23]
imul edx,ebp
add [@@scan_z2],edx
 
mov edx,[@@dx13]
imul edx,ebp
add eax,edx
mov edx,[@@dx23]
imul edx,ebp
add ebx,edx
add ecx,ebp
no_down_clip:
 
tt_loop2:
cmp ecx,SCREEN_Y
jge tt_loop2_end
 
pushad
mov edx,[@@scan_y2]
mov [@@tex_ly2],edx ;push dx
mov edx,[@@scan_x2]
mov [@@tex_lx2],edx ;push dx
mov edx,[@@scan_y1]
mov [@@tex_ly1],edx ;push dx
mov edx,[@@scan_x1]
mov [@@tex_lx1],edx ;push dx
 
mov edx,[@@scan_z1]
mov [@@lz1],edx
mov edx,[@@scan_z2]
mov [@@lz2],edx
 
mov [@@ly],ecx ;push cx
mov edx,ebx
sar edx,SHIFT
mov [@@lx2],edx ;push dx
mov edx,eax
sar edx,SHIFT
mov [@@lx1],edx ; push dx
call textured_horizontal_line
popad
 
mov edx,[@@tex_dx13]
add [@@scan_x1],edx
mov edx,[@@tex_dx23]
add [@@scan_x2],edx
mov edx,[@@tex_dy13]
add [@@scan_y1],edx
mov edx,[@@tex_dy23]
add [@@scan_y2],edx
 
mov edx,[@@z_dy13]
add [@@scan_z1],edx
mov edx,[@@z_dy23]
add [@@scan_z2],edx
 
add eax,[@@dx13]
add ebx,[@@dx23]
inc ecx
cmp ecx,[@@ty3]
jl tt_loop2
 
tt_loop2_end:
ret
 
align 512
@@lx1 dd 0
align 512
@@lx2 dd 0
align 512
@@ly dd 0
 
@@lz1 dd 0
@@lz2 dd 0
@@z_dx dd 0
 
align 512
@@tex_loff dd 0 ;equ [bp+10]
@@tex_lx1 dd 0 ;equ [bp+12]
@@tex_ly1 dd 0 ;equ [bp+14]
@@tex_lx2 dd 0 ;equ [bp+16]
@@tex_ly2 dd 0 ;equ [bp+18]
 
align 512
@@tex_ldx dd 0 ;equ [bp-2]
@@tex_ldy dd 0 ;equ [bp-4]
 
align 1024
textured_horizontal_line:
 
mov eax,[@@lx1]
cmp eax,[@@lx2]
je thl_quit
jl thl_ok
 
xchg eax,[@@lx2]
mov [@@lx1],eax
 
mov eax,[@@lz1]
xchg eax,[@@lz2]
mov [@@lz1],eax
 
mov eax,[@@tex_lx1]
xchg eax,[@@tex_lx2]
mov [@@tex_lx1],eax
 
mov eax,[@@tex_ly1]
xchg eax,[@@tex_ly2]
mov [@@tex_ly1],eax
 
thl_ok:
 
cmp [@@lx2],0
jle thl_quit
mov eax,SCREEN_X
cmp [@@lx1],eax
jge thl_quit
 
mov ecx,[@@lx2]
sub ecx,[@@lx1]
 
; Uneversal method
mov edi,[@@ly]
mov eax,SCREEN_X ;di = ly*320+lx1
imul edi
add eax,[@@lx1]
imul eax,3
mov edi,eax
add edi,I_END
 
;Right side clipping
mov eax,SCREEN_X
cmp [@@lx2],eax
jnge x1ok
mov edx,SCREEN_X
dec edx
sub edx,[@@lx1]
cmp edx,0
jle thl_quit
mov ecx,edx
x1ok:
 
;Left side clipping
cmp [@@lx1],0
jg x2ok
mov ecx,[@@lx2] ;cmp lx2 screen x if above cut (for future)
mov edi,[@@ly]
mov eax,SCREEN_X
imul edi,eax
imul edi,3
add edi,I_END
x2ok:
 
mov ebx,[@@lx2]
sub ebx,[@@lx1]
 
mov eax,[@@tex_lx2]
sub eax,[@@tex_lx1]
cdq
idiv ebx
mov [@@tex_ldx],eax ; tex_dx = (tex_x2-tex_x1)/(x2-x1)
 
mov eax,[@@tex_ly2]
sub eax,[@@tex_ly1]
cdq
idiv ebx
mov [@@tex_ldy],eax ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
 
mov eax,[@@lz2]
sub eax,[@@lz1]
cdq
idiv ebx
mov [@@z_dx],eax ; tex_dx = (tex_x2-tex_x1)/(x2-x1)
 
; Left clipping post correction
cmp [@@lx1],0
jg no_lcpc
mov eax,[@@lx1]
neg eax
mov ebp,[@@tex_ldx]
imul ebp,eax
add [@@tex_lx1],ebp
mov ebp,[@@tex_ldy]
imul ebp,eax
add [@@tex_ly1],ebp
mov ebp,[@@z_dx]
imul ebp,eax
add [@@lz1],ebp
no_lcpc:
 
inc ecx ;for equal correction
mov edx,[@@tex_lx1]
mov ebx,[@@tex_ly1]
mov esi,[@@lz1]
 
thl_loop:
mov ebp,esi
shr ebp,SHIFT
mov eax,dword [edi-I_END+zbuffer]
cmp ax,bp
jb no_set
mov [edi-I_END+zbuffer],bp
 
mov eax,edx
; and eax,0x0fff0000
ror ebx,16
mov ax,bx
ror ebx,16
shl ax,11 ; 8 for 256*256, 9 for 128*128 ...
shr eax,11
lea eax,[eax*2+eax] ; equ imul eax,3
add eax,[@@tex_off]
mov ebp,eax
 
mov ax,word [ebp]
mov [edi],ax
mov al,byte [ebp+2]
mov [edi+2],al
 
no_set:
add edi,3
 
add esi,[@@z_dx]
add edx,[@@tex_ldx]
add ebx,[@@tex_ldy]
dec ecx
jnz thl_loop
thl_quit:
ret
 
 
@@rgb dd 0
@@rgbax dw 0
@@rgbbl db 0
 
; === DATA ===
 
d_angle dd 0.19634954 ;pi/16
angle dd 0.0
mul_wave dd 1.5
 
sin_pos dw 0
sinwave rw 256
 
Xmap dd 0
Ymap dd 0
mapoff dd 0
 
Xcam dd 0
Ycam dd 0
Zcam dd -400
 
Xcamangle dd 0
Ycamangle dd 0
Zcamangle dd 0
 
Xcamsin dd 0
Xcamcos dd 0
Ycamsin dd 0
Ycamcos dd 0
Zcamsin dd 0
Zcamcos dd 0
 
X dd ? ; X,Y,Z variable for formula
Y dd ?
Z dd ?
 
Xp dd ?
Yp dd ?
 
Xangle dd 0 ; Angle to rotate around x
Yangle dd 0
Zangle dd 0
 
DeltaX dd 1 ; x,y,z rotation angle
DeltaY dd 1
DeltaZ dd 1
 
Xoff dd 256 ; x-cord
Yoff dd 256 ; y-cord
Zoff dd 0;800 ; Distance from viewer
 
Xsin dd ? ; Sine and cosine of angle to rotate around
Xcos dd ?
Ysin dd ?
Ycos dd ?
Zsin dd ?
Zcos dd ?
 
Mx dd SCREEN_X/2 ; Center of the screen
My dd SCREEN_Y/2
 
autorot db 0 ;Auto rotation flag
massize dd 0 ;Size of triangle massive
id dd 0
temp dd 0
 
; DATA AREA
labelt:
db '3D TEXTURED ENGINE'
labellen:
 
 
;Texture pusck 32*32 256
texpack_gif:
file 'TEXPACK.gif'
rb 50
 
;Ground texture
bmp_texmap:
file 'TEXMAP.bmp'
rb 50
 
 
; Ground livel map
gif_file_area5:
file 'MAP.gif' ;level map
rb 50
 
rb 8
texture_limg:
rb 4095
texture_img:
rb 4095
texture_img2:
rb 4095
 
rb (4095)*16*16
 
img_area:
rb 128*128*3+8
 
glm_img_area:
rb (MAP_XSIZE+1)*(MAP_YSIZE+1)*3+8
 
rb 8
 
texpack_img:
rb 512*512*3+8
 
keymap:
rb 1000
 
model_mas:
rb 4+8*100
 
; Hash area for decoding GIF
gif_hash_area:
rd 4096+1
 
MAX_MODEL_POINTS = 100
modelpoints:
rb MAX_MODEL_POINTS*3*4
 
; Matrix points massive
points:
; Massive of turn matrix points
tpoints=points+((MATRIX_XSIZE+1)*(MATRIX_YSIZE+1)*3*4)
; Ground level map massive
ground_level_map=tpoints+((MATRIX_XSIZE+1)*(MATRIX_YSIZE+1)*3*4)
; zbuffer
zbuffer=ground_level_map+((MAP_XSIZE+1)*(MAP_YSIZE+1)*4)
I_END=zbuffer+(SCREEN_X*SCREEN_Y)*3
/programs/demos/3detx60b/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
words2reg ebx,x,xs ;x*65536+xs
words2reg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+36
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,6*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
words2reg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
words2reg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/3detx60b/trunk/ascl.inc
0,0 → 1,897
lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.14 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;Please compile aplications on FASM ver1.54 or higer!!!
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
;0.10 wordstoreg by halyavin, add at ~30.08.2004
; random bug deleted eax is use.
;0.11 loadfile from me +puttxt bug del ~07.09.2004
;0.12 open/save dialog ~13.09.2004
;0.13 dialogs bugs deleted
;0.14 drawlbut ~03.10.2004
;0.15 extendet label!
 
; LOADFILE
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area
 
 
macro loadfile file_name,file_load_area,file_temp_area
{
local open,fileinfo,string
jmp open
fileinfo:
dd 0
dd 0
dd 1
dd file_load_area
dd file_temp_area
string:
db file_name,0
open:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[file_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
}
 
 
;macro wordstoreg reg,hiword,loword
;{
;if hiword eqtype 0 & loword eqtype 0
; mov reg,dword hiword*65536+loword
;else if hiword eqtype 12 & loword eqtype eax
; mov reg,dword hiword*65536
; add reg,dword loword
;else if hiword eqtype 12 & loword eqtype [123]
; mov reg,dword hiword*65536
; add reg,dword loword
;else
; mov reg,dword hiword
; shl reg,16
; add reg,dword loword
;end if
;}
 
macro dword2reg reg,doubleword
{
if doubleword eq
; not changes
else
mov reg,dword doubleword
end if
}
 
macro words2reg reg,hiword,lowword
{
if hiword eq
if lowword eq
; not changes
else
if lowword eqtype 12
and reg,dword 0xffff0000
add reg,dword lowword
else
and reg,dword 0xffff0000
add reg,dword lowword
end if
end if
else
if lowword eq
if hiword eqtype 12
and reg,dword 0x0000ffff
add reg,dword hiword*65536
else
shl reg,16
add reg,dword hiword
ror reg,16
end if
else
if lowword eqtype 12 & hiword eqtype 12
if lowword eq 0 & hiword eq 0
xor reg,reg
else
mov reg,dword hiword*65536+lowword
end if
else
mov reg,dword hiword
shl reg,16
add reg,dword lowword
end if
end if
end if
}
 
 
 
 
; DRAW BUTTON with label
 
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
{
local asd,lab
jmp asd
lab db text ;arg label
asd:
words2reg ebx,x,xs
words2reg ecx,y,ys
mov edx,id
mov esi,bcolor
mov eax,8
int 0x40
 
mov eax,asd-lab ;calc size
mov ebx,6
mul ebx
mov esi,eax
 
mov eax,xs
sub eax,esi
shr eax,1
add eax,x
 
mov edx,ys
sub edx,7
shr edx,1
add edx,y
 
mov ebx,eax
shl ebx,16
add ebx,edx
 
mov ecx,tcolor ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
 
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 1024 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo
;run_filepath:
db '/RD/1/SYSXTREE',0
 
procinfo:
times 1024 db 0
}
 
 
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr rsx2
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
and eax,0000ffffh
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro puttxt x,y,offs,size,color
{
; mov ebx,x
; shl ebx,16
; add ebx,y
words2reg ebx,x,y
 
dword2reg ecx,color
dword2reg edx,offs
dword2reg esi,size
 
; mov ecx,color
; mov edx,offs
; mov esi,size
mov eax,4
int 0x40
}
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
; mov edx,x*65536+y
words2reg edx,x,y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
; mov ebx,arg1*65536+arg3
; mov ecx,arg2*65536+arg4
words2reg ebx,arg1,arg3
words2reg ecx,arg2,arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
; mov ebx,arg1 ;arg1=y arg2=x
; shl ebx,16
; add ebx,arg2
 
words2reg ebx,arg1,arg2
 
dword2reg ecx,arg4
 
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040ff
cl_Cyan equ 0x0040e0ff
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/3detx60b/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm 3detx60b.asm 3detx60b
@pause
/programs/demos/3detx60b/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm 3detx60b.asm 3detx60b
@pause
/programs/demos/3detx60b/trunk/map.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/3detx60b/trunk/texmap.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/3detx60b/trunk/texpack.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/3dtcub10/trunk/3DTCUB10.ASM
0,0 → 1,938
;
; 9 Ver Screen saver
; 5 Ver 24 bit texture.
; 23/8/2004
; Pavlushin Evgeni 3d cube screen saver
; mail: waptap@mail.ru site: www.deck4.narod.ru
;
; This programm develop on sample text3d to Mikolaj Felix 25/5/2001
; mfelix@polbox.com
;
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x200000 ; memory for app
dd 0x200000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
MAX_DEGS equ 512 ;quantity of angels 2^n.Minimize for speedup
MAX_POINTS equ 8 ;quantity of points
MAX_FACES equ 6 ;quantity of points
 
START:
finit
call draw_window
call clear_screen
call init_sincos
 
still:
mov eax,23 ; wait for system event with 2 ms timeout
mov ebx,2 ; wait 2 ms, then continue
int 0x40
 
; mov eax,11 ;If you want maximum speed! :)
; int 0x40
 
dec eax ; window redraw request ?
je red
dec eax ; key in buffer ?
je key
dec eax ; button in buffer ?
je button
 
main_loop:
call fade_texture
 
mov esi,cube
mov edi,cube_rotated
mov ecx,MAX_POINTS*3
copy_object:
fild word [esi]
fstp dword [edi]
add esi,2
add edi,4
dec ecx
jnz copy_object
 
mov esi,angle_x
mov edi,cube_rotated
mov ecx,MAX_POINTS
call rotate_points
mov esi,cube_rotated
mov edi,coord2d
mov ecx,MAX_POINTS
call translate_points
 
call draw_textured_faces
call clear_screen_buffer
 
add [angle_x],1
add [angle_y],3
add [angle_z],1
 
jmp still
 
red:
call draw_window
jmp still
key:
mov eax,2
jmp exit
button:
mov eax,17
int 0x40
cmp ah,1
jne still
exit:
mov eax,-1
int 0x40
 
;Draw window
draw_window:
mov eax,12 ;Start
mov ebx,1
int 0x40
 
mov eax,0 ;Draw window
mov ebx,0*65536+(799) ;x start*65536+x size
mov ecx,0*65536+(599) ;y start*65536+y size
mov edx,0x00000000 ;0x03 use skinned window
int 0x40
 
call clear_screen
 
mov eax,12 ;End
mov ebx,2
int 0x40
ret
 
head_label: db "3D TEXTURED CUBE THE LITTLE SCREEN SAVER FOR MENUETOS. USE "
db "800x600 SCREEN MODE FROM VIEW. PRESS ANY KEY FOR EXIT"
hl_end:
 
;FADE IN FADE OUT TEXTURE
 
x_step db 0
x_num db 1
 
fade_texture:
mov ecx,0
loox:
mov al,[file_texture+ecx]
mov [texture+ecx],al
inc ecx
cmp ecx,128*128*3
jnae loox
 
mov ecx,0
loox2:
mov al,[file_texture+ecx]
cmp [x_step],al
jae xxx
sub al,[x_step]
jmp nnn
xxx:
mov al,0
nnn:
mov [texture+ecx],al
inc ecx
cmp ecx,128*128*3
jnae loox2
 
cmp [x_step],255
jne no_max
mov [x_num],-1
no_max:
cmp [x_step],0
jne no_min
mov [x_num],1
no_min:
mov al,[x_num]
add [x_step],al
ret
 
; Clear Screen
clear_screen:
mov eax,13
mov ebx,0*65536+800
mov ecx,0*65536+600
mov edx,0
int 40h
 
mov eax,4 ;Out Text
mov ebx,8*65536+8 ;x start*65536+y start
mov ecx,0x00ffffff ;color White
mov edx,head_label
mov esi,hl_end-head_label
int 0x40
ret
 
clear_screen_buffer:
mov ebx,scrbuf
mov ecx,800*65536+(600-40) ;sub 40 for antiflickering title
mov edx,0*65536+40
mov eax,7
int 0x40
 
mov eax,4 ;Out Text
mov ebx,8*65536+580 ;x start*65536+y start
mov ebp,[n_step]
shl ebp,16
sub ebx,ebp
mov ecx,0x0000ff00 ;color White
mov edx,move_text
add edx,[step]
mov esi,130 ;mt_end-move_text
int 0x40
 
inc [n_step]
cmp [n_step],6
jna t_ok
mov [n_step],0
inc [step]
cmp [step],mt_end-move_text-130
jng t_ok
mov [step],0
t_ok:
 
mov edi,scrbuf
mov eax,0 ;black background
mov ecx,800*600*3/4 ; 16000
cld
rep stosd
ret
 
n_step dd 0
step dd 0
 
move_text: db " "
db " "
db " "
db "***** 3D TEXTURED CUBE THE LITTLE SCREEN SAVER FOR "
db "MENUET OS. SET 800x600 SCREEN MODE FROM VIEW THIS SCREEN "
db "SAVER ***** "
db "SITE OF THE RUSSIAN DEVELOPERS TO MENUETOS: "
db "www.menuet.narod.ru "
db "RUSSIAN MENUET APLICATION ARCHIVE PAGE ON: "
db "www.meosfiles.narod.ru "
db "AUTOR OF THIS SCREEN SAVER Pavlushin Evgeni "
db "MY SITE: www.deck4.narod.ru (Slow update) "
db "AND MAIL BOX: waptap@mail.ru "
db "THANK YOU FOR USE! "
db " "
db " "
db " "
mt_end:
 
 
;include graphlib.asm Mikolaj Felix 9/12/2000 mfelix@polbox.com
;Draw textured faces proc
 
@@rx1 dw 0 ;equ [bp-2]
@@ry1 dw 0 ;equ [bp-4]
@@rx2 dw 0 ;equ [bp-6]
@@ry2 dw 0 ;equ [bp-8]
@@rx3 dw 0 ;equ [bp-10]
@@ry3 dw 0 ;equ [bp-12]
@@rx4 dw 0 ;equ [bp-14]
@@ry4 dw 0 ;equ [bp-16]
 
draw_textured_faces:
mov esi,link
mov ecx,MAX_FACES
dtf_loop:
push ecx
 
xor ebx,ebx
mov bl,byte [esi] ; point 1
shl bx,2
mov eax,dword [coord2d+bx] ;COPY 1 FOURANGLE POINT
mov dword [@@rx1],eax
 
xor ebx,ebx
mov bl,byte [esi+1] ; point 2
shl bx,2
mov eax,dword [coord2d+bx] ;COPY 2 FOURANGLE POINT
mov dword [@@rx2],eax
 
xor ebx,ebx
mov bl,byte [esi+2] ; point 3
shl bx,2
mov eax,dword [coord2d+bx] ;COPY 3 FOURANGLE POINT
mov dword [@@rx3],eax
 
xor bh,bh ; point 4
mov bl,byte [esi+3]
shl bx,2
mov eax,dword [coord2d+bx] ;COPY 4 FOURANGLE POINT
mov dword [@@rx4],eax
 
mov ax,[@@ry1]
sub ax,[@@ry3]
mov bx,[@@rx2]
sub bx,[@@rx1]
imul bx
shl edx,16
mov dx,ax
push edx
mov ax,[@@rx1]
sub ax,[@@rx3]
mov bx,[@@ry2]
sub bx,[@@ry1]
imul bx
shl edx,16
mov dx,ax
pop ebx
sub ebx,edx ; normal_z = (y1-y3)*(x2-x1)-(x1-x3)*(y2-y1)
or ebx,ebx
jl dtf_next_face ; normal_z < 0
 
; FIRST PICE OF FOUR ANGLE
 
; Set 3 triangel puts for texture ycoord*65536+xcoord
mov dword [@@tex_x3],127*65536+127 ;3 point
mov dword [@@tex_x2],0*65536+127 ;2 point
mov dword [@@tex_x1],0*65536+0 ;1 point
; Set texture bitmap offset
mov [@@tex_off],texture
; Set 3 triangel puts coordinates
mov eax,dword [@@rx3]
mov dword [@@x3],eax
mov eax,dword [@@rx2]
mov dword [@@x2],eax
mov eax,dword [@@rx1]
mov dword [@@x1],eax
call textured_triangle
 
; SECOND PICE OF FOUR ANGLE
 
; Set 3 triangel puts for texture ycoord*65536+xcoord
mov dword [@@tex_x3],127*65536+0 ;3 point
mov dword [@@tex_x2],127*65536+127 ;2 point
mov dword [@@tex_x1],0*65536+0 ;1 point
; Set texture bitmap offset
mov [@@tex_off],texture
; Set 3 triangel puts coordinates
mov eax,dword [@@rx4]
mov dword [@@x3],eax
mov eax,dword [@@rx3]
mov dword [@@x2],eax
mov eax,dword [@@rx1]
mov dword [@@x1],eax
call textured_triangle
 
dtf_next_face:
add esi,4
pop ecx
dec ecx
jnz dtf_loop
ret
 
;include tex3.asm Mikolaj Felix 15/5/2001 mfelix@polbox.com
 
@@x1 dw 0 ;equ [bp+4]
@@y1 dw 0 ;equ [bp+6]
@@x2 dw 0 ;equ [bp+8]
@@y2 dw 0 ;equ [bp+10]
@@x3 dw 0 ;equ [bp+12]
@@y3 dw 0 ;equ [bp+14]
 
@@tex_off dd 0 ;equ [bp+16]
@@tex_x1 dw 0 ;equ [bp+18]
@@tex_y1 dw 0 ;equ [bp+20]
@@tex_x2 dw 0 ;equ [bp+22]
@@tex_y2 dw 0 ;equ [bp+24]
@@tex_x3 dw 0 ;equ [bp+26]
@@tex_y3 dw 0 ;equ [bp+28]
 
@@dx12 dw 0 ;equ [bp-2]
@@dx13 dw 0 ;equ [bp-4]
@@dx23 dw 0 ;equ [bp-6]
 
@@tex_dx12 dw 0 ;equ [bp-8]
@@tex_dy12 dw 0 ;equ [bp-10]
@@tex_dx13 dw 0 ;equ [bp-12]
@@tex_dy13 dw 0 ;equ [bp-14]
@@tex_dx23 dw 0 ;equ [bp-16]
@@tex_dy23 dw 0 ;equ [bp-18]
 
@@scan_x1 dw 0 ;equ [bp-20]
@@scan_y1 dw 0 ;equ [bp-22]
@@scan_x2 dw 0 ;equ [bp-24]
@@scan_y2 dw 0 ;equ [bp-26]
 
 
textured_triangle:
 
mov ax,[@@y1]
cmp ax,[@@y3]
jb tt_check1
 
xchg ax,[@@y3]
mov [@@y1],ax
 
mov ax,[@@x1]
xchg ax,[@@x3]
mov [@@x1],ax
 
mov ax,[@@tex_y1]
xchg ax,[@@tex_y3]
mov [@@tex_y1],ax
 
mov ax,[@@tex_x1]
xchg ax,[@@tex_x3]
mov [@@tex_x1],ax
tt_check1:
mov ax,[@@y2]
cmp ax,[@@y3]
jb tt_check2
 
xchg ax,[@@y3]
mov [@@y2],ax
 
mov ax,[@@x2]
xchg ax,[@@x3]
mov [@@x2],ax
 
mov ax,[@@tex_y2]
xchg ax,[@@tex_y3]
mov [@@tex_y2],ax
 
mov ax,[@@tex_x2]
xchg ax,[@@tex_x3]
mov [@@tex_x2],ax
tt_check2:
mov ax,[@@y1]
cmp ax,[@@y2]
jb tt_check3
 
xchg ax,[@@y2]
mov [@@y1],ax
 
mov ax,[@@x1]
xchg ax,[@@x2]
mov [@@x1],ax
 
mov ax,[@@tex_y1]
xchg ax,[@@tex_y2]
mov [@@tex_y1],ax
 
mov ax,[@@tex_x1]
xchg ax,[@@tex_x2]
mov [@@tex_x1],ax
tt_check3:
 
mov bx,[@@y2]
sub bx,[@@y1]
jnz tt_dx12_make
 
mov word [@@dx12],0
mov word [@@tex_dx12],0
mov word [@@tex_dy12],0
jmp tt_dx12_done
tt_dx12_make:
mov ax,[@@x2]
sub ax,[@@x1]
shl ax,7
cwd
idiv bx
mov [@@dx12],ax ; dx12 = (x2-x1)/(y2-y1)
 
mov ax,[@@tex_x2]
sub ax,[@@tex_x1]
shl ax,7
cwd
idiv bx
mov [@@tex_dx12],ax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
 
mov ax,[@@tex_y2]
sub ax,[@@tex_y1]
shl ax,7
cwd
idiv bx
mov [@@tex_dy12],ax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
tt_dx12_done:
 
mov bx,[@@y3]
sub bx,[@@y1]
jnz tt_dx13_make
 
mov word [@@dx13],0
mov word [@@tex_dx13],0
mov word [@@tex_dy13],0
jmp tt_dx13_done
tt_dx13_make:
mov ax,[@@x3]
sub ax,[@@x1]
shl ax,7
cwd
idiv bx
mov [@@dx13],ax ; dx13 = (x3-x1)/(y3-y1)
 
mov ax,[@@tex_x3]
sub ax,[@@tex_x1]
shl ax,7
cwd
idiv bx
mov [@@tex_dx13],ax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
 
mov ax,[@@tex_y3]
sub ax,[@@tex_y1]
shl ax,7
cwd
idiv bx
mov [@@tex_dy13],ax ; tex_dy13 = (tex_y3-tex_x1)/(y3-y1)
tt_dx13_done:
 
mov bx,[@@y3]
sub bx,[@@y2]
jnz tt_dx23_make
 
mov word [@@dx23],0
mov word [@@tex_dx23],0
mov word [@@tex_dy23],0
jmp tt_dx23_done
tt_dx23_make:
mov ax,[@@x3]
sub ax,[@@x2]
shl ax,7
cwd
idiv bx
mov [@@dx23],ax ; dx23 = (x3-x2)/(y3-y2)
 
mov ax,[@@tex_x3]
sub ax,[@@tex_x2]
shl ax,7
cwd
idiv bx
mov [@@tex_dx23],ax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
 
mov ax,[@@tex_y3]
sub ax,[@@tex_y2]
shl ax,7
cwd
idiv bx
mov [@@tex_dy23],ax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
tt_dx23_done:
 
 
mov ax,[@@x1]
shl ax,7
mov bx,ax
mov cx,[@@y1]
 
mov dx,[@@tex_x1]
shl dx,7
mov [@@scan_x1],dx
mov [@@scan_x2],dx
mov dx,[@@tex_y1]
shl dx,7
mov [@@scan_y1],dx
mov [@@scan_y2],dx
tt_loop1:
pushad
; push ax
; push bx
; push cx
 
mov dx,[@@scan_y2]
shr dx,7
mov [@@tex_ly2],dx ;push dx
mov dx,[@@scan_x2]
shr dx,7
mov [@@tex_lx2],dx ;push dx
mov dx,[@@scan_y1]
shr dx,7
mov [@@tex_ly1],dx ;push dx
mov dx,[@@scan_x1]
shr dx,7
mov [@@tex_lx1],dx ;push dx
mov ebp,dword [@@tex_off] ;push word ptr @@tex_off
mov [@@tex_loff],ebp
 
mov [@@ly],cx ;push cx
mov dx,bx
shr dx,7
mov [@@lx2],dx ;push dx
mov dx,ax
shr dx,7
mov [@@lx1],dx ; push dx
call textured_horizontal_line
 
; pop cx
; pop bx
; pop ax
popad
 
mov dx,[@@tex_dx13]
add [@@scan_x1],dx
mov dx,[@@tex_dx12]
add [@@scan_x2],dx
mov dx,[@@tex_dy13]
add [@@scan_y1],dx
mov dx,[@@tex_dy12]
add [@@scan_y2],dx
 
add ax,[@@dx13]
add bx,[@@dx12]
inc cx
cmp cx,[@@y2]
jb tt_loop1
 
mov bx,[@@x2]
shl bx,7
mov cx,[@@y2]
 
mov dx,[@@tex_x2]
shl dx,7
mov [@@scan_x2],dx
mov dx,[@@tex_y2]
shl dx,7
mov [@@scan_y2],dx
tt_loop2:
 
pushad
; push ax
; push bx
; push cx
 
mov dx,[@@scan_y2]
shr dx,7
mov [@@tex_ly2],dx ;push dx
mov dx,[@@scan_x2]
shr dx,7
mov [@@tex_lx2],dx ;push dx
mov dx,[@@scan_y1]
shr dx,7
mov [@@tex_ly1],dx ;push dx
mov dx,[@@scan_x1]
shr dx,7
mov [@@tex_lx1],dx ;push dx
mov ebp,dword [@@tex_off] ;push word ptr @@tex_off
mov [@@tex_loff],ebp
 
mov [@@ly],cx ;push cx
mov dx,bx
shr dx,7
mov [@@lx2],dx ;push dx
mov dx,ax
shr dx,7
mov [@@lx1],dx ; push dx
call textured_horizontal_line
 
; pop cx
; pop bx
; pop ax
popad
 
mov dx,[@@tex_dx13]
add [@@scan_x1],dx
mov dx,[@@tex_dx23]
add [@@scan_x2],dx
mov dx,[@@tex_dy13]
add [@@scan_y1],dx
mov dx,[@@tex_dy23]
add [@@scan_y2],dx
 
add ax,[@@dx13]
add bx,[@@dx23]
inc cx
cmp cx,[@@y3]
jb tt_loop2
ret
 
@@lx1 dw 0 ;equ [bp+4]
@@lx2 dw 0 ;equ [bp+6]
@@ly dw 0 ;equ [bp+8]
 
@@tex_loff dd 0 ;equ [bp+10]
@@tex_lx1 dw 0 ;equ [bp+12]
@@tex_ly1 dw 0 ;equ [bp+14]
@@tex_lx2 dw 0 ;equ [bp+16]
@@tex_ly2 dw 0 ;equ [bp+18]
 
@@tex_ldx dw 0 ;equ [bp-2]
@@tex_ldy dw 0 ;equ [bp-4]
 
textured_horizontal_line:
 
mov ax,[@@lx1]
cmp ax,[@@lx2]
je thl_quit
jb thl_ok
 
xchg ax,[@@lx2]
mov [@@lx1],ax
 
mov ax,[@@tex_lx1]
xchg ax,[@@tex_lx2]
mov [@@tex_lx1],ax
 
mov ax,[@@tex_ly1]
xchg ax,[@@tex_ly2]
mov [@@tex_ly1],ax
thl_ok:
 
; Fast method
; mov edi,0
; mov di,[@@ly] ;edi = calculating start of line
; mov ax,di
; shl di,6 ;ly*64
; shl ax,8 ;ly*256
; add di,ax ;di = (ly*64)+(ly*256)
; add di,[@@lx1] ;di = ly*320+lx1
; mov eax,edi
; shl eax,1
; add edi,eax
; add edi,scrbuf
 
; Uneversal method
movsx edi,[@@ly]
mov eax,800 ;di = ly*320+lx1
mul edi
movsx ebx,[@@lx1]
add eax,ebx ;[@@lx1]
mov edi,3
mul edi
mov edi,eax
add edi,scrbuf
 
mov cx,[@@lx2]
sub cx,[@@lx1]
 
mov ax,[@@tex_lx2]
sub ax,[@@tex_lx1]
shl ax,7
cwd
idiv cx
mov [@@tex_ldx],ax ; tex_dx = (tex_x2-tex_x1)/(x2-x1)
 
mov ax,[@@tex_ly2]
sub ax,[@@tex_ly1]
shl ax,7
cwd
idiv cx
mov [@@tex_ldy],ax ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
 
cld
inc cx
mov ax,[@@tex_lx1]
shl ax,7
mov bx,[@@tex_ly1]
shl bx,7
 
thl_loop:
mov dx,ax
push bx
 
and bx,0ff80h
shr ax,7
add bx,ax
mov ebp,0
mov bp,bx
mov eax,ebp
shl eax,1
add ebp,eax
add ebp,[@@tex_loff]
 
mov al,byte [ebp+2]
stosb
mov al,byte [ebp+1]
stosb
mov al,byte [ebp]
stosb
 
pop bx
mov ax,dx
 
add ax,[@@tex_ldx]
add bx,[@@tex_ldy]
dec cx
jnz thl_loop
thl_quit:
ret
 
;include math3d_2.asm
; Mikolaj Felix 20/06/2001
; mfelix@polbox.com
 
;------------------------------------------------------------
; ds:si - offset to angles (int)
; ds:di - offset to array of 3d points
; cx - number of points
;------------------------------------------------------------
 
@@sin_x dd 0 ;equ dword ptr [bp-4]
@@cos_x dd 0 ;equ dword ptr [bp-8]
@@sin_y dd 0 ;equ dword ptr [bp-12]
@@cos_y dd 0 ;equ dword ptr [bp-16]
@@sin_z dd 0 ;equ dword ptr [bp-20]
@@cos_z dd 0 ;equ dword ptr [bp-24]
 
@@x equ dword [edi]
@@y equ dword [edi+4]
@@z equ dword [edi+8]
 
rotate_points:
 
push edi
mov edi,@@sin_x
mov edx,3
rp_sin_cos:
mov bx,word [esi]
and bx,MAX_DEGS-1
shl bx,2
mov eax,dword [sintab+bx]
mov dword [edi],eax
mov eax,dword [costab+bx]
mov dword [edi+4],eax
add edi,8
add esi,2
dec edx
jnz rp_sin_cos
pop edi
 
rp_rotate:
fld @@y
fmul [@@cos_x]
fld @@z
fmul [@@sin_x]
fsubp st1,st
fld @@y
fxch st1
fstp @@y ; Yrotated = Cos (A)*Y - Sin (A)*Z
fmul [@@sin_x]
fld @@z
fmul [@@cos_x]
faddp st1,st
fstp @@z ; Zrotated = Sin (A)*Y + Cos (A)*Z
fld @@x
fmul [@@cos_y]
fld @@z
fmul [@@sin_y]
fsubp st1,st
fld @@x
fxch st1
fstp @@x ; Xrotated = Cos (A)*X - Sin (A)*Z
fmul [@@sin_y]
fld @@z
fmul [@@cos_y]
faddp st1,st
fstp @@z ; Zrotated = Sin (A)*X + Cos (A)*Z
fld @@x
fmul [@@cos_z]
fld @@y
fmul [@@sin_z]
fsubp st1,st
fld @@x
fxch st1
fstp @@x ; Xrotated = Cos (A)*X - Sin (A)*Y
fmul [@@sin_z]
fld @@y
fmul [@@cos_z]
faddp st1,st
fstp @@y ; Yrotated = Sin (A)*X + Cos (A)*Y
 
add edi,12
dec ecx
jnz rp_rotate
ret
;------------------------------------------------------------
; ds:si - offset to array of 3d points
; ds:di - offset to 2d points
; cx - number of points
;------------------------------------------------------------
 
translate_points:
 
fld dword [esi+8]
fadd [perspective]
 
fld dword [esi]
fmul [perspective]
fdiv st,st1
fadd [correct_x]
fistp word [edi] ; x2d = (x*persp)/(z+persp)+correct_x
 
fld dword [esi+4]
fmul [perspective]
fdivrp st1,st
fadd [correct_y]
fistp word [edi+2] ; y2d = (y*persp)/(z+persp)+correct_y
 
add esi,12
add edi,4
dec ecx
jnz translate_points
ret
 
; initalize SIN&COS table
 
@@temp1 dd 0 ;dword ptr [bp-4]
@@temp2 dd 0 ;dword ptr [bp-8]
 
init_sincos:
mov [@@temp1],0
fldpi
mov [@@temp2],MAX_DEGS/2
fidiv [@@temp2]
fstp [@@temp2]
 
xor edi,edi
mov ecx,MAX_DEGS
isc_loop:
fld [@@temp1]
fld st0
fld st0
fsin
fstp dword [sintab+edi]
fcos
fstp dword [costab+edi]
fadd [@@temp2]
fstp [@@temp1]
 
add edi,4
dec ecx
jnz isc_loop
ret
 
perspective dd 256.0
correct_x dd 400.0
correct_y dd 300.0
 
angle_x dw 0
angle_y dw 0
angle_z dw 0
 
file_texture:
file 'texture.raw'
 
cube dw -50,-50,50, 50,-50,50, 50,50,50, -50,50,50
dw -50,-50,-50, 50,-50,-50, 50,50,-50, -50,50,-50
 
link db 0,1,2,3, 5,4,7,6, 1,5,6,2, 4,0,3,7, 4,5,1,0, 3,2,6,7
 
sintab:
rd MAX_DEGS
costab:
rd MAX_DEGS
 
cube_rotated:
rd MAX_POINTS*3
coord2d:
rw MAX_POINTS*2
texture:
rb 128*128*3
scrbuf:
 
I_END:
/programs/demos/3dtcub10/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm 3dtcub10.asm 3dtcub10
@pause
/programs/demos/3dtcub10/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm 3dtcub10.asm 3dtcub10
@pause
/programs/demos/3dtcub10/trunk/texture.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/aclock/trunk/Readme.txt
0,0 → 1,85
AClock 1.1
Copyright (c) 2002,2003 Thomas Mathys
killer@vantage.ch
 
 
what the hell is this ?
-----------------------
 
this is aclock, a silly analog clock application
for menuetos (http://www.menuetos.org).
 
 
why do i need it ?
------------------
 
well, this is certainly one of the last programs on
earth you'd ever need. anyway, it demonstrates how
how to do certain things:
 
- writing menuet apps that parse the command line.
includes a strtok-like function that you might
want to use in own projects. or maybe rather not.
- writing menuet apps that are aware of the current
window size and that have no problems with different
skin heights.
- how to write menuet apps with nasm instead of fasm
(there should be a gas version aswell, don't you think ?)
and how to write kick-ass code with nasm in general =)
 
 
compiling instructions
----------------------
 
yes, it's still written for nasm.
i really can't be bothered to work with fasm.
 
oh yes, you wanted to know how to compile aclock:
 
nasm -t -f bin -o aclock aclock.asm
if you get error messages like
 
nasm: unrecognised option `-t
type `nasm -h' for help
 
then you've got an old version of nasm.
get a newer version (0.98.36 or later) from
http://nasm.sourceforge.net
 
 
configuration
-------------
 
you might want to change some of the constants defined
somewhere at the top of aclock.asm. the following might
be useful:
 
- DEFAULT_XPOS
- DEFAULT_YPOS
- DEFAULT_WIDTH
- DEFAULT_HEIGHT
- MIN_WIDTH
- MIN_HEIGHT
for more info about DEFAULT_XPOS/DEFAULT_YPOS see next
section.
 
 
usage
-----
 
this version of AClock introduces command line parameters.
here's an example command line:
 
aclock w128 h128 x20 y-20
this creates a window that is 128 pixels wide and 128 pixels
high (that's for the work area, without border/title bar).
the window is placed at x=20, y=screen resolution-20
(because of the minus sign after the y).
 
all parameters are optional and may appear in any order.
you can't have any whitespaces in a parameter, e.g.
"w 128" is an invalid parameter (which will simply be ignored).
the command line parser is case sensitive.
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/aclock.asm
0,0 → 1,223
; aclock 1.1
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
bits 32
%include 'mos.inc'
section .text
 
 
;********************************************************************
; configuration stuff
;********************************************************************
 
%define APPNAME "AClock 1.1"
%define STACKSIZE 1024
 
; default window position/dimensions (work area)
%define DEFAULT_XPOS -20
%define DEFAULT_YPOS 20
%define DEFAULT_WIDTH 80
%define DEFAULT_HEIGHT 80
 
; minimal size (horizontal and vertical) of work area
%define MIN_WIDTH 80
%define MIN_HEIGHT 80
 
 
;********************************************************************
; header
;********************************************************************
MOS_HEADER01 main,image_end,memory_end,stacktop-4,cmdLine,0
 
; these includes introduce code and thus mustn't stand
; before the menuet header =)
%include 'dbgboard.inc'
%include 'strlen.inc'
%include 'str2dwrd.inc'
%include 'strtok.inc'
%include 'cmdline.inc'
%include 'adjstwnd.inc'
%include 'draw.inc'
 
;********************************************************************
; main program
;********************************************************************
main:
call getDefaultWindowColors
call parseCommandLine
 
; check minimal window dimensions
cmp dword [wndWidth],MIN_WIDTH
jae .widthok
mov dword [wndWidth],MIN_WIDTH
.widthok:
cmp dword [wndHeight],MIN_HEIGHT
jae .heightok
mov dword [wndHeight],MIN_HEIGHT
.heightok:
 
; adjust window dimensions
mov eax,ADJSTWND_TYPE_SKINNED
mov ebx,[wndXPos]
mov ecx,[wndYPos]
mov edx,[wndWidth]
mov esi,[wndHeight]
call adjustWindowDimensions
mov [wndXPos],ebx
mov [wndYPos],ecx
mov [wndWidth],edx
mov [wndHeight],esi
 
call drawWindow
.msgpump:
call drawClock
 
; wait up to a second for next event
mov eax,MOS_SC_WAITEVENTTIMEOUT
mov ebx,100
int 0x40
 
cmp eax,MOS_EVT_REDRAW
je .redraw
cmp eax,MOS_EVT_KEY
je .key
cmp eax,MOS_EVT_BUTTON
je .button
jmp .msgpump
 
.redraw:
call drawWindow
jmp .msgpump
.key:
mov eax,MOS_SC_GETKEY
int 0x40
jmp .msgpump
.button:
mov eax,MOS_SC_EXIT
int 0x40
jmp .msgpump
 
 
;********************************************************************
; get default window colors
; input : nothing
; output : wndColors contains default colors
; destroys : nothing
;********************************************************************
getDefaultWindowColors:
pushad
pushfd
mov eax,MOS_SC_WINDOWPROPERTIES
mov ebx,3
mov ecx,wndColors
mov edx,MOS_WNDCOLORS_size
int 0x40
popfd
popad
ret
 
 
;********************************************************************
; define and draw window
; input nothing
; output nothing
; destroys flags
;********************************************************************
align 4
drawWindow:
pusha
 
; start window redraw
mov eax,MOS_SC_REDRAWSTATUS
mov ebx,1
int 0x40
 
; create window
mov eax,MOS_SC_DEFINEWINDOW
mov ebx,[wndXPos]
shl ebx,16
or ebx,[wndWidth]
mov ecx,[wndYPos]
shl ecx,16
or ecx,[wndHeight]
mov edx,[wndColors+MOS_WNDCOLORS.work]
or edx,0x03000000
mov esi,[wndColors+MOS_WNDCOLORS.grab]
mov edi,[wndColors+MOS_WNDCOLORS.frame]
int 0x40
 
; draw window label
mov eax,MOS_SC_WRITETEXT
mov ebx,MOS_DWORD(8,8)
mov ecx,[wndColors+MOS_WNDCOLORS.grabText]
mov edx,label
mov esi,LABEL_LEN
int 0x40
call drawClock
; end window redraw
mov eax,MOS_SC_REDRAWSTATUS
mov ebx,2
int 0x40
popa
ret
 
 
;********************************************************************
; initialized data
;********************************************************************
 
; window position and dimensions.
; dimensions are for work area only.
wndXPos dd DEFAULT_XPOS
wndYPos dd DEFAULT_YPOS
wndWidth dd DEFAULT_WIDTH
wndHeight dd DEFAULT_HEIGHT
 
; window label
label db APPNAME,0
LABEL_LEN equ ($-label-1)
 
; token delimiter list for command line
delimiters db 9,10,11,12,13,32,0
 
; don't insert anything after this label
image_end:
 
 
;********************************************************************
; uninitialized data
;********************************************************************
section .bss
 
wndColors resb MOS_WNDCOLORS_size
procInfo resb MOS_PROCESSINFO_size
 
; space for command line. at the end we have an additional
; byte for a terminating zero, just to be sure...
cmdLine resb 257
 
alignb 4
stack resb STACKSIZE
stacktop:
 
; don't insert anything after this label
memory_end:
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/aclock.bmp
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/aclock/trunk/adjstwnd.inc
0,0 → 1,147
; adjustWindowDimensions
; adjust menut window dimensions to get a certain work area size.
; or so. who on earth cares anyway, i certinaly don't, i'm just
; writing this code because i've got to kill time somehow...
;
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _ADJSTWND_INC
%define _ADJSTWND_INC
 
 
;window types
ADJSTWND_TYPE_SKINNED equ 0
 
 
;********************************************************************
; adjust window dimensions to get a certain work area size
;
; - first the window width and height are adjusted
; and clamped if they're too large for the screen.
; - then the window positions are adjusted, if the
; window goes out of the screen.
;
; input:
; eax window type, one of the ADJSTWND_TYPE_xxx constants
; ebx window x position
; ecx window y position
; edx desired work area width
; esi desired work area height
;
; output:
; eax return code. 0 = ok, -1 = invalid window type
; ebx adjusted window x position
; ecx adjusted window y position
; edx window width to get desired work area width
; esi window height to get desired work area height
;
; destroys:
; nothing
;
; normally x and y are the upper left corner of the window,
; relative to the upper left corner of the screen.
; if you pass a negative x or y it will be treated as the
; lower right corner of the window, relative to the lower
; right corner of the screen.
;********************************************************************
adjustWindowDimensions:
push edi
push ebp
pushfd
 
; adjust window dimensions, depending on the window type
cmp eax,ADJSTWND_TYPE_SKINNED
je .adjust_skinned
mov eax,-1 ; invalid window type,
jmp .bye ; return error code
 
; clamp window dimensions
.clamp:
mov eax,MOS_SC_GETSCREENMAX ; get screen dimensions
int 0x40
mov edi,eax ; edi = screen width
shr edi,16
mov ebp,eax ; ebp = screen height
and ebp,0xffff
cmp edx,edi ; window width > screen width ?
jna .widthok
mov edx,edi ; yes -> use screen width
.widthok:
cmp esi,ebp ; wnd height > screen height ?
jna .heightok
mov esi,ebp ; yes -> use screen height
.heightok:
 
; adjust x position
or ebx,ebx ; do the lower right corner
jns .foo ; stuff if x is negative.
add ebx,edi
sub ebx,edx
.foo:
or ebx,ebx ; x < 0 ?
jns .xnotnegative
xor ebx,ebx ; yes -> x = 0
.xnotnegative:
mov eax,ebx ; x + width > screen width ?
add eax,edx
cmp eax,edi
jna .xok
sub eax,edi ; yes -> adjust
sub ebx,eax
.xok:
 
; adjust y position
or ecx,ecx ; do the lower right corner
jns .bar ; stuff if y is negative.
add ecx,ebp
sub ecx,esi
.bar:
or ecx,ecx ; y < 0 ?
jns .ynotnegative
xor ecx,ecx ; yes -> y = 0
.ynotnegative:
mov eax,ecx ; y + height > screen height ?
add eax,esi
cmp eax,ebp
jna .yok
sub eax,ebp ; yes -> adjust
sub ecx,eax
.yok:
 
.done:
xor eax,eax
.bye:
popfd
pop ebp
pop edi
ret
 
.adjust_skinned:
; adjust width (edx)
add edx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT
; adjust height (esi). we need the skin height to do this.
push ebx
mov eax,MOS_SC_WINDOWPROPERTIES
mov ebx,4
int 0x40
lea esi,[esi+eax+MOS_WND_SKIN_BORDER_BOTTOM]
pop ebx
jmp .clamp
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/cmdline.inc
0,0 → 1,151
; command line parsing code for aclock
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _CMDLINE_INC
%define _CMDLINE_INC
 
 
;********************************************************************
; parse the command line
; input : nothing
; output : wndXPos, wndYPos, wndWidth, wndHeight
; are changed.
; destroys : nothing
;********************************************************************
parseCommandLine:
pushad
pushfd
 
; terminate command line, just to be sure
mov byte [cmdLine + 256],0
 
; go through all tokens
mov eax,cmdLine ; eax -> command line
.parseloop:
mov ebx,delimiters ; ebx -> token delimiter list
call strtok ; get next parameter
or eax,eax ; no more parameters ?
jz .nomoretokens
mov cl,[eax] ; get 1st char of parameter
cmp cl,'x' ; which parameter is it ?
je .param_x
cmp cl,'y'
je .param_y
cmp cl,'w'
je .param_w
cmp cl,'h'
je .param_h
; if we reach this line it's an unknown parameter, ignore it
.nextparam:
xor eax,eax ; set eax = 0 to continue
jmp .parseloop ; after last token.
.nomoretokens:
DBG_BOARD_PRINTDWORD [wndXPos]
DBG_BOARD_PRINTCHAR 32
DBG_BOARD_PRINTDWORD [wndYPos]
DBG_BOARD_PRINTCHAR 32
DBG_BOARD_PRINTDWORD [wndWidth]
DBG_BOARD_PRINTCHAR 32
DBG_BOARD_PRINTDWORD [wndHeight]
DBG_BOARD_PRINTNEWLINE
popfd
popad
ret
 
; eax -> first character of the parameter
.param_x:
push eax
call parsePositionParam
mov [wndXPos],eax
pop eax
jmp .nextparam
 
; eax -> first character of the parameter
.param_y:
push eax
call parsePositionParam
mov [wndYPos],eax
pop eax
jmp .nextparam
 
; eax -> first character of the parameter
.param_w:
push eax
call parseSizeParam
mov [wndWidth],eax
pop eax
jmp .nextparam
 
; eax -> first character of the parameter
.param_h:
push eax
call parseSizeParam
mov [wndHeight],eax
pop eax
jmp .nextparam
 
; parse position parameter
; input : eax = address of first character of parameter
; output : eax contains position
; destroys : nothing
parsePositionParam:
push ebx
push esi
pushfd
 
; is the second char of the parameter a '-' ?
inc eax
xor ebx,ebx ; assume it isn't
cmp byte [eax],'-'
jne .nominus
mov ebx,1 ; yes -> set flag...
inc eax ; ...and move to next char
.nominus:
 
; convert rest of parameter to doubleword
mov esi,eax
call string2dword
 
; negate if necessary
or ebx,ebx
jz .rotationshyperboloid
neg eax
.rotationshyperboloid:
 
popfd
pop esi
pop ebx
ret
 
; parse dimension parameter
; input : eax = address of first char of parameter
; output : eax contains dimension
; destroys : nothing
parseSizeParam:
push esi
pushfd
lea esi,[eax + 1] ; esi -> 2nd char of parameter
call string2dword
popfd
pop esi
ret
 
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/dbgboard.inc
0,0 → 1,200
; macros to write stuff to menuet's debug message board.
; the macros don't change any registers, not even flags.
; they take only effect if DEBUG is defined.
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _DBGBOARD_INC
%define _DBGBOARD_INC
 
 
%ifdef DEBUG
 
 
;********************************************************************
; print newline
; no input
;********************************************************************
%macro DBG_BOARD_PRINTNEWLINE 0
call dbg_board_printnewline
%endm
 
 
;********************************************************************
; print a character
;
; examples : DBG_BOARD_PRINTCHAR '?'
; DBG_BOARD_PRINTCHAR 65
; DBG_BOARD_PRINTCHAR cl
; DBG_BOARD_PRINTCHAR [esi]
; DBG_BOARD_PRINTCHAR [somevariable]
;********************************************************************
%macro DBG_BOARD_PRINTCHAR 1
push ecx
mov cl,byte %1
call dbg_board_printchar
pop ecx
%endm
 
 
 
;********************************************************************
; print a dword (in hex)
;
; examples: DBG_BOARD_PRINTDWORD esp
; DBG_BOARD_PRINTDWORD 0xdeadbeef
; DBG_BOARD_PRINTDWORD [somevariable]
;********************************************************************
%macro DBG_BOARD_PRINTDWORD 1
push dword %1
call dbg_board_printdword
%endm
 
 
;********************************************************************
; print a string literal
; a terminating zero is automagically appended to the string.
;
; examples DBG_BOARD_PRINTSTRINGLITERAL "foo",0
; DBG_BOARD_PRINTSTRINGLITERAL "bar",10,13,0
;********************************************************************
%macro DBG_BOARD_PRINTSTRINGLITERAL 1+
jmp %%bar
%%foo db %1, 0 ; terminate string, just to be sure
%%bar:
push dword %%foo
call dbg_board_printstring
%endm
 
 
;********************************************************************
; print a string (asciiz)
;
; examples DBG_BOARD_PRINTSTRING addressofstring
; DBG_BOARD_PRINTSTRING esi
; DBG_BOARD_PRINTSTRING [ebx]
;********************************************************************
%macro DBG_BOARD_PRINTSTRING 1
push dword %1
call dbg_board_printstring
%endm
 
 
; no input
dbg_board_printnewline:
pushad
pushfd
mov eax,MOS_SC_DEBUGBOARD
mov ebx,1
mov ecx,10
int 0x40
mov ecx,13
int 0x40
popfd
popad
ret
; input : cl = character to print
dbg_board_printchar:
pushad
pushfd
mov eax,MOS_SC_DEBUGBOARD
mov ebx,1
and ecx,0xff
int 0x40
popfd
popad
ret
 
; input : dword to print on stack
dbg_board_printdword:
enter 0,0
pushad
pushfd
mov eax,MOS_SC_DEBUGBOARD
mov ebx,1
mov ecx,'0' ; print 0x prefix
int 0x40
mov ecx,'x'
int 0x40
mov edx,[ebp + 8] ; get dword to print
mov esi,8 ; iterate through all nibbles
.loop:
mov ecx,edx ; display hex digit
shr ecx,28
movzx ecx,byte [dbg_board_printdword_digits + ecx]
int 0x40
shl edx,4 ; next nibble
dec esi
jnz .loop
popfd
popad
leave
ret 4
dbg_board_printdword_digits:
db '0','1','2','3','4','5','6','7'
db '8','9','a','b','c','d','e','f'
 
; input : address of string (asciiz) to print on stack
dbg_board_printstring:
enter 0,0
pushad
pushfd
cld
mov esi,[ebp + 8] ; esi -> string
mov ebx,1
.loop:
lodsb ; get character
or al,al ; zero ?
je .done ; yeah -> get outta here
movzx ecx,al ; nope -> display character
mov eax,MOS_SC_DEBUGBOARD
int 0x40
jmp .loop
.done:
popfd
popad
leave
ret 4
%else
 
 
%macro DBG_BOARD_PRINTNEWLINE 0
%endm
 
%macro DBG_BOARD_PRINTCHAR 1
%endm
 
%macro DBG_BOARD_PRINTDWORD 1
%endm
 
%macro DBG_BOARD_PRINTSTRINGLITERAL 1+
%endm
 
%macro DBG_BOARD_PRINTSTRING 1
%endm
 
%endif
 
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/draw.inc
0,0 → 1,430
; drawing code for aclock
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _DRAW_INC
%define _DRAW_INC
 
 
TMR1_FACTOR dd 0.45
TMR2_FACTOR dd 0.426315789
SECR_FACTOR dd 0.378947368
MINR_FACTOR dd 0.355263158
HOURR_FACTOR dd 0.189473684
DATE_FACTOR dd 0.1
 
 
monthNames:
db "Jan"
db "Feb"
db "Mar"
db "Apr"
db "May"
db "Jun"
db "Jul"
db "Aug"
db "Sep"
db "Oct"
db "Nov"
db "Dec"
 
 
;********************************************************************
; draws the clock
; input : nothing
; output : nothing
; destroys : nothing
;********************************************************************
drawClock:
%push drawClock_context
%stacksize flat
%assign %$localsize 0
 
%local i:dword, \
TMR1X:dword, \
TMR1Y:dword, \
TMR2X:dword, \
TMR2Y:dword, \
SECRX:dword, \
SECRY:dword, \
MINRX:dword, \
MINRY:dword, \
HOURRX:dword, \
HOURRY:dword, \
workwidth:dword, \
workheight:dword, \
foo:dword
enter %$localsize,0
pushad
pushfd
 
; get window dimensions
mov eax,MOS_SC_GETPROCESSINFO
mov ebx,procInfo
mov ecx,-1
int 0x40
 
; calculate work area size (width/height = ecx/edx)
; if the work area is too small (maybe the window is shaded)
; we don't draw anything.
mov eax,MOS_SC_WINDOWPROPERTIES
mov ebx,4 ; get skin height (eax)
int 0x40
mov ecx,[procInfo + MOS_PROCESSINFO.wndWidth]
sub ecx,MOS_WND_SKIN_BORDER_LEFT+MOS_WND_SKIN_BORDER_RIGHT
mov edx,[procInfo + MOS_PROCESSINFO.wndHeight]
sub edx,eax
sub edx,MOS_WND_SKIN_BORDER_BOTTOM
cmp ecx,0 ; width too small ?
jle .bye
cmp edx,0 ; height too small ?
jnle .continue
.bye:
jmp .byebye
.continue:
mov [workwidth],ecx ; save for later (for fpu)
mov [workheight],edx
 
; calculate center of clock (x/y = esi/edi)
mov esi,[procInfo + MOS_PROCESSINFO.wndWidth]
shr esi,1
mov edi,[procInfo + MOS_PROCESSINFO.wndHeight]
sub edi,MOS_WND_SKIN_BORDER_BOTTOM
sub edi,eax
shr edi,1
add edi,eax
 
; clear work area
pushad
mov ebx,(MOS_WND_SKIN_BORDER_LEFT)*0x10000 ; x start
or ebx,ecx ; width
mov ecx,eax ; y start
shl ecx,16 ; (=skin height)
or ecx,edx ; height
mov edx,[wndColors + MOS_WNDCOLORS.work]
mov eax,MOS_SC_DRAWBAR
int 0x40
popad
 
; calculate second hand radii
fild dword [workwidth]
fmul dword [SECR_FACTOR]
fstp dword [SECRX]
fild dword [workheight]
fmul dword [SECR_FACTOR]
fstp dword [SECRY]
 
; calculate minute hand radii
fild dword [workwidth]
fmul dword [MINR_FACTOR]
fstp dword [MINRX]
fild dword [workheight]
fmul dword [MINR_FACTOR]
fstp dword [MINRY]
 
; calculate hour hand radii
fild dword [workwidth]
fmul dword [HOURR_FACTOR]
fstp dword [HOURRX]
fild dword [workheight]
fmul dword [HOURR_FACTOR]
fstp dword [HOURRY]
 
; calculate tick mark radii
fild dword [workwidth]
fmul dword [TMR1_FACTOR]
fstp dword [TMR1X]
fild dword [workheight]
fmul dword [TMR1_FACTOR]
fstp dword [TMR1Y]
fild dword [workwidth]
fmul dword [TMR2_FACTOR]
fstp dword [TMR2X]
fild dword [workheight]
fmul dword [TMR2_FACTOR]
fstp dword [TMR2Y]
 
; get system clock (edx)
mov eax,MOS_SC_GETSYSCLOCK
int 0x40
mov edx,eax
 
; draw second hand
push edx
mov eax,edx
shr eax,16
call bcdbin
mov ecx,eax ; save seconds for later
push ecx
push eax
fpush32 0.104719755 ; 2*pi/60
push dword [SECRX]
push dword [SECRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16
or ebx,esi
shl ecx,16
or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText]
int 0x40
pop ecx
pop edx
 
; draw minute hand
push edx
mov eax,edx
shr eax,8
call bcdbin
mov edx,60
mul edx
add eax,ecx
mov ecx,eax ; save for later
push ecx
push eax
fpush32 0.001745329 ; 2*pi/60/60
push dword [MINRX]
push dword [MINRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16
or ebx,esi
shl ecx,16
or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText]
int 0x40
pop ecx
pop edx
 
; draw hour hand
push edx
mov eax,edx
call bcdbin
cmp eax,11 ; % 12 (just to be sure)
jnae .hoursok
sub eax,12
.hoursok:
mov edx,60*60
mul edx
add eax,ecx
push eax
fpush32 0.000145444 ; 2*pi/60/60/12
push dword [HOURRX]
push dword [HOURRY]
push esi
push edi
call getHandCoords
mov eax,MOS_SC_DRAWLINE
shl ebx,16
or ebx,esi
shl ecx,16
or ecx,edi
mov edx,[wndColors + MOS_WNDCOLORS.workText]
int 0x40
pop edx
; draw tick marks
mov dword [i],11 ; draw 12 marks
.drawtickmarks:
push dword [i] ; calculate start point
fpush32 0.523598776 ; 2*pi/12
push dword [TMR1X]
push dword [TMR1Y]
push esi
push edi
call getHandCoords
mov eax,ebx ; save in eax and edx
mov edx,ecx
push dword [i]
fpush32 0.523598776 ; 2*pi/12
push dword [TMR2X]
push dword [TMR2Y]
push esi
push edi
call getHandCoords
shl eax,16
shl edx,16
or ebx,eax ; ebx = x start and end
or ecx,edx ; ecx = y start and end
mov edx,[wndColors + MOS_WNDCOLORS.workText]
mov eax,MOS_SC_DRAWLINE
int 0x40
dec dword [i]
jns .drawtickmarks
 
%define DATE_WIDTH 48
 
; calculate text start position
mov eax,[procInfo+MOS_PROCESSINFO.wndWidth]
sub eax,DATE_WIDTH ; x = (wndwidth-textwidth)/2
shr eax,1 ; eax = x
fild dword [workheight] ; y = DATE_FACTOR*workheight...
fmul dword [DATE_FACTOR]
mov [foo],edi ; ... + y_clockcenter
fiadd dword [foo]
fistp dword [foo]
mov ebx,[foo] ; ebx = y
 
; draw text at all ?
cmp dword [workwidth],DATE_WIDTH ; text too wide ?
jb .goodbye
mov ecx,ebx ; text too high ?
add ecx,10-1
mov edx,[procInfo+MOS_PROCESSINFO.wndHeight]
sub edx,MOS_WND_SKIN_BORDER_BOTTOM
cmp ecx,edx
jnae .yousuck
.goodbye:
jmp .bye
.yousuck:
 
 
; ebx = (x << 16) | y
shl eax,16
or ebx,eax
; get date (edi)
mov eax,MOS_SC_GETDATE
int 0x40
mov edi,eax
 
; display month
mov eax,edi ; get month
shr eax,8
call bcdbin
; ebx contains already position
mov ecx,[wndColors+MOS_WNDCOLORS.workText]
lea edx,[monthNames-3+eax*2+eax]; -3 because eax = 1..12 =]
mov esi,3 ; text length
mov eax,MOS_SC_WRITETEXT
int 0x40
 
; display date
add ebx,MOS_DWORD(3*6+3,0)
mov eax,edi ; get date
shr eax,16
call bcdbin
mov edx,ebx ; position must be in edx
mov ebx,0x00020000 ; number, display two digits
mov ecx,eax ; number to display
mov esi,[wndColors+MOS_WNDCOLORS.workText]
mov eax,MOS_SC_WRITENUMBER
int 0x40
 
; display year. the way we avoid the y2k bug is even
; simpler, yet much better than in the last version:
; now we simply display the last two digits and let the
; user decide wether it's the year 1903 or 2003 =]
add edx,MOS_DWORD(2*6+3,0)
mov eax,edi ; get year
call bcdbin
mov ebx,0x00020000 ; number, display two digits
mov ecx,eax ; number to display
; edx contains already position
mov esi,[wndColors+MOS_WNDCOLORS.workText]
mov eax,MOS_SC_WRITENUMBER
int 0x40
 
.byebye:
popfd
popad
leave
ret
%pop
 
 
;**********************************************************
; bcdbin
; converts a 8 bit bcd number into a 32 bit binary number
;
; in al = 8 bit bcd number
; out eax = 32 bit binary number
; destroys dl,flags
;**********************************************************
bcdbin:
push edx
pushfd
mov dl,al ; save bcd number
shr al,4 ; convert upper nibble
mov ah,10
mul ah
and dl,15 ; add lower nibble
add al,dl
and eax,255 ; !
popfd
pop edx
ret
 
 
;********************************************************************
; getHandCoords
; calculates the end point of a hand
;
; input (on stack, push from top to bottom):
; ANGLE angle (integer)
; DEG2RAD conversion factor for ANGLE (32 bit real)
; RADIUSX x radius (32 bit real)
; RADIUSY y radius (32 bit real)
; CENTERX x center of the clock (integer)
; CENTERY y center of the clock (integer)
;
; output:
; ebx x coordinate in bits 0..15, bits 16..31 are zero
; ecx y coordinate in bits 0..15, bits 16..31 are zero
;
; destroys:
; nothing
;********************************************************************
getHandCoords:
 
ANGLE equ 28
DEG2RAD equ 24
RADIUSX equ 20
RADIUSY equ 16
CENTERX equ 12
CENTERY equ 8
 
enter 0,0
pushfd
 
fild dword [ebp+ANGLE] ; get angle
fmul dword [ebp+DEG2RAD] ; convert to radians
fsincos
fmul dword [ebp+RADIUSY] ; -y * radius + clockcy
fchs
fiadd dword [ebp+CENTERY]
fistp dword [ebp+CENTERY]
fmul dword [ebp+RADIUSX] ; x * radius + clockcx
fiadd dword [ebp+CENTERX]
fistp dword [ebp+CENTERX]
mov ebx,[ebp+CENTERX]
mov ecx,[ebp+CENTERY]
 
popfd
leave
ret 4*6
 
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/make.bat
0,0 → 1,2
@rem nasm -t -f bin -o aclock -l aclock.lst aclock.asm -DDEBUG
nasm -t -f bin -o aclock aclock.asm
/programs/demos/aclock/trunk/mos.inc
0,0 → 1,334
; mos.inc 0.03
; Copyright (c) 2002 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _MOS_INC
%define _MOS_INC
 
 
;**********************************************************
; generates a menuetos 01 header
; takes 6 parameters:
;
; MOS_HEADER01 start, end, appmem, esp, i_param, i_icon
;**********************************************************
 
%macro MOS_HEADER01 6
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd %1 ; start of code
dd %2 ; image size
dd %3 ; application memory
dd %4 ; esp
dd %5 ; i_param
dd %6 ; i_icon
%endmacro
 
 
;**********************************************************
; MOS_DWORD
; packs 2 words into a double word
;**********************************************************
 
%define MOS_DWORD(hi,lo) ((((hi) & 0xffff) << 16) + ((lo) & 0xffff))
 
 
;**********************************************************
; MOS_RGB
; creates a menuet os compatible color (0x00RRGGBB)
;**********************************************************
 
%define MOS_RGB(r,g,b) ((((r) & 255) << 16) + (((g) & 255) << 8) + ((b) & 255))
 
 
;**********************************************************
; window stuff
;**********************************************************
 
; default window colors
struc MOS_WNDCOLORS
.frame: resd 1
.grab: resd 1
.grabButton: resd 1
.grabButtonText: resd 1
.grabText: resd 1
.work: resd 1
.workButton: resd 1
.workButtonText: resd 1
.workText: resd 1
.workGraphics: resd 1
endstruc
 
; skinned window borders
MOS_WND_SKIN_BORDER_LEFT equ 5
MOS_WND_SKIN_BORDER_RIGHT equ 5
MOS_WND_SKIN_BORDER_BOTTOM equ 5
 
 
;**********************************************************
; process info structure
;**********************************************************
 
struc MOS_PROCESSINFO
.CPUUsage: resd 1
.windowStackPos: resw 1
.windowStackVal: resw 1
.reserved1: resw 1
.processName: resb 12
.memStart: resd 1
.memUsed: resd 1
.pid: resd 1
.wndXPos resd 1
.wndYPos resd 1
.wndWidth resd 1
.wndHeight resd 1
.reserved2: resb (1024 - 50)
endstruc
 
 
 
;**********************************************************
; system call numbers
;**********************************************************
 
MOS_SC_EXIT equ -1
MOS_SC_DEFINEWINDOW equ 0
MOS_SC_PUTPIXEL equ 1
MOS_SC_GETKEY equ 2
MOS_SC_GETSYSCLOCK equ 3
MOS_SC_WRITETEXT equ 4
MOS_SC_DELAY equ 5
MOS_SC_OPENFILEFLOPPY equ 6 ; obsolete
MOS_SC_PUTIMAGE equ 7
MOS_SC_DEFINEBUTTON equ 8
MOS_SC_GETPROCESSINFO equ 9
MOS_SC_WAITEVENT equ 10
MOS_SC_CHECKEVENT equ 11
MOS_SC_REDRAWSTATUS equ 12
MOS_SC_DRAWBAR equ 13
MOS_SC_GETSCREENMAX equ 14
MOS_SC_SETBACKGROUND equ 15
MOS_SC_GETPRESSEDBUTTON equ 17
MOS_SC_SYSTEMSERVICE equ 18
MOS_SC_STARTPROGRAM equ 19 ; obsolete
MOS_SC_MIDIINTERFACE equ 20
MOS_SC_DEVICESETUP equ 21
MOS_SC_WAITEVENTTIMEOUT equ 23
MOS_SC_CDAUDIO equ 24
MOS_SC_SB16MIXER1 equ 25
MOS_SC_GETDEVICESETUP equ 26
MOS_SC_WSS equ 27
MOS_SC_SB16MIXER2 equ 28
MOS_SC_GETDATE equ 29
MOS_SC_READHD equ 30 ; obsolete
MOS_SC_STARTPROGRAMHD equ 31 ; obsolete
MOS_SC_DELETEFILEFLOPPY equ 32
MOS_SC_SAVEFILERAMDISK equ 33 ; obsolete
MOS_SC_READDIRRAMDISK equ 34 ; obsolete
MOS_SC_GETSCREENPIXEL equ 35
MOS_SC_GETMOUSEPOSITION equ 37
MOS_SC_DRAWLINE equ 38
MOS_SC_GETBACKGROUND equ 39
MOS_SC_SETEVENTMASK equ 40
MOS_SC_GETIRQOWNER equ 41
MOS_SC_GETDATAREADBYIRQ equ 42
MOS_SC_SENDDATATODEVICE equ 43
MOS_SC_PROGRAMIRQS equ 44
MOS_SC_RESERVEFREEIRQ equ 45
MOS_SC_RESERVEFREEPORTS equ 46
MOS_SC_WRITENUMBER equ 47
MOS_SC_WINDOWPROPERTIES equ 48
MOS_SC_SHAPEDWINDOWS equ 50
MOS_SC_CREATETHREAD equ 51
MOS_SC_STACKDRIVERSTATE equ 52
MOS_SC_SOCKETINTERFACE equ 53
MOS_SC_SOUNDINTERFACE equ 55
MOS_SC_WRITEFILEHD equ 56 ; obsolete
MOS_SC_DELETEFILEHD equ 57
MOS_SC_SYSTREEACCESS equ 58
MOS_SC_SYSCALLTRACE equ 59
MOS_SC_IPC equ 60
MOS_SC_DIRECTGRAPHICS equ 61
MOS_SC_PCI equ 62
MOS_SC_DEBUGBOARD equ 63
 
 
;**********************************************************
; event numbers
;**********************************************************
 
MOS_EVT_NONE equ 0
MOS_EVT_REDRAW equ 1
MOS_EVT_KEY equ 2
MOS_EVT_BUTTON equ 3
 
 
;**********************************************************
; event bits
;**********************************************************
 
MOS_EVTBIT_REDRAW equ (1 << 0)
MOS_EVTBIT_KEY equ (1 << 1)
MOS_EVTBIT_BUTTON equ (1 << 2)
MOS_EVTBIT_ENDREQUEST equ (1 << 3)
MOS_EVTBIT_BGDRAW equ (1 << 4)
MOS_EVTBIT_MOUSECHANGE equ (1 << 5)
MOS_EVTBIT_IPCEVENT equ (1 << 6)
MOS_EVTBIT_IRQ0 equ (1 << 16)
MOS_EVTBIT_IRQ1 equ (1 << 17)
MOS_EVTBIT_IRQ2 equ (1 << 18)
MOS_EVTBIT_IRQ3 equ (1 << 19)
MOS_EVTBIT_IRQ4 equ (1 << 20)
MOS_EVTBIT_IRQ5 equ (1 << 21)
MOS_EVTBIT_IRQ6 equ (1 << 22)
MOS_EVTBIT_IRQ7 equ (1 << 23)
MOS_EVTBIT_IRQ8 equ (1 << 24)
MOS_EVTBIT_IRQ9 equ (1 << 25)
MOS_EVTBIT_IRQ10 equ (1 << 26)
MOS_EVTBIT_IRQ11 equ (1 << 27)
MOS_EVTBIT_IRQ12 equ (1 << 28)
MOS_EVTBIT_IRQ13 equ (1 << 29)
MOS_EVTBIT_IRQ14 equ (1 << 30)
MOS_EVTBIT_IRQ15 equ (1 << 31)
 
 
;**********************************************************
; exit application (syscall -1)
;**********************************************************
 
; exit application
%macro MOS_EXIT 0
mov eax,MOS_SC_EXIT
int 0x40
%endmacro
 
; exit application, smaller version
%macro MOS_EXIT_S 0
xor eax,eax
dec eax
int 0x40
%endmacro
 
 
;**********************************************************
; wait event stuff
; (MOS_SC_WAITEVENT, syscall 10)
;**********************************************************
 
; wait for event
; destroys : nothing
; returns : eax = event type
%macro MOS_WAITEVENT 0
mov eax,MOS_SC_WAITEVENT
int 0x40
%endmacro
 
; wait for event, smaller version
; destroys : flags
; returns : eax = event type
%macro MOS_WAITEVENT_S 0
xor eax,eax
mov al,MOS_SC_WAITEVENT
int 0x40
%endmacro
 
 
;**********************************************************
; window redraw status stuff
; (MOS_SC_REDRAWSTATUS, syscall 12)
;**********************************************************
 
MOS_RS_STARTREDRAW equ 1
MOS_RS_ENDREDRAW equ 2
 
; start window redraw
; destroys: eax,ebx
%macro MOS_STARTREDRAW 0
mov ebx,MOS_RS_STARTREDRAW
mov eax,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; start window redraw, smaller version
; destroys: eax,ebx,flags
%macro MOS_STARTREDRAW_S 0
xor ebx,ebx
inc ebx
xor eax,eax
mov al,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; end window redraw
; destroys: eax,ebx
%macro MOS_ENDREDRAW 0
mov ebx,MOS_RS_ENDREDRAW
mov eax,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
; end window redraw, smaller version
; destroys: eax,ebx,flags
%macro MOS_ENDREDRAW_S 0
xor ebx,ebx
mov bl,MOS_RS_ENDREDRAW
xor eax,eax
mov al,MOS_SC_REDRAWSTATUS
int 0x40
%endmacro
 
 
;**********************************************************
; get screen max stuff (syscall 14)
;**********************************************************
 
; get screen dimensions in eax
; destroys: nothing
%macro MOS_GETSCREENMAX 0
mov eax,MOS_SC_GETSCREENMAX
int 0x40
%endmacro
 
; get screen dimensions in eax, smaller version
; destroys: flags
%macro MOS_GETSCREENMAX_S 0
xor eax,eax
mov al,MOS_SC_GETSCREENMAX
int 0x40
%endmacro
 
 
;********************************************************************
; opcode hacks
;********************************************************************
 
; nasm refuses to assemble stuff like
; push dword 4.44
; with the following macro this becomes possible:
; fpush32 9.81
; don't forget to use a decimal point. things like
; fpush32 1
; will probably not do what you expect. instead, write:
; fpush32 1.0
%macro fpush32 1
db 0x68 ; push imm32
dd %1
%endm
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/str2dwrd.inc
0,0 → 1,92
; string2dword - a useless string to double word conversion routine
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
 
 
;********************************************************************
; converts an asciiz string into an unsigned doubleword.
; (base 10 is assumed)
;
; - first, leading whitespaces are skipped
; - then the function converts the string, until it
; finds the terminating zero, another character it
; cannot convert or the number becomes too large.
;
; input : esi = pointer to string
; output : eax = unsigned doubleword
; the function tries to convert as
; many digits as possible, before it
; stops. if the value of the dword
; becomes too large, 0xffffffff is
; returned.
; destroys : nothing
;********************************************************************
string2dword:
push ebx
push ecx
push edx
push esi
pushfd
 
xor ebx,ebx ; ebx : dword
 
; skip leading whitespaces
.skipspaces:
lodsb
cmp al,32 ; space
je .skipspaces
cmp al,12 ; ff
je .skipspaces
cmp al,10 ; lf
je .skipspaces
cmp al,13 ; cr
je .skipspaces
cmp al,9 ; ht
je .skipspaces
cmp al,11 ; vt
je .skipspaces
 
; convert string
dec esi ; esi -> 1st non-whitespace
.convert:
xor eax,eax ; get character
lodsb
sub al,'0' ; convert to digit
cmp al,9 ; is digit in range [0,9] ?
ja .done ; nope -> stop conversion
mov ecx,eax ; save new digit
mov eax,10 ; dword = dword * 10
mul ebx
jc .overflow
add eax,ecx ; + new digit
jc .overflow
mov ebx,eax
jmp .convert
 
.overflow:
mov ebx,0xffffffff
.done:
mov eax,ebx
popfd
pop esi
pop edx
pop ecx
pop ebx
ret
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/strlen.inc
0,0 → 1,49
; strlen function
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _STRLEN_INC
%define _STRLEN_INC
 
 
;********************************************************************
; returns the length of an asciiz string
; input : esi = pointer to string
; output : eax = string length
; destroys : nothing
;********************************************************************
strlen:
push ecx
push edi
pushfd
cld ; !
mov ecx,-1
mov edi,esi ; find terminating zero
xor al,al
repne scasb
mov eax,edi ; calculate string length
sub eax,esi
dec eax
popfd
pop edi
pop ecx
ret
 
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/aclock/trunk/strtok.inc
0,0 → 1,125
; some strtok-like function
;
; Copyright (c) 2003 Thomas Mathys
; killer@vantage.ch
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;
%ifndef _STRTOK_INC
%define _STRTOK_INC
 
 
;********************************************************************
; strtok
; this function works like strtok from a c runtime library.
; note that it is not threadsafe. it would be an easy task
; to make it threadsafe, though:
; .adx must be removed, instead the last search address is
; stored at some location provided by the user (passed as
; a third parameter in ecx or so)
;
; input:
;
; eax : address of string to be searched (asciiz), or
; 0 to get the next token of the current string
; ebx : address of delimiter list (asciiz)
;
; output:
;
; eax : pointer to the next token, or 0 if there
; aren't any tokens anymore.
;
; destroys: nothing
;
;********************************************************************
strtok:
pushad
pushfd
 
; get start address
; if the new start address is 0, and the old address (.adx)
; is also 0, then there's nothing to do and we return 0.
or eax,eax ; new address = 0 ?
jz .nonewstring ; nope -> use old string
mov [.adx],eax ; yeah -> store new string adx
.nonewstring:
mov esi,[.adx] ; load string address
or esi,esi ; 0 ?
jnz .startadxok ; nope -> ok
xor eax,eax ; yeah -> return 0
je .bye
.startadxok:
 
; skip leading delimiters
.skipdelimiters:
lodsb ; read character
mov edi,ebx ; edi -> delimiter list
.foo:
mov cl,[edi] ; get delimiter
inc edi
or cl,cl ; end of delimiter list
jz .endofdelimiterlist
cmp al,cl ; if AL is a delimiter, then
je .skipdelimiters ; we need to skip it too...
jmp .foo ; otherwise try next delimiter
.endofdelimiterlist:
 
; end of string reached without finding any non-delimiters ?
or al,al ; character = 0 ?
jnz .bar ; nope -> continue
mov dword [.adx],0 ; yeah -> remember this
xor eax,eax ; and return 0
jmp .bye
.bar:
 
; found the start of a token, let's store its address
mov edx,esi
dec edx ; edx = start address of token
 
; find the end of the token
.abraham:
lodsb ; get character
mov edi,ebx ; edi -> delimiter list
.bebraham:
mov cl,[edi] ; get delimiter
inc edi
cmp al,cl ; is AL a delimiter ?
jne .cebraham ; nope -> continue
or al,al ; terminating zero found ?
jnz .argle
xor esi,esi ; yeah -> remember this
jmp .bargle
.argle:
mov byte [esi-1],0 ; nope -> mark end of token
.bargle:
mov [.adx],esi ; remember search address
mov eax,edx ; return token address
jmp .bye
.cebraham:
or cl,cl ; end of delimiter list ?
jnz .bebraham ; nope -> try next delimiter
jmp .abraham
; write return value into stack, so that when popad
; gets executed, eax will receive the return value.
.bye:
mov [esp+4*8],eax
popfd
popad
ret
.adx dd 0
 
%endif
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bcdclk/bcdclk/bcdclk.asm
0,0 → 1,157
;
; BCD CLOCK
;
; Compile with FASM for Menuet
;
;
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x100000
dd 0x7fff0
dd 0x0 , 0x0
 
include "lang.inc"
include "macros.inc"
 
 
START:
 
call drawwindow
 
still:
 
 
mov eax,23 ; wait for timeout
mov ebx,50
int 0x40
 
cmp eax,1 ; redraw ?
je red
 
cmp eax,3 ; button in buffer ?
je button
 
call drawclock
 
jmp still
 
red: ; redraw
call drawwindow
jmp still
 
button:
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
 
jmp still
 
drawclock:
 
mov eax,3 ; get time
int 0x40
bswap eax
shr eax,8
mov edi,dg1
mov ecx,6
dgtomem:
push eax
and al,15
mov [edi],al
inc edi
pop eax
shr eax,4
loop dgtomem
mov ebx,74*65536+10
mov edi,dg1
digitlp:
mov ecx,30*65536+10
xor esi,esi
plotlp:
xor edx,edx
test byte[edi],8
je nobit
mov edx,0x00ff0000
nobit:
mov eax,13 ; plot 8,4,2,1
int 0x40
add ecx,12*65536
shl byte[edi],1
inc esi
cmp esi,4
jne plotlp
shr byte[edi],4
mov edx,0x00880040
mov eax,13 ; draw digit box
int 0x40
pusha
mov edx,ebx
and edx,0xffff0000
shr ecx,16
or edx,ecx
add edx,3*65536+2
mov ebx,0x00010100
mov ecx,[edi]
mov esi,0x00ffffff
mov eax,47 ; display decimal
int 0x40
popa
sub ebx,12*65536
inc edi
cmp edi,dg1+6
jne digitlp
ret
 
 
drawwindow:
 
 
mov eax,12
mov ebx,1 ; start redraw
int 0x40
 
mov eax,0 ; window
mov ebx,100*65536+100
mov ecx,100*65536+100
mov edx,0x83400088
mov esi,0x805080d0
mov edi,0x000000ff
int 0x40
 
call drawclock
 
mov eax,4 ; text
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,title
mov esi,title-titlend
int 0x40
 
 
mov eax,12
mov ebx,2 ; end redraw
int 0x40
 
ret
 
 
 
title:
db 'BCD Clock'
titlend:
 
dg1: db ?
 
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bcdclk/bcdclk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm bcdclk.asm bcdclk
@pause
/programs/demos/bcdclk/bcdclk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm bcdclk.asm bcdclk
@pause
/programs/demos/bcdclk/bcdclk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/EURO.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/GOTH.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/LCOM.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/LITT.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/SANS.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/SCRI.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/SIMP.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/SMAL.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/TRIP.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/FONTS/TSCR.CHR
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/bgitest/trunk/bgifont.inc
0,0 → 1,691
; BGIFONT.INC v1.0 beta
;
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; Created: December 16, 2004
;
; Last changed: February 2, 2005
;
; Compile with FASM
 
; BGI constants
BGI_NODRAW equ 0x10000
BGI_ITALIC equ 0x20000
BGI_BOLD equ 0x40000
BGI_HALEFT equ 0x0
BGI_HARIGHT equ 0x1000
BGI_HACENTER equ 0x2000
BGI_VABOTTOM equ 0x0
BGI_VATOP equ 0x4000
BGI_VACENTER equ 0x8000
 
BGI_FREE equ 0x80000000
BGI_HAMASK equ 0x3000
BGI_VAMASK equ 0xc000
 
; Freetext structure
struc BGIfree FontName,XY,Angle,ScaleX,ScaleY,StrPtr,StrLen,Color,Align
{
dd FontName ;0
dd XY ;4
dd Angle ;8
dd ScaleX ;12
dd ScaleY ;16
dd StrPtr ;20
dd StrLen ;24
dd Color ;28
dd Align ;32
}
 
; font options structure
struc BGIrec FontName,CharsCount,FirstChar,UpperMargin,LowerMargin,\
Widths,FirstData,EOF,font_data
{
.FontName dd ? ; 0
.CharsCount db ? ; 4
.FirstChar db ? ; 5
.UpperMargin db ? ; 6
.LowerMargin db ? ; 7
.Widths dd ? ; 8
.FirstData dd ? ; 12
.EOF dd ? ; 16
.font_data dd ? ; 20 follows (Offsets)
}
 
macro BGIfont_GetID
{
call _BGIfont_GetID
}
 
macro BGIfont_Prepare
{
call _BGIfont_Prepare
}
 
macro BGIfont_Freetext
{
call _BGIfont_Freetext
}
 
macro BGIfont_Outtext
{
call _BGIfont_Outtext
}
 
macro _FI name,_size
{
db name
if BGI_LEVEL eq KERNEL
dw _size
end if
}
 
BGIfont_names:
_FI 'LCOM',11485 ;7
_FI 'EURO',8117 ;5
_FI 'GOTH',13816 ;6
_FI 'LITT',3596 ;8
_FI 'TRIP',11932 ;14
_FI 'SCRI',8490 ;11
_FI 'SMAL',4162 ;13
_FI 'TSCR',12134 ;15
_FI 'SANS',8453 ;10
_FI 'SIMP',9522 ;12
BGIfont_names_end:
 
macro BGIfont_Init
{
; in: ecx - number of fonts to load;
; esi-> _FI structure
; edi-> where to load
push edi
if BGI_LEVEL eq KERNEL
mov edi,0x40000
end if
.nfont:
mov edx,[esi]
if BGI_LEVEL eq KERNEL
movzx ebx,word[esi+4]
mov [BGIfont_Prepare.okflag],'N'
end if
call _BGIfont_Prepare
if ~ BGI_LEVEL eq KERNEL
add esi,4
else
push esi
test eax,eax
jz .fail
mov [BGIfont_Prepare.okflag],'*'
.fail:
mov esi,BGIfont_Prepare.font
call boot_log
pop esi
add esi,6
end if
loop .nfont
dph2 _BGI_BOLD,300,550
; movzx edi,byte[0x40000]
pop edi
}
 
BGIfont_get2head:
shr ecx,28 ; font #
sub ecx,4
jb .exit2 ; invalid #
mov edi,[BGIfont_Ptr]
inc edi
cmp cl,[edi-1]
jae .exit2 ; # too large
jecxz .ex
.fnext:
mov edi,[edi+16]
loop .fnext
jmp .ex
.exit2:
xor edi,edi
.ex:
ret
 
BGIfont_GetName:
; in: ecx-fontID;
; out: edx-font name.
call BGIfont_get2head
xor edx,edx
test edi,edi
jz .ex
mov edx,[edi]
.ex:
ret
 
macro dps2 _str
{
if ~ BGI_LEVEL eq KERNEL
if LOAD_MSG eq 1
dps _str
end if
else
pusha
mov esi,BGIfont_Prepare.okflag
mov byte[esi], _str
call boot_log
popa
end if
}
 
macro dph2 num,x,y
{
if BGI_LEVEL eq KERNEL
pusha
mov eax,0x00080100
mov ebx,num
mov ecx,x shl 16+y
mov edx,0xFF0000
call display_number
popa
end if
}
 
_BGIfont_GetID:
; in: edx-font name;
; out: eax-fontID, edi->BGIrec
push ecx edi
mov edi,[BGIfont_Ptr]
movzx ecx,byte[edi] ; ecx-font count
mov eax,ecx
inc edi ; edi->FontName
jecxz .ex
.fnext:
cmp edx,[edi]
jne .floop
sub eax,ecx
add eax,4
shl eax,28
jmp .ex
.floop:
mov edi,[edi+16]
loop .fnext
.num0:
xor eax,eax
.ex:
pop edi ecx
ret
 
_BGIfont_Prepare:
; in: edx-font name, edi->pointer to load fonts (fonts_count)
; out: eax-ID of new font loaded; eax=0 error
cmp [BGIfont_Ptr],0
jne .already
mov [BGIfont_Ptr],edi
.already:
pusha
mov edi,[BGIfont_Ptr]
movzx ecx,byte[edi] ; ecx-font count
mov eax,ecx
inc edi ; edi->FontName
jecxz .fload
.fnext:
cmp edx,[edi]
jne .loop
sub eax,ecx
inc eax
jmp .cr_id
.loop:
mov edi,[edi+16]
loop .fnext
.fload:
mov dword[.font],edx ; filename
mov esi,edi ; esi->FontName
mov [.dest],edi ; ptr to load font
if ~ BGI_LEVEL eq KERNEL
mov [.fsize],1
mov eax,58
mov ebx,.fontinfo
int 0x40
test eax,eax
jnz .fail
dps2 '1'
shr ebx,9
inc ebx
mov [.fsize],ebx
mov ebx,.fontinfo
mov eax,58
int 0x40 ; ebx - file size
else
push edi esi edx
mov eax,.font
xor ebx,ebx
mov esi,12
mov ecx,ebx
mov edx,edi
call fileread
pop edx esi edi
mov ebp,edi
add ebp,ebx
cmp ebp,0x50000
ja .fail
end if
cmp dword[edi],0x08084b50 ; 'PK',8,8
jne .fail
dps2 '2'
inc edi
mov eax,26 ; #EOF
mov ecx,253
cld
repne scasb ; skip Copyright
test ecx,ecx
jz .fail
dps2 '3'
cmp edx,[edi+2] ; FontName
jne .fail
dps2 '4'
movzx ecx,word[edi] ; HeaderSize
sub ebx,ecx ; Filesize-Headersize
movzx eax,word[edi+6] ; FontSize
cmp eax,ebx
jb .fail ; file truncated
add ecx,[.dest]
dps2 '5'
cmp byte[ecx],'+' ; ParPrefix
jne .fail
; font is valid, let's fill parameter table
dps2 '>'
mov [esi],edx ; FontName
mov edx,eax
add eax,ecx
mov [esi+16],eax ; Font EOF
movzx eax,word[ecx+5]
add eax,ecx
mov [esi+12],eax
lea edi,[esi+4] ; edi->CharsCount
lea esi,[ecx+1] ; esi->ParPrefix+1
xor eax,eax
lodsw
stosb ; CharsCount
inc esi
movsb ; FirstChar
add esi,3
lodsw
stosb ; UpperMargin
movsb ; LowerMargin
add esi,5 ; esi->offsets
mov eax,[esi]
push edi ; edi->Widths
; prepare moving data
add edi,12 ; edi->offsets
lea ecx,[edx-16]
rep movsb
pop edi ; edi->Widths
mov [edi+8],esi ; EOF
; mov eax,[edi]
movzx ecx,byte[edi-4] ; CharsCount
lea eax,[edi+12+ecx*2] ; eax->widths
stosd ; edi->FirstData
add eax,ecx
stosd ; edi->EOF
mov eax,[esp] ; eax->fonts_count
inc byte[eax] ; increase font counter
movzx eax,byte[eax]
.cr_id:
add eax,0x3 ; create unique ID
shl eax,28 ; to easy use in color(ecx)
jmp .exit
.fail:
xor eax,eax
.exit:
mov [esp+28],eax
popa
ret
 
if ~ BGI_LEVEL eq KERNEL
.fontinfo:
dd 0
dd 0
.fsize dd 0
.dest dd 0
dd 0x10000
db BGIFONT_PATH
.font db 'FONT.CHR',0
else
.dest dd 0
.font db 'FONT CHR'
.okflag db ' ',0
end if
 
BGIfont_Coo:
; y->word[txt.y1], x->word[txt.x1]
fild [txt.y1] ;y
fmul st0,st0; y*y
fild [txt.x1] ;x
fmul st0,st0; x*x
faddp ; x*x+y*y
fsqrt ; sqrt, angle
fild [txt.y1];y
fabs
fild [txt.x1] ; x
fabs
fpatan ; arctg(y/x)
.skip:
cmp [txt.x1],0
jge .xplus
fchs
fadd st0,st3
.xplus:
cmp [txt.y1],0
jge .yplus
fchs
.yplus:
fadd st0,st2
fsincos
fmul st0,st2
fiadd [txt.x0]
fistp [txt.x1] ; x=r*cos a
fmulp ; y=r*sin a,angle
fiadd [txt.y0]
fistp [txt.y1]
ret
 
_BGIfont_Freetext:
; in: ebx-BGIfree structure
; out: eax-new drawing coords
mov edx,[ebx]
call _BGIfont_GetID
test eax,eax
jnz .fexists
ret
.fexists:
pusha
fninit
fldpi
fld [pi180]
fimul dword[ebx+8]
fst [BGIangle]
mov esi,[ebx+28]
and esi,0xffffff
add esi,eax
mov eax,[ebx+32]
and [deform],0
test eax,BGI_ITALIC
jz .norm
mov [deform],0.4
.norm:
mov ebp,eax
or ebp,BGI_FREE
mov eax,[ebx+12]
mov [Xscale],eax
mov eax,[ebx+16]
mov [Yscale],eax
mov ecx,[ebx+20]
mov edx,ebp
and edx,BGI_FREE+BGI_VAMASK+BGI_HAMASK
add edx,[ebx+24]
mov eax,[ebx+4]
mov ebx,esi
add ebx,0x6000000
mov [esp+4],edx
mov [esp+20],ecx
jmp txt
 
pi180 dd 0.017453
 
_BGIfont_Outtext:
; in: ebx-[x][y], ecx-color, edx-string, esi-length
pusha
mov ebp,esi
if ~ BGI_LEVEL eq KERNEL
mov eax,ebx
mov ebx,ecx
mov ecx,edx
mov edx,esi
end if
; in: eax-[x][y], ebx-color, ecx-string, edx-length
txt:
if ~ BGI_LEVEL eq KERNEL
if BGI_WINDOW_CLIP eq 1
pusha
mov eax,9
mov ebx,BGI_PRC_INFO
mov ecx,-1
int 0x40
popa
end if
end if
mov [.y0],ax
shr eax,16
mov [.x0],ax
mov ecx,ebx ; color
and ebx,0xfffffff
mov [.color],ebx
call BGIfont_get2head
test edi,edi
jz .exit
mov ecx,[esp+4]; str length
mov esi,[esp+20]; str ptr
movzx eax,byte[edi+5]
push ecx
and ecx,0xff
jnz .lenok
add esp,4
jmp .ex2
.lenok:
pusha
push dword[txt.y0]
and dword[txt.y0],0
xor edx,edx
mov ebx,[edi+8]
.next:
call txt.BGIfont_GetChar
movzx eax,byte[ebx+eax]
add edx,eax
loop .next
mov ecx,edx ; ecx - x size
movzx dx,byte[edi+6]
mov ebx,[esp+36]
and ebx,BGI_HAMASK
cmp ebx,BGI_HARIGHT
je .nova
ja .subv
xor ecx,ecx
jmp .nova
.subv:
shr cx,1
.nova:
mov ebx,[esp+36]
and ebx,BGI_VAMASK
cmp ebx,BGI_VATOP
je .def
ja .subh
xor edx,edx
jmp .def
.subh:
shr dx,1
.def:
call txt.BGIfont_Deform
pop dword[txt.y0]
popa
pop ebx
mov ax,[txt.y1]
sub [txt.y0],ax
mov ax,[txt.x1]
sub [txt.x0],ax
xor eax,eax
cld
.mloop:
push [.y0]
pop [.y]
push [.x0]
pop [.x]
call .BGIfont_GetChar
push esi
lea esi,[edi+20] ; offset
movzx edx,word[esi+eax*2] ; ofs1
add edx,[edi+12]
inc eax
cmp al,[edi+4]
je .eof
movzx eax,word[esi+eax*2]; ofs2
add eax,[edi+12]
jmp .prc_vec
.eof:
mov eax,[edi+16] ; ofs2=eof
.prc_vec: ; edx-vec cmd ifs, eax-cmd limit
mov [.vec_end],eax
push ecx
.vec_loop:
mov ax,word[edx]
push edx
mov ecx,eax
and eax,0x8080 ; op
and ecx,0x7f ; xx
mov edx,[edx+1]
and edx,0x7f ; yy
cmp edx,63
jbe .positive
sub edx,128 ; yy-=128
.positive:
cmp ecx,63
jbe .positive2
sub ecx,128 ; xx-=128
.positive2:
call .BGIfont_Deform
cmp eax,0x8080
jne .noline
test ebp,BGI_NODRAW
jnz .noline
; draw vector
if ~ BGI_LEVEL eq KERNEL
push eax
mov ebx,dword[.x1]
mov ecx,dword[.y1]
if BGI_WINDOW_CLIP eq 1
movzx eax,[.x]
cmp eax,dword[BGI_PRC_INFO+42]
ja .nobold
movzx eax,[.y]
cmp eax,dword[BGI_PRC_INFO+46]
ja .nobold
xor eax,eax
cmp ax,bx
jg .nobold
cmp ax,cx
jg .nobold
end if
mov edx,[.color]
mov eax,38
int 0x40
test ebp,BGI_BOLD
jz .nobold
test ebp,BGI_FREE
jnz .free5
.free5:
add ebx,1 shl 16+1
int 0x40
.nobold:
pop eax
else
pusha
mov eax,dword[.x1]
mov ebx,dword[.y1]
mov ecx,[.color]
; call syscall_drawline
test dword[esp+8],BGI_BOLD
jz .nobold
add eax,1 shl 16+1
; call syscall_drawline
.nobold:
popa
end if
.noline:
pop edx
test eax,eax
je .eovecs ; op=0
push [.y1]
pop [.y]
push [.x1]
pop [.x]
add edx,2
cmp edx,[.vec_end]
jb .vec_loop
.eovecs:
pop ecx esi
push [.y]
pop [.y0]
push [.x]
pop [.x0]
loop .mloop1
jmp .exit
.mloop1:
jmp .mloop
.exit:
mov eax,dword[.y0]
mov [esp+28],eax
.ex2:
popa
ret
 
.BGIfont_Deform:
test ebp,BGI_FREE
jnz .free0
movzx ebx,byte[.color+3] ;ebx=scale
imul ecx,ebx
add ecx,2
shr ecx,2
imul edx,ebx
add edx,2
shr edx,2
neg edx
mov [.x1],cx
mov [.y1],dx
jmp .add
.free0:
mov [.x1],cx
mov [.y1],dx
fild [.y1]
fld st0
fmul [Yscale]
fchs
fistp [.y1]
fmul [deform]
fiadd [.x1]
fmul [Xscale]
fistp [.x1]
cmp [BGIangle],0
je .add
call BGIfont_Coo
jmp .eax
.add:
mov cx,[.x0]
add [.x1],cx
mov cx,[.y0]
add [.y1],cx
.eax:
ret
 
.BGIfont_GetChar:
; in: esi -> string; edi -> BGIrec
; out: esi -> next char; al - char obtained
lodsb ; al - char from str
sub al,[edi+5]
jb .out
cmp al,[edi+4]
jb .in
.out:
xor al,al ; al - 1st symbol available
.in:
ret
 
.y0 dw ?
.x0 dw ?
 
.x1 dw ?
.x dw ?
.y1 dw ?
.y dw ?
 
.color dd ?
.vec_end dd ?
BGIfont_Ptr dd 0
width dd ?
deform dd ?
BGIangle dd ?
Xscale dd ?
Yscale dd ?
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bgitest/trunk/bgitest.asm
0,0 → 1,444
; BGI Font Test
;
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; Created: December 20, 2004
;
; Last changed: February 2, 2005
;
 
BGIFONT_PATH equ '/RD/1/'
_X equ 340
_Y equ 240
 
BGI_WINDOW_CLIP equ 1
BGI_PRC_INFO equ pinfo
 
macro ListFonts
{
mov eax,lf_head
call PixelPrint
mov ebx,20 shl 16+60
mov ecx,(BGIfont_names_end-BGIfont_names)/4
mov esi,BGIfont_names
.l1:
pusha
pusha
mcall 4,,0x10777fac,esi,4
popa
mov edx,[esi]
BGIfont_GetID
mov dword[_BGIfont_Prepare.font],edx
mov ecx,eax
add ebx,140 shl 16
mov edx,ebx
mcall 47,0x80100,,,0x10ffffff
jecxz .nofont
lea ebx,[edx+80 shl 16+12]
mov edx,_BGIfont_Prepare.dest+8
mov esi,BGIfont_Coo-1
sub esi,edx
add ecx,0x3b800b8
BGIfont_Outtext
sub ebx,155 shl 16+12
mcall 4,,0x1000f000,load_ok,load_fail-load_ok
jmp .pop
.nofont:
lea ebx,[edx-80 shl 16]
mcall 4,,0x10f00010,load_fail,font_msg-load_fail
.pop:
popa
add esi,4
add ebx,39
loop .l2
jmp .ex
.l2:
jmp .l1
.ex:
}
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x100000
dd 0x0cfff0
dd 0x0
not1strun dd 0x0
 
include 'lang.inc'
include 'macros.inc'
;include 'debug.inc'
include 'bgifont.inc'
lang equ en;ru;en
 
START:
mov [help],0
mov ecx,(BGIfont_names_end-BGIfont_names)/4
mov esi,BGIfont_names
mov edi,I_END
BGIfont_Init
reset:
mov esi,[BGIfont_Ptr]
inc esi
mov edi,freeconst
movsd
mov esi,freeconst
mov edi,freetest
mov ecx,36
rep movsb
red:
mov eax,[freetest]
mov dword[title+19],eax
call draw_window
cmp [not1strun],0
jnz still
mcall 5,300
not [not1strun]
inc [help]
jmp red
still:
 
mov eax,10
int 0x40
 
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
 
jmp still
 
button:
mov eax,17
int 0x40
cmp ah,1
jnz noclose
close:
xor eax,eax
dec eax
int 0x40
noclose:
jmp still
 
key:
mov eax,2
int 0x40
shr eax,8
cmp al,27 ; esc - close
je close
cmp al,32 ; Space - help
jne .noh
inc [help]
cmp [help],3
jne red
and [help],0
jmp red
.noh:
cmp [help],2
jne still
cmp al,50
jb .noff
cmp al,57
ja .noff
sub al,46
.gn:
movzx ecx,al
shl ecx,28
call BGIfont_GetName
mov [freetest],edx
jmp red
.noff:
mov ecx,4
mov edi,Fkeys
.fkey:
cmp al,[edi]
je .fndkey
inc edi
loop .fkey
jmp .notfnd
.fndkey:
lea eax,[edi-Fkeys+0xc]
jmp .gn
.notfnd:
cmp al,114 ; r - reset
je reset
cmp al,176
jne .nol ; left
sub dword[freetest+8],5
jmp red
.nol:
cmp al,179
jne .nor ; right
add dword[freetest+8],5
jmp red
.nor:
cmp al,105 ; i -italic
jne .noi
xor dword[freetest+32],BGI_ITALIC
jmp red
.noi:
cmp al,98 ; b -bold
jne .nob
xor dword[freetest+32],BGI_BOLD
jmp red
.nob:
mov ecx,2
mov esi,ali
.ol2:
cmp al,[esi]
jne .othl2
mov ax,[freetest+32]
add ax,[esi+3]
mov bx,ax
mov dx,[esi+1]
and bx,dx
cmp bx,dx
jne .ok
not dx
and ax,dx
.ok:
mov [freetest+32],ax
jmp red
.othl2:
add esi,5
loop .ol2
.other:
mov esi,delt
mov ecx,4
.ol:
cmp al,[esi]
jne .othl
fld dword[esi+1]
movzx eax,byte[esi+5]
fadd dword[freetest+eax]
fstp dword[freetest+eax]
jmp red
.othl:
add esi,6
loop .ol
jmp still
 
draw_window:
mov eax,12
mov ebx,1
int 0x40
 
xor eax,eax
mov ebx,10*65536+_X*2
mov ecx,100*65536+_Y*2
mov edx,0x03261212
mov esi,0x805080d0
mov edi,0x005080d0
int 0x40
 
mov eax,4
mov ebx,8*65536+8
mov ecx,0x10ddeeff
mov edx,title
mov esi,title_end-title
cmp [help],2
je .int
sub esi,12
.int:
int 0x40
 
cmp [help],0
jnz .help
cmp byte[I_END],0
jnz .fontsok
mov eax,font_msg
call PixelPrint
.fontsok:
ListFonts
jmp .eod
.help:
cmp [help],1
jne .nohelp
mov eax,helptxt
cmp byte[I_END],0
jnz .fontsok2
mov word[eax+2],_X-80
call PixelPrint
jmp .eod
.fontsok2:
mov word[eax+2],_X
call Print
jmp .eod
.nohelp:
mov edi,cross
mov eax,38
mov edx,0x4b331a
mov ebx,[edi]
mov ecx,[edi+4]
int 0x40
mov ebx,[edi+8]
mov ecx,[edi+12]
int 0x40
mov ebx,freetest
BGIfont_Freetext
.eod:
mov eax,12
mov ebx,2
int 0x40
ret
 
Print: ; eax-pointer to _txt struc
pusha
mov ebx,[eax]
movzx ecx,byte[eax+12]
lea edx,[eax+13]
mov edi,eax
.nextstr:
mov esi,[edx]
add edx,4
push ecx
mov ecx,[edi+8]
BGIfont_Outtext
add ebx,[edi+4]
pop ecx
and esi,0xfff
add edx,esi
loop .nextstr
popa
ret
 
PixelPrint: ; eax-pointer to _txt struc, but used differently
pusha
mov ebp,eax
mov ebx,[ebp]
movzx ecx,byte[ebp+12]
mov eax,4
lea edx,[ebp+17]
.l:
mov esi,[edx-4]
and esi,0xfff
push ecx
mov ecx,[ebp+8]
int 0x40
pop ecx
lea edx,[esi+edx+4]
add ebx,[ebp+4]
loop .l
popa
ret
 
macro _txt _xy,_vert,_color,_opt,[_str]
{
common
_counter=0
forward
_counter=_counter+1
common
dd _xy ; 0
dd _vert ; 4
dd _color ; 8
db _counter ;_str_count ; 12
forward
local .str_beg,.str_end
dd (.str_end-.str_beg) or _opt ; 13
.str_beg:
db _str ;17
.str_end:
}
 
title db 'BGIFONT.INC demo - FONT font'
title_end:
_M equ 30
cross dd _M shl 16+_X*2-_M,_Y shl 16+_Y,_X shl 16+_X,_M shl 16+_Y*2-_M
helptxt:
if lang eq ru
_txt _X shl 16+60,40,0x434ba010,BGI_HACENTER,\
"ƒŽŸ—ˆ… Š‹€‚ˆ˜ˆ:",\
"à®¡¥« - èà¨äâë/íâ®â ⥪áâ/¤¥¬ª ;",\
"<-> áâ५ª¨ - ¢à é¥­¨¥ áâப¨;",\
"V - ¢ëà ¢­¨¢ ­¨¥ ¯® ¢¥à⨪ «¨;",\
"H - ¢ëà ¢­¨¢ ­¨¥ ¯® £®à¨§®­â «¨;",\
"[,] - ¬ áèâ ¡ ¯® ®á¨ X;",\
"A,Z - ¬ áèâ ¡ ¯® ®á¨ Y;",\
"B,I - ¯®«ã¦¨à­ë© èà¨äâ ¨ ªãàᨢ;",\
"R - á¡à®á ¯ à ¬¥â஢ èà¨äâ ;",\
"F1..F12 - ¢ë¡®à èà¨äâ ;",\
"Esc - § ªàëâì ¯à®£ã :-("
alpha:
db "‚®â ¯à¨¬¥à ⥪áâ !"
lf_head:
_txt 10 shl 16+30,85 shl 16,0x6e00f7,0,"ˆ¬ï èà¨äâ ","‘â âãá","ID",\
"ãâì ª ä ©«ã"
load_ok:
db "§ £à㦥­"
load_fail:
db "­¥ ­ ©¤¥­"
font_msg:
_txt (_X+20) shl 16+180,25,0x10ff0000,0,\
"Š ᮦ «¥­¨î, ­¥ ­ ©¤¥­® ­¨ ®¤­®£®",\
"¢¥ªâ®à­®£® èà¨äâ  *.CHR. ‚®§¬®¦­®,",\
"¢ ¬ á«¥¤ã¥â ¨á¯à ¢¨âì ª®­áâ ­âã",\
"BGIFONT_PATH ¢ ­ ç «¥ ä ©«  BGITEST.ASM",\
"¨ ¯¥à¥ª®¬¯¨«¨à®¢ âì ¥£® :-("
else
_txt _X shl 16+60,40,0x434ba010, BGI_HACENTER,\
"HOT KEYS:",\
"Space - font list/this message/demo;",\
"<-> arrows - rotate text string;",\
"V - toggle vertical alignment;",\
"H - toggle horizontal alignment;",\
"[,] - scale on X axis;",\
"A,Z - scale on Y axis;",\
"B,I - toggle bold & italic mode;",\
"R - reset font options;",\
"F1..F12 - select font;",\
"Esc - close demo :-("
alpha:
db 'This is a Sample text!'
; db 'ABCDEFGHIGKLMNOPQRSTUVWXWZ'
lf_head:
_txt 10 shl 16+30,85 shl 16,0x6e00f7,0,"Font name","Status","ID",\
"Filename"
load_ok:
db "loaded"
load_fail:
db "not found"
font_msg:
_txt (_X+20) shl 16+180,25,0x10ff0000,0,\
"Sorry, no vector font *.CHR found.",\
"Maybe you should correct BGIFONT_PATH",\
"constant at the beginning of file",\
"BGITEST.ASM and recompile it :-("
end if
 
macro Deltas _key,_scale,_ofs
{
db _key
dd _scale
db _ofs
}
 
delt:
Deltas 91, -0.15,12
Deltas 93, 0.15,12
Deltas 97, 0.15,16
Deltas 122,-0.15,16
Fkeys db 48,49,68,255
 
macro Aligns _key,_mask,_add
{
db _key
dw _mask,_add
}
ali:
Aligns 118,BGI_VAMASK,BGI_VATOP
Aligns 104,BGI_HAMASK,BGI_HARIGHT
freeconst BGIfree 'FONT',_X shl 16+_Y,0, 1.0, 1.0, alpha,\
lf_head-alpha,0xb800e7,\
BGI_VACENTER or BGI_HACENTER
freetest BGIfree ?,?,?,?,?,?,?,?,?
help db ?
pinfo:
times 1024 db ?
rb 10000 ; reserve, unless process info will corrupt our fonts (why?)
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bgitest/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm bgitest.asm bgitest
@pause
/programs/demos/bgitest/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm bgitest.asm bgitest
@pause
/programs/demos/bgitest/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bgitest/trunk/read_eng.txt
0,0 → 1,140
BGIFONT.INC v1.0 beta
 
Written in pure assembler by Ivushkin Andrey aka Willow
 
At present Menuet operation system has poor means to draw charaters. Its
distro contains 2 raster fonts (CHAR.MT & CHAR2.MT files). The kernel supports
them internally. That is Jarek Pelczar who makes certain efforts to develop
scalable TTF-like fonts but huge Menuet C Library does not become widespread
inside our assembly-written OS. Bulgarian MenuetOS team also tries to include
third scalable font into the kernel, though, as far as I know, its characters
are still under design and are incomplete. Therefore Bulgarian developing is
not valuable for ordinary users. It is obvious that scalable fonts will help
to develop such products as browsers and word processors where character
formatting is of great importance.
Let me introduce for public domain an include file BGIFONT.INC to process
vector fonts (*.CHR) worked out by famous Borland Corporation to use in Turbo
Pascal, Turbo C and Borland C++ compilers under MS-DOS. Sorry, I still fail to
add BGI font support into kernel - deeper knowledge on memory allocation and
system calls needed. I hope that Menuet system programmers will be glad to help
me. Module compiling within kernel is supposed using constant BGI_LEVEL equ
KERNEL. By means of conditional compiling it will be possible to use the module
at both kernel and application levels. Following is concerned using the include
file while programming an application.
 
BGI fonts may reside in any folder on HD or RD. They are searched using value
of constant BGI_PATH. If constant BGI_WINDOW_CLIP is equal to 1, module routines
perform window bounds check to avoid artifacts while drawing. Use this if you
aren't sure that strings are fit in window. All BGIFONT.INC routines are
declared as macros, that is they are used without "call". To load 11 fonts into
application's memory a contiguous free space up to 120 kb is needed. When
loading, font data relocation is performed to save memory. Let us see a chart:
 
| Font | | BGIrec | | Font | | BGIrec | | Font | | BGIrec |
| counter | | structure| | data | | structure| | data | | structure| ...
| (1 byte)| | | | | |
| ------------->------ -------------->----- ----------
- referenced by [BGIfont_Ptr]
 
BGIrec structure fields have following meaning:
 
+00 dword .FontName font name (4 characters)
+04 byte .CharsCount amount of font characters
+05 byte .FirstChar code of the first character present
+06 byte .UpperMargin high bound of characters
+07 byte .LowerMargin low bound of characters
+08 dword .Widths offset to width array
+12 dword .FirstData offset to vector table
+16 dword .EOF pointer to the following BGIrec
+20 dword .font_data here font data begin
 
Font loading and verification are carried out by BGIfont_Prepare procedure.
 
BGIfont_Prepare
in: EDX - font name (4 characters) to be loaded. It must to be the same as
the font filename (without extension)
EDI - address to where font have to be loaded. Used only for the
first time. Then you may find this value in [BGIfont_Ptr]
out: EAX=0, if an error occured, otherwise EAX is identifier (ID) of the
loaded font. Later it is possible to get font ID with BGIfont_GetID
function.
 
For the simultaneous loading of few fonts you may use BGIfont_Init routine.
 
BGIfont_Init
in: ESI - pointer to array of font names (for example db 'TRIPSIMPEURO')
ECX is amount of fonts to load
EDI - see BGIfont_Prepare
out: nothing.
 
To load 10 standard fonts the module defines an array BGIfont_names (see in
BGITEST for usage demonstration).
 
For compatibility and subsequent kernel introduction, the module offers 2
routines for drawing vector characters. One of them uses registers (like sysfunc
4), another uses a structure.
 
BGIfont_Outtext
in: EAX - "pivot point" of a string [x] shl 16+[y]
ECX - text color and font size 0xXYRRGGBB,
where X - vector font ID(4..F),
Y - size of caracters divided by 4, e.g. 0x1 - 1/4 of
ordinary size, 0xC - triple size.
EDX - pointer to the string
ESI - string length + formatting flags (see below). BGI_ITALIC and
BGI_NODRAW flags are ignored.
out: EAX - coords at the end of the string drawn [x] shl 16+[y].
 
As you can see, BGIfont_Outtext is similar to the 4th system function,
but provides an extended management of drawing symbols.
 
The most complete use of vector fonts is provided by BGIfont_Freetext routine.
Parameters are passed in a BGIfree structure.
 
BGIfree structure fields have following meaning:
 
+00 dword font name (4 characters)
+04 dword "pivot point" of a string [x] shl 16+[y]
+08 dword turn angle (clockwise, 0 is horizontal)
+12 dword X scale (floating point value!)
+16 dword Y scale (floating point value!)
+20 dword pointer to the string
+24 dword string length WITHOUT formatting flags
+28 dword text color 0x00RRGGBB
+32 dword formatting flags
 
The module defines following formatting flags:
BGI_NODRAW - do not draw
BGI_ITALIC - italic
BGI_BOLD - bold
BGI_HALEFT - left alignment
BGI_HARIGHT - right alignment
BGI_HACENTER - center alignment
BGI_VABOTTOM - bottom alignment
BGI_VATOP - top alignment
BGI_VACENTER - middle vertical alignment
 
Combination of flags can be performed by addition or the OR operation.
 
BGIfont_Freetext
in: EBX - pointer to BGIfree structure
out: EAX coords at the end of the string drawn [x] shl 16+[y].
 
BGIfont_GetID routine returns font ID by its name.
 
BGIfont_GetID
in: EDX - font name (4 characters)
out: EAX - ID of the font
EDI - pointer on font's BGIrec structure.
 
Using functions of BGIFONT.INC module is demonstrated by BGITEST app.
 
Todo list:
1. An insidious bug sometimes shows up while loading multiple fonts (as in
BGITEST), that corrupts some characters. It disappears when font loading
order is changed... :-(
2. To correct a hardly reproduceable bug when moving along the font list.
3. To perfect drawing of bold fonts.
4. To add number drawing routines.
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/bgitest/trunk/read_rus.txt
0,0 → 1,149
BGIFONT.INC v1.0 beta for MenuetOS
Œ®¤ã«ì ¤«ï à ¡®âë á ¢¥ªâ®à­ë¬¨ èà¨äâ ¬¨ ä®à¬ â  BGI
 
 ¯¨á ­ ­  ç¨á⮬  áᥬ¡«¥à¥ ˆ¢ã誨­ë¬ €­¤à¥¥¬ aka Willow
 
‚ ­ áâ®ï饥 ¢à¥¬ï ®¯¥à æ¨®­­ ï á¨á⥬  Menuet ®¡« ¤ ¥â áªã¤­ë¬¨ á।á⢠¬¨
®â®¡à ¦¥­¨ï ᨬ¢®«®¢. ‚ ¤¨áâਡã⨢¥ ¨¬¥îâáï 2 à áâ஢ëå èà¨äâ  (ä ©«ë CHAR.MT ¨
CHAR2.MT).  ¡®â  á ­¨¬¨ ¦¥á⪮ § è¨â  ¢ ï¤à¥. Ž¯à¥¤¥«¥­­ë¥ ãᨫ¨ï ¯® ¢­¥¤à¥­¨î
¬ áèâ ¡¨à㥬ëå èà¨ä⮢ TTF-¯®¤®¡­®£® ä®à¬ â  ¯à¥¤¯à¨­¨¬ ¥â Jarek Pelczar, ®¤­ ª®
£à®¬®§¤ª ï MenuetOS C Library ­¥ ¯®«ã稫  ¤® á¨å ¯®à ¡®«ì让 ¯®¯ã«ïà­®á⨠¢
 áᥬ¡«¥à­®© Ž‘. ®«£ à᪮© ª®¬ ­¤®© Menuet ¤¥« «¨áì ¯®¯ë⪨ ¢áâநâì ¢ ï¤à®
âà¥â¨© ¬ áèâ ¡¨àã¥¬ë© èà¨äâ, ­®, ­ áª®«ìª® ¬­¥ ¨§¢¥áâ­®, ¥£® ᨬ¢®«ë ­ å®¤ïâáï ¢
áâ ¤¨¨ ¤¨§ ©­ . ’ ª¨¬ ®¡à §®¬, ࠧࠡ®âª  ¡®«£ à ¯®ª  ­¥ ¯à¥¤áâ ¢«ï¥â 業­®áâ¨
¤«ï à冷¢ëå ¯®«ì§®¢ â¥«¥©. Žç¥¢¨¤­®, çâ® ¬ áèâ ¡¨àã¥¬ë¥ èà¨äâë ¯®¬®£ãâ
ࠧࠡ®âª¥ â ª¨å ¢ ¦­ëå ª â¥£®à¨© ¯à®£à ¬¬­ëå ¯à®¤ãªâ®¢, ª ª ¡à ã§¥àë ¨
⥪áâ®¢ë¥ ¯à®æ¥áá®àë, £¤¥ ¡®«ìèãî à®«ì ¨£à ¥â ä®à¬ â¨à®¢ ­¨¥ ᨬ¢®«®¢.
à¥¤áâ ¢«ïî ¢ ®¡é¥á⢥­­®¥ ¯®«ì§®¢ ­¨¥ ¢ª«îç ¥¬ë© ä ©« BGIFONT.INC ¤«ï à ¡®âë á
¢¥ªâ®à­ë¬¨ èà¨äâ ¬¨ *.CHR, ࠧࠡ®â ­­ë¥ §­ ¬¥­¨â®© ä¨à¬®© Borland ¤«ï
¨á¯®«ì§®¢ ­¨ï ¢ ª®¬¯¨«ïâ®à å Turbo Pascal, Turbo C ¨ Borland C++ ¥é¥ ¢ á।¥ MS-
DOS. Š ᮦ «¥­¨î, ¯®ª  çâ® ¬­¥ ­¥ 㤠¥âáï ®¡¥á¯¥ç¨âì ¯®¤¤¥à¦ªã BGI-èà¨ä⮢ ­ 
ã஢­¥ ï¤à  - ­ã¦­® £«ã¡¦¥ ¨§ãç âì ­î ­áë à á¯à¥¤¥«¥­¨ï ¯ ¬ï⨠¨ ¢ë§®¢ 
á¨á⥬­ëå ä㭪権. Ÿ ­ ¤¥îáì, çâ® á¨á⥬騪¨ Menuet á £®â®¢­®áâìî ¬­¥ ¯®¬®£ãâ.
Š®¬¯¨«ïæ¨ï ¬®¤ã«ï ¢ á®áâ ¢¥ ï¤à  ¯à¥¤¯®« £ ¥âáï á ¨á¯®«ì§®¢ ­¨¥¬ ª®­áâ ­âë
BGI_LEVEL equ KERNEL. « £®¤ àï ãá«®¢­®© ª®¬¯¨«ï樨 ¬®¤ã«ì ¬®¦­® ¡ã¤¥â
¨á¯®«ì§®¢ âì á ­¥§­ ç¨â¥«ì­ë¬¨ ¨§¬¥­¥­¨ï¬¨ ­  ã஢­¥ ª ª ï¤à , â ª ¨ ¯à¨«®¦¥­¨ï.
¨¦¥¨§«®¦¥­­®¥ ª á ¥âáï à ¡®âë ¬®¤ã«ï ­  ã஢­¥ ¯à¨«®¦¥­¨ï.
 
BGI-èà¨äâë ¬®£ãâ à á¯®« £ âìáï ¢ «î¡®¬ ª â «®£¥ HD ¨«¨ RD. ˆå ¯®¨áª
®áãé¥á⢫ï¥âáï ¯® §­ ç¥­¨î ª®­áâ ­âë BGI_PATH. …᫨ ª®­áâ ­â  BGI_WINDOW_CLIP
ãáâ ­®¢«¥­  ¢ 1, ¯à®æ¥¤ãà ¬¨ ¬®¤ã«ï ¢ ¯à®æ¥áᥠ¢ë¢®¤  ¢¥ªâ®à®¢ èà¨äâ 
®áãé¥á⢫ï¥âáï ¯à®¢¥àª  ¢ë室  §  £à ­¨æë ®ª­ , çâ®¡ë ¨§¡¥¦ âì  àâ¥ä ªâ®¢.
ˆá¯®«ì§ã©â¥ íâ®, ¥á«¨ ¢ë ­¥ 㢥७ë, çâ® ­ ¤¯¨á¨ ¡ã¤ãâ ¯®¬¥é âìáï ¢ ®ª­¥. ‚
í⮬ á«ãç ¥ ­¥®¡å®¤¨¬® ¤®¯®«­¨â¥«ì­® ®¯à¥¤¥«¨âì ª®­áâ ­âã BGI_PRC_INFO -  ¤à¥á
¢ ¯ ¬ï⨠(1024 ¡ ©â ), ªã¤  ¯à¨«®¦¥­¨¥ ¬®¦¥â ¯®«ãç âì ¨­ä®à¬ æ¨î ® ᢮¥¬ ®ª­¥
ç¥à¥§ 9-î á¨á⥬­ãî äã­ªæ¨î. ‚ᥠ¯à®æ¥¤ãàë ¬®¤ã«ï BGIFONT.INC ®¡ê¥­ë ª ª
¬ ªà®áë, â.¥. ¢ë§ë¢ îâáï ¡¥§ call. „«ï § £à㧪¨ 11 èà¨ä⮢ ¢  ¤à¥á­®¥
¯à®áâà ­á⢮ ¯à¨«®¦¥­¨ï ­¥®¡å®¤¨¬ ­¥¯à¥àë¢­ë© ãç á⮪ à §¬¥à®¬ ®ª®«® 120 ª¡.
à¨ § £à㧪¥ ®áãé¥á⢫ï¥âáï ¯¥à¥¬¥é¥­¨¥ ¤ ­­ëå á 楫ìî íª®­®¬¨¨ ¯ ¬ïâ¨. ‘奬 
à §¬¥é¥­¨ï èà¨ä⮢:
 
| ‘ç¥â稪 | | ‘âàãªâãà | |„ ­­ë¥| |‘âàãªâãà | | „ ­­ë¥| |‘âàãªâãà |
| èà¨ä⮢ | | BGIrec | |èà¨äâ | | BGIrec | | èà¨äâ | | BGIrec | ...
| (1 ¡ ©â)| | | | | |
| ------------->------ -------------->----- ----------
- á ááë« ¥âáï [BGIfont_Ptr]
 
®«ï áâàãªâãàë BGIrec ¨¬¥îâ á«¥¤ãî饥 ­ §­ ç¥­¨¥:
 
+00 dword .FontName ç¥âëà¥å¡ãª¢¥­­®¥ ¨¬ï èà¨äâ 
+04 byte .CharsCount ª®«¨ç¥á⢮ ᨬ¢®«®¢ ¢ èà¨äâ¥
+05 byte .FirstChar ª®¤ ¯¥à¢®£® ॠ«¨§®¢ ­­®£® ᨬ¢®« 
+06 byte .UpperMargin ¢¥àå­ïï £à ­¨æ  ᨬ¢®« 
+07 byte .LowerMargin ­¨¦­ïï £à ­¨æ  ᨬ¢®« 
+08 dword .Widths ᬥ饭¨¥ ¬ áᨢ  è¨à¨­ ᨬ¢®«®¢
+12 dword .FirstData ᬥ饭¨¥ â ¡«¨æë ¢¥ªâ®à®¢
+16 dword .EOF 㪠§ â¥«ì ­  á«¥¤ãî騩 BGIrec
+20 dword .font_data §¤¥áì ­ ç¨­ îâáï ¤ ­­ë¥ èà¨äâ 
 
‘®¡á⢥­­® § £à㧪㠨 ¢¥à¨ä¨ª æ¨î èà¨äâ  ®áãé¥á⢫ï¥â ¯à®æ¥¤ãà 
BGIfont_Prepare.
 
BGIfont_Prepare
¢å®¤: EDX - ç¥âëà¥å¡ãª¢¥­­®¥ ¨¬ï èà¨äâ , ¯®¤«¥¦ é¥£® § £à㧪¥. „®«¦­®
ᮢ¯ ¤ âì á ¨¬¥­¥¬ ä ©«  èà¨äâ  (¡¥§ à áè¨à¥­¨ï)
EDI -  ¤à¥á ãç á⪠ ¯ ¬ïâ¨, ªã¤  á«¥¤ã¥â ¯®¬¥áâ¨âì ¤ ­­ë¥ èà¨äâ .
ˆá¯®«ì§ã¥âáï ⮫쪮 ¯à¨ § £à㧪¥ ¯¥à¢®£® èà¨äâ . â® §­ ç¥­¨¥
§ ­®á¨âáï ¢ [BGIfont_Ptr]
¢ë室: EAX=0, ¥á«¨ ¯à®¨§®è«  ®è¨¡ª , ¨­ ç¥ ¢ EAX - ¨¤¥­â¨ä¨ª â®à (ID)
§ £à㦥­­®£® èà¨äâ . ‚¯®á«¥¤á⢨¨ ID ¬®¦­® ¯®«ãç¨âì äã­ªæ¨ï¬¨
BGIfont_GetID ¨ BGIfont_GetName.
 
„«ï ¥¤¨­®¢à¥¬¥­­®© § £à㧪¨ ­¥áª®«ìª¨å èà¨ä⮢ ¬®¦­® ¨á¯®«ì§®¢ âì ¯à®æ¥¤ãàã
BGIfont_Init.
 
BGIfont_Init
¢å®¤: ESI - 㪠§ â¥«ì ­  ᯨ᮪ ¨¬¥­ èà¨ä⮢ (­ ¯à¨¬¥à db 'TRIPSIMPEURO')
ECX - ª®«¨ç¥á⢮ èà¨ä⮢ ¤«ï § £à㧪¨
EDI - á¬. BGIfont_Prepare
¢ë室: ­¨ç¥£®.
 
„«ï § £à㧪¨ 10 áâ ­¤ àâ­ëå èà¨ä⮢ ¢ ¬®¤ã«¥ ®¯à¥¤¥«¥­ ¬ áᨢ BGIfont_names
(¨á¯®«ì§®¢ ­¨¥ á¬. ¢ BGITEST).
 
‚ 楫ïå ᮢ¬¥á⨬®á⨠¨ ¯®á«¥¤ãî饣® ¢­¥¤à¥­¨ï ¢ ï¤à® ¬®¤ã«ì ¯à¥¤« £ ¥â 2
¯à®æ¥¤ãàë ¤«ï ¢ë¢®¤  ᨬ¢®«®¢ ¢¥ªâ®à­ë¬¨ èà¨äâ ¬¨. Ž¤­  ¨§ ­¨å ¨á¯®«ì§ã¥â
ॣ¨áâàë (¯®¤®¡­® 4-© á¨á⥬­®© ä㭪樨), ¤à㣠ï - áâàãªâãàã.
 
BGIfont_Outtext
¢å®¤: EAX - "â®çª  ®âáç¥â " ¯à¨ ¢ë¢®¤¥ áâப¨ [x] shl 16+[y]
ECX - 梥â ⥪áâ  ¨ à §¬¥à èà¨äâ  0xXYRRGGBB,
£¤¥ X - ID ¢¥ªâ®à­®£® èà¨äâ  (4..F),
Y - ¢¥«¨ç¨­  ᨬ¢®«®¢/4, ­ ¯à¨¬¥à 0x1 - 1/4 ®¡ëç­®£® à §¬¥à ,
0xC - âன­®© à §¬¥à.
EDX - 㪠§ â¥«ì ­  áâபã
ESI - ¤«¨­  áâப¨ + ä« £¨ ä®à¬ â¨à®¢ ­¨ï (á¬. ­¨¦¥). ”« £¨
BGI_ITALIC ¨ BGI_NODRAW ¨£­®à¨àãîâáï.
¢ë室: EAX - ª®®à¤¨­ âë ª®­æ  ­ ¤¯¨á¨ [x] shl 16+[y].
 
Š ª ¢¨¤¨¬, BGIfont_Outtext ¯® ᢮¨¬ ¯ à ¬¥âà ¬ á宦  á 4-© á¨á⥬­®© ä㭪樥©,
­® ¤®¯ã᪠¥â à áè¨à¥­­®¥ ã¯à ¢«¥­¨¥ ¢ë¢®¤®¬ ᨬ¢®«®¢.
 
 ¨¡®«¥¥ ¯®«­®¥ ¨á¯®«ì§®¢ ­¨¥ ¢¥ªâ®à­ëå èà¨ä⮢ ®¡¥á¯¥ç¨¢ ¥â äã­ªæ¨ï
BGIfont_Freetext.  à ¬¥âàë ¢ë¢®¤  áâப¨ ¯¥à¥¤ îâáï ¢ áâàãªâãॠBGIfree.
 
®«ï áâàãªâãàë BGIfree ¨¬¥îâ á«¥¤ãî饥 ­ §­ ç¥­¨¥:
 
+00 dword ç¥âëà¥å¡ãª¢¥­­®¥ ¨¬ï èà¨äâ 
+04 dword "â®çª  ®âáç¥â " ¯à¨ ¢ë¢®¤¥ áâப¨ [x] shl 16+[y]
+08 dword 㣮« ¯®¢®à®â  (0 - £®à¨§®­â «ì, ®âáç¥â ¯® ç á®¢®© áâ५ª¥)
+12 dword ¬ áèâ ¡ ¯® ®á¨ X (§­ ç¥­¨¥ á ¯« ¢ î饩 â®çª®©!)
+16 dword ¬ áèâ ¡ ¯® ®á¨ Y (§­ ç¥­¨¥ á ¯« ¢ î饩 â®çª®©!)
+20 dword 㪠§ â¥«ì ­  áâபã
+24 dword ¤«¨­  áâப¨ …‡ ä« £®¢ ä®à¬ â¨à®¢ ­¨ï
+28 dword 梥â ⥪áâ  0x00RRGGBB
+32 dword ä« £¨ ä®à¬ â¨à®¢ ­¨ï
 
Œ®¤ã«ì ®¯à¥¤¥«ï¥â á«¥¤ãî騥 ä« £¨ ä®à¬ â¨à®¢ ­¨ï:
BGI_NODRAW - ­¥ à¨á®¢ âì ᨬ¢®«ë
BGI_ITALIC - ªãàᨢ
BGI_BOLD - ¯®«ã¦¨à­ë© èà¨äâ
BGI_HALEFT - ¢ë஢­ïâì ¯® «¥¢®¬ã ªà î
BGI_HARIGHT - ¢ë஢­ïâì ¯® ¯à ¢®¬ã ªà î
BGI_HACENTER - ¢ë஢­ïâì ¯® 業âàã
BGI_VABOTTOM - ¢ë஢­ïâì ¯® ­¨¦­¥¬ã ªà î
BGI_VATOP - ¢ë஢­ïâì ¯® ¢¥àå­¥¬ã ªà î
BGI_VACENTER - ¢ë஢­ïâì ¯® á¥à¥¤¨­¥
 
Š®¬¡¨­ æ¨ï ä« £®¢ ®¡à §ã¥âáï ¨å á«®¦¥­¨¥¬ ¨«¨ ®¯¥à æ¨¥© OR.
 
BGIfont_Freetext
¢å®¤: EBX - 㪠§ â¥«ì ­  áâàãªâãàã BGIfree
¢ë室: EAX - ª®®à¤¨­ âë ª®­æ  ­ ¤¯¨á¨ [x] shl 16+[y].
 
”ã­ªæ¨ï BGIfont_GetID ¢®§¢à é ¥â ID èà¨äâ  ¯® § ¤ ­­®¬ã ¨¬¥­¨.
 
BGIfont_GetID
¢å®¤: EDX - ç¥âëà¥å¡ãª¢¥­­®¥ ¨¬ï èà¨äâ 
¢ë室: EAX - ID èà¨äâ 
EDI - 㪠§ â¥«ì ­  BGIrec èà¨äâ .
 
ˆá¯®«ì§®¢ ­¨¥ ä㭪権 ¬®¤ã«ï BGIFONT.INC ¤¥¬®­áâà¨àã¥â ¯à®£à ¬¬  BGITEST.
 
—â® ¥é¥ ­ã¦­® ᤥ« âì:
1. à¨ ¬­®¦¥á⢥­­®© § £à㧪¥ èà¨ä⮢ (ª ª ¢ BGITEST) ¨­®£¤  ¯à®ï¢«ï¥âáï
ª®¢ à­ë© ¡ £, ¯®àâï騩 ­¥áª®«ìª® ᨬ¢®«®¢. à¨ ¨§¬¥­¥­¨¨ ¯®à浪  § £à㧪¨
èà¨ä⮢ ®­ ¨á祧 ¥â... :-(
2. ˆá¯à ¢¨âì âà㤮¢®á¯à®¨§¢®¤¨¬ë© ¡ £ ¯à¨ ¤¢¨¦¥­¨¨ ¯® ᯨáªã èà¨ä⮢.
3. “ᮢ¥à襭á⢮¢ âì ¯à®à¨á®¢ªã ¯®«ã¦¨à­ëå èà¨ä⮢.
4. „®¡ ¢¨âì ä㭪樨 ¢ë¢®¤  ç¨á¥«.
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/colorref/trunk/colorref.asm
0,0 → 1,503
; COLORREF.ASM - COLOR REFERENCE
;
; Compile with FASM for Menuet
;
 
use32
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd start ; start of code
dd finis ; size of image
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0,0x0 ; I_Param , I_Icon
 
include 'lang.inc'
wide: dd 0 ; screen pixels width
mouse: dd 0 ; 1=right,2=left [mouse click]
 
 
start:
 
mov eax,14 ; get screen size
int 0x40
shr eax,16 ; get width into AX
inc eax ; not 0 based
mov [wide],eax
 
call draw_window
 
still:
mov eax,23 ; wait for event w/timeout
mov ebx,5 ; delay in hundredths
int 0x40
 
cmp eax,1 ; redraw request ?
jne s1
jmp red
s1: cmp eax,2 ; key in buffer ?
jne s2
jmp key
s2: cmp eax,3 ; button in buffer ?
jne s3
jmp button
s3: mov eax,9 ; process info function
mov ebx,stat_table ; return data table
mov ecx,-1 ; who am i
int 0x40
cmp ax,[stat_table+4] ; are we active?
je active ; yep
jmp still
 
active:
mov eax,37 ; mouse info function
mov ebx,2 ; get buttons
int 0x40
cmp eax,0 ; mouse click?
jne click
jmp still
click:
mov [mouse],eax ; save mouse click
mov eax,37 ; mouse info
xor ebx,ebx ; get screen pos for mouse
int 0x40 ; into EAX
xor ebx,ebx
mov bx,ax ; BX=y screen position
shr eax,16 ; AX=x screen position
xchg eax,ebx ; EAX=y, EBX=x
dec eax ; don't calc mouse scanline
mov ecx,[wide] ; get pixels wide
mul ecx
add ebx,eax ; add x
mov eax,35 ; get mouse pos pixel
int 0x40 ; EAX=mouse pixel color
mov ebx,eax ; EBX has color
mov esi,colors ; color table
mov ecx,72 ; total colors
xor edx,edx ; init a counter
check:
lodsd
inc edx ; update counter
cmp ebx,eax ; color match?
je _match ; yep
loop check ; check all colors
jmp still ; no match
_match:
cmp [mouse],dword 1 ; right click?
je right ; yep
left:
cmp [picks],edx ; changed left color yet?
jne l1 ; no, do it
jmp still
l1: mov [picks],edx ; update left pick color
call clear ; erase old text
call draw_picks ; redraw colors and text
jmp still
right:
cmp [picks+4],edx ; changed right color yet?
jne r1 ; no, do it
jmp still
r1: mov [picks+4],edx ; update right pick color
call clear ; erase old text
call draw_picks ; redraw colors and text
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
cmp al,0 ; key in buffer?
je k1 ; yep
jmp still
k1: cmp ah,'H' ; cap H ?
je k2 ; yep
cmp ah,'h' ; locase h ?
je k2 ; yep
jmp still
k2: call help ; show help screen
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
je close
jmp still
 
close:
mov eax,-1 ; close this program
int 0x40
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
mov eax,12 ; tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
mov eax,0 ; DRAW WINDOW
mov ebx,1*65536+200 ; [x start] *65536 + [x size]
mov ecx,200*65536+240 ; [y start] *65536 + [y size]
mov edx,0x03000000 ; work area color (type II)
mov esi,0x82a0a0a0 ; grab bar color (w/glide)
mov edi,0x82bbbbbb ; frame color
int 0x40
mov eax,4 ; WINDOW LABEL
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0xeeeeee ; color of text (white)
mov edx,prog_name ; pointer to header
mov esi,namelen-prog_name ; text length
int 0x40
call palette ; display color palette
 
mov eax,12 ; tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
; *********************************************
; ******* COLOR PALETTE LAYOUT ROUTINES ******
; *********************************************
 
 
palette:
mov ebx,15*65536+18 ; LAYOUT: start x and width
mov edx,32*65536+18 ; LAYOUT: start y and depth
mov ecx,8 ; 8 rows
mov ebp,colors ; color table
p1: push ecx
mov ecx,9 ; 9 columns
p2: push ecx
push edx
mov ecx,edx ; y coord
mov edx,[ebp] ; color
mov eax,13 ; draw bar function
int 0x40
pop edx
pop ecx
add ebx,19*65536 ; next column
add ebp,4 ; next color
p3: loop p2
pop ecx
mov ebx,15*65536+18 ; restart x
add edx,19*65536 ; next row
loop p1
call draw_picks
 
ret
 
draw_picks:
mov ebx,64*65536+24 ; draw x and width
mov ecx,188*65536+42 ; draw y and depth
mov edx,0xc0c0c0 ; color grey
mov eax,13 ; draw bar function
int 0x40
mov eax,[picks] ; first picked color
mov esi,22*65536+196 ; print at x and y
call do_hex ; print color number
mov eax,[picks+4] ; second picked color
mov esi,22*65536+215 ; print at x and y
call do_hex ; print color number
mov eax,[picks] ; first picked color
mov ebx,67*65536+18 ; x and width
mov esi,191*65536+18 ; y and depth
call do_color ; paint color 1 square
mov eax,[picks+4] ; second picked color
mov ebx,67*65536+18 ; x and width
mov esi,209*65536+18 ; y and depth
call do_color ; paint color 2 square
mov eax,[picks] ; first picked color
mov ebx,96*65536+196 ; x and y
call do_name ; print color's name
mov eax,[picks+4] ; second picked color
mov ebx,96*65536+215 ; x and y
call do_name ; print color's name
 
ret
 
do_hex:
dec eax ; use 0 base
mov ecx,4 ; dword length
mul ecx ; calc pointer
mov edi,colors ; color table
add edi,eax ; add offset
mov ecx,[edi] ; save color 1
mov ebx,0x60100 ; print 6 hex digits
mov edx,esi ; copy color
mov esi,0xe1e1e1 ; use white
mov eax,47 ; print number function
int 0x40
 
ret
 
do_color:
dec eax ; use 0 base
mov ecx,4 ; dword length
mul ecx ; calc pointer
mov edi,colors ; color table
add edi,eax ; add offset
mov edx,[edi] ; color
mov ecx,esi ; recover y an depth
mov eax,13 ; draw bar function
int 0x40
 
ret
 
do_name:
dec eax ; use 0 base
mov ecx,15 ; string length
mul ecx ; calc pointer
mov edx,names ; color table
add edx,eax ; add offset
mov ecx,0xe1e1e1 ; color
mov esi,15
mov eax,4 ; print text function
int 0x40
 
ret
 
clear:
mov ebx,22*65536+36 ; x and width
mov ecx,196*65536+26 ; y and depth
mov edx,0x000000 ; color
mov eax,13 ; draw bar funx
int 0x40
mov ebx,96*65536+90 ; x and width
mov ecx,196*65536+26 ; y and depth
mov edx,0x000000 ; color
mov eax,13 ; draw bar funx
int 0x40
 
ret
 
help:
mov ebx,4*65536+192 ; x and width
mov ecx,20*65536+216 ; y and depth
mov edx,0x465e8f ; dark denim color
mov eax,13 ; write text funx
int 0x40
mov ebx,20*65536+40 ; starting x and y
mov edx,text ; start of text
mov esi,27 ; width of text
mov ecx,14 ; 14 text lines to do
mov eax,4 ; write text funx
h1: push ecx
sub ebx,65537 ; drop shadow x and y
mov ecx,0x000000 ; black shadow
int 0x40
add ebx,65537 ; original x and y
mov ecx,0xefefef ; white text
int 0x40
add edx,27 ; next line of text
add bx,12 ; next row
pop ecx
loop h1
mov eax,10 ; wait on event
int 0x40
cmp eax,2 ; got a key?
jne h2 ; nope
mov eax,2 ; yep, burn it
int 0x40
h2: mov ebx,4*65536+192 ; y and width
mov ecx,20*65536+216 ; x and depth
mov edx,0x00000 ; restore black bkg
mov eax,13 ; draw bar funx
int 0x40
call palette ; redraw color palette
 
ret
 
 
; *********************************************
; ********** DATA DEFINITIONS AREA ***********
; *********************************************
 
prog_name:
db 'COLOR REFERENCE H>HELP'
namelen:
 
picks:
dd 31,2 ; selected top/bot colors
 
colors:
dd 0xe0e0e0 ; white
dd 0xe7e6a0 ; pale yellow
dd 0xe7e05a ; lemon yellow
dd 0xe7c750 ; mustard
dd 0xe7b850 ; cadium yellow
dd 0xbfa461 ; yellow ocre
dd 0xe0c090 ; cream
dd 0xe0b27b ; peach
dd 0xe2986d ; dark peach
dd 0xebb2c0 ; pink
dd 0xe0b0a0 ; flesh
dd 0xc79790 ; artificial arm
dd 0xb88688 ; deep blush
dd 0xc4a077 ; washed khaki
dd 0xb69269 ; khaki
dd 0xa8845b ; dark khaki
dd 0xab937a ; beige
dd 0xa39370 ; poupon
dd 0x988c00 ; camouflage
dd 0x98a024 ; pale olive
dd 0x838b00 ; olive
dd 0x6d7600 ; dark olive
dd 0x5b6200 ; black olive
dd 0x94946a ; washed army
dd 0x74744a ; army
dd 0x66a696 ; pale teal
dd 0x409b90 ; faded teal
dd 0x008d8d ; pastel teal
dd 0x007c7c ; teal
dd 0x006464 ; dark teal
dd 0x00b8ca ; light turquoise
dd 0x00a0b2 ; turquoise
dd 0x00889a ; dark turquoise
dd 0x575f8c ; medium cobalt
dd 0x4e4e7c ; cobalt
dd 0x00459a ; ultramarine
dd 0x400088 ; navy blue
dd 0x4e00e7 ; true blue
dd 0x508cec ; sky blue
dd 0x6a73d0 ; mountain blue
dd 0x677ab0 ; faded jeans
dd 0x576fa0 ; denim
dd 0xd048c8 ; fuschia
dd 0xb800e7 ; lavendar
dd 0xa800a8 ; light violet
dd 0x780078 ; violet
dd 0x520064 ; purple
dd 0xb800b8 ; magenta
dd 0xa4307a ; rose
dd 0x90207f ; mauve
dd 0xe76e83 ; salmon
dd 0xea7a7d ; pastel orange
dd 0xe26830 ; orange
dd 0xac5800 ; burnt sienna
dd 0xcc0000 ; red orange
dd 0xac0000 ; cadium red
dd 0x880040 ; brick red
dd 0x780000 ; rust
dd 0x683020 ; terra cotta
dd 0x7f4658 ; light maroon
dd 0x702050 ; maroon
dd 0x7a5b5f ; umber blush
dd 0x584838 ; burnt umber
dd 0x8a5d1a ; cigar brown
dd 0x64504a ; ice brown
dd 0x564242 ; dark chocolate
dd 0x00aa66 ; celery stalk
dd 0x107a30 ; forest green
dd 0x365800 ; hooker's green
dd 0x8beb88 ; pastel lime
dd 0x7bbb64 ; lime
dd 0x4ba010 ; dark lime
 
names:
db 'WHITE '
db 'PALE YELLOW '
db 'LEMON YELLOW '
db 'MUSTARD '
db 'CADIUM YELLOW '
db 'YELLOW OCRE '
db 'CREAM '
db 'PEACH '
db 'DARK PEACH '
db 'PINK '
db 'FLESH '
db 'ARTIFICIAL ARM '
db 'DEEP BLUSH '
db 'WASHED KHAKI '
db 'KHAKI '
db 'DARK KHAKI '
db 'BEIGE '
db 'POUPON '
db 'CAMOUFLAGE '
db 'PALE OLIVE '
db 'OLIVE '
db 'DARK OLIVE '
db 'BLACK OLIVE '
db 'WASHED ARMY '
db 'ARMY '
db 'PALE TEAL '
db 'FADED TEAL '
db 'PASTEL TEAL '
db 'TEAL '
db 'DARK TEAL '
db 'LIGHT TURQUOISE'
db 'TURQUOISE '
db 'DARK TURQUOISE '
db 'MEDIUM COBALT '
db 'COBALT '
db 'ULTRAMARINE '
db 'NAVY BLUE '
db 'TRUE BLUE '
db 'SKY BLUE '
db 'MOUNTAIN BLUE '
db 'FADED JEANS '
db 'DENIM '
db 'FUSHIA '
db 'LAVENDAR '
db 'LIGHT VIOLET '
db 'VIOLET '
db 'PURPLE '
db 'MAGENTA '
db 'ROSE '
db 'MAUVE '
db 'SALMON '
db 'PASTEL ORANGE '
db 'ORANGE '
db 'BURNT SIENNA '
db 'RED ORANGE '
db 'CADIUM RED '
db 'BRICK RED '
db 'RUST '
db 'TERRA COTTA '
db 'LIGHT MAROON '
db 'MAROON '
db 'UMBER BLUSH '
db 'BURNT UMBER '
db 'CIGAR BROWN '
db 'ICE BROWN '
db 'DARK CHOCOLATE '
db 'CELERY STALK '
db 'FOREST GREEN '
db "HOOKER'S GREEN "
db 'PASTEL LIME '
db 'LIME '
db 'DARK LIME '
 
 
text:
db 'TO SEE HOW COLORS COMPARE '
db 'TO ONE ANOTHER, LEFT CLICK '
db 'THE FIRST COLOR AND RIGHT '
db 'CLICK THE SECOND. TO GET '
db "A SENSE OF A COLOR'S TRUE "
db 'HUE, RIGHT AND LEFT CLICK '
db 'THE SAME COLOR TO SEE IT '
db 'ON THE NEUTRAL BACKGROUND. '
db 'TO USE A LIGHTER OR DARKER '
db 'VALUE OF A COLOR, ADD OR '
db 'SUBTRACT 0x10 OR 0x20 FROM '
db 'EACH BYTE OF ITS HEX VALUE.'
db ' '
db ' ANY KEY ... '
 
stat_table:
 
 
finis:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/colorref/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm colorref.asm colorref
@pause
/programs/demos/colorref/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm colorref.asm colorref
@pause
/programs/demos/colors/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm colors.asm colors
@pause
/programs/demos/colors/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm colors.asm colors
@pause
/programs/demos/colors/trunk/colors.asm
0,0 → 1,206
;
; COLOR TABLE
;
; Compile with FASM for Menuet
;
 
use32
 
org 0x0
 
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x1000 ; required amount of memory
dd 0x1000 ; esp = 0x7FFF0
dd 0x00000000 ; reserved=no extended header
 
include 'lang.inc'
include 'macros.inc'
 
 
START: ; start of execution
 
call shape_window
 
call draw_window ; at first, draw the window
 
still:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
jz red
cmp eax,2 ; key in buffer ?
jz key
cmp eax,3 ; button in buffer ?
jz button
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jnz noclose
mov eax,0xffffffff ; close this program
int 0x40
noclose:
 
jmp still
 
 
shape_window:
 
pusha
 
mov eax,50 ; give the address of reference area
mov ebx,0
mov ecx,shape_reference
int 0x40
 
mov eax,50 ; give the scaling ( 5 -> 2^5 )
mov ebx,1
mov ecx,5
int 0x40
 
popa
 
ret
 
 
shape_reference:
 
db 1,0,1,0,1,0,1,0
db 0,1,0,1,0,1,0,1
db 1,0,1,0,1,0,1,0
db 0,1,0,1,0,1,0,1
db 1,0,1,0,1,0,1,0
db 0,1,0,1,0,1,0,1
db 1,0,1,0,1,0,1,0
db 0,1,0,1,0,1,0,1
 
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
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,100*65536+255 ; [x start] *65536 + [x size]
mov ecx,100*65536+255 ; [y start] *65536 + [y size]
mov edx,0x00000000
mov esi,0x8099bbff ; color of grab bar RRGGBB,8->color glide
mov edi,0x0099bbee ; color of frames RRGGBB
int 0x40
 
call draw_colors
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,5*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0xccaa22 ; button color RRGGBB
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
draw_colors:
 
pusha
 
mov [bar],dword 0
 
mov eax,-1
mov ebx,0
mov ecx,0
mov edx,0
 
mov edi,0
 
dc1:
 
add eax,1
cmp eax,256
jb na1
mov eax,0
add ebx,1
cmp ebx,256
jb na1
mov ebx,0
add ecx,5
na1:
 
mov dl,al
shl edx,8
mov dl,bl
shl edx,8
mov dl,cl
 
na2:
 
pusha
push edx
 
xor edx,edx
mov eax,edi
mov ebx,256
div ebx
mov ebx,edx
mov ecx,eax
 
add ebx,[addx]
add ecx,[addy]
 
pop edx
mov eax,1
int 0x40
popa
 
add edi,1
 
cmp edi,256*256
jb dc1
 
popa
ret
 
 
 
; DATA AREA
 
I_END:
 
bar dd ?
 
add1 dd ?
add2 dd ?
 
addx dd ?
addy dd ?
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/colors/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/crownscr/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm crownscr.asm crownscr
@pause
/programs/demos/crownscr/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm crownscr.asm crownscr
@pause
/programs/demos/crownscr/trunk/crownscr.asm
0,0 → 1,404
;
; Crown_s Soft Screensaver v1.13m
; WWW: http://www.crown-s-soft.com
;
; You may add you own figures. See file FIGURES.INC
;
; Compile with FASM v1.48 for Menuet or hier (FASM v1.40 contains bug)
;
; Copyright(c) 2002-2004 Crown_s Soft. All rights reserved.
;
 
fullscreen = 1
n_points = 0x1800
delay = 2
speed equ 0.004
 
 
macro align value { rb (value-1) - ($ + value-1) mod value }
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd start ; start of code
dd i_end ; size of image
dd i_end+0x1000 ; memory for app
dd i_end+0x1000 ; esp
dd 0x0 ; I_Param
dd 0x0 ; I_Icon
 
copyright db 'Crown_s Soft(c) Screensaver v1.13m www.crown-s-soft.com',0
copyrightlen:
 
include "lang.inc"
include "figuresi.inc"
include "macros.inc"
start:
cld
finit
call filling_alfbet ; fill table alfbet by casual numbers
 
mov eax,[tabl_calls]
mov [pp1adr],eax
 
 
cmp [flscr],0
jz nofullscreen
mov eax,14
int 0x40
 
mov [maxy],ax
sub ax,480
jnc m5
xor ax,ax
m5:
shr ax,1
mov [posy],ax
 
shr eax,16
mov [maxx],ax
sub ax,480
jnc m6
xor ax,ax
m6:
shr ax,1
mov [posx],ax
 
mov [outsize],480+65536*480
jmp m4
nofullscreen:
mov [posx],75
mov [posy],20
 
mov [outsize],450+65536*480
m4:
 
red:
call draw_window
 
still:
mov eax,23
mov ebx,delay
int 0x40 ; wait here for event
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
 
call calcframe
mov edx,dword [posy] ; edx=image position in window [x]*65536+[y]
mov ecx,[outsize] ; ecx=image position in window [x]*65536+[y]
mov ebx,scr ; ebx pointer to image in memory
mov eax,07 ; putimage
int 0x40
jmp still
 
key:
mov eax,2
int 0x40
 
cmp al,1 ; is key in buffer ?
jz still
cmp ah,0x1B ; is key ESC ?
jz close
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
; cmp ah,1 ; button id=1 ?
; jne still
 
close:
mov eax,-1 ; close this program
int 0x40
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
cmp [flscr],0
jnz m2
mov ebx,1*65536+640 ; [x start] *65536 + [x size]
mov ecx,1*65536+480 ; [y start] *65536 + [y size]
mov edx,0x02000000 ; color of work area RRGGBB,8->color gl
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl
mov edi,0x005080d0 ; color of frames RRGGBB
xor eax,eax ; function 0 : define and draw window
int 0x40
 
; WINDOW LABEL
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ddeeff ; color of text RRGGBB
mov edx,copyright ; pointer to text beginning
mov esi,copyrightlen-copyright; text length
mov eax,4 ; function 4 : write text to window
int 0x40
 
; CLOSE BUTTON
mov ebx,(640-19)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x6688dd ; button color RRGGBB
mov eax,8 ; function 8 : define and draw button
int 0x40
jmp m3
m2:
movzx ebx,[maxx] ; [x start] *65536 + [x size]
movzx ecx,[maxy] ; [y start] *65536 + [y size]
 
mov edx,0x01000000 ; color of work area RRGGBB,8->color gl
mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl
mov edi,0x005080d0 ; color of frames RRGGBB
xor eax,eax ; function 0 : define and draw window
int 0x40
 
inc bx
inc cx
mov eax,13 ; functiom 13 : draw bar
int 0x40
m3:
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
 
 
calcframe:
cld
mov edi,scr
mov ecx,480*480*3/4
xor eax,eax
rep stosd ; CLS
 
 
mov ebx,[frame]
not bh
test bh,03h
not bh
jnz lb1
; ebx=xxxx xxxx xxxx xxxx xxxx xx11 xxxx xxxxb
mov byte [p],bl
lb1:
 
test bx,03ffh
jnz lb2
; ebx=xxxx xxxx xxxx xxxx xxxx xx00 0000 0000b
mov [p],0
 
mov eax,[pp1adr]
mov [pp0adr],eax
 
inc [pp1]
cmp [pp1],num_tabl_calls
jnz lb3
mov [pp1],0
lb3:
 
movzx eax,[pp1]
mov eax,[tabl_calls+eax*4]
mov [pp1adr],eax
lb2:
 
 
fild [frame] ; st0=STime
fmul [speed1] ; st0=STime*Speed
fst [bt_r] ; al_rSTime*Speed
fadd st0,st0
fstp [al_r] ; al_rSTime*Speed*2
 
 
mov [Fl],0
mov ecx,[mFl]
mov esi,alfbet
ckl1:
call [pp0adr]
cmp [p],0
jz lb4
fstp [x1]
fstp [y1]
fstp [z1]
call [pp1adr]
call mix
lb4:
 
call turn
 
add esi,4
inc [Fl]
loop ckl1
 
inc ebx
mov [frame],ebx
ret
 
 
; turn coordinate system
turn:
; around Y
; x= x*cos(a)-z*sin(a)
; y= y
; z= x*sin(a)+z*cos(a)
fld st2 ; st0=z st1=x st2=y st3=z
fld st1 ; st0=x st1=z st2=x st3=y st4=z
fld [al_r] ; st0=a st1=x st2=z st3=x st4=y st5=z
fsincos ; st0=cos(a) st1=sin(a) st2=x st3=z st4=x st5=y st6=z
fmul st4,st0
fmulp st6,st0 ; st0=sin(a) st1=x st2=z st3=x*cos(a) st4=y st5=z*cos(a)
fmul st2,st0
fmulp st1,st0 ; st0=x*sin(a) st1=z*sin(a) st2=x*cos(a) st3=y st4=z*c
faddp st4,st0
fsubp st1,st0
 
 
; around X
; x=x
; y= y*cos(b)+z*sin(b)
; z=-y*sin(b)+z*cos(b)
fld st2 ; st0=z st1=x st2=y st3=z
fld st2 ; st0=y st1=z st2=x st3=y st4=z
fld [bt_r] ; st0=b st1=y st2=z st3=x st4=y st5=z
fsincos ; st0=cos(b) st1=sin(b) st2=y st3=z st4=x st5=y st6=z
fmul st5,st0
fmulp st6,st0 ; st0=sin(b) st1=y st2=z st3=x st4=y*cos(b) st5=z*cos(b)
fmul st2,st0
fmulp st1,st0 ; st0=y*sin(b) st1=z*sin(b) st2=x st3=y*cos(b) st4=z*cos(b)
fsubp st4,st0 ; st0=z*sin(b) st1=x st2=y*cos(b) st3=z*cos(b)-y*sin(b)
faddp st2,st0
 
; st0=x st1=y st2=z
fistp [x1]
fistp [y1]
fmul [Zdepth] ; st0=z*Zdepth
fiadd [Zcolor] ; st0=z*Zdepth+Zcolor
fistp [z_w] ; st0z*Zdepth+Zcolor
 
 
push edx
 
mov eax,[x1]
add eax,[mid]
mul [const480]
add eax,[y1]
add eax,[mid]
mul [const3]
 
mov dl,byte [z_w] ; al=ZZ
mov [scr+0+eax],dl
mov [scr+1+eax],dl
mov [scr+2+eax],dl
 
pop edx
ret
 
 
 
mix:
fild [p] ; st0=p
fmul [mp] ; st0=p=p*mp
fld st0 ; st0=p st1=p
fmul st4,st0
fmul st3,st0
fmulp st2,st0 ; st0=p st1=x*p st2=y*p st3=z*p
 
fld1
fsubrp st1,st0 ; st0=1-p st1=x*p st2=y*p st3=z*p
fld [z1] ; st0=z1 st1=1-p st2=x*p st3=y*p st4=z*p
fmul st0,st1
faddp st4,st0
fld [y1] ; st0=y1 st1=1-p st2=x*p st3=y*p st4=
fmul st0,st1
faddp st3,st0
fld [x1] ; st0=x1 st1=1-p st2=x*p st3=y*p+y1*(1-p) st4=
fmulp st1,st0 ; st0=x1*(1-p) st1=x*p st2=y*p+y1*(1-p) st3=
faddp st1,st0 ; st0=x=x*p+x1*(1-p) st1=y=y*p+y1*(1-p) st2=z
ret
 
 
filling_alfbet:
; Initialize RND
mov eax,3
int 40h
; eax - fist random number
 
mov ecx,n_points
mov edi,alfbet
mov ebx,8088405h
ck2:
stosd
; Compute next random number
; New := 8088405H * Old + 1
mul ebx
inc eax
loop ck2
ret
 
 
; DATA AREA
align 2
 
frame dd 0
 
mp dd 0.00390625
n_r dd 0.00390625
 
mal_r dd 6.28318530717958648
mbt_r dd 6.28318530717958648
 
const3 dd 3
const6 dw 6
const480 dd 480
 
mFl dd n_points
pp1 dw 0
 
Zdepth dd 0.3
Zcolor dw 140
 
mid dd 240 ; centre of screen
 
speed1 dd speed
flscr db fullscreen
 
align 4
 
outsize dd ?
posy dw ?
posx dw ?
maxy dw ?
maxx dw ?
 
Fl dd ?
 
p dd ?
al_r dd ?
bt_r dd ?
 
 
pp0adr dd ?
pp1adr dd ?
 
z_w dw ?
 
x1 dd ?
y1 dd ?
z1 dd ?
 
align 16
alfbet: ; alfbet db n_points*4 dup (?)
scr = alfbet+n_points*4 ; scr db 480*480*3+1 dup (?)
i_end = scr+480*480*3+1 ; i_param db 256 dup (?)
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/crownscr/trunk/figuresi.inc
0,0 → 1,564
;
; include file for Crown_s Soft Screensaver
;
; You may add you own figures for Screensaver.
; For example see tor function.
; If you add new figures, please contact us, we will help you.
;
;input parametrs:
; alf=word [esi] - random quantity 0<=alf<=0xffff
; bet=word [esi+2] - random quantity 0<=bet<=0xffff
; Fl - number of point in frame
; (may be used as random quantity) 0<=Fl<=mFl
; p - number of frame
; (may be use for animated figures)
;
;output parametrs:
; st0=x, st1=y, st2=z
 
 
 
align 8
 
const_mpi dd 0.0000958767251683032697061874258638112 ; 1/00007fffh*pi
const_m dd 0.0000305185094759971922971282082583087 ; 1/00007fffh
 
 
 
tabl_calls dd cubes
dd explosion
dd galaxy
dd cube
dd sin
dd tor1
dd tors
dd spiral
dd tor
dd planet
dd balls
num_tabl_calls=11
 
tor_r dw 60
tor_R dw 175
 
balls_x1 dw 0
balls_x2 dw 189
balls_x3 dw -94
balls_x4 dw -94
balls_y1 dw 0
balls_y2 dw 0
balls_y3 dw 163
balls_y4 dw -163
balls_z1 dw 200
balls_z2 dw -71
balls_z3 dw -71
balls_z4 dw -71
balls_R dw 35
 
cube_R dw 118
 
spiral_R dw 100
spiral_r dw 20
spiral_h dw 150
spiral_L dw 12
 
sin_a dw 165
sin_c dw 3
sin_k dw 20
sin_A dw 85
sin_R dw 10
 
planet_R dw 120
planet_r dw 25
planet_h dw 195
planet_d dw 30
 
tors_r dw 10
tors_R1 dw 100
tors_R2 dw 150
tors_R3 dw 200
tors_a1 dw 6
tors_a2 dw 3
 
tor1_R dw 7
tor1_r dd 1.8
tor1_turns dd 25.132741228718345907701147066236 ; 2*4*pi
tor1_whorls dd 87.9645943005142106769540147318261 ; 7*4*pi
tor1_a dw 20
 
galaxy_rq dw 45
galaxy_rz dw 30
galaxy_R dw 185
galaxy_k dd 9.42477796076937971538793014983851 ; 3*pi
galaxy_A dw 230
 
 
cubes_R dw 70
 
explosion_R dw 230
 
;---------------------------------------------------------------------------
;----------------------- calculation figures -------------------------------
;---------------------------------------------------------------------------
 
 
;---------------------------- explosion ------------------------------------
explosion:
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [Fl]
fidiv [mFl]
fadd [al_r]
fsin
fimul [explosion_R] ; st0=R st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
ret
 
 
;------------------------------ cubes --------------------------------------
cubes:
push edx
xor edx,edx
mov eax,[Fl]
div [const6]
 
 
fild [cubes_R] ; st0=R
bt dx,0
jc cubes_l0
; ax=xxxx xxxx xxxx xxx0b
fchs ; st0=-R
cubes_l0:
 
fild word [esi+2] ; st0=bet st1=R
fmul [const_m] ; st0=bet*mbet st1=R
fmul st0,st1 ; st0=R*bet*mbet st1=R
 
fild word [esi] ; st0=alf st1=R*bet*mbet st2=R
fmul [const_m] ; st0=alf*malf st1=R*bet*mbet st2=R
fmul st0,st2 ; st0=R*alf*malf st1=R*bet*mbet st2=R
 
bt dx,2
jc cubes_l1 ; dx=xxxx xxxx xxxx x10xb
bt dx,1
jc cubes_l2 ; dx=xxxx xxxx xxxx x01xb
; dx=xxxx xxxx xxxx x00xb
fstp st3
cubes_l1:
fstp st3
cubes_l2:
 
div [const6]
 
fild [cubes_R] ; st0=R
fadd st0,st0
bt dx,0
jc cubes_l4
; ax=xxxx xxxx xxxx xxx0b
fchs ; st0=-R
cubes_l4:
faddp st1,st0
 
bt dx,2
jc cubes_l5 ; ax=xxxx xxxx xxxx x10xb
bt dx,1
jc cubes_l6 ; ax=xxxx xxxx xxxx x01xb
; ax=xxxx xxxx xxxx x00xb
fstp st3
cubes_l5:
fstp st3
cubes_l6:
 
pop edx
ret
 
 
;----------------------------- galaxy --------------------------------------
galaxy:
bt [Fl],0
jc not_gal
fild [Fl]
fidiv [mFl] ; st0=f=Fl/mFl
fild word [esi+2] ; st0=bet st1=f
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=f
fsincos ; st0=cos(b) st1=sin(b) st2=f
fild word [esi] ; st0=alf st1=cos(b) st2=sin(b) st3=f
fmul [const_m] ; st0=a=alf*malf st1=cos(b) st2=sin(b) st3=f
fmul st2,st0 ; st0=a st1=cos(b) st2=a*sin(b) st3=f
fmulp st1,st0 ; st0=a*cos(b) st1=a*sin(b) st2=f
fmul st0,st2 ; st0=f*a*cos(b) st1=a*sin(b) st2=f
fimul [galaxy_rz] ; st0=rz*f*a*cos(b) st1=a*sin(b) st2=f
fstp st3 ; st0=a*sin(b) st1=f st2=Z
fimul [galaxy_rq] ; st0=a*rq*sin(b) st1=f st2=Z
fiadd [galaxy_R] ; st0=R+a*rq*sin(b) st1=f st2=Z
fxch st1 ; st0=f st1=R+rq*a*sin(b) st2=Z
fmul st1,st0 ; st0=f st1=f*(R+rq*a*sin(b)) st2=Z
fmul [galaxy_k] ; st0=F=k*f st1=f*(R+rq*a*sin(b)) st2=Z
 
bt [Fl],1
jc gal_lb
fldpi
faddp st1,st0 ; st0=F=F+pi st1=f*(R+rq*a*sin(b)) st2=Z
gal_lb:
 
fsincos ; st0=cos(F) st1=sin(F) st2=f*(R+rq*a*sin(b)) st3=Z
fxch st2 ; st0=f*(R+rq*a*sin(b)) st1=sin(F) st2=cos(F) st3=Z
fmul st2,st0
fmulp st1,st0 ; st0=cos(F)*f*(R+rq*a*sin(b)) st1=sin(F)*f*(R+rq*a*sin(b)) st2=Z
ret
not_gal:
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [Fl] ; st0=Fl st1=cos(a) st2=sin(a)
fidiv [mFl] ; st0=Fl/mFl st1=cos(a) st2=sin(a)
fmul st0,st0
fmul st0,st0
fmul st0,st0
fst st3
fimul [galaxy_A] ; st0=R=A*Fl/mFl st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
 
; around Z
fld st1
fld st1 ; st0=x st1=y st2=x st3=y st4=z
fld [al_r] ; st0=a st1=x st2=y st3=x st4=y st5=z
fchs
fmul st0,st6
fsincos ; st0=cos(a) st1=sin(a) st2=x st3=y st4=x st5=y st6=z
fmul st4,st0
fmulp st5,st0
fmul st2,st0
fmulp st1,st0 ; st0=x*sin(a) st1=y*sin(a) st2=x*cos(a) st3=y*cos(a) st4=z
faddp st3,st0
fsubp st1,st0
 
ffree st3
ret
 
 
 
;------------------------------ balls --------------------------------------
balls:
mov eax,[Fl]
and eax,03h
 
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [balls_R] ; st0=R st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
 
fiadd [balls_y1+2*eax] ; st0=y+R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
fxch st1 ; st0=R*cos(a)*cos(b) st1=y+R*cos(a)*sin(b) st2=R*sin(a)
fiadd [balls_z1+2*eax] ; st0=z+R*cos(a)*cos(b) st1=y+R*cos(a)*sin(b) st2=R*sin(a)
fxch st2 ; st0=R*sin(a) st1=y+R*cos(a)*sin(b) st2=z+R*cos(a)*cos(b)
fiadd [balls_x1+2*eax] ; st0=x+R*sin(a) st1=y+R*cos(a)*sin(b) st2=z+R*cos(a)*cos(b)
ret
 
 
;------------------------------- sin ---------------------------------------
sin:
test [Fl],3Fh
 
fild word [esi] ; st0=alf
 
jnz sin_lb1
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [sin_R] ; st0=R st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
fiadd [sin_A] ; st0=A+R*cos(b)*sin(a) st2=R*cos(a)*cos(b) st3=R*sin(a)
ret
 
sin_lb1:
fmul [const_m] ; st0=alf*malf
fild word [esi+2] ; st0=bet st1=alf*malf
fmul [const_m] ; st0=bet*mbet st1=alf*malf
 
fld st0 ; st0=bet*mbet st1=bet*mbet st2=alf*malf
fmul st0,st0 ; st0=(bet*mbet)^2 st1=bet*mbet st2=alf*malf
fld st2 ; st0=alf*malf st1=(bet*mbet)^2 st2=bet*mbet st3=alf*malf
fmul st0,st0 ; st0=(alf*malf)^2 st1=(bet*mbet)^2 st2=bet*mbet st3=alf*malf
faddp st1,st0 ; st0=(alf*malf)^2+(bet*mbet)^2 st1=bet*mbet st2=alf*malf
fsqrt ; st0=r=sqr((alf*malf)^2*(bet*mbet)^2) st1=bet*mbet st2=alf*malf
fild [sin_k] ; st0=k st1=r st2=bet*mbet st3=alf*malf
fmul st0,st1 ; st0=k*r st1=r st2=bet*mbet st3=alf*malf
fsin ; st0=sin(k*r) st1=r st2=bet*mbet st3=alf*malf
fdivrp st1,st0 ; st0=sin(k*r)/r st1=bet*mbet st2=alf*malf
fimul [sin_c] ; st0=c*sin(k*r)/r st1=bet*mbet st2=alf*malf
 
fild [sin_a] ; st0=a st1=c*sin(k*r)/r st2=bet*mbet st3=alf*malf
fmul st2,st0 ; st0=a st1=c*sin(k*r)/r st2=a*bet*mbet st3=alf*malf
fmulp st3,st0 ; st0=c*sin(k*r)/r st1=a*bet*mbet st2=a*alf*malf
ret
 
 
;------------------------------ tors ---------------------------------------
tors:
push edx
xor edx,edx
mov eax,[Fl]
div [const3]
mov al,dl
pop edx
 
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [tors_r] ; st0=r st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=r st1=cos(a) st2=r*sin(a)
fmulp st1,st0 ; st0=r*cos(a) st1=r*sin(a)
bt ax,1
jc tors_l1 ; ax=xxxx xxxx xxxx xx1xb
bt ax,0
jc tors_l2 ; ax=xxxx xxxx xxxx xxx1b
fiadd [tors_R3] ; st0=r*cos(a)+R st1=r*sin(a)
fild word [esi+2] ; st0=bet st1=r*cos(a)+R st2=r*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=r*cos(a)+R st2=r*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=r*cos(a)+R st3=r*sin(a)
fxch st2 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b) st3=r*sin(a)
fmul st2,st0 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b)*(r*cos(a)+R) st3=r*sin(a)
fmulp st1,st0 ; st0=sin(b)*(r*cos(a)+R) st1=cos(b)*(r*cos(a)+R) st2=r*sin(a)
ret
 
tors_l1:
fiadd [tors_R2] ; st0=r*cos(a)+R st1=r*sin(a)
fild word [esi+2] ; st0=bet st1=r*cos(a)+R st2=r*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=r*cos(a)+R st2=r*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=r*cos(a)+R st3=r*sin(a)
fxch st2 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b) st3=r*sin(a)
fmul st2,st0 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b)*(r*cos(a)+R) st3=r*sin(a)
fmulp st1,st0 ; st0=sin(b)*(r*cos(a)+R) st1=cos(b)*(r*cos(a)+R) st2=r*sin(a)
jmp tors_l3
 
tors_l2:
fiadd [tors_R1] ; st0=r*cos(a)+R st1=r*sin(a)
fild word [esi+2] ; st0=bet st1=r*cos(a)+R st2=r*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=r*cos(a)+R st2=r*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=r*cos(a)+R st3=r*sin(a)
fxch st2 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b) st3=r*sin(a)
fmul st2,st0 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b)*(r*cos(a)+R) st3=r*sin(a)
fmulp st1,st0 ; st0=sin(b)*(r*cos(a)+R) st1=cos(b)*(r*cos(a)+R) st2=r*sin(a)
 
 
; around Y
; x= x*cos(a)-z*sin(a)
; y= y
; z= x*sin(a)+z*cos(a)
fld st2 ; st0=z st1=x st2=y st3=z
fld st1 ; st0=x st1=z st2=x st3=y st4=z
fld [al_r]
fimul [tors_a1] ; st0=a st1=x st2=z st3=x st4=y st5=z
fsincos ; st0=cos(a) st1=sin(a) st2=x st3=z st4=x st5=y st6=z
fmul st4,st0
fmulp st6,st0 ; st0=sin(a) st1=x st2=z st3=x*cos(a) st4=y st5=z*cos(a)
fmul st2,st0
fmulp st1,st0 ; st0=x*sin(a) st1=z*sin(a) st2=x*cos(a) st3=y st4=z*cos(a)
faddp st4,st0
fsubp st1,st0
 
tors_l3:
; around X
; x=x
; y= y*cos(b)+z*sin(b)
; z=-y*sin(b)+z*cos(b)
fld st2 ; st0=z st1=x st2=y st3=z
fld st2 ; st0=y st1=z st2=x st3=y st4=z
fld [al_r]
fimul [tors_a2] ; st0=b st1=y st2=z st3=x st4=y st5=z
fsincos ; st0=cos(b) st1=sin(b) st2=y st3=z st4=x st5=y st6=z
fmul st5,st0
fmulp st6,st0 ; st0=sin(b) st1=y st2=z st3=x st4=y*cos(b) st5=z*cos(b)
fmul st2,st0
fmulp st1,st0 ; st0=y*sin(b) st1=z*sin(b) st2=x st3=y*cos(b) st4=z*cos(b)
fsubp st4,st0 ; st0=z*sin(b) st1=x st2=y*cos(b) st3=z*cos(b)-y*sin(b)
faddp st2,st0
ret
 
 
;------------------------------ tor1 ---------------------------------------
tor1:
fild [tor1_a] ; st0=a
fild word [esi+2] ; st0=bet st1=a
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=a
fsincos ; st0=cos(b) st1=sin(b) st2=a
fild word [esi] ; st0=alf st1=cos(b) st2=sin(b) st3=a
fmul [const_m] ; st0=alf*malf st1=cos(b) st2=sin(b) st3=a
fld st0 ; st0=alf*malf st1=alf*malf st2=cos(b) st3=sin(b) st4=a
fmul [tor1_whorls] ; st0=wa=whorls*alf*malf st1=alf*malf st2=cos(b) st3=sin(b) st4=a
fsincos ; st0=cos(wa) st1=sin(wa) st2=alf*malf st3=cos(b) st4=sin(b) st5=a
fld [tor1_r] ; st0=r st1=cos(wa) st2=sin(wa) st3=alf*malf st4=cos(b) st5=sin(b) st6=a
fmul st2,st0 ; st0=r st1=cos(wa) st2=r*sin(wa) st3=alf*malf st4=cos(b) st5=sin(b) st6=a
fmulp st1,st0 ; st0=r*cos(wa) st1=r*sin(wa) st2=alf*malf st3=cos(b) st4=sin(b) st5=a
fiadd [tor1_R] ; st0=R+r*cos(wa) st1=r*sin(wa) st2=alf*malf st3=cos(b) st4=sin(b) st5=a
faddp st3,st0 ; st0=r*sin(wa) st1=alf*malf st2=R+r*cos(wa)+cos(b) st3=sin(b) st4=a
faddp st3,st0 ; st0=alf*malf st1=R+r*cos(wa)+cos(b) st2=r*sin(wa)+sin(b) st3=a
fmul [tor1_turns] ; st0=ta=turns*alf*malf st1=R+r*cos(wa)+cos(b) st2=r*sin(wa)+sin(b) st3=a
fsincos ; st0=cos(ta) st1=sin(ta) st2=R+r*cos(wa)+cos(b) st3=r*sin(wa)+sin(b) st4=a
fmul st0,st2 ; st0=cos(ta)*(R+r*cos(wa)+cos(b)) st1=sin(ta) st2=R+r*cos(wa)+cos(b) st3=r*sin(wa)+sin(b) st4=a
fmul st0,st4 ; st0=a*cos(ta)*(R+r*cos(wa)+cos(b)) st1=sin(ta) st2=R+r*cos(wa)+cos(b) st3=r*sin(wa)+sin(b) st4=a
fstp st5 ; st0=sin(ta) st1=R+r*cos(wa)+cos(b) st2=r*sin(wa)+sin(b) st3=a st4=y
fmulp st1,st0 ; st0=sin(ta)*(R+r*cos(wa)+cos(b)) st1=r*sin(wa)+sin(b) st2=a st3=y
fmul st0,st2 ; st0=z=a*sin(ta)*(R+r*cos(wa)+cos(b)) st1=r*sin(wa)+sin(b) st2=a st3=y
fstp st4 ; st0=r*sin(wa)+sin(b) st1=a st2=y st3=z
fmulp st1,st0 ; st0=x=a*(r*sin(wa)+sin(b)) st1=y st2=z
ret
 
 
 
;------------------------------- tor ---------------------------------------
tor:
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [tor_r] ; st0=r st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=r st1=cos(a) st2=r*sin(a)
fmulp st1,st0 ; st0=r*cos(a) st1=r*sin(a)
fiadd [tor_R] ; st0=r*cos(a)+R st1=r*sin(a)
fild word [esi+2]; st0=bet st1=r*cos(a)+R st2=r*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=r*cos(a)+R st2=r*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=r*cos(a)+R st3=r*sin(a)
fxch st2 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b) st3=r*sin(a)
fmul st2,st0 ; st0=r*cos(a)+R st1=sin(b) st2=cos(b)*(r*cos(a)+R) st3=r*sin(a)
fmulp st1,st0 ; st0=sin(b)*(r*cos(a)+R) st1=cos(b)*(r*cos(a)+R) st2=r*sin(a)
ret
 
 
;------------------------------ spiral -------------------------------------
spiral:
fild word [esi+2] ; st0=bet
fmul [const_m] ; st0=bet*mbet
fild word [esi] ; st0=alf st1=bet*mbet
fmul [const_mpi] ; st0=a=pi*alf*malf st1=bet*mbet
fsincos ; st0=cos(a) st1=sin(a) st2=bet*mbet
fimul [spiral_r] ; st0=r*cos(a) st1=sin(a) st2=bet*mbet
fld st2 ; st0=bet*mbet st1=r*cos(a) st2=sin(a) st3=bet*mbet
fimul [spiral_h] ; st0=bet*mbet*h st1=r*cos(a) st2=sin(a) st3=bet*mbet
faddp st1,st0 ; st0=z=bet*mbet*h+r*cos(a) st1=sin(a) st2=bet*mbet
fstp st3 ; st0=sin(a) st1=bet*mbet st2=z
fimul [spiral_r] ; st0=r*sin(a) st1=bet*mbet st2=z
fiadd [spiral_R] ; st0=r*sin(a)+R st1=bet*mbet st2=z
fxch st1 ; st0=bet*mbet st1=r*sin(a)+R st2=z
fimul [spiral_L] ; st0=b=L*bet*mbet st1=r*sin(a)+R st2=z
fsincos ; st0=cos(b) st1=sin(b) st2=r*sin(a)+R st3=z
fxch st2 ; st0=r*sin(a)+R st1=sin(b) st2=cos(b) st3=z
fmul st2,st0 ; st0=r*sin(a)+R st1=sin(b) st2=(r*sin(a)+R)*cos(b) st3=z
fmulp st1,st0 ; st0=x=(r*sin(a)+R)*sin(b) st2=y=(r*sin(a)+R)*cos(b) st3=z
ret
 
 
;------------------------------- cube --------------------------------------
cube:
push edx
xor edx,edx
mov eax,[Fl]
div [const6]
 
fild [cube_R] ; st0=R
bt dx,0
jc cube_l0
; dx=xxxx xxxx xxxx xxx0b
fchs ; st0=-R
cube_l0:
 
fild word [esi+2] ; st0=bet st1=R
fmul [const_m] ; st0=bet*mbet st1=R
fmul st0,st1 ; st0=R*bet*mbet st1=R
 
fild word [esi] ; st0=alf st1=R*bet*mbet st2=R
fmul [const_m] ; st0=alf*malf st1=R*bet*mbet st2=R
fmul st0,st2 ; st0=R*alf*malf st1=R*bet*mbet st2=R
 
bt dx,2
jc cube_l1 ; dx=xxxx xxxx xxxx x10xb
bt dx,1
jc cube_l2 ; dx=xxxx xxxx xxxx x01xb
; dx=xxxx xxxx xxxx x00xb
fstp st3
cube_l1:
fstp st3
cube_l2:
pop edx
ret
 
 
;------------------------------ planet -------------------------------------
planet:
bt [Fl],0
jc planet_lb1
 
bt [Fl],1
jc planet_lb0
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [planet_R] ; st0=R st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
ret
planet_lb0:
fild word [esi] ; st0=alf
fmul [const_mpi] ; st0=a=pi*alf*malf
fsincos ; st0=cos(a) st1=sin(a)
fild [planet_r] ; st0=R st1=cos(a) st2=sin(a)
fmul st2,st0 ; st0=R st1=cos(a) st2=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a) st2=R*sin(a)
fild word [esi+2] ; st0=bet st1=R*cos(a) st2=R*sin(a)
fmul [const_mpi] ; st0=b=pi*bet*mbet st1=R*cos(a) st2=R*sin(a)
fsincos ; st0=cos(b) st1=sin(b) st2=R*cos(a) st3=R*sin(a)
fxch st2 ; st0=R*cos(a) st1=sin(b) st2=cos(b) st3=R*sin(a)
fmul st2,st0 ; st0=R*cos(a) st1=sin(b) st2=R*cos(a)*cos(b) st3=R*sin(a)
fmulp st1,st0 ; st0=R*cos(a)*sin(b) st1=R*cos(a)*cos(b) st2=R*sin(a)
fiadd [planet_h] ; st0=R*cos(a)*sin(b)+h st1=R*cos(a)*cos(b) st2=R*sin(a)
fxch st1 ; st0=R*cos(a)*cos(b) st1=R*cos(a)*sin(b)+h st2=R*sin(a)
ret
planet_lb1:
fild word [esi+2] ; st0=bet
fmul [const_m] ; st0=bet*mbet
fimul [planet_d] ; st0=d*bet*mbet
fiadd [planet_h] ; st0=h+d*bet*mbet
fild word [esi] ; st0=alf st1=h+d*bet*mbet
fmul [const_mpi] ; st0=a=pi*alf*malf st1=h+d*bet*mbet
fsincos ; st0=cos(a) st1=sin(a) st2=h+d*bet*mbet
fxch st2 ; st0=h+d*bet*mbet st1=sin(a) st2=cos(a)
fmul st2,st0 ; st0=h+d*bet*mbet st1=sin(a) st2=cos(a)*(h+d*bet*mbet)
fmulp st1,st0 ; st0=(h+d*bet*mbet)*sin(a) st1=cos(a)*(h+d*bet*mbet)
fldz ; st0=0 st1=(h+d*bet*mbet)*sin(a) st2=cos(a)*(h+d*bet*mbet)
ret
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/crownscr/trunk/macros.inc
0,0 → 1,261
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/cslide/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm cslide.asm cslide
@pause
/programs/demos/cslide/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm cslide.asm cslide
@pause
/programs/demos/cslide/trunk/cslide.asm
0,0 → 1,391
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Color Slider Control Demonstration ;
; ;
; Compile with FASM for Menuet ;
; ;
; Author: Jason Delozier ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
START: ; start of execution
 
call draw_window ; at first, draw the window
 
still:
call mouse_info
 
mov eax,23
mov ebx,2
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
shr eax,8
 
cmp eax,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
 
 
nofind:
jmp still
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
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,100*65536+200 ; [x start] *65536 + [x size]
mov ecx,100*65536+200 ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x806688cc
mov edi,0x006688cc
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,0x00ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
call draw_slider_info
 
xor ecx,ecx
Draw_Controls_Loop:
mov ebp, [App_Controls+ecx] ;get controls data location
or ebp,ebp
jz Draw_Controls_Done
call dword [App_Controls+ecx+4] ;call controls draw function
add ecx, 12
jmp Draw_Controls_Loop
Draw_Controls_Done:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
;***********************************************
;* Mouse Stuff
;***********************************************
mousey dw 0
mousex dw 0
mouseb dd 0
 
mouse_info:
mov eax, 37 ;get mouse cordinates
mov ebx, 1 ;
int 0x40 ;
mov ecx, eax ;
push ecx ;
mov eax, 37 ;get mouse buttons
mov ebx, 2 ;
int 0x40 ;
cmp [mouseb], eax ;compare old mouse states to new states
jne redraw_mouse_info ;
cmp [mousey], cx ;
jne redraw_mouse_info ;
shr ecx, 16 ;
cmp [mousex], cx ;
jne redraw_mouse_info ;
pop ecx ;
ret ;return if no change in states
 
 
redraw_mouse_info:
pop ecx
mov [mouseb], eax ;save new mouse states
mov dword [mousey], ecx
 
xor ecx, ecx
Check_Mouse_Over_Controls_Loop:
mov ebp, [App_Controls+ecx]
or ebp,ebp
jz Check_Mouse_Over_Controls_Loop_done
movzx eax,word [ebp+2]
cmp ax, [mousex]
ja mouse_not_on_control
movzx eax,word [ebp+6]
cmp ax, [mousey]
ja mouse_not_on_control
movzx eax,word [ebp]
add ax, [ebp+2]
cmp ax, [mousex]
jb mouse_not_on_control
movzx eax,word [ebp+4]
add ax, [ebp+6]
cmp ax, [mousey]
jb mouse_not_on_control
call dword [App_Controls+ecx+8]
mouse_not_on_control:
add ecx, 12
jmp Check_Mouse_Over_Controls_Loop
Check_Mouse_Over_Controls_Loop_done:
 
ret
 
 
 
 
;***********************************************
 
 
draw_slider_info:
;Repaint value background
mov eax, 13
mov ebx, 0x00960028
mov ecx, 0x00240010
mov edx, 0x00ffffff
int 0x40
;Draw Color Box
xor edx, edx
movzx ecx,word [slider_1+12]
mov dh, cl
movzx ecx,word [slider_2+12]
mov dl, cl
shl edx, 8
movzx ecx,word [slider_3+12]
mov dl,cl
mov ebx, 0x00860035
mov ecx, 0x00590040
mov eax, 13
int 0x40
;draw current value of slider
mov ecx, edx
mov eax, 47
mov ebx, 0x00060100
mov esi, 0
mov edx, 0x009A0029
int 0x40
ret
 
 
;**************************************
;*
;* App Controls
;*
;**************************************
 
App_Controls:
dd slider_1 , draw_slider, slider_mouse_over ;
dd slider_2 , draw_slider, slider_mouse_over ;
dd slider_3 , draw_slider, slider_mouse_over ;
dd 0 , 0 ; denotes last control do not delete
 
;**************************************
;*
;* Slider data
;*
;**************************************
 
slider_1:
dw 25 ;width +0
dw 10 ;x +2
dw 150 ;height +4
dw 30 ;y +6
dw 0 ;min +8
dw 255 ;max +10
dw 128 ;current +12
dw 1 ;small change +14
dw 5 ;big change +16
 
slider_2:
dw 25 ;width +0
dw 55 ;x +2
dw 150 ;height +4
dw 30 ;y +6
dw 0 ;min +8
dw 255 ;max +10
dw 128 ;current +12
dw 1 ;small change +14
dw 5 ;big change +16
 
slider_3:
dw 25 ;width +0
dw 100 ;x +2
dw 150 ;height +4
dw 30 ;y +6
dw 0 ;min +8
dw 255 ;max +10
dw 128 ;current +12
dw 1 ;small change +14
dw 5 ;big change +16
 
;**************************************
;*
;* Slider Code
;*
;**************************************
 
box_h dw 10 ;static slider box height
 
draw_slider:
push eax
push ebx
push ecx
push edx
;Draw slider background
mov eax, 13 ;slider background
mov ebx, [ebp] ;x start/width
mov ecx, [ebp+4] ;y start/height
mov edx, 0x002288DD ;color
int 0x40 ;draw bar
;Draw line for slide rail
mov eax, 38 ;draw vertical slide line
movzx ebx,word [ebp] ;x
shr ebx, 1 ;
add bx,word [ebp+2];
push bx ;
shl ebx, 16 ;
pop bx ;
mov ecx, [ebp+4] ;y start / height
add ecx, 0x000A0000 ;
add ecx, [ebp+6] ;y start
sub ecx, 10 ;
mov edx, 0x00 ;color
int 0x40 ;
;Draw slider box
movzx eax,word [ebp+4] ;height
sub eax, 20 ;
movzx ebx,word [ebp+10] ;max value
sub bx,word [ebp+8] ;min value
movzx ecx,word [ebp+12] ;
call slider_fpu_calc ;EAX = ((EAX/EBX)*ECX)
mov ebx, [ebp] ;x start / width
movzx ecx,word [ebp+4] ;height
add cx, [ebp+6] ;y
sub ecx, 10 ;
movzx edx, [box_h] ;
shr edx, 1 ;
sub ecx, edx ;
sub ecx, eax ;*slide box y position
shl ecx, 16 ;
mov cx, [box_h] ;height
mov eax, 13 ;draw bar sys function
mov edx, 0x00 ;color
int 0x40 ;draw slider box
pop edx
pop ecx
pop ebx
pop eax
ret
 
slider_mouse_over:
push eax
push ebx
push ecx
push edx
cmp [mouseb], 1
jne slider_mouse_over_done
movzx eax,word [ebp+4]
add ax, [ebp+6]
sub eax, 10
cmp [mousey], ax
ja slider_mouse_min
movzx eax,word [ebp+6]
add eax, 10
cmp [mousey], ax
jb slider_mouse_max
;determine new current value
movzx eax,word [ebp+10] ;slider max value
sub ax,word [ebp+8] ;slider min value
movzx ebx,word [ebp+4] ;slider height
sub ebx,20 ;rail size
movzx ecx,word [mousey] ;current mouse y pixel
sub cx,word [ebp+6] ;minus y start of slider
sub ecx, 10 ;minus pixels to top of rail
call slider_fpu_calc ;EAX = ((EAX/EBX)*ECX)
movzx ebx,word [ebp+10] ;slider max
sub ebx,eax ;*current calculated position
jmp slider_mouse_change;
slider_mouse_max: ;
movzx ebx,word [ebp+10] ;get maximum value
jmp slider_mouse_change ;
slider_mouse_min: ;
movzx ebx,word [ebp+8] ;get minimum value
slider_mouse_change: ;
mov [ebp+12],bx ;new slider current position
call draw_slider ;
call draw_slider_info ;
slider_mouse_over_done: ;
pop edx
pop ecx
pop ebx
pop eax
ret
 
 
temp dd 0 ;temp varibles used in fpu computations
temp2 dd 0
temp3 dd 0
 
slider_fpu_calc:
mov [temp], eax
mov [temp2], ebx
mov [temp3], ecx
finit ;initilize FPU
fld dword [temp] ;load value
fdiv dword [temp2] ;divide
fmul dword [temp3] ;multiply
fst dword [temp] ;store computed value
mov eax, [temp]
ret
 
;**************************************************
;* End Slider Code
;**************************************************
 
; DATA AREA
labelt: db 'Color Slider'
labellen:
I_END:
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/eyes/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm eyes.asm eyes
@pause
/programs/demos/eyes/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm eyes.asm eyes
@pause
/programs/demos/eyes/trunk/eyes.asm
0,0 → 1,388
;
; EYES FOR MENUET
;
; Written by Nikita Lesnikov (nlo_one@mail.ru)
;
; Position of "eyes" is fixed. To close "eyes" just click on them.
;
; NOTE: quite big timeout is used to disable blinking when redrawing.
; If "eyes" blink on your system, enlarge the TIMEOUT. If not, you can
; decrease it due to more realistic movement.
;
 
TIMEOUT equ 5
 
; EXECUTABLE HEADER
 
use32
 
org 0x0
db "MENUET01"
dd 0x01
dd ENTRANCE
dd EYES_END
dd 0x3000
dd 0x3000
dd 0x0
dd 0x0
 
include 'macros.inc'
ENTRANCE: ; start of code
 
; ==== main ====
 
call prepare_eyes
 
call shape_window
 
still:
 
call draw_eyes ; draw those funny "eyes"
 
mov eax,23 ; wait for event with timeout
mov ebx,TIMEOUT
int 0x40
 
cmp eax,1 ; redraw ?
jnz no_draw
call redraw_overlap
no_draw:
 
cmp eax,2 ; key ?
jz key
 
cmp eax,3 ; button ?
jz button
 
jmp still ; loop
 
; EVENTS
 
key:
mov eax,2 ; just read and ignore
int 0x40
jmp still
 
button: ; analyze button
mov eax,-1 ; this is button 1 - we have only one button :-)
int 0x40
jmp still
 
; -====- declarations -====-
 
imagedata equ EYES_END
skindata equ EYES_END+925
winref equ EYES_END+6325
 
; -====- shape -====-
 
shape_window:
 
mov eax,50 ; set up shape reference area
mov ebx,0
mov ecx,winref
int 0x40
 
ret
 
; -====- redrawing -====-
 
draw_eyes: ; check mousepos to disable blinking
 
mov eax,37
xor ebx,ebx
int 0x40
cmp dword [mouse],eax
jne redraw_ok
ret
redraw_ok:
mov [mouse],eax
 
redraw_overlap: ; label for redraw event (without checkmouse)
 
mov eax,12
mov ebx,1
int 0x40
 
xor eax,eax ; define window
mov ebx,[win_ebx]
mov ecx,[win_ecx]
xor edx,edx
xor esi,esi
xor edi,edi
int 0x40
 
mov eax,8 ; define closebutton
mov ebx,60
mov ecx,45
mov edx,1
int 0x40
 
mov eax,7
mov ebx,skindata
mov ecx,60*65536+30
mov edx,15
int 0x40
 
mov eax,15
mov ebx,30
call draw_eye_point
add eax,30
call draw_eye_point
 
mov eax,12
mov ebx,2
int 0x40
 
ret
 
draw_eye_point: ; draw eye point (EAX=X, EBX=Y)
pusha
 
mov ecx, [mouse] ; ecx = mousex, edx = mousey
mov edx,ecx
shr ecx,16
and edx,0xFFFF
 
; ===> calculate position
 
push eax
push ebx
mov byte [sign1],0
mov esi, [win_ebx]
shr esi,16
add eax,esi
sub ecx,eax ; ECX=ECX-EAX (signed) , ECX=|ECX|
jnc abs_ok_1
neg ecx
mov byte [sign1],1
abs_ok_1:
mov [temp1],ecx
mov byte [sign2],0
mov esi,[win_ecx]
shr esi,16
add ebx,esi
sub edx,ebx ; EDX=EDX-EBX (signed) , EDX=|EDX|
jnc abs_ok_2
neg edx
mov byte [sign2],1
abs_ok_2:
mov [temp2],edx
pop ebx
pop eax
 
push eax ; ECX*=ECX
push edx
xor eax,eax
xor edx,edx
mov ax,cx
mul cx
shl edx,16
or eax,edx
mov ecx,eax
pop edx
pop eax
 
push eax ; EDX*=EDX
push ecx
mov ecx,edx
xor eax,eax
xor edx,edx
mov ax,cx
mul cx
shl edx,16
or eax,edx
mov edx,eax
pop ecx
pop eax
 
push ebx
push ecx
push edx
push eax
mov ebx,ecx ; EBX=ECX+EDX
add ebx,edx
xor edi,edi ; ESI=SQRT(EBX)
mov ecx,edi
mov edx,edi
inc edi
mov eax,edi
inc edi
sqrt_loop:
add ecx,eax
add eax,edi
inc edx
cmp ecx,ebx
jbe sqrt_loop
dec edx
mov esi,edx
mov ax,si ; ESI=ESI/7
mov dl,7
div dl
and ax,0xFF
mov si,ax ; ESI ? 0 : ESI=1
jnz nozeroflag1
mov si,1
nozeroflag1:
 
pop eax
pop edx
pop ecx
pop ebx
 
push eax ; ECX=[temp1]/ESI
push edx
mov eax,[temp1]
mov dx,si
div dl
mov cl,al
and ecx,0xFF
pop edx
pop eax
 
cmp byte [sign1],1
je subtract_1
add eax,ecx ; EAX=EAX+ECX
jmp calc_ok_1
subtract_1:
sub eax,ecx ; EAX=EAX-ECX
calc_ok_1:
 
push eax ; EDX=[temp2]/ESI
push ecx
mov eax,[temp2]
mov dx,si
div dl
mov dl,al
and dx,0xFF
pop ecx
pop eax
 
cmp byte [sign2],1
je subtract_2
add ebx,edx ; EBX=EBX+EDX
jmp calc_ok_2
subtract_2:
sub ebx,edx ; EBX=EBX-EDX
calc_ok_2:
 
; <===
 
mov ecx,ebx ; draw point
mov ebx,eax
mov eax,13
dec ecx
dec ecx
dec ebx
dec ebx
shl ecx,16
add ecx,4
shl ebx,16
add ebx,4
mov eax,13
xor edx,edx
int 0x40
 
popa
ret
 
; -====- working on images and window -====-
 
prepare_eyes:
 
;mov eax,6 ; load EYES.RAW
;mov ebx,graphix
;mov ecx,0x00000000
;mov edx,0xFFFFFFFF
;mov esi,imagedata
;int 0x40
;cmp eax,0xFFFFFFFF
;jnz filefound
 
;mov eax,-1 ; file not exists...
;int 0x40
 
;filefound:
mov esi,imagedata+25 ; transform grayscale to putimage format
mov edi,skindata
mov ecx,30
transform_loop:
push ecx
mov ecx,30
lp1:
lodsb
stosb
stosb
stosb
loop lp1
sub esi,30
mov ecx,30
lp2:
lodsb
stosb
stosb
stosb
loop lp2
pop ecx
loop transform_loop
 
mov eax,14 ; calculating screen position
int 0x40
shr eax,1
mov ax,59
sub eax,30*65536
mov [win_ebx],eax
mov [win_ecx],dword 10*65536+44
 
mov esi,imagedata+25 ; calculate shape reference area
mov edi,winref
mov ecx,900 ; disable drag bar
mov al,0
rep stosb
 
mov ecx,30 ; calculate circles for eyes
shape_loop:
push ecx
 
call copy_line ; duplicate (we have two eyes :)
sub esi,30
call copy_line
 
pop ecx
loop shape_loop
 
ret
 
copy_line: ; copy single line to shape reference area
mov ecx,30
cpl_loop:
lodsb
cmp al,0xFF
jnz set_one
mov al,0
jmp cpl_ok
set_one:
mov al,1
cpl_ok:
stosb
loop cpl_loop
ret
 
; DATA
 
; environment
 
win_ebx dd 0x0
win_ecx dd 0x0
mouse dd 0xFFFFFFFF
;graphix db "EYES.RAW "
 
; temporary storage for math routines
 
temp1 dd 0
temp2 dd 0
sign1 db 0
sign2 db 0
 
EYES_END: ; end of code
file "EYES.RAW"
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/eyes/trunk/eyes.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/eyes/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/fire/trunk/fire.asm
0,0 → 1,259
;
; FIRE for MENUET - Compile with FASM
;
 
use32
 
org 0x0
db 'MENUET01' ; 8 byte id
dd 1 ; header version
dd START ; program start
dd I_END ; image size
dd mem_end ; reguired amount of memory
dd mem_end
dd 0,0 ; no parameters, no path
 
;include 'lang.inc'
include 'macros.inc'
 
START:
 
red:
 
; ************************************************
; ********* WINDOW DEFINITIONS AND DRAW **********
; ************************************************
 
draw_window:
 
mov eax,12 ; tell os about redraw
mov ebx,1
int 0x40
 
xor eax,eax ; define and draw window
mov ebx,100*65536+321
mov ecx,70*65536+222
mov edx,0x00000000
mov esi,0x00000000
mov edi,0x00000000
int 0x40
 
mov al,4 ; 'FIRE FOR MENUET'
mov ebx,110*65536+8
mov ecx,dword 0x00FFFFFF
mov edx,text
mov esi,textlen-text
int 0x40
 
mov al,8
mov ebx,(321-19)*65536+12 ; button start x & size
mov ecx,5*65536+12 ; button start y & size
mov edx,1 ; button number
mov esi,0x009a0000
int 0x40
 
mov ebx,ecx ;5*65536+12
inc edx
int 0x40
 
mov ebx,18*65536+12
inc edx
int 0x40
 
mov ebx,31*65536+12
inc edx
int 0x40
 
mov al,12 ; tell os about redraw end
mov ebx,2
int 0x40
 
sta: ; calculate fire image
 
mov esi, FireScreen+0x2300-80
mov ecx, 80
mov eax, [FireSeed]
 
NEWLINE:
 
mul [RandSeedConst]
inc eax
mov [esi], dl
inc esi
loop NEWLINE
 
mov [FireSeed], eax
 
mov ecx, 0x2300-80
sub esi, ecx
xor edx, edx
xor eax, eax
 
FIRELOOP:
lodsb
 
cmp [type], ah
jnz notype1
mov dl, [esi + 1]
add eax, edx
mov dl, [esi]
add eax, edx
mov dl, [esi + 80]
jmp typedone
notype1:
 
; cmp [type],1
; jnz notype2
mov dl, [esi - 2]
; add eax, edx
; mov dl, [esi - 2]
; add eax, edx
lea eax, [eax + edx*2]
mov dl, [esi + 78]
; notype2:
 
; type 2 is never used
; cmp [type],2
; jnz notype3
; mov dl, [esi - 2]
; add eax, edx
; mov dl, [esi]
; add eax, edx
; mov dl, [esi + 80]
; notype3:
 
typedone:
add eax, edx
shr eax, 2
jz ZERO
dec eax
 
ZERO:
 
mov [esi - 81], al
loop FIRELOOP
 
mov al, 5 ; in this moment always high 24 bits of eax are zero!
mov ebx,[delay]
int 0x40
 
inc [calc]
cmp [calc], byte 2
jnz nodrw
 
pdraw:
 
mov byte [calc],ah ;byte 0
 
mov edi,ImageData
push edi ; pointer for sysfunction 7, draw image
add edi,[fcolor]
mov esi,FireScreen
xor edx,edx
 
newc:
xor eax, eax
lodsb
 
mov ecx,eax
shr eax,1
add cl,al
mov ch,al
 
mov [edi+0],ecx
mov [edi+3],ecx
mov [edi+6],ecx
mov [edi+9],cx
lea ebx, [edi+320*3]
mov [ebx+0],ecx
mov [ebx+3],ecx
mov [ebx+6],ecx
mov [ebx+9],ecx
 
add edi,12
inc edx
cmp edx,80
jnz nnl
xor edx,edx
add edi,320*3
nnl:
cmp esi,FireScreen+8000; 0x2000
jnz newc
 
mov al,7 ; display image
; high 24 bits of eax are zero!
pop ebx
mov ecx,4*80*65536+200
mov edx,1*65536+22
int 0x40
 
nodrw:
 
mov eax,11 ; check if os wants to talk to us
int 0x40
dec eax
jz red
cmp al, 3-1
jnz nob4
 
button: ; get button id
mov al,17
int 0x40
shr eax, 8
 
dec eax
jnz noclose
or eax,-1 ; close this program
int 0x40
noclose:
 
dec eax ; change fire type
jnz nob2
xor [type], 1
nob2:
 
dec eax ; change delay
jnz nob3
xor [delay], 1
nob3:
 
dec eax ; change color
jnz nob4
mov eax,[fcolor]
inc eax
; cmp al,2
; jbe fcok
jnp fcok
xor eax,eax
fcok:
mov [fcolor],eax
mov edi,ImageData
mov ecx,(320*600)/4
xor eax,eax
rep stosd
 
nob4:
jmp sta
 
; DATA SECTION
RandSeedConst dd 0x8405
fcolor dd 2
xx db 'x'
type db 0
calc db 0
delay dd 0
FireSeed dd 0x1234
text: db 'FIRE FOR MENUET'
textlen:
 
I_END:
 
FireScreen:
rb 0x2300
ImageData:
rb 320*200*3
 
; stack
align 512
rb 512
mem_end:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/fire/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm fire.asm fire
@pause
/programs/demos/fire/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm fire.asm fire
@pause
/programs/demos/fire/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/fire2/trunk/fire2.asm
0,0 → 1,219
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd mem_end
dd mem_end
dd 0x0, 0x0
 
;include 'lang.inc'
START:
 
mov edi, my_img
mov ecx, 64001*3/4+1
xor eax, eax
rep stosd
 
mov al, 3
int 0x40
mov [curtime], eax
 
red:
push 12
pop eax
push 1
pop ebx
int 0x40
 
xor eax, eax
mov ebx, 200*65536+325
mov ecx, 150*65536+225
xor edx, edx
xor esi, esi
mov edi, 0x00100000
int 0x40
 
mov al, 8
mov ebx, (325-19)*65536+12
mov ecx, 5*65536+12
inc edx
mov esi, 0x00400000
int 0x40
 
mov al, 4
mov ebx, 8*65536+8
mov ecx, 0x00FFFFFF;0x00402020
mov edx, fire_label
push len00
pop esi
int 0x40
 
mov al, 12
push 2
pop ebx
int 0x40
 
still:
 
push 11
pop eax
int 0x40
 
dec eax
jz red
dec eax
jz key
dec eax
jz button
 
call image
push 3
pop eax
int 0x40
cmp eax, [curtime]
jz still
mov [curtime], eax
print_fps:
push 13
pop eax
mov ebx, (8+27*6)*65536+18
mov ecx, 8*65536+8
xor edx, edx
int 0x40
lea edx, [ebx-10]
mov al, 47
mov ebx, 30000h
xor ecx, ecx
xchg ecx, [fps]
mov esi, 0x00FFFFFF ;0x00400000
int 0x40
jmp still
 
key:
mov al, 2
int 0x40
cmp ah, 1Bh ;<Esc>
jne still
button:
; we have only one button, close
or eax, -1
int 0x40
 
image:
 
; ¨á㥬 ¯¥­â £p ¬¬ã
penta:
mov edi,my_img+0x540*3
mov ebx,(320)*3
mov eax,0x00fc0000
push edi
push 0x78
pop ecx
ll_3:
call put_big_point
lea edi, [edi+ebx+6]
loop ll_3
pop edi
mov cl, 0x60
ll_4:
call put_big_point
lea edi, [edi+ebx*2+3]
loop ll_4
mov cl, 0x61
ll_5:
call put_big_point
sub edi, 2*320*3-3
loop ll_5
mov edi, my_img+0x1D4F6
push edi
mov cl, 0x78
ll_6:
call put_big_point
add edi,6
sub edi,ebx
loop ll_6
pop edi
mov ecx,0x8F*2
ll_7: stosd
mov [edi+ebx-4],eax
dec edi
loop ll_7
 
fire:
; _‚HˆŒ€Hˆ…_! ‡¤¥áì á ¬®¥ ¨­â¥p¥á­®¥.
; €«£®p¨â¬ £®p¥­¨ï.
mov esi,[count1]
mov edx,[count2]
mov ecx, 10000h
Flame: cmp esi,0xFA00*3+my_img ; á¥¢¤®á«ãç ©­ ï â®çª  ¢ ¯p¥¤ « å íªp
jae NxtP ; ¥á«¨ H…’ - ¡¥p¥¬ á«¥¤ãîéãî.
lodsd
dec esi ; ‘ç¨â뢠¥¬ ¥¥ 梥â.
; and eax,0x00ff0000
test eax, eax
; ’®çª  ç¥p­ ï? (£®p¥âì ­¥ç¥¬ã?)
jz NxtP ; ¥á«¨ „€ - ¡¥p¥¬ á«¥¤ãîéãî.
sub eax,0x00040000
; –¢¥â®¬ ­  ¥¤¨­¨æã ¬¥­ì訬
mov [esi-2*3],eax ; áâ ¢¨¬ â®çªã á«¥¢ ,
mov [esi],eax ; á¯p ¢ ,
mov [320*3+esi-1*3],eax ; á­¨§ã
mov [esi-0x141*3],eax ; ¨ ᢥpåã.
NxtP:
add esi,edx
cmp esi,0xffff*3+my_img
jbe loc_cont
sub esi,0xfffe*3
loc_cont:
; ¥p¥¬ á«¥¤ãîéãî
add edx,3
cmp edx,0x10000*3
jbe loc_cont2
sub edx,0xfffe*3
loc_cont2:
; ¯á¥¢¤®á«ãç ©­ãî â®çªã.
;jnz Flame ; ˆ â ª 65536 p §.
loop Flame
mov [count1],esi
mov [count2],edx
 
mov ebx,my_img
mov ecx,320*65536+200
mov edx,2*65536+23
push 7
pop eax
int 0x40
 
inc [fps]
retn
 
put_big_point:
mov [edi], eax
mov [edi+3], eax
mov [edi-3], eax
mov [edi+ebx], eax
ret
 
;DATA
align 4
count1 dd my_img
count2 dd 0
curtime dd 0
fps dd 0
fire_label db 'Pentagramm in FIRE FPS:'
len00=$-fire_label
I_END:
 
align 16
rb 320*3
my_img rb 320*200*3
rb 320*3
 
; stack
align 256
rb 256
mem_end:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/fire2/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm fire2.asm fire2
@pause
/programs/demos/fire2/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm fire2.asm fire2
@pause
/programs/demos/free3d04/trunk/free3d04.asm
0,0 → 1,1079
;
; Fisheye Raycasting Engine Etc. FREE3D for MENUETOS by Dieter Marfurt
; Version 0.4 (requires some texture-files to compile (see Data Section))
; dietermarfurt@angelfire.com - www.melog.ch/mos_pub/
; Don't hit me - I'm an ASM-Newbie... since years :)
;
; Compile with FASM for Menuet (requires .INC files - see DATA Section)
;
; Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
;
; !!!! Don't use GIF.INC in your apps - it's modified for FREE3D !!!!
TEX_SIZE equ 64*64*4
ceil = sinus+16*1024
wall = ceil+TEX_SIZE*1
wall2 = ceil+TEX_SIZE*2
wall3 = ceil+TEX_SIZE*3
wall4 = ceil+TEX_SIZE*4
wall5 = ceil+TEX_SIZE*5
wall6 = ceil+TEX_SIZE*6
wall7 = ceil+TEX_SIZE*7
APP_MEM equ 0x200000
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd APP_MEM;0x300000 ; memory for app
dd APP_MEM;0x300000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
COLOR_ORDER equ OTHER
include 'gif.inc'
START: ; start of execution
mov esi,textures
mov edi,ceil
mov eax,sinus
call ReadGIF
mov esi,sinus
mov ecx,360*10
fninit
fld [sindegree]
.sinlp:
fst st1
fsin
fmul [sindiv]
fistp dword[esi]
add esi,4
fadd [sininc]
loop .sinlp
call draw_window ; at first, draw the window
call draw_stuff
gamestart:
; ******* MOUSE CHECK *******
; mov eax,37 ; check mouse (use mouse over window to navigate)
; mov ebx,2 ; check mousebuttons
; int 0x40
; cmp eax,0 ; only use mouse when button down
; je noneed ; deactivated cause of disappear-bug etc.
mov eax,37
mov ebx,1 ; check mouseposition
int 0x40
mov ebx,eax
shr eax,16
and eax,0x0000FFFF ; mousex
and ebx,0x0000FFFF ; mousey
cmp eax,5 ; mouse out of window ?
jb check_refresh ; it will prevent an app-crash
cmp ebx,22
jb check_refresh
cmp eax, 640
jg check_refresh
cmp ebx,501
jg check_refresh
cmp eax,315 ; navigating?
jb m_left
cmp eax,325 ;
jg m_right
continue:
cmp ebx,220 ;
jb s_up
cmp ebx,260 ;
jg s_down
; ******* END OF MOUSE CHECK *******
check_refresh:
; mov eax,23 ; wait for system event with 10 ms timeout
; mov ebx,1 ; thats max 100 FPS
mov eax,11 ; ask no wait for full speed
int 0x40
cmp eax,1 ; window redraw request ?
je red2
cmp eax,2 ; key in buffer ?
je key2
cmp eax,3 ; button in buffer ?
je button2
mov edi,[mouseya] ; check flag if a refresh has to be done
cmp edi,1
jne gamestart
mov [mouseya],dword 0
call draw_stuff
jmp gamestart
; END OF MAINLOOP
red2: ; redraw
call draw_window
call draw_stuff
jmp gamestart
key2: ; key
mov eax,2
int 0x40
cmp al,1
je gamestart ; keybuffer empty
cmp ah,27 ; esc=End App
je finish
cmp ah,178 ; up
je s_up
cmp ah,177 ; down
je s_down
cmp ah,176 ; left
je s_left
cmp ah,179 ; right
je s_right
jmp gamestart ; was any other key
s_up: ; walk forward (key or mouse)
mov eax,[vpx]
mov ebx,[vpy]
mov ecx,[vheading]
imul ecx,4
add ecx,sinus
mov edi,[ecx]
mov edx,[vheading]
imul edx,4
add edx,sinus
add edx,3600
cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
jb ok200
sub edx,14400
ok200:
mov esi,[edx]
; sal esi,1 ; edit walking speed here
; sal edi,1
add eax,edi ; newPx
add ebx,esi ; newPy
mov edi,eax ; newPx / ffff
mov esi,ebx ; newPy / ffff
sar edi,16
sar esi,16
mov ecx,esi
sal ecx,5 ; equal *32
add ecx,edi
add ecx,grid
cmp [ecx],byte 0 ; collision check
jne cannotwalk0
mov [vpx],eax
mov [vpy],ebx
mov [mouseya],dword 1 ; set refresh flag
cannotwalk0:
jmp check_refresh
s_down: ; walk backward
mov eax,[vpx]
mov ebx,[vpy]
mov ecx,[vheading]
imul ecx,4
add ecx,sinus
mov edi,[ecx]
mov edx,[vheading]
imul edx,4
add edx,sinus
add edx,3600
cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
jb ok201
sub edx,14400
ok201:
mov esi,[edx]
; sal esi,1 ; edit walking speed here
; sal edi,1
sub eax,edi ; newPx
sub ebx,esi ; newPy
mov edi,eax ; newPx / ffff
mov esi,ebx ; newPy / ffff
sar edi,16
sar esi,16
mov ecx,esi
sal ecx,5
add ecx,edi
add ecx,grid
cmp [ecx],byte 0
jne cannotwalk1
mov [vpx],eax
mov [vpy],ebx
mov [mouseya],dword 1
cannotwalk1:
jmp check_refresh
s_left: ; turn left (key)
mov edi,[vheading] ; heading
add edi,50
cmp edi,3600
jb ok_heading0
sub edi,3600
ok_heading0:
mov [vheading],edi
mov [mouseya],dword 1
jmp check_refresh
s_right: ; turn right
mov edi,[vheading]
sub edi,50
cmp edi,-1
jg ok_heading1
add edi,3600
ok_heading1:
mov [vheading],edi
mov [mouseya],dword 1
jmp check_refresh
m_left: ; turn left (mouse)
mov edi,[vheading] ; heading
mov ecx,315
sub ecx,eax
sar ecx,2
add edi,ecx
cmp edi,3600
jb ok_heading2
sub edi,3600
ok_heading2:
mov [vheading],edi
mov [mouseya],dword 1
jmp continue ; allow both: walk and rotate
m_right: ; turn right
mov edi,[vheading]
sub eax,325
sar eax,2
sub edi,eax
cmp edi,-1
jg ok_heading3
add edi,3600
ok_heading3:
mov [vheading],edi
mov [mouseya],dword 1
jmp continue
button2: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne gamestart
; eo GAME mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
finish:
mov eax,-1 ; close this program
int 0x40
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
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,50*65536+649 ; [x start] *65536 + [x size]
mov ecx,50*65536+504 ; [y start] *65536 + [y size]
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x80777777 ; color of grab bar RRGGBB,8->color gl
mov edi,0x00777777 ; 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,0x00ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,(649-19)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x777777 ; button color RRGGBB
int 0x40
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
; *********************************************
; ******* COMPUTE 3D-VIEW ********
; *********************************************
draw_stuff:
mov [step1],dword 1
;mov [step64],dword 64
mov esi,[vheading]
add esi,320
mov [va],esi
mov eax,[vheading]
sub eax,320
mov [vacompare],eax
;------------------------------------ CAST 640 PIXEL COLUMNS ---------------
; FOR A=320+heading to -319+heading step -1 (a is stored in [va])
;---------------------------------------------------------------------------
; mov edx,5
mov [vx1],dword 0 ;5 ;edx ; init x1 ... pixelcolumn
for_a:
mov edx,[vx1]
mov [vx1b],edx
sub [vx1b],dword 320
mov edx,[va] ; a2
cmp edx,-1 ; a2 is a mod 3600
jg ok1
add edx,3600
ok1:
cmp edx,3600
jb ok2
sub edx,3600
ok2:
; get stepx and stepy
mov ecx,edx
imul ecx,4
add ecx,sinus ; pointer to stepx
mov esi,[ecx]
sar esi,4 ; accuracy
mov [vstepx],esi ; store stepx
mov esi,edx
imul esi,4
add esi,sinus ; pointer to stepy
add esi,3600
cmp esi,eosinus ;cosinus taken from ((sinus plus 900) mod 3600)
jb ok202
sub esi,14400
ok202:
mov ecx,[esi]
sar ecx,4
mov [vstepy],ecx ; store stepy
mov eax,[vpx] ; get Camera Position
mov ebx,[vpy]
mov [vxx],eax ; init caster position
mov [vyy],ebx
mov edi,0 ; init L (number of raycsting-steps)
mov [step1],dword 1 ; init Caster stepwidth for L
; raycast a pixel column.................................
raycast:
add edi,[step1] ; count caster steps
;jmp nodouble ; use this to prevent blinking/wobbling textures: much slower!
cmp edi,32
je double
cmp edi,512
je double
cmp edi,1024
je double
jmp nodouble
double:
mov edx,[step1]
sal edx,1
mov [step1],edx
mov edx,[vstepx]
sal edx,1
mov [vstepx],edx
mov edx,[vstepy]
sal edx,1
mov [vstepy],edx
nodouble:
mov eax,32000 ; 3600 ; determine Floors Height based on distance
mov edx,0
mov ebx,edi
div ebx
mov esi,eax
mov [vdd],esi
mov edx,260
sub edx,esi
mov [vh],edx
cmp edx,22
jb no_nu_pixel
cmp edx,259
jg no_nu_pixel ; draw only new pixels
cmp edx,[h_old]
je no_nu_pixel
mov eax,[vxx] ; calc floor pixel
mov ebx,[vyy]
and eax,0x0000FFFF
and ebx,0x0000FFFF
shr eax,10
shr ebx,10 ; pixel coords inside Texture x,y 64*64
mov [xfrac],eax
mov [yfrac],ebx
; plot floor pixel !!!!
mov [vl],edi ; save L
mov [ytemp],esi ; remember L bzw. H
mov edi,[yfrac] ; get pixel color of this floor pixel
sal edi,8
mov esi,[xfrac]
sal esi,2
add edi,esi
add edi,wall ; in fact its floor, just using the wall texture :)
mov edx,[edi]
mov [remesi],esi
;**** calculate pixel adress:****
mov esi,[ytemp]
add esi,240
imul esi,1920
add esi,[vx1]
add esi,[vx1]
add esi,[vx1]
add esi,0x80000
cmp esi,0x80000+1920*480
jg foff0
cmp esi,0x80000
jb foff0
; now we have the adress of the floor-pixel color in edi
; and the adress of the pixel in the image in esi
mov edx,[edi]
;******************** custom distance DARKEN Floor
mov eax,[vdd]
; jmp nodark0 ; use this to deactivate darkening floor (a bit faster)
cmp eax,80
jg nodark0
; split rgb
mov [blue],edx
and [blue],dword 255
shr edx,8
mov [green],edx
and [green],dword 255
shr edx,8
mov [red],edx
and [red],dword 255
mov eax,81 ; darkness parameter
sub eax,[vdd]
sal eax,1
; reduce rgb
sub [red],eax
cmp [red], dword 0
jg notblack10
mov [red],dword 0
notblack10:
sub [green],eax
cmp [green],dword 0
jg notblack20
mov [green],dword 0
notblack20:
mov edx,[blue]
sub [blue],eax
cmp [blue],dword 0
jg notblack30
mov [blue],dword 0
notblack30:
shl dword [red],16 ; reassemble rgb
shl dword [green],8
mov edx,[red]
or edx,[green]
or edx,[blue]
nodark0:
; eo custom darken floor
mov eax,edx
mov [esi],eax ; actually draw the floor pixel
; paint "forgotten" pixels
mov edx,[lasty]
sub edx,1920
cmp esi,edx
je foff0
mov [esi+1920],eax
sub edx,1920
cmp esi,edx
je foff0
mov [edx+1920],eax
sub edx,1920
cmp esi,edx
je foff0
mov [edx+1920],eax
foff0:
mov [lasty],esi
;**** end of draw floor pixel ****
mov esi,[remesi]
mov edi,[vl] ; restore L
no_nu_pixel:
mov esi,[vh]
mov [h_old],esi
mov eax,[vxx]
mov ebx,[vyy]
add eax,[vstepx] ; casting...
add ebx,[vstepy]
mov [vxx],eax
mov [vyy],ebx
sar eax,16
sar ebx,16
mov [vpxi],eax ; casters position in Map Grid
mov [vpyi],ebx
mov edx,ebx
; imul edx,32
shl edx,5
add edx,grid
add edx,eax
cmp [edx],byte 0 ; raycaster reached a wall? (0=no)
jne getout
cmp edi,10000 ; limit view range
jb raycast
;................................................
getout:
mov eax,[edx] ; store Grid Wall Value for Texture Selection
mov [vk],eax
call blur ; deactivate this (blurs the near floor) : a bit faster
; simply copy floor to ceil pixel column here
;jmp nocopy ; use this for test purposes
pusha
mov eax,0x80000+1920*240
mov ebx,0x80000+1920*240
copyfloor:
sub eax,1920
add ebx,1920
mov ecx,0
add ecx,[vx1]
add ecx,[vx1]
add ecx,[vx1]
mov edx,ecx
add ecx,eax
add edx,ebx
mov esi,[edx]
mov [ecx],esi
cmp eax,0x80000
jg copyfloor
popa
; *** end of copy floor to ceil
;nocopy:
;__________________________________________________________________________
; draw this pixelrows wall
mov [vl],edi
mov edi,260
sub edi,[vdd]
cmp edi,0
jg ok3
xor edi,edi
ok3:
mov [vbottom],edi ; end wall ceil (or window top)
mov esi,262
add esi,[vdd] ; start wall floor
xor edi,edi
; somethin is wrong with xfrac,so recalc...
mov eax,[vxx]
and eax,0x0000FFFF
shr eax,10
mov [xfrac],eax
mov eax,[vyy]
and eax,0x0000FFFF
shr eax,10
mov [yfrac],eax
pixelrow:
; find each pixels color:
add edi,64
sub esi,1
cmp esi, 502 ; dont calc offscreen-pixels
jg speedup
xor edx,edx
mov eax, edi
mov ebx,[vdd]
add ebx,[vdd]
div ebx
and eax,63
mov [ytemp],eax ; get y of texture for wall
mov eax,[xfrac]
add eax,[yfrac]
and eax,63
mov [xtemp],eax ; get x of texture for wall
; now prepare to plot that wall-pixel...
mov [remedi],edi
mov edi,[ytemp]
sal edi,8
mov edx,[xtemp]
sal edx,2
add edi,edx
mov eax,[vk] ; determine which texture should be used
and eax,255
cmp eax,1
jne checkmore1
add edi,ceil
jmp foundtex
checkmore1:
cmp eax,2
jne checkmore2
add edi,wall
jmp foundtex
checkmore2:
cmp eax,3
jne checkmore3
add edi,wall2
jmp foundtex
checkmore3:
cmp eax,4
jne checkmore4
add edi,wall3
jmp foundtex
checkmore4:
cmp eax,5
jne checkmore5
add edi,wall4
jmp foundtex
checkmore5:
cmp eax,6
jne checkmore6
add edi,wall5
jmp foundtex
checkmore6:
cmp eax,7
jne checkmore7
add edi,wall6
jmp foundtex
checkmore7:
cmp eax,8
jne checkmore8
add edi,wall7
jmp foundtex
checkmore8:
foundtex:
mov edx,[edi] ; get pixel color inside texture
; ***pseudoshade south-west
jmp east ; activate this for southwest pseudoshade : a bit slower + blink-bug
mov edi,[yfrac]
mov [pseudo],dword 0 ; store flag for custom distance darkening
cmp edi,[xfrac]
jge east
and edx,0x00FEFEFE
shr edx,1
mov [pseudo],dword 1
east:
call dark_distance ; deactivate wall distance darkening: a bit faster
; ******* DRAW WALL PIXEL *******
mov eax,esi
sub eax,22
imul eax,1920
add eax,[vx1]
add eax,[vx1]
add eax,[vx1]
add eax,0x80000
cmp eax,0x80000+1920*480
jg dont_draw
cmp eax,0x80000
jb dont_draw
mov [eax],edx ; actually set the pixel in the image
; *** eo draw wall pixel
dont_draw:
mov edi,[remedi]
speedup:
cmp esi,[vbottom] ; end of this column?
jg pixelrow
mov edi,[vl] ; restoring
mov eax,[vx1] ; inc X1
add eax,1
mov [vx1],eax
;*** NEXT A ***
mov esi,[va]
sub esi,1
mov [va],esi
cmp esi,[vacompare]
jg for_a
;*** EO NEXT A ***
;---------------------------------------------------------------------------
; **** put image !!!!!****
; ***********************
mov eax,7
mov ebx,0x80000
mov ecx,640*65536+480
mov edx,5*65536+20
int 0x40
ret
blur:
pusha
mov eax,0x080000+360*1920
copyfloor2:
add eax,1920
mov ebx,eax
add ebx,[vx1]
add ebx,[vx1]
add ebx,[vx1]
mov ecx,[ebx-15]
and ecx,0x00FEFEFE
shr ecx,1
mov edx,[ebx-12]
and edx,0x00FEFEFE
shr edx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-9]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-6]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-3]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
mov [ebx],edx
cmp eax,0x80000+478*1920
jb copyfloor2
popa
ret
; ******* Darken by Distance *******
dark_distance:
; color must be in edx, wall height in [vdd]
mov eax,[vdd]
cmp eax,50
jg nodark
; split rgb
mov [blue],edx
and [blue],dword 255
shr edx,8
mov [green],edx
and [green],dword 255
shr edx,8
mov [red],edx
and [red],dword 255
mov eax,51 ; darkness parameter
sub eax,[vdd]
cmp [pseudo],dword 1
je isdarkside
sal eax,2
isdarkside:
; reduce rgb
sub [red],eax
cmp [red], dword 0
jg notblack10b
mov [red],dword 0
notblack10b:
sub [green],eax
cmp [green],dword 0
jg notblack20b
mov [green],dword 0
notblack20b:
mov edx,[blue]
sub [blue],eax
cmp [blue],dword 0
jg notblack30b
mov [blue],dword 0
notblack30b:
shl dword [red],16 ; reassemble rgb
shl dword [green],8
mov edx,[red]
or edx,[green]
or edx,[blue]
mov eax,edx
nodark:
ret
; DATA AREA
;ceil=ceil
;wall=wall floor
;2 corner stone
;3 leaf mosaic
;4 closed window
;5 greek mosaic
;6 old street stones
;7 maya wall
grid: ; 32*32 Blocks, Map: 0 = Air, 1 to 8 = Wall
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
db 1,0,0,0,1,0,0,0,0,0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8
db 5,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8
db 1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1,0,0,0,0,3,3,3,3,0,0,0,0,0,0,8
db 5,0,1,2,3,4,5,6,7,8,2,1,3,3,3,0,5,0,2,1,2,3,0,0,0,0,0,0,0,0,0,8
db 1,0,0,0,0,0,0,0,0,0,2,3,0,0,0,0,5,0,0,0,0,3,0,0,0,0,0,0,0,0,0,8
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,5,0,0,0,0,3,3,0,3,3,0,0,0,0,0,8
db 1,1,0,1,1,1,1,4,1,0,1,3,0,0,0,0,5,2,1,2,0,3,0,0,0,3,0,0,0,0,0,8
db 5,0,0,0,1,0,0,0,0,0,0,1,0,3,3,3,5,0,0,0,0,3,0,0,0,3,0,0,0,0,0,8
db 1,0,0,0,1,0,0,5,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,3,0,0,0,0,0,8
db 5,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,5,0,0,0,0,3,0,0,0,0,0,0,0,0,0,8
db 1,4,4,4,4,4,4,4,4,4,4,3,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,8,8
db 2,2,2,2,2,2,8,8,8,8,8,8,8,8,8,0,0,0,6,6,0,7,7,7,7,7,7,7,7,7,8,8
db 1,0,0,0,1,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1
db 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,2,2,2,2,0,0,0,0,3,3,3,3,3,1
db 1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,6,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1
db 5,0,2,3,2,3,2,3,2,3,2,1,0,0,0,0,6,0,2,2,0,2,0,0,0,0,3,0,5,5,0,1
db 1,0,0,0,0,0,0,4,0,0,0,3,0,0,0,0,6,0,0,2,0,2,0,2,0,0,3,0,0,0,0,1
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,6,0,0,2,2,2,0,2,0,0,3,3,3,3,0,1
db 1,1,0,1,1,1,1,4,1,0,1,3,7,7,7,0,6,0,0,0,0,0,0,2,0,0,0,0,0,3,0,1
db 5,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,6,0,0,0,0,2,2,2,0,0,0,0,0,3,0,1
db 1,0,0,0,1,0,0,5,0,0,0,3,0,0,0,0,6,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1
db 5,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,6,0,5,1,0,2,0,0,4,4,0,4,4,0,0,1
db 1,4,1,4,1,4,1,4,1,4,1,3,0,0,0,0,6,0,0,5,0,2,0,0,0,4,0,4,0,0,0,1
db 1,0,0,0,0,0,0,4,0,0,0,3,0,3,3,3,6,0,0,1,0,1,0,0,4,4,0,4,4,0,0,1
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,6,0,0,5,0,1,0,4,4,0,0,0,4,4,0,1
db 1,1,0,1,1,1,1,4,1,0,1,3,0,0,0,0,6,0,0,1,0,1,0,4,0,0,0,0,0,4,0,1
db 5,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,6,0,0,5,0,1,0,4,0,0,0,0,0,4,0,1
db 1,0,0,0,1,0,0,5,0,0,0,3,0,0,0,0,6,1,5,1,0,1,0,4,4,0,0,0,4,4,0,1
db 5,0,0,0,0,0,0,5,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,4,4,4,4,4,0,0,1
db 1,4,1,4,1,4,1,4,1,4,1,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
vpx:
dd 0x0001FFFF ; initial player position * 0xFFFF
vpy:
dd 0x0001FFFF
labelt:
db 'FISHEYE RAYCASTING ENGINE ETC. FREE3D'
labellen:
sindegree dd 0.0
sininc dd 0.0017453292519943295769236907684886
sindiv dd 6553.5
textures:
file 'texture.gif'
I_END:
col1:
dd ?;-
; misc raycaster vars:
vxx:
dd ?;-
vyy:
dd ?;-
vl:
dd ?;-
vstepx:
dd ?;-
vstepy:
dd ?;-
vxxint:
dd ?;-
vyyint:
dd ?;-
vk:
dd ?;-
va:
dd ?;-
va2:
dd ?;-
vdd:
dd ?;-
vx1:
dd ?;-
vx1b:
dd ?;-
vh:
dd ?;-
vdt:
dd ?;-
vheading: ; initial heading: 0 to 3599
dd ?;-
vacompare:
dd ?;-
vpxi:
dd ?;-
vpyi:
dd ?;-
wtolong:
dw ?,?;-,?;-
xtemp:
dd ?;-
ytemp:
dd ?;-
xfrac:
dd ?;-
yfrac:
dd ?;-
h_old:
dd ?;-
vbottom:
dd ?;-
mouseya:
dd ?;-
remeax:
dd ?;-
remebx:
dd ?;-
remecx:
dd ?;-
remedx:
dd ?;-
remedi:
dd ?;-
remesi:
dd ?;-
red:
dd ?;-
green:
dd ?;-
blue:
dd ?;-
pseudo:
dd ?;-
step1:
dd ?;-
step64:
dd ?;-
lasty:
dd ?;-
sinus rd 360*10
eosinus:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/free3d04/trunk/gif.inc
0,0 → 1,302
; GIF LITE v2.0 by Willow
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; This include file will contain functions to handle GIF image format
;
; Created: August 15, 2004
; Last changed: September 9, 2004
 
; Change COLOR_ORDER in your program
; if colors are displayed improperly
 
if ~ (COLOR_ORDER in <MENUETOS,OTHER>)
; This message may not appear under MenuetOS, so watch...
display 'Please define COLOR_ORDER: MENUETOS or OTHER',13,10
end if
 
; virtual structure, used internally
 
struc GIF_list
{
.NextImg rd 1
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
struc GIF_info
{
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
_null fix 0x1000
 
 
; ****************************************
; FUNCTION ReadGIF - unpacks GIF image
; ****************************************
; in:
; esi - pointer to GIF file in memory
; edi - pointer to output image list
; eax - pointer to work area (MIN 16 KB!)
 
; out:
; eax - 0, all OK;
; eax - 1, invalid signature;
; eax >=8, unsupported image attributes
;
; ecx - number of images
 
ReadGIF:
push esi edi
mov [.table_ptr],eax
mov [.cur_info],edi
xor eax,eax
mov [.globalColor],eax
mov [.img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne .er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc .nextblock
mov [.globalColor],esi
call .Gif_skipmap
.nextblock:
cmp byte[edi],0x21
jne .noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne .no_gc
add edi,7
jmp .nextblock
.no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne .no_comm
inc edi
.block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz .block_skip
inc edi
jmp .nextblock
.no_comm:
cmp byte[edi],0xff ; Application Ext
jne .nextblock
add edi,13
jmp .block_skip
.noextblock:
cmp byte[edi],0x2c ; image beginning
jne .er
inc [.img_count]
inc edi
mov esi,[.cur_info]
add esi,4
xchg esi,edi
movsd
movsd
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc .uselocal
push [.globalColor]
mov edi,esi
jmp .setPal
.uselocal:
call .Gif_skipmap
push esi
.setPal:
movzx ecx,byte[edi]
inc ecx
mov [.codesize],ecx
dec ecx
pop [.Palette]
lea esi,[edi+1]
mov edi,[.table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [.block_ofs],eax
mov [.bit_count],8
mov eax,1
shl eax,cl
mov [.CC],eax
inc eax
mov [.EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
.filltable:
stosd
inc eax
loop .filltable
pop edi
mov [.img_start],edi
.reinit:
mov edx,[.EOI]
inc edx
push [.codesize]
pop [.compsize]
call .Gif_get_sym
cmp eax,[.CC]
je .reinit
call .Gif_output
.cycle:
movzx ebx,ax
call .Gif_get_sym
cmp eax,edx
jae .notintable
cmp eax,[.CC]
je .reinit
cmp eax,[.EOI]
je .end
call .Gif_output
.add:
push eax
mov eax,[.table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae .cycle
inc edx
bsr ebx,edx
cmp ebx,[.compsize]
jne .noinc
inc [.compsize]
.noinc:
jmp .cycle
.notintable:
push eax
mov eax,ebx
call .Gif_output
push ebx
movzx eax,bx
call .Gif_output
pop ebx eax
jmp .add
.er:
pop edi
jmp .ex
.end:
mov eax,[.cur_info]
mov [eax],edi
mov [.cur_info],edi
add esi,2
xchg esi,edi
.nxt:
cmp byte[edi],0
jnz .continue
inc edi
jmp .nxt
.continue:
cmp byte[edi],0x3b
jne .nextblock
xor eax,eax
stosd
mov ecx,[.img_count]
.ex:
pop edi esi
ret
 
.Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
.Gif_get_sym:
mov ecx,[.compsize]
push ecx
xor eax,eax
.shift:
ror byte[esi],1
rcr eax,1
dec [.bit_count]
jnz .loop1
inc esi
cmp esi,[.block_ofs]
jb .noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz .nextbl
mov eax,[.EOI]
sub esi,2
add esp,8
jmp .exx
.nextbl:
add eax,esi
mov [.block_ofs],eax
pop eax
.noblock:
mov [.bit_count],8
.loop1:
loop .shift
pop ecx
rol eax,cl
.exx:
xor ecx,ecx
ret
 
.Gif_output:
push esi eax edx
mov edx,[.table_ptr]
.next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz .next
shl ebx,16
mov bx,[esp]
.loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[.Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
and byte[edi],0
inc edi
end if
 
loop .loop2
pop edx eax esi
ret
 
.globalColor rd 1
.img_count rd 1
.cur_info rd 1 ; image table pointer
.img_start rd 1
.codesize rd 1
.compsize rd 1
.bit_count rd 1
.CC rd 1
.EOI rd 1
.Palette rd 1
.block_ofs rd 1
.table_ptr rd 1
/programs/demos/free3d04/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
/programs/demos/free3d04/trunk/texture.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/free3d04/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm free3d04.asm free3d04
@pause
/programs/demos/free3d04/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm free3d04.asm free3d04
@pause
/programs/demos/free3d04/trunk/readme.txt
0,0 → 1,23
 
--------------------------------------------
*** Fisheye Raycasting Engine Etc. V.0.4 ***
--------------------------------------------
 
For the MenuetOs Operating System.
Assembler-Source for FASM for MenuetOs.
 
By Dieter Marfurt
 
--------------------------------------------
 
Format of texture include files:
 
dd 0x00RRGGBB,0x00RRGGBB....
 
for 64*64 pixels.
 
Have fun!
 
dietermarfurt@angelfire.com
 
--------------------------------------------
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/magnify/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm magnify.asm magnify
@pause
/programs/demos/magnify/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm magnify.asm magnify
@pause
/programs/demos/magnify/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/magnify/trunk/magnify.asm
0,0 → 1,348
;
; MAGNIFY SCREEN
;
; Compile with FASM for Menuet
;
 
use32
 
org 0x0
 
db 'MENUET00' ; 8 byte id
dd 38 ; required os
dd START ; program start
dd I_END ; program image size
dd 0x10000 ; required amount of memory
dd 0x10000
dd 0x00000000 ; reserved=no extended header
 
include 'lang.inc'
include 'macros.inc'
scr equ 0x1000
 
 
START: ; start of execution
 
mov esp,0xfff0
 
mov eax,14 ; get screen size
int 0x40
push eax
and eax,0x0000ffff
add eax,1
mov [size_y],eax
pop eax
shr eax,16
add eax,1
mov [size_x],eax
 
mov eax,[size_x]
shr eax,2
mov [cmp_ecx],eax
 
mov eax,[size_x]
xor edx,edx
mov ebx,3
mul ebx
mov [add_esi],eax
 
mov eax,[size_y]
shr eax,2
mov [cmp_edx],eax
 
 
 
call draw_window ; at first, draw the window
 
still:
 
call draw_screen
 
mov eax,23 ; wait here for event with timeout
mov ebx,[delay]
int 0x40
 
cmp eax,1 ; redraw request ?
jz red
cmp eax,2 ; key in buffer ?
jz key
cmp eax,3 ; button in buffer ?
jz button
 
jmp still
 
red: ; redraw
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jnz noclose
mov eax,0xffffffff ; close this program
int 0x40
noclose:
 
cmp ah,2
jnz nosave
call save_screen
nosave:
 
jmp still
 
 
 
save_screen:
 
pusha
 
mov ebx,0
mov edi,0x10000
 
ss1:
 
mov eax,35
int 0x40
 
add ebx,1
 
mov [edi],eax
add edi,3
 
cmp edi,0xFFFF0
jb ss1
 
mov eax,33
mov ebx,filename
mov ecx,0x10000
mov edx,0xEFFF0
mov esi,0
int 0x40
 
popa
 
ret
 
 
filename db 'SCREEN RAW'
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
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,100*65536 ; [x start] *65536 + [x size]
mov ebx,100*65536+322
mov ecx,100*65536+262 ; [y start] *65536 + [y size]
mov edx,0x0;01111cc ; color of work area RRGGBB
mov esi,0x809977ff ; color of grab bar RRGGBB,8->color glide
mov edi,0x00ffff00 ; 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,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov bx,12 ; [x start] *65536 + [x size]
mov ebx,(322-19)*65536+12
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x22aacc ; button color RRGGBB
int 0x40
 
call draw_screen
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
draw_screen:
 
call draw_magnify
 
ret
 
pusha
 
mov edi,scr
 
mov ecx,0
mov edx,0
 
mov esi,0
 
ds1:
 
mov eax,35
mov ebx,esi
int 0x40
stosd
sub edi,1
 
add esi,4
add ecx,1
cmp ecx,[cmp_ecx] ; 800/4
jb ds1
 
add esi,[add_esi] ; 800*3
mov ecx,0
add edx,1
cmp edx,[cmp_edx] ; 600/4
jb ds1
 
mov eax,7
mov ebx,scr
mov ecx,200*65536+160
mov ecx,[size_x]
shr ecx,2
shl ecx,16
mov cx,word [size_y]
shr cx,2
mov edx,20*65536+35
int 0x40
 
popa
 
call draw_magnify
 
ret
 
 
draw_magnify:
 
pusha
 
mov eax,37
mov ebx,0
int 0x40
 
mov ecx,eax
mov edx,eax
shr ecx,16
and edx,65535
 
sub ecx,39
sub edx,29
 
cmp ecx,3000
jb co1
popa
ret
co1:
cmp edx,3000
jb co2
popa
ret
 
co2:
 
and ecx,2047
and edx,2047
 
mov [m_x],ecx
mov [m_y],edx
 
add ecx,40
add edx,30
 
mov [m_xe],ecx
mov [m_ye],edx
 
mov ecx,[m_x]
mov edx,[m_y]
 
dm1:
 
push edx
mov eax,edx
mul [size_x]
pop edx
add eax,ecx
 
mov ebx,eax
mov eax,35
int 0x40
 
pusha
mov ebx,ecx
sub ebx,[m_x]
mov ecx,edx
sub ecx,[m_y]
shl ebx,3
add ebx,2
shl ebx,16
mov bx,7
shl ecx,3
add ecx,22
shl ecx,16
mov cx,7
 
mov edx,eax
mov eax,13
int 0x40
popa
 
add ecx,1
cmp ecx,[m_xe]
jnz dm1
mov ecx,[m_x]
add edx,1
cmp edx,[m_ye]
jnz dm1
 
popa
 
ret
 
 
 
; DATA AREA
 
m_x dd 100
m_y dd 100
 
m_xe dd 110
m_ye dd 110
 
size_x dd 0
size_y dd 0
 
cmp_ecx dd 0
add_esi dd 0
cmp_edx dd 0
 
delay dd 20
 
labelt:
db 'MAGNIFIER - MOVE MOUSE POINTER'
labellen:
 
 
I_END:
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/movback/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm movback.asm movback
@pause
/programs/demos/movback/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm movback.asm movback
@pause
/programs/demos/movback/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/movback/trunk/movback.asm
0,0 → 1,188
include "lang.inc"
include "macros.inc"
 
WND_SIZE_X = 320
WND_SIZE_Y = 200
 
VC_DELTA = 1
HC_DELTA = 2
 
MEOS_APP_START
CODE
fninit
call init_sinus_table
call init_background
call init_palette
mov eax,40
mov ebx,101b
int 0x40
jmp .paint_window
 
.event_loop:
mov eax,23
mov ebx,1
int 0x40
 
test eax,eax
je .draw_screen
dec eax
je .paint_window
 
or eax,-1
int 0x40
 
.draw_screen:
add word [ver_counter],VC_DELTA
add word [hor_counter],HC_DELTA
call handle_animation
mov eax,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(5 shl 16)+23
int 0x40
jmp .event_loop
 
.paint_window:
mov eax,12
mov ebx,1
int 0x40
 
xor eax,eax
mov ebx,(100 shl 16)+(WND_SIZE_X+9)
mov ecx,(100 shl 16)+(WND_SIZE_Y+28)
mov edx,0x03000000
int 0x40
 
mov eax,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(5 shl 16)+23
int 0x40
 
mov eax,4
mov ebx,0x00060006
mov ecx,0x10ffffff
mov edx,window_title
mov esi,window_title_len
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
 
jmp .event_loop
 
init_palette:
mov ecx,256
mov edi,_palette
xor eax,eax
.next_pal:
mov al,ah
shr al,2
stosb
stosb
stosb
inc edi
inc ah
loop .next_pal
ret
 
init_sinus_table:
sub esp,4
mov ecx,256
mov edi,sinetable
.sin_loop:
fld dword [esp]
fld st0
fsin
fmul [scale_sin]
fistp word [edi]
fadd [delta_angle]
fstp dword [esp]
add edi,2
loop .sin_loop
add esp,4
ret
 
init_background:
mov edi,background
xor edx,edx
.ib_vertical:
xor ecx,ecx
.ib_horizontal:
mov eax,ecx
xor eax,edx
stosb
inc ecx
cmp ecx,256
jne .ib_horizontal
inc edx
cmp edx,256
jne .ib_vertical
ret
 
s_OFFX = 0
s_OFFY = 2
 
handle_animation:
sub esp,4
mov ebx,[ver_counter]
and ebx,255
add ebx,ebx
mov ax,[sinetable+ebx]
mov [esp+s_OFFY],ax
mov ebx,[hor_counter]
and ebx,255
add ebx,ebx
mov ax,[sinetable+ebx]
mov [esp+s_OFFX],ax
mov edi,virtual_screen_32
mov edx,WND_SIZE_Y-1
.a_ver:
mov ecx,WND_SIZE_X-1
mov bx,[esp+s_OFFY]
add bx,dx
and ebx,255
shl ebx,8
.a_hor:
mov ax,[esp+s_OFFX]
add ax,cx
and eax,255
lea esi,[background+ebx+eax]
mov al,[esi]
and eax,0xff
mov eax,[_palette+eax*4]
stosw
shr eax,16
stosb
dec ecx
jge .a_hor
dec edx
jge .a_ver
add esp,4
ret
 
DATA
delta_angle dd 0.0245436926066 ; pi/128
scale_sin dd 128.0
 
window_title:
db 'MoveBack'
window_title_len = $ - window_title
 
UDATA
ver_counter dd ?
hor_counter dd ?
 
_palette: rd 256
 
virtual_screen_32:
rb WND_SIZE_X*WND_SIZE_Y*3
 
background:
rb 256*256
 
sinetable:
rw 256
 
MEOS_APP_END
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/plasma/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm plasma.asm plasma
@pause
/programs/demos/plasma/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm plasma.asm plasma
@pause
/programs/demos/plasma/trunk/graph8.inc
0,0 → 1,16
blit_8_to_32:
mov esi,virtual_screen_8 ; ESI=src
mov edi,virtual_screen_32 ; EDI=dst
mov ecx,WND_SIZE_X*WND_SIZE_Y ; ECX=size
.blit_next:
xor eax,eax ; EAX=byte to blit
mov al,[esi]
shl eax,2
mov eax,[_palette+eax]
mov [edi],ax
shr eax,16
mov [edi+2],al
inc esi
add edi,3
loop .blit_next
ret
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/plasma/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/plasma/trunk/plasma.asm
0,0 → 1,186
; Originally written by Jarek Pelczar
include "lang.inc"
include "macros.inc"
 
WND_SIZE_X = 320
WND_SIZE_Y = 200
 
MEOS_APP_START
CODE
fninit
mov al,40
mov bl,101b
int 0x40
call init_palette
call init_texture
jmp .paint_window
.event_loop:
mov al,23
mov ebx,1
int 0x40
test eax,eax
je .draw_screen
dec eax
je .paint_window
 
or eax,-1
int 0x40
 
.draw_screen:
call blit_8_to_32
mov al,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(4 shl 16)+24
int 0x40
call rotate_pal
jmp .event_loop
 
.paint_window:
mov al,12
push eax
xor ebx,ebx
inc ebx
int 0x40
 
xor eax,eax
mov ebx,(100 shl 16)+(WND_SIZE_X+8)
mov ecx,(100 shl 16)+(WND_SIZE_Y+28)
mov edx,0x03000000
int 0x40
 
mov al,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(4 shl 16)+24
int 0x40
 
mov al,4
mov ebx,0x00060006
mov ecx,0x10ffffff
mov edx,window_title
mov esi,window_title_len
int 0x40
 
pop eax
and ebx,2 ; bit 1 is set
int 0x40
 
jmp .event_loop
 
init_palette:
mov edi,_palette
mov ecx,64
xor eax,eax
.color1:
inc ah
mov al,ah
stosb
xor al,al
stosb
stosb
inc edi
loop .color1
mov ecx,64
push ecx
xor eax,eax
.color2:
mov al,63
stosb
mov al,ah
stosb
xor al,al
stosb
inc ah
inc edi
loop .color2
pop ecx
push ecx
xor eax,eax
.color3:
mov al,63
stosb
stosb
mov al,ah
stosb
inc ah
inc edi
loop .color3
pop ecx
mov eax,0x003f3f3f
rep stosd
ret
 
init_texture:
fldpi
mov [_fpom16],180
fidiv [_fpom16]
fstp [_st_rad]
mov edi,virtual_screen_8
cdq
.itex_vertical:
xor ecx,ecx
fld [_st_rad]
mov [_fpom16],5
fimul [_fpom16]
mov [_fpom16],dx
fimul [_fpom16]
fsin
fmul [_multiplier]
fstp [_fpom32]
.itex_horizontal:
fld [_st_rad]
mov [_fpom16],3
fimul [_fpom16]
mov [_fpom16],cx
fimul [_fpom16]
fsin
fmul [_multiplier]
fadd [_fpom32]
mov [_fpom16],127
fiadd [_fpom16]
fistp [_fpom16]
mov ax,[_fpom16]
inc eax
stosb
inc ecx
cmp ecx,WND_SIZE_X
jne .itex_horizontal
inc edx
cmp edx,WND_SIZE_Y
jne .itex_vertical
ret
 
rotate_pal:
mov ebx,[_palette+4]
mov edi,_palette+4
mov esi,_palette+8
xor ecx,ecx
mov cl,255
; cld
rep movsd
mov [_palette+1020],ebx
ret
 
include "graph8.inc"
 
DATA
_multiplier dd 63.5
 
window_title:
db 'Plasma'
window_title_len = $ - window_title
 
UDATA
_fpom32 rd 1
_fpom16 rw 1
_st_rad rd 1
_palette: rd 256
 
virtual_screen_8:
rb WND_SIZE_X*WND_SIZE_Y
 
virtual_screen_32:
rb WND_SIZE_X*WND_SIZE_Y*3
 
MEOS_APP_END
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/ss/trunk/@SS.ASM
0,0 → 1,553
; SCREENSAVER APPLICATION by lisovin@26.ru
;
; Compile with FASM for Menuet
;
use32
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x40000 ; memory for app (256 Kb)
dd 0x40000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
 
;include 'debug.inc'
 
START:
mov eax,14
int 0x40
and eax,0xFFFF0000
mov [top_right_corner],eax
 
mov eax,40 ; ãáâ ­®¢¨âì ¬ áªã ᮡë⨩
mov ebx,110010b ; ॠ£¨à㥬 ­  ª« ¢¨ âãàã, ¬ëèì, ®âà¨á®¢ªã ä®­ 
int 0x40
 
mov eax,14 ; ¯®«ã稬 à §¬¥àë íªà ­ 
int 0x40
mov [y_max],ax
shr eax,16
mov [x_max],ax
 
event: ; ®¡à ¡®â稪 ᮡë⨩ (¢á¥å)
mov eax,26
mov ebx,9
int 0x40 ; ¯®«ãç¨âì ¢à¥¬ï á¨á⥬ë
; mov eax,3
; int 0x40
mov [evtime],eax ; § ¯®¬­¨âì ¥£®
mov eax,37
mov ebx,2
int 0x40
cmp eax,3 ; ¯à®¤®«¦¨¬, ¥á«¨ ­ ¦ â  á।­ïï ª­®¯ª  ¬ëè¨
jne still
mov eax,37 ; ¯à®¢¥à¨¬ ª®®à¤¨­ âë
mov ebx,0
int 0x40
cmp [top_right_corner],eax
je create_setup ; ᮧ¤ ñ¬ ®ª­® ­ áâனª¨, ¥á«¨ ¬ëèì ¢ ¢¥àå­¥¬ ¯à ¢®¬
; 㣫ã íªà ­ 
 
 
 
still: ; ®á­®¢­®© 横« ¯à®£à ¬¬ë
 
mov eax,23 ; ¦¤ñ¬ ᮡëâ¨ï ¢ â¥ç¥­¨¥ 1 ᥪ㭤ë
mov ebx,100
int 0x40
 
bt dword [params],0 ; ssaver works?
jc event
bt dword [params],1 ; setup works?
jc event
 
cmp eax,2 ; key in buffer ?
je event
cmp eax,5
je event
cmp eax,6
je event
 
mov eax,26
mov ebx,9
int 0x40
sub eax,[evtime]
xor edx,edx
mov ebx,60*100 ; ¯®¤¥«¨¬ ­  60*100, ¯®«ã稬 ¢à¥¬ï ¢ ¬¨­ãâ å
div ebx
cmp al,[time]
jb still
 
; current_time-evtime/100/60 = ¢à¥¬ï ¢ ¬¨­ãâ å á ¯à®è«®£® ᮡëâ¨ï
 
call create_ss
jmp still
 
 
 
create_setup:
bt dword [params],1
jc still
mov eax,51
mov ebx,1
mov ecx,sthread
mov edx,0x3F000
int 0x40
bts dword [params],1
jmp still
 
create_ss:
mov eax,51
mov ebx,1
mov ecx,thread
mov edx,0x3E000
int 0x40
bts dword [params],0
ret
 
thread:
mov eax,5
mov ebx,eax
int 0x40
mov eax,40
mov ebx,100010b
int 0x40
cmp dword [type],0
je drawsswin
cmp dword [type],24
je asminit
mov dword [delay],1
mov [lx1],10 ; for "draw line"
mov [lx2],40
mov [ly1],50
mov [ly2],100
mov [addx1],1
mov [addx2],1
mov [addy1],1
mov [addy2],1
jmp drawsswin
asminit: ; for "assembler"
mov dword [delay],25
mov eax,58
mov ebx,fileinfo
int 0x40
asminit1:
mov eax,data_from_file
mov [stringstart],eax
mov dword [stringlen],1
newpage:
mov word [stringpos],10
 
drawsswin:
xor eax,eax
mov ebx,eax
mov ecx,eax
mov bx,[x_max]
mov cx,[y_max]
inc ebx
inc ecx
mov edx,0x01000000
int 0x40
mov eax,13
xor edx,edx
int 0x40
tstill:
mov eax,23
mov ebx,[delay]
int 0x40
cmp eax,2
je thr_end
cmp eax,6
je thr_end
cmp dword [type],0
je tstill
cmp dword [type],24
je drawssasm
call draw_line
jmp tstill
thr_end:
btr dword [params],0
mov eax,26
mov ebx,9
int 0x40
mov [evtime],eax
or eax,-1
int 0x40
 
drawssasm:
mov edi,[stringstart]
add edi,[stringlen]
dec edi
mov eax,edi
sub eax,data_from_file
cmp eax,10450
ja asminit1
cmp word [edi],0x0a0d
jne noaddstring
add word [stringpos],10
add edi,2
mov [stringstart],edi
mov dword [stringlen],1
mov ax,[stringpos]
cmp ax,[y_max]
jb tstill
jmp newpage
noaddstring:
mov eax,4
mov ebx,10*65536
mov bx,[stringpos]
mov ecx,0x104ba010
mov edx,[stringstart]
mov esi,[stringlen]
int 0x40
inc dword [stringlen]
cmp byte [edi],byte ' '
je drawssasm
jmp tstill
 
draw_line:
 
xor esi,esi
xor edi,edi
mov si,[x_max]
mov di,[y_max]
 
mov eax,[addx1]
add [lx1],eax
mov eax,[addy1]
add [ly1],eax
 
mov eax,[addx2]
add [lx2],eax
mov eax,[addy2]
add [ly2],eax
 
cmp [lx1],1
jge dl1
mov [addx1],1
dl1:
cmp [lx2],1
jge dl2
mov [addx2],1
dl2:
cmp [lx1],esi
jbe dl3
mov [addx1],0xffffffff
dl3:
cmp [lx2],esi
jbe dl4
mov [addx2],0xffffffff
dl4:
 
cmp [ly1],1
jge dl5
mov [addy1],1
dl5:
cmp [ly2],2
jge dl6
mov [addy2],1
dl6:
cmp [ly1],edi
jbe dl7
mov [addy1],-1
dl7:
cmp [ly2],edi
jbe dl8
mov [addy2],-1
dl8:
 
mov eax,[lx2]
cmp [lx1],eax
jz dnol
 
mov bx,word [lx1]
shl ebx,16
mov bx,word [lx2]
 
mov cx,word [ly1]
shl ecx,16
mov cx,word [ly2]
 
mov eax,38
mov edx,[lcolor]
and edx,0xffffff
int 0x40
 
dnol:
 
add [lcolor],0x010201
 
ret
 
 
sthread: ; start of execution
 
call sdraw_window
 
sstill:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je sthread
cmp eax,2 ; key in buffer ?
je sstill
cmp eax,3 ; button in buffer ?
je sbutton
 
jmp sstill
 
sbutton: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne snoclose
 
btr dword [params],1
mov eax,-1 ; close this program
int 0x40
snoclose:
cmp ah,7
jne nosetfl
btc dword [params],0
call drawflag
call drawtype
call drawtime
jmp sstill
nosetfl:
bt dword [params],0
jc sstill
cmp ah,2
jne notypedown
mov eax,[type]
test eax,eax
je sstill
sub eax,12
jmp typeupdn
notypedown:
cmp ah,3
jne notypeup
mov eax,[type]
cmp eax,24
jae sstill
add eax,12
jmp typeupdn
notypeup:
cmp ah,4
jne notimedown
mov al,[time]
cmp al,1
jbe sstill
dec al
; das
jmp timeupdn
notimedown:
cmp ah,5
jne notimeup
mov al,[time]
cmp al,59 ; 0x59
jae sstill
inc al
; daa
jmp timeupdn
notimeup:
cmp ah,6
jne noshow
mov eax,5
mov ebx,150
int 0x40
call create_ss
jmp sstill
noshow:
jmp sstill
 
timeupdn:
mov [time],al
call drawtime
jmp sstill
typeupdn:
mov [type],eax
call drawtype
jmp sstill
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
sdraw_window:
 
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
xor eax,eax ; function 0 : define and draw window
mov ebx,100*65536+215 ; [x start] *65536 + [x size]
mov ecx,100*65536+70 ; [y start] *65536 + [y size]
mov edx,0x03400088 ; color of work area RRGGBB,8->color gl
int 0x40
 
mov eax,8
mov ebx,47*65536+10
mov ecx,31*65536+10
mov edx,2
mov esi,0x702050
int 0x40
push ebx
add ebx,13*65536
mov edi,ebx
inc edx
int 0x40
pop ebx
add ecx,15*65536
inc edx
int 0x40
mov ebx,edi
inc edx
int 0x40
mov ebx,160*65536+40
mov ecx,28*65536+14
inc edx
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,0x10ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelt ; pointer to text beginning
mov esi,17 ; text length
int 0x40
add ebx,7*65536+25
mov ecx,0xffffff
mov edx,setuptext
mov esi,9
int 0x40
add ebx,15
add edx,esi
mov esi,30
int 0x40
mov ebx,169*65536+32
mov edx,buttext
mov esi,4
int 0x40
 
call drawtype
call drawtime
call drawflag
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
drawtype:
mov eax,13
mov ebx,80*65536+75
mov ecx,30*65536+12
mov edx,0xffffff
bt dword [params],0
jnc noblue
mov edx,0x4e00e7
noblue:
int 0x40
mov eax,4
mov ebx,82*65536+32
xor ecx,ecx
mov edx,typetext
add edx,[type]
mov esi,12
int 0x40
ret
 
drawtime:
mov eax,13
mov ebx,80*65536+15
mov ecx,45*65536+12
mov edx,0xffffff
bt dword [params],0
jnc noblue1
mov edx,0x4e00e7
noblue1:
int 0x40
mov eax,47
mov edx,82*65536+47
xor esi,esi
movzx ecx,byte [time]
mov ebx,0x00020000
int 0x40
ret
 
drawflag:
mov eax,8
mov ebx,150*65536+10
mov ecx,45*65536+10
mov edx,7
mov esi,0xe0e0e0
int 0x40
mov eax,4
mov ebx,153*65536+47
xor ecx,ecx
mov esi,1
mov edx,flag
bt dword [params],0
jc setf
inc edx
setf:
int 0x40
ret
 
; DATA AREA
buttext db 'SHOW'
flag db 'V '
labelt db 'SCREENSAVER SETUP'
setuptext db 'TYPE: < >TIME: < > MINUTES NEVER'
typetext db 'BLACK SCREENCOLOR LINES ASSEMBLER '
type dd 12
time db 15 ; ¢à¥¬ï ¤® § ¯ã᪠ § áâ ¢ª¨ ¢ ¬¨­ãâ å
delay dd 100
 
lx1 dd 10
lx2 dd 40
 
ly1 dd 50
ly2 dd 100
 
addx1 dd 1
addx2 dd 1
 
addy1 dd 1
addy2 dd 1
 
stringlen dd 1
stringstart dd 0
stringpos dw 10
 
params dd 0 ;if bit 0 set-ssaver works if bit 1 set-setup works
 
fileinfo:
dd 0,0,21,data_from_file,work_area
db '/RD/1/SS.ASM',0
 
I_END:
 
 
; UNINITIALIZED DATA:
 
lcolor dd ?
evtime dd ? ; ¢à¥¬ï ¯à¥¤ë¤ã饣® ᮡëâ¨ï
x_max dw ? ; à §¬¥àë íªà ­ 
y_max dw ?
 
top_right_corner dd ?
work_area:
rb 0x10000
data_from_file:
/programs/demos/ss/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm @ss.asm @ss
@pause
/programs/demos/ss/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm @ss.asm @ss
@pause
/programs/demos/ss/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/timer/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm timer.asm timer
@pause
/programs/demos/timer/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm timer.asm timer
@pause
/programs/demos/timer/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; language for programs
lang fix ru ; ru en fr ge fi
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/timer/trunk/timer.asm
0,0 → 1,176
;
; TIMER
;
; Compile with flat assembler
;
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
 
START: ; start of execution
mov eax, 40
mov ebx, 101b
int 0x40
 
red:
call draw_window
 
still:
 
mov eax,23 ; wait here for event
mov ebx,50
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,3 ; button in buffer ?
je button
 
call draw_clock
 
jmp still
 
 
button: ; button
or eax,-1 ; close this program
int 0x40
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
draw_clock:
mov eax, 13 ; clear area
mov ebx, 10*65536+55
mov ecx, 30*65536+10
mov edx, [sc.work]
int 0x40
 
mov eax, 26 ; get system counter
mov ebx, 9
int 0x40
 
cdq ;xor edx,edx
mov ebx,100
div ebx
 
push eax
 
xor edx,edx
mov ebx,60
div ebx
mov ecx,eax
 
push ecx
push ecx
 
xor edx,edx
mov ebx,60
div ebx
mov ecx,eax
 
mov eax,47 ; HH
mov esi,[sc.work_text]
or esi,0x10000000
mov ebx,0x00020000
mov edx,10*65536+30
int 0x40
 
pop eax ; MM
imul ecx,ecx,60
sub eax,ecx
mov ecx,eax
mov eax,47
add edx,20*65536
int 0x40
 
pop ecx
pop eax
 
imul ecx,ecx,60
sub eax,ecx
 
mov ecx,eax ; SS
mov eax,47
add edx,20*65536
int 0x40
 
ret
 
draw_window:
mov eax,48
mov ebx,3
mov ecx,sc
mov edx,sizeof.system_colors
int 0x40
 
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,100*65536+75 ; [x start] *65536 + [x size]
mov ecx,100*65536+45 ; [y start] *65536 + [y size]
mov edx,[sc.work] ; color of work area RRGGBB,8->color gl
mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color gl
or esi,0x80000000
mov edi,[sc.frame] ; color of frames RRGGBB
int 0x40
 
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,6*65536+7 ; [x start] *65536 + [y start]
mov ecx,[sc.grab_text] ; font 1 & color ( 0xF0RRGGBB )
or ecx,0x10000000
mov edx,header ; pointer to text beginning
mov esi,header.len ; text length
int 0x40
 
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,(75-16)*65536+12 ; [x start] *65536 + [x size]
mov ecx,4*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,[sc.grab_button] ; button color RRGGBB
int 0x40
 
call draw_clock
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
; DATA AREA
 
if lang eq ru
header:
db '’€‰Œ…'
.len = $ - header
else
header:
db 'TIMER'
.len = $ - header
end if
 
 
I_END:
 
temp dd ?
sc system_colors
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/tinyfrac/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm tinyfrac.asm tinyfrac
@pause
/programs/demos/tinyfrac/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm tinyfrac.asm tinyfrac
@pause
/programs/demos/tinyfrac/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; language for programs
lang fix ru ; ru en fr ge fi
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/tinyfrac/trunk/tinyfrac.asm
0,0 → 1,519
; tinyfrac.asm
;
; teeny program displays the Mandelbrot set.
;
; written on Sun 03-26-1995 by Ed Beroset (Fidonet 1:3641/1.250)
;
; This program was based on a program by Frank Hommers, later optimized
; for size by Mikko Hyvarinen and posted in Fidonet's 80XXX echo.
;
; This new version has many new features and was based on my own
; optimization of Hyvarinen's version. Some features:
;
; pan using the arrow keys, one can navigate the fractal.
;
; Home Up PgUp
; Left Right correspond to 8 obvious directions
; End Dn PgDn
;
; zoom there are now ten levels of magnification available. If the
; program is assembled with FEATURES defined, the number
; corresponding to the zoom level (0-9, zero is most zoomed in)
; is displayed in the upper left hand corner of the screen just
; before each new fractal is drawn. The gray '+' key zooms out,
; the gray '-' key zooms in.
;
; beep the program will beep at the completion of each fractal
; drawing or if the user attempts to zoom past either limit.
;
; mode if the program is assembled with MODECHANGE defined, the
; will change to the next video mode if the 'v' key is pressed.
; This is handy because drawing fractals at high resolution can
; be very timeconsuming. The user can find an interesting spot
; in a low res mode and then change to a high res mode to see it
; more fully rendered.
;
; size this whole project was started off as a size optimization
; exercise, so there have been some rather ugly tradeoffs to
; sacrifice speed for size.
;
; 8086 yes, it runs on an 8086 although only if you leave out either
; the FEATURES option or the MODECHANGE option and it would be
; slower and more painful than oral surgery.
;
; cost there IS such a thing as a free lunch! This code is hereby
; released to the public domain by the author.
;
;
; to assemble &amp; link:
; TASM /m2 tinyfrac (assemble using two pass mode if required)
; TLINK /Tdc tinyfrac (link Target platform is DOS, COM file)
;
;
 
PIXWIDTH equ 511
PIXHEIGHT equ 255
 
ZOOMLIMIT equ 13 ; can change to up to 13 for extended zoom in
 
; feel free to experiment with the following constants:
 
DELTA equ 200 ; the unit of pan movement in pixels
THRESHOLD equ 7 ; must be in the range of (0,255)
STARTSCALE equ 5 ; a number from 0 to ZOOMLIMIT, inclusive
CHAR_COLOR equ 0fh ; white on black background (for PRINTZOOM feature)
 
 
 
; ************************************************************
;
; Menuet header
 
 
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x62000
dd 0x1000
dd 0,0
 
include 'lang.inc'
include 'macros.inc'
 
STARTX dd 200
STARTY dd 120
 
scaleaddy dd 120
scaleaddx dd 200
 
START:
 
call draw_window
 
call draw_fractal
 
still:
 
mov eax,10
int 0x40
 
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
 
jmp still
 
red:
call draw_window
call put_image
jmp still
 
key:
mov eax,2
int 0x40
 
cmp ah,'e'
je cycle
cmp ah,'r'
je cycle
jmp no_cycle
cycle:
call color_cycle
jmp still
no_cycle:
 
cmp ah,'q'
jne no_in
inc byte [scale]
mov ebx,[STARTX]
imul ebx,2
sub ebx,[scaleaddx]
mov [STARTX],ebx
mov ebx,[STARTY]
imul ebx,2
sub ebx,[scaleaddy]
mov [STARTY],ebx
no_in:
 
cmp ah,'w'
jne no_out
dec byte [scale]
mov ebx,[STARTX]
add ebx,[scaleaddx]
shr ebx,1
mov [STARTX],ebx
mov ebx,[STARTY]
add ebx,[scaleaddy]
shr ebx,1
mov [STARTY],ebx
no_out:
 
cmp ah,130+48
jne no_up
sub [STARTY],100
no_up:
 
cmp ah,129+48
jne no_down
add [STARTY],100
no_down:
 
cmp ah,128+48
jne no_left
sub [STARTX],100
no_left:
 
cmp ah,131+48
jne no_right
add [STARTX],100
no_right:
 
call draw_fractal
jmp still
 
button:
mov eax,17
int 0x40
 
cmp ah,1
jne no_close
mov eax,-1
int 0x40
no_close:
 
cmp ah,2
jne no_bgr
 
mov eax,15 ; bgr 512 x 256
mov ebx,1
mov ecx,512
mov edx,256
int 0x40
 
mov eax,15
mov ebx,5
mov ecx,0x1000
mov edx,0
mov esi,512*3*256
int 0x40
 
mov eax,15
mov ebx,3
int 0x40
 
jmp still
 
no_bgr:
 
cmp ah,3
jb no_color
cmp ah,5
jg no_color
shr eax,8
sub eax,3
imul eax,8
add eax,8
not eax
and eax,11000b
; sub eax,8
mov [shlc],al
call draw_fractal
jmp still
 
no_color:
 
 
jmp still
 
 
color_cycle:
 
pusha
mov ecx,0x08080808
mov esi,(256/8)*5
cmp ah,'e'
je f_out
mov ecx,-0x08080808
mov esi,(256/8)*5-1
f_out:
 
newcycle:
mov edi,0x1000
newpix:
mov eax,[edi]
add eax,ecx
mov [edi],eax
add edi,4
cmp edi,0x1000+512*256*3
jb newpix
call put_image
mov eax,5
mov ebx,1
int 0x40
dec esi
jnz newcycle
 
mov eax,0
mov edi,0x1000
mov ecx,512*256*3 / 4 +50
cld
rep stosd
 
popa
 
call draw_fractal
 
ret
 
 
 
 
 
; **********************************************************************
;
; Tinyfrac
;
 
 
draw_fractal:
 
pusha
mov eax,4
mov ebx,15*65536+35
mov ecx,0xffffff
mov edx,calc
mov esi,calcl-calc
int 0x40
popa
pusha
 
movzx ebp,word [STARTX]
movzx edi,word [STARTY]
 
 
; This routine is the fractal drawing engine. It has been
; optimized for size, sacrificing speed.
 
mov cx, PIXHEIGHT ; height of screen in pixels
 
sub di,cx ; adjust our Y offset
@@CalcRow:
 
push cx
 
; and cl,0x7
; cmp cl,0
; jne noim
; call put_image
; noim:
 
mov cx, PIXWIDTH -1 ; width of screen in pixels
 
sub bp,cx ;
@@CalcPixel:
push cx ; save the column counter on stack
xor cx, cx ; clear out color loop counter
xor bx, bx ; zero i coefficient
xor dx, dx ; zero j coefficient
@@CycleColors:
push dx ; save j value for later
mov ax, bx ; ax = i
sub ax, dx ; ax = i - j
add dx, bx ; dx = i + j
stc ; one additional shift, please
call Shifty ; ax = ((i+j)*(i-j)) shifted right
pop dx ; retrieve our saved value for j
add ax,bp ; account for base offset...
cmp ah,THRESHOLD ; Q: is i &gt; THRESHOLD * 256?
xchg bx,ax ; now swap new i with old i
jg @@draw ; Y: draw this pixel
clc ; no additional shifts here, please
call Shifty ; now dx:ax = old i * j
xchg dx,ax ;
add dx,di ; account for base offset...
inc cl ; increment color
jnz @@CycleColors ; keep going until we're done
@@draw:
xchg ax, cx ; mov color into al
pop cx ; retrieve our column counter
pop dx ; fetch row (column already in cx)
push dx ; must leave a copy on the stack
xor bx,bx ; write to video page zero
 
call put_pixel
 
inc bp
loop @@CalcPixel
inc di
pop cx
loop @@CalcRow
 
call put_image
 
popa
 
ret
 
 
put_image:
 
pusha
 
mov eax,7
mov ebx,0x1000
mov ecx,512*65536+255
mov edx,10*65536+30
int 0x40
 
popa
 
ret
 
 
shlc db 0
 
put_pixel:
 
pusha
sub edi,[STARTY]
sub ebp,[STARTX]
and edi,0xff
and ebp,0x1ff
shl edi,9
mov ebx,edi ; * 3 - Y
add edi,ebx
add edi,ebx
mov ebx,ebp
add ebp,ebx
add ebp,ebx
add edi,ebp
mov cl,[shlc]
mov ebx,0xff
shl ebx,cl
add cl,3
shl eax,cl
and eax,ebx
mov [0x1000+edi],eax
popa
 
ret
 
 
;****************************************************************************
;
; This routine multiplies AX by DX and shifts the result (in
; DX:AX) to the right by scale bits (or scale+1 bits if CY is
; set). The resulting value is left in AX. DX is destroyed.
;
;****************************************************************************
 
Shifty:
push cx ; save middle bits (i*i - j*j)
db 0b1h ; code for mov cl,immed8
scale db STARTSCALE
adc cl,0 ; adjust per CY flag
imul dx ; do the multiply
 
xchg ax,dx ;
shl eax,16 ; put hi part in hi 16 bits
xchg ax,dx
shr eax,cl ;
 
pop cx ;
ret ;
 
 
 
; **********************************************************************
;
; WINDOW DEFINITIONS AND DRAW
;
; **********************************************************************
 
 
 
draw_window:
 
pusha
 
mov eax,12
mov ebx,1
int 0x40
 
mov eax,0
mov ebx,50*65536+531
mov ecx,100*65536+256+48
mov edx,0x02334455
mov esi,0x80778899
mov edi,0x00778899
int 0x40
 
mov eax,8
mov ebx,(531-19)*65536+12
mov ecx,5*65536+12
mov edx,1
mov esi,0x808080
int 0x40
 
mov eax,8
mov ebx,300*65536+112
mov ecx,5*65536+12
mov edx,2
mov esi,0x808080
int 0x40
 
mov ebx,430*65536+12
mov ecx,5*65536+12
mov edx,3
mov esi,0xa00000
mov edi,3
newcolor:
mov eax,8
int 0x40
add ebx,13*65536
shr esi,8
inc edx
dec edi
jnz newcolor
 
mov eax,4
mov ebx,8*65536+8
mov ecx,0xffffff
mov edx,l
mov esi,ll-l
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
 
popa
ret
 
 
; ***************************************************************
;
; DATA AREA
;
 
 
l: db 'TINYFRAC - MOVE: ARROWS, ZOOM Q/W, CYCLE: E/R '
db 'SET AS WALLPAPER'
ll:
 
calc db 'CALCULATING'
calcl:
 
I_END:
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/transp/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm transp.asm transp
@pause
/programs/demos/transp/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm transp.asm transp
@pause
/programs/demos/transp/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; language for programs
lang fix ru ; ru en fr ge fi
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/transp/trunk/transp.asm
0,0 → 1,222
;
; TRANSPARENT EXAMPLE
;
; Compile with FASM for Menuet
;
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x30000 ; memory for app
dd 0x30000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
 
START: ; start of execution
mov [procinfo.x_start], 100
mov [procinfo.x_size], 200
mov [procinfo.y_start], 80
mov [procinfo.y_size], 300
 
call draw_window ; at first, draw the window
 
still:
 
mov eax,10 ; wait here for event
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
 
jmp still
 
red: ; redraw
call get_transparent
call draw_window
jmp still
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp still
 
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne noclose
mov eax,-1 ; close this program
int 0x40
noclose:
 
jmp still
 
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
 
 
draw_window:
 
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,[procinfo.x_start]
shl ebx,16
add ebx,[procinfo.x_size]
dec ebx
mov ecx,[procinfo.y_start]
shl ecx,16
add ecx,[procinfo.y_size]
dec ecx
mov edx,0x03000000 ; color of work area RRGGBB,8->color gl
int 0x40
 
call draw_transparent
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x10ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
 
; call draw_transparent
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
 
ret
 
 
 
 
draw_transparent:
 
pusha
 
mov eax,7
mov ebx,0x1000
mov ecx,[procinfo.x_size]
shl ecx,16
add ecx,[procinfo.y_size]
mov edx,4*65536+22
int 0x40
 
popa
ret
 
 
get_transparent:
 
pusha
 
mov eax,9
mov ebx,I_END
mov ecx,-1
int 0x40
; mov eax,[I_END+34]
; mov [x_start],eax
; mov eax,[I_END+38]
; mov [y_start],eax
 
mov eax,14
int 0x40
 
shr eax,16
inc eax
mov [scx],eax
 
add [procinfo.x_start], 4
sub [procinfo.x_size], 4+4
add [procinfo.y_start], 22
sub [procinfo.y_size], 22+4
 
mov eax,[procinfo.x_start]
add eax,[procinfo.x_size]
mov [x_end],eax
mov eax,[procinfo.y_start]
add eax,[procinfo.y_size]
mov [y_end],eax
 
mov eax,[procinfo.x_start]
mov ebx,[procinfo.y_start]
 
dtpl1:
 
push eax
push ebx
 
imul ebx,[scx]
add ebx,eax
mov eax,35
int 0x40
 
; shr eax,1
; and eax,0x7f7f7f
or eax, 0x4e4e4e
 
mov ebx,[esp+4]
mov ecx,[esp]
sub ebx,[procinfo.x_start]
sub ecx,[procinfo.y_start]
imul ecx,[procinfo.x_size]
imul ebx,3
imul ecx,3
add ebx,ecx
mov [0x1000+ebx],eax
 
pop ebx
pop eax
 
inc eax
cmp eax,[x_end]
jb dtpl1
mov eax,[procinfo.x_start]
inc ebx
cmp ebx,[y_end]
jb dtpl1
 
popa
 
ret
 
 
 
 
; DATA AREA
 
;x_start dd 100
;y_start dd 80
 
;x_size dd 160
;y_size dd 200
 
x_end dd 0
y_end dd 0
 
scx dd 640
 
labelt:
db 'EXAMPLE APPLICATION'
labellen:
 
I_END:
procinfo process_information
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/trantest/trunk/ascgl.inc
0,0 → 1,1385
lang equ ru
 
;
; Assembler
; SMALL
; CODE
; Graphics
; Libary
;
; Ver 0.18 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;InfoList
;0.01 LoadImage
;0.02 SetBmp
;0.03 Bmptoimg, Setimg ~01.03.2004
;0.04 Bug deleted, copyimg ~03.05.2004
;0.05 fullimg, collimg ~05.05.2004
;0.06 getimg ~09.05.2004
;0.07 convbmp ~13.05.2004
;0.08 fps ~14.05.2004
;0.09 drawfbox ~03.06.2004
;0.10 all macros optimized by halyavin, add at ~07.06.2004
;0.11 many macros optimized by halyavin, add at ~30.08.2004
;0.12 bmptoimg ~07.09.2004
;0.13 imgtoimg ~08.09.2004
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
;0.15 giftoimg, giftoani ~10.09.2004
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
 
aframetoimg_use_count=0
macro aframetoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aframetoimg_use_count=aframetoimg_use_count+1
if aframetoimg_use_count = 1
 
jmp end_aframetoimg_proc
 
acolor dd 0
aframetoimg_proc:
;getout coord
mov [acolor],ebp
 
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aframetoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aframetoimg_proc
}
 
frametoimg_use_count=0
macro frametoimg img, x, y, canvas
{
local loo,loo2
frametoimg_use_count=frametoimg_use_count+1
if frametoimg_use_count = 1
 
jmp end_frametoimg_proc
 
frametoimg_proc:
;getout coord
mov edx,ebx ;img ;xsize
movzx eax,word [edx]
add eax,esi ;y cor
 
; mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
 
mov ebp,ebx ;img ;xsize
movzx edx,word [ebp]
add eax,edx
 
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
add ebx,4
mov eax,ebx ;img ;xsize
movzx esi,word [eax]
movzx edi,word [eax+2]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
 
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_frametoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call frametoimg_proc
}
 
 
aimgtoimg_use_count=0
macro aimgtoimg img, x, y, canvas,acol
{
local loo,loo2,acolor
aimgtoimg_use_count=aimgtoimg_use_count+1
if aimgtoimg_use_count = 1
 
jmp end_aimgtoimg_proc
 
acolor dd 0
aimgtoimg_proc:
;getout coord
mov [acolor],ebp
 
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
 
;test on alpha color
mov eax,[edx]
shl eax,8
shr eax,8
cmp eax,[acolor]
jne yx
add edx,3
add ebp,3
jmp nx
yx:
 
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
nx:
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_aimgtoimg_proc:
end if
push img
push canvas
push x
push y
push acol
pop ebp
pop esi
pop edi
pop ecx
pop ebx
call aimgtoimg_proc
}
 
 
 
 
imgtoimg_use_count=0
macro imgtoimg img, x, y, canvas
{
local loo,loo2
imgtoimg_use_count=imgtoimg_use_count+1
if imgtoimg_use_count = 1
 
jmp end_imgtoimg_proc
imgtoimg_proc:
;getout coord
mov eax,esi ;y cor
mul dword [ecx] ;canvas xsize
add eax,edi ;x cor
mov ebp,eax
shl eax,1
add ebp,eax
add ebp,ecx ;canvas+8;start
add ebp,8
;get img size
mov eax,ebx ;img ;xsize
mov esi,[eax]
add ebx,4
mov eax,ebx ; img+4 ;ysize
mov edi,[eax]
add ebx,4
mov edx,ebx ;img+8
loo2:
push esi
loo:
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
mov al,byte [edx]
mov byte [ebp],al
inc ebp
inc edx
dec esi
jnz loo
pop esi
sub ebp,3
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3)
sub eax,esi
add ebp,eax
shl eax,1
add ebp,eax
 
add ebp,3
 
dec edi
jnz loo2
ret
end_imgtoimg_proc:
end if
push img
push canvas
push x
push y
pop esi
pop edi
pop ecx
pop ebx
call imgtoimg_proc
}
 
 
;DrawBox
macro drawfbox x,y,xs,ys,color
{
wordstoreg ebx,x,xs ;x*65536+xs
wordstoreg ecx,y,ys ;y*65536+ys
mov edx,color
mov eax,13
int 0x40
}
 
; FPS - Set Frame Per Second Display
fps_show_frequency=40
macro fps x,y,color,delcolor
{
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
local no_out_fps
jmp spdat
savetime dd 0
fps_cntr dd 0
fps dd 0
ttt dd 0
spdat:
get_time:
mov eax,3
int 0x40
cmp eax,[savetime]
jne new_time
inc [fps_cntr]
cmp dword [ttt],0
je out_fps
dec dword [ttt]
jmp no_out_fps
new_time:
mov [savetime],eax
mov ebx,[fps_cntr]
mov [fps],ebx
mov [fps_cntr],0
out_fps:
if ~(delcolor eq )
mov ebx,x*65536+30
mov ecx,y*65536+7
mov edx,delcolor
mov eax,13
int 0x40
end if
mov dword [ttt],fps_show_frequency
mov eax,47
mov ebx,5*65536
; mov bl,0
mov edx,x*65536+y
mov esi,color
mov ecx,[fps]
int 0x40
no_out_fps:
}
 
; COLLIMG - Collusion image's
_1dbounce_count=0;
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
{
local bounce,exit,anot,bc,nbc
mov esi,[img1_off] ;xs1
mov edi,[img2_off] ;ys2
mov eax,x1 ;
mov ebx,x2 ;
call _1dbounce
mov edx,ecx
mov esi,[img1_off+4] ;ys1
mov edi,[img2_off+4] ;ys2
mov eax,y1 ;
mov ebx,y2 ;
call _1dbounce
add edx,ecx
cmp edx,2
je bounce
mov otv,0
jmp exit
_1dbounce_count=_1dbounce_count+1
if _1dbounce_count = 1
_1dbounce:
cmp ebx,eax
jb anot
add eax,esi
cmp eax,ebx
jbe nbc
bc:
mov ecx,1
ret
anot:
add ebx,edi
cmp ebx,eax
ja bc
nbc:
xor ecx,ecx
ret
end if
bounce:
mov otv,1
exit:
}
 
macro rgbtobgr image
{
local loo
mov eax,[image]
mul dword [image+4]
mov ecx,eax
mov esi,image+8
; add esi,8
loo:
mov al,[esi]
mov bl,[esi+2]
mov [esi],bl
mov [esi+2],al
add esi,3
dec ecx
jnz loo
}
 
 
macro setimg x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
mov cx,[arg3]
shl ecx,16
add cx,[arg3+4]
; wordstoreg ecx,[arg3],[arg3+4]
wordstoreg edx, x , y ;arg1*65536+arg2
int 0x40
}
 
macro setframe x , y ,arg3
{
mov eax,7
mov ebx,arg3
add ebx,8
wordstoreg edx, x , y ;arg1*65536+arg2
add edx,dword [arg3]
mov ecx,dword [arg3+4]
int 0x40
}
 
 
macro getimg imgsrc,x,y,xs,ys,imgdest
{
local cyc
if xs eqtype 0
mov dword [imgdest],xs
else
mov eax,xs
mov dword [imgdest],eax
end if
if ys eqtype 0
mov dword [imgdest+4],ys
else
mov eax,ys
mov dword [imgdest+4],eax
end if
 
mov eax,dword [imgsrc] ;getx size
; lea ecx,[eax+2*eax]
mov ecx,eax
shl ecx,1
add ecx,eax
 
mov ebx,y
mul ebx
add eax,x
mov edx,ecx
lea eax,[eax+2*eax] ;eax=offset on imsrc
; mov ebp,eax
; shl eax,1
; add eax,ebp
 
mov ecx,xs
mov ebx,ys
 
mov edi,8+imgdest
lea esi,[eax+8+imgsrc]
; mov esi,eax
; add esi,8
; add esi,imgsrc
 
cld
cyc:
movsw
movsb
dec ecx
jne cyc
add esi,edx
mov ecx,xs
sub esi,ecx
sub esi,ecx
sub esi,ecx
dec ebx
jne cyc
}
 
macro copyimg img2_off,img1_off
{
mov eax,dword [img1_off]
mov ebx,dword [img1_off+4]
mul ebx
lea ecx,[eax+2*eax]
lea esi,[img1_off+8]
lea edi,[img2_off+8]
cld
rep movsb
}
 
macro fullimg img_off,xs,ys,color
{
local cop
mov eax,xs
mov ebx,ys
mov dword [img_off],eax
mov dword [img_off+4],ebx
mul ebx
lea ebp,[eax+2*eax]
mov esi,color
if color eqtype 0
mov ecx,color/65536
else
mov ecx,esi
shr ecx,16
end if
xor edi,edi
cop:
mov word [img_off+8+edi],si
add edi,2
mov byte [img_off+8+edi],cl
inc edi
cmp edi,ebp
jne cop
}
 
 
 
; number of frame in ecx
; callculatin offset of raw data
 
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
{
local loo,setpic
mov ebp,num_of_frame ;ecx
mov esi,offset_of_animation;Image
loo:
cmp ebp,0
je setpic
movzx eax,word [esi+4]
movzx ebx,word [esi+6]
mul ebx ;dword [esi+4]
mov ebx,3
mul ebx
add eax,8
add esi,eax
dec ebp
jmp loo
setpic:
mov dword offset_of_frame,esi
}
 
 
; BMPTOIMG -Convert BMP format TO IMG format
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset
; (SAMPLE) View BMPLS.ASM sample.
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits
 
 
bmptoimg_data_area_count=0
macro bmptoimg bmp_load_area,img_dest_area
{
local fileinfo,string,end_bmp,nodix
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
;local qwe,bmpfn
 
; convert:
movzx eax,word [bmp_load_area+28]
mul dword [bmp_load_area+18]
add eax,31
shr eax,5
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string
shl eax,2
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string
 
cmp dword [bmp_load_area+34],0
jne yespicsize ;if picture size is defined
mul dword [bmp_load_area+22]
mov dword [bmp_load_area+34],eax
 
yespicsize:
mov ebp,img_dest_area+8
 
mov eax,bmp_load_area
mov ebx,eax
add ebx, [bmp_load_area+2];file size
inc ebx
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing
 
add eax, [bmp_load_area+10]
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file
add eax, [bmp_load_area+34]
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file
mov eax, [bmp_load_area+18]
lea eax,[eax+2*eax] ;3x pixels in eax
 
mov edi,dword [bmptoimg_soi] ;initializing
mov esi,dword [bmptoimg_data_area_eop]
sub esi,dword [bmptoimg_data_area_bps]
 
 
nextstring:
push edi
push ebp
cmp word [bmp_load_area+28],24
jne convertno32
 
mov edi,ebp
mov ecx,[bmptoimg_data_area_dwps]
cld
rep movsd
 
convert1:
pop ebp
pop edi
sub esi,dword [bmptoimg_data_area_bps]
sub esi,dword [bmptoimg_data_area_bps]
cmp esi,dword [bmptoimg_data_area_sop]
jb end_bmp
add edi,eax
add ebp,eax
jmp nextstring
 
convertno32:
mov ebx,bmp_load_area
add ebx, [bmp_load_area+14]
add ebx,14 ;start of color table
push esi
add esi,dword [bmptoimg_data_area_bps]
mov dword [bmptoimg_data_area_eos],esi
pop esi
nextelem:
push eax
movzx eax,byte [esi]
cmp word [bmp_load_area+28],4
je convert4bpp
cmp word [bmp_load_area+28],1
je convert1bpp
call converttable
 
convert2:
pop eax
inc esi
cmp esi,dword [bmptoimg_data_area_eos]
jae convert1
add edi,3
 
add ebp,3
 
jmp nextelem
 
convert4bpp:
shl ax,4
shr al,4
push ax
movzx eax,ah
call converttable
add edi,3
 
add ebp,3
 
pop ax
movzx eax,al
call converttable
jmp convert2
 
convert1bpp:
mov ecx,eax
mov edx,7
nextbit:
xor eax,eax
bt ecx,edx
jnc noaddelem
inc eax
noaddelem:
push edx
call converttable
pop edx
dec edx
js convert2
add edi,3
 
add ebp,3
 
jmp nextbit
 
converttable:
shl eax,2
add eax,ebx
mov edx, dword [eax]
; mov dword [edi],edx
mov [ebp],edx
ret
 
bmptoimg_data_area_count=bmptoimg_data_area_count+1
if bmptoimg_data_area_count = 1
; DATA AREA
bmptoimg_soi dd 0
bmptoimg_data_area_bps dd 0
bmptoimg_data_area_dwps dd 0
bmptoimg_data_area_sop dd 0
bmptoimg_data_area_eop dd 0
bmptoimg_data_area_eos dd 0
end if
 
end_bmp:
mov eax,dword [bmp_load_area+18]
mov ebx,dword [bmp_load_area+22]
mov dword [img_dest_area],eax
mov dword [img_dest_area+4],ebx
}
 
; For convert RGB to BGR
COLOR_ORDER equ MENUETOS
 
macro giftoani gifsrc,imgsrc,num_of_frames
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null equ 0x1000 ; 0x1000
 
; jmp sss
; if defined gif_hash_offset
; else
; hasharea:
; times 4096 dd 0 ;4096
; end if
;sss:
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
push ecx
pop dword num_of_frames
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
movsd
movsd
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
cmp byte[edi],0x3b ;read next frame
jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
 
 
macro giftoimg gifsrc,imgsrc
{
local hasharea, ReadGIF, nextblock,_null
local globalColor, img_count, cur_info, img_start
local codesize, compsize, bit_count, CC, EOI, Palette
local block_ofs, table_ptr, gifmacend
local no_gc, block_skip, no_comm, noextblock, uselocal
local setPal, filltable, reinit, cycle, zadd, noinc
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
local Gif_output, next, loop2
 
_null fix 0x1000 ; 0x1000
 
mov esi,gifsrc ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
mov edi,imgsrc ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
 
if defined gif_hash_offset
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
else
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
end if
 
call ReadGIF
jmp gifmacend
 
if defined gif_hash_offset
else
hasharea:
times 4096 dd 0 ;4096
end if
 
ReadGIF:
push esi edi
mov [table_ptr],eax
mov [cur_info],edi
xor eax,eax
mov [globalColor],eax
mov [img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc nextblock
mov [globalColor],esi
call Gif_skipmap
nextblock:
cmp byte[edi],0x21
jne noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne no_gc
add edi,7
jmp nextblock
no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne no_comm
inc edi
block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz block_skip
inc edi
jmp nextblock
no_comm:
cmp byte[edi],0xff ; Application Ext
jne nextblock
add edi,13
jmp block_skip
noextblock:
cmp byte[edi],0x2c ; image beginning
jne er
inc [img_count]
inc edi
mov esi,[cur_info]
xchg esi,edi
; movsd
; movsd
 
mov bp,word[esi+4]
movzx ebx,bp
mov [edi],ebx
 
mov bp,word[esi+6]
movzx ebx,bp
mov [edi+4],ebx
 
add edi,8
add esi,8
 
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc uselocal
push [globalColor]
mov edi,esi
jmp setPal
uselocal:
call Gif_skipmap
push esi
setPal:
movzx ecx,byte[edi]
inc ecx
mov [codesize],ecx
dec ecx
pop [Palette]
lea esi,[edi+1]
mov edi,[table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [block_ofs],eax
mov [bit_count],8
mov eax,1
shl eax,cl
mov [CC],eax
inc eax
mov [EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
filltable:
stosd
inc eax
loop filltable
pop edi
mov [img_start],edi
reinit:
mov edx,[EOI]
inc edx
push [codesize]
pop [compsize]
call Gif_get_sym
cmp eax,[CC]
je reinit
call Gif_output
cycle:
movzx ebx,ax
call Gif_get_sym
cmp eax,edx
jae notintable
cmp eax,[CC]
je reinit
cmp eax,[EOI]
je zend
call Gif_output
zadd:
push eax
mov eax,[table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae cycle
inc edx
bsr ebx,edx
cmp ebx,[compsize]
jne noinc
inc [compsize]
noinc:
jmp cycle
notintable:
push eax
mov eax,ebx
call Gif_output
push ebx
movzx eax,bx
call Gif_output
pop ebx eax
jmp zadd
er:
pop edi
jmp ex
zend:
; mov eax,[.cur_info] ; skip offset to next frame
; mov [eax],edi
mov [cur_info],edi
add esi,2
xchg esi,edi
nxt:
cmp byte[edi],0
jnz continue
inc edi
jmp nxt
continue:
; cmp byte[edi],0x3b ;read next frame
; jne nextblock
xor eax,eax
stosd
mov ecx,[img_count]
ex:
pop edi esi
ret
 
Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
Gif_get_sym:
mov ecx,[compsize]
push ecx
xor eax,eax
shift:
ror byte[esi],1
rcr eax,1
dec [bit_count]
jnz loop1
inc esi
cmp esi,[block_ofs]
jb noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz nextbl
mov eax,[EOI]
sub esi,2
add esp,8
jmp exx
nextbl:
add eax,esi
mov [block_ofs],eax
pop eax
noblock:
mov [bit_count],8
loop1:
loop shift
pop ecx
rol eax,cl
exx:
xor ecx,ecx
ret
 
Gif_output:
push esi eax edx
mov edx,[table_ptr]
next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz next
shl ebx,16
mov bx,[esp]
loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
end if
 
loop loop2
pop edx eax esi
ret
 
globalColor dd 1
img_count dd 1
cur_info dd 1 ; image table pointer
img_start dd 1
codesize dd 1
compsize dd 1
bit_count dd 1
CC dd 1
EOI dd 1
Palette dd 1
block_ofs dd 1
table_ptr dd 1
 
gifmacend:
}
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/trantest/trunk/ascl.inc
0,0 → 1,838
lang equ ru ; ru en fr ge fi
 
;
; Assembler
; SMALL
; CODE
; Libary
;
; Ver 0.14 By Pavlushin Evgeni (RUSSIA)
; www.waptap@mail.ru
 
;Please compile aplications on FASM ver1.54 or higer!!!
 
;InfoList
;0.01 scank,putpix,puttxt
;0.02 label,random,colors
;0.03 window,startwd,endwd,attributes
;0.04 close,delay,scevent ~30.04.2004
;0.05 small random, ~04.05.2004
;0.06 wtevent ~09.05.2004
;0.07 timeevent ~23.05.2004
;0.08 txtput ~14.06.2004
;0.09 opendialog,savedialog ~20.06.2004
;0.10 wordstoreg by halyavin, add at ~30.08.2004
; random bug deleted eax is use.
;0.11 loadfile from me +puttxt bug del ~07.09.2004
;0.12 open/save dialog ~13.09.2004
;0.13 dialogs bugs deleted
;0.14 drawlbut ~03.10.2004
 
; LOADFILE
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area
 
macro loadfile file_name,file_load_area,file_temp_area
{
local open,fileinfo,string
jmp open
fileinfo:
dd 0
dd 0
dd 1
dd file_load_area
dd file_temp_area
string:
db file_name,0
open:
mov dword [fileinfo+8],1 ; how many blocks to read (1)
mov eax,58
mov ebx,fileinfo
int 0x40
mov eax,[file_load_area+2]
shr eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
inc eax
mov dword [fileinfo+8],eax
mov eax,58
mov ebx,fileinfo
int 0x40
}
 
 
macro wordstoreg reg,hiword,loword
{
if hiword eqtype 0 & loword eqtype 0
mov reg,(hiword)*65536+(loword)
else if hiword eqtype 12 & loword eqtype eax
mov reg,(hiword)*65536
add reg,loword
else if hiword eqtype 0 & loword eqtype [123]
mov reg,(hiword)*65536
add reg,loword
else if (hiword eq ) & (loword eq )
else
mov reg,hiword
shl reg,16
add reg,loword
end if
}
 
 
; DRAW BUTTON with label
 
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
{
local asd,lab
jmp asd
lab db text ;arg label
asd:
wordstoreg ebx,x,xs
wordstoreg ecx,y,ys
mov edx,id
mov esi,bcolor
mov eax,8
int 0x40
 
mov eax,asd-lab ;calc size
mov ebx,6
mul ebx
mov esi,eax
 
mov eax,xs
sub eax,esi
shr eax,1
add eax,x
 
mov edx,ys
sub edx,7
shr edx,1
add edx,y
 
mov ebx,eax
shl ebx,16
add ebx,edx
 
mov ecx,tcolor ;arg4 color
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
 
macro opendialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,150 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
mov eax,2
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
dd 0 ; My dec PID
dd 0,0 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo ; 0x10000
;run_filepath
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
macro savedialog redproc,openoff,erroff,path
{
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
local run_fileinfo, run_filepath, param
local getmesloop, loox, mred, mkey, mbutton, mgetmes
local dlg_is_work, ready, procinfo
;
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
;
 
cld
;; mov esi,path
mov edi,path
mov eax,0
mov ecx,200
rep stosb
 
;mov [get_loops],0
mov [dlg_pid_get],0
 
; Get my PID in dec format 4 bytes
mov eax,9
mov ebx,procinfo
mov ecx,-1
int 0x40
 
; convert eax bin to param dec
mov eax,dword [procinfo+30] ;offset of myPID
mov edi,param+4-1 ;offset to 4 bytes
mov ecx,4
mov ebx,10
cld
new_d:
xor edx,edx
div ebx
add dl,'0'
mov [edi],dl
dec edi
loop new_d
 
; wirite 1 byte space to param
mov [param+4],byte 32 ;Space for next parametr
; and 1 byte type of dialog to param
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog)
 
;
; STEP2 prepare IPC area for get messages
;
 
; prepare IPC area
mov [path],dword 0
mov [path+4],dword 8
 
; define IPC memory
mov eax,60
mov ebx,1 ; define IPC
mov ecx,path ; offset of area
mov edx,120 ; size 150 bytes
int 0x40
 
; change wanted events list 7-bit IPC event
mov eax,40
mov ebx,01000111b
int 0x40
 
;
; STEP 3 run SYSTEM XTREE with parameters
;
 
mov eax,58
mov ebx,run_fileinfo
int 0x40
 
call redproc
 
mov [get_loops],0
getmesloop:
mov eax,23
mov ebx,50 ;0.5 sec
int 0x40
 
cmp eax,1
je mred
cmp eax,2
je mkey
cmp eax,3
je mbutton
cmp eax,7
je mgetmes
 
; Get number of procces
mov ebx,procinfo
mov ecx,-1
mov eax,9
int 0x40
mov ebp,eax
 
loox:
mov eax,9
mov ebx,procinfo
mov ecx,ebp
int 0x40
mov eax,[DLGPID]
cmp [procinfo+30],eax ;IF Dialog find
je dlg_is_work ;jmp to dlg_is_work
dec ebp
jnz loox
 
jmp erroff
 
dlg_is_work:
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
je erroff ;TESTODP2 terminated too
 
cmp [dlg_pid_get],dword 1
je getmesloop
inc [get_loops]
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated
jae erroff
jmp getmesloop
 
mred:
call redproc
jmp getmesloop
mkey:
int 0x40 ; read (eax=2)
jmp getmesloop
mbutton:
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne getmesloop
mov eax,-1 ; close this program
int 0x40
mgetmes:
 
; If dlg_pid_get then second message get jmp to still
cmp [dlg_pid_get],dword 1
je ready
 
; First message is number of PID SYSXTREE dialog
 
; convert PID dec to PID bin
movzx eax,byte [path+16]
sub eax,48
imul eax,10
movzx ebx,byte [path+16+1]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+2]
add eax,ebx
sub eax,48
imul eax,10
movzx ebx,byte [path+16+3]
add eax,ebx
sub eax,48
mov [DLGPID],eax
 
; Claear and prepare IPC area for next message
mov [path],dword 0
mov [path+4],dword 8
mov [path+8],dword 0
mov [path+12],dword 0
mov [path+16],dword 0
 
; Set dlg_pid_get for get next message
mov [dlg_pid_get],dword 1
call redproc ;show DLG_PID
jmp getmesloop
 
ready:
;
; The second message get
; Second message is 100 bytes path to SAVE/OPEN file
; shl path string on 16 bytes
;
cld
mov esi,path+16
mov edi,path
mov ecx,200
rep movsb
mov [edi],byte 0
 
jmp openoff
 
 
; DATA AREA
get_loops dd 0
dlg_pid_get dd 0
DLGPID dd 0
 
param:
rb 4 ; My dec PID
rb 6 ; Type of dialog
 
run_fileinfo:
dd 16
dd 0
dd param
dd 0
dd procinfo
run_filepath:
db '/RD/1/SYSXTREE',0
 
procinfo:
times 256 db 0
}
 
 
 
 
; RANDOM - generate random count (small)
; (SYNTAX) RANDOM MaxCount,OutArgument
; (SAMPLE) RANDOM 10000,eax
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations
 
randomuse = 0
 
macro random arg1,arg2
{
local rxproc
randomuse = randomuse + 1
 
jmp rxproc
 
if defined randomuse & randomuse = 1
randomproc:
jmp rnj
rsx1 dw 0x4321
rsx2 dw 0x1234
rnj:
; mov eax,arg1
push bx
push cx
push dx
push si
push di
mov cx,ax
mov ax,word ptr rsx1
mov bx,word ptr rsx2
mov si,ax
mov di,bx
mov dl,ah
mov ah,al
mov al,bh
mov bh,bl
xor bl,bl
rcr dl,1
rcr ax,1
rcr bx,1
add bx,di
adc ax,si
add bx,0x62e9
adc ax,0x3619
mov word ptr rsx1,bx
mov word ptr rsx2,ax
xor dx,dx
cmp ax,0
je nodiv
cmp cx,0
je nodiv
div cx
nodiv:
mov ax,dx
pop di
pop si
pop dx
pop cx
pop bx
and eax,0000ffffh
; mov arg2,0
; mov arg2,eax
ret
end if
 
rxproc:
mov eax,arg1
call randomproc
mov arg2,eax
}
 
macro scank
{
mov eax,10
int 0x40
}
 
macro putpix x,y,color
{
mov ebx,x
mov ecx,y
mov edx,color
mov eax,1
int 0x40
}
 
macro puttxt x,y,offs,size,color
{
; mov ebx,x
; shl ebx,16
; add ebx,y
wordstoreg ebx,x,y
mov ecx,color
mov edx,offs
mov esi,size
mov eax,4
int 0x40
}
 
macro outcount data, x, y, color, numtype
{
mov ecx,data
mov ebx,numtype
mov bl,0
; mov edx,x*65536+y
wordstoreg edx,x,y
mov esi,color
mov eax,47
int 0x40
}
 
; SCEVENT - Scan event
 
macro scevent red,key,but
{
mov eax,11
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; WTEVENT - Wait event
 
macro wtevent red,key,but
{
mov eax,10
int 0x40
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
; TIMEEVENT - Wite for event with timeout
 
macro timeevent xfps,noevent,red,key,but
{
mov eax,23
mov ebx,xfps
int 0x40
cmp eax,0
je noevent
dec eax
jz red
dec eax
jz key
dec eax
jz but
}
 
 
; CLOSE - Close program
 
macro close
{
mov eax,-1
int 0x40
}
 
; DELAY - Create delay 1/100 sec
; (SYNTAX) Delay time
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec
 
macro delay arg1
{
mov eax,5
mov ebx,arg1
int 0x40
}
 
; WINDOW - Draw window
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned
 
macro window arg1,arg2,arg3,arg4,arg5
{
; mov ebx,arg1*65536+arg3
; mov ecx,arg2*65536+arg4
wordstoreg ebx,arg1,arg3
wordstoreg ecx,arg2,arg4
mov edx,arg5
mov eax,0
int 0x40
}
 
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
{
mov ebx,arg1*65536+arg3
mov ecx,arg2*65536+arg4
mov edx,arg5
mov esi,arg6
mov edi,arg7
mov eax,0
int 0x40
}
 
 
; STARTWD - Start of window draw
 
macro startwd
{
mov eax,12
mov ebx,1
int 0x40
}
 
; ENDWD - End window draw
 
macro endwd
{
mov eax,12
mov ebx,2
int 0x40
}
 
; LABEL - Put text to frame
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big
 
macro label arg1,arg2,arg3,arg4
{
local asd,lab
jmp asd
lab db arg3 ;arg label
asd:
; mov ebx,arg1 ;arg1=y arg2=x
; shl ebx,16
; add ebx,arg2
wordstoreg ebx,arg1,arg2
if ~(arg4 eq )
mov ecx,arg4 ;arg4 color
end if
mov edx,lab
mov esi,asd-lab ;calc size
mov eax,4
int 0x40
}
 
;Key's
key_Up equ 178
key_Down equ 177
key_Right equ 179
key_Left equ 176
key_Esc equ 27
key_Space equ 32
key_Enter equ 13
key_Bspace equ 8
key_F1 equ 50
key_F2 equ 51
key_F3 equ 52
key_F4 equ 53
key_F5 equ 54
key_F6 equ 55
key_F7 equ 56
key_F8 equ 57
key_F9 equ 48
key_F10 equ 49
key_F11 equ 68
key_F12 equ 255
key_Home equ 180
key_End equ 181
key_PgUp equ 184
key_PgDown equ 183
 
;Attributes
 
;Window Attributes
window_Skinned equ 0x03000000
window_Type2 equ 0x02000000
window_Type1 equ 0x00000000
window_Reserve equ 0x01000000
 
;Font Attributes
font_Big equ 0x10000000
 
;Colors
cl_White equ 0x00ffffff
cl_Black equ 0x00000000
cl_Grey equ 0x00888888
cl_Red equ 0x00ff0000
cl_Lime equ 0x0000ff00
cl_Green equ 0x0000af00
cl_Blue equ 0x000000ff
cl_Purple equ 0x008080ff
cl_Violet equ 0x008040ff
cl_Cyan equ 0x0040e0ff
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/trantest/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm trantest.asm trantest
@pause
/programs/demos/trantest/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm trantest.asm trantest
@pause
/programs/demos/trantest/trunk/trantest.asm
0,0 → 1,333
;
; TRIANGLE SPEED TEST 3
; 32 triangle draw use! 12300 triangle in sec on 800Mhz processor
;
; Pavlushin Evgeni 11.09.2004
; mail: waptap@mail.ru site: www.deck4.narod.ru
; www.cyberdeck.fatal.ru
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x2000000 ; memory for app
dd 0x2000000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
SCREEN_X equ 320 ;800
SCREEN_Y equ 200 ;600
 
include 'lang.inc'
include 'ascl.inc'
include 'ascgl.inc'
 
START:
call draw_window
 
still:
scevent red,key,button
fps 280,8,cl_White,cl_Black
 
main_loop:
random SCREEN_X,eax
mov [@@tx1],eax
random SCREEN_Y,eax
mov [@@ty1],eax
random SCREEN_X,eax
mov [@@tx2],eax
random SCREEN_Y,eax
mov [@@ty2],eax
random SCREEN_X,eax
mov [@@tx3],eax
random SCREEN_Y,eax
mov [@@ty3],eax
 
random 255,eax
mov byte [@@rgb],al
random 255,eax
mov byte [@@rgb+1],al
random 255,eax
mov byte [@@rgb+2],al
pushad
call filled_triangle
popad
 
dec [count] ;for max speed
jnz xxx
call outscr
mov [count],100
xxx:
jmp still
 
count dd 100
 
red:
call draw_window
jmp still
key:
mov eax,2
int 0x40
jmp still
button:
mov eax,17
int 0x40
cmp ah,1
jne still
exit:
mov eax,-1
int 0x40
 
;Draw window
draw_window:
mov eax,12 ;Start
mov ebx,1
int 0x40
 
mov eax,0 ;Draw window
mov ebx,100*65536+(SCREEN_X+9) ;x start*65536+x size
mov ecx,100*65536+(SCREEN_Y+26) ;y start*65536+y size
mov edx,0x03000000 ;0x03 use skinned window
int 0x40
 
mov eax,4 ;Out Text
mov ebx,8*65536+8 ;x start*65536+y start
mov ecx,0x00ffffff ;color White
mov edx,head_label
mov esi,hl_end-head_label
int 0x40
 
mov eax,12 ;End
mov ebx,2
int 0x40
ret
 
head_label: db "3D TEST SAMPLE FOR MENUETOS"
hl_end:
 
outscr:
 
;outscrbuf
mov ebx,scrbuf
mov ecx,SCREEN_X*65536+SCREEN_Y
mov edx,5*65536+22
mov ax,7
int 0x40
 
ret
 
;filled trangle 32 bit draw procedure
;from NAAG3d demo
 
@@tx1 dd 0
@@ty1 dd 0
@@tx2 dd 0
@@ty2 dd 0
@@tx3 dd 0
@@ty3 dd 0
@@rgb dd 0
 
@@dx12 dd 0
@@dx13 dd 0
@@dx23 dd 0
 
filled_triangle:
mov eax,[@@ty1]
cmp eax,[@@ty3]
jle @@ok13
 
xchg eax,[@@ty3]
mov [@@ty1],eax
 
mov eax,[@@tx1]
xchg eax,[@@tx3]
mov [@@tx1],eax
@@ok13:
mov eax,[@@ty2]
cmp eax,[@@ty3]
jle @@ok23
 
xchg eax,[@@ty3]
mov [@@ty2],eax
 
mov eax,[@@tx2]
xchg eax,[@@tx3]
mov [@@tx2],eax
@@ok23:
mov eax,[@@ty1]
cmp eax,[@@ty2]
jle @@ok12
 
xchg eax,[@@ty2]
mov [@@ty1],eax
 
mov eax,[@@tx1]
xchg eax,[@@tx2]
mov [@@tx1],eax
@@ok12:
 
mov ebx,[@@ty2]
sub ebx,[@@ty1]
jnz @@make_d12
 
mov [@@dx12],dword 0
jmp @@done_d12
@@make_d12:
mov eax,[@@tx2]
sub eax,[@@tx1]
shl eax,12 ;7
cdq
idiv ebx
mov [@@dx12],eax ; dx12 = (x2-x1)/(y2-y1)
@@done_d12:
 
mov ebx,[@@ty3]
sub ebx,[@@ty1]
jnz @@make_d13
 
mov [@@dx13],dword 0
jmp @@done_d13
@@make_d13:
mov eax,[@@tx3]
sub eax,[@@tx1]
shl eax,12 ;7
cdq
idiv ebx
mov [@@dx13],eax ; dx13 = (x3-x1)/(y3-y1)
@@done_d13:
 
mov ebx,[@@ty3]
sub ebx,[@@ty2]
jnz @@make_d23
 
mov [@@dx23],dword 0
jmp @@done_d23
@@make_d23:
mov eax,[@@tx3]
sub eax,[@@tx2]
shl eax,12 ;7
cdq
idiv ebx
mov [@@dx23],eax ; dx23 = (x3-x2)/(y3-y2)
@@done_d23:
 
mov eax,[@@tx1]
shl eax,12 ;7
mov ebx,eax
 
mov ecx,[@@ty1]
cmp ecx,[@@ty2]
jge @@end_loop12
 
@@loop12:
 
call flat_line
 
add eax,[@@dx13]
add ebx,[@@dx12]
inc ecx
cmp ecx,[@@ty2]
jl @@loop12
@@end_loop12:
 
mov ecx,[@@ty2]
cmp ecx,[@@ty3]
jge @@end_loop23
mov ebx,[@@tx2]
shl ebx,12 ;7
@@loop23:
 
call flat_line
 
add eax,[@@dx13]
add ebx,[@@dx23]
inc ecx
cmp ecx,[@@ty3]
jl @@loop23
@@end_loop23:
 
ret
 
;flatline proc
 
flat_line:
push eax
push ebx
push ecx
 
or ecx,ecx
jl @@quit
cmp ecx,SCREEN_Y-1 ;199
jg @@quit
 
sar eax,12
sar ebx,12
 
or eax,eax
jge @@ok1
xor eax,eax
jmp @@ok2
@@ok1:
cmp eax,SCREEN_X-1 ;319
jle @@ok2
mov eax,SCREEN_X-1 ;319
@@ok2:
or ebx,ebx
jge @@ok3
xor ebx,ebx
jmp @@ok4
@@ok3:
cmp ebx,SCREEN_X-1 ;319
jle @@ok4
mov ebx,SCREEN_X-1 ;319
@@ok4:
cmp eax,ebx
jl @@ok
je @@quit
 
xchg eax,ebx
@@ok:
mov edi,ecx
 
; shl edi,6 ;for 320 speed+
; shl ecx,8
; add edi,ecx
 
push eax
mov eax,SCREEN_X
mul edi
mov edi,eax
pop eax
 
add edi,eax
 
mov ebp,edi
shl ebp,1
add edi,ebp
 
add edi,scrbuf
 
mov ecx,ebx
sub ecx,eax
 
lineout:
mov eax,[@@rgb]
mov byte [edi],al
shr eax,8
mov byte [edi+1],al
shr eax,8
mov byte [edi+2],al
add edi,3
dec ecx
jnz lineout
 
@@quit:
pop ecx
pop ebx
pop eax
ret
 
scrbuf:
I_END:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/tube/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm tube.asm tube
@pause
/programs/demos/tube/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm tube.asm tube
@pause
/programs/demos/tube/trunk/macros.inc
0,0 → 1,266
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a { ; mike.dld
if ~a eq
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
; language for programs
lang fix ru ; ru en fr ge fi
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/tube/trunk/tube.asm
0,0 → 1,277
 
; (Ü) ( ) Ü ) ( ) 256b intro by baze/3SC for Syndeecate 2001 use NASM to
; ßÛß ÛÜÛ ÛÛÛ ÛÛÜ loveC: thanks, Serzh: eat my socks dude ;] compile the
; ( ) ( ) ( ) ( ) e-mail: baze@stonline.sk, web: www.3SC.sk source code
 
; Menuet port by VT
 
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x40000
dd 0x3ff00
dd 0,0
 
include 'macros.inc'
 
START:
 
call draw_window
 
call init_tube
 
push ebx
 
still:
 
pop ebx
 
call MAIN
 
push ebx
 
mov eax,23
mov ebx,1
int 0x40
 
cmp eax,1
jne no_red
call draw_window
jmp still
no_red:
 
cmp eax,0
je still
 
mov eax,-1
int 0x40
 
 
SCREEN equ 160
PIXBUF equ 200h
EYE equ EYE_P-2
 
 
MAIN:
 
add bh,10;8
mov edi,PIXBUF
fadd dword [di-PIXBUF+TEXUV-4]
push di
mov dx,-80
 
TUBEY:
 
mov bp,-160
 
TUBEX:
 
mov si,TEXUV
fild word [si-TEXUV+EYE]
mov [si],bp
fild word [si]
mov [si],dx
fild word [si]
mov cl,2
 
ROTATE:
 
fld st3
fsincos
fld st2
fmul st0,st1
fld st4
fmul st0,st3
db 0xde,0xe9 ; fsubp st1,st0
db 0xd9,0xcb ; fxch st3
fmulp st2,st0
fmulp st3,st0
faddp st2,st0
db 0xd9,0xca ; fxch st2
 
loop ROTATE
 
fld st1
db 0xdc,0xc8 ; fmul st0,st
fld st1
db 0xdc,0xc8 ; fmul st0,st
faddp st1,st0
fsqrt
db 0xde,0xfb ; fdivp st3,st0
fpatan
fimul word [si-4]
fistp word [si]
fimul word [si-4]
fistp word [si+1]
mov si,[si]
 
lea ax,[bx+si]
add al,ah
and al,64
mov al,-5
jz STORE_1
 
shl si,2
lea ax,[bx+si]
sub al,ah
mov al,-16
jns STORE_1
 
shl si,1
mov al,-48
 
STORE_1:
 
; add al,[ebx+esi+0x80000]
add [di],al
inc di
 
inc bp
cmp bp,160
 
EYE_P:
 
jnz TUBEX
inc dx
cmp dx,80
jnz TUBEY
 
call display_image
 
pop si
mov ch,SCREEN*320/256
 
BLUR:
 
inc si
sar byte [si],2
loop BLUR
 
ret
 
 
 
display_image:
 
pusha
 
mov esi,PIXBUF
mov edi,0x10000
newp:
movzx edx,byte [esi]
shl edx,4
; mov dh,dl
mov [edi],edx
 
add edi,3
inc esi
 
cmp esi,320*160+PIXBUF
jbe newp
 
mov eax,7
mov ecx,320*65536+160
mov edx,10*65536+27
mov ebx,0x10000
int 0x40
 
popa
ret
 
 
 
draw_window:
 
pusha
 
mov eax,12
mov ebx,1
int 0x40
 
mov eax,0
mov ebx,100*65536+339
mov ecx,100*65536+198
mov edx,0x03225588
mov esi,0x0
mov esi,0x0
int 0x40
 
mov eax,4
mov ebx,8*65536+8
mov ecx,0xffffff
mov edx,labeltext
mov esi,19
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
 
popa
ret
 
labeltext db 'TUBE.ASM - with FPU'
 
db 41,0,0xC3,0x3C
 
TEXUV:
 
init_tube:
 
mov ecx,256
 
PAL1:
 
mov dx,3C8h
mov ax,cx
inc dx
sar al,1
js PAL2
mul al
shr ax,6
 
PAL2:
 
mov al,0
jns PAL3
sub al,cl
shr al,1
shr al,1
 
PAL3:
 
mov bx,cx
mov [ebx+0x1000],bh
loop PAL1
mov ecx,256
 
TEX:
 
mov bx,cx
add ax,cx
rol ax,cl
mov dh,al
sar dh,5
adc dl,dh
adc dl,[ebx+255+0x1000]
shr dl,1
mov [ebx+0x1000],dl
not bh
mov [ebx+0x1000],dl
loop TEX
 
fninit
fldz
 
ret
 
 
I_END:
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property