├── README.md └── TetRis.asm /README.md: -------------------------------------------------------------------------------- 1 | # Tetris-Assembly-8086 2 | The traditional tetris game implemented using 8086 assembly language. GUI Turbo Assembler was used to compile codes 3 | -------------------------------------------------------------------------------- /TetRis.asm: -------------------------------------------------------------------------------- 1 | .Model Small 2 | 3 | ;;;;;;;;;;;; macros ;;;;;;;;;; 4 | 5 | draw_row Macro x,y,z,color ;x - row, y - begining column, z - ending column 6 | Local L1 7 | ; draws a line in row x from col y to col z 8 | MOV AH, 0CH 9 | MOV AL, color 10 | MOV CX, y 11 | MOV DX, x 12 | L1: INT 10h 13 | INC CX 14 | CMP CX, z 15 | JL L1 16 | EndM 17 | 18 | draw_column Macro x,y,z,color ;x - column, y - begining row, z - ending row 19 | Local L2 20 | ; draws a line col y from row y to row z 21 | MOV AH, 0CH 22 | MOV AL, color 23 | MOV CX, x 24 | MOV DX, y 25 | L2: INT 10h 26 | INC DX 27 | CMP DX, z 28 | JL L2 29 | EndM 30 | 31 | display_string Macro x,row,column,length,color 32 | 33 | push ax 34 | push bx 35 | 36 | MOV AX, @DATA 37 | MOV ES, AX 38 | 39 | MOV AH, 13H ; WRITE THE STRING 40 | MOV AL, 0H; ATTRIBUTE IN BL, MOVE CURSOR TO THAT POSITION 41 | XOR BH,BH ; VIDEO PAGE = 0 42 | mov bl,color 43 | 44 | MOV BP, OFFSET x ; ES: BP POINTS TO THE TEXT 45 | MOV CX, length ; LENGTH OF THE STRING 46 | MOV DH, row ;ROW TO PLACE STRING 47 | MOV DL, column ; COLUMN TO PLACE STRING 48 | INT 10H 49 | 50 | pop bx 51 | pop ax 52 | 53 | EndM 54 | 55 | 56 | draw_block Macro start_row, end_row, start_column, end_column, color_block 57 | Local along_row 58 | 59 | ; draws a square 60 | 61 | MOV DX, start_row 62 | 63 | along_row: 64 | 65 | draw_row DX, start_column, end_column,color_block 66 | INC DX 67 | CMP DX, end_row 68 | JLE along_row 69 | 70 | EndM 71 | 72 | ;write a draw piece macro - task for tomorrow (angela) 73 | 74 | draw_full_block Macro pattern_name, color, compare ;compare - 4ta block er jonno jhamela,tai last row er first element ta eta 75 | Local draw 76 | 77 | ;draws a full pattern 78 | 79 | MOV BX,0 80 | 81 | draw: 82 | draw_block [pattern_name+BX],[pattern_name+BX+2],[pattern_name+BX+4],[pattern_name+BX+6],color 83 | ADD BX,8 84 | CMP BX,compare 85 | JLE draw 86 | 87 | EndM 88 | 89 | 90 | 91 | update_block Macro pattern_name, blockToBeUpdated 92 | local while 93 | 94 | push ax 95 | push bx 96 | push cx 97 | mov cx,16 98 | mov bx,0 99 | 100 | while: 101 | mov ax,pattern_name[bx] 102 | mov blockToBeUpdated[bx],ax 103 | add bx,2 104 | ; cmp bx,24 105 | loop while 106 | 107 | pop cx 108 | pop bx 109 | pop ax 110 | EndM 111 | 112 | 113 | 114 | 115 | ;pull row downwards 116 | modify_row_elements Macro pattern_name, delta, number_of_blocks ; delta = dhakkar amount :3 117 | local ghuro,exit 118 | 119 | push ax 120 | push bx 121 | PUSH CX 122 | PUSH DX 123 | 124 | 125 | ;modify row elements 126 | 127 | mov cx,number_of_blocks 128 | mov bx,0 129 | 130 | ghuro: 131 | 132 | xor ax,ax 133 | xor dx,dx 134 | 135 | MOV ax,pattern_name[bx] 136 | add ax,delta 137 | MOV pattern_name[bx],ax 138 | 139 | add bx,2 140 | 141 | MOV dx,pattern_name[bx] 142 | add dx,delta 143 | MOV pattern_name[bx],dx 144 | 145 | add bx,6 146 | 147 | loop ghuro 148 | 149 | 150 | exit: 151 | pop dx 152 | pop cx 153 | pop bx 154 | pop ax 155 | 156 | EndM 157 | 158 | ;;;;;;;;;;;;;; ;daine bame dhakka dibo B| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 159 | 160 | modify_column_elementsD Macro pattern_name, delta, compare ; delta = dhakkar amount :3 161 | local byebye,shorao 162 | 163 | 164 | push ax 165 | push bx 166 | PUSH CX 167 | PUSH DX 168 | 169 | ;modify column elements 170 | 171 | mov bx,4 172 | 173 | shorao: 174 | 175 | 176 | ; cmp pattern_name[30],345 177 | ; jg byebye 178 | koop: 179 | MOV cx,pattern_name[bx] 180 | add cx,delta 181 | cmp cx,380 182 | jge byebye 183 | MOV pattern_name[bx],cx 184 | 185 | add bx,2 186 | MOV dx,pattern_name[bx] 187 | 188 | add dx,delta 189 | MOV pattern_name[bx],dx 190 | 191 | add bx,6 192 | xor cx,cx 193 | xor dx,dx 194 | 195 | cmp bx,compare 196 | jle shorao 197 | 198 | 199 | 200 | byebye: 201 | 202 | 203 | pop dx 204 | pop cx 205 | pop bx 206 | pop ax 207 | 208 | EndM 209 | 210 | 211 | modify_column_elementsA Macro pattern_name, delta, compare 212 | local byebye,shorao 213 | 214 | push ax 215 | push bx 216 | PUSH CX 217 | PUSH DX 218 | 219 | ;modify column elements 220 | 221 | mov bx,4 222 | 223 | shorao: 224 | 225 | 226 | MOV cx,pattern_name[bx] 227 | sub cx,delta 228 | cmp cx,220 229 | jle byebye 230 | MOV pattern_name[bx],cx 231 | 232 | add bx,2 233 | MOV dx,pattern_name[bx] 234 | sub dx,delta 235 | MOV pattern_name[bx],dx 236 | 237 | 238 | add bx,6 239 | xor cx,cx 240 | xor dx,dx 241 | 242 | cmp bx,compare 243 | jle shorao 244 | 245 | 246 | byebye: 247 | 248 | ;sub cx,2 ; offset move 249 | ;MOV pattern_name[bx],cx 250 | 251 | pop dx 252 | pop cx 253 | pop bx 254 | pop ax 255 | 256 | 257 | EndM 258 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;dhakkadhakki sesh B| 259 | 260 | 261 | 262 | time_delay Macro pattern_name 263 | Local tt,tt1,tt2,tt3,tt4,tt5,tt6,tt7,tt8,tt9,tt10,tt11,sesh,show 264 | ; push ax 265 | push bx 266 | push cx 267 | push dx 268 | 269 | tt: 270 | CMP timer_flag, 1 271 | JNE tt 272 | MOV timer_flag, 0 273 | 274 | ;draw_block 158,163,235,360,08h 275 | 276 | 277 | 278 | CALL move_block 279 | ;CALL check_line 280 | 281 | 282 | mov bx,pattern_name[16] 283 | cmp bX,158 ;fixed this one 284 | jg sesh 285 | 286 | ;;;;;;;;;;;;;;;;;;;;; 287 | ; mov cx,pattern_name[20] 288 | ; add cx,5 289 | ; mov dx,pattern_name[16] 290 | ; add dx,10 291 | ; xor ax,ax 292 | ; mov ah,0dh 293 | ; int 10h 294 | ; cmp al,09h 295 | ; je sesh 296 | ;;;;;;;;;;;;;;;;;;;;; 297 | 298 | 299 | 300 | 301 | tt2: 302 | CMP timer_flag, 1 303 | JNE tt2 304 | MOV timer_flag, 0 305 | tt3: 306 | CMP timer_flag,1 307 | JNE tt3 308 | MOV timer_flag,0 309 | tt4: 310 | CMP timer_flag,1 311 | JNE tt4 312 | MOV timer_flag,0 313 | tt5: 314 | CMP timer_flag,1 315 | JNE tt5 316 | MOV timer_flag,0 317 | tt6: 318 | CMP timer_flag,1 319 | JNE tt6 320 | MOV timer_flag,0 321 | tt7: 322 | CMP timer_flag,1 323 | JNE tt7 324 | MOV timer_flag,0 325 | tt8: 326 | CMP timer_flag,1 327 | JNE tt8 328 | MOV timer_flag,0 329 | tt9: 330 | CMP timer_flag,1 331 | JNE tt9 332 | MOV timer_flag,0 333 | tt10: 334 | CMP timer_flag,1 335 | JNE tt10 336 | MOV timer_flag,0 337 | tt11: 338 | CMP timer_flag,1 339 | JNE tt11 340 | MOV timer_flag,0 341 | 342 | JMP tt 343 | 344 | 345 | sesh: 346 | 347 | 348 | ; mov [block_boshche],1 349 | 350 | pop dx 351 | pop cx 352 | pop bx 353 | EndM 354 | 355 | 356 | 357 | .Stack 100h 358 | 359 | 360 | .Data 361 | new_timer_vec dw ?,? 362 | old_timer_vec dw ?,? 363 | a1 dw ? 364 | a2 dw ? 365 | b1 dw ? 366 | b2 dw ? 367 | score dw ? 368 | flagg db 0 369 | color db 4 370 | seshs db 0 371 | next_color db 9 372 | line dw 0 373 | timer_flag db 0 374 | vel_x dw 1 375 | vel_y dw 1 376 | boxer_a dw ? ; these two vars deal with current upper and lower row bounds 377 | boxer_b dw ? ; of the single blocks 378 | 379 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 380 | ; strings that will be displayed ; 381 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 382 | 383 | msg_next db "Next$",0 384 | msg_left db "A - Left$" 385 | msg_right db "D - Right$" 386 | msg_rotate db "S - Jump Fast$" 387 | msg_quit db "Q - Quit$" 388 | msg_lines db "Lines$" 389 | msg_score db "Score$" 390 | msg_game_over db "Game Over!$" 391 | msg_tetris db "TETRIS$" 392 | game_score db "0000$" 393 | 394 | 395 | 396 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 397 | 398 | screen_width dw 320 399 | column_limit dw 0 400 | row_limit dw 0 401 | block_width dw 10 402 | block_height dw 5 403 | block_boundary dw 153 404 | block_boshche dw 0 405 | box_medium dw 100 406 | current_row dw 0 407 | current_block dw 0 408 | next_block dw 0 409 | 410 | 411 | ;;;;;;;; time ;;;;;;;; 412 | 413 | ;;;;;;;;;;;;; blocks ;;;;;;;;;;;;;;;;;;;;;; 414 | 415 | horizontal dw 51,56,290,300 416 | dw 51,56,300,310 417 | dw 51,56,310,320 418 | dw 0,0,0,0 419 | 420 | 421 | next_horizontal dw 71,76,430,440 422 | dw 71,76,440,450 423 | dw 71,76,450,460 424 | dw 0,0,0,0 425 | 426 | 427 | vertical dw 51,56,285,295 428 | dw 56,61,285,295 429 | dw 61,66,285,295 430 | 431 | 432 | 433 | T_shape dw 51,56,290,300 434 | dw 51,56,300,310 435 | dw 51,56,310,320 436 | dw 56,62,310,320 437 | 438 | 439 | L_shape dw 51,56,290,300 440 | dw 51,56,300,310 441 | dw 51,56,310,320 442 | dw 45,50,290,300 443 | 444 | 445 | next_L_shape dw 71,76,430,440 446 | dw 71,76,440,450 447 | dw 71,76,450,460 448 | dw 65,70,430,440 449 | 450 | 451 | 452 | Ulta_L dw 51,56,290,300 453 | dw 51,56,300,310 454 | dw 51,56,310,320 455 | dw 57,64,310,320 456 | 457 | 458 | Ulta_T dw 51,56,290,300 459 | dw 51,56,300,310 460 | dw 51,56,310,320 461 | dw 45,50,310,320 462 | 463 | 464 | right_L dw 51,56,290,300 465 | dw 51,56,300,310 466 | dw 51,56,310,320 467 | dw 45,50,310,320 468 | 469 | 470 | next_right_L dw 71,76,430,440 471 | dw 71,76,440,450 472 | dw 71,76,450,460 473 | dw 65,70,450,460 474 | 475 | 476 | currentBlock dw 0,0,0,0 477 | dw 0,0,0,0 478 | dw 0,0,0,0 479 | dw 0,0,0,0 480 | 481 | next_piece dw 0,0,0,0 482 | dw 0,0,0,0 483 | dw 0,0,0,0 484 | dw 0,0,0,0 485 | 486 | offsetArray dw 20,20,140,140 487 | dw 20,20,140,140 488 | dw 20,20,140,140 489 | dw 20,20,140,140 490 | 491 | temp_nxt_piece dw 0,0,0,0 492 | dw 0,0,0,0 493 | dw 0,0,0,0 494 | dw 0,0,0,0 495 | 496 | 497 | choose_random_piece dw 0,0,0,0 498 | dw 0,0,0,0 499 | dw 0,0,0,0 500 | dw 0,0,0,0 501 | 502 | 503 | zero_matrix dw 0,0,0,0 504 | dw 0,0,0,0 505 | dw 0,0,0,0 506 | dw 0,0,0,0 507 | 508 | 509 | 510 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 511 | 512 | .CODE 513 | 514 | MAIN PROC 515 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 516 | ; Initialization 517 | 518 | 519 | MOV AX,@DATA 520 | MOV DS,AX ;DATA INITIALIZATION HOYE GESE 521 | 522 | ; set CGA 640x200 high res mode 523 | mov AH,0 524 | MOV AL,0eh 525 | int 10h 526 | 527 | ; set keyboard parameters to be most responsive 528 | ;mov ax,0305h 529 | ; xor bx,bx 530 | ; int 16h 531 | 532 | ;set bgd color 533 | mov ah,0bh 534 | mov bh,0 535 | mov bl,15 536 | int 10h 537 | 538 | ;generate initial piece 539 | 540 | ;call proc.... 541 | 542 | ;display screen stuffs 543 | 544 | call procedure_draw_screen 545 | 546 | draw_block 158,164,236,360,0fh 547 | 548 | 549 | ;draw a block at roof middle position 550 | 551 | ;MOV BL,13 552 | ;draw_block 51,71,300,310,04h 553 | ;draw_block 51,71,320,330,08h 554 | ;draw_block 51,71,330,340,09h 555 | ;draw_block 160,170,300,310,09h 556 | 557 | ;;;;;;;;;;;;;;;; gravity niye khela hobe -_- ;;;;;;;;;;;;;; 558 | 559 | ; set up timer interrupt vector 560 | MOV new_timer_vec, offset timer_tick 561 | MOV new_timer_vec+2, CS 562 | MOV AL, 1CH; interrupt type 563 | LEA DI, old_timer_vec 564 | LEA SI, new_timer_vec 565 | CALL setup_int 566 | 567 | 568 | ;PUSH CX 569 | ;PUSH DX 570 | ;mov cx,horizontal[4] ;starting point,not yet done for each block,have to fix this one 571 | ;mov dx,horizontal[6] 572 | ; 573 | ;MOV boxer_a,cx 574 | ;MOV boxer_b,dx 575 | ; 576 | ;pop dx 577 | ;pop cx 578 | 579 | ; draw_block boxer_a,boxer_b,320,330,15 580 | ; CALL move_block 581 | ; MOV AH,01h 582 | ; INT 16H 583 | 584 | ;copy horizontal array to currentBlock 585 | ;draw_block 158,163,235,360,08h 586 | mov score,0 587 | ;update_block L_shape, currentBlock 588 | 589 | ;draw_block 158,163,235,360,08h 590 | 591 | ;show_next_piece T_shape,24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; modify this 592 | 593 | ;draw_block 158,163,235,360,08h 594 | 595 | ;for horizontal one 596 | ;time_delay currentBlock 597 | 598 | ; time_delay vertical 599 | ; time_delay L_shape 600 | 601 | ;;;infinite loop e fele diyechi dada;;; :p 602 | ;draw_block 158,163,235,359,08h 603 | 604 | notun_notun_block_banao: 605 | 606 | ;cmp [block_boshche],1 607 | ;jne notun_notun_block_banao 608 | ;mov [block_boshche],0 609 | ;show_next_piece horizontal 610 | ;copy horizontal array to currentBlock 611 | 612 | inc [current_block] 613 | cmp [current_block],3 614 | jle continue_kor 615 | 616 | mov [current_block],1 617 | 618 | continue_kor: 619 | 620 | call gen_block 621 | 622 | update_block choose_random_piece, currentBlock 623 | 624 | call gen_next_piece 625 | call show_next_piece 626 | 627 | time_delay currentBlock 628 | 629 | call hawahawaline 630 | 631 | 632 | 633 | call score_dekhao 634 | call gameover 635 | cmp seshs,23 636 | je seshh 637 | add color,5 638 | add next_color,5 639 | cmp color,14 640 | jg Ooops 641 | 642 | cmp next_color,14 643 | jg Ooops_next 644 | 645 | jmp notun_notun_block_banao 646 | Ooops: 647 | mov color,4 648 | jmp notun_notun_block_banao 649 | 650 | Ooops_next: 651 | mov next_color,4 652 | jmp notun_notun_block_banao 653 | seshh: 654 | 655 | mov ah,0 656 | mov al,13h 657 | int 10h 658 | 659 | 660 | mov ah,0bh 661 | mov bh,0 662 | mov bl,10 663 | int 10h 664 | 665 | 666 | display_string msg_game_over ,10,15,10,2 667 | display_string msg_game_over ,10,15,10,2 668 | display_string msg_game_over ,10,15,10,2 669 | display_string msg_game_over ,10,15,10,2 670 | 671 | 672 | jmp seshh 673 | 674 | MAIN ENDP 675 | 676 | 677 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; all procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 678 | 679 | ; draw screen elements 680 | 681 | procedure_draw_screen proc near 682 | 683 | draw_screen_border: 684 | 685 | ;top left to top right 686 | draw_row 5,10,630,03h 687 | ;top left to bottom left 688 | draw_column 10,5,195,03h 689 | ;top right to bottom right 690 | draw_column 630,5,195,03h 691 | ;bottom left to bottom right 692 | draw_row 195,10,630,03h 693 | 694 | 695 | draw_screen_play_area: 696 | 697 | ;top left to top right 698 | draw_row 42,228,381,7 699 | ;top left to bottom left 700 | draw_column 228,42,165,7 701 | ;top right to bottom right 702 | draw_column 381,42,165,7 703 | ;bottom left to bottom right 704 | draw_row 165,228,381,7 705 | 706 | 707 | draw_screen_next_piece: 708 | 709 | ;top left to top right 710 | draw_row 50,400,487,01h 711 | ;top left to bottom left 712 | draw_column 400,50,90,01h 713 | ;top right to bottom right 714 | draw_column 487,50,90,01h 715 | ;bottom left to bottom right 716 | draw_row 90,400,487,01h 717 | 718 | 719 | draw_screen_strings: 720 | 721 | 722 | ;MOV AX, @DATA 723 | ;MOV ES, AX 724 | 725 | ;MOV AH, 13H ; WRITE THE STRING 726 | ;MOV AL, 0H; ATTRIBUTE IN BL, MOVE CURSOR TO THAT POSITION 727 | ;XOR BH,BH ; VIDEO PAGE = 0 728 | 729 | ;MOV BL, 9 730 | display_string msg_left,10,10,8,9 731 | ;MOV BL, 12 732 | display_string msg_right,12,10,9,12 733 | ;MOV BL, 8 734 | display_string msg_rotate,14,10,13,8 735 | ;MOV BL, 13 736 | ;; display_string msg_quit,16,10,8,12 737 | ;MOV BL, 6 738 | display_string msg_tetris,3,35,6,6 739 | ;MOV BL, 8 740 | display_string msg_next,12,54,4,8 741 | ;MOV BL, 9 742 | display_string msg_score,18,53,5,9 743 | ;mov bl, 8 744 | display_string game_score,16,53,4,8 745 | 746 | ret 747 | 748 | procedure_draw_screen endp 749 | 750 | 751 | 752 | setup_int Proc 753 | ; save old vector and set up new vector 754 | ; input: al = interrupt number 755 | ; di = address of buffer for old vector 756 | ; si = address of buffer containing new vector 757 | ; save old interrupt vector 758 | 759 | MOV AH, 35h ; get vector 760 | INT 21h 761 | MOV [DI], BX ; save offset 762 | MOV [DI+2], ES ; save segment 763 | 764 | ; setup new vector 765 | 766 | MOV DX, [SI] ; dx has offset 767 | PUSH DS ; save ds 768 | MOV DS, [SI+2] ; ds has the segment number 769 | MOV AH, 25h ; set vector 770 | INT 21h 771 | POP DS 772 | RET 773 | setup_int EndP 774 | 775 | 776 | timer_tick Proc 777 | PUSH DS 778 | PUSH AX 779 | 780 | MOV AX, Seg timer_flag 781 | MOV DS, AX 782 | MOV timer_flag, 1 783 | 784 | 785 | exit: 786 | POP AX 787 | POP DS 788 | 789 | IRET 790 | timer_tick EndP 791 | 792 | 793 | 794 | 795 | move_block Proc 796 | ; erase block at current position and display at new position 797 | ; input: CX = col of block position 798 | ; DX = rwo of block position 799 | ; erase block 800 | ; MOV AL, 0 801 | ; mov bx,300 802 | ; mov cx,310 803 | ; push ax 804 | 805 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;keyboard bae 806 | 807 | ; mov ah, 1 ;keyboar buffer check korbe 808 | mov ah, 1 ;keyboar buffer check korbe 809 | int 16h 810 | ; int 16h 811 | jz foo 812 | mov ah, 0 ; key input nibe 813 | int 16h 814 | cmp al,97 ; a checker 815 | je keya 816 | cmp al,100 ; d checker 817 | je fix2 818 | cmp al,115 819 | je dours 820 | foo: jmp boo 821 | 822 | keya: 823 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 824 | 825 | xor cx,cx 826 | xor dx,dx 827 | mov cx,currentBlock[20] 828 | sub cx,45 829 | mov dx,currentBlock[16] 830 | fix1: 831 | jmp fix3 832 | fix2: 833 | jmp keyd 834 | dours: jmp dour 835 | fix3: 836 | 837 | ; xor ax,ax 838 | ; mov dx,158 839 | ; mov cx,301 840 | mov ah,0dh 841 | 842 | 843 | int 10h 844 | cmp al,09h 845 | je boo 846 | cmp al,0eh 847 | je boo 848 | cmp al,04h 849 | je boo 850 | add dx,10 851 | int 10h 852 | cmp al,0eh 853 | je boo 854 | cmp al,09h 855 | je boo 856 | cmp al,04h 857 | je boo 858 | 859 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 860 | draw_full_block currentBlock,15 , 24 861 | modify_column_elementsA currentBlock,30,30 862 | 863 | boo: jmp exittt 864 | 865 | dour: 866 | jmp exitttt 867 | 868 | keyd: 869 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 870 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 871 | xor cx,cx 872 | xor dx,dx 873 | mov cx,currentBlock[20] 874 | add cx,15 875 | mov dx,currentBlock[16] 876 | 877 | ; xor ax,ax 878 | ; mov dx,158 879 | ; mov cx,301 880 | mov ah,0dh 881 | 882 | 883 | int 10h 884 | cmp al,09h 885 | je exittt 886 | cmp al,0eh 887 | je exittt 888 | cmp al,04h 889 | je exittt 890 | 891 | add dx,10 892 | int 10h 893 | cmp al,09h 894 | je exittt 895 | cmp al,0eh 896 | je exittt 897 | cmp al,04h 898 | je exittt 899 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 900 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 901 | draw_full_block currentBlock,15 , 30 902 | modify_column_elementsD currentBlock,30,30 903 | jmp exittt 904 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;muhahaha hoya gese 905 | 906 | 907 | 908 | exittt: 909 | 910 | draw_full_block currentBlock,15, 24 911 | 912 | ;draw_full_block vertical,15 913 | ;draw_full_block L_shape,15 914 | 915 | jmp test_timer 916 | 917 | ; draw_block boxer_a,boxer_b,320,330,15 918 | ; draw_block boxer_a,boxer_b,332,342,15 919 | ; draw_block boxer_a,boxer_b,344,354,15 920 | 921 | ; get new position 922 | ; check boundary 923 | ; cmp cx,160 924 | ; jl exits 925 | ; CALL 926 | 927 | ; wait for 1 timer tick to display block 928 | 929 | exitttt: 930 | 931 | draw_full_block currentBlock,15, 24 932 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 933 | xor cx,cx 934 | xor dx,dx 935 | mov cx,currentBlock[4] 936 | inc cx 937 | ; add cx,20 938 | mov dx,currentBlock[16] 939 | 940 | xor ax,ax 941 | ; mov dx,158 942 | ; mov cx,301 943 | mov ah,0dh 944 | 945 | cmp dx,140 946 | jg test_timer 947 | add dx,24 948 | 949 | int 10h 950 | cmp al,09h 951 | je test_timer 952 | cmp al,0eh 953 | je test_timer 954 | cmp al,04h 955 | je test_timer 956 | add cx,20 957 | int 10h 958 | cmp al,09h 959 | je test_timer 960 | cmp al,0eh 961 | je test_timer 962 | cmp al,04h 963 | je test_timer 964 | ; add cx 20 965 | 966 | ; add dx,10 967 | ;int 10h 968 | ; cmp al,09h 969 | ; je exittt 970 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 971 | modify_row_elements currentBlock,12, 4 972 | jmp test_timer 973 | 974 | test_timer: 975 | 976 | xor ax,ax 977 | CMP timer_flag, 1 978 | JNE test_timer 979 | 980 | modify_row_elements currentBlock,6 ,16 981 | 982 | draw_full_block currentBlock,color,24 983 | ; modify_row_elements vertical 984 | ; modify_row_elements L_shape 985 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 986 | ; push ax 987 | ; push cx 988 | ; push dx 989 | xor cx,cx 990 | xor dx,dx 991 | mov cx,currentBlock[4] 992 | inc cx 993 | ; ; add cx, 994 | mov dx,currentBlock[16] 995 | add dx,10 996 | ; xor ax,ax 997 | ; mov dx,158 998 | ; mov cx,301 999 | mov ah,0dh 1000 | 1001 | 1002 | int 10h 1003 | cmp al,09h 1004 | je exits2 1005 | cmp al,0eh 1006 | je exits2 1007 | cmp al,04h 1008 | je exits2 1009 | 1010 | add cx,20 1011 | 1012 | int 10h 1013 | cmp al,09h 1014 | je exits2 1015 | cmp al,0eh 1016 | je exits2 1017 | cmp al,04h 1018 | je exits2 1019 | 1020 | ; jne exits 1021 | 1022 | 1023 | ; pop dx 1024 | ; pop cx 1025 | ; pop ax 1026 | 1027 | ; jne exits2 1028 | 1029 | ; exits2: 1030 | ; mov currentBlock[18],160 1031 | ; RET 1032 | 1033 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1034 | ; halum: 1035 | 1036 | ;draw_full_block currentBlock,09h 1037 | 1038 | ; draw_full_block vertical,08h 1039 | ; draw_full_block L_shape,08h 1040 | 1041 | 1042 | ;draw_block boxer_a,boxer_b,320,330,08h 1043 | ;draw_block boxer_a,boxer_b,332,342,08h 1044 | ;draw_block boxer_a,boxer_b,344,354,08h 1045 | ; 1046 | 1047 | MOV timer_flag, 0 1048 | ; MOV AL, 3 1049 | 1050 | exits: 1051 | 1052 | RET 1053 | 1054 | exits2: 1055 | 1056 | ; mov cx,170 1057 | 1058 | ; draw_full_block currentBlock,09h 1059 | mov currentBlock[16],170 1060 | 1061 | RET 1062 | 1063 | ;dec cx 1064 | 1065 | 1066 | 1067 | move_block EndP 1068 | 1069 | 1070 | hawahawaline Proc 1071 | ; push dx 1072 | ;; push cx 1073 | ; push bx 1074 | ; push ax 1075 | xor ax,ax 1076 | xor bx,bx 1077 | xor cx,cx 1078 | xor dx,dx 1079 | 1080 | hambahamba: 1081 | 1082 | mov ah,0dh 1083 | 1084 | mov a1,164 1085 | mov b1,56 1086 | mov a2,230 1087 | mov b2,240 1088 | 1089 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1090 | 1091 | 1092 | mov line,170 1093 | ; mov dx,line 1094 | khuru: 1095 | mov cx,235 1096 | sub line,6 1097 | mov dx,line 1098 | mov a1,dx 1099 | dhuru: 1100 | add cx,10 1101 | cmp cx,380 1102 | jg prehh1 1103 | xor ax,ax 1104 | mov ah,0dh 1105 | int 10h 1106 | cmp al,09h 1107 | je dhuru 1108 | cmp al,0eh 1109 | je dhuru 1110 | cmp al,04h 1111 | je dhuru 1112 | jmp hh3 1113 | 1114 | prehh1: 1115 | add score,10 1116 | hh1: 1117 | 1118 | mov a2,220 1119 | sub a1,6 1120 | hh2: 1121 | 1122 | cmp a1,55 1123 | jl hh3 1124 | 1125 | add a2,10 1126 | cmp a2,370 1127 | jg hh1 1128 | 1129 | mov bx,a1 1130 | add bx,6 1131 | mov b1,bx 1132 | 1133 | mov bx,a2 1134 | add bx,10 1135 | mov b2,bx 1136 | xor ax,ax 1137 | xor bx,bx 1138 | xor cx,cx 1139 | xor dx,dx 1140 | mov cx,a2 1141 | inc cx 1142 | ; add cx,15 1143 | mov dx,a1 1144 | sub dx,4 1145 | mov ah,0dh 1146 | int 10h 1147 | draw_block a1,b1,a2,b2,al ;0 hobe kaj korle 1148 | jmp hh2 1149 | 1150 | hh3: 1151 | mov a2,220 1152 | cmp line,60 1153 | jl fillhoynai 1154 | jmp khuru 1155 | fillhoynai: 1156 | ;mov ah,4ch 1157 | ; int 21h 1158 | ; pop ax 1159 | ; pop bx 1160 | ; pop cx 1161 | ; pop dx 1162 | RET 1163 | hawahawaline Endp 1164 | 1165 | 1166 | score_dekhao proc 1167 | 1168 | push ax 1169 | push bx 1170 | push cx 1171 | push dx 1172 | 1173 | 1174 | mov cx,10d 1175 | xor bx,bx 1176 | mov bx,3 1177 | mov ax,score 1178 | 1179 | bhag_kor: 1180 | 1181 | xor dx,dx 1182 | div cx 1183 | 1184 | ;push bx 1185 | ;inc cx 1186 | 1187 | or dl,30h 1188 | mov game_score[bx],dl 1189 | dec bx 1190 | 1191 | 1192 | or ax,ax 1193 | jne bhag_kor 1194 | 1195 | 1196 | 1197 | 1198 | display_string game_score,16,53,4,8 1199 | 1200 | 1201 | pop dx 1202 | pop cx 1203 | pop bx 1204 | pop ax 1205 | 1206 | 1207 | ret 1208 | 1209 | 1210 | score_dekhao Endp 1211 | 1212 | 1213 | gen_block proc 1214 | 1215 | cmp [current_block],1 1216 | je horizontal_ako 1217 | 1218 | cmp [current_block],2 1219 | je L_shape_ako 1220 | 1221 | cmp [current_block],3 1222 | je right_L_ako 1223 | 1224 | 1225 | horizontal_ako: 1226 | update_block horizontal, choose_random_piece 1227 | mov [next_block],2 1228 | ret 1229 | 1230 | 1231 | L_shape_ako: 1232 | update_block L_shape, choose_random_piece 1233 | mov [next_block],3 1234 | ret 1235 | 1236 | right_L_ako: 1237 | update_block right_L, choose_random_piece 1238 | mov [next_block],1 1239 | ret 1240 | 1241 | 1242 | ret 1243 | 1244 | gen_block endp 1245 | 1246 | 1247 | gen_next_piece proc 1248 | 1249 | cmp [next_block],1 1250 | je horizontal_akao 1251 | 1252 | cmp [next_block],2 1253 | je L_shape_akao 1254 | 1255 | cmp [next_block],3 1256 | je right_L_akao 1257 | 1258 | 1259 | horizontal_akao: 1260 | update_block next_horizontal, next_piece 1261 | ret 1262 | 1263 | L_shape_akao: 1264 | update_block next_L_shape, next_piece 1265 | ret 1266 | 1267 | right_L_akao: 1268 | update_block next_right_L, next_piece 1269 | ret 1270 | 1271 | 1272 | ret 1273 | 1274 | 1275 | gen_next_piece endp 1276 | 1277 | 1278 | show_next_piece proc ;pattern_name - konta next piece box e dekhano hobe 1279 | 1280 | push bx 1281 | push cx 1282 | push dx 1283 | 1284 | draw_block 61,89,401,470,0Fh 1285 | 1286 | 1287 | ; ;add_offset_array 1288 | ; ;pasher picchi box e dekhanor jonno 1289 | ; mov bx,0 1290 | ; mov cx,16 1291 | ; 1292 | ; 1293 | ; jog_koro: 1294 | ; mov dx,next_piece[bx] 1295 | ; add dx,offsetArray[bx] 1296 | ; 1297 | ; mov temp_nxt_piece[bx],dx 1298 | ; add bx,2 1299 | ; xor dx,dx 1300 | ; loop jog_koro 1301 | ; 1302 | ; ;draw_full_block next_piece 1303 | 1304 | draw_full_block next_piece, [next_color], 24 1305 | ; update_to_zero temp_nxt_piece 1306 | ; update_to_zero next_piece 1307 | 1308 | pop dx 1309 | pop cx 1310 | pop bx 1311 | 1312 | ret 1313 | 1314 | show_next_piece endp 1315 | 1316 | 1317 | update_to_zero macro input 1318 | local zero_banao 1319 | 1320 | push bx 1321 | push cx 1322 | 1323 | mov bx,0 1324 | mov cx,16 1325 | 1326 | zero_banao: 1327 | mov input[bx],0 1328 | add bx,2 1329 | loop zero_banao 1330 | 1331 | 1332 | EndM 1333 | 1334 | 1335 | ;keyboard strike 1336 | 1337 | 1338 | gameover proc 1339 | xor ax,ax 1340 | xor cx,cx 1341 | xor dx,dx 1342 | mov dx,59 1343 | mov cx,297 1344 | mov ah,0dh 1345 | int 10h 1346 | cmp al,09h 1347 | je sesh1 1348 | cmp al,04h 1349 | je sesh1 1350 | cmp al,0eh 1351 | je sesh1 1352 | 1353 | 1354 | sesh: RET 1355 | 1356 | sesh1: 1357 | 1358 | 1359 | mov ah,0bh 1360 | mov bh,1 1361 | mov bl,13 1362 | int 10h 1363 | mov seshs,23 1364 | RET 1365 | 1366 | 1367 | gameover endp 1368 | End main 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | --------------------------------------------------------------------------------