Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 108 → Rev 109

/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