Subversion Repositories Kolibri OS

Rev

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

Rev 1728 Rev 2067
1
; <--- description --->
1
; <--- description --->
2
; compiler:     FASM 1.50
2
; compiler:     FASM 1.50
3
; name:         FreeCell for MeOS
3
; name:         FreeCell for MeOS
4
; version:      1.00
4
; version:      1.00
5
; last update:  21/07/2004
5
; last update:  21/07/2004
6
; written by:   Alexandr Gorbovets
6
; written by:   Alexandr Gorbovets
7
; e-mail:       gorsash@mail.ru
7
; e-mail:       gorsash@mail.ru
8
 
8
 
9
 
9
 
10
include "macros.inc"
10
include "../../macros.inc"
11
include "lang.inc"
11
include "lang.inc"
12
meos_app_start
12
meos_app_start
13
 
13
 
14
code
14
code
15
   call    randomize
15
   call    randomize
16
   call    draw_window
16
   call    draw_window
17
 
17
 
18
  wait_event:
18
  wait_event:
19
    mov     eax, 10
19
    mov     eax, 10
20
    mcall
20
    mcall
21
 
21
 
22
    cmp     eax, 1           ;   if event == 1
22
    cmp     eax, 1           ;   if event == 1
23
    je      redraw           ;     jump to redraw handler
23
    je      redraw           ;     jump to redraw handler
24
    cmp     eax, 2           ;   else if event == 2
24
    cmp     eax, 2           ;   else if event == 2
25
    je      key              ;     jump to key handler
25
    je      key              ;     jump to key handler
26
    cmp     eax, 3           ;   else if event == 3
26
    cmp     eax, 3           ;   else if event == 3
27
    je      button           ;     jump to button handler
27
    je      button           ;     jump to button handler
28
 
28
 
29
 
29
 
30
    jmp     wait_event  ;else return to the start of main cycle
30
    jmp     wait_event  ;else return to the start of main cycle
31
 
31
 
32
 
32
 
33
  redraw:                    ; redraw event handler
33
  redraw:                    ; redraw event handler
34
    call    draw_window
34
    call    draw_window
35
    jmp     wait_event
35
    jmp     wait_event
36
 
36
 
37
 
37
 
38
  key:                       ; key event handler
38
  key:                       ; key event handler
39
    mov     eax, 2           ;   get key code
39
    mov     eax, 2           ;   get key code
40
    mcall
40
    mcall
41
 
41
 
42
    jmp     wait_event
42
    jmp     wait_event
43
 
43
 
44
  button:                    ; button event handler
44
  button:                    ; button event handler
45
    mov     eax, 17          ;   get button identifier
45
    mov     eax, 17          ;   get button identifier
46
    mcall
46
    mcall
47
 
47
 
48
    cmp     ah, 1
48
    cmp     ah, 1
49
    je      exit_app         ;   return if button id != 1
49
    je      exit_app         ;   return if button id != 1
50
 
50
 
51
    cmp     ah, 1 + 8
51
    cmp     ah, 1 + 8
52
    jbe     common_card      ;   if 1 < ah <= 9
52
    jbe     common_card      ;   if 1 < ah <= 9
53
 
53
 
54
    cmp     ah, 1 + 8 + 4    ;   if 9 < ah <= 13
54
    cmp     ah, 1 + 8 + 4    ;   if 9 < ah <= 13
55
    jbe     temp_cell
55
    jbe     temp_cell
56
 
56
 
57
    cmp     ah, 1 + 8 + 8
57
    cmp     ah, 1 + 8 + 8
58
    jbe     home_cell
58
    jbe     home_cell
59
 
59
 
60
    cmp     ah, 1 + 8 + 4 + 4 + 1
60
    cmp     ah, 1 + 8 + 4 + 4 + 1
61
    je      new_game_button
61
    je      new_game_button
62
 
62
 
63
    cmp     ah, 1 + 8 + 4 + 4 + 2
63
    cmp     ah, 1 + 8 + 4 + 4 + 2
64
    je      exit_app
64
    je      exit_app
65
 
65
 
66
 
66
 
67
    jmp     wait_event
67
    jmp     wait_event
68
 
68
 
69
 
69
 
70
  exit_app:
70
  exit_app:
71
    mov     eax, -1          ;   exit application
71
    mov     eax, -1          ;   exit application
72
    mcall
72
    mcall
73
 
73
 
74
  common_card:
74
  common_card:
75
    sub     ah, 2            ;going from number of card to number of column
75
    sub     ah, 2            ;going from number of card to number of column
76
    mov     [columnclicked], 0
76
    mov     [columnclicked], 0
77
    mov     byte [columnclicked], ah
77
    mov     byte [columnclicked], ah
78
    call    common_card_click
78
    call    common_card_click
79
    jmp     wait_event
79
    jmp     wait_event
80
 
80
 
81
  temp_cell:
81
  temp_cell:
82
    sub     ah, 2 + 8
82
    sub     ah, 2 + 8
83
    mov     [columnclicked], 0
83
    mov     [columnclicked], 0
84
    mov     byte [columnclicked], ah
84
    mov     byte [columnclicked], ah
85
    call    temp_cell_click
85
    call    temp_cell_click
86
    jmp     wait_event
86
    jmp     wait_event
87
 
87
 
88
 
88
 
89
  home_cell:
89
  home_cell:
90
    sub    ah, 2 + 8 + 4
90
    sub    ah, 2 + 8 + 4
91
    mov    [columnclicked], 0
91
    mov    [columnclicked], 0
92
    mov    byte [columnclicked], ah
92
    mov    byte [columnclicked], ah
93
    call   home_cell_click
93
    call   home_cell_click
94
    jmp    wait_event
94
    jmp    wait_event
95
 
95
 
96
  new_game_button:
96
  new_game_button:
97
    call   new_game_click
97
    call   new_game_click
98
    jmp    wait_event
98
    jmp    wait_event
99
 
99
 
100
 
100
 
101
;******************************************************************************
101
;******************************************************************************
102
;                            common_card_click(columnclicked)
102
;                            common_card_click(columnclicked)
103
  common_card_click:
103
  common_card_click:
104
 
104
 
105
                             ; counting code of card, that has been clicked
105
                             ; counting code of card, that has been clicked
106
    mov    eax, [columnclicked]
106
    mov    eax, [columnclicked]
107
    mov    [ncolumn], eax
107
    mov    [ncolumn], eax
108
    call   get_row_of_top_card_in_column
108
    call   get_row_of_top_card_in_column
109
    mov    eax, [topcardrow]  ; eax = topcardrow * 8 + columnofselcard
109
    mov    eax, [topcardrow]  ; eax = topcardrow * 8 + columnofselcard
110
    mov    bl, 8
110
    mov    bl, 8
111
    mul    bl
111
    mul    bl
112
    add    eax, [columnclicked]
112
    add    eax, [columnclicked]
113
    add    eax, cards
113
    add    eax, cards
114
 
114
 
115
    mov    ebx, 0
115
    mov    ebx, 0
116
    mov    bl, byte [eax]
116
    mov    bl, byte [eax]
117
    mov    [cardclicked], ebx
117
    mov    [cardclicked], ebx
118
 
118
 
119
 
119
 
120
    call   get_sel_card_code_and_addr
120
    call   get_sel_card_code_and_addr
121
 
121
 
122
    cmp    [selcardcode], 52
122
    cmp    [selcardcode], 52
123
    jb      .something_selected
123
    jb      .something_selected
124
 
124
 
125
 
125
 
126
    cmp    [cardclicked], 52
126
    cmp    [cardclicked], 52
127
    je      .end
127
    je      .end
128
 
128
 
129
    mov    [whereisselcard], scCommonCells
129
    mov    [whereisselcard], scCommonCells
130
    mov    eax, [columnclicked]
130
    mov    eax, [columnclicked]
131
    mov    [columnofselcard], eax
131
    mov    [columnofselcard], eax
132
    call   draw_window
132
    call   draw_window
133
    jmp    .end
133
    jmp    .end
134
 
134
 
135
 
135
 
136
    .something_selected:
136
    .something_selected:
137
 
137
 
138
 
138
 
139
             ; checking if selected and clicked cards are equivalent
139
             ; checking if selected and clicked cards are equivalent
140
      mov     eax, [selcardcode]
140
      mov     eax, [selcardcode]
141
      cmp     [cardclicked], eax
141
      cmp     [cardclicked], eax
142
      jne     .not_same_card
142
      jne     .not_same_card
143
 
143
 
144
      mov     [whereisselcard], scNotSelected
144
      mov     [whereisselcard], scNotSelected
145
      call    draw_window
145
      call    draw_window
146
      jmp     .end
146
      jmp     .end
147
 
147
 
148
    .not_same_card:
148
    .not_same_card:
149
 
149
 
150
      cmp     [cardclicked], 52
150
      cmp     [cardclicked], 52
151
      jae     .put_in_blank_cell
151
      jae     .put_in_blank_cell
152
 
152
 
153
 
153
 
154
      mov     eax, [selcardcode]
154
      mov     eax, [selcardcode]
155
      mov     bl, 4
155
      mov     bl, 4
156
      div     bl
156
      div     bl
157
 
157
 
158
      mov     ebx, 0
158
      mov     ebx, 0
159
      mov     bl, ah
159
      mov     bl, ah
160
      mov     [cardfamily], ebx
160
      mov     [cardfamily], ebx
161
 
161
 
162
      mov     ecx, 0
162
      mov     ecx, 0
163
      mov     cl, al
163
      mov     cl, al
164
      mov     [cardrange], ecx
164
      mov     [cardrange], ecx
165
 
165
 
166
 
166
 
167
      mov     eax, [cardclicked]
167
      mov     eax, [cardclicked]
168
      mov     bl, 4
168
      mov     bl, 4
169
      div     bl                     ; reminder in ah, quotient in al
169
      div     bl                     ; reminder in ah, quotient in al
170
 
170
 
171
      mov     ebx, 0
171
      mov     ebx, 0
172
      mov     bl, ah
172
      mov     bl, ah
173
      mov     [clickedcardfamily], ebx
173
      mov     [clickedcardfamily], ebx
174
 
174
 
175
      mov     ecx, 0
175
      mov     ecx, 0
176
      mov     cl, al
176
      mov     cl, al
177
      mov     [clickedcardrange], ecx
177
      mov     [clickedcardrange], ecx
178
 
178
 
179
                             ; clickedcardrange must be = cardrange + 1
179
                             ; clickedcardrange must be = cardrange + 1
180
      mov     eax, [cardrange]
180
      mov     eax, [cardrange]
181
      inc     eax
181
      inc     eax
182
 
182
 
183
      cmp     [clickedcardrange], eax ; eax is such as needed
183
      cmp     [clickedcardrange], eax ; eax is such as needed
184
      jne     .end
184
      jne     .end
185
 
185
 
186
 
186
 
187
      cmp     [cardfamily], 1
187
      cmp     [cardfamily], 1
188
      ja             .black_card
188
      ja             .black_card
189
 
189
 
190
                             ; if selected red card
190
                             ; if selected red card
191
      cmp     [clickedcardfamily], 1
191
      cmp     [clickedcardfamily], 1
192
      jbe     .end             ; if clicked red card (range <= 1) then exit
192
      jbe     .end             ; if clicked red card (range <= 1) then exit
193
 
193
 
194
      jmp     .valid_cards
194
      jmp     .valid_cards
195
 
195
 
196
    .black_card:
196
    .black_card:
197
                             ; if selected black card
197
                             ; if selected black card
198
      cmp     [clickedcardfamily], 1
198
      cmp     [clickedcardfamily], 1
199
      ja      .end             ; if clicked black card then exit
199
      ja      .end             ; if clicked black card then exit
200
 
200
 
201
      jmp     .valid_cards
201
      jmp     .valid_cards
202
 
202
 
203
    .valid_cards:
203
    .valid_cards:
204
                      ; moving card from its place on clicked card
204
                      ; moving card from its place on clicked card
205
 
205
 
206
      mov     eax, [columnclicked]
206
      mov     eax, [columnclicked]
207
      mov     [ncolumn], eax
207
      mov     [ncolumn], eax
208
      call    get_row_of_top_card_in_column
208
      call    get_row_of_top_card_in_column
209
      mov     eax, [topcardrow]
209
      mov     eax, [topcardrow]
210
      inc     eax
210
      inc     eax
211
 
211
 
212
      mov     bl, 8
212
      mov     bl, 8
213
      mul     bl
213
      mul     bl
214
 
214
 
215
      and     eax, $0000FFFF
215
      and     eax, $0000FFFF
216
      add     eax, [columnclicked]
216
      add     eax, [columnclicked]
217
      add     eax, cards
217
      add     eax, cards
218
 
218
 
219
      mov     bl, byte [selcardcode]
219
      mov     bl, byte [selcardcode]
220
      mov     byte [eax], bl
220
      mov     byte [eax], bl
221
 
221
 
222
      mov     eax, [selcardaddr]
222
      mov     eax, [selcardaddr]
223
      mov     byte [eax], 52
223
      mov     byte [eax], 52
224
 
224
 
225
      mov     [whereisselcard], scNotSelected
225
      mov     [whereisselcard], scNotSelected
226
 
226
 
227
      call    draw_window
227
      call    draw_window
228
 
228
 
229
      jmp     .end
229
      jmp     .end
230
 
230
 
231
      .put_in_blank_cell:
231
      .put_in_blank_cell:
232
 
232
 
233
      mov     eax, cards
233
      mov     eax, cards
234
      add     eax, [columnclicked]
234
      add     eax, [columnclicked]
235
      mov     bl,  byte [selcardcode]
235
      mov     bl,  byte [selcardcode]
236
      mov     byte [eax], bl
236
      mov     byte [eax], bl
237
 
237
 
238
      mov     eax, [selcardaddr]
238
      mov     eax, [selcardaddr]
239
      mov     byte [eax], 52
239
      mov     byte [eax], 52
240
 
240
 
241
      mov     [whereisselcard], scNotSelected
241
      mov     [whereisselcard], scNotSelected
242
 
242
 
243
      call    draw_window
243
      call    draw_window
244
 
244
 
245
    .end:
245
    .end:
246
 
246
 
247
  ret
247
  ret
248
 
248
 
249
 
249
 
250
;******************************************************************************
250
;******************************************************************************
251
;                            temp_cell_click(columnclicked)
251
;                            temp_cell_click(columnclicked)
252
  temp_cell_click:
252
  temp_cell_click:
253
    call   get_sel_card_code_and_addr
253
    call   get_sel_card_code_and_addr
254
    cmp    [selcardcode], 52
254
    cmp    [selcardcode], 52
255
    jb     .something_selected
255
    jb     .something_selected
256
 
256
 
257
 
257
 
258
    mov    [whereisselcard], scTempCells
258
    mov    [whereisselcard], scTempCells
259
    mov    eax, [columnclicked]
259
    mov    eax, [columnclicked]
260
    mov    [columnofselcard], eax
260
    mov    [columnofselcard], eax
261
    call   draw_window
261
    call   draw_window
262
    jmp    .end
262
    jmp    .end
263
 
263
 
264
    .something_selected:
264
    .something_selected:
265
                             ; checking if selected and clicked cards equivalent
265
                             ; checking if selected and clicked cards equivalent
266
    mov     eax, [columnclicked]
266
    mov     eax, [columnclicked]
267
    add     eax, tempcells
267
    add     eax, tempcells
268
 
268
 
269
    mov     ebx, 0
269
    mov     ebx, 0
270
    mov     bl, byte [eax]
270
    mov     bl, byte [eax]
271
    mov     [cardclicked], ebx
271
    mov     [cardclicked], ebx
272
 
272
 
273
    mov     eax, [selcardcode]
273
    mov     eax, [selcardcode]
274
    cmp     [cardclicked], eax
274
    cmp     [cardclicked], eax
275
    jne     .not_same_card
275
    jne     .not_same_card
276
 
276
 
277
    mov     [whereisselcard], scNotSelected
277
    mov     [whereisselcard], scNotSelected
278
    call    draw_window
278
    call    draw_window
279
 
279
 
280
    .not_same_card:
280
    .not_same_card:
281
 
281
 
282
                             ;putting cards in temp cells
282
                             ;putting cards in temp cells
283
 
283
 
284
    mov     eax, [columnclicked]
284
    mov     eax, [columnclicked]
285
    add     eax, tempcells
285
    add     eax, tempcells
286
 
286
 
287
    mov     ebx, 0
287
    mov     ebx, 0
288
    mov     bl, byte [eax]
288
    mov     bl, byte [eax]
289
    mov     [cardclicked], ebx
289
    mov     [cardclicked], ebx
290
 
290
 
291
 
291
 
292
    cmp     [cardclicked], 52
292
    cmp     [cardclicked], 52
293
    jb     .end
293
    jb     .end
294
                             ; if nothing lay in this cell
294
                             ; if nothing lay in this cell
295
                             ; move selected card to temp cell
295
                             ; move selected card to temp cell
296
    mov     eax, [columnclicked]
296
    mov     eax, [columnclicked]
297
    add     eax, tempcells
297
    add     eax, tempcells
298
    mov     bl, byte [selcardcode]
298
    mov     bl, byte [selcardcode]
299
    mov     byte [eax], bl
299
    mov     byte [eax], bl
300
 
300
 
301
    mov     eax, [selcardaddr]
301
    mov     eax, [selcardaddr]
302
    mov     byte [eax], 52
302
    mov     byte [eax], 52
303
 
303
 
304
    mov     [whereisselcard], scNotSelected
304
    mov     [whereisselcard], scNotSelected
305
 
305
 
306
    call    draw_window
306
    call    draw_window
307
 
307
 
308
 
308
 
309
    jmp     .end
309
    jmp     .end
310
 
310
 
311
 
311
 
312
    .end:
312
    .end:
313
 
313
 
314
  ret
314
  ret
315
 
315
 
316
;******************************************************************************
316
;******************************************************************************
317
;                            home_cell_click(column_clicked)
317
;                            home_cell_click(column_clicked)
318
  home_cell_click:
318
  home_cell_click:
319
    call    get_sel_card_code_and_addr
319
    call    get_sel_card_code_and_addr
320
 
320
 
321
    mov     eax, [columnclicked]
321
    mov     eax, [columnclicked]
322
    add     eax, homecells
322
    add     eax, homecells
323
 
323
 
324
 
324
 
325
    mov     ebx, 0
325
    mov     ebx, 0
326
    mov     bl, byte [eax]
326
    mov     bl, byte [eax]
327
    mov     [cardclicked], ebx
327
    mov     [cardclicked], ebx
328
 
328
 
329
    mov     eax, [selcardcode]
329
    mov     eax, [selcardcode]
330
    mov     bl, 4
330
    mov     bl, 4
331
    div     bl               ; reminder in ah, quotient in al
331
    div     bl               ; reminder in ah, quotient in al
332
 
332
 
333
    mov     ebx, 0
333
    mov     ebx, 0
334
    mov     bl, ah
334
    mov     bl, ah
335
    mov     [cardfamily], ebx
335
    mov     [cardfamily], ebx
336
 
336
 
337
    mov     ecx, 0
337
    mov     ecx, 0
338
    mov     cl, al
338
    mov     cl, al
339
    mov     [cardrange], ecx
339
    mov     [cardrange], ecx
340
 
340
 
341
 
341
 
342
    cmp     [cardclicked], 52
342
    cmp     [cardclicked], 52
343
    jb     .not_blank
343
    jb     .not_blank
344
                             ; if nothing lay in this cell
344
                             ; if nothing lay in this cell
345
    cmp     [cardrange], 0
345
    cmp     [cardrange], 0
346
    jne     .end
346
    jne     .end
347
                             ; move ace to home
347
                             ; move ace to home
348
    mov     eax, [columnclicked]
348
    mov     eax, [columnclicked]
349
    add     eax, homecells
349
    add     eax, homecells
350
    mov     bl, byte [selcardcode]
350
    mov     bl, byte [selcardcode]
351
    mov     byte [eax], bl
351
    mov     byte [eax], bl
352
 
352
 
353
    mov     eax, [selcardaddr]
353
    mov     eax, [selcardaddr]
354
    mov     byte [eax], 52
354
    mov     byte [eax], 52
355
 
355
 
356
    mov     [whereisselcard], scNotSelected
356
    mov     [whereisselcard], scNotSelected
357
 
357
 
358
    call    draw_window
358
    call    draw_window
359
 
359
 
360
 
360
 
361
    jmp     .end
361
    jmp     .end
362
 
362
 
363
    .not_blank:
363
    .not_blank:
364
 
364
 
365
    mov     eax, [cardclicked]
365
    mov     eax, [cardclicked]
366
    mov     bl, 4
366
    mov     bl, 4
367
    div     bl               ; reminder in ah, quotient in al
367
    div     bl               ; reminder in ah, quotient in al
368
 
368
 
369
    mov     ebx, 0
369
    mov     ebx, 0
370
    mov     bl, ah
370
    mov     bl, ah
371
    mov     [clickedcardfamily], ebx
371
    mov     [clickedcardfamily], ebx
372
 
372
 
373
    mov     ecx, 0
373
    mov     ecx, 0
374
    mov     cl, al
374
    mov     cl, al
375
    mov     [clickedcardrange], ecx
375
    mov     [clickedcardrange], ecx
376
 
376
 
377
    cmp     [cardfamily], ebx
377
    cmp     [cardfamily], ebx
378
    jne     .end
378
    jne     .end
379
 
379
 
380
    inc     ecx
380
    inc     ecx
381
    cmp     [cardrange], ecx
381
    cmp     [cardrange], ecx
382
    jne     .end
382
    jne     .end
383
 
383
 
384
                      ; moving card from its place to home with replacing
384
                      ; moving card from its place to home with replacing
385
                      ; of old card in home
385
                      ; of old card in home
386
    mov     eax, [columnclicked]
386
    mov     eax, [columnclicked]
387
    add     eax, homecells
387
    add     eax, homecells
388
    mov     bl, byte [selcardcode]
388
    mov     bl, byte [selcardcode]
389
    mov     byte [eax], bl
389
    mov     byte [eax], bl
390
 
390
 
391
    mov     eax, [selcardaddr]
391
    mov     eax, [selcardaddr]
392
    mov     byte [eax], 52
392
    mov     byte [eax], 52
393
 
393
 
394
    mov     [whereisselcard], scNotSelected
394
    mov     [whereisselcard], scNotSelected
395
 
395
 
396
    call    draw_window
396
    call    draw_window
397
 
397
 
398
 
398
 
399
 
399
 
400
    .end:
400
    .end:
401
 
401
 
402
  ret
402
  ret
403
 
403
 
404
 
404
 
405
;******************************************************************************
405
;******************************************************************************
406
  new_game_click:
406
  new_game_click:
407
 
407
 
408
      mov   [i], 0
408
      mov   [i], 0
409
    .deleting_cards_from_common_cells:
409
    .deleting_cards_from_common_cells:
410
      mov   eax, cards
410
      mov   eax, cards
411
      add   eax, [i]
411
      add   eax, [i]
412
      mov   byte [eax], 52
412
      mov   byte [eax], 52
413
 
413
 
414
 
414
 
415
      inc   [i]
415
      inc   [i]
416
      cmp   [i], 19*8
416
      cmp   [i], 19*8
417
      jb    .deleting_cards_from_common_cells
417
      jb    .deleting_cards_from_common_cells
418
 
418
 
419
 
419
 
420
    mov     [i], 0
420
    mov     [i], 0
421
    .filling_pack:
421
    .filling_pack:
422
      mov   eax, pack
422
      mov   eax, pack
423
      add   eax, [i]
423
      add   eax, [i]
424
      mov   bl, byte [i]
424
      mov   bl, byte [i]
425
      mov   byte [eax], bl
425
      mov   byte [eax], bl
426
 
426
 
427
      inc   [i]
427
      inc   [i]
428
      cmp   [i], 52
428
      cmp   [i], 52
429
      jb    .filling_pack
429
      jb    .filling_pack
430
 
430
 
431
      mov     [i], 0
431
      mov     [i], 0
432
 
432
 
433
    .putting_cards:
433
    .putting_cards:
434
 
434
 
435
      mov   [range], 52
435
      mov   [range], 52
436
      call  random
436
      call  random
437
      mov   eax, [random_value]
437
      mov   eax, [random_value]
438
      add   eax, pack
438
      add   eax, pack
439
 
439
 
440
      mov   ebx, 0
440
      mov   ebx, 0
441
      mov   bl, byte [eax]
441
      mov   bl, byte [eax]
442
      mov   [randomcard], ebx
442
      mov   [randomcard], ebx
443
 
443
 
444
      mov   eax, [random_value]
444
      mov   eax, [random_value]
445
      mov   [j], eax
445
      mov   [j], eax
446
 
446
 
447
      cmp   [randomcard], 52
447
      cmp   [randomcard], 52
448
      jb    .found_card
448
      jb    .found_card
449
 
449
 
450
 
450
 
451
      mov   [range], 52
451
      mov   [range], 52
452
      call  random
452
      call  random
453
      cmp   [random_value], 26
453
      cmp   [random_value], 26
454
      jae    .decreasing_j
454
      jae    .decreasing_j
455
 
455
 
456
    .increasing_j:
456
    .increasing_j:
457
      inc   [j]
457
      inc   [j]
458
                             ; j mod 52
458
                             ; j mod 52
459
      mov   eax, [j]
459
      mov   eax, [j]
460
      mov   edx, 0
460
      mov   edx, 0
461
      mov   ebx, 52
461
      mov   ebx, 52
462
      div   ebx
462
      div   ebx
463
      mov   [j], edx
463
      mov   [j], edx
464
 
464
 
465
 
465
 
466
      mov   eax, [j]
466
      mov   eax, [j]
467
      add   eax, pack
467
      add   eax, pack
468
      mov   ebx, 0
468
      mov   ebx, 0
469
      mov   bl, byte [eax]
469
      mov   bl, byte [eax]
470
      mov   [randomcard], ebx
470
      mov   [randomcard], ebx
471
      cmp   [randomcard], 52
471
      cmp   [randomcard], 52
472
      jb    .found_card
472
      jb    .found_card
473
 
473
 
474
      jmp  .increasing_j
474
      jmp  .increasing_j
475
 
475
 
476
 
476
 
477
    .decreasing_j:
477
    .decreasing_j:
478
      dec   [j]
478
      dec   [j]
479
                             ; i mod 32
479
                             ; i mod 32
480
      mov   eax, [j]
480
      mov   eax, [j]
481
      mov   edx, 0
481
      mov   edx, 0
482
      mov   ebx, 52
482
      mov   ebx, 52
483
      div   ebx
483
      div   ebx
484
      mov   [j], edx
484
      mov   [j], edx
485
 
485
 
486
      mov   eax, [j]
486
      mov   eax, [j]
487
      add   eax, pack
487
      add   eax, pack
488
      mov   ebx, 0
488
      mov   ebx, 0
489
      mov   bl, byte [eax]
489
      mov   bl, byte [eax]
490
      mov   [randomcard], ebx
490
      mov   [randomcard], ebx
491
      cmp   [randomcard], 52
491
      cmp   [randomcard], 52
492
      jb    .found_card
492
      jb    .found_card
493
 
493
 
494
      jmp  .decreasing_j
494
      jmp  .decreasing_j
495
 
495
 
496
    .found_card:
496
    .found_card:
497
                             ; putting card from pack
497
                             ; putting card from pack
498
      mov   eax, cards
498
      mov   eax, cards
499
      add   eax, [i]
499
      add   eax, [i]
500
      mov   bl, byte [randomcard]
500
      mov   bl, byte [randomcard]
501
      mov   byte [eax], bl
501
      mov   byte [eax], bl
502
                             ; deleting card from pack
502
                             ; deleting card from pack
503
      mov   eax, pack
503
      mov   eax, pack
504
      add   eax, [j]
504
      add   eax, [j]
505
      mov   byte [eax], 52
505
      mov   byte [eax], 52
506
 
506
 
507
 
507
 
508
      inc   [i]
508
      inc   [i]
509
      cmp   [i], 52
509
      cmp   [i], 52
510
      jb    .putting_cards
510
      jb    .putting_cards
511
 
511
 
512
 
512
 
513
 
513
 
514
 
514
 
515
      mov   [i], 0
515
      mov   [i], 0
516
    .deleting_cards_from_temp_cells:
516
    .deleting_cards_from_temp_cells:
517
      mov   eax, tempcells
517
      mov   eax, tempcells
518
      add   eax, [i]
518
      add   eax, [i]
519
      mov   byte [eax], 52
519
      mov   byte [eax], 52
520
 
520
 
521
 
521
 
522
      inc   [i]
522
      inc   [i]
523
      cmp   [i], 4
523
      cmp   [i], 4
524
      jb    .deleting_cards_from_temp_cells
524
      jb    .deleting_cards_from_temp_cells
525
 
525
 
526
      mov   [i], 0
526
      mov   [i], 0
527
    .deleting_cards_from_home_cells:
527
    .deleting_cards_from_home_cells:
528
      mov   eax, homecells
528
      mov   eax, homecells
529
      add   eax, [i]
529
      add   eax, [i]
530
      mov   byte [eax], 52
530
      mov   byte [eax], 52
531
 
531
 
532
 
532
 
533
      inc   [i]
533
      inc   [i]
534
      cmp   [i], 4
534
      cmp   [i], 4
535
      jb    .deleting_cards_from_home_cells
535
      jb    .deleting_cards_from_home_cells
536
 
536
 
537
 
537
 
538
    mov     [whereisselcard], scNotSelected
538
    mov     [whereisselcard], scNotSelected
539
    call    draw_window
539
    call    draw_window
540
 
540
 
541
 
541
 
542
  ret
542
  ret
543
 
543
 
544
 
544
 
545
;******************************************************************************
545
;******************************************************************************
546
;                       get_sel_card_code_and_addr(): selcardcode, selcardaddr
546
;                       get_sel_card_code_and_addr(): selcardcode, selcardaddr
547
;                       if nothing selected, then selcardcode is 52
547
;                       if nothing selected, then selcardcode is 52
548
  get_sel_card_code_and_addr:
548
  get_sel_card_code_and_addr:
549
    cmp     [whereisselcard], scNotSelected
549
    cmp     [whereisselcard], scNotSelected
550
    jne     .something_selected
550
    jne     .something_selected
551
 
551
 
552
    mov     [selcardcode], 52
552
    mov     [selcardcode], 52
553
    jmp     .end
553
    jmp     .end
554
 
554
 
555
    .something_selected:
555
    .something_selected:
556
    cmp     [whereisselcard], scTempCells
556
    cmp     [whereisselcard], scTempCells
557
    je      .temp_cells_selected
557
    je      .temp_cells_selected
558
 
558
 
559
                             ; common cells selected
559
                             ; common cells selected
560
    mov     eax, [columnofselcard]
560
    mov     eax, [columnofselcard]
561
    mov     [ncolumn], eax
561
    mov     [ncolumn], eax
562
    call    get_row_of_top_card_in_column
562
    call    get_row_of_top_card_in_column
563
 
563
 
564
 
564
 
565
    mov     eax, [topcardrow]; eax = topcardrow * 8  + columnofselcard
565
    mov     eax, [topcardrow]; eax = topcardrow * 8  + columnofselcard
566
    mov     bl, 8
566
    mov     bl, 8
567
    mul     bl                       ; result of multiplication in ax
567
    mul     bl                       ; result of multiplication in ax
568
    add     eax, [columnofselcard]
568
    add     eax, [columnofselcard]
569
    add     eax, cards
569
    add     eax, cards
570
 
570
 
571
 
571
 
572
    mov     [selcardaddr], eax
572
    mov     [selcardaddr], eax
573
    xor     ebx, ebx
573
    xor     ebx, ebx
574
    mov     bl, byte [eax]
574
    mov     bl, byte [eax]
575
    mov     [selcardcode], ebx
575
    mov     [selcardcode], ebx
576
 
576
 
577
    jmp     .end
577
    jmp     .end
578
 
578
 
579
    .temp_cells_selected:
579
    .temp_cells_selected:
580
 
580
 
581
    mov     eax, tempcells
581
    mov     eax, tempcells
582
    add     eax, [columnofselcard]
582
    add     eax, [columnofselcard]
583
    mov     [selcardaddr], eax
583
    mov     [selcardaddr], eax
584
    mov     ebx, 0
584
    mov     ebx, 0
585
    mov     bl, byte [eax]
585
    mov     bl, byte [eax]
586
    mov     [selcardcode], ebx
586
    mov     [selcardcode], ebx
587
 
587
 
588
    .end:
588
    .end:
589
 
589
 
590
  ret
590
  ret
591
 
591
 
592
;******************************************************************************
592
;******************************************************************************
593
;                            draw_window()
593
;                            draw_window()
594
 
594
 
595
  draw_window:
595
  draw_window:
596
    mov  eax,48  ; get system colors
596
    mov  eax,48  ; get system colors
597
    mov  ebx,3
597
    mov  ebx,3
598
    mov  ecx,syscolors
598
    mov  ecx,syscolors
599
    mov  edx,sizeof.system_colors
599
    mov  edx,sizeof.system_colors
600
    mcall
600
    mcall
601
 
601
 
602
 
602
 
603
    mov     eax, 12          ; start drawing
603
    mov     eax, 12          ; start drawing
604
    mov     ebx, 1
604
    mov     ebx, 1
605
    mcall
605
    mcall
606
 
606
 
607
    mov     eax, 0           ; create and draw the window
607
    mov     eax, 0           ; create and draw the window
608
    mov     ebx, 100 * 65536 + 8 * cardwidth + 10 + 7 * columnspace
608
    mov     ebx, 100 * 65536 + 8 * cardwidth + 10 + 7 * columnspace
609
    mov     ecx, 100 * 65536 + 500
609
    mov     ecx, 100 * 65536 + 500
610
    mov     edx, 0x13008000
610
    mov     edx, 0x13008000
611
    mov     edi, title
611
    mov     edi, title
612
    mcall
612
    mcall
613
 
613
 
614
    mov     eax, 9           ; getting window info
614
    mov     eax, 9           ; getting window info
615
    mov     ebx, process_info
615
    mov     ebx, process_info
616
    mov     ecx, -1          ; we want to know info of our window
616
    mov     ecx, -1          ; we want to know info of our window
617
    mcall
617
    mcall
-
 
618
 
-
 
619
    test    [process_info.wnd_state], 0x04
-
 
620
    jnz     draw_window.end_draw
618
 
621
 
619
 
622
 
620
    mov     eax, [process_info.box.height]
623
    mov     eax, [process_info.box.height]
621
    mov     [WindowHeight], ax
624
    mov     [WindowHeight], ax
622
 
625
 
623
    mov     eax, [process_info.box.width]
626
    mov     eax, [process_info.box.width]
624
    mov     [WindowWidth], ax
627
    mov     [WindowWidth], ax
625
 
628
 
626
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
629
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
627
        ; draw top panel
630
        ; draw top panel
628
 
631
 
629
    mov     eax, 13
632
    mov     eax, 13
630
    mov     ebx, 5
633
    mov     ebx, 5
631
    shl     ebx, 16
634
    shl     ebx, 16
632
    add     bx, word [process_info.box.width]
635
    add     bx, word [process_info.box.width]
633
    sub     bx, 9
636
    sub     bx, 9
634
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 1
637
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 1
635
    mov     edx, [syscolors.work_graph]
638
    mov     edx, [syscolors.work_graph]
636
    mcall
639
    mcall
637
 
640
 
638
                             ; draw button "new game"
641
                             ; draw button "new game"
639
 
642
 
640
    mov     eax, 8
643
    mov     eax, 8
641
    mov     ebx, 5 shl 16 + 80
644
    mov     ebx, 5 shl 16 + 80
642
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 2
645
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 2
643
    mov     edx, 1 + 8 + 4 + 4 + 1 ;button id
646
    mov     edx, 1 + 8 + 4 + 4 + 1 ;button id
644
    mov     esi, [syscolors.work_button]
647
    mov     esi, [syscolors.work_button]
645
    mcall
648
    mcall
646
 
649
 
647
    mov     eax, 4
650
    mov     eax, 4
648
    mov     ebx, 20 shl 16 + 22 + topbuttonsbarheight/2 - 4
651
    mov     ebx, 20 shl 16 + 22 + topbuttonsbarheight/2 - 4
649
    mov     ecx, [syscolors.work_button_text]
652
    mov     ecx, [syscolors.work_button_text]
650
    mov     edx, new_game
653
    mov     edx, new_game
651
    mov     esi, new_game_len
654
    mov     esi, new_game_len
652
    mcall
655
    mcall
653
 
656
 
654
 
657
 
655
       ; draw button "exit"
658
       ; draw button "exit"
656
    mov     eax, 8
659
    mov     eax, 8
657
    mov     ebx, (5 + 85) shl 16 + 80 + 5
660
    mov     ebx, (5 + 85) shl 16 + 80 + 5
658
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 2
661
    mov     ecx, 22 shl 16 + topbuttonsbarheight - 2
659
    mov     edx, 1 + 8 + 4 + 4 + 2 ;button id
662
    mov     edx, 1 + 8 + 4 + 4 + 2 ;button id
660
    mov     esi, [syscolors.work_button]
663
    mov     esi, [syscolors.work_button]
661
    mcall
664
    mcall
662
 
665
 
663
    mov     eax, 4
666
    mov     eax, 4
664
    mov     ebx, (40 + 80) shl 16 + 22 + topbuttonsbarheight/2 - 4
667
    mov     ebx, (40 + 80) shl 16 + 22 + topbuttonsbarheight/2 - 4
665
    mov     ecx, [syscolors.work_button_text]
668
    mov     ecx, [syscolors.work_button_text]
666
    mov     edx, exit
669
    mov     edx, exit
667
    mov     esi, exit_len
670
    mov     esi, exit_len
668
    mcall
671
    mcall
669
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
672
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
670
;                        draw separators between home, temp and common cells
673
;                        draw separators between home, temp and common cells
671
    mov     eax, 13
674
    mov     eax, 13
672
                   ; horizontal line
675
                   ; horizontal line
673
    mov     ebx, 5
676
    mov     ebx, 5
674
    shl     ebx, 16
677
    shl     ebx, 16
675
    add     bx,  word [process_info.box.width]
678
    add     bx,  word [process_info.box.width]
676
    sub     bx,  9
679
    sub     bx,  9
677
    mov     ecx, (21 + topbuttonsbarheight + cardheight + columnspace) shl 16+1
680
    mov     ecx, (21 + topbuttonsbarheight + cardheight + columnspace) shl 16+1
678
 
681
 
679
    mov     edx, [syscolors.work_graph]
682
    mov     edx, [syscolors.work_graph]
680
    mcall
683
    mcall
681
                  ; verical line
684
                  ; verical line
682
    mov     eax, [process_info.box.width]
685
    mov     eax, [process_info.box.width]
683
    mov     edx, 0
686
    mov     edx, 0
684
    mov     ecx, 2
687
    mov     ecx, 2
685
    div     ecx
688
    div     ecx
686
 
689
 
687
    mov     ebx, eax
690
    mov     ebx, eax
688
 
691
 
689
    ;
692
    ;
690
    shl     ebx, 16
693
    shl     ebx, 16
691
    add     bx,  1
694
    add     bx,  1
692
    mov     ecx, (21 + topbuttonsbarheight) shl 16 + cardheight + columnspace
695
    mov     ecx, (21 + topbuttonsbarheight) shl 16 + cardheight + columnspace
693
    mov     edx, [syscolors.work_graph]
696
    mov     edx, [syscolors.work_graph]
694
    mov     eax, 13
697
    mov     eax, 13
695
    mcall
698
    mcall
696
 
699
 
697
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
700
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
698
;                            draw temp buttons
701
;                            draw temp buttons
699
 
702
 
700
    mov     [j], 0           ;counter that loops from 0 to 51
703
    mov     [j], 0           ;counter that loops from 0 to 51
701
 
704
 
702
    draw_a_temp_card:
705
    draw_a_temp_card:
703
 
706
 
704
                             ; code of card must be in ecx
707
                             ; code of card must be in ecx
705
    mov     eax, tempcells
708
    mov     eax, tempcells
706
    add     eax, [j]
709
    add     eax, [j]
707
    xor     ecx, ecx
710
    xor     ecx, ecx
708
    mov     cl, byte [eax]   ; placing in cl value from memory
711
    mov     cl, byte [eax]   ; placing in cl value from memory
709
                             ;  with address [tempcells + j] or
712
                             ;  with address [tempcells + j] or
710
                             ;  j-th element of array "tempcells"
713
                             ;  j-th element of array "tempcells"
711
 
714
 
712
    mov     [cardcode], ecx
715
    mov     [cardcode], ecx
713
 
716
 
714
    mov     eax, [j]
717
    mov     eax, [j]
715
    xor     edx, edx
718
    xor     edx, edx
716
    mov     ebx, 8
719
    mov     ebx, 8
717
    div     ebx              ; divsion by 8 (8 columns),
720
    div     ebx              ; divsion by 8 (8 columns),
718
                             ;   so in eax quotient - number of row
721
                             ;   so in eax quotient - number of row
719
                             ;   and in edx remainder -
722
                             ;   and in edx remainder -
720
                             ;   number of column where lay card
723
                             ;   number of column where lay card
721
 
724
 
722
    mov     [row], eax
725
    mov     [row], eax
723
    mov     [column], edx
726
    mov     [column], edx
724
 
727
 
725
    mov     eax, [process_info.box.width]       ; width of window
728
    mov     eax, [process_info.box.width]       ; width of window
726
    sub     eax, 10
729
    sub     eax, 10
727
    sub     eax, cardwidth
730
    sub     eax, cardwidth
728
    mov     ebx, 7
731
    mov     ebx, 7
729
    mov     edx, 0
732
    mov     edx, 0
730
    div     ebx
733
    div     ebx
731
    mov     ebx, [column]
734
    mov     ebx, [column]
732
    mul     ebx
735
    mul     ebx
733
    add     eax, 5
736
    add     eax, 5
734
 
737
 
735
    mov     [xpos], eax
738
    mov     [xpos], eax
736
 
739
 
737
 
740
 
738
    mov     eax, [row]
741
    mov     eax, [row]
739
    mov     bl, rowsize
742
    mov     bl, rowsize
740
    mul     bl
743
    mul     bl
741
    add     eax, 24 + topbuttonsbarheight
744
    add     eax, 24 + topbuttonsbarheight
742
    mov     [ypos], eax
745
    mov     [ypos], eax
743
 
746
 
744
                             ; checking, if this card selected
747
                             ; checking, if this card selected
745
 
748
 
746
    mov     [negativedraw], 0
749
    mov     [negativedraw], 0
747
 
750
 
748
    cmp     [whereisselcard], scTempCells
751
    cmp     [whereisselcard], scTempCells
749
    jne     .this_temp_cell_isnt_selected
752
    jne     .this_temp_cell_isnt_selected
750
 
753
 
751
    mov     eax, [column]
754
    mov     eax, [column]
752
    cmp     [columnofselcard], eax
755
    cmp     [columnofselcard], eax
753
    jne     .this_temp_cell_isnt_selected
756
    jne     .this_temp_cell_isnt_selected
754
 
757
 
755
    mov     [negativedraw], 1
758
    mov     [negativedraw], 1
756
 
759
 
757
    .this_temp_cell_isnt_selected:
760
    .this_temp_cell_isnt_selected:
758
 
761
 
759
    call    draw_card
762
    call    draw_card
760
 
763
 
761
                             ; define button on place of card
764
                             ; define button on place of card
762
    mov     eax, 8
765
    mov     eax, 8
763
    mov     ebx, [xpos]
766
    mov     ebx, [xpos]
764
    shl     ebx, 16
767
    shl     ebx, 16
765
    add     bx, cardwidth - 1
768
    add     bx, cardwidth - 1
766
    mov     ecx, [ypos]
769
    mov     ecx, [ypos]
767
    shl     ecx, 16
770
    shl     ecx, 16
768
    add     cx, cardheight - 1
771
    add     cx, cardheight - 1
769
    mov     edx, [column]
772
    mov     edx, [column]
770
    add     edx, 01000000000000000000000000000000b + 2 + 8;  button id = column
773
    add     edx, 01000000000000000000000000000000b + 2 + 8;  button id = column
771
                                           ; id = 1 reserved as close button
774
                                           ; id = 1 reserved as close button
772
    mcall
775
    mcall
773
 
776
 
774
 
777
 
775
    inc     [j]
778
    inc     [j]
776
    cmp     [j], 4
779
    cmp     [j], 4
777
    jb      draw_a_temp_card
780
    jb      draw_a_temp_card
778
 
781
 
779
 
782
 
780
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
783
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
781
;                            draw home buttons
784
;                            draw home buttons
782
 mov     [j], 0              ;counter that loops from 0 to 51
785
 mov     [j], 0              ;counter that loops from 0 to 51
783
 
786
 
784
    draw_a_home_card:
787
    draw_a_home_card:
785
 
788
 
786
 
789
 
787
                             ; code of card must be in ecx
790
                             ; code of card must be in ecx
788
    mov     eax, homecells
791
    mov     eax, homecells
789
    add     eax, [j]
792
    add     eax, [j]
790
    xor     ecx, ecx
793
    xor     ecx, ecx
791
    mov     cl, byte [eax]   ; placing in cl value from memory
794
    mov     cl, byte [eax]   ; placing in cl value from memory
792
                             ;  with address [tempcells + j] or
795
                             ;  with address [tempcells + j] or
793
                             ;  j-th element of array "tempcells"
796
                             ;  j-th element of array "tempcells"
794
 
797
 
795
    mov     [cardcode], ecx
798
    mov     [cardcode], ecx
796
 
799
 
797
    mov     eax, [j]
800
    mov     eax, [j]
798
    xor     edx, edx
801
    xor     edx, edx
799
    mov     ebx, 8
802
    mov     ebx, 8
800
    div     ebx              ; divsion by 8 (8 columns),
803
    div     ebx              ; divsion by 8 (8 columns),
801
                             ;  so in eax quotient - number of row
804
                             ;  so in eax quotient - number of row
802
                             ;  and in edx remainder -
805
                             ;  and in edx remainder -
803
                             ;  number of column where lay card
806
                             ;  number of column where lay card
804
 
807
 
805
    mov     [row], eax
808
    mov     [row], eax
806
    mov     [column], edx
809
    mov     [column], edx
807
 
810
 
808
    mov     eax, [process_info.box.width]       ; width of window
811
    mov     eax, [process_info.box.width]       ; width of window
809
    sub     eax, 10
812
    sub     eax, 10
810
    sub     eax, cardwidth
813
    sub     eax, cardwidth
811
    mov     ebx, 7
814
    mov     ebx, 7
812
    mov     edx, 0
815
    mov     edx, 0
813
    div     ebx
816
    div     ebx
814
    mov     ebx, [column]
817
    mov     ebx, [column]
815
    add     ebx, 4
818
    add     ebx, 4
816
    mul     ebx
819
    mul     ebx
817
    add     eax, 5
820
    add     eax, 5
818
 
821
 
819
    mov     [xpos], eax
822
    mov     [xpos], eax
820
 
823
 
821
    mov     eax, [row]
824
    mov     eax, [row]
822
    mov     bl, rowsize
825
    mov     bl, rowsize
823
    mul     bl
826
    mul     bl
824
    add     eax, 24 + topbuttonsbarheight
827
    add     eax, 24 + topbuttonsbarheight
825
    mov     [ypos], eax
828
    mov     [ypos], eax
826
 
829
 
827
    mov     [negativedraw], 0
830
    mov     [negativedraw], 0
828
 
831
 
829
    call    draw_card
832
    call    draw_card
830
 
833
 
831
                             ; define button on place of card
834
                             ; define button on place of card
832
 
835
 
833
    mov     eax, 8
836
    mov     eax, 8
834
    mov     ebx, [xpos]
837
    mov     ebx, [xpos]
835
    shl     ebx, 16
838
    shl     ebx, 16
836
    add     bx, cardwidth - 1
839
    add     bx, cardwidth - 1
837
    mov     ecx, [ypos]
840
    mov     ecx, [ypos]
838
    shl     ecx, 16
841
    shl     ecx, 16
839
    add     cx, cardheight - 1
842
    add     cx, cardheight - 1
840
    mov     edx, [column]
843
    mov     edx, [column]
841
    add     edx, 01000000000000000000000000000000b + 2 + 8 + 4 ; button id
844
    add     edx, 01000000000000000000000000000000b + 2 + 8 + 4 ; button id
842
 
845
 
843
                             ; id = 1 reserved as close button
846
                             ; id = 1 reserved as close button
844
    mcall
847
    mcall
845
 
848
 
846
 
849
 
847
    inc     [j]
850
    inc     [j]
848
    cmp     [j], 4
851
    cmp     [j], 4
849
    jb       draw_a_home_card
852
    jb       draw_a_home_card
850
 
853
 
851
 
854
 
852
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
855
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
853
;                            draw common cards
856
;                            draw common cards
854
 
857
 
855
    mov     [j], 0           ;counter that loops from 0 to 8 * 19
858
    mov     [j], 0           ;counter that loops from 0 to 8 * 19
856
 
859
 
857
    draw_a_card:
860
    draw_a_card:
858
 
861
 
859
 
862
 
860
                             ; code of card must be in ecx
863
                             ; code of card must be in ecx
861
    mov     eax, cards
864
    mov     eax, cards
862
    add     eax, [j]
865
    add     eax, [j]
863
    xor     ecx, ecx
866
    xor     ecx, ecx
864
    mov     cl, byte [eax]   ; placing in cl value from memory
867
    mov     cl, byte [eax]   ; placing in cl value from memory
865
                             ;  with address [cards + j] or
868
                             ;  with address [cards + j] or
866
                             ;  j-th element of array "cards"
869
                             ;  j-th element of array "cards"
867
;    cmp     ecx, 52          ; if code of card >= 52 then there is no card
870
;    cmp     ecx, 52          ; if code of card >= 52 then there is no card
868
;    jae     no_draw
871
;    jae     no_draw
869
;
872
;
870
;    cmp     ecx, 0           ; if code of card  < 0 then there is no card
873
;    cmp     ecx, 0           ; if code of card  < 0 then there is no card
871
;    jb      no_draw
874
;    jb      no_draw
872
 
875
 
873
    mov     [cardcode], ecx
876
    mov     [cardcode], ecx
874
 
877
 
875
 
878
 
876
 
879
 
877
    mov     eax, [j]
880
    mov     eax, [j]
878
    xor     edx, edx
881
    xor     edx, edx
879
    mov     ebx, 8
882
    mov     ebx, 8
880
    div     ebx             ; divsion by 8 (8 columns),
883
    div     ebx             ; divsion by 8 (8 columns),
881
                            ;  so in eax quotient - number of row
884
                            ;  so in eax quotient - number of row
882
                            ;  and in edx remainder -
885
                            ;  and in edx remainder -
883
                            ;  number of column where lay card
886
                            ;  number of column where lay card
884
 
887
 
885
    mov     [row], eax
888
    mov     [row], eax
886
    mov     [column], edx
889
    mov     [column], edx
887
 
890
 
888
    mov     eax, [process_info.box.width]       ; width of window
891
    mov     eax, [process_info.box.width]       ; width of window
889
    sub     eax, 10
892
    sub     eax, 10
890
    sub     eax, cardwidth
893
    sub     eax, cardwidth
891
    mov     ebx, 7
894
    mov     ebx, 7
892
    mov     edx, 0
895
    mov     edx, 0
893
    div     ebx
896
    div     ebx
894
    mov     ebx, [column]
897
    mov     ebx, [column]
895
    mul     ebx
898
    mul     ebx
896
    add     eax, 5
899
    add     eax, 5
897
 
900
 
898
    mov     [xpos], eax
901
    mov     [xpos], eax
899
 
902
 
900
    mov     eax, [row]
903
    mov     eax, [row]
901
    mov     bl, rowsize
904
    mov     bl, rowsize
902
    mul     bl
905
    mul     bl
903
    add     eax, cardheight + 24 + topbuttonsbarheight + columnspace
906
    add     eax, cardheight + 24 + topbuttonsbarheight + columnspace
904
    mov     [ypos], eax
907
    mov     [ypos], eax
905
 
908
 
906
 
909
 
907
    mov     [negativedraw], 0 ;checking, if this is selected card
910
    mov     [negativedraw], 0 ;checking, if this is selected card
908
 
911
 
909
    cmp     [whereisselcard], scCommonCells
912
    cmp     [whereisselcard], scCommonCells
910
    jne     .this_card_isnt_selected
913
    jne     .this_card_isnt_selected
911
 
914
 
912
    mov     eax, [column]
915
    mov     eax, [column]
913
    cmp     [columnofselcard], eax
916
    cmp     [columnofselcard], eax
914
    jne     .this_card_isnt_selected
917
    jne     .this_card_isnt_selected
915
 
918
 
916
 
919
 
917
    mov     eax, [column]
920
    mov     eax, [column]
918
    mov     [ncolumn], eax
921
    mov     [ncolumn], eax
919
    call    get_row_of_top_card_in_column
922
    call    get_row_of_top_card_in_column
920
    mov     eax, [row]
923
    mov     eax, [row]
921
    cmp     [topcardrow], eax
924
    cmp     [topcardrow], eax
922
    jne     .this_card_isnt_selected
925
    jne     .this_card_isnt_selected
923
 
926
 
924
    mov     [negativedraw], 1
927
    mov     [negativedraw], 1
925
 
928
 
926
    .this_card_isnt_selected:
929
    .this_card_isnt_selected:
927
 
930
 
928
    call    draw_card
931
    call    draw_card
929
 
932
 
930
 
933
 
931
 
934
 
932
                             ; now checking if it is top card in its column
935
                             ; now checking if it is top card in its column
933
                             ; if it does, we'll define button on its place
936
                             ; if it does, we'll define button on its place
934
    mov     eax, [column]
937
    mov     eax, [column]
935
    mov     [ncolumn], eax
938
    mov     [ncolumn], eax
936
    call    get_row_of_top_card_in_column
939
    call    get_row_of_top_card_in_column
937
    mov     eax, [row]
940
    mov     eax, [row]
938
    cmp     [topcardrow], eax
941
    cmp     [topcardrow], eax
939
    je       .define_button
942
    je       .define_button
940
 
943
 
941
    cmp     [topcardrow], 0
944
    cmp     [topcardrow], 0
942
    jne     .no_define_button
945
    jne     .no_define_button
943
 
946
 
944
    cmp     [row], 0
947
    cmp     [row], 0
945
    jne     .no_define_button
948
    jne     .no_define_button
946
 
949
 
947
 
950
 
948
    .define_button:
951
    .define_button:
949
    mov     eax, 8
952
    mov     eax, 8
950
    mov     ebx, [xpos]
953
    mov     ebx, [xpos]
951
    shl     ebx, 16
954
    shl     ebx, 16
952
    add     bx, cardwidth - 1
955
    add     bx, cardwidth - 1
953
    mov     ecx, [ypos]
956
    mov     ecx, [ypos]
954
    shl     ecx, 16
957
    shl     ecx, 16
955
    add     cx, cardheight - 1
958
    add     cx, cardheight - 1
956
    mov     edx, [column]
959
    mov     edx, [column]
957
    add     edx, 01000000000000000000000000000000b + 2; button id = column + 2,
960
    add     edx, 01000000000000000000000000000000b + 2; button id = column + 2,
958
                             ; id = 1 reserved as close button
961
                             ; id = 1 reserved as close button
959
    mcall
962
    mcall
960
 
963
 
961
 
964
 
962
    .no_define_button:
965
    .no_define_button:
963
 
966
 
964
    inc     [j]
967
    inc     [j]
965
    cmp     [j], 8 * 19
968
    cmp     [j], 8 * 19
966
    jb       draw_a_card
969
    jb       draw_a_card
967
 
970
 
968
 
971
 
969
 
972
 
970
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
973
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
971
 
-
 
-
 
974
    draw_window.end_draw:
972
 
975
 
973
    mov     eax, 12          ; finish drawing
976
    mov     eax, 12          ; finish drawing
974
    mov     ebx, 2
977
    mov     ebx, 2
975
    mcall
978
    mcall
976
 
979
 
977
  ret
980
  ret
978
 
981
 
979
 
982
 
980
;******************************************************************************
983
;******************************************************************************
981
;            get_row_of_top_card_in_column(ncolumn): topcardrow
984
;            get_row_of_top_card_in_column(ncolumn): topcardrow
982
 
985
 
983
  get_row_of_top_card_in_column:
986
  get_row_of_top_card_in_column:
984
                             ; number of column in ncolumn
987
                             ; number of column in ncolumn
985
                             ; returns in topcardrow
988
                             ; returns in topcardrow
986
 
989
 
987
    mov [i], 0               ; i loops from 0 to 1, ... while card i * 8 + ncolumn
990
    mov [i], 0               ; i loops from 0 to 1, ... while card i * 8 + ncolumn
988
                             ; is valid card (0 <= its code < 52)
991
                             ; is valid card (0 <= its code < 52)
989
 
992
 
990
    .cycle:
993
    .cycle:
991
       xor  eax, eax
994
       xor  eax, eax
992
       mov  al, 8
995
       mov  al, 8
993
       mov  ebx, [i]
996
       mov  ebx, [i]
994
       mul  bl
997
       mul  bl
995
       add  eax, [ncolumn]
998
       add  eax, [ncolumn]
996
       add  eax, cards
999
       add  eax, cards
997
       xor  ecx, ecx
1000
       xor  ecx, ecx
998
       mov  cl, byte [eax]
1001
       mov  cl, byte [eax]
999
 
1002
 
1000
       cmp  ecx, 52
1003
       cmp  ecx, 52
1001
       jae  .endcycle
1004
       jae  .endcycle
1002
 
1005
 
1003
 
1006
 
1004
       cmp  [i], 18
1007
       cmp  [i], 18
1005
       ja   .endcycle
1008
       ja   .endcycle
1006
 
1009
 
1007
 
1010
 
1008
       inc  [i]
1011
       inc  [i]
1009
 
1012
 
1010
       jmp  .cycle
1013
       jmp  .cycle
1011
 
1014
 
1012
    .endcycle:
1015
    .endcycle:
1013
 
1016
 
1014
      cmp   [i], 0
1017
      cmp   [i], 0
1015
      je    .dont_dec
1018
      je    .dont_dec
1016
 
1019
 
1017
      dec   [i]
1020
      dec   [i]
1018
 
1021
 
1019
    .dont_dec:
1022
    .dont_dec:
1020
 
1023
 
1021
      mov   eax, [i]
1024
      mov   eax, [i]
1022
      mov   [topcardrow], eax
1025
      mov   [topcardrow], eax
1023
  ret
1026
  ret
1024
 
1027
 
1025
 
1028
 
1026
;******************************************************************************
1029
;******************************************************************************
1027
;                      invert_image_colors(imagetoinvert, sizeofimagetoinvert)
1030
;                      invert_image_colors(imagetoinvert, sizeofimagetoinvert)
1028
  invert_image_colors:
1031
  invert_image_colors:
1029
    mov     [i], 0
1032
    mov     [i], 0
1030
 
1033
 
1031
    .inverting:
1034
    .inverting:
1032
    mov     eax, [imagetoinvert]
1035
    mov     eax, [imagetoinvert]
1033
    add     eax, [i]
1036
    add     eax, [i]
1034
 
1037
 
1035
    mov     bl, byte [eax]
1038
    mov     bl, byte [eax]
1036
    ;xor     ebx, ebx
1039
    ;xor     ebx, ebx
1037
    ;add     ebx, 10
1040
    ;add     ebx, 10
1038
    not     ebx
1041
    not     ebx
1039
 
1042
 
1040
    mov     byte [eax], bl
1043
    mov     byte [eax], bl
1041
 
1044
 
1042
 
1045
 
1043
    inc     [i]
1046
    inc     [i]
1044
 
1047
 
1045
    mov     ecx, [sizeofimagetoinvert]
1048
    mov     ecx, [sizeofimagetoinvert]
1046
    cmp     [i], ecx
1049
    cmp     [i], ecx
1047
    jb      .inverting
1050
    jb      .inverting
1048
 
1051
 
1049
    jmp   .later
1052
    jmp   .later
1050
 
1053
 
1051
 
1054
 
1052
    .exit:
1055
    .exit:
1053
      mov  eax, -1
1056
      mov  eax, -1
1054
      mcall
1057
      mcall
1055
 
1058
 
1056
    .later:
1059
    .later:
1057
 
1060
 
1058
 
1061
 
1059
  ret
1062
  ret
1060
 
1063
 
1061
 
1064
 
1062
 
1065
 
1063
;******************************************************************************
1066
;******************************************************************************
1064
;            draw_card(xpos, ypos, cardcode, negativedraw)
1067
;            draw_card(xpos, ypos, cardcode, negativedraw)
1065
; if negativedraw = 1 then card drawn in inverted colors
1068
; if negativedraw = 1 then card drawn in inverted colors
1066
 
1069
 
1067
  draw_card: ; draws card with left top corner
1070
  draw_card: ; draws card with left top corner
1068
                    ; in point ([xpos],[ypos]),
1071
                    ; in point ([xpos],[ypos]),
1069
                    ; type of card in [cardcode]
1072
                    ; type of card in [cardcode]
1070
 
1073
 
1071
    cmp     [cardcode], 52   ; if code of card >= 52 then there is no card
1074
    cmp     [cardcode], 52   ; if code of card >= 52 then there is no card
1072
    jae     .no_draw_card
1075
    jae     .no_draw_card
1073
 
1076
 
1074
 
1077
 
1075
    cmp     [negativedraw], 1
1078
    cmp     [negativedraw], 1
1076
    jne     .no_invert1
1079
    jne     .no_invert1
1077
                             ;doing if negativedraw
1080
                             ;doing if negativedraw
1078
    mov     [bgcolor], $00000000
1081
    mov     [bgcolor], $00000000
1079
    mov     [blackcolor], $00FFFFFF
1082
    mov     [blackcolor], $00FFFFFF
1080
    mov     [redcolor], $0000FFFF
1083
    mov     [redcolor], $0000FFFF
1081
 
1084
 
1082
             ;inverting all images
1085
             ;inverting all images
1083
    call invert_all_images
1086
    call invert_all_images
1084
 
1087
 
1085
    jmp     .colors_selection_done
1088
    jmp     .colors_selection_done
1086
 
1089
 
1087
    .no_invert1:
1090
    .no_invert1:
1088
                             ;doing if not negativedraw
1091
                             ;doing if not negativedraw
1089
    mov     [bgcolor], $00FFFFFF
1092
    mov     [bgcolor], $00FFFFFF
1090
    mov     [blackcolor], $00000000
1093
    mov     [blackcolor], $00000000
1091
    mov     [redcolor], $00FF0000
1094
    mov     [redcolor], $00FF0000
1092
 
1095
 
1093
 
1096
 
1094
    .colors_selection_done:
1097
    .colors_selection_done:
1095
 
1098
 
1096
    mov     eax, 13
1099
    mov     eax, 13
1097
 
1100
 
1098
    mov     ebx, [xpos]      ; filling card with bgcolor
1101
    mov     ebx, [xpos]      ; filling card with bgcolor
1099
                             ; (big background rectangle)
1102
                             ; (big background rectangle)
1100
    mov     edx, [bgcolor]
1103
    mov     edx, [bgcolor]
1101
    add     ebx, 2
1104
    add     ebx, 2
1102
    shl     ebx, 16
1105
    shl     ebx, 16
1103
    mov     bx, cardwidth - 4
1106
    mov     bx, cardwidth - 4
1104
 
1107
 
1105
    mov     ecx, [ypos]
1108
    mov     ecx, [ypos]
1106
    add     ecx, 2
1109
    add     ecx, 2
1107
    shl     ecx, 16
1110
    shl     ecx, 16
1108
    mov     cx, cardheight - 4
1111
    mov     cx, cardheight - 4
1109
    mcall
1112
    mcall
1110
 
1113
 
1111
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1114
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1112
 
1115
 
1113
    mov     ebx, [xpos]      ; left black line
1116
    mov     ebx, [xpos]      ; left black line
1114
    shl     ebx, 16
1117
    shl     ebx, 16
1115
    mov     bx, 1
1118
    mov     bx, 1
1116
 
1119
 
1117
    mov     ecx, [ypos]
1120
    mov     ecx, [ypos]
1118
    add     ecx, 5
1121
    add     ecx, 5
1119
    shl     ecx, 16
1122
    shl     ecx, 16
1120
    xor     cx, cx
1123
    xor     cx, cx
1121
    mov     cx, cardheight - 2 * radius - 2
1124
    mov     cx, cardheight - 2 * radius - 2
1122
    mov     edx, [blackcolor]
1125
    mov     edx, [blackcolor]
1123
    mcall
1126
    mcall
1124
 
1127
 
1125
    mov     ebx, [xpos]      ; left white line
1128
    mov     ebx, [xpos]      ; left white line
1126
    inc     ebx
1129
    inc     ebx
1127
    shl     ebx, 16
1130
    shl     ebx, 16
1128
    mov     bx, 1
1131
    mov     bx, 1
1129
    mov     edx, [bgcolor]
1132
    mov     edx, [bgcolor]
1130
    mcall
1133
    mcall
1131
 
1134
 
1132
    mov     ebx, [xpos]      ; right black line
1135
    mov     ebx, [xpos]      ; right black line
1133
    add     ebx, cardwidth - 1
1136
    add     ebx, cardwidth - 1
1134
    shl     ebx, 16
1137
    shl     ebx, 16
1135
    mov     bx,  1
1138
    mov     bx,  1
1136
    mov     edx, [blackcolor]
1139
    mov     edx, [blackcolor]
1137
    mcall
1140
    mcall
1138
 
1141
 
1139
    mov     ebx, [xpos]      ; right white line
1142
    mov     ebx, [xpos]      ; right white line
1140
    add     ebx, cardwidth - 2
1143
    add     ebx, cardwidth - 2
1141
    shl     ebx, 16
1144
    shl     ebx, 16
1142
    mov     bx, 1
1145
    mov     bx, 1
1143
    mov     edx, [bgcolor]
1146
    mov     edx, [bgcolor]
1144
    mcall
1147
    mcall
1145
 
1148
 
1146
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1149
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1147
 
1150
 
1148
    mov     ecx, [ypos]      ; top black line
1151
    mov     ecx, [ypos]      ; top black line
1149
    shl     ecx, 16
1152
    shl     ecx, 16
1150
    mov     cx, 1
1153
    mov     cx, 1
1151
 
1154
 
1152
    mov     ebx, [xpos]
1155
    mov     ebx, [xpos]
1153
    add     ebx, 5
1156
    add     ebx, 5
1154
    shl     ebx, 16
1157
    shl     ebx, 16
1155
    mov     bx, cardwidth - 2 * radius - 2
1158
    mov     bx, cardwidth - 2 * radius - 2
1156
    mov     edx, [blackcolor]
1159
    mov     edx, [blackcolor]
1157
    mcall
1160
    mcall
1158
 
1161
 
1159
    mov     ecx, [ypos]      ; top white line
1162
    mov     ecx, [ypos]      ; top white line
1160
    inc     ecx
1163
    inc     ecx
1161
    shl     ecx, 16
1164
    shl     ecx, 16
1162
    mov     cx, 1
1165
    mov     cx, 1
1163
    mov     edx, [bgcolor]
1166
    mov     edx, [bgcolor]
1164
    mcall
1167
    mcall
1165
 
1168
 
1166
    mov     ecx, [ypos]      ; bottom black line
1169
    mov     ecx, [ypos]      ; bottom black line
1167
    add     ecx, cardheight - 1
1170
    add     ecx, cardheight - 1
1168
    shl     ecx, 16
1171
    shl     ecx, 16
1169
    mov     cx,  1
1172
    mov     cx,  1
1170
    mov     edx, [blackcolor]
1173
    mov     edx, [blackcolor]
1171
    mcall
1174
    mcall
1172
 
1175
 
1173
    mov     ecx, [ypos]      ; bottom white line
1176
    mov     ecx, [ypos]      ; bottom white line
1174
    add     ecx, cardheight - 2
1177
    add     ecx, cardheight - 2
1175
    shl     ecx, 16
1178
    shl     ecx, 16
1176
    mov     cx, 1
1179
    mov     cx, 1
1177
    mov     edx, [bgcolor]
1180
    mov     edx, [bgcolor]
1178
    mcall
1181
    mcall
1179
 
1182
 
1180
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1183
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1181
 
1184
 
1182
    mov    eax, 1            ; drawing points
1185
    mov    eax, 1            ; drawing points
1183
    mov    edx, [blackcolor] ; black color for all pixels
1186
    mov    edx, [blackcolor] ; black color for all pixels
1184
 
1187
 
1185
    mov    ebx, [xpos]       ; draw top left corner
1188
    mov    ebx, [xpos]       ; draw top left corner
1186
    mov    ecx, [ypos]
1189
    mov    ecx, [ypos]
1187
    inc    ebx
1190
    inc    ebx
1188
    add    ecx, 4
1191
    add    ecx, 4
1189
    mcall
1192
    mcall
1190
 
1193
 
1191
    dec    ecx
1194
    dec    ecx
1192
    mcall
1195
    mcall
1193
 
1196
 
1194
    dec    ecx
1197
    dec    ecx
1195
    inc    ebx
1198
    inc    ebx
1196
    mcall
1199
    mcall
1197
 
1200
 
1198
    dec    ecx
1201
    dec    ecx
1199
    inc    ebx
1202
    inc    ebx
1200
    mcall
1203
    mcall
1201
 
1204
 
1202
    inc    ebx
1205
    inc    ebx
1203
    mcall
1206
    mcall
1204
 
1207
 
1205
    mov    ebx, [xpos]       ;drawing top right corner
1208
    mov    ebx, [xpos]       ;drawing top right corner
1206
    mov    ecx, [ypos]
1209
    mov    ecx, [ypos]
1207
    add    ebx, cardwidth - 2
1210
    add    ebx, cardwidth - 2
1208
    add    ecx, 4
1211
    add    ecx, 4
1209
    mcall
1212
    mcall
1210
 
1213
 
1211
    dec    ecx
1214
    dec    ecx
1212
    mcall
1215
    mcall
1213
 
1216
 
1214
    dec    ebx
1217
    dec    ebx
1215
    dec    ecx
1218
    dec    ecx
1216
    mcall
1219
    mcall
1217
 
1220
 
1218
    dec    ebx
1221
    dec    ebx
1219
    dec    ecx
1222
    dec    ecx
1220
    mcall
1223
    mcall
1221
 
1224
 
1222
    dec    ebx
1225
    dec    ebx
1223
    mcall
1226
    mcall
1224
                             ;drawing bottom left corner
1227
                             ;drawing bottom left corner
1225
    mov    ebx, [xpos]
1228
    mov    ebx, [xpos]
1226
    mov    ecx, [ypos]
1229
    mov    ecx, [ypos]
1227
    inc    ebx
1230
    inc    ebx
1228
    add    ecx, cardheight - 5
1231
    add    ecx, cardheight - 5
1229
    mcall
1232
    mcall
1230
 
1233
 
1231
    inc    ecx
1234
    inc    ecx
1232
    mcall
1235
    mcall
1233
 
1236
 
1234
    inc    ebx
1237
    inc    ebx
1235
    inc    ecx
1238
    inc    ecx
1236
    mcall
1239
    mcall
1237
 
1240
 
1238
    inc    ebx
1241
    inc    ebx
1239
    inc    ecx
1242
    inc    ecx
1240
    mcall
1243
    mcall
1241
 
1244
 
1242
    inc    ebx
1245
    inc    ebx
1243
    mcall
1246
    mcall
1244
                             ;drawing bottom right corner
1247
                             ;drawing bottom right corner
1245
    mov    ebx, [xpos]
1248
    mov    ebx, [xpos]
1246
    mov    ecx, [ypos]
1249
    mov    ecx, [ypos]
1247
    add    ebx, cardwidth - 2
1250
    add    ebx, cardwidth - 2
1248
    add    ecx, cardheight - 5
1251
    add    ecx, cardheight - 5
1249
    mcall
1252
    mcall
1250
 
1253
 
1251
    inc    ecx
1254
    inc    ecx
1252
    mcall
1255
    mcall
1253
 
1256
 
1254
    dec    ebx
1257
    dec    ebx
1255
    inc    ecx
1258
    inc    ecx
1256
    mcall
1259
    mcall
1257
 
1260
 
1258
    dec    ebx
1261
    dec    ebx
1259
    inc    ecx
1262
    inc    ecx
1260
    mcall
1263
    mcall
1261
 
1264
 
1262
    dec    ebx
1265
    dec    ebx
1263
    mcall
1266
    mcall
1264
 
1267
 
1265
 
1268
 
1266
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1269
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1267
;   drawing text and images
1270
;   drawing text and images
1268
 
1271
 
1269
    mov    eax, [cardcode]
1272
    mov    eax, [cardcode]
1270
    mov    edx, 0
1273
    mov    edx, 0
1271
    mov    ebx, 4
1274
    mov    ebx, 4
1272
    div    ebx
1275
    div    ebx
1273
 
1276
 
1274
    mov    [cardfamily], edx
1277
    mov    [cardfamily], edx
1275
    mov    [cardrange], eax
1278
    mov    [cardrange], eax
1276
 
1279
 
1277
                     ; counting position of small card image
1280
                     ; counting position of small card image
1278
    mov eax, 7
1281
    mov eax, 7
1279
    mov ecx, 8*65536+8
1282
    mov ecx, 8*65536+8
1280
    mov edx, [xpos]
1283
    mov edx, [xpos]
1281
    add edx, radius
1284
    add edx, radius
1282
    shl edx, 16
1285
    shl edx, 16
1283
    mov dx, word [ypos]
1286
    mov dx, word [ypos]
1284
    add dx, radius + 8
1287
    add dx, radius + 8
1285
 
1288
 
1286
 
1289
 
1287
 
1290
 
1288
    cmp    [cardfamily], 0
1291
    cmp    [cardfamily], 0
1289
    je     .heart
1292
    je     .heart
1290
 
1293
 
1291
    cmp    [cardfamily], 1
1294
    cmp    [cardfamily], 1
1292
    je     .diamond
1295
    je     .diamond
1293
 
1296
 
1294
    cmp    [cardfamily], 2
1297
    cmp    [cardfamily], 2
1295
    je     .club
1298
    je     .club
1296
 
1299
 
1297
    cmp    [cardfamily], 3
1300
    cmp    [cardfamily], 3
1298
    je     .spade
1301
    je     .spade
1299
 
1302
 
1300
    .heart:
1303
    .heart:
1301
       mov esi, [redcolor]
1304
       mov esi, [redcolor]
1302
       mov [color], esi
1305
       mov [color], esi
1303
       mov [imageaddr], heart
1306
       mov [imageaddr], heart
1304
       mov [imageflipaddr], heart_updown
1307
       mov [imageflipaddr], heart_updown
1305
 
1308
 
1306
       mov ebx, heart_small
1309
       mov ebx, heart_small
1307
       mcall
1310
       mcall
1308
 
1311
 
1309
       jmp .selnumber
1312
       jmp .selnumber
1310
 
1313
 
1311
    .diamond:
1314
    .diamond:
1312
       mov esi, [redcolor]
1315
       mov esi, [redcolor]
1313
       mov [color], esi
1316
       mov [color], esi
1314
       mov [imageaddr], diamond
1317
       mov [imageaddr], diamond
1315
       mov [imageflipaddr], diamond_updown
1318
       mov [imageflipaddr], diamond_updown
1316
 
1319
 
1317
       mov ebx, diamond_small
1320
       mov ebx, diamond_small
1318
       mcall
1321
       mcall
1319
 
1322
 
1320
       jmp .selnumber
1323
       jmp .selnumber
1321
 
1324
 
1322
    .club:
1325
    .club:
1323
      mov  esi, [blackcolor]
1326
      mov  esi, [blackcolor]
1324
      mov  [color], esi
1327
      mov  [color], esi
1325
      mov  [imageaddr], club
1328
      mov  [imageaddr], club
1326
      mov  [imageflipaddr], club_updown
1329
      mov  [imageflipaddr], club_updown
1327
 
1330
 
1328
      mov ebx, club_small
1331
      mov ebx, club_small
1329
      mcall
1332
      mcall
1330
 
1333
 
1331
      jmp  .selnumber
1334
      jmp  .selnumber
1332
 
1335
 
1333
    .spade:
1336
    .spade:
1334
      mov  esi, [blackcolor]
1337
      mov  esi, [blackcolor]
1335
      mov  [color], esi
1338
      mov  [color], esi
1336
      mov  [imageaddr], spade
1339
      mov  [imageaddr], spade
1337
      mov  [imageflipaddr], spade_updown
1340
      mov  [imageflipaddr], spade_updown
1338
 
1341
 
1339
      mov ebx, spade_small
1342
      mov ebx, spade_small
1340
      mcall
1343
      mcall
1341
 
1344
 
1342
 
1345
 
1343
 
1346
 
1344
    .selnumber:
1347
    .selnumber:
1345
 
1348
 
1346
    mov    ebx, [xpos]       ; counting position of text
1349
    mov    ebx, [xpos]       ; counting position of text
1347
                             ; in ebx, same for all cards
1350
                             ; in ebx, same for all cards
1348
    add    ebx, radius
1351
    add    ebx, radius
1349
    shl    ebx, 16
1352
    shl    ebx, 16
1350
    mov    bx,  word [ypos]
1353
    mov    bx,  word [ypos]
1351
    add    bx,  radius
1354
    add    bx,  radius
1352
 
1355
 
1353
 
1356
 
1354
    mov    ecx, [color]
1357
    mov    ecx, [color]
1355
 
1358
 
1356
 
1359
 
1357
    cmp    [cardrange], 0
1360
    cmp    [cardrange], 0
1358
    je     .ace
1361
    je     .ace
1359
 
1362
 
1360
    cmp    [cardrange], 1
1363
    cmp    [cardrange], 1
1361
    je     .two
1364
    je     .two
1362
 
1365
 
1363
    cmp    [cardrange], 2
1366
    cmp    [cardrange], 2
1364
    je     .three
1367
    je     .three
1365
 
1368
 
1366
    cmp    [cardrange], 3
1369
    cmp    [cardrange], 3
1367
    je     .four
1370
    je     .four
1368
 
1371
 
1369
    cmp    [cardrange], 4
1372
    cmp    [cardrange], 4
1370
    je     .five
1373
    je     .five
1371
 
1374
 
1372
    cmp    [cardrange], 5
1375
    cmp    [cardrange], 5
1373
    je     .six
1376
    je     .six
1374
 
1377
 
1375
    cmp    [cardrange], 6
1378
    cmp    [cardrange], 6
1376
    je     .seven
1379
    je     .seven
1377
 
1380
 
1378
    cmp    [cardrange], 7
1381
    cmp    [cardrange], 7
1379
    je     .eight
1382
    je     .eight
1380
 
1383
 
1381
    cmp    [cardrange], 8
1384
    cmp    [cardrange], 8
1382
    je     .nine
1385
    je     .nine
1383
 
1386
 
1384
    cmp    [cardrange], 9
1387
    cmp    [cardrange], 9
1385
    je     .ten
1388
    je     .ten
1386
 
1389
 
1387
    cmp    [cardrange], 10
1390
    cmp    [cardrange], 10
1388
    je     .jack
1391
    je     .jack
1389
 
1392
 
1390
    cmp    [cardrange], 11
1393
    cmp    [cardrange], 11
1391
    je     .queen
1394
    je     .queen
1392
 
1395
 
1393
    cmp    [cardrange], 12
1396
    cmp    [cardrange], 12
1394
    je     .king
1397
    je     .king
1395
 
1398
 
1396
    ;      +-------+-------+-------+
1399
    ;      +-------+-------+-------+
1397
    ;      |   3   |   2   |   3   |   ace   = 1
1400
    ;      |   3   |   2   |   3   |   ace   = 1
1398
    ;      +-------+-------+-------+   two   = 2
1401
    ;      +-------+-------+-------+   two   = 2
1399
    ;      |       |       |       |   three = 2 + 1
1402
    ;      |       |       |       |   three = 2 + 1
1400
    ;      +-------+-------+-------+   four  = 3
1403
    ;      +-------+-------+-------+   four  = 3
1401
    ;      |       |   6   |       |   five  = 3 + 1
1404
    ;      |       |   6   |       |   five  = 3 + 1
1402
    ;      +-------+-------+-------+   six   = 3 + 4
1405
    ;      +-------+-------+-------+   six   = 3 + 4
1403
    ;      |   5   |       |   5   |   seven = 3 + 4 + 6
1406
    ;      |   5   |       |   5   |   seven = 3 + 4 + 6
1404
    ;      +-------+-------+-------+   eight = 3 + 5
1407
    ;      +-------+-------+-------+   eight = 3 + 5
1405
    ;      |   4   |   1   |   4   |   nine  = 3 + 5
1408
    ;      |   4   |   1   |   4   |   nine  = 3 + 5
1406
    ;      +-------+-------+-------+   ten   = 3 + 5 + 6 + 7
1409
    ;      +-------+-------+-------+   ten   = 3 + 5 + 6 + 7
1407
    ;      |   5   |       |   5   |
1410
    ;      |   5   |       |   5   |
1408
    ;      +-------+-------+-------+
1411
    ;      +-------+-------+-------+
1409
    ;      |       |   7   |       |   1 means draw_1
1412
    ;      |       |   7   |       |   1 means draw_1
1410
    ;      +-------+-------+-------+
1413
    ;      +-------+-------+-------+
1411
    ;      |       |       |       |
1414
    ;      |       |       |       |
1412
    ;      +-------+-------+-------+
1415
    ;      +-------+-------+-------+
1413
    ;      |   3   |   2   |   3   |
1416
    ;      |   3   |   2   |   3   |
1414
    ;      +-------+-------+-------+
1417
    ;      +-------+-------+-------+
1415
 
1418
 
1416
 
1419
 
1417
 
1420
 
1418
    .ace:
1421
    .ace:
1419
      mov  eax, 4
1422
      mov  eax, 4
1420
      mov  [s], byte 'A'
1423
      mov  [s], byte 'A'
1421
      mov  edx, s
1424
      mov  edx, s
1422
      mov  esi, 1
1425
      mov  esi, 1
1423
      mcall
1426
      mcall
1424
 
1427
 
1425
      call draw_1
1428
      call draw_1
1426
      jmp .end
1429
      jmp .end
1427
 
1430
 
1428
    .two:
1431
    .two:
1429
      mov  eax, 4
1432
      mov  eax, 4
1430
      mov  [s], byte '2'
1433
      mov  [s], byte '2'
1431
      mov  edx, s
1434
      mov  edx, s
1432
      mov  esi, 1
1435
      mov  esi, 1
1433
      mcall
1436
      mcall
1434
 
1437
 
1435
      call draw_2
1438
      call draw_2
1436
      jmp .end
1439
      jmp .end
1437
 
1440
 
1438
 
1441
 
1439
    .three:
1442
    .three:
1440
      mov  eax, 4
1443
      mov  eax, 4
1441
      mov  [s], byte '3'
1444
      mov  [s], byte '3'
1442
      mov  edx, s
1445
      mov  edx, s
1443
      mov  esi, 1
1446
      mov  esi, 1
1444
      mcall
1447
      mcall
1445
 
1448
 
1446
      call draw_1
1449
      call draw_1
1447
      call draw_2
1450
      call draw_2
1448
 
1451
 
1449
      jmp  .end
1452
      jmp  .end
1450
 
1453
 
1451
    .four:
1454
    .four:
1452
      mov  eax, 4
1455
      mov  eax, 4
1453
      mov  [s], byte '4'
1456
      mov  [s], byte '4'
1454
      mov  edx, s
1457
      mov  edx, s
1455
      mov  esi, 1
1458
      mov  esi, 1
1456
      mcall
1459
      mcall
1457
 
1460
 
1458
      call draw_3
1461
      call draw_3
1459
      jmp  .end
1462
      jmp  .end
1460
 
1463
 
1461
    .five:
1464
    .five:
1462
      mov  eax, 4
1465
      mov  eax, 4
1463
      mov  [s], byte '5'
1466
      mov  [s], byte '5'
1464
      mov  edx, s
1467
      mov  edx, s
1465
      mov  esi, 1
1468
      mov  esi, 1
1466
      mcall
1469
      mcall
1467
 
1470
 
1468
      call draw_1
1471
      call draw_1
1469
      call draw_3
1472
      call draw_3
1470
 
1473
 
1471
      jmp  .end
1474
      jmp  .end
1472
 
1475
 
1473
    .six:
1476
    .six:
1474
      mov  eax, 4
1477
      mov  eax, 4
1475
      mov  [s], byte '6'
1478
      mov  [s], byte '6'
1476
      mov  edx, s
1479
      mov  edx, s
1477
      mov  esi, 1
1480
      mov  esi, 1
1478
      mcall
1481
      mcall
1479
 
1482
 
1480
      call draw_3
1483
      call draw_3
1481
      call draw_4
1484
      call draw_4
1482
 
1485
 
1483
      jmp  .end
1486
      jmp  .end
1484
 
1487
 
1485
    .seven:
1488
    .seven:
1486
      mov  eax, 4
1489
      mov  eax, 4
1487
      mov  [s], byte '7'
1490
      mov  [s], byte '7'
1488
      mov  edx, s
1491
      mov  edx, s
1489
      mov  esi, 1
1492
      mov  esi, 1
1490
      mcall
1493
      mcall
1491
 
1494
 
1492
      call draw_3
1495
      call draw_3
1493
      call draw_4
1496
      call draw_4
1494
      call draw_6
1497
      call draw_6
1495
 
1498
 
1496
      jmp  .end
1499
      jmp  .end
1497
 
1500
 
1498
    .eight:
1501
    .eight:
1499
      mov  eax, 4
1502
      mov  eax, 4
1500
      mov  [s], byte '8'
1503
      mov  [s], byte '8'
1501
      mov  edx, s
1504
      mov  edx, s
1502
      mov  esi, 1
1505
      mov  esi, 1
1503
      mcall
1506
      mcall
1504
 
1507
 
1505
      call draw_3
1508
      call draw_3
1506
      call draw_5
1509
      call draw_5
1507
 
1510
 
1508
      jmp  .end
1511
      jmp  .end
1509
 
1512
 
1510
    .nine:
1513
    .nine:
1511
      mov  eax, 4
1514
      mov  eax, 4
1512
      mov  [s], byte '9'
1515
      mov  [s], byte '9'
1513
      mov  edx, s
1516
      mov  edx, s
1514
      mov  esi, 1
1517
      mov  esi, 1
1515
      mcall
1518
      mcall
1516
 
1519
 
1517
      call draw_3
1520
      call draw_3
1518
      call draw_5
1521
      call draw_5
1519
      call draw_1
1522
      call draw_1
1520
 
1523
 
1521
      jmp  .end
1524
      jmp  .end
1522
 
1525
 
1523
    .ten:
1526
    .ten:
1524
      mov  eax, 4
1527
      mov  eax, 4
1525
      mov  [s], word '10'
1528
      mov  [s], word '10'
1526
      mov  edx, s
1529
      mov  edx, s
1527
      mov  esi, 2
1530
      mov  esi, 2
1528
      mcall
1531
      mcall
1529
 
1532
 
1530
      call draw_3
1533
      call draw_3
1531
      call draw_5
1534
      call draw_5
1532
      call draw_6
1535
      call draw_6
1533
      call draw_7
1536
      call draw_7
1534
 
1537
 
1535
      jmp  .end
1538
      jmp  .end
1536
 
1539
 
1537
    .jack:
1540
    .jack:
1538
      mov  eax, 4
1541
      mov  eax, 4
1539
      mov  [s], byte 'J'
1542
      mov  [s], byte 'J'
1540
      mov  edx, s
1543
      mov  edx, s
1541
      mov  esi, 1
1544
      mov  esi, 1
1542
      mcall
1545
      mcall
1543
 
1546
 
1544
      jmp  .end
1547
      jmp  .end
1545
 
1548
 
1546
    .queen:
1549
    .queen:
1547
      mov  eax, 4
1550
      mov  eax, 4
1548
      mov  [s], byte 'Q'
1551
      mov  [s], byte 'Q'
1549
      mov  edx, s
1552
      mov  edx, s
1550
      mov  esi, 1
1553
      mov  esi, 1
1551
      mcall
1554
      mcall
1552
 
1555
 
1553
      jmp  .end
1556
      jmp  .end
1554
 
1557
 
1555
    .king:
1558
    .king:
1556
      mov  eax, 4
1559
      mov  eax, 4
1557
      mov  [s], byte 'K'
1560
      mov  [s], byte 'K'
1558
      mov  edx,s
1561
      mov  edx,s
1559
      mov  esi, 1
1562
      mov  esi, 1
1560
      mcall
1563
      mcall
1561
 
1564
 
1562
    .end:
1565
    .end:
1563
 
1566
 
1564
 
1567
 
1565
    cmp  [negativedraw], 1
1568
    cmp  [negativedraw], 1
1566
    jne  .no_invert2
1569
    jne  .no_invert2
1567
 
1570
 
1568
    call invert_all_images
1571
    call invert_all_images
1569
 
1572
 
1570
 
1573
 
1571
    .no_invert2:
1574
    .no_invert2:
1572
    .no_draw_card:
1575
    .no_draw_card:
1573
 
1576
 
1574
  ret
1577
  ret
1575
 
1578
 
1576
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1579
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1577
;                            invert_all_images()
1580
;                            invert_all_images()
1578
  invert_all_images:
1581
  invert_all_images:
1579
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1582
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1580
    mov  [imagetoinvert], heart
1583
    mov  [imagetoinvert], heart
1581
    call invert_image_colors
1584
    call invert_image_colors
1582
 
1585
 
1583
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1586
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1584
    mov  [imagetoinvert], diamond
1587
    mov  [imagetoinvert], diamond
1585
    call invert_image_colors
1588
    call invert_image_colors
1586
 
1589
 
1587
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1590
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1588
    mov  [imagetoinvert], spade
1591
    mov  [imagetoinvert], spade
1589
    call invert_image_colors
1592
    call invert_image_colors
1590
 
1593
 
1591
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1594
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1592
    mov  [imagetoinvert], club
1595
    mov  [imagetoinvert], club
1593
    call invert_image_colors
1596
    call invert_image_colors
1594
 
1597
 
1595
 
1598
 
1596
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1599
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1597
    mov  [imagetoinvert], heart_updown
1600
    mov  [imagetoinvert], heart_updown
1598
    call invert_image_colors
1601
    call invert_image_colors
1599
 
1602
 
1600
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1603
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1601
    mov  [imagetoinvert], diamond_updown
1604
    mov  [imagetoinvert], diamond_updown
1602
    call invert_image_colors
1605
    call invert_image_colors
1603
 
1606
 
1604
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1607
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1605
    mov  [imagetoinvert], spade_updown
1608
    mov  [imagetoinvert], spade_updown
1606
    call invert_image_colors
1609
    call invert_image_colors
1607
 
1610
 
1608
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1611
    mov  [sizeofimagetoinvert], 16 * 16 * 3
1609
    mov  [imagetoinvert], club_updown
1612
    mov  [imagetoinvert], club_updown
1610
    call invert_image_colors
1613
    call invert_image_colors
1611
 
1614
 
1612
 
1615
 
1613
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1616
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1614
    mov  [imagetoinvert], heart_small
1617
    mov  [imagetoinvert], heart_small
1615
    call invert_image_colors
1618
    call invert_image_colors
1616
 
1619
 
1617
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1620
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1618
    mov  [imagetoinvert], diamond_small
1621
    mov  [imagetoinvert], diamond_small
1619
    call invert_image_colors
1622
    call invert_image_colors
1620
 
1623
 
1621
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1624
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1622
    mov  [imagetoinvert], spade_small
1625
    mov  [imagetoinvert], spade_small
1623
    call invert_image_colors
1626
    call invert_image_colors
1624
 
1627
 
1625
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1628
    mov  [sizeofimagetoinvert], 8 * 8 * 3
1626
    mov  [imagetoinvert], club_small
1629
    mov  [imagetoinvert], club_small
1627
    call invert_image_colors
1630
    call invert_image_colors
1628
 
1631
 
1629
 
1632
 
1630
 
1633
 
1631
  ret
1634
  ret
1632
 
1635
 
1633
 
1636
 
1634
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1637
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1635
 
1638
 
1636
  draw_1:
1639
  draw_1:
1637
                             ;draw center image
1640
                             ;draw center image
1638
      mov     ebx, [imageaddr]
1641
      mov     ebx, [imageaddr]
1639
      mov     ecx, 16 * 65536 + 16
1642
      mov     ecx, 16 * 65536 + 16
1640
      mov     edx, [xpos]
1643
      mov     edx, [xpos]
1641
      add     edx, cardwidth/2 - 8
1644
      add     edx, cardwidth/2 - 8
1642
      shl     edx, 16
1645
      shl     edx, 16
1643
      mov     dx, word [ypos]
1646
      mov     dx, word [ypos]
1644
      add     dx, cardheight/2 - 8
1647
      add     dx, cardheight/2 - 8
1645
      mov      eax, 7
1648
      mov      eax, 7
1646
      mcall
1649
      mcall
1647
  ret
1650
  ret
1648
 
1651
 
1649
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1652
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1650
 
1653
 
1651
 
1654
 
1652
  draw_2:
1655
  draw_2:
1653
                             ;draw top image
1656
                             ;draw top image
1654
      mov     ebx, [imageaddr]
1657
      mov     ebx, [imageaddr]
1655
      mov     ecx, 16 * 65536 + 16
1658
      mov     ecx, 16 * 65536 + 16
1656
      mov     edx, [xpos]
1659
      mov     edx, [xpos]
1657
      add     edx, 40 - 8
1660
      add     edx, 40 - 8
1658
      shl     edx, 16
1661
      shl     edx, 16
1659
      mov     dx, word [ypos]
1662
      mov     dx, word [ypos]
1660
      add     dx, margin
1663
      add     dx, margin
1661
      mov     eax, 7
1664
      mov     eax, 7
1662
      mcall
1665
      mcall
1663
                             ;draw bottom image
1666
                             ;draw bottom image
1664
      mov     ebx, [imageflipaddr]
1667
      mov     ebx, [imageflipaddr]
1665
      mov     edx, [xpos]
1668
      mov     edx, [xpos]
1666
      add     edx, cardwidth/2 - 8
1669
      add     edx, cardwidth/2 - 8
1667
      shl     edx, 16
1670
      shl     edx, 16
1668
      mov     dx, word [ypos]
1671
      mov     dx, word [ypos]
1669
      add     dx, cardheight - 16 - margin
1672
      add     dx, cardheight - 16 - margin
1670
      mov     eax, 7
1673
      mov     eax, 7
1671
      mcall
1674
      mcall
1672
  ret
1675
  ret
1673
 
1676
 
1674
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1677
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1675
 
1678
 
1676
  draw_3:
1679
  draw_3:
1677
                             ;draw top left image
1680
                             ;draw top left image
1678
      mov     ebx, [imageaddr]
1681
      mov     ebx, [imageaddr]
1679
      mov     ecx, 16 * 65536 + 16
1682
      mov     ecx, 16 * 65536 + 16
1680
      mov     edx, [xpos]
1683
      mov     edx, [xpos]
1681
      add     edx, margin
1684
      add     edx, margin
1682
      shl     edx, 16
1685
      shl     edx, 16
1683
      mov     dx, word [ypos]
1686
      mov     dx, word [ypos]
1684
      add     dx, margin
1687
      add     dx, margin
1685
      mov     eax, 7
1688
      mov     eax, 7
1686
      mcall
1689
      mcall
1687
                             ;draw bottom left image
1690
                             ;draw bottom left image
1688
      mov     ebx, [imageflipaddr]
1691
      mov     ebx, [imageflipaddr]
1689
      mov     edx, [xpos]
1692
      mov     edx, [xpos]
1690
      add     edx, margin
1693
      add     edx, margin
1691
      shl     edx, 16
1694
      shl     edx, 16
1692
      mov     dx, word [ypos]
1695
      mov     dx, word [ypos]
1693
      add     dx, cardheight - margin - 16
1696
      add     dx, cardheight - margin - 16
1694
      mov     eax, 7
1697
      mov     eax, 7
1695
      mcall
1698
      mcall
1696
                             ;draw top right image
1699
                             ;draw top right image
1697
      mov     ebx, [imageaddr]
1700
      mov     ebx, [imageaddr]
1698
      mov     edx, [xpos]
1701
      mov     edx, [xpos]
1699
      add     edx, cardwidth - margin - 16
1702
      add     edx, cardwidth - margin - 16
1700
      shl     edx, 16
1703
      shl     edx, 16
1701
      mov     dx, word [ypos]
1704
      mov     dx, word [ypos]
1702
      add     dx, margin
1705
      add     dx, margin
1703
      mov     eax, 7
1706
      mov     eax, 7
1704
      mcall
1707
      mcall
1705
                             ;draw bottom right image
1708
                             ;draw bottom right image
1706
      mov     ebx, [imageflipaddr]
1709
      mov     ebx, [imageflipaddr]
1707
      mov     edx, [xpos]
1710
      mov     edx, [xpos]
1708
      add     edx, cardwidth - margin - 16
1711
      add     edx, cardwidth - margin - 16
1709
      shl     edx, 16
1712
      shl     edx, 16
1710
      mov     dx, word [ypos]
1713
      mov     dx, word [ypos]
1711
      add     dx, cardheight - margin - 16
1714
      add     dx, cardheight - margin - 16
1712
      mov     eax, 7
1715
      mov     eax, 7
1713
      mcall
1716
      mcall
1714
  ret
1717
  ret
1715
 
1718
 
1716
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1719
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1717
 
1720
 
1718
  draw_4:
1721
  draw_4:
1719
                             ;draw center left image
1722
                             ;draw center left image
1720
      mov     ebx, [imageaddr]
1723
      mov     ebx, [imageaddr]
1721
      mov     ecx, 16 * 65536 + 16
1724
      mov     ecx, 16 * 65536 + 16
1722
      mov     edx, [xpos]
1725
      mov     edx, [xpos]
1723
      add     edx, margin
1726
      add     edx, margin
1724
      shl     edx, 16
1727
      shl     edx, 16
1725
      mov     dx, word [ypos]
1728
      mov     dx, word [ypos]
1726
      add     dx, cardheight/2 - 8
1729
      add     dx, cardheight/2 - 8
1727
      mov     eax, 7
1730
      mov     eax, 7
1728
      mcall
1731
      mcall
1729
                             ;draw center right image
1732
                             ;draw center right image
1730
      mov     edx, [xpos]
1733
      mov     edx, [xpos]
1731
      add     edx, cardwidth - margin - 16
1734
      add     edx, cardwidth - margin - 16
1732
      shl     edx, 16
1735
      shl     edx, 16
1733
      mov     dx, word [ypos]
1736
      mov     dx, word [ypos]
1734
      add     dx, cardheight/2 - 8
1737
      add     dx, cardheight/2 - 8
1735
      mov     eax, 7
1738
      mov     eax, 7
1736
      mcall
1739
      mcall
1737
  ret
1740
  ret
1738
 
1741
 
1739
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1742
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1740
 
1743
 
1741
  draw_5:
1744
  draw_5:
1742
                             ;draw top left image
1745
                             ;draw top left image
1743
      mov     ebx, [imageaddr]
1746
      mov     ebx, [imageaddr]
1744
      mov     ecx, 16 * 65536 + 16
1747
      mov     ecx, 16 * 65536 + 16
1745
      mov     edx, [xpos]
1748
      mov     edx, [xpos]
1746
      add     edx, margin
1749
      add     edx, margin
1747
      shl     edx, 16
1750
      shl     edx, 16
1748
      mov     dx, word [ypos]
1751
      mov     dx, word [ypos]
1749
      add     dx, cardheight * 3 / 9
1752
      add     dx, cardheight * 3 / 9
1750
      mov     eax, 7
1753
      mov     eax, 7
1751
      mcall
1754
      mcall
1752
                             ;draw bottom left image
1755
                             ;draw bottom left image
1753
      mov     ebx, [imageflipaddr]
1756
      mov     ebx, [imageflipaddr]
1754
      mov     edx, [xpos]
1757
      mov     edx, [xpos]
1755
      add     edx, 16
1758
      add     edx, 16
1756
      shl     edx, 16
1759
      shl     edx, 16
1757
      mov     dx, word [ypos]
1760
      mov     dx, word [ypos]
1758
      add     dx, cardheight * 5 / 9
1761
      add     dx, cardheight * 5 / 9
1759
      mov     eax, 7
1762
      mov     eax, 7
1760
      mcall
1763
      mcall
1761
                             ;draw top right image
1764
                             ;draw top right image
1762
      mov     ebx, [imageaddr]
1765
      mov     ebx, [imageaddr]
1763
      mov     edx, [xpos]
1766
      mov     edx, [xpos]
1764
      add     edx, cardwidth - margin - 16
1767
      add     edx, cardwidth - margin - 16
1765
      shl     edx, 16
1768
      shl     edx, 16
1766
      mov     dx, word [ypos]
1769
      mov     dx, word [ypos]
1767
      add     dx, cardheight * 3 / 9
1770
      add     dx, cardheight * 3 / 9
1768
      mov     eax, 7
1771
      mov     eax, 7
1769
      mcall
1772
      mcall
1770
                             ;draw bottom right image
1773
                             ;draw bottom right image
1771
      mov     ebx, [imageflipaddr]
1774
      mov     ebx, [imageflipaddr]
1772
      mov     edx, [xpos]
1775
      mov     edx, [xpos]
1773
      add     edx, cardwidth - margin - 16
1776
      add     edx, cardwidth - margin - 16
1774
      shl     edx, 16
1777
      shl     edx, 16
1775
      mov     dx, word [ypos]
1778
      mov     dx, word [ypos]
1776
      add     dx, cardheight * 5 / 9
1779
      add     dx, cardheight * 5 / 9
1777
      mov     eax, 7
1780
      mov     eax, 7
1778
      mcall
1781
      mcall
1779
  ret
1782
  ret
1780
 
1783
 
1781
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1784
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1782
 
1785
 
1783
  draw_6:
1786
  draw_6:
1784
      mov     ebx, [imageaddr]
1787
      mov     ebx, [imageaddr]
1785
      mov     ecx, 16 * 65536 + 16
1788
      mov     ecx, 16 * 65536 + 16
1786
      mov     edx, [xpos]
1789
      mov     edx, [xpos]
1787
      add     edx, cardwidth/2 - 8
1790
      add     edx, cardwidth/2 - 8
1788
      shl     edx, 16
1791
      shl     edx, 16
1789
      mov     dx, word [ypos]
1792
      mov     dx, word [ypos]
1790
      add     dx, cardheight * 2 / 9
1793
      add     dx, cardheight * 2 / 9
1791
      mov     eax, 7
1794
      mov     eax, 7
1792
      mcall
1795
      mcall
1793
  ret
1796
  ret
1794
 
1797
 
1795
 
1798
 
1796
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1799
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1797
  draw_7:
1800
  draw_7:
1798
      mov     ebx, [imageflipaddr]
1801
      mov     ebx, [imageflipaddr]
1799
      mov     ecx, 16 * 65536 + 16
1802
      mov     ecx, 16 * 65536 + 16
1800
      mov     edx, [xpos]
1803
      mov     edx, [xpos]
1801
      add     edx, cardwidth/2 - 8
1804
      add     edx, cardwidth/2 - 8
1802
      shl     edx, 16
1805
      shl     edx, 16
1803
      mov     dx, word [ypos]
1806
      mov     dx, word [ypos]
1804
      add     dx, cardheight * 6 / 9
1807
      add     dx, cardheight * 6 / 9
1805
      mov     eax, 7
1808
      mov     eax, 7
1806
      mcall
1809
      mcall
1807
  ret
1810
  ret
1808
 
1811
 
1809
 
1812
 
1810
;******************************************************************************
1813
;******************************************************************************
1811
  randomize:
1814
  randomize:
1812
    push eax
1815
    push eax
1813
 
1816
 
1814
    mov  eax, 3
1817
    mov  eax, 3
1815
    mcall
1818
    mcall
1816
 
1819
 
1817
    mov  ebx, $A59E3F1C
1820
    mov  ebx, $A59E3F1C
1818
    mul  ebx
1821
    mul  ebx
1819
    mov  dword [randseed], eax
1822
    mov  dword [randseed], eax
1820
    pop  eax
1823
    pop  eax
1821
  ret
1824
  ret
1822
 
1825
 
1823
 
1826
 
1824
 
1827
 
1825
;******************************************************************************
1828
;******************************************************************************
1826
;          function Random(Range): RandomValue
1829
;          function Random(Range): RandomValue
1827
  random:
1830
  random:
1828
    push ebx
1831
    push ebx
1829
 
1832
 
1830
    mov  eax, [randseed]
1833
    mov  eax, [randseed]
1831
    mov  edx, 0
1834
    mov  edx, 0
1832
    mov  ebx, 7
1835
    mov  ebx, 7
1833
    div  ebx
1836
    div  ebx
1834
 
1837
 
1835
    cmp  edx, 0
1838
    cmp  edx, 0
1836
    je   _0
1839
    je   _0
1837
 
1840
 
1838
    cmp  edx, 1
1841
    cmp  edx, 1
1839
    je   _1
1842
    je   _1
1840
 
1843
 
1841
    cmp  edx, 2
1844
    cmp  edx, 2
1842
    je   _2
1845
    je   _2
1843
 
1846
 
1844
    cmp  edx, 3
1847
    cmp  edx, 3
1845
    je   _3
1848
    je   _3
1846
 
1849
 
1847
    cmp  edx, 4
1850
    cmp  edx, 4
1848
    je   _4
1851
    je   _4
1849
 
1852
 
1850
    cmp  edx, 5
1853
    cmp  edx, 5
1851
    je   _5
1854
    je   _5
1852
 
1855
 
1853
    cmp  edx, 6
1856
    cmp  edx, 6
1854
    je   _6
1857
    je   _6
1855
 
1858
 
1856
    jmp  _end
1859
    jmp  _end
1857
 
1860
 
1858
 
1861
 
1859
    _0:
1862
    _0:
1860
      ;base := base + 58 + a[8];
1863
      ;base := base + 58 + a[8];
1861
      mov  eax, [randseed]
1864
      mov  eax, [randseed]
1862
      add  eax, 58
1865
      add  eax, 58
1863
      add  eax, dword [a + 8 * 4]
1866
      add  eax, dword [a + 8 * 4]
1864
      mov  [randseed], eax
1867
      mov  [randseed], eax
1865
      jmp  _end;
1868
      jmp  _end;
1866
 
1869
 
1867
    _1:
1870
    _1:
1868
      ;base := base + 1 + a[9];
1871
      ;base := base + 1 + a[9];
1869
      mov  eax, [randseed]
1872
      mov  eax, [randseed]
1870
      add  eax, 1
1873
      add  eax, 1
1871
      add  eax, dword [a + 9 * 4]
1874
      add  eax, dword [a + 9 * 4]
1872
      mov  [randseed], eax
1875
      mov  [randseed], eax
1873
      jmp _end;
1876
      jmp _end;
1874
 
1877
 
1875
    _2:
1878
    _2:
1876
      ;base := base + 4 + a[88];
1879
      ;base := base + 4 + a[88];
1877
      mov  eax, [randseed]
1880
      mov  eax, [randseed]
1878
      add  eax, 4
1881
      add  eax, 4
1879
      add  eax, dword [a + 88 * 4]
1882
      add  eax, dword [a + 88 * 4]
1880
      mov  [randseed], eax
1883
      mov  [randseed], eax
1881
      jmp _end;
1884
      jmp _end;
1882
 
1885
 
1883
    _3:
1886
    _3:
1884
      ;randseed := randseed + 79 + a[43];
1887
      ;randseed := randseed + 79 + a[43];
1885
      mov  eax, [randseed]
1888
      mov  eax, [randseed]
1886
      add  eax, 79
1889
      add  eax, 79
1887
      add  eax, dword [a + 43 * 4]
1890
      add  eax, dword [a + 43 * 4]
1888
      mov  [randseed], eax
1891
      mov  [randseed], eax
1889
      jmp _end;
1892
      jmp _end;
1890
 
1893
 
1891
    _4:
1894
    _4:
1892
      ;randseed := randseed + 3 + a[12];
1895
      ;randseed := randseed + 3 + a[12];
1893
      mov  eax, [randseed]
1896
      mov  eax, [randseed]
1894
      add  eax, 3
1897
      add  eax, 3
1895
      add  eax, dword [a + 12 * 4]
1898
      add  eax, dword [a + 12 * 4]
1896
      mov  [randseed], eax
1899
      mov  [randseed], eax
1897
      jmp _end;
1900
      jmp _end;
1898
 
1901
 
1899
    _5:
1902
    _5:
1900
      ;randseed := randseed + 2 + a[63];
1903
      ;randseed := randseed + 2 + a[63];
1901
      mov  eax, [randseed]
1904
      mov  eax, [randseed]
1902
      add  eax, 2
1905
      add  eax, 2
1903
      add  eax, dword [a + 63 * 4]
1906
      add  eax, dword [a + 63 * 4]
1904
      mov  [randseed], eax
1907
      mov  [randseed], eax
1905
      jmp _end;
1908
      jmp _end;
1906
 
1909
 
1907
    _6:
1910
    _6:
1908
      ;randseed := randseed + 151 + a[24];
1911
      ;randseed := randseed + 151 + a[24];
1909
      mov  eax, [randseed]
1912
      mov  eax, [randseed]
1910
      add  eax, 151
1913
      add  eax, 151
1911
      add  eax, dword [a + 24 * 4]
1914
      add  eax, dword [a + 24 * 4]
1912
      mov  [randseed], eax
1915
      mov  [randseed], eax
1913
 
1916
 
1914
      _end:
1917
      _end:
1915
 
1918
 
1916
    mov  eax, [randseed]
1919
    mov  eax, [randseed]
1917
    mov  edx, eax
1920
    mov  edx, eax
1918
    shl  edx, 16
1921
    shl  edx, 16
1919
    mov  bx, 100
1922
    mov  bx, 100
1920
    div  bx                   ; dx = randseed mod 100
1923
    div  bx                   ; dx = randseed mod 100
1921
 
1924
 
1922
    mov  ax, dx               ; ax = randseed mod 100
1925
    mov  ax, dx               ; ax = randseed mod 100
1923
    mov  bx, 4
1926
    mov  bx, 4
1924
    mul  bx                   ; dx:ax = (randseed mod 100) * 4
1927
    mul  bx                   ; dx:ax = (randseed mod 100) * 4
1925
    and  eax, $0000FFFF
1928
    and  eax, $0000FFFF
1926
    shr  edx, 16
1929
    shr  edx, 16
1927
    and  edx, $FFFF0000
1930
    and  edx, $FFFF0000
1928
    or   eax, edx
1931
    or   eax, edx
1929
 
1932
 
1930
    mov  eax, dword [a + eax] ; eax = dword[a + (randseed mod 100) * 4]
1933
    mov  eax, dword [a + eax] ; eax = dword[a + (randseed mod 100) * 4]
1931
                            ; ~ a[randseed mod 100]
1934
                            ; ~ a[randseed mod 100]
1932
    mov  ebx, dword [a + 47 * 4]
1935
    mov  ebx, dword [a + 47 * 4]
1933
    mul  ebx                  ; eax = low(a[randseed mod 100] * a[47])
1936
    mul  ebx                  ; eax = low(a[randseed mod 100] * a[47])
1934
 
1937
 
1935
    add  eax, [randseed]
1938
    add  eax, [randseed]
1936
    add  eax, $4AE783A
1939
    add  eax, $4AE783A
1937
    mov  [randseed], eax
1940
    mov  [randseed], eax
1938
 
1941
 
1939
    mov  eax, dword [a + 6 * 4]
1942
    mov  eax, dword [a + 6 * 4]
1940
    mov  edx, 0
1943
    mov  edx, 0
1941
    mov  ebx,  100
1944
    mov  ebx,  100
1942
    div  ebx
1945
    div  ebx
1943
    mov  eax, edx
1946
    mov  eax, edx
1944
    mov  ebx, 4
1947
    mov  ebx, 4
1945
    mul  ebx                  ; eax = (dword [a + 6 * 4] mod 100) * 4 ~ a[6] mod 100
1948
    mul  ebx                  ; eax = (dword [a + 6 * 4] mod 100) * 4 ~ a[6] mod 100
1946
 
1949
 
1947
 
1950
 
1948
    mov  eax, dword [a + eax] ; eax = dword [a + (dword [a + 6 * 4] mod 100) * 4
1951
    mov  eax, dword [a + eax] ; eax = dword [a + (dword [a + 6 * 4] mod 100) * 4
1949
 
1952
 
1950
                            ; ~ a[a[6] mod 100]
1953
                            ; ~ a[a[6] mod 100]
1951
    add  eax, [randseed]
1954
    add  eax, [randseed]
1952
    mov  [random_value], eax
1955
    mov  [random_value], eax
1953
 
1956
 
1954
    mov  edx, 0
1957
    mov  edx, 0
1955
 
1958
 
1956
    mov  ebx, [range]
1959
    mov  ebx, [range]
1957
    div  ebx
1960
    div  ebx
1958
    mov  [random_value], edx
1961
    mov  [random_value], edx
1959
 
1962
 
1960
    mov  al, [TimesCalled]
1963
    mov  al, [TimesCalled]
1961
    xor  ah, ah
1964
    xor  ah, ah
1962
    inc  al
1965
    inc  al
1963
    mov  bl, 100
1966
    mov  bl, 100
1964
    div  bl
1967
    div  bl
1965
    mov  [TimesCalled], ah   ; TimesCalled = (TimesCalled + 1 ) mod 100
1968
    mov  [TimesCalled], ah   ; TimesCalled = (TimesCalled + 1 ) mod 100
1966
 
1969
 
1967
    mov  al, ah
1970
    mov  al, ah
1968
    mov  bl, 4
1971
    mov  bl, 4
1969
    mul  bl
1972
    mul  bl
1970
    and  eax, $0000FFFF
1973
    and  eax, $0000FFFF
1971
 
1974
 
1972
    mov  ebx, [randseed]
1975
    mov  ebx, [randseed]
1973
    mov  dword [a + eax], ebx ; a[TimesCalled] = randseed
1976
    mov  dword [a + eax], ebx ; a[TimesCalled] = randseed
1974
 
1977
 
1975
    pop  ebx
1978
    pop  ebx
1976
  ret
1979
  ret
1977
 
1980
 
1978
;******************************************************************************
1981
;******************************************************************************
1979
 
1982
 
1980
; <--- initialised data --->
1983
; <--- initialised data --->
1981
if lang eq ru
1984
if lang eq ru
1982
  title db '‘®«¨â¥à',0
1985
  title db '‘®«¨â¥à',0
1983
 
1986
 
1984
  new_game: db "®¢ ï ¨£à "
1987
  new_game: db "®¢ ï ¨£à "
1985
  new_game_len = $ - new_game
1988
  new_game_len = $ - new_game
1986
 
1989
 
1987
  exit: db "‚ë室"
1990
  exit: db "‚ë室"
1988
  exit_len = $ - exit
1991
  exit_len = $ - exit
1989
 
1992
 
1990
  s: db "10"
1993
  s: db "10"
1991
 
1994
 
1992
else
1995
else
1993
  title db 'Freecell',0
1996
  title db 'Freecell',0
1994
 
1997
 
1995
  new_game: db "New game"
1998
  new_game: db "New game"
1996
  new_game_len = $ - new_game
1999
  new_game_len = $ - new_game
1997
 
2000
 
1998
  exit: db "Exit"
2001
  exit: db "Exit"
1999
  exit_len = $ - exit
2002
  exit_len = $ - exit
2000
 
2003
 
2001
  s: db "10"
2004
  s: db "10"
2002
end if
2005
end if
2003
 
2006
 
2004
  negativedraw db 0          ; for procedure draw_card
2007
  negativedraw db 0          ; for procedure draw_card
2005
 
2008
 
2006
 
2009
 
2007
  spade          file 'Spade.bmp': 54
2010
  spade          file 'Spade.bmp': 54
2008
  spade_updown   file 'SpadeUD.bmp': 54
2011
  spade_updown   file 'SpadeUD.bmp': 54
2009
  spade_small    file 'SpadeSml.bmp': 54
2012
  spade_small    file 'SpadeSml.bmp': 54
2010
 
2013
 
2011
  club           file 'Club.bmp': 54
2014
  club           file 'Club.bmp': 54
2012
  club_updown    file 'ClubUD.bmp': 54
2015
  club_updown    file 'ClubUD.bmp': 54
2013
  club_small     file 'ClubSml.bmp': 54
2016
  club_small     file 'ClubSml.bmp': 54
2014
 
2017
 
2015
  diamond        file 'Diam.bmp': 54
2018
  diamond        file 'Diam.bmp': 54
2016
  diamond_updown file 'DiamUD.bmp': 54
2019
  diamond_updown file 'DiamUD.bmp': 54
2017
  diamond_small  file 'DiamSml.bmp': 54
2020
  diamond_small  file 'DiamSml.bmp': 54
2018
 
2021
 
2019
  heart          file 'Heart.bmp': 54
2022
  heart          file 'Heart.bmp': 54
2020
  heart_updown   file 'HeartUD.bmp': 54
2023
  heart_updown   file 'HeartUD.bmp': 54
2021
  heart_small    file 'HeartSml.bmp': 54
2024
  heart_small    file 'HeartSml.bmp': 54
2022
 
2025
 
2023
 
2026
 
2024
  scNotSelected = 0
2027
  scNotSelected = 0
2025
  scCommonCells = 1
2028
  scCommonCells = 1
2026
  scTempCells = 2
2029
  scTempCells = 2
2027
 
2030
 
2028
 
2031
 
2029
  whereisselcard  dd scNotSelected
2032
  whereisselcard  dd scNotSelected
2030
  columnofselcard dd 0       ; if WhereIsSelCard = scGeneralCells
2033
  columnofselcard dd 0       ; if WhereIsSelCard = scGeneralCells
2031
                             ;    then this can be 0 .. 7,
2034
                             ;    then this can be 0 .. 7,
2032
                             ; if scTempCells then - 0 .. 3
2035
                             ; if scTempCells then - 0 .. 3
2033
                             ; if scNotSelected - no matter
2036
                             ; if scNotSelected - no matter
2034
 
2037
 
2035
  tempcells: times 4 db 52;
2038
  tempcells: times 4 db 52;
2036
  homecells: times 4 db 52 ; maximal card code is 51
2039
  homecells: times 4 db 52 ; maximal card code is 51
2037
  cards:     times 8 * 19 db 52; - %
2040
  cards:     times 8 * 19 db 52; - %
2038
  pack:      times 52 db ?
2041
  pack:      times 52 db ?
2039
 
2042
 
2040
 
2043
 
2041
 
2044
 
2042
udata
2045
udata
2043
  process_info process_information
2046
  process_info process_information
2044
  syscolors system_colors
2047
  syscolors system_colors
2045
 
2048
 
2046
  WindowHeight rw 1
2049
  WindowHeight rw 1
2047
  WindowWidth rw 1
2050
  WindowWidth rw 1
2048
 
2051
 
2049
  xpos rd 1
2052
  xpos rd 1
2050
  ypos rd 1
2053
  ypos rd 1
2051
  bgcolor rd 1
2054
  bgcolor rd 1
2052
  blackcolor rd 1
2055
  blackcolor rd 1
2053
  redcolor rd 1
2056
  redcolor rd 1
2054
 
2057
 
2055
 
2058
 
2056
  lastparam rd 1                  ;
2059
  lastparam rd 1                  ;
2057
 
2060
 
2058
  randomcard rd 1                ; for new_game_click
2061
  randomcard rd 1                ; for new_game_click
2059
 
2062
 
2060
  columnclicked rd 1             ; used in common_card_click, temp_cell_click,
2063
  columnclicked rd 1             ; used in common_card_click, temp_cell_click,
2061
  cardclicked rd 1               ;    home_cell_click
2064
  cardclicked rd 1               ;    home_cell_click
2062
  clickedcardrange rd 1          ;
2065
  clickedcardrange rd 1          ;
2063
  clickedcardfamily rd 1         ;
2066
  clickedcardfamily rd 1         ;
2064
 
2067
 
2065
 
2068
 
2066
  selcardcode rd 1               ; for procedure get_sel_card_code_and_addr
2069
  selcardcode rd 1               ; for procedure get_sel_card_code_and_addr
2067
  selcardaddr rd 1               ;
2070
  selcardaddr rd 1               ;
2068
 
2071
 
2069
  column rd 1                    ; for procedure draw_window
2072
  column rd 1                    ; for procedure draw_window
2070
  row rd 1                          ;
2073
  row rd 1                          ;
2071
 
2074
 
2072
  imagetoinvert rd 1             ; for procedure invert_image_colors
2075
  imagetoinvert rd 1             ; for procedure invert_image_colors
2073
  sizeofimagetoinvert rd 1       ;
2076
  sizeofimagetoinvert rd 1       ;
2074
 
2077
 
2075
  ncolumn rd 1                   ; for procedure get_row_of_top_card_in_column
2078
  ncolumn rd 1                   ; for procedure get_row_of_top_card_in_column
2076
  topcardrow rd 1                ;
2079
  topcardrow rd 1                ;
2077
 
2080
 
2078
 
2081
 
2079
  color rd 1                     ; for procedue draw_card
2082
  color rd 1                     ; for procedue draw_card
2080
  imageaddr rd 1                 ;
2083
  imageaddr rd 1                 ;
2081
  imageflipaddr rd 1             ;
2084
  imageflipaddr rd 1             ;
2082
 
2085
 
2083
  cardcode rd 1                  ; used in differrent procedures
2086
  cardcode rd 1                  ; used in differrent procedures
2084
  cardrange rd 1                 ; cardcode = cardrange * 4 + cardfamily
2087
  cardrange rd 1                 ; cardcode = cardrange * 4 + cardfamily
2085
  cardfamily rd 1                ;
2088
  cardfamily rd 1                ;
2086
 
2089
 
2087
  a: times 100 rd 1              ; for function Random
2090
  a: times 100 rd 1              ; for function Random
2088
  range rd 1                     ;
2091
  range rd 1                     ;
2089
  random_value rd 1              ;
2092
  random_value rd 1              ;
2090
  randseed rd 1                  ;
2093
  randseed rd 1                  ;
2091
  TimesCalled rb 1               ;
2094
  TimesCalled rb 1               ;
2092
 
2095
 
2093
  j rd 1                         ; number of card (in array cards) drawn now
2096
  j rd 1                         ; number of card (in array cards) drawn now
2094
  i rd 1                         ; used in many procedures of 1-st level
2097
  i rd 1                         ; used in many procedures of 1-st level
2095
  k rd 1
2098
  k rd 1
2096
 
2099
 
2097
  cardwidth = 80
2100
  cardwidth = 80
2098
  cardheight = 120
2101
  cardheight = 120
2099
  radius = 4                     ; not recommended to change
2102
  radius = 4                     ; not recommended to change
2100
  rowsize = 30                   ; distance between top poins
2103
  rowsize = 30                   ; distance between top poins
2101
                                 ;of cards in neighboring rows
2104
                                 ;of cards in neighboring rows
2102
  columnspace = 5                ; minimal space between cards
2105
  columnspace = 5                ; minimal space between cards
2103
  margin = 14                       ; margin of every card
2106
  margin = 14                       ; margin of every card
2104
 
2107
 
2105
  topbuttonsbarheight = 20
2108
  topbuttonsbarheight = 20
2106
 
2109
 
2107
 
2110
 
2108
meos_app_end
2111
meos_app_end