kolibrios-gitea/programs/cmm/examples/rgb.c
Kirill Lipatov (Leency) 067e22eae8 Eolite File Manager 4.1:
- show 8.3 names in title case at /rd/1, 
- add hotkeys to change sorting by Ctrl+Fn
- change disk drive by Ctrl+number
Kolibri Graphics Benchmark 0.9 (mgb): 
- big fonts and UI impovements
- add second editbox to edit the Right comment
- show difference in percent between two columns
- if the difference is less or equal to 1% it is not shown
- Russian translation by Daniel Ovchinnikov
- add 16x16 icon for *.mgb files, add associations
icons32.png:
- add Pig icon, bought at http://porctrijambiste.e-monsite.com/contact/contact.html and a bit improved
Kiv:
- improve icons

git-svn-id: svn://kolibrios.org@7628 a494cfbc-eb01-0410-851d-a64ba20cac60
2019-04-16 21:21:19 +00:00

137 lines
3.3 KiB
C

//Generated with Lev's C-- pack for HiAsm, www.hiasm.com
#define MEMSIZE 4096*400
#include "../lib/kolibri.h"
#include "../lib/gui.h"
/*========================================================
= =
= DATA =
= =
========================================================*/
_rgb image[256*256];
#define fw 256+167
#define fh 290
enum {
DRAW1_BTN=10,
DRAW2_BTN,
SETBG_BTN
};
/*========================================================
= =
= MAIN CYCLE =
= =
========================================================*/
void main()
int id;
{
loop() switch(WaitEvent())
{
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
if (id==DRAW1_BTN) EventDraw1();
if (id==DRAW2_BTN) EventDraw2();
if (id==SETBG_BTN) EventSetBackground(#image,256,256);
break;
case evKey:
if (GetKeys()==27) ExitProcess();
break;
case evReDraw:
system.color.get();
DefineAndDrawWindow(screen.width-fw/2,screen.height-fh/2,fw,fh+skin_height,0x33,0xE0DFE3,"Rainbow (rgb test)",0);
_PutImage(0,0,256,256,#image);
DrawCaptButton(280,20, 110,30,DRAW1_BTN,system.color.work_button,system.color.work_button_text,"Draw 1");
DrawCaptButton(280,60, 110,30,DRAW2_BTN,system.color.work_button,system.color.work_button_text,"Draw 2");
DrawCaptButton(280,100,110,30,SETBG_BTN,system.color.work_button,system.color.work_button_text,"Background");
}
}
/*========================================================
= =
= Background system functions =
= =
========================================================*/
inline fastcall void BG_PaintMode( ECX)
{
$mov eax, 15
$mov ebx, 4
$int 0x40
}
inline fastcall void BG_SetImageSize( ECX, EDX)
{
$mov eax, 15
$mov ebx, 1
$int 0x40
}
inline fastcall void BG_PutPixels( ECX, EDX, ESI)
{
$mov eax, 15
$mov ebx, 5
$int 0x40
}
inline fastcall void BG_Redraw()
{
$mov eax, 15
$mov ebx, 3
$int 0x40
}
/*========================================================
= =
= EVENTS =
= =
========================================================*/
void EventDraw1()
{
int i1;
int i4;
int pos;
for(i4 = 0; i4 < 256; i4++) {
for(i1 = 0; i1 < 256; i1++) {
pos = i1 * 256 + i4;
image[pos].b = i1;
image[pos].r = 0;
image[pos].g = 0;
}
}
_PutImage(0,0,256,256,#image);
}
void EventDraw2()
{
int i1;
int i4;
int t2;
for(i4 = 0; i4 < 256; i4++) {
for(i1 = 0; i1 < 256; i1++) {
t2 = i1 * 256 + i4;
image[t2].r = i4;
image[t2].g = i1;
image[t2].b = 0;
}
}
_PutImage(0,0,256,256,#image);
}
void EventSetBackground(dword img_pointer, w,h)
{
BG_PaintMode(2); //1-tile,2-stratch
BG_SetImageSize(w,h);
BG_PutPixels(img_pointer, 0, 3*w*h);
BG_Redraw();
}
stop: