Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+82 -85
View File
@@ -20,8 +20,8 @@
// ???:David Smoth - ???
// ???:Bret Rowdon for RIO/GORGE - added 640x480 SVGA support
// 05-11jun96:HJH - added routines for bitmap use, and
// other utilities
// 08-May-97 ARM Adapted for Win95 Standard Gaming Platform
// other utilities
// 08-May-97 ARM Adapted for Win95 Standard Gaming Platform
//
//**************************************************************************
@@ -31,7 +31,6 @@
//
//**************************************************************************
//#include "stdafx.h"
#include <conio.h>
#include "flic.h"
#include "windows.h"
@@ -226,7 +225,7 @@ static void screen_repeat_two(FlicScreen *s, int x, int y, Pixels2 pixels2, int
count <<= 1; // Convert from word to pixel count.
if (!line_clip(s, &x, &y, &count))
return;
is_odd = (count&1); // Did it turn odd after clipping? Ack!
is_odd = (count&1); // Did it turn odd after clipping? Ack!
count >>= 1; // Convert back to word count.
// Calculate start screen address.
@@ -246,7 +245,7 @@ static void screen_repeat_two(FlicScreen *s, int x, int y, Pixels2 pixels2, int
//
// screen_put_colors
//
// Set count colors in color map starting at start. RGB values
// Set count colors in color map starting at start. RGB values
// go from 0 to 255.
//
// Parameter List :
@@ -279,7 +278,7 @@ static void screen_put_colors(FlicScreen *s, int start, Colour *colors, int coun
//
// screen_put_colors_64
//
// Set count colors in color map starting at start. RGB values
// Set count colors in color map starting at start. RGB values
// go from 0 to 64. */
//
// Parameter List :
@@ -325,13 +324,13 @@ static void screen_put_colors_64(FlicScreen *s, int start, Colour *colors, int c
//
//**************************************************************************
static void decode_byte_run(Uchar *data, Flic *flic)
static void decode_byte_run(Uchar *data, Flic *flic)
{
int x,y;
int width = flic->head.width;
int height = flic->head.height;
int psize; // was char -> HJH
Char *cpt = (Char *)data;
Char *cpt = (Char *)data;
int end;
y = flic->yoff;
@@ -375,12 +374,12 @@ static void decode_byte_run(Uchar *data, Flic *flic)
//
//**************************************************************************
static void decode_delta_fli(Uchar *data, Flic *flic)
static void decode_delta_fli(Uchar *data, Flic *flic)
{
int xorg = flic->xoff;
int yorg = flic->yoff;
Short *wpt = (Short *)data;
Uchar *cpt = (Uchar *)(wpt + 2);
Short *wpt = (Short *)data;
Uchar *cpt = (Uchar *)(wpt + 2);
int x,y;
Short lines;
Uchar opcount;
@@ -419,7 +418,7 @@ static void decode_delta_fli(Uchar *data, Flic *flic)
//
// decode_delta_flc
//
// Flc-style delta decompression. The data is word oriented though
// Flc-style delta decompression. The data is word oriented though
// a lot of the control info (how to skip, how many words to
// copy) are byte oriented still to save space.
//
@@ -433,7 +432,7 @@ static void decode_delta_fli(Uchar *data, Flic *flic)
//
//**************************************************************************
static void decode_delta_flc(Uchar *data, Flic *flic)
static void decode_delta_flc(Uchar *data, Flic *flic)
{
int xorg = flic->xoff;
int yorg = flic->yoff;
@@ -442,7 +441,7 @@ static void decode_delta_flc(Uchar *data, Flic *flic)
Short lp_count;
Short opcount;
int psize;
union {Short *w; Uchar *ub; Char *b; Pixels2 *p2;} wpt;
union {Short *w; Uchar *ub; Char *b; Pixels2 *p2;} wpt;
int lastx;
@@ -504,7 +503,7 @@ OUTT:
//
// decode_black
//
// Decode a BLACK chunk. Set frame to solid color 0 one
// Decode a BLACK chunk. Set frame to solid color 0 one
// line at a time.
//
// Parameter List :
@@ -517,7 +516,7 @@ OUTT:
//
//**************************************************************************
static void decode_black(Uchar *data, Flic *flic)
static void decode_black(Uchar *data, Flic *flic)
{
Pixels2 black;
int i;
@@ -539,7 +538,7 @@ static void decode_black(Uchar *data, Flic *flic)
//
// decode_literal
//
// Decode a LITERAL chunk. Just copy data to screen one line at
// Decode a LITERAL chunk. Just copy data to screen one line at
// a time.
//
// Parameter List :
@@ -552,7 +551,7 @@ static void decode_black(Uchar *data, Flic *flic)
//
//**************************************************************************
static void decode_literal(Uchar *data, Flic *flic)
static void decode_literal(Uchar *data, Flic *flic)
{
int i;
int height = flic->head.height;
@@ -570,16 +569,16 @@ static void decode_literal(Uchar *data, Flic *flic)
typedef void ColorOut(FlicScreen *s, int start, Colour *colors, int count);
/* This is the type of output parameter to our decode_color below.
* Not coincedently screen_put_color is of this type. */
* Not coincedently screen_put_color is of this type. */
//**************************************************************************
//
// decode_color
//
// Decode color map. Put results into output. The two color
// Decode color map. Put results into output. The two color
// compressions are identical except for whether the RGB values
// are 0-63 or 0-255. Passing in an output that does the appropriate
// are 0-63 or 0-255. Passing in an output that does the appropriate
// shifting on the way to the real pallete lets us use the same
// code for both COLOR_64 and COLOR_256 compression.
//
@@ -594,7 +593,7 @@ typedef void ColorOut(FlicScreen *s, int start, Colour *colors, int count);
//
//**************************************************************************
static void decode_color(Uchar *data, Flic *flic, ColorOut *output)
static void decode_color(Uchar *data, Flic *flic, ColorOut *output)
{
int start = 0;
Uchar *cbuf = (Uchar *)data;
@@ -631,7 +630,7 @@ static void decode_color(Uchar *data, Flic *flic, ColorOut *output)
//
//**************************************************************************
static void decode_color_256(Uchar *data, Flic *flic)
static void decode_color_256(Uchar *data, Flic *flic)
{
decode_color(data, flic, screen_put_colors);
}
@@ -652,7 +651,7 @@ static void decode_color_256(Uchar *data, Flic *flic)
//
//**************************************************************************
static void decode_color_64(Uchar *data, Flic *flic)
static void decode_color_64(Uchar *data, Flic *flic)
{
decode_color(data, flic, screen_put_colors_64);
}
@@ -676,40 +675,40 @@ static void decode_color_64(Uchar *data, Flic *flic)
//
//**************************************************************************
static ErrCode decode_frame(Flic *flic, FrameHead *frame, Uchar *data)
static ErrCode decode_frame(Flic *flic, FrameHead *frame, Uchar *data)
{
int i;
ChunkHead *chunk;
for (i=0; i<frame->chunks; ++i)
{
chunk = (ChunkHead *)data;
chunk = (ChunkHead *)data;
data += chunk->size;
switch (chunk->type)
{
case COLOR_256:
if (flic->screen.change_palette)
//decode_color_256((Uchar *)(chunk+1), flic);
decode_color_256( (((Uchar *)chunk) + 4 ), flic);
//decode_color_256((Uchar *)(chunk+1), flic);
decode_color_256( (((Uchar *)chunk) + 4 ), flic);
break;
case DELTA_FLC:
decode_delta_flc((Uchar *)(chunk+1), flic);
decode_delta_flc((Uchar *)(chunk+1), flic);
break;
case COLOR_64:
if (flic->screen.change_palette)
decode_color_64((Uchar *)(chunk+1), flic);
decode_color_64((Uchar *)(chunk+1), flic);
break;
case DELTA_FLI:
decode_delta_fli((Uchar *)(chunk+1), flic);
decode_delta_fli((Uchar *)(chunk+1), flic);
break;
case BLACK_FRAME:
decode_black((Uchar *)(chunk+1), flic);
decode_black((Uchar *)(chunk+1), flic);
break;
case BYTE_RUN:
decode_byte_run((Uchar *)(chunk+1), flic);
decode_byte_run((Uchar *)(chunk+1), flic);
break;
case LITERAL:
decode_literal((Uchar *)(chunk+1), flic);
decode_literal((Uchar *)(chunk+1), flic);
break;
default:
break;
@@ -719,7 +718,7 @@ static ErrCode decode_frame(Flic *flic, FrameHead *frame, Uchar *data)
}
static ErrCode file_read_big_block(FILE *file, char *block, Ulong size)
/* Read in a big block. Could be bigger than 64K. */
/* Read in a big block. Could be bigger than 64K. */
{
char *pt = block;
unsigned size1;
@@ -758,10 +757,10 @@ static ErrCode fill_in_frame2(Flic *flic)
(*flic->seek)(flic, flic->head.oframe1);
if ( fread(&head, sizeof(head), 1, flic->file) != 1 )
return ErrFlicRead;
return ErrFlicRead;
if ( fread(&head, sizeof(head), 1, flic->file) != 1 )
return ErrFlicRead;
return ErrFlicRead;
flic->head.oframe2 = flic->head.oframe1 + head.size;
@@ -790,7 +789,7 @@ static ErrCode flic_next_frame(Flic *flic, BOOL fDecode)
long size;
if ( fread(&head, sizeof(head), 1, flic->file) != 1 )
err = ErrFlicRead;
err = ErrFlicRead;
else
{
if (head.type == FRAME_TYPE)
@@ -802,7 +801,7 @@ static ErrCode flic_next_frame(Flic *flic, BOOL fDecode)
{
//TRACE("FLC chunk too big: %d\n",size);
//Assert(0);
FastDebugMsg(String("flic_next_frame: FLC chunk too big: %d", size));
FastDebugMsg(String("flic_next_frame: FLC chunk too big: %d", size));
size = 64000;
}
if (!(err = file_read_big_block(flic->file, pcxbuf, size)))
@@ -835,7 +834,7 @@ static ErrCode flic_next_frame(Flic *flic, BOOL fDecode)
static Boolean flic_check_frame(Flic *flic)
{
return TRUE;
return TRUE;
}
//**************************************************************************
@@ -846,12 +845,12 @@ static Boolean flic_check_frame(Flic *flic)
static ErrCode flic_open(Flic *flic, const char *filename)
{
return (flic->file = fopen(filename, "rb")) ? 0 : ErrFlicAccess;
return (flic->file = fopen(filename, "rb")) ? 0 : ErrFlicAccess;
}
static ErrCode flic_seek(Flic *flic, long offset)
{
return fseek(flic->file, offset, SEEK_SET) ? ErrFlicSeek : 0;
return fseek(flic->file, offset, SEEK_SET) ? ErrFlicSeek : 0;
}
//**************************************************************************
@@ -871,20 +870,20 @@ static ErrCode flic_seek(Flic *flic, long offset)
void FlicInit(Flic *flic, unsigned screen_width, unsigned screen_height, char change_palette, char *Buff)
{
flic->file = NULL;
//flic->lib.names = NULL;
flic->file = NULL;
//flic->lib.names = NULL;
flic->open = flic_open; /* Set routines for single flick file access */
flic->seek = flic_seek;
flic->open = flic_open; /* Set routines for single flick file access */
flic->seek = flic_seek;
flic->check_frame = flic_check_frame; /* Select a dummy routine */
flic->check_frame = flic_check_frame; /* Select a dummy routine */
/** Info used by low level routines */
/** Info used by low level routines */
flic->screen.pixels = (unsigned char *)Buff; // (char *) 0xa0000;
flic->screen.width = screen_width;
flic->screen.height = screen_height;
flic->screen.change_palette = change_palette;
flic->screen.pixels = (unsigned char *)Buff; // (char *) 0xa0000;
flic->screen.width = screen_width;
flic->screen.height = screen_height;
flic->screen.change_palette = change_palette;
}
//**************************************************************************
@@ -912,7 +911,7 @@ ErrCode FlicOpen(Flic *flic, const char *filename)
if ( !(err = (*flic->open)(flic, filename)) )
{
if (fread(&flic->head, sizeof(flic->head), 1, flic->file) != 1)
err = ErrFlicRead;
err = ErrFlicRead;
else
{
flic->name = filename;
@@ -966,8 +965,8 @@ ErrCode FlicOpen(Flic *flic, const char *filename)
void FlicSetOrigin(Flic *flic, unsigned x, unsigned y)
{
flic->xoff = x;
flic->yoff = y;
flic->xoff = x;
flic->yoff = y;
}
//**************************************************************************
@@ -1024,7 +1023,7 @@ static void flic_play_loop_timer()
}
#ifdef DEBUG
#pragma on (check_stack)
#pragma on (check_stack)
#endif
//**************************************************************************
@@ -1083,16 +1082,16 @@ ErrCode FlicPlay(Flic *flic, Ulong max_loop)
}
for (flic->status.loop_count = 0; !max_loop || flic->status.loop_count < max_loop;
++flic->status.loop_count)
++flic->status.loop_count)
{
// Seek to second frame
(*flic->seek)(flic, flic->head.oframe2);
// Loop from 2nd frame thru ring frame
for (flic->status.frame_index=0;
(flic->status.frame_index < (flic->head.frames-1)) ||
( (flic->status.frame_index < flic->head.frames) &&
( !max_loop || (flic->status.loop_count < (max_loop - 1))));
++flic->status.frame_index)
(flic->status.frame_index < (flic->head.frames-1)) ||
( (flic->status.frame_index < flic->head.frames) &&
( !max_loop || (flic->status.loop_count < (max_loop - 1))));
++flic->status.frame_index)
{
while (!timer_flag);
@@ -1133,10 +1132,10 @@ int FlicAdvance(Flic *flic, BOOL fDecode)
// Loop from 2nd frame thru ring frame
// for (flic->status.frame_index=0;
// (flic->status.frame_index < (flic->head.frames-1)) ||
// ( (flic->status.frame_index < flic->head.frames) &&
// ( !max_loop || (flic->status.loop_count < (max_loop - 1))));
// ++flic->status.frame_index)
// (flic->status.frame_index < (flic->head.frames-1)) ||
// ( (flic->status.frame_index < flic->head.frames) &&
// ( !max_loop || (flic->status.loop_count < (max_loop - 1))));
// ++flic->status.frame_index)
// {
if(flic->status.frame_index < flic->head.frames)
@@ -1150,7 +1149,7 @@ int FlicAdvance(Flic *flic, BOOL fDecode)
return(0);
// if (flic->check_frame && !(*flic->check_frame)(flic))
// return 0;
// return 0;
}
static void center_flic(Flic *flic)
@@ -1163,20 +1162,20 @@ static void center_flic(Flic *flic)
void set_flic_origin(Flic *flic, int x, int y)
{
flic->xoff = x;
flic->yoff = y;
flic->xoff = x;
flic->yoff = y;
}
int frame_check(Flic *flic)
{
/*
char key;
/*
char key;
if (Esc())
{
{
//AbortScript = TRUE;
return 0;
}
}
if (flic->status.frame_index == FlcSoundFrames[FlcSoundIndex][0])
{
@@ -1206,7 +1205,7 @@ int frame_check(Flic *flic)
}
RefreshSound();
*/
return 1;
return 1;
}
//**************************************************************************
@@ -1295,7 +1294,7 @@ ErrCode FlicGetStats(char *filename, int width, int height, Flic *flic, int *piB
if ( !(err = (*flic->open)(flic, filename)) )
{
if (fread(&flic->head, sizeof(flic->head), 1, flic->file) != 1)
err = ErrFlicRead;
err = ErrFlicRead;
}
if ( !err && piBufferSize )
@@ -1352,7 +1351,7 @@ ErrCode FlicGetColourPalette(CHAR *filename, int width, int height, CHAR **ppBuf
return(-1);
FlicSetOrigin(&flic, 0, 0);
*ppBuffer = (CHAR *)MemAlloc( iColourPaletteSize );
chunk = (ChunkHead *)FlicSeekChunk( &flic, 0, COLOR_256, NULL );
pcPosition = (CHAR *)(((BYTE *)chunk)+6);
@@ -1374,11 +1373,11 @@ ErrCode FlicGetColourPalette(CHAR *filename, int width, int height, CHAR **ppBuf
count = 256;
{
colors = (Colour *)cbuf;
end = start + count;
end = start + count;
for (ix = start; ix < end; ++ix)
{
(*ppBuffer)[ix*3] =colors->r;
(*ppBuffer)[ix*3] =colors->r;
(*ppBuffer)[ix*3+1]=colors->g;
(*ppBuffer)[ix*3+2]=colors->b;
++colors;
@@ -1424,9 +1423,8 @@ CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize)
{
FrameHead head;
LONG lSize;
BOOL fFound = FALSE;
ErrCode err=0;
INT i;
INT i;
FlicSeekFirst(flic);
@@ -1434,7 +1432,7 @@ CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize)
FlicAdvance(flic, FALSE);
if ( fread(&head, sizeof(head), 1, flic->file) != 1 )
err = ErrFlicRead;
err = ErrFlicRead;
else
{
if (head.type == FRAME_TYPE)
@@ -1449,20 +1447,19 @@ CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize)
}
if (!(err = file_read_big_block(flic->file, pcxbuf, lSize)))
{
FrameHead *frame = &head;
Uchar *data = (unsigned char *)pcxbuf;
int i;
ChunkHead *chunk;
for (i=0; i<head.chunks; ++i)
{
chunk = (ChunkHead *)data;
chunk = (ChunkHead *)data;
data += chunk->size;
if ( chunk->type == eType )
{
if ( piChunkSize )
*piChunkSize = chunk->size;
return( ((char *)chunk) );
return( ((char *)chunk) );
}
}
}
@@ -1500,7 +1497,7 @@ CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize)
INT FlicFindByteRunBeforeFrame(Flic *flic, INT iFrame)
{
INT iRet = BAD_INDEX;
INT i;
INT i;
for ( i=iFrame-1 ; i>=0 ; i-- )
@@ -1620,7 +1617,7 @@ ErrCode FlicFillFrameData(
//GetObject( hBitmap, sizeof(DIBSECTION), &dibSection );
flic->screen.pixels = (Pixel *)pcBuffer;
iNumBytesInBuffer = *piNumBytes;
iNumBytesInBuffer = *piNumBytes;
if ( iPrevFrame == BAD_INDEX || iPrevFrame != (iFrame-1) )
{