Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.    Memory Blocks for KolibriOS v1.02
  3.              L&V Edition
  4.  
  5.         Èäåÿ è äèçàéí: Leency
  6.         Ðåàëèçîâàíî: Veliant è Leency
  7.           Compile with C--
  8.                        2008
  9. */
  10. #codesize
  11. #include "kolibri.h--"
  12. #include "icons.txt"
  13. #define strok 6         //êîëè÷åñòâî áëîêîâ ïî âåðòèêàëè
  14. #define stolbcov 10     //êîëè÷åñòâî áëîêîâ ïî ãîðèçîíòàëè
  15.  
  16. char button_r[20] = "®¢ ï ¨£à (F2) ‘ç¥â:"; //íîâàÿ èãðà
  17. char button_e[20] = "New  game (F2)Count:";
  18.  
  19. byte bitstat[60], bitpict[60];
  20. dword butonsx[60], butonsy[60];
  21. dword firstbit, secondbit;
  22. int i, count, lang;
  23.  
  24. void main()
  25. {
  26.         byte id;
  27.         init();
  28.         loop()
  29.         {
  30.                 switch (WaitEvent())
  31.                 {
  32.                         CASE evButton:
  33.                                 id = GetButtonID();
  34.                                 SWITCH (id)
  35.                                 {
  36.                                         CASE 1:
  37.                                                 ExitProcess();
  38.                                         CASE 5:
  39.                                                 init();
  40.                                                 break;
  41.                                         CASE 6:
  42.                                                 FOR (i=0;i<20;i++) button_r[i]><button_e[i];
  43.                                                 IF (!lang) lang=1; ELSE lang=0;
  44.                                                 Draw_Panel();
  45.                                                 break;
  46.                                         default:
  47.                                                 if (bitstat[id-100] == 0)
  48.                                                 {
  49.                                                         if (firstbit <> 0x0BAD)
  50.                                                         {
  51.                                                                 if (secondbit <> 0x0BAD)
  52.                                                                 {
  53.                                                                         IF (bitpict[firstbit-100] == bitpict[secondbit-100])
  54.                                                                                 bitstat[firstbit-100] = bitstat[secondbit-100] = 2;
  55.                                                                         ELSE
  56.                                                                                 bitstat[firstbit-100] = bitstat[secondbit-100] = 0;
  57.                                                                         ReDraw_Game_Button(firstbit - 100);
  58.                                                                         ReDraw_Game_Button(secondbit - 100);
  59.                                                                         secondbit = 0x0BAD;
  60.                                                                         firstbit = id;
  61.                                                                         bitstat[id-100] = 1;
  62.                                                                         ReDraw_Game_Button(id - 100);
  63.                                                                         count++;
  64.                                                                 }
  65.                                                                 ELSE IF (firstbit<>id)
  66.                                                                 {
  67.                                                                         secondbit = id;
  68.                                                                         bitstat[id-100] = 1;
  69.                                                                         ReDraw_Game_Button(id - 100);
  70.                                                                         count++;
  71.                                                                 }
  72.                                                         }
  73.                                                         ELSE
  74.                                                         {
  75.                                                                 firstbit = id;
  76.                                                                 bitstat[id-100] = 1;
  77.                                                                 ReDraw_Game_Button(id - 100);
  78.                                                                 count++;
  79.                                                         }
  80.                                                 }
  81.                                                 Draw_Count();
  82.                                 }
  83.                                 break;
  84.                         case evKey:
  85.                                 IF (GetKey()==51) init();
  86.                                 BREAK;
  87.                         case evReDraw:
  88.                                 WindowRedrawStatus(1);
  89.                                 DefineAndDrawWindow(100, 100, 434, 291 + GetSkinWidth(), 0x34, 0x10C0C0C0, 0, 0, "Memory Blocks L&V Edition");
  90.                                 Draw_Panel();
  91.                                 Draw_Game_Pole();
  92.                                 WindowRedrawStatus(2);
  93.                 }
  94.         }
  95. }
  96.  
  97.  
  98. void init()
  99. {
  100.         byte off;
  101.         $mov    edi, #bitstat
  102.         $mov    ecx, 60
  103.         $xor    al, al
  104.         $rep    $stosb                  //ñòèðàåì ñòàðûå äàíívå î íàæàòûõ êíîïêàõ
  105.  
  106.         $mov    edi, #bitpict
  107.         $mov    ecx, 60
  108.         $xor    al, al
  109.         $rep    $stosb                  //ñòèðàåì ñòàðûå äàííûå î êàðòèíêàõ
  110.  
  111.         count = 0;
  112.         firstbit = secondbit = 0x0BAD;
  113.         FOR (i = 0; i < 30; i++)
  114.         {
  115.                 do off = random(60); while (bitpict[off] != 0);
  116.                 bitpict[off] = i;
  117.                 do off = random(60); while (bitpict[off] != 0);
  118.                 bitpict[off] = i;
  119.         }
  120.         Draw_Game_Pole();
  121.         Draw_Panel();
  122. }
  123.  
  124. void ReDraw_Game_Button(int id)
  125. {
  126.         DefineButton(butonsx[id], butonsy[id], 38, 38, 100 + id + BT_HIDE, 0xEFEBEF);   //äåëàåì íîâóþ
  127.         switch (bitstat[id])
  128.         {
  129.                 CASE 0:
  130.                         Draw_Block(butonsx[id], butonsy[id]);
  131.                         break;
  132.                 CASE 1:
  133.                         Draw_Pressed_Block(butonsx[id], butonsy[id]);
  134.                         PutImage(bitpict[id]*32*32+#data,32,32,butonsx[id]+3,butonsy[id]+3, #palitra);
  135.                         BREAK;
  136.                 CASE 2:
  137.                         Draw_Open_Block(butonsx[id], butonsy[id]);
  138.                         PutImage(bitpict[id]*32*32+#data,32,32,butonsx[id]+3,butonsy[id]+3, #palitra);
  139.                         BREAK;
  140.         }
  141. }
  142.  
  143. void Draw_Game_Pole()
  144. {
  145.         byte j;
  146.         FOR (j = 0; j < stolbcov; j++)  FOR (i = 0; i < strok; i++)
  147.         {
  148.                         butonsx[j*strok+i] = j * 42 + 4;                //ñîõðàíÿåì êîîðäèíàòû ÷òîá íå ñ÷èòàòü â äàëüíåéøåì
  149.                         butonsy[j*strok+i] = i * 42 + 4;
  150.                         ReDraw_Game_Button(j*strok + i);                //ðèñóåì ïîëå
  151.         }
  152. }
  153.  
  154. void Draw_Block(dword x, y)
  155. {
  156.         DrawRegion(x, y, 38, 38, 0x0094AECE);//ðàìêà
  157.         DrawBar(x+1, y+1, 37, 1, 0xFFFFFF); //áåëûå ëèíèè
  158.         DrawBar(x+1, y+2, 1, 35, 0xFFFFFF);
  159.         DrawBar(x+1, y+37, 37, 1, 0xDEDEDE); //ñåðûå ëèíèè
  160.         DrawBar(x+37, y+2, 1, 35, 0xDEDEDE);
  161.         DrawBar(x + 2, y + 2, 35, 35, 0x00BDC7D6);//ôîí
  162. }
  163.  
  164. void Draw_Open_Block(dword x, y)
  165. {
  166.         DrawRegion(x, y, 38, 38, 0x0094AECE);//ðàìêà
  167.         DrawBar(x + 1, y + 1, 37, 37, 0x00EFEBEF);//ôîí
  168. }
  169.  
  170. void Draw_Pressed_Block(dword x, y)
  171. {
  172.         DrawRegion(x, y, 38, 38, 0x0094AECE);//ðàìêà
  173.         DrawRegion(x + 1, y + 1, 36, 36, 0x0094DB00);//ðàìêà çåëåíàÿ
  174.         DrawRegion(x + 2, y + 2, 34, 34, 0x0094DB00);//ðàìêà çåëåíàÿ
  175.         DrawBar(x + 3, y + 3, 33, 33, 0x00EFEBEF);//ôîí
  176. }
  177.  
  178.  
  179. void Draw_Panel()
  180. {
  181.         DrawBar(0, 255, 425, 32, 0xEBE7DB);//ôîí ïàíåëè
  182.         DrawBar(0, 255, 425, 1, 0x94AECE); //ëèíèè
  183.         DrawBar(0, 256, 425, 1, 0xFFFFFF); //ëèíèè
  184.         //êíîïêè
  185.         DrawFlatButton(9, 260, 107, 23, 5, 0xEFEBEF);//íîâàÿ èãðà
  186.         WriteText(22,268,0x00,0,#button_r,14);
  187.         WriteText(150, 268, 0x80, 0x00, #button_r+14, 0); //íàäïèñü "Ñ÷åò"
  188.         DrawFlatButton(215, 260, 23, 23, 6, 0xEFEBEF); //ÿçûê
  189.         IF (!lang)
  190.                 WriteText(221,268,0x80,0,"EN",0);
  191.         ELSE
  192.                 WriteText(221,268,0x80,0,"RU",0);
  193.         Draw_Count();
  194.         //ïðÿìîóãîëüíèêè ñïðàâà
  195.         DrawBar(400 , 265, 2, 2, 0xBDCBDE);
  196.         DrawBar(398 , 270, 6, 6, 0xBDCBDE);
  197.         DrawBar(406 , 275, 6, 6, 0xBDCBDE);
  198.         DrawBar(407 , 262, 9, 8, 0xD6D7CE);
  199. }
  200.  
  201.  
  202. void Draw_Count()
  203. {
  204.         DrawBar(190,268,18,7,0xEBE7DB);  //öâåò ïàíåëè
  205.         WriteNumber(190, 268, 0x80, 0x00, 3, count);
  206. }
  207.  
  208.  
  209. stop:
  210.