Subversion Repositories Kolibri OS

Rev

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

Rev 551 Rev 2681
1
;
1
;
2
;   The famous game 15
2
;   The famous game 15
3
;   Author: Lloyd, coded by Ivushkin Andrey
3
;   Author: Lloyd, coded by Ivushkin Andrey
4
;   Compile with FASM
4
;   Compile with FASM
5
;
5
;
6
include 'lang.inc'
6
include 'lang.inc'
7
include '..\..\..\macros.inc' ; decreases program size (not required)
7
include '..\..\..\macros.inc' ; decreases program size (not required)
8
 
8
 
9
StatusColor equ 0x02ffffff
9
StatusColor equ 0x02ffffff
10
StatusColor2 equ 0x02dc1e14
10
StatusColor2 equ 0x02dc1e14
11
BgdColor equ 0x04aabbcc
11
BgdColor equ 0x14aabbcc
12
 
12
 
13
; Main window dimensions
13
; Main window dimensions
14
XXwindow equ 200 shl 16+276
14
XXwindow equ 200 shl 16+276
15
YYwindow equ 200 shl 16+300
15
YYwindow equ 200 shl 16+300
16
; Status bar
16
; Status bar
17
XYstatus equ 35 shl 16+283
17
XYstatus equ 35 shl 16+283
18
XXbar equ 35 shl 16+136
18
XXbar equ 35 shl 16+136
19
YYbar equ 280 shl 16+15
19
YYbar equ 280 shl 16+15
20
; Buttons
20
; Buttons
21
BtnTop equ 28
21
BtnTop equ 28
22
BtnLeft equ 13
22
BtnLeft equ 13
23
BtnSize equ 60
23
BtnSize equ 60
24
BtnColor equ 0xafbb55
24
BtnColor equ 0xafbb55
25
BtnColor2 equ 0x0228c314
25
BtnColor2 equ 0x0228c314
26
 
26
 
27
NumColor equ 0x10000000
27
NumColor equ 0x10000000
28
; Number shifting for nice look
28
; Number shifting for nice look
29
NumShift equ 24 shl 16+27
29
NumShift equ 24 shl 16+27
30
NumShift2 equ 4 shl 16
30
NumShift2 equ 4 shl 16
31
; Shuffle button
31
; Shuffle button
32
XXSh equ 202 shl 16+60
32
XXSh equ 202 shl 16+60
33
YYSh equ 280 shl 16+12
33
YYSh equ 280 shl 16+12
34
XYShText equ 212 shl 16+283
34
XYShText equ 212 shl 16+283
35
 
35
 
36
; Conf button
36
; Conf button
37
XXCnf equ 13 shl 16+13
37
XXCnf equ 13 shl 16+13
38
YYCnf equ 280 shl 16+12
38
YYCnf equ 280 shl 16+12
39
XYCnfText equ 18 shl 16+283
39
XYCnfText equ 18 shl 16+283
40
 
40
 
41
; Position of the 'hole'
41
; Position of the 'hole'
42
null equ (curconf+16)
42
null equ (curconf+16)
43
; Amount of moves to perform shuffle
43
; Amount of moves to perform shuffle
44
SH_CYCLES equ 400
44
SH_CYCLES equ 400
45
; (Amount of tasks)-1
45
; (Amount of tasks)-1
46
CONF_COUNT equ 2
46
CONF_COUNT equ 2
47
 
47
 
48
use32
48
use32
49
 
49
 
50
  org    0x0
50
  org    0x0
51
 
51
 
52
  db     'MENUET01'
52
  db     'MENUET01'
53
  dd     0x01
53
  dd     0x01
54
  dd     START
54
  dd     START
55
  dd     I_END
55
  dd     I_END
56
  dd     0x2000  ; 8 Kb
56
  dd     0x2000  ; 8 Kb
57
  dd     0x2000
57
  dd     0x2000
58
  dd     0x0
58
  dd     0x0
59
  dd     0x0
59
  dd     0x0
60
 
60
 
61
 
61
 
62
START:
62
START:
63
    mov  [cptr],CONF_COUNT  ; number of task
63
    mov  [cptr],CONF_COUNT  ; number of task
64
    mov  eax,3
64
    mov  eax,3
65
    mcall
65
    mcall
66
    mov  cl,16
66
    mov  cl,16
67
    ror  eax,cl
67
    ror  eax,cl
68
    mov  [generator],eax    ; random generator from Tetris
68
    mov  [generator],eax    ; random generator from Tetris
69
  init:
69
  init:
70
    mov  ecx,17
70
    mov  ecx,17
71
    movzx  eax,[cptr]
71
    movzx  eax,[cptr]
72
    inc  eax
72
    inc  eax
73
    cmp  eax,CONF_COUNT
73
    cmp  eax,CONF_COUNT
74
    jna  init_ok
74
    jna  init_ok
75
    xor  eax,eax            ; cycling 0..CONF_COUNT
75
    xor  eax,eax            ; cycling 0..CONF_COUNT
76
  init_ok:
76
  init_ok:
77
    mov  [cptr],al
77
    mov  [cptr],al
78
    mov  esi,eax
78
    mov  esi,eax
79
    shl  esi,4
79
    shl  esi,4
80
    add  esi,conf
80
    add  esi,conf
81
    add  esi,eax
81
    add  esi,eax
82
    add  al,0x31
82
    add  al,0x31
83
    mov  [lenTitle-1],al     ;task number to program title
83
    mov  [txtTitle+17],al     ;task number to program title
84
    mov  [task],esi
84
    mov  [task],esi
85
    mov  edi,curconf
85
    mov  edi,curconf
86
    rep  movsb          ; initial configuration
86
    rep  movsb          ; initial configuration
87
 
87
 
88
    mov  [sts],4
88
    mov  [sts],4
89
    jmp  red
89
    jmp  red
90
SHUF:
90
SHUF:
91
    call shuffle        ; immediate shuffle
91
    call shuffle        ; immediate shuffle
92
red:                    ; window redraw
92
red:                    ; window redraw
93
 
93
 
94
    call draw_window
94
    call draw_window
95
 
95
 
96
still:                  ; MAIN PROGRAM CYCLE
96
still:                  ; MAIN PROGRAM CYCLE
97
 
97
 
98
    mov  eax,10         ; wait for event
98
    mov  eax,10         ; wait for event
99
    mcall
99
    mcall
100
 
100
 
101
    cmp  eax,1          ; redraw? -
101
    cmp  eax,1          ; redraw? -
102
    je   red            ; goto red
102
    je   red            ; goto red
103
    cmp  eax,2          ; key pressed? -
103
    cmp  eax,2          ; key pressed? -
104
    je   key            ; goto key
104
    je   key            ; goto key
105
    cmp  eax,3          ; button pressed? -
105
    cmp  eax,3          ; button pressed? -
106
    je   button         ; goto button
106
    je   button         ; goto button
107
 
107
 
108
    jmp  still          ; no more events to process
108
    jmp  still          ; no more events to process
109
 
109
 
110
  key:                  ; Key pressed
110
  key:                  ; Key pressed
111
    mov  eax,2
111
    mov  eax,2
112
    mcall
112
    mcall
113
    shr  eax,8
113
    shr  eax,8
114
    cmp  eax,32         ;  = Shuffle
114
    cmp  eax,32         ;  = Shuffle
115
    je   SHUF
115
    je   SHUF
116
    cmp  eax,13         ;  = Choose task
116
    cmp  eax,13         ;  = Choose task
117
    je   init
117
    je   init
118
    cmp  eax,176
118
    cmp  eax,176
119
    jl   still
119
    jl   still
120
    sub  eax,176
120
    sub  eax,176
121
    cmp  eax,3
121
    cmp  eax,3
122
    ja   still
122
    ja   still
123
    movzx eax,byte [eax+correct] ; 'delta' value from correct[]
123
    movzx eax,byte [eax+correct] ; 'delta' value from correct[]
124
    jmp  m_check
124
    jmp  m_check
125
 
125
 
126
  button:              ; Button pressed
126
  button:              ; Button pressed
127
    mov  eax,17
127
    mov  eax,17
128
    mcall
128
    mcall
129
    shr  eax,8
129
    shr  eax,8
130
    sub  eax,2
130
    sub  eax,2
131
 
131
 
132
    cmp  eax,-1        ; id == 1 (closeme)?
132
    cmp  eax,-1        ; id == 1 (closeme)?
133
    jne  noclose
133
    jne  noclose
134
    mcall
134
    mcall
135
 
135
 
136
  noclose:
136
  noclose:
137
    jl   SHUF          ; Shuffle (id=0) pressed
137
    jl   SHUF          ; Shuffle (id=0) pressed
138
    cmp  eax,18
138
    cmp  eax,18
139
    je   init          ; Conf button pressed
139
    je   init          ; Conf button pressed
140
    sub  al,byte [null]
140
    sub  al,byte [null]
141
    mov  edi,correct
141
    mov  edi,correct
142
    mov  ecx,4
142
    mov  ecx,4
143
    repne scasb        ; checking for valid move-part 1
143
    repne scasb        ; checking for valid move-part 1
144
    jne  fail
144
    jne  fail
145
  m_check:
145
  m_check:
146
    cmp  byte[sts],4 ; puzzle completed, blocking buttons
146
    cmp  byte[sts],4 ; puzzle completed, blocking buttons
147
    ja   still
147
    ja   still
148
    call move_check    ; checking for valid move-part 2
148
    call move_check    ; checking for valid move-part 2
149
    jnc  fail
149
    jnc  fail
150
    inc  [move_count]
150
    inc  [move_count]
151
    call draw_moves
151
    call draw_moves
152
fail:
152
fail:
153
    jmp  still          ; ¢®§¢à é ¥¬áï
153
    jmp  still          ; ¢®§¢à é ¥¬áï
154
 
154
 
155
;   *******************************
155
;   *******************************
156
;   *******  WINDOW DRAWING *******
156
;   *******  WINDOW DRAWING *******
157
;   *******************************
157
;   *******************************
158
 
158
 
159
draw_window:
159
draw_window:
160
    mov  eax,12
-
 
161
    mov  ebx,1                     ; begin draw
-
 
162
    mcall
-
 
163
 
160
                  
164
                                   ; CREATING WINDOW
-
 
165
    mov  eax,0
-
 
166
    mov  ebx,XXwindow
-
 
167
    mov  ecx,YYwindow
161
    mcall 12, 1 ; begin draw
168
    mov  edx,BgdColor
162
	mcall 0, XXwindow, YYwindow, BgdColor,, txtTitle ; CREATING WINDOW
169
    mov  esi,0x805080d0
-
 
170
    mov  edi,0x005080d0
-
 
171
    mcall
-
 
172
 
-
 
173
                                   ; PROGRAM TITLE
-
 
174
    mov  eax,4
-
 
175
    mov  ebx,8*65536+8
-
 
176
    mov  ecx,0x10000000
-
 
177
    mov  edx,txtTitle
-
 
178
    mov  esi,lenTitle-txtTitle
-
 
179
    mcall
163
 
180
 
164
 
181
    mov  eax,8                     ; SHUFFLE BUTTON
165
    mov  eax,8                     ; SHUFFLE BUTTON
182
    mov  ebx,XXSh
166
    mov  ebx,XXSh
183
    mov  ecx,YYSh
167
    mov  ecx,YYSh
184
    xor  edx,edx
168
    xor  edx,edx
185
    mov  esi,BtnColor
169
    mov  esi,BtnColor
186
    mcall
170
    mcall
187
 
171
 
188
    mov  ebx,XXCnf                  ; CONF BUTTON
172
    mov  ebx,XXCnf                  ; CONF BUTTON
189
    mov  ecx,YYCnf
173
    mov  ecx,YYCnf
190
    mov  edx,20
174
    mov  edx,20
191
    mov  esi,BtnColor
175
    ;mov  esi,BtnColor
192
    mcall
176
    mcall
193
 
177
 
194
    mov  ebx, XYShText             ; SHUFFLE TEXT
178
    mov  ebx, XYShText             ; SHUFFLE TEXT
195
    mov  ecx, StatusColor
179
    mov  ecx, StatusColor
196
    mov  edx,txtSh
180
    mov  edx,txtSh
197
    mov  esi,lenSh-txtSh
181
    mov  esi,lenSh-txtSh
198
    mov  eax,4
182
    mov  eax,4
199
    mcall
183
    mcall
200
 
184
 
201
    mov  ebx, XYCnfText             ; CONF TEXT
185
    mov  ebx, XYCnfText             ; CONF TEXT
202
    mov  edx,lenVictory-1
186
    mov  edx,lenVictory-1
203
    mov  esi,1
187
    mov  esi,1
204
    mcall
188
    mcall
205
 
189
 
206
    mov  ecx, 16                   ; FIELD BUTTONS
190
    mov  ecx, 16                   ; FIELD BUTTONS
207
  dbut:
191
  dbut:
208
    call draw_button
192
    call draw_button
209
    loop dbut
193
    loop dbut
210
 
194
 
211
    call draw_moves
195
    call draw_moves
212
 
-
 
213
    mov  eax,12
196
 
214
    mov  ebx,2                     ; end of drawing
-
 
215
    mcall
197
    mcall 12, 2 ; end of drawing
216
    ret
198
    ret
217
 
199
 
218
 
200
 
219
;   *********************************************
201
;   *********************************************
220
;   ******* DRAWING A FIELD BUTTON **************
202
;   ******* DRAWING A FIELD BUTTON **************
221
;   *********************************************
203
;   *********************************************
222
;   ECX - button number
204
;   ECX - button number
223
 
205
 
224
draw_button:
206
draw_button:
225
    pusha
207
    pusha
226
    dec  ecx
208
    dec  ecx
227
  ; calculating button dimensions
209
  ; calculating button dimensions
228
    mov  edi, ecx
210
    mov  edi, ecx
229
    lea  edx,[ecx+2]
211
    lea  edx,[ecx+2]
230
    mov  ebx,ecx
212
    mov  ebx,ecx
231
    and  ebx,11b
213
    and  ebx,11b
232
    shr  ecx,2
214
    shr  ecx,2
233
 
215
 
234
    imul ebx,BtnSize+3
216
    imul ebx,BtnSize+3
235
    add  ebx,BtnLeft
217
    add  ebx,BtnLeft
236
    shl  ebx,16
218
    shl  ebx,16
237
    add  ebx,BtnSize
219
    add  ebx,BtnSize
238
 
220
 
239
    imul ecx,BtnSize+3
221
    imul ecx,BtnSize+3
240
    add  ecx,BtnTop
222
    add  ecx,BtnTop
241
    shl  ecx,16
223
    shl  ecx,16
242
    add  ecx,BtnSize
224
    add  ecx,BtnSize
243
    movzx eax,byte [null]
225
    movzx eax,byte [null]
244
    cmp  eax,edi
226
    cmp  eax,edi
245
    jne   no_hole
227
    jne   no_hole
246
 
228
 
247
    pusha
229
    pusha
248
    inc  ebx
230
    inc  ebx
249
    inc  ecx
231
    inc  ecx
250
    mov  edx,BgdColor
232
    mov  edx,BgdColor
251
    mov  eax,13         ; clearing - 'hole'
233
    mov  eax,13         ; clearing - 'hole'
252
    mcall
234
    mcall
253
    popa
235
    popa
254
 
236
 
255
    or   edx,0x80000000 ; and removing button under it
237
    or   edx,0x80000000 ; and removing button under it
256
no_hole:
238
no_hole:
257
    mov  al,byte[edi+curconf]
239
    mov  al,byte[edi+curconf]
258
    mov  esi,[task]
240
    mov  esi,[task]
259
    cmp  al,byte[edi+esi]
241
    cmp  al,byte[edi+esi]
260
    je   highlight
242
    je   highlight
261
    mov  esi,BtnColor
243
    mov  esi,BtnColor
262
    jmp  s_rbutton
244
    jmp  s_rbutton
263
highlight:
245
highlight:
264
    mov  esi,BtnColor2
246
    mov  esi,BtnColor2
265
s_rbutton:
247
s_rbutton:
266
    mov  eax,8          ; set/remove button
248
    mov  eax,8          ; set/remove button
267
    mcall
249
    mcall
268
    movzx eax,byte [null]
250
    movzx eax,byte [null]
269
    cmp  eax,edi
251
    cmp  eax,edi
270
    je   no_text        ; no digits - that's hole
252
    je   no_text        ; no digits - that's hole
271
    mov  edx,ebx
253
    mov  edx,ebx
272
    shr  ecx,16
254
    shr  ecx,16
273
    mov  dx,cx
255
    mov  dx,cx
274
    add  edx,NumShift
256
    add  edx,NumShift
275
    mov  ebx,0x20000
257
    mov  ebx,0x20000
276
    movzx  ecx,byte [edi+curconf]
258
    movzx  ecx,byte [edi+curconf]
277
    cmp  ecx,9
259
    cmp  ecx,9
278
    ja   two_num
260
    ja   two_num
279
    add  edx,NumShift2    ; shift to center digits
261
    add  edx,NumShift2    ; shift to center digits
280
    sub  ebx,0x10000
262
    sub  ebx,0x10000
281
two_num:
263
two_num:
282
    mov  esi,NumColor
264
    mov  esi,NumColor
283
    mov  eax,47
265
    mov  eax,47
284
    mcall
266
    mcall
285
no_text:
267
no_text:
286
    popa
268
    popa
287
    ret
269
    ret
288
 
270
 
289
 
271
 
290
;   *********************************************
272
;   *********************************************
291
;   ******* DRAWING STATUS LINE *****************
273
;   ******* DRAWING STATUS LINE *****************
292
;   *********************************************
274
;   *********************************************
293
 
275
 
294
draw_moves:
276
draw_moves:
295
    mov  eax, 13          ; clear area
277
    mov  eax, 13          ; clear area
296
    mov  ebx, XXbar
278
    mov  ebx, XXbar
297
    mov  ecx, YYbar
279
    mov  ecx, YYbar
298
    mov  edx, BgdColor
280
    mov  edx, BgdColor
299
    mcall
281
    mcall
300
 
282
 
301
    mov  eax, 4
283
    mov  eax, 4
302
    mov  ebx, XYstatus
284
    mov  ebx, XYstatus
303
    mov  ecx, StatusColor
285
    mov  ecx, StatusColor
304
    cmp  ax, [sts]
286
    cmp  ax, [sts]
305
    jl   report_victory
287
    jl   report_victory
306
    jne  report_moves
288
    jne  report_moves
307
    mov  edx,txtCnf  ; prompt to choose configuration
289
    mov  edx,txtCnf  ; prompt to choose configuration
308
    mov  esi,lenCnf-txtCnf
290
    mov  esi,lenCnf-txtCnf
309
    jmp  e_dm
291
    jmp  e_dm
310
  report_moves:
292
  report_moves:
311
    mov  edx,txtMoves  ; how many moves done
293
    mov  edx,txtMoves  ; how many moves done
312
    mov  esi,lenMoves-txtMoves
294
    mov  esi,lenMoves-txtMoves
313
    mov  eax,4
295
    mov  eax,4
314
    mcall
296
    mcall
315
    mov  esi,ecx
297
    mov  esi,ecx
316
    mov  edx,ebx
298
    mov  edx,ebx
317
    add  edx, 40 shl 16
299
    add  edx, 40 shl 16
318
    mov  ebx,0x030000
300
    mov  ebx,0x030000
319
    movzx  ecx, byte[move_count]
301
    movzx  ecx, byte[move_count]
320
    mov  eax,47
302
    mov  eax,47
321
    jmp  e_dm
303
    jmp  e_dm
322
  report_victory:               ; puzzle completed
304
  report_victory:               ; puzzle completed
323
    mov  ecx,StatusColor2
305
    mov  ecx,StatusColor2
324
    mov  edx,txtVictory
306
    mov  edx,txtVictory
325
    mov  esi,lenVictory-txtVictory
307
    mov  esi,lenVictory-txtVictory
326
  e_dm:
308
  e_dm:
327
    mcall
309
    mcall
328
    ret
310
    ret
329
 
311
 
330
 
312
 
331
;   *********************************************
313
;   *********************************************
332
;   ********* SHUFFLE ***************************
314
;   ********* SHUFFLE ***************************
333
;   *********************************************
315
;   *********************************************
334
 
316
 
335
shuffle:
317
shuffle:
336
    xor  eax,eax
318
    xor  eax,eax
337
    mov  [sts],ax
319
    mov  [sts],ax
338
    mov  [move_count],ax   ; reset moves to 0
320
    mov  [move_count],ax   ; reset moves to 0
339
    mov  [sh_off],al
321
    mov  [sh_off],al
340
    mov  eax, [generator]
322
    mov  eax, [generator]
341
 
323
 
342
    mov  ecx,SH_CYCLES
