A classic Tetris game implementation in x86 Assembly language, featuring multiple difficulty levels, score tracking, and background music.
- 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
- Easy Mode: Slower piece movement
- Medium Mode: Balanced speed
- Hard Mode: Faster piece movement
- 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
- Left Arrow: Move piece left
- Right Arrow: Move piece right
- Automatic: Pieces fall down automatically
- ESC: Exit game
- 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)
- Direct video memory manipulation
- Interrupt vector table modifications
- Custom interrupt handlers for:
- Keyboard input
- Timer events
- Sound generation
- Text mode graphics (80x25 characters)
- Custom character attributes for colors
- Real-time screen updates
- Smooth piece movement
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.
-
Download and Install Prerequisites
- Download DOSBox, NASM, and AFD from the links above.
- Place
dosbox.exe,nasm.exe, andafd.exein the same directory.
-
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
-
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+Enterin DOSBox to enter or exit full screen mode for the best experience.
- Launch DOSBox and enter the following commands (replace the path with your actual directory):
- Start screen with game title
- Instructions screen
- Difficulty level selection
- Main game
- Game over screen with final score
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.
- Points awarded for:
- Piece placement: 5 points
- Line completion: 10 points bonus
- Score displayed in real-time
- Final score shown on game over screen
- Code segment: Game logic
- Data segment: Game assets and variables
- Stack segment: Function calls and local variables
- Video memory: 0xB800 segment for display
- Keyboard ISR for piece movement
- Timer ISR for:
- Game timing
- Piece movement
- Score updates
- Music playback
- Muhammad Husnain Ali
- Email: [email protected]
- GitHub: M-Husnain-Ali
Made with 💙 in Assembly