From 91386937c13331205e5a6d4f8a6533115e7ff697 Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Sat, 16 Mar 2013 15:54:25 +0000 Subject: [PATCH] Adding ColorDialog, it is still a prototype. git-svn-id: svn://kolibrios.org@3380 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/colrdial/color_dialog.asm | 207 ++++++++++++++++++++++ programs/system/colrdial/color_dialog.bat | 6 + programs/system/colrdial/i_data.inc | 4 + programs/system/colrdial/palette.inc | 130 ++++++++++++++ programs/system/colrdial/tone.inc | 112 ++++++++++++ programs/system/colrdial/u_data.inc | 42 +++++ 6 files changed, 501 insertions(+) create mode 100644 programs/system/colrdial/color_dialog.asm create mode 100644 programs/system/colrdial/color_dialog.bat create mode 100644 programs/system/colrdial/i_data.inc create mode 100644 programs/system/colrdial/palette.inc create mode 100644 programs/system/colrdial/tone.inc create mode 100644 programs/system/colrdial/u_data.inc diff --git a/programs/system/colrdial/color_dialog.asm b/programs/system/colrdial/color_dialog.asm new file mode 100644 index 0000000000..a5406a63e8 --- /dev/null +++ b/programs/system/colrdial/color_dialog.asm @@ -0,0 +1,207 @@ +;***************************************************************************** +; Color Dialog - for Kolibri OS +; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario +; 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 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 Marat Zakiyanov ''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 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. +;***************************************************************************** + use32 + org 0x0 + + db 'MENUET01' + dd 0x01 + dd START + dd IM_END + dd I_END + dd stacktop + dd 0x0 + dd 0x0 +;--------------------------------------------------------------------- +include '../../macros.inc' +;include 'lang.inc' +;--------------------------------------------------------------------- +p_start_x = 10 +p_start_y = 10 + +p_size_x = 20 +p_size_y = 256 +;-------------------------------------- +t_start_x = 40 +t_start_y = 10 +;-------------------------------------- +w_start_x = 200 +w_start_y = 200 + +w_size_x = 400 +w_size_y = 350 +;-------------------------------------- +c_start_x = t_start_x + p_size_y + 10 +c_start_y = 10 + +c_size_x = 40 +c_size_y = 20 +;--------------------------------------------------------------------- + +START: + mcall 68,11 + + xor eax,eax + mov al,p_size_x + mov [palette_SIZE_X],eax + mov ax,p_size_y + mov [palette_SIZE_Y],eax + mov [tone_SIZE_X],eax + mov [tone_SIZE_Y],eax + mov eax,0xff0000 + mov [tone_color],eax + mov [selected_color],eax +;-------------------------------------- + mov ecx,[palette_SIZE_Y] + imul ecx,[palette_SIZE_X] + lea ecx,[ecx*3] + inc ecx ;reserve for stosd + mcall 68,12 + mov [palette_area],eax +;-------------------------------------- + call create_palette +;-------------------------------------- + mov ecx,[tone_SIZE_Y] + imul ecx,[tone_SIZE_X] + lea ecx,[ecx*3] + inc ecx ;reserve for stosd + mcall 68,12 + mov [tone_area],eax +;-------------------------------------- + call create_tone +;--------------------------------------------------------------------- +align 4 +red: + call draw_window +;--------------------------------------------------------------------- +align 4 +still: + mcall 10 + + cmp eax,1 + je red + + cmp eax,2 + je key + + cmp eax,3 + jne still +;--------------------------------------------------------------------- +align 4 +button: + mcall 17 + + cmp ah, 2 + je palette_button + + cmp ah, 3 + je tone_button + + cmp ah, 1 + jne still + +.exit: + mcall -1 +;--------------------------------------------------------------------- +align 4 +palette_button: + mcall 37,1 + and eax,0xffff + sub eax,p_start_y + imul eax,p_size_x + dec eax + lea eax,[eax+eax*2] + add eax,[palette_area] + mov eax,[eax] + mov [tone_color],eax + mov [selected_color],eax + call create_and_draw_tone + call draw_selected_color + jmp still +;--------------------------------------------------------------------- +align 4 +tone_button: + mcall 37,1 + mov ebx,eax + and eax,0xffff + shr ebx,16 + sub eax,t_start_y + imul eax,p_size_y + sub ebx,t_start_x + add eax,ebx + lea eax,[eax+eax*2] + add eax,[tone_area] + mov eax,[eax] + mov [selected_color],eax + call draw_selected_color + jmp still +;--------------------------------------------------------------------- +align 4 +key: + mcall 2 + jmp still +;--------------------------------------------------------------------- +align 4 +draw_selected_color: + mcall 13,,,[selected_color] + ret +;--------------------------------------------------------------------- +align 4 +create_and_draw_tone: + call create_tone + call draw_tone + ret +;--------------------------------------------------------------------- +align 4 +draw_tone: + mcall 65,[tone_area],<[tone_SIZE_X],[tone_SIZE_Y]>,,24 + ret +;--------------------------------------------------------------------- +align 4 +draw_window: + mcall 12,1 + mcall 0, , , 0x33AABBCC,,title + mcall 8,,,0x60000002 + mcall ,,,0x60000003 + mcall 65,[palette_area],<[palette_SIZE_X],[palette_SIZE_Y]>,,24 + call draw_tone + call draw_selected_color + mcall 12,2 + ret +;--------------------------------------------------------------------- +include 'palette.inc' +;--------------------------------------------------------------------- +include 'tone.inc' +;--------------------------------------------------------------------- +include 'i_data.inc' +;--------------------------------------------------------------------- +IM_END: +;--------------------------------------------------------------------- +include 'u_data.inc' +;--------------------------------------------------------------------- +I_END: +;--------------------------------------------------------------------- \ No newline at end of file diff --git a/programs/system/colrdial/color_dialog.bat b/programs/system/colrdial/color_dialog.bat new file mode 100644 index 0000000000..330b608af8 --- /dev/null +++ b/programs/system/colrdial/color_dialog.bat @@ -0,0 +1,6 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm color_dialog.asm color_dialog +@kpack color_dialog +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/system/colrdial/i_data.inc b/programs/system/colrdial/i_data.inc new file mode 100644 index 0000000000..4811ddd51a --- /dev/null +++ b/programs/system/colrdial/i_data.inc @@ -0,0 +1,4 @@ +;--------------------------------------------------------------------- +title: + db 'ColorDialog',0 +;--------------------------------------------------------------------- diff --git a/programs/system/colrdial/palette.inc b/programs/system/colrdial/palette.inc new file mode 100644 index 0000000000..967fc6e82a --- /dev/null +++ b/programs/system/colrdial/palette.inc @@ -0,0 +1,130 @@ +;----------------------------------------------------------------------------- +align 4 +create_palette: +;------------------------------------------- + mov eax,[palette_SIZE_Y] + mov ebx,6 + xor edx,edx + div ebx + mov [part_of_size_y],eax +;------------------------------------------- + mov ebx,eax + mov eax,255 shl 24 + xor edx,edx + div ebx + mov [offset_y],eax +;------------------------------------------- + mov edi,[palette_area] + mov edx,[offset_y] +;------------------------------------------- + xor ecx,ecx + mov eax,[tone_color] +;------------------------------------------- +align 4 +@@: + call palette_put_line +; blue + call next_color + add ecx,1 + cmp ecx,[part_of_size_y] + jne @b +;------------------------------------------- + mov ecx,[part_of_size_y] +;------------------------------------------- +align 4 +@@: + call palette_put_line +; red + ror eax,16 + call next_color + rol eax,16 + sub ecx,1 + jne @b +;------------------------------------------- + xor ecx,ecx +;------------------------------------------- +align 4 +@@: + call palette_put_line +; green + ror eax,8 + call next_color + rol eax,8 + add ecx,1 + cmp ecx,[part_of_size_y] + jne @b +;------------------------------------------- + mov ecx,[part_of_size_y] +;------------------------------------------- +align 4 +@@: + call palette_put_line +; blue + call next_color + sub ecx,1 + jne @b +;------------------------------------------- + xor ecx,ecx +;------------------------------------------- +align 4 +@@: + call palette_put_line +; red + ror eax,16 + call next_color + rol eax,16 + add ecx,1 + cmp ecx,[part_of_size_y] + jne @b +;------------------------------------------- + mov ecx,[part_of_size_y] +;------------------------------------------- +align 4 +@@: + call palette_put_line +; green + ror eax,8 + call next_color + rol eax,8 + sub ecx,1 + jne @b +;------------------------------------------- + mov edx,[part_of_size_y] + lea edx,[edx*3] + shl edx,1 + mov ecx,[palette_SIZE_Y] + sub ecx,edx + test ecx,ecx + jz .end +;------------------------------------------- +align 4 +@@: + call palette_put_line + loop @b +;------------------------------------------- +align 4 +.end: + ret +;--------------------------------------------------------------------- +align 4 +next_color: + mov ebx,ecx + imul ebx,edx + rol ebx,8 + mov al,bl + ret +;--------------------------------------------------------------------- +align 4 +palette_put_line: + push ecx + mov ecx,[palette_SIZE_X] + cld +;------------------------------------------- +align 4 +.loop: + stosd + dec edi + loop .loop + pop ecx + ret +;--------------------------------------------------------------------- \ No newline at end of file diff --git a/programs/system/colrdial/tone.inc b/programs/system/colrdial/tone.inc new file mode 100644 index 0000000000..3cc210b33f --- /dev/null +++ b/programs/system/colrdial/tone.inc @@ -0,0 +1,112 @@ +;----------------------------------------------------------------------------- +align 4 +create_tone: +;------------------------------------------- + mov ebx,[tone_SIZE_Y] + xor eax,eax + dec al + sub al,[tone_color.red] + shl eax,24 + xor edx,edx + div ebx + mov [offset_y.red],eax + + xor eax,eax + dec al + sub al,[tone_color.green] + shl eax,24 + xor edx,edx + div ebx + mov [offset_y.green],eax + + xor eax,eax + dec al + sub al,[tone_color.blue] + shl eax,24 + xor edx,edx + div ebx + mov [offset_y.blue],eax +;------------------------------------------- + mov edi,[tone_area] + xor ecx,ecx +;------------------------------------------- +align 4 +@@: + mov eax,[tone_color] +; blue + mov edx,[offset_y.blue] + call next_color_Y + ror eax,8 +; green + mov edx,[offset_y.green] + call next_color_Y + ror eax,8 +; red + mov edx,[offset_y.red] + call next_color_Y + rol eax,16 + + call tone_put_line + add ecx,1 + cmp ecx,[tone_SIZE_X] + jne @b + + ret +;----------------------------------------------------------------------------- +tone_put_line: + push ecx + + mov ecx,eax + mov ebx,[tone_SIZE_X] + shl eax,24 + xor edx,edx + div ebx + mov [offset_x.blue],eax + + mov eax,ecx + shr eax,8 + shl eax,24 + xor edx,edx + div ebx + mov [offset_x.green],eax + + mov eax,ecx + shr eax,16 + shl eax,24 + xor edx,edx + div ebx + mov [offset_x.red],eax + mov eax,ecx + + push ebx esi + mov ecx,[tone_SIZE_X] + xor edx,edx + xor ebx,ebx + xor esi,esi +@@: + mov eax,edx + shr eax,24 + add edx,[offset_x.blue] + mov [edi],al + mov eax,ebx + shr eax,24 + add ebx,[offset_x.green] + mov [edi+1],al + mov eax,esi + shr eax,24 + add esi,[offset_x.red] + mov [edi+2],al + add edi,3 + dec ecx + jnz @b + pop esi ebx + pop ecx + ret +;----------------------------------------------------------------------------- +align 4 +next_color_Y: + imul edx,ecx + rol edx,8 + add al,dl + ret +;----------------------------------------------------------------------------- \ No newline at end of file diff --git a/programs/system/colrdial/u_data.inc b/programs/system/colrdial/u_data.inc new file mode 100644 index 0000000000..845166b31a --- /dev/null +++ b/programs/system/colrdial/u_data.inc @@ -0,0 +1,42 @@ +;--------------------------------------------------------------------- +align 4 +palette_area rd 1 +tone_area rd 1 +part_of_size_y rd 1 +;-------------------------------------- +offset_y: +.red rd 1 +.green rd 1 +.blue rd 1 +;-------------------------------------- +offset_x: +.red rd 1 +.green rd 1 +.blue rd 1 +;-------------------------------------- +tone_color: +.blue rb 1 +.green rb 1 +.red rb 1 +.align rb 1 +;-------------------------------------- +selected_color: +.blue rb 1 +.green rb 1 +.red rb 1 +.align rb 1 +;-------------------------------------- +palette_SIZE_Y rd 1 +palette_SIZE_X rd 1 + +tone_SIZE_Y rd 1 +tone_SIZE_X rd 1 +;--------------------------------------------------------------------- +;align 4 +;procinfo: +; rb 1024 +;--------------------------------------------------------------------- +align 4 + rb 4096 +stacktop: +;--------------------------------------------------------------------- \ No newline at end of file