This is my blog, where I post anything I might have to share. This could be projects I'm working on, old projects I have abandoned and found somewhere, or just what I'm doing or thinking. If you want, you can keep updated with my posts with RSS, or you can just bookmark this page and check it out whenever you want :)

You can follow my posts by subscribing to my RSS feed.

Weekend projects: OS development adventures

Over the years, I've created a ton of smaller projects, just for fun, experimentation or for learning purposes, which may or (most likely) may not ever have been finished. Some of these are shown on my "other projects" page, but those are just a couple of everything I've done. Here's something more I've created.

I've always, like many of those who are reading my blog, been fasinated by how computers work, and I think that the deeper you go into the inner workings of the computer, the more fasinating it gets. Having electronics class in HTX really introduced me to how the hardware of the computer work, on the most basic level. Since then, I've really developed an interest for making my own operating system.

Lots of other people on the internet do so too, and I've found some tutorials, which can guide you through the creation of a basic OS. The best tutorial I've found is Bran's kernel development tutorials and JamesM's kernel development tutorials, and following those, I've actually managed to create working operating systems, putting them on a floppy disk, and booting them on a real computer. They're very basic, it's still missing very basic funcionality like memory management, multitasking and graphics, but I think it's worth writing about. So here's two of my successful experiments.

The first is the most simple. It just displays text on the screen, and there's no interaction with it. It still was a breakthrough for me, since it actually had a lot of required features, like text output, interrupts and paging (I'm not sure that paging ever worked really well, though ;) ).

It's inspired by GLaDOS from Portal, and prints out the first piece of Still Alive, the song playing in the end of the game. At the end, it creates a page fault, which is a fatal error, which I show by chaning the ASCII floppy disk in the corner to a ASCII explosion, and writing "encountered EPIC FAIL".

The next OS is one I've been working on recently. I call it Spira OS ("Spira" is the world of Final Fantasy X), and other than interrupts, text output, etc., I got one very important thing working: the keyboard. This, as you might imagine, opened up a world of posibilities. The first "version" only had three commands: "hello, computer" answered with "hello, human", "echo" printed the text following the command on the next line, and "clear" cleared the terminal. In the newer version, I added the "sysinfo" command, which displayed some facts about the system. But that's by far the most interesting thing I made for it.

The most exciting thing I made for it, which I actually for the idea for and implemented today, was a Minesweeper game in the system. It still doesn't have memory management, and it's greating limiting what is possible. My original idea was to make a Tetris game for it, but since that would require bering able to allocate memory, I went with a more simple game, but still not too simple. And so, here it is:

You control the cursor around with WASD, chooses a block with X and quits the game with Q. There's no score or time keeper, but the game works perfectly, and is very playable.

Since there isn't any way to get a random number on a computer, I used a way of placing the mines with pseudo random numbers. I do this by having a header file with 10.000 random 1's and 0's, with about one 1 for every ten 0. I then start by getting a random number from the time passed since the OS booted, and reads random 1's and 0's from that point. It's very simple, but it's actually working quite well.

That's what I had to show off for now. I'll certanly be working more with OS development, and I may make another blog post if I create something cool :) I'll probably also post more weekend projects blog posts with various themes. If you want to learn more about OS development, be sure to visit the OSDev forums and wiki!

Weekend projects: OS development adventures (via @gereen)

Previous post: Japanese text emoji's in iOS 4.0
Twitter Follow me on Twitter! Donation

Recent projects