View3ds 0.068: Editing option - new 'editor' button [by macgub]

git-svn-id: svn://kolibrios.org@6769 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-11-30 10:24:07 +00:00
parent 3d2f646747
commit c83f800bbe
9 changed files with 1060 additions and 530 deletions

View File

@ -28,6 +28,137 @@ make_vector:
ret ret
end if end if
reverse_mx_3x3:
; esi - source matrix
; edi - desired reversed matrix
push ebp
mov ebp,esp
sub esp,4
.det equ ebp-4
fninit
fld dword[esi]
fmul dword[esi+16]
fmul dword[esi+32]
fld dword[esi+12]
fmul dword[esi+28]
fmul dword[esi+8]
faddp
fld dword[esi+24]
fmul dword[esi+4]
fmul dword[esi+20]
faddp
fld dword[esi]
fmul dword[esi+28]
fmul dword[esi+20]
fchs
faddp
fld dword[esi+24]
fmul dword[esi+16]
fmul dword[esi+8]
fchs
faddp
fld dword[esi+12]
fmul dword[esi+4]
fmul dword[esi+32]
fchs
faddp
fstp dword[.det]
cmp dword[.det],0
jne @f
int3
@@:
; fld1
; fdiv dword[.det]
; fstp dword[.det]
fld dword[esi+16]
fmul dword[esi+32]
fld dword[esi+20]
fmul dword[esi+28]
fchs
faddp
fdiv dword[.det]
fstp dword[edi]
fld dword[esi+8]
fmul dword[esi+28]
fld dword[esi+4]
fmul dword[esi+32]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+4]
fld dword[esi+4]
fmul dword[esi+20]
fld dword[esi+8]
fmul dword[esi+16]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+8]
fld dword[esi+20]
fmul dword[esi+24]
fld dword[esi+12]
fmul dword[esi+32]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+12]
fld dword[esi]
fmul dword[esi+32]
fld dword[esi+8]
fmul dword[esi+24]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+16]
fld dword[esi+8]
fmul dword[esi+12]
fld dword[esi]
fmul dword[esi+20]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+20]
fld dword[esi+12]
fmul dword[esi+28]
fld dword[esi+16]
fmul dword[esi+24]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+24]
fld dword[esi+4]
fmul dword[esi+24]
fld dword[esi]
fmul dword[esi+28]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+28]
fld dword[esi]
fmul dword[esi+16]
fld dword[esi+4]
fmul dword[esi+12]
fchs
faddp
fdiv dword[.det]
fstp dword[edi+32]
mov esp,ebp
pop ebp
ret
make_vector_r: make_vector_r:
fninit fninit
fld dword[edi] ;edi+x3d fld dword[edi] ;edi+x3d
@ -211,7 +342,7 @@ make_rotation_matrix:
faddp faddp
fstp dword[edi+24] fstp dword[edi+24]
fld .siny fld .cosy
fmul .sinz fmul .sinz
fstp dword[edi+4] fstp dword[edi+4]
@ -377,6 +508,7 @@ ret
translate_points: ; just convert into integer; z coord still needed translate_points: ; just convert into integer; z coord still needed
fninit fninit
.again: .again:
if 0
fld dword[esi+8] fld dword[esi+8]
; fmul [rsscale] ; fmul [rsscale]
fist word[edi+4] fist word[edi+4]
@ -403,7 +535,19 @@ translate_points: ; just convert into integer; z coord still needed
fiadd [yobs] fiadd [yobs]
fiadd [vect_y] fiadd [vect_y]
fistp word[edi+2] fistp word[edi+2]
end if
; movups xmm0,[esi]
; cvtps2dq xmm0,xmm0
; packsdw xmm0,xmm0
; movq [edi]
fld dword[esi]
fiadd [vect_x]
fistp word[edi]
fld dword[esi+4]
fiadd [vect_y]
fistp word[edi+2]
fld dword[esi+8]
fistp word[edi+4]
add esi,12 add esi,12
add edi,6 add edi,6
dec ecx dec ecx

View File

@ -176,9 +176,9 @@ if Ext >= SSE2
punpcklbw xmm3,xmm0 punpcklbw xmm3,xmm0
punpcklbw xmm4,xmm0 punpcklbw xmm4,xmm0
psubsw xmm1,xmm2 psubsw xmm1,xmm2
paddw xmm1,[.bias] paddw xmm1,[emboss_bias]
psubsw xmm3,xmm4 psubsw xmm3,xmm4
paddw xmm3,[.bias] paddw xmm3,[emboss_bias]
pmulhw xmm1,xmm3 pmulhw xmm1,xmm3
movaps xmm7,xmm1 movaps xmm7,xmm1
movaps xmm6,xmm1 movaps xmm6,xmm1
@ -228,9 +228,9 @@ end if
end if end if
ret ret
align 16 ;align 16
.bias: ; emboss_bias:
dw 128, 128, 128, 128, 128, 128, 128, 128 ; dw 128, 128, 128, 128, 128, 128, 128, 128
if 0 ; old emb proc if 0 ; old emb proc

View File

@ -11,7 +11,7 @@
tex_y_div2 dw TEX_Y / 2 tex_y_div2 dw TEX_Y / 2
xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera
yobs dw 0 ;SIZE_Y / 2 ;200 ;coordinates yobs dw 0 ;SIZE_Y / 2 ;200 ;coordinates
zobs dw -500 zobs dw -1000
; size_x dw SIZE_X ; size_x dw SIZE_X
; size_y dw SIZE_Y ; size_y dw SIZE_Y
@ -38,8 +38,32 @@
XYZpartices: XYZpartices:
db 'X','Y','Z' db 'X','Y','Z'
i10 dw 10 i10 dw 10
draw_win_at_first db 1 offset_y:
i25 dw 25 ; screen buff offset
offset_x:
i5 dw 5
triangles_ptr dd 0
triangles_w_z_ptr dd 0
triangles_normals_ptr dd 0
points_normals_ptr dd 0
points_normals_rot_ptr dd 0
points_ptr dd 0
points_rotated_ptr dd 0
points_translated_ptr dd 0
screen_ptr dd 0
Zbuffer_ptr dd 0
vertices_index_ptr dd 0
; draw_win_at_first db 1
vertex_edit_no dw 0
edit_start_x:
dw 0
edit_start_y dw 0
edit_end_x:
dw 0
edit_end_y dw 0
mouse_state dd 0
menu: menu:
db 2 ; button number = index db 2 ; button number = index
db 'rotary ' ; label db 'rotary ' ; label
@ -179,6 +203,12 @@ dec_bright_flag db 0 ;1
sinus_flag db 0 sinus_flag db 0
dd onoff_f dd onoff_f
db 25
db 'editor '
db 2
edit_flag db 0
dd onoff_f
; db 24 ; db 24
; db 'max ' ; db 'max '
; db 2 ; db 2
@ -314,7 +344,7 @@ base_vector:
if Ext=SSE2 if Ext=SSE2
db ' (SSE2)' db ' (SSE2)'
end if end if
db ' 0.067',0 db ' 0.068',0
labellen: labellen:
STRdata db '-1 ' STRdata db '-1 '
@ -343,7 +373,7 @@ else
db '/rd/1/teapot.3ds',0 db '/rd/1/teapot.3ds',0
end if end if
I_END: ;I_END:
rb 256 rb 256
@ -390,7 +420,11 @@ lights:
;=============================================== ;===============================================
lightsend: lightsend:
align 16
emboss_bias:
dw 128, 128, 128, 128, 128, 128, 128, 128
I_END:
if USE_LFN = 0 if USE_LFN = 0
hash_table rb 4096 hash_table rb 4096
SourceFile: SourceFile:
@ -425,16 +459,20 @@ align 8
;== ;==
triangles_count_var dw ? triangles_count_var dw ?
points_count_var dw ? points_count_var dw ?
triangles_ptr dd ? ; triangles_ptr dd ?
triangles_w_z_ptr dd ? ; triangles_w_z_ptr dd ?
triangles_normals_ptr dd ? ; triangles_normals_ptr dd ?
points_normals_ptr dd ? ; points_normals_ptr dd ?
points_normals_rot_ptr dd ? ; points_normals_rot_ptr dd ?
points_ptr dd ? ; points_ptr dd ?
points_rotated_ptr dd ? ; points_rotated_ptr dd ?
points_translated_ptr dd ? ; points_translated_ptr dd ?
screen_ptr dd ? ; screen_ptr dd ?
Zbuffer_ptr dd ? ; Zbuffer_ptr dd ?
; vertices_index_ptr dd ?
; edit_start_x:
dw ? ; don't change order
; edit_start_y dw ?
; edges_ptr dd ? ; edges_ptr dd ?
size_y_var: size_y_var:
dw ? dw ?

