Limpiados archivos que sobraban de la graphics.dll

This commit is contained in:
Víctor Román Archidona 2002-10-17 01:20:37 +00:00
parent 4f482df658
commit 5d0b93a1aa
12 changed files with 0 additions and 1715 deletions

View file

@ -1,122 +0,0 @@
/*
* eDiv Compiler
* Copyright (C) 2001 Sion Entertainment
* http://www.sion-e.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Este fichero es la cabecera para las DLL's de eDIV.
* Para saber cómo se utiliza, consulte el eDIV SDK de la documentación de eDIV
* ESTE FICHERO -NO- HA DE SER MODIFICADO PARA CREAR DLLs, TAN SÓLO POR
* DESARROLLADORES DE eDIV. EN CASO DE SER MODIFICADO, SE PERDERÁ LA
* COMPATIBILIDAD CON eDIV Y EL RESTO DE DLLs.
* En caso de encontrar cualquier bug o anomalía en este archivo, por favor
* notifíquelo a Sion Entertainment en bugs@edivcentral.com
*/
// COMPATIBILIDAD WIN <-> LINUX
#ifdef WIN32
# define DllMain() WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
# include <windows.h>
#else
typedef enum { FALSE, TRUE } bool;
#endif
// Funciones de exportación de datos
typedef int (TYPEOF_EDIV_Export)(char* cadena, int nparam, void* hfuncion);
typedef int (TYPEOF_EDIV_Export_Const)(char* cadena, int valor);
typedef int* (TYPEOF_EDIV_Export_Global)(char* cadena, int valor);
typedef int* (TYPEOF_EDIV_Export_Global_Tab)(char* cadena, int numregs);
typedef void* (TYPEOF_EDIV_Export_Global_Struct)(char* cadena, int numregs);
typedef int* (TYPEOF_EDIV_Export_Member_Int)(char* cadena, int valor);
typedef char* (TYPEOF_EDIV_Export_Member_Str)(char* cadena, int tamano);
typedef int* (TYPEOF_EDIV_Export_Member_Tab)(char* cadena, int numregs);
typedef int (TYPEOF_EDIV_Export_EndStruct)();
typedef int (TYPEOF_EDIV_Export_Local)(char* cadena, int valor);
typedef int (TYPEOF_EDIV_Export_Local_Tab)(char* cadena, int numregs);
typedef int (TYPEOF_EDIV_Export_Local_Struct)(char* cadena, int numregs);
// estilo BO2K, sólo para "defaultear" las funciones como NULL
/*extern TYPEOF_EDIV_Export *EDIV_Export;
extern TYPEOF_EDIV_Export_Const *EDIV_Export_Const;
extern TYPEOF_EDIV_Export_Global *EDIV_Export_Global;
extern TYPEOF_EDIV_Export_Global_Tab *EDIV_Export_Global_Tab;
extern TYPEOF_EDIV_Export_Global_Struct *EDIV_Export_Global_Struc;
extern TYPEOF_EDIV_Export_Member_Int *EDIV_Export_Member_Int;
extern TYPEOF_EDIV_Export_Member_Str *EDIV_Export_Member_Str;
extern TYPEOF_EDIV_Export_Member_Tab *EDIV_Export_Member_Tab;
extern TYPEOF_EDIV_Export_EndStruct *EDIV_Export_EndStruct;
extern TYPEOF_EDIV_Export_Local *EDIV_Export_Local;
extern TYPEOF_EDIV_Export_Local_Tab *EDIV_Export_Local_Tab;
extern TYPEOF_EDIV_Export_Local_Struct *EDIV_Export_Local_Struct;*/
/*TYPEOF_EDIV_Export *EDIV_Export =NULL;
TYPEOF_EDIV_Export_Const *EDIV_Export_Const =NULL;
TYPEOF_EDIV_Export_Global *EDIV_Export_Global =NULL;
TYPEOF_EDIV_Export_Global_Tab *EDIV_Export_Global_Tab =NULL;
TYPEOF_EDIV_Export_Global_Struct *EDIV_Export_Global_Struct=NULL;
TYPEOF_EDIV_Export_Member_Int *EDIV_Export_Member_Int =NULL;
TYPEOF_EDIV_Export_Member_Str *EDIV_Export_Member_Str =NULL;
TYPEOF_EDIV_Export_Member_Tab *EDIV_Export_Member_Tab =NULL;
TYPEOF_EDIV_Export_EndStruct *EDIV_Export_EndStruct =NULL;
TYPEOF_EDIV_Export_Local *EDIV_Export_Local =NULL;
TYPEOF_EDIV_Export_Local_Tab *EDIV_Export_Local_Tab =NULL;
TYPEOF_EDIV_Export_Local_Struct *EDIV_Export_Local_Struct =NULL;*/
// EXPORTAFUNCS_PARAMS deben usarse como parßmetros para ExportaFuncs
#define EXPORTAFUNCS_PARAMS \
TYPEOF_EDIV_Export *EDIV_Export ,\
TYPEOF_EDIV_Export_Const *EDIV_Export_Const ,\
TYPEOF_EDIV_Export_Global *EDIV_Export_Global ,\
TYPEOF_EDIV_Export_Global_Tab *EDIV_Export_Global_Tab ,\
TYPEOF_EDIV_Export_Global_Struct *EDIV_Export_Global_Struct,\
TYPEOF_EDIV_Export_Member_Int *EDIV_Export_Member_Int ,\
TYPEOF_EDIV_Export_Member_Str *EDIV_Export_Member_Str ,\
TYPEOF_EDIV_Export_Member_Tab *EDIV_Export_Member_Tab ,\
TYPEOF_EDIV_Export_EndStruct *EDIV_Export_EndStruct ,\
TYPEOF_EDIV_Export_Local *EDIV_Export_Local ,\
TYPEOF_EDIV_Export_Local_Tab *EDIV_Export_Local_Tab ,\
TYPEOF_EDIV_Export_Local_Struct *EDIV_Export_Local_Struct
// Voy a poner unos #defines para que la declaración de datos sea un poco más BASIC... :p
#ifdef CONST
# undef CONST
#endif
#define FUNCTION EDIV_Export
#define CONST EDIV_Export_Const
#define GLOBAL EDIV_Export_Global
#define GLOBAL_ARRAY EDIV_Export_Global_Tab
#define GLOBAL_STRUCT EDIV_Export_Global_Struct
#define _INT EDIV_Export_Member_Int
#define _STRING EDIV_Export_Member_Str
#define _ARRAY EDIV_Export_Member_Tab
#define END_STRUCT EDIV_Export_EndStruct()
#define LOCAL EDIV_Export_Local
#define LOCAL_ARRAY EDIV_Export_Local_Tab
#define LOCAL_STRUCT EDIV_Export_Local_Struct
// FUNCTION_PARAMS deben usarse como parametros para TODAS las funciones
#define FUNCTION_PARAMS int *params, int sp
// Se usa igual que el getparm() de DIV
#define getparm() params[--sp]
// Y esto por si los despistes xD
#define retval(a) return (a)

View file

@ -1,470 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "files.h"
char * possible_paths[32] =
{
"",
0
} ;
#define MAX_X_FILES 256
typedef struct
{
char name[40] ;
int offset ;
long pos ;
int size ;
int eof ;
FILE * fp ;
}
XFILE ;
XFILE x_file[MAX_X_FILES] ;
int x_files_count = 0 ;
/* Añade un nuevo archivo al PATH */
void file_add_xfile (file * fp, long offset, char * name, int size)
{
assert (x_files_count < MAX_X_FILES) ;
assert (fp->type == F_FILE) ;
x_file[x_files_count].fp = fp->fp ;
x_file[x_files_count].offset = offset ;
x_file[x_files_count].size = size ;
x_file[x_files_count].pos = offset ;
x_file[x_files_count].eof = 0 ;
strncpy (x_file[x_files_count].name, name, 39) ;
x_file[x_files_count].name[39] = 0 ;
x_files_count++ ;
}
/* Lee un bloque de datos del fichero */
int file_read (file * fp, void * buffer, int len)
{
assert (len != 0);
if (fp->type == F_XFILE)
{
XFILE * xf ;
int result ;
xf = &x_file[fp->n] ;
if (len + xf->pos > xf->offset + xf->size)
{
xf->eof = 1 ;
len = xf->size + xf->offset - xf->pos ;
}
fseek (xf->fp, xf->pos, SEEK_SET) ;
result = fread (buffer, 1, len, xf->fp) ;
xf->pos = ftell (xf->fp) ;
return result ;
}
if (fp->type == F_GZFILE)
{
int result = gzread (fp->gz, buffer, len) ;
if ((fp->error = result < 0) != 0)
result = 0 ;
return result ;
}
return fread (buffer, 1, len, fp->fp) ;
}
/* Guarda una cadena "cuoteada" al disco */
int file_puts (file * fp, const char * buffer)
{
char dest[1024], * optr ;
const char * ptr ;
ptr = buffer ;
optr = dest ;
while (*ptr)
{
if (optr > dest+1000)
{
*optr++ = '\\' ;
*optr++ = '\n' ;
*optr = 0 ;
file_write (fp, dest, optr-dest) ;
optr = dest ;
}
if (*ptr == '\n')
{
*optr++ = '\\' ;
*optr++ = 'n' ;
ptr++ ;
continue ;
}
if (*ptr == '\\')
{
*optr++ = '\\' ;
*optr++ = *ptr++ ;
continue ;
}
*optr++ = *ptr++ ;
}
*optr++ = '\n' ;
return file_write (fp, dest, optr-dest) ;
}
/* Recupera una cadena de un fichero y la "descuotea" */
int file_gets (file * fp, char * buffer, int len)
{
char * ptr, * result ;
if (fp->type == F_XFILE)
{
XFILE * xf ;
int l = 0, result = 0 ;
char * ptr = buffer ;
xf = &x_file[fp->n] ;
fseek (xf->fp, xf->pos, SEEK_SET) ;
while (l < len)
{
if (xf->pos >= xf->offset + xf->size)
{
xf->eof = 1 ;
break ;
}
fread (ptr, 1, 1, xf->fp) ;
result++ ;
xf->pos++ ;
if (*ptr++ == '\n')
break ;
}
*ptr = 0 ;
xf->pos = ftell(xf->fp) ;
}
else if (fp->type == F_GZFILE)
{
result = gzgets (fp->gz, buffer, len) ;
}
else
{
result = fgets(buffer, len, fp->fp);
}
if (result == 0) { buffer[0] = 0 ; return 0 ; }
ptr = buffer ;
while (*ptr)
{
if (*ptr == '\\')
{
if (ptr[1] == 'n') ptr[1] = '\n' ;
strcpy (ptr, ptr+1) ;
ptr++ ;
continue ;
}
if (*ptr == '\n')
{
*ptr = 0 ;
break ;
}
ptr++ ;
}
return strlen(buffer) ;
}
/* Escribe un bloque de datos en el fichero */
int file_write (file * fp, void * buffer, int len)
{
if (fp->type == F_XFILE)
{
XFILE * xf ;
int result ;
xf = &x_file[fp->n] ;
if (len + xf->pos > xf->offset + xf->size)
{
xf->eof = 1 ;
len = xf->size + xf->offset - xf->pos ;
}
fseek (xf->fp, xf->pos, SEEK_SET) ;
result = fwrite (buffer, 1, len, xf->fp) ;
xf->pos = ftell (xf->fp) ;
return result ;
}
if (fp->type == F_GZFILE)
{
int result = gzwrite (fp->gz, buffer, len) ;
if ((fp->error = result < 0) != 0)
result = 0 ;
return result < len ? 0 : 1 ;
}
return fwrite (buffer, 1, len, fp->fp) ;
}
/* Devuelve el tamaño de un fichero */
int file_size (file * fp)
{
long pos, size ;
if (fp->type == F_XFILE)
return x_file[fp->n].size ;
if (fp->type == F_GZFILE)
{
fprintf (stderr, "file_size: inválida en ficheros comprimidos\n") ;
return 0 ;
}
pos = ftell(fp->fp) ;
fseek (fp->fp, 0, SEEK_END) ;
size = ftell(fp->fp) ;
fseek (fp->fp, pos, SEEK_SET) ;
return size ;
}
/* Devuelve la posición actual de un fichero */
int file_pos (file * fp)
{
if (fp->type == F_XFILE)
return x_file[fp->n].pos - x_file[fp->n].offset ;
if (fp->type == F_GZFILE)
return gztell(fp->gz) ;
return ftell (fp->fp) ;
}
/* Posiciona el puntero de lectura/escritura dentro de un fichero */
int file_seek (file * fp, int pos, int where)
{
assert(fp);
if (fp->type == F_XFILE)
{
if (where == SEEK_END)
pos = x_file[fp->n].size - pos + 1 ;
else if (where == SEEK_CUR)
pos += x_file[fp->n].pos - x_file[fp->n].offset ;
if (x_file[fp->n].size < pos)
pos = x_file[fp->n].size ;
if (pos < 0) pos = 0 ;
x_file[fp->n].pos = pos + x_file[fp->n].offset ;
return x_file[fp->n].pos - x_file[fp->n].offset ;
}
if (fp->type == F_GZFILE)
{
assert(fp->gz);
return gzseek (fp->gz, pos, where) ;
}
assert(fp->fp);
return fseek (fp->fp, pos, where) ;
}
/* Abre un fichero */
static int open_raw (file * f, const char * filename, const char * mode)
{
if (!strchr(mode,'0'))
{
f->type = F_GZFILE ;
f->gz = gzopen (filename, mode) ;
if (f->gz) return 1 ;
}
f->type = F_FILE ;
f->fp = fopen (filename, mode) ;
if (f->fp) return 1 ;
return 0 ;
}
file * file_open (const char * filename, char * mode)
{
char name [256] ;
char path [256] ;
char here [256] ;
const char * c, * n ;
int i ;
#ifdef TARGET_linux
int j ;
#endif
file * f ;
f = (file *) malloc(sizeof(file)) ;
assert (f) ;
memset (f, 0, sizeof(f)) ;
c = filename ;
for (n = c+strlen(c) ; n >= c ; n--)
{
if (*n == '/' || *n == '\\')
{
c = n+1 ;
break ;
}
}
strcpy (name, c) ;
strcpy (path, filename) ;
path[c-filename] = 0 ;
#ifdef TARGET_linux
for (j = 0 ; path[j] ; j++)
if (path[j] == '\\') path[j] = '/' ;
#endif
if (strchr(mode,'r') && strchr(mode,'b'))
for (i = 0 ; i < x_files_count ; i++)
{
if (strcmp(name, x_file[i].name) == 0)
{
x_file[i].pos = x_file[i].offset ;
f->type = F_XFILE ;
f->n = i ;
return f ;
}
}
strcpy (here, path) ;
strcat (here, name) ;
if (open_raw (f, here, mode)) return f ;
/* Busca por el directorio de la extensión (directorio FPG para FPG) */
if (strchr(name,'.'))
{
strcpy (here, strchr(name,'.') + 1) ;
#ifdef TARGET_linux
strcat (here, "/") ;
#else
strcat (here, "\\") ;
#endif
strcat (here, path) ;
strcat (here, name) ;
if (open_raw (f, here, mode)) return f ;
}
for (i = 0 ; possible_paths[i] ; i++)
{
strcpy (here, possible_paths[i]) ;
strcat (here, name) ;
#ifdef TARGET_linux
for (j = 0 ; here[j] ; j++)
if (here[j] == '\\') here[j] = '/' ;
#endif
if (open_raw (f, here, mode)) return f ;
}
free (f) ;
return 0 ;
}
/* Cierra un fichero */
void file_close (file * fp)
{
if (fp->type == F_XFILE)
x_file[fp->n].pos = x_file[fp->n].offset ;
if (fp->type == F_FILE)
fclose(fp->fp) ;
if (fp->type == F_GZFILE)
gzclose(fp->gz) ;
free(fp) ;
}
/* Añade un nuevo directorio al PATH */
void file_addp (const char * path)
{
char truepath[256];
int n ;
strcpy (truepath, path) ;
for (n = 0 ; truepath[n] ; n++)
if (truepath[n] == '/')
truepath[n] = '\\' ;
if (truepath[strlen(truepath)-1] != '\\')
strcat (truepath, "\\") ;
for (n = 0 ; n < 31 && possible_paths[n] ; n++) ;
//possible_paths[n] = strdup (truepath) ;
possible_paths[n+1] = 0 ;
}
/* Devuelve cierto si existe el fichero */
int file_exists (char * filename)
{
file * fp ;
fp = file_open (filename, "rb") ;
if (fp)
{
file_close (fp) ;
return 1 ;
}
return 0 ;
}
/* Devuelve cierto si se leyó más allá del fin del fichero */
int file_eof (file * fp)
{
if (fp->type == F_XFILE)
{
XFILE * f = &x_file[fp->n] ;
return f->eof ;
}
if (fp->type == F_GZFILE)
{
if (fp->error) return 1 ;
return gzeof(fp->gz) ;
}
return feof(fp->fp) ;
}
/* Devuelve el FILE * correspondiente al fichero */
FILE * file_fp (file * f)
{
if (f->type == F_XFILE)
{
XFILE * xf = &x_file[f->n] ;
fseek (xf->fp, xf->pos, SEEK_SET) ;
return xf->fp ;
}
return f->fp ;
}

