macro square_width_put
{
local .no_put_to_screen
local .next_color_put
local .vertical_width_put
local .horizontal_width_put
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz .no_put_to_screen
mov ecx,[ebx]
add ebx,4
xor ebp,ebp
.next_color_put:
;put saved pixels in ReserveArray
push ecx
mov [counter2],5
mov edi,[ebx]
push edi
.vertical_width_put:
mov [counter],5
.horizontal_width_put:
mov edx,[ebx+4807*4+ebp]
;and edx,0xffffff
mov [edi],dx
shr edx,16
mov [edi+2],dl
add edi,3
add ebp,4
dec [counter]
jnz .horizontal_width_put
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
dec [counter2]
jnz .vertical_width_put
pop edi
pop ecx
add ebx,4
dec ecx
jnz .next_color_put
.no_put_to_screen:
}
macro square_width_save
{
local .next_color_save
local .vertical_width_save
local .horizontal_width_save
mov ebx,[ReserveArray]
mov [ebx],eax
mov ecx,eax
add ebx,4
xor ebp,ebp
.next_color_save:
;save color of pixel in ReserveArray
push ecx
mov [counter2],5
mov edi,[ebx]
.vertical_width_save:
mov [counter],5
.horizontal_width_save:
mov eax,edi
mov edx,[eax]
;and edx,0xffffff
mov [ebx+4807*4+ebp],dx
shr edx,16
mov [ebx+4807*4+2+ebp],dl
add edi,3
add ebp,4
dec [counter]
jnz .horizontal_width_save
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add edi,ecx
dec [counter2]
jnz .vertical_width_save
pop ecx
add ebx,4
dec ecx
jnz .next_color_save
}
macro draw_calc_pixels brush
{
local .next_pixel_put
local .vertical_width
local .horizontal_width
local .no_draw_pixel
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[line_width]
dec edi
imul edi,25
add edi,brush
.next_pixel_put:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
mov [counter2],5
.vertical_width:
mov [counter],5
.horizontal_width:
xor ecx,ecx
mov cl,byte[edi+ebp]
test cl,cl
jz .no_draw_pixel
mov [eax],si
mov [eax+2],dl
.no_draw_pixel:
add eax,3
inc ebp
dec [counter]
jnz .horizontal_width
mov ecx,[Picture_SizeX]
sub ecx,5
lea ecx,[ecx+ecx*2]
add eax,ecx
dec [counter2]
jnz .vertical_width
pop ecx
pop eax
add ebx,4
dec ecx
jnz .next_pixel_put
}
;-----------------------------------------------------------
;-----instruments of panel(icon's instruments)--------------
;-----------------------------------------------------------
;input:
; [Current_instrument] - instrument code
;
; *** instrument codes ***
;10 - pensil
;11 - draw brush
;12 - spray
;13 - lastik
;14 - flood fill
;15 - pipetka
;16 - draw line
;17 - draw rectangle
;18 - draw circle
;19 - draw ellips
;20 - draw hard contour
;21 - allocation of a countour
;23 - reflection from left to right
;24 - reflection from up to down
;40 - brush 1
;41 - brush 2
;42 - brush 3
;43 - brush 4
;44 - brush 5
;45 - zoom 1
;46 - zoom 2
;47 - zoom 3
;48 - zoom 4
;49 - zoom 8
;50 - zoom 16
;51 - palette
align 4
TakeButtonInstruments:
mov eax,[Current_instrument]
;*************************brush 1***********************
cmp eax,40
jne no_brush1
mov [Brush_SizeX],4
mov [Brush_SizeY],4
mov [Number_Brush],0
mov ebx,[Last_instrument]
mov [Current_instrument],ebx
mov [line_width],1
ret
no_brush1:
;*************************brush 2***********************
cmp eax,41
jne no_brush2
mov [Brush_SizeX],6
mov [Brush_SizeY],4
mov [Number_Brush],1
mov ebx,[Last_instrument]
mov [Current_instrument],ebx
mov [line_width],2
ret
no_brush2:
;*************************brush 3***********************
cmp eax,42
jne no_brush3
mov [Brush_SizeX],8
mov [Brush_SizeY],7
mov [Number_Brush],2
mov ebx,[Last_instrument]
mov [Current_instrument],ebx
mov [line_width],3
ret
no_brush3:
;*************************brush 4***********************
cmp eax,43
jne no_brush4
mov [Brush_SizeX],14
mov [Brush_SizeY],14
mov [Number_Brush],3
mov ebx,[Last_instrument]
mov [Current_instrument],ebx
mov [line_width],4
ret
no_brush4:
;*************************brush 5***********************
cmp eax,44
jne no_brush5
mov [Brush_SizeX],6
mov [Brush_SizeY],6
mov [Number_Brush],4
mov ebx,[Last_instrument]
mov [Current_instrument],ebx
mov [line_width],5
ret
no_brush5:
;*************************pensil************************
cmp eax,10
jne no_pensil
mov al,[exit_from_work_arrea]
test al,al
jz no_exit_from_work_arrea
and [Activate_instrument],0
and [exit_from_work_arrea],0
no_exit_from_work_arrea:
mov al,[Activate_instrument]
test al,al
jnz no_activated_later
call GetScreenCordinats
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
no_activated_later:
mov eax,[PointerToPicture]
mov ebx,[ReserveArray]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
call calculate_line
mov ecx,eax
mov edx,[Color]
mov esi,[Color]
shr edx,16
xor ebx,ebx
mov eax,[ReserveArray]
pensil_next_pixel_draw:
mov ebx,[eax]
mov [ebx],si
mov [ebx+2],dl
add eax,4
dec ecx
jnz pensil_next_pixel_draw
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
call MovePictureToWorkScreen
mov [Activate_instrument],1
ret
no_pensil:
;*************************draw brush********************
cmp eax,11
jne no_brush
mov [Last_instrument],eax
jmp no_lastik_
lastik_in:
mov eax,[Color]
mov [SColor],eax
mov [Color],0xffffff
no_lastik_:
mov eax,[ScreenX]
mov ebx,[ScreenY]
mov ecx,[Brush_SizeX]
mov edx,[Brush_SizeY]
add eax,[PosX]
add ebx,[PosY]
add eax,ecx
add ebx,edx
cmp eax,[Picture_SizeX]
jl no_max_pos_x
mov eax,[Picture_SizeX]
no_max_pos_x:
cmp ebx,[Picture_SizeY]
jl no_max_pos_y
mov ebx,[Picture_SizeY]
no_max_pos_y:
cmp eax,ecx
ja no_min_pos_x
mov eax,[Brush_SizeX]
no_min_pos_x:
cmp ebx,edx
ja no_min_pos_y
mov ebx,[Brush_SizeY]
no_min_pos_y:
sub eax,[Brush_SizeX]
sub ebx,[Brush_SizeY]
mov [x],eax
mov [y],ebx
mov al,[exit_from_work_arrea]
test al,al
jz no_exit_from_work_arrea_brush
and [Activate_instrument],0
and [exit_from_work_arrea],0
no_exit_from_work_arrea_brush:
mov al,[Activate_instrument]
test al,al
jnz no_new_brush_xy
mov eax,[x]
mov ebx,[y]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
no_new_brush_xy:
mov eax,[PointerToPicture]
mov ebx,[ReserveArray]
add ebx,4
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[x]
mov edi,[y]
call calculate_line
mov ebx,[ReserveArray]
mov [ebx],eax
;procedure drawing of brush
mov ebx,[ReserveArray]
mov ecx,[ebx]
mov edx,[Color]
mov esi,[Color]
shr edx,16
add ebx,4
mov edi,[Number_Brush]
imul edi,20*20
next_pixel_put_brush:
mov eax,[ebx]
push eax
push ecx
xor ebp,ebp
and [counter2],0
vertical_width_brush:
and [counter],0
horizontal_width_brush:
xor ecx,ecx
mov cl,byte[Brush_color+edi+ebp]
test cl,cl
jz no_draw_pixel_brush
mov [eax],si
mov [eax+2],dl
no_draw_pixel_brush:
add eax,3
inc ebp
inc [counter]
cmp [counter],20
jne horizontal_width_brush
mov ecx,[Picture_SizeX]
sub ecx,20
lea ecx,[ecx+ecx*2]
add eax,ecx
inc [counter2]
cmp [counter2],20
jne vertical_width_brush
pop ecx
pop eax
add ebx,4
dec ecx
jnz next_pixel_put_brush
mov eax,[x]
mov ebx,[y]
mov [OldX],eax
mov [OldY],ebx
mov al,[lastik_is_active]
test al,al
jz no_lastik_active
mov eax,[SColor]
mov [Color],eax
and [lastik_is_active],0
no_lastik_active:
call MovePictureToWorkScreen
mov eax,[Current_instrument]
mov [Last_instrument],eax
ret
no_brush:
;*************************pipetka***********************
cmp eax,15
jne no_pipetka
mov eax,[ScreenY]
mov ebx,[Picture_SizeX]
add eax,[PosY]
imul eax,ebx
add eax,[ScreenX]
add eax,[PosX]
lea eax,[eax+eax*2]
add eax,[PointerToPicture]
mov ebx,[eax]
and ebx,0xffffff
mov [Color],ebx
mcall SF_DRAW_RECT, ((ci_panel_x_pos+130) shl 16)+21,\
((ci_panel_y_pos+28) shl 16)+21, [Color]
ret
no_pipetka:
;************************lastik*************************
cmp eax,13
jne no_lastik
mov [Last_instrument],eax
mov [lastik_is_active],1
jmp lastik_in
no_lastik:
;************************Flood Fill*********************
cmp eax,14
jne no_FloodFill
mov eax,[PointerToPicture]
mov ebx,[PointerToEditBufer]
mov ecx,[Picture_SizeX]
imul ecx,[Picture_SizeY]
lea ecx,[ecx+ecx*2]
shl ecx,1
cmp ecx,mem_flood_f
ja normal_size_of_bufer
mov ebx,[ReserveArray]
normal_size_of_bufer:
add ebx,4
mov ecx,[Picture_SizeX]
mov edx,[ScreenX]
add edx,[PosX]
shl edx,16
add edx,[ScreenY]
add edx,[PosY]
mov esi,[Picture_SizeX]
dec esi
shl esi,16
add esi,[Picture_SizeY]
dec esi
mov edi,[Color]
call flood_fill
call MovePictureToWorkScreen
ret
no_FloodFill:
;************************spray**************************
cmp eax,12
jne no_spray
cmp [Activate_instrument],0
jne no_null_spray
mov [Activate_instrument],1
ret
no_null_spray:
mov eax,[ScreenX]
mov ebx,[ScreenY]
mov ecx,[Brush_SizeX]
mov edx,[Brush_SizeY]
add eax,[PosX]
add ebx,[PosY]
add eax,ecx
add ebx,edx
cmp eax,[Picture_SizeX]
jl no_max_pos_x_spray
mov eax,[Picture_SizeX]
no_max_pos_x_spray:
cmp ebx,[Picture_SizeY]
jl no_max_pos_y_spray
mov ebx,[Picture_SizeY]
no_max_pos_y_spray:
cmp eax,ecx
ja no_min_pos_x_spray
mov eax,[Brush_SizeX]
no_min_pos_x_spray:
cmp ebx,edx
ja no_min_pos_y_spray
mov ebx,[Brush_SizeY]
no_min_pos_y_spray:
sub eax,[Brush_SizeX]
sub ebx,[Brush_SizeY]
mov edi,0;[Number_Brush]
imul edi,20*20
mov [x],eax
mov [y],ebx
mov ebp,[Picture_SizeX]
xor edx,edx
brush_y_spray:
xor ecx,ecx
brush_x_spray:
;calculate position in array of spray
mov esi,edx
lea esi,[esi+esi*4] ;esi=esi*5
shl esi,2 ;esi=(esi*3)*4
add esi,ecx
add esi,edi
;read byte from array
xor eax,eax
mov al,[Spray_color+esi]
test eax,eax
jz no_color_spray
mov eax,[x]
mov ebx,[y]
add eax,ecx
add ebx,edx
imul ebx,ebp; ebp=[Picture_SizeX]
add eax,ebx
lea eax,[eax+eax*2]
add eax,[PointerToPicture]
mov ebx,[Color]
mov [eax],bx
shr ebx,16
mov [eax+2],bl
no_color_spray:
inc ecx
cmp ecx,20
jl brush_x_spray
inc edx
cmp edx,20
jl brush_y_spray
call MovePictureToWorkScreen
ret
no_spray:
;************************palette************************
cmp eax,51
jne no_palette
mov eax,20
mov ebx,ci_palete_y_pos
mov ecx,32*10+32*5+7
mov edx,140
mov esi,1
call draw_volume_rectangle
mov [x],20+5
mov [y],ci_palete_y_pos+10
mov edi,256
xor esi,esi
next_rectangle:
mov ebx,[x]
mov ecx,[y]
mov edx,[palitra+esi]
and edx,0xffffff
shl ebx,16
shl ecx,16
add ebx,13
add ecx,13
mcall SF_DRAW_RECT
add [x],15
cmp [x],20+15*32
jl no_new_line
mov [x],20+5
add [y],15
no_new_line:
add esi,4
dec edi
jnz next_rectangle
wait_events:
mcall SF_WAIT_EVENT
cmp eax,1
jne @f
ret
@@:
cmp eax,2
jne no_keys
mcall SF_GET_KEY
jmp wait_events
no_keys:
cmp eax,3
jne no_buttons
mcall SF_GET_BUTTON
jmp wait_events
no_buttons:
cmp eax,6
jne wait_events
call GetMouseClick
test eax,eax
jz wait_events
call GetMouseCoordinats
mov [x],20+5
mov [y],ci_palete_y_pos+10
mov [counter],0
next_rectangle_column:
mov eax,[x]
mov ebx,[y]
mov ecx,[MouseX]
mov edx,[MouseY]
mov esi,13
mov edi,13
call columnus
test eax,eax
jz no_columnus_color
mov eax,[counter]
shl eax,2
mov ebx,[palitra+eax]
and ebx,0xffffff
mov [Color],ebx
no_columnus_color:
add [x],15
cmp [x],20+15*32
jl no_new_line_column
mov [x],20+5
add [y],15
no_new_line_column:
inc [counter]
cmp [counter],257
jne next_rectangle_column
mcall SF_SLEEP,10
call drawwin
mov eax,[Last_instrument]
mov [Current_instrument],eax
ret
no_palette:
;************************draw line**********************
cmp eax,16
jne no_line
mov [Last_instrument],eax
mov al,[Activate_instrument]
test al,al
jnz no_new_line_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
xor eax,eax
mov ecx,mem_flood_f/4
mov edi,[ReserveArray]
cld
rep stosd
ret
no_new_line_xy:
;put saved pixels
square_width_put
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
mov ebp,[Picture_SizeX]
sub ebp,[line_width]
cmp esi,ebp
jl no_minimum_x_line
mov esi,ebp
no_minimum_x_line:
mov ebp,[Picture_SizeY]
sub ebp,[line_width]
cmp edi,ebp
jl no_minimum_y_line
mov edi,ebp
no_minimum_y_line:
call calculate_line
;save color pixels in ReserveArray
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels
call MovePictureToWorkScreen
ret
no_line:
;************************draw rectangle*****************
cmp eax,17
jne no_rectangle
mov [Last_instrument],eax
mov al,[Activate_instrument]
test al,al
jnz no_new_rectangle_xy
mov eax,[ScreenX]
mov ebx,[ScreenY]
add eax,[PosX]
add ebx,[PosY]
mov [OldX],eax
mov [OldY],ebx
mov [Activate_instrument],1
xor eax,eax
mov ecx,mem_flood_f/4
mov edi,[ReserveArray]
cld
rep stosd
ret
no_new_rectangle_xy:
;put saved pixels
square_width_put
;calculate line
mov ebx,[ReserveArray]
add ebx,4
mov eax,[PointerToPicture]
mov ecx,[Picture_SizeX]
mov edx,[OldX]
shl edx,16
add edx,[OldY]
mov esi,[ScreenX]
mov edi,[ScreenY]
add esi,[PosX]
add edi,[PosY]
mov ebp,[Picture_SizeX]
sub ebp,[line_width]
cmp esi,ebp
jl no_minimum_x_rectangle
mov esi,ebp
no_minimum_x_rectangle:
mov