C only graphics, no library.

Started by
23 comments, last by Extrarius 18 years ago
Quote:Original post by Mike2343
DOS had nothing to do with it if I remember right (been awhile since I made a 3D engine in a non-Windows environment). You used assembly to directly access the video card (which is no longer available if I remember correctly as no one releases the specs or builds them to the same ones, but I think old Mode 13/Mode X still could be used???).

Wolf3D was a mix of assembly and C code, you can download the code, or even Dooms code from idsoftware.com. If you have older hardware you can do this for sure, if you have newer video cards YMMV I'm not sure. There are still people writing software renderers for the knowledge gained so yes, it is still possible.
Best of luck.


The good part of using dos was that you got your game into memory from the fat filesystem. After this point you could just forgot dos and wrote anything that you wanted. Even elder novell oses used dos as a bootloader. Most games took direct control of every hardware they wanted to use.

Today this is not possible, since there is no common standard for the hardware. You need device drivers and most manufacturers don't give out the hardware specifications, so you can only use your computer with windows or sometimes linux and other less supported oses.

The c standard allows the writing of operating systems with very little inline assembly. If you have the full hardware specification, you can do it. Otherwise you have to use a supported os and its drivers, and that requires the use of the system specific interfaces and libraries.

Just remember, c is a language and not a predefined set of i/o functions. The language standard doesn't come with a single function predefined. Even the 'standard' libraries are optional.

Viktor
Advertisement
Quote:Original post by Anonymous Poster

Today this is not possible, since there is no common standard for the hardware.

Viktor


Hmm, actually I feel its more out of being a good programmer and let the OS control the hardware, to help prevent you from screwing up everything, or from others screwing your program over.

As you said, DOS was little more than an bootloader / file I/O library for many games.
If every program tried to take over and access the hardware directly, that would screw up multitasking.
Quote:Original post by furby100
If every program tried to take over and access the hardware directly, that would screw up multitasking.


The idea behind writing a program that doesn't use any libraries or other external code is to have something that runs without an os. Otherwise one has to use the services offered by the os and the program is not stand alone anymore.
If you want to write a standalone program, you either need to use assembly or a compiler with appropriate extensions. Standard C does not include anything to interact with hardware, and you're going to have to do that since you don't have an OS to do it for you. If you want to see a basic bootable program, check out Boot Sector Tic-Tac-Toe

The reason DOS games could take complete control of the hardware is simply that DOS didn't set up the processor to prevent you from doing so. Modern OSes do set up such protections, and that's a very good thing, because it prevents random crashes, restarts, hardware death, some security problems, and many other things. Imagine if you could write a simple script and upload it to your shared web server and take complete control of the machine - you could access anybody's data, alter server-wide configuration information, etc.

The way DOS games made such use of hardware was either through assembly code or through non-standard compiler extensions. Buy any old programming books and you'll find tons of information about BIOS interrupts, memory-mapped hardware, etc. If you want book suggestions, I can check my library when I get home and see which have the most info on such things.

Note that in order to make such use of hardware, games had to have _HUGE_ libraries of 'drivers' because each brand of each hardware device could have it's own interface, and that's why old games only support 5-10 sound cards, low (VGA) resolutions, etc. Things like OpenGL, DirectX, etc are a huge blessing and you really should take advantage of them in general.

If you want to make a 'real' stand-alone game, I'd suggest just using a bootable linux CD. Pack all the drivers you can onto it, then make your game using OpenGL for graphics and similar libraries for sound etc.

Quote:Original post by Anonymous Poster
Quote:Original post by furby100
If every program tried to take over and access the hardware directly, that would screw up multitasking.


The idea behind writing a program that doesn't use any libraries or other external code is to have something that runs without an os. Otherwise one has to use the services offered by the os and the program is not stand alone anymore.
"Stand-Alone" doesn't have to mean "works by itself", it could also mean "Works without anything besides what is on the disk", which could include a bootable version of linux or the like. Either way, I don't understand why you'd want a standalone program - besides being a novelty, they don't really offer any benefits, and having to reboot from the installed OS and be unable to use anything else besides that one program is a HUGE step back - multitasking is a _very_ good thing.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement