kolibrios/programs/develop/examples/editbox/trunk/editbox.asm
Alexey Teplov ( 94747a3d1a retype fuction .check_offset
git-svn-id: svn://kolibrios.org@295 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-01-26 11:20:00 +00:00

108 lines
4.4 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.

; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace? 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
;<3B>ä䥪⨢­®¥ ¯à®£à ¬¬¨à®¢ ­¨¥ ¢ KOLIBRI
;Ž¯â¨¬¨§¨à®¢ ­­ë© ª®¬¯®­¥­â EditBox (ˆá室­ë© ¢ à¨ ­â ®â Maxxxx32)
;Ž¯â¨¬¨§ æ¨ï ª®¬ ­¤.
;<Lrz> - ’¥¯«®¢ €«¥ªá¥© www.lrz.land.ru
;§ £®«®¢®ª ¯à¨«®¦¥­¨ï
use32 ; âà ­á«ïâ®à, ¨á¯®«ì§ãî騩 32 à §à來ëå ª®¬ ­¤ë
org 0x0 ; ¡ §®¢ë©  ¤à¥á ª®¤ , ¢á¥£¤  0x0
db 'MENUET01' ; ¨¤¥­â¨ä¨ª â®à ¨á¯®«­ï¥¬®£® ä ©«  (8 ¡ ©â)
dd 0x1 ; ¢¥àá¨ï ä®à¬ â  § £®«®¢ª  ¨á¯®«­ï¥¬®£® ä ©« 
dd start ;  ¤à¥á, ­  ª®â®àë© á¨á⥬  ¯¥à¥¤ ñâ ã¯à ¢«¥­¨¥
; ¯®á«¥ § £à㧪¨ ¯à¨«®¦¥­¨ï ¢ ¯ ¬ïâì
dd i_end ; à §¬¥à ¯à¨«®¦¥­¨ï
dd i_end and not 3 ; Ž¡ê¥¬ ¨á¯®«ì§ã¥¬®© ¯ ¬ïâ¨, ¤«ï á⥪  ®â¢¥¤¥¬ 0å100 ¡ ©â ¨ ¢ë஢­¨¬ ­  £à­¨æã 4 ¡ ©â 
dd i_end and not 3 ; à á¯®«®¦¨¬ ¯®§¨æ¨î á⥪  ¢ ®¡« á⨠¯ ¬ïâ¨, áࠧ㠧  ⥫®¬ ¯à®£à ¬¬ë. ‚¥à設  á⥪  ¢ ¤¨ ¯ §®­¥ ¯ ¬ïâ¨, 㪠§ ­­®¬ ¢ëè¥
dd 0x0,0x0 ; 㪠§ â¥«ì ­  áâபã á ¯ à ¬¥âà ¬¨.
; ¥á«¨ ¯®á«¥ § ¯ã᪠ ­¥à ¢­® ­ã«î, ¯à¨«®¦¥­¨¥ ¡ë«®
; § ¯ã饭® á ¯ à ¬¥âà ¬¨ ¨§ ª®¬ ­¤­®© áâப¨
; 㪠§ â¥«ì ­  áâபã, ¢ ª®â®àãî § ¯¨á ­ ¯ãâì,
; ®âªã¤  § ¯ã饭® ¯à¨«®¦¥­¨¥
include 'editbox.inc'
use_edit_box
;Ž¡« áâì ª®¤ 
start: ;’®çª  ¢å®¤  ¢ ¯à®£à ¬¬ã
mov eax,40 ;ãáâ ­®¢¨âì ¬ áªã ¤«ï ®¦¨¤ ¥¬ëå ᮡë⨩
mov ebx,0x27 ;á¨á⥬  ¡ã¤¥â ॠ£¨à®¢ âì ⮫쪮 ­  á®®¡é¥­¨¥ ® ¯¥à¥à¨á®¢ª¥,­ ¦ â  ª­®¯ª , ®¯à¥¤¥«ñ­­ ï à ­¥¥, ᮡë⨥ ®â ¬ëè¨ (çâ®-â® á«ã稫®áì - ­ ¦ â¨¥ ­  ª­®¯ªã ¬ëè¨ ¨«¨ ¯¥à¥¬¥é¥­¨¥; á¡à á뢠¥âáï ¯à¨ ¯à®ç⥭¨¨) ¨ ­ ¦ â¨¥ ª« ¢¨è¨
int 0x40
red_win:
call draw_window ;¯¥à¢®­ ç «ì­® ­¥®¡å®¤¨¬® ­ à¨á®¢ âì ®ª­®
still: ;®á­®¢­®© ®¡à ¡®â稪
mov eax,10 ;Ž¦¨¤ âì ᮡëâ¨ï
int 0x40 ;®¦¨¤ âì ᮡë⨥ ¢ â¥ç¥­¨¥ 2 ¬¨««¨á¥ªã­¤
cmp al,0x1 ;¥á«¨ ¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
jz red_win
cmp al,0x2 ;¥á«¨ ­ ¦ â  ª« ¢¨è  â® ¯¥à¥©â¨
jz key
cmp al,0x3 ;¥á«¨ ­ ¦ â  ª­®¯ª  â® ¯¥à¥©â¨
jz button
mouse_edit_boxes editboxes,editboxes_end
jmp still ;¥á«¨ ­¨ç¥£® ¨§ ¯¥à¥ç¨á«¥­­®£® â® á­®¢  ¢ 横«
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
button:
mov eax,17 ;¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª« ¢¨è¨
int 0x40
test ah,ah ;¥á«¨ ¢ ah 0, â® ¯¥à¥©â¨ ­  ®¡à ¡®â稪 ᮡë⨩ still
jz still
or eax,-1 ;¢ eax,-1 - 5 ,¡ ©â®¢ ã ­ á ¦¥ ⮫쪮 3 ¢ë©â¨
int 0x40 ;¤ «¥¥ ¢ë¯®«­ï¥âáï ¢ë室 ¨§ ¯à®£à ¬¬ë
key:
mov eax,2 ;§ £à㧨¬ §­ ç¥­¨¥ 2 ¢ ॣ¨áâ®à eax
int 0x40 ;¯®«ã稬 ª®¤ ­ ¦ â®© ª« ¢¨è¨
key_edit_boxes editboxes,editboxes_end
jmp still
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
draw_window: ;à¨á®¢ ­¨¥ ®ª­  ¯à¨«®¦¥­¨ï
mov eax,12 ;¢ ॣ¨áâà ¢­¥á⨠§­ ç¥­¨¥ = 12
mov ebx,1 ;¯à¨á¢®¨âì 1
int 0x40
xor eax,eax ;®¡­ã«¨âì eax
mov ebx,50*65536+390 ;[ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ x]
mov ecx,30*65536+200 ;[ª®®à¤¨­ â  ¯® ®á¨ y]*65536 + [à §¬¥à ¯® ®á¨ y]
mov edx,0x03AABBCC ;0xXYRRGGBB Y =3 - ¢ë¢®¤ à ¬ª¨, ¨á¯®«ì§ãï áªà¨­
mov esi,0x805080DD ;0xXYRRGGBB - 梥⠧ £®«®¢ª 
mov edi,0x005080DD ;0x00RRGGBB - 梥â à ¬ª¨
int 0x40 ;­ à¨á®¢ âì ®ª­® ¯à¨«®¦¥­¨ï
add eax,4 ;¥á«¨ ¯à¥¤¯®« £ ¥âáï ¨á¯®«ì§®¢ âì ᪠«ïà­ë© ¯à®æ¥áá®à, â® ¬®¦­® ¨á¯®«ì§®¢ âì ¤ ­­î ¨­áâàãªæ¨î
mov ebx,8*65536+8 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y] mov ecx,0x10DDEEFF ; 0xX0RRGGBB, £¤¥ RR, GG, BB § ¤ îâ 梥â ⥪áâ 
mov edx,hed ; 㪠§ â¥«ì ­  ­ ç «® áâப¨
mov esi,i_end1 - hed ; ¤«¨­  áâப¨, ¤®«¦­  ¡ëâì ­¥ ¡®«ìè¥ 255
int 0x40 ;¢ë¢¥á⨠⥪áâ
draw_edit_boxes editboxes,editboxes_end ;à¨á®¢ ­¨¥ edit box'®¢
add eax,8 ;”ã­ªæ¨ï 12 - ­ ç âì/§ ª®­ç¨âì ¯¥à¥à¨á®¢ªã ®ª­ .
mov ebx,2 ;<3B>®¤äã­ªæ¨ï 2 - § ª®­ç¨âì ¯¥à¥à¨á®¢ªã ®ª­ .
int 0x40
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DATA ¤ ­­ë¥
editboxes:
edit1 edit_box 168,10,50,0xffffff,0,0,0,512,ed_buffer.1,ed_focus
edit2 edit_box 168,10,30,0xffffff,0,0,0,99,ed_buffer.2,ed_figure_only
edit3 edit_box 35,10,70,0xffffff,0,0,0,9,ed_buffer.3,ed_figure_only
edit4 edit_box 16,10,90,0xffffff,0,0,0,1,ed_buffer.4,ed_figure_only
editboxes_end:
;data_of_code dd 0
ed_buffer:
.1: rb 513;256
.2: rb 100
.3: rb 10
.4: rb 2
;text_b: db 'Š®«-¢® ᨬ¢®«®¢'
;buffer: dd 0
buffer_end:
hed db 'EDITBOX optimization and retype <Lrz> date 26.01.2007'
i_end1:
rb 2048
i_end:
keymap: