This commit is contained in:
dz 2016-10-01 18:55:52 +02:00
parent 1d5445d1ba
commit 49a3d7cf4d
6 changed files with 219 additions and 12 deletions

View file

@ -1,15 +1,15 @@
all: mbr.img
all: tetros.img
mbr.img: tetros.asm Makefile
nasm -d DEBUG -f bin tetros.asm -o mbr.img
@echo "size is" `stat -c "%s" mbr.img`
@if [ `stat -c "%s" mbr.img` -gt 446 ]; then \
tetros.img: tetros.asm Makefile
nasm -d DEBUG -f bin tetros.asm -o tetros.img
@echo "size is" `stat -c "%s" tetros.img`
@if [ `stat -c "%s" tetros.img` -gt 446 ]; then \
bash -c 'echo -e "\e[91mOutput exceeded size of 446 bytes.\e[0m"'; \
rm -f mbr.img; exit 1; fi
nasm -f bin tetros.asm -o mbr.img
rm -f tetros.img; exit 1; fi
nasm -f bin tetros.asm -o tetros.img
run:
@qemu-system-i386 -drive file=mbr.img,index=0,media=disk,format=raw
@qemu-system-i386 -drive file=tetros.img,index=0,media=disk,format=raw
clean:
rm -f mbr.img
rm -f tetros.img

View file

@ -1,13 +1,18 @@
# TetrOS
TetrOS is a small *feature rich* Tetris clone which is written in Assembly.
It fits completely into a 512 byte boot sector and is executed during the
boot sequence. It does not need any existing operating system. TetrOS is its own
operating system, hence the suffix OS in its name.
boot sequence before any operating system is loaded. It does not need any
existing operating system. TetrOS is its own operating system, hence the suffix
OS in its name.
This is how it looks like:
![TetrOS - Tetris in 512 byte boot sector](https://github.com/daniel-e/mbr_tetris/blob/master/tetros_tetris_screenshot.png)
And this is how the machine code looks:
![TetrOS - Machine code](https://github.com/daniel-e/mbr_tetris/blob/master/code.png)
## Features
* Each brick shape has a unique color.
* Blinking cursor is not visible.
@ -21,6 +26,11 @@ This is how it looks like:
## Features missing due to size limits
* Scores and highscores.
* Intro.
* Game over message.
* Game over message and restart without rebooting.
* Show next brick.
* Increase speed.
## Similar projects
* https://github.com/dbittman/bootris
* https://github.com/Shikhin/tetranglix
* http://olivier.poudade.free.fr/src/BootChess.asm

BIN
code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View file

@ -0,0 +1,45 @@
; game_over:
; mov cx, 10
; mov dx, 0x0323
; mov bx, 0x8c
; mov bp, game_over_msg + 0x7c00
; mov ax, 0x1300
; int 0x10
; xor ax, ax ; wait for keyboard
; int 16h
; jmp start_tetris
;game_over_msg: db "GAME OVER!"
; ==============================================================================
initial_animation:
; call clear_screen
; mov ah, 2 ; set cursor position
; xor bx, bx
; mov dh, 5
; mov dl, 10
; int 0x10
; mov si, message + 0x7c00 ; MBR is loaded at address 0000:7C00
initial_animation_next:
; cld
; lodsb
; cmp al, 0
; jne initial_animation_do
; xor ax, ax ; wait for keyboard
; int 16h
; ret
initial_animation_do:
; mov bx, 0x0a ; write character
; mov cx, 1
; mov ah, 9
; int 0x10
; call cursor_right
; push dx
; mov cx, 2 ; wait 2x65536 microseconds
; xor dx, dx
; call wait_abit
; pop dx
; jmp initial_animation_next
;message: db "Let's play tetris ...", 0

152
dev/bricks.txt Normal file
View file

@ -0,0 +1,152 @@
.X..
.X..
.X..
.X..
XXXX
....
....
....
.X..
.X..
.X..
.X..
XXXX
....
....
....
====
..X.
..X.
.XX.
....
XXX.
..X.
....
....
.XX.
.X..
.X..
....
X...
XXX.
....
....
====
.X..
.X..
.XX.
....
..X.
XXX.
....
....
.XX.
..X.
..X.
....
XXX.
X...
....
....
====
.XX.
.XX.
....
....
.XX.
.XX.
....
....
.XX.
.XX.
....
....
.XX.
.XX.
....
....
====
XX..
.XX.
....
....
..X.
.XX.
.X..
....
XX..
.XX.
....
....
..X.
.XX.
.X..
....
====
.X..
XXX.
....
....
.X..
XX..
.X..
....
XXX.
.X..
....
....
X...
XX..
X...
....
====
.XX.
XX..
....
....
X...
XX..
.X..
....
.XX.
XX..
....
....
X...
XX..
.X..
....

BIN
tetros.img Normal file

Binary file not shown.