Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 177 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 126
Line 1... Line 1...
1
/*******************************************************************************
1
/*******************************************************************************
Line 2... Line 2...
2
 
2
 
3
    MenuetOS MineSweeper
3
    MenuetOS MineSweeper
Line 4... Line 4...
4
    Copyright (C) 2003  Ivan Poddubny
4
    Copyright (C) 2003, 2004  Ivan Poddubny
5
 
5
 
6
    This program is free software; you can redistribute it and/or modify
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
7
    it under the terms of the GNU General Public License as published by
Line 20... Line 20...
20
*******************************************************************************/
20
*******************************************************************************/
Line 21... Line 21...
21
 
21
 
22
void draw_window()
22
void draw_window()
23
// Ïðîöåäóðà îòðèñîâêè îêíà
23
// Ïðîöåäóðà îòðèñîâêè îêíà
24
{
-
 
Line 25... Line 24...
25
  mouse_disable();
24
{
26
 
25
 
Line 27... Line 26...
27
  sys_window_redraw(1);
26
  sys_window_redraw(1);
28
  sys_get_colors(#colors, 40);
27
  sys_get_colors(#colors, 40);
29
 
28
 
30
  // WINDOW
29
  // WINDOW
Line 31... Line 30...
31
  EBX = xpos << 16 + xsize;
30
  EBX = xpos << 16 + xsize;
32
  ECX = ypos << 16 + ysize;
31
  ECX = ypos << 16 + ysize;
Line 33... Line 32...
33
  sys_draw_window(EBX, ECX, 0x02CCCCCC, colors.w_grab | 0x80000000, colors.w_frames);
32
  sys_draw_window(EBX, ECX, 0x02CCCCCC, colors.w_grab | 0x80000000, colors.w_frames);
34
 
33
 
35
  // LABEL
34
  // LABEL
Line 36... Line 35...
36
  sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MeOS MineSweeper", 16);
35
  sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "MineSweeper", 11);
37
 
36
 
38
  //  BUTTON (1)
37
  //  BUTTON (1)
39
  EBX = xsize - 19; EBX = EBX<<16 + 12;
38
  EBX = xsize - 19; EBX = EBX<<16 + 12;
Line -... Line 39...
-
 
39
  sys_draw_button(EBX, 5<<16+12, 1, colors.w_grab_button);
-
 
40
 
-
 
41
  //  BUTTON (911)
-
 
42
  EBX = xsize / 2 - 10;
-
 
43
  EBX = EBX << 16 + 20;
40
  sys_draw_button(EBX, 5<<16+12, 1, colors.w_grab_button);
44
  sys_draw_button(EBX, 25<<16+20, 911, clLightGray);
41
 
45
 
Line 42... Line 46...
42
  //  BUTTON (911)
46
  // 
BUTTON (1000)
43
  EBX = xsize / 2 - 10;
47
//  EBX = ncx * XPX; EBX += XST << 16;
Line 63... Line 67...
63
 
67
 
64
  draw_time();     // draw timer
68
  draw_time();     // draw timer
65
  draw_minesi();   // draw mines
69
  draw_minesi();   // draw mines
Line 66... Line -...
66
  draw_squares();  // draw field
-
 
67
 
70
  draw_squares();  // draw field
Line 68... Line 71...
68
  mouse_enable();
71
 
69
}
72
}
70
 
73
 
Line 78... Line 81...
78
  0x117089,  // 6
81
  0x117089,  // 6
79
  0x000000,  // 7
82
  0x000000,  // 7
80
  0x808080   // 8
83
  0x808080   // 8
81
};
84
};
Line 82... Line -...
82
 
-
 
-
 
85
 
83
void draw_square(int x, y)
86
 
-
 
87
// Îòðèñîâêà îäíîé êëåòêè
84
// Îòðèñîâêà îäíîé êëåòêè
88
void draw_square(int x, y)
85
{
89
{
86
   int xl, xr, yt, yb;
90
   int xl, xr, yt, yb;       // ñëåâà, ñïðàâà, ñâåðõó, ñíèçó
87
   dword tcolor = clBlack;
91
   dword tcolor = clBlack;   // öâåò çíà÷åíèÿ êëåòêè ïî óìîë÷àíèþ ÷åðíûé
Line 88... Line 92...
88
   byte tchar,tval;
92
   byte tchar, tval;
89
 
93
 
90
   xl = XPX * x + XST;
94
   xl = XPX * x + XST;
Line 94... Line 98...
94
 
98
 
95
   EBX = xl << 16 + xr - xl;
99
   EBX = xl << 16 + xr - xl;
96
   ECX = yt << 16 + yb - yt;
100
   ECX = yt << 16 + yb - yt;
97
   $inc ebx
101
   $inc ebx
98
   $inc ecx
102
   $inc ecx
Line 99... Line 103...
99
   sys_draw_bar(EBX, ECX, clLightGray);
103
   sys_draw_bar(EBX, ECX, clLightGray);  // ðèñóåò çàêðàøåííûé ïðÿìîóãîëüíèê
100
 
104
 
-
 
105
   if (!get_open(x, y))
101
   if (!get_open(x, y))
106
   {
102
   {
107
      // ðèñóåì ðàìêó
103
      ECX = yt << 16 + yb - 1;
108
      ECX = yt << 16 + yb - 1;
104
      sys_draw_line(xl<<16+xl, ECX, clWhite);
109
      sys_draw_line(xl<<16+xl, ECX, clWhite);
105
      EBX = xl << 16 + xr - 1;
110
      EBX = xl << 16 + xr - 1;
Line 123... Line 128...
123
      }
128
      }
124
   }
129
   }
125
   else          // get_open(x,y)==TRUE
130
   else          // get_open(x,y)==TRUE
126
   {
131
   {
127
      tval = get_value(x, y);
132
      tval = get_value(x, y);
128
      IF (tval == 0)
133
      IF (tval != 0)
129
      {
134
      {
130
        //tcolor=clLightGray;
-
 
131
        //tchar=' ';
-
 
132
        GOTO NOCHAR;
-
 
133
      }
-
 
134
      ELSE IF (tval == MINE)
135
        IF (tval == MINE)
135
      {
136
        {
136
        tcolor = 0xee1111;
137
          tcolor = 0xee1111;
137
        tchar = '*';
138
          tchar = '*';
138
      }
139
        }
139
      ELSE
140
        ELSE
140
      {
141
        {
141
        tchar = tval + '0';
142
          tchar = tval + '0';
142
        tcolor = num_colors[tval-1];
143
          tcolor = num_colors[tval-1];
143
      }
144
        }
144
 
-
 
145
      EBX = xl + 5; EBX <<= 16; EBX += yt + 5;
145
        EBX = xl + 5; EBX <<= 16; EBX += yt + 5;
146
      sys_write_text(EBX, tcolor, #tchar, 1);
146
        sys_write_text(EBX, tcolor, #tchar, 1);
147
      EBX += 0x00010000;
147
        EBX += 0x00010000;
148
      sys_write_text(EBX, ECX, EDX, ESI);
148
        sys_write_text(EBX, ECX, EDX, ESI);
149
NOCHAR:
149
      }
150
      sys_draw_line(xl << 16 + xl, yt << 16 + yb, clDarkGray);
150
      sys_draw_line(xl << 16 + xl, yt << 16 + yb, clDarkGray);
151
      sys_draw_line(xl << 16 + xr, yt << 16 + yt, EDX);
151
      sys_draw_line(xl << 16 + xr, yt << 16 + yt, EDX);
152
   }
152
   }
153
}
153
}
Line 154... Line -...
154
 
-
 
-
 
154
 
155
void draw_time()
155
 
-
 
156
// Òàéìåð
156
// Òàéìåð
157
void draw_time()
157
{
158
{
158
  sys_draw_bar(XST<<16+25, 31<<16+10, 0xCCCCCC);
159
  sys_draw_bar(XST<<16+25, 31<<16+10, 0xCCCCCC);
159
  EBX = 0x00030000;
160
  EBX = 0x00030000;
160
  sys_write_number(EBX, time, XST<<16+32, 0x10ff0000);
161
  sys_write_number(EBX, time, XST<<16+32, 0x10ff0000);
Line 161... Line -...
161
}
-
 
-
 
162
}
162
 
163
 
-
 
164
 
163
void draw_minesi()
165
// Èíäèêàòîð êîëè÷åñòâà íåðàññòàâëåííûõ ìèí
164
// Èíäèêàòîð êîëè÷åñòâà íåðàññòàâëåííûõ ìèí
166
void draw_minesi()
165
{
167
{
166
  EBX = xsize - XST - 25;
168
  EBX = xsize - XST - 25;
167
  $PUSH EBX
169
  $PUSH EBX
168
  EBX = EBX << 16 + 25;
170
  EBX = EBX << 16 + 25;
169
  sys_draw_bar(EBX, 31<<16+12, 0xCCCCCC);
171
  sys_draw_bar(EBX, 31<<16+10, 0xCCCCCC);
170
  $POP EDX
172
  $POP EDX
171
  EDX <<= 16; EDX += 30;
173
  EDX <<= 16; EDX += 32;
172
  EBX = 0x00030000;
174
  EBX = 0x00030000;
Line 173... Line -...
173
  sys_write_number(EBX, cmines, EDX, 0x10ff0000);
-
 
-
 
175
  sys_write_number(EBX, cmines, EDX, 0x10ff0000);
174
}
176
}
-
 
177
 
175
 
178
 
176
void draw_squares()
179
// Îòðèñîâêà ìèííîãî ïîëÿ
Line 177... Line 180...
177
// Îòðèñîâêà ìèííîãî ïîëÿ
180
void draw_squares()
178
{
181
{