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