Palitra v0.7 - Add picker

git-svn-id: svn://kolibrios.org@3453 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Akyltist 2013-04-06 10:12:49 +00:00
parent 58f7495fc7
commit 6137a14777
3 changed files with 225 additions and 99 deletions

View File

@ -31,6 +31,7 @@
;; 0.6.0 - „®¡ ¢«¥­  ¢®§¬®¦­®áâì § ¯ã᪠ á ¯ à ¬¥âà ¬¨ | ;; 0.6.0 - „®¡ ¢«¥­  ¢®§¬®¦­®áâì § ¯ã᪠ á ¯ à ¬¥âà ¬¨ |
;; - „®¡ ¢«¥­ ०¨¬ H (hidden) ¯à®¨§¢®¤¨â § ¬¥­ã ä®­  à ¡®ç¥£® á⮫  £à ¤¨¥­â­®© § «¨¢ª®©. | ;; - „®¡ ¢«¥­ ०¨¬ H (hidden) ¯à®¨§¢®¤¨â § ¬¥­ã ä®­  à ¡®ç¥£® á⮫  £à ¤¨¥­â­®© § «¨¢ª®©. |
;; - <20>®«ìè ï ¤¥®¯â¨¬¨§ æ¨ï. | ;; - <20>®«ìè ï ¤¥®¯â¨¬¨§ æ¨ï. |
;; 0.7.0 - „®¡ ¢«¥­  ¯¨¯¥âª  - ¢ë¡®à ­  á।­îî ª­®¯ªã ¬ëè¨ |
;..................................................................................................... ;.....................................................................................................
;; All rights reserved. | ;; All rights reserved. |
;; | ;; |
@ -62,13 +63,12 @@
;----------------------------------------------------------------------------------------------------/ ;----------------------------------------------------------------------------------------------------/
use32 use32
org 0x0 org 0x0
db 'MENUET01' db 'MENUET01'
dd 0x01 dd 0x01
dd START dd START
dd I_END dd I_END
dd 0x100000 dd I_END+4096
dd 0x1000 dd I_END+4096
dd params dd params
dd 0x0 dd 0x0
@ -79,33 +79,13 @@
WIN_X equ 250 ; ª®®à¤¨­ â  å ®ª­  WIN_X equ 250 ; ª®®à¤¨­ â  å ®ª­ 
WIN_Y equ 190 ; ª®®à¤¨­ â  ã ®ª­  WIN_Y equ 190 ; ª®®à¤¨­ â  ã ®ª­ 
panel:
file "panel.raw"
START: START:
; ®¡à ¡®âª  ¯ à ¬¥â஢ ª®¬ ­¤­®© áâப¨ mcall 68,11 ; ¨­¨æ¨ «¨§ æ¨ï ªãç¨
mov edi,params ; 㪠§ â¥«ì ­  áâபã mcall 40,0x27 ; ãáâ ­ ¢«¨¢ ¥¬ ¬ áªã ᮡë⨩
call str_len ; ¯®«ãç ¥¬ ¤«¨­ã áâப¨ include 'params_init.inc' ; ®¡à ¡®âª  ¯ à ¬¥â஢ ª®¬ ­¤­®© áâப¨
cmp eax,0 ; áâà ¢­¨¢ ¥¬ ¤«¨­ã á ­ã«ñ¬
je red ; ¥á«¨ ¯ à ¬¥â஢ ­¥â â® ã室¨¬
call _read_params ; ¨­ ç¥ ç¨â ¥¬ ¯ à ¬¥âàë æ¢¥â  (®ç¥­ì ªà¨¢®)
xor eax,eax ; § ­ã«ï¥¬ ॣ¨áâà
mov al,byte [params] ; ç¨â ¥¬ ¯ à ¬¥âà ¬®¤ 
cmp al,'N' ; áà ¢­¨¢ ¥¬ á normal mode
jne _no_normalmode ; ¥á«¨ ­¥â â® ã室¨¬ ­  ¯à®¢¥àªã ¤ «ìè¥
mov [runmode],1 ; ¥á«¨ ¤  â® ãáâ ­ ¢«¨¢ ¥¬ ¥£®
jmp red ; ¨¤ñ¬ ­  ®âà¨á®¢ªã
_no_normalmode: ; ¥á«¨ ­¥ normal mode â®
cmp al,'H' ; ¢®§¬®¦­® hidden mode
jne _no_hiddenmode ; ¥á«¨ ­¥ ®­ â® ã室¨¬ ¤ «ìè¥
mov [runmode],2 ; ¥á«¨ ®­ â® ãáâ ­ ¢«¨¢ ¥¬ çâ® íâ® ®­ (­ å?)
call set_background ; ¬¥­ï¥¬ ä®­
jmp bexit ; ¨ § ªà뢠¥¬ ¯à®£ã
_no_hiddenmode: ; ¥á«¨ ­¥ hidden mode
cmp al,'D' ; ¢®§¬®¦­® íâ® color dialog mode
jne _no_dialogmode ; ¥á«¨ ¢áñ â ª¨ ­¥ ®­ â® ã室¨¬
mov [runmode],3 ; ¨­ ç¥ 㪠§ë¢ ¥¬ çâ® íâ® â ª¨ ®­
jmp red ; ¨ ã室¨¬ ­  ¢ë¯®«­¥­¨¥
_no_dialogmode: ; ¥á«¨ íâ® ­¨ ®¤¨­ ¨§ § ï¢«¥­ëå ¬®¤®¢
mov [runmode],1 ; â® á¡à á뢠¥¬ ­  ¤¥ä®«â
jmp red ; ¨ à¨á㥬
;#___________________________________________________________________________________________________ ;#___________________________________________________________________________________________________
;****************************************************************************************************| ;****************************************************************************************************|
@ -121,6 +101,8 @@ still:
je key ; ¥á«¨ ¤  - ­  key je key ; ¥á«¨ ¤  - ­  key
cmp eax,3 ; ­ ¦ â  ª­®¯ª  ? cmp eax,3 ; ­ ¦ â  ª­®¯ª  ?
je button ; ¥á«¨ ¤  - ­  button je button ; ¥á«¨ ¤  - ­  button
cmp eax,6 ; ᮡë⨥ ®â ¬ëè¨ ¢­¥ ®ª­ 
je mouse ; ¥á«¨ ¤  - ­  button
jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横«  jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
;end_still ;end_still
@ -129,6 +111,19 @@ key: ;
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横«  jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
;end_key ;end_key
mouse:
mov eax,[renmode]
cmp eax,2
jnz still
call cyrcle_draw
mcall 37,2
cmp al,100b
jne still
mov [color],edx
call draw_result
jmp still ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
;end_mouse
button: button:
mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨ mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
cmp ah, 1 ; ¥á«¨ ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1, cmp ah, 1 ; ¥á«¨ ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
@ -154,7 +149,7 @@ button:
circle_bg: circle_bg:
cmp ah, 15 ; Š­®¯ª  Šà㣮¢ ï ¯ «¨âà  cmp ah, 15 ; Š­®¯ª  Šà㣮¢ ï ¯ «¨âà 
jne next_end ; ¥á«¨ ­¥ ­ ¦ â  â® ¢ë室¨¬ jne next_end ; ¥á«¨ ­¥ ­ ¦ â  â® ¢ë室¨¬
;mov [renmode],2 ; ¢ª«îç ¥¬ ®âà¨á®¢ªã ªà㣮¢®© ¯ «¨âàë mov [renmode],2 ; ¢ª«îç ¥¬ ®âà¨á®¢ªã ªà㣮¢®© ¯ «¨âàë
call draw_palitra ; <20>ˆ“…Œ <20>ˆ<CB86> call draw_palitra ; <20>ˆ“…Œ <20>ˆ<CB86>
jmp still ; ¨ ­  ®¦¨¤ ­¨¥ ᮡëâ¨ï jmp still ; ¨ ­  ®¦¨¤ ­¨¥ ᮡëâ¨ï
next_end: next_end:
@ -303,41 +298,52 @@ draw_main:
mov edx,0x6000000C ; ID = 12 mov edx,0x6000000C ; ID = 12
mov esi,[sc.work_button] ; RGB mov esi,[sc.work_button] ; RGB
int 0x40 ; call int 0x40 ; call
mov eax,13 ; draw rect ; circle diagram
mov ebx,266 shl 16+16 ; [x] + [size] add ecx,19 shl 16 ; move rect
mov ecx,9 shl 16+16 ; [y] + [size] mov edx,0x6000000F ; ID = 15
mov edx,0x666666 ; RGB int 0x40 ; call
push esi ; backup esi
mov esi,8 ; counter=8 mov eax,7 ; 7 - ­®¬¥à ä㭪樨
draw_lpanel: ; loop label mov ebx,panel ; 㪠§ â¥«ì ­  ¨§®¡à ¦¥­¨¥ ¢ ä®à¬ â¥ BBGGRRBBGGRR...
int 0x40 ; call draw black rect mov ecx, 16 shl 16 + 149 ; [à §¬¥à ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ y]
add ecx,19 shl 16 ; move rect mov edx,266 shl 16 + 9 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
dec esi ; decrement counter int 0x40
cmp esi,0 ; if counter!=zero
jne draw_lpanel ; then goto label ;mov eax,13 ; draw rect
mov esi,8 ; else counter=8 ;mov ebx,266 shl 16+16 ; [x] + [size]
mov ebx,267 shl 16+14 ; [x] + [size] ;mov ecx,9 shl 16+16 ; [y] + [size]
mov ecx,10 shl 16+14 ; [y] + [size] ;mov edx,0x666666 ; RGB
mov edx,0xF3F3F3 ; RGB ;push esi ; backup esi
draw_lpanel2: ; 2 loop label ;mov esi,8 ; counter=8
int 0x40 ; call draw white rect ;draw_lpanel: ; loop label
add ecx,19 shl 16 ; move rect ; int 0x40 ; call draw black rect
dec esi ; decrement counter ; add ecx,19 shl 16 ; move rect
cmp esi,0 ; if counter!=0 ; dec esi ; decrement counter
jne draw_lpanel2 ; then goto label2 ; cmp esi,0 ; if counter!=zero
pop esi ; restore esi ; jne draw_lpanel ; then goto label
; mov esi,8 ; else counter=8
; mov ebx,267 shl 16+14 ; [x] + [size]
; mov ecx,10 shl 16+14 ; [y] + [size]
; mov edx,0xF3F3F3 ; RGB
;draw_lpanel2: ; 2 loop label
; int 0x40 ; call draw white rect
; add ecx,19 shl 16 ; move rect
; dec esi ; decrement counter
; cmp esi,0 ; if counter!=0
; jne draw_lpanel2 ; then goto label2
;pop esi ; restore esi
; draw_left_arrow for button_next_colorsheme ; draw_left_arrow for button_next_colorsheme
mov eax,4 ; Write string ;mov eax,4 ; Write string
mov ebx,272 shl 16+13 ; [x] + [y] ;mov ebx,272 shl 16+13 ; [x] + [y]
mov ecx,0x0 ; RGB ;mov ecx,0x0 ; RGB
mov edx,larrow ; string pointer ;mov edx,larrow ; string pointer
mov esi,1 ; count symbol ;mov esi,1 ; count symbol
int 0x40 ; call ;int 0x40 ; call
mov eax,38 ; draw line ;mov eax,38 ; draw line
mov ebx,270 shl 16+272 ; [start x] + [end x] ;mov ebx,270 shl 16+272 ; [start x] + [end x]
mov ecx,16 shl 16+16 ; [start y] + [end y] ;mov ecx,16 shl 16+16 ; [start y] + [end y]
mov edx,0x0 ; RGB ;mov edx,0x0 ; RGB
int 0x40 ; call ;int 0x40 ; call
ret ; return ret ; return
;................................................................................................. ;.................................................................................................
@ -456,10 +462,11 @@ desktop_get:
int 0x40 ; xsize = à §¬¥à ¯® £®à¨§®­â «¨ - 1 int 0x40 ; xsize = à §¬¥à ¯® £®à¨§®­â «¨ - 1
mov ebx,eax ; mov ebx,eax ;
shr ebx,16 ; ebx = xsize-1 shr ebx,16 ; ebx = xsize-1
;movzx edx,ax ;; edx = ysize-1 («¨è­¨© ª®¤) movzx edx,ax ; edx = ysize-1 («¨è­¨© ª®¤)
inc ebx ; ebx = xsize inc ebx ; ebx = xsize
;inc edx ;; edx = ysize («¨è­¨© ª®¤) inc edx ; edx = ysize («¨è­¨© ª®¤)
mov [desctop_w],ebx mov [desctop_w],ebx
mov [desctop_h],edx
ret ret
;end_desktop_get ;end_desktop_get
@ -504,8 +511,8 @@ draw_palitra:
mov edx,[sc.work] ; 梥â mov edx,[sc.work] ; 梥â
int 0x40 int 0x40
;cmp [renmode],2 cmp [renmode],2
;je cyrcle_draw je cyrcle_draw
;cmp [renmode],1 ;cmp [renmode],1
;je picker_draw ;je picker_draw
cmp [renmode],0 cmp [renmode],0
@ -515,13 +522,125 @@ draw_palitra:
;................................................................................................. ;.................................................................................................
; Žâà¨á®¢ª  ªà㣮¢®© ¤¨ £à ¬¬ë ; Žâà¨á®¢ª  ªà㣮¢®© ¤¨ £à ¬¬ë
;................................................................................................. ;.................................................................................................
;cyrcle_draw: cyrcle_draw:
;mov eax,7 ; 7 - ­®¬¥à ä㭪樨 ;mov eax,13
;mov ebx,circle ; 㪠§ â¥«ì ­  ¨§®¡à ¦¥­¨¥ ¢ ä®à¬ â¥ BBGGRRBBGGRR... ;mov edx,0x666666
;mov ecx,148 shl 16 + 148 ; [à §¬¥à ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ y] ;mov ebx,108*65536+152
;mov edx,110 shl 16 + 9 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y] ;mov ecx,125*65536+33
;int 0x40 ;mcall
;ret ;mov edx,0xF3F3F3
;mov ebx,109*65536+150
;mov ecx,126*65536+31
;mcall
;mov eax,4 ; 4 - ¢ë¢¥á⨠áâபã ⥪áâ  ¢ ®ª­®
;mov ebx,115 shl 16+131 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
;mov ecx,0x666666 ; 0xX0RRGGBB (RR, GG, BB § ¤ îâ 梥â ⥪áâ )
;mov edx,hint ; 㪠§ â¥«ì ­  ­ ç «® áâப¨
;mov esi,24 ; ¢ë¢®¤¨âì esi ᨬ¢®«®¢
;mcall
;mov ebx,125 shl 16+144 ; [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
;mov edx,hint2 ; 㪠§ â¥«ì ­  ­ ç «® áâப¨
;mov esi,21 ; ¢ë¢®¤¨âì esi ᨬ¢®«®¢
;mcall
mov eax,13
mov edx,0x666666
mov ebx,111*65536+145
mov ecx, 9*65536+145
mcall
;mov edx,[color]
;mov ebx,109*65536+150
;mov ecx, 10*65536+150
;mcall
call mouse_local ; ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® ®ª­ 
mov ecx, [mouse_x] ; § ­®á¨¬ ¢ ॣ¨áâà
mov edx, [mouse_y] ; § ­®á¨¬ ¢ ॣ¨áâà
cmp ecx, WIN_W-10
jg cyrcle_draw_2
cmp edx, WIN_H
jle end_cyrcle_draw
cyrcle_draw_2:
call desktop_get
call mouse_global
mov ebx,112*65536+11
mov esi,0 ; counter=8
circle_loop:
mov ecx, 10*65536+11
mov edi,0
circle_loop2:
mov eax,13
call circle_pixel_read
mcall
add ecx,11 shl 16
inc edi
cmp edi,13
jne circle_loop2
add ebx,11 shl 16
inc esi
cmp esi,13
jne circle_loop
mov eax,13
mov edx,0x0
mov ebx,177*65536+13
mov ecx, 76*65536+13
mcall
mov ecx, [mouse_x]
mov edx, [mouse_y]
inc ecx
inc edx
mov ebx, edx
imul ebx, [desctop_w]
add ebx, ecx
mov eax, 35
mcall
mov edx,eax
mov eax,13
mov ebx,178*65536+11
mov ecx, 77*65536+11
mcall
end_cyrcle_draw:
ret
circle_pixel_read:
push ecx
push ebx
push eax
mov ecx, [mouse_x]
mov edx, [mouse_y]
inc ecx
add ecx, esi
cmp ecx, 6
jl _cpr_exit
sub ecx, 6
inc edx
add edx, edi
cmp edx, 6
jl _cpr_exit
sub edx, 6
mov ebx, edx
imul ebx, [desctop_w]
add ebx, ecx
mov eax, 35
mcall
mov edx,eax
pop eax
pop ebx
pop ecx
ret
_cpr_exit:
mov edx,0x00000000
pop eax
pop ebx
pop ecx
ret
;picker_draw: ;picker_draw:
;ret ;ret
@ -1079,35 +1198,13 @@ str_len:
ret ret
;end_str_len ;end_str_len
;.................................................................................................
; ¢®§¢à é ¥â 㪠§ â¥«ì ­  ¯¥à¢®¥ ¢å®¦¤¥­¨¥ Chr L (¢å®¤->EDI string ; ¢ë室->EAX offset)
;.................................................................................................
;strscan:
; push ecx ; ¤«¨­  áâப¨
; push ebx ; 㪠§ â¥«ì ­  ᨬ¢®« (bl)
; push esi ; ¯à¨£®¤¨âáï
; push edi ; 㪠§ â¥«ì ­  áâபã
; mov esi, edi
; mov al,bl
; repne scasb
; sub edi, esi
; mov eax, edi
; dec eax
; pop edi
; pop esi
; pop ebx
; pop ecx
; ret
;end;
;#___________________________________________________________________________________________________ ;#___________________________________________________________________________________________________
;****************************************************************************************************| ;****************************************************************************************************|
; <20>ŽŠ <20><EFBFBD>…Œ…<C592><E280A6>ˆ ŠŽ<C5A0><E28099> | ; <20>ŽŠ <20><EFBFBD>…Œ…<C592><E280A6>ˆ ŠŽ<C5A0><E28099> |
;----------------------------------------------------------------------------------------------------/ ;----------------------------------------------------------------------------------------------------/
circle:
cm db 12 dup(0) cm db 12 dup(0)
color dd 00000000h ; åà ­¨â §­ ç¥­¨¥ ¢ë¡à ­­®£® æ¢¥â  color dd 00000000h ; åà ­¨â §­ ç¥­¨¥ ¢ë¡à ­­®£® 梥â 
color2 dd 00FFFFFFh ; åà ­¨â §­ ç¥­¨¥ ¢â®à®£® ¢ë¡à ­­®£® æ¢¥â  color2 dd 00FFFFFFh ; åà ­¨â §­ ç¥­¨¥ ¢â®à®£® ¢ë¡à ­­®£® 梥â 
@ -1115,8 +1212,9 @@ str_len:
mouse_y dd 0 ; åà ­¨â £«®¡ «ì­ãî ã ª®®à¤¨­ âã ¬ëè¨ mouse_y dd 0 ; åà ­¨â £«®¡ «ì­ãî ã ª®®à¤¨­ âã ¬ëè¨
mouse_f dd 0 ; åà ­¨â ¤ ­­ë¥ ® ⮬ ª ª ï ª­®¯ª  ¬ëè¨ ¡ë«  ­ ¦ â  mouse_f dd 0 ; åà ­¨â ¤ ­­ë¥ ® ⮬ ª ª ï ª­®¯ª  ¬ëè¨ ¡ë«  ­ ¦ â 
desctop_w dd 0 ; åà ­¨â è¨à¨­ã íªà ­  desctop_w dd 0 ; åà ­¨â è¨à¨­ã íªà ­ 
desctop_h dd 0 ; åà ­¨â ¢ëá®âã íªà ­ 
sc system_colors ; åà ­¨â áâàãªâãàã á¨á⥬­ëå 梥⮢ ᪨­  sc system_colors ; åà ­¨â áâàãªâãàã á¨á⥬­ëå 梥⮢ ᪨­ 
title db 'Palitra v0.6',0 ; åà ­¨â ¨¬ï ¯à®£à ¬¬ë title db 'Palitra v0.7',0 ; åà ­¨â ¨¬ï ¯à®£à ¬¬ë
hidden db 'Hidden',0 hidden db 'Hidden',0
hex db '#',0 ; ¤«ï ¢ë¢®¤  à¥èñ⪨ ª ª ⥪áâ  hex db '#',0 ; ¤«ï ¢ë¢®¤  à¥èñ⪨ ª ª ⥪áâ 
cname db 'RGBAx' ; åà ­¨â à §àï¤ë 梥⮢ (red,green,blue) x-¬¥âª  ª®­æ  cname db 'RGBAx' ; åà ­¨â à §àï¤ë 梥⮢ (red,green,blue) x-¬¥âª  ª®­æ 
@ -1132,6 +1230,9 @@ str_len:
runmode dd 1 ; ०¨¬ § ¯ã᪠ (1-normal, 2-hidden, 3-colordialog) runmode dd 1 ; ०¨¬ § ¯ã᪠ (1-normal, 2-hidden, 3-colordialog)
params db 20 dup(0) ; ¯à¨ñ¬ ¯ à ¬¥â஢ params db 20 dup(0) ; ¯à¨ñ¬ ¯ à ¬¥â஢
params_c db 9 dup(0) ; ¯à¨ñ¬­¨ª ¤«ï æ¢¥â  params_c db 9 dup(0) ; ¯à¨ñ¬­¨ª ¤«ï 梥â 
I_END: I_END:

Binary file not shown.

View File

@ -0,0 +1,25 @@
mov edi,params ; указатель на строку
call str_len ; получаем длину строки
cmp eax,0 ; стравниваем длину с нулём
je red ; если параметров нет то уходим
call _read_params ; иначе читаем параметры цвета (очень криво)
xor eax,eax ; зануляем регистр
mov al,byte [params] ; читаем параметр мода
cmp al,'N' ; сравниваем с normal mode
jne _no_normalmode ; если нет то уходим на проверку дальше
mov [runmode],1 ; если да то устанавливаем его
jmp red ; идём на отрисовку
_no_normalmode: ; если не normal mode то
cmp al,'H' ; возможно hidden mode
jne _no_hiddenmode ; если не он то уходим дальше
mov [runmode],2 ; если он то устанавливаем что это он (нах?)
call set_background ; меняем фон
jmp bexit ; и закрываем прогу
_no_hiddenmode: ; если не hidden mode
cmp al,'D' ; возможно это color dialog mode
jne _no_dialogmode ; если всё таки не он то уходим
mov [runmode],3 ; иначе указываем что это таки он
jmp red ; и уходим на выполнение
_no_dialogmode: ; если это ни один из заявленых модов
mov [runmode],1 ; то сбрасываем на дефолт
jmp red ; и рисуем