From c5dc86cc2c3bb127f65abdd8f6ee5c14395efb48 Mon Sep 17 00:00:00 2001 From: IgorA Date: Tue, 28 Dec 2021 21:57:16 +0000 Subject: [PATCH] function 'buf2d_line_sm' - fix error when the line is 45 degrees git-svn-id: svn://kolibrios.org@9520 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../buf2d/trunk/examples/e5_lines_sm.asm | 27 ++-- .../libraries/buf2d/trunk/fun_draw.inc | 118 +++++++++--------- programs/other/cnc_control/cnc_control.inc | 2 - programs/other/cnc_editor/cnc_editor.inc | 4 - 4 files changed, 74 insertions(+), 77 deletions(-) diff --git a/programs/develop/libraries/buf2d/trunk/examples/e5_lines_sm.asm b/programs/develop/libraries/buf2d/trunk/examples/e5_lines_sm.asm index 0cbf375440..5e06ba0867 100644 --- a/programs/develop/libraries/buf2d/trunk/examples/e5_lines_sm.asm +++ b/programs/develop/libraries/buf2d/trunk/examples/e5_lines_sm.asm @@ -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: diff --git a/programs/develop/libraries/buf2d/trunk/fun_draw.inc b/programs/develop/libraries/buf2d/trunk/fun_draw.inc index 78e335dcee..9ad6713841 100644 --- a/programs/develop/libraries/buf2d/trunk/fun_draw.inc +++ b/programs/develop/libraries/buf2d/trunk/fun_draw.inc @@ -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 (x0x1) + 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