Subversion Repositories Kolibri OS

Rev

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

Rev 1756 Rev 2679
1
; Date : 1st April 2001
1
; Date : 1st April 2001
2
; TETRIS for MENUET
2
; TETRIS for MENUET
3
; Author : Paolo Minazzi (email paolo.minazzi@inwind.it)
3
; Author : Paolo Minazzi (email paolo.minazzi@inwind.it)
4
;
4
;
5
; -Note-
5
; -Note-
6
; 1. This program requires a PENTIUM or higher because uses the RDTSC
6
; 1. This program requires a PENTIUM or higher because uses the RDTSC
7
;    instrucion for get a random number.
7
;    instrucion for get a random number.
8
; 2. You must use NASM to compile. Compiling is OK with NASM 0.98, I
8
; 2. You must use NASM to compile. Compiling is OK with NASM 0.98, I
9
;    don't know what happen with other versions.
9
;    don't know what happen with other versions.
10
; 3. You must use the arrow key to move and rotate a block.
10
; 3. You must use the arrow key to move and rotate a block.
11
; 4. In the near future there will be a new version of TETRIS. This is
11
; 4. In the near future there will be a new version of TETRIS. This is
12
;    only the beginning.
12
;    only the beginning.
13
;
13
;
14
; Thanks to Ville, the author of this wonderful OS !
14
; Thanks to Ville, the author of this wonderful OS !
15
; Join with us to code !
15
; Join with us to code !
16
;
16
;
17
;
17
;
18
; Changelog:
18
; Changelog:
19
; 30.12.2007 - cleaning keybuffer before reading an key - Gluk
19
; 30.12.2007 - cleaning keybuffer before reading an key - Gluk
20
; 09.11.2005 - fix for work under MeosDebug & better random - Andrey Halyavin
20
; 09.11.2005 - fix for work under MeosDebug & better random - Andrey Halyavin
21
; 23.09.2005 - fixed bug, when 011111111111111-like sequence interpreted
21
; 23.09.2005 - fixed bug, when 011111111111111-like sequence interpreted
22
;              as _11111111111111 in check_full_line - Sergey Kuzmin aka Wildwest
22
;              as _11111111111111 in check_full_line - Sergey Kuzmin aka Wildwest
23
; 18.09.2005 - added 'Pause' button and made appropriate code and interface redesign
23
; 18.09.2005 - added 'Pause' button and made appropriate code and interface redesign
24
;              BTW, you can MOVE and ROTATE block during Pause ;)  - Sergey Kuzmin aka Wildwest
24
;              BTW, you can MOVE and ROTATE block during Pause ;)  - Sergey Kuzmin aka Wildwest
25
; 03.11.2003 - added new blocks & random - Ivan Poddubny
25
; 03.11.2003 - added new blocks & random - Ivan Poddubny
26
; 31.10.2001 - rdtsc replaced            - quickcode 
26
; 31.10.2001 - rdtsc replaced            - quickcode 
27
; 28.06.2001 - fasm port & framed blocks - Ville Turjanmaa
27
; 28.06.2001 - fasm port & framed blocks - Ville Turjanmaa
28
; 
28
; 
29
;
29
;
30
 
30
 
31
LEN_X equ 19  ;width of table
31
LEN_X equ 19  ;width of table
32
LEN_Y equ 29  ; height of table
32
LEN_Y equ 29  ; height of table
33
BORDER_LEFT equ 1
33
BORDER_LEFT equ 1
34
BORDER_RIGHT equ 1
34
BORDER_RIGHT equ 1
35
BORDER_TOP equ 1
35
BORDER_TOP equ 1
36
BORDER_BOTTOM equ 1
36
BORDER_BOTTOM equ 1
37
ADOBE_SIZE equ 12
37
ADOBE_SIZE equ 12
38
 
38
 
39
X_LOCATION equ 30 ; distance to table from left side
39
X_LOCATION equ 30 ; distance to table from left side
40
Y_LOCATION equ 50 ; distance to table from header 
40
Y_LOCATION equ 50 ; distance to table from header 
41
 
41
 
42
UP_KEY equ 130+48
42
UP_KEY equ 130+48
43
DOWN_KEY equ 129+48
43
DOWN_KEY equ 129+48
44
LEFT_KEY equ 128+48
44
LEFT_KEY equ 128+48
45
RIGHT_KEY equ 131+48
45
RIGHT_KEY equ 131+48
46
;BACKGROUND equ 03000080h
46
;BACKGROUND equ 03000080h
47
 
47
 
48
_MAXBLOCKS_ = 7*4
48
_MAXBLOCKS_ = 7*4
49
 
49
 
50
use32
50
use32
51
 
51
 
52
                org     0x0
52
                org     0x0
53
 
53
 
54
                db      'MENUET01'    ; 8 byte id
54
                db      'MENUET01'    ; 8 byte id
55
                dd      0x01          ; header version
55
                dd      0x01          ; header version
56
                dd      START         ; program start
56
                dd      START         ; program start
57
                dd      I_END         ; program image size
57
                dd      I_END         ; program image size
58
                dd      I_END+1024    ; reguired amount of memory
58
                dd      I_END+1024    ; reguired amount of memory
59
                dd      I_END+1024    ; esp
59
                dd      I_END+1024    ; esp
60
                dd      0x0,0x0       ; I_PARAM, I_ICON
60
                dd      0x0,0x0       ; I_PARAM, I_ICON
61
include 'lang.inc'
61
include 'lang.inc'
62
include 'macros.inc'
62
include '../../../macros.inc'
63
 
-
 
64
 
63
 
65
START:                          ; start of execution
64
START:                          ; start of execution
66
 
65
 
67
 
66
 
68
    ; --  quickcode - start
67
    ; --  quickcode - start
69
 
68
 
70
    mov   eax,3
69
    mov   eax,3
71
    int   0x40
70
    int   0x40
72
    mov   cl,16
71
    mov   cl,16
73
    ror   eax,cl ; to make seconds more significant
72
    ror   eax,cl ; to make seconds more significant
74
    mov   [generator],eax
73
    mov   [generator],eax
75
    call  random
74
    call  random
76
 
75
 
77
    ; --  quickcode - end
76
    ; --  quickcode - end
78
 
77
 
79
 
78
 
80
    call clear_table_tetris
79
    call clear_table_tetris
81
    call new_block
80
    call new_block
82
    call draw_window            ; at first, draw the window
81
    call draw_window            ; at first, draw the window
83
 
82
 
84
still:
83
still:
85
    xor  edx,edx
84
    xor  edx,edx
86
    call draw_block
85
    call draw_block
87
 
86
 
88
attesa:
87
attesa:
89
 
88
 
90
    mov  eax,11                 ; get event
89
    mov  eax,11                 ; get event
91
    int  0x40
90
    int  0x40
92
 
91
 
93
    cmp  eax,1                  ; redraw request ?
92
    cmp  eax,1                  ; redraw request ?
94
    jz   red
93
    jz   red
95
    cmp  eax,2                  ; key in buffer ?
94
    cmp  eax,2                  ; key in buffer ?
96
    jnz  check_button
95
    jnz  check_button
97
    jmp  key
96
    jmp  key
98
check_button:
97
check_button:
99
    cmp  eax,3                  ; button in buffer ?
98
    cmp  eax,3                  ; button in buffer ?
100
    jnz  scendi
99
    jnz  scendi
101
    jmp  button
100
    jmp  button
102
 
101
 
103
  red:                          ; redraw
102
  red:                          ; redraw
104
    call draw_window
103
    call draw_window
105
    jmp  still
104
    jmp  still
106
 
105
 
107
 
106
 
108
 
107
 
109
scendi:
108
scendi:
110
;///////////////////////////////////////////////// Wildwest
109
;///////////////////////////////////////////////// Wildwest
111
                 cmp dword [pauses], 0
110
                 cmp dword [pauses], 0
112
                 je ok
111
                 je ok
113
                 jne not_ok
112
                 jne not_ok
114
not_ok:  
113
not_ok:  
115
                inc   dword [current_block_y]
114
                inc   dword [current_block_y]
116
                dec  dword [current_block_y]
115
                dec  dword [current_block_y]
117
                call  check_crash
116
                call  check_crash
118
                jne   block_crash
117
                jne   block_crash
119
                jmp draw            
118
                jmp draw            
120
ok:  
119
ok:  
121
 ;/////////////////////////////////////////////////  
120
 ;/////////////////////////////////////////////////  
122
                inc   dword [current_block_y]
121
                inc   dword [current_block_y]
123
                call  check_crash
122
                call  check_crash
124
                jne   block_crash
123
                jne   block_crash
125
draw:           movzx edx,byte [current_block_color]
124
draw:           movzx edx,byte [current_block_color]
126
                call  draw_block
125
                call  draw_block
127
                mov   eax,5
126
                mov   eax,5
128
                movzx ebx,byte [delay]
127
                movzx ebx,byte [delay]
129
                int   0x40
128
                int   0x40
130
                mov   [force_down],	1
129
                mov   [force_down],	1
131
                jmp   still
130
                jmp   still
132
 
131
 
133
block_crash:    dec dword [current_block_y]
132
block_crash:    dec dword [current_block_y]
134
                movzx edx,byte [current_block_color]
133
                movzx edx,byte [current_block_color]
135
                call draw_block
134
                call draw_block
136
                call fix_block
135
                call fix_block
137
                call check_full_line
136
                call check_full_line
138
                call draw_table
137
                call draw_table
139
                call new_block
138
                call new_block
140
                inc dword [score]
139
                inc dword [score]
141
                call write_score
140
                call write_score
142
                call check_crash
141
                call check_crash
143
                jz adr400
142
                jz adr400
144
aspetta:        mov eax,10
143
aspetta:        mov eax,10
145
                int 0x40
144
                int 0x40
146
                cmp eax,1
145
                cmp eax,1
147
                jne adr10000
146
                jne adr10000
148
                call draw_window
147
                call draw_window
149
adr10000:       cmp eax,3
148
adr10000:       cmp eax,3
150
                jne aspetta
149
                jne aspetta
151
new_game:       mov eax,17
150
new_game:       mov eax,17
152
                int 0x40
151
                int 0x40
153
                cmp ah,1
152
                cmp ah,1
154
                jnz adr401
153
                jnz adr401
155
                jmp end_program
154
                jmp end_program
156
adr401:      
155
adr401:      
157
;///////////////////////////////////////////////////// Wildwest
156
;///////////////////////////////////////////////////// Wildwest
158
                mov dword [pauses], 0   
157
                mov dword [pauses], 0   
159
;////////////////////////////////////////////////////
158
;////////////////////////////////////////////////////
160
                mov dword [score],0
159
                mov dword [score],0
161
                call clear_table_tetris
160
                call clear_table_tetris
162
                call new_block
161
                call new_block
163
                call draw_window
162
                call draw_window
164
 
163
 
165
adr400:         movzx edx,byte [current_block_color]
164
adr400:         movzx edx,byte [current_block_color]
166
                call draw_block
165
                call draw_block
167
                mov eax,5
166
                mov eax,5
168
                movzx ebx,byte [delay]
167
                movzx ebx,byte [delay]
169
                int 0x40
168
                int 0x40
170
                jmp still
169
                jmp still
171
 
170
 
172
key:            mov  eax,2 ; Gluk
171
key:            mov  eax,2 ; Gluk
173
                int  0x40
172
                int  0x40
174
				cmp eax,1
173
				cmp eax,1
175
				jne getkeyi
174
				jne getkeyi
176
				mov ah,dh
175
				mov ah,dh
177
				jmp adr32
176
				jmp adr32
178
 
177
 
179
getkeyi:		mov dh,ah ; Gluk
178
getkeyi:		mov dh,ah ; Gluk
180
				jmp key
179
				jmp key
181
 
180
 
182
adr32:          cmp ah,LEFT_KEY
181
adr32:          cmp ah,LEFT_KEY
183
                jne adr_30
182
                jne adr_30
184
                dec dword [current_block_x]
183
                dec dword [current_block_x]
185
                call check_crash
184
                call check_crash
186
                jz adr4000
185
                jz adr4000
187
                inc dword [current_block_x]
186
                inc dword [current_block_x]
188
adr4000:        jmp scendi
187
adr4000:        jmp scendi
189
 
188
 
190
adr_30:         cmp ah,RIGHT_KEY
189
adr_30:         cmp ah,RIGHT_KEY
191
                jne adr_31
190
                jne adr_31
192
                inc dword [current_block_x]
191
                inc dword [current_block_x]
193
                call check_crash
192
                call check_crash
194
                jz adr3000
193
                jz adr3000
195
                dec dword [current_block_x]
194
                dec dword [current_block_x]
196
adr3000:        jmp scendi
195
adr3000:        jmp scendi
197
 
196
 
198
adr_31:         cmp ah,UP_KEY
197
adr_31:         cmp ah,UP_KEY
199
                jne adr51
198
                jne adr51
200
                mov edx,[current_block_pointer]
199
                mov edx,[current_block_pointer]
201
                mov edx,[edx+16]
200
                mov edx,[edx+16]
202
                mov esi,[current_block_pointer]
201
                mov esi,[current_block_pointer]
203
                mov [current_block_pointer],edx
202
                mov [current_block_pointer],edx
204
                call check_crash
203
                call check_crash
205
                jz adr50
204
                jz adr50
206
                mov [current_block_pointer],esi
205
                mov [current_block_pointer],esi
207
adr50:          jmp scendi
206
adr50:          jmp scendi
208
 
207
 
209
adr51:          cmp ah,DOWN_KEY
208
adr51:          cmp ah,DOWN_KEY
210
                jne adr61
209
                jne adr61
211
                cmp [force_down], 1
210
                cmp [force_down], 1
212
                 jne scendi
211
                 jne scendi
213
                mov byte [delay],5  ;!!! 2
212
                mov byte [delay],5  ;!!! 2
214
adr52:          jmp scendi
213
adr52:          jmp scendi
215
 
214
 
216
adr61:          cmp ah,' '
215
adr61:          cmp ah,' '
217
                jne adr62
216
                jne adr62
218
                cmp [force_down], 1
217
                cmp [force_down], 1
219
                 jne scendi
218
                 jne scendi
220
                mov byte [delay],5  ;!!! 2
219
                mov byte [delay],5  ;!!! 2
221
adr62:          jmp scendi
220
adr62:          jmp scendi
222
 
221
 
223
 
222
 
224
button:                       ; button
223
button:                       ; button
225
    mov  eax,17
224
    mov  eax,17
226
    int  0x40
225
    int  0x40
227
    cmp  ah,1                   ; button id=1 ?
226
    cmp  ah,1                   ; button id=1 ?
228
    jz  end_program
227
    jz  end_program
229
    cmp ah,2
228
    cmp ah,2
230
    jz go_new_game
229
    jz go_new_game
231
    cmp  ah,3                   ; button id=3 ? ///Wildwest's  'Pause' button
230
    cmp  ah,3                   ; button id=3 ? ///Wildwest's  'Pause' button
232
    jz  pause_program
231
    jz  pause_program
233
    jmp still
232
    jmp still
234
 
233
 
235
end_program:
234
end_program:
236
    or   eax,-1                ; close this program
235
    or   eax,-1                ; close this program
237
    int  0x40
236
    int  0x40
238
 
237
 
239
go_new_game:
238
go_new_game:
240
    jmp new_game
239
    jmp new_game
241
;//////////////////////////////////////////////////// Wildwest
240
;//////////////////////////////////////////////////// Wildwest
242
pause_program:
241
pause_program:
243
cmp dword [pauses], 0
242
cmp dword [pauses], 0
244
je incr
243
je incr
245
mov dword [pauses], 0
244
mov dword [pauses], 0
246
 jmp still
245
 jmp still
247
incr:
246
incr:
248
mov dword [pauses], 1
247
mov dword [pauses], 1
249
jmp still
248
jmp still
250
;////////////////////////////////////////////////////
249
;////////////////////////////////////////////////////
251
;   *********************************************
250
;   *********************************************
252
;   *******  WINDOW DEFINITIONS AND DRAW ********
251
;   *******  WINDOW DEFINITIONS AND DRAW ********
253
;   *********************************************
252
;   *********************************************
254
draw_window:
253
draw_window:
255
 
254
 
256
 
255
 
257
    mov  eax,48
256
    mov  eax,48
258
    mov  ebx,3
257
    mov  ebx,3
259
    mov  ecx,sc
258
    mov  ecx,sc
260
    mov  edx,sizeof.system_colors
259
    mov  edx,sizeof.system_colors
261
    int  0x40
260
    int  0x40
262
 
261
 
263
    mov  eax,12                    ; function 12:tell os about windowdraw
262
    mov  eax,12                    ; function 12:tell os about windowdraw
264
    mov  ebx,1                     ; 1, start of draw
263
    mov  ebx,1                     ; 1, start of draw
265
    int  0x40
264
    int  0x40
266
 
265
 
267
                                 ; DRAW WINDOW
266
                                 ; DRAW WINDOW
268
  xor  eax,eax                   ; function 0 : define and draw window
267
  xor  eax,eax                   ; function 0 : define and draw window
269
  mov  ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2
268
  mov  ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2
270
  mov  ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30
269
  mov  ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30
271
  mov  edx,[sc.work]             ; color of work area RRGGBB
270
  mov  edx,[sc.work]             ; color of work area RRGGBB
272
  or   edx,0x13000000
271
  or   edx,0x13000000
273
  mov  edi,title                 ; WINDOW LABEL
272
  mov  edi,title                 ; WINDOW LABEL
274
  int  0x40
273
  int  0x40
275
 
274
 
276
                                    
275
                                    
277
    mov eax,8
276
    mov eax,8
278
    mov ebx,30*65536+100
277
    mov ebx,30*65536+100
279
    mov ecx,378*65536+18
278
    mov ecx,378*65536+18
280
    mov edx,2
279
    mov edx,2
281
    mov esi,[sc.work_button]
280
    mov esi,[sc.work_button]
282
    int 0x40
281
    int 0x40
283
;/////////////////////////////////////////////// Wildwest's  'Pause' button
282
;/////////////////////////////////////////////// Wildwest's  'Pause' button
284
    ;mov eax,8
283
    ;mov eax,8
285
    mov ebx,132*65536+102
284
    mov ebx,132*65536+102
286
    mov ecx,378*65536+18
285
    mov ecx,378*65536+18
287
    mov edx,3
286
    mov edx,3
288
    mov esi,[sc.work_button];
287
    mov esi,[sc.work_button];
289
    int 0x40
288
    int 0x40
290
 
289
 
291
    mov  eax,4                      ; function 4 : write text to window
290
    mov  eax,4                      ; function 4 : write text to window
292
    mov  ebx,164*65536+384          ; [x start] *65536 + [y start]
291
    mov  ebx,164*65536+384          ; [x start] *65536 + [y start]
293
    mov  ecx,[sc.work_button_text]  ; color of text RRGGBB
292
    mov  ecx,[sc.work_button_text]  ; color of text RRGGBB
294
    or   ecx,0x90000000
293
    or   ecx,0x90000000
295
    mov  edx,labe                   ; pointer to text
294
    mov  edx,labe                   ; pointer to text
296
    int  0x40
295
    int  0x40
297
;///////////////////////////////////////////////
296
;///////////////////////////////////////////////
298
    ;mov eax,4
297
    ;mov eax,4
299
    mov ebx,49*65536+384
298
    mov ebx,49*65536+384
300
    mov edx,game_finished
299
    mov edx,game_finished
301
    int 0x40
300
    int 0x40
302
    call draw_table
301
    call draw_table
303
 
302
 
304
    movzx edx,byte [current_block_color]
303
    movzx edx,byte [current_block_color]
305
    call draw_block
304
    call draw_block
306
 
305
 
307
    cld
306
    cld
308
    mov  ebx,38*65536+35           ; draw info text with function 4
307
    mov  ebx,38*65536+35           ; draw info text with function 4
309
    mov  ecx,[sc.work_text]              ; color
308
    mov  ecx,[sc.work_text]              ; color
310
    or   ecx,0x90000000    
309
    or   ecx,0x90000000    
311
    mov  edx,text
310
    mov  edx,text
312
    mov  eax,4
311
    mov  eax,4
313
    int  0x40
312
    int  0x40
314
 
313
 
315
    call write_score
314
    call write_score
316
 
315
 
317
    mov  eax,12                    ; function 12:tell os about windowdraw
316
    mov  eax,12                    ; function 12:tell os about windowdraw
318
    mov  ebx,2                     ; 2, end of draw
317
    mov  ebx,2                     ; 2, end of draw
319
    int  0x40
318
    int  0x40
320
 
319
 
321
    ret
320
    ret
322
 
321
 
323
;-------------------------------------------------------------
322
;-------------------------------------------------------------
324
; CHECK CRASH
323
; CHECK CRASH
325
; output        Z  flag => OK
324
; output        Z  flag => OK
326
;               NZ flag => NO
325
;               NZ flag => NO
327
;-------------------------------------------------------------
326
;-------------------------------------------------------------
328
 
327
 
329
check_crash:    mov ebx,[current_block_pointer]
328
check_crash:    mov ebx,[current_block_pointer]
330
 
329
 
331
                mov edx,[current_block_y]
330
                mov edx,[current_block_y]
332
                imul edx,LEN_X
331
                imul edx,LEN_X
333
                add edx,[current_block_x]          ;find the offset in tetris_t
332
                add edx,[current_block_x]          ;find the offset in tetris_t
334
 
333
 
335
                add edx,table_tetris
334
                add edx,table_tetris
336
 
335
 
337
                mov ecx,4
336
                mov ecx,4
338
                xor ax,ax
337
                xor ax,ax
339
 
338
 
340
adr_1:          cmp byte [ebx],1
339
adr_1:          cmp byte [ebx],1
341
                jne adr_2
340
                jne adr_2
342
                add al,[edx]
341
                add al,[edx]
343
                adc ah,0
342
                adc ah,0
344
adr_2:          inc ebx
343
adr_2:          inc ebx
345
                inc edx
344
                inc edx
346
 
345
 
347
                cmp byte [ebx],1
346
                cmp byte [ebx],1
348
                jne adr_3
347
                jne adr_3
349
                add al,[edx]
348
                add al,[edx]
350
                adc ah,0
349
                adc ah,0
351
adr_3:          inc ebx
350
adr_3:          inc ebx
352
                inc edx
351
                inc edx
353
 
352
 
354
                cmp byte [ebx],1
353
                cmp byte [ebx],1
355
                jne adr_4
354
                jne adr_4
356
                add al,[edx]
355
                add al,[edx]
357
                adc ah,0
356
                adc ah,0
358
adr_4:          inc ebx
357
adr_4:          inc ebx
359
                inc edx
358
                inc edx
360
 
359
 
361
                cmp byte [ebx],1
360
                cmp byte [ebx],1
362
                jne adr_5
361
                jne adr_5
363
                add al,[edx]
362
                add al,[edx]
364
                adc ah,0
363
                adc ah,0
365
adr_5:          inc ebx
364
adr_5:          inc ebx
366
                add edx,LEN_X-3
365
                add edx,LEN_X-3
367
 
366
 
368
                loop adr_1
367
                loop adr_1
369
                or ax,ax
368
                or ax,ax
370
                ret
369
                ret
371
;-------------------------------------------------------------
370
;-------------------------------------------------------------
372
;NEW BLOCK
371
;NEW BLOCK
373
;-------------------------------------------------------------
372
;-------------------------------------------------------------
374
new_block:      mov dword [current_block_y],1
373
new_block:      mov dword [current_block_y],1
375
                mov dword [current_block_x],7
374
                mov dword [current_block_x],7
376
 
375
 
377
				mov   [force_down],	0				; allow fast falling _after_ first game step
376
				mov   [force_down],	0				; allow fast falling _after_ first game step
378
 
377
 
379
                call random
378
                call random
380
                and al,7
379
                and al,7
381
                setz ah
380
                setz ah
382
                add al,ah
381
                add al,ah
383
                mov [current_block_color],al
382
                mov [current_block_color],al
384
 
383
 
385
                call random
384
                call random
386
                ;and eax,15
385
                ;and eax,15
387
            ; ---- Ivan ----
386
            ; ---- Ivan ----
388
                and eax,0xff
387
                and eax,0xff
389
              @@:
388
              @@:
390
                cmp eax,_MAXBLOCKS_
389
                cmp eax,_MAXBLOCKS_
391
                jl  @f
390
                jl  @f
392
                add eax,-(_MAXBLOCKS_)
391
                add eax,-(_MAXBLOCKS_)
393
                jmp @b
392
                jmp @b
394
              @@:
393
              @@:
395
            ; ---- Ivan ----
394
            ; ---- Ivan ----
396
                mov edx,[block_table+eax*4]
395
                mov edx,[block_table+eax*4]
397
                mov [current_block_pointer],edx
396
                mov [current_block_pointer],edx
398
 
397
 
399
                mov byte [delay],22 ;19 ;!!! 15
398
                mov byte [delay],22 ;19 ;!!! 15
400
                ret
399
                ret
401
;-------------------------------------------------------------
400
;-------------------------------------------------------------
402
; FIX BLOCK
401
; FIX BLOCK
403
;-------------------------------------------------------------
402
;-------------------------------------------------------------
404
fix_block:      mov ebx,[current_block_pointer]
403
fix_block:      mov ebx,[current_block_pointer]
405
 
404
 
406
                mov edx,[current_block_y]
405
                mov edx,[current_block_y]
407
                imul edx,LEN_X
406
                imul edx,LEN_X
408
                add edx,[current_block_x]       ;find the offset in tetris_t
407
                add edx,[current_block_x]       ;find the offset in tetris_t
409
 
408
 
410
                add edx,table_tetris
409
                add edx,table_tetris
411
 
410
 
412
                mov ecx,4
411
                mov ecx,4
413
                mov al,[current_block_color]
412
                mov al,[current_block_color]
414
 
413
 
415
adr_21:         cmp byte [ebx],1
414
adr_21:         cmp byte [ebx],1
416
                jne adr_22
415
                jne adr_22
417
                mov [edx],al
416
                mov [edx],al
418
adr_22:         inc ebx
417
adr_22:         inc ebx
419
                inc edx
418
                inc edx
420
 
419
 
421
                cmp byte [ebx],1
420
                cmp byte [ebx],1
422
                jne adr_23
421
                jne adr_23
423
                mov [edx],al
422
                mov [edx],al
424
adr_23:         inc ebx
423
adr_23:         inc ebx
425
                inc edx
424
                inc edx
426
 
425
 
427
                cmp byte [ebx],1
426
                cmp byte [ebx],1
428
                jne adr_24
427
                jne adr_24
429
                mov [edx],al
428
                mov [edx],al
430
adr_24:         inc ebx
429
adr_24:         inc ebx
431
                inc edx
430
                inc edx
432
 
431
 
433
                cmp byte [ebx],1
432
                cmp byte [ebx],1
434
                jne adr_25
433
                jne adr_25
