Merge branch 'd2x-rebirth' into unification/master
This commit is contained in:
commit
d7f46c9623
|
@ -80,26 +80,6 @@ int PCXHeader_read_n(PCXHeader *ph, int n, PHYSFS_file *fp)
|
|||
return i;
|
||||
}
|
||||
|
||||
int pcx_get_dimensions( char *filename, int *width, int *height)
|
||||
{
|
||||
PHYSFS_file *PCXfile;
|
||||
PCXHeader header;
|
||||
|
||||
PCXfile = PHYSFSX_openReadBuffered(filename);
|
||||
if (!PCXfile) return PCX_ERROR_OPENING;
|
||||
|
||||
if (PCXHeader_read_n(&header, 1, PCXfile) != 1) {
|
||||
PHYSFS_close(PCXfile);
|
||||
return PCX_ERROR_NO_HEADER;
|
||||
}
|
||||
PHYSFS_close(PCXfile);
|
||||
|
||||
*width = header.Xmax - header.Xmin+1;
|
||||
*height = header.Ymax - header.Ymin+1;
|
||||
|
||||
return PCX_ERROR_NONE;
|
||||
}
|
||||
|
||||
int pcx_read_bitmap( char * filename, grs_bitmap * bmp,int bitmap_type ,ubyte * palette )
|
||||
{
|
||||
PCXHeader header;
|
||||
|
|
|
@ -1,407 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Routines for scaling a bitmap.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <conf.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "fix.h"
|
||||
#include "gr.h"
|
||||
#include "dxxerror.h"
|
||||
#include "rle.h"
|
||||
|
||||
#if 0
|
||||
#define TRANSPARENCY_COLOR 255;
|
||||
#endif
|
||||
|
||||
static int Transparency_color = TRANSPARENCY_COLOR;
|
||||
|
||||
void rls_stretch_scanline( char * source, char * dest, int XDelta, int YDelta );
|
||||
void rls_stretch_scanline_setup( int XDelta, int YDelta );
|
||||
void scale_bitmap_asm(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 );
|
||||
void scale_bitmap_asm_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 );
|
||||
void scale_bitmap_cc_asm(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 );
|
||||
void scale_bitmap_cc_asm_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 );
|
||||
|
||||
void scale_row_c( ubyte * sbits, ubyte * dbits, int width, fix u, fix du )
|
||||
{
|
||||
int i;
|
||||
ubyte c;
|
||||
|
||||
for ( i=0; i<width; i++ ) {
|
||||
c = sbits[ f2i(u) ];
|
||||
|
||||
if ( c != Transparency_color )
|
||||
*dbits = c;
|
||||
|
||||
dbits++;
|
||||
u += du;
|
||||
}
|
||||
}
|
||||
|
||||
#define FIND_SCALED_NUM(x,x0,x1,y0,y1) (fixmuldiv((x)-(x0),(y1)-(y0),(x1)-(x0))+(y0))
|
||||
|
||||
// Scales bitmap, bp, into vertbuf[0] to vertbuf[1]
|
||||
void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf ,int orientation)
|
||||
{
|
||||
grs_bitmap * dbp = &grd_curcanv->cv_bitmap;
|
||||
fix x0, y0, x1, y1;
|
||||
fix u0, v0, u1, v1;
|
||||
fix clipped_x0, clipped_y0, clipped_x1, clipped_y1;
|
||||
fix clipped_u0, clipped_v0, clipped_u1, clipped_v1;
|
||||
fix xmin, xmax, ymin, ymax;
|
||||
int dx0, dy0, dx1, dy1;
|
||||
int dtemp;
|
||||
// Set initial variables....
|
||||
|
||||
x0 = vertbuf[0].x; y0 = vertbuf[0].y;
|
||||
x1 = vertbuf[2].x; y1 = vertbuf[2].y;
|
||||
|
||||
xmin = 0; ymin = 0;
|
||||
xmax = i2f(dbp->bm_w)-fl2f(.5); ymax = i2f(dbp->bm_h)-fl2f(.5);
|
||||
|
||||
u0 = i2f(0); v0 = i2f(0);
|
||||
u1 = i2f(bp->bm_w-1); v1 = i2f(bp->bm_h-1);
|
||||
|
||||
// Check for obviously offscreen bitmaps...
|
||||
if ( (y1<=y0) || (x1<=x0) ) return;
|
||||
if ( (x1<0 ) || (x0>=xmax) ) return;
|
||||
if ( (y1<0 ) || (y0>=ymax) ) return;
|
||||
|
||||
clipped_u0 = u0; clipped_v0 = v0;
|
||||
clipped_u1 = u1; clipped_v1 = v1;
|
||||
|
||||
clipped_x0 = x0; clipped_y0 = y0;
|
||||
clipped_x1 = x1; clipped_y1 = y1;
|
||||
|
||||
// Clip the left, moving u0 right as necessary
|
||||
if ( x0 < xmin ) {
|
||||
clipped_u0 = FIND_SCALED_NUM(xmin,x0,x1,u0,u1);
|
||||
clipped_x0 = xmin;
|
||||
}
|
||||
|
||||
// Clip the right, moving u1 left as necessary
|
||||
if ( x1 > xmax ) {
|
||||
clipped_u1 = FIND_SCALED_NUM(xmax,x0,x1,u0,u1);
|
||||
clipped_x1 = xmax;
|
||||
}
|
||||
|
||||
// Clip the top, moving v0 down as necessary
|
||||
if ( y0 < ymin ) {
|
||||
clipped_v0 = FIND_SCALED_NUM(ymin,y0,y1,v0,v1);
|
||||
clipped_y0 = ymin;
|
||||
}
|
||||
|
||||
// Clip the bottom, moving v1 up as necessary
|
||||
if ( y1 > ymax ) {
|
||||
clipped_v1 = FIND_SCALED_NUM(ymax,y0,y1,v0,v1);
|
||||
clipped_y1 = ymax;
|
||||
}
|
||||
|
||||
dx0 = f2i(clipped_x0); dx1 = f2i(clipped_x1);
|
||||
dy0 = f2i(clipped_y0); dy1 = f2i(clipped_y1);
|
||||
|
||||
if (dx1<=dx0) return;
|
||||
if (dy1<=dy0) return;
|
||||
|
||||
Assert( dx0>=0 );
|
||||
Assert( dy0>=0 );
|
||||
Assert( dx1<dbp->bm_w );
|
||||
Assert( dy1<dbp->bm_h );
|
||||
Assert( f2i(u0)<=f2i(u1) );
|
||||
Assert( f2i(v0)<=f2i(v1) );
|
||||
Assert( f2i(u0)>=0 );
|
||||
Assert( f2i(v0)>=0 );
|
||||
Assert( u1<i2f(bp->bm_w) );
|
||||
Assert( v1<i2f(bp->bm_h) );
|
||||
|
||||
dtemp = f2i(clipped_u1)-f2i(clipped_u0);
|
||||
|
||||
if ( bp->bm_flags & BM_FLAG_RLE ) {
|
||||
if ( (dtemp < (f2i(clipped_x1)-f2i(clipped_x0))) && (dtemp>0) )
|
||||
scale_bitmap_cc_asm_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 );
|
||||
else
|
||||
scale_bitmap_asm_rle(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 );
|
||||
} else {
|
||||
if ( (dtemp < (f2i(clipped_x1)-f2i(clipped_x0))) && (dtemp>0) )
|
||||
scale_bitmap_cc_asm(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 );
|
||||
else
|
||||
scale_bitmap_asm(bp, dbp, dx0, dy0, dx1, dy1, clipped_u0, clipped_v0, clipped_u1, clipped_v1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void scale_bitmap_c(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 )
|
||||
{
|
||||
fix u, v, du, dv;
|
||||
int x, y;
|
||||
ubyte * sbits, * dbits;
|
||||
|
||||
du = (u1-u0) / (x1-x0);
|
||||
dv = (v1-v0) / (y1-y0);
|
||||
|
||||
v = v0;
|
||||
|
||||
for (y=y0; y<=y1; y++ ) {
|
||||
sbits = &source_bmp->bm_data[source_bmp->bm_rowsize*f2i(v)];
|
||||
dbits = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0];
|
||||
u = u0;
|
||||
v += dv;
|
||||
for (x=x0; x<=x1; x++ ) {
|
||||
*dbits++ = sbits[ u >> 16 ];
|
||||
u += du;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scale_bitmap_asm(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 )
|
||||
{
|
||||
fix du, dv, v;
|
||||
int y;
|
||||
|
||||
du = (u1-u0) / (x1-x0);
|
||||
dv = (v1-v0) / (y1-y0);
|
||||
|
||||
v = v0;
|
||||
|
||||
for (y=y0; y<=y1; y++ ) {
|
||||
scale_row_asm_transparent( &source_bmp->bm_data[source_bmp->bm_rowsize*f2i(v)], &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0], x1-x0+1, u0, du );
|
||||
v += dv;
|
||||
}
|
||||
}
|
||||
|
||||
ubyte scale_rle_data[640];
|
||||
|
||||
void decode_row( grs_bitmap * bmp, int y )
|
||||
{
|
||||
int i, offset=4+bmp->bm_h;
|
||||
|
||||
for (i=0; i<y; i++ )
|
||||
offset += bmp->bm_data[4+i];
|
||||
gr_rle_decode( &bmp->bm_data[offset], scale_rle_data );
|
||||
}
|
||||
|
||||
void scale_bitmap_asm_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 )
|
||||
{
|
||||
fix du, dv, v;
|
||||
int y, last_row=-1;
|
||||
|
||||
du = (u1-u0) / (x1-x0);
|
||||
dv = (v1-v0) / (y1-y0);
|
||||
|
||||
v = v0;
|
||||
|
||||
for (y=y0; y<=y1; y++ ) {
|
||||
if ( f2i(v) != last_row ) {
|
||||
last_row = f2i(v);
|
||||
decode_row( source_bmp, last_row );
|
||||
}
|
||||
scale_row_asm_transparent( scale_rle_data, &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0], x1-x0+1, u0, du );
|
||||
v += dv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void scale_bitmap_cc_asm(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 )
|
||||
{
|
||||
fix dv, v;
|
||||
int y;
|
||||
|
||||
dv = (v1-v0) / (y1-y0);
|
||||
|
||||
rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) );
|
||||
if ( scale_ydelta_minus_1 < 1 ) return;
|
||||
rls_do_cc_setup_asm();
|
||||
|
||||
v = v0;
|
||||
|
||||
for (y=y0; y<=y1; y++ ) {
|
||||
scale_source_ptr = &source_bmp->bm_data[source_bmp->bm_rowsize*f2i(v)+f2i(u0)];
|
||||
scale_dest_ptr = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0];
|
||||
scale_do_cc_scanline();
|
||||
v += dv;
|
||||
}
|
||||
}
|
||||
|
||||
void scale_bitmap_cc_asm_rle(grs_bitmap *source_bmp, grs_bitmap *dest_bmp, int x0, int y0, int x1, int y1, fix u0, fix v0, fix u1, fix v1 )
|
||||
{
|
||||
fix dv, v;
|
||||
int y, last_row = -1;
|
||||
|
||||
dv = (v1-v0) / (y1-y0);
|
||||
|
||||
rls_stretch_scanline_setup( (int)(x1-x0), f2i(u1)-f2i(u0) );
|
||||
if ( scale_ydelta_minus_1 < 1 ) return;
|
||||
rls_do_cc_setup_asm();
|
||||
|
||||
v = v0;
|
||||
|
||||
for (y=y0; y<=y1; y++ ) {
|
||||
if ( f2i(v) != last_row ) {
|
||||
last_row = f2i(v);
|
||||
decode_row( source_bmp, last_row );
|
||||
}
|
||||
//scale_source_ptr = &source_bmp->bm_data[source_bmp->bm_rowsize*f2i(v)+f2i(u0)];
|
||||
scale_source_ptr = &scale_rle_data[f2i(u0)];
|
||||
scale_dest_ptr = &dest_bmp->bm_data[dest_bmp->bm_rowsize*y+x0];
|
||||
scale_do_cc_scanline();
|
||||
v += dv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Run-length slice bitmap scan line stretcher
|
||||
|
||||
void DrawHorizontalRun(char *ScreenPtr, int RunLength, int Color)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<RunLength; i++)
|
||||
*ScreenPtr++ = Color;
|
||||
}
|
||||
|
||||
void rls_stretch_scanline( char * source, char * dest, int XDelta, int YDelta )
|
||||
{
|
||||
int AdjUp, AdjDown, ErrorTerm;
|
||||
int WholeStep, InitialPixelCount, FinalPixelCount, i, RunLength;
|
||||
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = XDelta / YDelta;
|
||||
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
AdjUp = (XDelta % YDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
AdjDown = YDelta * 2;
|
||||
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
ErrorTerm = (XDelta % YDelta) - (YDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += YDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
//if ( *source != Transparency_color )
|
||||
rep_stosb(dest, InitialPixelCount, *source );
|
||||
dest += InitialPixelCount;
|
||||
source++;
|
||||
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(YDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
|
||||
/* Advance the error term and add an extra pixel if the error term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
|
||||
//if ( *source != Transparency_color )
|
||||
rep_stosb(dest, RunLength, *source );
|
||||
dest += RunLength;
|
||||
source++;
|
||||
|
||||
}
|
||||
|
||||
/* Draw the final run of pixels */
|
||||
//if ( *source != Transparency_color )
|
||||
rep_stosb(dest, FinalPixelCount, *source );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void rls_stretch_scanline_setup( int XDelta, int YDelta )
|
||||
{
|
||||
scale_trans_color = Transparency_color & 0xFF;
|
||||
scale_ydelta_minus_1 = YDelta - 1;
|
||||
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
scale_whole_step = XDelta / YDelta;
|
||||
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
scale_adj_up = (XDelta % YDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
scale_adj_down = YDelta * 2;
|
||||
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
scale_error_term = (XDelta % YDelta) - (YDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
scale_initial_pixel_count = (scale_whole_step / 2) + 1;
|
||||
scale_final_pixel_count = scale_initial_pixel_count;
|
||||
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((scale_adj_up == 0) && ((scale_whole_step & 0x01) == 0))
|
||||
{
|
||||
scale_initial_pixel_count--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((scale_whole_step & 0x01) != 0)
|
||||
{
|
||||
scale_error_term += YDelta;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -449,7 +449,7 @@ void ogl_cache_level_textures(void)
|
|||
ogl_cache_polymodel_textures(Player_ship->model_num);
|
||||
ogl_cache_vclipn_textures(Player_ship->expl_vclip_num);
|
||||
|
||||
for (i=0;i<Highest_object_index;i++){
|
||||
for (i=0;i<=Highest_object_index;i++){
|
||||
if(Objects[i].render_type==RT_POWERUP){
|
||||
ogl_cache_vclipn_textures(Objects[i].rtype.vclip_info.vclip_num);
|
||||
switch (Objects[i].id){
|
||||
|
|
|
@ -21,7 +21,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef DO_MEMINFO
|
||||
#include <i86.h>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Routines for recording/playing/saving macros
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "inferno.h"
|
||||
#include "segment.h"
|
||||
#include "editor.h"
|
||||
#include "gr.h"
|
||||
#include "ui.h"
|
||||
#include "key.h"
|
||||
#include "fix.h"
|
||||
#include "3d.h"
|
||||
#include "mouse.h"
|
||||
#include "bm.h"
|
||||
#include "dxxerror.h"
|
||||
#include "medlisp.h"
|
||||
#include "kdefs.h"
|
||||
#include "u_mem.h"
|
||||
|
||||
#define MAX_NUM_EVENTS 10000
|
||||
|
||||
UI_EVENT * RecordBuffer;
|
||||
|
||||
int MacroNumEvents = 0;
|
||||
int MacroStatus = 0;
|
||||
|
||||
static char filename[PATH_MAX] = "*.MIN";
|
||||
|
||||
int MacroRecordAll()
|
||||
{
|
||||
if ( MacroStatus== UI_STATUS_NORMAL )
|
||||
{
|
||||
if (RecordBuffer) d_free( RecordBuffer );
|
||||
MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
|
||||
ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_MOUSE | UI_RECORD_KEYS );
|
||||
MacroStatus = UI_STATUS_RECORDING;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MacroRecordKeys()
|
||||
{
|
||||
if ( MacroStatus== UI_STATUS_NORMAL )
|
||||
{
|
||||
if (RecordBuffer) d_free( RecordBuffer );
|
||||
MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
|
||||
ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_KEYS );
|
||||
MacroStatus = UI_STATUS_RECORDING;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MacroPlayNormal()
|
||||
{
|
||||
if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
|
||||
{
|
||||
ui_set_playback_speed( 1 );
|
||||
ui_play_events_realtime(MacroNumEvents, RecordBuffer);
|
||||
MacroStatus = UI_STATUS_PLAYING;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MacroPlayFast()
|
||||
{
|
||||
if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
|
||||
{
|
||||
mouse_toggle_cursor(0);
|
||||
ui_play_events_fast(MacroNumEvents, RecordBuffer);
|
||||
MacroStatus = UI_STATUS_FASTPLAY;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MacroSave()
|
||||
{
|
||||
|
||||
if (MacroNumEvents < 1 )
|
||||
{
|
||||
ui_messagebox( -2, -2, 1, "No macro has been defined to save!", "Oops" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ui_get_filename( filename, "*.MAC", "SAVE MACRO" ))
|
||||
{
|
||||
PHYSFS_file *fp = PHYSFS_openWrite(filename);
|
||||
|
||||
if (!fp) return 0;
|
||||
RecordBuffer[0].type = 7;
|
||||
RecordBuffer[0].frame = 0;
|
||||
RecordBuffer[0].data = MacroNumEvents;
|
||||
PHYSFS_write(fp, RecordBuffer, sizeof(UI_EVENT), MacroNumEvents);
|
||||
PHYSFS_close(fp);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MacroLoad()
|
||||
{
|
||||
if (ui_get_filename( filename, "*.MAC", "LOAD MACRO" ))
|
||||
{
|
||||
PHYSFS_file *fp = PHYSFS_openRead(filename);
|
||||
int length;
|
||||
|
||||
if (!fp)
|
||||
return 0;
|
||||
if (RecordBuffer)
|
||||
d_free( RecordBuffer );
|
||||
length = PHYSFS_fileLength(fp);
|
||||
RecordBuffer = d_malloc(length);
|
||||
if (!RecordBuffer)
|
||||
return 0;
|
||||
|
||||
PHYSFS_read(fp, RecordBuffer, length, 1);
|
||||
PHYSFS_close(fp);
|
||||
MacroNumEvents = RecordBuffer[0].data;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void macro_free_buffer()
|
||||
{
|
||||
if ( RecordBuffer )
|
||||
d_free(RecordBuffer);
|
||||
}
|
||||
|
||||
int MacroMenu()
|
||||
{
|
||||
int x;
|
||||
char * MenuItems[] = { "Play fast",
|
||||
"Play normal",
|
||||
"Record all",
|
||||
"Record keys",
|
||||
"Save macro",
|
||||
"Load macro" };
|
||||
|
||||
x = MenuX( -1, -1, 6, MenuItems );
|
||||
|
||||
switch( x )
|
||||
{
|
||||
case 1:
|
||||
MacroPlayFast();
|
||||
break;
|
||||
case 2:
|
||||
MacroPlayNormal();
|
||||
break;
|
||||
case 3:
|
||||
MacroRecordAll();
|
||||
break;
|
||||
case 4:
|
||||
MacroRecordKeys();
|
||||
break;
|
||||
case 5: // Save
|
||||
MacroSave();
|
||||
break;
|
||||
case 6: // Load
|
||||
MacroLoad();
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
//checker.h added 05/17/99 Matt Mueller
|
||||
//FD_* on linux use asm, but checker doesn't like it. Borrowed these non-asm versions outta <selectbits.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef __CHECKER__
|
||||
|
||||
#undef FD_ZERO(set)
|
||||
#undef FD_SET(d, set)
|
||||
#undef FD_CLR(d, set)
|
||||
#undef FD_ISSET(d, set)
|
||||
|
||||
# define FD_ZERO(set) \
|
||||
do { \
|
||||
unsigned int __i; \
|
||||
for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \
|
||||
((__fd_mask *) set)[__i] = 0; \
|
||||
} while (0)
|
||||
# define FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
|
||||
# define FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
|
||||
# define FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
|
||||
|
||||
//checker doesn't seem to handle jmp's correctly...
|
||||
#undef setjmp(env)
|
||||
#define setjmp(env) __chcksetjmp(env)
|
||||
#undef longjmp(env,val)
|
||||
#define longjmp(env,val) __chcklongjmp(env,val)
|
||||
|
||||
int __chcklongjmp(jmp_buf buf,int val);
|
||||
int __chcksetjmp(jmp_buf buf);
|
||||
|
||||
void chcksetwritable(char * p, int size);
|
||||
void chcksetunwritable(char * p, int size);
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
/* XPM */
|
||||
static char *pixmap[] = {
|
||||
/* width height ncols cpp */
|
||||
"32 32 3 2",
|
||||
/* Colors */
|
||||
"00 c #000000",
|
||||
"01 c #FF0000",
|
||||
".. s None c None",
|
||||
"................................................................",
|
||||
"..............01................................01..............",
|
||||
"..............0101............................0101..............",
|
||||
"..............010101........................010101..............",
|
||||
"..............01010101....................01010101..............",
|
||||
"..............0101010101................0101010101..............",
|
||||
"..............010101010101............010101010101..............",
|
||||
"..............01010101010101........01010101010101..............",
|
||||
"..............0101000101010101......01010101010001..............",
|
||||
"..............010001010101010101......010101010100..............",
|
||||
"..............00010101010101010101......010101010100............",
|
||||
"..............0000010101010101010101......0101010000............",
|
||||
"............00000000010101010100000001......0100000000..........",
|
||||
"............0000..0000010101000000000001....0000..0000..........",
|
||||
"................0000000000000000000000000000000000..............",
|
||||
"................0000..0000000000000000000000..0000..............",
|
||||
"..................0100000000000000000000000000..................",
|
||||
"................0000000000000000000000000000000000..............",
|
||||
"..............00000101000000000000000000000001010000............",
|
||||
"............000000000101000000000000000000010100000000..........",
|
||||
"..........000001000001010101....010101010101010000010000........",
|
||||
"........0000010101010101010101....010101010101010101010000......",
|
||||
"....00000101010101010101010101......01010101010101010101010000..",
|
||||
"....0000..............................010101010101010101010000..",
|
||||
"........................................010101010101010101......",
|
||||
"..........................................0101010101010101......",
|
||||
"............................................01010101010101......",
|
||||
"..............................................010101010101......",
|
||||
"................................................0101010101......",
|
||||
"..................................................01010101......",
|
||||
"....................................................010101......",
|
||||
"................................................................",
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
/* XPM */
|
||||
static char *pixmap[] = {
|
||||
/* width height ncols cpp */
|
||||
"32 32 7 2",
|
||||
/* Colors */
|
||||
"00 c #000000",
|
||||
"01 c #800000",
|
||||
"02 c #C0C0C0",
|
||||
"03 c #808080",
|
||||
"04 c #FF0000",
|
||||
"05 c #FFFFFF",
|
||||
".. s None c None",
|
||||
"................................................................",
|
||||
"................................................................",
|
||||
"..........0303..........0301........0304..............03........",
|
||||
"..........030303........040301....03030304........030303........",
|
||||
"..........0303030303..0303030304010303030304..0303030303........",
|
||||
"..........0303030303030303020303000303020303030303030303........",
|
||||
"..........0303030303030303020303030303030303030303030303........",
|
||||
"..........0303030303030303020303030303020303030303030303........",
|
||||
"............0101000303030303030303030303030303010100............",
|
||||
"..............01010303030303030303030303030303010101............",
|
||||
"............0301010303030303030303030203030303010103............",
|
||||
"..........03010101030303030300000003000303030301010103..........",
|
||||
"........030101010101030300000000000000030303030301010103........",
|
||||
"........020101010303030300000000000000000303020303010403........",
|
||||
"......03010101040103030300000000000000000303..040401010103......",
|
||||
"......010101030402..030300000000000000030303..050503010103......",
|
||||
"....030101030304....030300030000000000030300..04040303010103....",
|
||||
"....03010303..00....000303030000000000030302..04040303030103....",
|
||||
"....030303..........0303030300000000030303..........03030303....",
|
||||
"....030303..........0303030300000000030303............030303....",
|
||||
"....0302............030303030303030303030303..........040103....",
|
||||
"......04............030303030303030303030303............0103....",
|
||||
"......04............030303030303030303030303............04......",
|
||||
"....0401............030303030303030303030303............04......",
|
||||
"....0000............0303030303030303030303..............04......",
|
||||
"....................0303030303030303030303..............00......",
|
||||
"......................030303030303030303........................",
|
||||
"......................030303030303030303........................",
|
||||
"......................0303030303030303..........................",
|
||||
"................................................................",
|
||||
"................................................................",
|
||||
"................................................................",
|
||||
};
|
|
@ -1,4 +0,0 @@
|
|||
#ifndef _I86_H
|
||||
#define _I86_H
|
||||
|
||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
#if !defined(PA_ENABL_H)
|
||||
#define PA_ENABL_H
|
||||
|
||||
//#define POLY_ACC // define this if poly support wanted.
|
||||
|
||||
#if defined(POLY_ACC)
|
||||
|
||||
// uncomment only ONE of the following.
|
||||
//#define PA_S3_VIRGE
|
||||
//#define PA_DIAMOND_S3_VIRGE
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PA_3DFX_VOODOO
|
||||
#define PA_DFX(x) x
|
||||
#define NO_DFX(x)
|
||||
#else
|
||||
#define PA_DFX(x)
|
||||
#define NO_DFX(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -33,8 +33,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
// then bmp->bm_data is allocated and the w,h are filled.
|
||||
// If palette==NULL the palette isn't read in. Returns error code.
|
||||
|
||||
extern int pcx_get_dimensions( char *filename, int *width, int *height);
|
||||
|
||||
extern int pcx_read_bitmap( char * filename, grs_bitmap * bmp, int bitmap_type, ubyte * palette );
|
||||
|
||||
// Writes the bitmap bmp to filename, using palette. Returns error code.
|
||||
|
|
|
@ -1283,6 +1283,10 @@ void do_endlevel_flythrough(int n)
|
|||
//update target point & angles
|
||||
|
||||
compute_center_point_on_side(&dest_point,pseg,exit_side);
|
||||
if (pseg->children[exit_side] == -2)
|
||||
nextcenter = dest_point;
|
||||
else
|
||||
compute_segment_center(&nextcenter,&Segments[pseg->children[exit_side]]);
|
||||
|
||||
//update target point and movement points
|
||||
|
||||
|
@ -1319,7 +1323,6 @@ void do_endlevel_flythrough(int n)
|
|||
vm_vec_scale(&flydata->step,flydata->speed);
|
||||
|
||||
compute_segment_center(&curcenter,pseg);
|
||||
compute_segment_center(&nextcenter,&Segments[pseg->children[exit_side]]);
|
||||
vm_vec_sub(&flydata->headvec,&nextcenter,&curcenter);
|
||||
|
||||
#ifdef COMPACT_SEGS
|
||||
|
|
|
@ -774,7 +774,7 @@ int load_mission(mle *mission)
|
|||
snprintf(Ending_text_filename, sizeof(Ending_text_filename), "%s.txb",Current_mission_filename);
|
||||
}
|
||||
|
||||
while (PHYSFSX_fgets(buf,80,mfile)) {
|
||||
while (PHYSFSX_fgets(buf,sizeof(buf),mfile)) {
|
||||
if (istok(buf,"name") && !Current_mission->enhanced) {
|
||||
Current_mission->enhanced = 0;
|
||||
continue; //already have name, go to next line
|
||||
|
@ -857,7 +857,7 @@ int load_mission(mle *mission)
|
|||
}
|
||||
|
||||
for (i=0;i<n_levels;i++) {
|
||||
PHYSFSX_fgets(buf,80,mfile);
|
||||
PHYSFSX_fgets(buf,sizeof(buf),mfile);
|
||||
add_term(buf);
|
||||
if (strlen(buf) <= 12) {
|
||||
strcpy(Level_names[i],buf);
|
||||
|
@ -895,7 +895,7 @@ int load_mission(mle *mission)
|
|||
for (i=0;i<N_secret_levels;i++) {
|
||||
char *t;
|
||||
|
||||
PHYSFSX_fgets(buf,80,mfile);
|
||||
PHYSFSX_fgets(buf,sizeof(buf),mfile);
|
||||
if ((t=strchr(buf,','))!=NULL) *t++=0;
|
||||
else
|
||||
break;
|
||||
|
|
|
@ -112,7 +112,7 @@ void songs_init()
|
|||
{
|
||||
while (!PHYSFS_eof(fp))
|
||||
{
|
||||
PHYSFSX_fgets(inputline, 80, fp );
|
||||
PHYSFSX_fgets(inputline, sizeof(inputline), fp );
|
||||
if ( strlen( inputline ) )
|
||||
{
|
||||
BIMSongs = d_realloc(BIMSongs, sizeof(bim_song_info)*(i+1));
|
||||
|
|
|
@ -1052,8 +1052,7 @@ int state_save_all_sub(char *filename, char *desc)
|
|||
// Save the automap visited info
|
||||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
for ( i = 0; i <= Highest_segment_index; i++ )
|
||||
PHYSFS_write(fp, Automap_visited, sizeof(ubyte), 1);
|
||||
PHYSFS_write(fp, Automap_visited, sizeof(ubyte), Highest_segment_index + 1);
|
||||
}
|
||||
else
|
||||
PHYSFS_write(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS_ORIGINAL);
|
||||
|
@ -1088,8 +1087,7 @@ int state_save_all_sub(char *filename, char *desc)
|
|||
PHYSFS_write(fp, &PaletteBlueAdd, sizeof(int), 1);
|
||||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
for ( i = 0; i <= Highest_segment_index; i++ )
|
||||
PHYSFS_write(fp, Light_subtracted, sizeof(Light_subtracted[0]), 1);
|
||||
PHYSFS_write(fp, Light_subtracted, sizeof(Light_subtracted[0]), Highest_segment_index + 1);
|
||||
}
|
||||
else
|
||||
PHYSFS_write(fp, Light_subtracted, sizeof(Light_subtracted[0]), MAX_SEGMENTS_ORIGINAL);
|
||||
|
@ -1507,8 +1505,7 @@ int state_restore_all_sub(char *filename, int secret_restore)
|
|||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
memset(&Automap_visited, 0, MAX_SEGMENTS);
|
||||
for ( i = 0; i <= Highest_segment_index; i++ )
|
||||
PHYSFS_read(fp, Automap_visited, sizeof(ubyte), 1);
|
||||
PHYSFS_read(fp, Automap_visited, sizeof(ubyte), Highest_segment_index + 1);
|
||||
}
|
||||
else
|
||||
PHYSFS_read(fp, Automap_visited, sizeof(ubyte), MAX_SEGMENTS_ORIGINAL);
|
||||
|
@ -1581,8 +1578,7 @@ int state_restore_all_sub(char *filename, int secret_restore)
|
|||
if ( Highest_segment_index+1 > MAX_SEGMENTS_ORIGINAL )
|
||||
{
|
||||
memset(&Light_subtracted, 0, sizeof(Light_subtracted[0])*MAX_SEGMENTS);
|
||||
for ( i = 0; i <= Highest_segment_index; i++ )
|
||||
PHYSFS_read(fp, Light_subtracted, sizeof(Light_subtracted[0]), 1);
|
||||
PHYSFS_read(fp, Light_subtracted, sizeof(Light_subtracted[0]), Highest_segment_index + 1);
|
||||
}
|
||||
else
|
||||
PHYSFS_read(fp, Light_subtracted, sizeof(Light_subtracted[0]), MAX_SEGMENTS_ORIGINAL);
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef _DISK_H
|
||||
#define _DISK_H
|
||||
|
||||
unsigned long getdiskfree();
|
||||
|
||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
#define DEBUG_ON 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dxxerror.h"
|
||||
|
||||
main(int argc,char **argv)
|
||||
{
|
||||
error_init("Thank-you for running ERRTEST!");
|
||||
|
||||
Assert(argc!=0);
|
||||
// Assert(argc==5);
|
||||
|
||||
Error("test of error, argc=%d, argv=%x",argc,argv);
|
||||
}
|
||||
|
||||
ÿ
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
#pragma off (unreferenced)
|
||||
static char rcsid[] = "$Id: parsarg.c,v 1.1.1.1 2006/03/17 19:58:50 zicodxx Exp $";
|
||||
#pragma on (unreferenced)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dos.h>
|
||||
|
||||
#include "parsarg.h"
|
||||
|
||||
#define ARGBUF_SIZE 500
|
||||
#define MAX_ARGS 100
|
||||
|
||||
char arg_buf[ARGBUF_SIZE];
|
||||
char *ab_ptr=arg_buf;
|
||||
|
||||
void perror_exit(int n,char *s)
|
||||
{
|
||||
perror(s);
|
||||
exit(n);
|
||||
}
|
||||
|
||||
void verror(char *s,void *first_arg_ptr)
|
||||
{
|
||||
fprintf(stderr,"Error: ");
|
||||
vfprintf(stderr,s,first_arg_ptr);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
void error_exit(int ret_code,char *s,...)
|
||||
{
|
||||
verror(s,((char *) &s)+sizeof(s)); /* addr of next parm on stack */
|
||||
exit(ret_code);
|
||||
}
|
||||
|
||||
void parse_args(int argc,char **argv,void (*handler_func)(char *arg),int flags)
|
||||
{
|
||||
|
||||
for (;argc--;argv++) {
|
||||
if (**argv=='@') { /* read args from file */
|
||||
char *arg_ptrs[MAX_ARGS];
|
||||
int arg_count;
|
||||
FILE *argfile;
|
||||
int len;
|
||||
char *p=ab_ptr,c;
|
||||
|
||||
if ((argfile=fopen(*argv+1,"rt"))==0) perror_exit(10,*argv+1);
|
||||
if ((len=fread(ab_ptr,1,ARGBUF_SIZE-((int) (ab_ptr-arg_buf)),argfile))==ARGBUF_SIZE-(ab_ptr-arg_buf)) error_exit(20,"Argument buffer not big enough\n");
|
||||
fclose(argfile);
|
||||
ab_ptr[len++]=0; /* write terminating null */
|
||||
|
||||
/* remove comments */
|
||||
|
||||
while ((p=strchr(ab_ptr,';'))!=NULL) {
|
||||
char *p2=strchr(p,'\n');
|
||||
|
||||
if (p2) { /* found cr */
|
||||
strcpy(p,p2); /* copy over comment */
|
||||
len = strlen(ab_ptr);
|
||||
}
|
||||
else { /* no cr, end of string */
|
||||
*p=0;
|
||||
len = (int) (p-ab_ptr);
|
||||
}
|
||||
}
|
||||
ab_ptr[len]=0; /* write terminating null */
|
||||
|
||||
while (!ab_ptr[len-1]) len--; /* back up over terminating nulls */
|
||||
p=ab_ptr;
|
||||
|
||||
|
||||
for (arg_count=0;p<ab_ptr+len;) {
|
||||
while (p<ab_ptr+len && ((c=*p)==' ' || c=='\t' || c=='\n')) p++;
|
||||
if (p<ab_ptr+len) { /* found parm? */
|
||||
arg_ptrs[arg_count++]=p;
|
||||
if (arg_count>=MAX_ARGS) error_exit(10,"Too many args");
|
||||
while (p<ab_ptr+len && !((c=*p)==' ' || c=='\t' || c=='\n')) p++;
|
||||
*p++=0;
|
||||
}
|
||||
}
|
||||
ab_ptr+=len;
|
||||
parse_args(arg_count,arg_ptrs,handler_func,flags);
|
||||
}
|
||||
else
|
||||
if (flags&PA_EXPAND && (**argv != '-')) {
|
||||
struct find_t ffblk;
|
||||
char drive[_MAX_DRIVE],dir[_MAX_DIR];
|
||||
char filename[_MAX_DRIVE+_MAX_DIR+13],*nptr;
|
||||
int done;
|
||||
|
||||
d_splitpath(*argv,drive,dir,NULL,NULL); //get path
|
||||
strcpy(filename,drive);
|
||||
strcat(filename,dir);
|
||||
nptr = filename + strlen(filename); //point at name part
|
||||
|
||||
done = _dos_findfirst(*argv,0,&ffblk);
|
||||
|
||||
if (done) handler_func(*argv);
|
||||
|
||||
else while (!done) {
|
||||
|
||||
strcpy(nptr,ffblk.name); //copy name after path
|
||||
|
||||
handler_func(filename);
|
||||
|
||||
done = _dos_findnext(&ffblk);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
handler_func(*argv);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Routine to parse the command line. Will also read and parse args
|
||||
* from a file.
|
||||
*
|
||||
* parse_args() is called with argc & argv from main(), the function
|
||||
* to be called with each argument, and flags. argc & argv are usually
|
||||
* adjusted to not pass the first parameter (the program file name).
|
||||
* Thus the general method of calling is:
|
||||
*
|
||||
* parse_args(argc-1,argv+1,hander_func,flags);
|
||||
*
|
||||
* handler_func() is then called with each parameter.
|
||||
*
|
||||
* If the PA_EXPAND flag is passed, all arguments which do not start
|
||||
* with '-' are assumed to be filenames and are expanded for wildcards,
|
||||
* with the handler function called for each match. If a spec matches
|
||||
* nothing, the spec itself is passed to the handler func.
|
||||
*
|
||||
* Args that start with '@' are assumed to be argument files. These
|
||||
* files are opened, and arguments are read from them just as if they
|
||||
* were specified on the command line. Arg files can be nested.
|
||||
*
|
||||
*/
|
||||
|
||||
//Flags
|
||||
|
||||
#define PA_EXPAND 1 //wildcard expand args that don't start with '-'
|
||||
|
||||
|
||||
//Function
|
||||
|
||||
void parse_args(int argc,char **argv,void (*handler_func)(char *arg),int flags);
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "parsarg.h"
|
||||
|
||||
|
||||
handle_arg(char *a)
|
||||
{
|
||||
printf("%s\n",a);
|
||||
}
|
||||
|
||||
|
||||
main(int argc,char **argv)
|
||||
{
|
||||
|
||||
parse_args(argc-1,argv+1,handle_arg,PA_EXPAND);
|
||||
}
|
||||
|
||||
ÿ
|
|
@ -1,93 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <png.h>
|
||||
|
||||
#include "pngfile.h"
|
||||
#include "u_mem.h"
|
||||
#include "pstypes.h"
|
||||
|
||||
int read_png(char *filename, png_data *pdata)
|
||||
{
|
||||
ubyte header[8];
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytepp row_pointers = NULL;
|
||||
png_uint_32 width, height;
|
||||
int depth, color_type;
|
||||
int i;
|
||||
FILE *fp = NULL;
|
||||
|
||||
if (!filename || !pdata)
|
||||
return 0;
|
||||
|
||||
if ((fp = fopen(filename, "rb")) == NULL)
|
||||
return 0;
|
||||
|
||||
fread(header, 1, 8, fp);
|
||||
if (!png_check_sig(header, 8))
|
||||
return 0;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
pdata->data = pdata->palette = NULL;
|
||||
pdata->num_palette = 0;
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||
if (pdata->data)
|
||||
free(pdata->data);
|
||||
if (pdata->palette)
|
||||
free(pdata->palette);
|
||||
if (row_pointers)
|
||||
free(row_pointers);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
png_get_IHDR(png_ptr, info_ptr, &width, &height, &depth, &color_type, NULL, NULL, NULL);
|
||||
|
||||
pdata->width = width;
|
||||
pdata->height = height;
|
||||
pdata->depth = depth;
|
||||
|
||||
pdata->data = (ubyte*)malloc(png_get_rowbytes(png_ptr, info_ptr) * height);
|
||||
row_pointers = (png_bytep *)malloc(sizeof(png_bytep) * height);
|
||||
for (i = 0; i < height; i++)
|
||||
row_pointers[i] = &pdata->data[png_get_rowbytes(png_ptr, info_ptr) * i];
|
||||
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
free(row_pointers);
|
||||
row_pointers=NULL;
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
png_colorp palette;
|
||||
|
||||
if (png_get_PLTE(png_ptr, info_ptr, &palette, &pdata->num_palette))
|
||||
{
|
||||
pdata->palette = (ubyte*)malloc(pdata->num_palette * 3);
|
||||
memcpy(pdata->palette, palette, pdata->num_palette * 3);
|
||||
}
|
||||
}
|
||||
|
||||
pdata->paletted = (color_type & PNG_COLOR_MASK_PALETTE) > 0;
|
||||
pdata->color = (color_type & PNG_COLOR_MASK_COLOR) > 0;
|
||||
pdata->alpha = (color_type & PNG_COLOR_MASK_ALPHA) > 0;
|
||||
if (pdata->color && pdata->alpha)
|
||||
pdata->channels = 4;
|
||||
else if (pdata->color && !pdata->alpha)
|
||||
pdata->channels = 3;
|
||||
else if (!pdata->color && pdata->alpha)
|
||||
pdata->channels = 2;
|
||||
else //if (!pdata->color && !pdata->alpha)
|
||||
pdata->channels = 1;
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "fix.h"
|
||||
#include "pstypes.h"
|
||||
#include "gr.h"
|
||||
#include "ui.h"
|
||||
#include "key.h"
|
||||
|
||||
|
||||
static UI_WINDOW * wnd = NULL;
|
||||
static int bar_width, bar_height, bar_x, bar_y, bar_maxlength;
|
||||
|
||||
void ui_barbox_open( char * text, int length )
|
||||
{
|
||||
grs_font * temp_font;
|
||||
int text_width, text_height, avg;
|
||||
int w,h, width, height, xc, yc, x, y;
|
||||
|
||||
w = grd_curscreen->sc_w;
|
||||
h = grd_curscreen->sc_h;
|
||||
|
||||
width = w/3;
|
||||
|
||||
bar_maxlength = length;
|
||||
|
||||
if ( w < 640 ) {
|
||||
temp_font = grd_curscreen->sc_canvas.cv_font;
|
||||
grd_curscreen->sc_canvas.cv_font = ui_small_font;
|
||||
}
|
||||
|
||||
gr_get_string_size(text, &text_width, &text_height, &avg );
|
||||
|
||||
text_width += avg*6;
|
||||
text_width += 10;
|
||||
|
||||
if (text_width > width )
|
||||
width = text_width;
|
||||
|
||||
height = text_height;
|
||||
height += 30;
|
||||
|
||||
xc = w/2;
|
||||
yc = h/2;
|
||||
|
||||
x = xc - width/2;
|
||||
y = yc - height/2;
|
||||
|
||||
if (x < 0 ) x = 0;
|
||||
if ( (x+width-1) >= w ) x = w - width;
|
||||
if (y < 0 ) y = 0;
|
||||
if ( (y+height-1) >= h ) y = h - height;
|
||||
|
||||
wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
|
||||
|
||||
y = 5 + text_height/2 ;
|
||||
|
||||
ui_string_centered( width/2, y, text );
|
||||
|
||||
y = 10 + text_height;
|
||||
|
||||
bar_width = width - 15;
|
||||
bar_height = 10;
|
||||
bar_x = (width/2) - (bar_width/2);
|
||||
bar_y = height - 15;
|
||||
|
||||
ui_draw_line_in( bar_x-2, bar_y-2, bar_x+bar_width+1, bar_y+bar_height+1 );
|
||||
|
||||
grd_curscreen->sc_canvas.cv_font = temp_font;
|
||||
|
||||
}
|
||||
|
||||
void ui_barbox_update( int position )
|
||||
{
|
||||
int spos;
|
||||
|
||||
spos = (position * bar_width)/bar_maxlength;
|
||||
|
||||
gr_set_current_canvas( wnd->canvas );
|
||||
|
||||
ui_mouse_hide();
|
||||
gr_setcolor( BM_XRGB(0,0,10));
|
||||
gr_rect( bar_x, bar_y, bar_x+spos-1, bar_y+bar_height-1 );
|
||||
ui_mouse_show();
|
||||
ui_mouse_process();
|
||||
|
||||
}
|
||||
|
||||
void ui_barbox_close()
|
||||
{
|
||||
if (wnd)
|
||||
ui_close_window(wnd);
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
||||
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
||||
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
||||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "fix.h"
|
||||
#include "pstypes.h"
|
||||
#include "gr.h"
|
||||
#include "ui.h"
|
||||
|
||||
#define TEXT_EXTRA_HEIGHT 5
|
||||
|
||||
double ui_input_number( short xc, short yc, char * text, double OrgNumber )
|
||||
{
|
||||
UI_WINDOW * wnd;
|
||||
UI_GADGET_INPUTBOX * InputBox;
|
||||
|
||||
int text_width, text_height, avg;
|
||||
short box_width, box_height, width, height, x, y;
|
||||
short w, h;
|
||||
char string[100];
|
||||
|
||||
sprintf( string, "%f", OrgNumber );
|
||||
|
||||
box_width = box_height = 0;
|
||||
|
||||
gr_set_current_canvas( &grd_curscreen->sc_canvas );
|
||||
|
||||
box_width = 8*20;
|
||||
box_height = 20;
|
||||
|
||||
gr_get_string_size(text, &text_width, &text_height, &avg );
|
||||
|
||||
width = box_width + 50;
|
||||
|
||||
text_width += avg*6;
|
||||
text_width += 10;
|
||||
|
||||
if (text_width > width )
|
||||
width = text_width;
|
||||
|
||||
height = text_height;
|
||||
height += box_height;
|
||||
height += 4*5;
|
||||
|
||||
// Center X and Y
|
||||
w = grd_curscreen->sc_w;
|
||||
h = grd_curscreen->sc_h;
|
||||
|
||||
if ( xc == -1 ) xc = Mouse.x;
|
||||
if ( yc == -1 ) yc = Mouse.y - box_height/2;
|
||||
if ( xc == -2 ) xc = w/2;
|
||||
if ( yc == -2 ) yc = h/2;
|
||||
|
||||
x = xc - width/2;
|
||||
y = yc - height/2;
|
||||
|
||||
// Make sure that we're onscreen
|
||||
if (x < 0 ) x = 0;
|
||||
if ( (x+width-1) >= w ) x = w - width;
|
||||
if (y < 0 ) y = 0;
|
||||
if ( (y+height-1) >= h ) y = h - height;
|
||||
|
||||
|
||||
wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
|
||||
|
||||
y = TEXT_EXTRA_HEIGHT + text_height/2 - 1;
|
||||
|
||||
ui_string_centered( width/2, y, text );
|
||||
|
||||
y = 2*TEXT_EXTRA_HEIGHT + text_height;
|
||||
|
||||
y = height - TEXT_EXTRA_HEIGHT - box_height-10;
|
||||
|
||||
InputBox = ui_add_gadget_inputbox( wnd, 10, y, 20, 20, string );
|
||||
|
||||
ui_gadget_calc_keys(wnd);
|
||||
|
||||
//key_flush();
|
||||
|
||||
wnd->keyboard_focus_gadget = (UI_GADGET *)InputBox;
|
||||
|
||||
while(1)
|
||||
{
|
||||
ui_mega_process();
|
||||
ui_window_do_gadgets(wnd);
|
||||
|
||||
if (InputBox->pressed) break;
|
||||
}
|
||||
|
||||
ui_close_window(wnd);
|
||||
|
||||
OrgNumber = atof(InputBox->text);
|
||||
|
||||
return OrgNumber;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue