update voxel editor:

1) can draw and erase in parent level with [Shift] pressed
2) modify brush

git-svn-id: svn://kolibrios.org@3047 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2012-11-16 17:42:51 +00:00
parent 881c591f08
commit 43c00f1c99

View File

@ -16,7 +16,7 @@ include '../../../dll.inc'
include 'vox_draw.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'Voxel editor 01.10.12',0 ;¯®¤¯¨áì ®ª­ 
caption db 'Voxel editor 16.11.12',0 ;¯®¤¯¨áì ®ª­ 
struct FileInfoBlock
Function dd ?
@ -109,6 +109,7 @@ OT_CAPT_Y_COLOR equ 30
PEN_MODE_NONE equ -1
PEN_MODE_CLEAR equ 0 ;०¨¬ áâ¨à ­¨ï
PEN_MODE_SELECT_COLOR equ 2 ;०¨¬ ¢ë¡®à  梥â 
PEN_MODE_BRUSH equ 3 ;०¨¬ à ¡®âë á ª¨áâìî
align 4
start:
@ -346,22 +347,33 @@ mouse:
push dword[v_color]
@@:
;¢ë§®¢ ®¡é¨å ¯ à ¬¥â஢ ¤«ï ä㭪権
push dword[v_zoom]
push edx
push ebx
push eax
mov ecx,dword[v_zoom]
mov edi,eax
mov esi,ebx
mcall 66,3
and eax,3 ;3 -> ¡¨â 0 «¥¢ë© Shift ­ ¦ â, ¡¨â 1 ¯à ¢ë© Shift ­ ¦ â
jz .shift_end
;¥á«¨ ­ ¦ â Shift, ⮠। ªâ¨à㥬 ­  ¢¥àå­¥¬ ã஢­¥
;¤«ï í⮣® ¢á¥ ª®®à¤¨­ âë ¤¥«¨¬ ­  2   ®â ¬ áâ ¡  ®â­¨¬ ¥¬ 1
shr edx,1
shr esi,1
shr edi,1
dec ecx
.shift_end:
;¢ë§®¢ ®¡é¨å ¯ à ¬¥â஢ ¤«ï ä㭪権
push ecx edx esi edi
push dword[open_file_vox]
;¢ë§®¢ ä㭪権
cmp dword[v_pen_mode],1
jne @f
call buf2d_vox_obj_create_node
;stdcall buf2d_vox_obj_create_node, [open_file_vox], eax,ebx,edx, [v_zoom], [v_color]
;stdcall buf2d_vox_obj_create_node, [open_file_vox], edi,esi,edx, [v_zoom], [v_color]
jmp .end_1
@@:
call buf2d_vox_obj_delete_node
;stdcall buf2d_vox_obj_delete_node, [open_file_vox], eax,ebx,edx, [v_zoom]
;stdcall buf2d_vox_obj_delete_node, [open_file_vox], edi,esi,edx, [v_zoom]
.end_1:
call draw_objects
@ -1195,8 +1207,7 @@ but_bru_w_m:
dec dword[brush_w]
pushad
call draw_pok
call draw_vox_cursor
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
call draw_plane
popad
@@:
ret
@ -1208,8 +1219,7 @@ but_bru_w_p:
inc dword[brush_w]
pushad
call draw_pok
call draw_vox_cursor
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
call draw_plane
popad
@@:
ret
@ -1221,8 +1231,7 @@ but_bru_h_m:
dec dword[brush_h]
pushad
call draw_pok
call draw_vox_cursor
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
call draw_plane
popad
@@:
ret
@ -1234,15 +1243,14 @@ but_bru_h_p:
inc dword[brush_h]
pushad
call draw_pok
call draw_vox_cursor
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
call draw_plane
popad
@@:
ret
align 4
but_brush_copy:
cmp dword[v_pen_mode],3
cmp dword[v_pen_mode],PEN_MODE_BRUSH
jne .end_f
pushad
mov eax,[v_cur_x]
@ -1297,7 +1305,7 @@ popad
align 4
but_brush_draw:
cmp dword[v_pen_mode],3
cmp dword[v_pen_mode],PEN_MODE_BRUSH
jne .end_f
pushad
mov eax,[v_cur_x]
@ -1355,7 +1363,7 @@ popad
align 4
but_brush_clear:
cmp dword[v_pen_mode],3
cmp dword[v_pen_mode],PEN_MODE_BRUSH
jne .end_f
pushad
mov eax,[v_cur_x]
@ -1445,11 +1453,11 @@ txt_mull db '*',0
txt_space db ' ',0
txt_buf rb 16
;à¨á®¢ ­¨¥ ¡ãä¥à  á ¢®ªá¥«ì­ë¬¨ ®¡ê¥ªâ ¬¨
align 4
draw_objects:
stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
stdcall [buf2d_clear], buf_0z, 0 ;ç¨á⨬ ¡ãä¥à
stdcall [buf2d_clear], buf_pl, [buf_pl.color] ;ç¨á⨬ ¡ãä¥à
cmp dword[v_pen_mode],PEN_MODE_SELECT_COLOR
jne @f
@ -1477,8 +1485,6 @@ 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], 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
@ -1491,8 +1497,6 @@ draw_objects:
sub eax,[scaled_zoom]
stdcall [buf2d_vox_obj_draw_3g_scaled], buf_0, buf_0z, [buf_vox],\
[open_file_vox], 0,0, 0, [scaled_zoom], [cam_x],[cam_y],[cam_z],eax, [sc.work_graph] ;scroll -> 2^eax
stdcall [buf2d_vox_obj_draw_pl_scaled], buf_pl, [open_file_vox],\
OT_MAP_X,OT_MAP_Y,[tile_size], [scaled_zoom], [n_plane], [sc.work_graph],[cam_x],[cam_y],[cam_z],eax
bt dword[mode_light],0
jnc .end_2
stdcall [buf2d_vox_obj_draw_3g_shadows], buf_0, buf_0z, [buf_vox], 0,0, 0, [scaled_zoom], 3
@ -1500,11 +1504,35 @@ draw_objects:
.end_0:
pop ecx ebx eax
call draw_vox_cursor
call draw_plane
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
.end_f:
ret
;à¨á®¢ ­¨¥ ¯«®áª®á⨠á á¥ç¥­¨¥¬ ®¡ê¥ªâ 
align 4
proc draw_plane uses eax
stdcall [buf2d_clear], buf_pl, [buf_pl.color] ;ç¨á⨬ ¡ãä¥à
mov eax,[v_zoom]
cmp eax,[scaled_zoom]
jg @f
;®¡ëç­ë© ०¨¬ ¨§®¡à ¦¥­¨ï
stdcall [buf2d_vox_obj_draw_pl], buf_pl, [open_file_vox],\
OT_MAP_X,OT_MAP_Y,[tile_size], eax, [n_plane], [sc.work_graph]
jmp .end_0
@@:
;०¨¬ ¬ áèâ ¡¨à®¢ ­¨ï ¨§®¡à ¦¥­¨ï
sub eax,[scaled_zoom]
stdcall [buf2d_vox_obj_draw_pl_scaled], buf_pl, [open_file_vox],\
OT_MAP_X,OT_MAP_Y,[tile_size], [scaled_zoom], [n_plane], [sc.work_graph],[cam_x],[cam_y],[cam_z],eax
.end_0:
call draw_vox_cursor
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
.end_f:
ret
endp
;à¨á®¢ ­¨¥ ªãàá®à 
align 4
@ -1531,15 +1559,14 @@ pushad
imul ebx,edi
add ebx,OT_MAP_Y
inc eax
cmp dword[v_pen_mode],PEN_MODE_BRUSH
je .brush
inc ebx
sub edi,2
sub edi,2
stdcall [buf2d_rect_by_size], buf_pl, eax,ebx, edi,edi,[sc.work_graph]
dec ebx
add edi,2
cmp dword[v_pen_mode],3
je .brush
;£®à¨§®­â «ì­ë¥ «¨­¨¨
sub eax,2
mov ecx,edi
@ -1569,6 +1596,42 @@ pushad
imul esi,[tile_size]
stdcall [buf2d_rect_by_size], buf_pl, eax,ebx, edi,esi,[sc.work_graph]
;à¨á®¢ ­¨¥ â®ç¥ª ¤«ï ª¨áâ¨
mov ecx,[brush_w]
mov edx,[tile_size]
sub eax,edx ;eax-=tile_size
shr edx,2
add eax,edx ;eax+=tile_size/4
add ebx,edx ;ebx+=tile_size/4
mov edx,eax
mov esi,[tile_size]
imul esi,ecx
imul ecx,[brush_h]
add esi,edx
;eax = from edx to esi
mov edi,brush_data
cld
@@:
add eax,[tile_size]
bt dword[edi],31
jc .no_pixel
bt dword[edi],30
jc .sel_color
push dword[edi]
jmp .set_pixel
.sel_color:
push [v_color]
.set_pixel:
stdcall [buf2d_rect_by_size], buf_pl, eax,ebx, 3,3 ;, [edi]
.no_pixel:
add edi,4
cmp eax,esi
jl .end_line
mov eax,edx
add ebx,[tile_size]
.end_line:
loop @b
.end_f:
popad
ret