View file

@ -1,60 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __FILES_H
#define __FILES_H
/* Funciones de acceso a ficheros */
/* ------------------------------ */
/* Ahora mismo son casi wrappers de stdio.h, pero en el futuro
* el tipo "file" puede ser una estructura y las funciones,
* ofrecer soporte transparente para ficheros PAK, etc. */
#define F_XFILE 1
#define F_FILE 2
#define F_GZFILE 3
#include <zlib.h>
typedef struct
{
int type ;
FILE * fp ;
gzFile gz ;
int n ;
int error ;
}
file ;
extern file * file_open (const char * filename, char * mode) ;
extern int file_read (file * fp, void * buffer, int len) ;
extern int file_write (file * fp, void * buffer, int len) ;
extern int file_gets (file * fp, char * buffer, int len) ;
extern int file_puts (file * fp, const char * buffer) ;
extern int file_size (file * fp) ;
extern int file_pos (file * fp) ;
extern int file_seek (file * fp, int pos, int where) ;
extern void file_addp (const char * path) ;
extern void file_close (file * fp) ;
extern int file_exists (char * filename) ;
extern void file_add_xfile (file * fp, long offset, char * name, int size) ;
extern int file_eof (file * fp) ;
extern FILE * file_fp (file * fp) ;
#endif

