Handmade Hero»Forums»Code
Shazan Shums
159 posts
Some day I will make quality software. Programming FTW.
OS independent game development
Is it possible to code a game where it doesn't need an OS.
It loads directly to the game like old consoles. Is it possible with the raspberry pi.
I wish these days games are like this, you load the disk and it works.

This might be not possible nowadays but it would be great if you could.
Bill Strong
50 posts
OS independent game development
So there is always some code underneath, even if it is the UEFI/BIOS. But you can do this today on UEFI machines. One stunt that Rust can do is compile a UEFI program. You would do all rendering in software, as there are no GPU accelerator drivers for UEFi, but at this level you would be making your own micro kernel to handle that type of stuff any way.

You can do the same with BIOS of course, create a simple micro kernel that only handles things specific to your use case. Or use one of the many Open Source ones such as SeL4 that will get you started.

There is also the idea of a microOS, in which your application code is compiled into the kernel, and the only thing that runs is your application.
Mārtiņš Možeiko
2559 posts / 2 projects
OS independent game development
It's still possible to insert usb/cd/floppy in modern CPU and directly boot from it and run only your code, not OS code.

The biggest problem with this approach will be how to use GPU hardware. For pure software solution there is no problem. Just set up your video mode and write pixels to it. But to use GPU hardware will be huge pain. First of all - there is so much different hardware - AMD, NVIDIA, Intel. Each very different and even different models of same vendor are very different architecture/interface. So for developer to support all GPU's is huge amount of work. Like really really huge. Take a look at Linux - there a lot of good developers working on open-source drivers, but still after how many years the open-source drivers are simply not as good/complete as closed source drivers directly from vendor (on Windows).

And second issue - not all documentation for GPU hardware is available. So you won't be able to do anything with GPU hardware without support from vendor. Intel has published complete documentation of their GPU's, for example here's docs for Skylake: https://01.org/linuxgraphics/docu...processors-based-skylake-platform
There are some docs available for AMD, but I don't think they keep it up to date: http://developer.amd.com/resources/developer-guides-manuals/ I don't think there are any reasnonable docs available for NVIDIA. But people are reverse engineering it.

Additionally to GPU there are some other issues with hardware - like network/WiFi which can also require proprietary drivers without docs.

That's why on PC games don't do this.
Michael Cameron
31 posts
OS independent game development
Unfortunately as hardware has become more "Plug'n'play" it has basically just got worse since vendors are content to say something "works" as long as there is some driver for just one platform - in the past there may have been at least some effort to design sensible hardware interfaces that could be used with minimal drivers or none at all or to design hardware to be compatible with products (ie. make your new soundcard work like a soundblaster) but for a long time now things haven't come with manuals or pin-outs or anything and instead they just bundle a driver CD for Windows or nothing at all and rely on heroic complexity of the driver to make things "just work".

Technically you could just build all this heroic complexity into your game (or application) but at that point you'd basically just be including Linux so there probably isn't any point.

However, if your goals are practical and not ideological then probably a better approach is to create an OS that isn't quite so bat-shit insane, ie. One that abstracts away the hardware only as much has necessary, has no mysterious "background tasks", doesn't impose multi-user/time-sharing on you, doesn't force you to use some crappy windowing system, has a dead-simple security model, etc.

Personally I'd very much like to have an OS that behaves more like an emulator, eg. the game/other software runs in the emulator and has _no_ access to the outside system, if it needs to read/write to a file then the user must attach that resource (like mounting a save cartridge), the system interfaces are simple enough that they can be implemented/emulated on any other system without heroic effort, etc.
Some implementations of containers/zones/jails on Linux/BSD/Solaris manage to meet some of these goals and CloudABI seems like the closest thing I've seen to this but unfortunately whilst perfectly suitable for server software is lacking in interfaces necessary for games (and other desktop software) such as supporting Vulkan/OpenGL (and afaik the necessary memory-mapping stuff to make that work) but at least they've got the security and portability sorted out so it'd probably be a great stepping stone.
Shazan Shums
159 posts
Some day I will make quality software. Programming FTW.
OS independent game development
Can you provide more info on setting up video mode is it possible with the raspberry pi and how?
25 posts
None
OS independent game development
Edited by hugo on
I think you have to Google "raspberry pi bare metal"

A few other easier, probably funnier options to program without an OS:
- old console emulators, for example this link)
- Embedded programming: smaller microcontrollers (Arduino, stm32) which you can hook up to simple displays and write every part of the system, feeling in control
- FPGAs with VGA connectors (here you would even write code to drive an VGA display, and you could write your own "processor" in a hardware description language (VHDL, Verilog). You can also use parts from OpenCores, eg http://opencores.org/project,minirisc

You could also just try to avoid using system calls and the standard libraries while programming in Windows/Linux...
511 posts
OS independent game development
chronokun

Personally I'd very much like to have an OS that behaves more like an emulator, eg. the game/other software runs in the emulator and has _no_ access to the outside system, if it needs to read/write to a file then the user must attach that resource (like mounting a save cartridge), the system interfaces are simple enough that they can be implemented/emulated on any other system without heroic effort, etc.
Some implementations of containers/zones/jails on Linux/BSD/Solaris manage to meet some of these goals and CloudABI seems like the closest thing I've seen to this but unfortunately whilst perfectly suitable for server software is lacking in interfaces necessary for games (and other desktop software) such as supporting Vulkan/OpenGL (and afaik the necessary memory-mapping stuff to make that work) but at least they've got the security and portability sorted out so it'd probably be a great stepping stone.


sounds like what google chrome does (or tries to do) for it's process isolation for its tab processes.
Shazan Shums
159 posts
Some day I will make quality software. Programming FTW.
OS independent game development
Is there a resource for pixel programming and low level software rendering for a beginner who knows nothing about graphics at all.
25 posts
None
OS independent game development
Edited by hugo on
Pixel art is more of a visual style of 2D games. So I recommend you watch the first episodes of https://handmadehero.org/, and you will start learning what you need to learn to write those kinds of games.

A couple interesting resources:
- https://love2d.org/ - make 2D games in Lua. Check those cute pixel art games written in Love (IIRC): https://rxi.itch.io They run smooth enough!
- https://github.com/martincohen/Punity - a framework for tiny games written in C from scratch (Windows only)

Shazan Shums
159 posts
Some day I will make quality software. Programming FTW.
OS independent game development
I didn't mean pixel art I meant software rendering because I don't how to manipulate the pixels. I understand how pixels are located in memory and how they are shown but I can't manipulate them maybe I'm missing math or something.
And thanks for the people who answered my questions.
511 posts
OS independent game development
msmshazan
I didn't mean pixel art I meant software rendering because I don't how to manipulate the pixels. I understand how pixels are located in memory and how they are shown but I can't manipulate them maybe I'm missing math or something.
And thanks for the people who answered my questions.


Handmade hero starts with doing software rendering. The core of it is done in the first few episodes.
25 posts
None
OS independent game development
Are you already a programmer working in another area, or just getting started?
David Butler
81 posts / 1 project
I love pretty much anything technical, whether it be programming, networking, hacking or electronics.
OS independent game development
This is hardly an optimal solution and would take a lot of work but one thing that might be worth mentioning is that you can build a compatibility layer so that you can load drivers meant for other platforms. Linux did this so that it could load windows WiFi drivers (Ndiswrapper) and GNU HURD has the ability to load older Linux drivers. Also you might be able to adapt Mesa (an open source OpenGL implementation) to work on your custom OS (it already has been implemented on Windows and Linux)
Mārtiņš Možeiko
2559 posts / 2 projects
OS independent game development
Edited by Mārtiņš Možeiko on
At that point, if you are using ndiswrapper and mesa, you simply take Linux and adopt to your use case instead of writing whole OS yourself. Linux can be customized stripped down pretty significantly.

msmshazan
Can you provide more info on setting up video mode is it possible with the raspberry pi and how?

Here are few examples:
https://github.com/brianwiddas/pi-baremetal
https://github.com/ICTeam28/PiFox
http://magicsmoke.co.za/?p=284
Keywords to search is "bare metal".

If you'll want to do 3D graphics on raspberry pi, you'll need to read and understand this document: http://www.broadcom.com/docs/supp...videocore/VideoCoreIV-AG100-R.pdf