Subversion Repositories Kolibri OS

Rev

Rev 2275 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2275 Rev 5777
1
; 10.06.2010 staper@inbox.ru
1
; 10.06.2010 staper@inbox.ru
2
 
2
 
3
;Œ £¨ç¥áª¨© ª¢ ¤à â - íâ® ­ ¡®à â ª¨å 楫ëå ç¨á¥«, çâ® ¨å á㬬ë
3
;Œ £¨ç¥áª¨© ª¢ ¤à â - íâ® ­ ¡®à â ª¨å 楫ëå ç¨á¥«, çâ® ¨å á㬬ë
4
;¢ áâப å, á⮫¡æ å (०¥ ¢ ¤¨ £®­ «ïå) à ¢­ë.
4
;¢ áâப å, á⮫¡æ å (०¥ ¢ ¤¨ £®­ «ïå) à ¢­ë.
5
 
5
 
6
;à¨¬¥à:
6
;à¨¬¥à:
7
 
7
 
8
; 16 3  2  13
8
; 16 3  2  13
9
; 5  10 11 8
9
; 5  10 11 8
10
; 9  6  7  12
10
; 9  6  7  12
11
; 4  15 14 1
11
; 4  15 14 1
12
 
12
 
13
use32
13
use32
14
org	0x0
14
org	0x0
15
 db	'MENUET01'
15
 db	'MENUET01'
16
 dd	0x1, START, I_END, (D_END+100) and not 3,  (D_END+100) and not 3, 0, 0
16
 dd	0x1, START, I_END, (D_END+100) and not 3,  (D_END+100) and not 3, 0, 0
17
 
17
 
18
;–¢¥â :
18
;–¢¥â :
19
Bckgrd_clr	equ 0xffffff	;䮭
19
Bckgrd_clr	equ 0xffffff	;䮭
20
Brdr_line_clr	equ 0xb0b0b0	;«¨­¨¨ ¯® £à ­¨æ ¬
20
Brdr_line_clr	equ 0xb0b0b0	;«¨­¨¨ ¯® £à ­¨æ ¬
21
Inter_line_clr	equ 0xb0b0b0	;¢­ãâ७­¨¥ «¨­¨¨
21
Inter_line_clr	equ 0xb0b0b0	;¢­ãâ७­¨¥ «¨­¨¨
22
Square_clr	equ 0xdddddd	;梥⠪ãàá®à 
22
Square_clr	equ 0xdddddd	;梥⠪ãàá®à 
23
Fix_nmb_clr	equ 0x83459	;áâ â¨ç­®¥ §­ ç¥­¨¥
23
Fix_nmb_clr	equ 0x83459	;áâ â¨ç­®¥ §­ ç¥­¨¥
24
Chg_nmb_clr	equ 0;x008d8d	;¯¥à¥¬¥­­®¥ §­ ç¥­¨¥
24
Chg_nmb_clr	equ 0;x008d8d	;¯¥à¥¬¥­­®¥ §­ ç¥­¨¥
25
Text_clr	equ 0x000000	;⥪áâ
25
Text_clr	equ 0x000000	;⥪áâ
26
Message_clr	equ 0x0000ff	;á®®¡é¥­¨ï
26
Message_clr	equ 0x0000ff	;á®®¡é¥­¨ï
27
 
27
 
28
max_dif equ 10
28
max_dif equ 10
29
min_dif equ 2
29
min_dif equ 2
30
len_kub equ 30	;¤«¨­  áâ®à®­ë ª¢ ¤à â¨ª 
30
len_kub equ 30	;¤«¨­  áâ®à®­ë ª¢ ¤à â¨ª 
31
beg_x	equ 40	;ª®®à¤¨­ â  • «¥¢®£® ¢¥àå­¥£® 㣫 
31
beg_x	equ 40	;ª®®à¤¨­ â  • «¥¢®£® ¢¥àå­¥£® 㣫 
32
beg_y	equ 50	;ª®®à¤¨­ â  Y «¥¢®£® ¢¥àå­¥£® 㣫 
32
beg_y	equ 50	;ª®®à¤¨­ â  Y «¥¢®£® ¢¥àå­¥£® 㣫 
33
sym_x equ 20
33
sym_x equ 20
34
sym_y equ 20
34
sym_y equ 20
35
win_x equ 400	;è¨à¨­  ®ª­ 
35
win_x equ 400	;è¨à¨­  ®ª­ 
36
win_y equ 400	;¢ëá®â  ®ª­ 
36
win_y equ 400	;¢ëá®â  ®ª­ 
37
 
37
 
38
 
38
 
39
DEBUG equ 0
39
DEBUG equ 0
40
 
40
 
41
macro dbg_dec num
41
macro dbg_dec num
42
{pushad
42
{pushad
43
newline
43
newline
44
debug_print_dec num
44
debug_print_dec num
45
popad
45
popad
46
}
46
}
47
 
47
 
48
include '../../../macros.inc'
48
include '../../../macros.inc'
49
;include 'debug.inc'
49
;include 'debug.inc'
50
include 'editbox_ex.mac'
50
include 'editbox_ex.mac'
51
include 'lang.inc'
51
include 'lang.inc'
52
 
52
 
53
 
53
 
54
START:
54
START:
55
	;mcall	40,7
55
	;mcall	40,7
56
 
56
 
57
redraw_all:
57
redraw_all:
58
	mcall	12,1
58
	mcall	12,1
59
	mcall	48,4
59
	mcall	48,4
60
	add	eax,100*65536+win_x
60
	add	eax,100*65536+win_x
61
	mov	ecx,eax
61
	mov	ecx,eax
62
	mcall	0,100*65536+win_y,,(0x34000000+Bckgrd_clr),,title
62
	mcall	0,100*65536+win_y,,(0x34000000+Bckgrd_clr),,title
63
	movzx	eax,[Difficult]
63
	movzx	eax,[Difficult]
64
	mov	ebx,len_kub
64
	mov	ebx,len_kub
65
	xor	edx,edx
65
	xor	edx,edx
66
	mul	ebx
66
	mul	ebx
67
	add	eax,beg_x*65536+beg_x
67
	add	eax,beg_x*65536+beg_x
68
	xchg	eax,ebx
68
	xchg	eax,ebx
69
	mcall	38,,beg_y*65536+beg_y,Brdr_line_clr
69
	mcall	38,,beg_y*65536+beg_y,Brdr_line_clr
70
	mov	edx,Inter_line_clr
70
	mov	edx,Inter_line_clr
71
	movzx	esi,[Difficult]
71
	movzx	esi,[Difficult]
72
	dec	esi
72
	dec	esi
73
  @@:	add	ecx,len_kub*65536+len_kub
73
  @@:	add	ecx,len_kub*65536+len_kub
74
	mcall
74
	mcall
75
	dec	esi
75
	dec	esi
76
	jnz	@b
76
	jnz	@b
77
	add	ecx,len_kub*65536+len_kub
77
	add	ecx,len_kub*65536+len_kub
78
	mcall	,,,Brdr_line_clr
78
	mcall	,,,Brdr_line_clr
79
 
79
 
80
	movzx	eax,[Difficult]
80
	movzx	eax,[Difficult]
81
	mov	ecx,len_kub
81
	mov	ecx,len_kub
82
	xor	edx,edx
82
	xor	edx,edx
83
	mul	ecx
83
	mul	ecx
84
	add	eax,(beg_y+1)*65536+beg_y-1
84
	add	eax,(beg_y+1)*65536+beg_y-1
85
	xchg	eax,ecx
85
	xchg	eax,ecx
86
	mov	ebx,beg_x*65536+beg_x
86
	mov	ebx,beg_x*65536+beg_x
87
	mcall	38,,,Brdr_line_clr
87
	mcall	38,,,Brdr_line_clr
88
	mov	edx,Inter_line_clr
88
	mov	edx,Inter_line_clr
89
	movzx	esi,[Difficult]
89
	movzx	esi,[Difficult]
90
	dec	esi
90
	dec	esi
91
 
91
 
92
  @@:	add	ebx,len_kub*65536+len_kub
92
  @@:	add	ebx,len_kub*65536+len_kub
93
	mcall
93
	mcall
94
	dec	esi
94
	dec	esi
95
	jnz	@b
95
	jnz	@b
96
	add	ebx,len_kub*65536+len_kub
96
	add	ebx,len_kub*65536+len_kub
97
	mcall	,,,Brdr_line_clr
97
	mcall	,,,Brdr_line_clr
98
 
98
 
99
	mcall	8,<4,78>,<4,13>,2,0xbbbbbb
99
	mcall	8,<4,78>,<4,13>,2,0xbbbbbb
100
	mcall	4,<8,7>,(0x80000000+Text_clr),txt.clear
100
	mcall	4,<8,7>,(0x80000000+Text_clr),txt.clear
101
	mcall	,<105,7>,,txt.dif
101
	mcall	,<105,7>,,txt.dif
102
 
102
 
103
 
103
 
104
	call	show_level
104
	call	show_level
105
 
105
 
106
	push	dword Map;esi;  mov     esi,Map
106
	push	dword Map;esi;  mov     esi,Map
107
	mcall	12,2
107
	mcall	12,2
108
draw_pole:
108
draw_pole:
109
	if DEBUG
109
	if DEBUG
110
	call	SysMsgBoardNum	;show esp
110
	call	SysMsgBoardNum	;show esp
111
	endf
111
	endf
112
 
112
 
113
	movzx	eax,[Y]
113
	movzx	eax,[Y]
114
	dec	al
114
	dec	al
115
	movzx	ebx,[Difficult]
115
	movzx	ebx,[Difficult]
116
	mul	bl
116
	mul	bl
117
	mov	bl,[X]
117
	mov	bl,[X]
118
	add	al,bl
118
	add	al,bl
119
	pop	esi	;       mov     esi,Map
119
	pop	esi	;       mov     esi,Map
120
	push	eax	;ªãàá®à稪
120
	push	eax	;ªãàá®à稪
121
	movzx	eax,[Difficult]
121
	movzx	eax,[Difficult]
122
	mov	ebx,eax
122
	mov	ebx,eax
123
	mul	eax
123
	mul	eax
124
	sub	eax,ebx
124
	sub	eax,ebx
125
	mov	edi,eax
125
	mov	edi,eax
126
	pop	eax
126
	pop	eax
127
	push	eax
127
	push	eax
128
;	mov	edi,81-9
128
;	mov	edi,81-9
129
	movzx	ebp,[Difficult]
129
	movzx	ebp,[Difficult]
130
	mov	ebx,beg_x*65536+beg_x+sym_x
130
	mov	ebx,beg_x*65536+beg_x+sym_x
131
	mov	ecx,beg_y*65536+beg_y+sym_y
131
	mov	ecx,beg_y*65536+beg_y+sym_y
132
	call	out_numbers
132
	call	out_numbers
133
	pop	eax
133
	pop	eax
134
	call	out_sum
134
	call	out_sum
135
 
135
 
136
still:
136
still:
137
	mcall	10
137
	mcall	10
138
 
138
 
139
	dec	al
139
	dec	al
140
	jz	redraw_all
140
	jz	redraw_all
141
	dec	al
141
	dec	al
142
	jz	key
142
	jz	key
143
	dec	al
143
	dec	al
144
	jnz	still
144
	jnz	still
145
;button:
145
;button:
146
	mcall	17
146
	mcall	17
147
	cmp	ah,1
147
	cmp	ah,1
148
	jne	@f
148
	jne	@f
149
	mcall	-1
149
	mcall	-1
150
.clear:
150
.clear:
151
@@:	mov	ecx,max_dif*max_dif
151
@@:	mov	ecx,max_dif*max_dif
152
	mov	esi,Map
152
	mov	esi,Map
153
@@:	mov	byte [esi+ecx-1],0
153
@@:	mov	byte [esi+ecx-1],0
154
	loop	@b
154
	loop	@b
155
	jmp	redraw_all
155
	jmp	redraw_all
156
 
156
 
157
key:
157
key:
158
	mcall	2
158
	mcall	2
159
 
159
 
160
.43:	cmp	ah,43		;+
160
.43:	cmp	ah,43		;+
161
	jne	.45
161
	jne	.45
162
	cmp	[Difficult],max_dif
162
	cmp	[Difficult],max_dif
163
	je	still
163
	je	still
164
	inc	[Difficult]
164
	inc	[Difficult]
165
	jmp	redraw_all
165
	jmp	redraw_all
166
	jmp	still
166
	jmp	still
167
.45:				;-
167
.45:				;-
168
	cmp	ah,45
168
	cmp	ah,45
169
	jne	.99
169
	jne	.99
170
	cmp	[Difficult],min_dif
170
	cmp	[Difficult],min_dif
171
	je	still
171
	je	still
172
	dec	[Difficult]
172
	dec	[Difficult]
-
 
173
	movzx	eax, [Difficult]
-
 
174
	cmp	al, [X]
-
 
175
	jae	@f
-
 
176
	mov	[X], al
-
 
177
@@:
-
 
178
	cmp	al, [Y]
-
 
179
	jae	@f
-
 
180
	mov	[Y], al
-
 
181
@@:
173
	jmp	redraw_all
182
	jmp	redraw_all
174
	jmp	still
183
	jmp	still
175
 
184
 
176
.99:	cmp	ah,0x58
185
.99:	cmp	ah,0x58
177
	je	@f
186
	je	@f
178
	cmp	ah,0x78
187
	cmp	ah,0x78
179
	jne	.39
188
	jne	.39
180
@@:	jmp	still.clear
189
@@:	jmp	still.clear
181
 
190
 
182
.39:	cmp	ah,0x39
191
.39:	cmp	ah,0x39
183
	ja	.110
192
	ja	.110
184
	cmp	ah,0x30
193
	cmp	ah,0x30
185
	jb	still
194
	jb	still
186
	sub	ah,0x30
195
	sub	ah,0x30
187
	mov	cl,ah
196
	mov	cl,ah
188
 
197
 
189
	movzx	eax,[Y]
198
	movzx	eax,[Y]
190
	dec	al
199
	dec	al
191
	mov	ebx,max_dif;[Difficult]
200
	mov	ebx,max_dif;[Difficult]
192
	mul	bl
201
	mul	bl
193
	mov	bl,[X]
202
	mov	bl,[X]
194
	dec	bl
203
	dec	bl
195
	add	al,bl
204
	add	al,bl
196
 
205
 
197
	mov	esi,Map
206
	mov	esi,Map
198
	bt	[flags],9
207
	bt	[flags],9
199
	jnc	@f
208
	jnc	@f
200
	mov	bl,[esi+eax]
209
	mov	bl,[esi+eax]
201
	push	eax
210
	push	eax
202
	mov	ax,10
211
	mov	ax,10
203
	xor	dl,dl
212
	xor	dl,dl
204
	mul	bl
213
	mul	bl
205
	add	cl,al
214
	add	cl,al
206
	pop	eax
215
	pop	eax
207
	mov	[esi+eax],cl
216
	mov	[esi+eax],cl
208
	btr	[flags],9
217
	btr	[flags],9
209
	jmp	.onedraw
218
	jmp	.onedraw
210
   @@:	mov	[esi+eax],cl
219
   @@:	mov	[esi+eax],cl
211
	bts	[flags],9
220
	bts	[flags],9
212
	jmp	.onedraw
221
	jmp	.onedraw
213
 
222
 
214
 
223
 
215
.110:	cmp	ah,110		;n
224
.110:	cmp	ah,110		;n
216
	jne	.176
225
	jne	.176
217
.new_game:
226
.new_game:
218
	jmp	redraw_all
227
	jmp	redraw_all
219
 
228
 
220
.176:	cmp	ah,176 ;ªãàá®àë
229
.176:	cmp	ah,176 ;ªãàá®àë
221
	jne	.177
230
	jne	.177
222
	call	draw_one_symbol
231
	call	draw_one_symbol
223
	dec	[X]
232
	dec	[X]
224
	cmp	[X],1
233
	cmp	[X],1
225
	jge	@f
234
	jge	@f
226
	push	eax
235
	push	eax
227
	movzx	eax,[Difficult]
236
	movzx	eax,[Difficult]
228
	mov	[X],al
237
	mov	[X],al
229
	pop	eax
238
	pop	eax
230
@@:	btr	[flags],9
239
@@:	btr	[flags],9
231
	jmp	.onedraw
240
	jmp	.onedraw
232
.177:	cmp	ah,177
241
.177:	cmp	ah,177
233
	jne	.178
242
	jne	.178
234
	call	draw_one_symbol
243
	call	draw_one_symbol
235
	inc	[Y]
244
	inc	[Y]
236
	push	eax
245
	push	eax
237
	movzx	eax,[Difficult]
246
	movzx	eax,[Difficult]
238
	cmp	[Y],al
247
	cmp	[Y],al
239
	jbe	@f
248
	jbe	@f
240
	mov	[Y],1
249
	mov	[Y],1
241
@@:	pop	eax
250
@@:	pop	eax
242
	btr	[flags],9
251
	btr	[flags],9
243
	jmp	.onedraw
252
	jmp	.onedraw
244
.178:	cmp	ah,178
253
.178:	cmp	ah,178
245
	jne	.179
254
	jne	.179
246
	call	draw_one_symbol
255
	call	draw_one_symbol
247
	dec	[Y]
256
	dec	[Y]
248
	cmp	[Y],1
257
	cmp	[Y],1
249
	jge	@f
258
	jge	@f
250
	push	eax
259
	push	eax
251
	movzx	eax,[Difficult]
260
	movzx	eax,[Difficult]
252
	mov	[Y],al
261
	mov	[Y],al
253
	pop	eax
262
	pop	eax
254
@@:	btr	[flags],9
263
@@:	btr	[flags],9
255
	jmp	.onedraw
264
	jmp	.onedraw
256
.179:	cmp	ah,179
265
.179:	cmp	ah,179
257
	jne	still
266
	jne	still
258
	call	draw_one_symbol
267
	call	draw_one_symbol
259
	inc	[X]
268
	inc	[X]
260
	push	eax
269
	push	eax
261
	movzx	eax,[Difficult]
270
	movzx	eax,[Difficult]
262
	cmp	[X],al
271
	cmp	[X],al
263
	jbe	@f
272
	jbe	@f
264
	mov	[X],1
273
	mov	[X],1
265
@@:	btr	[flags],9
274
@@:	btr	[flags],9
266
	pop	eax
275
	pop	eax
267
.onedraw:
276
.onedraw:
268
	bts	[flags],4
277
	bts	[flags],4
269
	call	draw_one_symbol
278
	call	draw_one_symbol
270
	call	out_one_sum
279
	call	out_one_sum
271
	jmp	still ;.todraw
280
	jmp	still ;.todraw
272
 
281
 
273
show_level:
282
show_level:
274
	movzx	ecx,[Difficult]
283
	movzx	ecx,[Difficult]
275
	mcall	47,0x10000,,<205,5>,(0x50000000+Text_clr),Bckgrd_clr
284
	mcall	47,0x80020000,,<205,5>,(0x50000000+Text_clr),Bckgrd_clr
276
ret
285
ret
277
 
286
 
278
 
287
 
279
draw_one_symbol:
288
draw_one_symbol:
280
	movzx	eax,[X]
289
	movzx	eax,[X]
281
	mov	ebx,len_kub*65536+len_kub
290
	mov	ebx,len_kub*65536+len_kub
282
	mul	ebx
291
	mul	ebx
283
	xchg	eax,ebx
292
	xchg	eax,ebx
284
	add	ebx,(beg_x*65536+beg_y-len_kub*65536+len_kub)
293
	add	ebx,(beg_x*65536+beg_y-len_kub*65536+len_kub)
285
	movzx	eax,[Y]
294
	movzx	eax,[Y]
286
	mov	ecx,len_kub*65536+len_kub
295
	mov	ecx,len_kub*65536+len_kub
287
	mul	ecx
296
	mul	ecx
288
	xchg	eax,ecx
297
	xchg	eax,ecx
289
	add	ecx,(beg_y*65536+beg_y+sym_y-len_kub*65536+len_kub)
298
	add	ecx,(beg_y*65536+beg_y+sym_y-len_kub*65536+len_kub)
290
	movzx	eax,[Y]
299
	movzx	eax,[Y]
291
	dec	al
300
	dec	al
292
	push	ebx
301
	push	ebx
293
	movzx	ebx,[Difficult]
302
	movzx	ebx,[Difficult]
294
	mul	bl
303
	mul	bl
295
	mov	bl,[X]
304
	mov	bl,[X]
296
	add	al,bl
305
	add	al,bl
297
	dec	al
306
	dec	al
298
	pop	ebx
307
	pop	ebx
299
	mov	esi,Map
308
	mov	esi,Map
300
	add	esi,eax
309
	add	esi,eax
301
	push	dword 0 ;­¥ ªãàá®à
310
	push	dword 0 ;­¥ ªãàá®à
302
	bt	[flags],4
311
	bt	[flags],4
303
	jnc	@f
312
	jnc	@f
304
	mov	dword [esp],1 ;ªãàá®à
313
	mov	dword [esp],1 ;ªãàá®à
305
	btr	[flags],4
314
	btr	[flags],4
306
@@:	mov	edi,0
315
@@:	mov	edi,0
307
	mov	ebp,1
316
	mov	ebp,1
308
	call	out_numbers
317
	call	out_numbers
309
	pop	eax
318
	pop	eax
310
ret
319
ret
311
 
320
 
312
 
321
 
313
out_numbers:
322
out_numbers:
314
	push	ebx ecx esi
323
	push	ebx ecx esi
315
	shr	ebx,16
324
	shr	ebx,16
316
	inc	bx
325
	inc	bx
317
	shl	ebx,16
326
	shl	ebx,16
318
	add	ebx,len_kub-1
327
	add	ebx,len_kub-1
319
	shr	ecx,16
328
	shr	ecx,16
320
	inc	cx
329
	inc	cx
321
	shl	ecx,16
330
	shl	ecx,16
322
	add	ecx,len_kub-1
331
	add	ecx,len_kub-1
323
	mov	edx,Bckgrd_clr
332
	mov	edx,Bckgrd_clr
324
	push	ebp
333
	push	ebp
325
	dec	dword [esp+4*5]
334
	dec	dword [esp+4*5]
326
	jnz	@f
335
	jnz	@f
327
	mov	edx,Square_clr
336
	mov	edx,Square_clr
328
@@:	mcall	13
337
@@:	mcall	13
329
	pop	ebp
338
	pop	ebp
330
	pop	esi
339
	pop	esi
331
 
340
 
332
	push	ebx edx
341
	push	ebx edx
333
	mov	eax,esi
342
	mov	eax,esi
334
	sub	eax,Map-1
343
	sub	eax,Map-1
335
	xor	edx,edx
344
	xor	edx,edx
336
	movzx	ebx,[Difficult]
345
	movzx	ebx,[Difficult]
337
	div	ebx
346
	div	ebx
338
	push	edx
347
	push	edx
339
	xor	edx,edx
348
	xor	edx,edx
340
	mov	ebx,max_dif
349
	mov	ebx,max_dif
341
	mul	ebx
350
	mul	ebx
342
	pop	edx
351
	pop	edx
343
	test	edx,edx
352
	test	edx,edx
344
	jnz	@f
353
	jnz	@f
345
	movzx	edx,[Difficult]
354
	movzx	edx,[Difficult]
346
	sub	eax,max_dif
355
	sub	eax,max_dif
347
@@:	add	eax,edx
356
@@:	add	eax,edx
348
	mov	al,[eax+Map-1]
357
	mov	al,[eax+Map-1]
349
	pop	edx ebx
358
	pop	edx ebx
350
	test	al,al
359
	test	al,al
351
 
360
 
352
;	cmp	byte [esi],0
361
;	cmp	byte [esi],0
353
	jnz	.changeable_number
362
	jnz	.changeable_number
354
	jmp	.null
363
	jmp	.null
355
.end:
364
.end:
356
	inc	esi
365
	inc	esi
357
	dec	ebp
366
	dec	ebp
358
	jnz	out_numbers
367
	jnz	out_numbers
359
	test	edi,edi
368
	test	edi,edi
360
	jz	@f
369
	jz	@f
361
	push	ebx edx
370
	push	ebx edx
362
	movzx	eax,[Difficult]
371
	movzx	eax,[Difficult]
363
	sub	edi,eax
372
	sub	edi,eax
364
	mov	ebp,eax
373
	mov	ebp,eax
365
	mov	ebx,len_kub*65536
374
	mov	ebx,len_kub*65536
366
	xor	edx,edx
375
	xor	edx,edx
367
	mul	ebx
376
	mul	ebx
368
	push	eax
377
	push	eax
369
	movzx	eax,[Difficult]
378
	movzx	eax,[Difficult]
370
	mov	ebx,len_kub
379
	mov	ebx,len_kub
371
	mul	ebx
380
	mul	ebx
372
	pop	ebx
381
	pop	ebx
373
	add	eax,ebx
382
	add	eax,ebx
374
	pop	edx
383
	pop	edx
375
	pop	ebx
384
	pop	ebx
376
	sub	ebx,eax
385
	sub	ebx,eax
377
;	add	ebx,-9*24*65536-9*24
386
;	add	ebx,-9*24*65536-9*24
378
	add	ecx,len_kub*65536+len_kub
387
	add	ecx,len_kub*65536+len_kub
379
	jmp	out_numbers
388
	jmp	out_numbers
380
  @@:
389
  @@:
381
ret
390
ret
382
 
391
 
383
 
392
 
384
.null:
393
.null:
385
	pop	ecx ebx
394
	pop	ecx ebx
386
	add	ebx,len_kub*65536+len_kub
395
	add	ebx,len_kub*65536+len_kub
387
	jmp	.end
396
	jmp	.end
388
.changeable_number:
397
.changeable_number:
389
	push	esi
398
	push	esi
390
	shr	ebx,16
399
	shr	ebx,16
391
	shr	ecx,16
400
	shr	ecx,16
392
	mov	dx,bx
401
	mov	dx,bx
393
	shl	edx,16
402
	shl	edx,16
394
	mov	dx,cx
403
	mov	dx,cx
395
	add	edx,8*65536+4
404
	add	edx,8*65536+4
396
 
405
 
397
	push	ebx edx
406
	push	ebx edx
398
	mov	eax,esi
407
	mov	eax,esi
399
	sub	eax,Map-1
408
	sub	eax,Map-1
400
	xor	edx,edx
409
	xor	edx,edx
401
	movzx	ebx,[Difficult]
410
	movzx	ebx,[Difficult]
402
	div	ebx
411
	div	ebx
403
	push	edx
412
	push	edx
404
	xor	edx,edx
413
	xor	edx,edx
405
	mov	ebx,max_dif
414
	mov	ebx,max_dif
406
	mul	ebx
415
	mul	ebx
407
	pop	edx
416
	pop	edx
408
	test	edx,edx
417
	test	edx,edx
409
	jnz	@f
418
	jnz	@f
410
	movzx	edx,[Difficult]
419
	movzx	edx,[Difficult]
411
	sub	eax,max_dif
420
	sub	eax,max_dif
412
@@:	add	eax,edx
421
@@:	add	eax,edx
413
	pop	edx ebx
422
	pop	edx ebx
414
	
423
	
415
	movzx	ebx,byte [eax+Map-1];[esi]
424
	movzx	ebx,byte [eax+Map-1];[esi]
416
 
425
 
417
 
426
 
418
	push	esi ebp edi edx
427
	push	esi ebp edi edx
419
	sub	edx,2*65536-3
428
	sub	edx,2*65536-3
420
	push	edx
429
	push	edx
421
	xchg	eax,ebx
430
	xchg	eax,ebx
422
	mov	ebx,10
431
	mov	ebx,10
423
	xor	edx,edx
432
	xor	edx,edx
424
	div	ebx
433
	div	ebx
425
	mov	ebx,edx
434
	mov	ebx,edx
426
	pop	edx
435
	pop	edx
427
	
436
	
428
	push	ebx
437
	push	ebx
429
 
438
 
430
	test	eax,eax
439
	test	eax,eax
431
	jz	.only_first_num
440
	jz	.only_first_num
432
 
441
 
433
;	bt	[flags],9
442
;	bt	[flags],9
434
;	jc	.only_first_num
443
;	jc	.only_first_num
435
 
444
 
436
	xchg	eax,ebx
445
	xchg	eax,ebx
437
 
446
 
438
	shl	bx,4
447
	shl	bx,4
439
	add	ebx,FONT
448
	add	ebx,FONT
440
	mov	ecx,8*65536+16
449
	mov	ecx,8*65536+16
441
 
450
 
442
	mov	edi,Pltr.ch
451
	mov	edi,Pltr.ch
443
	cmp	dword [esp+4*9],0
452
	cmp	dword [esp+4*9],0
444
	jne	@f
453
	jne	@f
445
	mov	edi,Pltr.chk
454
	mov	edi,Pltr.chk
446
@@:	mov	esi,1
455
@@:	mov	esi,1
447
	mov	ebp,0
456
	mov	ebp,0
448
	mcall	65
457
	mcall	65
449
 
458
 
450
.only_first_num:
459
.only_first_num:
451
	pop	ebx
460
	pop	ebx
452
	shl	bl,4
461
	shl	bl,4
453
 
462
 
454
	add	ebx,FONT
463
	add	ebx,FONT
455
	mov	ecx,8*65536+16
464
	mov	ecx,8*65536+16
456
	add	edx,8*65536
465
	add	edx,8*65536
457
	mov	edi,Pltr.ch
466
	mov	edi,Pltr.ch
458
	cmp	dword [esp+4*8],0
467
	cmp	dword [esp+4*8],0
459
	jne	@f
468
	jne	@f
460
	mov	edi,Pltr.chk
469
	mov	edi,Pltr.chk
461
@@:	mov	esi,1
470
@@:	mov	esi,1
462
	mov	ebp,0
471
	mov	ebp,0
463
	mcall	65
472
	mcall	65
464
	pop	edx edi ebp esi
473
	pop	edx edi ebp esi
465
	pop	esi ecx ebx
474
	pop	esi ecx ebx
466
	add	ebx,len_kub*65536+len_kub
475
	add	ebx,len_kub*65536+len_kub
467
	jmp	.end
476
	jmp	.end
468
 
477
 
469
out_sum:
478
out_sum:
470
	movzx	eax,[Difficult]
479
	movzx	eax,[Difficult]
471
	push	eax
480
	push	eax
472
	mov	esi,Map
481
	mov	esi,Map
473
	mov	edi,out_sum_buf
482
	mov	edi,out_sum_buf
474
.1:	xor	ebx,ebx
483
.1:	xor	ebx,ebx
475
	xor	ecx,ecx
484
	xor	ecx,ecx
476
	xor	edx,edx
485
	xor	edx,edx
477
.2:	mov	dl,[ebx+esi]
486
.2:	mov	dl,[ebx+esi]
478
	add	ecx,edx
487
	add	ecx,edx
479
	inc	ebx
488
	inc	ebx
480
	cmp	ebx,[esp]
489
	cmp	ebx,[esp]
481
	jne	.2
490
	jne	.2
482
	mov	word [edi],cx
491
	mov	word [edi],cx
483
	add	edi,2
492
	add	edi,2
484
	add	esi,max_dif
493
	add	esi,max_dif
485
	dec	eax
494
	dec	eax
486
	jnz	.1
495
	jnz	.1
487
 
496
 
488
	push	out_sum_buf
497
	push	out_sum_buf
489
	movzx	eax,[Difficult]
498
	movzx	eax,[Difficult]
490
	mov	ebx,len_kub*65536
499
	mov	ebx,len_kub*65536
491
	xor	edx,edx
500
	xor	edx,edx
492
	mul	ebx
501
	mul	ebx
493
	add	eax,40*65536
502
	add	eax,40*65536
494
	push	eax
503
	push	eax
495
	mov	edx,(beg_x-30)*65536+beg_y+10
504
	mov	edx,(beg_x-30)*65536+beg_y+10
496
	mov	ebx,0x30000
505
	mov	ebx,0x30000
497
	mov	esi,0x50000000+Fix_nmb_clr
506
	mov	esi,0x50000000+Fix_nmb_clr
498
	mov	edi,Bckgrd_clr
507
	mov	edi,Bckgrd_clr
499
 
508
 
500
.3:	mov	ecx,[esp+4]
509
.3:	mov	ecx,[esp+4]
501
	mov	cx,[ecx]
510
	mov	cx,[ecx]
502
	shl	ecx,16
511
	shl	ecx,16
503
	shr	ecx,16
512
	shr	ecx,16
504
	mcall	47
513
	mcall	47
505
	push	edx
514
	push	edx
506
	add	edx,[esp+4]
515
	add	edx,[esp+4]
507
	mcall	
516
	mcall	
508
	pop	edx
517
	pop	edx
509
	add	edx,len_kub
518
	add	edx,len_kub
510
	add	dword [esp+4],2
519
	add	dword [esp+4],2
511
	dec	dword [esp+8]
520
	dec	dword [esp+8]
512
	jnz	.3
521
	jnz	.3
513
	pop	eax
522
	pop	eax
514
	pop	eax
523
	pop	eax
515
	pop	eax
524
	pop	eax
516
 
525
 
517
 
526
 
518
	movzx	eax,[Difficult]
527
	movzx	eax,[Difficult]
519
	push	eax
528
	push	eax
520
	mov	esi,Map
529
	mov	esi,Map
521
	mov	edi,out_sum_buf
530
	mov	edi,out_sum_buf
522
	xor	ebx,ebx
531
	xor	ebx,ebx
523
.4:	xor	ecx,ecx
532
.4:	xor	ecx,ecx
524
	xor	edx,edx
533
	xor	edx,edx
525
	mov	ebx,[esp]
534
	mov	ebx,[esp]
526
.5:	mov	dl,[esi]
535
.5:	mov	dl,[esi]
527
	add	ecx,edx
536
	add	ecx,edx
528
	add	esi,max_dif
537
	add	esi,max_dif
529
	dec	ebx
538
	dec	ebx
530
	jnz	.5
539
	jnz	.5
531
	mov	word [edi],cx
540
	mov	word [edi],cx
532
	add	edi,2
541
	add	edi,2
533
	push	eax
542
	push	eax
534
	mov	eax,max_dif
543
	mov	eax,max_dif
535
	xor	edx,edx
544
	xor	edx,edx
536
	mul	dword [esp+4]
545
	mul	dword [esp+4]
537
	dec	eax
546
	dec	eax
538
	sub	esi,eax
547
	sub	esi,eax
539
	pop	eax
548
	pop	eax
540
	dec	eax
549
	dec	eax
541
	jnz	.4
550
	jnz	.4
542
 
551
 
543
	push	out_sum_buf
552
	push	out_sum_buf
544
	movzx	eax,[Difficult]
553
	movzx	eax,[Difficult]
545
	mov	ebx,len_kub
554
	mov	ebx,len_kub
546
	xor	edx,edx
555
	xor	edx,edx
547
	mul	ebx
556
	mul	ebx
548
	add	eax,35
557
	add	eax,35
549
	push	eax
558
	push	eax
550
	mov	edx,(beg_x+5)*65536+beg_y-20
559
	mov	edx,(beg_x+5)*65536+beg_y-20
551
	mov	ebx,0x30000
560
	mov	ebx,0x30000
552
	mov	esi,0x50000000+Fix_nmb_clr
561
	mov	esi,0x50000000+Fix_nmb_clr
553
	mov	edi,Bckgrd_clr
562
	mov	edi,Bckgrd_clr
554
 
563
 
555
.6:	mov	ecx,[esp+4]
564
.6:	mov	ecx,[esp+4]
556
	mov	ecx,[ecx]
565
	mov	ecx,[ecx]
557
	shl	ecx,16
566
	shl	ecx,16
558
	shr	ecx,16
567
	shr	ecx,16
559
	mcall	47
568
	mcall	47
560
	push	edx
569
	push	edx
561
	add	edx,[esp+4]
570
	add	edx,[esp+4]
562
	mcall	
571
	mcall	
563
	pop	edx
572
	pop	edx
564
	add	edx,len_kub*65536;[esp]
573
	add	edx,len_kub*65536;[esp]
565
	add	dword [esp+4],2
574
	add	dword [esp+4],2
566
	dec	dword [esp+8]
575
	dec	dword [esp+8]
567
	jnz	.6
576
	jnz	.6
568
	pop	eax
577
	pop	eax
569
	pop	eax
578
	pop	eax
570
	pop	eax
579
	pop	eax
571
ret
580
ret
572
 
581
 
573
 
582
 
574
 
583
 
575
out_one_sum:
584
out_one_sum:
576
	movzx	ecx,[Difficult]
585
	movzx	ecx,[Difficult]
577
	mov	esi,Map
586
	mov	esi,Map
578
	xor	edx,edx
587
	xor	edx,edx
579
 
588
 
580
	movzx	eax,[Y]
589
	movzx	eax,[Y]
581
	dec	al
590
	dec	al
582
	mov	ebx,max_dif
591
	mov	ebx,max_dif
583
	mul	bl
592
	mul	bl
584
	add	esi,eax
593
	add	esi,eax
585
@@:	mov	al,[esi]
594
@@:	mov	al,[esi]
586
	inc	esi
595
	inc	esi
587
	add	edx,eax
596
	add	edx,eax
588
	loop	@b
597
	loop	@b
589
 
598
 
590
	mov	ecx,edx
599
	mov	ecx,edx
591
	movzx	eax,[Difficult]
600
	movzx	eax,[Difficult]
592
	mov	ebx,len_kub*65536
601
	mov	ebx,len_kub*65536
593
	xor	edx,edx
602
	xor	edx,edx
594
	mul	ebx
603
	mul	ebx
595
	add	eax,40*65536
604
	add	eax,40*65536
596
	push	eax
605
	push	eax
597
	movzx	eax,[Y]
606
	movzx	eax,[Y]
598
	dec	eax
607
	dec	eax
599
	mov	ebx,len_kub
608
	mov	ebx,len_kub
600
	xor	edx,edx
609
	xor	edx,edx
601
	mul	ebx
610
	mul	ebx
602
	mov	edx,(beg_x-30)*65536+beg_y+10
611
	mov	edx,(beg_x-30)*65536+beg_y+10
603
	add	edx,eax
612
	add	edx,eax
604
	mov	ebx,0x30000
613
	mov	ebx,0x30000
605
	mov	esi,0x50000000+Fix_nmb_clr
614
	mov	esi,0x50000000+Fix_nmb_clr
606
	mov	edi,Bckgrd_clr
615
	mov	edi,Bckgrd_clr
607
 
616
 
608
	mcall	47
617
	mcall	47
609
	add	edx,[esp]
618
	add	edx,[esp]
610
	mcall	
619
	mcall	
611
	pop	eax
620
	pop	eax
612
 
621
 
613
 
622
 
614
 
623
 
615
 
624
 
616
	movzx	ecx,[Difficult]
625
	movzx	ecx,[Difficult]
617
	mov	esi,Map
626
	mov	esi,Map
618
	xor	edx,edx
627
	xor	edx,edx
619
 
628
 
620
	movzx	eax,[X]
629
	movzx	eax,[X]
621
	dec	al
630
	dec	al
622
	add	esi,eax
631
	add	esi,eax
623
@@:	mov	al,[esi]
632
@@:	mov	al,[esi]
624
	add	esi,max_dif
633
	add	esi,max_dif
625
	add	edx,eax
634
	add	edx,eax
626
	loop	@b
635
	loop	@b
627
 
636
 
628
	mov	ecx,edx
637
	mov	ecx,edx
629
	movzx	eax,[Difficult]
638
	movzx	eax,[Difficult]
630
	mov	ebx,len_kub
639
	mov	ebx,len_kub
631
	xor	edx,edx
640
	xor	edx,edx
632
	mul	ebx
641
	mul	ebx
633
	add	eax,35
642
	add	eax,35
634
	push	eax
643
	push	eax
635
	movzx	eax,[X]
644
	movzx	eax,[X]
636
	dec	eax
645
	dec	eax
637
	mov	ebx,len_kub*65536
646
	mov	ebx,len_kub*65536
638
	xor	edx,edx
647
	xor	edx,edx
639
	mul	ebx
648
	mul	ebx
640
	mov	edx,eax
649
	mov	edx,eax
641
	add	edx,(beg_x+5)*65536+beg_y-20
650
	add	edx,(beg_x+5)*65536+beg_y-20
642
	mov	ebx,0x30000
651
	mov	ebx,0x30000
643
	mov	esi,0x50000000+Fix_nmb_clr
652
	mov	esi,0x50000000+Fix_nmb_clr
644
	mov	edi,Bckgrd_clr
653
	mov	edi,Bckgrd_clr
645
 
654
 
646
	mcall	47
655
	mcall	47
647
	add	edx,[esp]
656
	add	edx,[esp]
648
	mcall	
657
	mcall	
649
 
658
 
650
	pop	edx
659
	pop	edx
651
 
660
 
652
ret
661
ret
653
 
662
 
654
 
663
 
655
 
664
 
656
 
665
 
657
if DEBUG
666
if DEBUG
658
SysMsgBoardNum: ;warning: destroys eax,ebx,ecx,esi
667
SysMsgBoardNum: ;warning: destroys eax,ebx,ecx,esi
659
	mov	ebx,esp
668
	mov	ebx,esp
660
	mov	ecx,8
669
	mov	ecx,8
661
	mov	esi,(number_to_out+1)
670
	mov	esi,(number_to_out+1)
662
.1:
671
.1:
663
	mov	eax,ebx
672
	mov	eax,ebx
664
	and	eax,0xF
673
	and	eax,0xF
665
	add	al,'0'
674
	add	al,'0'
666
	cmp	al,(10+'0')
675
	cmp	al,(10+'0')
667
	jb	@f
676
	jb	@f
668
	add	al,('A'-'0'-10)
677
	add	al,('A'-'0'-10)
669
@@:
678
@@:
670
	mov	[esi+ecx],al
679
	mov	[esi+ecx],al
671
	shr	ebx,4
680
	shr	ebx,4
672
	loop	.1
681
	loop	.1
673
	dec	esi
682
	dec	esi
674
	mcall	71,1,number_to_out
683
	mcall	71,1,number_to_out
675
ret
684
ret
676
 
685
 
677
number_to_out	db '0x00000000',13,10,0
686
number_to_out	db '0x00000000',13,10,0
678
endf
687
endf
679
 
688
 
680
 
689
 
681
 
690
 
682
 
691
 
683
 
692
 
684
if lang eq ru
693
if lang eq ru
685
title db 'Œ £¨ç¥áª¨© ª¢ ¤à â',0
694
title db 'Œ £¨ç¥áª¨© ª¢ ¤à â',0
686
txt:
695
txt:
687
.dif db "‘«®¦­®áâì (+/-):",0
696
.dif db "‘«®¦­®áâì (+/-):",0
688
.clear db 'Žç¨áâ¨âì (x)',0
697
.clear db 'Žç¨áâ¨âì (x)',0
689
else
698
else
690
title db 'Magical square',0
699
title db 'Magical square',0
691
txt:
700
txt:
692
.dif db "Difficult (+/-)",0
701
.dif db "Difficult (+/-)",0
693
.clear db 'Clear (x)',0
702
.clear db 'Clear (x)',0
694
endf
703
endf
695
 
704
 
696
 
705
 
697
 
706
 
698
 
707
 
699
align 4
708
align 4
700
; «¨âàë:
709
; «¨âàë:
701
Pltr:
710
Pltr:
702
.ch dd Bckgrd_clr,Chg_nmb_clr
711
.ch dd Bckgrd_clr,Chg_nmb_clr
703
.chk dd Square_clr,Chg_nmb_clr
712
.chk dd Square_clr,Chg_nmb_clr
704
.fx dd Bckgrd_clr,Fix_nmb_clr
713
.fx dd Bckgrd_clr,Fix_nmb_clr
705
.fxk dd Square_clr,Fix_nmb_clr
714
.fxk dd Square_clr,Fix_nmb_clr
706
 
715
 
707
FONT file "MSquare.fnt"
716
FONT file "MSquare.fnt"
708
 
717
 
709
X db 1
718
X db 1
710
Y db 1
719
Y db 1
711
 
720
 
712
Difficult db 3
721
Difficult db 3
713
 
722
 
714
I_END:
723
I_END:
715
align 16
724
align 16
716
Map	rb max_dif*max_dif
725
Map	rb max_dif*max_dif
717
out_sum_buf rw max_dif
726
out_sum_buf rw max_dif
718
 
727
 
719
flags rw 1
728
flags rw 1
720
 
729
 
721
D_END:
730
D_END:
722
;¡¨â 0: á¬. ¯¥à¥¤ draw_pole
731
;¡¨â 0: á¬. ¯¥à¥¤ draw_pole
723
;2: ¢ draw_pole ¨ key
732
;2: ¢ draw_pole ¨ key
724
;4: in draw_one_symbol
733
;4: in draw_one_symbol
725
;9: ¢¢¥¤ñ­  ¯¥à¢ ï æ¨äà  ç¨á« 
734
;9: ¢¢¥¤ñ­  ¯¥à¢ ï æ¨äà  ç¨á«