Subversion Repositories Kolibri OS

Rev

Rev 1446 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1446 Rev 2285
1
use32
1
use32
2
	db	'MENUET01'
2
	db	'MENUET01'
3
	dd	1
3
	dd	1
4
	dd	start
4
	dd	start
5
	dd	i_end
5
	dd	i_end
6
	dd	mem
6
	dd	mem
7
	dd	mem
7
	dd	mem
8
	dd	0
8
	dd	0
9
	dd	0
9
	dd	0
10
 
10
 
11
; field size in items
11
; field size in items
12
FieldWidth = 10
12
FieldWidth = 10
13
FieldHeight = 6
13
FieldHeight = 6
14
 
14
 
15
; size of one picture in pixels
15
; size of one picture in pixels
16
ImageWidth = 32
16
ImageWidth = 32
17
ImageHeight = 32
17
ImageHeight = 32
18
 
18
 
19
; size of one button in pixels
19
; size of one button in pixels
20
ButtonWidth = ImageWidth + 6
20
ButtonWidth = ImageWidth + 6
21
ButtonHeight = ImageHeight + 6
21
ButtonHeight = ImageHeight + 6
22
 
22
 
23
SpaceWidth = ButtonWidth + 4
23
SpaceWidth = ButtonWidth + 4
24
SpaceHeight = ButtonHeight + 4
24
SpaceHeight = ButtonHeight + 4
25
 
25
 
26
; size of window in pixels
26
; size of window in pixels
27
WindowWidth = 434
27
WindowWidth = 434
28
WindowHeight = 291	; excluding skin height
28
WindowHeight = 291	; excluding skin height
29
 
29
 
30
if FieldWidth*FieldHeight mod 2
30
if FieldWidth*FieldHeight mod 2
31
error field size must be an even number!
31
error field size must be an even number!
32
end if
32
end if
33
 
33
 
34
draw_frame:
34
draw_frame:
35
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=color
35
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=color
36
;	ystart is relative to SkinHeight
36
;	ystart is relative to SkinHeight
37
; out: nothing
37
; out: nothing
38
; destroys: eax,ecx
38
; destroys: eax,ecx
39
	push	13
39
	push	13
40
	pop	eax
40
	pop	eax
41
	ror	ecx, 16
41
	ror	ecx, 16
42
	add	ecx, [SkinHeight]
42
	add	ecx, [SkinHeight]
43
	push	ecx
43
	push	ecx
44
	shl	ecx, 16
44
	shl	ecx, 16
45
	inc	ecx
45
	inc	ecx
46
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=[ystart]*65536+1
46
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=[ystart]*65536+1
47
	ror	ecx, 16
47
	ror	ecx, 16
48
	add	cx, [esp+2]
48
	add	cx, [esp+2]
49
	ror	ecx, 16
49
	ror	ecx, 16
50
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=([ystart]+[ysize])*65536+1
50
	int	0x40	; ebx=[xstart]*65536+[xsize], ecx=([ystart]+[ysize])*65536+1
51
	pop	ecx
51
	pop	ecx
52
	ror	ecx, 16
52
	ror	ecx, 16
53
	push	ebx
53
	push	ebx
54
	mov	bx, 1
54
	mov	bx, 1
55
	int	0x40	; ebx=[xstart]*65536+1, ecx=[ystart]*65536+[ysize]
55
	int	0x40	; ebx=[xstart]*65536+1, ecx=[ystart]*65536+[ysize]
56
	ror	ebx, 16
56
	ror	ebx, 16
57
	add	bx, [esp]
57
	add	bx, [esp]
58
	ror	ebx, 16
58
	ror	ebx, 16
59
	inc	ecx
59
	inc	ecx
60
	int	0x40	; ebx=([xstart]+[xsize])*65536+1, ecx=[ystart]*65536+([ysize]+1)
60
	int	0x40	; ebx=([xstart]+[xsize])*65536+1, ecx=[ystart]*65536+([ysize]+1)
61
	dec	ecx
61
	dec	ecx
62
	pop	ebx
62
	pop	ebx
63
	ret
63
	ret
64
 
64
 
65
draw_button:
65
draw_button:
66
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=button color,esi=id
66
; in: ebx=[xstart]*65536+[xsize],ecx=[ystart]*65536+[ysize],edx=button color,esi=id
67
;	ystart is relative to SkinHeight
67
;	ystart is relative to SkinHeight
68
; out: nothing
68
; out: nothing
69
; destroys: eax
69
; destroys: eax
70
	push	edx
70
	push	edx
71
	mov	edx, 0x94AECE
71
	mov	edx, 0x94AECE
72
	call	draw_frame
72
	call	draw_frame
73
	mov	edx, 0xFFFFFF
73
	mov	edx, 0xFFFFFF
74
	push	ebx
74
	push	ebx
75
	add	ebx, 0xFFFF
75
	add	ebx, 0xFFFF
76
	push	ecx
76
	push	ecx
77
	add	ecx, 0x10000
77
	add	ecx, 0x10000
78
	mov	cx, 1
78
	mov	cx, 1
79
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-1), ecx=([ystart]+1)*65536+1
79
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-1), ecx=([ystart]+1)*65536+1
80
	pop	ecx
80
	pop	ecx
81
	mov	edx, 0xC0C0C0
81
	mov	edx, 0xC0C0C0
82
	dec	ebx
82
	dec	ebx
83
	push	ecx
83
	push	ecx
84
	shr	ecx, 16
84
	shr	ecx, 16
85
	add	ecx, [esp]
85
	add	ecx, [esp]
86
	dec	ecx
86
	dec	ecx
87
	shl	ecx, 16
87
	shl	ecx, 16
88
	inc	ecx
88
	inc	ecx
89
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-2), ecx=([ystart]+[ysize]-1)*65536+1
89
	int	0x40	; ebx=([xstart]+1)*65536+([xsize]-2), ecx=([ystart]+[ysize]-1)*65536+1
90
	pop	ecx
90
	pop	ecx
91
	mov	edx, 0xFFFFFF
91
	mov	edx, 0xFFFFFF
92
	push	ecx
92
	push	ecx
93
	add	ecx, 0xFFFF
93
	add	ecx, 0xFFFF
94
	push	ebx
94
	push	ebx
95
	mov	bx, 1
95
	mov	bx, 1
96
	int	0x40	; ebx=([xstart]+1)*65536+1, ecx=([ystart]+1)*65536+([ysize]-1)
96
	int	0x40	; ebx=([xstart]+1)*65536+1, ecx=([ystart]+1)*65536+([ysize]-1)
97
	pop	ebx
97
	pop	ebx
98
	push	ebx
98
	push	ebx
99
	shr	ebx, 16
99
	shr	ebx, 16
100
	add	ebx, [esp]
100
	add	ebx, [esp]
101
	shl	ebx, 16
101
	shl	ebx, 16
102
	inc	ebx
102
	inc	ebx
103
	mov	edx, 0xC0C0C0
103
	mov	edx, 0xC0C0C0
104
	add	ecx, 0xFFFF
104
	add	ecx, 0xFFFF
105
	int	0x40	; ebx=([xstart]+[xsize]-1)*65536+1, ecx=([ystart]+2)*65536+([ysize]-2)
105
	int	0x40	; ebx=([xstart]+[xsize]-1)*65536+1, ecx=([ystart]+2)*65536+([ysize]-2)
106
	pop	ebx
106
	pop	ebx
107
	pop	ecx
107
	pop	ecx
108
	pop	ebx
108
	pop	ebx
109
	pop	edx
109
	pop	edx
110
	push	ebx ecx
110
	push	ebx ecx
111
	add	ebx, 20000h - 3
111
	add	ebx, 20000h - 3
112
	add	ecx, 20000h - 3
112
	add	ecx, 20000h - 3
113
	int	0x40
113
	int	0x40
114
	pop	ecx ebx
114
	pop	ecx ebx
115
	push	edx
115
	push	edx
116
	mov	edx, esi
116
	mov	edx, esi
117
	or	edx, 0x80000000
117
	or	edx, 0x80000000
118
	mov	al, 8
118
	mov	al, 8
119
	int	0x40
119
	int	0x40
120
	mov	edx, esi
120
	mov	edx, esi
121
	or	edx, 0x40000000
121
	or	edx, 0x40000000
122
	int	0x40
122
	int	0x40
123
	pop	edx
123
	pop	edx
124
	ret
124
	ret
125
 
125
 
126
;digits_ptr	dd	0
126
;digits_ptr	dd	0
127
;digits_str	rb	11
127
;digits_str	rb	11
128
 
128
 
129
;images:
129
;images:
130
;	file	'mblocks.raw'
130
;	file	'mblocks.raw'
131
images:
131
images:
132
	file	'mblocksi.raw'
132
	file	'mblocksi.raw'
133
palette:
133
palette:
134
	file	'mblocksp.raw'
134
	file	'mblocksp.raw'
135
 
135
 
136
aNewGame_ru	db	'®¢ ï ¨£à (F2)',0
136
aNewGame_ru	db	'®¢ ï ¨£à (F2)',0
137
aCount_ru	db	' ‘ç¥â:',0
137
aCount_ru	db	' ‘ç¥â:',0
138
aRu		db	'RU',0
138
aRu		db	'RU',0
139
aNewGame_en	db	'New  game (F2)',0
139
aNewGame_en	db	'New  game (F2)',0
140
aCount_en	db	'Count:',0
140
aCount_en	db	'Count:',0
141
aEn		db	'EN',0
141
aEn		db	'EN',0
142
 
142
 
143
CurLanguage	db	0	; 0=russian, 1=english
143
CurLanguage	db	0	; 0=russian, 1=english
144
 
144
 
145
field_status	rb	60	; status of field elements: 0=closed, 1=temporarily opened, 2=permanently opened
145
field_status	rb	60	; status of field elements: 0=closed, 1=temporarily opened, 2=permanently opened
146
field_items	rb	60	; items in field
146
field_items	rb	60	; items in field
147
 
147
 
148
count		dd	0
148
count		dd	0
149
 
149
 
150
start:
150
start:
151
	push	26
151
	push	26
152
	pop	eax
152
	pop	eax
153
	push	5
153
	push	5
154
	pop	ebx
154
	pop	ebx
155
	int	0x40
155
	int	0x40
156
	cmp	eax, 4
156
	cmp	eax, 4
157
	setnz	[CurLanguage]
157
	setnz	[CurLanguage]
158
	call	generate
158
	call	generate
159
; get skin height
159
; get skin height
160
	push	48
160
	push	48
161
	pop	eax
161
	pop	eax
162
	push	4
162
	push	4
163
	pop	ebx
163
	pop	ebx
164
	int	0x40
164
	int	0x40
165
	mov	[SkinHeight], eax
165
	mov	[SkinHeight], eax
166
; no previous click
166
; no previous click
167
	mov	eax, 0xBAD
167
	mov	eax, 0xBAD
168
	mov	[FirstClick], eax
168
	mov	[FirstClick], eax
169
	mov	[SecondClick], eax
169
	mov	[SecondClick], eax
170
; draw window
170
; draw window
171
redraw:
171
redraw:
172
	call	draw_window
172
	call	draw_window
173
; events loop
173
; events loop
174
evloop:
174
evloop:
175
	push	10
175
	push	10
176
	pop	eax
176
	pop	eax
177
	int	0x40
177
	int	0x40
178
	dec	eax
178
	dec	eax
179
	jz	redraw
179
	jz	redraw
180
	dec	eax
180
	dec	eax
181
	jz	key
181
	jz	key
182
	mov	al, 17
182
	mov	al, 17
183
	int	0x40
183
	int	0x40
184
	shr	eax, 8
184
	shr	eax, 8
185
;	cmp	eax, 6
185
;	cmp	eax, 6
186
;	jz	set_lang
186
;	jz	set_lang
187
	cmp	eax, 5
187
	cmp	eax, 5
188
	jz	new_game
188
	jz	new_game
189
	cmp	eax, 1
189
	cmp	eax, 1
190
	jnz	field_pressed
190
	jnz	field_pressed
191
	push	-1
191
	push	-1
192
	pop	eax
192
	pop	eax
193
	int	0x40
193
	int	0x40
194
key:
194
key:
195
	mov	al, 2
195
	mov	al, 2
196
	int	0x40
196
	int	0x40
197
	cmp	ah, '3'		; F2?
197
	cmp	ah, '3'		; F2?
198
	jnz	evloop
198
	jnz	evloop
199
new_game:
199
new_game:
200
	mov	edi, field_status
200
	mov	edi, field_status
201
	mov	ecx, FieldWidth*FieldHeight/2
201
	mov	ecx, FieldWidth*FieldHeight/2
202
	xor	eax, eax
202
	xor	eax, eax
203
	rep	stosd
203
	rep	stosd
204
	mov	[count], eax
204
	mov	[count], eax
205
	mov	eax, 0xBAD
205
	mov	eax, 0xBAD
206
	mov	[FirstClick], eax
206
	mov	[FirstClick], eax
207
	mov	[SecondClick], eax
207
	mov	[SecondClick], eax
208
	call	generate
208
	call	generate
209
	call	draw_field
209
	call	draw_field
210
@@:
210
@@:
211
	call	draw_aux
211
	call	draw_aux
212
	jmp	evloop
212
	jmp	evloop
213
;set_lang:
213
;set_lang:
214
;	xor	[CurLanguage], 1
214
;	xor	[CurLanguage], 1
215
;	jmp	@b
215
;	jmp	@b
216
field_pressed:
216
field_pressed:
217
	sub	eax, 100
217
	sub	eax, 100
218
	cmp	[field_status+eax], 0
218
	cmp	[field_status+eax], 0
219
	jnz	cont
219
	jnz	cont
220
	mov	ebx, [FirstClick]
220
	mov	ebx, [FirstClick]
221
	mov	ecx, [SecondClick]
221
	mov	ecx, [SecondClick]
222
	cmp	ebx, 0xBAD
222
	cmp	ebx, 0xBAD
223
	jz	first_click
223
	jz	first_click
224
	cmp	ecx, 0xBAD
224
	cmp	ecx, 0xBAD
225
	jz	second_click
225
	jz	second_click
226
	mov	dl, [field_items+ecx]
226
	mov	dl, [field_items+ecx]
227
	cmp	[field_items+ebx], dl
227
	cmp	[field_items+ebx], dl
228
	jnz	dont_match
228
	jnz	dont_match
229
	mov	[field_status+ebx], 2
229
	mov	[field_status+ebx], 2
230
	mov	[field_status+ecx], 2
230
	mov	[field_status+ecx], 2
231
	jmp	@f
231
	jmp	@f
232
dont_match:
232
dont_match:
233
	mov	[field_status+ebx], 0
233
	mov	[field_status+ebx], 0
234
	mov	[field_status+ecx], 0
234
	mov	[field_status+ecx], 0
235
@@:
235
@@:
236
	push	eax ecx
236
	push	eax ecx
237
	mov	eax, ebx
237
	mov	eax, ebx
238
	call	draw_field_item
238
	call	draw_field_item
239
	pop	eax
239
	pop	eax
240
	call	draw_field_item
240
	call	draw_field_item
241
	mov	[SecondClick], 0xBAD
241
	mov	[SecondClick], 0xBAD
242
	pop	eax
242
	pop	eax
243
	mov	[FirstClick], eax
243
	mov	[FirstClick], eax
244
	jmp	@f
244
	jmp	@f
245
second_click:
245
second_click:
246
	cmp	[FirstClick], eax
246
	cmp	[FirstClick], eax
247
	jz	cont
247
	jz	cont
248
	mov	[SecondClick], eax
248
	mov	[SecondClick], eax
249
@@:
249
@@:
250
	mov	[field_status+eax], 1
250
	mov	[field_status+eax], 1
251
	call	draw_field_item
251
	call	draw_field_item
252
	inc	[count]
252
	inc	[count]
253
cont:
253
cont:
254
	call	draw_count
254
	call	draw_count
255
	jmp	evloop
255
	jmp	evloop
256
first_click:
256
first_click:
257
	mov	[FirstClick], eax
257
	mov	[FirstClick], eax
258
	jmp	@b
258
	jmp	@b
259
 
259
 
260
draw_window:
260
draw_window:
261
	push	48
-
 
262
	pop	eax
261
	mov eax, 48
263
	push	3
-
 
264
	pop	ebx
262
	mov ebx, 3
265
	mov	ecx, color_table
263
	mov ecx, color_table
266
	push	4*10
-
 
267
	pop	edx
264
	mov edx, 40
268
	int	0x40	; get color table
265
	int	0x40 	; get color table
269
	push	12
266
 
270
	pop	eax
267
	mov eax, 12
271
	push	1
-
 
272
	pop	ebx
268
	mov ebx, 1
273
	int	0x40	; start redraw
269
	int	0x40	; start redraw
274
	push	ebx
270
	
275
	xor	eax, eax
271
	xor	eax, eax
276
	mov	ebx, 100*65536 + WindowWidth
272
	mov	ebx, 100*65536 + WindowWidth
277
	mov	ecx, 100*65536 + WindowHeight
273
	mov	ecx, 100*65536 + WindowHeight
278
	add	ecx, [SkinHeight]
274
	add	ecx, [SkinHeight]
279
	mov	edx, 4C0C0C0h
275
	mov	edx, 0x14C0C0C0
280
	int	0x40	; define window
-
 
281
	mov	al, 71
-
 
282
	pop	ebx
-
 
283
	mov	ecx, caption
276
	mov	edi, caption
284
	int	0x40	; set caption
277
	int	0x40
-
 
278
	
285
	call	draw_aux
279
	call	draw_aux
286
	call	draw_field
280
	call	draw_field
287
	push	12
281
	
288
	pop	eax
282
	mov eax, 12
289
	push	2
-
 
290
	pop	ebx
283
	mov ebx, 2
291
	int	0x40
284
	int	0x40	; end redraw
-
 
285
	
292
	ret
286
	ret
293
 
287
 
294
caption	db	'Memory Blocks L&V Edition',0
288
caption	db	'Memory Blocks L&V Edition',0
295
 
289
 
296
generate:
290
generate:
297
; generate random field
291
; generate random field
298
	xor	edi, edi
292
	xor	edi, edi
299
.loop:
293
.loop:
300
	call	random
294
	call	random
301
	cmp	[field_items+edx], 0
295
	cmp	[field_items+edx], 0
302
	jnz	.loop
296
	jnz	.loop
303
	mov	eax, edi
297
	mov	eax, edi
304
	shr	eax, 1
298
	shr	eax, 1
305
	inc	eax
299
	inc	eax
306
	mov	[field_items+edx], al
300
	mov	[field_items+edx], al
307
	inc	edi
301
	inc	edi
308
	cmp	edi, FieldWidth*FieldHeight
302
	cmp	edi, FieldWidth*FieldHeight
309
	jb	.loop
303
	jb	.loop
310
	ret
304
	ret
311
 
305
 
312
draw_field_item:
306
draw_field_item:
313
; in: eax=field item
307
; in: eax=field item
314
; out: nothing
308
; out: nothing
315
; destroys: eax,ebx,ecx,edx,esi
309
; destroys: eax,ebx,ecx,edx,esi
316
	mov	esi, eax
310
	mov	esi, eax
317
	lea	edx, [eax+0x80000000+100]
311
	lea	edx, [eax+0x80000000+100]
318
	push	8
312
	push	8
319
	pop	eax
313
	pop	eax
320
	int	0x40	; delete old button
314
	int	0x40	; delete old button
321
	mov	ebx, [xstart+esi*4]
315
	mov	ebx, [xstart+esi*4]
322
	shl	ebx, 16
316
	shl	ebx, 16
323
	mov	bl, ButtonWidth
317
	mov	bl, ButtonWidth
324
	mov	ecx, [ystart+esi*4]
318
	mov	ecx, [ystart+esi*4]
325
	add	ecx, [SkinHeight]
319
	add	ecx, [SkinHeight]
326
	shl	ecx, 16
320
	shl	ecx, 16
327
	mov	cl, ButtonHeight
321
	mov	cl, ButtonHeight
328
	lea	edx, [esi+0x40000000+100]
322
	lea	edx, [esi+0x40000000+100]
329
	int	0x40	; define new button
323
	int	0x40	; define new button
330
	ror	ecx, 16
324
	ror	ecx, 16
331
	sub	ecx, [SkinHeight]
325
	sub	ecx, [SkinHeight]
332
	ror	ecx, 16
326
	ror	ecx, 16
333
	mov	al, [field_status+esi]
327
	mov	al, [field_status+esi]
334
	dec	eax
328
	dec	eax
335
	js	draw_closed_item
329
	js	draw_closed_item
336
	jz	draw_current_item
330
	jz	draw_current_item
337
draw_opened_item:
331
draw_opened_item:
338
	mov	edx, 0x94AECE
332
	mov	edx, 0x94AECE
339
	call	draw_frame
333
	call	draw_frame
340
	mov	edx, 0xEFEBEF
334
	mov	edx, 0xEFEBEF
341
	add	ebx, 0xFFFF
335
	add	ebx, 0xFFFF
342
	add	ecx, 0xFFFF
336
	add	ecx, 0xFFFF
343
	mov	al, 13
337
	mov	al, 13
344
	int	0x40
338
	int	0x40
345
	jmp	draw_item_image
339
	jmp	draw_item_image
346
draw_current_item:
340
draw_current_item:
347
	push	ebx ecx
341
	push	ebx ecx
348
	mov	edx, 0x94AECE
342
	mov	edx, 0x94AECE
349
	call	draw_frame
343
	call	draw_frame
350
	pop	ecx ebx
344
	pop	ecx ebx
351
	add	ebx, 10000h
345
	add	ebx, 10000h
352
	add	ecx, 10000h
346
	add	ecx, 10000h
353
	push	ebx ecx
347
	push	ebx ecx
354
	mov	bl, ButtonWidth-2
348
	mov	bl, ButtonWidth-2
355
	mov	cl, ButtonHeight-2
349
	mov	cl, ButtonHeight-2
356
	mov	edx, 0x94DB00
350
	mov	edx, 0x94DB00
357
	call	draw_frame
351
	call	draw_frame
358
	pop	ecx ebx
352
	pop	ecx ebx
359
	add	ebx, 10000h
353
	add	ebx, 10000h
360
	add	ecx, 10000h
354
	add	ecx, 10000h
361
	mov	bl, ButtonWidth-4
355
	mov	bl, ButtonWidth-4
362
	mov	cl, ButtonHeight-4
356
	mov	cl, ButtonHeight-4
363
	mov	edx, 0x94DB00
357
	mov	edx, 0x94DB00
364
	call	draw_frame
358
	call	draw_frame
365
	add	ebx, 10000h
359
	add	ebx, 10000h
366
	add	ecx, 10000h
360
	add	ecx, 10000h
367
	mov	bl, ButtonWidth-5
361
	mov	bl, ButtonWidth-5
368
	mov	cl, ButtonHeight-5
362
	mov	cl, ButtonHeight-5
369
	mov	edx, 0xEFEBEF
363
	mov	edx, 0xEFEBEF
370
	int	0x40
364
	int	0x40
371
draw_item_image:
365
draw_item_image:
372
;	push	7
366
;	push	7
373
;	pop	eax
367
;	pop	eax
374
;	movzx	ebx, [field_items+esi]
368
;	movzx	ebx, [field_items+esi]
375
;	dec	ebx
369
;	dec	ebx
376
;	imul	ebx, ImageWidth*ImageHeight*3
370
;	imul	ebx, ImageWidth*ImageHeight*3
377
;	add	ebx, images
371
;	add	ebx, images
378
;	mov	ecx, ImageWidth*10000h+ImageHeight
372
;	mov	ecx, ImageWidth*10000h+ImageHeight
379
;	mov	edx, [xstart+esi*4]
373
;	mov	edx, [xstart+esi*4]
380
;	shl	edx, 16
374
;	shl	edx, 16
381
;	add	edx, [ystart+esi*4]
375
;	add	edx, [ystart+esi*4]
382
;	add	edx, 3*10001h
376
;	add	edx, 3*10001h
383
;	add	edx, [SkinHeight]
377
;	add	edx, [SkinHeight]
384
;	int	0x40
378
;	int	0x40
385
	push	65
379
	push	65
386
	pop	eax
380
	pop	eax
387
	movzx	ebx, [field_items+esi]
381
	movzx	ebx, [field_items+esi]
388
	dec	ebx
382
	dec	ebx
389
	imul	ebx, ImageWidth*ImageHeight
383
	imul	ebx, ImageWidth*ImageHeight
390
	add	ebx, images
384
	add	ebx, images
391
	mov	ecx, ImageWidth*10000h+ImageHeight
385
	mov	ecx, ImageWidth*10000h+ImageHeight
392
	mov	edx, [xstart+esi*4]
386
	mov	edx, [xstart+esi*4]
393
	shl	edx, 16
387
	shl	edx, 16
394
	add	edx, [ystart+esi*4]
388
	add	edx, [ystart+esi*4]
395
	add	edx, 3*10001h
389
	add	edx, 3*10001h
396
	add	edx, [SkinHeight]
390
	add	edx, [SkinHeight]
397
	push	8
391
	push	8
398
	pop	esi
392
	pop	esi
399
	mov	edi, palette
393
	mov	edi, palette
400
	xor	ebp, ebp
394
	xor	ebp, ebp
401
	int	0x40
395
	int	0x40
402
	ret
396
	ret
403
draw_closed_item:
397
draw_closed_item:
404
	mov	edx, 0x94AECE
398
	mov	edx, 0x94AECE
405
	call	draw_frame
399
	call	draw_frame
406
	push	38
400
	push	38
407
	pop	eax
401
	pop	eax
408
	shr	ebx, 16
402
	shr	ebx, 16
409
	inc	ebx
403
	inc	ebx
410
	imul	ebx, 0x10001
404
	imul	ebx, 0x10001
411
	push	ebx
405
	push	ebx
412
	add	ebx, ButtonWidth-2
406
	add	ebx, ButtonWidth-2
413
	shr	ecx, 16
407
	shr	ecx, 16
414
	inc	ecx
408
	inc	ecx
415
	imul	ecx, 0x10001
409
	imul	ecx, 0x10001
416
	mov	edx, 0xFFFFFF
410
	mov	edx, 0xFFFFFF
417
	int	0x40
411
	int	0x40
418
	pop	ebx
412
	pop	ebx
419
	push	ecx
413
	push	ecx
420
	add	ecx, ButtonHeight-3
414
	add	ecx, ButtonHeight-3
421
	int	0x40
415
	int	0x40
422
	pop	ecx
416
	pop	ecx
423
	push	ebx ecx
417
	push	ebx ecx
424
	add	ebx, ButtonWidth-2
418
	add	ebx, ButtonWidth-2
425
	shr	ecx, 16
419
	shr	ecx, 16
426
	add	ecx, ButtonHeight-2
420
	add	ecx, ButtonHeight-2
427
	imul	ecx, 0x10001
421
	imul	ecx, 0x10001
428
	mov	edx, 0xDEDEDE
422
	mov	edx, 0xDEDEDE
429
	int	0x40
423
	int	0x40
430
	pop	ecx
424
	pop	ecx
431
	push	ecx
425
	push	ecx
432
	movzx	ebx, bx
426
	movzx	ebx, bx
433
	imul	ebx, 0x10001
427
	imul	ebx, 0x10001
434
	add	ecx, 10000h+ButtonHeight-3
428
	add	ecx, 10000h+ButtonHeight-3
435
	int	0x40
429
	int	0x40
436
	pop	ecx ebx
430
	pop	ecx ebx
437
	add	ebx, 10000h
431
	add	ebx, 10000h
438
	mov	bx, ButtonWidth-3
432
	mov	bx, ButtonWidth-3
439
	add	ecx, 10000h
433
	add	ecx, 10000h
440
	mov	cx, ButtonHeight-3
434
	mov	cx, ButtonHeight-3
441
	mov	al, 13
435
	mov	al, 13
442
	mov	edx, 0xBDC7D6
436
	mov	edx, 0xBDC7D6
443
	int	0x40
