Skip to content

mousewanderer/ASM_GAME

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

ASM_GAME – Gambling Dice in x86 Assembly

Created with Iniw

A classic text‑based betting game written in x86 Assembly, playable in an emulator like EMU8086.
Test your luck, manage your virtual bankroll, and experience retro computing at its finest.


Introduction

Gambling Dice is a terminal‑based dice‑rolling game developed entirely in x86 Assembly.
The player starts with $1000 and can bet on a number between 1 and 6. After placing a bet, a random dice roll determines whether they win or lose.
The game continues until the player quits or runs out of money.

This project was created for educational and technical demonstration purposes, showcasing low‑level programming concepts in a fun, interactive way.
It embraces the retro computing aesthetic reminiscent of early DOS‑based text games.


✨ Game Features

  • Betting System – Start with a virtual bankroll of $1000.
  • Random Dice Generator – Uses system time (INT 1Ah) to generate unpredictable rolls.
  • Win / Lose Logic – Compare player’s guess against the rolled number.
  • Quick and Dynamic Visual Feedback – Colored screen segments indicate win or loss.
  • Multiple Rounds – Play repeatedly until you decide to quit or go bankrupt.
  • ASCII Dice Animation – A special rolling animation adds excitement.
  • Money Tracking – Balance updates automatically after each round.
  • Platform – Designed for EMU8086 and compatible emulators.

User Interface & Screenshots

The game features a terminal‑based interface with pixel‑graphics‑like animations.

Enter the amount to bet:

Screenshot 2025-05-22 172801

Choose your number (1–6):

Screenshot 2025-05-22 174109

Roll animation:

Screenshot 2025-05-22 175802

Win screen:

Screenshot 2025-05-22 175435

Exit prompt:

Screenshot 2025-05-22 180959


Controls

  • Number keys (1–6) – Choose your bet number.
  • Enter bet amount – Must be ≤ current money.
  • 0 – Exit the game.
  • Any key – After a result, press any key to continue.

Flowchart

The following flowchart illustrates the game logic:

79948e27-fd92-4b7d-a4bb-fa065320c725


Challenges & Solutions

1. Generating Random Numbers

Challenge: x86 Assembly has no built‑in random number generator; ensuring fairness was tricky.
Solution: Used the system clock’s low‑level ticks (via INT 1Ah) to seed a pseudo‑random algorithm, then applied modular arithmetic to constrain the result to 1–6.

2. Limited Registers

Challenge: Tracking bets, balance, and dice results simultaneously with only a handful of registers.
Solution: Reserved memory addresses using .data directives to persist data and minimized register dependency.

3. Dice Animation Timing

Challenge: Creating smooth animations without hardware‑level timing control.
Solution: Implemented a loop‑based delay for the animation and leveraged terminal text printing for a responsive feel.


Lessons Learned

  • Low‑Level Constraints: Working with Assembly reinforced the importance of manual memory and register management.
  • Debugging Rigor: Even small errors (e.g., incorrect CMP operands) could cause crashes, emphasizing systematic testing.
  • Creative Problem‑Solving: Hardware limitations drove innovative solutions, such as using system interrupts for randomness.

Future Enhancements

  • Expanded Gameplay – Add more casino games (Blackjack, Roulette, etc.).
  • Visual Upgrades – Colorized text warnings when money runs low, improved win/lose animations, and a main menu for selecting games.
  • Code Optimization – Refactor repetitive logic into macros/subroutines, especially for the animation sequences.

🛠️ References & Inspiration


How to Run

  1. Install EMU8086 (or any x86 emulator that supports the required interrupts).
  2. Load the ASM_GAME.asm source file.
  3. Assemble and run the program.
  4. Follow on‑screen instructions to play.

Collaborated with

Iniw41
GitHub: @Iniw41


License

This project is open‑source and available under the MIT License.

About

it is a terminal‑based dice‑rolling game developed entirely in x86 Assembly. Incorporates betting system, money tracking, on time animation, scalable structure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors