diff --git a/Makefile b/Makefile index b10ac62..d8f070f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index cc90f93..5fb7748 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/code.png b/code.png new file mode 100644 index 0000000..ce20326 Binary files /dev/null and b/code.png differ diff --git a/dev/additional_features.asm b/dev/additional_features.asm new file mode 100644 index 0000000..fc2d595 --- /dev/null +++ b/dev/additional_features.asm @@ -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 diff --git a/dev/bricks.txt b/dev/bricks.txt new file mode 100644 index 0000000..832249e --- /dev/null +++ b/dev/bricks.txt @@ -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.. +.... + diff --git a/tetros.img b/tetros.img new file mode 100644 index 0000000..d4572e5 Binary files /dev/null and b/tetros.img differ