⬆️ ⬇️

Three computer games (30 bytes each)

Inspired by Shifticida (32 bytes) and the smallest racing game in the world (58 bytes), I decided to make the smallest computer game for x86. Instead of one game, we got three. Alas, they are not as cool as the race, but they occupy only 30 bytes each.



Guess what



A game for two players. The first player presses any button on the keyboard. After that, the second player goes through the buttons on the keyboard until he presses the same button as the first. To the second player did not suffer too long, prompts are displayed on the screen. When the desired button is found, the game ends.



;;-



int 16h ;;

mov bl, al ;;



still: ;;

int 29h ;;



mov al, 13;;

int 29h



mov ah,1 ;;

int 21h



cmp al, bl ;;

je true ;; , true

ja big ;; , big



; , , , bl,

mov al, '-' ; "-"

jmp still



big:

mov al, '+' ; "+"

jmp still



true:

int 20h ;;





Bachet



A classic math game in which computer is your opponent. The rules are as follows: on the table there are 15 sticks, you need to take turns from 1 to 3. The one who has nothing to take from the table loses.

')

The game displays the current number of sticks and waits for input from the keyboard (boldly press 1, 2 or 3). After the person makes his move, the computer also takes a few sticks, and displays the remaining number of sticks on the screen. The game ends with chopsticks, and if you win, you will see a heart on the screen. Caution: keyboard input is not filtered, so you can take 15 or even 200 sticks at once. The computer will react to this in the same way as a living person in a similar situation (may be very offended).



;;



mov dl, 15 ;; dl



still: ;;



mov al, '|' ;;

mov cl, dl ;; ,

disp: ;; cl

int 29h ;; 29h

loop disp



mov ah, 1 ;;

int 21h



sub al, '0' ;; ASCII-



cmp dl, al ;; - ,

je win



sub dl, 4 ;; 4

jns still ;; ,



jmp fin ;; -



win:

int 29h ;;



fin:

int 20h ;;





Unfortunately, after the second time playing in the Bachet becomes boring.



One-armed bandit



The program scrolls the characters on the screen very quickly (one by one, in the upper left corner). To fix the current symbol and go to the next one, press the Right Arrow key. If you can get three identical symbols, it means either you have a very old computer, or you are very lucky!



;;



push 0b800H ;;

pop ds



mov cx, 3 ;;



le: ;;

push cx ;; cx,

add bl, 2 ;;



inf: ;;

int 1AH ;;

add dl, bl ;; , ""

mov [bx], dl ;;



;;

in al, 60H

cmp al, 77

jz re ;; " ",

;;



jmp inf ;;



re: ;;

pop cx ;; cx

loop le ;; " "



int 20h ;;





Conclusion



I compiled the source code for games using fasm . You can run, for example, in dosbox. For One-armed, I recommend reducing CPU cycles.



ex2.com - Guess

poo2.com - Bache

roll.com - One-armed bandit



PS Is it possible to make the game even smaller? Sure you may!

Source: https://habr.com/ru/post/119765/



All Articles