Skip to content

BuildMindX/Tetris-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮 Assembly Tetris Game

Assembly Platform Genre License

A classic Tetris game implementation in x86 Assembly language, featuring multiple difficulty levels, score tracking, and background music.

🎯 Features

Game Mechanics

  • Multiple Tetromino Shapes: Square, Rectangle, L-shape, and T-shape pieces
  • Piece Movement: Left/Right movement and automatic downward falling
  • Line Clearing: Score bonus for completing full lines
  • Score System: Points awarded for piece placement and line clears
  • Game Timer: 5-minute game sessions

Difficulty Levels

  • Easy Mode: Slower piece movement
  • Medium Mode: Balanced speed
  • Hard Mode: Faster piece movement

Audio & Visual

  • Background Music: Multiple music tracks
    • Dungeon theme
    • Game Over music
    • Instruction screen music
  • Color Graphics: Colorful piece display and game interface
  • Score Display: Real-time score tracking
  • Timer Display: Countdown timer visualization

🎮 Controls

  • Left Arrow: Move piece left
  • Right Arrow: Move piece right
  • Automatic: Pieces fall down automatically
  • ESC: Exit game

🛠️ Technical Details

Architecture

  • Written in x86 Assembly language
  • Uses BIOS and DOS interrupts for:
    • Keyboard input (INT 16h)
    • Timer (INT 8h)
    • Sound generation
    • Video display (0xB800 memory segment)

Memory Management

  • Direct video memory manipulation
  • Interrupt vector table modifications
  • Custom interrupt handlers for:
    • Keyboard input
    • Timer events
    • Sound generation

Display Features

  • Text mode graphics (80x25 characters)
  • Custom character attributes for colors
  • Real-time screen updates
  • Smooth piece movement

🚀 Getting Started

Prerequisites

You must install all three tools below before running the game:

  • DOSBox: DOS emulator for running the game
  • NASM: Netwide Assembler for assembling the source code
  • AFD: Advanced Full Screen Debugger for DOS (optional, for debugging and inspecting assembly code)

⚠️ All above installations are necessary for the game to work.

Setup Instructions

  1. Download and Install Prerequisites

    • Download DOSBox, NASM, and AFD from the links above.
    • Place dosbox.exe, nasm.exe, and afd.exe in the same directory.
  2. Clone the Repository

    • Open a terminal or command prompt in the directory where you have DOSBox, NASM, and AFD.
    • Run:
      git clone https://github.com/M-Husnain-Ali/Tetris-Game.git
      cd Tetris-Game
  3. Assemble and Run the Game in DOSBox

    • Launch DOSBox and enter the following commands (replace the path with your actual directory):
      mount c /path/to/your/tools-and-repo
      c:
      nasm tetris.asm -o tetris.com
      tetris.com
      
    • Tip: Press Ctrl+Alt+Enter in DOSBox to enter or exit full screen mode for the best experience.

Game Flow

  1. Start screen with game title
  2. Instructions screen
  3. Difficulty level selection
  4. Main game
  5. Game over screen with final score

🎵 Sound System

The game features three different music tracks:

  • Main theme (dungeon.imf)
  • Game over music (camein.imf)
  • Instructions music (getthem.imf)

Sound is implemented using direct port manipulation for the PC speaker.

📊 Scoring System

  • Points awarded for:
    • Piece placement: 5 points
    • Line completion: 10 points bonus
  • Score displayed in real-time
  • Final score shown on game over screen

🔧 Technical Implementation

Memory Layout

  • Code segment: Game logic
  • Data segment: Game assets and variables
  • Stack segment: Function calls and local variables
  • Video memory: 0xB800 segment for display

Interrupt Handlers

  • Keyboard ISR for piece movement
  • Timer ISR for:
    • Game timing
    • Piece movement
    • Score updates
    • Music playback

👨‍💻 Author


Made with 💙 in Assembly

About

A retro-style Tetris game built entirely in x86 Assembly for DOS. Features smooth piece movement, real-time scoring, difficulty levels, colorful text-mode graphics, and classic PC speaker sound. Run it using DOSBox for the full nostalgic experience.

Topics

Resources

Stars

Watchers

Forks

Contributors