'buf2d.obj' new function and 2 examples

git-svn-id: svn://kolibrios.org@2815 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2012-06-21 11:32:18 +00:00
parent 8de57a728f
commit 56de4bac0f
6 changed files with 745 additions and 98 deletions

View File

@ -54,6 +54,7 @@ table { font-size: 15px; }
<ul>
<li><a href="#f_init">lib_init</a></li>
<li><a href="#f_b_create">buf2d_create</a></li>
<li><a href="#f_c_color">buf2d_crop_color</a></li>
<li><a href="#f_v_brush_c">buf2d_vox_brush_create</a></li>
</ul>
</li>
@ -70,7 +71,7 @@ table { font-size: 15px; }
Есть функции рисования линий, кривых Безье, прямоугольников, окружностей.
Также есть функции для рисований воксельной графики.</p>
<p>Последнее обновление библиотеки 12.06.12.</p>
<p>Последнее обновление библиотеки 21.06.12.</p>
<h1><a name="format_buf">Форматы буферов</a></h1>
<p>Поддерживается 3 формата буферов.
@ -203,16 +204,16 @@ stdcall [buf2d_convert_text_matrix], buf_1</pre>
<h4>buf2d_draw_text</h4>
<p>Рисует текст в буфере, используя матрицу с текстом размером 1*256 символов. Пример:</p>
<pre>stdcall [buf2d_draw_text], buf_0, buf_1,some_text,20,10,0x4040ff ;рисуем строку с текстом</pre>
<p>где buf_0 - структура буфера в котором будет рисоваться текст;
buf_1 - структура буфера с текстовой матрицей в формате 8 бит, размером 1*256 символов;
some_text - текст, который будет выведен в буфер buf_0.</p>
<p>где buf_0 - структура буфера в котором будет рисоваться текст;</p>
<p>buf_1 - структура буфера с текстовой матрицей в формате 8 бит, размером 1*256 символов;</p>
<p>some_text - текст, который будет выведен в буфер buf_0.</p>
<h4>buf2d_crop_color</h4>
<h4><a name="f_c_color">buf2d_crop_color</a></h4>
<p>Обрезание буфера, по указанному цвету. Функция используется для уменьшения памяти, занимаемой буфером. Отрезаются крайние части буфера имеющие одинаковый цвет. Пример:</p>
<pre>stdcall [buf2d_crop_color], buf_0,0xffffff,BUF2D_OPT_CROP_TOP+BUF2D_OPT_CROP_BOTTOM</pre>
<p>где buf_0 - структура буфера который будет обрезан;
0xffffff - цвет по которому будет обрезаться буфер;
BUF2D_OPT_CROP_TOP и BUF2D_OPT_CROP_BOTTOM - константы, указывающие с каких сторон обрезать буфер.</p>
<p>где buf_0 - структура буфера который будет обрезан;</p>
<p>0xffffff - цвет по которому будет обрезаться буфер;</p>
<p>BUF2D_OPT_CROP_TOP и BUF2D_OPT_CROP_BOTTOM - константы, указывающие с каких сторон обрезать буфер.</p>
<h4>buf2d_offset_h</h4>
<p>Сдвиг изображения в буфере по высоте вверх или вниз.</p>
@ -220,11 +221,11 @@ stdcall [buf2d_convert_text_matrix], buf_1</pre>
<h4>buf2d_flood_fill</h4>
<p>Функция для рекурсивной заливки выбранным цветом. Имеется два варианта заливки. Пример:</p>
<pre>stdcall [buf2d_flood_fill], buf_0, 100,200, 0, 0xff,0xff0000</pre>
<p>где buf_0 - структура буфера;
100,200 - координаты точки, с которой начнется заливка;
0 - параметр, определяет алгоритм заливки (может быть 0 или 1);
0xff - цвет заливки;</p>
0xff0000 - зависит от значения 4-го параметра, 1) если 0 - цвет до которого будет заливаться область; 2) если 1 - цвет области которая будет заливатся;</p>
<p>где buf_0 - структура буфера;</p>
<p>100,200 - координаты точки, с которой начнется заливка;</p>
<p>0 - параметр, определяет алгоритм заливки (может быть 0 или 1);</p>
<p>0xff - цвет заливки;</p>
<p>0xff0000 - зависит от значения 4-го параметра, 1) если 0 - цвет до которого будет заливаться область; 2) если 1 - цвет области которая будет заливатся;</p>
<h4>buf2d_set_pixel</h4>
<p>Функция ставит точку, принимает координаты и цвет.</p>
@ -246,6 +247,9 @@ stdcall [buf2d_convert_text_matrix], buf_1</pre>
<h4>buf2d_vox_brush_delete</h4>
<p>Удаление воксельной кисти.</p>
<h4>buf2d_vox_obj_draw_1g</h4>
<p>Рисование воксельного объекта с 1-й гранью.</p>
<h4>buf2d_vox_obj_get_img_w_3g</h4>
<p>Возврашает ширину воксельного изображения с 3-мя гранями (которое рисуется функцией <b>buf2d_vox_obj_draw_3g</b>), принимает указатель на кисть и масштаб.</p>
@ -269,13 +273,13 @@ stdcall [buf2d_convert_text_matrix], buf_1</pre>
<h1><a name="const">Константы</a></h1>
<h4>BUF2D_OPT_CROP_TOP equ 1</h4>
<p>Константа для функции buf2d_crop_color, обозначает обрезку буфера сверху</p>
<p>Константа для функции <a href="#f_c_color">buf2d_crop_color</a>, обозначает обрезку буфера сверху</p>
<h4>BUF2D_OPT_CROP_LEFT equ 2</h4>
<p>Константа для функции buf2d_crop_color, обозначает обрезку буфера слева</p>
<p>Константа для функции <a href="#f_c_color">buf2d_crop_color</a>, обозначает обрезку буфера слева</p>
<h4>BUF2D_OPT_CROP_BOTTOM equ 4</h4>
<p>Константа для функции buf2d_crop_color, обозначает обрезку буфера снизу</p>
<p>Константа для функции <a href="#f_c_color">buf2d_crop_color</a>, обозначает обрезку буфера снизу</p>
<h4>BUF2D_OPT_CROP_RIGHT equ 8</h4>
<p>Константа для функции buf2d_crop_color, обозначает обрезку буфера справа</p>
<p>Константа для функции <a href="#f_c_color">buf2d_crop_color</a>, обозначает обрезку буфера справа</p>
<h1><a name="tabl_e">Таблица экспорта</a></h1>
<p>Пример таблицы экспорта, расчитанной на использование макроса <b>@use_library_mem</b>:</p>
@ -312,6 +316,7 @@ import_buf2d_lib:
;воксельные функции:
buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
@ -352,6 +357,7 @@ import_buf2d_lib:
;воксельные функции:
sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0

View File

@ -2986,7 +2986,169 @@ proc buf_vox_obj_get_img_h_3g uses ecx, h_br:dword,k_scale:dword
endp
;description:
; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ
; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ (¢¨¤­  1 £à ­ì)
;input:
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
align 4
proc buf_vox_obj_draw_1g, buf_i:dword, buf_z:dword, v_obj:dword, coord_x:dword,\
coord_y:dword, k_scale:dword
cmp [k_scale],0
jl .end_f
pushad
mov edi,[buf_i]
cmp buf2d_bits,24
jne .error1
mov edi,[buf_z]
cmp buf2d_bits,32
jne .error2
mov ecx,[k_scale]
mov ebx,[coord_x]
mov edx,[coord_y]
mov edi,[v_obj]
add edi,vox_offs_data
xor esi,esi
stdcall draw_sub_vox_obj_1g, [buf_i],[buf_z],[v_obj]
jmp .end_0
.error1:
stdcall print_err,sz_buf2d_vox_obj_draw_1g,txt_err_n24b
jmp .end_0
.error2:
stdcall print_err,sz_buf2d_vox_obj_draw_1g,txt_err_n32b
.end_0:
popad
.end_f:
ret
endp
;input:
; ebx - coord_x
; edx - coord_y
; esi - coord_z
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
; edi - 㪠§ â¥«ì ­  ¤ ­­ë¥ ¢®ªá¥«ì­®£® ®¡ê¥ªâ 
align 4
proc draw_sub_vox_obj_1g, buf_i:dword, buf_z:dword, v_obj:dword
cmp byte[edi+3],0 ;ᬮâਬ ¥áâì «¨ ¯®¤¤¥à¥¢ìï
je .sub_trees
;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
cmp ecx,0
jne @f
;¯à®¢¥àª  £«ã¡¨­ë esi
stdcall buf_get_pixel, [buf_z], ebx,edx, esi
cmp eax,esi
jge @f
push ecx
mov ecx,dword[edi]
and ecx,0xffffff
stdcall buf_set_pixel, [buf_i], ebx,edx, ecx
stdcall buf_set_pixel, [buf_z], ebx,edx, esi
pop ecx
@@:
;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
push edx
;¢å®¤ ¢­ãâàì 㧫 
dec ecx
mov eax,1
cmp ecx,1
jl @f
shl eax,cl
@@:
add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
mov ah,byte[edi+3]
add edi,4
mov al,8
.cycle:
bt ax,8 ;â¥áâ¨à㥬 ⮫쪮 ah
jnc .c_next
push eax ebx edx esi
stdcall vox_corect_coords_pl, [v_obj],1
stdcall draw_sub_vox_obj_1g, [buf_i],[buf_z],[v_obj]
pop esi edx ebx eax
.c_next:
shr ah,1
dec al
jnz .cycle
;¢ë室 ¨§ 㧫 
inc ecx
pop edx
jmp .end_f
.sub_trees:
cmp ecx,0
jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
;à¨á㥬 㧥«
mov eax,[edi]
and eax,0xffffff
cmp ecx,1
jl @f
;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
stdcall vox_draw_square_1g, [buf_i],[buf_z],eax
jmp .end_0
@@:
;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
push ecx
mov ecx,eax
stdcall buf_get_pixel, [buf_z], ebx,edx
cmp eax,esi
jge .end_1
stdcall buf_set_pixel, [buf_i], ebx,edx,ecx
stdcall buf_set_pixel, [buf_z], ebx,edx,esi
.end_1:
pop ecx
.end_0:
add edi,4
.end_f:
ret
endp
;output:
; eax - à §àãè ¥âáï
align 4
proc vox_draw_square_1g uses ecx edx edi, buf_i:dword, buf_z:dword, color:dword
locals
img_size dd ?
coord_y dd ?
endl
mov edi,[buf_z]
xor eax,eax
inc eax
shl eax,cl
mov [img_size],eax
mov [coord_y],eax
.cycle_0:
push ebx
mov ecx,[img_size]
cld
.cycle_1:
push ecx
mov ecx,edx
call get_pixel_32
pop ecx
cmp eax,esi
jge @f
stdcall buf_set_pixel, [buf_i], ebx,edx, [color]
stdcall buf_set_pixel, edi, ebx,edx, esi
@@:
inc ebx
loop .cycle_1
pop ebx
inc edx
dec dword[coord_y]
jnz .cycle_0
ret
endp
;description:
; äã­ªæ¨ï à¨áãîé ï ¢®ªá¥«ì­ë© ®¡ê¥ªâ (¢¨¤­® 3 £à ­¨)
;input:
; buf_i - ¡ãä¥à ¢ ª®â®à®¬ à¨áã¥âáï (24 ¡¨â )
; buf_z - ¡ãä¥à £«ã¡¨­ë (32 ¡¨â  ¯® ç¨á«ã ¯¨ªá¥«¥© ¤®«¦¥­ ᮢ¯ ¤ âì á buf_i)
@ -3000,27 +3162,10 @@ pushad
mov edi,[v_obj]
mov ecx,[k_scale]
mov ebx,[coord_x]
;---
;â¥á⮢ ï à ¬ª 
mov eax,[h_br]
movzx edx,byte[eax]
movzx esi,byte[eax+1]
cmp ecx,1
jl .end_c0
shl edx,cl
shl esi,cl
.end_c0:
stdcall buf_rect_by_size, [buf_i], ebx,[coord_y],edx,esi, 0xd0d0d0
;---
mov edx,[coord_y]
add edi,vox_offs_data
mov esi,[coord_z]
stdcall vox_go_in_node, [buf_i], [buf_z], [h_br], [v_obj]
popad
ret
endp
@ -3425,15 +3570,18 @@ pushad
pop ecx
;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
;edi - 㪠§ â¥«ì à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
;edi - 㪠§ â¥«ì ­  à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
mov ebx,[coord_x]
mov edx,[coord_y]
mov edi,[v_obj]
add edi,vox_offs_data
xor esi,esi
push eax
imul eax,[n_plane]
stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
mov eax,1
shl eax,cl
dec eax
sub eax,[n_plane]
stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj],eax
popad
.end_f:
ret
@ -3531,13 +3679,16 @@ endl
mov eax,[v_size]
;eax - à §¬¥à ®¤­®£® ª¢ ¤à â 
;edi - 㪠§ â¥«ì à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
;edi - 㪠§ â¥«ì ­  à¨áã¥¬ë¥ ¤ ­­ë¥ ¨§ ®¡ê¥ªâ 
mov ecx,[k_scale]
mov ebx,[coord_x]
mov edx,[coord_y]
xor esi,esi
push eax
imul eax,[n_plane]
mov eax,1
shl eax,cl
dec eax
sub eax,[n_plane]
stdcall draw_sub_vox_obj_pl, [buf_i],[v_obj], eax
.end_2:
@ -3651,21 +3802,20 @@ v_size:dword
;¯à®à¨á®¢ª  à ¬ª¨ ¥á«¨ à §¬¥à 㧫  = 1
cmp ecx,0
jne @f
;¯à®¢¥àª  £«ã¡¨­ë esi
;clip_z=n_plane*v_size
stdcall vox_is_clip, [clip_z],[v_size]
cmp eax,0
je @f
push ecx
mov ecx,dword[edi]
and ecx,0xffffff
stdcall buf_rect_by_size, [buf_i], ebx,edx, [v_size],[v_size],ecx
pop ecx
;¯à®¢¥àª  £«ã¡¨­ë esi
;clip_z=n_plane
stdcall vox_is_clip, [clip_z];,[v_size]
cmp eax,0
je @f
push ecx
mov ecx,dword[edi]
and ecx,0xffffff
stdcall buf_rect_by_size, [buf_i], ebx,edx, [v_size],[v_size],ecx
pop ecx
@@:
;४ãàᨢ­ë© ¯¥à¥¡®à ¯®¤¤¥à¥¢ì¥¢
push edx
;¢å®¤ ¢­ãâàì 㧫 
dec ecx
@ -3674,6 +3824,7 @@ v_size:dword
jl @f
shl eax,cl
@@:
add edx,eax ;ª®à¥ªâ¨à®¢ª  ¢ëá®âë ¯®¤ ¢®ªá¥«ì ­¨¦­¥£® ã஢­ï
mov ah,byte[edi+3]
@ -3690,49 +3841,46 @@ v_size:dword
shr ah,1
dec al
jnz .cycle
;¢ë室 ¨§ 㧫 
inc ecx
pop edx
jmp .end_f
.sub_trees:
cmp ecx,0
jl .end_0 ;­¥ à¨á㥬 ®ç¥­ì ¬ «¥­ìª¨¥ ¢®ªá¥«¨
;¯à®¢¥àª  £«ã¡¨­ë esi
;clip_z=n_plane*v_size
stdcall vox_is_clip, [clip_z],[v_size]
cmp eax,0
je .end_0
;¯à®¢¥àª  £«ã¡¨­ë esi
;clip_z=n_plane
stdcall vox_is_clip, [clip_z]
cmp eax,0
je .end_0
;à¨á㥬 㧥«
mov eax,[edi]
and eax,0xffffff
push eax ;梥â 㧫 
mov eax,[v_size]
cmp ecx,1
jl @f
;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
shl eax,cl ;à §¬¥à 㧫 
stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
push ebx edx esi
mov esi,eax
inc ebx
inc edx
sub esi,2
mov eax,[buf_i]
push dword 128
push dword[eax+16] ;+16 - b_color
stdcall combine_colors_3,[edi]
stdcall buf_rect_by_size, [buf_i], ebx,edx, esi,esi,eax
pop esi edx ebx
jmp .end_0
@@:
;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
;à¨á㥬 㧥«
mov eax,[edi]
and eax,0xffffff
push eax ;梥â 㧫 
mov eax,[v_size]
cmp ecx,1
jl @f
;ª¢ ¤à â ¡®«ìè¥ â¥ªã饣® ¬ áèâ ¡ 
shl eax,cl ;à §¬¥à 㧫 
stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
push ebx edx esi
mov esi,eax
inc ebx
inc edx
sub esi,2
mov eax,[buf_i]
push dword 128
push dword[eax+16] ;+16 - b_color
stdcall combine_colors_3,[edi]
stdcall buf_rect_by_size, [buf_i], ebx,edx, esi,esi,eax
pop esi edx ebx
jmp .end_0
@@:
;ª¢ ¤à â ⥪ã饣® ¬ áèâ ¡ 
stdcall buf_filled_rect_by_size, [buf_i], ebx,edx, eax,eax
.end_0:
add edi,4
.end_f:
@ -3744,24 +3892,24 @@ endp
;input:
; ecx - ã஢¥­ì ⥪ã襣® 㧫 
; esi - coord z
; clip_z - n_plane*v_size
; clip_z - n_plane
;output:
; eax - 0 if no draw, 1 if draw
align 4
proc vox_is_clip uses ebx edi, clip_z:dword, v_size:dword
proc vox_is_clip uses ebx edi, clip_z:dword
xor eax,eax
mov ebx,[clip_z]
mov edi,[v_size]
mov edi,1
cmp ecx,1
jl @f
shl edi,cl
@@:
;edi = 2^ecx
add edi,esi
cmp edi,ebx ;if (esi+2^ecx*v_size <= (n_plane*v_size)) no draw
cmp edi,ebx ;if (esi+2^ecx <= n_plane) no draw
jle @f
add ebx,[v_size]
cmp esi,ebx ;if (esi >= (n_plane+1)*v_size) no draw
inc ebx
cmp esi,ebx ;if (esi >= (n_plane+1)) no draw
jge @f
inc eax
@@:
@ -3795,9 +3943,9 @@ proc vox_corect_coords_pl, v_obj:dword, v_size:dword
add edi,8
sub edi,eax
mov eax,[v_size] ;eax - ¢ëá®â  ®á­®¢ ­¨ï ¥¤¨­¨ç­®£® ¢®ªá¥«ï
mov eax,[v_size]
cmp ecx,1
jl @f ;¢® ¨§¡¥¦ ­¨¥ § æ¨ª«¨¢ ­¨ï
jl @f
shl eax,cl
@@:
@ -3805,14 +3953,19 @@ proc vox_corect_coords_pl, v_obj:dword, v_size:dword
jnc @f
add ebx,eax
@@:
bt word[edi],1 ;test voxel coord y
jnc @f
add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
@@:
bt word[edi],2 ;test voxel coord z
jnc @f
sub edx,eax
@@:
bt word[edi],1 ;test voxel coord y
jc @f
mov eax,1
cmp ecx,1
jl .end_0
shl eax,cl
.end_0:
add esi,eax ;¬¥­ï¥¬ £«ã¡¨­ã ¤«ï ¡ãä¥à  z
@@:
pop edi eax
.end_f:
ret
@ -3933,6 +4086,7 @@ endp
txt_err_n8b db 'need buffer 8 bit',13,10,0
txt_err_n24b db 'need buffer 24 bit',13,10,0
txt_err_n32b db 'need buffer 32 bit',13,10,0
txt_err_n8_24b db 'need buffer 8 or 24 bit',13,10,0
align 16
@ -3968,6 +4122,7 @@ EXPORTS:
dd sz_buf2d_vox_brush_delete, vox_brush_delete
dd sz_buf2d_vox_obj_get_img_w_3g, buf_vox_obj_get_img_w_3g
dd sz_buf2d_vox_obj_get_img_h_3g, buf_vox_obj_get_img_h_3g
dd sz_buf2d_vox_obj_draw_1g, buf_vox_obj_draw_1g
dd sz_buf2d_vox_obj_draw_3g, buf_vox_obj_draw_3g
dd sz_buf2d_vox_obj_draw_3g_scaled, buf_vox_obj_draw_3g_scaled
dd sz_buf2d_vox_obj_draw_pl, buf_vox_obj_draw_pl
@ -4005,6 +4160,7 @@ EXPORTS:
sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0

