tests, tlib.c, tlib.h: silence / fix warnings:
fix wrong error check in SimpleRleDecode() (thanks gcc -Wsign-compare). fix some old wrong warning fixes in glide2x tree. also remove ctype.h dependency and use a generic strupr().
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
#include <stdarg.h>
|
||||
#ifndef __linux__
|
||||
#include <conio.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -337,7 +335,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -425,15 +426,6 @@ void tlConSet( float minX, float minY,
|
||||
return;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Function: tlConOutput
|
||||
Date: 2/28
|
||||
@@ -454,13 +446,19 @@ int tlConOutput( const char *fmt, ... ) {
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char* temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
strupr( buffer );
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -950,10 +948,14 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow = (float)fontTable[(int) character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow = (float)fontTable[(int) character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow = a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow = a.tmuvtx[0].tow + (float)fontHeight;
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
a.tmuvtx[0].tow + (float)fontHeight;
|
||||
|
||||
grDrawTriangle( &a, &d, &c );
|
||||
grDrawTriangle( &a, &b, &d );
|
||||
@@ -963,6 +965,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -983,6 +986,74 @@ static void putTex( FxU32 addr, void *storage ) {
|
||||
grTexDownloadMipMap( 0, addr, GR_MIPMAPLEVELMASK_BOTH, &fontInfo );
|
||||
}
|
||||
|
||||
|
||||
static void grabTex( FxU32 addr, void *storage ) {
|
||||
static FxU16 tmpSpace[256][256];
|
||||
GrTexInfo texInfo;
|
||||
GrVertex a, b, c, d;
|
||||
|
||||
grGlideGetState( &state );
|
||||
grDitherMode( GR_DITHER_DISABLE );
|
||||
grColorMask( FXTRUE, FXFALSE );
|
||||
grSstOrigin( GR_ORIGIN_UPPER_LEFT );
|
||||
grCullMode( GR_CULL_DISABLE );
|
||||
|
||||
/* Grab Upper Left 256*256 of frame buffer */
|
||||
readRegion( tmpSpace, 0, 0, 256, 256 );
|
||||
|
||||
/* Grab First 256x256 MM in Texture Ram */
|
||||
texInfo.smallLod = GR_LOD_256;
|
||||
texInfo.largeLod = GR_LOD_256;
|
||||
texInfo.aspectRatio = GR_ASPECT_1x1;
|
||||
texInfo.format = GR_TEXFMT_RGB_565;
|
||||
texInfo.data = 0;
|
||||
grTexMipMapMode( 0, GR_MIPMAP_DISABLE, FXFALSE );
|
||||
grTexFilterMode( 0,
|
||||
GR_TEXTUREFILTER_POINT_SAMPLED,
|
||||
GR_TEXTUREFILTER_POINT_SAMPLED );
|
||||
grTexCombine( 0,
|
||||
GR_COMBINE_FUNCTION_LOCAL,
|
||||
GR_COMBINE_FACTOR_NONE,
|
||||
GR_COMBINE_FUNCTION_LOCAL,
|
||||
GR_COMBINE_FACTOR_NONE,
|
||||
FXFALSE,
|
||||
FXFALSE );
|
||||
grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
|
||||
GR_COMBINE_FACTOR_ONE,
|
||||
GR_COMBINE_LOCAL_NONE,
|
||||
GR_COMBINE_OTHER_TEXTURE,
|
||||
FXFALSE );
|
||||
grTexSource( 0, addr, GR_MIPMAPLEVELMASK_BOTH, &texInfo );
|
||||
grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
|
||||
GR_BLEND_ONE, GR_BLEND_ZERO);
|
||||
grDepthBufferFunction( GR_DEPTHBUFFER_DISABLE );
|
||||
grAlphaTestFunction( GR_CMP_ALWAYS );
|
||||
grFogMode( GR_FOG_DISABLE );
|
||||
grCullMode( GR_CULL_DISABLE );
|
||||
grChromakeyMode( GR_CHROMAKEY_DISABLE );
|
||||
/*-------------------
|
||||
A---B
|
||||
| \ |
|
||||
C---D
|
||||
-------------------*/
|
||||
a.oow = a.tmuvtx[0].oow = 1.0f;
|
||||
b = c = d = a;
|
||||
a.x = c.x = a.y = b.y = 0.5f;
|
||||
b.x = d.x = c.y = d.y = 255.6f;
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow = a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
0.5f;
|
||||
b.tmuvtx[0].sow = d.tmuvtx[0].sow = c.tmuvtx[0].tow = d.tmuvtx[0].tow =
|
||||
0.5f;
|
||||
grDrawTriangle( &a, &d, &c );
|
||||
grDrawTriangle( &a, &b, &d );
|
||||
readRegion( storage, 0, 0, 256, 256 );
|
||||
|
||||
/* Restore The Upper Left Hand of Frame Buffer */
|
||||
writeRegion( tmpSpace, 0, 0, 256, 256 );
|
||||
grGlideSetState( &state );
|
||||
return;
|
||||
}
|
||||
|
||||
static void readRegion( void *data,
|
||||
int sx, int sy,
|
||||
int w, int h ) {
|
||||
@@ -1042,6 +1113,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1098,6 +1170,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1110,6 +1184,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1118,8 +1194,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1355,8 +1429,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
return !!fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else
|
||||
@@ -1394,8 +1469,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else /* __WIN32__ */
|
||||
@@ -1622,7 +1698,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
@@ -1634,7 +1710,7 @@ tlErrorMessage( char *err)
|
||||
fflush(stdout);
|
||||
|
||||
MessageBox( hWndMain, err, "ERROR", MB_OK );
|
||||
return FALSE;
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,19 +19,20 @@
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* If not debugging, change the meaning of the ANSI assert
|
||||
* so that it is a harmless wrapper rather than ((void)0) as in <assert.h>
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#define NDEBUG
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
int tlGetOpt( int argc, char *argv[], const char *tags, char *match, char **remArgs[] );
|
||||
@@ -98,7 +99,7 @@ void tlProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include <stdarg.h>
|
||||
#ifndef __linux__
|
||||
#include <conio.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -337,7 +335,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -425,15 +426,6 @@ void tlConSet( float minX, float minY,
|
||||
return;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Function: tlConOutput
|
||||
Date: 2/28
|
||||
@@ -454,13 +446,19 @@ int tlConOutput( const char *fmt, ... ) {
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char* temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
strupr( buffer );
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -950,10 +948,14 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow = (float)fontTable[(int) character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow = (float)fontTable[(int) character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow = a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow = a.tmuvtx[0].tow + (float)fontHeight;
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
a.tmuvtx[0].tow + (float)fontHeight;
|
||||
|
||||
grDrawTriangle( &a, &d, &c );
|
||||
grDrawTriangle( &a, &b, &d );
|
||||
@@ -963,6 +965,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -983,6 +986,74 @@ static void putTex( FxU32 addr, void *storage ) {
|
||||
grTexDownloadMipMap( 0, addr, GR_MIPMAPLEVELMASK_BOTH, &fontInfo );
|
||||
}
|
||||
|
||||
|
||||
static void grabTex( FxU32 addr, void *storage ) {
|
||||
static FxU16 tmpSpace[256][256];
|
||||
GrTexInfo texInfo;
|
||||
GrVertex a, b, c, d;
|
||||
|
||||
grGlideGetState( &state );
|
||||
grDitherMode( GR_DITHER_DISABLE );
|
||||
grColorMask( FXTRUE, FXFALSE );
|
||||
grSstOrigin( GR_ORIGIN_UPPER_LEFT );
|
||||
grCullMode( GR_CULL_DISABLE );
|
||||
|
||||
/* Grab Upper Left 256*256 of frame buffer */
|
||||
readRegion( tmpSpace, 0, 0, 256, 256 );
|
||||
|
||||
/* Grab First 256x256 MM in Texture Ram */
|
||||
texInfo.smallLod = GR_LOD_256;
|
||||
texInfo.largeLod = GR_LOD_256;
|
||||
texInfo.aspectRatio = GR_ASPECT_1x1;
|
||||
texInfo.format = GR_TEXFMT_RGB_565;
|
||||
texInfo.data = 0;
|
||||
grTexMipMapMode( 0, GR_MIPMAP_DISABLE, FXFALSE );
|
||||
grTexFilterMode( 0,
|
||||
GR_TEXTUREFILTER_POINT_SAMPLED,
|
||||
GR_TEXTUREFILTER_POINT_SAMPLED );
|
||||
grTexCombine( 0,
|
||||
GR_COMBINE_FUNCTION_LOCAL,
|
||||
GR_COMBINE_FACTOR_NONE,
|
||||
GR_COMBINE_FUNCTION_LOCAL,
|
||||
GR_COMBINE_FACTOR_NONE,
|
||||
FXFALSE,
|
||||
FXFALSE );
|
||||
grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
|
||||
GR_COMBINE_FACTOR_ONE,
|
||||
GR_COMBINE_LOCAL_NONE,
|
||||
GR_COMBINE_OTHER_TEXTURE,
|
||||
FXFALSE );
|
||||
grTexSource( 0, addr, GR_MIPMAPLEVELMASK_BOTH, &texInfo );
|
||||
grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
|
||||
GR_BLEND_ONE, GR_BLEND_ZERO);
|
||||
grDepthBufferFunction( GR_DEPTHBUFFER_DISABLE );
|
||||
grAlphaTestFunction( GR_CMP_ALWAYS );
|
||||
grFogMode( GR_FOG_DISABLE );
|
||||
grCullMode( GR_CULL_DISABLE );
|
||||
grChromakeyMode( GR_CHROMAKEY_DISABLE );
|
||||
/*-------------------
|
||||
A---B
|
||||
| \ |
|
||||
C---D
|
||||
-------------------*/
|
||||
a.oow = a.tmuvtx[0].oow = 1.0f;
|
||||
b = c = d = a;
|
||||
a.x = c.x = a.y = b.y = 0.5f;
|
||||
b.x = d.x = c.y = d.y = 255.6f;
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow = a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
0.5f;
|
||||
b.tmuvtx[0].sow = d.tmuvtx[0].sow = c.tmuvtx[0].tow = d.tmuvtx[0].tow =
|
||||
0.5f;
|
||||
grDrawTriangle( &a, &d, &c );
|
||||
grDrawTriangle( &a, &b, &d );
|
||||
readRegion( storage, 0, 0, 256, 256 );
|
||||
|
||||
/* Restore The Upper Left Hand of Frame Buffer */
|
||||
writeRegion( tmpSpace, 0, 0, 256, 256 );
|
||||
grGlideSetState( &state );
|
||||
return;
|
||||
}
|
||||
|
||||
static void readRegion( void *data,
|
||||
int sx, int sy,
|
||||
int w, int h ) {
|
||||
@@ -1042,6 +1113,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1098,6 +1170,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1110,6 +1184,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1118,8 +1194,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1355,8 +1429,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
return !!fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else
|
||||
@@ -1394,8 +1469,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else /* __WIN32__ */
|
||||
@@ -1622,7 +1698,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
|
||||
@@ -19,19 +19,20 @@
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* If not debugging, change the meaning of the ANSI assert
|
||||
* so that it is a harmless wrapper rather than ((void)0) as in <assert.h>
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#define NDEBUG
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
int tlGetOpt( int argc, char *argv[], const char *tags, char *match, char **remArgs[] );
|
||||
@@ -98,7 +99,7 @@ void tlProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include <stdarg.h>
|
||||
#ifndef __linux__
|
||||
#include <conio.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -337,8 +335,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -426,15 +426,6 @@ void tlConSet( float minX, float minY,
|
||||
return;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
Function: tlConOutput
|
||||
Date: 2/28
|
||||
@@ -449,20 +440,25 @@ static void strupr(char *str) {
|
||||
int - number of chars printed
|
||||
-------------------------------------------------------------------*/
|
||||
int tlConOutput( const char *fmt, ... ) {
|
||||
static short tmpTex[256*256];
|
||||
int rv = 0;
|
||||
va_list argptr;
|
||||
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char *temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
strupr( buffer );
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -530,8 +526,6 @@ void tlConClear() {
|
||||
none
|
||||
-------------------------------------------------------------------*/
|
||||
void tlConRender( void ) {
|
||||
static short tmpTex[256*256];
|
||||
|
||||
if( fontInitialized ) {
|
||||
int x, y;
|
||||
|
||||
@@ -955,9 +949,9 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[character][0];
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[character][1];
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
@@ -971,6 +965,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -1118,6 +1113,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1174,6 +1170,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1186,6 +1184,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1194,8 +1194,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1431,9 +1429,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
return FXTRUE;
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else
|
||||
@@ -1471,8 +1469,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
#else /* __WIN32__ */
|
||||
@@ -1699,7 +1698,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
@@ -1711,7 +1710,7 @@ tlErrorMessage( char *err)
|
||||
fflush(stdout);
|
||||
|
||||
MessageBox( hWndMain, err, "ERROR", MB_OK );
|
||||
return FALSE;
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* If not debugging, change the meaning of the ANSI assert
|
||||
* so that it is a harmless wrapper rather than ((void)0) as in <assert.h>
|
||||
*/
|
||||
@@ -34,7 +32,7 @@ extern "C" {
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (exp)
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
int tlGetOpt( int argc, char *argv[], const char *tags, char *match, char **remArgs[] );
|
||||
@@ -101,7 +99,7 @@ void tlProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/*
|
||||
** Insert new header here
|
||||
**
|
||||
**
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -31,15 +29,6 @@ static FxBool fullScreen = FXTRUE;
|
||||
static void *state = NULL;
|
||||
static void *vlstate = NULL;
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FxBool
|
||||
tlOkToRender()
|
||||
{
|
||||
@@ -387,8 +376,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -501,31 +492,25 @@ void tlConSet( float minX, float minY,
|
||||
int - number of chars printed
|
||||
-------------------------------------------------------------------*/
|
||||
int tlConOutput( const char *fmt, ... ) {
|
||||
static short tmpTex[256*256];
|
||||
int rv = 0;
|
||||
va_list argptr;
|
||||
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char* temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
#if defined(__MWERKS__)
|
||||
{
|
||||
char* temp = buffer;
|
||||
|
||||
while(*temp != '\0') {
|
||||
*temp = toupper(*temp);
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
strupr( buffer );
|
||||
#endif
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -593,8 +578,6 @@ void tlConClear() {
|
||||
none
|
||||
-------------------------------------------------------------------*/
|
||||
void tlConRender( void ) {
|
||||
static short tmpTex[256*256];
|
||||
|
||||
if( fontInitialized ) {
|
||||
int x, y;
|
||||
|
||||
@@ -1061,9 +1044,9 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[character][0];
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[character][1];
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
@@ -1077,6 +1060,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -1224,6 +1208,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1280,6 +1265,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1292,6 +1279,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1300,8 +1289,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1537,8 +1524,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1630,8 +1618,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1822,7 +1811,7 @@ main( int argc, char **argv)
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
/*
|
||||
** Insert new header here
|
||||
**
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
@@ -18,7 +15,7 @@ extern "C" {
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (exp)
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
/* The two most commonly defined macros in the known universe */
|
||||
@@ -149,7 +146,7 @@ void tlCProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
**
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -30,15 +29,6 @@ static FxBool fullScreen = FXTRUE;
|
||||
static void *state = NULL;
|
||||
static void *vlstate = NULL;
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FxBool
|
||||
tlOkToRender()
|
||||
{
|
||||
@@ -386,8 +376,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -500,31 +492,25 @@ void tlConSet( float minX, float minY,
|
||||
int - number of chars printed
|
||||
-------------------------------------------------------------------*/
|
||||
int tlConOutput( const char *fmt, ... ) {
|
||||
static short tmpTex[256*256];
|
||||
int rv = 0;
|
||||
va_list argptr;
|
||||
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char* temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
#if defined(__MWERKS__)
|
||||
{
|
||||
char* temp = buffer;
|
||||
|
||||
while(*temp != '\0') {
|
||||
*temp = toupper(*temp);
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
strupr( buffer );
|
||||
#endif
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -592,8 +578,6 @@ void tlConClear() {
|
||||
none
|
||||
-------------------------------------------------------------------*/
|
||||
void tlConRender( void ) {
|
||||
static short tmpTex[256*256];
|
||||
|
||||
if( fontInitialized ) {
|
||||
int x, y;
|
||||
|
||||
@@ -1060,9 +1044,9 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[character][0];
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[character][1];
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
@@ -1076,6 +1060,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -1223,6 +1208,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1279,6 +1265,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1291,6 +1279,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1299,8 +1289,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1536,8 +1524,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1629,8 +1618,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1821,7 +1811,7 @@ main( int argc, char **argv)
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
** Insert new header here
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
@@ -17,7 +15,7 @@ extern "C" {
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (exp)
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
/* The two most commonly defined macros in the known universe */
|
||||
@@ -148,7 +146,7 @@ void tlCProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
**
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -126,15 +125,6 @@ static FxBool okToRender = FXTRUE;
|
||||
static void *state = NULL;
|
||||
static void *vlstate = NULL;
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FxBool tlOkToRender(void)
|
||||
{
|
||||
return okToRender;
|
||||
@@ -439,7 +429,7 @@ static tlPixelFormat pfTable[] = {
|
||||
int tlGetPixelFormat( const char *pf )
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (sizeof(pfTable) / sizeof(tlPixelFormat)); i++) {
|
||||
for (i = 0; i < (int)(sizeof(pfTable)/sizeof(tlPixelFormat)); i++) {
|
||||
if ( !strcmp( pf, pfTable[i].name ) ) {
|
||||
return pfTable[i].type;
|
||||
}
|
||||
@@ -608,8 +598,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static int drawChar( char character,
|
||||
float x, float y,
|
||||
@@ -1355,7 +1347,7 @@ int _tlLoadTXS( const char *filename,
|
||||
if(stream==NULL) return FXFALSE;
|
||||
|
||||
/* Read the full header */
|
||||
if ( fscanf ( stream, "%4s %f %d %d %d %d %8x",
|
||||
if ( fscanf ( stream, "%4s %f %hu %hu %hu %hu %8x",
|
||||
cookie,
|
||||
&info.version,
|
||||
&info.format,
|
||||
@@ -1494,7 +1486,7 @@ int _tlLoadTXS( const char *filename,
|
||||
(info.format == GR_TEXFMT_AYIQ_8422))
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < sizeof(GuNccTable) >> 2; i++){
|
||||
for (i = 0; i < (int) sizeof(GuNccTable) >> 2; i++){
|
||||
if (!_Read32 (stream, &((FxU32 *)table)[i]))
|
||||
{
|
||||
#if DEBUG
|
||||
@@ -1722,9 +1714,9 @@ static int drawChar( char character,
|
||||
#define TEXTURE_EPS 0.1f
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[(int)character][0] + TEXTURE_EPS;
|
||||
(float)fontTable[(unsigned char)character][0] + TEXTURE_EPS;
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[(int)character][1] + TEXTURE_EPS;
|
||||
(float)fontTable[(unsigned char)character][1] + TEXTURE_EPS;
|
||||
|
||||
/* we need to multiply times 2 since Glide wants texture coords in
|
||||
* the range of 0..255 and our font texture is only 128 wide */
|
||||
@@ -1750,6 +1742,7 @@ static int drawChar( char character,
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -1901,6 +1894,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format )
|
||||
@@ -1958,6 +1952,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1970,6 +1966,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1978,8 +1976,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -2198,9 +2194,9 @@ int tlKbHit( void ) {
|
||||
return lin_kbhit();
|
||||
}
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
return FXTRUE;
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
@@ -2287,10 +2283,10 @@ char tlGetCH( void )
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
fprintf(stderr, err);
|
||||
return FXTRUE;
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32 tlGethWnd( void ) {
|
||||
@@ -2535,7 +2531,7 @@ main( int argc, char **argv)
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
@@ -2547,7 +2543,7 @@ tlErrorMessage( char *err)
|
||||
fflush(stdout);
|
||||
|
||||
MessageBox( hWndMain, err, "ERROR", MB_OK );
|
||||
return FALSE;
|
||||
return FXFALSE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
/*-------------------------------------------------------------------
|
||||
@@ -2663,7 +2659,7 @@ void tlInitGlideExt ( tlGlideExtension *gExt)
|
||||
memset(gExt, 0, sizeof(tlGlideExtension));
|
||||
|
||||
extension = grGetString(GR_EXTENSION);
|
||||
if (extstr = strstr(extension, "PIXEXT")) {
|
||||
if ((extstr = strstr(extension, "PIXEXT")) != NULL) {
|
||||
if (!strncmp(extstr, "PIXEXT", 6)) {
|
||||
gExt->grSstWinOpen = grGetProcAddress("grSstWinOpenExt");
|
||||
gExt->grColorMask = grGetProcAddress("grColorMaskExt");
|
||||
@@ -2681,7 +2677,7 @@ void tlInitGlideExt ( tlGlideExtension *gExt)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extstr = strstr(extension, "COMBINE")) {
|
||||
if ((extstr = strstr(extension, "COMBINE")) != NULL) {
|
||||
if (!strncmp(extstr, "COMBINE", 7)) {
|
||||
gExt->grColorCombineExt = grGetProcAddress("grColorCombineExt");
|
||||
gExt->grAlphaCombineExt = grGetProcAddress("grAlphaCombineExt");
|
||||
@@ -2693,14 +2689,14 @@ void tlInitGlideExt ( tlGlideExtension *gExt)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extstr = strstr(extension, "TEXFMT")) {
|
||||
if ((extstr = strstr(extension, "TEXFMT")) != NULL) {
|
||||
if (!strncmp(extstr, "TEXFMT", 6)) {
|
||||
gExt->canDo32BitTexture = FXTRUE;
|
||||
gExt->canDoFXT1Texture = FXTRUE;
|
||||
gExt->canDo2kTexture = FXTRUE;
|
||||
}
|
||||
}
|
||||
if (extstr = strstr(extension, "TEXUMA")) {
|
||||
if ((extstr = strstr(extension, "TEXUMA")) != NULL) {
|
||||
if (!strncmp(extstr, "TEXUMA", 6)) {
|
||||
gExt->umaExt = FXTRUE;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
@@ -33,7 +32,7 @@ extern "C" {
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (exp)
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
/* The two most commonly defined macros in the known universe */
|
||||
@@ -227,7 +226,7 @@ GrContext_t* tlGetRenderContext(FxU32 glideDeviceNum, FxU32 hWnd,
|
||||
int nColBuf, int nAuxBuf);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
**
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -30,15 +29,6 @@ static FxBool fullScreen = FXTRUE;
|
||||
static void *state = NULL;
|
||||
static void *vlstate = NULL;
|
||||
|
||||
#ifdef __linux__
|
||||
static void strupr(char *str) {
|
||||
while (*str) {
|
||||
if (islower(*str)) *str=toupper(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FxBool
|
||||
tlOkToRender()
|
||||
{
|
||||
@@ -386,8 +376,10 @@ static const int charsPerLine = 14;
|
||||
|
||||
static int fontInitialized;
|
||||
|
||||
#if 0 /* not used */
|
||||
static void grabTex( FxU32 addr, void *storage );
|
||||
static void putTex( FxU32 addr, void *storage );
|
||||
#endif
|
||||
static void consoleScroll( void );
|
||||
static void drawChar( char character, float x, float y, float w, float h );
|
||||
|
||||
@@ -500,31 +492,25 @@ void tlConSet( float minX, float minY,
|
||||
int - number of chars printed
|
||||
-------------------------------------------------------------------*/
|
||||
int tlConOutput( const char *fmt, ... ) {
|
||||
static short tmpTex[256*256];
|
||||
int rv = 0;
|
||||
va_list argptr;
|
||||
|
||||
if( fontInitialized ) {
|
||||
static char buffer[1024];
|
||||
const char *c;
|
||||
char* temp;
|
||||
|
||||
va_start( argptr, fmt );
|
||||
rv = vsprintf( buffer, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
#if defined(__MWERKS__)
|
||||
{
|
||||
char* temp = buffer;
|
||||
|
||||
while(*temp != '\0') {
|
||||
*temp = toupper(*temp);
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
strupr( buffer );
|
||||
#endif
|
||||
|
||||
temp = buffer;
|
||||
while(*temp != '\0') {
|
||||
if (*temp >= 'a' && *temp <= 'z')
|
||||
*temp -= ('a'-'A');
|
||||
temp++;
|
||||
}
|
||||
|
||||
c = buffer;
|
||||
|
||||
/* update console grid */
|
||||
@@ -592,8 +578,6 @@ void tlConClear() {
|
||||
none
|
||||
-------------------------------------------------------------------*/
|
||||
void tlConRender( void ) {
|
||||
static short tmpTex[256*256];
|
||||
|
||||
if( fontInitialized ) {
|
||||
int x, y;
|
||||
|
||||
@@ -1060,9 +1044,9 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
grConstantColorValue( consoleColor );
|
||||
|
||||
a.tmuvtx[0].sow = c.tmuvtx[0].sow =
|
||||
(float)fontTable[character][0];
|
||||
(float)fontTable[(unsigned char)character][0];
|
||||
a.tmuvtx[0].tow = b.tmuvtx[0].tow =
|
||||
(float)fontTable[character][1];
|
||||
(float)fontTable[(unsigned char)character][1];
|
||||
d.tmuvtx[0].sow = b.tmuvtx[0].sow =
|
||||
a.tmuvtx[0].sow + (float)fontWidth;
|
||||
d.tmuvtx[0].tow = c.tmuvtx[0].tow =
|
||||
@@ -1076,6 +1060,7 @@ static void drawChar( char character, float x, float y, float w, float h ) {
|
||||
|
||||
|
||||
|
||||
#if 0 /* not used */
|
||||
static void readRegion( void *data,
|
||||
int x, int y,
|
||||
int w, int h );
|
||||
@@ -1223,6 +1208,7 @@ static void writeRegion( void *data,
|
||||
assert( grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GrTexTable_t texTableType( GrTextureFormat_t format ) {
|
||||
@@ -1279,6 +1265,8 @@ SimpleRleDecode
|
||||
run = *mem & 0x7f;
|
||||
run++;
|
||||
mem++;
|
||||
if (count < run)
|
||||
return FXFALSE;
|
||||
count -= run;
|
||||
while (run) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1291,6 +1279,8 @@ SimpleRleDecode
|
||||
lit = *mem;
|
||||
lit++;
|
||||
mem++;
|
||||
if (count < lit)
|
||||
return FXFALSE;
|
||||
count -= lit;
|
||||
while (lit) {
|
||||
memcpy(buff, mem, pixelsize);
|
||||
@@ -1299,8 +1289,6 @@ SimpleRleDecode
|
||||
mem+=pixelsize;
|
||||
}
|
||||
}
|
||||
if (count < 0)
|
||||
return FXFALSE;
|
||||
}
|
||||
return FXTRUE;
|
||||
}
|
||||
@@ -1536,8 +1524,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1629,8 +1618,9 @@ char tlGetCH( void ) {
|
||||
}
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err) {
|
||||
fprintf(stderr, err);
|
||||
tlErrorMessage(const char *err) {
|
||||
fprintf(stderr, "%s", err);
|
||||
return FXTRUE;
|
||||
} /* tlErrorMessage */
|
||||
|
||||
FxU32
|
||||
@@ -1821,7 +1811,7 @@ main( int argc, char **argv)
|
||||
} /* WinMain */
|
||||
|
||||
FxBool
|
||||
tlErrorMessage( char *err)
|
||||
tlErrorMessage(const char *err)
|
||||
{
|
||||
/* make the cursor visible */
|
||||
SetCursor(LoadCursor( NULL, IDC_ARROW ));
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
** Insert new header here
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _TLIB_H_
|
||||
#define _TLIB_H_
|
||||
#ifdef __cplusplus
|
||||
@@ -17,7 +15,7 @@ extern "C" {
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(exp) (exp)
|
||||
#define assert(exp) (void) (exp)
|
||||
#endif
|
||||
|
||||
/* The two most commonly defined macros in the known universe */
|
||||
@@ -148,7 +146,7 @@ void tlCProjectVertices( TlVertex3D *dstList,
|
||||
FxBool tlOkToRender(void);
|
||||
|
||||
FxBool
|
||||
tlErrorMessage(char *err);
|
||||
tlErrorMessage(const char *err);
|
||||
|
||||
typedef FxU32 TlPalette[256];
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user