View file

@ -1,138 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __FLIC_H
#define __FLIC_H
#include <SDL/SDL_types.h>
#ifndef __GNUC__
#define __PACKED
#define inline __inline
#else
#define __PACKED __attribute__ ((packed))
#endif
/* Reproducción de FLI */
/* ------------------- */
typedef struct {
Uint32 size; /* Size of FLIC including this header */
Uint16 type; /* File type 0xAF11, 0xAF12, 0xAF30, 0xAF44, ... */
Uint16 frames; /* Number of frames in first segment */
Uint16 width; /* FLIC width in pixels */
Uint16 height; /* FLIC height in pixels */
Uint16 depth; /* Bits per pixel (usually 8) */
Uint16 flags; /* Set to zero or to three */
Uint32 speed; /* Delay between frames */
Uint16 reserved1; /* Set to zero */
Uint32 created; /* Date of FLIC creation (FLC only) */
Uint32 creator; /* Serial number or compiler id (FLC only) */
Uint32 updated; /* Date of FLIC update (FLC only) */
Uint32 updater; /* Serial number (FLC only), see creator */
Uint16 aspect_dx; /* Width of square rectangle (FLC only) */
Uint16 aspect_dy; /* Height of square rectangle (FLC only) */
Uint16 ext_flags; /* EGI: flags for specific EGI extensions */
Uint16 keyframes; /* EGI: key-image frequency */
Uint16 totalframes; /* EGI: total number of frames (segments) */
Uint32 req_memory; /* EGI: maximum chunk size (uncompressed) */
Uint16 max_regions; /* EGI: max. number of regions in a CHK_REGION chunk */
Uint16 transp_num; /* EGI: number of transparent levels */
Uint8 reserved2[24]; /* Set to zero */
Uint32 oframe1; /* Offset to frame 1 (FLC only) */
Uint32 oframe2; /* Offset to frame 2 (FLC only) */
Uint8 reserved3[40]; /* Set to zero */
}
__PACKED
FLIC_HEADER;
typedef union
{
struct {
Uint32 size; /* Size of the chunk */
Uint16 type; /* Chunk type */
}
header ;
struct {
Uint32 size; /* Size of the chunk */
Uint16 type; /* Chunk type: 12 */
Uint16 first_line; /* First line */
Uint16 line_count; /* Number of lines in the chunk */
Uint8 data[0];
}
delta_fli ;
struct {
Uint32 size; /* Size of the chunk */
Uint16 type; /* Chunk type: 15, 12, etc. */
Uint8 data[0];
}
raw ;
}
FLIC_CHUNK ;
typedef struct
{
Uint32 size; /* Size of the frame, including subchunks */
Uint16 type; /* Chunk type: 0xF1FA */
Uint16 chunks; /* Number of subchunks */
Uint8 expand[8];
}
FLIC_FRAME ;
typedef struct
{
FLIC_HEADER header ;
FLIC_CHUNK * chunk ;
FLIC_FRAME * frame ;
Uint32 frame_reserved ;
GRAPH * bitmap ;
file * fp ;
int current_frame ;
int speed_ms ;
int last_frame_ms ;
int finished ;
}
FLIC ;
/* Tipos de chunk */
#define CHUNK_COLOR_256 4
#define CHUNK_COLOR_64 11
#define CHUNK_DELTA_FLI 12
#define CHUNK_DELTA_FLC 7
#define CHUNK_BLACK 13
#define CHUNK_BYTE_RUN 15
#define CHUNK_FLI_COPY 16
#define CHUNK_STAMP 18
#define CHUNK_PREFIX 0xF100
#define CHUNK_FRAME 0xF1FA
extern FLIC * flic_open (const char * filename) ;
extern void flic_destroy (FLIC * flic) ;
extern FLIC * flic_do_frame (FLIC * flic) ;
extern void flic_reset (FLIC * flic) ;
extern FLIC * current_fli ;
extern int current_fli_x ;
extern int current_fli_y ;
#endif

View file

@ -1,84 +0,0 @@
/* Rutinas matemáticas de punto fijo, basadas en Allegro */
typedef long int fixed ;
extern fixed cos_table[90001] ;
extern int cos_table_initialized ;
extern void init_cos_tables() ;
#ifndef __GNUC__
#define inline __inline
#endif
#ifdef DEBUG
# define __INLINE static
#else
# define __INLINE static inline
#endif
#define FIXED_PREC 12
__INLINE fixed ftofix(double x)
{
if (x > (1 << (31-FIXED_PREC))) {
return 0x7FFFFFFF;
}
if (x < -(1 << (31-FIXED_PREC))) {
return -(int)0x7FFFFFFF;
}
return (long)(x * (1 << FIXED_PREC) + (x < 0 ? -0.5 : 0.5));
}
__INLINE float fixtof (fixed x)
{
return (float)x / (1 << FIXED_PREC) ;
}
__INLINE fixed itofix(int x)
{
return x << FIXED_PREC ;
}
__INLINE int fixtoi(fixed x)
{
return (x >> FIXED_PREC) ;
}
__INLINE fixed fcos(int x)
{
if (x < 0) x = -x ;
if (x > 360000) x %= 360000 ;
if (x > 270000) return cos_table[360000 - x] ;
if (x > 180000) return -cos_table[x - 180000] ;
if (x > 90000) return -cos_table[180000 - x] ;
return cos_table[x] ;
}
__INLINE fixed fsin(int x)
{
if (x < 0) return -fsin(-x) ;
if (x > 360000) x %= 360000 ;
if (x > 270000) return -cos_table[x - 270000] ;
if (x > 180000) return -cos_table[270000 - x] ;
if (x > 90000) return cos_table[x - 90000 ] ;
return cos_table[90000 - x] ;
}
__INLINE fixed fmul(int x, int y)
{
return ftofix (fixtof(x) * fixtof(y)) ;
}
__INLINE fixed fdiv(int x, int y)
{
return ftofix (fixtof(x) / fixtof(y)) ;
}

View file

@ -1,35 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Variables globales de propósito general */
#include <SDL/SDL.h>
#include "files.h"
#include "xctype.h"
#include <zlib.h>
/* Constantes */
#ifndef M_PI
# define M_PI 3.14159265358979323846 /* pi */
#endif
int fpgs_cargados;
#include "grlib.h"
#include "flic.h"

View file

@ -1,207 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __GRLIB_H
#define __GRLIB_H
/* -------------------------------------------------------------------- */
/* Librería gráfica */
/* -------------------------------------------------------------------- */
/* Tipos y datos globales */
typedef struct _cpoint
{
short int x ;
short int y ;
}
CPOINT ;
typedef struct _animation
{
int frames ;
int length ;
int pos ;
int speed ;
int remaining ;
int last_frame ;
Sint16 * order ;
}
ANIMATION ;
typedef struct _bitmap
{
int width ;
int pitch ;
int height ;
int code ;
int depth ;
char name[32] ;
void * data ;
CPOINT * cpoints ;
int flags ;
Uint32 offset ;
ANIMATION * animation ;
Sint16 * blend_table ;
int modified ;
int info_flags ;
//Hasta q no esten los entrypoints
int x;
int y;
int z;
}
GRAPH ;
#define F_NCPOINTS 0x0FFF
#define F_ANIMATION 0x1000
#define GI_NOCOLORKEY 1
typedef struct _font
{
GRAPH * chars[256] ;
int voffset[256] ;
int width [256] ;
}
FONT ;
typedef struct _grlib
{
GRAPH * * maps ;
int map_count ;
int map_reserved ;
}
GRLIB ;
typedef struct _clipregion
{
int x ;
int y ;
int x2 ; /* Inclusive */
int y2 ;
}
REGION ;
extern int scr_initialized ;
extern REGION regions[32] ;
extern GRAPH * background ;
extern GRAPH * scrbitmap ;
extern GRLIB * syslib ;
extern int keytable[] ;
extern int last_frame_ms ;
extern int joy_x[], joy_y[], joy_b[] ;
#define region_get(n) ( ((n)>=0 && (n)<=31) ? &regions[n] : &regions[0] )
/* Inicialización y control de tiempo */
/* ---------------------------------- */
extern void gr_init (int w, int h) ;
extern void gr_set_fps (int fps, int max_jump) ;
extern void gr_wait_frame () ;
extern void gr_advance_timers () ;
extern void gr_draw_frame () ;
/* Paleta de colores */
/* ----------------- */
extern SDL_Color vpalette[256] ;
extern SDL_Color palette[256] ;
extern Uint16 colorequiv[256] ; /* Equivalencia paleta -> pantalla */
extern Uint16 colorghost[65536] ; /* Deja un color a 50% de intensidad */
extern GRAPH * background_8bits ;
extern int background_8bits_used ;
extern int background_is_black ;
extern Uint8 trans_table[256][256] ; /* Tabla de transparencias 8 bits */
extern int trans_table_updated ; /* 1 = La tabla es utilizable */
extern void gr_make_trans_table() ;
extern int palette_loaded ; /* ¿Se ha cargado ya la paleta inicial ? */
extern int palette_changed ; /* Poner a 1 cuando se cambien colores */
extern int fade_on ; /* ¿Hay un fade activo? */
extern int fade_step ; /* Si lo hay, posición (0=off) */
extern int gr_read_pal (file * file) ;
extern void gr_refresh_palette () ;
extern void gr_fade_init (int r, int g, int b, int speed, int dir) ;
extern void gr_fade_step () ;
extern void gr_roll_palette (int color0, int num, int inc) ;
extern int gr_find_nearest_color (int r, int g, int b) ;
extern void gr_set_rgb (int c, int r, int g, int b) ;
extern int gr_rgb (int r, int g, int b) ;
extern void gr_get_rgb (int color, int *r, int *g, int *b) ;
extern void gr_set_colors (int color, int num, Uint8 * pal) ;
/* Gestión de bitmaps y librerías de gráficos */
/* ------------------------------------------ */
extern int gr_load_map (const char * filename) ;
extern int gr_load_png (const char * filename) ;
extern int gr_load_pcx (const char * filename) ;
extern int gr_load_fpg (const char * filename) ;
extern int gr_load_pal (const char * filename) ;
extern int grlib_new () ;
extern GRLIB * grlib_get (int libid) ;
extern void grlib_destroy (int libid) ;
extern int grlib_add_map (GRLIB * lib, GRAPH * map) ;
extern int grlib_unload_map (GRLIB * lib, int mapcode) ;
extern GRAPH * bitmap_new (int code, int w, int h, int depth) ;
extern GRAPH * bitmap_clone (GRAPH * this) ;
extern GRAPH * bitmap_new_syslib (int w, int h, int depth) ;
extern GRAPH * bitmap_get (int libid, int mapcode) ;
extern void bitmap_destroy (GRAPH * map) ;
extern void bitmap_add_cpoint (GRAPH *map, int x, int y) ;
extern void bitmap_analize (GRAPH * bitmap) ;
extern void bitmap_animate (GRAPH * bitmap) ;
extern void bitmap_animate_to (GRAPH * bitmap, int pos, int speed) ;
/* Bajo nivel */
/* ---------- */
/* Flags para gr_blit */
#define B_HMIRROR 0x01
#define B_VMIRROR 0x02
#define B_TRANSLUCENT 0x04
#define B_NOCOLORKEY 0x80
/* Las funciones gráficas admiten dest=0 para referirse a la pantalla.
* Para poder usar esta funcionalidad, debe estar bloqueada antes */
extern int gr_lock_screen () ;
extern void gr_unlock_screen () ;
/* Primitivas gráficas */
extern void gr_clear (GRAPH * dest) ;
extern void gr_clear_as (GRAPH * dest, int color) ;
extern void gr_put_pixel (GRAPH * dest, int x, int y, int color) ;
extern int gr_get_pixel (GRAPH * dest, int x, int y) ;
extern void gr_setcolor (int c) ;
extern void gr_vline (GRAPH * dest, REGION * clip, int x, int y, int h) ;
#endif

View file

@ -1,106 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include "fxi.h"
extern SDL_Surface * screen ;
typedef struct {
Uint8 Manufacturer;
Uint8 Version;
Uint8 Encoding;
Uint8 BitsPerPixel;
Sint16 Xmin, Ymin, Xmax, Ymax;
Sint16 HDpi, VDpi;
Uint8 Colormap[48];
Uint8 Reserved;
Uint8 NPlanes;
Sint16 BytesPerLine;
Sint16 PaletteInfo;
Sint16 HscreenSize;
Sint16 VscreenSize;
Uint8 Filler[54];
}
PCXheader ;
/* --------------------------------- */
/* Rutina de lectura de gráficos PCX */
/* --------------------------------- */
GRAPH * gr_read_pcx (const char * filename)
{
PCXheader header ;
file * file ;
int width, height, x, y, p, count ;
GRAPH * bitmap ;
Uint8 * ptr, ch ;
file = file_open (filename, "rb") ;
// COMPLETAR ESTO (Daijo)
if (!file);
// Aki añadir el codigo
file_read (file, &header, sizeof(header)) ;
width = header.Xmax - header.Xmin + 1 ;
height = header.Ymax - header.Ymin + 1 ;
bitmap = bitmap_new (0, width, height, header.BitsPerPixel == 8 ? 8:16) ;
// if (!bitmap) gr_error ("%s: sin memoria\n", filename) ;
assert (width <= header.BytesPerLine) ;
if (header.BitsPerPixel == 8)
{
for (y = 0 ; y < height ; y++)
for (p = 0 ; p < header.NPlanes ; p++)
{
ptr = (Uint8 *)bitmap->data + bitmap->width * y ;
for (x = 0 ; x < header.BytesPerLine ; )
{
// if (file_read (file, &ch, 1) < 1)
// gr_error ("%s: fichero truncado", filename) ;
if ((ch & 0xC0) == 0xC0)
{
count = (ch & 0x3F) ;
file_read (file, &ch, 1) ;
}
else count = 1 ;
while (count--)
{
*ptr = ch ;
x++ ;
ptr += header.NPlanes ;
}
}
}
}
// else
// gr_error ("%s: profundidad de color no soportada\n", filename) ;
bitmap->modified = 1 ;
return bitmap ;
}

View file

@ -1,159 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <png.h>
#include "fxi.h"
extern SDL_Surface * screen ;
/* --------------------------------- */
/* Rutina de lectura de gráficos PNG */
/* --------------------------------- */
static file * png ;
static void user_read_data (png_structp png_ptr,
png_bytep data, png_size_t length)
{
file_read (png, data, length) ;
}
GRAPH * gr_read_png (const char * filename)
{
GRAPH * bitmap ;
unsigned int n, x ;
Uint16 * ptr ;
Uint32 * orig ;
Uint32 row[2048] ;
Uint32 Rshift, Gshift, Bshift ;
Uint32 Rmask, Gmask, Bmask ;
png_bytep rowpointers[2048] ;
png_structp png_ptr ;
png_infop info_ptr, end_info ;
png_uint_32 width, height, rowbytes;
int depth, color ;
/* Abre el fichero y se asegura de que screen está inicializada */
png = file_open (filename, "rb") ;
// if (!png) gr_error ("No existe %s\n", filename) ;
/* Prepara las estructuras internas */
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0) ;
info_ptr = png_create_info_struct (png_ptr) ;
end_info = png_create_info_struct (png_ptr) ;
// if (!info_ptr || !end_info) gr_error ("Error al cargar PNG") ;
/* Rutina de error */
if (setjmp (png_ptr->jmpbuf))
{
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info) ;
file_close (png) ;
return 0 ;
}
/* Recupera información sobre el PNG */
png_set_read_fn (png_ptr, 0, user_read_data) ;
png_read_info (png_ptr, info_ptr) ;
png_get_IHDR (png_ptr, info_ptr, &width, &height, &depth, &color, 0, 0 , 0) ;
// if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA)
// gr_error ("No se soportan PNG en escala de grises") ;
// if (height > 2048 || width > 2048)
// gr_error ("PNG demasiado grande") ;
/* Configura los distintos modos disponibles */
if (depth < 8)
png_set_expand(png_ptr) ;
if (depth == 16)
png_set_strip_16(png_ptr) ;
if (color == PNG_COLOR_TYPE_RGB)
png_set_filler (png_ptr, 0xFF, PNG_FILLER_AFTER) ;
png_set_bgr(png_ptr) ;
/* Recupera el fichero, convirtiendo a 16 bits si es preciso */
rowbytes = png_get_rowbytes (png_ptr, info_ptr) ;
bitmap = bitmap_new (0, width, height, color == PNG_COLOR_TYPE_PALETTE ? 8 : 16) ;
// if (!bitmap) gr_error ("Error al cargar PNG") ;
if (color == PNG_COLOR_TYPE_PALETTE)
{
for (n = 0 ; n < height ; n++)
rowpointers[n] = ((Uint8*)bitmap->data) + n*bitmap->width ;
png_read_image (png_ptr, rowpointers) ;
}
else
{
ptr = (Uint16*) bitmap->data ;
Bshift = 16-screen->format->Rshift ;
Gshift = 8-screen->format->Gshift ;
Rshift = 0-screen->format->Bshift ;
Bmask = 0xFF0000 ;
Gmask = 0x00FF00 ;
Rmask = 0x0000FF ;
for (n = 0 ; n < screen->format->Rloss ; n++) Rshift++, Rmask <<= 1 ;
for (n = 0 ; n < screen->format->Gloss ; n++) Gshift++, Gmask <<= 1 ;
for (n = 0 ; n < screen->format->Bloss ; n++) Bshift++, Bmask <<= 1 ;
Bmask &= 0xFF0000 ;
Gmask &= 0x00FF00 ;
Rmask &= 0x0000FF ;
for (n = 0 ; n < height ; n++)
{
rowpointers[0] = (void *)row ;
png_read_rows (png_ptr, rowpointers, 0, 1) ;
orig = row ;
for (x = 0 ; x < width ; x++)
{
if ((*orig) & 0x80000000)
{
*ptr = ((*orig & Rmask) >> Rshift)|
((*orig & Gmask) >> Gshift)|
((*orig & Bmask) >> Bshift) ;
if (!*ptr) (*ptr)++ ;
}
else *ptr = 0 ;
ptr++, orig++ ;
}
}
}
/* Fin */
png_read_end (png_ptr, 0) ;
file_close (png) ;
bitmap->modified = 1 ;
return bitmap ;
}

View file

@ -1,120 +0,0 @@
/* ------------------------------------------ */
/* Offsets de los datos globales predefinidos */
/* ------------------------------------------ */
#define MOUSEX 4*0
#define MOUSEY 4*1
#define MOUSEGRAPH 4*2
#define MOUSEFILE 4*3
#define MOUSEZ 4*4
#define MOUSEANGLE 4*5
#define MOUSESIZE 4*6
#define MOUSEFLAGS 4*7
#define MOUSEREGION 4*8
#define MOUSELEFT 4*9
#define MOUSEMIDDLE 4*10
#define MOUSERIGHT 4*11
#define SCROLLS 4*12
/* Siguen 10 estructuras scroll de tamaño 20 */
#define JOYLEFT 4*212
#define JOYRIGHT 4*213
#define JOYUP 4*214
#define JOYDOWN 4*215
#define JOYBUTTON1 4*216
#define JOYBUTTON2 4*217
#define JOYBUTTON3 4*218
#define JOYBUTTON4 4*219
#define SETUPCARD 4*220
#define SETUPPORT 4*221
#define SETUPIRQ 4*222
#define SETUPDMA 4*223
#define SETUPDMA2 4*224
#define SETUPMASTER 4*225
#define SETUPSOUNDFX 4*226
#define SETUPCDAUDIO 4*227
#define TIMER 4*228
/* Siguen 9 temporizadores adicionales */
#define TEXTZ 4*238
#define FADING 4*239
#define SHIFTSTATUS 4*240
#define ASCII 4*241
#define SCANCODE 4*242
#define JOYFILTER 4*243
#define JOYSTATUS 4*244
#define RESTORETYPE 4*245
#define DUMPTYPE 4*246
#define MAXPROCESSTIME 4*247
#define M7STRUCTS 4*248
/* Siguen 10 estructuras de tamaño 10 */
/* Extras */
#define FPS 4*348
#define TEXT_FLAGS 4*349
#define PANSEP 4*350
#define REVERB 4*351
#define VOLUME 4*352
#define SOUND_FREQ 4*353
#define SOUND_MODE 4*354
#define GRAPH_MODE 4*355
#define ARGC 4*356
#define ARGV_TABLE 4*357 /* 32+1 cadenas */
#define SPEED_GAUGE 4*390
/* ----------------------------------------- */
/* Offsets de los datos locales predefinidos */
/* ----------------------------------------- */
#define PROCESS_ID 4*0
#define ID_SCAN 4*1
#define PROCESS_TYPE 4*2
#define TYPE_SCAN 4*3
#define STATUS 4*4
#define PARAM_OFFSET 4*5
#define PROGRAM_INDEX 4*6
#define IS_EXECUTED 4*7
#define IS_PAINTED 4*8
#define DISTANCE_1 4*9
#define DISTANCE_2 4*10
#define FRAME_PERCENT 4*11
#define BOX_X0 4*12
#define BOX_Y0 4*13
#define BOX_X1 4*14
#define BOX_Y1 4*15
#define FATHER 4*16
#define SON 4*17
#define SMALLBRO 4*18
#define BIGBRO 4*19
#define PRIORITY 4*20
#define CTYPE 4*21
#define CFLAGS 4*22
#define COORDX 4*23
#define COORDY 4*24
#define COORDZ 4*25
#define GRAPHID 4*26
#define FLAGS 4*27
#define GRAPHSIZE 4*28
#define ANGLE 4*29
#define REGIONID 4*30
#define FILEID 4*31
#define XGRAPH 4*32
#define HEIGHT 4*33
#define CNUMBER 4*34
#define RESOLUTION 4*35
/* Algunas definiciones comunes */
#define STATUS_DEAD 0
#define STATUS_KILLED 1
#define STATUS_RUNNING 2
#define STATUS_SLEEPING 3
#define STATUS_FROZEN 4

View file

@ -1,171 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xctype.h"
/* Tabla de conversión de caracteres MS-DOS a Windows */
int dos_chars = 0 ;
unsigned char dos_to_win[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 248, 163, 216, 215, 131,
225, 237, 243, 250, 241, 209, 170, 186, 191, 174, 172, 189, 188, 161, 171, 187,
166, 166, 166, 166, 166, 193, 194, 192, 169, 166, 166, 43, 43, 162, 165, 43,
43, 45, 45, 43, 45, 43, 227, 195, 43, 43, 45, 45, 166, 45, 43, 164,
240, 208, 202, 203, 200, 105, 205, 206, 207, 43, 43, 166, 95, 166, 204, 175,
211, 223, 212, 210, 245, 213, 181, 254, 222, 218, 219, 217, 253, 221, 175, 180,
173, 177, 61, 190, 182, 167, 247, 184, 176, 168, 183, 185, 179, 178, 166, 160
} ;
/* Tabla de conversión de caracteres Windows a MS-DOS */
unsigned char win_to_dos[256] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 130, 159, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
255, 173, 189, 156, 207, 190, 254, 245, 249, 184, 166, 174, 170, 240, 169, 238,
248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168,
183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216,
209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225,
133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139,
208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231, 152
} ;
/* Tipos de caracter */
char c_type[256] ;
unsigned char c_upper[256] ;
unsigned char c_lower[256] ;
int c_type_initialized = 0 ;
unsigned char convert (unsigned char c)
{
return dos_chars ? c:win_to_dos[c] ;
}
static void set_c_range (int first, int last, int type)
{
while (first <= last) c_type[first++] |= type ;
}
static void set_c_from (const unsigned char * chars, int type)
{
if (dos_chars)
while (*chars) c_type[win_to_dos[*chars++]] |= type ;
else
while (*chars) c_type[*chars++] |= type ;
}
static void set_c_as (int prev_type, int type)
{
int n ;
for (n = 0 ; n < 256 ; n++)
{
if (c_type[n] & prev_type)
c_type[n] |= type ;
}
}
static void set_c_upper (const unsigned char * from, const unsigned char * to)
{
if (dos_chars)
while (*from) c_upper[win_to_dos[*from++]] = win_to_dos[*to++] ;
else
while (*from) c_upper[*from++] = *to++ ;
}
static void set_c_lower (const unsigned char * from, const unsigned char * to)
{
if (dos_chars)
while (*from) c_lower[win_to_dos[*from++]] = win_to_dos[*to++] ;
else
while (*from) c_lower[*from++] = *to++ ;
}
void init_c_type ()
{
int c ;
memset (c_type, 0, sizeof(c_type)) ;
if (dos_chars)
for (c = 0 ; c < 256 ; c++)
c_lower[c] = c_upper[c] = win_to_dos[c] ;
else
for (c = 0 ; c < 256 ; c++)
c_lower[c] = c_upper[c] = c ;
set_c_upper ("abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
set_c_lower ("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvwxyz") ;
#ifdef RESPETAR_ACENTOS
set_c_upper ("áéíóúñçàèìòùäëïöüýâêîôûæãåõ",
"ÁÉÍÓÚÑÇÀÈÌÒÙÄËÏÖÜÝÂÊÎÔÛÆÃÅÕ") ;
set_c_lower ("ÁÉÍÓÚÑÇÀÈÌÒÙÄËÏÖÜÝÂÊÎÔÛÆÃÅÕ",
"áéíóúñçàèìòùäëïöüýâêîôûæãåõ") ;
#else
set_c_upper ("áéíóúñÑçÇàèìòùäëïöüýâêîôûæãåõÁÉÍÓÚ",
"AEIOUNNCCAEIOUAEIOUYAEIOUÆAAOAEIOU") ;
set_c_lower ("áéíóúñÑçÇàèìòùäëïöüýâêîôûæãåõÁÉÍÓÚ",
"aeiounnccaeiouaeiouyaeiouÆaaoaeiou") ;
#endif
set_c_from (" \t\n\r", CTYPE_SPACE) ;
set_c_range ('0', '9', CTYPE_NUM) ;
set_c_range ('A', 'Z', CTYPE_ALPHA) ;
set_c_range ('a', 'z', CTYPE_ALPHA) ;
set_c_from ("áéíóúÁÉÍÓÚñÑçÇàèìòùÀÈÌÒÙäëïöüÄËÏÖÜÿýâêîôûÂÊÎÔÛ"
"æÆãåðõªºÃÅÐÕØ", CTYPE_ALPHA) ;
set_c_as (CTYPE_ALPHA, CTYPE_WORDCHAR) ;
set_c_from ("_", CTYPE_WORDCHAR) ;
set_c_as (CTYPE_WORDCHAR, CTYPE_WORDFIRST) ;
set_c_range ('0', '9', CTYPE_WORDCHAR) ;
c_type_initialized = 1 ;
}

View file

@ -1,43 +0,0 @@
/* Fenix - Compilador/intérprete de videojuegos
* Copyright (C) 1999 José Luis Cebrián Pagüe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
extern int dos_chars ; /* 1 = Código fuente en caracteres MS-DOS */
extern char c_type[256] ;
extern unsigned char c_upper[256] ;
extern unsigned char c_lower[256] ;
#define ISALPHA(c) (c_type [(unsigned char)c] & CTYPE_ALPHA)
#define ISSPACE(c) (c_type [(unsigned char)c] & CTYPE_SPACE)
#define ISNUM(c) (c_type [(unsigned char)c] & CTYPE_NUM)
#define ISWORDCHAR(c) (c_type [(unsigned char)c] & CTYPE_WORDCHAR)
#define ISWORDFIRST(c) (c_type [(unsigned char)c] & CTYPE_WORDFIRST)
#define TOUPPER(c) (c_upper[(unsigned char)c])
#define TOLOWER(c) (c_lower[(unsigned char)c])
extern unsigned char convert (unsigned char c) ;
extern void init_c_type () ;
extern unsigned char dos_to_win[256] ;
extern unsigned char win_to_dos[256] ;
#define CTYPE_ALPHA 1
#define CTYPE_NUM 2
#define CTYPE_WORDCHAR 4
#define CTYPE_WORDFIRST 8
#define CTYPE_SPACE 16