The smallest game in the world (58 bytes)
For those who read the article in the sandbox: added the section “Is it possible to make the game smaller?”.
After reading the history of one byte , I remembered my story.
When I was in school and just starting to program, I was very attracted to assembler and optimization. Namely - painstaking optimization, with the calculation of ticks and bytes. During the summer holidays, my cousin and I got the idea to write the smallest game in the world.
The first prototype, 80 bytes in size, was ready the next day. (Since I didn’t even know about version control at that time, it remains to believe the memories). From that moment, my struggle for bytes began. I remember that pretty quickly the size was reduced to 65 (or so), then every byte was given with great and great difficulty. By the end of summer, the result was 58 bytes.
Plot and management
You rush along the highway in a truck with two trailers. On your left is a dividing strip, on the right is a roadside sheltered by grass. On the road there are people and trees (maybe holes). Your task: not to knock people down and not crash into trees (not to fall into holes).
Management: left-right arrows - turn; Esc - pause.
Screenshot

Source
begin:
; ds указывает на видеопамять
push 0b800H
pop ds
; установить графический режим 40×25
int 10H
; bx = 700H - смещение, по которому находиться грузовик
mov bh, 7H
main_loop:
; Задержка и вывод грузовика на экран
xchg cx, ax ; mov ah, 0
int 1AH
mov [bx], dl
delay:
int 1AH
cmp [bx], dl
je delay
; si - смещение следующего препятствия
xchg ax, si
add al, dl
xchg ax, si
xchg ax, cx ; mov cx, 0
; Получение нажатой клавиши
in al, 60H
cmp al, 77
jnz keytest1
; вправо
inc bx
inc bx
keytest1:
; влево
ja keytest2
dec bx
dec bx
keytest2:
; очистка буфера клавиатуры
mov ah, 0CH
int 21H
; скролл экрана на 1 строчку
mov ax, 0701H
mov dx, 1827H
int 10H
; вывод препятствия
mov [si], ax
; вывод травы и разделительной полосы
mov [di+51], dx
; проверка что перед грузовиком нет препятствий
cmp [bx], dh
ja main_loop
ret
Archive with source and binary (Tasm was used for compilation)
Comments
In XP, the program works, but the timer does not work smoothly and the keyboard state is not reset at first. In DosBox, it works without problems.
In the source, two instructions (push 0b800H and mov [di + 51], dx) are written in machine code (db 68H, 00H, 0b8H and db 89H, 55H, 51H), this is due to the fact that Tasm did not accept them in the mode compilation by default. In my opinion, he demanded the inclusion of x386 instructions, although I could be wrong.
Is it possible to make the game smaller?
Probably yes. Scrolling the screen (8 bytes) and latency (10 bytes) take up a lot of space. If you change the direction of movement (obstacles move upward), then the scroll can be replaced by the quick output of the line feed character ( ). The delay can be replaced by checking the status of the double word at 0040: 006Ch. There should be a counter of timer counters since midnight (Timer ticks since midnight). UPD: Thank you! Moved to the assembler blog UPD2: Imp5 tells me that I'm not quite right. Shifticida is a two-player game that takes 32 bytes. So the correct name of the topic: "The smallest racing game in the world"
mov al, 0Ch; int 29h