1,12 → 1,13 |
|
; application : View3ds ver. 0.065 - tiny .3ds and .asc files viewer. |
; application : View3ds ver. 0.066 - tiny .3ds and .asc files viewer |
; with a few graphics effects demonstration. |
; compiler : FASM |
; system : KolibriOS |
; author : Macgub aka Maciej Guba |
; email : macgub3@wp.pl |
; web : www.macgub.hekko.pl |
; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS. |
; Special greetings to all MenuetOS maniax in the world. |
; Fell free to use this intro in your own distribution of KolibriOS. |
; Special greetings to KolibriOS team . |
; I hope because my intros Christian Belive will be near to each of You. |
|
|
16,8 → 17,8 |
; can be: |
; 1) Read from a file (*.3DS standard) |
; 2) Written in manually (at the end of the code) |
;include 'proc32.inc' |
|
|
SIZE_X equ 512 |
SIZE_Y equ 512 ; ///// I want definitely |
TIMEOUT equ 10 ; ------ say: |
53,6 → 54,27 |
|
START: ; start of execution |
cld |
mov eax,14 |
int 0x40 |
sub eax,150 shl 16 + 150 |
mov [size_y_var],ax |
shr ax,1 |
mov [vect_y],ax |
|
shr ax,1 |
movzx ebx,ax |
push ebx |
fninit |
fild dword[esp] |
fstp [rsscale] |
pop ebx |
|
shr eax,16 |
mov [size_x_var],ax |
shr ax,1 |
mov [vect_x],ax |
|
|
call alloc_buffer_mem |
call read_param |
call read_from_disk ; read, if all is ok eax = 0 |
493,8 → 515,11 |
je .no_inc_bright |
movzx ebx,[inc_bright_flag] |
shl ebx,4 |
mov esi,screen |
mov ecx,SIZE_X*SIZE_Y*3 |
mov esi,[screen_ptr] |
movzx ecx,word[size_y_var] |
movzx eax,word[size_x_var] |
mul ecx |
lea ecx,[eax*3] |
if (Ext = MMX)|(Ext = SSE) |
mov bh,bl |
push bx |
538,7 → 563,7 |
movaps [esi],xmm1 |
add esi,16 |
sub ecx,16 |
jnz .oop |
jnc .oop |
end if |
|
.no_inc_bright: |
548,8 → 573,11 |
je .no_dec_bright |
movzx ebx,[dec_bright_flag] |
shl ebx,4 |
mov esi,screen |
mov ecx,SIZE_X*SIZE_Y*3 |
mov esi,[screen_ptr] |
movzx eax,word[size_x_var] |
movzx ecx,word[size_y_var] |
mul ecx |
lea ecx,[eax*3] |
if (Ext = MMX)|(Ext = SSE) |
mov bh,bl |
push bx |
590,7 → 618,7 |
movaps [esi],xmm1 |
add esi,16 |
sub ecx,16 |
jnz .oop1 |
jnc .oop1 |
end if |
.no_dec_bright: |
;======================================commmented==================== |
680,18 → 708,29 |
|
mov eax,7 ; put image |
mov ebx,screen |
mov ecx,SIZE_X shl 16 + SIZE_Y |
mov ecx,[size_y_var] |
; mov ecx,SIZE_X shl 16 + SIZE_Y |
mov edx,5 shl 16 + 25 |
int 0x40 |
|
mov eax,13 |
mov ebx,530*65536+60 |
mov ecx,510*65536+9 |
mov bx,[size_x_var] |
add ebx,18 |
shl ebx,16 |
mov bx,60 |
mov cx,[size_y_var] |
sub cx,2 |
shl ecx,16 |
mov cx,9 |
xor edx,edx |
int 40h |
|
mov eax,4 ; function 4 : write text to window |
mov ebx,530*65536+510 ; [x start] *65536 + [y start] |
mov bx,[size_x_var] |
add ebx,18 |
shl ebx,16 |
mov bx,[size_y_var] |
sub bx,2 ; [x start] *65536 + [y start] |
mov ecx,0x00888888 |
mov edx,STRdata ; pointer to text beginning |
mov esi,10 ; text length |
726,10 → 765,12 |
|
|
alloc_buffer_mem: |
movzx ecx,[size_x] |
movzx eax,[size_y] |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
mul ecx |
lea ecx,[eax*3] |
add ecx,16 |
and ecx,0xfffffff0 |
push ecx |
shl eax,2 |
add ecx,eax |
778,7 → 819,9 |
add ecx,28 |
shl ecx,16 |
add ecx,14 ; ecx = [coord y]*65536 + [size y] |
mov ebx,(SIZE_X+12+70)*65536+25 ; [x start] *65536 + [size x] |
mov bx,[size_x_var] |
shl ebx,16 |
add ebx,(12+70)*65536+25 ; [x start] *65536 + [size x] |
mov edx,0x00000000 ; color 0x00RRGGBB |
int 0x40 |
|
787,7 → 830,10 |
sub bl,2 |
lea ebx,[ebx*3] |
lea ebx,[ebx*5] |
add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
mov cx,[size_x_var] |
shl ecx,16 |
add ebx,ecx |
add ebx,(12+70)*65536+28 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
movzx edx,byte[edi+12] ; current flag |
shl edx,2 ; * 4 = text length |
1603,11 → 1649,15 |
|
clrscr: |
mov edi,screen |
mov ecx,SIZE_X*SIZE_Y*3/4 |
movzx ecx,word[size_x_var] |
movzx eax,word[size_y_var] |
imul ecx,eax |
lea ecx,[ecx*3] |
shr ecx,2 |
xor eax,eax |
if Ext=NON |
rep stosd |
else |
else if Ext = MMX |
pxor mm0,mm0 |
@@: |
movq [edi+00],mm0 |
1617,7 → 1667,24 |
add edi,32 |
sub ecx,8 |
jnc @b |
else |
push ecx |
mov ecx,edi |
and ecx,0x0000000f |
rep stosb |
pop ecx |
and ecx,0xfffffff0 |
xorps xmm0,xmm0 |
@@: |
movaps [edi],xmm0 |
movaps [edi+16],xmm0 |
movaps [edi+32],xmm0 |
movaps [edi+48],xmm0 |
add edi,64 |
sub ecx,16 |
jnz @b |
end if |
|
ret |
|
|
2044,7 → 2111,7 |
ror ebx,16 |
mov ecx,dword[xx3] |
ror ecx,16 |
mov edi,screen |
mov edi,[screen_ptr] |
mov esi,envmap_cub |
cmp [catmull_flag],0 |
je @f |
2572,10 → 2639,32 |
|
fill_Z_buffer: |
mov eax,0x70000000 |
; mov edi,Z_buffer |
mov edi,[Zbuffer_ptr] |
mov ecx,SIZE_X*SIZE_Y |
movzx ecx,word[size_x_var] |
movzx ebx,word[size_y_var] |
imul ecx,ebx |
if Ext>=SSE2 |
movd xmm0,eax |
shufps xmm0,xmm0,0 |
push ecx |
mov ecx,edi |
and edi,0xffffff00 |
and ecx,0x000000ff |
mov edx,ecx |
rep stosd |
pop ecx |
sub ecx,edx |
@@: |
movaps [edi],xmm0 |
movaps [edi+16],xmm0 |
movaps [edi+32],xmm0 |
movaps [edi+48],xmm0 |
add edi,64 |
sub ecx,16 |
jnc @b |
else |
rep stosd |
end if |
ret |
|
read_tp_variables: ; read [triangles_count_var] and [points_count_var] |
2959,7 → 3048,9 |
mov edi,menu |
.again: |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
mov bx,[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+62 ; [x start] *65536 + [x size] |
movzx ecx,byte[edi] ; button id = position+2 |
sub cl,2 |
lea ecx,[ecx*5] |
2976,7 → 3067,10 |
sub bl,2 ; button id, according to position |
lea ebx,[ebx*3] |
lea ebx,[ebx*5] |
add ebx,(SIZE_X+12)*65536+28 ; [x start] *65536 + [y start] |
mov cx,[size_x_var] |
shl ecx,16 |
add ebx,ecx |
add ebx,(12)*65536+28 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
lea edx,[edi+1] ; pointer to text beginning |
mov esi,10 ; text length |
3013,11 → 3107,11 |
|
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] |
mov ecx,100*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] |
mov bx,[size_x] |
mov ebx,50*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] |
mov ecx,50*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] |
mov bx,[size_x_var] |
add bx,115 |
mov cx,[size_y] |
mov cx,[size_y_var] |
add cx,30 |
mov edx,0x14000000 ; color of work area RRGGBB,8->color gl |
mov edi,labelt ; WINDOW LABEL |
3029,7 → 3123,9 |
|
; ADD VECTOR LABEL ; add vector buttons - 30 ++ |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelvector ; pointer to text beginning |
mov esi,labelvectorend-labelvector ; text length |
3040,7 → 3136,9 |
int 0x40 |
; VECTOR Y- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+30)*65536+20 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,30*65536+20 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,30 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3047,7 → 3145,9 |
int 0x40 |
;VECTOR Y- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelyminus ; pointer to text beginning |
mov esi,labelyminusend-labelyminus ; text length |
3058,7 → 3158,9 |
int 0x40 |
; VECTOR Z+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,31 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3065,7 → 3167,9 |
int 0x40 |
;VECTOR Z+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelzplus ; pointer to text beginning |
mov esi,labelzplusend-labelzplus ; text length |
3077,7 → 3181,9 |
int 0x40 |
; VECTOR x- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,32 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3084,7 → 3190,9 |
int 0x40 |
;VECTOR x- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelxminus ; pointer to text beginning |
mov esi,labelxminusend-labelxminus ; text length |
3095,7 → 3203,9 |
int 0x40 |
; VECTOR x+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,33 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3102,7 → 3212,9 |
int 0x40 |
;VECTOR x+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelxplus ; pointer to text beginning |
mov esi,labelxplusend-labelxplus ; text length |
3113,7 → 3225,9 |
int 0x40 |
; VECTOR z- BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10)*65536+62-41 ; [x start] *65536 + [x size] |
mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,34 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3120,7 → 3234,9 |
int 0x40 |
;VECTOR z- LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelzminus ; pointer to text beginning |
mov esi,labelzminusend-labelzminus ; text length |
3131,7 → 3247,9 |
int 0x40 |
;VECTOR Y+ BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(SIZE_X+10+20)*65536+20 ; [x start] *65536 + [x size] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(10+20)*65536+20 ; [x start] *65536 + [x size] |
mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
mov edx,35 ; button id |
mov esi,0x6688dd ; button color RRGGBB |
3138,7 → 3256,9 |
int 0x40 |
;VECTOR Y+ LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,(SIZE_X+32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
movzx ebx,word[size_x_var] |
shl ebx,16 |
add ebx,(32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
mov edx,labelyplus ; pointer to text beginning |
mov esi,labelyplusend-labelyplus ; text length |
3157,5 → 3277,5 |
; DATA AREA ************************************ |
|
include 'DATA.INC' |
|
align 16 |
MEM_END: |