palitra v0.2 uploaded

git-svn-id: svn://kolibrios.org@3004 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-11-05 12:38:32 +00:00
parent 41086737df
commit cfa3ea094a

View File

@ -0,0 +1,645 @@
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; Program Palitra (c) Sergei Steshin (Akyltist) |
;----------------------------------------------------------------------------------------------------|
;; compiler: FASM 1.69.31 |
;; version: 0.2.0 |
;; last update: 15/09/2012 |
;; e-mail: dr.steshin@gmail.com |
;.....................................................................................................
;; History: |
;; 0.1.0 - <20>¥à¢ ï ¢¥àá¨ï ¯à®£à ¬¬ë |
;; 0.2.0 - ˆá¯à ¢«¥­® ¯®¯ ¤ ­¨¥ ¢ á¥âªã, ¡¥à¥âáï ¡«¨¦ ©è¨© ¯® ¤¨ £®­ «¨ ¯¨ªá¥«ì. |
;; - „®¡ ¢«¥­ë ¯®«§ã­ª¨, ¤«ï ॣ㫨஢ ­¨ï rgb á®áâ ¢«ïîé¨å æ¢¥â  ¨ ¢ë¢®¤ íâ¨å á®áâ ¢«ïîé¨å. |
;; - “¡à ­ ¢ë¢®¤ æ¢¥â  ¢ ¡¨­ à­®¬ ¢¨¤¥ (¯®ª  §  ­¥ ­ ¤®¡­®áâìî ¨ ­¥  ªâã «ì­®áâìî). |
;; - Œ¥«ª ï ª®á¬¥â¨ª . |
;.....................................................................................................
;; All rights reserved. |
;; |
;; Redistribution and use in source and binary forms, with or without modification, are permitted |
;; provided that the following conditions are met: |
;; * Redistributions of source code must retain the above copyright notice, this list of |
;; conditions and the following disclaimer. |
;; * Redistributions in binary form must reproduce the above copyright notice, this list of |
;; conditions and the following disclaimer in the documentation and/or other materials |
;; provided with the distribution. |
;; * Neither the name of the <organization> nor the names of its contributors may be used to |
;; endorse or promote products derived from this software without specific prior written |
;; permission. |
;; |
;; THIS SOFTWARE IS PROVIDED BY Sergei Steshin ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
;; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY DIRECT, |
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
;....................................................................................................|
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; ‡€ƒŽ‹Ž‚ŽŠ ˆ<CB86>Ž<C5BD>Ÿ…ŒŽƒŽ ”€‰‹€ <20><>ˆŽ†…<E280A0>ˆŸ „‹Ÿ ŠŽˆ<E280B9><CB86>ˆ Ž‘ |
;----------------------------------------------------------------------------------------------------/
use32
org 0x0
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x1000
dd 0x1000
dd 0x0
dd 0x0
include 'macros.inc'
START:
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; Ž<C5BD>Ž<C5BD>Ž‰ –ˆŠ‹ <20><>Žƒ<C5BD>€ŒŒ - Ž<><C5BD><EFBFBD>ŽŠ€ Ž<E28098>ˆ‰ |
;----------------------------------------------------------------------------------------------------/
red:
call draw_window ; ¢ë§ë¢ ¥¬ ¯¥à¥à¨á®¢ªã ®ª­  ¯à¨«®¦¥­¨ï
still:
mcall 10 ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª­® ?
je red ; ¥á«¨ ¤  - ­  ¬¥âªã red
cmp eax,2 ; ­ ¦ â  ª« ¢¨è  ?
je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
;end_still
key: ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
mcall 2 ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  (¢ ah) (âãâ ¢ ¯à¨­æ¨¯¥ ­¥ ­ã¦­ )
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
;end_key
button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
cmp ah, 1 ; ¥á«¨ ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
jz bexit ; ¢ë室¨¬
cmp ah, 7
jne color_button
call mouse_get
jmp still
color_button:
push eax
call mouse_local ; ¯®«ã稫 «®ª «ì­ë¥ ª®®à¤¨­ âë
mov ebx,129
mov ecx,[mouse_y]
sub ebx,ecx
mov ecx,3
imul ecx,ebx
;push ecx
pop eax
red_button:
cmp ah, 8
jne green_button
mov [cred],cl
call set_spectr
jmp still
green_button:
cmp ah, 9
jne blue_button
mov [cgreen],cl
call set_spectr
jmp still
blue_button:
cmp ah, 10
jne still
mov [cblue],cl
call set_spectr
jmp still
bexit:
mcall -1 ; ¨­ ç¥ ª®­¥æ ¯à®£à ¬¬ë
;end_button
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; ƒ<E282AC>‰ ŒŽ„“‹œ Ž<C5BD>ˆŽŠˆ ŽŠ<C5BD>ˆ <20>…Œ…<C592>Ž <20><>ˆŽ†…<E280A0>ˆŸ |
;----------------------------------------------------------------------------------------------------/
draw_window:
mov eax,12 ; äã­ªæ¨ï 12: ®§­ ç ¥â, çâ® ¡ã¤¥â à¨á®¢ âìáï ®ª­®
mov ebx,1 ; 1,­ ç «® à¨á®¢ ­¨ï
int 0x40 ; <20>à¥à뢠­¨¥
mov eax,48 ; ”ã­ªæ¨ï 48 - á⨫¨ ®â®¡à ¦¥­¨ï ®ª®­
mov ebx,3 ; <20>®¤äã­ªæ¨ï 3 - ¯®«ãç¨âì áâ ­¤ àâ­ë¥ æ¢¥â  ®ª®­.
mov ecx,sc ; “ª § â¥«ì ­  ¡ãä¥à à §¬¥à®¬ edx ¡ ©â, ¯®¤ áâàãªâãàã
mov edx,sizeof.system_colors ; <20> §¬¥à â ¡«¨æë 梥⮢ (¤®«¦¥­ ¡ëâì 40 ¡ ©â)
int 0x40 ; <20>à¥à뢠­¨¥
mov eax,48 ; ”ã­ªæ¨ï 48 - á⨫¨ ®â®¡à ¦¥­¨ï ®ª®­.
mov ebx,4 ; <20>®¤äã­ªæ¨ï 4 - ¢®§¢à é ¥â eax = ¢ëá®â  ᪨­ .
int 0x40 ; <20>à¥à뢠­¨¥
mov ecx,eax ; ‡ ¯®¬¨­ ¥¬ ¢ëá®âã ᪨­ 
xor eax,eax ; Žç¨é ¥¬ eax (mov eax,0) (”ã­ªæ¨ï 0)
mov ebx,200 shl 16+325 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ x]
add ecx,200 shl 16+168 ; ‚ëá®â  ᪨­  + [ª®®à¤¨­ â  ¯® y]*65536 + [à §¬¥à ¯® y]
mov edx,[sc.work] ; ‚¨¤¨¬® áâ¨«ì ®ª­  ¯® ¤¥ä®«âã
or edx,0x34000000 ; ˆ«¨ ®ª­® ᮠ᪨­®¬ 䨪á¨à®¢ ­­ëå à §¬¥à®¢
mov edi,title ; ‡ £®«®¢®ª ®ª­ 
int 0x40 ; <20>à¥à뢠­¨¥
call draw_palitra ; <20>ˆ“…Œ <20>ˆ<CB86>
call draw_result ; <20>ˆ“…Œ <20>…‡“œ
mov eax,8 ; ”ã­ªæ¨ï 8 - ®¯à¥¤¥«¨âì/㤠«¨âì ª­®¯ªã
mov ebx,89 shl 16+222 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® å [ª-â  x]*65536 + [à §¬¥à]
mov ecx,9 shl 16+147 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
mov edx,0x60000007 ; <20> ç «ì­®¥ ID ª­®¯®ª - 0xXYnnnnnn
int 0x40
mov ebx,10 shl 16+8 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® å [ª-â  x]*65536 + [à §¬¥à]
mov edx,0x60000008 ; ID = 8
mov ecx,45 shl 16+85 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40 ; <20>¨á㥬 ­¥¢¨¤¨¬ãî ª­®¯ªã ¯®¤ á« ©¤¥à®¬ red
add ebx,29 shl 16 ; „®¡ ¢«ï¥¬
inc edx ; ID = 9
int 0x40 ; <20>¨á㥬 ­¥¢¨¤¨¬ãî ª­®¯ªã ¯®¤ á« ©¤¥à®¬ green
add ebx,29 shl 16 ; „®¡ ¢«ï¥¬
inc edx ; ID = 10
int 0x40 ; <20>¨á㥬 ­¥¢¨¤¨¬ãî ª­®¯ªã ¯®¤ á« ©¤¥à®¬ blue
mov eax,12 ; äã­ªæ¨ï 12: ®§­ ç ¥â, çâ® ¡ã¤¥â à¨á®¢ âìáï ®ª­®
mov ebx,2 ; 1,­ ç «® à¨á®¢ ­¨ï
int 0x40 ; <20>à¥à뢠­¨¥
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; <20>ŽŠ <E2809A>ŽŒŽƒ€œ<E280B9><20><>Ž…„“<E2809E> ˆ ”“<E2809D>Šˆ<20><>ˆŽ†…<E280A0>ˆŸ |
;----------------------------------------------------------------------------------------------------/
mouse_global:
;.................................................................................................
; <20>®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨
;.................................................................................................
mov eax,37 ; ”ã­ªæ¨ï 37 - à ¡®â  á ¬ëèìî
mov ebx,0 ; ­ ¬ ­ã¦­ë £«®¡ «ì­ë¥ ª®®à¤¨­ âë
int 0x40 ; eax = x*65536 + y, (x,y)=ª®®à¤¨­ âë ªãàá®à  ¬ëè¨
mov ecx,eax ;
shr ecx,16 ; ecx = x+1
movzx edx,ax ; edx = y+1
dec ecx ; ecx = x
dec edx ; edx = y
mov [mouse_x],ecx ; mouse_x = x
mov [mouse_y],edx ; mouse_y = y
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_mouse_global
mouse_local:
;.................................................................................................
; <20>®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® ®ª­ 
;.................................................................................................
mov eax,37 ; ”ã­ªæ¨ï 37 - à ¡®â  á ¬ëèìî
mov ebx,1 ; ­ ¬ ­ã¦­ë £«®¡ «ì­ë¥ ª®®à¤¨­ âë
int 0x40 ; eax = x*65536 + y, (x,y)=ª®®à¤¨­ âë ªãàá®à  ¬ëè¨
mov ecx,eax ;
shr ecx,16 ; ecx = x+1
movzx edx,ax ; edx = y+1
dec ecx ; ecx = x
dec edx ; edx = y
mov [mouse_x],ecx ; mouse_x = x
mov [mouse_y],edx ; mouse_y = y
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_mouse_local
desktop_get:
;.................................................................................................
; Ž¯à¥¤¥«ï¥¬ è¨à¨­ã íªà ­ 
;.................................................................................................
mov eax,14 ; Ž¯à¥¤¥«ï¥¬ è¨à¨­ã íªà ­  (eax = [xsize]*65536 + [ysize])
int 0x40 ; xsize = à §¬¥à ¯® £®à¨§®­â «¨ - 1
mov ebx,eax ;
shr ebx,16 ; ebx = xsize-1
;movzx edx,ax ;; edx = ysize-1 («¨è­¨© ª®¤)
inc ebx ; ebx = xsize
;inc edx ;; edx = ysize («¨è­¨© ª®¤)
mov [desctop_w],ebx
ret
;end_desktop_get
mouse_get:
mov esi,2 ; ŠŽ‘’›‹œ: ä« £ ¤«ï ¨§¡¥¦ ­¨ï § æ¨ª«¨¢ ­¨ï
call mouse_global
call desktop_get
re_mouse_loop: ; ŠŽ‘’›‹œ: ¬¥âª  ¤«ï ¢®§¢à â  ¥á«¨ ¯®¯ «¨ ¢ á¥âªã
mov ebx,[desctop_w]
imul ebx,[mouse_y] ; ebx = y*xsize
add ebx,[mouse_x] ; ebx = y*xsize+x
;.................................................................................................
; <20>¥à¥¬ 梥â á ¯ «¨âàë ¢ ¯¥à¥¬¥­­ãî
;.................................................................................................
mov eax,35 ; ”ã­ªæ¨ï ¢§ïâ¨ï 梥â 
;mov ebx,ecx ;; ebx = y*xsize+x («¨è­¨© ª®¤)
int 0x40 ; <20>®«ãç ¥¬ 梥⠢ eax
cmp eax,[sc.work] ; ‘à ¢­¨¢ ¥¬ á ä®­®¬ ¯à¨«®¦¥­¨ï
je mouse_err ; …᫨ íâ® ®­ - â® ­¨ç¥£® ­¥ ¤¥« ¥¬
cmp eax,0x222222 ; ‘à ¢­¨¢ ¥¬ á 梥⮬ á¥âª¨
je mouse_err ; …᫨ íâ® ®­ - â® ­¨ç¥£® ­¥ ¤¥« ¥¬
jmp mouse_set ; ŠŽ‘’›‹œ: ¯à룠¥¬ çâ®¡ë ­¥ ¡à âì 梥â á¥âª¨
mouse_err: ; ŠŽ‘’›‹œ: ¥á«¨ ¯®¯ «¨ ¢ á¥âªã ¨«¨ ä®­
inc [mouse_y] ; ŠŽ‘’›‹œ: ᬥ頥¬ ¯® ¤¨ £®­ «¨ á­ ç «  ¯® å
inc [mouse_x] ; ŠŽ‘’›‹œ: ᬥ頥¬ ¯® ¤¨ £®­ «¨ ¯®â®¬ ¯® ã
dec esi ; ŠŽ‘’›‹œ: “¬¥­ìè ¥¬ ä« £
cmp esi,0 ; ŠŽ‘’›‹œ: ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
jz mouse_exit ; ŠŽ‘’›‹œ: …᫨ ­®«ì ⮠ᤥ« «¨ ¢áñ çâ® ¬®£«¨
jmp re_mouse_loop ; ŠŽ‘’›‹œ: …᫨ ­¥ ­®«ì â® ¯®¯à®¡ã¥¬ ¢§ïâì á®á¥«­¨© ¯¨ªá¥«ì
mouse_set:
mov [color],eax ; ˆ­ ç¥ § ¯®¬¨­ ¥¬ ­®¢ë© 梥â
call draw_result ; ‚뢮¤¨¬ १ã«ìâ â
mouse_exit:
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_mouse_get----------------------------------------------------------------------------------------
draw_palitra:
;.................................................................................................
; Žâà¨á®¢ª  ä®­  ¯®¤ ª­®¯ª¨
;.................................................................................................
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,0x222222 ; 梥â
mov ecx,9 shl 16+73 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
mov esi,2 ; ‘ç¥â稪 «¨­¨© ¯®¤«®¦¥ª
re_draw:
mov ebx,89 shl 16+73 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov edi,3 ; ‘ç¥â稪 ª®«¨ç¥á⢠ ¯®¤«®¦¥ª
for_fon_loop:
int 0x40 ; <20>à¥à뢠­¨¥
add ebx,75 shl 16 ; ‘¬¥é ¥¬ ¯®«®¦¥­¨¥ «¨­¨¨ ¯® å
dec edi ; “¬¥­ìè ¥¬ áç¥â稪 ª­®¯®ª
cmp edi,0 ; ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
jnz for_fon_loop ; …᫨ ­¥ ­®«ì â® ¢ ­ ç «® 横« 
dec esi ; “¬¥­ìè ¥¬ ¥£®
cmp esi,0 ; ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
mov ecx,84 shl 16+73 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
jnz re_draw ; …᫨ ­¥ ­®«ì â® ¢ ­ ç «® 横« 
;.................................................................................................
; Žâà¨á®¢ª  ª­®¯®ª ¯® 横«ã
;.................................................................................................
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,0x0FFFFFFF ; 梥â
mov esi,6 ; ‘ç¥â稪 ª®«¨ç¥á⢠  ¡§ æ¥¢ (#4,8)
mov ebx,78 shl 16+8 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
for_abz:
;;push esi ; ‘®å࠭塞 §­ ç¥­¨¥ áç¥â稪  «¨­¨© ¢ á⥪
cmp esi,3
jne x2_line
mov ebx,78 shl 16+8
x2_line:
add ebx,3 shl 16 ; ‘¬¥é ¥¬ ¯®«®¦¥­¨¥ «¨­¨¨ ¯® x
mov edi,8 ; ‘ç¥â稪 ª®«¨ç¥á⢠ ª­®¯®ª ¢ áâப¥
for_stolbik:
push edi ; ‘®å࠭塞 §­ ç¥­¨¥ áç¥â稪  «¨­¨© ¢ á⥪
mov edi,8 ; ‘ç¥â稪 ª®«¨ç¥á⢠ ª­®¯®ª ¢ áâப¥
mov ecx, 1 shl 16+8 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
cmp esi,3
jg y2_line ; …᫨ ¡®«ìè¥ 4 â® ¨£­®à¨¬
mov ecx,76 shl 16+8
y2_line:
add ebx,9 shl 16 ; ‘¬¥é ¥¬ ¯®«®¦¥­¨¥ «¨­¨¨ ¯® x
for_loop:
add ecx,9 shl 16 ; ‘¬¥é ¥¬ ¯®«®¦¥­¨¥ «¨­¨¨ ¯® y
int 0x40 ; <20>à¥à뢠­¨¥
sub edx,32 shl 16
dec edi ; “¬¥­ìè ¥¬ áç¥â稪 ª­®¯®ª
cmp edi,0 ; ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
jnz for_loop ; …᫨ ­¥ ­®«ì â® ¢ ­ ç «® 横« 
sub edx,32 shl 8
pop edi ; ˆ­ ç¥ ¢®ááâ ­ ¢«¨¢ ¥¬ áç¥â稪 «¨­¨©
dec edi ; “¬¥­ìè ¥¬ ¥£®
cmp edi,0 ; ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
jnz for_stolbik ; …᫨ ­¥ ­®«ì â® ¢ ­ ç «® 横« 
sub edx,48 ; (#64,32)
;;pop esi ; ˆ­ ç¥ ¢®ááâ ­ ¢«¨¢ ¥¬ áç¥â稪 «¨­¨©
dec esi ; “¬¥­ìè ¥¬ ¥£®
cmp esi,0 ; ‘à ¢­¨¢ ¥¬ á ­ã«¥¬
jnz for_abz ; …᫨ ­¥ ­®«ì â® ¢ ­ ç «® 横« 
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_draw_palitra-------------------------------------------------------------------------------------
draw_result:
;.................................................................................................
; Žâà¨á®¢ª  १ã«ìâ â  æ¢¥â  ¢ hex
;.................................................................................................
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,0x222222 ; 梥â-®¡¢®¤ª¨
mov ebx,4 shl 16+15 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,9 shl 16+15 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40 ; <20>à¥à뢠­¨¥ (®á à¨áã¥â ¯àאַ㣮«ì­¨ª)
mov ebx,23 shl 16+62 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40 ; <20>à¥à뢠­¨¥ (®á à¨áã¥â ¯àאַ㣮«ì­¨ª)
mov edx,[color] ; 梥â
mov ebx,5 shl 16+13 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,10 shl 16+13 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40 ; <20>à¥à뢠­¨¥ (®á à¨áã¥â ¯àאַ㣮«ì­¨ª)
mov edx,0xFFFFFF ; 梥â-ä®­ 
mov ebx,24 shl 16+60 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40 ; <20>à¥à뢠­¨¥ (®á à¨áã¥â ¯àאַ㣮«ì­¨ª)
mov eax,47 ; ”ã­ªæ¨ï 47 - ¢ë¢®¤ ç¨á«  ¢ ®ª­®
mov ecx,[color] ; ç¨á«® (¯à¨ bl=0) ¨«¨ 㪠§ â¥«ì (¯à¨ bl=1)
mov esi,0x0 ; 0xX0RRGGBB
mov ebx,256+8 shl 16 ; ¯ à ¬¥âàë ¯à¥®¡à §®¢ ­¨ï ç¨á«  ¢ ⥪áâ (HEX)
mov edx,34 shl 16+13 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
int 0x40 ; <20>à¥à뢠­¨¥ - ¢ë¢®¤¨¬ १ã«ìâ â ¢ ®ª­® (HEX)
mov eax,4 ; äã­ªæ¨ï 4: ­ ¯¨á âì ⥪áâ ¢ ®ª­¥
mov ebx,27*65536+13 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
mov ecx,0x0 ; 梥â ⥪áâ  RRGGBB
mov edx,hex ; à¨á㥬 '#'
mov esi,1 ; ¤«¨­  ⥪áâ  ¢ ¡ ©â å
int 0x40
;.................................................................................................
; Žâà¨á®¢ª  ¯®«¥© ¤«ï r g b §­ ç¥­¨©
;.................................................................................................
call get_spectr
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,0x222222 ; 梥â-®¡¢®¤ª¨
mov ebx,4 shl 16+23 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,142 shl 16+15 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
mov ebx,33 shl 16+23 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40
mov ebx,62 shl 16+23 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40
mov edx,0xFFFFFF ; 梥â-®¡¢®¤ª¨
mov ebx,5 shl 16+21 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,143 shl 16+13 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
mov ebx,34 shl 16+21 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40
mov ebx,63 shl 16+21 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
int 0x40
;.................................................................................................
; Žâà¨á®¢ª  r g b §­ ç¥­¨©
;.................................................................................................
movzx eax,[cred] ; ªà á­ë©
mov ebx,7*65536+146 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
call draw_value ; ¢ë¢®¤¨¬ १ã«ìâ â
movzx eax,[cgreen] ; §¥«¥­ë©
mov ebx,36*65536+146 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
call draw_value ; ¢ë¢®¤¨¬ १ã«ìâ â
movzx eax,[cblue] ; ᨭ¨©
mov ebx,65*65536+146 ; [x ­ ç «ì­ë©] *65536 + [y ­ ç «ì­ë©]
call draw_value ; ¢ë¢®¤¨¬ १ã«ìâ â
;.................................................................................................
; Ž¡­ã«ï¥¬ ä®­
;.................................................................................................
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,[sc.work] ; 梥â-®¡¢®¤ª¨
mov ebx,8 shl 16+66 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,40 shl 16+87 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
;mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
;mov edx,0x222222 ; 梥â-®¡¢®¤ª¨
;mov ebx,4 shl 16+23 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
;mov ecx,30 shl 16+105 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
;int 0x40
;add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
;int 0x40
;add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
;int 0x40
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,[sc.work] ; 梥â-®¡¢®¤ª¨
mov ebx,5 shl 16+21 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,31 shl 16+103 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
;.................................................................................................
; ‚뢮¤¨¬ ¡ãª¢ë r g b
;.................................................................................................
mov eax,4 ; 4 - ¢ë¢¥á⨠áâபã ⥪áâ  ¢ ®ª­®
mov ebx,12 shl 16+34 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
mov ecx,0x0 ; 0xX0RRGGBB (RR, GG, BB § ¤ îâ 梥â ⥪áâ )
mov edx,cname ; 㪠§ â¥«ì ­  ­ ç «® áâப¨
mov esi,2 ; ¢ë¢®¤¨âì esi ᨬ¢®«®¢
newline: ; 横«
int 0x40 ; <20>à¥à뢠­¨¥
add ebx,29 shl 16 ; „®¡ ¢«ï¥¬
add edx,2 ; „®¡ ¢«ï¥¬
cmp [edx],byte 'x' ; ‘à ¢­¥­¨¥ á ¡ ©â®¬ å
jne newline ; …᫨ ­¥ ­ã«ì ¨«¨ ­¥ à ¢­®
;.................................................................................................
; Žâà¨á®¢ª  á« ©¤¥à®¢
;.................................................................................................
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
mov edx,0x222222 ; 梥â-®¡¢®¤ª¨
mov ebx,12 shl 16+4 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,45 shl 16+85 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
mov edx,0xFA0919 ; 梥â-®¡¢®¤ª¨
mov ebx,13 shl 16+2 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
mov ecx,46 shl 16+83 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® y [ª-â  y]*65536 + [à §¬¥à]
int 0x40
mov edx,0x08CE19 ; 梥â-®¡¢®¤ª¨
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
mov edx,0x0909FF ; 梥â-®¡¢®¤ª¨
add ebx,29 shl 16 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  y]*65536 + [à §¬¥à]
int 0x40
;.................................................................................................
; Žâà¨á®¢ª  ¯®«§ã­ª®¢
;.................................................................................................
mov edx,0x0 ; 梥â-¯®«§ã­ª®¢
mov ebx,10 shl 16+8 ; <20> ç «ì­ë¥ ª®®à¤¨­ âë ¯® x [ª-â  x]*65536 + [à §¬¥à]
movzx eax,[cred] ; ¡¥à¥¬ §­ ç¥­¨¥ 梥â 
call draw_slider
add ebx,29 shl 16
movzx eax,[cgreen] ; ¡¥à¥¬ §­ ç¥­¨¥ 梥â 
call draw_slider
add ebx,29 shl 16
movzx eax,[cblue] ; ¡¥à¥¬ §­ ç¥­¨¥ 梥â 
call draw_slider
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_draw_result
draw_slider:
xor ecx,ecx
mov cl,0x3 ; ¡ã¤¥¬ ¤¥«¨âì ¥£® ­  3 â ª ª ª ¯®«§ã­ª¨ ¤«¨­­®© 85 ¯¨ªá¥«¥©
div cl ; ¤¥«¨¬ - 楫®¥ ¢ al ®áâ â®ª ¢ ah
mov cl,128 ; ­¨¦­ïï â®çª  ¯®«§ã­ª 
sub cl,al ; cl=cl-al
shl ecx,16
add ecx,4 ; § ¤ ¥¬ ­ ç «ì­®¥ ¯®«®¦¥­¨¥
mov eax,13 ; ”ã­ªæ¨ï 13 - ­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª
int 0x40
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_slider
draw_value:
;.................................................................................................
; ‚뢮¤ ç¨á«  ¨§ áâப¨ ¢ 㪠§ ­­®© ®¡« áâ¨
;.................................................................................................
push ebx ; á®å࠭塞 ¯à¨á« ­­ë¥ ª®®à¤¨­ âë
mov ebx,10 ; ãáâ ­ ¢«¨¢ ¥¬ ®á­®¢ ­¨¥ á¨á⥬ë áç¨á«¥­¨ï
mov edi,buff ; 㪠§ â¥«ì ­  áâப㠡ãä¥à 
call int2ascii ; ª®­¢¥àâ¨à㥬 ç¨á«® ¨ «®¦¨¬ ª ª áâப㠢 ¡ãä¥à + esi ¤«¨­ 
mov eax,4 ; äã­ªæ¨ï 4: ­ ¯¨á âì ⥪áâ ¢ ®ª­¥
pop ebx ; ¤®áâ ¥¬ ¨§ á⥪  ¯à¨á« ­­ë¥ ª®®à¤¨­ âë
mov ecx,0x0 ; 梥â ⥪áâ  RRGGBB
mov edx,buff ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
int 0x40
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_draw_value
hex_digit:
;.................................................................................................
; <20>८¡à §®¢ ­¨¥ ¢ ASCII (¢­¥ § ¢¨á¨¬®á⨠®â á¨á⥬ë áç¨á«¥­¨ï)
;.................................................................................................
cmp dl,10 ; ¢ dl ®¦¨¤ ¥âáï ç¨á«® ®â 0 ¤® 15
jb .less ; ¥á«¨ dl<10 â® ¯¥à¥å®¤¨¬
add dl,'A'-10 ; 10->A 11->B 12->C ...
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
.less:
or dl,'0' ; …᫨ á¨á⥬  áç¨á«¥­¨ï 10-ï ¨ ¬¥­¥¥
ret ; ‚®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_hex_digit
int2ascii:
;.................................................................................................
; <20>८¡à §®¢ ­¨¥ ç¨á«  ¢ áâபã
;.................................................................................................
; eax - 32-å §­ ç­®¥ ç¨á«®
; ebx - ®á­®¢ ­¨¥ á¨á⥬ë áç¨á«¥­¨ï
; edi - 㪠§ â¥«ì ­  áâப㠡ãä¥à 
; ‚®§¢à é ¥â § ¯®«­¥­­ë© ¡ãä¥à ¨ esi - ¤«¨­  áâப¨
;pushad
xor esi,esi ; § ­ã«ï¥¬ áç¥â稪 ᨬ¢®«®¢
convert_loop:
xor edx,edx ; § ­ã«ï¥¬ ॣ¨áâà ¯®¤ ®áâ â®ª
div ebx ; eax/ebx - ®áâ â®ª ¢ edx
call hex_digit ; ¯à¥®¡à §ã¥¬ ᨬ¢®«
push edx ; «®¦¨¬ ¢ á⥪
inc esi ; 㢥«¨ç¨¢ ¥¬ áç¥â稪
test eax,eax ; ¥á«¨ ¥é¥ ¬®¦­® ¤¥«¨âì
jnz convert_loop ; â® ¤¥«¨¥¬ ¥é¥
cld ; Ž<>Ÿ‡€œ<E280B9>Ž á¡à á뢠¥¬ ä« £ ­ ¯à ¢«¥­¨ï DF (§ ¯¨áì ¢¯¥àñ¤)
write_loop: ; ¨­ ç¥
pop eax ; ¤®áâ ¥¬ ¨§ á⥪  ¢ ¥ å
stosb ; § ¯¨á뢠¥¬ ¢ ¡ãä¥à ¯®  ¤à¥áã ES:(E)DI
dec esi ; 㬥­ìè ¥¬ áç¥â稪
test esi,esi ; ¥á«¨ ¥áâì çâ® ¤®áâ ¢ âì ¨§ á⥪ 
jnz write_loop ; â® ¤®áâ ñ¬
mov byte [edi],0 ; ¨­ ç¥ ¤®¯¨áë뢠¥¬ ­ã«¥¢®© ¡ ©â
;popad ; ¢®ááâ ­ ¢«¨¢ ¥¬ §­ ç¥­¨ï ॣ¨áâ஢
; ª®¤ ­¨¦¥ ­¥ ¨¬¥¥â ­¨ç¥£® ®¡é¥£® ª ä㭪樨, ¯à®áâ® ¢®§¢à é ¥â ¥é¥ ¤«¨­­ã ¯®«ã祭­®© áâப¨
mov edi,buff ; 㪠§ â¥«ì ­  ­ ç «® ⥪áâ 
call str_len
mov esi,eax
ret ; ¨ ¢®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_int2ascii
get_spectr:
;.................................................................................................
; ¢®§¢à é ¥â r,g,b á®á⮢«ïî騥 梥â 
;.................................................................................................
; get blue
mov ecx,[color]
movzx eax,cl
mov [cblue],al
; get red
mov eax,ecx
xor ax,ax
shr eax,16
mov [cred],al
; get green
shl ecx,16
shr ecx,24
mov [cgreen],cl
ret ; ¨ ¢®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_get_spectr
set_spectr:
;.................................................................................................
; ãáâ ­ ¢«¨¢ ¥â ¨§ r,g,b 梥â
;.................................................................................................
; get blue
movzx eax,[cred]
shl eax,8
mov al,[cgreen]
shl eax,8
mov al,[cblue]
mov [color],eax
call draw_result ; ‚뢮¤¨¬ १ã«ìâ â
ret ; ¨ ¢®§¢à é ¥¬ ã¯à ¢«¥­¨¥
;end_get_spectr
str_len:
;.................................................................................................
; ®¯à¥¤¥«ï¥â ¤«¨­ã áâப¨ (¢å®¤->EDI ZS offset ; ¢ë室->EAX ZS length)
;.................................................................................................
push ecx
push esi
push edi
cld
xor al, al
mov ecx, 0FFFFFFFFh
mov esi, edi
repne scasb
sub edi, esi
mov eax, edi
dec eax
pop edi
pop esi
pop ecx
ret
;end_str_len
;#___________________________________________________________________________________________________
;****************************************************************************************************|
; <20>ŽŠ <20><EFBFBD>…Œ…<C592><E280A6>ˆ ŠŽ<C5A0><E28099> |
;----------------------------------------------------------------------------------------------------/
color dd 00000000h ; åà ­¨â §­ ç¥­¨¥ ¢ë¡à ­­®£® 梥â 
mouse_x dd 0 ; åà ­¨â £«®¡ «ì­ãî å ª®®à¤¨­ âã ¬ëè¨
mouse_y dd 0 ; åà ­¨â £«®¡ «ì­ãî ã ª®®à¤¨­ âã ¬ëè¨
desctop_w dd 0 ; åà ­¨â è¨à¨­ã íªà ­ 
sc system_colors ; åà ­¨â áâàãªâãàã á¨á⥬­ëå 梥⮢ ᪨­ 
title db 'Palitra v0.2',0 ; åà ­¨â ¨¬ï ¯à®£à ¬¬ë
hex db '#',0 ; ¤«ï ¢ë¢®¤  à¥èñ⪨ ª ª ⥪áâ 
cname db 'R G B x' ; åà ­¨â à §àï¤ë 梥⮢ (red,green,blue) x-¬¥âª  ª®­æ 
cred db 0 ; åà ­¨¬ ªà á­ë© ᯥªàâ
cgreen db 0 ; åà ­¨¬ §¥«¥­ë© ᯥªâà
cblue db 0 ; åà ­¨¬ ᨭ¨© ᯥªâà
buff db '000',0
I_END: