Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 551 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 485
Line 2... Line 2...
2
;   The famous game 15
2
;   The famous game 15
3
;   Author: Lloyd, coded by Ivushkin Andrey
3
;   Author: Lloyd, coded by Ivushkin Andrey
4
;   Compile with FASM
4
;   Compile with FASM
5
;
5
;
6
include 'lang.inc'
6
include 'lang.inc'
7
include 'macros.inc' ; decreases program size (not required)
7
include '..\..\..\macros.inc' ; decreases program size (not required)
Line 8... Line -...
8
 
-
 
9
BgdColor equ 0x02aabbcc
8
 
10
StatusColor equ 0x02ffffff
9
StatusColor equ 0x02ffffff
11
StatusColor2 equ 0x02dc1e14
10
StatusColor2 equ 0x02dc1e14
Line 12... Line 11...
12
BgdColor equ 0x03aabbcc
11
BgdColor equ 0x03aabbcc
Line 61... Line 60...
61
 
60
 
62
 
61
 
63
START:
62
START:
64
    mov  [cptr],CONF_COUNT  ; number of task
63
    mov  [cptr],CONF_COUNT  ; number of task
65
    mov  eax,3
64
    mov  eax,3
66
    int  0x40
65
    mcall
67
    mov  cl,16
66
    mov  cl,16
68
    ror  eax,cl
67
    ror  eax,cl
69
    mov  [generator],eax    ; random generator from Tetris
68
    mov  [generator],eax    ; random generator from Tetris
Line 95... Line 94...
95
    call draw_window
94
    call draw_window
Line 96... Line 95...
96
 
95
 
Line 97... Line 96...
97
still:                  ; MAIN PROGRAM CYCLE
96
still:                  ; MAIN PROGRAM CYCLE
98
 
97
 
Line 99... Line 98...
99
    mov  eax,10         ; wait for event
98
    mov  eax,10         ; wait for event
100
    int  0x40
99
    mcall
101
 
100
 
102
    cmp  eax,1          ; redraw? -
101
    cmp  eax,1          ; redraw? -
Line 108... Line 107...
108
 
107
 
Line 109... Line 108...
109
    jmp  still          ; no more events to process
108
    jmp  still          ; no more events to process
110
 
109
 
111
  key:                  ; Key pressed
110
  key:                  ; Key pressed
112
    mov  eax,2
111
    mov  eax,2
113
    int  0x40
112
    mcall
114
    shr  eax,8
113
    shr  eax,8
115
    cmp  eax,32         ;  = Shuffle
114
    cmp  eax,32         ;  = Shuffle
116
    je   SHUF
115
    je   SHUF
Line 124... Line 123...
124
    movzx eax,byte [eax+correct] ; 'delta' value from correct[]
123
    movzx eax,byte [eax+correct] ; 'delta' value from correct[]
125
    jmp  m_check
124
    jmp  m_check
Line 126... Line 125...
126
 
125
 
127
  button:              ; Button pressed
126
  button:              ; Button pressed
128
    mov  eax,17
127
    mov  eax,17
129
    int  0x40
128
    mcall
130
    shr  eax,8
129
    shr  eax,8
Line 131... Line 130...
131
    sub  eax,2
130
    sub  eax,2
132
 
131
 
133
    cmp  eax,-1        ; id == 1 (closeme)?
132
    cmp  eax,-1        ; id == 1 (closeme)?
Line 134... Line 133...
134
    jne  noclose
133
    jne  noclose
135
    int  0x40
134
    mcall
136
 
135
 
137
  noclose:
136
  noclose:
Line 158... Line 157...
158
;   *******************************
157
;   *******************************
Line 159... Line 158...
159
 
158
 
160
draw_window:
159
draw_window:
161
    mov  eax,12
160
    mov  eax,12
162
    mov  ebx,1                     ; begin draw
161
    mov  ebx,1                     ; begin draw
Line 163... Line 162...
163
    int  0x40
162
    mcall
164
 
163
 
165
                                   ; CREATING WINDOW
164
                                   ; CREATING WINDOW
166
    mov  eax,0
165
    mov  eax,0
167
    mov  ebx,XXwindow
166
    mov  ebx,XXwindow
168
    mov  ecx,YYwindow
167
    mov  ecx,YYwindow
169
    mov  edx,BgdColor
168
    mov  edx,BgdColor
170
    mov  esi,0x805080d0
169
    mov  esi,0x805080d0
Line 171... Line 170...
171
    mov  edi,0x005080d0
170
    mov  edi,0x005080d0
172
    int  0x40
171
    mcall
173
 
172
 
174
                                   ; PROGRAM TITLE
173
                                   ; PROGRAM TITLE
175
    mov  eax,4
174
    mov  eax,4
176
    mov  ebx,8*65536+8
175
    mov  ebx,8*65536+8
177
    mov  ecx,0x10ddeeff
176
    mov  ecx,0x10000000
Line 178... Line 177...
178
    mov  edx,txtTitle
177
    mov  edx,txtTitle
179
    mov  esi,lenTitle-txtTitle
178
    mov  esi,lenTitle-txtTitle
180
    int  0x40
179
    mcall
181
 
180
 
182
    mov  eax,8                     ; SHUFFLE BUTTON
181
    mov  eax,8                     ; SHUFFLE BUTTON
183
    mov  ebx,XXSh
182
    mov  ebx,XXSh
Line 184... Line 183...
184
    mov  ecx,YYSh
183
    mov  ecx,YYSh
185
    xor  edx,edx
184
    xor  edx,edx
186
    mov  esi,BtnColor
185
    mov  esi,BtnColor
187
    int  0x40
186
    mcall
188
 
187
 
Line 189... Line 188...
189
    mov  ebx,XXCnf                  ; CONF BUTTON
188
    mov  ebx,XXCnf                  ; CONF BUTTON
190
    mov  ecx,YYCnf
189
    mov  ecx,YYCnf
191
    mov  edx,20
190
    mov  edx,20
192
    mov  esi,BtnColor
191
    mov  esi,BtnColor
193
    int  0x40
192
    mcall
194
 
193
 
Line 195... Line 194...
195
    mov  ebx, XYShText             ; SHUFFLE TEXT
194
    mov  ebx, XYShText             ; SHUFFLE TEXT
196
    mov  ecx, StatusColor
195
    mov  ecx, StatusColor
197
    mov  edx,txtSh
196
    mov  edx,txtSh
198
    mov  esi,lenSh-txtSh
197
    mov  esi,lenSh-txtSh
Line 199... Line 198...
199
    mov  eax,4
198
    mov  eax,4
200
    int  0x40
199
    mcall
201
 
200
 
202
    mov  ebx, XYCnfText             ; CONF TEXT
201
    mov  ebx, XYCnfText             ; CONF TEXT
Line 203... Line 202...
203
    mov  edx,lenVictory-1
202
    mov  edx,lenVictory-1
Line 204... Line 203...
204
    mov  esi,1
203
    mov  esi,1
205
    int  0x40
204
    mcall
206
 
205
 
207
    mov  ecx, 16                   ; FIELD BUTTONS
206
    mov  ecx, 16                   ; FIELD BUTTONS
Line 208... Line 207...
208
  dbut:
207
  dbut:
209
    call draw_button
208
    call draw_button
Line 248... Line 247...
248
    pusha
247
    pusha
249
    inc  ebx
248
    inc  ebx
250
    inc  ecx
249
    inc  ecx
251
    mov  edx,BgdColor
250
    mov  edx,BgdColor
252
    mov  eax,13         ; clearing - 'hole'
251
    mov  eax,13         ; clearing - 'hole'
253
    int  0x40
252
    mcall
254
    popa
253
    popa
Line 255... Line 254...
255
 
254
 
256
    or   edx,0x80000000 ; and removing button under it
255
    or   edx,0x80000000 ; and removing button under it
257
no_hole:
256
no_hole:
Line 263... Line 262...
263
    jmp  s_rbutton
262
    jmp  s_rbutton
264
highlight:
263
highlight:
265
    mov  esi,BtnColor2
264
    mov  esi,BtnColor2
266
s_rbutton:
265
s_rbutton:
267
    mov  eax,8          ; set/remove button
266
    mov  eax,8          ; set/remove button
268
    int  0x40
267
    mcall
269
    movzx eax,byte [null]
268
    movzx eax,byte [null]
270
    cmp  eax,edi
269
    cmp  eax,edi
271
    je   no_text        ; no digits - that's hole
270
    je   no_text        ; no digits - that's hole
272
    mov  edx,ebx
271
    mov  edx,ebx
273
    shr  ecx,16
272
    shr  ecx,16
Line 280... Line 279...
280
    add  edx,NumShift2    ; shift to center digits
279
    add  edx,NumShift2    ; shift to center digits
281
    sub  ebx,0x10000
280
    sub  ebx,0x10000
282
two_num:
281
two_num:
283
    mov  esi,NumColor
282
    mov  esi,NumColor
284
    mov  eax,47
283
    mov  eax,47
285
    int  0x40
284
    mcall
286
no_text:
285
no_text:
287
    popa
286
    popa
288
    ret
287
    ret
Line 295... Line 294...
295
draw_moves:
294
draw_moves:
296
    mov  eax, 13          ; clear area
295
    mov  eax, 13          ; clear area
297
    mov  ebx, XXbar
296
    mov  ebx, XXbar
298
    mov  ecx, YYbar
297
    mov  ecx, YYbar
299
    mov  edx, BgdColor
298
    mov  edx, BgdColor
300
    int  0x40
299
    mcall
Line 301... Line 300...
301
 
300
 
302
    mov  eax, 4
301
    mov  eax, 4
303
    mov  ebx, XYstatus
302
    mov  ebx, XYstatus
304
    mov  ecx, StatusColor
303
    mov  ecx, StatusColor
Line 310... Line 309...
310
    jmp  e_dm
309
    jmp  e_dm
311
  report_moves:
310
  report_moves:
312
    mov  edx,txtMoves  ; how many moves done
311
    mov  edx,txtMoves  ; how many moves done
313
    mov  esi,lenMoves-txtMoves
312
    mov  esi,lenMoves-txtMoves
314
    mov  eax,4
313
    mov  eax,4
315
    int  0x40
314
    mcall
316
    mov  esi,ecx
315
    mov  esi,ecx
317
    mov  edx,ebx
316
    mov  edx,ebx
318
    add  edx, 40 shl 16
317
    add  edx, 40 shl 16
319
    mov  ebx,0x030000
318
    mov  ebx,0x030000
320
    movzx  ecx, byte[move_count]
319
    movzx  ecx, byte[move_count]
Line 323... Line 322...
323
  report_victory:               ; puzzle completed
322
  report_victory:               ; puzzle completed
324
    mov  ecx,StatusColor2
323
    mov  ecx,StatusColor2
325
    mov  edx,txtVictory
324
    mov  edx,txtVictory
326
    mov  esi,lenVictory-txtVictory
325
    mov  esi,lenVictory-txtVictory
327
  e_dm:
326
  e_dm:
328
    int  0x40
327
    mcall
329
    ret
328
    ret
Line 330... Line 329...
330
 
329
 
331
 
330