Rev 3932 | Rev 4604 | 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 |
||
4603 | dnivra | 183 | cmp dword[pauses], 1 ; fixes pause bug |
184 | je adr4000 |
||
131 | diamond | 185 | dec dword [current_block_x] |
186 | call check_crash |
||
187 | jz adr4000 |
||
188 | inc dword [current_block_x] |
||
189 | adr4000: jmp scendi |
||
31 | halyavin | 190 | |
131 | diamond | 191 | adr_30: cmp ah,RIGHT_KEY |
192 | jne adr_31 |
||
4603 | dnivra | 193 | cmp dword[pauses], 1 ; fixes pause bug |
194 | je adr3000 |
||
131 | diamond | 195 | inc dword [current_block_x] |
196 | call check_crash |
||
197 | jz adr3000 |
||
198 | dec dword [current_block_x] |
||
199 | adr3000: jmp scendi |
||
31 | halyavin | 200 | |
131 | diamond | 201 | adr_31: cmp ah,UP_KEY |
202 | jne adr51 |
||
4603 | dnivra | 203 | cmp dword[pauses], 1 ; fixes pause bug |
204 | je adr50 |
||
131 | diamond | 205 | mov edx,[current_block_pointer] |
206 | mov edx,[edx+16] |
||
207 | mov esi,[current_block_pointer] |
||
208 | mov [current_block_pointer],edx |
||
209 | call check_crash |
||
210 | jz adr50 |
||
211 | mov [current_block_pointer],esi |
||
212 | adr50: jmp scendi |
||
31 | halyavin | 213 | |
131 | diamond | 214 | adr51: cmp ah,DOWN_KEY |
215 | jne adr61 |
||
1756 | dunkaist | 216 | cmp [force_down], 1 |
217 | jne scendi |
||
131 | diamond | 218 | mov byte [delay],5 ;!!! 2 |
219 | adr52: jmp scendi |
||
220 | |||
221 | adr61: cmp ah,' ' |
||
222 | jne adr62 |
||
1756 | dunkaist | 223 | cmp [force_down], 1 |
224 | jne scendi |
||
131 | diamond | 225 | mov byte [delay],5 ;!!! 2 |
226 | adr62: jmp scendi |
||
227 | |||
228 | |||
229 | button: ; button |
||
230 | mov eax,17 |
||
685 | gluk | 231 | int 0x40 |
131 | diamond | 232 | cmp ah,1 ; button id=1 ? |
233 | jz end_program |
||
234 | cmp ah,2 |
||
235 | jz go_new_game |
||
236 | cmp ah,3 ; button id=3 ? ///Wildwest's 'Pause' button |
||
237 | jz pause_program |
||
238 | jmp still |
||
239 | |||
240 | end_program: |
||
205 | heavyiron | 241 | or eax,-1 ; close this program |
685 | gluk | 242 | int 0x40 |
131 | diamond | 243 | |
244 | go_new_game: |
||
245 | jmp new_game |
||
246 | ;//////////////////////////////////////////////////// Wildwest |
||
247 | pause_program: |
||
248 | cmp dword [pauses], 0 |
||
249 | je incr |
||
250 | mov dword [pauses], 0 |
||
251 | jmp still |
||
252 | incr: |
||
253 | mov dword [pauses], 1 |
||
254 | jmp still |
||
255 | ;//////////////////////////////////////////////////// |
||
256 | ; ********************************************* |
||
257 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
258 | ; ********************************************* |
||
259 | draw_window: |
||
260 | |||
261 | |||
180 | heavyiron | 262 | mov eax,48 |
263 | mov ebx,3 |
||
264 | mov ecx,sc |
||
265 | mov edx,sizeof.system_colors |
||
685 | gluk | 266 | int 0x40 |
180 | heavyiron | 267 | |
131 | diamond | 268 | mov eax,12 ; function 12:tell os about windowdraw |
269 | mov ebx,1 ; 1, start of draw |
||
685 | gluk | 270 | int 0x40 |
131 | diamond | 271 | |
272 | ; DRAW WINDOW |
||
180 | heavyiron | 273 | xor eax,eax ; function 0 : define and draw window |
131 | diamond | 274 | mov ebx,320*65536+(LEN_X-BORDER_LEFT-BORDER_RIGHT)*ADOBE_SIZE+X_LOCATION*2 |
275 | mov ecx,25*65536+ (LEN_Y-BORDER_TOP-BORDER_BOTTOM)*ADOBE_SIZE+Y_LOCATION+30 |
||
180 | heavyiron | 276 | mov edx,[sc.work] ; color of work area RRGGBB |
685 | gluk | 277 | or edx,0x13000000 |
1728 | clevermous | 278 | mov edi,title ; WINDOW LABEL |
685 | gluk | 279 | int 0x40 |
131 | diamond | 280 | |
180 | heavyiron | 281 | |
131 | diamond | 282 | mov eax,8 |
180 | heavyiron | 283 | mov ebx,30*65536+100 |
131 | diamond | 284 | mov ecx,378*65536+18 |
285 | mov edx,2 |
||
180 | heavyiron | 286 | mov esi,[sc.work_button] |
685 | gluk | 287 | int 0x40 |
131 | diamond | 288 | ;/////////////////////////////////////////////// Wildwest's 'Pause' button |
180 | heavyiron | 289 | ;mov eax,8 |
131 | diamond | 290 | mov ebx,132*65536+102 |
291 | mov ecx,378*65536+18 |
||
292 | mov edx,3 |
||
180 | heavyiron | 293 | mov esi,[sc.work_button]; |
685 | gluk | 294 | int 0x40 |
131 | diamond | 295 | |
296 | mov eax,4 ; function 4 : write text to window |
||
180 | heavyiron | 297 | mov ebx,164*65536+384 ; [x start] *65536 + [y start] |
298 | mov ecx,[sc.work_button_text] ; color of text RRGGBB |
||
299 | or ecx,0x90000000 |
||
300 | mov edx,labe ; pointer to text |
||
685 | gluk | 301 | int 0x40 |
131 | diamond | 302 | ;/////////////////////////////////////////////// |
180 | heavyiron | 303 | ;mov eax,4 |
131 | diamond | 304 | mov ebx,49*65536+384 |
305 | mov edx,game_finished |
||
685 | gluk | 306 | int 0x40 |
131 | diamond | 307 | call draw_table |
308 | |||
309 | movzx edx,byte [current_block_color] |
||
310 | call draw_block |
||
311 | |||
312 | cld |
||
313 | mov ebx,38*65536+35 ; draw info text with function 4 |
||
180 | heavyiron | 314 | mov ecx,[sc.work_text] ; color |
315 | or ecx,0x90000000 |
||
131 | diamond | 316 | mov edx,text |
317 | mov eax,4 |
||
685 | gluk | 318 | int 0x40 |
131 | diamond | 319 | |
320 | call write_score |
||
321 | |||
322 | mov eax,12 ; function 12:tell os about windowdraw |
||
323 | mov ebx,2 ; 2, end of draw |
||
685 | gluk | 324 | int 0x40 |
131 | diamond | 325 | |
326 | ret |
||
327 | |||
328 | ;------------------------------------------------------------- |
||
329 | ; CHECK CRASH |
||
330 | ; output Z flag => OK |
||
331 | ; NZ flag => NO |
||
332 | ;------------------------------------------------------------- |
||
333 | |||
334 | check_crash: mov ebx,[current_block_pointer] |
||
335 | |||
336 | mov edx,[current_block_y] |
||
337 | imul edx,LEN_X |
||
338 | add edx,[current_block_x] ;find the offset in tetris_t |
||
339 | |||
340 | add edx,table_tetris |
||
341 | |||
342 | mov ecx,4 |
||
343 | xor ax,ax |
||
344 | |||
345 | adr_1: cmp byte [ebx],1 |
||
346 | jne adr_2 |
||
347 | add al,[edx] |
||
348 | adc ah,0 |
||
349 | adr_2: inc ebx |
||
350 | inc edx |
||
351 | |||
352 | cmp byte [ebx],1 |
||
353 | jne adr_3 |
||
354 | add al,[edx] |
||
355 | adc ah,0 |
||
356 | adr_3: inc ebx |
||
357 | inc edx |
||
358 | |||
359 | cmp byte [ebx],1 |
||
360 | jne adr_4 |
||
361 | add al,[edx] |
||
362 | adc ah,0 |
||
363 | adr_4: inc ebx |
||
364 | inc edx |
||
365 | |||
366 | cmp byte [ebx],1 |
||
367 | jne adr_5 |
||
368 | add al,[edx] |
||
369 | adc ah,0 |
||
370 | adr_5: inc ebx |
||
371 | add edx,LEN_X-3 |
||
372 | |||
373 | loop adr_1 |
||
374 | or ax,ax |
||
375 | ret |
||
376 | ;------------------------------------------------------------- |
||
377 | ;NEW BLOCK |
||
378 | ;------------------------------------------------------------- |
||
379 | new_block: mov dword [current_block_y],1 |
||
380 | mov dword [current_block_x],7 |
||
381 | |||
1756 | dunkaist | 382 | mov [force_down], 0 ; allow fast falling _after_ first game step |
383 | |||
131 | diamond | 384 | call random |
385 | and al,7 |
||
386 | setz ah |
||
387 | add al,ah |
||
388 | mov [current_block_color],al |
||
389 | |||
390 | call random |
||
391 | ;and eax,15 |
||
392 | ; ---- Ivan ---- |
||
393 | and eax,0xff |
||
394 | @@: |
||
395 | cmp eax,_MAXBLOCKS_ |
||
396 | jl @f |
||
397 | add eax,-(_MAXBLOCKS_) |
||
398 | jmp @b |
||
399 | @@: |
||
400 | ; ---- Ivan ---- |
||
401 | mov edx,[block_table+eax*4] |
||
402 | mov [current_block_pointer],edx |
||
403 | |||
404 | mov byte [delay],22 ;19 ;!!! 15 |
||
405 | ret |
||
406 | ;------------------------------------------------------------- |
||
407 | ; FIX BLOCK |
||
408 | ;------------------------------------------------------------- |
||
409 | fix_block: mov ebx,[current_block_pointer] |
||
410 | |||
411 | mov edx,[current_block_y] |
||
412 | imul edx,LEN_X |
||
413 | add edx,[current_block_x] ;find the offset in tetris_t |
||
414 | |||
415 | add edx,table_tetris |
||
416 | |||
417 | mov ecx,4 |
||
418 | mov al,[current_block_color] |
||
419 | |||
420 | adr_21: cmp byte [ebx],1 |
||
421 | jne adr_22 |
||
422 | mov [edx],al |
||
423 | adr_22: inc ebx |
||
424 | inc edx |
||
425 | |||
426 | cmp byte [ebx],1 |
||
427 | jne adr_23 |
||
428 | mov [edx],al |
||
429 | adr_23: inc ebx |
||
430 | inc edx |
||
431 | |||
432 | cmp byte [ebx],1 |
||
433 | jne adr_24 |
||
434 | mov [edx],al |
||
435 | adr_24: inc ebx |
||
436 | inc edx |
||
437 | |||
438 | cmp byte [ebx],1 |
||
439 | jne adr_25 |
||
440 | mov [edx],al |
||
441 | adr_25: inc ebx |
||
442 | add edx,LEN_X-3 |
||
443 | |||
444 | loop adr_21 |
||
445 | ret |
||
446 | |||
447 | ;-------------------------------------------------------------- |
||
448 | ; DRAW_TABLE |
||
449 | ;-------------------------------------------------------------- |
||
450 | draw_table: mov esi,table_tetris+LEN_X*BORDER_TOP+BORDER_LEFT |
||
451 | |||
452 | mov ebx,X_LOCATION*65536+ADOBE_SIZE |
||
453 | mov ecx,Y_LOCATION*65536+ADOBE_SIZE |
||
454 | mov edi,LEN_Y-BORDER_TOP-BORDER_BOTTOM |
||
455 | y_draw: push edi |
||
456 | |||
457 | mov edi,LEN_X-BORDER_LEFT-BORDER_RIGHT |
||
458 | x_draw: push edi |
||
459 | ; pusha |
||
460 | ; mov eax,5 |
||
461 | ; mov ebx,10 |
||
685 | gluk | 462 | ; int 0x40 |
131 | diamond | 463 | ; popa |
180 | heavyiron | 464 | mov eax,13 |
131 | diamond | 465 | movzx edx,byte [esi] |
466 | mov edx,[color_table+edx*4] |
||
685 | gluk | 467 | int 0x40 |
131 | diamond | 468 | call draw_frames |
469 | inc esi |
||
470 | add ebx,65536*ADOBE_SIZE |
||
471 | pop edi |
||
472 | dec edi |
||
473 | jnz x_draw |
||
474 | |||
475 | add esi,BORDER_LEFT+BORDER_RIGHT |
||
476 | mov ebx,X_LOCATION*65536+ADOBE_SIZE |
||
477 | add ecx,65536*ADOBE_SIZE |
||
478 | pop edi |
||
479 | dec edi |
||
480 | jnz y_draw |
||
481 | |||
482 | ret |
||
483 | ;-------------------------------------------------------------- |
||
484 | ;DRAW BLOCK |
||
485 | ; |
||
486 | ; ebx=x [0..LEN_X-1] |
||
487 | ; ecx=y [0..LEN_Y-1] |
||
488 | ; edi=pointer block |
||
489 | ;-------------------------------------------------------------- |
||
490 | draw_block: |
||
491 | |||
492 | mov eax,13 |
||
493 | mov edx,[color_table+edx*4] |
||
494 | |||
495 | mov ebx,[current_block_x] |
||
496 | mov ecx,[current_block_y] |
||
497 | mov edi,[current_block_pointer] |
||
498 | |||
499 | sub ebx,BORDER_LEFT |
||
500 | imul ebx,ADOBE_SIZE |
||
501 | add ebx,X_LOCATION |
||
502 | shl ebx,16 |
||
503 | mov bx,ADOBE_SIZE |
||
504 | |||
505 | sub ecx,BORDER_TOP |
||
506 | imul ecx,ADOBE_SIZE |
||
507 | add ecx,Y_LOCATION |
||
508 | shl ecx,16 |
||
509 | mov cx,ADOBE_SIZE |
||
510 | |||
511 | mov dword [TMP_1],4 |
||
512 | adr_122: mov dword [TMP_0],4 |
||
513 | adr_121: cmp byte [edi],0 |
||
514 | je adr_120 |
||
515 | |||
685 | gluk | 516 | int 040h |
131 | diamond | 517 | |
518 | call draw_frames |
||
519 | |||
520 | adr_120: inc edi |
||
521 | add ebx,ADOBE_SIZE*65536 |
||
522 | dec dword [TMP_0] |
||
523 | jnz adr_121 |
||
524 | sub ebx,4*ADOBE_SIZE*65536 |
||
525 | add ecx,ADOBE_SIZE*65536 |
||
526 | dec dword [TMP_1] |
||
527 | jnz adr_122 |
||
528 | |||
529 | ret |
||
530 | |||
531 | draw_frames: |
||
532 | cmp edx,0 |
||
533 | jne df1 |
||
534 | ret |
||
535 | df1: |
||
536 | pusha |
||
537 | mov bx,1 |
||
538 | add edx,0x282828 |
||
539 | mov eax,13 |
||
685 | gluk | 540 | int 0x40 |
131 | diamond | 541 | popa |
542 | |||
543 | pusha |
||
544 | mov cx,1 |
||
545 | add edx,0x282828 |
||
546 | mov eax,13 |
||
685 | gluk | 547 | int 0x40 |
131 | diamond | 548 | popa |
549 | |||
550 | pusha |
||
551 | push ebx |
||
552 | sub bx,1 |
||
553 | add [esp+2],bx |
||
554 | pop ebx |
||
555 | mov bx,1 |
||
556 | shr edx,1 |
||
557 | and edx,0x7f7f7f |
||
558 | mov eax,13 |
||
685 | gluk | 559 | int 0x40 |
131 | diamond | 560 | popa |
561 | |||
562 | pusha |
||
563 | push ecx |
||
564 | sub cx,1 |
||
565 | add [esp+2],cx |
||
566 | pop ecx |
||
567 | mov cx,1 |
||
568 | shr edx,1 |
||
569 | and edx,0x7f7f7f |
||
570 | mov eax,13 |
||
685 | gluk | 571 | int 0x40 |
131 | diamond | 572 | popa |
573 | |||
574 | ret |
||
575 | |||
576 | |||
577 | ;-------------------------------------------------------------- |
||
578 | clear_table_tetris: |
||
579 | cld |
||
580 | mov al,1 |
||
581 | mov edi,table_tetris |
||
582 | mov ecx,LEN_X*BORDER_TOP |
||
583 | rep stosb |
||
584 | |||
585 | mov edx,LEN_Y-BORDER_TOP-BORDER_BOTTOM |
||
586 | adr300: mov cl,BORDER_LEFT |
||
587 | rep stosb |
||
588 | dec ax ;AL=0 |
||
589 | mov cl,LEN_X-BORDER_LEFT-BORDER_RIGHT |
||
590 | rep stosb |
||
591 | inc ax ;AL=1 |
||
592 | mov cl,BORDER_RIGHT |
||
593 | rep stosb |
||
594 | dec dx |
||
595 | jne adr300 |
||
596 | |||
597 | mov ecx,LEN_X*BORDER_BOTTOM |
||
598 | rep stosb |
||
599 | ret |
||
600 | ;-------------------------------------------------------------- |
||
601 | ;edx = pointer |
||
602 | ;ebx = contatore |
||
603 | check_full_line: |
||
604 | std |
||
605 | mov al,0 |
||
606 | mov edx,table_tetris+LEN_X*(LEN_Y-BORDER_BOTTOM)-1 |
||
607 | mov ebx,(LEN_Y-BORDER_TOP-BORDER_BOTTOM-1)*LEN_X |
||
608 | |||
609 | adr_5000: mov edi,edx |
||
610 | mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT+1;Wildwest's fix for bug |
||
611 | ;(was LEN_X-BORDER_LEFT-BORDER_RIGHT) |
||
612 | repne scasb |
||
613 | jz no_full_line |
||
614 | |||
615 | lea esi,[edx-LEN_X] |
||
616 | mov edi,edx |
||
617 | mov ecx,ebx |
||
618 | rep movsb |
||
619 | sub edi,BORDER_RIGHT |
||
620 | mov ecx,LEN_X-BORDER_LEFT-BORDER_RIGHT |
||
621 | rep stosb |
||
622 | add dword [score],50 |
||
623 | jmp adr_5000 |
||
624 | |||
625 | no_full_line: sub edx,LEN_X |
||
626 | sub ebx,LEN_X |
||
627 | jnz adr_5000 |
||
628 | |||
629 | ret |
||
630 | ;-------------------------------------------------------------- |
||
631 | random: mov eax,[generator] |
||
632 | add eax,-43ab45b5h |
||
633 | ror eax,1 |
||
634 | xor eax,32c4324fh |
||
635 | ror eax,1 |
||
636 | mov [generator],eax |
||
637 | ; --- IVAN --- |
||
638 | push ebx |
||
639 | mov eax,26 |
||
640 | mov ebx,9 |
||
685 | gluk | 641 | int 0x40 |
131 | diamond | 642 | pop ebx |
643 | xor eax,0xdeadbeef |
||
644 | add eax,[generator] |
||
645 | ; --- IVAN --- |
||
646 | mov [generator],eax ; Halyavin |
||
647 | ret |
||
648 | ;-------------------------------------------------------------- |
||
649 | number_to_str: mov edi,end_number_str-1 |
||
650 | mov ecx,9;size_of_number_str |
||
651 | mov ebx,10 |
||
652 | cld |
||
653 | new_digit: xor edx,edx |
||
654 | div ebx |
||
655 | add dl,'0' |
||
656 | mov [edi],dl |
||
657 | dec edi |
||
658 | loop new_digit |
||
659 | ret |
||
660 | ;-------------------------------------------------------------- |
||
661 | write_score: |
||
662 | mov eax,[score] |
||
663 | call number_to_str |
||
664 | |||
180 | heavyiron | 665 | mov ebx,90*65536+35 ; draw info text with function 4 |
666 | mov ecx,[sc.work_text] ; color |
||
667 | or ecx,0x50000000 |
||
131 | diamond | 668 | mov edx,number_str |
669 | mov esi,[size_of_number_str] |
||
180 | heavyiron | 670 | mov edi,[sc.work] |
131 | diamond | 671 | mov eax,4 |
685 | gluk | 672 | int 0x40 |
131 | diamond | 673 | ret |
674 | |||
31 | halyavin | 675 | ; DATA AREA |
676 | |||
131 | diamond | 677 | ;-------------------------------------------------------------- |
678 | ;DEFINITION BLOCKS |
||
679 | ;-------------------------------------------------------------- |
||
680 | t_block_0: db 0,0,0,0 |
||
681 | db 1,1,1,0 |
||
682 | db 0,1,0,0 |
||
683 | db 0,0,0,0 |
||
684 | dd t_block_3 |
||
31 | halyavin | 685 | |
131 | diamond | 686 | t_block_1: db 0,1,0,0 |
687 | db 1,1,0,0 |
||
688 | db 0,1,0,0 |
||
689 | db 0,0,0,0 |
||
690 | dd t_block_0 |
||
31 | halyavin | 691 | |
131 | diamond | 692 | t_block_2: db 0,1,0,0 |
693 | db 1,1,1,0 |
||
694 | db 0,0,0,0 |
||
695 | db 0,0,0,0 |
||
696 | dd t_block_1 |
||
31 | halyavin | 697 | |
131 | diamond | 698 | t_block_3 db 0,1,0,0 |
699 | db 0,1,1,0 |
||
700 | db 0,1,0,0 |
||
701 | db 0,0,0,0 |
||
702 | dd t_block_2 |
||
703 | ;-------------------------------------------------------------- |
||
704 | i_block_0: db 0,1,0,0 |
||
705 | db 0,1,0,0 |
||
706 | db 0,1,0,0 |
||
707 | db 0,1,0,0 |
||
708 | dd i_block_1 |
||
31 | halyavin | 709 | |
131 | diamond | 710 | i_block_1: db 0,0,0,0 |
711 | db 1,1,1,1 |
||
712 | db 0,0,0,0 |
||
713 | db 0,0,0,0 |
||
714 | dd i_block_0 |
||
715 | ;-------------------------------------------------------------- |
||
716 | q_block_0: db 0,1,1,0 |
||
717 | db 0,1,1,0 |
||
718 | db 0,0,0,0 |
||
719 | db 0,0,0,0 |
||
720 | dd q_block_0 |
||
721 | ;-------------------------------------------------------------- |
||
722 | s_block_0: |
||
723 | db 0,0,0,0 |
||
724 | db 0,1,1,0 |
||
725 | db 1,1,0,0 |
||
726 | db 0,0,0,0 |
||
727 | dd s_block_1 |
||
31 | halyavin | 728 | |
131 | diamond | 729 | s_block_1: db 1,0,0,0 |
730 | db 1,1,0,0 |
||
731 | db 0,1,0,0 |
||
732 | db 0,0,0,0 |
||
733 | dd s_block_0 |
||
734 | ;-------------------------------------------------------------- |
||
735 | l_block_0: db 0,0,0,0 |
||
736 | db 1,1,1,0 |
||
737 | db 1,0,0,0 |
||
738 | db 0,0,0,0 |
||
739 | dd l_block_3 |
||
31 | halyavin | 740 | |
131 | diamond | 741 | l_block_1: db 1,1,0,0 |
742 | db 0,1,0,0 |
||
743 | db 0,1,0,0 |
||
744 | db 0,0,0,0 |
||
745 | dd l_block_0 |
||
31 | halyavin | 746 | |
131 | diamond | 747 | l_block_2: db 0,0,1,0 |
748 | db 1,1,1,0 |
||
749 | db 0,0,0,0 |
||
750 | db 0,0,0,0 |
||
751 | dd l_block_1 |
||
752 | |||
753 | l_block_3: db 0,1,0,0 |
||
754 | db 0,1,0,0 |
||
755 | db 0,1,1,0 |
||
756 | db 0,0,0,0 |
||
757 | dd l_block_2 |
||
758 | ;----------------------------------------------- |
||
759 | |||
760 | g_block_0: |
||
761 | |||
762 | db 0,1,0,0 |
||
763 | db 0,1,0,0 |
||
764 | db 1,1,0,0 |
||
765 | db 0,0,0,0 |
||
766 | dd g_block_1 |
||
767 | |||
768 | g_block_1: |
||
769 | db 0,0,0,0 |
||
770 | db 1,1,1,0 |
||
771 | db 0,0,1,0 |
||
772 | db 0,0,0,0 |
||
773 | dd g_block_2 |
||
774 | |||
775 | g_block_2: |
||
776 | db 0,1,1,0 |
||
777 | db 0,1,0,0 |
||
778 | db 0,1,0,0 |
||
779 | db 0,0,0,0 |
||
780 | dd g_block_3 |
||
781 | |||
782 | g_block_3: |
||
783 | db 1,0,0,0 |
||
784 | db 1,1,1,0 |
||
785 | db 0,0,0,0 |
||
786 | db 0,0,0,0 |
||
787 | dd g_block_0 |
||
788 | |||
789 | ;----------------------------------- |
||
790 | |||
791 | k_block_0: |
||
792 | db 0,0,0,0 |
||
793 | db 1,1,0,0 |
||
794 | db 0,1,1,0 |
||
795 | db 0,0,0,0 |
||
796 | dd k_block_1 |
||
797 | |||
798 | k_block_1: |
||
799 | db 0,1,0,0 |
||
800 | db 1,1,0,0 |
||
801 | db 1,0,0,0 |
||
802 | db 0,0,0,0 |
||
803 | dd k_block_0 |
||
804 | |||
805 | ;----------------------------------- |
||
806 | |||
807 | color_table: dd 00000000h ;black 0 |
||
808 | dd 00cccccch ;white 1 |
||
809 | dd 00cc0000h ;red 2 |
||
810 | dd 0000cc00h ;green 3 |
||
811 | dd 000000cch ;blue 4 |
||
812 | dd 00cccc00h ;yellow 5 |
||
813 | dd 0000cccch ;cyan 6 |
||
814 | dd 00cc00cch ;pink 7 |
||
815 | |||
816 | block_table: |
||
817 | dd t_block_0 ; t |
||
818 | dd t_block_1 |
||
819 | dd t_block_2 |
||
820 | dd t_block_3 |
||
821 | dd i_block_0 ; i |
||
822 | dd i_block_1 |
||
823 | dd i_block_0 |
||
824 | dd i_block_1 |
||
825 | dd q_block_0 ; q |
||
826 | dd q_block_0 |
||
827 | dd q_block_0 |
||
828 | dd q_block_0 |
||
829 | dd s_block_0 ; s |
||
830 | dd s_block_1 |
||
831 | dd s_block_0 |
||
832 | dd s_block_1 |
||
833 | dd l_block_0 ; l |
||
834 | dd l_block_1 |
||
835 | dd l_block_2 |
||
836 | dd l_block_3 |
||
837 | dd g_block_0 ; g |
||
838 | dd g_block_1 |
||
839 | dd g_block_2 |
||
840 | dd g_block_3 |
||
841 | dd k_block_0 ; k |
||
842 | dd k_block_1 |
||
843 | dd k_block_0 |
||
844 | dd k_block_1 |
||
845 | |||
846 | if lang eq ru |
||
847 | |||
1728 | clevermous | 848 | title db '’…’ˆ‘ 1.61 - ‘’…‹Šˆ ˆ Ž…‹',0 |
180 | heavyiron | 849 | labe db '€“‡€',0 |
850 | text db 'Žçª¨:',0 |
||
2679 | leency | 851 | game_finished: db ' Ž‚€Ÿ',0 |
131 | diamond | 852 | |
3932 | kaitz | 853 | else if lang eq et |
854 | |||
855 | title db 'TETRIS 1.61 - NOOLED & TÜHIK',0 |
||
856 | labe db 'PAUS',0 |
||
857 | text db 'Tulemus:',0 |
||
858 | game_finished: db 'UUS MÄNG',0 |
||
859 | |||
131 | diamond | 860 | else |
861 | |||
1728 | clevermous | 862 | title db 'TETRIS 1.61 - ARROWS & SPACE',0 |
180 | heavyiron | 863 | labe db 'PAUSE',0 |
864 | text db 'Score:',0 |
||
865 | game_finished: db 'NEW GAME',0 |
||
131 | diamond | 866 | |
867 | end if |
||
868 | |||
869 | pauses dd 0 ;/// Wildwest |
||
870 | parallel dd 1 |
||
871 | score: dd 0 |
||
872 | TMP_0: dd 0 |
||
873 | TMP_1: dd 0 |
||
874 | generator: dd 0 |
||
875 | current_block_x: dd 0 |
||
876 | current_block_y: dd 0 |
||
877 | current_block_pointer: dd 0 |
||
878 | current_block_color: db 0 |
||
879 | number_str: db 0,0,0,0,0,0,0,0,0 |
||
31 | halyavin | 880 | end_number_str: |
131 | diamond | 881 | size_of_number_str dd 9 |
882 | delay: db 40 |
||
1756 | dunkaist | 883 | force_down dd 1 |
180 | heavyiron | 884 | sc system_colors |
131 | diamond | 885 | table_tetris: |
31 | halyavin | 886 | |
131 | diamond | 887 | I_END: |
180 | heavyiron | 888 |