-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the LibDOS wiki!
LibDOS uses SDL2, which needs to be installed. See www.libsdl.org/download-2.0. On Mac, the easiest way to get SDL2 is to use Homebrew and type at the commend line: brew install sdl2
In a location of your choosing, at the command line, type:
git clone https://github.com/teefoss/LibDOS.git
In the directory that's created (called LibDOS), type:
make install
This will build libdos.a and copy it and the header files to /usr/local/lib and /usr/local/include, respectively. (If you want to build the library but not install it, just type make.)
(Coming soon(?))
To build a LibDOS program you must link with the LibDOS library and the SDL2 library:
cc main.c -ldos -lSDL2
This assumes libdos.a is in the system library location (/usr/local/lib).
#include <dos.h> /* for initialization and basic library functions */
#include <conio.h> /* for console input/output */
#include <graphics.h> /* for graphics functions (drawing shapes, etc.) */
int main()
{
/* initialization options should come before calling initdos() */
setcursor(CURSOR_NONE);
setbordersize(0);
initdos(); /* initialize LibDOS */
/* main loop */
while ( 1 )
{
int key;
if ( kbhit() )
key = getch(); /* get a keystroke */
if ( key == 'p' )
{
textcolor(RED);
gotoxy(5, 5); /* move cursor position */
cprintf("Hello, world!"); /* display red text */
}
else if ( key == 'c' )
{
clrscr(); /* clear the screen */
}
setcolor(LIGHTBLUE);
circle(64, 64, 48); /* draw a light blue circle at (64, 64) with radius 48. */
refresh(); /* make any changes appear */
}
}