fix selection rectangle

git-svn-id: svn://kolibrios.org@6379 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2016-03-26 19:14:00 +00:00
parent 50b7ed90e3
commit 7ddfc6356d
3 changed files with 231 additions and 98 deletions

View File

@ -269,19 +269,25 @@ Picture_SizeX rd 1
Picture_SizeY rd 1
ScreenX rd 1 ;ª®®à¤¨­ â  x ªãàá®à  á ãç¥â®¬ ¬ áèâ ¡ 
ScreenY rd 1 ;ª®®à¤¨­ â  y ªãàá®à  á ãç¥â®¬ ¬ áèâ ¡ 
WorkScreen_SizeX rd 1
WorkScreen_SizeY rd 1
WorkScreen_SizeX rd 1 ;è¨à¨­  à ¡®ç¥£® íªà ­ 
WorkScreen_SizeY rd 1 ;¢ëá®â  à ¡®ç¥£® íªà ­ 
MaxWorkScreen_SizeX rd 1
MaxWorkScreen_SizeY rd 1
k rd 1 ;¬ áèâ ¡
ReserveArray rd 1
register rd 1
CounterX rd 1
ReserveArray rd 1 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¨á¯®«ì§ã¥¬ãî ¯à¨ à¨á®¢ ­¨¨ 䨣ãà
;¤«ï á®åà ­¥­¨ï ãç á⪮¢ ä®­  ¯®¤ 䨣ãà ¬¨,   â ª¦¥ ¤«ï § «¨¢ª¨
CounterX rd 1 ;ç¨á«® ¯¨ªá¥«¥© ¨§®¡à ¦¥­¨ï ¯® è¨à¨­¥, ª®â®àë¥ ¯®¯ ¤ îâ
;¢ íªà ­ à ¡®ç¥© ®¡« áâ¨, á ãç¥â®¬ ⥪ã饣® ¬ áèâ ¡ 
CounterY rd 1
OffsetYPicture rd 1
OffsetYWorkScreen rd 1
OffsetYBigPixel rd 1
OffsetYPicture rd 1 ;ᤢ¨£ ¯® ®á¨ y ¢ ¡ãä¥à¥ ¨§®¡à ¦¥­¨ï ¯à¨ à¨á®¢ ­¨¨
;á«¥¤ãî饩 «¨­¨¨ ¨§®¡à ¦¥­¨ï
OffsetYWorkScreen rd 1 ;ᤢ¨£ ¯® ®á¨ y ¢ ¡ãä¥à¥ à ¡®ç¥© ®¡« á⨠¯à¨
;à¨á®¢ ­¨¨ á«¥¤ãî饩 «¨­¨¨ ¯¨ªá¥«¥©. —¥¬ ¡®«ìè¥ ¬ áèâ ¡, ⥬ ­¨¦¥
;­ã¦­® ®¯ã᪠âìáï ¯® à ¡®ç¥© ®¡« áâ¨.
OffsetYBigPixel rd 1 ;ᤢ¨£ ¯® ®á¨ y ¤«ï à¨á®¢ ­¨ï ¯¨ªá¥«¥© ­  ¡®«ì讬
;¬ áèâ ¡¥. <20>¨áã¥âáï 1-ï ¯®«®á  ¯¨ªá¥«ï,   ¯®â®¬ ­ã¦­® ¯¥à¥©â¨ ¢­¨§ ¨
;¢«¥¢® ¤«ï à¨á®¢ ­¨ï á«¥¤ãî饩 ¯®«®áë.
Icon_X rd 1
Icon_Y rd 1

View File

@ -1164,24 +1164,24 @@ TakeButtonInstruments:
mov edi,[rectangular_shade_y]
sub esi,eax
jns no_sign_sprite_size_x
neg esi
no_sign_sprite_size_x:
jns @f
neg esi ;sign sprite size x
@@:
sub edi,ebx
jns no_sign_sprite_size_y
neg edi
no_sign_sprite_size_y:
jns @f
neg edi ;sign sprite size y
@@:
test esi,esi
jnz no_null_sprite_x
mov esi,1
no_null_sprite_x:
jnz @f
mov esi,1 ;null sprite x
@@:
test edi,edi
jnz no_null_sprite_y
mov edi,1
no_null_sprite_y:
jnz @f
mov edi,1 ;null sprite y
@@:
mov [SpriteSizeX],esi
mov [SpriteSizeY],edi
@ -1213,7 +1213,6 @@ TakeButtonInstruments:
test eax,eax
jnz crossing_with_work_area
mov [finishing_crossing],1
mov [register],1
crossing_with_work_area:
pop [ScreenY]
@ -1245,68 +1244,66 @@ TakeButtonInstruments:
mov [SpriteCoordinatY],ebx
cmp [SpriteCoordinatX],0
jns no_null_sprite_coordinat_x
mov [SpriteCoordinatX],1
no_null_sprite_coordinat_x:
jns @f
mov [SpriteCoordinatX],1 ;null sprite coordinat x
@@:
cmp [SpriteCoordinatY],0
jns no_null_sprite_coordinat_y
mov [SpriteCoordinatY],1
no_null_sprite_coordinat_y:
jns @f
mov [SpriteCoordinatY],1 ;null sprite coordinat y
@@:
mov esi,[rectangular_shade_x]
mov edi,[rectangular_shade_y]
sub esi,[OldX]
jns no_znak_size_of_rectangulare_crossing_x
neg esi
no_znak_size_of_rectangulare_crossing_x:
jns @f
neg esi
@@:
sub edi,[OldY]
jns no_znak_size_of_rectangulare_crossing_y
neg edi
no_znak_size_of_rectangulare_crossing_y:
jns @f
neg edi
@@:
mov ecx,[OldX]
mov edx,[OldY]
sub ecx,[PosX]
jns no_minimum_x_crossing
mov ecx,0
jns @f
xor ecx,ecx
add ecx,[PosX]
mov [OldX],ecx
add ecx,esi
mov [rectangular_shade_x],ecx
no_minimum_x_crossing:
@@:
sub edx,[PosY]
jns no_minimum_y_crossing
mov edx,0
jns @f
xor edx,edx
add edx,[PosY]
mov [OldY],edx
add edx,edi
mov [rectangular_shade_y],edx
no_minimum_y_crossing:
@@:
mov ecx,[Picture_SizeX]
sub ecx,esi
cmp [OldX],ecx
jl no_maximum_x_crossing
jl @f
dec ecx
mov [OldX],ecx
add ecx,esi
mov [rectangular_shade_x],ecx
no_maximum_x_crossing:
@@:
mov edx,[Picture_SizeY]
sub edx,edi
cmp [OldY],edx
jl no_maximum_y_crossing
jl @f
dec edx
mov [OldY],edx
add edx,edi
mov [rectangular_shade_y],edx
no_maximum_y_crossing:
@@:
mov eax,[rectangular_shade_x]
mov ebx,[rectangular_shade_y]
@ -1323,9 +1320,9 @@ TakeButtonInstruments:
jne no_activate_put_fon_
cmp [Paste_flag],1
je no_put_fon___
call PutFonForSprite
no_put_fon___:
je @f
call PutFonForSprite
@@:
and [Paste_flag],0
no_activate_put_fon_:
@ -1355,16 +1352,16 @@ TakeButtonInstruments:
mov ebp,[Picture_SizeX]
dec ebp
cmp esi,ebp
jl no_minimum_x_allocation
mov esi,ebp
no_minimum_x_allocation:
jl @f
mov esi,ebp ;minimum x allocation
@@:
mov ebp,[Picture_SizeY]
dec ebp
cmp edi,ebp
jl no_minimum_y_allocation
mov edi,ebp
no_minimum_y_allocation:
jl @f
mov edi,ebp ;minimum y allocation
@@:
call calculate_rectangle
@ -1372,7 +1369,7 @@ TakeButtonInstruments:
square_width_save
cmp [DrawSprite_flag],1
jne no_save_fon_for_sprite_
jne @f
;save current coordinats as old
mov eax,[SpriteCoordinatX]
mov ebx,[SpriteCoordinatY]
@ -1381,40 +1378,12 @@ TakeButtonInstruments:
call SaveFonForSprite
no_save_fon_for_sprite_:
;draw calculated pixels on work arrea
mov ebx,[ReserveArray]
mov ecx,[ebx]
add ebx,4
next_pixel_put_allocation:
mov edx,0x1f3fff
mov esi,edx
shr edx,16
mov ebp,ecx
and ebp,8
cmp ebp,8
jne black_color
mov si,0xffff
mov dl,0xff
black_color:
mov eax,[ebx]
mov [eax],si
mov [eax+2],dl
add ebx,4
dec ecx
jnz next_pixel_put_allocation
@@:
cmp [DrawSprite_flag],1
jne no_activate_draw_sprite_
call DrawSprite
no_activate_draw_sprite_:
jne @f
call DrawSprite
@@:
mov al,[instrument_used]
test al,al

View File

@ -90,12 +90,11 @@ screen_y_1:
screen_x_1:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov [ebx],bp
mov [ebx+2],cl
add ebx,3;
add ebx,3
add eax,3
dec esi
jnz screen_x_1
@ -114,7 +113,6 @@ screen_y_2:
screen_x_2:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov edx,ebx
@ -128,8 +126,6 @@ screen_x_2:
mov [edx+2],cl
mov [edx+3],bp
mov [edx+3+2],cl
add edx,3*2
add edx,[OffsetYBigPixel]
add ebx,3*2
add eax,3
dec esi
@ -149,7 +145,6 @@ screen_y_4:
screen_x_4:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
mov edx,ebx
@ -191,8 +186,6 @@ screen_x_4:
mov [edx+6+2],cl
mov [edx+9],bp
mov [edx+9+2],cl
add edx,3*4
add edx,[OffsetYBigPixel]
add ebx,4*3
add eax,3
dec esi
@ -210,7 +203,6 @@ screen_y:
screen_x:
mov ecx,[eax]
and ecx,0xffffff
mov ebp,ecx
shr ecx,16
;---------------------------------------------------------
@ -243,17 +235,183 @@ big_pixel_x:
jnz screen_y
fps:
mov ebx,[ScreenPointer]
;calculate selection rect
cmp [instrument_used],1
jne .no_selection_rect
mov edx,[rectangular_shade_y]
sub edx,[PosY]
mov ecx,[rectangular_shade_x]
sub ecx,[PosX]
mov ebx,[OldY]
sub ebx,[PosY]
mov eax,[OldX]
sub eax,[PosX]
cmp [k],1
je .zo_1
cmp eax,ecx
jle @f
xchg eax,ecx
@@:
cmp ebx,edx
jle @f
xchg ebx,edx
@@:
inc eax
inc ebx
imul eax,[k]
imul ebx,[k]
imul ecx,[k]
imul edx,[k]
dec eax
dec ebx
.zo_1:
stdcall draw_selection_rect, eax,ebx,ecx,edx
.no_selection_rect:
mov ecx,[WorkScreen_SizeX]
shl ecx,16
add ecx,[WorkScreen_SizeY]
mov edx,((ci_edit_wnd_x_pos+ci_edit_wnd_border) shl 16)\
+ (ci_edit_wnd_y_pos+ci_edit_wnd_border)
mcall SF_PUT_IMAGE
mcall SF_PUT_IMAGE, [ScreenPointer]
ret
;----------------------------------------------------------
align 4
proc draw_selection_rect, x0:dword, y0:dword, x1:dword, y1:dword
mov eax,0xffff3fff ;2:2
mov edx,0xff1f ;1:1
mov edi,[x0]
mov ebx,[y0]
mov ecx,[x1]
cmp edi,ecx
jle @f
xchg edi,ecx
@@:
call draw_line_h
mov ebx,[y1]
call draw_line_h
mov edi,[x0]
mov ecx,[y0]
cmp ebx,ecx
jle @f
xchg ebx,ecx
@@:
call draw_line_w
mov edi,[x1]
call draw_line_w
ret
endp
;input:
; eax - color1(g,r):color2(g,r)
; dx - color1(b):color2(b)
; edi - x0
; ebx - y0
; ecx - x1 (x1 >= x0)
align 4
draw_line_h:
cmp edi,ecx
je .end_f
cmp ecx,1
jl .end_f
cmp edi,[WorkScreen_SizeX]
jge .end_f
cmp ebx,0
jl .end_f
cmp ebx,[WorkScreen_SizeY]
jge .end_f
push ebx ecx edi
cmp ecx,[WorkScreen_SizeX]
jl @f
mov ecx,[WorkScreen_SizeX]
@@:
cmp edi,0
jge @f
xor edi,edi
@@:
sub ecx,edi
imul ebx,[WorkScreen_SizeX]
add edi,ebx
lea edi,[edi+edi*2]
add edi,[ScreenPointer]
cld
.line_t:
stosw
mov byte[edi],dl
inc edi
bt ecx,1
jc @f
bt ecx,0
jc @f
ror eax,16
ror dx,8
@@:
dec ecx
jnz .line_t
pop edi ecx ebx
.end_f:
ret
;input:
; eax - color1(g,r):color2(g,r)
; dx - color1(b):color2(b)
; edi - x0
; ebx - y0
; ecx - y1 (y1 >= y0)
align 4
draw_line_w:
cmp edi,0
jl .end_f
cmp edi,[WorkScreen_SizeX]
jge .end_f
cmp ebx,ecx
je .end_f
cmp ebx,[WorkScreen_SizeY]
jge .end_f
cmp ecx,1
jl .end_f
push ebx ecx edi
cmp ecx,[WorkScreen_SizeY]
jl @f
mov ecx,[WorkScreen_SizeY]
@@:
cmp ebx,0
jge @f
xor ebx,ebx
@@:
sub ecx,ebx
cmp ecx,1
jl .end_f
imul ebx,[WorkScreen_SizeX]
add edi,ebx
lea edi,[edi+edi*2]
add edi,[ScreenPointer]
mov ebx,[WorkScreen_SizeX]
lea ebx,[ebx+ebx*2]
sub ebx,2
cld
.line_r:
stosw
mov byte[edi],dl
add edi,ebx
bt ecx,1
jc @f
bt ecx,0
jc @f
ror eax,16
ror dx,8
@@:
dec ecx
jnz .line_r
pop edi ecx ebx
.end_f:
ret
;----------------------------------------------------------
;--------------------clear screen--------------------------
;----------------------------------------------------------
align 4
cleare_screen:
mov edi,[ScreenPointer]
mov ebx,[WorkScreen_SizeX]