2017-09-06 18:16:43 +02:00
|
|
|
|
/*
|
2019-03-16 22:06:09 +01:00
|
|
|
|
Memory Blocks for KolibriOS v1.11
|
2017-09-06 18:16:43 +02:00
|
|
|
|
Leency&Veliant Edition
|
2019-03-16 22:06:09 +01:00
|
|
|
|
2008-2019
|
2017-09-06 18:16:43 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2018-04-16 11:30:24 +02:00
|
|
|
|
#define MEMSIZE 4096 * 15
|
2017-09-06 18:16:43 +02:00
|
|
|
|
#include "..\lib\gui.h"
|
|
|
|
|
#include "..\lib\random.h"
|
|
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
|
#include "..\lib\obj\libio.h"
|
|
|
|
|
#include "..\lib\obj\libimg.h"
|
2017-09-06 18:16:43 +02:00
|
|
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
|
|
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define COLOR_CELL_BG 0xFFFfff
|
|
|
|
|
#define COLOR_CELL_BORDER 0x94AECE
|
|
|
|
|
#define CELL_SIZE 43
|
|
|
|
|
#define PANEL_Y CELL_SIZE+4*6 + 4
|
|
|
|
|
#define PANEL_H 36
|
|
|
|
|
|
|
|
|
|
#define strok 6 //cell count x
|
|
|
|
|
#define stolbcov 10 //cell count y
|
|
|
|
|
|
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
#define LABEL_NEW_GAME "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> (F2)";
|
2018-04-04 01:38:46 +02:00
|
|
|
|
#else
|
|
|
|
|
#define LABEL_NEW_GAME "New game (F2)";
|
2017-09-06 18:16:43 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int bitstat[60], bitpict[60];
|
|
|
|
|
dword butonsx[60], butonsy[60];
|
|
|
|
|
dword firstbit, secondbit;
|
2019-03-16 22:06:09 +01:00
|
|
|
|
int count;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
dword id;
|
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
|
|
2020-05-24 18:46:26 +02:00
|
|
|
|
skin.load("/sys/icons32.png");
|
|
|
|
|
skin.fill_transparent(COLOR_CELL_BG);
|
2017-09-06 18:16:43 +02:00
|
|
|
|
|
|
|
|
|
NewGame();
|
|
|
|
|
|
|
|
|
|
loop() switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (key_scancode==60) NewGame();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evButton:
|
2019-03-16 22:06:09 +01:00
|
|
|
|
id = GetButtonID();
|
|
|
|
|
if (id==1) ExitProcess();
|
|
|
|
|
else if (id==5) NewGame();
|
|
|
|
|
else {
|
|
|
|
|
if (bitstat[id-100] == 0)
|
|
|
|
|
{
|
|
|
|
|
if (firstbit <> 0x0BAD)
|
2017-09-06 18:16:43 +02:00
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
if (secondbit <> 0x0BAD)
|
2017-09-06 18:16:43 +02:00
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
if (bitpict[firstbit-100] == bitpict[secondbit-100])
|
|
|
|
|
bitstat[firstbit-100] = bitstat[secondbit-100] = 2;
|
|
|
|
|
else
|
|
|
|
|
bitstat[firstbit-100] = bitstat[secondbit-100] = 0;
|
|
|
|
|
ReDraw_Game_Button(firstbit - 100);
|
|
|
|
|
ReDraw_Game_Button(secondbit - 100);
|
|
|
|
|
secondbit = 0x0BAD;
|
|
|
|
|
firstbit = id;
|
|
|
|
|
bitstat[id-100] = 1;
|
|
|
|
|
ReDraw_Game_Button(id - 100);
|
|
|
|
|
count++;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
}
|
2019-03-16 22:06:09 +01:00
|
|
|
|
else if (firstbit<>id)
|
2017-09-06 18:16:43 +02:00
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
secondbit = id;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
bitstat[id-100] = 1;
|
|
|
|
|
ReDraw_Game_Button(id - 100);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-16 22:06:09 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
firstbit = id;
|
|
|
|
|
bitstat[id-100] = 1;
|
|
|
|
|
ReDraw_Game_Button(id - 100);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Draw_Count();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2020-04-18 01:52:24 +02:00
|
|
|
|
sc.get();
|
2019-03-16 22:06:09 +01:00
|
|
|
|
DefineAndDrawWindow(215,100,CELL_SIZE+4*10 + 4 + 9,PANEL_Y+4+PANEL_H+skin_height,
|
|
|
|
|
0x34,0xC0C0C0,"Memory Blocks",0);
|
2017-09-06 18:16:43 +02:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
|
Draw_Panel();
|
|
|
|
|
Draw_Game_Pole();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NewGame()
|
|
|
|
|
{
|
|
|
|
|
int off;
|
2019-03-16 22:06:09 +01:00
|
|
|
|
int i;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
|
|
|
|
|
FOR (i = 0; i < 60; i++)
|
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
bitstat[i] = 0;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
bitpict[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
|
firstbit = secondbit = 0x0BAD;
|
|
|
|
|
FOR (i = 0; i < 30; i++)
|
|
|
|
|
{
|
|
|
|
|
do off = random(60); while (bitpict[off] != 0);
|
|
|
|
|
bitpict[off] = i;
|
|
|
|
|
do off = random(60); while (bitpict[off] != 0);
|
|
|
|
|
bitpict[off] = i;
|
|
|
|
|
}
|
2019-03-16 22:06:09 +01:00
|
|
|
|
Draw_Game_Pole();
|
|
|
|
|
Draw_Panel();
|
2017-09-06 18:16:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ReDraw_Game_Button(int id)
|
|
|
|
|
{
|
|
|
|
|
DefineButton(butonsx[id], butonsy[id], CELL_SIZE, CELL_SIZE, 100 + id + BT_HIDE, 0);
|
|
|
|
|
switch (bitstat[id])
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
Draw_Block(butonsx[id], butonsy[id]);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
Draw_Pressed_Block(butonsx[id], butonsy[id]);
|
|
|
|
|
img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32);
|
|
|
|
|
BREAK;
|
|
|
|
|
case 2:
|
|
|
|
|
Draw_Open_Block(butonsx[id], butonsy[id]);
|
|
|
|
|
img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32);
|
|
|
|
|
BREAK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Game_Pole()
|
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
int i;
|
2017-09-06 18:16:43 +02:00
|
|
|
|
byte j;
|
|
|
|
|
for (j = 0; j < stolbcov; j++) for (i = 0; i < strok; i++)
|
|
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
|
butonsx[j*strok+i] = CELL_SIZE+4 * j + 4; //save coordinates to avoid
|
|
|
|
|
butonsy[j*strok+i] = CELL_SIZE+4 * i + 4; //their recalculation after
|
2017-09-06 18:16:43 +02:00
|
|
|
|
ReDraw_Game_Button(j*strok + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Block(dword x, y)
|
|
|
|
|
{
|
|
|
|
|
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border
|
|
|
|
|
DrawRectangle3D(x + 1, y + 1, CELL_SIZE-2, CELL_SIZE-2, 0xFFFFFF, 0xDEDEDE);//bump
|
|
|
|
|
DrawBar(x + 2, y + 2, CELL_SIZE-3, CELL_SIZE-3, 0xBDC7D6);//background
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Open_Block(dword x, y)
|
|
|
|
|
{
|
|
|
|
|
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border
|
|
|
|
|
DrawBar(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, COLOR_CELL_BG);//background
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Pressed_Block(dword x, y)
|
|
|
|
|
{
|
|
|
|
|
DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border
|
|
|
|
|
DrawWideRectangle(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, 2, 0x94DB00);//border green
|
|
|
|
|
DrawBar(x + 3, y + 3, CELL_SIZE-5, CELL_SIZE-5, COLOR_CELL_BG);//background
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Panel()
|
|
|
|
|
{
|
2020-04-18 01:52:24 +02:00
|
|
|
|
DrawBar(0, PANEL_Y, Form.cwidth, 1, sc.work_dark);
|
|
|
|
|
DrawBar(0, PANEL_Y+1, Form.cwidth, 1, sc.work_light);
|
|
|
|
|
DrawBar(0, PANEL_Y+2, Form.cwidth, PANEL_H-2, sc.work);
|
2017-09-06 18:16:43 +02:00
|
|
|
|
DrawStandartCaptButton(9, PANEL_Y+5, 5, LABEL_NEW_GAME);
|
|
|
|
|
Draw_Count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw_Count()
|
|
|
|
|
{
|
2020-04-18 01:52:24 +02:00
|
|
|
|
DrawBar(Form.cwidth-32,PANEL_Y + 12,30,12,sc.work);
|
|
|
|
|
WriteNumber(Form.cwidth-32, PANEL_Y + 12, 0x90, sc.work_text, 3, count);
|
2017-09-06 18:16:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|