View File

@ -6,6 +6,7 @@ if not exist bin\font8x9.bmp @copy ..\..\..\..\..\fs\kfar\trunk\font8x9.bmp bin\
@copy foto.jpg bin\foto.jpg
@copy img0.png bin\img0.png
@copy img1.png bin\img1.png
if not exist bin\vaz2106.vox @copy ..\..\..\..\..\media\voxel_editor\trunk\vaz2106.vox bin\vaz2106.vox
@fasm.exe -m 16384 e0_dr_lines.asm bin\e0_dr_lines.kex
@fasm.exe -m 16384 e1_scaling.asm bin\e1_scaling.kex
@ -13,6 +14,8 @@ if not exist bin\font8x9.bmp @copy ..\..\..\..\..\fs\kfar\trunk\font8x9.bmp bin\
@fasm.exe -m 16384 e3_text.asm bin\e3_text.kex
@fasm.exe -m 16384 e4_graf_ed.asm bin\e4_graf_ed.kex
@fasm.exe -m 16384 e5_lines_sm.asm bin\e5_lines_sm.kex
@fasm.exe -m 16384 e6_vox_1g.asm bin\e6_vox_1g.kex
@fasm.exe -m 16384 e7_vox_3g.asm bin\e7_vox_3g.kex
@kpack bin\e0_dr_lines.kex
@kpack bin\e1_scaling.kex
@ -20,4 +23,6 @@ if not exist bin\font8x9.bmp @copy ..\..\..\..\..\fs\kfar\trunk\font8x9.bmp bin\
@kpack bin\e3_text.kex
@kpack bin\e4_graf_ed.kex
@kpack bin\e5_lines_sm.kex
@kpack bin\e6_vox_1g.kex
@kpack bin\e7_vox_3g.kex
pause

View File

@ -0,0 +1,226 @@
use32
org 0x0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 0x1
dd start
dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
dd mem,stacktop
dd 0,cur_dir_path
include '../../../../../macros.inc'
include '../../../../../proc32.inc'
include '../../../../../develop/libraries/box_lib/load_lib.mac'
include 'mem.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc, 0 ;dll.Load
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
max_open_file_size equ 64*1024 ;64 Kb
align 4
open_file_vox dd 0 ;㪠§ â¥«ì ­  ®¡« áâì ¤«ï ®âªàëâ¨ï ä ©«®¢
run_file_70 FileInfoBlock
f_name db 'vaz2106.vox',0
vox_offs_tree_table equ 4
;¯®¢®à®â ®¡ê¥ªâ  ­  90 £à ¤ãᮢ
;x0y0 - x1y0
;x1y0 - x1y1
;x0y1 - x0y0
;x1y1 - x0y1
align 4
proc vox_obj_rot_z uses eax ebx ecx, v_obj:dword
mov ebx,[v_obj]
add ebx,vox_offs_tree_table
mov ecx,2
cld
@@:
mov eax,dword[ebx]
mov byte[ebx+1],al
mov byte[ebx+3],ah
shr eax,16
mov byte[ebx],al
mov byte[ebx+2],ah
add ebx,4
loop @b
ret
endp
align 4
start:
load_library vectors_name, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, import_buf2d_lib, err_message_import, head_f_i
cmp eax,-1
jz button.exit
mcall 40,0x27
stdcall [buf2d_create], buf_0 ;ᮧ¤ ¥¬ ¡ãä¥à
stdcall [buf2d_create], buf_z
stdcall mem.Alloc,max_open_file_size
mov dword[open_file_vox],eax
copy_path f_name,[32],file_name,0x0
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov dword[run_file_70.Count], max_open_file_size
m2m [run_file_70.Buffer], [open_file_vox]
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], file_name
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ¢®ªá¥«ì­ë© ®¡ê¥ªâ
stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_z, [open_file_vox], 0,0, 7
stdcall vox_obj_rot_z, [open_file_vox]
stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_z, [open_file_vox], 128,0, 7
stdcall vox_obj_rot_z, [open_file_vox]
stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_z, [open_file_vox], 0,128, 7
stdcall vox_obj_rot_z, [open_file_vox]
stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_z, [open_file_vox], 128,128, 7
align 4
red_win:
call draw_window
align 4
still:
mcall 10
cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
jz red_win
cmp al,2
jz key
cmp al,3
jz button
jmp still
align 4
draw_window:
pushad
mcall 12,1
mov edx,0x33000000
mcall 0,(50 shl 16)+330,(30 shl 16)+295,,,caption
stdcall [buf2d_draw], buf_0
mcall 12,2
popad
ret
align 4
key:
mcall 2
cmp ah,27 ;Esc
je button.exit
jmp still
align 4
button:
mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0 ;㤠«ï¥¬ ¡ãä¥à
stdcall [buf2d_delete],buf_z
stdcall mem.Free,[open_file_vox]
mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
caption db 'Test buf2d library, [Esc] - exit',0
;--------------------------------------------------
align 4
import_buf2d_lib:
dd sz_lib_init
buf2d_create dd sz_buf2d_create
buf2d_clear dd sz_buf2d_clear
buf2d_draw dd sz_buf2d_draw
buf2d_delete dd sz_buf2d_delete
;¢®ªá¥«ì­ë¥ ä㭪樨:
;buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
;buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
;buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
;buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
;buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
;buf2d_vox_obj_draw_3g_scaled dd sz_buf2d_vox_obj_draw_3g_scaled
;buf2d_vox_obj_draw_3g_shadows dd sz_buf2d_vox_obj_draw_3g_shadows
;buf2d_vox_obj_draw_pl dd sz_buf2d_vox_obj_draw_pl
;buf2d_vox_obj_draw_pl_scaled dd sz_buf2d_vox_obj_draw_pl_scaled
dd 0,0
sz_lib_init db 'lib_init',0
sz_buf2d_create db 'buf2d_create',0
sz_buf2d_clear db 'buf2d_clear',0
sz_buf2d_draw db 'buf2d_draw',0
sz_buf2d_delete db 'buf2d_delete',0
;¢®ªá¥«ì­ë¥ ä㭪樨:
;sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
;sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
;sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
;sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
;sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
;sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
;sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
;sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
;sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
align 4
buf_0:
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 20 ;+4 left
dw 5 ;+6 top
dd 256 ;+8 w
dd 256 ;+12 h
dd 0xffffff ;+16 color
db 24 ;+20 bit in pixel
align 4
buf_z:
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 20 ;+4 left
dw 5 ;+6 top
dd 256 ;+8 w
dd 256 ;+12 h
dd 0 ;+16 color
db 32 ;+20 bit in pixel
;--------------------------------------------------
system_path db '/sys/lib/'
vectors_name db 'buf2d.obj',0
err_message_found_lib db 'Sorry I cannot load library buf2d.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library buf2d.obj',0
;--------------------------------------------------
i_end: ;ª®­¥æ ª®¤ 
rb 1024
stacktop:
file_name:
rb 4096
cur_dir_path:
rb 4096
library_path:
rb 4096
mem:

View File

@ -0,0 +1,249 @@
use32
org 0x0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 0x1
dd start
dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
dd mem,stacktop
dd 0,cur_dir_path
include '../../../../../macros.inc'
include '../../../../../proc32.inc'
include '../../../../../develop/libraries/box_lib/load_lib.mac'
include 'mem.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc, 0 ;dll.Load
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
max_open_file_size equ 64*1024 ;64 Kb
align 4
open_file_vox dd 0 ;㪠§ â¥«ì ­  ®¡« áâì ¤«ï ®âªàëâ¨ï ä ©«®¢
run_file_70 FileInfoBlock
f_name db 'vaz2106.vox',0
BUF_STRUCT_SIZE equ 21
vox_offs_tree_table equ 4
;¯®¢®à®â ®¡ê¥ªâ  ­  90 £à ¤ãᮢ
;x0y0 - x1y0
;x1y0 - x1y1
;x0y1 - x0y0
;x1y1 - x0y1
align 4
proc vox_obj_rot_z uses eax ebx ecx, v_obj:dword
mov ebx,[v_obj]
add ebx,vox_offs_tree_table
mov ecx,2
cld
@@:
mov eax,dword[ebx]
mov byte[ebx+1],al
mov byte[ebx+3],ah
shr eax,16
mov byte[ebx],al
mov byte[ebx+2],ah
add ebx,4
loop @b
ret
endp
align 4
start:
load_library vectors_name, cur_dir_path, library_path, system_path, \
err_message_found_lib, head_f_l, import_buf2d_lib, err_message_import, head_f_i
cmp eax,-1
jz button.exit
mcall 40,0x27
stdcall [buf2d_create], buf_0 ;ᮧ¤ ¥¬ ¡ãä¥à
stdcall [buf2d_create], buf_z
stdcall [buf2d_vox_brush_create], buf_vox, vox_6_7_z ;ᮧ¤ ¥¬ ¢®ªá¥«ì­ãî ª¨áâì
stdcall mem.Alloc,max_open_file_size
mov dword[open_file_vox],eax
copy_path f_name,[32],file_name,0x0
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov dword[run_file_70.Count], max_open_file_size
m2m [run_file_70.Buffer], [open_file_vox]
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], file_name
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ¢®ªá¥«ì­ë© ®¡ê¥ªâ
stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_z, buf_vox,\
[open_file_vox], 0,0, 0, 6 ;à¨á㥬 ¢®ªá¥«ì­ë© ®¡ê¥ªâ
stdcall [buf2d_vox_obj_draw_3g_shadows], buf_0, buf_z, buf_vox,\
0,0, 0, 6, 3 ;à¨á㥬 ⥭¨
stdcall vox_obj_rot_z, [open_file_vox] ;¯®¢®à ç¨¢ ¥¬
stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_z, buf_vox, [open_file_vox], 0,0, 0, 5
stdcall vox_obj_rot_z, [open_file_vox]
stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_z, buf_vox, [open_file_vox], 100,0, 0, 5
stdcall vox_obj_rot_z, [open_file_vox]
stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_z, buf_vox, [open_file_vox], 200,0, 0, 5
align 4
red_win:
call draw_window
align 4
still:
mcall 10
cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
jz red_win
cmp al,2
jz key
cmp al,3
jz button
jmp still
align 4
draw_window:
pushad
mcall 12,1
mov edx,0x33000000
mcall 0,(50 shl 16)+410,(30 shl 16)+480,,,caption
stdcall [buf2d_draw], buf_0
mcall 12,2
popad
ret
align 4
key:
mcall 2
cmp ah,27 ;Esc
je button.exit
jmp still
align 4
button:
mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0 ;㤠«ï¥¬ ¡ãä¥à
stdcall [buf2d_delete],buf_z
stdcall [buf2d_vox_brush_delete],buf_vox
stdcall mem.Free,[open_file_vox]
mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
caption db 'Test buf2d library, [Esc] - exit',0
;--------------------------------------------------
align 4
import_buf2d_lib:
dd sz_lib_init
buf2d_create dd sz_buf2d_create
buf2d_clear dd sz_buf2d_clear
buf2d_draw dd sz_buf2d_draw
buf2d_delete dd sz_buf2d_delete
;¢®ªá¥«ì­ë¥ ä㭪樨:
buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
;buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
;buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
;buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
;buf2d_vox_obj_draw_3g_scaled dd sz_buf2d_vox_obj_draw_3g_scaled
buf2d_vox_obj_draw_3g_shadows dd sz_buf2d_vox_obj_draw_3g_shadows
;buf2d_vox_obj_draw_pl dd sz_buf2d_vox_obj_draw_pl
;buf2d_vox_obj_draw_pl_scaled dd sz_buf2d_vox_obj_draw_pl_scaled
dd 0,0
sz_lib_init db 'lib_init',0
sz_buf2d_create db 'buf2d_create',0
sz_buf2d_clear db 'buf2d_clear',0
sz_buf2d_draw db 'buf2d_draw',0
sz_buf2d_delete db 'buf2d_delete',0
;¢®ªá¥«ì­ë¥ ä㭪樨:
sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
;sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
;sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
;sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
;sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0
;sz_buf2d_vox_obj_draw_pl db 'buf2d_vox_obj_draw_pl',0
;sz_buf2d_vox_obj_draw_pl_scaled db 'buf2d_vox_obj_draw_pl_scaled',0
align 4
buf_0: ;¡ãä¥à ®á­®¢­®£® ¨§®¡à ¦¥­¨ï
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 5 ;+4 left
dw 3 ;+6 top
dd 6*64 ;+8 w
dd 7*64 ;+12 h
dd 0xffffff ;+16 color
db 24 ;+20 bit in pixel
align 4
buf_z: ;¡ãä¥à £«ã¡¨­ë
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 0 ;+4 left
dw 0 ;+6 top
dd 6*64 ;+8 w
dd 7*64 ;+12 h
dd 0 ;+16 color
db 32 ;+20 bit in pixel
;¤ ­­ë¥ ¤«ï ᮧ¤ ­¨ï ¬¨­¨¬ «ì­®£® ¥¤¨­¨ç­®£® ¢®ªá¥«ï
align 4
vox_6_7_z:
dd 0,0,1,1,0,0,\
0,2,2,2,2,0,\
2,2,2,2,2,2,\
2,3,2,2,3,2,\
2,3,3,3,3,2,\
0,3,3,3,3,0,\
0,0,3,3,0,0
align 4
buf_vox:
db 6,7,4,3 ;w,h,h_osn,n
rb BUF_STRUCT_SIZE*(2+1)
;--------------------------------------------------
system_path db '/sys/lib/'
vectors_name db 'buf2d.obj',0
err_message_found_lib db 'Sorry I cannot load library buf2d.obj',0
head_f_i:
head_f_l db 'System error',0
err_message_import db 'Error on load import library buf2d.obj',0
;--------------------------------------------------
i_end: ;ª®­¥æ ª®¤ 
rb 1024
stacktop:
file_name:
rb 4096
cur_dir_path:
rb 4096
library_path:
rb 4096
mem:

View File

@ -17,7 +17,7 @@ include 'dll.inc'
include 'vox_draw.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'Voxel editor 19.06.12',0 ;¯®¤¯¨áì ®ª­ 
caption db 'Voxel editor 21.06.12',0 ;¯®¤¯¨áì ®ª­ 
struct FileInfoBlock
Function dd ?
@ -932,6 +932,7 @@ push edi
inc eax
stdcall [buf2d_vox_obj_draw_3g], buf_r_img, buf_r_z, buf_vox, [open_file_vox], 0,0, 0, eax
stdcall [buf2d_vox_obj_draw_1g], buf_r_img, buf_r_z, [open_file_vox], 0,0, eax
bt dword[mode_light],0
jnc @f
stdcall [buf2d_vox_obj_draw_3g_shadows], buf_r_img, buf_r_z, buf_vox, 0,0, 0, eax, 3
@ -1021,7 +1022,9 @@ draw_objects:
stdcall [buf2d_vox_obj_draw_3g], buf_0, buf_0z, buf_vox,\
[open_file_vox], ebx,ecx, 0, eax
stdcall [buf2d_vox_obj_draw_pl], buf_pl, [open_file_vox],\
OT_MAP_X,OT_MAP_Y,TILE_SIZE, [v_zoom], [n_plane], [sc.work_graph]
OT_MAP_X,OT_MAP_Y,TILE_SIZE, eax, [n_plane], [sc.work_graph]
stdcall [buf2d_vox_obj_draw_1g], buf_0, buf_0z,\
[open_file_vox], 0,0, eax
bt dword[mode_light],0
jnc .end_1
stdcall [buf2d_vox_obj_draw_3g_shadows], buf_0, buf_0z, buf_vox, ebx,ecx, 0, eax, 3
@ -1327,6 +1330,7 @@ import_buf2d:
buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
buf2d_vox_obj_get_img_w_3g dd sz_buf2d_vox_obj_get_img_w_3g
buf2d_vox_obj_get_img_h_3g dd sz_buf2d_vox_obj_get_img_h_3g
buf2d_vox_obj_draw_1g dd sz_buf2d_vox_obj_draw_1g
buf2d_vox_obj_draw_3g dd sz_buf2d_vox_obj_draw_3g
buf2d_vox_obj_draw_3g_scaled dd sz_buf2d_vox_obj_draw_3g_scaled
buf2d_vox_obj_draw_3g_shadows dd sz_buf2d_vox_obj_draw_3g_shadows
@ -1363,6 +1367,7 @@ import_buf2d:
sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
sz_buf2d_vox_obj_get_img_w_3g db 'buf2d_vox_obj_get_img_w_3g',0
sz_buf2d_vox_obj_get_img_h_3g db 'buf2d_vox_obj_get_img_h_3g',0
sz_buf2d_vox_obj_draw_1g db 'buf2d_vox_obj_draw_1g',0
sz_buf2d_vox_obj_draw_3g db 'buf2d_vox_obj_draw_3g',0
sz_buf2d_vox_obj_draw_3g_scaled db 'buf2d_vox_obj_draw_3g_scaled',0
sz_buf2d_vox_obj_draw_3g_shadows db 'buf2d_vox_obj_draw_3g_shadows',0