forked from KolibriOS/kolibrios
FindNumbers: -1 IMG sector
git-svn-id: svn://kolibrios.org@8287 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1bc102cf71
commit
02503d625c
@ -1,8 +1,7 @@
|
|||||||
//(C) Artemonische, 2010
|
//(C) Artemonische, 2010
|
||||||
|
|
||||||
#pragma option meos
|
#pragma option meos
|
||||||
//#include "..\lib\kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
|
#include "kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
|
||||||
#include "kolibri.h--"
|
|
||||||
|
|
||||||
#ifndef AUTOBUILD
|
#ifndef AUTOBUILD
|
||||||
#include "lang.h--"
|
#include "lang.h--"
|
||||||
@ -32,9 +31,8 @@
|
|||||||
?define WIN_TEXT "You have found all numbers! :)"
|
?define WIN_TEXT "You have found all numbers! :)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int find=10;
|
int find;
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int button_id;
|
int button_id;
|
||||||
@ -42,31 +40,26 @@ struct
|
|||||||
int text;
|
int text;
|
||||||
}box[81];
|
}box[81];
|
||||||
|
|
||||||
|
#define BUTTON_NEW_GAME 582
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int button,tempi,tempj;
|
int button,tempi,tempj;
|
||||||
randomize();
|
randomize();
|
||||||
initialization();
|
new_game();
|
||||||
draw_window();
|
loop() switch(@WaitEvent())
|
||||||
draw_buttons();
|
|
||||||
loop()
|
|
||||||
{
|
|
||||||
switch(WaitEvent())
|
|
||||||
{
|
{
|
||||||
case evButton:
|
case evButton:
|
||||||
button=GetButtonID();
|
button=@GetButtonID();
|
||||||
IF (button==1)
|
IF (button==1)
|
||||||
{
|
{
|
||||||
ExitProcess();
|
ExitProcess();
|
||||||
}
|
}
|
||||||
IF (button==582)
|
IF (button==BUTTON_NEW_GAME)
|
||||||
{
|
{
|
||||||
find=10;
|
new_game();
|
||||||
initialization();
|
|
||||||
draw_window();
|
|
||||||
draw_buttons();
|
|
||||||
}
|
}
|
||||||
if (button>500) && (button<582) && (box[button-500].text == find)
|
if (button>500) && (button<BUTTON_NEW_GAME) && (box[button-500].text == find)
|
||||||
{
|
{
|
||||||
box[button-500].mark=2;
|
box[button-500].mark=2;
|
||||||
find++;
|
find++;
|
||||||
@ -88,27 +81,17 @@ void main()
|
|||||||
}
|
}
|
||||||
BREAK;
|
BREAK;
|
||||||
case evKey: //¥á«¨ ¯à®¨§®è«® ¦ ⨥ ª« ¢¨è¨ ª« ¢¨ âãà¥
|
case evKey: //¥á«¨ ¯à®¨§®è«® ¦ ⨥ ª« ¢¨è¨ ª« ¢¨ âãà¥
|
||||||
IF (GetKey()==051)
|
IF (@GetKey()==051) new_game(); //F2
|
||||||
{
|
|
||||||
find=10;
|
|
||||||
initialization();
|
|
||||||
draw_window();
|
|
||||||
draw_buttons();
|
|
||||||
}
|
|
||||||
BREAK;
|
BREAK;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
draw_window();
|
draw_window();
|
||||||
draw_buttons();
|
draw_buttons();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExitProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_window()
|
void draw_window()
|
||||||
{
|
{
|
||||||
WindowRedrawStatus(1); // ç «® ¯¥à¥à¨á®¢ª¨ ®ª
|
DefineAndDrawWindow(300,176,280,343,0x34,0xDCFFDC,"FindNumbers");
|
||||||
DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //à¨á㥬 ®ª®
|
|
||||||
DrawBar(0,13,271,1,0x0CFF0C); //«¨¨ï ᢥàåã
|
DrawBar(0,13,271,1,0x0CFF0C); //«¨¨ï ᢥàåã
|
||||||
DrawBar(0,285,271,1,0x0CFF0C);
|
DrawBar(0,285,271,1,0x0CFF0C);
|
||||||
DrawBar(0,299,271,1,0x0CFF0C); //«¨¨ï ᨧã
|
DrawBar(0,299,271,1,0x0CFF0C); //«¨¨ï ᨧã
|
||||||
@ -119,15 +102,28 @@ void draw_window()
|
|||||||
WriteText(BOT_RIGHT_TEXT_COL,289,0x80,0x000000,BOT_RIGHT_TEXT);
|
WriteText(BOT_RIGHT_TEXT_COL,289,0x80,0x000000,BOT_RIGHT_TEXT);
|
||||||
WriteNumber(BOT_LEFT_NUMBER_COL,289,0x80,0,find);
|
WriteNumber(BOT_LEFT_NUMBER_COL,289,0x80,0,find);
|
||||||
WriteNumber(BOT_RIGHT_NUMBER_COL,289,0x80,0,90-find+1);
|
WriteNumber(BOT_RIGHT_NUMBER_COL,289,0x80,0,90-find+1);
|
||||||
DrawFlatButton(155,300,115,14,582,0xAFFFAF,F2_TEXT);
|
DrawNewGameButton(155,300,115,14,0xAFFFAF);
|
||||||
WriteText(2,304,0x80,0x000000,"Made by Artemonische,2010");
|
WriteText(2,304,0x80,0x000000,"Made by Artemonische,2010");
|
||||||
}
|
}
|
||||||
IF (find==91)
|
IF (find==91)
|
||||||
{
|
{
|
||||||
WriteText(70,100,0x80,0x000000,WIN_TEXT);
|
WriteText(70,100,0x80,0x000000,WIN_TEXT);
|
||||||
DrawFlatButton(100,110,70,20,582,0xE4DFE1,F2_TEXT);
|
DrawNewGameButton(100,110,70,20,0xE4DFE1);
|
||||||
}
|
}
|
||||||
WindowRedrawStatus(2); //ª®¥æ ¯¥à¥à¨á®¢ª¨ ®ª
|
}
|
||||||
|
|
||||||
|
void DrawNewGameButton(dword x,y,width,height,color)
|
||||||
|
{
|
||||||
|
DefineButton(x,y,width,height,BUTTON_NEW_GAME,color);
|
||||||
|
WriteText(-11*6+width/2+x+1,height/2-3+y,0x80,0,F2_TEXT,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void new_game()
|
||||||
|
{
|
||||||
|
find=10;
|
||||||
|
initialization();
|
||||||
|
draw_window();
|
||||||
|
draw_buttons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_buttons()
|
void draw_buttons()
|
||||||
|
@ -6,14 +6,12 @@ char os_name[8] = {'M','E','N','U','E','T','0','1'};
|
|||||||
dword os_version = 0x00000001;
|
dword os_version = 0x00000001;
|
||||||
dword start_addr = #main;
|
dword start_addr = #main;
|
||||||
dword final_addr = #stop+32;
|
dword final_addr = #stop+32;
|
||||||
dword alloc_mem = 0x00100000;
|
dword alloc_mem = 0x0090000;
|
||||||
dword x86esp_reg = 0x00100000;
|
dword x86esp_reg = 0x0090000;
|
||||||
dword I_Param = #param;
|
dword I_Param = 0x0;
|
||||||
dword I_Icon = 0x0;
|
dword I_Icon = 0x0;
|
||||||
char param[256]="";
|
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
#define evMouse 6
|
|
||||||
#define evButton 3
|
#define evButton 3
|
||||||
#define evKey 2
|
#define evKey 2
|
||||||
#define evReDraw 1
|
#define evReDraw 1
|
||||||
@ -44,31 +42,27 @@ inline fastcall word GetButtonID(){
|
|||||||
EAX = EAX >> 8;
|
EAX = EAX >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fastcall dword strlen(dword EDI){
|
inline fastcall ExitProcess(){
|
||||||
EAX=0;
|
EAX = -1; // close this program
|
||||||
ECX=-1;
|
$int 0x40
|
||||||
$REPNE $SCASB
|
|
||||||
EAX-=2+ECX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte WindowRePaint=0;
|
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,EDI)
|
||||||
inline fastcall void WindowRedrawStatus(dword EBX)
|
|
||||||
{
|
{
|
||||||
EAX = 12; // function 12:tell os about windowdraw
|
EAX = 12; // function 12:tell os about windowdraw
|
||||||
|
EBX = 1;
|
||||||
$int 0x40
|
$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;
|
EBX = x << 16 + sizeX;
|
||||||
ECX = y << 16 + sizeY;
|
ECX = y << 16 + sizeY;
|
||||||
EDX = mainAreaType << 24 | mainAreaColour;
|
EDX = mainAreaType << 24 | mainAreaColour;
|
||||||
ESI = headerType << 24 | headerColour;
|
|
||||||
$xor eax,eax
|
$xor eax,eax
|
||||||
$int 0x40
|
$int 0x40
|
||||||
}
|
|
||||||
|
|
||||||
|
EAX = 12; // function 12:tell os about windowdraw
|
||||||
|
EBX = 2;
|
||||||
|
$int 0x40
|
||||||
|
}
|
||||||
|
|
||||||
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
|
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
|
||||||
{
|
{
|
||||||
@ -87,8 +81,6 @@ ESI = fontType<<24+ESI;
|
|||||||
$int 0x40;
|
$int 0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DrawBar(dword x,y,w,h,EDX)
|
void DrawBar(dword x,y,w,h,EDX)
|
||||||
{
|
{
|
||||||
EAX = 13;
|
EAX = 13;
|
||||||
@ -112,16 +104,6 @@ inline fastcall void DeleteButton(dword EDX)
|
|||||||
$int 0x40;
|
$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 - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
|
dword generator; // random number generator - äëÿ ãåíåðàöèè ñëó÷àéíûõ ÷èñåë
|
||||||
|
|
||||||
:int random(int max)
|
:int random(int max)
|
||||||
@ -153,16 +135,3 @@ dword generator; // random number generator -
|
|||||||
}
|
}
|
||||||
generator = EAX;
|
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);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user