435
                mov [edx],al
434
                mov [edx],al
436
adr_25:         inc ebx
435
adr_25:         inc ebx
437
                add edx,LEN_X-3
436
                add edx,LEN_X-3
438
 
437
 
439
                loop adr_21
438
                loop adr_21
440
                ret
439
                ret
441
 
440
 
442
;--------------------------------------------------------------
441
;--------------------------------------------------------------
443
; DRAW_TABLE
442
; DRAW_TABLE
444
;--------------------------------------------------------------
443
;--------------------------------------------------------------
445
draw_table:     mov esi,table_tetris+LEN_X*BORDER_TOP+BORDER_LEFT
444
draw_table:     mov esi,table_tetris+LEN_X*BORDER_TOP+BORDER_LEFT
446
 
445
 
447
                mov ebx,X_LOCATION*65536+ADOBE_SIZE
446
                mov ebx,X_LOCATION*65536+ADOBE_SIZE
448
                mov ecx,Y_LOCATION*65536+ADOBE_SIZE
447
                mov ecx,Y_LOCATION*65536+ADOBE_SIZE
449
                mov edi,LEN_Y-BORDER_TOP-BORDER_BOTTOM
448
                mov edi,LEN_Y-BORDER_TOP-BORDER_BOTTOM
450
y_draw:         push edi
449
y_draw:         push edi
451
 
450
 
452
                mov edi,LEN_X-BORDER_LEFT-BORDER_RIGHT
451
                mov edi,LEN_X-BORDER_LEFT-BORDER_RIGHT
453
x_draw:         push edi
452
x_draw:         push edi
454
              ;  pusha
453
              ;  pusha
455
              ;  mov eax,5
454
              ;  mov eax,5
456
              ;  mov ebx,10
455
              ;  mov ebx,10
457
              ;  int 0x40
456
              ;  int 0x40
458
              ;  popa
457
              ;  popa
459
                mov eax,13
458
                mov eax,13
460
                movzx edx,byte [esi]
459
                movzx edx,byte [esi]
461
                mov edx,[color_table+edx*4]
460
                mov edx,[color_table+edx*4]
462
                int 0x40
461
                int 0x40
463
                call draw_frames
462
                call draw_frames
464
                inc esi
463
                inc esi
465
                add ebx,65536*ADOBE_SIZE
464
                add ebx,65536*ADOBE_SIZE
466
                pop edi
465
                pop edi
467
                dec edi
466
                dec edi
468
                jnz x_draw
467
                jnz x_draw
469
 
468
 
470
                add esi,BORDER_LEFT+BORDER_RIGHT
469
                add esi,BORDER_LEFT+BORDER_RIGHT
471
                mov ebx,X_LOCATION*65536+ADOBE_SIZE
470
                mov ebx,X_LOCATION*65536+ADOBE_SIZE
472
                add ecx,65536*ADOBE_SIZE
471
                add ecx,65536*ADOBE_SIZE
473
                pop edi
472
                pop edi
474
                dec edi
473
                dec edi
475
                jnz y_draw
474
                jnz y_draw
476
 
475
 
477
                ret
476
                ret
478
;--------------------------------------------------------------
477
;--------------------------------------------------------------
479
;DRAW BLOCK
478
;DRAW BLOCK
480
;
479
;
481
; ebx=x [0..LEN_X-1]
480
; ebx=x [0..LEN_X-1]
482
; ecx=y [0..LEN_Y-1]
481
; ecx=y [0..LEN_Y-1]
483
; edi=pointer block
482
; edi=pointer block
484
;--------------------------------------------------------------
483
;--------------------------------------------------------------
485
draw_block: 
484
draw_block: 
486
              
485
              
487
                mov eax,13
486
                mov eax,13
488
                mov edx,[color_table+edx*4]
487
                mov edx,[color_table+edx*4]
489
 
488
 
490
                mov ebx,[current_block_x]
489
                mov ebx,[current_block_x]
491
                mov ecx,[current_block_y]
490
                mov ecx,[current_block_y]
492
                mov edi,[current_block_pointer]
491
                mov edi,[current_block_pointer]
493
 
492
 
494
                sub ebx,BORDER_LEFT
493
                sub ebx,BORDER_LEFT
495
                imul ebx,ADOBE_SIZE
494
                imul ebx,ADOBE_SIZE
496
                add ebx,X_LOCATION
495
                add ebx,X_LOCATION
497
                shl ebx,16
496
                shl ebx,16
498
                mov bx,ADOBE_SIZE
497
                mov bx,ADOBE_SIZE
499
 
498
 
500
                sub ecx,BORDER_TOP
499
                sub ecx,BORDER_TOP
501
                imul ecx,ADOBE_SIZE
500
                imul ecx,ADOBE_SIZE
502
                add ecx,Y_LOCATION
501
                add ecx,Y_LOCATION
503
                shl ecx,16
502
                shl ecx,16
504
                mov cx,ADOBE_SIZE
503
                mov cx,ADOBE_SIZE
505
 
504
 
506
                mov dword [TMP_1],4
505
                mov dword [TMP_1],4
507
adr_122:        mov dword [TMP_0],4
506
adr_122:        mov dword [TMP_0],4
508
adr_121:        cmp byte [edi],0
507
adr_121:        cmp byte [edi],0
509
                je adr_120
508
                je adr_120
510
 
509
 
511
                int 040h
510
                int 040h
512
 
511
 
513
                call draw_frames
512
                call draw_frames
514
 
513
 
515
adr_120:        inc edi
514
adr_120:        inc edi
516
                add ebx,ADOBE_SIZE*65536
515
                add ebx,ADOBE_SIZE*65536
517
                dec dword [TMP_0]
516
                dec dword [TMP_0]
518
                jnz adr_121
517
                jnz adr_121
519
                sub ebx,4*ADOBE_SIZE*65536
518
                sub ebx,4*ADOBE_SIZE*65536
520
                add ecx,ADOBE_SIZE*65536
519
                add ecx,ADOBE_SIZE*65536
521
                dec dword [TMP_1]
520
                dec dword [TMP_1]
522
                jnz adr_122
521
                jnz adr_122
523
 
522
 
524
                ret
523
                ret
525
 
524
 
526
draw_frames:
525
draw_frames:
527
                 cmp edx,0
526
                 cmp edx,0
528
                 jne df1
527
                 jne df1
529
                 ret
528
                 ret
530
             df1:
529
             df1:
531
                 pusha
530
                 pusha
532
                 mov bx,1
531
                 mov bx,1
533
                 add edx,0x282828
532
                 add edx,0x282828
534
                 mov eax,13
533
                 mov eax,13
535
                 int 0x40
534
                 int 0x40
536
                 popa
535
                 popa
537
 
536
 
538
                 pusha
537
                 pusha
539
                 mov cx,1
538
                 mov cx,1
540
                 add edx,0x282828
539
                 add edx,0x282828
541
                 mov eax,13
540
                 mov eax,13
542
                 int 0x40
541
                 int 0x40
543
                 popa
542
                 popa
544
 
543
 
545
                 pusha
544
                 pusha
546
                 push ebx
545
                 push ebx
547
                 sub  bx,1
546
                 sub  bx,1
548
                 add  [esp+2],bx
547
                 add  [esp+2],bx
549
                 pop  ebx
548
                 pop  ebx
550
                 mov  bx,1
549
                 mov  bx,1
551
                 shr  edx,1
550
                 shr  edx,1
552
                 and  edx,0x7f7f7f
551
                 and  edx,0x7f7f7f
553
                 mov  eax,13
552
                 mov  eax,13
554
                 int  0x40
553
                 int  0x40
555
                 popa
554
                 popa
556
 
555
 
557
                 pusha
556
                 pusha
558
                 push ecx
557
                 push ecx
559
                 sub  cx,1
558
                 sub  cx,1
560
                 add  [esp+2],cx
559
                 add  [esp+2],cx
561
                 pop  ecx
560
                 pop  ecx
562
                 mov  cx,1
561
                 mov  cx,1
563
                 shr  edx,1
562
                 shr  edx,1
564
                 and  edx,0x7f7f7f
563
                 and  edx,0x7f7f7f
565
                 mov  eax,13
564
                 mov  eax,13
566
                 int  0x40
565
                 int  0x40
567
                 popa
566
                 popa
568
 
567
 
569
                 ret
568
                 ret
570
 
569
 
571
 
570
 
572
;--------------------------------------------------------------
571
;--------------------------------------------------------------
573
clear_table_tetris:
572
clear_table_tetris:
574
                cld
573
                cld
575
                mov al,1
574
                mov al,1
576
                mov edi,table_tetris
575
                mov edi,table_tetris
577
                mov ecx,LEN_X*BORDER_TOP
576
                mov ecx,LEN_X*BORDER_TOP
578
                rep stosb
577
                rep stosb
579
 
578
 
580
                mov edx,LEN_Y-BORDER_TOP-BORDER_BOTTOM
579
                mov edx,LEN_Y-BORDER_TOP-BORDER_BOTTOM
581
adr300:         mov cl,BORDER_LEFT
580
adr300:         mov cl,BORDER_LEFT
582
                rep stosb
581
                rep stosb
583
                dec ax  ;AL=0
582
                dec ax  ;AL=0
584
                mov cl,LEN_X-BORDER_LEFT-BORDER_RIGHT
583
                mov cl,LEN_X-BORDER_LEFT-BORDER_RIGHT
585
                rep stosb
584
                rep stosb
586
                inc ax  ;AL=1
585
                inc ax  ;AL=1
587
                mov cl,BORDER_RIGHT
586
                mov cl,BORDER_RIGHT
588
                rep stosb
587
                rep stosb
589
                dec dx
588
                dec dx
590
                jne adr300
589
                jne adr300
591
 
590
 
592
                mov ecx,LEN_X*BORDER_BOTTOM
591
                mov ecx,LEN_X*BORDER_BOTTOM
593
                rep stosb
592
                rep stosb
594
                ret
593
                ret
595
;--------------------------------------------------------------
594
;--------------------------------------------------------------
596
;edx = pointer
595
;edx = pointer
597
;ebx = contatore
596
;ebx = contatore
598
check_full_line:
597
check_full_line:
599
                std
598
                std
600
                mov al,0
599
                mov al,0
601
                mov edx,table_tetris+LEN_X*(LEN_Y-BORDER_BOTTOM)-1
600
                mov edx,table_tetris+LEN_X*(LEN_Y-BORDER_BOTTOM)-1
602
                mov ebx,(LEN_Y-BORDER_TOP-BORDER_BOTTOM-1)*LEN_X
601
                mov ebx,(LEN_Y-BORDER_TOP-BORDER_BOTTOM-1)*LEN_X
603
 
602
 
604
adr_5000:       mov edi,edx
603
adr_5000:       mov edi,edx
605
                mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT+1;Wildwest's fix for bug 
604
                mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT+1;Wildwest's fix for bug 
606
                                 ;(was LEN_X-BORDER_LEFT-BORDER_RIGHT)
605
                                 ;(was LEN_X-BORDER_LEFT-BORDER_RIGHT)
607
                repne scasb
606
                repne scasb
608
                jz no_full_line
607
                jz no_full_line
609
 
608
 
610
                lea esi,[edx-LEN_X]
609
                lea esi,[edx-LEN_X]
611
                mov edi,edx
610
                mov edi,edx
612
                mov ecx,ebx
611
                mov ecx,ebx
613
                rep movsb
612
                rep movsb
614
                sub edi,BORDER_RIGHT
613
                sub edi,BORDER_RIGHT
615
                mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT
614
                mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT
616
                rep stosb
615
                rep stosb
617
                add dword [score],50
616
                add dword [score],50
618
                jmp adr_5000
617
                jmp adr_5000
619
 
618
 
620
no_full_line:   sub edx,LEN_X
619
no_full_line:   sub edx,LEN_X
621
                sub ebx,LEN_X
620
                sub ebx,LEN_X
622
                jnz adr_5000
621
                jnz adr_5000
623
 
622
 
624
                ret
623
                ret
625
;--------------------------------------------------------------
624
;--------------------------------------------------------------
626
random:         mov eax,[generator]
625
random:         mov eax,[generator]
627
                add eax,-43ab45b5h
626
                add eax,-43ab45b5h
628
                ror eax,1
627
                ror eax,1
629
                xor eax,32c4324fh
628
                xor eax,32c4324fh
630
                ror eax,1
629
                ror eax,1
631
                mov [generator],eax
630
                mov [generator],eax
632
                ; --- IVAN ---
631
                ; --- IVAN ---
633
                push ebx
632
                push ebx
634
                mov eax,26
633
                mov eax,26
635
                mov ebx,9
634
                mov ebx,9
636
                int 0x40
635
                int 0x40
637
                pop ebx
636
                pop ebx
638
                xor eax,0xdeadbeef
637
                xor eax,0xdeadbeef
639
                add eax,[generator]
638
                add eax,[generator]
640
                ; --- IVAN ---
639
                ; --- IVAN ---
641
                mov [generator],eax ; Halyavin
640
                mov [generator],eax ; Halyavin
642
                ret
641
                ret
643
;--------------------------------------------------------------
642
;--------------------------------------------------------------
644
number_to_str:  mov edi,end_number_str-1
643
number_to_str:  mov edi,end_number_str-1
645
                mov ecx,9;size_of_number_str
644
                mov ecx,9;size_of_number_str
646
                mov ebx,10
645
                mov ebx,10
647
                cld
646
                cld
648
new_digit:      xor edx,edx
647
new_digit:      xor edx,edx
649
                div ebx
648
                div ebx
650
                add dl,'0'
649
                add dl,'0'
651
                mov [edi],dl
650
                mov [edi],dl
652
                dec edi
651
                dec edi
653
                loop new_digit
652
                loop new_digit
654
                ret
653
                ret
655
;--------------------------------------------------------------
654
;--------------------------------------------------------------
656
write_score:
655
write_score:
657
    mov  eax,[score]
656
    mov  eax,[score]
658
    call number_to_str
657
    call number_to_str
659
 
658
 
660
    mov  ebx,90*65536+35          ; draw info text with function 4
659
    mov  ebx,90*65536+35          ; draw info text with function 4
661
    mov  ecx,[sc.work_text]        ; color
660
    mov  ecx,[sc.work_text]        ; color
662
    or   ecx,0x50000000    
661
    or   ecx,0x50000000    
663
    mov  edx,number_str
662
    mov  edx,number_str
664
    mov  esi,[size_of_number_str]
663
    mov  esi,[size_of_number_str]
665
    mov  edi,[sc.work]
664
    mov  edi,[sc.work]
666
    mov  eax,4
665
    mov  eax,4
667
    int  0x40
666
    int  0x40
668
    ret
667
    ret
669
 
668
 
670
; DATA AREA
669
; DATA AREA
671
 
670
 
672
;--------------------------------------------------------------
671
;--------------------------------------------------------------
673
;DEFINITION BLOCKS
672
;DEFINITION BLOCKS
674
;--------------------------------------------------------------
673
;--------------------------------------------------------------
675
t_block_0:  db 0,0,0,0
674
t_block_0:  db 0,0,0,0
676
                db 1,1,1,0
675
                db 1,1,1,0
677
                db 0,1,0,0
676
                db 0,1,0,0
678
                db 0,0,0,0
677
                db 0,0,0,0
679
                dd t_block_3
678
                dd t_block_3
680
 
679
 
681
t_block_1:  db 0,1,0,0
680
t_block_1:  db 0,1,0,0
682
                db 1,1,0,0
681
                db 1,1,0,0
683
                db 0,1,0,0
682
                db 0,1,0,0
684
                db 0,0,0,0
683
                db 0,0,0,0
685
                dd t_block_0
684
                dd t_block_0
686
 
685
 
687
t_block_2:  db 0,1,0,0
686
t_block_2:  db 0,1,0,0
688
                db 1,1,1,0
687
                db 1,1,1,0
689
                db 0,0,0,0
688
                db 0,0,0,0
690
                db 0,0,0,0
689
                db 0,0,0,0
691
                dd t_block_1
690
                dd t_block_1
692
 
691
 
693
t_block_3   db 0,1,0,0
692
t_block_3   db 0,1,0,0
694
                db 0,1,1,0
693
                db 0,1,1,0
695
                db 0,1,0,0
694
                db 0,1,0,0
696
                db 0,0,0,0
695
                db 0,0,0,0
697
                dd t_block_2
696
                dd t_block_2
698
;--------------------------------------------------------------
697
;--------------------------------------------------------------
699
i_block_0:  db 0,1,0,0
698
i_block_0:  db 0,1,0,0
700
                db 0,1,0,0
699
                db 0,1,0,0
701
                db 0,1,0,0
700
                db 0,1,0,0
702
                db 0,1,0,0
701
                db 0,1,0,0
703
                dd i_block_1
702
                dd i_block_1
704
 
703
 
705
i_block_1:  db 0,0,0,0
704
i_block_1:  db 0,0,0,0
706
                db 1,1,1,1
705
                db 1,1,1,1
707
                db 0,0,0,0
706
                db 0,0,0,0
708
                db 0,0,0,0
707
                db 0,0,0,0
709
                dd i_block_0
708
                dd i_block_0
710
;--------------------------------------------------------------
709
;--------------------------------------------------------------
711
q_block_0: db 0,1,1,0
710
q_block_0: db 0,1,1,0
712
                db 0,1,1,0
711
                db 0,1,1,0
713
                db 0,0,0,0
712
                db 0,0,0,0
714
                db 0,0,0,0
713
                db 0,0,0,0
715
                dd q_block_0
714
                dd q_block_0
716
;--------------------------------------------------------------
715
;--------------------------------------------------------------
717
s_block_0:
716
s_block_0:
718
      db 0,0,0,0
717
      db 0,0,0,0
719
      db 0,1,1,0
718
      db 0,1,1,0
720
      db 1,1,0,0
719
      db 1,1,0,0
721
      db 0,0,0,0
720
      db 0,0,0,0
722
      dd s_block_1
721
      dd s_block_1
723
 
722
 
724
s_block_1: db 1,0,0,0
723
s_block_1: db 1,0,0,0
725
                db 1,1,0,0
724
                db 1,1,0,0
726
                db 0,1,0,0
725
                db 0,1,0,0
727
                db 0,0,0,0
726
                db 0,0,0,0
728
                dd s_block_0
727
                dd s_block_0
729
;--------------------------------------------------------------
728
;--------------------------------------------------------------
730
l_block_0:  db 0,0,0,0
729
l_block_0:  db 0,0,0,0
731
                db 1,1,1,0
730
                db 1,1,1,0
732
                db 1,0,0,0
731
                db 1,0,0,0
733
                db 0,0,0,0
732
                db 0,0,0,0
734
                dd l_block_3
733
                dd l_block_3
735
 
734
 
736
l_block_1:  db 1,1,0,0
735
l_block_1:  db 1,1,0,0
737
                db 0,1,0,0
736
                db 0,1,0,0
738
                db 0,1,0,0
737
                db 0,1,0,0
739
                db 0,0,0,0
738
                db 0,0,0,0
740
                dd l_block_0
739
                dd l_block_0
741
 
740
 
742
l_block_2:  db 0,0,1,0
741
l_block_2:  db 0,0,1,0
743
                db 1,1,1,0
742
                db 1,1,1,0
744
                db 0,0,0,0
743
                db 0,0,0,0
745
                db 0,0,0,0
744
                db 0,0,0,0
746
                dd l_block_1
745
                dd l_block_1
747
 
746
 
748
l_block_3:  db 0,1,0,0
747
l_block_3:  db 0,1,0,0
749
                db 0,1,0,0
748
                db 0,1,0,0
750
                db 0,1,1,0
749
                db 0,1,1,0
751
                db 0,0,0,0
750
                db 0,0,0,0
752
                dd l_block_2
751
                dd l_block_2
753
;-----------------------------------------------
752
;-----------------------------------------------
754
 
753
 
755
g_block_0:
754
g_block_0:
756
 
755
 
757
db 0,1,0,0
756
db 0,1,0,0
758
db 0,1,0,0
757
db 0,1,0,0
759
db 1,1,0,0
758
db 1,1,0,0
760
db 0,0,0,0
759
db 0,0,0,0
761
dd g_block_1
760
dd g_block_1
762
 
761
 