324
    mov  ecx,SH_CYCLES
343
 sh_cycle:
325
 sh_cycle:
344
    sub  eax,0x43ab45b5    ; next random number
326
    sub  eax,0x43ab45b5    ; next random number
345
    ror  eax,1
327
    ror  eax,1
346
    xor  eax,0x32c4324f
328
    xor  eax,0x32c4324f
347
    ror  eax,1
329
    ror  eax,1
348
    mov  [generator],eax
330
    mov  [generator],eax
349
 
331
 
350
    push eax
332
    push eax
351
    and  eax,11b           ; direction 0..3
333
    and  eax,11b           ; direction 0..3
352
    movzx eax,byte [eax+correct]
334
    movzx eax,byte [eax+correct]
353
    call move_check
335
    call move_check
354
    pop  eax
336
    pop  eax
355
    jnc  sh_cycle          ; if fails then retry
337
    jnc  sh_cycle          ; if fails then retry
356
    loop sh_cycle
338
    loop sh_cycle
357
    inc  byte[sh_off]          ; shuffling complete
339
    inc  byte[sh_off]          ; shuffling complete
358
    ret
340
    ret
359
 
341
 
360
 
342
 
361
;   *********************************************
343
;   *********************************************
362
;   ********* MOVE VALIDITY CHECK ***************
344
;   ********* MOVE VALIDITY CHECK ***************
363
;   *********************************************
345
;   *********************************************
364
;   AL - 'DELTA' DIRECTION
346
;   AL - 'DELTA' DIRECTION
365
 
347
 
366
move_check:
348
move_check:
367
    pusha
349
    pusha
368
    mov  ah,byte [null]
350
    mov  ah,byte [null]
369
    mov  bx,ax
351
    mov  bx,ax
370
    cmp  bh,3
352
    cmp  bh,3
371
    ja   no_top
353
    ja   no_top
372
    cmp  al,-4       ; top of field
354
    cmp  al,-4       ; top of field
373
    je   no_move
355
    je   no_move
374
no_top:
356
no_top:
375
    cmp  bh,12
357
    cmp  bh,12
376
    jb   no_bottom
358
    jb   no_bottom
377
    cmp  al,4        ; bottom of field
359
    cmp  al,4        ; bottom of field
378
    je   no_move
360
    je   no_move
379
no_bottom:
361
no_bottom:
380
    and  bh,11b
362
    and  bh,11b
381
    cmp  bh,0
363
    cmp  bh,0
382
    jnz  no_left
364
    jnz  no_left
383
    cmp  al,-1       ; left of field
365
    cmp  al,-1       ; left of field
384
    je  no_move
366
    je  no_move
385
no_left:
367
no_left:
386
    cmp  bh,11b
368
    cmp  bh,11b
387
    jnz  ok
369
    jnz  ok
388
    cmp  al,1        ; right of field
370
    cmp  al,1        ; right of field
389
    je  no_move
371
    je  no_move
390
ok:
372
ok:
391
    mov bx,ax
373
    mov bx,ax
392
    add bh,bl        ; bh-new hole
374
    add bh,bl        ; bh-new hole
393
    mov byte [null],bh
375
    mov byte [null],bh
394
    movzx ecx,ah
376
    movzx ecx,ah
395
    mov al,byte[ecx+curconf]
377
    mov al,byte[ecx+curconf]
396
    movzx edx,bh
378
    movzx edx,bh
397
    mov bl,byte[edx+curconf] ; swapping button & hole
379
    mov bl,byte[edx+curconf] ; swapping button & hole
398
    mov byte[ecx+curconf],bl
380
    mov byte[ecx+curconf],bl
399
    mov byte[edx+curconf],al
381
    mov byte[edx+curconf],al
400
 
382
 
401
    cmp  byte[sh_off],0  ; if shuffle in progress,
383
    cmp  byte[sh_off],0  ; if shuffle in progress,
402
    jz   no_win      ; then no redraw
384
    jz   no_win      ; then no redraw
403
 
385
 
404
  ; drawing button & hole
386
  ; drawing button & hole
405
    inc  ecx
387
    inc  ecx
406
    call draw_button
388
    call draw_button
407
    movzx ecx,bh
389
    movzx ecx,bh
408
    inc  ecx
390
    inc  ecx
409
    call draw_button
391
    call draw_button
410
  ; testing if task completed
392
  ; testing if task completed
411
    mov  esi,[task]
393
    mov  esi,[task]
412
    mov  edi,curconf
394
    mov  edi,curconf
413
    mov  ecx,16
395
    mov  ecx,16
414
    repe cmpsb
396
    repe cmpsb
415
    cmp  ecx,0
397
    cmp  ecx,0
416
    jne  no_win
398
    jne  no_win
417
    mov  word[sts],6  ; puzzle done. Victory!
399
    mov  word[sts],6  ; puzzle done. Victory!
418
no_win:
400
no_win:
419
    popa
401
    popa
420
    stc
402
    stc
421
    ret
403
    ret
422
no_move:
404
no_move:
423
    popa
405
    popa
424
    clc
406
    clc
425
    ret
407
    ret
426
; this is deprecated debug routine
408
; this is deprecated debug routine
427
;ud:
409
;ud:
428
;    ud2
410
;    ud2
429
 
411
 
430
; These are data used by program
412
; These are data used by program
431
 
413
 
432
correct db 1,-4,4,-1
414
correct db 1,-4,4,-1
433
 
415
 
434
conf db 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,15
416
conf db 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,15
435
     db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0
417
     db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0
436
     db 1,2,3,4,12,13,14,5,11,0,15,6,10,9,8,7,9
418
     db 1,2,3,4,12,13,14,5,11,0,15,6,10,9,8,7,9
437
 
419
 
438
txtMoves:
420
txtMoves:
439
if lang eq ru
421
if lang eq ru
440
     db '•®¤®¢:'
422
     db '•®¤®¢:'
441
else
423
else
442
     db 'Moves:'
424
     db 'Moves:'
443
end if
425
end if
444
lenMoves:
426
lenMoves:
445
 
427
 
446
txtSh:
428
txtSh:
447
if lang eq ru
429
if lang eq ru
448
     db '’ á®¢ª '
430
     db '’ á®¢ª '
449
else
431
else
450
     db 'Shuffle'
432
     db 'Shuffle'
451
end if
433
end if
452
lenSh:
434
lenSh:
453
 
435
 
454
txtCnf:
436
txtCnf:
455
if lang eq ru
437
if lang eq ru
456
     db '‚ë¡¥à¨â¥ § ¤ çã ¨ ­ ¦¬¨â¥->'
438
     db '‚ë¡¥à¨â¥ § ¤ çã ¨ ­ ¦¬¨â¥->'
457
else
439
else
458
     db 'Select task,  then press ->'
440
     db 'Select task,  then press ->'
459
end if
441
end if
460
lenCnf:
442
lenCnf:
461
 
443
 
462
txtTitle:               ; áâப  § £®«®¢ª 
444
txtTitle:              ; áâப  § £®«®¢ª 
463
if lang eq ru
445
if lang eq ru
464
     db   'ˆ£à  15 - § ¤ ç  X'
446
     db   'ˆ£à  15 - § ¤ ç  X', 0
465
else
447
else
466
     db   'Game 15 - puzzle X'
448
     db   'Game 15 - puzzle X', 0
467
end if
-
 
468
lenTitle:                ; ¨ ¥ñ ª®­¥æ
449
end if
469
 
450
 
470
txtVictory:
451
txtVictory:
471
if lang eq ru
452
if lang eq ru
472
     db '‚ë à¥è¨«¨ § ¤ çã!  ¦¬¨â¥->'
453
     db '‚ë à¥è¨«¨ § ¤ çã!  ¦¬¨â¥->'
473
else
454
else
474
     db 'Puzzle completed!   Press->'
455
     db 'Puzzle completed!   Press->'
475
end if
456
end if
476
lenVictory:
457
lenVictory:
477
 
458
 
478
arrow equ lenVictory-2
459
arrow equ lenVictory-2
479
 
460
 
480
I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
461
I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
481
;null db ?
462
;null db ?
482
move_count dw ?
463
move_count dw ?
483
cptr db ?
464
cptr db ?
484
sts dw ?
465
sts dw ?
485
sh_off db ?
466
sh_off db ?
486
task dd ?
467
task dd ?
487
generator dd ?
468
generator dd ?
488
curconf:
469
curconf: