Subversion Repositories Kolibri OS

Rev

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

Rev 1806 Rev 1824
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,<3,78>,<3,13>,2,0xbbbbbb
99
	mcall	8,<3,78>,<3,13>,2,0xbbbbbb
100
	mcall	4,<7,5>,(0x80000000+Text_clr),txt.clear
100
	mcall	4,<7,5>,(0x80000000+Text_clr),txt.clear
101
	mcall	,<105,5>,,txt.dif
101
	mcall	,<105,5>,,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
	jmp	redraw_all
173
	jmp	redraw_all
174
	jmp	still
174
	jmp	still
175
 
175
 
176
.99:	cmp	ah,0x58
176
.99:	cmp	ah,0x58
177
	je	@f
177
	je	@f
178
	cmp	ah,0x78
178
	cmp	ah,0x78
179
	jne	.39
179
	jne	.39
180
@@:	jmp	still.clear
180
@@:	jmp	still.clear
181
 
181
 
182
.39:	cmp	ah,0x39
182
.39:	cmp	ah,0x39
183
	ja	.110
183
	ja	.110
184
	cmp	ah,0x30
184
	cmp	ah,0x30
185
	jb	still
185
	jb	still
186
	sub	ah,0x30
186
	sub	ah,0x30
187
	mov	cl,ah
187
	mov	cl,ah
188
 
188
 
189
	movzx	eax,[Y]
189
	movzx	eax,[Y]
190
	dec	al
190
	dec	al
191
	mov	ebx,max_dif;[Difficult]
191
	mov	ebx,max_dif;[Difficult]
192
	mul	bl
192
	mul	bl
193
	mov	bl,[X]
193
	mov	bl,[X]
194
	dec	bl
194
	dec	bl
195
	add	al,bl
195
	add	al,bl
196
 
196
 
197
	mov	esi,Map
197
	mov	esi,Map
198
	bt	[flags],9
198
	bt	[flags],9
199
	jnc	@f
199
	jnc	@f
200
	mov	bl,[esi+eax]
200
	mov	bl,[esi+eax]
201
	push	eax
201
	push	eax
202
	mov	ax,10
202
	mov	ax,10
203
	xor	dl,dl
203
	xor	dl,dl
204
	mul	bl
204
	mul	bl
205
	add	cl,al
205
	add	cl,al
206
	pop	eax
206
	pop	eax
207
	mov	[esi+eax],cl
207
	mov	[esi+eax],cl
208
	btr	[flags],9
208
	btr	[flags],9
209
	jmp	.onedraw
209
	jmp	.onedraw
210
   @@:	mov	[esi+eax],cl
210
   @@:	mov	[esi+eax],cl
211
	bts	[flags],9
211
	bts	[flags],9
212
	jmp	.onedraw
212
	jmp	.onedraw
213
 
213
 
214
 
214
 
215
.110:	cmp	ah,110		;n
215
.110:	cmp	ah,110		;n
216
	jne	.176
216
	jne	.176
217
.new_game:
217
.new_game:
218
	jmp	redraw_all
218
	jmp	redraw_all
219
 
219
 
220
.176:	cmp	ah,176 ;ªãàá®àë
220
.176:	cmp	ah,176 ;ªãàá®àë
221
	jne	.177
221
	jne	.177
222
	call	draw_one_symbol
222
	call	draw_one_symbol
223
	dec	[X]
223
	dec	[X]
224
	cmp	[X],1
224
	cmp	[X],1
225
	jge	@f
225
	jge	@f
226
	push	eax
226
	push	eax
227
	movzx	eax,[Difficult]
227
	movzx	eax,[Difficult]
228
	mov	[X],al
228
	mov	[X],al
229
	pop	eax
229
	pop	eax
230
@@:	btr	[flags],9
230
@@:	btr	[flags],9
231
	jmp	.onedraw
231
	jmp	.onedraw
232
.177:	cmp	ah,177
232
.177:	cmp	ah,177
233
	jne	.178
233
	jne	.178
234
	call	draw_one_symbol
234
	call	draw_one_symbol
235
	inc	[Y]
235
	inc	[Y]
236
	push	eax
236
	push	eax
237
	movzx	eax,[Difficult]
237
	movzx	eax,[Difficult]
