Jump to content

FizzBuzz OS Completed (Now with Breakout action)

Avratz

As I alluded to in my 100 line challenge post, I've been working on a better version of my FizzBuzz bootloader.

 

Well, I'm pleased to say it's finished. I figured I would make a new thread since its quite a bit longer than 100 lines now.

 

My first version was a nice proof of concept, but it lacked the flair I was looking for. Plus it used BIOS interrupt 10h to print which is practically cheating.  :)

 

This version directly accesses the VGA to write text, hardware scroll, and control the cursor. It also uses the RTC as a timer to control the scrolling rate.

 

Being a pure bootloader, it all has to fit in 510 bytes of space. Data and code. This space is meant for switching the cpu into a different mode and loading the OS, but I figured I would abuse it for a completely worthless task.

 

I came in right under the limit at 506 bytes. It should boot on just about any 386 and above PC made in the last 30 years.

 

The source

http://pastebin.com/ibZnWpta

 

Bootable floppy image. If anyone actually has one, haha. Dig out that old PC, and fire it up.

http://www.mediafire.com/download/0rxcknqo5uga7o3/fizzcolor.img

 

Sweet video of it in action in Bochs

 

 

 

If you're interesting in writing your own bootable code check out

http://wiki.osdev.org/Main_Page

 

They have a great starting out section

 

Next challenge is doing a proper bootloader that switches into protected or long mode, and loads a game. I think I'll start with porting my raycaster.

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
Share on other sites

Link to post
Share on other sites

Bootloader Breakout

 

Well, I got distracted. I had to find out if I could write a playable game in 510 bytes or less, so here's a bootable, playable version of breakout. It took the entire bootloader's 510 bytes of space to pull it off.

 

There's some minor bugs with brick collision, but it doesn't affect gameplay much. There's no way to win anyway. You can only lose. Miss enough and it reboots the computer  :P

 

Source code (assemble with NASM)

http://pastebin.com/Bte1XVuC

 

Boot floppy image

http://www.mediafire.com/download/i83apjb2xk61f7i/breakout.img

 

I actually commented this code, so if you wanna know how it works. There ya go.

 

RTC timer drives the update loop, and I wrote my own keyboard interrupt handler. No BIOS interrupts here. Those alone ate quite a bit into my available space.

 

Reset is accomplished by polling the keyboard controller system flag then sending 0xFE (reset)

 

Sweet GIF action in Bochs (framerate sucks, it runs faster live)

 

Jia6p6r.gif

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×