kolibrios/programs/media/voxel_editor/trunk/voxel_editor.asm
IgorA 0b625a1233 1) add new program 'voxel_editor'
2) fix file menu.dat

git-svn-id: svn://kolibrios.org@2748 a494cfbc-eb01-0410-851d-a64ba20cac60
2012-06-05 15:33:54 +00:00

1115 lines
25 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use32
org 0x0
db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
dd 0x1
dd start
dd i_end ;à §¬¥à ¯à¨«®¦¥­¨ï
dd mem
dd stacktop
dd 0
dd sys_path
include 'd:/kolibri/svn/programs/macros.inc'
include 'd:/kolibri/svn/programs/proc32.inc'
include 'd:/kolibri/svn/programs/develop/libraries/box_lib/load_lib.mac'
include 'mem.inc'
include 'dll.inc'
include 'vox_draw.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'Voxel editor 5.06.12',0 ;¯®¤¯¨áì ®ª­ 
struct FileInfoBlock
Function dd ?
Position dd ?
Flags dd ?
Count dd ?
Buffer dd ?
db ?
FileName dd ?
ends
run_file_70 FileInfoBlock
image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
fn_toolbar db 'toolbar.png',0
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*14
image_data_toolbar dd 0
max_open_file_size equ 64*1024 ;64 Kb
macro load_image_file path,buf,size { ;¬ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨©
;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
jmp @f
local .path_str
.path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
db 0
@@:
;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
copy_path .path_str,[32],file_name,0x0
else
copy_path path,[32],file_name,0x0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
end if
stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
mov [buf],eax
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 0
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov [run_file_70.Count], dword size
m2m [run_file_70.Buffer], [buf]
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je @f
;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_decode], dword[buf],ebx,0
mov dword[image_data],eax
;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
stdcall dword[img_destroy], dword[image_data]
@@:
}
OT_MAP_X equ 0
OT_MAP_Y equ 0
TILE_SIZE equ 10
align 4
start:
load_libraries l_libs_start,l_libs_end
;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
mov ebp,lib_2
cmp dword [ebp+ll_struc_size-4],0
jz @f
mcall -1 ;exit not correct
@@:
mcall 48,3,sc,sizeof.system_colors
mcall 40,0x27
stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª  ¤¨ «®£ 
stdcall [buf2d_create], buf_0 ;ᮧ¤ ­¨¥ ¡ãä¥à  ¨§®¡à ¦¥­¨ï
stdcall [buf2d_create], buf_0z ;ᮧ¤ ­¨¥ ¡ãä¥à  £«ã¡¨­ë
stdcall [buf2d_create], buf_pl ;ᮧ¤ ­¨¥ ¡ãä¥à  ¤«ï á¥ç¥­¨ï
stdcall [buf2d_vox_brush_create], buf_vox, vox_6_7_z
load_image_file fn_toolbar, image_data_toolbar,IMAGE_TOOLBAR_SIZE
stdcall mem.Alloc,max_open_file_size
mov dword[open_file_vox],eax
call but_new_file
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
cmp al,6
jne @f
mcall 9,procinfo,-1
cmp ax,word[procinfo+4]
jne @f ;®ª­® ­¥  ªâ¨¢­®
call mouse
@@:
jmp still
align 4
mouse:
pushad
mcall 37,2
bt eax,0 ;left button
jnc .end_f
mcall 37,1 ;get mouse coords
mov ebx,eax
and eax,0xffff
cmp dword[v_pen_mode],2 ;select color
jne .end_2
stdcall get_buf_color, buf_0
stdcall get_buf_color, buf_pl
jmp .end_f
.end_2:
movzx edx,word[buf_pl.t]
add edx,OT_MAP_Y
cmp eax,edx
jl .end_f
sub eax,edx
xor edx,edx
mov ecx,TILE_SIZE ;H
div ecx
shr ebx,16
movzx edx,word[buf_pl.l]
add edx,OT_MAP_X
cmp ebx,edx
jl .end_f
call convert_y ;¯à¥®¡à §®¢ ­¨¥ ª®®à¤¨­ âë y
cmp eax,0
jge .end_0 ;®£à ­¨ç¥­¨¥ ¯® ­¨¦­¥© ª®®à¤¨­ â¥ y
cmp eax,-1
jne .end_f
;¬¥­ï¥¬ á¥ç¥­¨¥, ¯®¯ «¨ ­  ª¢ ¤à â¨ª
sub ebx,edx
mov eax,ebx
xor edx,edx
mov ecx,TILE_SIZE ;W
div ecx
mov [n_plane],eax
jmp .end_1
.end_0:
mov [v_cur_y],eax ;Y-coord
sub ebx,edx
mov eax,ebx
xor edx,edx
mov ecx,TILE_SIZE ;W
div ecx
mov [v_cur_x],eax ;X-coord
cmp dword[v_pen_mode],0
jne @f
stdcall buf2d_vox_obj_delete_node, [open_file_vox], [v_cur_x],[n_plane],[v_cur_y], [v_zoom]
@@:
cmp dword[v_pen_mode],1
jne .end_1
stdcall buf2d_vox_obj_create_node, [open_file_vox], [v_cur_x],[n_plane],[v_cur_y], [v_color], [v_zoom]
.end_1:
call draw_objects
call draw_pok
.end_f:
popad
ret
align 4
proc get_buf_color uses eax ebx edi, buf:dword
mov edi,[buf]
cmp ax,buf2d_t
jl .end_f
sub ax,buf2d_t
cmp eax,buf2d_h
jg .end_f
shr ebx,16
cmp bx,buf2d_l
jl .end_f
sub bx,buf2d_l
cmp ebx,buf2d_w
jg .end_f
stdcall [buf2d_get_pixel], edi,ebx,eax
mov [v_color],eax
stdcall [buf2d_filled_rect_by_size], buf_0, 5,3, 8,8,eax
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
.end_f:
ret
endp
;¯à¥®¡à §®¢ë¢ ¥¬ ª®®à¤¨­ âã y (§­ ç¥­¨¥ ¤®«¦­® 㢥«¨ç¨¢ âìáï á ­¨§ã ¢¢¥àå)
align 4
convert_y:
push ecx edx
mov ecx,[v_zoom]
mov edx,1
cmp ecx,1
jl .end_0
cld
@@:
shl edx,1
loop @b
.end_0:
sub edx,eax
dec edx
mov eax,edx
pop edx ecx
ret
align 4
draw_window:
pushad
mcall 12,1
; *** à¨á®¢ ­¨¥ £« ¢­®£® ®ª­  (¢ë¯®«­ï¥âáï 1 à § ¯à¨ § ¯ã᪥) ***
xor eax,eax
mov ebx,(20 shl 16)+540
mov ecx,(20 shl 16)+415
mov edx,[sc.work]
or edx,(3 shl 24)+0x30000000
mov edi,caption
int 0x40
; *** ᮧ¤ ­¨¥ ª­®¯®ª ­  ¯ ­¥«ì ***
mov eax,8
mov ebx,(5 shl 16)+20
mov ecx,(5 shl 16)+20
mov edx,3
mov esi,[sc.work_button]
int 0x40
mov ebx,(30 shl 16)+20
mov edx,4
int 0x40
add ebx,25 shl 16
mov edx,5
int 0x40
add ebx,30 shl 16
mov edx,6
int 0x40
add ebx,25 shl 16
mov edx,7
int 0x40
add ebx,25 shl 16
mov edx,8
int 0x40
add ebx,25 shl 16
mov edx,9
int 0x40
add ebx,25 shl 16
mov edx,10
int 0x40
add ebx,25 shl 16
mov edx,11
int 0x40
add ebx,25 shl 16
mov edx,12
int 0x40
add ebx,25 shl 16
mov edx,13
int 0x40
add ebx,25 shl 16
mov edx,14
int 0x40
add ebx,25 shl 16
mov edx,15
int 0x40
add ebx,25 shl 16
mov edx,16
int 0x40
; *** à¨á®¢ ­¨¥ ¨ª®­®ª ­  ª­®¯ª å ***
mov eax,7
mov ebx,[image_data_toolbar]
mov ecx,(16 shl 16)+16
mov edx,(7 shl 16)+7 ;icon new
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon open
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;icon save
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(30 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
add ebx,IMAGE_TOOLBAR_ICON_SIZE
add edx,(25 shl 16) ;
int 0x40
; *** à¨á®¢ ­¨¥ ¡ãä¥à®¢ ***
call draw_objects
call draw_pok
mcall 12,2
popad
ret
align 4
draw_pok:
mov eax,4 ;à¨á®¢ ­¨¥ ⥪áâ 
mov ebx,(365 shl 16)+5
mov ecx,[sc.work_text]
or ecx,0x80000000 ;or (1 shl 30)
mov edx,txt_zoom
;mov edi,[sc.work]
int 0x40
add bx,9
mov edx,txt_cur_x
int 0x40
add bx,9
mov edx,txt_cur_y
int 0x40
add bx,9
mov edx,txt_n_plane
int 0x40
mov eax,47
mov ecx,[v_zoom]
mov ebx,(2 shl 16)
mov edx,((365+6*9) shl 16)+5
mov esi,[sc.work_button_text]
or esi,(1 shl 30)
mov edi,[sc.work_button]
int 0x40 ;¬ áèâ ¡
mov ebx,(5 shl 16)
mov ecx,[v_cur_x]
add edx,(6*2)*65536+9
int 0x40 ;
mov ebx,(5 shl 16)
mov ecx,[v_cur_y]
add edx,(6*0)*65536+9
int 0x40 ;
mov ebx,(5 shl 16)
mov ecx,[n_plane]
add edx,(6*0)*65536+9
int 0x40 ;
ret
align 4
key:
mcall 2
jmp still
align 4
button:
mcall 17
cmp ah,3
jne @f
call but_new_file
call draw_objects
call draw_pok
@@:
cmp ah,4
jne @f
call but_open_file
@@:
cmp ah,5
jne @f
call but_save_file
@@:
cmp ah,6
jne @f
call but_1
@@:
cmp ah,7
jne @f
call but_2
@@:
cmp ah,8
jne @f
call but_3
@@:
cmp ah,9
jne @f
call but_4
@@:
cmp ah,10
jne @f
call but_5
@@:
cmp ah,11
jne @f
call but_6
@@:
cmp ah,12
jne @f
call but_7
@@:
cmp ah,13
jne @f
call but_8
@@:
cmp ah,14
jne @f
mov dword[v_pen_mode],2 ;select color
call draw_palete
@@:
cmp ah,15
jne @f
call but_light
@@:
cmp ah,16
jne @f
call but_rend_2_2
@@:
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0
stdcall [buf2d_delete],buf_0z
cmp dword[buf_r_img],0
je @f
stdcall [buf2d_delete],buf_r_img
stdcall [buf2d_delete],buf_r_z
@@:
stdcall [buf2d_vox_brush_delete], buf_vox
stdcall mem.Free,[image_data_toolbar]
stdcall mem.Free,[open_file_vox]
mcall -1
align 4
vox_new_data:
db 2,0,0,0
db 000b,001b,010b,011b, 100b,101b,110b,111b ;default table
dd 0 ;null node
align 4
proc but_new_file uses ecx edi esi
mov ecx,vox_offs_data+4
mov esi,vox_new_data
mov edi,[open_file_vox]
cld
rep movsb
ret
endp
align 4
open_file_vox dd 0 ;㪠§ â¥«ì ­  ®¡« áâì ¤«ï ®âªàëâ¨ï ä ©«®¢
align 4
but_open_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],0
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2
je .end_open_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
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], openfile_path
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je .end_open_file
add ebx,[open_file_vox]
mov byte[ebx],0 ;­  á«ãç © ¥á«¨ à ­¥¥ ¡ë« ®âªàëâ ä ©« ¡®«ì襣® à §¬¥à  ç¨á⨬ ª®­¥æ ¡ãä¥à  á ä ©«®¬
mcall 71,1,openfile_path
;---
;
mov eax,[open_file_vox]
movzx eax,byte[eax]
and eax,0xff ;¡¥à¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
mov dword[v_zoom],eax ;¡¥à¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
call draw_objects
.end_open_file:
popad
ret
align 4
but_save_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],1
stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2
je .end_save_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
mov eax,dword[v_zoom] ;§ ¤ ¥¬ ¬ áèâ ¡ ¯® 㬮«ç ­¨î
mov ebx,[open_file_vox]
mov byte[ebx],al
stdcall buf2d_vox_obj_get_size, ebx
mov dword[run_file_70.Count], eax ;à §¬¥à ä ©« 
mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
mov [run_file_70.Function], 2
mov [run_file_70.Position], 0
mov [run_file_70.Flags], 0
mov ebx, dword[open_file_vox]
mov [run_file_70.Buffer], ebx
mov byte[run_file_70+20], 0
mov dword[run_file_70.FileName], openfile_path
mov ebx,run_file_70
int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
cmp ebx,0xffffffff
je .end_save_file
.end_save_file:
popad
ret
align 4
but_1:
cmp dword[v_zoom],7
jge @f
inc dword[v_zoom]
shl dword[n_plane],1
call draw_objects
call draw_pok
@@:
ret
align 4
but_2:
cmp dword[v_zoom],-1
jl @f
dec dword[v_zoom]
shr dword[n_plane],1
call draw_objects
call draw_pok
@@:
ret
align 4
but_3:
stdcall vox_obj_rot_z, [open_file_vox]
call draw_objects
ret
align 4
but_4:
stdcall vox_obj_rot_x, [open_file_vox]
call draw_objects
ret
align 4
but_5:
inc dword[n_plane]
call draw_objects
call draw_pok
ret
align 4
but_6:
cmp dword[n_plane],0
jle @f
dec dword[n_plane]
call draw_objects
call draw_pok
@@:
ret
align 4
but_7:
push eax
mov eax,dword[v_pen_mode]
mov dword[v_pen_mode],1 ;draw
cmp eax,2
jne @f
call draw_objects
@@:
pop eax
ret
align 4
but_8:
push eax
mov eax,dword[v_pen_mode]
mov dword[v_pen_mode],0 ;clear
cmp eax,2
jne @f
call draw_objects
@@:
pop eax
ret
align 4
but_light:
xor dword[mode_light],1
call draw_objects
ret
align 4
but_rend_2_2:
push edi
cmp dword[buf_r_img],0
jne @f
;ᮧ¤ ­¨¥ ¡ãä¥à  ¤«ï ७¤¥à 
push ecx esi
mov edi,buf_r_img
mov esi,buf_0
mov ecx,BUF_STRUCT_SIZE
cld
rep movsb ;ª®¯¨à㥬 ¢á¥ ¯ à ¬¥âàë á ®á­®¢­®£® ¡ãä¥à 
mov edi,buf_r_img
mov buf2d_data,0
shl buf2d_w,1 ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¡ãä¥à 
shl buf2d_h,1
stdcall [buf2d_create],buf_r_img
mov edi,buf_r_z
mov esi,buf_0z
mov ecx,BUF_STRUCT_SIZE
cld
rep movsb ;ª®¯¨à㥬 ¢á¥ ¯ à ¬¥âàë á ®á­®¢­®£® ¡ãä¥à 
mov edi,buf_r_z
mov buf2d_data,0
shl buf2d_w,1 ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¡ãä¥à 
shl buf2d_h,1
stdcall [buf2d_create],buf_r_z
pop esi ecx
@@:
stdcall [buf2d_clear], buf_r_img, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
stdcall [buf2d_clear], buf_r_z, 0 ;ç¨á⨬ ¡ãä¥à
push eax ebx ecx
mov eax,[v_zoom]
inc eax
stdcall buf2d_vox_obj_draw_3g, buf_r_img, buf_r_z, buf_vox, [open_file_vox], 0,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
@@:
mov edi,buf_r_img
stdcall [buf2d_img_hdiv2], edi
shr buf2d_h,1
stdcall [buf2d_img_wdiv2], edi
shr buf2d_w,1
stdcall buf2d_vox_obj_get_img_w_3g, buf_vox,[v_zoom]
mov ebx,[buf_0.w]
sub ebx,eax
shr ebx,1 ;ebx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯® £®à¨§®­â «¨
stdcall buf2d_vox_obj_get_img_h_3g, buf_vox,[v_zoom]
cmp eax,[buf_0.h]
jg @f
mov ecx,[buf_0.h]
sub ecx,eax
shr ecx,1 ;ecx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯®
@@:
stdcall [buf2d_bit_blt], buf_0, ebx,ecx, edi
shl buf2d_h,1
shl buf2d_w,1
pop ecx ebx eax
pop edi
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
ret
align 4
draw_palete:
stdcall [buf2d_clear], buf_0, [buf_0.color] ;ç¨á⨬ ¡ãä¥à
stdcall [buf2d_filled_rect_by_size], buf_0, 5,3, 8,8,[v_color]
stdcall buf2d_draw_palete, buf_0, 5,14, 9,6, 18, 512
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
ret
v_zoom dd 2 ;⥪ã騩 ¬ áèâ ¡
v_cur_x dd 0 ;ª®®à¤¨­ â  ªãàá®à  x
v_cur_y dd 0 ;ª®®à¤¨­ â  ªãàá®à  y (­® ®áì ¢ ®¡ê¥ªâ¥ z)
n_plane dd 0 ;¯«®áª®áâì á¥ç¥­¨ï
v_color dd 0xff ;梥⠪ à ­¤ è 
v_pen_mode dd 1 ;०¨¬: 0-áâ¨à ­¨ï, 1-à¨á®¢ ­¨ï
mode_light dd 1 ;०¨¬ ®á¢¥é¥­¨ï
txt_zoom db 'Œ áèâ ¡:',0
txt_cur_x db 'x:',0
txt_cur_y db 'y:',0
txt_n_plane db '‘¥ç¥­¨¥:',0
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],2
jne @f
call draw_palete
jmp .end_f
@@:
push eax ebx ecx
stdcall buf2d_vox_obj_get_img_w_3g, buf_vox,[v_zoom]
mov ebx,[buf_0.w]
sub ebx,eax
shr ebx,1 ;ebx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯® £®à¨§®­â «¨
xor ecx,ecx
stdcall buf2d_vox_obj_get_img_h_3g, buf_vox,[v_zoom]
cmp eax,[buf_0.h]
jg @f
mov ecx,[buf_0.h]
sub ecx,eax
shr ecx,1 ;ecx - ¤«ï 業â஢ª¨ ¬ «¥­ìª¨å ¨§®¡à ¦¥­¨© ¯®
@@:
stdcall buf2d_vox_obj_draw_3g, buf_0, buf_0z, buf_vox, [open_file_vox], ebx,ecx, 0, [v_zoom]
bt dword[mode_light],0
jnc @f
stdcall buf2d_vox_obj_draw_3g_shadows, buf_0, buf_0z, buf_vox, ebx,ecx, 0, [v_zoom], 3
@@:
pop ecx ebx eax
.end_0:
stdcall buf2d_vox_obj_draw_pl, buf_pl, [open_file_vox], OT_MAP_X,OT_MAP_Y,TILE_SIZE, [v_zoom], [n_plane], 0xd0d0d0
stdcall [buf2d_draw], buf_0 ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
stdcall [buf2d_draw], buf_pl ;®¡­®¢«ï¥¬ ¡ãä¥à ­  íªà ­¥
.end_f:
ret
if 0
;input:
; buf - 㪠§ â¥«ì ­  áâபã, ç¨á«® ¤®«¦­® ¡ëâì ¢ 10 ¨«¨ 16 à¨ç­®¬ ¢¨¤¥
;output:
; eax - ç¨á«®
align 4
proc conv_str_to_int, buf:dword
xor eax,eax
push ebx ecx esi
xor ebx,ebx
mov esi,[buf]
;®¯à¥¤¥«¥­¨¥ ®âà¨æ â¥«ì­ëå ç¨á¥«
xor ecx,ecx
inc ecx
cmp byte[esi],'-'
jne @f
dec ecx
inc esi
@@:
cmp word[esi],'0x'
je .load_digit_16
.load_digit_10: ;áç¨â뢠­¨¥ 10-â¨ç­ëå æ¨äà
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'9'
jg @f
sub bl,'0'
imul eax,10
add eax,ebx
inc esi
jmp .load_digit_10
jmp @f
.load_digit_16: ;áç¨â뢠­¨¥ 16-à¨ç­ëå æ¨äà
add esi,2
.cycle_16:
mov bl,byte[esi]
cmp bl,'0'
jl @f
cmp bl,'f'
jg @f
cmp bl,'9'
jle .us1
cmp bl,'A'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'9' ¨ <'A'
.us1: ;á®áâ ¢­®¥ ãá«®¢¨¥
cmp bl,'F'
jle .us2
cmp bl,'a'
jl @f ;®âᥨ¢ ¥¬ ᨬ¢®«ë >'F' ¨ <'a'
sub bl,32 ;¯¥à¥¢®¤¨¬ ᨬ¢®«ë ¢ ¢¥àå­¨© ॣ¨áâà, ¤«ï ã¯à®é¥­¨ï ¨å ¯®á«¥¤ã饩 ®¡à ¡®âª¨
.us2: ;á®áâ ¢­®¥ ãá«®¢¨¥
sub bl,'0'
cmp bl,9
jle .cor1
sub bl,7 ;convert 'A' to '10'
.cor1:
shl eax,4
add eax,ebx
inc esi
jmp .cycle_16
@@:
cmp ecx,0 ;¥á«¨ ç¨á«® ®âà¨æ â¥«ì­®¥
jne @f
sub ecx,eax
mov eax,ecx
@@:
pop esi ecx ebx
ret
endp
end if
;¤ ­­ë¥ ¤«ï ¤¨ «®£  ®âªàëâ¨ï ä ©«®¢
align 4
OpenDialog_data:
.type dd 0 ;0 - ®âªàëâì, 1 - á®åà ­¨âì, 2 - ¢ë¡à âì ¤â४â®à¨î
.procinfo dd procinfo ;+4
.com_area_name dd communication_area_name ;+8
.com_area dd 0 ;+12
.opendir_path dd plugin_path ;+16
.dir_default_path dd default_dir ;+20
.start_path dd file_name ;+24 ¯ãâì ª ¤¨ «®£ã ®âªàëâ¨ï ä ©«®¢
.draw_window dd draw_window ;+28
.status dd 0 ;+32
.openfile_path dd openfile_path ;+36 ¯ãâì ª ®âªà뢠¥¬®¬ã ä ©«ã
.filename_area dd filename_area ;+40
.filter_area dd Filter
.x:
.x_size dw 420 ;+48 ; Window X size
.x_start dw 10 ;+50 ; Window X position
.y:
.y_size dw 320 ;+52 ; Window y size
.y_start dw 10 ;+54 ; Window Y position
default_dir db '/rd/1',0
communication_area_name:
db 'FFFFFFFF_open_dialog',0
open_dialog_name:
db 'opendial',0
communication_area_default_path:
db '/rd/1/File managers/',0
Filter:
dd Filter.end - Filter ;.1
.1:
db 'VOX',0
.end:
db 0
head_f_i:
head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
system_dir_0 db '/sys/lib/'
lib_name_0 db 'proc_lib.obj',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
system_dir_1 db '/sys/lib/'
lib_name_1 db 'libimg.obj',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
system_dir_2 db '/sys/lib/'
lib_name_2 db 'buf2d.obj',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
l_libs_start:
lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
l_libs_end:
align 4
import_libimg:
dd alib_init1
img_is_img dd aimg_is_img
img_info dd aimg_info
img_from_file dd aimg_from_file
img_to_file dd aimg_to_file
img_from_rgb dd aimg_from_rgb
img_to_rgb dd aimg_to_rgb
img_to_rgb2 dd aimg_to_rgb2
img_decode dd aimg_decode
img_encode dd aimg_encode
img_create dd aimg_create
img_destroy dd aimg_destroy
img_destroy_layer dd aimg_destroy_layer
img_count dd aimg_count
img_lock_bits dd aimg_lock_bits
img_unlock_bits dd aimg_unlock_bits
img_flip dd aimg_flip
img_flip_layer dd aimg_flip_layer
img_rotate dd aimg_rotate
img_rotate_layer dd aimg_rotate_layer
img_draw dd aimg_draw
dd 0,0
alib_init1 db 'lib_init',0
aimg_is_img db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ­­ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª  ᤥ« âì ¨§ ­¨å ¨§®¡à ¦¥­¨¥
aimg_info db 'img_info',0
aimg_from_file db 'img_from_file',0
aimg_to_file db 'img_to_file',0
aimg_from_rgb db 'img_from_rgb',0
aimg_to_rgb db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ­¨¥ ¨§®¡à ¦¥­¨ï ¢ ¤ ­­ë¥ RGB
aimg_to_rgb2 db 'img_to_rgb2',0
aimg_decode db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ­­ëå
aimg_encode db 'img_encode',0
aimg_create db 'img_create',0
aimg_destroy db 'img_destroy',0
aimg_destroy_layer db 'img_destroy_layer',0
aimg_count db 'img_count',0
aimg_lock_bits db 'img_lock_bits',0
aimg_unlock_bits db 'img_unlock_bits',0
aimg_flip db 'img_flip',0
aimg_flip_layer db 'img_flip_layer',0
aimg_rotate db 'img_rotate',0
aimg_rotate_layer db 'img_rotate_layer',0
aimg_draw db 'img_draw',0
align 4
proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start
dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0
align 4
import_buf2d:
init dd sz_init
buf2d_create dd sz_buf2d_create
buf2d_create_f_img dd sz_buf2d_create_f_img
buf2d_clear dd sz_buf2d_clear
buf2d_draw dd sz_buf2d_draw
buf2d_delete dd sz_buf2d_delete
buf2d_line dd sz_buf2d_line
buf2d_rect_by_size dd sz_buf2d_rect_by_size
buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
buf2d_circle dd sz_buf2d_circle
buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
buf2d_bit_blt dd sz_buf2d_bit_blt
buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
buf2d_curve_bezier dd sz_buf2d_curve_bezier
buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
buf2d_draw_text dd sz_buf2d_draw_text
buf2d_crop_color dd sz_buf2d_crop_color
buf2d_offset_h dd sz_buf2d_offset_h
buf2d_flood_fill dd sz_buf2d_flood_fill
buf2d_set_pixel dd sz_buf2d_set_pixel
buf2d_get_pixel dd sz_buf2d_get_pixel
buf2d_vox_brush_create dd sz_buf2d_vox_brush_create
buf2d_vox_brush_delete dd sz_buf2d_vox_brush_delete
dd 0,0
sz_init db 'lib_init',0
sz_buf2d_create db 'buf2d_create',0
sz_buf2d_create_f_img db 'buf2d_create_f_img',0
sz_buf2d_clear db 'buf2d_clear',0
sz_buf2d_draw db 'buf2d_draw',0
sz_buf2d_delete db 'buf2d_delete',0
sz_buf2d_line db 'buf2d_line',0
sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
sz_buf2d_circle db 'buf2d_circle',0
sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
sz_buf2d_bit_blt db 'buf2d_bit_blt',0
sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
sz_buf2d_draw_text db 'buf2d_draw_text',0
sz_buf2d_crop_color db 'buf2d_crop_color',0
sz_buf2d_offset_h db 'buf2d_offset_h',0
sz_buf2d_flood_fill db 'buf2d_flood_fill',0
sz_buf2d_set_pixel db 'buf2d_set_pixel',0
sz_buf2d_get_pixel db 'buf2d_get_pixel',0
sz_buf2d_vox_brush_create db 'buf2d_vox_brush_create',0
sz_buf2d_vox_brush_delete db 'buf2d_vox_brush_delete',0
mouse_dd dd 0x0
sc system_colors
align 16
procinfo process_information
;¡ãä¥à ®á­®¢­®£® ¨§®¡à ¦¥­¨ï
align 4
buf_0: dd 0 ;㪠§ â¥«ì ­  ¤a­ë¥ ¨§®¡à ¦¥­¨ï
.l: dw 5 ;+4 left
.t: dw 45 ;+6 top
.w: dd 192 ;+8 w
.h: dd 224 ;+12 h
.color: dd 0xffffff ;+16 color
db 24 ;+20 bit in pixel
;¡ãä¥à £«ã¡¨­ë ®á­®¢­®£® ¨§®¡à ¦¥­¨ï
align 4
buf_0z: dd 0
dw 0 ;+4 left
dw 0 ;+6 top
.w: dd 192 ;+8 w
.h: dd 224 ;+12 h
.color: dd 0 ;+16 color
db 32 ;+20 bit in pixel
;¡ãä¥à ¤«ï à¨á®¢ ­¨ï á१  ®¡ê¥ªâ 
align 4
buf_pl: dd 0
.l: dw 10+192 ;+4 left
.t: dw 45 ;+6 top
.w: dd 320 ;+8 w
.h: dd 330 ;+12 h
.color: dd 0xffffff ;+16 color
db 24 ;+20 bit in pixel
;¡ãä¥à ¤«ï ã«ãç襭®£® ७¤¥à 
align 4
buf_r_img:
rb BUF_STRUCT_SIZE
align 4
buf_r_z:
rb BUF_STRUCT_SIZE
;¤ ­­ë¥ ¤«ï ᮧ¤ ­¨ï ¬¨­¨¬ «ì­®£® ¥¤¨­¨ç­®£® ¢®ªá¥«ï
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)
i_end:
rb 2048
stacktop:
sys_path rb 1024
file_name:
rb 1024 ;4096
library_path rb 1024
plugin_path rb 4096
openfile_path rb 4096
filename_area rb 256
mem: