C language on MSDOS…

C program which I wrote.

It can set pixels, draw a circle, and draw a box.

All very primitive- technology from 30 years ago.

It is old graphics card and MSDOS (FreeDOS) which runs in a hard drive partition.

C compiler is not free but it is not sold anymore.

Software from 1992! Eventually it is Borland C++.

It can use XMS and EMS memory.

 

//#include <stdio.h>

#include <conio.h>

#include <dos.h>

#include <math.h>

char far* cgam = (char far*) MK_FP(0xb800,0x0000);

char shofs[]={6,4,2,0};

char clpatt[]={0x3f,0xcf,0xf3,0xfc};

char stpatt[]={0xc0,0x30,0x0c,0x03};

int cgaofs[]={0,8192};

void setpix(int x,int y,int c)

{int rx,ry,rc,rcl;

rx=x>>2;

ry=(y>>1)*80;

ry+=cgaofs[y&1];

rc=*(cgam+rx+ry);

rcl=rc&clpatt[x&3];

rcl|=stpatt[x&3]&(c<<shofs[x&3]);

*(cgam+rx+ry)=rcl;

}

void circle(int x,int y,int r,int color)

{int xc,yc,r2;

float rc,ac;

rc=0;

r2=r/2;

ac=6.28/(r*20);

reloop:

yc=(sin(rc)*r);

xc=(cos(rc)*r);

rc+=ac;

setpix( (r2+x)+xc,(r2+y)+yc,color);

setpix( (r2+x)-xc,(r2+y)-yc,color);

if(rc<3.14)goto reloop;

}

void box(int x,int y,int x2,int y2,int c)

{int x0=x;

reloopy: if(y>y2)goto complete;

reloopx: setpix(x++,y,c);

if(x>x2){x=x0;y++;goto reloopy;}goto reloopx;

complete:}

void main ()

{

int i,i2,x,y;

asm mov ax,0x0004

asm int 0x10

box(35,5,103,100,2);

box(55,35,123,135,1);

box(75,65,143,165,3);

circle(150,100,50,1);

while(!getch());

asm mov ax,0x0003

asm int 0x10

}

Leave a Reply

Your email address will not be published. Required fields are marked *