Skip to content

deangabbai/Assembly-DOS-SimonGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

๐ŸŽฎ SIMON - The Classic Memory Game in Assembly! ๐Ÿ•น๏ธ

Welcome to the assembly-coded wonderland of SIMON! Are you ready to test your memory skills and relive some retro magic? This game isn't just about winningโ€”it's about embracing the pure, unfiltered awesomeness of assembly coding. So grab your virtual joystick, and letโ€™s jump into this nostalgic ride! ๐Ÿš€โœจ


๐Ÿ“š Table of Contents


๐ŸŒŸ About the Game

SIMON is the classic memory game we all know and loveโ€”brought back to life in Assembly language for DOS! ๐Ÿ–ฅ๏ธโœจ Your mission, should you choose to accept it, is to remember and repeat increasingly complex sequences of keys. It's more than a game; it's an 8-bit retro party for your brain! ๐ŸŽ‰

Think you're up for the challenge? Put your memory to the ultimate test and let's find out! ๐Ÿง ๐Ÿ’ช


โœจ Features

  • Pure Assembly Code: Forget about fancy high-level programmingโ€”this game is made from scratch with the raw magic of assembly! ๐Ÿ’ป๐Ÿงค
  • Interactive Gameplay: Think you have what it takes to follow the sequence? SIMON is here to put you to the test! ๐Ÿ•ฐ๏ธ
  • Colorful Interface: Okay, maybe โ€œcolorfulโ€ by DOS standards... but hey, it's got character! ๐ŸŒˆ๐Ÿ˜‰
  • Sound Effects: Beeps, boops, and bloopsโ€”classic gaming sounds to make you feel right at home! ๐Ÿ”Š๐ŸŽถ
  • Retro Vibes: Immerse yourself in the nostalgia of yesteryear, when floppy disks ruled and graphics were... well, simpler. ๐Ÿ˜Ž๐Ÿ•น๏ธ

๐Ÿ”ง Getting Started

๐Ÿ“‹ Prerequisites

To hop into this time machine and play SIMON, you'll need:

  • A DOS emulator like DOSBox. Yep, we're going old-school! ๐Ÿ’พ
  • An assembler like MASM or TASM. (Gotta get those assembly vibes!) ๐Ÿ”ง
  • Basic knowledge of how to assemble and run assembly programs. You got this! ๐Ÿ’ช

๐Ÿ’พ Installation

  1. Clone the Repository:

    git clone https://github.com/yourusername/simon-assembly-game.git

    Easy-peasy! ๐Ÿ‹

  2. Assemble the Code:

    Open your DOS emulator and navigate to the game directory. Time to work your magic! ๐Ÿฆ‰

    masm simon.asm;
    link simon.obj;

    Who knew coding could feel so nostalgic? ๐Ÿ˜Œ

  3. Run the Game:

    simon.exe

    And boomโ€”youโ€™re ready to rock 'n' roll! ๐ŸŽธ


๐ŸŽฎ How to Play

  1. Start the Game:

    After running simon.exe, you'll be greeted by the legendary title screen. Get ready for the ultimate brain workout! ๐Ÿ’ฅ

    Title_Screen

  2. Understand the Keys:

    • q = Green ๐ŸŒฟ
    • w = Red ๐Ÿ”ด
    • a = Blue ๐Ÿ”ต
    • s = Yellow ๐ŸŒผ
    • ESC = End Game ๐Ÿ˜ญ
  3. Game Mechanics:

    • Press ENTER to Start: And let the fun begin! ๐Ÿš€

    • Watch the Sequence: The game will show you a sequence of keys. Keep those eyes peeled! ๐Ÿ‘€

      Game Sequence Display

    • Repeat the Sequence: Got it memorized? Now it's your turn! Tap those keys! โŒจ๏ธโœจ

    • Progress: Each round, the sequence gets longer, and your brain gets a bigger workout! How far can you go before your memory says โ€œnopeโ€? ๐Ÿคฏ

    • Victory: Nailed it? Awesome! Revel in your moment of triumph! ๐ŸŽ‰๐Ÿ†

      Victory Screen

    • Defeat: Slip up? Donโ€™t worry, it happens to the best of us! Dust yourself off and try again! ๐Ÿ’”๐Ÿ•ฐ๏ธ

      Defeat Screen

  4. Exit the Game:

    • Press ESC at any time to bow out.
    • After the game ends, press ENTER to return to DOS and bask in the glow of your assembly journey. โœจ

๐Ÿ–ผ๏ธ Gameplay Preview

Check out the action behind the scenes! ๐Ÿ‘€๐ŸŽฎ

Assembling and Running the Game


๐Ÿ“ Code Logic

Ever wondered what's happening under the hood of this assembly masterpiece? Let's dive into the code logic and explore how SIMON comes to life! ๐Ÿ”๐Ÿง 

Overview

The game is written in 8086 Assembly language for DOS, utilizing BIOS and DOS interrupts for screen manipulation, keyboard input, and sound generation. Here's a high-level breakdown of the code structure:

  1. Initialization: Set up data segments and display the start screen.
  2. Main Game Loop: Generate and display the sequence, get user input, and check for correctness.
  3. Display Functions: Handle drawing the game interface and updating the squares.
  4. Sound Functions: Play tones corresponding to each square.
  5. Utility Functions: Clear the screen, position the cursor, hide the cursor, etc.

Key Components

1. Data Segment

Defines messages for display, key mappings, and temporary variables.

.data
titleMsg db "SIMON - A MEMORY GAME$", 0Dh, 0Ah, "$"
; ... other messages
keysToMove db 'w', 'a', 'q', 's' ; Key sequence
temp dw 3 ; Sequence length

2. Main Procedure

Starts the game by displaying the title and instructions, waits for the player to press ENTER, and then enters the main game loop.

main proc
    ; Setup data segment
    mov ax, @data
    mov ds, ax

    ; Display start screen
    call clearScreen
    ; ... display messages

    ; Wait for ENTER key
waitForEnter:
    mov ah, 00h
    int 16h
    cmp al, 0dh
    jne waitForEnter

    ; Start the game
    call clearScreenWithoutBlink
    call cursorHider
    call drawSquares

    ; Main game loop
loopTheGame:
    inc temp ; Increase sequence length
    ; ... display sequence, get user input, check correctness

3. Displaying the Sequence

Displays the sequence to the player by lighting up squares and playing corresponding sounds.

displayInSeq:
    mov al, [si]
    call PlayAndDraw
    inc si
    inc cx
    cmp cx, temp
    jb displayInSeq

4. User Input

Captures the player's input and compares it with the generated sequence.

userInputSeq:
    push cx
    mov ah, 07h
    int 21h
    call PlayAndDraw
    cmp al, 1bh ; ESC key to exit
    jne notCancel
    jmp exit

notCancel:
    cmp al, [si]
    jne wrongInput
    inc si
    pop cx
    inc cx
    cmp cx, temp
    jb userInputSeq

5. PlayAndDraw Procedure

Handles the logic for updating the display and playing sounds based on the key pressed.

PlayAndDraw proc
    push ax
    ; Check which key was pressed and call corresponding functions
    cmp al, 'q'
    jne ifNotGreen
    call newGreen
    mov bx, 5709 ; Sound frequency for green
    call playMusic
    call newGreen2
    jmp incomplete

    ; ... similar blocks for other keys

incomplete:
    pop ax
    ret
PlayAndDraw endp

6. Drawing Squares

Functions like newGreen, newGreen2, newred, etc., draw the colored squares on the screen.

newGreen proc
    mov bl, 0aah ; Light green color code
    mov dl, 29 ; X-axis
    mov dh, 5 ; Y-axis
    call drawLines
    ret
newGreen endp

7. Sound Generation

The playMusic procedure plays a tone corresponding to the square's color.

playMusic proc
    push cx
    mov al, 10110110B
    out 43H, al
    mov ax, bx
    out 42H, al
    mov al, ah
    out 42H, al
    ; ... wait and stop sound
    pop cx
    ret
playMusic endp

8. Utility Procedures

  • clearScreen: Clears the screen.
  • cursorHider: Hides the blinking cursor during gameplay.
  • positioningTheCursor: Positions the cursor at a specific location.
  • printString: Prints strings to the screen.

Game Flow

  1. Start Screen: Displays the title and instructions.
  2. Waiting for Start: The game waits for the player to press ENTER.
  3. Sequence Display: Shows the sequence by lighting up squares and playing sounds.
  4. Player Input: Waits for the player to repeat the sequence.
  5. Checking Input: Compares the player's input with the sequence.
    • Correct Input: If the input matches, the game increases the sequence length and loops back.
    • Incorrect Input: Displays the defeat message and exits the game.
  6. End Game: Upon completion or exit, displays a message and waits for ENTER to return to DOS.

Notes

  • Sequence Generation: The sequence is currently static, stored in keysToMove. To make it dynamic, you could implement random key selection.
  • Game Loop: The game attempts to loop indefinitely, increasing the difficulty each time.
  • Sound and Graphics: Uses low-level BIOS interrupts for sound and graphics, giving it an authentic retro feel.

Potential Improvements

  • Randomized Sequences: Implement a random number generator to create unpredictable sequences.
  • Score Tracking: Keep track of the player's score or highest level reached.
  • Optimized Code: Refine the assembly code for efficiency and readability.
  • Error Handling: Add more robust input validation and error messages.

Feel free to dive into the code and tinker around! The beauty of assembly is that it gives you complete control over the hardware. Happy coding! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป


๐Ÿค” Contributing

Think you can make SIMON even more awesome? We'd love your help!

  • Report Bugs: If you spot a glitch, shout it out! ๐Ÿ›๐Ÿ“ข
  • Enhance Features: Have an idea for a new twist? Code it up and submit a pull request! ๐Ÿ’ก๐Ÿš€
  • Optimize Code: Attention, assembly wizards! If you know how to make this faster or cleaner, we want you! ๐Ÿงโ€โ™€๏ธโœจ

๐Ÿ’„ License

This project is open-source and available under the MIT License. Feel free to make it your own! ๐Ÿ“๐Ÿ’–


๐Ÿ“จ Contact

Got questions, want to collaborate, or just feel like saying hi? We're all ears! ๐Ÿ‘‚


Enjoy the game and may your memory be unbeatable! ๐Ÿง ๐ŸŽ‰

Happy coding and gaming! ๐Ÿ‘พ๐Ÿ’™

About

A Simon game ๐ŸŽฎ, was developed with a student of mine, May Ben Hamo ๐Ÿ‘ฉโ€๐ŸŽ“, using the DOSBox assembler ๐Ÿ”ง and Notepad ๐Ÿ“.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors