Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1804 → Rev 1805

/programs/games/FindNumbers/trunk/FindNumbers.c--
0,0 → 1,157
//(C) Artemonische, 2010
 
#pragma option meos
//#include "..\lib\kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
#include "kolibri.h--"
 
int find=10;
struct
{
int x;
int y;
int button_id;
int mark;
int text;
}box[81];
 
void main()
{
int button,tempi,tempj;
randomize();
initialization();
draw_window();
draw_buttons();
loop()
{
switch(WaitEvent())
{
CASE evButton:
button=GetButtonID();
IF (button==1)
{
ExitProcess();
}
IF (button==582)
{
find=10;
initialization();
draw_window();
draw_buttons();
}
if (button>500) && (button<582) && (box[button-500].text == find)
{
box[button-500].mark=2;
find++;
if (find==91)
{
draw_window();
}
else
{
DeleteButton(button);
tempi=box[button-500].y*30-30;
tempj=30*box[button-500].x-16;
DrawBar(tempi,tempj,30,30,0xDCFFDC);
DrawBar(70,289,16,8,0xDCFFDC);
DrawBar(252,289,16,8,0xDCFFDC);
WriteNumber(70,289,0x80,0,find);
WriteNumber(252,289,0x80,0,90-find+1);
}
}
BREAK;
CASE evKey: //¥á«¨ ¯à®¨§®è«® ­ ¦ â¨¥ ª« ¢¨è¨ ­  ª« ¢¨ âãà¥
IF (GetKey()==051)
{
find=10;
initialization();
draw_window();
draw_buttons();
}
BREAK;
CASE evReDraw:
draw_window();
draw_buttons();
BREAK;
}
}
ExitProcess();
}
 
void draw_window()
{
WindowRedrawStatus(1); //­ ç «® ¯¥à¥à¨á®¢ª¨ ®ª­ 
DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //à¨á㥬 ®ª­®
DrawBar(0,13,271,1,0x0CFF0C); //«¨­¨ï ᢥàåã
DrawBar(0,285,271,1,0x0CFF0C);
DrawBar(0,299,271,1,0x0CFF0C); //«¨­¨ï á­¨§ã
if (find<=90)
{
WriteText(4,4,0x80,0x000000,"‘®¡¥à¨â¥ ¢á¥ ç¨á«  ®â 10 ¤® 90 ¯® ¯®à浪ã...");
WriteText(4,289,0x80,0x000000,"ˆé¥¬ ç¨á«®: ");
WriteText(162,289,0x80,0x000000,"Žáâ «®áì ­ ©â¨: ");
WriteNumber(70,289,0x80,0,find);
WriteNumber(252,289,0x80,0,90-find+1);
DrawFlatButton(155,300,115,14,582,0xAFFFAF,"‡ ­®¢® (F2)");
WriteText(4,304,0x80,0x000000,"Made by Artemonische,2010");
}
IF (find==91)
{
WriteText(70,100,0x80,0x000000,"‚ë ­ è«¨ ¢á¥ ç¨á« ! :)");
DrawFlatButton(100,110,70,20,582,0xE4DFE1,"‡ ­®¢® (F2)");
}
WindowRedrawStatus(2); //ª®­¥æ ¯¥à¥à¨á®¢ª¨ ®ª­ 
}
 
void draw_buttons()
{
int i,tempi,tempj;
for (i=1;i<=81;i++)
{
IF (box[i].mark==1)
{
tempi=box[i].y*30-30;
tempj=30*box[i].x-16;
DefineButton(tempi,tempj,29,29,box[i].button_id,0xAFFFAF);
WriteNumber(tempi+11,tempj+11,0x80,0,box[i].text);
}
}
}
 
void initialization()
{
int i,j,t;
t=0;
FOR (i=1;i<=9;i++)
{
FOR (j=1;j<=9;j++)
{
t++;
box[t].x=j;
box[t].y=i;
box[t].mark=1;
box[t].button_id=500+t;
box[t].text=Generate(t);
}
}
}
 
int Generate(int xx)
{
int temp,k,p;
p=2;
WHILE (p==2)
{
temp=random(81)+10;
p=1;
FOR (k=1; k<xx; k++)
{
IF (box[k].text==temp)
{
p=2;
BREAK;
}
}
}
return temp;
}
stop:
/programs/games/FindNumbers/trunk/kolibri.h--
0,0 → 1,168
//CODED by Veliant, Leency, Nable. GNU GPL licence.
 
#code32 TRUE
 
char os_name[8] = {'M','E','N','U','E','T','0','1'};
dword os_version = 0x00000001;
dword start_addr = #main;
dword final_addr = #stop+32;
dword alloc_mem = 0x00100000;
dword x86esp_reg = 0x00100000;
dword I_Param = #param;
dword I_Icon = 0x0;
char param[256]="";
 
//Events
#define evMouse 6
#define evButton 3
#define evKey 2
#define evReDraw 1
 
//Button options
#define BT_DEL 0x80000000
#define BT_HIDE 0x40000000
#define BT_NOFRAME 0x20000000
 
#define OLD -1
#define true 1
#define false 0
 
inline fastcall dword WaitEvent(){
EAX = 10;
$int 0x40
}
 
inline fastcall word GetKey(){
EAX = 2; // just read this key from buffer
$int 0x40
EAX = EAX >> 8;
}
 
inline fastcall word GetButtonID(){
EAX = 17;
$int 0x40
EAX = EAX >> 8;
}
 
inline fastcall dword strlen(dword EDI){
EAX=0;
ECX=-1;
$REPNE $SCASB
EAX-=2+ECX;
}
 
byte WindowRePaint=0;
inline fastcall void WindowRedrawStatus(dword EBX)
{
EAX = 12; // function 12:tell os about windowdraw
$int 0x40
IF (EBX==1) WindowRePaint=1; ELSE WindowRePaint=0;
}
 
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
{
EBX = x << 16 + sizeX;
ECX = y << 16 + sizeY;
EDX = mainAreaType << 24 | mainAreaColour;
ESI = headerType << 24 | headerColour;
$xor eax,eax
$int 0x40
}
 
 
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
{
EAX = 4;
EBX = x<<16+y;
ECX = fontType<<24+color;
$int 0x40;
}
 
void WriteNumber(dword x,y,byte fontType, ESI, ECX)
{
EAX = 47;
EBX = 2<<16;
EDX = x<<16+y;
ESI = fontType<<24+ESI;
$int 0x40;
}
 
 
 
void DrawBar(dword x,y,w,h,EDX)
{
EAX = 13;
EBX = x<<16+w;
ECX = y<<16+h;
$int 0x40
}
 
void DefineButton(dword x,y,w,h,EDX,ESI)
{
EAX = 8;
EBX = x<<16+w;
ECX = y<<16+h;
$int 0x40
}
 
inline fastcall void DeleteButton(dword EDX)
{
EAX = 8;
EDX += BT_DEL;
$int 0x40;
}
 
void DrawFlatButton(dword x,y,width,height,id,color,text)
{
DrawRegion_3D(x,y,width,height,0x94AECE,0x94AECE);
DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,0xC7C7C7);
DrawBar(x+2,y+2,width-3,height-3,color); //§ «¨¢ª 
IF (id<>0) DefineButton(x,y,width,height,id+BT_HIDE,0xEFEBEF); //ª­®¯ª 
WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,0,text,0);
}
 
 
dword generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
 
:int random(int max)
// get pseudo-random number - ïîëó÷èòü ïñåâäîñëó÷àéíîå ÷èñëî
{
$rdtsc // eax & edx
$xor eax,edx
$not eax
 
EBX = generator;
$ror ebx,3
$xor ebx,0xdeadbeef
EBX += EAX;
generator = EBX;
EAX += EBX;
EAX = EAX % max;
return EAX;
}
 
:randomize()
// initialize random number generator - èíèöèàëèçèðîâàòü ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
{
asm
{
mov eax,3
int 0x40
ror eax,16
}
generator = EAX;
}
 
inline fastcall ExitProcess(){
EAX = -1; // close this program
$int 0x40
}
 
void DrawRegion_3D(dword x,y,width,height,color1,color2)
{
DrawBar(x,y,width+1,1,color1);
DrawBar(x,y+1,1,height-1,color1);
DrawBar(x+width,y+1,1,height,color2);
DrawBar(x,y+height,width,1,color2);
}
/programs/games/FindNumbers/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/FindNumbers/.
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property