View File

@ -77,7 +77,7 @@ end if
macro .draw_pixel macro .draw_pixel
{ {
mov [esi],ebx ; actualize Z buffer mov [esi],ebx ; actualize Z buffer
if Ext=SSE2 if Ext>=SSE2
movaps xmm7,xmm1 ;[.cb] ;;xmm1 movaps xmm7,xmm1 ;[.cb] ;;xmm1
shufps xmm7,xmm7,00111001b shufps xmm7,xmm7,00111001b
psrld xmm7,ROUND psrld xmm7,ROUND
@ -136,8 +136,10 @@ end if
jne .end_line jne .end_line
movzx edx,word [size_x_var] movzx edx,word [size_x_var]
mov [.xres],edx mov [.xres],edx
dec edx
movzx ecx,word [size_y_var] movzx ecx,word [size_y_var]
mov [.yres],ecx mov [.yres],ecx
dec ecx
cmp word[.x1],dx ;SIZE_X cmp word[.x1],dx ;SIZE_X
jg .end_line jg .end_line
cmp word[.x2],dx ;SIZE_X cmp word[.x2],dx ;SIZE_X
@ -209,7 +211,7 @@ end if
call .calc_delta call .calc_delta
movzx eax,word [size_x_var] ;SIZE_X mov eax,[.xres] ;SIZE_X
movsx ebx,word[.y1] movsx ebx,word[.y1]
mul ebx mul ebx
add esi,eax add esi,eax
@ -275,7 +277,7 @@ end if
call .calc_delta call .calc_delta
movzx eax,word[size_x_var] ;SIZE_X mov eax,[.xres] ;SIZE_X
movsx ebx,word[.y1] movsx ebx,word[.y1]
mul ebx mul ebx
add esi,eax add esi,eax

View File

@ -1,5 +1,8 @@
View3ds 0.067 - XI 2016
1. Sizable app window.
-----------------------------------------------------------------------------------
View 3ds 0,066 - X 2016 View3ds 0,066 - X 2016
1. App window size according to current screen resolution. 1. App window size according to current screen resolution.
2. New emboss procedure. 2. New emboss procedure.
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------

View File

@ -1,10 +1,10 @@
View3ds 0.067 - tiny viewer to .3ds and .asc files with several graphics View3ds 0.068 - tiny viewer to .3ds and .asc files with several graphics
effects implementation. effects implementation.
What's new? What's new?
1. Sizable app window. 1. Editing option - new 'editor' button.
2. For now I disable perspective correction, to make implemtation of editing option easier.
Buttons description: Buttons description:
1. rotary: choosing rotary axle: x, y, x+y. 1. rotary: choosing rotary axle: x, y, x+y.
@ -34,5 +34,9 @@ Buttons description:
19. bright + -> increase picture brightness. 19. bright + -> increase picture brightness.
20. bright - -> decrease picture brightness. 20. bright - -> decrease picture brightness.
21. wav effect -> do effect based sine function. 21. wav effect -> do effect based sine function.
22. editor -> setting editing option. If is "on" then red bars are draw according to each vertex, Pressing
and moving left mouse button (cursor must be on handler)- change vertex position. If left mouse button
is released apply current position. You may also decrease whole handlers count by enable culling (using
appropriate button) - some back handlers become hidden.
Maciej Guba XI 2016 Maciej Guba XI 2016

View File

@ -788,7 +788,9 @@ two_tex_line_z:
mov ecx,.y mov ecx,.y
or ecx,ecx or ecx,ecx
jl .bl_end jl .bl_end
cmp cx,word[size_y_var] ;SIZE_Y mov dx,word[size_y_var]
dec dx
cmp cx,dx ;word[size_y_var] ;SIZE_Y
jge .bl_end jge .bl_end
cmp eax,ebx cmp eax,ebx
@ -827,6 +829,7 @@ end if
push eax ebx ;store x1, x2 push eax ebx ;store x1, x2
mov ebx,.x1 mov ebx,.x1
movzx edx,word[size_x_var] movzx edx,word[size_x_var]
dec edx
cmp ebx,edx cmp ebx,edx
; cmp bx,word[size_x_var] ;SIZE_X ; cmp bx,word[size_x_var] ;SIZE_X
jg .bl_end jg .bl_end
@ -836,7 +839,7 @@ end if
mov ebx,.x2 mov ebx,.x2
sub ebx,.x1 sub ebx,.x1
if Ext>=SSE if Ext >= SSE
sub esp,16 sub esp,16
cvtsi2ss xmm3,ebx ;rcps cvtsi2ss xmm3,ebx ;rcps

View File

@ -1,5 +1,5 @@
; application : View3ds ver. 0.067 - tiny .3ds and .asc files viewer ; application : View3ds ver. 0.068 - tiny .3ds and .asc files viewer
; with a few graphics effects demonstration. ; with a few graphics effects demonstration.
; compiler : FASM ; compiler : FASM
; system : KolibriOS ; system : KolibriOS
@ -8,7 +8,7 @@
; web : www.macgub.hekko.pl ; web : www.macgub.hekko.pl
; Fell free to use this intro in your own distribution of KolibriOS. ; Fell free to use this intro in your own distribution of KolibriOS.
; Special greetings to KolibriOS team . ; Special greetings to KolibriOS team .
; I hope because my intros Christian Belive will be near to each of You. ; I hope because my demos Christian Belive will be near to each of You.
; Some adjustments made by Madis Kalme ; Some adjustments made by Madis Kalme
@ -57,7 +57,7 @@ START: ; start of execution
; mov eax,14 ; window size according to cur res ... ; mov eax,14 ; window size according to cur res ...
; int 0x40 ; int 0x40
; sub eax,150 shl 16 + 150 ; sub eax,150 shl 16 + 150
mov eax, 600 shl 16 + 600 ; ... or set manually mov eax, 500 shl 16 + 600 ; ... or set manually
mov [size_y_var],ax mov [size_y_var],ax
shr ax,1 shr ax,1
mov [vect_y],ax mov [vect_y],ax
@ -132,16 +132,33 @@ START: ; start of execution
call calc_bumpmap call calc_bumpmap
call calc_bumpmap_coords ; bump and texture mapping call calc_bumpmap_coords ; bump and texture mapping
call draw_window call draw_window
mov [draw_win_at_first],0 ; mov [draw_win_at_first],0
; mov eax,40 ; set events mask
; mov ebx,1100000000000000000000000100111b
; int 0x40
still: still:
cmp [edit_flag],1
jne @f
mov eax,40 ; set events mask
mov ebx,1100000000000000000000000100111b
jmp .int
@@:
mov eax,40 ; set events mask
mov ebx,111b
.int:
int 0x40
mov eax,23 ; wait here for event with timeout mov eax,23
mov ebx,TIMEOUT mov ebx,TIMEOUT
cmp [speed_flag],1 cmp [speed_flag],0
jne .skip je .skip
mov eax,11 mov eax,11
.skip: .skip:
cmp [edit_flag],1
jne @f
mov eax,10
@@:
int 0x40 int 0x40
cmp eax,1 ; redraw request ? cmp eax,1 ; redraw request ?
@ -150,7 +167,16 @@ still:
je key je key
cmp eax,3 ; button in buffer ? cmp eax,3 ; button in buffer ?
je button je button
cmp eax,6
jne @f
cmp [edit_flag],1
jne @f
mov eax,37
mov ebx,3 ;read mouse state
int 0x40
mov [mouse_state],eax
call edit
@@:
jmp noclose jmp noclose
red: ; redraw red: ; redraw
@ -216,7 +242,7 @@ still:
; ah = 5 -> scale- ; ah = 5 -> scale-
cmp ah,5 cmp ah,5
jne @f jne @f
mov [scale],0.7 mov dword[scale],0.7
fninit fninit
fld [rsscale] fld [rsscale]
fmul [scale] fmul [scale]
@ -225,7 +251,7 @@ still:
@@: @@:
cmp ah,6 ; ah = 6 -> scale+ cmp ah,6 ; ah = 6 -> scale+
jne @f jne @f
mov [scale],1.3 mov dword[scale],1.3
fninit fninit
fld [rsscale] fld [rsscale]
fmul [scale] fmul [scale]
@ -430,6 +456,8 @@ still:
noclose: noclose:
cmp [edit_flag],1
jz .end_rot
cmp [r_flag],2 cmp [r_flag],2
jne .no_x jne .no_x
inc [angle_x] inc [angle_x]
@ -516,6 +544,19 @@ still:
jmp .blurrr jmp .blurrr
@@: @@:
call draw_triangles ; draw all triangles from the list call draw_triangles ; draw all triangles from the list
cmp [edit_flag],0
jz .no_edit
call clear_vertices_index
call draw_handlers
; call edit
.no_edit:
.blurrr: .blurrr:
cmp [sinus_flag],0 cmp [sinus_flag],0
je @f je @f
@ -652,75 +693,7 @@ else
jnc .oop1 jnc .oop1
end if end if
.no_dec_bright: .no_dec_bright:
;======================================commmented====================
if 0
if Ext >= SSE
cmp [max_flag],0
je .no_max
;movzx ebx,[max_flag]
.again_max:
; push ecx
mov edi,screen
mov ecx,SIZE_X*3/4
; ; pxor mm5,mm5
xor eax,eax
rep stosd
mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
.calc_max:
@@:
movq mm0,[edi+SIZE_X*3]
movq mm1,[edi-SIZE_X*3]
movq mm2,[edi-3]
movq mm3,[edi+3]
pmaxub mm0,mm1
pmaxub mm2,mm3
pmaxub mm0,mm2
movq [edi],mm0
add edi,8
loop @b
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
end if
.no_max:
if Ext >= SSE
cmp [min_flag],0
je .no_min
; push ecx
mov edi,screen
mov ecx,SIZE_X*3/4
; ; pxor mm5,mm5
xor eax,eax
rep stosd
mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
@@:
movq mm0,[edi+SIZE_X*3]
movq mm1,[edi-SIZE_X*3]
movq mm2,[edi-3]
movq mm3,[edi+3]
pminub mm0,mm1
pminub mm2,mm3
pminub mm0,mm2
movq [edi],mm0
add edi,8
loop @b
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
end if
.no_min:
end if
RDTSC RDTSC
sub eax,[esp] sub eax,[esp]
@ -741,7 +714,7 @@ end if
mov ebx,[screen_ptr] mov ebx,[screen_ptr]
mov ecx,[size_y_var] mov ecx,[size_y_var]
; mov ecx,SIZE_X shl 16 + SIZE_Y ; mov ecx,SIZE_X shl 16 + SIZE_Y
mov edx,5 shl 16 + 25 mov edx,[offset_y] ;5 shl 16 + 25
int 0x40 int 0x40
mov eax,13 mov eax,13
@ -792,10 +765,184 @@ include "BUMP_TEX.INC"
include "GRD_TEX.INC" include "GRD_TEX.INC"
include "TWO_TEX.INC" include "TWO_TEX.INC"
include "ASC.INC" include "ASC.INC"
clear_vertices_index:
mov edi,[vertices_index_ptr]
movzx eax,word[size_x_var]
movzx ecx,word[size_y_var]
imul ecx,eax
xor eax,eax
shr ecx,1
rep stosd
ret
edit: ; mmx required, edit mesh by vertex
push ebp
mov ebp,esp
sub esp,128
.y_coord equ ebp-2
.x_coord equ ebp-4
.points_translated equ ebp-10
.points equ ebp-22
.points_rotated equ ebp-34
.mx equ ebp-70
macro check_bar
{
movzx ebx,word[.x_coord]
movzx ecx,word[.y_coord]
movzx edx,word[size_x_var]
imul edx,ecx
add ebx,edx
lea ecx,[ebx*2]
lea ebx,[ebx*3]
add ebx,[screen_ptr]
mov ebx,[ebx]
and ebx,0x00ffffff
cmp ebx,0x00ff0000 ; is handle bar ?
}
emms
mov eax,37 ; get mouse state
mov ebx,1 ; x = 5, y = 25 - offsets
int 0x40
mov ebx,[offset_y] ;5 shl 16 + 25
movd mm0,ebx
movd mm1,eax
movd mm3,[size_y_var]
pcmpgtw mm0,mm1
pcmpgtw mm3,mm1
pxor mm3,mm0
movd eax,mm3
mov cx,ax
shr eax,16
and ax,cx
or ax,ax
jz .no_edit
movd mm0,ebx
psubw mm1,mm0
movd eax,mm1
; store both x and y coordinates
ror eax,16
; push eax
; sub esp,256
mov [.x_coord],eax
test word[mouse_state],100000000b
jz .not_press ; check if left mouse button press
; left button pressed
; macro check_bar
; {
; movzx ebx,word[.x_coord]
; movzx ecx,word[.y_coord]
; imul ebx,ecx
; lea ecx,[ebx*2]
; lea ebx,[ebx*3]
; add ebx,[screen_ptr]
; mov ebx,[ebx]
; and ebx,0x00ffffff
; cmp ebx,0x00ff0000 ; is handle bar ?
; }
check_bar
jne .no_edit
add ecx,[vertices_index_ptr]
mov cx,word[ecx]
inc cx
mov [vertex_edit_no],cx ;if vert_edit_no = 0, no vertex selected
mov eax,dword[.x_coord]
mov dword[edit_end_x],eax
mov dword[edit_start_x],eax
jmp .end
.not_press:
test byte[mouse_state],1b ; check if left button is held
jz .not_held
; check_bar
; jne .no_edit
; add ecx,[vertices_index_ptr]
; mov cx,[ecx]
; inc cx
cmp [vertex_edit_no],0 ; cx ; vertex number
je .end
push dword[.x_coord]
pop dword[edit_end_x]
jmp .end
.not_held:
shr [mouse_state],16
test byte[mouse_state],1b ; test if left button released
jz .end
check_bar
jne .end
movzx esi,[vertex_edit_no]
dec esi
lea esi,[esi*3]
add esi,esi
add esi,[points_translated_ptr]
emms
movd mm1,dword[esi]
paddw mm1,mm0
psubw mm1,qword[vect_x]
movd dword[esi],mm1
lea edi,[.points]
; detranslate
fninit
fild word[esi+4]
fstp dword[edi+8]
fild word[esi+2]
fisub word[offset_x]
fstp dword[edi+4]
fild word[esi]
fisub word[offset_y] ; proteza
fstp dword[edi]
mov esi,matrix
lea edi,[.mx]
call reverse_mx_3x3
lea esi,[.points]
lea edi,[.points_rotated]
lea ebx,[.mx]
mov ecx,1
call rotary
; inject into vertex list
movzx edi,[vertex_edit_no]
dec edi
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
lea esi,[.points_rotated]
mov ecx,3
cld
rep movsd
mov dword[edit_end_x],0
mov [vertex_edit_no],0
.no_edit:
.end:
mov esp,ebp
pop ebp
ret
alloc_buffer_mem: alloc_buffer_mem:
push ebp
mov ebp,esp
.temp equ ebp-4
push dword 0
mov eax, 68 mov eax, 68
mov ebx, 11 mov ebx, 11
int 0x40 ; -> create heap, to be sure int 0x40 ; -> create heap, to be sure
@ -804,31 +951,43 @@ alloc_buffer_mem:
movzx ecx,word[size_x_var] movzx ecx,word[size_x_var]
movzx eax,word[size_y_var] movzx eax,word[size_y_var]
mul ecx mul ecx
; add eax,100
push eax mov [.temp],eax
lea ecx,[eax*3] lea ecx,[eax*3]
add ecx,256
mov eax,68 mov eax,68
mov ebx,20 mov ebx,20
mov edx,[screen_ptr] mov edx,[screen_ptr]
cmp [draw_win_at_first],1
jne @f
xor edx,edx
@@:
int 0x40 int 0x40
; and eax,0xfffffff0
mov [screen_ptr],eax mov [screen_ptr],eax
pop ecx mov ecx,[.temp]
shl ecx,2 shl ecx,2
add ecx,256
mov eax,68 mov eax,68
mov ebx,20 mov ebx,20
mov edx,[Zbuffer_ptr] mov edx,[Zbuffer_ptr]
cmp [draw_win_at_first],1
jne @f
xor edx,edx
@@:
int 0x40 int 0x40
; and eax,0xfffffff0
mov [Zbuffer_ptr],eax mov [Zbuffer_ptr],eax
mov ecx,[.temp]
add ecx,ecx
add ecx,256
mov eax,68
mov ebx,20
mov edx,[vertices_index_ptr]
int 0x40
; and eax,0xfffffff0
mov [vertices_index_ptr],eax
mov esp,ebp
pop ebp
if 0 if 0
;old Menuet style alloc ;old Menuet style alloc
movzx ecx,word[size_x_var] movzx ecx,word[size_x_var]
@ -1757,6 +1916,25 @@ ret
draw_triangles: draw_triangles:
emms
; update translated list MMX required
cmp [vertex_edit_no],0
je @f
movzx eax,[vertex_edit_no]
dec eax
movd mm0,[edit_end_x]
psubw mm0,[edit_start_x]
lea eax,[eax*3]
add eax,eax
add eax,[points_translated_ptr]
movd mm1,dword[eax]
paddw mm1,mm0
movd dword[eax],mm1
@@:
mov esi,[triangles_ptr] mov esi,[triangles_ptr]
mov [edges_counter],0 mov [edges_counter],0
.again_dts: .again_dts:
@ -1769,6 +1947,10 @@ draw_triangles:
push ebp push ebp
add ebp,eax add ebp,eax
mov eax,[ebp] mov eax,[ebp]
cmp [vertex_edit_no],0
jne @f
@@:
mov dword[xx1],eax mov dword[xx1],eax
mov eax,[ebp+4] mov eax,[ebp+4]
mov [zz1],ax mov [zz1],ax
@ -1823,6 +2005,44 @@ draw_triangles:
movq qword[xx3],mm2 movq qword[xx3],mm2
; emms ; emms
end if ; ********************************* end if ; *********************************
if 0
cmp [vertex_edit_no],0
jne .no_edit
mov ax,[vertex_edit_no]
dec ax
cmp ax,[point_index1]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx1]
paddw mm1,mm0
movd dword[xx1],mm1
jmp .no_edit
@@:
cmp ax,[point_index2]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx2]
paddw mm1,mm0
movd dword[xx2],mm1
jmp .no_edit
@@:
cmp ax,[point_index3]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx3]
paddw mm1,mm0
movd dword[xx3],mm1
jmp .no_edit
@@:
.no_edit:
end if
push esi ; push esi ;
fninit ; DO culling AT FIRST fninit ; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1) cmp [culling_flag],1 ; (if culling_flag = 1)
@ -2705,6 +2925,111 @@ draw_triangles:
ret ret
draw_handlers:
push ebp
mov ebp,esp
.counter equ ebp-16
.xres3m18 equ ebp-8
.xres2m12 equ ebp-12
; init counter
sub esp,12
push dword 0
movzx eax,word[size_x_var]
lea ebx,[eax*3]
sub ebx,18
add eax,eax
sub eax,12
mov [.xres3m18],ebx
mov [.xres2m12],eax
mov esi,[points_translated_ptr]
.loop:
push esi
; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling
mov edi,[.counter] ; *********************************
lea edi,[edi*3]
shl edi,2
add edi,[points_normals_rot_ptr]
mov eax,[edi+8] ; check sign of z coof
shr eax,31
cmp eax,1
jnz .skip
.no_culling:
mov eax,[esi]
movzx ebx,ax ; ebx - x
shr eax,16 ; eax - y
cmp eax,4 ; check if markers not exceedes screen
jle .skip
cmp ebx,4
jle .skip
movzx edx,word[size_x_var]
sub edx,4
movzx ecx,word[size_y_var]
sub ecx,4
cmp ebx,edx
jge .skip
cmp eax,ecx
jge .skip
movzx edx,word[size_x_var]
; sub ebx,3
; sub eax,3
imul eax,edx
add eax,ebx
lea edi,[eax*3]
lea eax,[eax*2]
; draw bar 6x6
add edi,[screen_ptr]
add eax,dword[vertices_index_ptr]
mov edx,[.counter]
mov ecx,6
.oop:
push ecx
mov ecx,6
@@:
mov word[edi],0x0000 ;ax
mov byte[edi+2],0xff ;al
mov word[eax],dx
add eax,2
add edi,3
loop @b
add edi,[.xres3m18]
add eax,[.xres2m12]
pop ecx
loop .oop
.skip:
pop esi
add esi,6
inc dword[.counter]
mov ecx,[.counter]
cmp cx,[points_count_var]
jng .loop
mov esp,ebp
pop ebp
ret
fill_Z_buffer: fill_Z_buffer:
mov eax,0x70000000 mov eax,0x70000000
mov edi,[Zbuffer_ptr] mov edi,[Zbuffer_ptr]
@ -2900,11 +3225,11 @@ read_from_file:
@@: @@:
push edi push edi
mov edi,[points_ptr] mov edi,[points_ptr]
push dword[esi+4]
pop dword[edi+ebx*2+0]
push dword[esi+8]
pop dword[edi+ebx*2+4]
push dword[esi+0] push dword[esi+0]
pop dword[edi+ebx*2+0]
push dword[esi+4]
pop dword[edi+ebx*2+4]
push dword[esi+8]
pop dword[edi+ebx*2+8] pop dword[edi+ebx*2+8]
pop edi pop edi
; fld dword[esi+4] ; fld dword[esi+4]
@ -3001,6 +3326,13 @@ alloc_mem_for_tp:
int 0x40 ; -> allocate memory for triangles normals int 0x40 ; -> allocate memory for triangles normals
mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem
; mov eax, 68
; movzx ecx,[points_count_var]
; lea ecx,[2+ecx*2]
; mov edx,dword [vertices_index_ptr]
; int 0x40
; mov dword[vertices_index_ptr], eax
mov eax, 68 mov eax, 68
movzx ecx, [points_count_var] movzx ecx, [points_count_var]
lea ecx,[3+ecx*3] lea ecx,[3+ecx*3]
@ -3008,6 +3340,11 @@ alloc_mem_for_tp:
mov edx,[points_normals_ptr] mov edx,[points_normals_ptr]
int 0x40 int 0x40
mov [points_normals_ptr], eax mov [points_normals_ptr], eax
; int3
; int3
mov eax, 68 mov eax, 68
; mov ebx, 12 ; mov ebx, 12
@ -3067,7 +3404,6 @@ if USE_LFN
int 0x40 ; -> read file int 0x40 ; -> read file
mov [fsize],ebx mov [fsize],ebx
cmp eax,6 cmp eax,6
jnz @f jnz @f
xor eax,eax ;;;;--- xor eax,eax ;;;;---
@ -3081,6 +3417,9 @@ else
shr eax,9 shr eax,9
inc eax inc eax
mov [fsize],eax mov [fsize],eax
; mov ecx,ebx ; mov ecx,ebx
; add ecx,MEM_END ; add ecx,MEM_END
; mov ebx,1 ; mov ebx,1
@ -3192,7 +3531,7 @@ ret
call buttons ; more buttons call buttons ; more buttons
.Y_ADD equ 1 ;-> offset of 'add vector' buttons .Y_ADD equ 2 ;-> offset of 'add vector' buttons
; ADD VECTOR LABEL ; add vector buttons - 30 ++ ; ADD VECTOR LABEL ; add vector buttons - 30 ++
mov eax,4 ; function 4 : write text to window mov eax,4 ; function 4 : write text to window

View File

@ -337,12 +337,9 @@ proc get_font_size, color:dword ; x86 calling convention uses eax ecx edx
ret ret
endp endp
CODE_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë; ---------------------------------------------------------------------------- ;
; ---------------------------------------------------------------------------- ;
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;--- „€<E2809E><E282AC><20><>Žƒ<C5BD>€ŒŒ ---------------------------------------------- ;--- „€<E2809E><E282AC><20><>Žƒ<C5BD>€ŒŒ ----------------------------------------------
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
proc_info rd 1024 proc_info rd 1024
DATA_END: ; ¬¥âª  ª®­æ  ¤ ­­ëå ¯à®£à ¬¬ë; ---------------------------------------------------------------------------- ;