This a very simple x86 operating system that just have enough to play small games, you can try using it on your browser
preview.mp4
- Custom Bootloader
- x86 at least works on QEMU
- Keyboard Driver PS/2
- PIT
- 320x200 Video mode Mode 13h
- Modifiable (meaning you can replace flappybird game easily), the game isn't hard coded like other alternatives.
- Fits in a Floppy Disk, who could have guessed?
- Memory management, TODO
- Works on real hardware, TODO
You will have to build a cross compiler, you could read more about cross compilers here. my exact setup.
You also will need nasm
to compile the assembly code.
once you have nasm
& i386-elf-gcc
& i386-elf-ld
you can use the command make iso
to generate the raw image, or make FLOPPY=1 iso
for a bootable floppy disk.
You will have to have qemu
emulator, (this works for both the FLOPPY
edition and the raw
edition).
qemu-system-i386 -drive format=raw,file=boot.iso
for the floppy edition
qemu-system-i386 -fda boot.iso
to launch the emulator. alternatively you can simply type make run
For a simple game you will need just these 4 functions
add_keyboard_handler(void (*function_ptr)(unsigned int scancode)
- Takes a function pointer, it passes the key scancode to function.
get_timer(void)
- Gets you the current tick
draw_screen(unsigned char *video_buffer)
- to draw the buffer on the screen, it resides in
drivers/monitor.h
, also the video_buffer size should be320x200
. for more info
- to draw the buffer on the screen, it resides in
and you all set, you can develop something like flappybird out of it.
this project includes 2 ways of writing to the screen
- video mode: is used to write colors and pixels to the screen, like in the game.
- text mode: for text based info, it is used here to print some interrupt info, but it will probably have some sort of shell in the feature.
The "custome bootloader" is dumb, you have to specify the number of sectors to read to load the kernel. for my game it isn't an issue, but for yours it could be. so calculate the number of sectors your kernel is (kernel size / 512 bytes) and change line 32 in boot/boot_sect.asm
accordingly.
https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf
http://www.jamesmolloy.co.uk/tutorial_html/
https://wiki.osdev.org/James_Molloy%27s_Tutorial_Known_Bugs#Problem:_Not_using_a_cross-compiler
generally osdev.org has good explanations of low level topics