238
	cmp	[Y],al
238
	cmp	[Y],al
239
	jbe	@f
239
	jbe	@f
240
	mov	[Y],1
240
	mov	[Y],1
241
@@:	pop	eax
241
@@:	pop	eax
242
	btr	[flags],9
242
	btr	[flags],9
243
	jmp	.onedraw
243
	jmp	.onedraw
244
.178:	cmp	ah,178
244
.178:	cmp	ah,178
245
	jne	.179
245
	jne	.179
246
	call	draw_one_symbol
246
	call	draw_one_symbol
247
	dec	[Y]
247
	dec	[Y]
248
	cmp	[Y],1
248
	cmp	[Y],1
249
	jge	@f
249
	jge	@f
250
	push	eax
250
	push	eax
251
	movzx	eax,[Difficult]
251
	movzx	eax,[Difficult]
252
	mov	[Y],al
252
	mov	[Y],al
253
	pop	eax
253
	pop	eax
254
@@:	btr	[flags],9
254
@@:	btr	[flags],9
255
	jmp	.onedraw
255
	jmp	.onedraw
256
.179:	cmp	ah,179
256
.179:	cmp	ah,179
257
	jne	still
257
	jne	still
258
	call	draw_one_symbol
258
	call	draw_one_symbol
259
	inc	[X]
259
	inc	[X]
260
	push	eax
260
	push	eax
261
	movzx	eax,[Difficult]
261
	movzx	eax,[Difficult]
262
	cmp	[X],al
262
	cmp	[X],al
263
	jbe	@f
263
	jbe	@f
264
	mov	[X],1
264
	mov	[X],1
265
@@:	btr	[flags],9
265
@@:	btr	[flags],9
266
	pop	eax
266
	pop	eax
267
.onedraw:
267
.onedraw:
268
	bts	[flags],4
268
	bts	[flags],4
269
	call	draw_one_symbol
269
	call	draw_one_symbol
270
	call	out_one_sum
270
	call	out_one_sum
271
	jmp	still ;.todraw
271
	jmp	still ;.todraw
272
 
272
 
273
show_level:
273
show_level:
274
	movzx	ecx,[Difficult]
274
	movzx	ecx,[Difficult]
275
	mcall	47,0x10000,,<205,5>,(0x50000000+Text_clr),Bckgrd_clr
275
	mcall	47,0x10000,,<205,5>,(0x50000000+Text_clr),Bckgrd_clr
276
ret
276
ret
277
 
277
 
278
 
278
 
279
draw_one_symbol:
279
draw_one_symbol:
280
	movzx	eax,[X]
280
	movzx	eax,[X]
281
	mov	ebx,len_kub*65536+len_kub
281
	mov	ebx,len_kub*65536+len_kub
282
	mul	ebx
282
	mul	ebx
283
	xchg	eax,ebx
283
	xchg	eax,ebx
284
	add	ebx,(beg_x*65536+beg_y-len_kub*65536+len_kub)
284
	add	ebx,(beg_x*65536+beg_y-len_kub*65536+len_kub)
285
	movzx	eax,[Y]
285
	movzx	eax,[Y]
286
	mov	ecx,len_kub*65536+len_kub
286
	mov	ecx,len_kub*65536+len_kub
287
	mul	ecx
287
	mul	ecx
288
	xchg	eax,ecx
288
	xchg	eax,ecx
289
	add	ecx,(beg_y*65536+beg_y+sym_y-len_kub*65536+len_kub)
289
	add	ecx,(beg_y*65536+beg_y+sym_y-len_kub*65536+len_kub)
290
	movzx	eax,[Y]
290
	movzx	eax,[Y]
291
	dec	al
291
	dec	al
292
	push	ebx
292
	push	ebx
293
	movzx	ebx,[Difficult]
293
	movzx	ebx,[Difficult]
294
	mul	bl
294
	mul	bl
295
	mov	bl,[X]
295
	mov	bl,[X]
296
	add	al,bl
296
	add	al,bl
297
	dec	al
297
	dec	al
298
	pop	ebx
298
	pop	ebx
299
	mov	esi,Map
299
	mov	esi,Map
300
	add	esi,eax
300
	add	esi,eax
301
	push	dword 0 ;­¥ ªãàá®à
301
	push	dword 0 ;­¥ ªãàá®à
302
	bt	[flags],4
302
	bt	[flags],4
303
	jnc	@f
303
	jnc	@f
304
	mov	dword [esp],1 ;ªãàá®à
304
	mov	dword [esp],1 ;ªãàá®à
305
	btr	[flags],4
305
	btr	[flags],4
306
@@:	mov	edi,0
306
@@:	mov	edi,0
307
	mov	ebp,1
307
	mov	ebp,1
308
	call	out_numbers
308
	call	out_numbers
309
	pop	eax
309
	pop	eax
310
ret
310
ret
311
 
311
 
312
 
312
 
313
out_numbers:
313
out_numbers:
314
	push	ebx ecx esi
314
	push	ebx ecx esi
315
	shr	ebx,16
315
	shr	ebx,16
316
	inc	bx
316
	inc	bx
317
	shl	ebx,16
317
	shl	ebx,16
318
	add	ebx,len_kub-1
318
	add	ebx,len_kub-1
319
	shr	ecx,16
319
	shr	ecx,16
320
	inc	cx
320
	inc	cx
321
	shl	ecx,16
321
	shl	ecx,16
322
	add	ecx,len_kub-1
322
	add	ecx,len_kub-1
323
	mov	edx,Bckgrd_clr
323
	mov	edx,Bckgrd_clr
324
	push	ebp
324
	push	ebp
325
	dec	dword [esp+4*5]
325
	dec	dword [esp+4*5]
326
	jnz	@f
326
	jnz	@f
327
	mov	edx,Square_clr
327
	mov	edx,Square_clr
328
@@:	mcall	13
328
@@:	mcall	13
329
	pop	ebp
329
	pop	ebp
330
	pop	esi
330
	pop	esi
331
 
331
 
332
	push	ebx edx
332
	push	ebx edx
333
	mov	eax,esi
333
	mov	eax,esi
334
	sub	eax,Map-1
334
	sub	eax,Map-1
335
	xor	edx,edx
335
	xor	edx,edx
336
	movzx	ebx,[Difficult]
336
	movzx	ebx,[Difficult]
337
	div	ebx
337
	div	ebx
338
	push	edx
338
	push	edx
339
	xor	edx,edx
339
	xor	edx,edx
340
	mov	ebx,max_dif
340
	mov	ebx,max_dif
341
	mul	ebx
341
	mul	ebx
342
	pop	edx
342
	pop	edx
343
	test	edx,edx
343
	test	edx,edx
344
	jnz	@f
344
	jnz	@f
345
	movzx	edx,[Difficult]
345
	movzx	edx,[Difficult]
346
	sub	eax,max_dif
346
	sub	eax,max_dif
347
@@:	add	eax,edx
347
@@:	add	eax,edx
348
	mov	al,[eax+Map-1]
348
	mov	al,[eax+Map-1]
349
	pop	edx ebx
349
	pop	edx ebx
350
	test	al,al
350
	test	al,al
351
 
351
 
352
;	cmp	byte [esi],0
352
;	cmp	byte [esi],0
353
	jnz	.changeable_number
353
	jnz	.changeable_number
354
	jmp	.null
354
	jmp	.null
355
.end:
355
.end:
356
	inc	esi
356
	inc	esi
357
	dec	ebp
357
	dec	ebp
358
	jnz	out_numbers
358
	jnz	out_numbers
359
	test	edi,edi
359
	test	edi,edi
360
	jz	@f
360
	jz	@f
361
	push	ebx edx
361
	push	ebx edx
362
	movzx	eax,[Difficult]
362
	movzx	eax,[Difficult]
363
	sub	edi,eax
363
	sub	edi,eax
364
	mov	ebp,eax
364
	mov	ebp,eax
365
	mov	ebx,len_kub*65536
365
	mov	ebx,len_kub*65536
366
	xor	edx,edx
366
	xor	edx,edx
367
	mul	ebx
367
	mul	ebx
368
	push	eax
368
	push	eax
369
	movzx	eax,[Difficult]
369
	movzx	eax,[Difficult]
370
	mov	ebx,len_kub
370
	mov	ebx,len_kub
371
	mul	ebx
371
	mul	ebx
372
	pop	ebx
372
	pop	ebx
373
	add	eax,ebx
373
	add	eax,ebx
374
	pop	edx
374
	pop	edx
375
	pop	ebx
375
	pop	ebx
376
	sub	ebx,eax
376
	sub	ebx,eax
377
;	add	ebx,-9*24*65536-9*24
377
;	add	ebx,-9*24*65536-9*24
378
	add	ecx,len_kub*65536+len_kub
378
	add	ecx,len_kub*65536+len_kub
379
	jmp	out_numbers
379
	jmp	out_numbers
380
  @@:
380
  @@:
381
ret
381
ret
382
 
382
 
383
 
383
 
384
.null:
384
.null:
385
	pop	ecx ebx
385
	pop	ecx ebx
386
	add	ebx,len_kub*65536+len_kub
386
	add	ebx,len_kub*65536+len_kub
387
	jmp	.end
387
	jmp	.end
388
.changeable_number:
388
.changeable_number:
389
	push	esi
389
	push	esi
390
	shr	ebx,16
390
	shr	ebx,16
391
	shr	ecx,16
391
	shr	ecx,16
392
	mov	dx,bx
392
	mov	dx,bx
393
	shl	edx,16
393
	shl	edx,16
394
	mov	dx,cx
394
	mov	dx,cx
395
	add	edx,8*65536+4
395
	add	edx,8*65536+4
396
 
396
 
397
	push	ebx edx
397
	push	ebx edx
398
	mov	eax,esi
398
	mov	eax,esi
399
	sub	eax,Map-1
399
	sub	eax,Map-1
400
	xor	edx,edx
400
	xor	edx,edx
401
	movzx	ebx,[Difficult]
401
	movzx	ebx,[Difficult]
402
	div	ebx
402
	div	ebx
403
	push	edx
403
	push	edx
404
	xor	edx,edx
404
	xor	edx,edx
405
	mov	ebx,max_dif
405
	mov	ebx,max_dif
406
	mul	ebx
406
	mul	ebx
407
	pop	edx
407
	pop	edx
408
	test	edx,edx
408
	test	edx,edx
409
	jnz	@f
409
	jnz	@f
410
	movzx	edx,[Difficult]
410
	movzx	edx,[Difficult]
411
	sub	eax,max_dif
411
	sub	eax,max_dif
412
@@:	add	eax,edx
412
@@:	add	eax,edx
413
	pop	edx ebx
413
	pop	edx ebx
414
	
414
	
415
	movzx	ebx,byte [eax+Map-1];[esi]
415
	movzx	ebx,byte [eax+Map-1];[esi]
416
 
416
 
417
 
417
 
418
	push	esi ebp edi edx
418
	push	esi ebp edi edx
419
	sub	edx,2*65536-3
419
	sub	edx,2*65536-3
420
	push	edx
420
	push	edx
421
	xchg	eax,ebx
421
	xchg	eax,ebx
422
	mov	ebx,10
422
	mov	ebx,10
423
	xor	edx,edx
423
	xor	edx,edx
424
	div	ebx
424
	div	ebx
425
	mov	ebx,edx
425
	mov	ebx,edx
426
	pop	edx
426
	pop	edx
427
	
427
	
428
	push	ebx
428
	push	ebx
429
 
429
 
430
	test	eax,eax
430
	test	eax,eax
431
	jz	.only_first_num
431
	jz	.only_first_num
432
 
432
 
433
;	bt	[flags],9
433
;	bt	[flags],9
434
;	jc	.only_first_num
434
;	jc	.only_first_num
435
 
435
 
436
	xchg	eax,ebx
436
	xchg	eax,ebx
437
 
437
 
438
	shl	bx,4
438
	shl	bx,4
439
	add	ebx,FONT
439
	add	ebx,FONT
440
	mov	ecx,8*65536+16
440
	mov	ecx,8*65536+16
441
 
441
 
442
	mov	edi,Pltr.ch
442
	mov	edi,Pltr.ch
443
	cmp	dword [esp+4*9],0
443
	cmp	dword [esp+4*9],0
444
	jne	@f
444
	jne	@f
445
	mov	edi,Pltr.chk
445
	mov	edi,Pltr.chk
446
@@:	mov	esi,1
446
@@:	mov	esi,1
447
	mov	ebp,0
447
	mov	ebp,0
448
	mcall	65
448
	mcall	65
449
 
449
 
450
.only_first_num:
450
.only_first_num:
451
	pop	ebx
451
	pop	ebx
452
	shl	bl,4
452
	shl	bl,4
453
 
453
 
454
	add	ebx,FONT
454
	add	ebx,FONT
455
	mov	ecx,8*65536+16
455
	mov	ecx,8*65536+16
456
	add	edx,8*65536
456
	add	edx,8*65536
457
	mov	edi,Pltr.ch
457
	mov	edi,Pltr.ch
458
	cmp	dword [esp+4*8],0
458
	cmp	dword [esp+4*8],0
459
	jne	@f
459
	jne	@f
460
	mov	edi,Pltr.chk
460
	mov	edi,Pltr.chk
461
@@:	mov	esi,1
461
@@:	mov	esi,1
462
	mov	ebp,0
462
	mov	ebp,0
463
	mcall	65
463
	mcall	65
464
	pop	edx edi ebp esi
464
	pop	edx edi ebp esi
465
	pop	esi ecx ebx
465
	pop	esi ecx ebx
466
	add	ebx,len_kub*65536+len_kub
466
	add	ebx,len_kub*65536+len_kub
467
	jmp	.end
467
	jmp	.end
468
 
468
 
469
out_sum:
469
out_sum:
470
	movzx	eax,[Difficult]
470
	movzx	eax,[Difficult]
471
	push	eax
471
	push	eax
472
	mov	esi,Map
472
	mov	esi,Map
473
	mov	edi,out_sum_buf
473
	mov	edi,out_sum_buf
474
.1:	xor	ebx,ebx
474
.1:	xor	ebx,ebx
475
	xor	ecx,ecx
475
	xor	ecx,ecx
476
	xor	edx,edx
476
	xor	edx,edx
477
.2:	mov	dl,[ebx+esi]
477
.2:	mov	dl,[ebx+esi]
478
	add	ecx,edx
478
	add	ecx,edx
479
	inc	ebx
479
	inc	ebx
480
	cmp	ebx,[esp]
480
	cmp	ebx,[esp]
481
	jne	.2
481
	jne	.2
482
	mov	word [edi],cx
482
	mov	word [edi],cx
483
	add	edi,2
483
	add	edi,2
484
	add	esi,max_dif
484
	add	esi,max_dif
485
	dec	eax
485
	dec	eax
486
	jnz	.1
486
	jnz	.1
487
 
487
 
488
	push	out_sum_buf
488
	push	out_sum_buf
489
	movzx	eax,[Difficult]
489
	movzx	eax,[Difficult]
490
	mov	ebx,len_kub*65536
490
	mov	ebx,len_kub*65536
491
	xor	edx,edx
491
	xor	edx,edx
492
	mul	ebx
492
	mul	ebx
493
	add	eax,40*65536
493
	add	eax,40*65536
494
	push	eax
494
	push	eax
495
	mov	edx,(beg_x-30)*65536+beg_y+10
495
	mov	edx,(beg_x-30)*65536+beg_y+10
496
	mov	ebx,0x30000
496
	mov	ebx,0x30000
497
	mov	esi,0x50000000+Fix_nmb_clr
497
	mov	esi,0x50000000+Fix_nmb_clr
498
	mov	edi,Bckgrd_clr
498
	mov	edi,Bckgrd_clr
499
 
499
 
500
.3:	mov	ecx,[esp+4]
500
.3:	mov	ecx,[esp+4]
501
	mov	cx,[ecx]
501
	mov	cx,[ecx]
502
	shl	ecx,16
502
	shl	ecx,16
503
	shr	ecx,16
503
	shr	ecx,16
504
	mcall	47
504
	mcall	47
505
	push	edx
505
	push	edx
506
	add	edx,[esp+4]
506
	add	edx,[esp+4]
507
	mcall	
507
	mcall	
508
	pop	edx
508
	pop	edx
509
	add	edx,len_kub
509
	add	edx,len_kub
510
	add	dword [esp+4],2
510
	add	dword [esp+4],2
511
	dec	dword [esp+8]
511
	dec	dword [esp+8]
512
	jnz	.3
512
	jnz	.3
513
	pop	eax
513
	pop	eax
514
	pop	eax
514
	pop	eax
515
	pop	eax
515
	pop	eax
516
 
516
 
517
 
517
 
518
	movzx	eax,[Difficult]
518
	movzx	eax,[Difficult]
519
	push	eax
519
	push	eax
520
	mov	esi,Map
520
	mov	esi,Map
521
	mov	edi,out_sum_buf
521
	mov	edi,out_sum_buf
522
	xor	ebx,ebx
522
	xor	ebx,ebx
523
.4:	xor	ecx,ecx
523
.4:	xor	ecx,ecx
524
	xor	edx,edx
524
	xor	edx,edx
525
	mov	ebx,[esp]
525
	mov	ebx,[esp]
526
.5:	mov	dl,[esi]
526
.5:	mov	dl,[esi]
527
	add	ecx,edx
527
	add	ecx,edx
528
	add	esi,max_dif
528
	add	esi,max_dif
529
	dec	ebx
529
	dec	ebx
530
	jnz	.5
530
	jnz	.5
531
	mov	word [edi],cx
531
	mov	word [edi],cx
532
	add	edi,2
532
	add	edi,2
533
	push	eax
533
	push	eax
534
	mov	eax,max_dif
534
	mov	eax,max_dif
535
	xor	edx,edx
535
	xor	edx,edx
536
	mul	dword [esp+4]
536
	mul	dword [esp+4]
537
	dec	eax
537
	dec	eax
538
	sub	esi,eax
538
	sub	esi,eax
539
	pop	eax
539
	pop	eax
540
	dec	eax
540
	dec	eax
541
	jnz	.4
541
	jnz	.4
542
 
542
 
543
	push	out_sum_buf
543
	push	out_sum_buf
544
	movzx	eax,[Difficult]
544
	movzx	eax,[Difficult]
545
	mov	ebx,len_kub
545
	mov	ebx,len_kub
546
	xor	edx,edx
546
	xor	edx,edx
547
	mul	ebx
547
	mul	ebx
548
	add	eax,35
548
	add	eax,35
549
	push	eax
549
	push	eax
550
	mov	edx,(beg_x+5)*65536+beg_y-20
550
	mov	edx,(beg_x+5)*65536+beg_y-20
551
	mov	ebx,0x30000
551
	mov	ebx,0x30000
552
	mov	esi,0x50000000+Fix_nmb_clr
552
	mov	esi,0x50000000+Fix_nmb_clr
553
	mov	edi,Bckgrd_clr
553
	mov	edi,Bckgrd_clr
554
 
554
 
555
.6:	mov	ecx,[esp+4]
555
.6:	mov	ecx,[esp+4]
556
	mov	ecx,[ecx]
556
	mov	ecx,[ecx]
557
	shl	ecx,16
557
	shl	ecx,16
558
	shr	ecx,16
558
	shr	ecx,16
559
	mcall	47
559
	mcall	47
560
	push	edx
560
	push	edx
561
	add	edx,[esp+4]
561
	add	edx,[esp+4]
562
	mcall	
562
	mcall	
563
	pop	edx
563
	pop	edx
564
	add	edx,len_kub*65536;[esp]
564
	add	edx,len_kub*65536;[esp]
565
	add	dword [esp+4],2
565
	add	dword [esp+4],2
566
	dec	dword [esp+8]
566
	dec	dword [esp+8]
567
	jnz	.6
567
	jnz	.6
568
	pop	eax
568
	pop	eax
569
	pop	eax
569
	pop	eax
570
	pop	eax
570
	pop	eax
571
ret
571
ret
572
 
572
 
573
 
573
 
574
 
574
 
575
out_one_sum:
575
out_one_sum:
576
	movzx	ecx,[Difficult]
576
	movzx	ecx,[Difficult]
577
	mov	esi,Map
577
	mov	esi,Map
578
	xor	edx,edx
578
	xor	edx,edx
579
 
579
 
580
	movzx	eax,[Y]
580
	movzx	eax,[Y]
581
	dec	al
581
	dec	al
582
	mov	ebx,max_dif
582
	mov	ebx,max_dif
583
	mul	bl
583
	mul	bl
584
	add	esi,eax
584
	add	esi,eax
585
@@:	mov	al,[esi]
585
@@:	mov	al,[esi]
586
	inc	esi
586
	inc	esi
587
	add	edx,eax
587
	add	edx,eax
588
	loop	@b
588
	loop	@b
589
 
589
 
590
	mov	ecx,edx
590
	mov	ecx,edx
591
	movzx	eax,[Difficult]
591
	movzx	eax,[Difficult]
592
	mov	ebx,len_kub*65536
592
	mov	ebx,len_kub*65536
593
	xor	edx,edx
593
	xor	edx,edx
594
	mul	ebx
594
	mul	ebx
595
	add	eax,40*65536
595
	add	eax,40*65536
596
	push	eax
596
	push	eax
597
	movzx	eax,[Y]
597
	movzx	eax,[Y]
598
	dec	eax
598
	dec	eax
599
	mov	ebx,len_kub
599
	mov	ebx,len_kub
600
	xor	edx,edx
600
	xor	edx,edx
601
	mul	ebx
601
	mul	ebx
602
	mov	edx,(beg_x-30)*65536+beg_y+10
602
	mov	edx,(beg_x-30)*65536+beg_y+10
603
	add	edx,eax
603
	add	edx,eax
604
	mov	ebx,0x30000
604
	mov	ebx,0x30000
605
	mov	esi,0x50000000+Fix_nmb_clr
605
	mov	esi,0x50000000+Fix_nmb_clr
606
	mov	edi,Bckgrd_clr
606
	mov	edi,Bckgrd_clr
607
 
607
 
608
	mcall	47
608
	mcall	47
609
	add	edx,[esp]
609
	add	edx,[esp]
610
	mcall	
610
	mcall	
611
	pop	eax
611
	pop	eax
612
 
612
 
613
 
613
 
614
 
614
 
615
 
615
 
616
	movzx	ecx,[Difficult]
616
	movzx	ecx,[Difficult]
617
	mov	esi,Map
617
	mov	esi,Map
618
	xor	edx,edx
618
	xor	edx,edx
619
 
619
 
620
	movzx	eax,[X]
620
	movzx	eax,[X]
621
	dec	al
621
	dec	al
622
	add	esi,eax
622
	add	esi,eax
623
@@:	mov	al,[esi]
623
@@:	mov	al,[esi]
624
	add	esi,max_dif
624
	add	esi,max_dif
625
	add	edx,eax
625
	add	edx,eax
626
	loop	@b
626
	loop	@b
627
 
627
 
628
	mov	ecx,edx
628
	mov	ecx,edx
629
	movzx	eax,[Difficult]
629
	movzx	eax,[Difficult]
630
	mov	ebx,len_kub
630
	mov	ebx,len_kub
631
	xor	edx,edx
631
	xor	edx,edx
632
	mul	ebx
632
	mul	ebx
633
	add	eax,35
633
	add	eax,35
634
	push	eax
634
	push	eax
635
	movzx	eax,[X]
635
	movzx	eax,[X]
636
	dec	eax
636
	dec	eax
637
	mov	ebx,len_kub*65536
637
	mov	ebx,len_kub*65536
638
	xor	edx,edx
638
	xor	edx,edx
639
	mul	ebx
639
	mul	ebx
640
	mov	edx,eax
640
	mov	edx,eax
641
	add	edx,(beg_x+5)*65536+beg_y-20
641
	add	edx,(beg_x+5)*65536+beg_y-20
642
	mov	ebx,0x30000
642
	mov	ebx,0x30000
643
	mov	esi,0x50000000+Fix_nmb_clr
643
	mov	esi,0x50000000+Fix_nmb_clr
644
	mov	edi,Bckgrd_clr
644
	mov	edi,Bckgrd_clr
645
 
645
 
646
	mcall	47
646
	mcall	47
647
	add	edx,[esp]
647
	add	edx,[esp]
648
	mcall	
648
	mcall	
649
 
649
 
650
	pop	edx
650
	pop	edx
651
 
651
 
652
ret
652
ret
653
 
653
 
654
 
654
 
655
 
655
 
656
 
656
 
657
if DEBUG
657
if DEBUG
658
SysMsgBoardNum: ;warning: destroys eax,ebx,ecx,esi
658
SysMsgBoardNum: ;warning: destroys eax,ebx,ecx,esi
659
	mov	ebx,esp
659
	mov	ebx,esp
660
	mov	ecx,8
660
	mov	ecx,8
661
	mov	esi,(number_to_out+1)
661
	mov	esi,(number_to_out+1)
662
.1:
662
.1:
663
	mov	eax,ebx
663
	mov	eax,ebx
664
	and	eax,0xF
664
	and	eax,0xF
665
	add	al,'0'
665
	add	al,'0'
666
	cmp	al,(10+'0')
666
	cmp	al,(10+'0')
667
	jb	@f
667
	jb	@f
668
	add	al,('A'-'0'-10)
668
	add	al,('A'-'0'-10)
669
@@:
669
@@:
670
	mov	[esi+ecx],al
670
	mov	[esi+ecx],al
671
	shr	ebx,4
671
	shr	ebx,4
672
	loop	.1
672
	loop	.1
673
	dec	esi
673
	dec	esi
674
	mcall	71,1,number_to_out
674
	mcall	71,1,number_to_out
675
ret
675
ret
676
 
676
 
677
number_to_out	db '0x00000000',13,10,0
677
number_to_out	db '0x00000000',13,10,0
678
endf
678
endf
679
 
679
 
680
 
680
 
681
 
681
 
682
 
682
 
683
 
683
 
684
if lang eq ru
684
if lang eq ru
685
title db 'Œ £¨ç¥áª¨© ª¢ ¤à â',0
685
title db 'Œ £¨ç¥áª¨© ª¢ ¤à â',0
686
txt:
686
txt:
687
.dif db "‘«®¦­®áâì (+/-):",0
687
.dif db "‘«®¦­®áâì (+/-):",0
688
.clear db 'Žç¨áâ¨âì (x)',0
688
.clear db 'Žç¨áâ¨âì (x)',0
689
else
689
else
690
title db 'Magical square',0
690
title db 'Magical square',0
691
txt:
691
txt:
692
.dif db "Difficult (+/-)",0
692
.dif db "Difficult (+/-)",0
693
.clear db 'Clear (x)',0
693
.clear db 'Clear (x)',0
694
endf
694
endf
695
 
695
 
696
 
696
 
697
 
697
 
698
 
698
 
699
align 4
699
align 4
700
; «¨âàë:
700
; «¨âàë:
701
Pltr:
701
Pltr:
702
.ch dd Bckgrd_clr,Chg_nmb_clr
702
.ch dd Bckgrd_clr,Chg_nmb_clr
703
.chk dd Square_clr,Chg_nmb_clr
703
.chk dd Square_clr,Chg_nmb_clr
704
.fx dd Bckgrd_clr,Fix_nmb_clr
704
.fx dd Bckgrd_clr,Fix_nmb_clr
705
.fxk dd Square_clr,Fix_nmb_clr
705
.fxk dd Square_clr,Fix_nmb_clr
706
 
706
 
707
FONT file "MSquare.fnt"
707
FONT file "MSquare.fnt"
708
 
708
 
709
X db 1
709
X db 1
710
Y db 1
710
Y db 1
711
 
711
 
712
Difficult db 3
712
Difficult db 3
713
 
713
 
714
I_END:
714
I_END:
715
align 16
715
align 16
716
Map	rb max_dif*max_dif
716
Map	rb max_dif*max_dif
717
out_sum_buf rw max_dif
717
out_sum_buf rw max_dif
718
 
718
 
719
flags rw 1
719
flags rw 1
720
 
720
 
721
D_END:
721
D_END:
722
;¡¨â 0: á¬. ¯¥à¥¤ draw_pole
722
;¡¨â 0: á¬. ¯¥à¥¤ draw_pole
723
;2: ¢ draw_pole ¨ key
723
;2: ¢ draw_pole ¨ key
724
;4: in draw_one_symbol
724
;4: in draw_one_symbol
725
;9: ¢¢¥¤ñ­  ¯¥à¢ ï æ¨äà  ç¨á« 
725
;9: ¢¢¥¤ñ­  ¯¥à¢ ï æ¨äà  ç¨á«