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