kolibrios-gitea/programs/develop/libraries/buf2d/trunk/examples/e5_lines_sm.asm
IgorA c5dc86cc2c function 'buf2d_line_sm' - fix error when the line is 45 degrees
git-svn-id: svn://kolibrios.org@9520 a494cfbc-eb01-0410-851d-a64ba20cac60
2021-12-28 21:57:16 +00:00

183 lines
4.8 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 0
db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
include '../../../../../KOSfuncs.inc'
include '../../../../../macros.inc'
include '../../../../../proc32.inc'
include '../../../../../load_lib.mac'
include '../../../../../dll.inc'
@use_library mem.Alloc,mem.Free,mem.ReAlloc, 0 ;dll.Load
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
start:
load_library lib0_name, library_path, system_path, import_buf2d_lib
cmp eax,-1
jz button.exit
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 ;à¨á㥬 ¯àאַ㣮«ì­¨ª
stdcall [buf2d_line], buf_0, 10,10, 100,75, 0xff0000 ;à¨á㥬 ¯à®áâãî «¨­¨î
stdcall [buf2d_line_sm], buf_0, 100,75, 190,140, 0xff0000 ;à¨á㥬 ᣫ ¦¥­­ãî «¨­¨î
align 4
red_win:
call draw_window
align 4
still:
mcall SF_WAIT_EVENT
cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
jz red_win
cmp al,2
jz key
cmp al,3
jz button
cmp al,6
jz mouse
jmp still
align 4
draw_window:
pushad
mcall SF_REDRAW,SSF_BEGIN_DRAW
;mov edx,0x32000000
mov edx,0x33000000
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
stdcall [buf2d_draw], buf_0
mcall SF_REDRAW,SSF_END_DRAW
popad
ret
align 4
key:
mcall SF_GET_KEY
cmp ah,27 ;Esc
je button.exit
jmp still
align 4
button:
mcall SF_GET_BUTTON
cmp ah,1
jne still
.exit:
stdcall [buf2d_delete],buf_0 ;㤠«ï¥¬ ¡ãä¥à
mcall SF_TERMINATE_PROCESS
align 4
mouse:
;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
mcall SF_MOUSE_GET,SSF_BUTTON
cmp al,1
jne @f
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 ;®ç¨é ¥¬ íªà ­ ®â ¯à¥¤ë¤ãé¨å à¨á®¢ ­¨©
stdcall [buf2d_filled_rect_by_size], edi, 100-50,70-25, 100,50, 0xffffff ;à¨á㥬 ¯àאַ㣮«ì­¨ª
stdcall [buf2d_line], edi, 10,10, ebx,eax, 0xff0000 ;à¨á㥬 ¯à®áâãî «¨­¨î
stdcall [buf2d_line_sm], edi, 190,140, ebx,eax, 0xff0000 ;à¨á㥬 ᣫ ¦¥­­ãî «¨­¨î
stdcall [buf2d_draw], edi ;®¡­®¢«ï¥¬ íªà ­
@@:
jmp still
caption db 'Press left mouse button, [Esc] - exit',0
;--------------------------------------------------
align 4
import_buf2d_lib:
dd sz_lib_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_line_sm dd sz_buf2d_line_sm
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
dd 0,0
sz_lib_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_line_sm db 'buf2d_line_sm',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
align 4
buf_0:
dd 0 ;㪠§ â¥«ì ­  ¡ãä¥à ¨§®¡à ¦¥­¨ï
dw 20 ;+4 left
dw 10 ;+6 top
dd 200 ;+8 w
dd 150 ;+12 h
dd 0x80 ;+16 color
db 24 ;+20 bit in pixel
;--------------------------------------------------
system_path db '/sys/lib/'
lib0_name db 'buf2d.obj',0
;--------------------------------------------------
align 16
i_end: ;ª®­¥æ ª®¤ 
rb 1024
stacktop:
cur_dir_path:
rb 4096
library_path:
rb 4096
mem: