mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-27 03:09:59 +03:00
function 'buf2d_line_sm' - fix error when the line is 45 degrees
git-svn-id: svn://kolibrios.org@9520 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
130b0311ad
commit
c5dc86cc2c
@ -13,6 +13,8 @@ include '../../../../../dll.inc'
|
||||
|
||||
buf2d_l equ word[edi+4] ;®âáâ㯠᫥¢
|
||||
buf2d_t equ word[edi+6] ;®âáâ㯠ᢥàåã
|
||||
buf2d_w equ dword[edi+8]
|
||||
buf2d_h equ dword[edi+12]
|
||||
buf2d_color equ dword[edi+16] ;梥â ä® ¡ãä¥à
|
||||
|
||||
align 4
|
||||
@ -21,7 +23,7 @@ start:
|
||||
cmp eax,-1
|
||||
jz button.exit
|
||||
|
||||
mcall 40,0x27
|
||||
mcall SF_SET_EVENTS_MASK,0xC0000027
|
||||
stdcall [buf2d_create], buf_0 ;ᮧ¤ ¥¬ ¡ãä¥à
|
||||
;à¨á㥬 ¯¥à¢® ç «ìë© ª ¤à
|
||||
stdcall [buf2d_filled_rect_by_size], buf_0, 100-50,70-25, 100,50, 0xffffff ;à¨á㥬 ¯àאַ㣮«ì¨ª
|
||||
@ -34,7 +36,7 @@ red_win:
|
||||
|
||||
align 4
|
||||
still:
|
||||
mcall 10
|
||||
mcall SF_WAIT_EVENT
|
||||
cmp al,1 ;¨§¬¥¨«®áì ¯®«®¦¥¨¥ ®ª
|
||||
jz red_win
|
||||
cmp al,2
|
||||
@ -48,21 +50,21 @@ still:
|
||||
align 4
|
||||
draw_window:
|
||||
pushad
|
||||
mcall 12,1
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
|
||||
;mov edx,0x32000000
|
||||
mov edx,0x33000000
|
||||
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||
|
||||
stdcall [buf2d_draw], buf_0
|
||||
|
||||
mcall 12,2
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
popad
|
||||
ret
|
||||
|
||||
align 4
|
||||
key:
|
||||
mcall 2
|
||||
mcall SF_GET_KEY
|
||||
|
||||
cmp ah,27 ;Esc
|
||||
je button.exit
|
||||
@ -71,26 +73,30 @@ key:
|
||||
|
||||
align 4
|
||||
button:
|
||||
mcall 17 ;¯®«ãç¨âì ª®¤ ¦ ⮩ ª®¯ª¨
|
||||
mcall SF_GET_BUTTON
|
||||
cmp ah,1
|
||||
jne still
|
||||
.exit:
|
||||
stdcall [buf2d_delete],buf_0 ;㤠«ï¥¬ ¡ãä¥à
|
||||
mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
align 4
|
||||
mouse:
|
||||
;®¡à ¡ âë¢ ¥¬ ®ª® । ªâ®à
|
||||
mcall 37,2 ;get mouse buttons
|
||||
mcall SF_MOUSE_GET,SSF_BUTTON
|
||||
cmp al,1
|
||||
jne @f
|
||||
mcall 37,1 ;get mouse coords
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov ebx,eax
|
||||
shr ebx,16 ;¢ eax ª®®à¤¨ â ¬¨è¨ ¯® ®á¨ 'x'
|
||||
and eax,0xffff ;¢ eax ª®®à¤¨ â ¬¨è¨ ¯® ®á¨ 'y'
|
||||
mov edi,buf_0
|
||||
sub ax,buf2d_t ;ᤢ¨£ ¥¬ ª®®à¤¨ âë ãç¨âë¢ ï ᬥ饨¥ ¡ãä¥à
|
||||
cmp eax,buf2d_h
|
||||
jge @f
|
||||
sub bx,buf2d_l
|
||||
cmp ebx,buf2d_w
|
||||
jge @f
|
||||
|
||||
;à¨á®¢ ¨¥ ¯à¨ ¦ ⨨
|
||||
stdcall [buf2d_clear], edi, buf2d_color ;®ç¨é ¥¬ íªà ®â ¯à¥¤ë¤ãé¨å à¨á®¢ ¨©
|
||||
@ -164,6 +170,7 @@ system_path db '/sys/lib/'
|
||||
lib0_name db 'buf2d.obj',0
|
||||
;--------------------------------------------------
|
||||
|
||||
align 16
|
||||
i_end: ;ª®¥æ ª®¤
|
||||
rb 1024
|
||||
stacktop:
|
||||
|
@ -5,7 +5,7 @@
|
||||
align 16
|
||||
proc buf_draw_buf, buf_struc:dword
|
||||
pushad
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
cmp buf2d_bits,24
|
||||
jne .error
|
||||
mov eax,7
|
||||
@ -226,7 +226,7 @@ endp
|
||||
align 4
|
||||
proc buf_clear, buf_struc:dword, color:dword ;®ç¨á⪠¡ãä¥à § ¤ ë¬ æ¢¥â®¬
|
||||
pushad
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
|
||||
mov ecx,buf2d_w
|
||||
mov ebx,buf2d_h
|
||||
@ -275,15 +275,14 @@ locals
|
||||
napravl db ?
|
||||
endl
|
||||
pushad
|
||||
mov eax,dword[coord_x1]
|
||||
sub eax,dword[coord_x0]
|
||||
mov eax,[coord_x1]
|
||||
sub eax,[coord_x0]
|
||||
bt eax,31
|
||||
jae @f
|
||||
neg eax
|
||||
inc eax
|
||||
@@:
|
||||
mov ebx,dword[coord_y1]
|
||||
sub ebx,dword[coord_y0]
|
||||
mov ebx,[coord_y1]
|
||||
sub ebx,[coord_y0]
|
||||
jnz @f
|
||||
;¥á«¨ § ¤ £®à¨§®â «ì ï «¨¨ï y0=y1
|
||||
stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
|
||||
@ -292,9 +291,8 @@ endl
|
||||
bt ebx,31
|
||||
jae @f
|
||||
neg ebx
|
||||
inc ebx
|
||||
@@:
|
||||
mov edx,dword[color]
|
||||
mov edx,[color]
|
||||
|
||||
mov [napravl],byte 0 ;bool steep=false
|
||||
cmp eax,ebx
|
||||
@ -315,15 +313,15 @@ endl
|
||||
; int error ebp-6
|
||||
; int ystep ebp-8
|
||||
|
||||
mov eax,dword[coord_y0]
|
||||
mov esi,dword[coord_y1]
|
||||
mov eax,[coord_y0]
|
||||
mov esi,[coord_y1]
|
||||
sub esi,eax ;deltax = y1-y0
|
||||
mov ebx,esi
|
||||
shr ebx,1
|
||||
mov [loc_1],ebx ;error = deltax/2
|
||||
|
||||
mov eax,dword[coord_x0]
|
||||
mov edi,dword[coord_x1]
|
||||
mov edi,[coord_x1]
|
||||
mov [loc_2],dword -1 ;ystep = -1
|
||||
cmp eax,edi ;if (x0<x1) ystep = 1;
|
||||
jge @f
|
||||
@ -334,7 +332,6 @@ endl
|
||||
bts edi,31
|
||||
jae @f
|
||||
neg edi
|
||||
inc edi
|
||||
@@:
|
||||
and edi,0x7fffffff ;deltay = abs(x1-x0)
|
||||
|
||||
@ -399,15 +396,18 @@ locals
|
||||
napravl db ?
|
||||
endl
|
||||
pushad
|
||||
mov eax,dword[coord_x1]
|
||||
sub eax,dword[coord_x0]
|
||||
mov eax,[coord_x1]
|
||||
sub eax,[coord_x0]
|
||||
jnz @f
|
||||
stdcall buf_line_brs, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [coord_y1], [color] ;«¨¨ï |
|
||||
jmp .coord_end
|
||||
@@:
|
||||
bt eax,31
|
||||
jae @f
|
||||
neg eax
|
||||
inc eax
|
||||
@@:
|
||||
mov ebx,dword[coord_y1]
|
||||
sub ebx,dword[coord_y0]
|
||||
mov ebx,[coord_y1]
|
||||
sub ebx,[coord_y0]
|
||||
jnz @f
|
||||
;¥á«¨ § ¤ £®à¨§®â «ì ï «¨¨ï y0=y1
|
||||
stdcall buf_line_h, [buf_struc], [coord_x0], [coord_y0], [coord_x1], [color]
|
||||
@ -416,9 +416,8 @@ endl
|
||||
bt ebx,31
|
||||
jae @f
|
||||
neg ebx
|
||||
inc ebx
|
||||
@@:
|
||||
mov edx,dword[color]
|
||||
mov edx,[color]
|
||||
|
||||
mov [napravl],byte 0 ;bool steep=false
|
||||
cmp eax,ebx
|
||||
@ -427,8 +426,8 @@ endl
|
||||
swap dword[coord_x0],dword[coord_y0] ;swap(x0, y0);
|
||||
swap dword[coord_x1],dword[coord_y1] ;swap(x1, y1);
|
||||
@@:
|
||||
mov eax,dword[coord_y0] ;x0
|
||||
cmp eax,dword[coord_y1] ;if(x0>x1)
|
||||
mov eax,[coord_y0] ;x0
|
||||
cmp eax,[coord_y1] ;if(x0>x1)
|
||||
jle @f
|
||||
swap dword[coord_y0],dword[coord_y1] ;swap(x0, x1);
|
||||
swap dword[coord_x0],dword[coord_x1] ;swap(y0, y1);
|
||||
@ -439,15 +438,15 @@ endl
|
||||
; int error ebp-6
|
||||
; int ystep ebp-8
|
||||
|
||||
mov eax,dword[coord_y0]
|
||||
mov esi,dword[coord_y1]
|
||||
mov eax,[coord_y0]
|
||||
mov esi,[coord_y1]
|
||||
sub esi,eax ;deltax = y1-y0
|
||||
mov ebx,esi
|
||||
shr ebx,1
|
||||
mov [loc_1],ebx ;error = deltax/2
|
||||
|
||||
mov eax,dword[coord_x0]
|
||||
mov edi,dword[coord_x1]
|
||||
mov eax,[coord_x0]
|
||||
mov edi,[coord_x1]
|
||||
mov [loc_2],dword -1 ;ystep = -1
|
||||
cmp eax,edi ;if (x0<x1) ystep = 1;
|
||||
jge @f
|
||||
@ -458,7 +457,6 @@ endl
|
||||
bts edi,31
|
||||
jae @f
|
||||
neg edi
|
||||
inc edi
|
||||
@@:
|
||||
and edi,0x7fffffff ;deltay = abs(x1-x0)
|
||||
|
||||
@ -469,11 +467,11 @@ endl
|
||||
|
||||
cmp [napravl],0
|
||||
jne .coord_yx
|
||||
mov ebx,dword[coord_x0]
|
||||
mov ecx,dword[coord_y0]
|
||||
mov ebx,[coord_x0]
|
||||
mov ecx,[coord_y0]
|
||||
|
||||
@@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
|
||||
cmp ecx,dword[coord_y1]
|
||||
cmp ecx,[coord_y1]
|
||||
jg @f ;jge ???
|
||||
push eax
|
||||
mov eax,esi
|
||||
@ -484,7 +482,7 @@ endl
|
||||
stdcall draw_pixel_transp, [loc_1],esi
|
||||
sub ebx,[loc_2]
|
||||
|
||||
sub dword[loc_1],eax ;error -= deltay
|
||||
sub [loc_1],eax ;error -= deltay
|
||||
cmp dword[loc_1],0 ;if(error<0)
|
||||
jge .if0
|
||||
add ebx,[loc_2] ;y += ystep
|
||||
@ -495,11 +493,11 @@ endl
|
||||
@@:
|
||||
jmp .coord_end
|
||||
.coord_yx:
|
||||
mov ebx,dword[coord_y0]
|
||||
mov ecx,dword[coord_x0]
|
||||
mov ebx,[coord_y0]
|
||||
mov ecx,[coord_x0]
|
||||
|
||||
@@: ;for (x=x0 ; x<x1; x++) ;------------------------------------
|
||||
cmp ebx,dword[coord_y1]
|
||||
cmp ebx,[coord_y1]
|
||||
jg @f ;jge ???
|
||||
push eax
|
||||
mov eax,esi
|
||||
@ -510,7 +508,7 @@ endl
|
||||
stdcall draw_pixel_transp, [loc_1],esi
|
||||
sub ecx,[loc_2]
|
||||
|
||||
sub dword[loc_1],eax ;error -= deltay
|
||||
sub [loc_1],eax ;error -= deltay
|
||||
cmp dword[loc_1],0 ;if(error<0)
|
||||
jge .if1
|
||||
add ecx,[loc_2] ;y += ystep
|
||||
@ -623,8 +621,8 @@ pushad
|
||||
mov ecx,[w]
|
||||
;cmp ecx,1
|
||||
;jl .coord_end
|
||||
cmp ecx,0
|
||||
je .coord_end
|
||||
or ecx,ecx
|
||||
jz .coord_end
|
||||
jg @f
|
||||
add eax,ecx
|
||||
inc eax
|
||||
@ -635,8 +633,8 @@ pushad
|
||||
mov edx,[h]
|
||||
;cmp edx,1
|
||||
;jl .coord_end
|
||||
cmp edx,0
|
||||
je .coord_end
|
||||
or edx,edx
|
||||
jz .coord_end
|
||||
jg @f
|
||||
add ebx,edx
|
||||
inc ebx
|
||||
@ -645,7 +643,7 @@ pushad
|
||||
|
||||
add edx,ebx
|
||||
dec edx
|
||||
mov esi,dword[color]
|
||||
mov esi,[color]
|
||||
stdcall buf_line_h, edi, eax, ebx, ecx, esi ;«¨¨ï -
|
||||
stdcall buf_line_brs, edi, eax, ebx, eax, edx, esi ;«¨¨ï |
|
||||
stdcall buf_line_h, edi, eax, edx, ecx, esi ;«¨¨ï -
|
||||
@ -668,26 +666,24 @@ pushad
|
||||
mov eax,[coord_x]
|
||||
mov ebx,[coord_y]
|
||||
mov edx,[w]
|
||||
cmp edx,0
|
||||
je .coord_end ;¥á«¨ ¢ëá®â 0 ¯¨ªá¥«¥©
|
||||
or edx,edx
|
||||
jz .coord_end ;¥á«¨ ¢ëá®â 0 ¯¨ªá¥«¥©
|
||||
jg @f ;¥á«¨ ¢ëá®â ¯®«®¦¨â¥«ì ï
|
||||
add eax,edx
|
||||
inc eax
|
||||
neg edx ;è¨à¨ã ¤¥« ¥¬ ¯®«®¦¨â¥«ì®©
|
||||
;inc edx ;¯®ç¥¬ã âãâ ¥ ¤®¡ ¢«ï¥¬ 1-æã ï ¥ § î, ® á ¥© à ¡®â ¥â ¥ ¯à ¢¨«ì®
|
||||
@@:
|
||||
add edx,eax
|
||||
dec edx
|
||||
mov ecx,[h]
|
||||
cmp ecx,0
|
||||
je .coord_end ;¥á«¨ ¢ëá®â 0 ¯¨ªá¥«¥©
|
||||
or ecx,ecx
|
||||
jz .coord_end ;¥á«¨ ¢ëá®â 0 ¯¨ªá¥«¥©
|
||||
jg @f ;¥á«¨ ¢ëá®â ¯®«®¦¨â¥«ì ï
|
||||
add ebx,ecx ;ᤢ¨£ ¥¬ ¢¥àåîî ª®®à¤¨ âã ¯àאַ㣮«ì¨ª
|
||||
inc ebx
|
||||
neg ecx ;¢ëá®âã ¤¥« ¥¬ ¯®«®¦¨â¥«ì®©
|
||||
;inc ecx ;¯®ç¥¬ã âãâ ¥ ¤®¡ ¢«ï¥¬ 1-æã ï ¥ § î, ® á ¥© à ¡®â ¥â ¥ ¯à ¢¨«ì®
|
||||
@@:
|
||||
mov esi,dword[color]
|
||||
mov esi,[color]
|
||||
cld
|
||||
@@:
|
||||
stdcall buf_line_h, edi, eax, ebx, edx, esi ;«¨¨ï -
|
||||
@ -705,7 +701,7 @@ locals
|
||||
po_y dd ?
|
||||
endl
|
||||
pushad
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
cmp buf2d_bits,8
|
||||
je @f
|
||||
cmp buf2d_bits,24
|
||||
@ -773,10 +769,10 @@ proc buf_flood_fill, buf_struc:dword, coord_x:dword, coord_y:dword, mode:dword,
|
||||
cmp buf2d_bits,24
|
||||
jne .end24
|
||||
|
||||
mov ebx,dword[coord_x]
|
||||
mov ecx,dword[coord_y]
|
||||
mov edx,dword[color_f]
|
||||
mov esi,dword[color_b]
|
||||
mov ebx,[coord_x]
|
||||
mov ecx,[coord_y]
|
||||
mov edx,[color_f]
|
||||
mov esi,[color_b]
|
||||
|
||||
cmp dword[mode],1 ;¢ § ¢¨á¨¬®á⨠®â 'mode' ®¯à¥¤¥«ï¥¬ ª ª¨¬ «£®à¨â¬®¬ ¡ã¤¥¬ ¯®«ì§®¢ âìáï
|
||||
je @f
|
||||
@ -903,10 +899,10 @@ buf_flood_fill_recurs_1:
|
||||
;äãªæ¨ï ¤«ï à¨á®¢ ¨ï â®çª¨
|
||||
align 4
|
||||
proc buf_set_pixel uses ebx ecx edx edi, buf_struc:dword, coord_x:dword, coord_y:dword, color:dword
|
||||
mov edi,dword[buf_struc]
|
||||
mov ebx,dword[coord_x]
|
||||
mov ecx,dword[coord_y]
|
||||
mov edx,dword[color]
|
||||
mov edi,[buf_struc]
|
||||
mov ebx,[coord_x]
|
||||
mov ecx,[coord_y]
|
||||
mov edx,[color]
|
||||
call draw_pixel
|
||||
ret
|
||||
endp
|
||||
@ -916,7 +912,7 @@ endp
|
||||
; ¢ á«ãç ¥ ®è¨¡ª¨ eax = 0xffffffff
|
||||
align 4
|
||||
proc buf_get_pixel uses ebx ecx edi, buf_struc:dword, coord_x:dword, coord_y:dword
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
mov ebx,[coord_x]
|
||||
mov ecx,[coord_y]
|
||||
|
||||
@ -949,7 +945,7 @@ proc buf_convert_text_matrix, buf_struc:dword
|
||||
c3 dw ?
|
||||
endl
|
||||
pushad
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
cmp buf2d_bits,8
|
||||
jne .error0
|
||||
mov ecx,buf2d_h
|
||||
@ -1003,7 +999,7 @@ proc buf_convert_text_matrix, buf_struc:dword
|
||||
cmp word[c3],0
|
||||
jg .c_3
|
||||
|
||||
mov edi,dword[buf_struc] ;ª®¯¨à®¢ ¨¥ ®¢®© ¬ âà¨æë ¢ ®á®¢®© ¡ãä¥à
|
||||
mov edi,[buf_struc] ;ª®¯¨à®¢ ¨¥ ®¢®© ¬ âà¨æë ¢ ®á®¢®© ¡ãä¥à
|
||||
mov edi,buf2d_data
|
||||
mov esi,[tmp_mem]
|
||||
mov ecx,ebx
|
||||
@ -1028,10 +1024,10 @@ proc buf_draw_text, buf_struc:dword, buf_t_matr:dword, text:dword, coord_x:dword
|
||||
buf_s_matr buf_2d_header ? ;ebp-BUF_STRUCT_SIZE «®ª «ì ï ¬ âà¨æ ᨬ¢®«
|
||||
endl
|
||||
pushad
|
||||
mov edi,dword[buf_struc]
|
||||
mov edi,[buf_struc]
|
||||
cmp buf2d_bits,24
|
||||
jne .error2
|
||||
mov edi,dword[buf_t_matr]
|
||||
mov edi,[buf_t_matr]
|
||||
cmp buf2d_bits,8
|
||||
jne .error1
|
||||
mov edx,buf2d_data
|
||||
|
@ -1065,7 +1065,6 @@ align 4
|
||||
mov [line_col],0xff0000 ;if was printed
|
||||
.end1:
|
||||
stdcall [buf2d_line_sm], [pbuf], [PervX],[PervY], [GrafX],[GrafY], [line_col]
|
||||
stdcall [buf2d_line], [pbuf], [PervX],[PervY], [GrafX],[GrafY], [line_col]
|
||||
.end0:
|
||||
mov eax,[GrafX]
|
||||
mov [PervX],eax
|
||||
@ -1170,7 +1169,6 @@ align 4
|
||||
cmp ecx,[ebx+Figure.PoiCount]
|
||||
je @f
|
||||
stdcall [buf2d_line_sm], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
|
||||
stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
|
||||
@@:
|
||||
mov eax,[GrafX]
|
||||
mov [PervX],eax
|
||||
|
@ -1104,9 +1104,6 @@ align 4
|
||||
cmp ecx,[ebx+Figure.PoiCount]
|
||||
je @f
|
||||
stdcall [buf2d_line_sm], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80
|
||||
;sub esp,24
|
||||
;call [buf2d_line]
|
||||
stdcall [buf2d_line], [pbuf], [PervX],[PervY], [GrafX],[GrafY], 0x80
|
||||
@@:
|
||||
mov eax,[GrafX]
|
||||
mov [PervX],eax
|
||||
@ -1214,7 +1211,6 @@ align 4
|
||||
cmp ecx,[ebx+Figure.PoiCount]
|
||||
je @f
|
||||
stdcall [buf2d_line_sm], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
|
||||
stdcall [buf2d_line], buf_0, [PervX],[PervY], [GrafX],[GrafY], [col_lin]
|
||||
@@:
|
||||
mov eax,[GrafX]
|
||||
mov [PervX],eax
|
||||
|
Loading…
Reference in New Issue
Block a user