763
g_block_1:
762
g_block_1:
764
db 0,0,0,0
763
db 0,0,0,0
765
db 1,1,1,0
764
db 1,1,1,0
766
db 0,0,1,0
765
db 0,0,1,0
767
db 0,0,0,0
766
db 0,0,0,0
768
dd g_block_2
767
dd g_block_2
769
 
768
 
770
g_block_2:
769
g_block_2:
771
db 0,1,1,0
770
db 0,1,1,0
772
db 0,1,0,0
771
db 0,1,0,0
773
db 0,1,0,0
772
db 0,1,0,0
774
db 0,0,0,0
773
db 0,0,0,0
775
dd g_block_3
774
dd g_block_3
776
 
775
 
777
g_block_3:
776
g_block_3:
778
db 1,0,0,0
777
db 1,0,0,0
779
db 1,1,1,0
778
db 1,1,1,0
780
db 0,0,0,0
779
db 0,0,0,0
781
db 0,0,0,0
780
db 0,0,0,0
782
dd g_block_0
781
dd g_block_0
783
 
782
 
784
;-----------------------------------
783
;-----------------------------------
785
 
784
 
786
k_block_0:
785
k_block_0:
787
      db 0,0,0,0
786
      db 0,0,0,0
788
      db 1,1,0,0
787
      db 1,1,0,0
789
      db 0,1,1,0
788
      db 0,1,1,0
790
      db 0,0,0,0
789
      db 0,0,0,0
791
      dd k_block_1
790
      dd k_block_1
792
 
791
 
793
k_block_1:
792
k_block_1:
794
      db 0,1,0,0
793
      db 0,1,0,0
795
      db 1,1,0,0
794
      db 1,1,0,0
796
      db 1,0,0,0
795
      db 1,0,0,0
797
      db 0,0,0,0
796
      db 0,0,0,0
798
      dd k_block_0
797
      dd k_block_0
799
 
798
 
800
;-----------------------------------
799
;-----------------------------------
801
 
800
 
802
color_table: dd 00000000h    ;black      0
801
color_table: dd 00000000h    ;black      0
803
                  dd 00cccccch    ;white      1
802
                  dd 00cccccch    ;white      1
804
                  dd 00cc0000h    ;red         2
803
                  dd 00cc0000h    ;red         2
805
                  dd 0000cc00h    ;green     3
804
                  dd 0000cc00h    ;green     3
806
                  dd 000000cch    ;blue        4
805
                  dd 000000cch    ;blue        4
807
                  dd 00cccc00h    ;yellow     5
806
                  dd 00cccc00h    ;yellow     5
808
                  dd 0000cccch    ;cyan      6
807
                  dd 0000cccch    ;cyan      6
809
                  dd 00cc00cch    ;pink        7
808
                  dd 00cc00cch    ;pink        7
810
 
809
 
811
block_table:
810
block_table:
812
    dd t_block_0 ; t
811
    dd t_block_0 ; t
813
    dd t_block_1
812
    dd t_block_1
814
    dd t_block_2
813
    dd t_block_2
815
    dd t_block_3
814
    dd t_block_3
816
    dd i_block_0 ; i
815
    dd i_block_0 ; i
817
    dd i_block_1
816
    dd i_block_1
818
    dd i_block_0
817
    dd i_block_0
819
    dd i_block_1
818
    dd i_block_1
820
    dd q_block_0 ; q
819
    dd q_block_0 ; q
821
    dd q_block_0
820
    dd q_block_0
822
    dd q_block_0
821
    dd q_block_0
823
    dd q_block_0
822
    dd q_block_0
824
    dd s_block_0 ; s
823
    dd s_block_0 ; s
825
    dd s_block_1
824
    dd s_block_1
826
    dd s_block_0
825
    dd s_block_0
827
    dd s_block_1
826
    dd s_block_1
828
    dd l_block_0 ; l
827
    dd l_block_0 ; l
829
    dd l_block_1
828
    dd l_block_1
830
    dd l_block_2
829
    dd l_block_2
831
    dd l_block_3
830
    dd l_block_3
832
    dd g_block_0 ; g
831
    dd g_block_0 ; g
833
    dd g_block_1
832
    dd g_block_1
834
    dd g_block_2
833
    dd g_block_2
835
    dd g_block_3
834
    dd g_block_3
836
    dd k_block_0 ; k
835
    dd k_block_0 ; k
837
    dd k_block_1
836
    dd k_block_1
838
    dd k_block_0
837
    dd k_block_0
839
    dd k_block_1
838
    dd k_block_1
840
 
839
 
841
if lang eq ru
840
if lang eq ru
842
 
841
 
843
  title          db '’…’ˆ‘ 1.61 - ‘’…‹Šˆ ˆ Ž…‹',0
842
  title          db '’…’ˆ‘ 1.61 - ‘’…‹Šˆ ˆ Ž…‹',0
844
  labe           db '€“‡€',0
843
  labe           db '€“‡€',0
845
  text           db 'Žçª¨:',0
844
  text           db 'Žçª¨:',0
846
  game_finished: db 'Ž‚€Ÿ',0
845
  game_finished: db '  Ž‚€Ÿ',0
847
 
846
 
848
else
847
else
849
 
848
 
850
  title          db 'TETRIS 1.61 - ARROWS & SPACE',0
849
  title          db 'TETRIS 1.61 - ARROWS & SPACE',0
851
  labe           db 'PAUSE',0
850
  labe           db 'PAUSE',0
852
  text           db 'Score:',0
851
  text           db 'Score:',0
853
  game_finished: db 'NEW GAME',0
852
  game_finished: db 'NEW GAME',0
854
 
853
 
855
end if
854
end if
856
 
855
 
857
pauses dd 0  ;/// Wildwest
856
pauses dd 0  ;/// Wildwest
858
parallel dd 1
857
parallel dd 1
859
score:                  dd 0
858
score:                  dd 0
860
TMP_0:                  dd 0
859
TMP_0:                  dd 0
861
TMP_1:                  dd 0
860
TMP_1:                  dd 0
862
generator:              dd 0
861
generator:              dd 0
863
current_block_x:        dd 0
862
current_block_x:        dd 0
864
current_block_y:        dd 0
863
current_block_y:        dd 0
865
current_block_pointer:  dd 0
864
current_block_pointer:  dd 0
866
current_block_color:    db 0
865
current_block_color:    db 0
867
number_str:             db 0,0,0,0,0,0,0,0,0
866
number_str:             db 0,0,0,0,0,0,0,0,0
868
end_number_str:
867
end_number_str:
869
size_of_number_str      dd 9
868
size_of_number_str      dd 9
870
delay:                  db 40
869
delay:                  db 40
871
force_down				dd 1
870
force_down				dd 1
872
sc     system_colors
871
sc     system_colors
873
table_tetris:
872
table_tetris:
874
 
873
 
875
I_END:
874
I_END: