First commit ~0,10

This commit is contained in:
2021-09-08 21:26:43 +02:00
commit 37dffcdec3
188 changed files with 23679 additions and 0 deletions

300
G/BIN/BGI.CPP Normal file
View File

@ -0,0 +1,300 @@
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <alloc.h>
#include <string.h>
#include <io.h>
#include <dos.h>
#include <bios.h>
#include <fcntl.h>
#include "gif_lib.h"
#define ARCHIVO_Abrir 10
#define ARCHIVO_Cerrar 11
#define MEMORIA 50
#define DECODING 60
#define TAMANYO 70
#define DESCRIPCION 80
#define OK 00
typedef unsigned char DacPalette256[256][3];
void setvgapalette256(DacPalette256 *PalBuf);
extern int far _Cdecl Svga256_fdriver[];
int huge DetectVGA256(){ return 2; }
int MuestraGif( char *file, int PosX, int PosY );
extern unsigned int
_stklen = 16384; /* Increase default stack size. */
/******************************************************************************
* Interpret the command line and scan the given GIF file. *
******************************************************************************/
void main(int argc, char **argv)
{
/* Make some variables global, so we could access them faster: */
int GraphDriver, GraphMode;
char Str[80];
struct text_info TextInfo; /* So we can restore starting text mode. */
installuserdriver("Svga256",DetectVGA256);
gettextinfo(&TextInfo); /* Save current mode so we can recover. */
GraphDriver = DETECT;
initgraph(&GraphDriver, &GraphMode, "");
MuestraGif( argv[1], 0, 0 );
while( !kbhit() );
closegraph();
textmode(TextInfo.currmode);
}
/**************************************************************************\
|* *|
|* MuestraGif *|
|* *|
|* Descripcion: *|
|* Dado el nombre del .GIF, y la posici<63>n de inicio f<>sica *|
|* decodifica y muestra est<73> en pantalla... *|
|* *|
|* Entradas: *|
|* Nombre de Archivo, Posiciones iniciales X, Y *|
|* Salidas: *|
|* OK *|
|* C<>digos de Errores *|
|* *|
\*************************************************************************/
#define MIN(x, y) ((x) < (y) ? (x) : (y))
int MuestraGif( char *file, int PosX, int PosY )
{
// int k, sum;
int i, j, Error, NumFiles, Size, Row, Col, Width, Height, ExtCode,
ColorMapSize;
DacPalette256 Palette256;
int
RecX,
// ImageNum = 0,
// BackGround = 0,
// ForeGround = 1, /* As close to white as possible. */
MaximumScreenHeight,
// DeviceMaxX = 640, DeviceMaxY = 400, /* Physical device dimensions. */
// ScreenWidth = 320, ScreenHeight = 200, /* Gif image screen size. */
InterlacedOffset[] = { 0, 4, 2, 1 }, /* The way Interlaced image should. */
InterlacedJumps[] = { 8, 8, 4, 2 }; /* be read - offsets and jumps... */
GifColorType
*ColorMap;
GifRecordType RecordType;
GifByteType *Extension;
GifRowType *ScreenBuffer;
GifFileType *GifFile;
if ((GifFile = DGifOpenFileName( file )) == NULL)
{
return ARCHIVO_Abrir;
}
if ((ScreenBuffer = (GifRowType *)
malloc( sizeof(GifRowType *))) == NULL)
return MEMORIA;
Size = GifFile -> SWidth * sizeof(GifPixelType);/* Size in bytes of one row.*/
if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL) /* First row. */
{
free( ScreenBuffer );
return MEMORIA;
}
for (i = 0; i < GifFile -> SWidth; i++) /* Set its color to BackGround. */
ScreenBuffer[0][i] = GifFile -> SBackGroundColor;
MaximumScreenHeight = GifFile -> SHeight - 1;
/* Scan the content of the GIF file and load the image(s) in: */
do {
for (i = 0; i < GifFile -> SWidth; i++) /* Set its color to BackGround. */
ScreenBuffer[0][i] = GifFile -> SBackGroundColor;
if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
break;
switch (RecordType)
{
case IMAGE_DESC_RECORD_TYPE:
if (DGifGetImageDesc(GifFile) == GIF_ERROR)
return DESCRIPCION;
Row = GifFile -> ITop; /* Image Position relative to Screen. */
Col = GifFile -> ILeft;
Width = GifFile -> IWidth;
Height = GifFile -> IHeight;
if (GifFile -> ILeft + GifFile -> IWidth > GifFile -> SWidth ||
GifFile -> ITop + GifFile -> IHeight > GifFile -> SHeight)
{
free( ScreenBuffer[0] );
free( ScreenBuffer );
return TAMANYO;
}
if (GifFile -> IInterlace)
{
/* Need to perform 4 passes on the images: */
for ( i = 0; i < 4; i++)
for (j = Row + InterlacedOffset[i]; j < Row + Height;
j += InterlacedJumps[i])
{
if (DGifGetLine(GifFile,
&ScreenBuffer[/*MIN(j, MaximumScreenHeight)*/0][Col],
Width) == GIF_ERROR)
{
free( ScreenBuffer[0] );
free( ScreenBuffer );
return DECODING;
}
/////////////////////////////////////////////////
///Procesa linea obtenida////////////////////////
/////////////////////////////////////////////////
for ( i = 0; i < Width; i ++ )
putpixel( RecX+PosX, j+PosY, ScreenBuffer[/*MIN(j, MaximumScreenHeight)*/0][RecX] );
/////////////////////////////////////////////////
/////////////////////////////////////////////////
}
}
else {
for (i = 0; i < Height; i++, Row++)
{
if (DGifGetLine(GifFile, &ScreenBuffer[/*MIN(Row, MaximumScreenHeight)*/0][Col],
Width) == GIF_ERROR)
{
MaximumScreenHeight = MIN(i - 1, MaximumScreenHeight);
}
/////////////////////////////////////////////////
///Procesa linea obtenida////////////////////////
/////////////////////////////////////////////////
for ( RecX = 0; RecX < Width; RecX ++ )
putpixel( RecX+PosX, Row+PosY, ScreenBuffer[/*MIN(j, MaximumScreenHeight)*/0][RecX] );
/////////////////////////////////////////////////
/////////////////////////////////////////////////
}
}
break;
case EXTENSION_RECORD_TYPE:
/* Skip any extension blocks in file: */
if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR)
{
free( ScreenBuffer[0] );
free( ScreenBuffer );
return DECODING;
}
while (Extension != NULL)
{
if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR)
{
free( ScreenBuffer[0] );
free( ScreenBuffer );
return DECODING;
}
}
break;
case TERMINATE_RECORD_TYPE:
break;
default: /* Should be traps by DGifGetRecordType. */
break;
}
}
while (RecordType != TERMINATE_RECORD_TYPE);
/* Lets display it - set the global variables required and do it: */
ColorMap = (GifFile -> IColorMap ? GifFile -> IColorMap :
GifFile -> SColorMap);
ColorMapSize = 1 << (GifFile -> IColorMap ? GifFile -> IBitsPerPixel :
GifFile -> SBitsPerPixel);
/* Initialize hardware pallete and also select fore/background color. */
/*
Sum = ((int) ColorMap[1].Red) +
((int) ColorMap[1].Green) +
((int) ColorMap[1].Blue);
j = k = Sum;
*/
for (i = 0; i < ColorMapSize; i++)
{
Palette256[i][0] = ColorMap[i].Red >> 2;
Palette256[i][1] = ColorMap[i].Green >> 2;
Palette256[i][2] = ColorMap[i].Blue >> 2;
/*
Sum = ((int) ColorMap[i].Red) +
((int) ColorMap[i].Green) +
((int) ColorMap[i].Blue);
if (i != 0 && Sum > j) // * Dont use color 0. *
{
ForeGround = i;
j = Sum;
}
if (i != 0 && Sum <= k) // * Dont use color 0. *
{
BackGround = i;
k = Sum;
}
*/
}
setvgapalette256( &Palette256 );
/*
ScreenWidth = GifFile -> SWidth;
ScreenHeight = MIN(GifFile -> SHeight, MaximumScreenHeight);
*/
if (DGifCloseFile(GifFile) == GIF_ERROR)
{
free( ScreenBuffer[0] );
free( ScreenBuffer );
// closegraph();
return ARCHIVO_Cerrar;
}
free( ScreenBuffer[0] );
free( ScreenBuffer );
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,&reg);
}

BIN
G/BIN/DISCO.GIF Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

3
G/BIN/DUMMY Normal file
View File

@ -0,0 +1,3 @@
This file ensures the bin directory will be created when unzipped - this
directory is the default for the unix version for exectutables. Remove it
if the destination is not to here.

BIN
G/BIN/GIF.DSK Normal file

Binary file not shown.

BIN
G/BIN/GIF.EXE Normal file

Binary file not shown.

BIN
G/BIN/GIF.PRJ Normal file

Binary file not shown.

207
G/BIN/GIF_LIB.H Normal file
View File

@ -0,0 +1,207 @@
/******************************************************************************
* In order to make life a little bit easier when using the GIF file format, *
* this library was written, and which does all the dirty work... *
* *
* Written by Gershon Elber, Jun. 1989 *
*******************************************************************************
* History: *
* 14 Jun 89 - Version 1.0 by Gershon Elber. *
* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
******************************************************************************/
#ifndef GIF_LIB_H
#define GIF_LIB_H
#define GIF_LIB_VERSION " Version 1.2, "
#define GIF_ERROR 0
#define GIF_OK 1
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */
typedef int GifBooleanType;
typedef unsigned char GifPixelType;
typedef unsigned char * GifRowType;
typedef unsigned char GifByteType;
#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); }
#ifdef SYSV
#define VoidPtr char *
#else
#define VoidPtr void *
#endif /* SYSV */
typedef struct GifColorType {
GifByteType Red, Green, Blue;
} GifColorType;
/* Note entries prefixed with S are of Screen information, while entries */
/* prefixed with I are of the current defined Image. */
typedef struct GifFileType {
int SWidth, SHeight, /* Screen dimensions. */
SColorResolution, SBitsPerPixel, /* How many colors can we generate? */
SBackGroundColor, /* I hope you understand this one... */
ILeft, ITop, IWidth, IHeight, /* Current image dimensions. */
IInterlace, /* Sequential/Interlaced lines. */
IBitsPerPixel; /* How many colors this image has? */
GifColorType *SColorMap, *IColorMap; /* NULL if not exists. */
VoidPtr Private; /* The regular user should not mess with this one! */
} GifFileType;
typedef enum {
UNDEFINED_RECORD_TYPE,
SCREEN_DESC_RECORD_TYPE,
IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
EXTENSION_RECORD_TYPE, /* Begin with '!' */
TERMINATE_RECORD_TYPE /* Begin with ';' */
} GifRecordType;
/* DumpScreen2Gif routine constants identify type of window/screen to dump. */
/* Note all values below 1000 are reserved for the IBMPC different display */
/* devices (it has many!) and are compatible with the numbering TC2.0 */
/* (Turbo C 2.0 compiler for IBM PC) gives to these devices. */
typedef enum {
GIF_DUMP_SGI_WINDOW = 1000,
GIF_DUMP_X_WINDOW = 1001
} GifScreenDumpType;
/******************************************************************************
* O.k. here are the routines one can access in order to encode GIF file: *
* (GIF_LIB file EGIF_LIB.C). *
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance);
GifFileType *EGifOpenFileHandle(int GifFileHandle);
void EGifSetGifVersion(char *Version);
int EGifPutScreenDesc(GifFileType *GifFile,
int GifWidth, int GifHeight, int GifColorRes, int GifBackGround,
int GifBitsPerPixel, GifColorType *GifColorMap);
int EGifPutImageDesc(GifFileType *GifFile,
int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace,
int GifBitsPerPixel, GifColorType *GifColorMap);
int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
int EGifPutComment(GifFileType *GifFile, char *GifComment);
int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen,
VoidPtr GifExtension);
int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
GifByteType *GifCodeBlock);
int EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock);
int EGifCloseFile(GifFileType *GifFile);
#ifdef __cplusplus
}
#endif
#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */
#define E_GIF_ERR_WRITE_FAILED 2
#define E_GIF_ERR_HAS_SCRN_DSCR 3
#define E_GIF_ERR_HAS_IMAG_DSCR 4
#define E_GIF_ERR_NO_COLOR_MAP 5
#define E_GIF_ERR_DATA_TOO_BIG 6
#define E_GIF_ERR_NOT_ENOUGH_MEM 7
#define E_GIF_ERR_DISK_IS_FULL 8
#define E_GIF_ERR_CLOSE_FAILED 9
#define E_GIF_ERR_NOT_WRITEABLE 10
/******************************************************************************
* O.k. here are the routines one can access in order to decode GIF file: *
* (GIF_LIB file DGIF_LIB.C). *
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
GifFileType *DGifOpenFileName(char *GifFileName);
GifFileType *DGifOpenFileHandle(int GifFileHandle);
int DGifGetScreenDesc(GifFileType *GifFile);
int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
int DGifGetImageDesc(GifFileType *GifFile);
int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
int DGifGetComment(GifFileType *GifFile, char *GifComment);
int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
GifByteType **GifExtension);
int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
GifByteType **GifCodeBlock);
int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
int DGifCloseFile(GifFileType *GifFile);
#ifdef __cplusplus
}
#endif
#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */
#define D_GIF_ERR_READ_FAILED 102
#define D_GIF_ERR_NOT_GIF_FILE 103
#define D_GIF_ERR_NO_SCRN_DSCR 104
#define D_GIF_ERR_NO_IMAG_DSCR 105
#define D_GIF_ERR_NO_COLOR_MAP 106
#define D_GIF_ERR_WRONG_RECORD 107
#define D_GIF_ERR_DATA_TOO_BIG 108
#define D_GIF_ERR_NOT_ENOUGH_MEM 109
#define D_GIF_ERR_CLOSE_FAILED 110
#define D_GIF_ERR_NOT_READABLE 111
#define D_GIF_ERR_IMAGE_DEFECT 112
#define D_GIF_ERR_EOF_TOO_SOON 113
/******************************************************************************
* O.k. here are the routines from GIF_LIB file QUANTIZE.C. *
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize,
GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
GifByteType *OutputBuffer, GifColorType *OutputColorMap);
#ifdef __cplusplus
}
#endif
/******************************************************************************
* O.k. here are the routines from GIF_LIB file QPRINTF.C. *
******************************************************************************/
extern int GifQuitePrint;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_VARARGS
void GifQprintf();
#else
void GifQprintf(char *Format, ...);
#endif /* USE_VARARGS */
/******************************************************************************
* O.k. here are the routines from GIF_LIB file GIF_ERR.C. *
******************************************************************************/
void PrintGifError(void);
int GifLastError(void);
/******************************************************************************
* O.k. here are the routines from GIF_LIB file DEV2GIF.C. *
******************************************************************************/
int DumpScreen2Gif(char *FileName, int ReqGraphDriver, int ReqGraphMode1,
int ReqGraphMode2,
int ReqGraphMode3);
#ifdef __cplusplus
}
#endif
#endif /* GIF_LIB_H */

BIN
G/BIN/GIF_LIBC.LIB Normal file

Binary file not shown.

BIN
G/BIN/GIF_LIBH.LIB Normal file

Binary file not shown.

BIN
G/BIN/GIF_LIBL.LIB Normal file

Binary file not shown.

BIN
G/BIN/GIF_LIBM.LIB Normal file

Binary file not shown.

BIN
G/BIN/GIF_LIBS.LIB Normal file

Binary file not shown.

BIN
G/BIN/GRAPHBGI.LIB Normal file

Binary file not shown.