437
	int	0x40
444
	ret
438
	ret
445
 
439
 
446
draw_field:
440
draw_field:
447
	xor	ebx, ebx
441
	xor	ebx, ebx
448
	xor	ecx, ecx
442
	xor	ecx, ecx
449
	mov	edi, xstart
443
	mov	edi, xstart
450
.loop:
444
.loop:
451
	mov	eax, ebx
445
	mov	eax, ebx
452
	imul	eax, SpaceWidth
446
	imul	eax, SpaceWidth
453
	add	eax, 9
447
	add	eax, 9
454
	stosd
448
	stosd
455
	mov	eax, ecx
449
	mov	eax, ecx
456
	imul	eax, SpaceHeight
450
	imul	eax, SpaceHeight
457
	add	eax, 4
451
	add	eax, 4
458
	mov	[edi+ystart-xstart-4], eax
452
	mov	[edi+ystart-xstart-4], eax
459
	lea	eax, [edi-xstart-4]
453
	lea	eax, [edi-xstart-4]
460
	shr	eax, 2
454
	shr	eax, 2
461
	push	ebx ecx edi
455
	push	ebx ecx edi
462
	call	draw_field_item
456
	call	draw_field_item
463
	pop	edi ecx ebx
457
	pop	edi ecx ebx
464
	inc	ecx
458
	inc	ecx
465
	cmp	ecx, FieldHeight
459
	cmp	ecx, FieldHeight
466
	jb	.loop
460
	jb	.loop
467
	xor	ecx, ecx
461
	xor	ecx, ecx
468
	inc	ebx
462
	inc	ebx
469
	cmp	ebx, FieldWidth
463
	cmp	ebx, FieldWidth
470
	jb	.loop
464
	jb	.loop
471
	ret
465
	ret
472
 
466
 
473
draw_aux:
467
draw_aux:
474
	push	13
468
	push	13
475
	pop	eax
469
	pop	eax
476
	mov	ebx, 5*65536 + 425
470
	mov	ebx, 5*65536 + 425
477
	mov	ecx, [SkinHeight]
471
	mov	ecx, [SkinHeight]
478
	shl	ecx, 16
472
	shl	ecx, 16
479
	add	ecx, 256*65536 + 1
473
	add	ecx, 256*65536 + 1
480
	mov	edx, 0xFFFFFF
474
	mov	edx, 0xFFFFFF
481
	int	0x40
475
	int	0x40
482
	add	ecx, 1*65536 + 29
476
	add	ecx, 1*65536 + 29
483
	mov	edx, [color_table+5*4]
477
	mov	edx, [color_table+5*4]
484
	int	0x40
478
	int	0x40
485
	push	8
479
	push	8
486
	pop	eax
480
	pop	eax
487
	mov	ebx, 14*65536 + 107
481
	mov	ebx, 14*65536 + 107
488
	add	ecx, 3*65536 - 7
482
	add	ecx, 3*65536 - 7
489
	push	5
483
	push	5
490
	pop	edx
484
	pop	edx
491
	mov	esi, [color_table+6*4]
485
	mov	esi, [color_table+6*4]
492
	int	0x40
486
	int	0x40
493
	push	4
487
	push	4
494
	pop	eax
488
	pop	eax
495
	mov	ebx, 27*65536 + 268
489
	mov	ebx, 27*65536 + 268
496
	add	ebx, [SkinHeight]
490
	add	ebx, [SkinHeight]
497
	mov	ecx, [color_table+7*4]
491
	mov	ecx, [color_table+7*4]
498
	or	ecx, 0x80000000
492
	or	ecx, 0x80000000
499
	mov	edx, aNewGame_ru
493
	mov	edx, aNewGame_ru
500
	cmp	[CurLanguage], 0
494
	cmp	[CurLanguage], 0
501
	jz	@f
495
	jz	@f
502
	mov	edx, aNewGame_en
496
	mov	edx, aNewGame_en
503
@@:
497
@@:
504
	int	0x40
498
	int	0x40
505
	mov	ebx, 155*65536 + 268
499
	mov	ebx, 155*65536 + 268
506
	add	ebx, [SkinHeight]
500
	add	ebx, [SkinHeight]
507
	mov	ecx, [color_table+8*4]
501
	mov	ecx, [color_table+8*4]
508
	or	ecx, 0x80000000
502
	or	ecx, 0x80000000
509
	mov	edx, aCount_ru
503
	mov	edx, aCount_ru
510
	cmp	[CurLanguage], 0
504
	cmp	[CurLanguage], 0
511
	jz	@f
505
	jz	@f
512
	mov	edx, aCount_en
506
	mov	edx, aCount_en
513
@@:
507
@@:
514
	int	0x40
508
	int	0x40
515
	call	draw_count
509
	call	draw_count
516
	mov	al, 13
510
	mov	al, 13
517
	mov	ecx, [SkinHeight]
511
	mov	ecx, [SkinHeight]
518
	shl	ecx, 16
512
	shl	ecx, 16
519
	mov	ebx, 405*65536 + 2
513
	mov	ebx, 405*65536 + 2
520
	add	ecx, 265*65536 + 2
514
	add	ecx, 265*65536 + 2
521
	mov	edx, 0xBDCBDE
515
	mov	edx, 0xBDCBDE
522
	int	0x40
516
	int	0x40
523
	mov	ebx, 403*65536 + 6
517
	mov	ebx, 403*65536 + 6
524
	add	ecx, (270*65536 + 6) - (265*65536 + 2)
518
	add	ecx, (270*65536 + 6) - (265*65536 + 2)
525
	int	0x40
519
	int	0x40
526
	mov	ebx, 411*65536 + 6
520
	mov	ebx, 411*65536 + 6
527
	add	ecx, (275*65536 + 6) - (270*65536 + 6)
521
	add	ecx, (275*65536 + 6) - (270*65536 + 6)
528
	int	0x40
522
	int	0x40
529
	mov	ebx, 412*65536 + 9
523
	mov	ebx, 412*65536 + 9
530
	add	ecx, (262*65536 + 8) - (275*65536 + 6)
524
	add	ecx, (262*65536 + 8) - (275*65536 + 6)
531
	mov	edx, 0xD6D7CE
525
	mov	edx, 0xD6D7CE
532
	int	0x40
526
	int	0x40
533
	ret
527
	ret
534
 
528
 
535
draw_count:
529
draw_count:
536
	mov	edi, string_for_number+15
530
	mov	edi, string_for_number+15
537
	mov	eax, [count]
531
	mov	eax, [count]
538
	push	10
532
	push	10
539
	pop	ecx
533
	pop	ecx
540
@@:
534
@@:
541
	xor	edx, edx
535
	xor	edx, edx
542
	div	ecx
536
	div	ecx
543
	dec	edi
537
	dec	edi
544
	add	dl, '0'
538
	add	dl, '0'
545
	mov	[edi], dl
539
	mov	[edi], dl
546
	test	eax, eax
540
	test	eax, eax
547
	jnz	@b
541
	jnz	@b
548
	mov	al, 4
542
	mov	al, 4
549
	mov	ebx, [SkinHeight]
543
	mov	ebx, [SkinHeight]
550
	add	ebx, 195*65536 + 268
544
	add	ebx, 195*65536 + 268
551
	mov	ecx, [color_table+8*4]
545
	mov	ecx, [color_table+8*4]
552
	or	ecx, 0xC0000000
546
	or	ecx, 0xC0000000
553
	mov	edx, edi
547
	mov	edx, edi
554
	mov	edi, [color_table+5*4]
548
	mov	edi, [color_table+5*4]
555
	int	0x40
549
	int	0x40
556
	ret
550
	ret
557
 
551
 
558
random:
552
random:
559
; in: nothing
553
; in: nothing
560
; out: edx = random value in [0..FieldWidth*FieldHeight-1]
554
; out: edx = random value in [0..FieldWidth*FieldHeight-1]
561
; destroys: eax,ecx,edx
555
; destroys: eax,ecx,edx
562
	rdtsc
556
	rdtsc
563
	xor	edx, eax
557
	xor	edx, eax
564
	not	edx
558
	not	edx
565
	mov	eax, [RandSeed]
559
	mov	eax, [RandSeed]
566
	ror	eax, 3
560
	ror	eax, 3
567
	xor	eax, 0DEADBEEFh
561
	xor	eax, 0DEADBEEFh
568
	add	eax, edx
562
	add	eax, edx
569
	mov	[RandSeed], eax
563
	mov	[RandSeed], eax
570
	add	eax, edx
564
	add	eax, edx
571
	xor	edx, edx
565
	xor	edx, edx
572
	push	FieldWidth*FieldHeight
566
	push	FieldWidth*FieldHeight
573
	pop	ecx
567
	pop	ecx
574
	div	ecx
568
	div	ecx
575
	ret
569
	ret
576
 
570
 
577
i_end:
571
i_end:
578
 
572
 
579
SkinHeight	dd	?
573
SkinHeight	dd	?
580
color_table	rd	10
574
color_table	rd	10
581
RandSeed	dd	?
575
RandSeed	dd	?
582
FirstClick	dd	?
576
FirstClick	dd	?
583
SecondClick	dd	?
577
SecondClick	dd	?
584
string_for_number	rb	16
578
string_for_number	rb	16
585
xstart		rd	60
579
xstart		rd	60
586
ystart		rd	60
580
ystart		rd	60
587
 
581
 
588
align 1000h
582
align 1000h
589
stk	rb	1000h
583
stk	rb	1000h
590
mem:
584
mem: