forked from KolibriOS/kolibrios
cmm: add rgb example
git-svn-id: svn://kolibrios.org@6266 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8afc377269
commit
30ab10e50a
@ -6,3 +6,4 @@ end
|
||||
tup.rule("window.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "window.com")
|
||||
tup.rule("collections.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "collections.com")
|
||||
tup.rule("menu.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "menu.com")
|
||||
tup.rule("rgb.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "rgb.com")
|
||||
|
@ -1,17 +1,14 @@
|
||||
c-- window.c
|
||||
c-- collections.c
|
||||
c-- menu.c
|
||||
@del *.kex
|
||||
|
||||
@echo off
|
||||
@del _window
|
||||
@del _collections
|
||||
@del _menu
|
||||
@c-- window.c
|
||||
@c-- collections.c
|
||||
@c-- menu.c
|
||||
@c-- rgb.c
|
||||
|
||||
@rename window.com _window
|
||||
@rename collections.com _collections
|
||||
@rename menu.com _menu
|
||||
@rename *.com *.kex
|
||||
@mkdir bin
|
||||
@move *.kex bin\
|
||||
|
||||
@del warning.txt
|
||||
@echo on
|
||||
|
||||
@pause
|
136
programs/cmm/examples/rgb.c
Normal file
136
programs/cmm/examples/rgb.c
Normal file
@ -0,0 +1,136 @@
|
||||
//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()
|
||||
byte 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 (GetKey()==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)");
|
||||
_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:
|
@ -4,7 +4,7 @@
|
||||
|
||||
struct _rgb
|
||||
{
|
||||
byte r,g,b;
|
||||
byte b,g,r;
|
||||
void DwordToRgb();
|
||||
dword RgbToDword();
|
||||
} rgb;
|
||||
|
Loading…
Reference in New Issue
Block a user