Jump to content
  • Advertisement
Sign in to follow this  

Creating a simple operating system

This topic is 2680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

I want to make a game console (like PS or xbox etc) for myself, so i thought, what would i need? a screen to show the game, the screen needs something to send it data, which is the processor, and since i have an old motherboard, i thought that i could make a simple operating system for it, that could just interface with usb devices and the screen, and do some operations to get the game running, hope it's possible and simple as i could think it is

as for the joysticks and all that - i can create them and make them connect via usb, and i'm going to store games on a flash drive which can be modified by a normal computer
as for the games that runs on the console - i think that's pretty much related to the OS itself, so i'll leave it for later
as for knowledge, im experienced with C (and most of C++) and good at electronics, and i'm ready to learn assembly if that's a must

but i'm somewhat confused, i don't know where to start - i know it might take hours, hundred of hours, or even thousand or more, which doesn't bother me at all
so where do i start?

thanks for reading.

Share this post

Link to post
Share on other sites
The easiest way to do this would be to take the linux kernal and start adding whatever you need on top of it, creating a super-minimal linux distro to do what you want. I would advise against writing your own kernel from scratch, mostly because modern standards like USB are pretty complex.

If you want to write a minimal OS from scratch (write your own kernel), you'll have a much easier time reading joysticks through the old game port (if this board is old enough to have one). You can bootstrap a PC and read the keyboard/write to the screen with pretty little work. If you need to read/write from a proper filesystem, or interface with USB joysticks, that's where it'll get complicated. (Don't worry about USB keyboard; on most PCs the USB keyboard is emulated by the BIOS to look like an old ps/2 keyboard)

This link will show a preview of what kind of trouble you're asking for :)

Share this post

Link to post
Share on other sites
There's no sense reinventing the wheel just because. Start by building a custom Linux kernel for the machine that boots straight into a custom 'game', without any of the Linux desktop trimmings. That alone should be a good first step.

Share this post

Link to post
Share on other sites
Thanks for the links - helped me really much.

though i'm stuck at some point: i can't seem to be able to get my bootloader on the first sector of a virtual floppy disk (made it using VFD (virtual floppy drive)), i got this basic asm code:

; Boot1.asm
; - A Simple Bootloader
; Operating Systems Development Tutorial

org 0x7c00 ; We are loaded by BIOS at 0x7C00

bits 16 ; We are still in 16 bit Real Mode


cli ; Clear all Interrupts
hlt ; halt the system

times 510 - ($-$) db 0 ; We have to be 512 bytes. Clear the rest of the bytes with 0

dw 0xAA55 ; Boot Signiture

compiled via nasm and the created bin seems right (2 bytes at beginning, and 2 bytes signature at ending)

so i did this:
in command prompt:
debug c:\boot.bin
-l 0
-w 0 0 0 1 <-- here

i get an error by windows saying:
title: "16 bit MS-DOS subsystem
"Drive A: . Unable to lock for exclusive access. Another application may be using the drive. When the other application has finished using the drive you may retry the operation. Choose 'close' to terminate the application." -close- -abort- -ignore-

perhaps, i can't write to a virtual disk?
well i followed the above link's tutorial which used an application called partcopy, it also said that i cannot write to destination at offset 0

what could be causing this? how can i solve it?

Share this post

Link to post
Share on other sites

Yeah, that's when I gave up. Sorry, I don't know enough to solve your problem. :lol:

ah..it's sad to end that soon - there must be a way :(

Share this post

Link to post
Share on other sites
I have written some simple multithreaded kernels in C++ in the past, and, more recently, I was involved in the RenrakuOS project, which was a project to build a managed (.NET/Mono) OS in 100% Boo (ok ok, some compiler magic was needed to spit out assembly when we needed low level control - basically, certain methods of certain objects were transformed to specific assembly sequences (think compiler intrinsics on a class level)). I also have a little experience with programming for microcontrollers (my most recent project being the firmware for this).

First, don't even bother thinking you could compete with current-gen (or previous gen) consoles. Its just not a realistic goal. (Since you mentioned PS and xbox)

Having said that, depending on what your goals are, you do have a few options:
  • Write a gaming OS for existing computers (PC/mac) - I wouldn't really recommend it. Its a lot of work and you will have a lot of trouble trying to support certain hardware, eg, graphics cards, because most manufacturers simply do not release enough documentation. You could limit your graphics card support to Intel cards, for which decent open source drivers exist, and then port those to you OS, but it will still be a lot of work and you'll be missing out on the latest and greatest AMD and Nvidia offerings. Either way, it will be a huge amount of work to build a custom OS. If you DO decide to go this route, I would advise against using C or assembly in favor of building a managed OS, built on top of either .NET of the JVM as it will greatly increase the speed at which you get stuff done, plus if you do it right, makes porting existing code easy and may even let you use existing tools (eg, for Renraku, we were able to use the Microsoft .NET debugger - very very useful!)
    • Base your OS on Linux and use Linux-compatible hardware. This is the route I'd go if I were to do such a project. If your system will run on generic PC hardware, you can make use of existing Linux drivers for things like graphics cards - including AMD and Nvidia cards! If you don't want to go the PC hardware route, then you still have a few good options, for example, basing your console on a BeagleBoard or PandaBoard would be a good start. The PandaBoard features a very fast ARM Cortex A9, running at 1GHz, with 1 GB of RAM and an onboard DSP for graphics acceleration. The graphics accelerator won't come anywhere close to a current-gen console or PC GPU, but it is pretty powerful nontheless (capable of OpenGL ES, 1080p HD video etc). The PandaBoard also has a bunch of functionality baked in (wifi/ethernet, expansion headers, SD Card, USB, VGA/HDMI output etc) and is priced at a very reasonable US$175. Finally, you can run Ubuntu, Meego and Android on it - all of which would make a reasonable base for a console OS.
      • Finally, you could build your own console from scratch (if you ave the technical skills) or based around an existing hardware kit. You will not be able to compete with any recent hardware, but you could build something on par with a SNES or Genesis, with enough effort. A good start would be to get an XGameStation or HYDRA or Chameleon (I own a 16bit Chameleon and its great!) The HYDRA is based around the Propeller microcontroller from Parallax - an 8 core microcontroller running at ~20MHz. This would be a pretty cool option and you are guaranteed to learn a LOT about hardware, software, video generation, audio generation etc etc. But, like I said, about the best you could compete with is a late 80's/early 90's console.

        I personally wouldn't bother with the first option (PC hardware), but, if all you want is to get something working for yourself, this may be a simple option. Basically, you would build a bare-bones PC and attach existing peripherals either through USB, like you said, or through the serial port. You can then write a custom OS (or, much more realistic for the reasons I mentioned above, base it on Linux). You could, for example, configure Linux to give you a simple menu to select which game (stored on a memory stick or SD card) you want to play and then run it in full screen. A lightweight and simple window manager, like Musca would be a good way to achieve this (Musca is very minimal and very easily controlled through scripts or external programs - exactly what you want!) Hardware modding is probably not realistic with PC hardware (other than itnerfacing through serial or USB).

        Buying a beagleboard or pandaboard is also a very effective way of getting started quickly, lets you write 3D games, lets you connect USB devices and is very mod-friendly (extension pins, UART/SPI/I2C connectors, etc). You would probably still want to base it on Linux, so that you don't have to worry about the low low level details like accessing the graphics accelerator.

        So, in summary, I would go with either option 2 (BeagleBoard or other EXISTING hardware + Linux, possibly modded) or option 3 (microcotnroller based NES/SNES/Genesis/Gameboy clone).

        In any case, good luck.

        [color=#1C2837][size=2]i can't seem to be able to get my bootloader
        [color=#1C2837][size=2]I would recommend NOT writing your own bootloader. It really doesn't help you achieve your goal at all. Just use GRUB to boot your kernel and be done with it. Really, nothing your own bootloader will do will be much different from existing bootloaders. The interesting work begins in the kernel anyway, not the bootloader.

Share this post

Link to post
Share on other sites
thanks for the detailed post - some points seems to be misunderstood, i don't want to compete with anything, even though it's possible (i don't know why you are so disappointed about it :P) all i want is creating an OS that can read a USB or a DVD or even hard disk, and it might not even be a game console if it's unrealistic as you said.

the whole thing is that i wanted to draw graphics on a monitor - it started when i ordered an arduino (didn't arrive yet, bad service x(! ), saw some vids on youtube that i could use an lcd with it (my order also included a small lcd (no colors)), so i'm going to play with it and use it for some mini project i have, but now i thought, if that small chip is able to use a small lcd (128x64 or something) wihout being too slow (the processor is at 16MHz), why don't i use a computer processor, which is much faster (2GHz?) to display more complex graphics on larger screens? alright - i thought that i wouldn't need a gfx card and calculate everything on the CPU because the OS will be simple and all the processor's power will be used only for this app, so it would be sufficient (hope i'm not mistaken :/ ), since i can't solder the computer processor on my own board, which would require much planning and experience (which i don't REALLY have), i thought that i should just use the motherboard as if im running a normal PC but with my own very simple OS

even if that's a terribly bad idea, i would really love to try, and it will be a very good challenge for me to write an OS, even if it's simple, it's great to learn and experiment something new.

ok well, now some comments here and there scare me about the OS, yet i don't see why it's that HARD - i personally thought that it's hard because you have to use assembly in everything, but now i found out that only the boot loader should be in assembly, which can just be simple enough to load a kernel which is in C, and nothing's hard in C!, so is the kernel responsible for EVERYTHING after it was loaded by the bootloader? and the bootloader is simple enough to only run that kernel? and so, the whole OS is in that kernel?

also one last thing, what is GRUB? "a multibootloader", well, still a bootloader? so it must be on the first sector of the disk? and the problem will remain the same: how to get it in there? windows won't allow me to do this even using the cmd

Share this post

Link to post
Share on other sites
seems it's not the time to give up! following some tutorials, i managed to get my bootloader installed on a virtual system (virtualbox), hope i can go on from here, following your links

thanks again.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!