Google for, and try svgacc.zip.
16 bit graphics pack.
Or zsvga.zip for 32 bit.
>I need to draw some images for a Turbo C++ 1.01 game. The game is to use
>the BGI library, an EGA adaptor and EGALO screen mode. Where can I find
>the necessary software?
Just write your own... like the following... I saved lots of olde code from
my mispent middle-age... if you want any just ask.
// egastuff.c by Bill Buckels Christmas 1993
// supplementary graphics and miscellaneous program module
// for EGA screen mode 320 x 200
// written in Microsoft C 6.00a
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <dos.h>
#include <bios.h>
#include <io.h>
#include <malloc.h>
#include <conio.h>
#define SPACEBAR 32
#define ENTERKEY '\x0d' /* character generated by the Enter Key
*/
#define ESCKEY '\x1b' /* character generated by the Esc key
*/
#define FUNCKEY '\x00' /* first character generated by function keys
*/
#define UPARROW 'H' /* second character generated by up-arrow key
*/
#define DOWNARROW 'P' /* second character generated by down-arrow key
*/
#define LTARROW 'K' /* second character generated by left-arrow key
*/
#define RTARROW 'M' /* second character generated by right-arrow key
*/
#define PGUP 'I' /* second character generated by page up key
*/
#define PGDOWN 'Q' /* second character generated by page down key
*/
#define CRETURN '\x0d'
#define LFEED '\x0A'
#define CTRLZ '\x1a'
#define DELETE '\x7f'
#define ESCAPE '\x1b'
#define ON 1
#define OFF 0
#define EGA '\x0e'
#define TEXT '\x03'
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define WHITE 7
#define GRAY 8
#define LBLUE 9
#define LGREEN 10
#define LCYAN 11
#define LRED 12
#define LMAGENTA 13
#define YELLOW 14
#define BWHITE 15
char far *crtptr, *packbuffer;
char far *rawbuffer[200];
int filexists(char *filename)
{
int i;
if((i=open(filename,O_RDONLY|O_BINARY))!=-1)
{
close(i);
return 0;
}
return i;
}
int bsvload(char *filename)
{
int i;
char far *bsvptr;
if((i=open(filename,O_RDONLY|O_BINARY))!=-1)
{
bsvptr=(char far *)0xb8000000L;
read(i,bsvptr,7);
read(i,bsvptr,4000);
close(i);
return 0;
}
return i;
}
// position cursor at 0
// clear with character and attribute specified
int clearch(char c,unsigned front, unsigned back)
{
unsigned char d=(unsigned char)(back<<4|front);
_asm{
mov ah,2
mov bh,0
xor dx,dx
int 10h
mov ah,9
mov al,c
mov bh,0
mov bl,d
mov cx,2000
int 10h
}
}
#define TIMEOUT 0x2c00
int sound(freq,tlen)
int freq; /* freq of sound in Hertz */
int tlen; /* duration of sound 18.2 ticks per second */
{
union REGS inregs,outregs;
unsigned frdiv = 1331000L/freq; /* timer divisor */
int seed,hiseed,hold=0,setting;
if(freq!=32767)
{
outp(0x43,0xB6) ; /* write timer mode register */
outp(0x42,frdiv & 0x00FF); /* write divisor LSB */
outp(0x42,frdiv >> 8); /* write divisor MSB */
setting= inp(0x61); /* get current port B setting */
outp(0x61,setting | 0x03); /* turn speaker on */
}
if(tlen>0){
tlen=((tlen*1000)/182); /* convert from 18.2 ticks to 100ths */
inregs.x.ax= TIMEOUT;
int86(0x21,&inregs,&outregs);
seed=(outregs.x.dx)&0xff;
while(hold<tlen)
{
inregs.x.ax = TIMEOUT;
int86(0x21,&inregs,&outregs);
if(seed!=(outregs.x.dx&0xff))
{
hiseed= (outregs.x.dx)&0xff;
if(hiseed<seed)hiseed+=100;
hold+=(hiseed-seed);
seed =(outregs.x.dx)&0xff;
}
}
}
if(freq!=32767)
{
outp(0x61,setting);
}
/* restore port B setting */
return 0;
}
int s1 = 523; /* some values for the keyclick */
int s2 = 659;
int s3 = 784;
void keyclick(void)
{
sound(s1,1); sound(s2,1); sound(s3,1);
}
void bronx(void)
{
sound(60,4);
sound(40,8);
}
void bell()
{ /* dual tone beep */
sound(220,1);
sound(440,1);
}
unsigned char setcrtmode(unsigned char vidmode)
{
unsigned char temp = vidmode;
_asm{
mov al,temp
mov ah,0
int 10h
mov ah,0fh
int 10h
mov temp,al
}
return temp;
}
/* type conversion function */
unsigned int byteword(unsigned char a, unsigned char b)
{
return b<<8|a;
}
unsigned char pcxheader[128];
int checkpcxscreen(unsigned char *pcxheader)
{
unsigned int zsoft,codetype,pixbits;
unsigned int xmin, ymin, xmax,ymax;
unsigned int no_planes;
int invalid = -1, valid = 0, status=valid;
/* read the file header */
zsoft =pcxheader[0];
codetype=pcxheader[2];
pixbits =pcxheader[3];
if(zsoft!=10) status = invalid;
if(codetype!=1) status = invalid;
if(pixbits !=1) status = invalid;
xmin=byteword(pcxheader[4],pcxheader[5]);
ymin=byteword(pcxheader[6],pcxheader[7]);
xmax=byteword(pcxheader[8],pcxheader[9]);
ymax=byteword(pcxheader[10],pcxheader[11]);
no_planes =pcxheader[65];
if(xmin != 0 ) status = invalid;
if(ymin != 0 ) status = invalid;
if(xmax != 319) status = invalid;
if(ymax != 199) status = invalid;
if(no_planes!=4) status = invalid;
return status;
}
/* byte 0-15 are colors... byte 16 is overscan register */
unsigned char egainfo[17]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void palettebits(int i, unsigned char color,
unsigned char arg1, unsigned char arg2)
{
if(color>0x33)egainfo[i]|=arg1;
if(color>0x77)
{
egainfo[i]&=~arg1;
egainfo[i]|= arg2;
}
if(color>0xbb)egainfo[i]|=(arg1+arg2);
}
void rgb2ega(unsigned char *ptr)
{
int i;
unsigned char color;
for(i=0;i<16;i++)
{
egainfo[i]=0;
color=*ptr++;
palettebits(i,color,0x20,0x04);
color=*ptr++;
palettebits(i,color,0x10,0x02);
color=*ptr++;
palettebits(i,color,0x08,0x01);
}
egainfo[0]=0;
}
int setegapalette()
{
unsigned i,temp;
for(i=0;i<16;i++)
{
temp = egainfo[i];
temp = (temp<<8)+i;
_asm{
mov bx, temp;
xor ax, ax
mov ah, 10h
int 10h
}
}
/* dump data to color registers */
return 0;
}
unsigned char dummy;
void plot(unsigned x, unsigned y, unsigned color)
{
register j = 0x80>>(x%8);
register i = (y*40)+(x/8);
crtptr = (char far *)0xa0000000l;
if(x>320)goto skip;
_asm{
mov al, 8 ; graphics out
mov dx, 3ceh
out dx, al
mov ax, j
mov dx, 3cfh
out dx, al
mov al, 3 ; graphics out
mov dx, 3ceh
out dx, al
mov al, 0
mov dx, 3cfh
out dx, al
}
_asm{
mov al, 2 ; sequencer out
mov dx, 3c4h
out dx, al
mov al, 0fh
mov dx, 3c5h
out dx, al
}
dummy = crtptr[i];
crtptr[i]='\x00';
_asm{
mov al, 2 ; sequencer out
mov dx, 3c4h
out dx, al
mov ax, color
mov dx, 3c5h
out dx, al
}
crtptr[i]='\xff';
_asm{
mov al, 2 ; sequencer out
mov dx, 3c4h
out dx, al
mov al, 0fh
mov dx, 3c5h
out dx, al
}
_asm{
mov al, 3 ;graphics out
mov dx, 3ceh
out dx, al
mov al, 0
mov dx, 3cfh
out dx, al
mov al, 8 ;graphics out
mov dx, 3ceh
out dx, al
mov al, 0ffh
mov dx, 3cfh
out dx, al
}
skip:;
}
void screenline(char far *target,char far *source,unsigned nbytes)
{
// write 4 planes of image data to the screen
// use 8088 string instructions and inline code with no computation
#define dest 6
#define src 10
#define nbytes 14
_asm{
push ds
push es
push di
push si
; write plane 0
mov al,2
mov dx,3c4h
out dx,al
mov al,1
mov dx,3c5h
out dx,al
lds si, DWORD PTR [bp+src]
les di, DWORD PTR [bp+dest]
mov cx, WORD PTR [bp+nbytes]
cld
rep movsb
; write plane 1
mov al,2
mov dx,3c4h
out dx,al
mov al,2
mov dx,3c5h
out dx,al
lds si, DWORD PTR [bp+src]
add si, 40
les di, DWORD PTR [bp+dest]
mov cx, WORD PTR [bp+nbytes]
cld
rep movsb
; write plane 2
mov al,2
mov dx,3c4h
out dx,al
mov al,4
mov dx,3c5h
out dx,al
lds si, DWORD PTR [bp+src]
add si, 80
les di, DWORD PTR [bp+dest]
mov cx, WORD PTR [bp+nbytes]
cld
rep movsb
; write plane 3
mov al,2
mov dx,3c4h
out dx,al
mov al,8
mov dx,3c5h
out dx,al
lds si, DWORD PTR [bp+src]
add si, 120
les di, DWORD PTR [bp+dest]
mov cx, WORD PTR [bp+nbytes]
cld
rep movsb
pop si
pop di
pop es
pop ds
}
#undef dest
#undef src
#undef nbytes
}
void restorescreen(unsigned x1, unsigned y1,
unsigned x2, unsigned y2)
{
unsigned width;
register y = y1;
register x = x1/8;
x2++;
y2++;
width = (x2-x1)/8;
crtptr=(char far *)0xa0000000l+(y1*40)+x;
// test for retrace
_asm{
mov dx, 3dah
retry: in al, dx
test al, 8
jz retry
}
while(y<y2)
{
screenline(crtptr,(char far *)&rawbuffer[y][x],width);
crtptr+=40;
y++;
}
}
int egatext(char *str, unsigned x, unsigned y, unsigned colorvalue)
{
int scanline,byte,character,nibble; /* flags etcetera */
int counter;
unsigned char *romfont=(unsigned char *) 0xffa6000el;
/* a pointer to the 8 x 8 BITMAPPED font in the PC ROM */
int target = strlen(str); /* string length */
if(!target)return 0;
for(counter=0;counter<target;counter++){
if(str[counter]<' '||str[counter]>'z')str[counter]=0;
if(str[counter]==CRETURN)target=counter;
}
for (scanline=0;scanline<8;scanline++) /* finish the current scanline
before advancing to the next
*/
{
for (byte=0;byte<target;byte++) /* run the scanline
*/
{ /* use the current character
as an indices for the font
*/
character = romfont[(str[byte]&0x7f)*8+scanline];
if (character != 0)
for (nibble=0;nibble<8;nibble++)
if (character & 0x80>>nibble)
{
plot(x+byte*8+nibble,y,colorvalue);
}
}
y++;
}
return target;
}
/* center justified x-dimension only */
int egatextM(unsigned char *str,unsigned xorigin,unsigned yorigin,
unsigned tempcolor)
{
int target = strlen(str); /* string length */
int counter;
if(!target)return 0;
for(counter=0;counter<target;counter++){
if(str[counter]<' '||str[counter]>'z')str[counter]=0;
if(str[counter]==CRETURN)target=counter;
}
xorigin=(xorigin-(target*4));/* extrapolate the left edge */
egatext(str,xorigin,yorigin,tempcolor); /* pass to the usual function
*/
return target;
}
void fbox(int x1, int y1, int x2, int y2, unsigned color)
{
unsigned x;
x2++;
y2++;
while(y1<y2)
{
for(x=x1;x<x2;x++)plot(x,y1,color);
y1++;
}
}
int egascreen(char *name)
{
unsigned byteoff,offset;
unsigned int packet;
unsigned char byte,bytecount;
unsigned int temp;
register safety;
char far *ptr,*ptr2;
int fh;
/* open the file and check it out */
if((fh = open(name,O_RDONLY|O_BINARY))==-1)return -1;
read(fh,pcxheader,128);
if(checkpcxscreen(pcxheader)!=0)
{
close(fh);
return -2;
}
ptr=(char *)&pcxheader[16];
rgb2ega(ptr);
setegapalette();
temp=0;
byteoff=0;
safety=0;
offset=0;
ptr2=(char far *)&rawbuffer[0][0];
read(fh,packbuffer,(unsigned)64000);
close(fh);
ptr=(char far *)&packbuffer[0];
do{ bytecount=1; /* start with a seed count */
byte=*ptr; /* check to see if its raw */
if(0xC0 == (0xC0 &byte))
{
/* if its not, run encoded */
bytecount= 0x3f &byte;
*ptr++;
byte=*ptr;
}
if(temp>160)temp=160;
switch(temp)
{
case 160: offset++;
temp=0;
case 0:
case 40:
case 80:
case 120: safety= 0;
ptr2=(char far *)&rawbuffer[offset][temp];
}
for(packet=0;packet<bytecount;packet++)
{
ptr2[safety]=byte;
safety++;
// if(safety>39)packet=bytecount;
byteoff++;
temp++;
}
*ptr++;
}while(byteoff<(unsigned)32000);
restorescreen(0,0,319,199);
return 0;
}
void sleep(int seconds)
{
int ticks,i,j;
ticks = (seconds * 91)/5;
j=ticks/25;
for(i=0;i<j;i++)sound(32767,25);
j=ticks%25;
if(j)sound(32767,j);
}