mirror of
https://github.com/daniel-e/tetros.git
synced 2025-04-20 00:48:05 +02:00
Compare commits
No commits in common. "master" and "1" have entirely different histories.
6 changed files with 15 additions and 69 deletions
21
LICENSE.md
21
LICENSE.md
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2016
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
Makefile
11
Makefile
|
@ -1,16 +1,9 @@
|
|||
UNAME := $(shell uname)
|
||||
ifeq ($(UNAME), Darwin)
|
||||
STAT := gstat
|
||||
else
|
||||
STAT := stat
|
||||
endif
|
||||
|
||||
all: tetros.img
|
||||
|
||||
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 \
|
||||
@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 tetros.img; exit 1; fi
|
||||
nasm -f bin tetros.asm -o tetros.img
|
||||
|
|
44
README.md
44
README.md
|
@ -1,29 +1,17 @@
|
|||
# TetrOS
|
||||
TetrOS is a small *feature rich* Tetris clone which is written in Assembly. It fits completely into a 512 byte boot sector as it requires only 446 bytes (which is the maximum allowed size of the first stage boot loader in the master boot record (MBR) of a drive) and is executed during the boot sequence before any operating system is loaded. Actually, it does not need any existing operating system. TetrOS *is* an operating system, hence the suffix OS in its name.
|
||||
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 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.
|
||||
|
||||
Video that shows TetrOS in action:
|
||||
This is how it looks like:
|
||||
|
||||
[](https://youtu.be/Hl7M7f-Hh78)
|
||||

|
||||
|
||||
And this is the complete machine code:
|
||||
|
||||

|
||||
|
||||
## Running TetrOS
|
||||
|
||||
There are two options to run TetrOS. Either in an emulator like qemu or via an installation of TetrOS in the boot sector of a real disk, USB stick or some other media.
|
||||
|
||||
### Running via qemu
|
||||
|
||||
Simply run `make run`. This will execute qemu with the right parameters to run TetrOS. If you're using Ubuntu and qemu is not intalled on your system you can install it via `sudo apt-get install qemu`.
|
||||
|
||||
### Running via an USB stick
|
||||
|
||||
First, copy the image to an USB stick. For example, if your USB stick is on `/dev/sde` use the following command to overwrite the first sector of the USB stick with the TetrOS image:
|
||||
|
||||
`sudo dd if=tetros.img of=/dev/sde`
|
||||
|
||||
After that you should be able to boot the stick to play TetrOS.
|
||||

|
||||
|
||||
## Features
|
||||
* Each brick shape has a unique color.
|
||||
|
@ -33,7 +21,7 @@ After that you should be able to boot the stick to play TetrOS.
|
|||
* Down arrow to drop a brick.
|
||||
* Game over detection. It stops if a new brick could not be placed.
|
||||
* Selects the next brick at random via a linear congruential generator.
|
||||
* Nice playing field.
|
||||
* Shows a nice playing field.
|
||||
|
||||
## Features missing due to size limits
|
||||
* Scores and highscores.
|
||||
|
@ -42,21 +30,7 @@ After that you should be able to boot the stick to play TetrOS.
|
|||
* Show next brick.
|
||||
* Increase speed.
|
||||
|
||||
## Compiling the sources
|
||||
|
||||
The repository already contains an image which you can use for testing. However, if you want to compile the image from the sources you need nasm, a general prupose x86 assembler to be installed on your system. On Ubuntu you can can install it via the command `sudo apt-get install nasm`. On macOS you will need [homebrew](http://brew.sh/) to install `nasm` and `binutils`.
|
||||
|
||||
If `nasm` is installed you can compile the sources by executing `make`. This will create the image `tetros.img`. After that you can run the image via qemu or you can copy the image via `dd` on an USB disk or a disk (see above).
|
||||
|
||||
I have tested it with nasm 2.11.08 on Ubuntu 16.04.
|
||||
|
||||
## Similar projects
|
||||
* https://github.com/dbittman/bootris
|
||||
* https://github.com/Shikhin/tetranglix
|
||||
* http://olivier.poudade.free.fr/src/BootChess.asm
|
||||
* https://github.com/programble/tetrasm - Tetris for x86 in NASM but which does not fit into the boot sector.
|
||||
|
||||
## Acknowledgements
|
||||
I would like to thank the following persons for contributing to TetrOS.
|
||||
* [DraftYeti5608](https://github.com/DraftYeti5608)
|
||||
* [Ivoah](https://github.com/Ivoah)
|
||||
|
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
@ -90,7 +90,7 @@ new_brick:
|
|||
mov byte [delay], 100 ; 3 * 100 = 300ms
|
||||
select_brick ; returns the selected brick in AL
|
||||
mov dx, start_row_col ; start at row 4 and col 38
|
||||
lp:
|
||||
loop:
|
||||
call check_collision
|
||||
jne $ ; collision -> game over
|
||||
call print_brick
|
||||
|
@ -154,7 +154,7 @@ no_key:
|
|||
call clear_brick
|
||||
inc dh ; increase row
|
||||
call check_collision
|
||||
je lp ; no collision
|
||||
je loop ; no collision
|
||||
dec dh
|
||||
call print_brick
|
||||
call check_filled
|
||||
|
@ -253,7 +253,7 @@ check_collision_main: ; DI = 1 -> check, 0 -> print
|
|||
cc:
|
||||
push cx
|
||||
mov cl, 4
|
||||
zz:
|
||||
dd:
|
||||
test ah, 10000000b
|
||||
jz is_zero
|
||||
|
||||
|
@ -278,7 +278,7 @@ is_zero_a:
|
|||
is_zero:
|
||||
shl ax, 1 ; move to next bit in brick mask
|
||||
inc dx ; move to next column
|
||||
loop zz
|
||||
loop dd
|
||||
sub dl, 4 ; reset column
|
||||
inc dh ; move to next row
|
||||
pop cx
|
||||
|
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue