commit c3b744f27029b805ef855686c3f692722038f3c2 Author: jdg Date: Wed Sep 8 21:30:32 2021 +0200 First commit 16/09/1994 diff --git a/BGI/DEMO.EXE b/BGI/DEMO.EXE new file mode 100644 index 0000000..a392983 Binary files /dev/null and b/BGI/DEMO.EXE differ diff --git a/BGI/INITSVGA.C b/BGI/INITSVGA.C new file mode 100644 index 0000000..fa539e5 --- /dev/null +++ b/BGI/INITSVGA.C @@ -0,0 +1,108 @@ +/* Sample program that initializes the SuperVGA driver */ + +#include + +extern int far Svga16_fdriver[]; +extern int far Svga256_fdriver[]; +extern int far Twk16_fdriver[]; +extern int far Twk256_fdriver[]; + +int huge DetectVGA256() +{ + int Vid; + + printf("Which video mode would you like to use? \n"); + printf(" 0) 320x200x256\n"); + printf(" 1) 640x400x256\n"); + printf(" 2) 640x480x256\n"); + printf(" 3) 800x600x256\n"); + printf(" 4) 1024x768x256\n\n>"); + scanf("%d",&Vid); + return Vid; +} + +int huge DetectVGA16() +{ + int Vid; + + printf("Which video mode would you like to use? \n"); + printf(" 0) 320x200x16\n"); + printf(" 1) 640x200x16\n"); + printf(" 2) 640x350x16\n"); + printf(" 3) 640x480x256\n"); + printf(" 4) 800x600x16\n"); + printf(" 5) 1024x768x16\n\n>"); + scanf("%d",&Vid); + return Vid; +} + +int huge DetectTwk16() +{ + int Vid; + + printf("Which video mode would you like to use? \n"); + printf(" 0) 704x528x16\n"); + printf(" 1) 720x540x16\n"); + printf(" 2) 736x552x16\n"); + printf(" 3) 752x564x16\n"); + printf(" 4) 768x576x16\n"); + printf(" 5) 784x588x16\n"); + printf(" 6) 800x600x16\n\n>"); + scanf("%d",&Vid); + return Vid; +}; + +int huge DetectTwk256() +{ + int Vid; + + printf("Which video mode would you like to use? \n"); + printf(" 0) 320x400x256\n"); + printf(" 1) 320x480x256\n"); + printf(" 2) 360x480x256\n"); + printf(" 3) 376x564x256\n"); + printf(" 4) 400x564x256\n"); + printf(" 5) 400x600x256\n"); + scanf("%d",&Vid); + return Vid; +}; + + +main() +{ + int Gd = DETECT, Gm; + int Drv; + + printf("Which driver would you like to use?\n"); + printf(" 0) Svga256\n"); + printf(" 1) Svga16\n"); + printf(" 2) Tweak256\n"); + printf(" 3) Tweak16\n"); + printf(">"); + scanf("%d",&Drv); + switch(Drv) + { + case 0: installuserdriver("Svga256",DetectVGA256); +/* If driver is linked with file, remove comments */ +/* registerfarbgidriver(Svga256_fdriver); */ + break; + case 1: installuserdriver("Svga16",DetectVGA16); +/* If driver is linked with file, remove comments */ +/* registerfarbgidriver(Svga16_fdriver); */ + break; + case 2: installuserdriver("Twk16",DetectTwk16); +/* If driver is linked with file, remove comments */ +/* registerfarbgidriver(Twk16_fdriver); */ + break; + case 3: installuserdriver("Twk256",DetectTwk256); +/* If driver is linked with file, remove comments */ +/* registerfarbgidriver(Twk256_fdriver); */ + } + initgraph(&Gd,&Gm,""); + setcolor(15); + line(0,0,getmaxx(),getmaxy()); + line(0,getmaxy(),getmaxx(),0); + getch(); + closegraph(); +} + \ No newline at end of file diff --git a/BGI/INITSVGA.PAS b/BGI/INITSVGA.PAS new file mode 100644 index 0000000..2c7c5f3 --- /dev/null +++ b/BGI/INITSVGA.PAS @@ -0,0 +1,103 @@ +{ Sample program that initializes the SuperVGA driver} +Program Test256; + +Uses Graph,Crt,Dos; + +{$i svga16.inc} +{$i svga256.inc} + +var + GraphMode, GraphDriver : integer; + Ky : Char; + Drv : Integer; + +{$F+} +function DetectVGA256 : Integer; +var Vid : Integer; + +begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 320x200x256'); + Writeln(' 1) 640x400x256'); + Writeln(' 2) 640x480x256'); + Writeln(' 3) 800x600x256'); + Writeln(' 4) 1024x768x256'); + Write('> '); + Readln(Vid); + DetectVGA256 := Vid; +end; + +function DetectVGA16 : Integer; +var Vid : Integer; + +begin + Writeln('Which video mode would you like to use? '); + Writeln(' 0) 320x200x16'); + Writeln(' 1) 640x200x16'); + Writeln(' 2) 640x350x16'); + Writeln(' 3) 640x480x256'); + Writeln(' 4) 800x600x16'); + Writeln(' 5) 1024x768x16'); + Writeln('>'); + Readln(Vid); + DetectVGA16 := Vid; +end; + +function DetectTwk256 : Integer; +var Vid : Integer; + +begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 320x400x256'); + Writeln(' 1) 320x480x256'); + Writeln(' 2) 360x480x256'); + Writeln(' 3) 376x564x256'); + Writeln(' 4) 400x564x256'); + Writeln(' 5) 400x600x256'); + Write('> '); + Readln(Vid); + DetectTwk256 := Vid; +end; + +function DetectTwk16 : Integer; +var Vid : Integer; + +begin + Writeln('Which video mode would you like to use? '); + Writeln(' 0) 704x528x16'); + Writeln(' 1) 720x540x16'); + Writeln(' 2) 736x552x16'); + Writeln(' 3) 752x564x256'); + Writeln(' 4) 768x576x16'); + Writeln(' 5) 784x588x16'); + Writeln(' 6) 800x600x16'); + Writeln('>'); + Readln(Vid); + DetectTwk16 := Vid; +end; +{$F-} + +begin + Writeln('Which driver would you like to use?'); + Writeln(' 0) Svga256'); + Writeln(' 1) Svga16'); + Writeln(' 2) Tweak256'); + Writeln(' 3) Tweak16'); + Write('>'); + Readln(Drv); + if (Drv = 0) then + GraphDriver := InstallUserDriver('SVGA256',@DetectVGA256) + else if (Drv = 1) + GraphDriver := InstallUserDriver('SVGA16',@DetectVGA16) + else if (Drv = 2) + GraphDriver := InstallUserDriver('Twk256',@DetectTwk256) + else if (Drv = 3) + GraphDriver := InstallUserDriver('Twk16',@DetectTwk16); + GraphDriver := Detect; + InitGraph(GraphDriver,GraphMode,''); + setcolor(15); + line(0,0,GetMaxX,GetMaxY); + line(0,GetMaxY,GetMaxX,0); + Ky := ReadKey; + CloseGraph; +end. \ No newline at end of file diff --git a/BGI/MAKEFILE.SVG b/BGI/MAKEFILE.SVG new file mode 100644 index 0000000..1b26656 --- /dev/null +++ b/BGI/MAKEFILE.SVG @@ -0,0 +1,19 @@ +## Makefile for initsvga.c (SuperVGA drivers) +## Demonstrates use of registerfarbgidriver +PROG = initsvga # Program name to compile +CC = tcc # Command-line compiler (tcc/bcc) +LIB = e:\lang\lib # Library directory +INCLUDE = e:\lang\include # Include directory +MODEL = s # Memory Model + +$(PROG).exe: $(PROG).c svga256f.obj svga16f.obj + $(CC) -L$(LIB) -I$(INCLUDE) -m$(MODEL) $(PROG).c \ + svga256f.obj svga16f.obj graphics.lib + +svga256f.obj : svga256.bgi + bgiobj /F svga256.bgi svga256f.obj _Svga256_fdriver SVGA256_TEXT + +svga16f.obj : svga16.bgi + bgiobj /F svga16.bgi svga16f.obj _Svga16_fdriver SVGA16_TEXT + + \ No newline at end of file diff --git a/BGI/MAKEFILE.TWK b/BGI/MAKEFILE.TWK new file mode 100644 index 0000000..334ec08 --- /dev/null +++ b/BGI/MAKEFILE.TWK @@ -0,0 +1,19 @@ +## Makefile for initsvga.c (Tweaked drivers) +## Demonstrates use of registerfarbgidriver +PROG = initsvga # Program name to compile +CC = tcc # Command-line compiler (tcc/bcc) +LIB = e:\lang\lib # Library directory +INCLUDE = e:\lang\include # Include directory +MODEL = s # Memory Model + +$(PROG).exe: $(PROG).c twk256f.obj twk16f.obj + $(CC) -L$(LIB) -I$(INCLUDE) -m$(MODEL) $(PROG).c \ + twk256f.obj twk16f.obj graphics.lib + +twk256f.obj : twk256.bgi + bgiobj /F twk256.bgi twk256f.obj _twk256_fdriver TWK256_TEXT + +twk16f.obj : twk16.bgi + bgiobj /F twk16.bgi twk16f.obj _twk16_fdriver TWK16_TEXT + + \ No newline at end of file diff --git a/BGI/NOTES16.SVG b/BGI/NOTES16.SVG new file mode 100644 index 0000000..9a84bbd --- /dev/null +++ b/BGI/NOTES16.SVG @@ -0,0 +1,14 @@ +SuperVGA 16 BGI driver +Version 1.11 +August 20, 1991 + +This is the latest version of my 16 color BGI driver. All functions have +been implemented (including paging and floodfill), and should work like +the EGAVGA driver. + + o Fixed getimage bug + + o Added new logical operations to putimage: + XNOR_PUT + NAND_PUT + NOR_PUT \ No newline at end of file diff --git a/BGI/NOTES16.TWK b/BGI/NOTES16.TWK new file mode 100644 index 0000000..14f4d5b --- /dev/null +++ b/BGI/NOTES16.TWK @@ -0,0 +1,12 @@ +TweakVGA 16 BGI driver +Version 1.0 +August 20, 1991 + +This is the first version of my 16 color tweaked BGI driver. All functions +have been implemented (including floodfill), and should work like +the EGAVGA driver. + +NOTES: + Paging and mouse cursor will not work + + \ No newline at end of file diff --git a/BGI/NOTES256.SVG b/BGI/NOTES256.SVG new file mode 100644 index 0000000..897de4d --- /dev/null +++ b/BGI/NOTES256.SVG @@ -0,0 +1,25 @@ +SuperVGA 256 BGI driver +Version 2.21 +August 20, 1991 + +This is the newest version of my SuperVGA 256 BGI driver. I have fixed +several bugs in the previous releases, as well as added several improvements. + + o 1024x768x256 color mode is now supported on Tseng 4000, + Chips&Tech, Trident 8900 and Ahead video cards. + + o Getimage and putimage will work with bitmaps up to the + size of available memory. (> 64k) + + o VESA support has been added. + + o Added setvgapalette256 function. + + o Floodfill is implemented. + + o Added new logical operations to putimage + XNOR_PUT + NAND_PUT + NOR_PUT + TRANS_COPY_PUT - Treats 0 as transparent + \ No newline at end of file diff --git a/BGI/NOTES256.TWK b/BGI/NOTES256.TWK new file mode 100644 index 0000000..776087b --- /dev/null +++ b/BGI/NOTES256.TWK @@ -0,0 +1,11 @@ +TweakVGA 256 BGI driver +Version 0.5 +August 20, 1991 + +This is the first version of my 256 color tweaked BGI driver. All functions +have been implemented (except getimage/putimage, but these will be added soon). + +NOTES: + Paging and mouse cursor will not work + + \ No newline at end of file diff --git a/BGI/OCTREE.C b/BGI/OCTREE.C new file mode 100644 index 0000000..8222637 --- /dev/null +++ b/BGI/OCTREE.C @@ -0,0 +1,181 @@ +#include +#include "alloc.h" +#include "dos.h" +#include "quant.h" +#include "octree.h" + +#define TESTBIT(a,i) ( ((a) >> (i)) & 1) +#define MAXDEPTH 8 +#define BYTE unsigned char + +UCHAR palette [MAXCOLORS][3]; + +static UINT size; +static UINT reducelevel; +static UINT leaflevel; +static OCTREE tree; +static BYTE rgb_mio[3]; +static OCTREE reducelist[MAXDEPTH + 1]; + +static unsigned char quant_r, + quant_g, + quant_b; + + /* Quantiza seg£n TESTBIT, pero solamente de retorno */ + +static char quant2(OCTREE tree) +{ + if (tree->leaf) return(tree->colorindex); + else return(quant2(tree->next[ + TESTBIT(quant_r, MAXDEPTH - tree->level) * 4 + + TESTBIT(quant_g, MAXDEPTH - tree->level) * 2 + + TESTBIT(quant_b, MAXDEPTH - tree->level)])); +} + + /* devuelve el indice a la paleta quantizada de acuerdo con RGB apuntado */ + +int pal_index(UCHAR *p) +{ + quant_r = p[RED]; + quant_g = p[GREEN]; + quant_b = p[BLUE]; + return quant2(tree); +} + +static double init_Cfactor; +static UINT init_col_num; + +static void initpalette(OCTREE tree) +{ + UINT j; + + if (tree == NULL) return; + if (tree->leaf || tree->level == leaflevel) { + palette[init_col_num][RED] = (char) ((init_Cfactor * tree->rgbsum.r) / tree->colorcount + .5); + palette[init_col_num][GREEN] = (char) ((init_Cfactor * tree->rgbsum.g) / tree->colorcount + .5); + palette[init_col_num][BLUE] = (char) ((init_Cfactor * tree->rgbsum.b) / tree->colorcount + .5); + tree->colorindex = init_col_num; + tree->leaf = TRUE; + init_col_num++; + } else { + for (j = 0; j < 8; j++) + initpalette(tree->next[j]); + } +} + + /* calcula la paleta de acuerdo con un factor introducido */ + +UINT calc_palette(UINT i, double Cfactor) +{ + init_Cfactor = Cfactor; + init_col_num = i; + initpalette(tree); + return init_col_num; +} + + +static void newandinit(OCTREE *tree, UINT depth) + { + unsigned long rest; + *tree = (OCTREE)calloc(1,sizeof(struct node)); + if (*tree == NULL) { + rest=coreleft(); + printf("No hay bastante Memoria"); + exit(1); + } + (*tree)->level = depth; + (*tree)->leaf = (depth >= leaflevel); + if ((*tree)->leaf) + size++; + } + +static void getreduceable(OCTREE *node) + { + UINT newreducelevel; + + newreducelevel = reducelevel; + while (reducelist[newreducelevel] == NULL) + newreducelevel--; + *node = reducelist[newreducelevel]; + reducelist[newreducelevel] = + reducelist[newreducelevel]->nextreduceable; + } + +static void makereduceable(UINT level,OCTREE node) +{ + node->nextreduceable = reducelist[level]; + reducelist[level] = node; +} + + /* reduzcamos el arbol, pues K+1>size */ + +static void reducetree(void) +{ + OCTREE node; + UINT depth; + + getreduceable(&node); + node->leaf = 1; + size = size - node->children + 1; + depth = node->level; + if (depth < reducelevel) { + reducelevel = depth; + leaflevel = reducelevel + 1; + } +} + +static UCHAR insert_rgb[3]; + + /* para insertar cada color dentro del arbol */ + +static void inserttree(OCTREE *tree, UINT depth) +{ + UINT branch; + + if (*tree == NULL) + newandinit(tree,depth); + (*tree)->colorcount++; + (*tree)->rgbsum.r += insert_rgb[RED]; + (*tree)->rgbsum.g += insert_rgb[GREEN]; + (*tree)->rgbsum.b += insert_rgb[BLUE]; + if ((*tree)->leaf == FALSE && depth < leaflevel) { + branch = TESTBIT(insert_rgb[RED],MAXDEPTH - depth) * 4 + + TESTBIT(insert_rgb[GREEN],MAXDEPTH - depth) * 2 + + TESTBIT(insert_rgb[BLUE],MAXDEPTH - depth); + if ((*tree)->next[branch] == NULL) { + (*tree)->children++; + if ((*tree)->children == 2) + makereduceable(depth,*tree); + } + inserttree(&((*tree)->next[branch]), depth + 1); + } +} + + +void lee(FILE *uno,double gamm) /* funci¢n que leer  la 1¦ vez el TGA */ +{ + union REGS regset; + struct SREGS sregset; + + reducelevel = MAXDEPTH; + leaflevel = reducelevel + 1; + + while (!feof(uno)) { + fread(&rgb_mio,3,1,uno); + insert_rgb[0]=rgb_mio[2]; // CUIDADO, valores de TGA tipo 2 + insert_rgb[1]=rgb_mio[1]; // Estan BGR no RGB + insert_rgb[2]=rgb_mio[0]; + inserttree(&tree, 0); + if (size > MAXCOLORS - 1) /* > K+1? (colores) */ + reducetree(); + } + calc_palette((unsigned int)0,gamm); + regset.x.ax=0x1012; + regset.x.bx=0; + regset.x.cx=256; + regset.x.dx=FP_OFF(palette); + sregset.es=FP_SEG(palette); + int86x(0x10,®set,®set,&sregset); /* interrupci¢n que carga y */ + /* activa la paleta nueva */ +} + diff --git a/BGI/OCTREE.H b/BGI/OCTREE.H new file mode 100644 index 0000000..c8c3c43 --- /dev/null +++ b/BGI/OCTREE.H @@ -0,0 +1,19 @@ +struct colorsum { + unsigned long r, g, b; +}; + +typedef struct node * OCTREE; +struct node { + unsigned char leaf; + unsigned char level; + unsigned char colorindex; + unsigned char children; + unsigned long colorcount; + struct colorsum rgbsum; + OCTREE nextreduceable; + OCTREE next[8]; +}; + +extern OCTREE tree; + +UINT calc_palette(UINT i, double Cfactor); diff --git a/BGI/QUA.C b/BGI/QUA.C new file mode 100644 index 0000000..60454da --- /dev/null +++ b/BGI/QUA.C @@ -0,0 +1,146 @@ +/* Ejemplo de displayado de TGA tipo 2 en SVGA 640*480*256 + Autor: Juan Ramon Lehmann + 14-09-1994 (c) + No olvidar compilar en modo large + y a¤adir libreria de graficos */ + +#include "graphics.h" +#include "stdlib.h" +#include "alloc.h" +#include "math.h" +#include "dos.h" +#include "conio.h" +#include "stdio.h" +#include "string.h" +#include "search.h" +#include "math.h" + +typedef unsigned char BYTE; +typedef unsigned int WORD; + +void InitGrafico(void); +int huge DetectSVGA(void); + +struct Triplete { + BYTE Red; + BYTE Green; + BYTE Blue; + } *MiTriplete; + +struct { + BYTE bIDFieldSize; + BYTE bColorMapType; + BYTE bImageType; + BYTE ClrMapSpec[5]; + WORD wXOrigin; + WORD wYOrigin; + WORD wWidth; + WORD wHeight; + BYTE bBitsPerPixel; + BYTE bImageDesc; + } stTarga24Header = { + 0,0,2, + 0,0,0,0,0, + 0,0,0,0, + 24, + 0 + }; + +int pal_index(unsigned char *p); +void lee(FILE *uno,double gam); /* funci¢n que leer  la 1¦ vez el TGA */ + + // Para las llamadas a las interrupciones + union REGS regset; + struct SREGS sregset; + FILE *in; + +int main(int argv,char *argc[]) +{ + register n; + static BYTE RGBLineBuffer[1024*3]; + int wLineCount,i,x,y; + static double gamma; + static BYTE pixel; + char *name,*endptr; + WORD wHeight,wWidth; + + if (argv<2) + { + printf("Error, la sintaxis es demo.exe \n"); + printf("filename= TGA tipo 2\n"); + printf("gamma factor= Factor de correcci¢n, se aconseja 0.2\n\n\n"); + exit(0); + } + + name=argc[1]; // nombre del fichero + gamma=strtod(argc[2],&endptr); + + InitGrafico(); + + if ((in=fopen(name,"rb"))==NULL) + { + perror("Error al abrir el fichero TGA"); + exit(0); + } + + fread(&stTarga24Header, sizeof(stTarga24Header),1, in); // leo cabecera + lee(in,gamma); /* Lee TGA la primera vez */ + + // aqui ya est  la quantizaci¢n + + fseek(in, 0L, SEEK_SET); // dejo el fichero al principio + fread(&stTarga24Header, sizeof(stTarga24Header),1, in); // leo cabecera + + wHeight=stTarga24Header.wHeight; + wWidth=stTarga24Header.wWidth; // longitud grafico + + y=320; + x=0; + + for(wLineCount=0;wLineCount<=wHeight-1;wLineCount++) + { + fread(&RGBLineBuffer,wWidth*3,1,in); //wWidth*3 ---> 320 + + i=0; + while (i<=wWidth*3) + { + /* como los valores est n a la inversa....:-) */ + + MiTriplete->Blue=RGBLineBuffer[i++]; + MiTriplete->Green=RGBLineBuffer[i++]; + MiTriplete->Red=RGBLineBuffer[i++]; + + pixel=pal_index(MiTriplete); + putpixel(x++,y,pixel); + } + x=0; + y--; + } + getch(); + closegraph(); /* desactiva modo grafico */ + fclose(in); + return 0; +} + + +void InitGrafico(void) + { + int gdriver = DETECT, gmode=0, errorcode; + installuserdriver("Svga256",DetectSVGA); + initgraph(&gdriver,&gmode, ""); + errorcode = graphresult(); + if (errorcode != grOk) + { + printf("Error de gr ficos: %s\n", grapherrormsg(errorcode)); + printf("Pulse una tecla para salir:"); + getch(); + exit(1); + } + } + +int huge DetectSVGA(void) + { + return(2); /* 2=SVGA 640*480*256 0=320*200*256*/ + } + + diff --git a/BGI/QUANT.H b/BGI/QUANT.H new file mode 100644 index 0000000..0c7f297 --- /dev/null +++ b/BGI/QUANT.H @@ -0,0 +1,20 @@ +#include +#include +#include + +#define TRUE 1 +#define FALSE 0 + +#define RED 0 +#define GREEN 1 +#define BLUE 2 + +#define MAXCOLORS 255 + +typedef unsigned char UCHAR; /* 8 bits */ +typedef unsigned short int UINT; /* 16 bits */ +typedef unsigned long int ULONG; /* 32 bits */ + +extern UCHAR palette[MAXCOLORS][3]; +int pal_index(UCHAR *pixel); + diff --git a/BGI/README b/BGI/README new file mode 100644 index 0000000..d2d56b3 --- /dev/null +++ b/BGI/README @@ -0,0 +1,135 @@ +************************************************************** +COPYRIGHT 1991, JORDAN HARGRAPHIX SOFTWARE +PORTIONS COPYRIGHT JOHN BRIDGES, 1990 + CHRISTOPHER MORGAN, 1984 +************************************************************** + +Here it is! The SuperVGA/Tweak BGI drivers you have all been waiting for! ;-> + + These drivers support a wide range of VGA cards, and should work on +all major brands. + +Card types supported: (SuperVGA drivers) + Ahead, ATI, Chips & Tech, Everex, Genoa, Paradise, Trident (both 8800 +and 8900), Tseng (both 3000 and 4000 chipsets) and Video7. + These drivers will also work on video cards with VESA capability. + The tweaked drivers will work on any register-compatible VGA card. + +I have not tested these drivers on all these card types, so I can not guarantee +perfect operation with your card. I have tested them extensively +on Trident, Tseng and ATI cards, and have had no problems. (Trident 8800 +cards occasionally have problems, especially older models) + +Modes currently supported: +  SuperVGA 16-color + 0) Standard EGA/VGA 320x200x16 + 1) Standard EGA/VGA 640x200x16 + 2) Standard EGA/VGA 640x350x16 + 3) Standard VGA 640x480x16 + 4) SuperVGA/VESA 800x600x16 + 5) SuperVGA/VESA 1024x768x16 + +  SuperVGA 256-color + 0) Standard VGA/MCGA 320x200x256 + 1) 256k Svga/VESA 640x400x256 + 2) 512k Svga/VESA 640x480x256 + 3) 512k Svga/VESA 800x600x256 + 4) 1024k Svga/VESA 1024x768x256 + +  Tweaked 16-color + 0) 704x528x16 + 1) 720x540x16 + 2) 736x552x16 + 3) 752x564x16 + 4) 768x576x16 + 5) 784x588x16 + 6) 800x600x16 + +  Tweaked 256-color + 0) 320x400x256 + 1) 320x480x256 + 2) 360x480x256 + 3) 376x564x256 + 4) 400x564x256 + 5) 400x600x256 + +---------------------------------------------------------------------------- +INSTALLATION: + Using the driver in existing programs is easy. (If you have the source) + + Check the files INITSVGA.C and INITSVGA.PAS for examples of installation +into C and Pascal programs. + +---------------------------------------------------------------------------- +NOTE: + + - The mouse cursor may not work in all modes of my driver. This is because + most mouse drivers do not support SuperVGA/Tweak modes. + + - The registerbgidriver(*) function does not work. This is due to a limitation + in the BGI kernel, which checks the linked in driver with a list of the + standard BGI drivers (CGA,EGAVGA,etc..), and if it is not one of those, + will not use the linked in driver. + + * However, registerfarbgidriver DOES work properly with C/C++... (8/1/91) + Check INITSVGA.C and the makefile for examples of how to use. + + - Imagesize does not work. (the kernel does not call the driver to do this) + Use the following formula: + * imsize = ((xwid >> 1)+1)*ywid+4; (16-color) + * imsize = xwid*ywid+4; (256-color) + +---------------------------------------------------------------------------- +WARNING: The drivers do not test to see if the card installed is +actually a VGA card (If the Svga drivers do not detect a SuperVGA card, they +treat the card as a standard VGA), so DO NOT use the drivers if you do not +have a VGA card installed. + +------------------------------------------------------------------------- +REGISTRATION: + I have decided to release these drivers free of charge, +although donations would be greatly appreciated and certainly +expedite the release of future versions. :-> + The drivers have not been crippled in any way, though beta releases of new +drivers may have some functions yet unimplemented. + +Registration fees: + + SuperVGA 256 $20 + SuperVGA 16 $20 + Tweak 16 $20 + Tweak 256 $20 + + Any two: $30 + All 4: $50 + +With donations of $20 and up, you will be considered a registered user. +Registered users get the full source code and upgrades on future releases. + +From September 1-May 8, please send checks/money to: + Jordan Hargrave + 1000 Morewood Ave, Box #3277 + Pittsburgh, PA 15213 + (412) 268-4493 + +From May 8-September 1, send to: + Jordan Hargrave + 1615 Burnley Road + Charlotte, NC 28210 + (704) 553-2332 + + +I have started working on a new graphics library that will support resolutions +from 160x200 (Ick! ;->) all the way up to 1280x1024, and from 1-bit color +to 24-bit color. It will support a wide range of cards and I need testers +for XGA/8514/Hercules Graphics Station cards. + +*===============================*===========================================* +| Jordan Powell Hargrave | Internet: jh5y@andrew.cmu.edu | +| 1000 Morewood Ave, Box #3277 | Bitnet: jh5y%andrew.cmu.edu@cmccvb | +| Pittsburgh, PA 15213 | UUCP: uunet!andrew.cmu.edu!jh5y | +| (412) 268-4493 | Prodigy: HXNJ79A | +| | Compuserve: [72510,1143] | +*===============================*===========================================* + + \ No newline at end of file diff --git a/BGI/REGISTER.DOC b/BGI/REGISTER.DOC new file mode 100644 index 0000000..68a3ecf --- /dev/null +++ b/BGI/REGISTER.DOC @@ -0,0 +1,58 @@ +Registration Form + +EMAIL ADDRESS:___________________________________________ + +NAME:____________________________________________________ +ADDRESS:_________________________________________________ + _________________________________________________ + _________________________________________________ +CITY:________________________ STATE:____ ZIP:____________ +COUNTRY:____________ + +PHONE # (Data): ___ ____ ______________ + (Voice): ___ ____ ______________ + +General info: + +Machine type: 8088/6[_] 80286[_] 80386[_] 80486[_] Other[_] +Machine name: ________________________________________ + +Display type: MDA[_] CGA[_] Herc[_] EGA[_] MCGA[_] VGA[_] SVGA[_] +Card name:_____________________________________________ + +Floppy drives: 3« 720k[_] 3« 1.44M[_] 3« 2.88M[_] + 5¬ 360k[_] 5¬ 1.2M [_] + + +Modem speed: 1200[_] 2400[_] 4800[_] 9600[_] 19200[_] Other: ________ +Modem name:_____________________________ + +Other configuration:_________________________________________________ + _________________________________________________ + _________________________________________________ + _________________________________________________ + _________________________________________________ + +Driver type: Svga 256 ____ @ $20 + Svga 16 ____ @ $20 + Tweak 256 ____ @ $20 + Tweak 16 ____ @ $30 + + Two drivers ____ @ $30 (check above) + Four drivers ____ @ $50 + +Do you want a copy of the source? _____ + +From September 1-May 8, please send checks/money to: + Jordan Hargrave + 1000 Morewood Ave, Box #3277 + Pittsburgh, PA 15213 + (412) 268-4493 + +From May 8-September 1, send to: + Jordan Hargrave + 1615 Burnley Road + Charlotte, NC 28210 + (704) 553-2332 + + \ No newline at end of file diff --git a/BGI/SVGA16.BGI b/BGI/SVGA16.BGI new file mode 100644 index 0000000..97ae9f0 Binary files /dev/null and b/BGI/SVGA16.BGI differ diff --git a/BGI/SVGA16.H b/BGI/SVGA16.H new file mode 100644 index 0000000..6fcc1e7 --- /dev/null +++ b/BGI/SVGA16.H @@ -0,0 +1,48 @@ +/************************************************/ +/* */ +/* SuperVGA 16 BGI driver defines */ +/* Copyright (c) 1991 */ +/* Jordan Hargraphix Software */ +/* */ +/************************************************/ + +#include + +typedef unsigned char DacPalette16[16][3]; + +extern int far Svga16_fdriver[]; + +/* These are the currently supported modes */ +#define SVGA320x200x16 0 /* 320x200x16 Standard EGA/VGA */ +#define SVGA640x200x16 1 /* 640x200x16 Standard EGA/VGA */ +#define SVGA640x350x16 2 /* 640x350x16 Standard EGA/VGA */ +#define SVGA640x480x16 3 /* 640x480x16 Standard VGA */ +#define SVGA800x600x16 4 /* 800x600x16 SuperVGA/VESA */ +#define SVGA1024x768x16 5 /* 1024x768x16 SuperVGA/VESA */ + +#ifndef XNOR_PUT +#define XNOR_PUT 5 +#define NAND_PUT 6 +#define NOR_PUT 7 +#endif + +/* Setvgapalette16 sets the entire 16 color palette */ +/* PalBuf contains RGB values for all 16 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette16 dac16; */ +/* */ +/* setvgapalette(&dac16); */ +void setvgapalette16(DacPalette16 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 16; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} + + \ No newline at end of file diff --git a/BGI/SVGA16.INC b/BGI/SVGA16.INC new file mode 100644 index 0000000..44c0dac --- /dev/null +++ b/BGI/SVGA16.INC @@ -0,0 +1,42 @@ +(************************************************) +(* *) +(* SuperVGA 16 BGI driver defines *) +(* Copyright (c) 1991 *) +(* Jordan Hargraphix Software *) +(* *) +(************************************************) + +type DacPalette16 = array[0..15] of array[0..2] of Byte; + +(* These are the currently supported modes *) +const + SVGA320x200x16 = 0; (* 320x200x16 Standard EGA/VGA *) + SVGA640x200x16 = 1; (* 640x200x16 Standard EGA/VGA *) + SVGA640x350x16 = 2; (* 640x350x16 Standard EGA/VGA *) + SVGA640x480x16 = 3; (* 640x480x16 Standard VGA *) + SVGA800x600x16 = 4; (* 800x600x16 SuperVGA/VESA *) + SVGA1024x768x16 = 5; (* 1024x768x16 SuperVGA/VESA *) + + XNOR_PUT = 5; + NAND_PUT = 6; + NOR_PUT = 7; + +(* Setvgapalette sets the entire 16 color palette *) +(* PalBuf contains RGB values for all 16 colors *) +(* R,G,B values range from 0 to 63 *) +procedure SetVGAPalette16(PalBuf : DacPalette16); +var + Reg : Registers; + +begin + reg.ax := $1012; + reg.bx := 0; + reg.cx := 16; + reg.es := Seg(PalBuf); + reg.dx := Ofs(PalBuf); + intr($10,reg); +end; + + + + \ No newline at end of file diff --git a/BGI/SVGA256.BGI b/BGI/SVGA256.BGI new file mode 100644 index 0000000..f74bc72 Binary files /dev/null and b/BGI/SVGA256.BGI differ diff --git a/BGI/SVGA256.H b/BGI/SVGA256.H new file mode 100644 index 0000000..133ca66 --- /dev/null +++ b/BGI/SVGA256.H @@ -0,0 +1,47 @@ +/************************************************/ +/* */ +/* SuperVGA 256 BGI driver defines */ +/* Copyright (c) 1991 */ +/* Jordan Hargraphix Software */ +/* */ +/************************************************/ + +#include + +typedef unsigned char DacPalette256[256][3]; + +extern int far _Cdecl Svga256_fdriver[]; + +/* These are the currently supported modes */ +#define SVGA320x200x256 0 /* 320x200x256 Standard VGA */ +#define SVGA640x400x256 1 /* 640x400x256 Svga/VESA */ +#define SVGA640x480x256 2 /* 640x480x256 Svga/VESA */ +#define SVGA800x600x256 3 /* 800x600x256 Svga/VESA */ +#define SVGA1024x768x256 4 /* 1024x768x256 Svga/VESA */ + +#ifndef XNOR_PUT +#define XNOR_PUT 5 +#define NAND_PUT 6 +#define NOR_PUT 7 +#endif +#define TRANS_COPY_PUT 8 + +/* Setvgapalette256 sets the entire 256 color palette */ +/* PalBuf contains RGB values for all 256 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette256 dac256; */ +/* */ +/* setvgapalette256(&dac256); */ +void setvgapalette256(DacPalette256 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 256; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} + \ No newline at end of file diff --git a/BGI/SVGA256.INC b/BGI/SVGA256.INC new file mode 100644 index 0000000..d07c783 --- /dev/null +++ b/BGI/SVGA256.INC @@ -0,0 +1,38 @@ +(************************************************) +(* *) +(* SuperVGA 256 BGI driver defines *) +(* Copyright (c) 1991 *) +(* Jordan Hargraphix Software *) +(* *) +(************************************************) + +type DacPalette256 = array[0..255] of array[0..2] of Byte; + +(* These are the currently supported modes *) +const + SVGA320x200x256 = 0; (* 320x200x256 Standard VGA *) + SVGA640x400x256 = 1; (* 640x400x256 Svga *) + SVGA640x480x256 = 2; (* 640x480x256 Svga *) + SVGA800x600x256 = 3; (* 800x600x256 Svga *) + SVGA1024x768x256 = 4; (* 1024x768x256 Svga *) + + TRANS_COPY_PIX = 8; + +(* Setvgapalette sets the entire 256 color palette *) +(* PalBuf contains RGB values for all 256 colors *) +(* R,G,B values range from 0 to 63 *) +procedure SetVGAPalette256(PalBuf : DacPalette256); +var + Reg : Registers; + +begin + reg.ax := $1012; + reg.bx := 0; + reg.cx := 256; + reg.es := Seg(PalBuf); + reg.dx := Ofs(PalBuf); + intr($10,reg); +end; + + + \ No newline at end of file diff --git a/BGI/TWK16.BGI b/BGI/TWK16.BGI new file mode 100644 index 0000000..9672964 Binary files /dev/null and b/BGI/TWK16.BGI differ diff --git a/BGI/TWK16.H b/BGI/TWK16.H new file mode 100644 index 0000000..c8b9332 --- /dev/null +++ b/BGI/TWK16.H @@ -0,0 +1,48 @@ +/************************************************/ +/* */ +/* Tweaked 16 BGI driver defines */ +/* Copyright (c) 1991 */ +/* Jordan Hargraphix Software */ +/* */ +/************************************************/ + +#include + +typedef unsigned char DacPalette16[16][3]; + +extern int far Twk16_fdriver[]; + +/* These are the currently supported modes */ +#define TWK704x528x16 0 /* 704x528x16 Tweaked VGA */ +#define TWK720x540x16 1 /* 720x540x16 Tweaked VGA */ +#define TWK736x552x16 2 /* 736x552x16 Tweaked VGA */ +#define TWK752x564x16 3 /* 752x564x16 Tweaked VGA */ +#define TWK784x588x16 4 /* 784x588x16 Tweaked VGA */ +#define TWK800x600x16 5 /* 800x600x16 Tweaked VGA */ + +#ifndef XNOR_PUT +#define XNOR_PUT 5 +#define NAND_PUT 6 +#define NOR_PUT 7 +#endif + +/* Setvgapalette16 sets the entire 16 color palette */ +/* PalBuf contains RGB values for all 16 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette16 dac16; */ +/* */ +/* setvgapalette(&dac16); */ +void setvgapalette16(DacPalette16 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 16; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} + + \ No newline at end of file diff --git a/BGI/TWK16.INC b/BGI/TWK16.INC new file mode 100644 index 0000000..159e85e --- /dev/null +++ b/BGI/TWK16.INC @@ -0,0 +1,39 @@ +(************************************************) +(* *) +(* SuperVGA 16 BGI driver defines *) +(* Copyright (c) 1991 *) +(* Jordan Hargraphix Software *) +(* *) +(************************************************) + +type DacPalette16 = array[0..15] of array[0..2] of Byte; + +(* These are the currently supported modes *) +const + TWK704x528x16 = 0 (* 704x528x16 Tweaked VGA *) + TWK720x540x16 = 1 (* 720x540x16 Tweaked VGA *) + TWK736x552x16 = 2 (* 736x552x16 Tweaked VGA *) + TWK752x564x16 = 3 (* 752x564x16 Tweaked VGA *) + TWK784x588x16 = 4 (* 784x588x16 Tweaked VGA *) + TWK800x600x16 = 5 (* 800x600x16 Tweaked VGA *) + + XNOR_PUT = 5; + NAND_PUT = 6; + NOR_PUT = 7; + +(* Setvgapalette sets the entire 16 color palette *) +(* PalBuf contains RGB values for all 16 colors *) +(* R,G,B values range from 0 to 63 *) +procedure SetVGAPalette16(PalBuf : DacPalette16); +var + Reg : Registers; + +begin + reg.ax := $1012; + reg.bx := 0; + reg.cx := 16; + reg.es := Seg(PalBuf); + reg.dx := Ofs(PalBuf); + intr($10,reg); +end; + \ No newline at end of file diff --git a/BGI/TWK256.BGI b/BGI/TWK256.BGI new file mode 100644 index 0000000..38fdbd0 Binary files /dev/null and b/BGI/TWK256.BGI differ diff --git a/BGI/TWK256.H b/BGI/TWK256.H new file mode 100644 index 0000000..a103a29 --- /dev/null +++ b/BGI/TWK256.H @@ -0,0 +1,48 @@ +/************************************************/ +/* */ +/* Tweaked 256 BGI driver defines */ +/* Copyright (c) 1991 */ +/* Jordan Hargraphix Software */ +/* */ +/************************************************/ + +#include + +typedef unsigned char DacPalette256[256][3]; + +extern int far _Cdecl Twk256_fdriver[]; + +/* These are the currently supported modes */ +#define TWK320x400x256 0 +#define TWK320x480x256 1 +#define TWK360x480x256 2 +#define TWK376x564x256 3 +#define TWK400x564x256 4 +#define TWK400x600x256 5 + +#ifndef XNOR_PUT +#define XNOR_PUT 5 +#define NAND_PUT 6 +#define NOR_PUT 7 +#endif +#define TRANS_COPY_PUT 8 + +/* Setvgapalette256 sets the entire 256 color palette */ +/* PalBuf contains RGB values for all 256 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette256 dac256; */ +/* */ +/* setvgapalette256(&dac256); */ +void setvgapalette256(DacPalette256 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 256; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} + \ No newline at end of file diff --git a/BGI/TWK256.INC b/BGI/TWK256.INC new file mode 100644 index 0000000..d1fb7c6 --- /dev/null +++ b/BGI/TWK256.INC @@ -0,0 +1,39 @@ +(************************************************) +(* *) +(* Tweaked 256 BGI driver defines *) +(* Copyright (c) 1991 *) +(* Jordan Hargraphix Software *) +(* *) +(************************************************) + +type DacPalette256 = array[0..255] of array[0..2] of Byte; + +(* These are the currently supported modes *) +const + TWK320x400x256 = 0; + TWK320x480x256 = 1; + TWK360x480x256 = 2; + TWK376x564x256 = 3; + TWK400x564x256 = 4; + TWK400x600x256 = 5; + + TRANS_COPY_PIX = 8; + +(* Setvgapalette sets the entire 256 color palette *) +(* PalBuf contains RGB values for all 256 colors *) +(* R,G,B values range from 0 to 63 *) +procedure SetVGAPalette256(PalBuf : DacPalette256); +var + Reg : Registers; + +begin + reg.ax := $1012; + reg.bx := 0; + reg.cx := 256; + reg.es := Seg(PalBuf); + reg.dx := Ofs(PalBuf); + intr($10,reg); +end; + + + \ No newline at end of file diff --git a/BGI/VGADEMO.EXE b/BGI/VGADEMO.EXE new file mode 100644 index 0000000..c93dd5b Binary files /dev/null and b/BGI/VGADEMO.EXE differ diff --git a/BGI/VGADEMO.PAS b/BGI/VGADEMO.PAS new file mode 100644 index 0000000..6a5f54d --- /dev/null +++ b/BGI/VGADEMO.PAS @@ -0,0 +1,1608 @@ +program BGIDemo; +{ + + Turbo Pascal Borland Graphics Interface (BGI) demonstration + program. This program shows how to use many features of + the Graph unit. + + Copyright (c) 1985-89 by Borland International, Inc. + +} + +uses + Crt, Dos, Graph; + + +const + { The five fonts available } + Fonts : array[0..4] of string[13] = + ('DefaultFont', 'TriplexFont', 'SmallFont', 'SansSerifFont', 'GothicFont'); + + { The five predefined line styles supported } + LineStyles : array[0..4] of string[9] = + ('SolidLn', 'DottedLn', 'CenterLn', 'DashedLn', 'UserBitLn'); + + { The twelve predefined fill styles supported } + FillStyles : array[0..11] of string[14] = + ('EmptyFill', 'SolidFill', 'LineFill', 'LtSlashFill', 'SlashFill', + 'BkSlashFill', 'LtBkSlashFill', 'HatchFill', 'XHatchFill', + 'InterleaveFill', 'WideDotFill', 'CloseDotFill'); + + { The two text directions available } + TextDirect : array[0..1] of string[8] = ('HorizDir', 'VertDir'); + + { The Horizontal text justifications available } + HorizJust : array[0..2] of string[10] = ('LeftText', 'CenterText', 'RightText'); + + { The vertical text justifications available } + VertJust : array[0..2] of string[10] = ('BottomText', 'CenterText', 'TopText'); + +var + GraphDriver : integer; { The Graphics device driver } + GraphMode : integer; { The Graphics mode value } + MaxX, MaxY : word; { The maximum resolution of the screen } + ErrorCode : integer; { Reports any graphics errors } + MaxColor : word; { The maximum color value available } + OldExitProc : Pointer; { Saves exit procedure address } + +{$F+} +procedure MyExitProc; +begin + ExitProc := OldExitProc; { Restore exit procedure address } + CloseGraph; { Shut down the graphics system } +end; { MyExitProc } +{$F-} + +{$F+} +function DetectVGA256 : integer; +{ Detects VGA or MCGA video cards } +var + DetectedDriver : integer; + SuggestedMode : integer; +begin + DetectGraph(DetectedDriver, SuggestedMode); + if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then + begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 320x200x256'); + Writeln(' 1) 640x400x256'); + Writeln(' 2) 640x480x256'); + Writeln(' 3) 800x600x256'); + Writeln(' 4) 1024x768x256'); + Write('> '); + Readln(SuggestedMode); + DetectVGA256 := SuggestedMode; + end + else + DetectVGA256 := grError; { Couldn't detect hardware } +end; { DetectVGA256 } +{$F-} + +{$F+} +function DetectTwk256 : integer; +{ Detects VGA or MCGA video cards } +var + DetectedDriver : integer; + SuggestedMode : integer; +begin + DetectGraph(DetectedDriver, SuggestedMode); + if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then + begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 320x400x256'); + Writeln(' 1) 320x480x256'); + Writeln(' 2) 360x480x256'); + Writeln(' 3) 376x564x256'); + Writeln(' 4) 400x564x256'); + Writeln(' 5) 400x600x256'); + Write('> '); + Readln(SuggestedMode); + DetectTwk256 := SuggestedMode; + end + else + DetectTwk256 := grError; { Couldn't detect hardware } +end; { DetectVGA256 } +{$F-} + + +{$F+} +function DetectVGA16 : integer; +{ Detects VGA or MCGA video cards } +var + DetectedDriver : integer; + SuggestedMode : integer; +begin + DetectGraph(DetectedDriver, SuggestedMode); + if (DetectedDriver = EGA) or (DetectedDriver = VGA) then + begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 320x200x16'); + Writeln(' 1) 640x200x16'); + Writeln(' 2) 640x350x16'); + Writeln(' 3) 640x480x16'); + Writeln(' 4) 800x600x16'); + Writeln(' 5) 1024x768x16'); + Write('> '); + Readln(SuggestedMode); + DetectVGA16 := SuggestedMode; + end + else + DetectVGA16 := grError; { Couldn't detect hardware } +end; { DetectVGA256 } +{$F-} + +{$F+} +function DetectTwk16 : integer; +{ Detects VGA or MCGA video cards } +var + DetectedDriver : integer; + SuggestedMode : integer; +begin + DetectGraph(DetectedDriver, SuggestedMode); + if (DetectedDriver = VGA) then + begin + Writeln('Which video mode would you like to use?'); + Writeln(' 0) 704x528x16'); + Writeln(' 1) 720x540x16'); + Writeln(' 2) 736x552x16'); + Writeln(' 3) 752x564x16'); + Writeln(' 4) 768x576x16'); + Writeln(' 5) 784x588x16'); + Writeln(' 6) 800x600x16'); + Write('> '); + Readln(SuggestedMode); + DetectTwk16 := SuggestedMode; + end + else + DetectTwk16 := grError; { Couldn't detect hardware } +end; { DetectVGA256 } +{$F-} + +var + AutoDetectPointer : pointer; + +procedure Initialize; +{ Initialize graphics and report any errors that may occur } +var + InGraphicsMode : boolean; { Flags initialization of graphics mode } + PathToDriver : string; { Stores the DOS path to *.BGI & *.CHR } + UseWhichDriver : integer; +begin + { when using Crt and graphics, turn off Crt's memory-mapped writes } + DirectVideo := False; + OldExitProc := ExitProc; { save previous exit proc } + ExitProc := @MyExitProc; { insert our exit proc in chain } + PathToDriver := ''; + repeat + Writeln('Which driver to use?'); + Writeln(' 0) Svga256'); + Writeln(' 1) Svga16'); + Writeln(' 2) Tweak256'); + Writeln(' 3) Tweak16'); + Write('>'); + Readln(UseWhichDriver); + if (UseWhichDriver = 0) then + begin + AutoDetectPointer := @DetectVGA256; + GraphDriver := InstallUserDriver('Svga256',AutoDetectPointer); + end + else if (UseWhichDriver=1) then + begin + AutoDetectPointer := @DetectVGA16; { Point to detection routine } + GraphDriver := InstallUserDriver('SVGA16', AutoDetectPointer); + end + else if (UseWhichDriver=2) then + begin + AutoDetectPointer := @DetectTwk256; + GraphDriver := InstallUserDriver('Twk256',AutoDetectPointer); + end + else if (UseWhichDriver=3) then + begin + AutoDetectPointer := @DetectTwk16; + GraphDriver := InstallUserDriver('Twk16',AutoDetectPointer); + end; + GraphDriver := Detect; + InitGraph(GraphDriver, GraphMode, PathToDriver); + ErrorCode := GraphResult; { preserve error return } + if ErrorCode <> grOK then { error? } + begin + Writeln('Graphics error: ', GraphErrorMsg(ErrorCode)); + if ErrorCode = grFileNotFound then { Can't find driver file } + begin + Writeln('Enter full path to BGI driver or type to quit:'); + Readln(PathToDriver); + Writeln; + end + else + Halt(1); { Some other error: terminate } + end; + until ErrorCode = grOK; + Randomize; { init random number generator } + MaxColor := GetMaxColor; { Get the maximum allowable drawing color } + MaxX := GetMaxX; { Get screen resolution values } + MaxY := GetMaxY; +end; { Initialize } + +function Int2Str(L : LongInt) : string; +{ Converts an integer to a string for use with OutText, OutTextXY } +var + S : string; +begin + Str(L, S); + Int2Str := S; +end; { Int2Str } + +function RandColor : word; +{ Returns a Random non-zero color value that is within the legal + color range for the selected device driver and graphics mode. + MaxColor is set to GetMaxColor by Initialize } +begin + RandColor := Random(MaxColor)+1; +end; { RandColor } + +procedure DefaultColors; +{ Select the maximum color in the Palette for the drawing color } +begin + SetColor(White); +end; { DefaultColors } + +procedure DrawBorder; +{ Draw a border around the current view port } +var + ViewPort : ViewPortType; +begin + DefaultColors; + SetLineStyle(SolidLn, 0, NormWidth); + GetViewSettings(ViewPort); + with ViewPort do + Rectangle(0, 0, x2-x1, y2-y1); +end; { DrawBorder } + +procedure FullPort; +{ Set the view port to the entire screen } +begin + SetViewPort(0, 0, MaxX, MaxY, ClipOn); +end; { FullPort } + +procedure MainWindow(Header : string); +{ Make a default window and view port for demos } +begin + DefaultColors; { Reset the colors } + ClearDevice; { Clear the screen } + SetTextStyle(DefaultFont, HorizDir, 1); { Default text font } + SetTextJustify(CenterText, TopText); { Left justify text } + FullPort; { Full screen view port } + OutTextXY(MaxX div 2, 2, Header); { Draw the header } + { Draw main window } + SetViewPort(0, TextHeight('M')+4, MaxX, MaxY-(TextHeight('M')+4), ClipOn); + DrawBorder; { Put a border around it } + { Move the edges in 1 pixel on all sides so border isn't in the view port } + SetViewPort(1, TextHeight('M')+5, MaxX-1, MaxY-(TextHeight('M')+5), ClipOn); +end; { MainWindow } + +procedure StatusLine(Msg : string); +{ Display a status line at the bottom of the screen } +begin + FullPort; + DefaultColors; + SetTextStyle(DefaultFont, HorizDir, 1); + SetTextJustify(CenterText, TopText); + SetLineStyle(SolidLn, 0, NormWidth); + SetFillStyle(EmptyFill, 0); + Bar(0, MaxY-(TextHeight('M')+4), MaxX, MaxY); { Erase old status line } + Rectangle(0, MaxY-(TextHeight('M')+4), MaxX, MaxY); + OutTextXY(MaxX div 2, MaxY-(TextHeight('M')+2), Msg); + { Go back to the main window } + SetViewPort(1, TextHeight('M')+5, MaxX-1, MaxY-(TextHeight('M')+5), ClipOn); +end; { StatusLine } + +procedure WaitToGo; +{ Wait for the user to abort the program or continue } +const + Esc = #27; +var + Ch : char; +begin + StatusLine('Esc aborts or press a key...'); + repeat until KeyPressed; + Ch := ReadKey; + if Ch = Esc then + Halt(0) { terminate program } + else + ClearDevice; { clear screen, go on with demo } +end; { WaitToGo } + +procedure GetDriverAndMode(var DriveStr, ModeStr : string); +{ Return strings describing the current device driver and graphics mode + for display of status report } +begin + DriveStr := GetDriverName; + ModeStr := GetModeName(GetGraphMode); +end; { GetDriverAndMode } + +procedure ReportStatus; +{ Display the status of all query functions after InitGraph } +const + X = 10; +var + ViewInfo : ViewPortType; { Parameters for inquiry procedures } + LineInfo : LineSettingsType; + FillInfo : FillSettingsType; + TextInfo : TextSettingsType; + Palette : PaletteType; + DriverStr : string; { Driver and mode strings } + ModeStr : string; + Y : word; + +procedure WriteOut(S : string); +{ Write out a string and increment to next line } +begin + OutTextXY(X, Y, S); + Inc(Y, TextHeight('M')+2); +end; { WriteOut } + +begin { ReportStatus } + GetDriverAndMode(DriverStr, ModeStr); { Get current settings } + GetViewSettings(ViewInfo); + GetLineSettings(LineInfo); + GetFillSettings(FillInfo); + GetTextSettings(TextInfo); + GetPalette(Palette); + + Y := 4; + MainWindow('Status report after InitGraph'); + SetTextJustify(LeftText, TopText); + WriteOut('Graphics device : '+DriverStr); + WriteOut('Graphics mode : '+ModeStr); + WriteOut('Screen resolution : (0, 0, '+Int2Str(GetMaxX)+', '+Int2Str(GetMaxY)+')'); + with ViewInfo do + begin + WriteOut('Current view port : ('+Int2Str(x1)+', '+Int2Str(y1)+', '+Int2Str(x2)+', '+Int2Str(y2)+')'); + if ClipOn then + WriteOut('Clipping : ON') + else + WriteOut('Clipping : OFF'); + end; + WriteOut('Current position : ('+Int2Str(GetX)+', '+Int2Str(GetY)+')'); + WriteOut('Palette entries : '+Int2Str(Palette.Size)); + WriteOut('GetMaxColor : '+Int2Str(GetMaxColor)); + WriteOut('Current color : '+Int2Str(GetColor)); + with LineInfo do + begin + WriteOut('Line style : '+LineStyles[LineStyle]); + WriteOut('Line thickness : '+Int2Str(Thickness)); + end; + with FillInfo do + begin + WriteOut('Current fill style : '+FillStyles[Pattern]); + WriteOut('Current fill color : '+Int2Str(Color)); + end; + with TextInfo do + begin + WriteOut('Current font : '+Fonts[Font]); + WriteOut('Text direction : '+TextDirect[Direction]); + WriteOut('Character size : '+Int2Str(CharSize)); + WriteOut('Horizontal justify : '+HorizJust[Horiz]); + WriteOut('Vertical justify : '+VertJust[Vert]); + end; + WaitToGo; +end; { ReportStatus } + +procedure FillEllipsePlay; +{ Random filled ellipse demonstration } +const + MaxFillStyles = 12; { patterns 0..11 } +var + MaxRadius : word; + FillColor : integer; +begin + MainWindow('FillEllipse demonstration'); + StatusLine('Esc aborts or press a key'); + MaxRadius := MaxY div 10; + SetLineStyle(SolidLn, 0, NormWidth); + repeat + FillColor := RandColor; + SetColor(FillColor); + SetFillStyle(Random(MaxFillStyles), FillColor); + FillEllipse(Random(MaxX), Random(MaxY), + Random(MaxRadius), Random(MaxRadius)); + until KeyPressed; + WaitToGo; +end; { FillEllipsePlay } + +procedure SectorPlay; +{ Draw random sectors on the screen } +const + MaxFillStyles = 12; { patterns 0..11 } +var + MaxRadius : word; + FillColor : integer; + EndAngle : integer; +begin + MainWindow('Sector demonstration'); + StatusLine('Esc aborts or press a key'); + MaxRadius := MaxY div 10; + SetLineStyle(SolidLn, 0, NormWidth); + repeat + FillColor := RandColor; + SetColor(FillColor); + SetFillStyle(Random(MaxFillStyles), FillColor); + EndAngle := Random(360); + Sector(Random(MaxX), Random(MaxY), Random(EndAngle), EndAngle, + Random(MaxRadius), Random(MaxRadius)); + until KeyPressed; + WaitToGo; +end; { SectorPlay } + +procedure WriteModePlay; +{ Demonstrate the SetWriteMode procedure for XOR lines } +const + DelayValue = 50; { milliseconds to delay } +var + ViewInfo : ViewPortType; + Color : word; + Left, Top : integer; + Right, Bottom : integer; + Step : integer; { step for rectangle shrinking } +begin + MainWindow('SetWriteMode demonstration'); + StatusLine('Esc aborts or press a key'); + GetViewSettings(ViewInfo); + Left := 0; + Top := 0; + with ViewInfo do + begin + Right := x2-x1; + Bottom := y2-y1; + end; + Step := Bottom div 50; + SetColor(White); + Line(Left, Top, Right, Bottom); + Line(Left, Bottom, Right, Top); + SetWriteMode(XORPut); { Set XOR write mode } + repeat + Line(Left, Top, Right, Bottom); { Draw XOR lines } + Line(Left, Bottom, Right, Top); + Rectangle(Left, Top, Right, Bottom); { Draw XOR rectangle } + Delay(DelayValue); { Wait } + Line(Left, Top, Right, Bottom); { Erase lines } + Line(Left, Bottom, Right, Top); + Rectangle(Left, Top, Right, Bottom); { Erase rectangle } + if (Left+Step < Right) and (Top+Step < Bottom) then + begin + Inc(Left, Step); { Shrink rectangle } + Inc(Top, Step); + Dec(Right, Step); + Dec(Bottom, Step); + end + else + begin + Color := RandColor; { New color } + SetColor(Color); + Left := 0; { Original large rectangle } + Top := 0; + with ViewInfo do + begin + Right := x2-x1; + Bottom := y2-y1; + end; + end; + until KeyPressed; + SetWriteMode(CopyPut); { back to overwrite mode } + WaitToGo; +end; { WriteModePlay } + +procedure AspectRatioPlay; +{ Demonstrate SetAspectRatio command } +var + ViewInfo : ViewPortType; + CenterX : integer; + CenterY : integer; + Radius : word; + Xasp, Yasp : word; + i : integer; + RadiusStep : word; +begin + MainWindow('SetAspectRatio demonstration'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + CenterX := (x2-x1) div 2; + CenterY := (y2-y1) div 2; + Radius := 3*((y2-y1) div 5); + end; + RadiusStep := (Radius div 30); + Circle(CenterX, CenterY, Radius); + GetAspectRatio(Xasp, Yasp); + for i := 1 to 30 do + begin + SetAspectRatio(Xasp, Yasp+(I*GetMaxX)); { Increase Y aspect factor } + Circle(CenterX, CenterY, Radius); + Dec(Radius, RadiusStep); { Shrink radius } + end; + Inc(Radius, RadiusStep*30); + for i := 1 to 30 do + begin + SetAspectRatio(Xasp+(I*GetMaxX), Yasp); { Increase X aspect factor } + if Radius > RadiusStep then + Dec(Radius, RadiusStep); { Shrink radius } + Circle(CenterX, CenterY, Radius); + end; + SetAspectRatio(Xasp, Yasp); { back to original aspect } + WaitToGo; +end; { AspectRatioPlay } + +procedure TextPlay; +{ Demonstrate text justifications and text sizing } +var + Size : word; + W, H, X, Y : word; + ViewInfo : ViewPortType; +begin + MainWindow('SetTextJustify / SetUserCharSize demo'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + SetTextStyle(TriplexFont, VertDir, 4); + Y := (y2-y1) - 2; + SetTextJustify(CenterText, BottomText); + OutTextXY(2*TextWidth('M'), Y, 'Vertical'); + SetTextStyle(TriplexFont, HorizDir, 4); + SetTextJustify(LeftText, TopText); + OutTextXY(2*TextWidth('M'), 2, 'Horizontal'); + SetTextJustify(CenterText, CenterText); + X := (x2-x1) div 2; + Y := TextHeight('H'); + for Size := 1 to 4 do + begin + SetTextStyle(TriplexFont, HorizDir, Size); + H := TextHeight('M'); + W := TextWidth('M'); + Inc(Y, H); + OutTextXY(X, Y, 'Size '+Int2Str(Size)); + end; + Inc(Y, H div 2); + SetTextJustify(CenterText, TopText); + SetUserCharSize(5, 6, 3, 2); + SetTextStyle(TriplexFont, HorizDir, UserCharSize); + OutTextXY((x2-x1) div 2, Y, 'User defined size!'); + end; + WaitToGo; +end; { TextPlay } + +procedure TextDump; +{ Dump the complete character sets to the screen } +const + CGASizes : array[0..4] of word = (1, 3, 7, 3, 3); + NormSizes : array[0..4] of word = (1, 4, 7, 4, 4); +var + Font : word; + ViewInfo : ViewPortType; + Ch : char; +begin + for Font := 0 to 4 do + begin + MainWindow(Fonts[Font]+' character set'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + SetTextJustify(LeftText, TopText); + MoveTo(2, 3); + if Font = DefaultFont then + begin + SetTextStyle(Font, HorizDir, 1); + Ch := #0; + repeat + OutText(Ch); + if (GetX + TextWidth('M')) > (x2-x1) then + MoveTo(2, GetY + TextHeight('M')+3); + Ch := Succ(Ch); + until (Ch >= #255); + end + else + begin + if MaxY < 200 then + SetTextStyle(Font, HorizDir, CGASizes[Font]) + else + SetTextStyle(Font, HorizDir, NormSizes[Font]); + Ch := '!'; + repeat + OutText(Ch); + if (GetX + TextWidth('M')) > (x2-x1) then + MoveTo(2, GetY + TextHeight('M')+3); + Ch := Succ(Ch); + until (Ord(Ch) = Ord('~')+1); + end; + end; { with } + WaitToGo; + end; { for loop } +end; { TextDump } + +procedure LineToPlay; +{ Demonstrate MoveTo and LineTo commands } +const + MaxPoints = 15; +var + Points : array[0..MaxPoints] of PointType; + ViewInfo : ViewPortType; + I, J : integer; + CenterX : integer; { The center point of the circle } + CenterY : integer; + Radius : word; + StepAngle : word; + Xasp, Yasp : word; + Radians : real; + +function AdjAsp(Value : integer) : integer; +{ Adjust a value for the aspect ratio of the device } +begin + AdjAsp := (LongInt(Value) * Xasp) div Yasp; +end; { AdjAsp } + +begin + MainWindow('MoveTo, LineTo demonstration'); + GetAspectRatio(Xasp, Yasp); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + CenterX := (x2-x1) div 2; + CenterY := (y2-y1) div 2; + Radius := CenterY; + while (CenterY+AdjAsp(Radius)) < (y2-y1)-20 do + Inc(Radius); + end; + StepAngle := 360 div MaxPoints; + for I := 0 to MaxPoints - 1 do + begin + Radians := (StepAngle * I) * Pi / 180; + Points[I].X := CenterX + round(Cos(Radians) * Radius); + Points[I].Y := CenterY - AdjAsp(round(Sin(Radians) * Radius)); + end; + Circle(CenterX, CenterY, Radius); + for I := 0 to MaxPoints - 1 do + begin + for J := I to MaxPoints - 1 do + begin + MoveTo(Points[I].X, Points[I].Y); + LineTo(Points[J].X, Points[J].Y); + end; + end; + WaitToGo; +end; { LineToPlay } + +procedure LineRelPlay; +{ Demonstrate MoveRel and LineRel commands } +const + MaxPoints = 12; +var + Poly : array[1..MaxPoints] of PointType; { Stores a polygon for filling } + CurrPort : ViewPortType; + +procedure DrawTesseract; +{ Draw a Tesseract on the screen with relative move and + line drawing commands, also create a polygon for filling } +const + CheckerBoard : FillPatternType = (0, $10, $28, $44, $28, $10, 0, 0); +var + X, Y, W, H : integer; + +begin + GetViewSettings(CurrPort); + with CurrPort do + begin + W := (x2-x1) div 9; + H := (y2-y1) div 8; + X := ((x2-x1) div 2) - round(2.5 * W); + Y := ((y2-y1) div 2) - (3 * H); + + { Border around viewport is outer part of polygon } + Poly[1].X := 0; Poly[1].Y := 0; + Poly[2].X := x2-x1; Poly[2].Y := 0; + Poly[3].X := x2-x1; Poly[3].Y := y2-y1; + Poly[4].X := 0; Poly[4].Y := y2-y1; + Poly[5].X := 0; Poly[5].Y := 0; + MoveTo(X, Y); + + { Grab the whole in the polygon as we draw } + MoveRel(0, H); Poly[6].X := GetX; Poly[6].Y := GetY; + MoveRel(W, -H); Poly[7].X := GetX; Poly[7].Y := GetY; + MoveRel(4*W, 0); Poly[8].X := GetX; Poly[8].Y := GetY; + MoveRel(0, 5*H); Poly[9].X := GetX; Poly[9].Y := GetY; + MoveRel(-W, H); Poly[10].X := GetX; Poly[10].Y := GetY; + MoveRel(-4*W, 0); Poly[11].X := GetX; Poly[11].Y := GetY; + MoveRel(0, -5*H); Poly[12].X := GetX; Poly[12].Y := GetY; + + { Fill the polygon with a user defined fill pattern } + SetFillPattern(CheckerBoard, Green); + FillPoly(12, Poly); + + MoveRel(W, -H); + LineRel(0, 5*H); LineRel(2*W, 0); LineRel(0, -3*H); + LineRel(W, -H); LineRel(0, 5*H); MoveRel(0, -5*H); + LineRel(-2*W, 0); LineRel(0, 3*H); LineRel(-W, H); + MoveRel(W, -H); LineRel(W, 0); MoveRel(0, -2*H); + LineRel(-W, 0); + + { Flood fill the center } + FloodFill((x2-x1) div 2, (y2-y1) div 2,15); + end; +end; { DrawTesseract } + +begin + MainWindow('LineRel / MoveRel demonstration'); + GetViewSettings(CurrPort); + with CurrPort do + { Move the viewport out 1 pixel from each end } + SetViewPort(x1-1, y1-1, x2+1, y2+1, ClipOn); + DrawTesseract; + WaitToGo; +end; { LineRelPlay } + +procedure PiePlay; +{ Demonstrate PieSlice and GetAspectRatio commands } +var + ViewInfo : ViewPortType; + CenterX : integer; + CenterY : integer; + Radius : word; + Xasp, Yasp : word; + X, Y : integer; + +function AdjAsp(Value : integer) : integer; +{ Adjust a value for the aspect ratio of the device } +begin + AdjAsp := (LongInt(Value) * Xasp) div Yasp; +end; { AdjAsp } + +procedure GetTextCoords(AngleInDegrees, Radius : word; var X, Y : integer); +{ Get the coordinates of text for pie slice labels } +var + Radians : real; +begin + Radians := AngleInDegrees * Pi / 180; + X := round(Cos(Radians) * Radius); + Y := round(Sin(Radians) * Radius); +end; { GetTextCoords } + +begin + MainWindow('PieSlice / GetAspectRatio demonstration'); + GetAspectRatio(Xasp, Yasp); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + CenterX := (x2-x1) div 2; + CenterY := ((y2-y1) div 2) + 20; + Radius := (y2-y1) div 3; + while AdjAsp(Radius) < round((y2-y1) / 3.6) do + Inc(Radius); + end; + SetTextStyle(TriplexFont, HorizDir, 4); + SetTextJustify(CenterText, TopText); + OutTextXY(CenterX, 0, 'This is a pie chart!'); + + SetTextStyle(TriplexFont, HorizDir, 3); + + SetFillStyle(SolidFill, RandColor); + PieSlice(CenterX+10, CenterY-AdjAsp(10), 0, 90, Radius); + GetTextCoords(45, Radius, X, Y); + SetTextJustify(LeftText, BottomText); + OutTextXY(CenterX+10+X+TextWidth('H'), CenterY-AdjAsp(10+Y), '25 %'); + + SetFillStyle(HatchFill, RandColor); + PieSlice(CenterX, CenterY, 225, 360, Radius); + GetTextCoords(293, Radius, X, Y); + SetTextJustify(LeftText, TopText); + OutTextXY(CenterX+X+TextWidth('H'), CenterY-AdjAsp(Y), '37.5 %'); + + SetFillStyle(InterleaveFill, RandColor); + PieSlice(CenterX-10, CenterY, 135, 225, Radius); + GetTextCoords(180, Radius, X, Y); + SetTextJustify(RightText, CenterText); + OutTextXY(CenterX-10+X-TextWidth('H'), CenterY-AdjAsp(Y), '25 %'); + + SetFillStyle(WideDotFill, RandColor); + PieSlice(CenterX, CenterY, 90, 135, Radius); + GetTextCoords(112, Radius, X, Y); + SetTextJustify(RightText, BottomText); + OutTextXY(CenterX+X-TextWidth('H'), CenterY-AdjAsp(Y), '12.5 %'); + + WaitToGo; +end; { PiePlay } + +procedure Bar3DPlay; +{ Demonstrate Bar3D command } +const + NumBars = 7; { The number of bars drawn } + BarHeight : array[1..NumBars] of byte = (1, 3, 2, 5, 4, 2, 1); + YTicks = 5; { The number of tick marks on the Y axis } +var + ViewInfo : ViewPortType; + H : word; + XStep : real; + YStep : real; + I, J : integer; + Depth : word; + Color : word; +begin + MainWindow('Bar3D / Rectangle demonstration'); + H := 3*TextHeight('M'); + GetViewSettings(ViewInfo); + SetTextJustify(CenterText, TopText); + SetTextStyle(TriplexFont, HorizDir, 4); + OutTextXY(MaxX div 2, 6, 'These are 3D bars !'); + SetTextStyle(DefaultFont, HorizDir, 1); + with ViewInfo do + SetViewPort(x1+50, y1+40, x2-50, y2-10, ClipOn); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Line(H, H, H, (y2-y1)-H); + Line(H, (y2-y1)-H, (x2-x1)-H, (y2-y1)-H); + YStep := ((y2-y1)-(2*H)) / YTicks; + XStep := ((x2-x1)-(2*H)) / NumBars; + J := (y2-y1)-H; + SetTextJustify(CenterText, CenterText); + + { Draw the Y axis and ticks marks } + for I := 0 to Yticks do + begin + Line(H div 2, J, H, J); + OutTextXY(0, J, Int2Str(I)); + J := Round(J-Ystep); + end; + + + Depth := trunc(0.25 * XStep); { Calculate depth of bar } + + { Draw X axis, bars, and tick marks } + SetTextJustify(CenterText, TopText); + J := H; + for I := 1 to Succ(NumBars) do + begin + SetColor(White); + Line(J, (y2-y1)-H, J, (y2-y1-3)-(H div 2)); + OutTextXY(J, (y2-y1)-(H div 2), Int2Str(I-1)); + if I <> Succ(NumBars) then + begin + Color := RandColor; + SetFillStyle(I, Color); + SetColor(Color); + Bar3D(J, round((y2-y1-H)-(BarHeight[I] * Ystep)), + round(J+Xstep-Depth), round((y2-y1)-H-1), Depth, TopOn); + J := Round(J+Xstep); + end; + end; + + end; + WaitToGo; +end; { Bar3DPlay } + +procedure SolidBarPlay; +{ Draw random solid bars on the screen } +var + MaxWidth : integer; + MaxHeight : integer; + ViewInfo : ViewPortType; + Color : word; +begin + MainWindow('Random Solid Bars'); + StatusLine('Esc aborts or press a key'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + MaxWidth := x2-x1; + MaxHeight := y2-y1; + end; + repeat + Color := Random(256); { RandColor } + SetColor(Color); + SetFillStyle(SolidFill, Color); + Bar3D(Random(MaxWidth), Random(MaxHeight), + Random(MaxWidth), Random(MaxHeight), 0, TopOff); + until KeyPressed; + WaitToGo; +end; { SolidBarPlay } + +procedure BarPlay; +{ Demonstrate Bar command } +const + NumBars = 5; + BarHeight : array[1..NumBars] of byte = (1, 3, 5, 2, 4); + Styles : array[1..NumBars] of byte = (1, 3, 10, 5, 9); +var + ViewInfo : ViewPortType; + BarNum : word; + H : word; + XStep : real; + YStep : real; + I, J : integer; + Color : word; +begin + MainWindow('Bar / Rectangle demonstration'); + H := 3*TextHeight('M'); + GetViewSettings(ViewInfo); + SetTextJustify(CenterText, TopText); + SetTextStyle(TriplexFont, HorizDir, 4); + OutTextXY(MaxX div 2, 6, 'These are 2D bars !'); + SetTextStyle(DefaultFont, HorizDir, 1); + with ViewInfo do + SetViewPort(x1+50, y1+30, x2-50, y2-10, ClipOn); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Line(H, H, H, (y2-y1)-H); + Line(H, (y2-y1)-H, (x2-x1)-H, (y2-y1)-H); + YStep := ((y2-y1)-(2*H)) / NumBars; + XStep := ((x2-x1)-(2*H)) / NumBars; + J := (y2-y1)-H; + SetTextJustify(CenterText, CenterText); + + { Draw Y axis with tick marks } + for I := 0 to NumBars do + begin + Line(H div 2, J, H, J); + OutTextXY(0, J, Int2Str(i)); + J := Round(J-Ystep); + end; + + { Draw X axis, bars, and tick marks } + J := H; + SetTextJustify(CenterText, TopText); + for I := 1 to Succ(NumBars) do + begin + SetColor(White); + Line(J, (y2-y1)-H, J, (y2-y1-3)-(H div 2)); + OutTextXY(J, (y2-y1)-(H div 2), Int2Str(I)); + if I <> Succ(NumBars) then + begin + Color := RandColor; + SetFillStyle(Styles[I], Color); + SetColor(Color); + Bar(J, round((y2-y1-H)-(BarHeight[I] * Ystep)), round(J+Xstep), (y2-y1)-H-1); + Rectangle(J, round((y2-y1-H)-(BarHeight[I] * Ystep)), round(J+Xstep), (y2-y1)-H-1); + end; + J := Round(J+Xstep); + end; + + end; + WaitToGo; +end; { BarPlay } + +procedure CirclePlay; +{ Draw random circles on the screen } +var + MaxRadius : word; +begin + MainWindow('Circle demonstration'); + StatusLine('Esc aborts or press a key'); + MaxRadius := MaxY div 10; + SetLineStyle(SolidLn, 0, NormWidth); + repeat + SetColor(RandColor); + Circle(Random(MaxX), Random(MaxY), Random(MaxRadius)); + until KeyPressed; + WaitToGo; +end; { CirclePlay } + + +procedure RandBarPlay; +{ Draw random bars on the screen } +var + MaxWidth : integer; + MaxHeight : integer; + ViewInfo : ViewPortType; + Color : word; +begin + MainWindow('Random Bars'); + StatusLine('Esc aborts or press a key'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + MaxWidth := x2-x1; + MaxHeight := y2-y1; + end; + repeat + Color := RandColor; + SetColor(Color); + SetFillStyle(Random(CloseDotFill)+1, Color); + Bar3D(Random(MaxWidth), Random(MaxHeight), + Random(MaxWidth), Random(MaxHeight), 0, TopOff); + until KeyPressed; + WaitToGo; +end; { RandBarPlay } + +procedure ArcPlay; +{ Draw random arcs on the screen } +var + MaxRadius : word; + EndAngle : word; + ArcInfo : ArcCoordsType; +begin + MainWindow('Arc / GetArcCoords demonstration'); + StatusLine('Esc aborts or press a key'); + MaxRadius := MaxY div 10; + repeat + SetColor(RandColor); + EndAngle := Random(360); + SetLineStyle(SolidLn, 0, NormWidth); + Arc(Random(MaxX), Random(MaxY), Random(EndAngle), EndAngle, Random(MaxRadius)); + GetArcCoords(ArcInfo); + with ArcInfo do + begin + Line(X, Y, XStart, YStart); + Line(X, Y, Xend, Yend); + end; + until KeyPressed; + WaitToGo; +end; { ArcPlay } + +procedure PutPixelPlay; +{ Demonstrate the PutPixel and GetPixel commands } +const + Seed = 1962; { A seed for the random number generator } + NumPts = 2000; { The number of pixels plotted } + Esc = #27; +var + I : word; + X, Y, Color : word; + XMax, YMax : integer; + ViewInfo : ViewPortType; +begin + MainWindow('PutPixel / GetPixel demonstration'); + StatusLine('Esc aborts or press a key...'); + + GetViewSettings(ViewInfo); + with ViewInfo do + begin + XMax := (x2-x1-1); + YMax := (y2-y1-1); + end; + + while not KeyPressed do + begin + { Plot random pixels } + RandSeed := Seed; + I := 0; + while (not KeyPressed) and (I < NumPts) do + begin + Inc(I); + PutPixel(Random(XMax)+1, Random(YMax)+1, RandColor); + end; + + { Erase pixels } + RandSeed := Seed; + I := 0; + while (not KeyPressed) and (I < NumPts) do + begin + Inc(I); + X := Random(XMax)+1; + Y := Random(YMax)+1; + Color := GetPixel(X, Y); + if Color = RandColor then + PutPixel(X, Y, 0); + end; + end; + WaitToGo; +end; { PutPixelPlay } + +procedure PutImagePlay; +{ Demonstrate the GetImage and PutImage commands } + +const + r = 20; + StartX = 100; + StartY = 150; + +var + CurPort : ViewPortType; + +procedure MoveSaucer(var X, Y : integer; Width, Height : integer); +var + Step : integer; +begin + Step := Random(2*r); + if Odd(Step) then + Step := -Step; + X := X + Step; + Step := Random(r); + if Odd(Step) then + Step := -Step; + Y := Y + Step; + + { Make saucer bounce off viewport walls } + with CurPort do + begin + if (x1 + X + Width - 1 > x2) then + X := x2-x1 - Width + 1 + else + if (X < 0) then + X := 0; + if (y1 + Y + Height - 1 > y2) then + Y := y2-y1 - Height + 1 + else + if (Y < 0) then + Y := 0; + end; +end; { MoveSaucer } + +var + Pausetime : word; + Saucer : pointer; + X, Y : integer; + ulx, uly : word; + lrx, lry : word; + Size : word; + I : word; +begin + ClearDevice; + FullPort; + + { PaintScreen } + ClearDevice; + MainWindow('GetImage / PutImage Demonstration'); + StatusLine('Esc aborts or press a key...'); + GetViewSettings(CurPort); + + { DrawSaucer } + Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2); + Ellipse(StartX, StartY-4, 190, 357, r, r div 3); + Line(StartX+7, StartY-6, StartX+10, StartY-12); + Circle(StartX+10, StartY-12, 2); + Line(StartX-7, StartY-6, StartX-10, StartY-12); + Circle(StartX-10, StartY-12, 2); + SetFillStyle(SolidFill, 1); + FloodFill(StartX+1, StartY+4, GetColor); + + { ReadSaucerImage } + ulx := StartX-(r+1); + uly := StartY-14; + lrx := StartX+(r+1); + lry := StartY+(r div 3)+3; + + Size := ImageSize(ulx, uly, lrx, lry); + GetMem(Saucer, Size); + GetImage(ulx, uly, lrx, lry, Saucer^); + PutImage(ulx, uly, Saucer^, XORput); { erase image } + { Plot some "stars" } + for I := 1 to 1000 do + PutPixel(Random(MaxX), Random(MaxY), RandColor); + X := MaxX div 2; + Y := MaxY div 2; + PauseTime := 70; + + { Move the saucer around } + repeat + X := (X div 8)*8; + PutImage(X, Y, Saucer^, XORput); { draw image } + Delay(PauseTime); + PutImage(X, Y, Saucer^, XORput); { erase image } + MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1); { width/height } + until KeyPressed; + FreeMem(Saucer, size); + WaitToGo; +end; { PutImagePlay } + +procedure PolyPlay; +{ Draw random polygons with random fill styles on the screen } +const + MaxPts = 5; +type + PolygonType = array[1..MaxPts] of PointType; +var + Poly : PolygonType; + I, Color : word; +begin + MainWindow('FillPoly demonstration'); + StatusLine('Esc aborts or press a key...'); + repeat + Color := RandColor; + SetFillStyle(Random(11)+1, Color); + SetColor(Color); + for I := 1 to MaxPts do + with Poly[I] do + begin + X := Random(MaxX); + Y := Random(MaxY); + end; + FillPoly(MaxPts, Poly); + until KeyPressed; + WaitToGo; +end; { PolyPlay } + +procedure FillStylePlay; +{ Display all of the predefined fill styles available } +var + Style : word; + Width : word; + Height : word; + X, Y : word; + I, J : word; + ViewInfo : ViewPortType; + +procedure DrawBox(X, Y : word); +begin + SetFillStyle(Style, White); + with ViewInfo do + Bar(X, Y, X+Width, Y+Height); + Rectangle(X, Y, X+Width, Y+Height); + OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style)); + Inc(Style); +end; { DrawBox } + +begin + MainWindow('Pre-defined fill styles'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Width := 2 * ((x2+1) div 13); + Height := 2 * ((y2-10) div 10); + end; + X := Width div 2; + Y := Height div 2; + Style := 0; + for J := 1 to 3 do + begin + for I := 1 to 4 do + begin + DrawBox(X, Y); + Inc(X, (Width div 2) * 3); + end; + X := Width div 2; + Inc(Y, (Height div 2) * 3); + end; + SetTextJustify(LeftText, TopText); + WaitToGo; +end; { FillStylePlay } + +procedure FillPatternPlay; +{ Display some user defined fill patterns } +const + Patterns : array[0..11] of FillPatternType = ( + ($AA, $55, $AA, $55, $AA, $55, $AA, $55), + ($33, $33, $CC, $CC, $33, $33, $CC, $CC), + ($F0, $F0, $F0, $F0, $F, $F, $F, $F), + (0, $10, $28, $44, $28, $10, 0, 0), + (0, $70, $20, $27, $25, $27, $4, $4), + (0, 0, 0, $18, $18, 0, 0, 0), + (0, 0, $3C, $3C, $3C, $3C, 0, 0), + (0, $7E, $7E, $7E, $7E, $7E, $7E, 0), + (0, 0, $22, $8, 0, $22, $1C, 0), + ($FF, $7E, $3C, $18, $18, $3C, $7E, $FF), + (0, $10, $10, $7C, $10, $10, 0, 0), + (0, $42, $24, $18, $18, $24, $42, 0)); +var + Style : word; + Width : word; + Height : word; + X, Y : word; + I, J : word; + ViewInfo : ViewPortType; + +procedure DrawBox(X, Y : word); +begin + SetFillPattern(Patterns[Style], White); + with ViewInfo do + Bar(X, Y, X+Width, Y+Height); + Rectangle(X, Y, X+Width, Y+Height); + Inc(Style); +end; { DrawBox } + +begin + MainWindow('User defined fill styles'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Width := 2 * ((x2+1) div 13); + Height := 2 * ((y2-10) div 10); + end; + X := Width div 2; + Y := Height div 2; + Style := 0; + for J := 1 to 3 do + begin + for I := 1 to 4 do + begin + DrawBox(X, Y); + Inc(X, (Width div 2) * 3); + end; + X := Width div 2; + Inc(Y, (Height div 2) * 3); + end; + SetTextJustify(LeftText, TopText); + WaitToGo; +end; { FillPatternPlay } + +procedure ColorPlay; +{ Display all of the colors available for the current driver and mode } +var + Color : word; + Width : word; + Height : word; + X, Y : word; + I, J : word; + ViewInfo : ViewPortType; + +procedure DrawBox(X, Y : word); +begin + SetFillStyle(SolidFill, Color); + SetColor(Color); + with ViewInfo do + Bar(X, Y, X+Width, Y+Height); + Rectangle(X, Y, X+Width, Y+Height); + Color := GetColor; + if Color = 0 then + begin + SetColor(White); + Rectangle(X, Y, X+Width, Y+Height); + end; + Color := Succ(Color); +end; { DrawBox } + +begin + MainWindow('256 Color demonstration'); + Color := 0; + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Width := 2 * ((x2-x1+1) div 46); + Height := 2 * ((y2-x1+1) div 47); + end; + X := Width div 3; + Y := Height div 3; + for J := 1 to 16 do + begin + for I := 1 to 16 do + begin + DrawBox(X, Y); + Inc(X, (Width div 2) * 3); + end; + X := Width div 3; + Inc(Y, (Height div 2) * 3); + end; + WaitToGo; +end; { ColorPlay } + +procedure PalettePlay; +{ Demonstrate the use of the SetRGBPalette command } +const + XBars = 15; + YBars = 10; +type + RGBColor = record + R, G, B : byte; + end; + VGAPalette = array[0..255] of RGBColor; + +var + I, J : word; + X, Y : word; + Color : word; + ViewInfo : ViewPortType; + Width : word; + Height : word; + VGAPal : VGAPalette; + Rand : integer; + +procedure ReadDACBlock(Start, Count : integer; var Pal : VGAPalette); +var + Regs : Registers; +begin + with Regs do + begin + AH := $10; + AL := $17; + BX := Start; + CX := Count; + ES := Seg(Pal); + DX := Ofs(Pal); + end; + Intr($10, Regs); +end; + +procedure SetDACBlock(Start, Count : integer; var Pal : VGAPalette); +var + Regs : Registers; +begin + with Regs do + begin + AH := $10; + AL := $12; + BX := Start; + CX := Count; + ES := Seg(Pal); + DX := Ofs(Pal); + end; + Intr($10, Regs); +end; + +begin + ReadDACBlock(0, 256, VGAPal); + MainWindow('SetRGBPalette demonstration'); + StatusLine('Press any key...'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + Width := (x2-x1) div XBars; + Height := (y2-y1) div YBars; + end; + X := 0; Y := 0; + Color := 0; + for J := 1 to YBars do + begin + for I := 1 to XBars do + begin + SetFillStyle(SolidFill, Color); + Bar(X, Y, X+Width, Y+Height); + Inc(X, Width+1); + Inc(Color); + Color := Color mod 16; + end; + X := 0; + Inc(Y, Height+1); + end; + repeat + {SetPalette(Random(16), VGAPal[Random(256)]);} + with VGAPal[Random(16)] do + SetRGBPalette(Random(16), R, G, B); + until KeyPressed; + SetDACBlock(0, 256, VGAPal); + WaitToGo; +end; { PalettePlay } + +procedure CrtModePlay; +{ Demonstrate the use of RestoreCrtMode and SetGraphMode } +var + ViewInfo : ViewPortType; + Ch : char; +begin + MainWindow('SetGraphMode / RestoreCrtMode demo'); + GetViewSettings(ViewInfo); + SetTextJustify(CenterText, CenterText); + with ViewInfo do + begin + OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'Now you are in graphics mode'); + StatusLine('Press any key for text mode...'); + repeat until KeyPressed; + Ch := ReadKey; + RestoreCrtmode; + Writeln('Now you are in text mode.'); + Write('Press any key to go back to graphics...'); + repeat until KeyPressed; + Ch := ReadKey; + SetGraphMode(GetGraphMode); + MainWindow('SetGraphMode / RestoreCrtMode demo'); + SetTextJustify(CenterText, CenterText); + OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'Back in graphics mode...'); + end; + WaitToGo; +end; { CrtModePlay } + +procedure LineStylePlay; +{ Demonstrate the predefined line styles available } +var + Style : word; + Step : word; + X, Y : word; + ViewInfo : ViewPortType; + +begin + ClearDevice; + DefaultColors; + MainWindow('Pre-defined line styles'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + X := 35; + Y := 10; + Step := (x2-x1) div 11; + SetTextJustify(LeftText, TopText); + OutTextXY(X, Y, 'NormWidth'); + SetTextJustify(CenterText, TopText); + for Style := 0 to 3 do + begin + SetLineStyle(Style, 0, NormWidth); + Line(X, Y+20, X, Y2-40); + OutTextXY(X, Y2-30, Int2Str(Style)); + Inc(X, Step); + end; + Inc(X, 2*Step); + SetTextJustify(LeftText, TopText); + OutTextXY(X, Y, 'ThickWidth'); + SetTextJustify(CenterText, TopText); + for Style := 0 to 3 do + begin + SetLineStyle(Style, 0, ThickWidth); + Line(X, Y+20, X, Y2-40); + OutTextXY(X, Y2-30, Int2Str(Style)); + Inc(X, Step); + end; + end; + SetTextJustify(LeftText, TopText); + WaitToGo; +end; { LineStylePlay } + +procedure UserLineStylePlay; +{ Demonstrate user defined line styles } +var + Style : word; + X, Y, I : word; + ViewInfo : ViewPortType; +begin + MainWindow('User defined line styles'); + GetViewSettings(ViewInfo); + with ViewInfo do + begin + X := 4; + Y := 10; + Style := 0; + I := 0; + while X < X2-4 do + begin + {$B+} + Style := Style or (1 shl (I mod 16)); + {$B-} + SetLineStyle(UserBitLn, Style, NormWidth); + Line(X, Y, X, (y2-y1)-Y); + Inc(X, 5); + Inc(I); + if Style = 65535 then + begin + I := 0; + Style := 0; + end; + end; + end; + WaitToGo; +end; { UserLineStylePlay } + + +procedure SayGoodbye; +{ Say goodbye and then exit the program } +var + ViewInfo : ViewPortType; +begin + MainWindow(''); + GetViewSettings(ViewInfo); + SetTextStyle(TriplexFont, HorizDir, 4); + SetTextJustify(CenterText, CenterText); + with ViewInfo do + OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'That''s all folks!'); + StatusLine('Press any key to quit...'); + repeat until KeyPressed; +end; { SayGoodbye } + +begin { program body } + ClrScr; + writeln('VGA BGI Demo Program Copyright(c) 1987,1989 Borland International, Inc.'); + writeln; + Initialize; + ReportStatus; + AspectRatioPlay; + FillEllipsePlay; + SectorPlay; + WriteModePlay; + ColorPlay; + PalettePlay; + PutPixelPlay; + PutImagePlay; + RandBarPlay; + SolidBarPlay; + BarPlay; + Bar3DPlay; + ArcPlay; + CirclePlay; + PiePlay; + LineToPlay; + LineRelPlay; + LineStylePlay; + UserLineStylePlay; + TextDump; + TextPlay; + CrtModePlay; + FillStylePlay; + FillPatternPlay; + PolyPlay; + SayGoodbye; + CloseGraph; +end. + \ No newline at end of file diff --git a/DEMO.PCX b/DEMO.PCX new file mode 100644 index 0000000..f28dc10 Binary files /dev/null and b/DEMO.PCX differ diff --git a/FILMA_1.C b/FILMA_1.C new file mode 100644 index 0000000..3ad374f --- /dev/null +++ b/FILMA_1.C @@ -0,0 +1,383 @@ +/*****************************************************************************/ +/* TECNICA FILMATION (1¦ PARTE) */ +/* */ +/* por: Jos‚ Antonio Acedo Mart¡n-Grande, miembro de "GOLDY GAMES" */ +/* */ +/* TEL: (91) 6 11 72 71 (MADRID) */ +/*****************************************************************************/ + +/**************************** FICHEROS A INCLUIR ****************************/ + +#include +#include +#include +#include +#include +#include + +/******************************* DEFINICIONES ********************************/ + +#define ALFANUMERICO 3 +#define GRAFICO 19 +#define COLOR 0 +#define ULTIMO -1 + +/*********************** DECLARACIONES DE FUNCIONES **************************/ + +void BORRA_ZONA_MEMORIA(char *, int); +void COPIA_ZONA_MEMORIA(char *, char *); +void DIBUJA_BLOQUE (int *, char *, char *); +void DIBUJA_BLOQUE_CUT(int *, char *, char *); +void VUELCA_PANTALLA(int,int, int,int, int,int, char *); +void SET_VECTORES(volatile char *); +void UNSET_VECTORES(void); +void asigna_modo_video(char); +void lee_ficheros(const char *, char *); +void descomprime_dibujo(char *); +void asigna_rgb(char *); +void asigna_memoria(void); +void libera_memoria(void); +void error_memoria(void); +void error_fichero(void); +void salir_al_dos(void); + +/*************************** VARIABLES GLOBALES /*****************************/ + +char *dir_carga_dibujos; +char *dir_dibujo1; +char *dir_muestra_dibujo1; +char *dir_zona_pantalla; +FILE *handle_dibujos; +char mapa_teclado[256]; +char dibujo1[] = "filma_1.pcx"; +int logotipo_filmation [6] = { 0,31, 0,182, 133,14 }; +int logotipo_parte1 [6] = { 133,31, 0, 0, 64,18 }; +int logotipo_goldy_games[6] = { 0,46, 206,182, 114,18 }; + +int mapa_zona_1[][6] = { 0, 0, 144, 36, 32,15, /* suelo rojo */ + 0, 0, 112, 52, 32,15, + 0, 0, 144, 52, 32,15, + 0, 0, 176, 52, 32,15, + 0, 0, 80, 68, 32,15, + 0, 0, 112, 68, 32,15, + 0, 0, 144, 68, 32,15, + 0, 0, 176, 68, 32,15, + 0, 0, 208, 68, 32,15, + 0, 0, 48, 84, 32,15, + 0, 0, 80, 84, 32,15, + 0, 0, 112, 84, 32,15, + 0, 0, 144, 84, 32,15, + 0, 0, 176, 84, 32,15, + 0, 0, 208, 84, 32,15, + 0, 0, 240, 84, 32,15, + 0, 0, 16,100, 32,15, + 0, 0, 48,100, 32,15, + 0, 0, 80,100, 32,15, + 0, 0, 112,100, 32,15, + 0, 0, 144,100, 32,15, + 0, 0, 176,100, 32,15, + 0, 0, 208,100, 32,15, + 0, 0, 240,100, 32,15, + 0, 0, 272,100, 32,15, + 0, 0, 16,116, 32,15, + 0, 0, 48,116, 32,15, + 0, 0, 80,116, 32,15, + 0, 0, 112,116, 32,15, + 0, 0, 144,116, 32,15, + 0, 0, 176,116, 32,15, + 0, 0, 208,116, 32,15, + 0, 0, 240,116, 32,15, + 0, 0, 272,116, 32,15, + 0, 0, 48,132, 32,15, + 0, 0, 80,132, 32,15, + 0, 0, 112,132, 32,15, + 0, 0, 144,132, 32,15, + 0, 0, 176,132, 32,15, + 0, 0, 208,132, 32,15, + 0, 0, 240,132, 32,15, + 0, 0, 80,148, 32,15, + 0, 0, 112,148, 32,15, + 0, 0, 144,148, 32,15, + 0, 0, 176,148, 32,15, + 0, 0, 208,148, 32,15, + 0, 0, 112,164, 32,15, + 0, 0, 144,164, 32,15, + 0, 0, 176,164, 32,15, + 0, 0, 144,180, 32,15, + + 32, 0, 128, 44, 32,15, /* suelo amarillo */ + 32, 0, 160, 44, 32,15, + 32, 0, 96, 60, 32,15, + 32, 0, 128, 60, 32,15, + 32, 0, 160, 60, 32,15, + 32, 0, 192, 60, 32,15, + 32, 0, 64, 76, 32,15, + 32, 0, 96, 76, 32,15, + 32, 0, 128, 76, 32,15, + 32, 0, 160, 76, 32,15, + 32, 0, 192, 76, 32,15, + 32, 0, 224, 76, 32,15, + 32, 0, 32, 92, 32,15, + 32, 0, 64, 92, 32,15, + 32, 0, 96, 92, 32,15, + 32, 0, 128, 92, 32,15, + 32, 0, 160, 92, 32,15, + 32, 0, 192, 92, 32,15, + 32, 0, 224, 92, 32,15, + 32, 0, 256, 92, 32,15, + 32, 0, 0,108, 32,15, + 32, 0, 32,108, 32,15, + 32, 0, 64,108, 32,15, + 32, 0, 96,108, 32,15, + 32, 0, 128,108, 32,15, + 32, 0, 160,108, 32,15, + 32, 0, 192,108, 32,15, + 32, 0, 224,108, 32,15, + 32, 0, 256,108, 32,15, + 32, 0, 288,108, 32,15, + 32, 0, 32,124, 32,15, + 32, 0, 64,124, 32,15, + 32, 0, 96,124, 32,15, + 32, 0, 128,124, 32,15, + 32, 0, 160,124, 32,15, + 32, 0, 192,124, 32,15, + 32, 0, 224,124, 32,15, + 32, 0, 256,124, 32,15, + 32, 0, 64,140, 32,15, + 32, 0, 96,140, 32,15, + 32, 0, 128,140, 32,15, + 32, 0, 160,140, 32,15, + 32, 0, 192,140, 32,15, + 32, 0, 224,140, 32,15, + 32, 0, 96,156, 32,15, + 32, 0, 128,156, 32,15, + 32, 0, 160,156, 32,15, + 32, 0, 192,156, 32,15, + 32, 0, 128,172, 32,15, + 32, 0, 160,172, 32,15, + + 0, 15, 0,116, 16,12, /* borde suelo izq */ + 0, 15, 16,124, 16,12, + 0, 15, 32,132, 16,12, + 0, 15, 48,140, 16,12, + 0, 15, 64,148, 16,12, + 0, 15, 80,156, 16,12, + 0, 15, 96,164, 16,12, + 0, 15, 112,172, 16,12, + 0, 15, 128,180, 16,12, + 0, 15, 144,188, 16,12, + + 16, 15, 304,116, 16,12, /* borde suelo der */ + 16, 15, 288,124, 16,12, + 16, 15, 272,132, 16,12, + 16, 15, 256,140, 16,12, + 16, 15, 240,148, 16,12, + 16, 15, 224,156, 16,12, + 16, 15, 208,164, 16,12, + 16, 15, 192,172, 16,12, + 16, 15, 176,180, 16,12, + 16, 15, 160,188, 16,12, + + 288, 0, 128,-28, 32,79, /* pared izq */ + 288, 0, 96,-12, 32,79, + 288, 0, 64, 4, 32,79, + 288, 0, 32, 20, 32,79, + 288, 0, 0, 36, 32,79, + + 256, 0, 160,-28, 32,79, /* pared der */ + 256, 0, 192,-12, 32,79, + 256, 0, 224, 4, 32,79, + 256, 0, 256, 20, 32,79, + 256, 0, 288, 36, 32,79, + ULTIMO + }; + +int objetos_zona_1[6]; /* array para las coordenadas de los cubos */ + +int xyz_objetos_zona_1[][8] = { 64,0, 0, 0, 0, 32,30, +2, /* cubo rojo */ + 96,0, 8, 0,24, 32,30, +2, /* cubo verde */ + 128,0, 16, 0,48, 32,30, -2, /* cubo azul */ + 160,0, 24, 0,72, 32,30, +2, /* cubo marr¢n */ + ULTIMO + }; + +/********************************* PROGRAMA **********************************/ + +void main(void) +{ + int bloq, cubo, x, y, z; + + asigna_memoria(); + asigna_modo_video(GRAFICO); + lee_ficheros(dibujo1, dir_dibujo1); + SET_VECTORES(mapa_teclado); + BORRA_ZONA_MEMORIA(dir_muestra_dibujo1, COLOR); + DIBUJA_BLOQUE(logotipo_filmation, dir_dibujo1, dir_muestra_dibujo1); + DIBUJA_BLOQUE(logotipo_parte1, dir_dibujo1, dir_muestra_dibujo1); + DIBUJA_BLOQUE(logotipo_goldy_games, dir_dibujo1, dir_muestra_dibujo1); + + for(bloq=0; mapa_zona_1[bloq][0]!=ULTIMO; bloq++) + DIBUJA_BLOQUE_CUT(&mapa_zona_1[bloq][0], dir_dibujo1, dir_muestra_dibujo1); + + while(mapa_teclado[0]==0) + { + COPIA_ZONA_MEMORIA(dir_muestra_dibujo1, dir_zona_pantalla); + + for(bloq=0; xyz_objetos_zona_1[bloq][0]!=ULTIMO; bloq++) + { + x=xyz_objetos_zona_1[bloq][2]; + y=xyz_objetos_zona_1[bloq][3]; + z=xyz_objetos_zona_1[bloq][4]; + + objetos_zona_1[0]=xyz_objetos_zona_1[bloq][0]; + objetos_zona_1[1]=xyz_objetos_zona_1[bloq][1]; + objetos_zona_1[2]=144+((x-z) << 1); + objetos_zona_1[3]= 21+ (x+z)-(y << 1); + objetos_zona_1[4]=xyz_objetos_zona_1[bloq][5]; + objetos_zona_1[5]=xyz_objetos_zona_1[bloq][6]; + DIBUJA_BLOQUE_CUT(objetos_zona_1, dir_dibujo1, dir_zona_pantalla); + } + + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + + for(cubo=0; xyz_objetos_zona_1[cubo][0]!=ULTIMO; cubo++) + { + if(xyz_objetos_zona_1[cubo][2]==0) + { + xyz_objetos_zona_1[cubo][7]=+2; + sound(1000+(500*cubo)); + delay(10); + nosound(); + } + else if(xyz_objetos_zona_1[cubo][2]==72) + { + xyz_objetos_zona_1[cubo][7]=-2; + sound(2000+(500*cubo)); + delay(10); + nosound(); + } + xyz_objetos_zona_1[cubo][2]+=xyz_objetos_zona_1[cubo][7]; + } + } + salir_al_dos(); +} + +void salir_al_dos(void) +{ + asigna_modo_video(ALFANUMERICO); + libera_memoria(); + UNSET_VECTORES(); + textcolor(WHITE); textbackground(BLUE); + cprintf("Copyright (c) Goldy Games 1994. Jos‚ Antonio Acedo Mart¡n-Grande. Continuar  ..."); + gotoxy(1,24); + exit(0); +} + +void asigna_memoria(void) +{ + if((dir_carga_dibujos =(char *)malloc(320*200))==NULL) error_memoria(); + if((dir_dibujo1 =(char *)malloc(320*200))==NULL) error_memoria(); + if((dir_muestra_dibujo1=(char *)malloc(320*200))==NULL) error_memoria(); + if((dir_zona_pantalla =(char *)malloc(320*200))==NULL) error_memoria(); +} + +void libera_memoria(void) +{ + free(dir_carga_dibujos); + free(dir_dibujo1); + free(dir_muestra_dibujo1); + free(dir_zona_pantalla); +} + +void error_memoria(void) +{ + asigna_modo_video(ALFANUMERICO); + libera_memoria(); + printf("No hay suficiente memoria. Libere programas residentes."); + exit(1); +} + +void error_fichero(void) +{ + asigna_modo_video(ALFANUMERICO); + libera_memoria(); + printf("Error leyendo fichero .PCX"); + exit(1); +} + +void asigna_modo_video(char modo) /* asigna el modo de v¡deo indicado */ +{ /* en la variable "modo" */ + union REGS ent, sal; + + ent.h.al = modo; + ent.h.ah = 0; + int86(16, &ent, &sal); /* funci¢n para asignar el modo de video */ +} + +void lee_ficheros(const char *file, char *dir_dibujo) +{ + char *dir; + + dir=dir_carga_dibujos; + if((handle_dibujos = fopen(file, "rb"))==NULL) error_fichero(); + while(!feof(handle_dibujos)) { *dir++=getc(handle_dibujos); } + fclose(handle_dibujos); + descomprime_dibujo(dir_dibujo); +} + +void descomprime_dibujo(char *dir_escritura) +{ + unsigned char byte; + char *dir_lectura; + int columnas, filas, contador; + + dir_lectura=dir_carga_dibujos+128; /* inicio del dibujo comprimido */ + + for(filas=200; filas>0; filas--) + { + columnas=320; + dir_escritura-=columnas; dir_escritura+=320; + while(columnas>0) + { + byte=(unsigned)*dir_lectura++; + if(byte<=192) + { + *dir_escritura++=byte; columnas--; + } + else + { + contador=byte&63; byte=*dir_lectura++; + for(; contador>0; contador--) + { + *dir_escritura++=byte; columnas--; + } + } + } + } + asigna_rgb(dir_lectura+1); /* remapea los 256 colores del dibujo */ +} + +void asigna_rgb(char *dir_lectura) +{ + struct SREGS seg; + union REGS ent, sal; + unsigned int n; + long int dir; + char *dir_col; + + dir_col=dir_lectura; /* divide entre */ + for(n=256*3; n>0; n--) { /* 4 los colores */ + *dir_col=*dir_col >> 2; dir_col++; + } + + dir =(long)dir_lectura; /* obtiene el segmento */ + seg.es=(int)(dir >> 16); /* donde estan los colores */ + + ent.h.al = 18; + ent.h.ah = 16; + ent.x.bx = 0; + ent.x.cx = 256; + ent.x.dx = (int)dir_lectura; /* offset de los colores */ + int86x(0x10, &ent, &sal, &seg); /* funci¢n para asignar los colores */ +} + \ No newline at end of file diff --git a/MOVES.CPP b/MOVES.CPP new file mode 100644 index 0000000..c3ddc71 --- /dev/null +++ b/MOVES.CPP @@ -0,0 +1,362 @@ +int CargaPaleta(char *file ); + +#include +#include +#include +#include +#include +//#include + +#define NUM_MOVES 4 // Numero de movimientos por secuencia + +#define IZQUIERDA 0 +#define DERECHA 1 +#define ARRIBA 2 +#define ABAJO 3 +#define IZQARR 4 +#define IZQABJ 5 +#define DERARR 6 +#define DERABJ 7 + +#define OK 0 +#define ERROR 1 + +#define SIZE_PERSONAJE (59*33) + +typedef unsigned char DacPalette256[256][3]; + +void setvgapalette256(DacPalette256 *PalBuf); + + + +unsigned char far *video_buffer = (char far *)0xA0000000L; // vram byte ptr + +void putpixel( int x, int y, int color) +{ + video_buffer[((y<<8) + (y<<6)) + x] = color; +}; + +typedef struct +{ + unsigned char Frame[NUM_MOVES][SIZE_PERSONAJE]; +} Pmovim; + +/*Pmovim *Personaje;*/ + +typedef struct pcx_header_typ + { + char manufacturer; + char version; + char encoding; + char bits_per_pixel; + int x,y; + int width,height; + int horz_res; + int vert_res; + char ega_palette[48]; + char reserved; + char num_color_planes; + int bytes_per_line; + int palette_type; + char padding[58]; + + } PCX_HEADER; + +Pmovim far *Jugador; + +#define PALETTE_MASK 0x3c6 +#define PALETTE_REGISTER_RD 0x3c7 +#define PALETTE_REGISTER_WR 0x3c8 +#define PALETTE_DATA 0x3c9 +// this structure holds a RGB triple in three bytes + +typedef struct RGB_color_typ + { + + unsigned char red; // red component of color 0-63 + unsigned char green; // green component of color 0-63 + unsigned char blue; // blue component of color 0-63 + + } RGB_color, *RGB_color_ptr; + +void Set_Palette_Register(int index, RGB_color_ptr color) +{ +// this function sets a single color look up table value indexed by index +// with the value in the color structure + +// tell VGA card we are going to update a pallete register + +outport(PALETTE_MASK,0xff); + +// tell vga card which register we will be updating + +outport(PALETTE_REGISTER_WR, index); + +// now update the RGB triple, note the same port is used each time + +outport(PALETTE_DATA,color->red); +outport(PALETTE_DATA,color->green); +outport(PALETTE_DATA,color->blue); + +}; // end Set_Palette_Color + + +int IniciaJugador( Pmovim far **JUgador, int Direcciones, char *PCX, long PorDonde ) +{ + FILE *PCX_ptr; + PCX_HEADER pcx_header; + int alto, ancho, movimiento; + int desplaz, contador; + unsigned char byte; + int color = -1; + int contar = -1; + + //Asignamos memoria para los movimientos del jugador +// if ( ( (*Jugador) = (Pmovim far *)farmalloc( sizeof(Pmovim)*Direcciones ) ) == NULL ) return ERROR; + + // Abrimos el fichero de los movimientos + if ( ( PCX_ptr = fopen( PCX, "rb" ) ) == NULL ) return ERROR; + + // Nos posicionamos en el lugar de comienzo del PCX + fseek( PCX_ptr, PorDonde, SEEK_SET ); + + // Leemos la cabecera + fread( &pcx_header, sizeof(PCX_HEADER), 1, PCX_ptr ); + + // Comprobamos que sea un PCX + if ( pcx_header.manufacturer == 10 ) + { + for(alto=0; alto= (47+82*movimiento) && alto < (106+82*movimiento) ) + { + for ( desplaz = 0; desplaz < Direcciones; desplaz++ ) + if ( ancho >= (80+71*desplaz) && ancho < (113+71*desplaz) ) + { + Jugador[desplaz]./*->*/ Frame[movimiento][ (ancho-(80+71*desplaz)) + 33 * (alto-(47+82*movimiento)) ] = byte; + break; + } + break; + } + ancho++; + } + else + { + contador=byte&0x3F; byte=getc(PCX_ptr); + for(; contador>0; contador--) + { + for ( movimiento = 0; movimiento < NUM_MOVES; movimiento++ ) + if ( alto >= (47+82*movimiento) && alto < (106+82*movimiento) ) + { + for ( desplaz = 0; desplaz < Direcciones; desplaz++ ) + if ( ancho >= (80+71*desplaz) && ancho < (113+71*desplaz) ) + { + Jugador[desplaz]./*->*/ Frame[movimiento][ (ancho-(80+71*desplaz)) + 33 * (alto-(47+82*movimiento)) ] = byte; + break; + } + break; + } + ancho++; + } + } + } + } + } + CargaPaleta( PCX ); + + // Cerramos el fichero de movimientos + fclose( PCX_ptr ); + + return OK; +}; + +void MuestraJugador( unsigned char *BitMap_Ptr, int Px, int Py, char FILL ) +{ + int x, y; + static color = -1; + + if ( color == -1 ) color = *(BitMap_Ptr); + + for ( x = 0; x < 33; x++ ) + for ( y = 0; y < 59; y++ ) + if ( 1 || *(BitMap_Ptr + x + y*33) != color ) + if ( FILL==1 ) + putpixel( x+Px, y+Py, 0 ); + else + putpixel( x+Px, y+Py, *(BitMap_Ptr + x + y*33) ); + else + putpixel( x+Px, y+Py, 0 ); +} +void asigna_modo_video(char modo) /* asigna el modo de v¡deo indicado */ +{ /* en la variable "modo" */ + union REGS ent, sal; + + ent.h.al = modo; + ent.h.ah = 0; + int86(16, &ent, &sal); /* funci¢n para asignar el modo de video */ +}; + +void main(void) +{ + Pmovim far *Figuras; + int Direccion, O_K = 0; + float MovAct; + + float x, y; + // Inicializamos la Pantalla + asigna_modo_video(0x13); + + + + if ( ( (Jugador) = (Pmovim far *)farmalloc( sizeof(Pmovim)*8 ) ) == NULL ) return ; + + if ( ( (Figuras) = (Pmovim far *)farcalloc( 8, sizeof(Pmovim) ) ) == NULL ) return ; + + if ( IniciaJugador( &Figuras, 8, "moves.pcx", 0 ) != OK ) return; + + // Mostramos los personajes en la pantalla + + Direccion = 0; + MovAct = 0; + float Incx=0, Incy=0; + x = 0; y = 0; + do + { + if ( kbhit() ) + if ( getch() == 0 ) + { + switch( getch() ) + { + case 72: //ARRIBA + Direccion = 4; + Incx = 0; + Incy = -8; + break; + case 80: //ABAJO + Direccion = 0; + Incx = 0; + Incy = 8; + break; + case 75: //IZQ + Direccion = 2; + Incx = -8; + Incy = 0; + break; + case 77: //DER + Direccion = 6; + Incx = 8; + Incy = 0; + break; + case 71: + Direccion = 3; + Incx = -5; + Incy = -5; + break; + case 73: + Direccion = 5; + Incx = 2; + Incy = -2; + break; + case 81: + Direccion = 7; + Incx = 2; + Incy = 2; + break; + case 79: + Direccion = 2; + Incx = -2; + Incy = 2; + break; + + default: + O_K = 1; + break; + } + + } +// memset( video_buffer, 254, 320*200 ); + + MuestraJugador( Jugador[Direccion].Frame[(int)MovAct], x, y, 1 ); + x += Incx; y += Incy; MovAct = (MovAct+=1); if ( MovAct >= 4 ) MovAct = 0; + if ( x > 320-33 ) x = 320-33; if ( x < 0 ) x = 0; + if ( y > 200-59 ) y = 200-59; if ( y < 0 ) y = 0; + MuestraJugador( Jugador[Direccion].Frame[(int)MovAct], x, y, 0 ); + delay(100); + } while( !O_K ); + + farfree( Figuras ); + // Volvemos la pantalla a su estado normal + asigna_modo_video(0x3); + +} + + + + /**************************************************************************\ +|* *| +|* CargaPaleta *| +|* *| +|* Descripci¢n: *| +|* Carga la paleta con los colores por defecto *| +|* *| +|* *| +|* Entradas: achivo PCX de donde cargar la paleta *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +int CargaPaleta(char *file ) +{ + DacPalette256 Palette256; + int index; + FILE *fp; + + if ( (fp=fopen( file, "rb" ) ) == NULL ) + return ERROR; + + if ( fseek( fp, -768L, SEEK_END ) == 0 ) + { + for (index=0; index<256; index++) + { + // get the red component + // get the green component + // get the blue component + // set components + Palette256[index][0] = getc(fp) >> 2; + Palette256[index][1] = getc(fp) >> 2; + Palette256[index][2] = getc(fp) >> 2; + } // end for index + + } + setvgapalette256( &Palette256 ); + + + fclose( fp ); + return OK; +} + +/* Setvgapalette256 sets the entire 256 color palette */ +/* PalBuf contains RGB values for all 256 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette256 dac256; */ +/* */ +/* setvgapalette256(&dac256); */ +void setvgapalette256(DacPalette256 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 256; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} diff --git a/MOVES.DSK b/MOVES.DSK new file mode 100644 index 0000000..5157159 Binary files /dev/null and b/MOVES.DSK differ diff --git a/MOVES.EXE b/MOVES.EXE new file mode 100644 index 0000000..b96e60c Binary files /dev/null and b/MOVES.EXE differ diff --git a/MOVES.PCX b/MOVES.PCX new file mode 100644 index 0000000..774e1b9 Binary files /dev/null and b/MOVES.PCX differ diff --git a/MOVES.PRJ b/MOVES.PRJ new file mode 100644 index 0000000..724114a Binary files /dev/null and b/MOVES.PRJ differ diff --git a/PCX.CPP b/PCX.CPP new file mode 100644 index 0000000..f56be01 --- /dev/null +++ b/PCX.CPP @@ -0,0 +1,204 @@ +#include +#include +#include +#include +#include + +#define ERROR 1 +#define OK 1 + +typedef unsigned char DacPalette256[256][3]; + +void setvgapalette256(DacPalette256 *PalBuf); + + DacPalette256 Palette256; + +void InicializaSVGA(void); +extern int far _Cdecl Svga256_fdriver[]; +int huge DetectVGA256(){ return 2; } + +int MuestraImagen( char *file ); +int CargaPaleta(char *file ); + +void main( void ) +{ + int index, salida; + + // Inicializamos el modo SVGA 640*480 256 c. ( VESA ) + InicializaSVGA(); + MuestraImagen( "DEMO.PCX" ); + while( !kbhit() ); + + salida = 0; + for( ; salida == 0; ) + { + for (index=0; index<256; index++) + { + // set components + if( Palette256[index][0]>0 ) Palette256[index][0]--; + if( Palette256[index][1]>0 ) Palette256[index][1] --; + if( Palette256[index][2]>0 ) Palette256[index][2] --; + if( Palette256[index][0]==0 && Palette256[index][1]==0 && Palette256[index][2]==0 ) + salida = 1; + else + salida = 0; + } // end for index + setvgapalette256( &Palette256 ); + delay(50); + } + + + closegraph(); + +} + + +#define RES_X 640 +#define RES_Y 480 + /**************************************************************************\ +|* *| +|* MuestraImagen *| +|* *| +|* Descripci¢n: *| +|* Descomprime y copia a la pagina indicada un PCX *| +|* *| +|* Entradas: nombre de la imagen *| +|* *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +int MuestraImagen( char *file ) +{ + int alto, ancho, contador; + unsigned char byte; + FILE *fp; + + CargaPaleta( file ); + + if ( (fp = fopen( file,"rb")) != NULL ) + { + // Saltamos la cabecera + fseek( fp, 128, SEEK_SET ); + + for(alto=0; alto0; contador--) + { + putpixel (ancho, alto, byte); + ancho++; + } + } + } + } + + fclose(fp); + + } else return ERROR; + + + + return OK; +} + + + + /**************************************************************************\ +|* *| +|* CargaPaleta *| +|* *| +|* Descripci¢n: *| +|* Carga la paleta con los colores por defecto *| +|* *| +|* *| +|* Entradas: achivo PCX de donde cargar la paleta *| +|* *| +|* Salidas: OK Todo ha ido bien *| +|* ERROR Algo va mal *| +|* *| + \**************************************************************************/ +int CargaPaleta(char *file ) +{ + int index; + FILE *fp; + + if ( (fp=fopen( file, "rb" ) ) == NULL ) + return ERROR; + + if ( fseek( fp, -768L, SEEK_END ) == 0 ) + { + for (index=0; index<256; index++) + { + // get the red component + // get the green component + // get the blue component + // set components + Palette256[index][0] = (getc(fp) >> 2)*64 / 256; + Palette256[index][1] = (getc(fp) >> 2)*64 / 256; + Palette256[index][2] = (getc(fp) >> 2)*64 / 256; + } // end for index + + } + setvgapalette256( &Palette256 ); + + + fclose( fp ); + return OK; +} + +/* Setvgapalette256 sets the entire 256 color palette */ +/* PalBuf contains RGB values for all 256 colors */ +/* R,G,B values range from 0 to 63 */ +/* Usage: */ +/* DacPalette256 dac256; */ +/* */ +/* setvgapalette256(&dac256); */ +void setvgapalette256(DacPalette256 *PalBuf) +{ + struct REGPACK reg; + + reg.r_ax = 0x1012; + reg.r_bx = 0; + reg.r_cx = 256; + reg.r_es = FP_SEG(PalBuf); + reg.r_dx = FP_OFF(PalBuf); + intr(0x10,®); +} + + + +void InicializaSVGA(void) { + + int Gd = DETECT, Gm; + int Drv, errorcode; + + installuserdriver("Svga256",DetectVGA256); +// registerfarbgidriver(Svga256_fdriver); + + initgraph(&Gd,&Gm,""); + + /* read result of initialization */ + errorcode = graphresult(); + +if (errorcode != grOk) /* an error occurred */ +{ + cprintf("Graphics error: %s\n", grapherrormsg(errorcode)); + cprintf("Presione una tecla para finalizar:"); + getch(); + exit(1); /* return with error code */ +} + +} + + + diff --git a/PCX.EXE b/PCX.EXE new file mode 100644 index 0000000..08ca1b7 Binary files /dev/null and b/PCX.EXE differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3742350 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +#MOVES + + +*16/09/1994* + +ToDo: wwtcf? + + +![screenshot](/MOVES.png "Screenshot") diff --git a/X_DEMO.PCX b/X_DEMO.PCX new file mode 100644 index 0000000..85d5990 Binary files /dev/null and b/X_DEMO.PCX differ