Rev 7978 | Rev 7982 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7978 | Rev 7981 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | Memory Blocks for KolibriOS v1.11 |
2 | Memory Blocks for KolibriOS v1.2 |
3 | Leency&Veliant Edition |
3 | Leency&Veliant Edition |
4 | 2008-2019 |
4 | 2008-2020 |
5 | */ |
5 | */ |
Line 6... | Line 6... | ||
6 | 6 | ||
7 | #define MEMSIZE 4096 * 15 |
7 | #define MEMSIZE 1024 * 20 |
8 | #include "..\lib\gui.h" |
8 | #include "..\lib\gui.h" |
Line 9... | Line 9... | ||
9 | #include "..\lib\random.h" |
9 | #include "..\lib\random.h" |
10 | 10 | ||
Line 11... | Line -... | ||
11 | #include "..\lib\obj\libio.h" |
- | |
12 | #include "..\lib\obj\libimg.h" |
- | |
13 | 11 | #include "..\lib\obj\libio.h" |
|
14 | proc_info Form; |
12 | #include "..\lib\obj\libimg.h" |
15 | 13 | ||
Line 16... | Line 14... | ||
16 | #ifndef AUTOBUILD |
14 | #ifndef AUTOBUILD |
17 | #include "lang.h--" |
15 | #include "lang.h--" |
- | 16 | #endif |
|
- | 17 | ||
18 | #endif |
18 | #define BTN_CLOSED 0 |
19 | 19 | #define BTN_PRESSED 1 |
|
20 | #define COLOR_CELL_BG 0xFFFfff |
20 | #define BTN_OPEN 2 |
- | 21 | ||
- | 22 | #define CELL_SIZE 43 |
|
Line 21... | Line 23... | ||
21 | #define COLOR_CELL_BORDER 0x94AECE |
23 | #define PANEL_Y CELL_SIZE+4*6 + 4 |
- | 24 | #define PANEL_H 36 |
|
22 | #define CELL_SIZE 43 |
25 | #define WIN_W CELL_SIZE+4*10 + 4 |
Line 23... | Line 26... | ||
23 | #define PANEL_Y CELL_SIZE+4*6 + 4 |
26 | #define WIN_H PANEL_Y+PANEL_H |
24 | #define PANEL_H 36 |
27 | |
25 | 28 | #define ROWS 6 |
|
26 | #define strok 6 //cell count x |
29 | #define COLS 10 |
27 | #define stolbcov 10 //cell count y |
30 | #define COUNT ROWS*COLS |
Line 28... | Line 31... | ||
28 | 31 | ||
29 | #ifdef LANG_RUS |
32 | #ifdef LANG_RUS |
30 | #define LABEL_NEW_GAME "®¢ ï ¨£à (F2)"; |
33 | #define LABEL_NEW_GAME "®¢ ï ¨£à "; |
31 | #else |
34 | #else |
Line 32... | Line 35... | ||
32 | #define LABEL_NEW_GAME "New game (F2)"; |
35 | #define LABEL_NEW_GAME " New game"; |
Line 43... | Line 46... | ||
43 | dword id; |
46 | dword id; |
44 | load_dll(libio, #libio_init,1); |
47 | load_dll(libio, #libio_init,1); |
45 | load_dll(libimg, #libimg_init,1); |
48 | load_dll(libimg, #libimg_init,1); |
Line 46... | Line 49... | ||
46 | 49 | ||
47 | skin.load("/sys/icons32.png"); |
50 | skin.load("/sys/icons32.png"); |
Line 48... | Line 51... | ||
48 | skin.replace_color(0x00000000, COLOR_CELL_BG); |
51 | skin.replace_color(0x00000000, 0xFFFfff); |
Line 49... | Line 52... | ||
49 | 52 | ||
50 | NewGame(); |
53 | NewGame(); |
51 | 54 | ||
52 | loop() switch(WaitEvent()) |
- | |
53 | { |
55 | loop() switch(@WaitEvent()) |
54 | case evKey: |
56 | { |
Line 55... | Line 57... | ||
55 | GetKeys(); |
57 | case evKey: |
56 | if (key_scancode==60) NewGame(); |
58 | if (@GetKeyScancode()==SCAN_CODE_F2) NewGame(); |
57 | break; |
59 | break; |
58 | 60 | ||
59 | case evButton: |
61 | case evButton: |
- | 62 | id = @GetButtonID(); |
|
60 | id = GetButtonID(); |
63 | if (id==1) @ExitProcess(); |
61 | if (id==1) ExitProcess(); |
64 | else if (id==5) NewGame(); |
62 | else if (id==5) NewGame(); |
65 | else { |
63 | else { |
66 | id -= 100; |
64 | if (bitstat[id-100] == 0) |
67 | if (bitstat[id] == BTN_CLOSED) |
65 | { |
68 | { |
66 | if (firstbit <> 0x0BAD) |
69 | if (firstbit != 0x0BAD) |
67 | { |
70 | { |
68 | if (secondbit <> 0x0BAD) |
71 | if (secondbit != 0x0BAD) |
69 | { |
72 | { |
70 | if (bitpict[firstbit-100] == bitpict[secondbit-100]) |
73 | if (bitpict[firstbit] == bitpict[secondbit]) |
71 | bitstat[firstbit-100] = bitstat[secondbit-100] = 2; |
74 | bitstat[firstbit] = bitstat[secondbit] = BTN_OPEN; |
72 | else |
75 | else |
73 | bitstat[firstbit-100] = bitstat[secondbit-100] = 0; |
76 | bitstat[firstbit] = bitstat[secondbit] = BTN_CLOSED; |
74 | ReDraw_Game_Button(firstbit - 100); |
77 | ReDraw_Game_Button(firstbit); |
75 | ReDraw_Game_Button(secondbit - 100); |
78 | ReDraw_Game_Button(secondbit); |
76 | secondbit = 0x0BAD; |
79 | secondbit = 0x0BAD; |
77 | firstbit = id; |
80 | firstbit = id; |
78 | bitstat[id-100] = 1; |
81 | bitstat[id] = BTN_PRESSED; |
79 | ReDraw_Game_Button(id - 100); |
82 | ReDraw_Game_Button(id); |
80 | count++; |
83 | count++; |
81 | } |
84 | } |
82 | else if (firstbit<>id) |
85 | else if (firstbit != id) |
83 | { |
86 | { |
84 | secondbit = id; |
87 | secondbit = id; |
85 | bitstat[id-100] = 1; |
88 | bitstat[id] = BTN_PRESSED; |
86 | ReDraw_Game_Button(id - 100); |
89 | ReDraw_Game_Button(id); |
87 | count++; |
90 | count++; |
88 | } |
91 | } |
89 | } |
92 | } |
90 | else |
93 | else |
91 | { |
94 | { |
92 | firstbit = id; |
95 | firstbit = id; |
93 | bitstat[id-100] = 1; |
96 | bitstat[id] = BTN_PRESSED; |
94 | ReDraw_Game_Button(id - 100); |
97 | ReDraw_Game_Button(id); |
95 | count++; |
98 | count++; |
96 | } |
99 | } |
Line 97... | Line 100... | ||
97 | } |
100 | } |
98 | Draw_Count(); |
101 | Draw_Count(); |
99 | } |
102 | } |
100 | break; |
103 | break; |
101 | - | ||
102 | case evReDraw: |
104 | |
103 | sc.get(); |
105 | case evReDraw: |
104 | DefineAndDrawWindow(215,100,CELL_SIZE+4*10 + 4 + 9,PANEL_Y+4+PANEL_H+skin_height, |
- | |
105 | 0x34,0xC0C0C0,"Memory Blocks",0); |
106 | sc.get(); |
106 | GetProcessInfo(#Form, SelfInfo); |
107 | DefineAndDrawWindow(215,100,WIN_W + 9,WIN_H+4+skin_height, |
Line 107... | Line 108... | ||
107 | Draw_Panel(); |
108 | 0x34,0xC0C0C0,"Memory Blocks",0); |
108 | Draw_Game_Pole(); |
109 | Draw_Panel(); |
109 | break; |
110 | Draw_Game_Pole(); |
110 | } |
111 | } |
Line 111... | Line 112... | ||
111 | } |
112 | } |
112 | 113 | ||
113 | void NewGame() |
114 | void NewGame() |
114 | { |
115 | { |
115 | int off; |
116 | int off; |
Line 116... | Line 117... | ||
116 | int i; |
117 | int i; |
117 | 118 | ||
118 | FOR (i = 0; i < 60; i++) |
119 | FOR (i = 0; i < COUNT; i++) |
119 | { |
120 | { |
120 | bitstat[i] = 0; |
121 | bitstat[i] = 0; |
121 | bitpict[i] = 0; |
122 | bitpict[i] = 0; |
122 | } |
123 | } |
123 | 124 | ||
124 | count = 0; |
125 | count = 0; |
125 | firstbit = secondbit = 0x0BAD; |
126 | firstbit = secondbit = 0x0BAD; |
126 | FOR (i = 0; i < 30; i++) |
127 | FOR (i = 0; i < COUNT/2; i++) |
127 | { |
128 | { |
Line 128... | Line -... | ||
128 | do off = random(60); while (bitpict[off] != 0); |
- | |
129 | bitpict[off] = i; |
- | |
130 | do off = random(60); while (bitpict[off] != 0); |
- | |
131 | bitpict[off] = i; |
- | |
132 | } |
- | |
133 | Draw_Game_Pole(); |
- | |
134 | Draw_Panel(); |
- | |
135 | } |
- | |
136 | - | ||
137 | void ReDraw_Game_Button(int id) |
- | |
138 | { |
- | |
139 | DefineButton(butonsx[id], butonsy[id], CELL_SIZE, CELL_SIZE, 100 + id + BT_HIDE, 0); |
- | |
140 | switch (bitstat[id]) |
- | |
141 | { |
- | |
142 | case 0: |
- | |
143 | Draw_Block(butonsx[id], butonsy[id]); |
- | |
144 | break; |
- | |
145 | case 1: |
- | |
146 | Draw_Pressed_Block(butonsx[id], butonsy[id]); |
- | |
147 | img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32); |
129 | do off = random(COUNT); while (bitpict[off] != 0); |
148 | BREAK; |
130 | bitpict[off] = i; |
149 | case 2: |
131 | do off = random(COUNT); while (bitpict[off] != 0); |
150 | Draw_Open_Block(butonsx[id], butonsy[id]); |
132 | bitpict[off] = i; |
151 | img_draw stdcall(skin.image, butonsx[id]+6, butonsy[id]+6, 32, 32, 0, bitpict[id]*32); |
133 | } |
152 | BREAK; |
134 | Draw_Game_Pole(); |
153 | } |
135 | Draw_Panel(); |
154 | } |
136 | } |
155 | 137 | ||
156 | void Draw_Game_Pole() |
138 | void Draw_Game_Pole() |
157 | { |
139 | { |
Line 158... | Line 140... | ||
158 | int i; |
140 | int i; |
159 | byte j; |
141 | byte j; |
- | 142 | for (j = 0; j < COLS; j++) for (i = 0; i < ROWS; i++) |
|
- | 143 | { |
|
- | 144 | butonsx[j*ROWS+i] = CELL_SIZE+4 * j + 4; //save coordinates to avoid |
|
160 | for (j = 0; j < stolbcov; j++) for (i = 0; i < strok; i++) |
145 | butonsy[j*ROWS+i] = CELL_SIZE+4 * i + 4; //their recalculation after |
161 | { |
146 | ReDraw_Game_Button(j*ROWS + i); |
162 | butonsx[j*strok+i] = CELL_SIZE+4 * j + 4; //save coordinates to avoid |
- | |
163 | butonsy[j*strok+i] = CELL_SIZE+4 * i + 4; //their recalculation after |
- | |
164 | ReDraw_Game_Button(j*strok + i); |
- | |
165 | } |
147 | } |
166 | } |
148 | } |
- | 149 | ||
167 | 150 | void ReDraw_Game_Button(int id) |
|
- | 151 | { |
|
- | 152 | dword xx, yy; |
|
- | 153 | xx = butonsx[id]; |
|
- | 154 | yy = butonsy[id]; |
|
- | 155 | DefineButton(xx, yy, CELL_SIZE, CELL_SIZE, 100 + BT_HIDE + id, 0); |
|
- | 156 | DrawRectangle3D(xx, yy, CELL_SIZE, CELL_SIZE, 0x94AECE, 0x94AECE);//border |
|
- | 157 | switch (bitstat[id]) |
|
- | 158 | { |
|
168 | void Draw_Block(dword x, y) |
159 | case BTN_CLOSED: |
- | 160 | DrawRectangle3D(xx + 1, yy + 1, CELL_SIZE-2, CELL_SIZE-2, 0xFFFFFF, 0xDEDEDE);//bump |
|
169 | { |
161 | DrawBar(xx + 2, yy + 2, CELL_SIZE-3, CELL_SIZE-3, 0xBDC7D6);//background |
170 | DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
- | |
171 | DrawRectangle3D(x + 1, y + 1, CELL_SIZE-2, CELL_SIZE-2, 0xFFFFFF, 0xDEDEDE);//bump |
- | |
172 | DrawBar(x + 2, y + 2, CELL_SIZE-3, CELL_SIZE-3, 0xBDC7D6);//background |
- | |
173 | } |
- | |
174 | - | ||
175 | void Draw_Open_Block(dword x, y) |
- | |
176 | { |
162 | break; |
Line 177... | Line 163... | ||
177 | DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
163 | case BTN_PRESSED: |
178 | DrawBar(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, COLOR_CELL_BG);//background |
164 | DrawWideRectangle(xx + 1, yy + 1, CELL_SIZE-1, CELL_SIZE-1, 2, 0x94DB00);//border green |
179 | } |
165 | DrawBar(xx + 3, yy + 3, CELL_SIZE-5, CELL_SIZE-5, 0xFFFfff);//background |
180 | 166 | img_draw stdcall(skin.image, xx+6, yy+6, 32, 32, 0, bitpict[id]*32); |
|
181 | void Draw_Pressed_Block(dword x, y) |
167 | BREAK; |
182 | { |
168 | case BTN_OPEN: |
- | 169 | DrawBar(xx+1, yy+1, CELL_SIZE-1, CELL_SIZE-1, 0xFFFfff);//background |
|
183 | DrawRectangle(x, y, CELL_SIZE, CELL_SIZE, COLOR_CELL_BORDER);//border |
170 | img_draw stdcall(skin.image, xx+6, yy+6, 32, 32, 0, bitpict[id]*32); |
184 | DrawWideRectangle(x + 1, y + 1, CELL_SIZE-1, CELL_SIZE-1, 2, 0x94DB00);//border green |
171 | } |
Line 185... | Line 172... | ||
185 | DrawBar(x + 3, y + 3, CELL_SIZE-5, CELL_SIZE-5, COLOR_CELL_BG);//background |
172 | } |
186 | } |
173 | |
187 | 174 | void Draw_Panel() |
|
188 | void Draw_Panel() |
175 | { |
189 | { |
176 | DrawBar(0, PANEL_Y, WIN_W, 1, sc.work_dark); |