Removed unused image and font code.

This commit is contained in:
Steven Fuller 2008-05-04 02:51:54 -07:00 committed by Patryk Obara
parent a64e100838
commit 76403986b1
10 changed files with 0 additions and 5773 deletions

View file

@ -1,914 +0,0 @@
#include "3dc.h"
#include "inline.h"
#include "module.h"
#include "gamedef.h"
#include "font.h"
#include "indexfnt.hpp"
#define UseLocalAssert 1
#include "ourasert.h"
/* Roxbys font stuff. any comments will be useful!!!
font control - Fonts description and sturctures game/plat/font.h
Platform dependent processing game/plat/platsup.c or ddplat.cpp
*/
/* general ideas. Crap I know!!!
written to maintain compatiblity with the current texture (bitmap) processing tools.
all the information about spacing of the font is maintained witin the bitmap itself,
using hotspots for the texture processing, that way we dont need extra tools to convert
fonts. It also allows complete font positioning (except different letter combos changing)
I have shifted most of the emphasis onto the artists to set up the font and to mark it how they
see fit. All the fonts must contain hotspots for all the letters. In that way we can easily
expand fonts. The character offests at the mo are simply -32. We may have to set up jump tables
at some later date to get chars for different languages.
Nothing supports anti-aliasing at the moment. Be careful with colours!!!
Most of the info is being passed as locals. Clumsy I know. I didnt want to take up more
space than was nessecery
HARD coded. Names of the fonts
Number of fonts to load
Number of characters in the font. you can leave letters blank. The number of
characters in the fonts can be changed for different languages
AVP-Win95
This loads all the fonts in the structure PFFONT AvpFonts[] that is passed
to while NUM_FONTS. The Imageheader->ImagePtr for the data is maintained
untill we have processd the characters. I dont fancy manipulating the data
in a LPDIRECTDRAWSURFACE. The character descriptors in the font contain
nothing but a src RECT. the void* pointer in the PFFONT structure in this
case is cast to LPDIRECTDRAWSURFACE.
Not that the entire font is placed into a
file That is then processed. CLUT where to
put the CLU???? Put it into the vid memory.
use a void*
*/
/*
Only have 8 bit support a tne moment. More to come!!!
Screen modes. I recommend loading up different fonts for different screen modes.
Simply reference a different structure.
*/
#define CHAR_WIDTH(font_num, offset) ((AvpFonts[font_num].srcRect[offset].right - AvpFonts[font_num].srcRect[offset].left))
#define CHAR_HEIGHT(font_num, offset) ((AvpFonts[font_num].srcRect[offset].bottom - AvpFonts[font_num].srcRect[offset].top))
#define IS_CHAR_WHITE_SPACE(ch) ((ch == '\t' || ch == '\n' || ch == ' ' || (int)ch == 0x0))
static int ProcessFontEntry
(
PFFONT* font,
unsigned char* fontstartaddress,
unsigned pitch,
int* countfromrow,
int* countfromcol,
int charnum
);
static int ProcessLineLength
(
char* start_ch, // start char of string
AVP_FONTS fontnum, // the font we are using
int offset, // the offset from the font
int max_width, // the width of the line
char** end_ch, // filled with end address
int* line_length
);
void LoadAllFonts()
{
// these fonts end up being in memory all the time,
// I will also supply a function which is delete
// specific font.
int fontnum = 0;
while(fontnum < NUM_FONTS)
{
/* load the font in turn */
LoadPFFont(fontnum);
fontnum ++;
}
}
void LoadPFFont(int fontnum)
{
// these fonts end up being in memory all the time,
// I will also supply a function which is delete
// specific font.
PFFONT *font = &AvpFonts[fontnum];
unsigned nPitch;
unsigned char * pSurface;
LoadFont(font);
/* get the hotspot color first entry in */
if(font->fttexBitDepth == 15)font->fttexBitDepth = 16;
pSurface = FontLock(font,&nPitch);
GLOBALASSERT(pSurface);
font->hotSpotValue = *(unsigned *)pSurface & (font->fttexBitDepth<32 ? (1<<font->fttexBitDepth)-1 : 0xffffffffU);
/* the hotspot value is the top-left pixel */
{
int charnum = 0;
int countfromrow = 1;
int countfromcol = 0;
/*
find the hotspots and send everything to the
processing function. This part of routine find the
hotspots in numbers of pixels
*/
/*Top line of the texture is redundent we get the hotspot from this*/
/*edge of the texture has only lines*/
while(charnum < font->num_chars_in_font)
{
ProcessFontEntry(font,pSurface,nPitch,&countfromrow,&countfromcol,charnum);
charnum++;
}
#if 0
// Taken out by DHM 26/11/97:
fontnum++;
#endif
charnum = 0;
}
FontUnlock(font);
#if SupportWindows95
INDEXFNT_PFLoadHook
(
(FontIndex) fontnum,
// FontIndex I_Font_New,
font // PFFONT *pffont_New
);
#endif
}
static int ProcessFontEntry
(
PFFONT* font,
unsigned char* fontstartaddress,
unsigned pitch,
int* countfromrow,
int* countfromcol,
int charnum
)
{
/*
okay set the starting point
countfromrow marks the current depth of the processing row in the texture.
countfromcol marks how far along the current coloum we have processed
* = HOTSPOT .. the first pixel is used as the hotspot
**********************
* ** ** **** * <---- startfromrow
###
#
## # # ###
# # # # # ##
### ### #### ##
* * # * **** * Blank chars marked by two hotspots adjacent
### ^^ |at the top and the bottom
* * || |
^ ||______|
|
|
startfromcol
********************* Note that the spot in col 0 marks a new linw of chars
*/
int curr_row = *countfromrow;
int curr_col = *countfromcol;
int y_offset = 0, x_offset = curr_col;
GLOBALASSERT(font);
GLOBALASSERT(fontstartaddress);
GLOBALASSERT(charnum < font->num_chars_in_font);
GLOBALASSERT(curr_row < font->fttexHeight);
GLOBALASSERT(curr_col <= font->fttexWidth);
/*remember that all the corrdinates are done by pixels
find the x and y corrdinates of the left lower hotspot
we process each line (row) from startfromrow to the end
first find the next marker in startfromrow
*/
// only supported if bit depth is a whole number of bytes
GLOBALASSERT(8==font->fttexBitDepth || 16==font->fttexBitDepth || 24==font->fttexBitDepth || 32==font->fttexBitDepth);
while(1)
{
// this bit processes the chars, finds uvs, extents and fills in the sturcture*/
// count along the row to find the next x position
unsigned int colour_here;
if(x_offset > font->fttexWidth - 1)
{
// reached the end of the line! reset x and then y
x_offset = 0;
curr_col = 0;
curr_row += font->fontHeight; // max line height
*countfromrow = curr_row;
GLOBALASSERT(curr_row < font->fttexHeight);
}
switch (font->fttexBitDepth)
{
default:
GLOBALASSERT(0);
case 8:
colour_here = *(fontstartaddress + (curr_row*pitch + x_offset));
break;
case 16:
colour_here = *(unsigned short *)(fontstartaddress + (curr_row*pitch + 2*x_offset));
break;
case 24:
{
unsigned char * pPixel = fontstartaddress + (curr_row*pitch + 3*x_offset);
// assuming the right endianness
colour_here = pPixel[0] | (unsigned)pPixel[1] << 8 | (unsigned)pPixel[2] << 16;
break;
}
case 32:
colour_here = *(unsigned *)(fontstartaddress + (curr_row*pitch + 4*x_offset));
break;
}
if(colour_here == font->hotSpotValue)
{
int width = -1, height = -1;
/* set up the uv corrds of the top left corner*/
int u = x_offset + 1;
int v = curr_row + 1;
/* scan down to give height*/
for(y_offset = (curr_row + 1); y_offset < font->fttexHeight; y_offset++)
{
switch (font->fttexBitDepth)
{
default:
GLOBALASSERT(0);
case 8:
colour_here = *(fontstartaddress + (y_offset*pitch + x_offset));
break;
case 16:
colour_here = *(unsigned short *)(fontstartaddress + (y_offset*pitch + 2*x_offset));
break;
case 24:
{
unsigned char * pPixel = fontstartaddress + (y_offset*pitch + 3*x_offset);
// assuming the right endianness
colour_here = pPixel[0] | (unsigned)pPixel[1] << 8 | (unsigned)pPixel[2] << 16;
break;
}
case 32:
colour_here = *(unsigned *)(fontstartaddress + (y_offset*pitch + 4*x_offset));
break;
}
if(colour_here == font->hotSpotValue)
{
height = y_offset - curr_row - 1; // -1 because we exclude the top and bottom hotspots
break;
}
}
/* scan along to get the width*/
for(++x_offset; x_offset < font->fttexWidth; x_offset ++)
{
switch (font->fttexBitDepth)
{
default:
GLOBALASSERT(0);
case 8:
colour_here = *(fontstartaddress + (curr_row*pitch + x_offset));
break;
case 16:
colour_here = *(unsigned short *)(fontstartaddress + (curr_row*pitch + 2*x_offset));
break;
case 24:
{
unsigned char * pPixel = fontstartaddress + (curr_row*pitch + 3*x_offset);
// assuming the right endianness
colour_here = pPixel[0] | (unsigned)pPixel[1] << 8 | (unsigned)pPixel[2] << 16;
break;
}
case 32:
colour_here = *(unsigned *)(fontstartaddress + (curr_row*pitch + 4*x_offset));
break;
}
if(colour_here == font->hotSpotValue)
{
width = x_offset - curr_col - 1; // exclude end hotspot
break;
}
}
*countfromcol = x_offset + 1; /* ready for the next char*/
/*fill in the data structure - platform dependent*/
FillCharacterSlot(u, v, width, height, charnum, font);
return 0;
}
x_offset++;
}
return 0;
}
#if 0 // obsolete
static int Process8BitEntry(PFFONT* font,
char* fontstartaddress,
int* countfromrow,
int* countfromcol,
int charnum)
{
/*
okay set the starting point
countfromrow marks the current depth of the processing row in the texture.
countfromcol marks how far along the current coloum we have processed
* = HOTSPOT .. the first pixel is used as the hotspot
**********************
* ** ** **** * <---- startfromrow
###
#
## # # ###
# # # # # ##
### ### #### ##
* * # * **** * Blank chars marked by two hotspots adjacent
### ^^ |at the top and the bottom
* * || |
^ ||______|
|
|
startfromcol
********************* Note that the spot in col 0 marks a new linw of chars
*/
int curr_row = *countfromrow;
int curr_col = *countfromcol;
int y_offset = 0, x_offset = curr_col;
GLOBALASSERT(font);
GLOBALASSERT(fontstartaddress);
GLOBALASSERT(charnum < font->num_chars_in_font);
GLOBALASSERT(curr_row < font->fttexHeight);
GLOBALASSERT(curr_col <= font->fttexWidth);
/*remember that all the corrdinates are done by pixels
find the x and y corrdinates of the left lower hotspot
we process each line (row) from startfromrow to the end
first find the next marker in startfromrow
*/
while(1)
{
// this bit processes the chars, finds uvs, extents and fills in the sturcture*/
// count along the row to find the next x position
unsigned int colour_here;
if(x_offset > font->fttexWidth - 1)
{
// reached the end of the line! reset x and then y
x_offset = 0;
curr_col = 0;
curr_row += font->fontHeight; // max line height
*countfromrow = curr_row;
GLOBALASSERT(curr_row < font->fttexHeight);
}
colour_here = (int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset));
if(colour_here == font->hotSpotValue)
{
int width = -1, height = -1;
/* set up the uv corrds of the top left corner*/
int u = x_offset + 1;
int v = curr_row + 1;
/* scan down to give height*/
for(y_offset = (curr_row + 1); y_offset < font->fttexHeight; y_offset++)
{
colour_here = (int)*(fontstartaddress + (y_offset*font->fttexWidth + x_offset));
if(colour_here == font->hotSpotValue)
{
height = y_offset - curr_row - 1; // -1 because we exclude the top and bottom hotspots
break;
}
}
/* scan along to get the width*/
for(++x_offset; x_offset < font->fttexWidth; x_offset ++)
{
colour_here = (int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset));
if(colour_here == font->hotSpotValue)
{
width = x_offset - curr_col - 1; // exclude end hotspot
break;
}
}
*countfromcol = x_offset + 1; /* ready for the next char*/
/*fill in the data structure - platform dependent*/
FillCharacterSlot(u, v, width, height, charnum, font);
return 0;
}
x_offset++;
} a
}
static int Process16BitEntry(PFFONT *font,
char* fontstartaddress,
int* countfromrow,
int* countfromcol,
int charnum)
{
int curr_row = *countfromrow;
int curr_col = *countfromcol;
int y_offset = 0, x_offset = curr_col;
GLOBALASSERT(font);
GLOBALASSERT(fontstartaddress);
GLOBALASSERT(charnum < font->num_chars_in_font);
GLOBALASSERT(curr_row < font->fttexHeight);
GLOBALASSERT(curr_col <= font->fttexWidth);
/*remember that all the corrdinates are done by pixels
find the x and y corrdinates of the left lower hotspot
we process each line (row) from startfromrow to the end
first find the next marker in startfromrow
*/
while(1)
{
// this bit processes the chars, finds uvs, extents and fills in the sturcture*/
// count along the row to find the next x position
unsigned int colour_here;
if(x_offset > font->fttexWidth - 1)
{
// reached the end of the line! reset x and then y
x_offset = 0;
curr_col = 0;
curr_row += font->fontHeight; // max line height
*countfromrow = curr_row;
GLOBALASSERT(curr_row < font->fttexHeight);
}
{
unsigned int colour_high = 0x000000ff & (unsigned int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset)*2);
unsigned int colour_low = 0x000000ff & (int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset)*2 + 1);
colour_here = (colour_high << 8) | colour_low;
}
if(colour_here == font->hotSpotValue)
{
int width = -1, height = -1;
/* set up the uv corrds of the top left corner*/
int u = x_offset + 1;
int v = curr_row + 1;
/* scan down to give height*/
for(y_offset = (curr_row + 1); y_offset < font->fttexHeight; y_offset++)
{
{
int colour_high = 0x000000ff & (int)*(fontstartaddress + (y_offset*font->fttexWidth + x_offset)*2);
int colour_low = 0x000000ff & (int)*(fontstartaddress + (y_offset*font->fttexWidth + x_offset)*2 + 1);
colour_here = (colour_high << 8) | colour_low;
}
if(colour_here == font->hotSpotValue)
{
height = y_offset - curr_row - 1; // -1 because we exclude the top and bottom hotspots
break;
}
}
/* scan along to get the width*/
for(++x_offset; x_offset < font->fttexWidth; x_offset ++)
{
{
int colour_high = 0x000000ff & (int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset)*2);
int colour_low = 0x000000ff & (int)*(fontstartaddress + (curr_row*font->fttexWidth + x_offset)*2 + 1);
colour_here = (colour_high << 8) | colour_low;
}
if(colour_here == font->hotSpotValue)
{
width = x_offset - curr_col - 1; // exclude end hotspot
break;
}
}
*countfromcol = x_offset + 1; /* ready for the next char*/
/*fill in the data structure - platform dependent*/
FillCharacterSlot(u, v, width, height, charnum, font);
return 0;
}
x_offset++;
}
return 0;
}
static int Process24BitEntry(PFFONT* font,
char* fontstartaddress,
int* countfromrow,
int* countfromcol,
int charnum)
{
return 0;
}
#endif
void BLTWholeFont(int fontnum, int x , int y, int win_width)
{
int i = 0;
int plotto_x = x, plotto_y = y;
while(i < AvpFonts[fontnum].num_chars_in_font)
{
int charwidth = AvpFonts[fontnum].srcRect[i].right - AvpFonts[fontnum].srcRect[i].left;
if((charwidth + plotto_x - x) > win_width)
{
plotto_y += AvpFonts[fontnum].fontHeight;
plotto_x= x;
}
BLTFontOffsetToHUD(&AvpFonts[fontnum], plotto_x, plotto_y, i);
plotto_x += charwidth + 1;
i++;
}
return;
}
void BLTString(FONT_DESC str_packet)
{
PFFONT font = AvpFonts[str_packet.fontnum];
unsigned char *strptr = str_packet.string;
int offset = 0;
int not_finished = Yes;
int pos_x = str_packet.destx;
int pos_y = str_packet.desty;
int white_space_width = CHAR_WIDTH(str_packet.fontnum, 0);
// set up the font processing varibles depending on the type of font
switch(font.font_type)
{
case(I_FONT_NUMERIC):
{
offset = 0x30;
break;
}
case(I_FONT_UC_NUMERIC):
{
offset = 0x20;
break;
}
case(I_FONT_UCLC_NUMERIC):
{
offset = 0x20;
break;
}
default:
GLOBALASSERT(2<1);
}
while(not_finished)
{
int line_length;
char *end_char;
// find the line length and the end char in the line
not_finished = ProcessLineLength
(
strptr, // start char of string
str_packet.fontnum, // the font we are using
offset, // the offset from the font
str_packet.width, // the width of the line
&end_char, // filled with end address
&line_length // filled with line length
);
// work out where to print the line
if(line_length)
{
switch(str_packet.just)
{
case FJ_LEFT_JUST:
{
pos_x = str_packet.destx;
break;
}
case FJ_CENTRED:
{
pos_x = str_packet.destx + ((str_packet.width - line_length) >> 1);
break;
}
case FJ_RIGHT_JUST:
{
pos_x = str_packet.destx + (str_packet.width - line_length);
break;
}
default:
{
;
}
}
// now print the line untill we reach the address of
// the end char
do
{
if(*strptr == ' ')
{
pos_x += white_space_width;
}
else if(*strptr == '\t')
{
pos_x += 4*white_space_width;
}
else if(*strptr == '\n' || strptr == 0x0)
{
GLOBALASSERT(strptr == end_char);
}
else if((int)*strptr == 0xD)
{
// carrige return
// do nothing - our next char should be '\n'
GLOBALASSERT(*(strptr + 1) == '\n');
}
else
{
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
int end_pos = pos_x + CHAR_WIDTH(str_packet.fontnum, ((int)*strptr - offset));
int bottom_pos = pos_y + CHAR_HEIGHT(str_packet.fontnum, ((int)*strptr - offset));
if(end_pos > ScreenDescriptorBlock.SDB_Width || pos_x < 0)
{
//dont draw
//not_finished = No;
}
else if( bottom_pos > ScreenDescriptorBlock.SDB_Height || pos_y < 0)
{
not_finished = No;
}
else
{
pos_x += BLTFontOffsetToHUD
(
&font,
pos_x,
pos_y,
(int)*strptr - offset
);
pos_x ++; // to make space between letters
}
}
}
while(++strptr != (unsigned char *)end_char);
pos_y += font.fontHeight - 2;
}
strptr++;
}
}
/*
RWH - changes to font line processing
This function takes a pointer to a string a font and a width and
puts the length of the line into line_length AND puts the end char address into end_ch
It returns 0 when we have reached the end of a string
*/
int ProcessLineLength
(
char* start_ch, // start char of string
AVP_FONTS fontnum, // the font we are using
int offset, // the offset from the font
int max_width, // the width of the line
char** end_ch, // filled with end address
int* line_length
)
{
int continue_to_process_word = Yes;
int white_space_width = CHAR_WIDTH(fontnum, 0);
char *word_ptr = start_ch;
*line_length = 0;
if(start_ch == NULL)
{
*end_ch = NULL;
*line_length = 0;
return 0;
}
// first process any white space at the end of the
// line out
while(*start_ch == ' ')
{
// make sure we havent run out
// of chars to process
if(*start_ch == 0x0)
{
*end_ch = NULL;
*line_length = 0;
return 0;
}
start_ch++;
}
// Now we can start on the characters in the line
// note that we have to have two loops. The first
// continues untill we break out of it. The second
// adds up the length of each word and sees if the line
// with the new word will overrun the max_width
// the word_ptr points to the current char - it is only incremented
// when we can be sure that we can add the current letter to the word
while(1)
{
int word_length = 0;
continue_to_process_word = Yes;
while(continue_to_process_word)
{
// is the next char white space ?
// if so close the word
if(IS_CHAR_WHITE_SPACE(*(word_ptr + 1)))
{
// hit white space - finish this current word but only
// AFTER we have processed the current char
continue_to_process_word = No;
}
// need to process every white space seperately
if(*word_ptr == '\t')
{
// a one char word!
word_length = 4 * white_space_width;
continue_to_process_word = No;
word_ptr++;
}
else if(*word_ptr == 0x0)
{
// reached end of file - need to return 0
*end_ch = word_ptr;
return 0;
}
else if(*word_ptr == '\n')
{
*end_ch = word_ptr;
return 1;
}
else if(*word_ptr == ' ')
{
if(word_length)
{
// tag on the white space onto the word length
word_length += white_space_width;
}
// other wise keep on tiking on
word_ptr++;
}
else
{
// yeah add a letter to the word length
int char_off = (char)(*word_ptr - offset);
word_length += CHAR_WIDTH(fontnum, char_off);
word_length ++; //for space between lettes
word_ptr++; //process next char
}
}
// okay we have the length of this word - check to see if
// it overruns the end of the line - if it is too long,
// break out of the line loop
if((word_length + *line_length) >= max_width)
{
*end_ch = start_ch;
return 1;
}
else
{
*line_length += word_length;
// set up the next word save the beginning of teh word in start_ch
start_ch = word_ptr;
}
}
}

View file

@ -60,19 +60,6 @@ typedef enum font_justification
}FONT_JUST;
// this prints a string packet
typedef struct font_desc {
int fontnum; // see list of PFFONTS;
char *string; // this will eventually point into a resource fileMENU_GRAPHIC_ITEM Gamestart_MenuItems[] = {
short destx;
short desty;
FONT_JUST just;
short width; // width - the width we have to print
// the font in - overrides onto next line
} FONT_DESC;
// bitfield of flags
typedef struct
@ -201,12 +188,6 @@ extern void * FontLock(PFFONT const * pFont, unsigned * pPitch);
extern void FontUnlock(PFFONT const * pFont);
// drawing functions
extern void BLTWholeFont(int fontnum, int x , int y, int win_width);
extern void BLTString(FONT_DESC str_packet);
// the array of all the Fonts int the game
extern PFFONT AvpFonts[];

View file

@ -30,9 +30,6 @@
#include "hudgadg.hpp"
// for ClearTheQueue()
#include "font.h"
// for the font tests
#define UseLocalAssert Yes
#include "ourasert.h"
@ -154,40 +151,6 @@ void TextReportGadget :: Render
/* CODE */
{
#if 0
BLTFontOffsetToHUD
(
// PFFONT* font ,
400, // int xdest,
100, // int ydest,
0 // int offset
);
#endif
#if 0
BLTWholeFont
(
3, // int fontnum,
30, // int x ,
130, // int y,
100 // int win_width
);
#endif
#if 0
textprint
(
"TextReportGadget :: Render at (%i,%i) clipped (%i,%i,%i,%i) alpha=%i\n",
R2Pos . x,
R2Pos . y,
R2Rect_Clip . x0,
R2Rect_Clip . y0,
R2Rect_Clip . x1,
R2Rect_Clip . y1,
FixP_Alpha
);
#endif
IndexedFont* pLetterFont = IndexedFont :: GetFont( I_Font_TeletypeLettering );
GLOBALASSERT( pLetterFont );
@ -916,81 +879,3 @@ void CheesyDaemon_Lifetime :: Reset(void)
#endif // UseGadgets
#if UseGadgets && 0
// test code
#define FONT_INDEX (3)
void TestStringRender_Unclipped
(
r2pos& R2Pos_Cursor,
// start position for string;
// gets written back to with final position
// Renders as a single line; it is asserted that the result is fully within
// the physical screen (i.e. already clipped)
const SCString& SCStr
)
{
/* PRECONDITION */
{
}
/* CODE */
{
// GetOffset:
const pffont& PFFont = AvpFonts[FONT_INDEX];
ProjChar* pProjChar_I = SCStr . pProjCh();
while ( *pProjChar_I )
{
const ProjChar ProjCh = *pProjChar_I;
if
(
PFFont . bPrintable( ProjCh )
)
{
#if 0
textprint("printable \'%c\'\n",ProjCh);
#endif
R2Pos_Cursor . x += 1+BLTFontOffsetToHUD
(
(PFFONT*)&PFFont, // PFFONT* font,
// "cast away the const-ness" for the moment
R2Pos_Cursor . x, // int xdest,
R2Pos_Cursor . y, // int ydest,
PFFont . ProjCharToOffset( ProjCh ) // int offset
);
// appears to return the width of the character...
}
else
{
#if 0
textprint("unprintable \'%c\'\n",ProjCh);
#endif
}
pProjChar_I++;
}
}
}
void TestStringRender_Clipped
(
r2pos& R2Pos_Cursor,
const r2rect& R2Rect_Clip,
const SCString& SCStr
)
{
}
#endif // test code

View file

@ -480,232 +480,12 @@ static void LoadVideoModeSettings(void)
static size_t IsNotEnoughVidMemForBytes(size_t required)
{
return 0;
// Won't be using this. I don't think
#if 0
char buff[128];
sprintf(buff,"Want: %d Have: %d",(int)required,GetAvailableVideoMemory());
LOGDXSTR(buff);
if (required > GetAvailableVideoMemory()) return GetAvailableVideoMemory();
LOGDXSTR("Maybe enough");
#if DISABLE_VIDEOCARD_ANALYSIS
return 0;
#endif
static size_t what_we_know_we_can_have = 0;
if (required <= what_we_know_we_can_have) return 0;
// deal with cards whose video memory is fragmented
// such that textures may not be able to use all the
// available video memory
// we don't know we can use all the available video memory
// for textures - so try and find out what we can use
// with the current options - and in future, as long as
// available video memory exceeds this amount, we'll know
// at least a minimum amount that we can have without having
// to run this test again
List<IMAGEHEADER *> imgs;
size_t vidmem_before = GetAvailableVideoMemory();
CL_Image random_tx;
CL_Select_Mode(CLL_D3DTEXTURE);
random_tx.MakeRandom(512,512,RND_SEED1);
// throw d3d textures at the system until we can no more
do
{
CL_Error copyerr;
do
{
IMAGEHEADER * new_ih = new IMAGEHEADER;
memset(new_ih,0,sizeof(IMAGEHEADER));
size_t vidmem_before_create = GetAvailableVideoMemory();
copyerr = random_tx.CopyToD3DTexture((LPDIRECTDRAWSURFACE *)&new_ih->DDPtr,(LPVOID *)&new_ih->DDSurface,DDSCAPS_SYSTEMMEMORY);
if (CLE_OK == copyerr)
{
copyerr = CLE_DXERROR;
if (CopyD3DTexture(new_ih))
{
if (LoadD3DTextureIntoD3DMaterial(new_ih))
copyerr = CLE_OK;
}
}
size_t vidmem_after_create = GetAvailableVideoMemory();
imgs.add_entry(new_ih);
if (vidmem_after_create >= vidmem_before_create) copyerr = CLE_DXERROR;
LOGDXFMT(("VidMem: %d",vidmem_after_create));
}
while (CLE_OK==copyerr);
random_tx.MakeRandom(random_tx.width>>1,random_tx.height>>1);
}
while (random_tx.width>=32 && random_tx.height>=32);
size_t vidmem_after = GetAvailableVideoMemory();
what_we_know_we_can_have = vidmem_before - vidmem_after;
char buf[128];
sprintf(buf,"Can have %d\n",what_we_know_we_can_have);
LOGDXSTR(buf);
// release all dummy textures we threw at the system
while (imgs.size())
{
if (imgs.first_entry()->DDSurface)
ReleaseDDSurface(imgs.first_entry()->DDSurface);
if (imgs.first_entry()->D3DTexture)
ReleaseD3DTexture(imgs.first_entry()->D3DTexture);
delete imgs.first_entry();
imgs.delete_first_entry();
}
if (required <= what_we_know_we_can_have)
return 0;
else
return what_we_know_we_can_have;
#endif
}
static BOOL IsNotEnoughVidMemForScreenDepth(int s_depth)
{
// bollocks - this is all obsolete - FIXME
return FALSE;
#if 0
LOGDXSTR("Testing Vid Mem");
CL_Init_All(); - not required any more
// determine if d3d textures need to be a power of two in width and height
// try 48x48
IMAGEHEADER tmp_iheader;
memset(&tmp_iheader,0,sizeof(IMAGEHEADER));
CL_Image random_tx;
CL_Error copyerr;
// do we need texture powers of two or square
need_textures_powers_of_two = d3d.ThisDriver.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2 ? 1 : 0;
need_textures_square = d3d.ThisDriver.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ? 1 : 0;
LOGDXFMT(("Need POW_2 : %d",need_textures_powers_of_two));
LOGDXFMT(("Need SQUARE : %d",need_textures_square));
// determine how much texture memory is used by a typical 64x64 hud graphic
#if DISABLE_VIDEOCARD_ANALYSIS
size_t vidmem_before, vidmem_after;
copyerr = CLE_DXERROR;
#else
CL_Select_Mode(CLL_DDSURFACE);
random_tx.MakeRandom(64,64,RND_SEED4);
size_t vidmem_before = GetAvailableVideoMemory();
copyerr = random_tx.CopyToDirectDrawSurface((LPDIRECTDRAWSURFACE *)&tmp_iheader.DDSurface,(LPVOID *)&tmp_iheader.DDPtr,DDSCAPS_SYSTEMMEMORY);
size_t vidmem_after = GetAvailableVideoMemory();
if (tmp_iheader.DDSurface)
{
ReleaseDDSurface(tmp_iheader.DDSurface);
tmp_iheader.DDSurface = (void*) 0;
tmp_iheader.DDPtr = (void*) 0;
}
if (tmp_iheader.D3DTexture)
{
ReleaseD3DTexture(tmp_iheader.D3DTexture);
tmp_iheader.D3DTexture = (void*) 0;
tmp_iheader.D3DMaterial = (void*) 0;
tmp_iheader.D3DHandle = (void*) 0;
}
#endif
float hud_bytespertexel =
CLE_OK == copyerr
? (float)(vidmem_before-vidmem_after)/(random_tx.width*random_tx.height)
: (float)s_depth/8
;
char buf[128];
sprintf(buf,"HUD BPP: %f",hud_bytespertexel);
LOGDXSTR(buf);
// determine how much texture memory is used by a typical 128x128 texture
#if DISABLE_VIDEOCARD_ANALYSIS
#else
CL_Select_Mode(CLL_D3DTEXTURE);
random_tx.MakeRandom(128,128,RND_SEED2);
LOGDXSTR("Trying D3D");
//size_t
vidmem_before = GetAvailableVideoMemory();
copyerr = random_tx.CopyToD3DTexture((LPDIRECTDRAWSURFACE *)&tmp_iheader.DDPtr,(LPVOID *)&tmp_iheader.DDSurface,DDSCAPS_SYSTEMMEMORY);
if (CLE_OK == copyerr)
{
copyerr = CLE_DXERROR;
if (CopyD3DTexture(&tmp_iheader))
if (LoadD3DTextureIntoD3DMaterial(&tmp_iheader))
copyerr = CLE_OK;
}
//size_t
vidmem_after = GetAvailableVideoMemory();
if (tmp_iheader.DDSurface)
{
ReleaseDDSurface(tmp_iheader.DDSurface);
tmp_iheader.DDSurface = (void*) 0;
tmp_iheader.DDPtr = (void*) 0;
}
if (tmp_iheader.D3DTexture)
{
ReleaseD3DTexture(tmp_iheader.D3DTexture);
tmp_iheader.D3DTexture = (void*) 0;
tmp_iheader.D3DMaterial = (void*) 0;
tmp_iheader.D3DHandle = (void*) 0;
}
#endif
float textures_bytespertexel =
CLE_OK == copyerr
? (float)(vidmem_before-vidmem_after)/(random_tx.width*random_tx.height)
: (float)BitsPerPixel(&d3d.TextureFormat[d3d.CurrentTextureFormat])/8
;
//char buf[128];
sprintf(buf,"Textures BPP: %f",textures_bytespertexel);
LOGDXSTR(buf);
ImageSizeRestrictionIdx isri = need_textures_square ? need_textures_powers_of_two ? ISRI_SQUAREANDPOWER2 : ISRI_SQUARE : need_textures_powers_of_two ? ISRI_POWER2 : ISRI_UNIT4;
size_t vram_rq;
size_t vram_avail;
for (int i=0; hw_try_desc[i]; ++i)
{
desc_textures_to_load = hw_try_desc[i];
vram_rq = (size_t)(
hw_max_num_texels[isri][ITI_HUD][desc_textures_to_load[ITI_HUD]] * hud_bytespertexel +
hw_max_num_texels[isri][ITI_TEXTURE][desc_textures_to_load[ITI_TEXTURE]] * textures_bytespertexel +
hw_max_num_texels[isri][ITI_SPRITE][desc_textures_to_load[ITI_SPRITE]] * textures_bytespertexel
);
vram_avail = IsNotEnoughVidMemForBytes(vram_rq);
if (!vram_avail) return FALSE;
}
// bollocks - return FALSE anayway, since the following doesn't actually work anymore anyway
return FALSE;
char errstring[512];
sprintf(errstring,"THIS SET OF OPTIONS REQUIRES AT LEAST %d BYTES OF VIDEO MEMORY FREE. THERE ARE ONLY %d BYTES FREE. THE TEXTURE FORMAT WAS %d-BIT",(int)vram_rq,(int)vram_avail,BitsPerPixel(&d3d.TextureFormat[d3d.CurrentTextureFormat]));
EmergencyPcOptionsMenu(errstring);
return TRUE;
#endif
}
@ -1011,8 +791,6 @@ extern int SetGameVideoMode(void)
return 0;
}
// CL_Init_All(); // set up shifts for display pixel format - not required
if (ScanDrawMode == ScanDrawDirectDraw)
{
ScreenDescriptorBlock.SDB_Depth = ScreenDescriptorBlock.SDB_ScreenDepth;

View file

@ -1,699 +0,0 @@
#include <string.h>
#define TRY_OLD_DIRS 0 // obsolete
#define ALLOW_LOAD_ORIGINAL 0
#if TRY_OLD_DIRS // temporary until all textures go into subshps directory
#include "ffstdio.h"
#endif
#include "chnkimag.hpp"
#include "list_tem.hpp"
#include "envchunk.hpp"
#include "chunkpal.hpp"
#include "bmpnames.hpp"
#include "chnkload.hpp"
char const * CL_RIFFImage::game_mode = 0;
// useful filename handling functions
// returns pointer into string pointing to filename without dirname
template <class C> // C can be char or char const
static C * strip_path(C * n)
{
C * rm = strrchr(n,':');
if (rm) n = rm+1;
rm = strrchr(n,'/');
if (rm) n = rm+1;
rm = strrchr(n,'\\');
if (rm) n = rm+1;
return n;
}
// removes any .extension from filename by inserting null character
static void strip_file_extension(char * n)
{
char * dotpos = strrchr(n,'.');
if (dotpos) *dotpos = 0;
}
static char * strip_file_extension(char const * n)
{
char * nn = new char[strlen(n)+1];
strcpy(nn,n);
strip_file_extension(nn);
return nn;
}
////////////////////////
//
// riff file interface
//
////////////////////////
// get the directory associated with the riff - free with delete[]
static char * riff_basename(Chunk_With_Children * envd)
{
RIF_Name_Chunk * rnc = 0;
List<Chunk *> chlst = envd->lookup_child("RIFFNAME");
if (chlst.size())
{
rnc = (RIF_Name_Chunk *)chlst.first_entry();
const char * rif_name = strip_path(rnc->rif_name);
char * basename = new char[strlen(rif_name)+1];
strcpy(basename,rif_name);
strip_file_extension(basename);
return basename;
}
const char * deflt = "empty";
char * basename = new char [strlen(deflt)+1];
strcpy(basename,deflt);
return basename;
}
#if OUTPUT_LOG
#define _LOGID CL_LogFile.lprintf("%s:%d :: ",__FILE__,__LINE__)
#define _LOGPUT(s) _LOGID,CL_LogFile.lputs(s)
#define _LOGPRINT(args) _LOGID,CL_LogFile.lprintf args
#else
#define _LOGPUT(s) (void)0
#define _LOGPRINT(args) (void)0
#endif
void CL_RIFFImage::GetPath(ImageDescriptor const & idsc, Environment_Data_Chunk * envd, BMPN_Flags bflags)
{
if (fname) delete[] fname;
fname = 0;
// set the name
if (name) delete[] name;
char * nptr = strip_path(idsc.filename);
name = new char[strlen(nptr)+1];
strcpy(name,nptr);
#if 0
char orig_ext[32];
char const * oeP = strrchr(name,'.');
if (!oeP) eoP = "";
strcpy(orig_ext,oeP);
#endif
strip_file_extension(name);
// load this image
char const * pg0ext = ".PG0";
switch (imode)
{
case CLM_16BIT:
case CLM_24BIT:
case CLM_32BIT:
#if ALLOW_LOAD_ORIGINAL
{
char const * dir2 = idsc.flags & IDSCF_SPRITE ? "Sprites\\" : "";
char * riffname = riff_basename(envd);
char const * dir3 = idsc.flags & IDSCF_INCLUDED ? idsc.rifname : riffname;
fname = new char[strlen(ToolsTex_Directory)+strlen(dir2)+strlen(dir3)+1+strlen(name)+5];
strcpy(fname,ToolsTex_Directory);
strcat(fname,dir2);
strcat(fname,dir3);
strcat(fname,"\\");
strcat(fname,name);
strcat(fname,".PP0");
delete[] riffname;
break;
}
#endif
case CLM_ATTACHEDPALETTE:
{
char const * dir2 = idsc.flags & IDSCF_SPRITE ? "Sprites\\" : idsc.flags & IDSCF_SUBSHAPE ? "SubShps\\All\\" : "";
char * riffname = riff_basename(envd);
char const * dir3 = idsc.flags & IDSCF_INCLUDED ? idsc.rifname : riffname;
fname = new char[strlen(GenTex_Directory)+strlen(dir2)+strlen(dir3)+1+strlen(name)+5];
strcpy(fname,GenTex_Directory);
strcat(fname,dir2);
strcat(fname,dir3);
strcat(fname,"\\");
strcat(fname,name);
strcat(fname,".BM0");
delete[] riffname;
#if TRY_OLD_DIRS // temporary until all textures go into subshps directory
FFILE * ftest = ffopen(fname,"rb");
if (ftest) ffclose(ftest);
else
{
_LOGPUT("WARNING! Not found in SubShps directory\n");
char const * dir2 = idsc.flags & IDSCF_SPRITE ? "Sprites\\" : "";
char * riffname = riff_basename(envd);
char const * dir3 = idsc.flags & IDSCF_INCLUDED ? idsc.rifname : riffname;
delete[] fname;
fname = new char[strlen(GenTex_Directory)+strlen(dir2)+strlen(dir3)+1+strlen(name)+5];
strcpy(fname,GenTex_Directory);
strcat(fname,dir2);
strcat(fname,dir3);
strcat(fname,"\\");
strcat(fname,name);
strcat(fname,".BM0");
delete[] riffname;
}
#endif
break;
}
case CLM_TLTPALETTE:
if (!(bflags & ChunkBMPFlag_NotLit))
{
pg0ext = ".PW0";
flags.tltpalette = 1;
}
case CLM_GLOBALPALETTE:
{
if (idsc.flags & IDSCF_FIXEDPALETTE)
{
char const * dir2 = idsc.fixrifname ? *idsc.fixrifname ? idsc.fixrifname : 0 : 0;
char const * dir3 = idsc.flags & IDSCF_SPRITE ? "Sprites\\" : "";
char * riffname = riff_basename(envd);
char const * dir4 = idsc.flags & IDSCF_INCLUDED ? idsc.rifname : riffname;
fname = new char[strlen(FixTex_Directory)+(dir2 ? strlen(dir2)+1 : 0)+strlen(dir3)+strlen(dir4)+1+strlen(name)+5];
strcpy(fname,FixTex_Directory);
if (dir2)
{
strcat(fname,dir2);
strcat(fname,"\\");
}
strcat(fname,dir3);
strcat(fname,dir4);
strcat(fname,"\\");
strcat(fname,name);
strcat(fname,pg0ext);
delete[] riffname;
}
else
{
char const * dir1 = game_mode ? GameTex_Directory : ToolsTex_Directory;
char * dir2 = riff_basename(envd);
char const * dir4 = idsc.flags & IDSCF_SPRITE ? "Sprites\\" : "";
char const * dir5 = idsc.flags & IDSCF_INCLUDED ? idsc.rifname : 0;
fname = new char[strlen(dir1)+strlen(dir2)+1+(game_mode ? strlen(game_mode)+1 : 0)+strlen(dir4)+(dir5 ? strlen(dir5)+1 : 0)+strlen(name)+5];
strcpy(fname,dir1);
strcat(fname,dir2);
strcat(fname,"\\");
if (game_mode)
{
strcat(fname,game_mode);
strcat(fname,"\\");
}
strcat(fname,dir4);
if (dir5)
{
strcat(fname,dir5);
strcat(fname,"\\");
}
strcat(fname,name);
strcat(fname,pg0ext);
delete[] dir2;
}
break;
}
}
if (!fname)
{
_LOGPUT("WARNING! GetPath returning NULL pointer\n");
}
else
_LOGPRINT(("file expected to be %s\n",fname));
}
CL_Error CL_RIFFImage::Locate(char const * iname, int const enum_id)
{
_LOGPRINT(("RIF File image finder called for %s, id %d\n",iname,enum_id));
if (!Env_Chunk)
_LOGPUT("WARNING! no .RIF file loaded\n");
if (!Env_Chunk) return CLE_RIFFERROR;
switch (imode)
{
case CLM_ATTACHEDPALETTE:
case CLM_16BIT:
case CLM_24BIT:
case CLM_32BIT:
case CLM_GLOBALPALETTE:
case CLM_TLTPALETTE:
break;
default:
_LOGPUT("WARNING! undefined video mode\n");
return CLE_INVALIDDXMODE;
}
// remove projectsubdirectory from start of image name if it is there
unsigned int const psdirlen = strlen(projectsubdirectory);
if (!strncmp(projectsubdirectory,iname,psdirlen))
iname += psdirlen;
List<Chunk *> envdl (Env_Chunk->lookup_child("REBENVDT"));
if (!envdl.size())
{
_LOGPUT("WARNING! no environment data chunk\n");
return CLE_RIFFERROR;
}
Environment_Data_Chunk * envd = (Environment_Data_Chunk *) envdl.first_entry();
CL_Error retval = CLE_OK;
Environment_Game_Mode_Chunk * egmc = 0;
if (game_mode)
{
if (*game_mode)
{
List<Chunk *> egmcl (envd->lookup_child("GAMEMODE"));
for (LIF<Chunk *> egmci(&egmcl); !egmci.done(); egmci.next())
{
Environment_Game_Mode_Chunk * egmcm = (Environment_Game_Mode_Chunk *) egmci();
if (egmcm->id_equals(game_mode))
{
egmc = egmcm;
break;
}
}
if (!egmc) retval = CLE_INVALIDGAMEMODE;
// only returns this error if the game mode cannot be found *and* the image is not listed
}
}
if (name)
{
delete[] name;
name = 0;
}
if (iname) name = strip_file_extension(strip_path(iname));
char * rcname = 0;
if (iname)
{
if (strchr(iname,'\\'))
{
rcname = new char[strlen(iname)+1];
strcpy(rcname,iname);
*strchr(rcname,'\\')=0;
}
else if (strchr(iname,'/'))
{
rcname = new char[strlen(iname)+1];
strcpy(rcname,iname);
*strchr(rcname,'/')=0;
}
}
if (egmc)
{
int shapefoundingm = rcname ? 0 : 1;
// Get the matching image 'Processor' chunk
List<Chunk *> micl = egmc->lookup_child("MATCHIMG");
Matching_Images_Chunk * mic = 0;
if (micl.size()) mic = (Matching_Images_Chunk *)micl.first_entry();
List<Chunk *> rcl = egmc->lookup_child("RIFCHILD");
for (LIF<Chunk *> rci(&rcl); !rci.done(); rci.next())
{
RIF_Child_Chunk * rcm = (RIF_Child_Chunk *) rci();
if (rcname)
{
if (_stricmp(rcname,rcm->rifname) && (*rcname || *rcm->filename))
continue;
shapefoundingm = 1;
}
for (LIF<BMP_Flags> bmpfi(&rcm->bmps); !bmpfi.done(); bmpfi.next())
{
BMP_Flags bmpft(bmpfi());
strip_file_extension(bmpft.filename);
if (iname ? !_stricmp(name,strip_path(bmpft.filename)) : enum_id == bmpft.enum_id)
{
// select image descriptor
ImageDescriptor const idsc
(
*rcm->filename ?
(IDscFlags)((bmpft.flags & ChunkBMPFlag_FixedPalette ?
IDSCF_FIXEDPALETTE
:
IDSCF_0)
|IDSCF_INCLUDED)
:
IDSCF_0,
bmpfi().filename,
*rcm->filename ? rcm->rifname : 0
);
ImageDescriptor const * p_idsc = &idsc;
if (mic) p_idsc = &mic->GetLoadImage(idsc);
else _LOGPRINT(("WARNING! no rule to find matching images in game mode %s\n",egmc->header->mode_identifier));
// load this image
GetPath(*p_idsc,envd,bmpft.flags);
if (fname)
{
if (rcname)
{
delete[] rcname;
rcname = 0;
}
flags.located = 1;
return CLE_OK;
}
}
}
}
List<Chunk *> ssc = egmc->lookup_child("SHBMPNAM");
for (LIF<Chunk *> ssi(&ssc); !ssi.done(); ssi.next())
{
External_Shape_BMPs_Store_Chunk * ss = (External_Shape_BMPs_Store_Chunk *) ssi();
if (rcname)
if (_stricmp(rcname,ss->shapename) && *rcname)
continue;
for (LIF<BMP_Name> bmpfi(&ss->bmps); !bmpfi.done(); bmpfi.next())
{
BMP_Name bmpft(bmpfi());
strip_file_extension(bmpft.filename);
if (iname ? !_stricmp(name,strip_path(bmpft.filename)) : enum_id == bmpft.enum_id)
{
// select image descriptor
ImageDescriptor const idsc
(
(IDscFlags)((bmpft.flags & ChunkBMPFlag_FixedPalette ?
IDSCF_FIXEDPALETTE
:
IDSCF_0)
|(ss->GetExtendedData()->flags & GBF_SPRITE ?
IDSCF_SPRITE
:
IDSCF_SUBSHAPE)
|IDSCF_INCLUDED),
bmpfi().filename,
ss->shapename,
bmpft.flags & ChunkBMPFlag_FixedPalette ? ss->rifname : 0
);
ImageDescriptor const * p_idsc = &idsc;
if (mic) p_idsc = &mic->GetLoadImage(idsc);
else _LOGPRINT(("WARNING! no rule to find matching images in game mode %s\n",egmc->header->mode_identifier));
#if TRY_OLD_DIRS // temporary until all textures move to SubShps/All directory
if (*p_idsc == idsc)
{
// select image descriptor
ImageDescriptor const idsc2
(
(IDscFlags)((bmpft.flags & ChunkBMPFlag_FixedPalette ?
IDSCF_FIXEDPALETTE
:
IDSCF_0)
|(ss->GetExtendedData()->flags & GBF_SPRITE ?
IDSCF_SPRITE
:
IDSCF_0)
|IDSCF_INCLUDED),
bmpfi().filename,
ss->shapename,
bmpft.flags & ChunkBMPFlag_FixedPalette ? ss->rifname : 0
);
ImageDescriptor const * p_idsc2 = &idsc2;
if (mic) p_idsc2 = &mic->GetLoadImage(idsc2);
else _LOGPRINT(("WARNING! no rule to find matching images in game mode %s\n",egmc->header->mode_identifier));
if (*p_idsc2 != idsc2)
{
_LOGPUT("WARNING! Not listed as in SubShps directory\n");
p_idsc = p_idsc2;
}
}
#endif
// load this image
GetPath(*p_idsc,envd,bmpft.flags);
if (fname)
{
if (rcname)
{
delete[] rcname;
rcname = 0;
}
flags.located = 1;
return CLE_OK;
}
}
}
}
if (rcname)
{
if (!shapefoundingm)
_LOGPRINT(("WARNING! shape/sprite %s not found in this RIF file\n",rcname));
else
_LOGPRINT(("WARNING! shape/sprite %s does not appear to list %s\n",rcname,name));
}
}
List<Chunk *> micl = envd->lookup_child("MATCHIMG");
Matching_Images_Chunk * mic_fix = 0;
Matching_Images_Chunk * mic_nrm = 0;
for (LIF<Chunk *> mici(&micl); !mici.done(); mici.next())
{
Matching_Images_Chunk * mic = (Matching_Images_Chunk *)mici();
if (mic->flags & MICF_FIXEDPALETTE)
mic_fix = mic;
else
mic_nrm = mic;
}
List<Chunk_With_Children *> shapesandsprites;
List<Chunk *> shlst = Env_Chunk->lookup_child("REBSHAPE");
for (LIF<Chunk *> shLIF(&shlst); !shLIF.done(); shLIF.next())
{
List<Chunk *> shxflst = ((Shape_Chunk *)shLIF())->lookup_child("SHPEXTFL");
if (shxflst.size())
{
shapesandsprites.add_entry( (Shape_External_File_Chunk *)shxflst.first_entry() );
}
}
shlst = Env_Chunk->lookup_child("RSPRITES");
if (shlst.size())
{
List<Chunk *> splst = ((Chunk_With_Children *)shlst.first_entry())->lookup_child("SPRIHEAD");
for (LIF<Chunk *> spLIF(&splst); !spLIF.done(); spLIF.next())
{
shapesandsprites.add_entry( (Chunk_With_Children *)spLIF() );
}
}
int shapefound = rcname ? 0 : 1;
for (LIF<Chunk_With_Children *> sasLIF(&shapesandsprites); !sasLIF.done(); sasLIF.next())
{
char * subrifname = riff_basename(sasLIF());
if (rcname)
{
if (_stricmp(subrifname,rcname)) // must match shapes name exactly
{
delete[] subrifname;
continue;
}
shapefound = 1;
}
List<Chunk *> blsclst = sasLIF()->lookup_child("BMPLSTST");
if (blsclst.size())
{
Bitmap_List_Store_Chunk * gbnc = (Bitmap_List_Store_Chunk *) blsclst.first_entry();
for (LIF<BMP_Name> bmpni(&gbnc->bmps); !bmpni.done(); bmpni.next())
{
BMP_Name bmpnt(bmpni());
strip_file_extension(bmpnt.filename);
if (iname ? !_stricmp(name,strip_path(bmpnt.filename)) : enum_id == bmpnt.enum_id)
{
// select image descriptor
char * riffname = riff_basename(envd);
ImageDescriptor const idsc
(
(IDscFlags)((bmpnt.flags & ChunkBMPFlag_FixedPalette ?
IDSCF_FIXEDPALETTE
:
IDSCF_0)
|(gbnc->GetExtendedData()->flags & GBF_SPRITE ?
IDSCF_SPRITE
:
IDSCF_SUBSHAPE)
|IDSCF_INCLUDED),
bmpni().filename,
subrifname,
bmpnt.flags & ChunkBMPFlag_FixedPalette ? riffname : 0
);
ImageDescriptor const * p_idsc = &idsc;
delete[] riffname;
if (bmpnt.flags & ChunkBMPFlag_FixedPalette)
{
if (mic_fix) p_idsc = &mic_fix->GetLoadImage(idsc);
else _LOGPUT("WARNING! no rule to find fixed palette matching images in environment data\n");
}
else
{
if (mic_nrm) p_idsc = &mic_nrm->GetLoadImage(idsc);
else _LOGPUT("WARNING! no rule to find matching images in environment data (interface engine?)\n");
}
#if TRY_OLD_DIRS // temporary until all textures move to SubShps/All directory
if (*p_idsc == idsc)
{
// select image descriptor
char * riffname = riff_basename(envd);
ImageDescriptor const idsc2
(
(IDscFlags)((bmpnt.flags & ChunkBMPFlag_FixedPalette ?
IDSCF_FIXEDPALETTE
:
IDSCF_0)
|(gbnc->GetExtendedData()->flags & GBF_SPRITE ?
IDSCF_SPRITE
:
IDSCF_0)
|IDSCF_INCLUDED),
bmpni().filename,
subrifname,
bmpnt.flags & ChunkBMPFlag_FixedPalette ? riffname : 0
);
ImageDescriptor const * p_idsc2 = &idsc2;
delete[] riffname;
if (bmpnt.flags & ChunkBMPFlag_FixedPalette)
{
if (mic_fix) p_idsc2 = &mic_fix->GetLoadImage(idsc2);
else _LOGPUT("WARNING! no rule to find fixed palette matching images in environment data\n");
}
else
{
if (mic_nrm) p_idsc2 = &mic_nrm->GetLoadImage(idsc2);
else _LOGPUT("WARNING! no rule to find matching images in environment data (interface engine?)\n");
}
if (*p_idsc2 != idsc2)
{
_LOGPUT("WARNING! Not listed as in SubShps directory\n");
p_idsc = p_idsc2;
}
}
#endif
// load this image
GetPath(*p_idsc,envd,bmpnt.flags);
if (fname)
{
delete[] subrifname;
if (rcname)
{
delete[] rcname;
rcname = 0;
}
flags.located = 1;
return CLE_OK;
}
}
}
}
delete[] subrifname;
}
if (rcname)
{
if (!shapefound)
_LOGPRINT(("WARNING! shape/sprite %s not found in this RIF file\n",rcname));
else
_LOGPRINT(("WARNING! shape/sprite %s does not appear to list %s\n",rcname,name));
delete[] rcname;
rcname = 0;
}
// not found in game textures, so look in default
else // but only if there is no virtual shape directory
{
List<Chunk *> gbncl = envd->lookup_child("BMPNAMES");
if (gbncl.size())
{
Global_BMP_Name_Chunk * gbnc = (Global_BMP_Name_Chunk *) gbncl.first_entry();
for (LIF<BMP_Name> bmpni(&gbnc->bmps); !bmpni.done(); bmpni.next())
{
BMP_Name bmpnt(bmpni());
strip_file_extension(bmpnt.filename);
if (iname ? !_stricmp(name,strip_path(bmpnt.filename)) : enum_id == bmpnt.enum_id)
{
// select image descriptor
ImageDescriptor const idsc (bmpnt.flags & ChunkBMPFlag_FixedPalette ? IDSCF_FIXEDPALETTE : IDSCF_0, bmpni().filename);
ImageDescriptor const * p_idsc = &idsc;
if (bmpnt.flags & ChunkBMPFlag_FixedPalette)
{
if (mic_fix) p_idsc = &mic_fix->GetLoadImage(idsc);
else _LOGPUT("WARNING! no rule to find fixed palette matching images in environment data\n");
}
else
{
if (mic_nrm) p_idsc = &mic_nrm->GetLoadImage(idsc);
else _LOGPUT("WARNING! no rule to find matching images in environment data (interface engine?)\n");
}
// load this image
GetPath(*p_idsc,envd,bmpnt.flags);
if (fname)
{
flags.located = 1;
return CLE_OK;
}
}
}
}
}
if (retval != CLE_OK) return retval;
return CLE_FINDERROR;
}

View file

@ -1,33 +0,0 @@
#ifndef _included__chnkimag_hpp_
#define _included__chnkimag_hpp_
#error "This file is obsolete"
#include <stdio.h>
#include "d3_image.hpp"
#include "mishchnk.hpp"
#include "bmpnames.hpp"
extern "C" extern char projectsubdirectory[];
extern char const * GameTex_Directory;
extern char const * GenTex_Directory;
extern char const * FixTex_Directory;
extern char const * ToolsTex_Directory;
struct CL_RIFFImage : public CL_Image
{
public:
static char const * game_mode; // game mode defines palette and set of graphics - can be null or "" for default
CL_RIFFImage() : CL_Image() {}
CL_RIFFImage(CL_Image const & base) : CL_Image(base) {}
private:
virtual CL_Error Locate(char const * iname, int const enum_id);
void GetPath(ImageDescriptor const & idsc, Environment_Data_Chunk * envd, BMPN_Flags bflags);
};
#endif // !_included__chnkimag_hpp_

View file

@ -1,34 +0,0 @@
#include "cl_init.h"
#include "system.h" // because the 3dc header files don't automatically include the ones they need
#include "equates.h" // because the 3dc header files don't automatically include the ones they need
#include "platform.h" // for VideoModeTypes
#include "shape.h" // because the 3dc header files don't automatically include the ones they need
#include "prototyp.h" // for SDB
#include "d3_image.hpp" // for init functions
extern "C" extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
void CL_Init_All(void)
{
switch (VideoModeTypeScreen)
{
case VideoModeType_8:
if (ScreenDescriptorBlock.SDB_Flags & SDB_Flag_TLTPalette)
CL_Init_DirectDrawMode(CLV_8TLT);
else
CL_Init_DirectDrawMode(CLV_8);
break;
case VideoModeType_15:
CL_Init_DirectDrawMode(CLV_15);
break;
case VideoModeType_24:
CL_Init_DirectDrawMode(CLV_24);
break;
case VideoModeType_8T:
CL_Init_DirectDrawMode(CLV_8T);
break;
}
if (ScanDrawDirectDraw != ScanDrawMode)
CL_Init_D3DMode(&(d3d.TextureFormat[d3d.CurrentTextureFormat].ddsd));
}

View file

@ -1,23 +0,0 @@
#ifndef _included_cl_init_h_
#define _included_cl_init_h_
#error "This file is obsolete"
#ifdef __cplusplus
extern "C" {
#endif
#include "d3d.h" // required by d3_func.hpp
#include "d3_func.h" // for D3DINFO definition
extern int VideoModeTypeScreen;
extern int ScanDrawMode;
extern D3DINFO d3d;
void CL_Init_All(void);
#ifdef __cplusplus
};
#endif
#endif // !_included_cl_init_h_

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff