Mail Archives: djgpp/2000/01/18/19:28:24
From: | "=?iso-8859-1?Q?Stefan_Fr=F6berg?=" <traveler AT netti DOT fi>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Not important, just some stuff...
|
Date: | Wed, 19 Jan 2000 01:57:34 +0200
|
Organization: | SAUNALAHDEN SERVERIN asiakas
|
Lines: | 122
|
Message-ID: | <862u3b$ssg$1@tron.sci.fi>
|
NNTP-Posting-Host: | dxci.tdyn.saunalahti.fi
|
Mime-Version: | 1.0
|
X-Newsreader: | Microsoft Outlook Express 4.72.3110.5
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3110.3
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Tämä on moniosainen MIME-muotoinen viesti.
------=_NextPart_000_0018_01BF6220.8E017940
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hmmm...
I have been a bit lazy lately with my programming practices (a whole =
month and not a single line of code !).
Anyway, heres something I made with C++ (C++, because I just LOVE =
default parameters, function overloading, etc...)
Any questions and comments are welcome.
"Traveler 2000 AD..."
traveler AT netti DOT fi
------=_NextPart_000_0018_01BF6220.8E017940
Content-Type: text/plain;
name="Functions.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Functions.txt"
#include <conio.h>
#include <dpmi.h>
#include <go32.h>
#include <math.h>
#include <sys/farptr.h>
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned int UINT;
typedef unsigned long ULONG;
enum FILL {SOLID,WIRE};
enum VIDEO {TEXT = 0x3,VGA = 0x13};
double cos_table[360],
sin_table[360];
box(int x1,int y1,int x2,int y2,UCHAR color,FILL mode=WIRE);
circle(int center_x,int center_y,ULONG radius,UCHAR color);
putpixel(int x,int y,UCHAR color);
setmode(VIDEO mode);
int main(void)
{
// Just a pre-calculating the tables for circle function...
register unsigned long angle;
for(angle=0;angle<360;angle++)
{
cos_table[angle] = cos(angle * (PI/180));
sin_table[angle] = sin(angle * (PI/180));
}
_farsetsel(_dos_ds);
setmode(VGA);
circle(160,100,20,YELLOW);
box(140,80,180,120,WHITE);
putpixel(160,100,RED);
getch();
setmode(TEXT);
return(0);
}
void box(int x1,int y1,int x2,int y2,UCHAR color,FILL mode)
{
register int x,
y;
int inc_x = (x2 - x1)/abs(x2 - x1),
inc_y = (y2 - y1)/abs(y2 - y1);
for(y = y1;y != (y2+inc_y);y += inc_y)
for(x = x1;x != (x2+inc_x);x += inc_x)
switch(mode)
{
case SOLID:
putpixel(x,y,color);
break;
case WIRE:
if(x == x1 || x == x2 || y == y1 || y == y2)
putpixel(x,y,color);
break;
default:
break;
};
}
void circle(int center_x,int center_y,ULONG radius,UCHAR color)
{
int x,
y;
register unsigned long n;
for(n = 0;n<360;n++)
{
x = (int)(cos_table[n] * radius) + center_x;
y = (int)(sin_table[n] * radius) + center_y;
putpixel(x,y,color);
}
}
void putpixel(int x,int y,UCHAR color)
{
_farnspokeb(0xa0000+(y<<8)+(y<<6)+x,color);
}
void setmode(int mode)
{
static __dpmi_regs r;
r.h.ah = 0x00;
r.h.al = mode;
__dpmi_int(0x10,&r);
}
------=_NextPart_000_0018_01BF6220.8E017940--
- Raw text -