Skip to content

Commit

Permalink
Implemented PhysFS support; Implemended D2X memory functions; Code cl…
Browse files Browse the repository at this point in the history
…eanups
  • Loading branch information
zicodxx committed Jan 23, 2008
1 parent da7fd57 commit d9e2337
Show file tree
Hide file tree
Showing 91 changed files with 3,538 additions and 4,754 deletions.
97 changes: 7 additions & 90 deletions 2d/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,9 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
* $Source: /cvsroot/dxx-rebirth/d1x-rebirth/2d/bitmap.c,v $
* $Revision: 1.1.1.1 $
* $Author: zicodxx $
* $Date: 2006/03/17 19:38:51 $
*
* Graphical routines for manipulating grs_bitmaps.
*
* $Log: bitmap.c,v $
* Revision 1.1.1.1 2006/03/17 19:38:51 zicodxx
* initial import
*
* Revision 1.7 1999/10/08 08:50:54 donut
* fixed ogl sub bitmap support
*
* Revision 1.6 1999/10/07 20:48:17 donut
* ogl fix for sub bitmaps and segv
*
* Revision 1.5 1999/10/07 02:27:14 donut
* OGL includes to remove warnings
*
* Revision 1.4 1999/09/22 02:02:31 donut
* ogl: gr_set_bitmap_data frees the texture rather than just resetting the gltexture flag
*
* Revision 1.3 1999/09/21 04:05:54 donut
* mostly complete OGL implementation (still needs bitmap handling (reticle), and door/fan textures are corrupt)
*
* Revision 1.2 1999/08/05 22:53:40 sekmu
*
* D3D patch(es) from ADB
*
* Revision 1.1.1.1 1999/06/14 21:57:15 donut
* Import of d1x 1.37 source.
*
* Revision 1.17 1994/11/18 22:50:25 john
* Changed shorts to ints in parameters.
*
* Revision 1.16 1994/11/10 15:59:46 john
* Fixed bugs with canvas's being created with bogus bm_flags.
*
* Revision 1.15 1994/10/26 23:55:53 john
* Took out roller; Took out inverse table.
*
* Revision 1.14 1994/09/19 14:40:21 john
* Changed dpmi stuff.
*
* Revision 1.13 1994/09/19 11:44:04 john
* Changed call to allocate selector to the dpmi module.
*
* Revision 1.12 1994/06/09 13:14:57 john
* Made selectors zero our
* out, I meant.
*
* Revision 1.11 1994/05/06 12:50:07 john
* Added supertransparency; neatend things up; took out warnings.
*
* Revision 1.10 1994/04/08 16:59:39 john
* Add fading poly's; Made palette fade 32 instead of 16.
*
* Revision 1.9 1994/03/16 17:21:09 john
* Added slow palette searching options.
*
* Revision 1.8 1994/03/14 17:59:35 john
* Added function to check bitmap's transparency.
*
* Revision 1.7 1994/03/14 17:16:21 john
* fixed bug with counting freq of pixels.
*
* Revision 1.6 1994/03/14 16:55:47 john
* Changed grs_bitmap structure to include bm_flags.
*
* Revision 1.5 1994/02/18 15:32:22 john
* *** empty log message ***
*
* Revision 1.4 1993/10/15 16:22:49 john
* *** empty log message ***
*
* Revision 1.3 1993/09/08 17:37:11 john
* Checking for errors with Yuan...
*
* Revision 1.2 1993/09/08 14:46:27 john
* looking for possible bugs...
*
* Revision 1.1 1993/09/08 11:43:05 john
* Initial revision
*
*
*/

#include <stdlib.h>
Expand Down Expand Up @@ -172,7 +89,7 @@ void gr_init_bitmap( grs_bitmap *bm, int mode, int x, int y, int w, int h, int b
void gr_init_bitmap_alloc( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline)
{
gr_init_bitmap(bm, mode, x, y, w, h, bytesperline, 0);
gr_set_bitmap_data(bm, malloc(MAX_BMP_SIZE(w, h)));
gr_set_bitmap_data(bm, d_malloc(MAX_BMP_SIZE(w, h)));
}

void gr_init_bitmap_data (grs_bitmap *bm) // TODO: virtulize
Expand All @@ -193,7 +110,7 @@ void gr_free_bitmap(grs_bitmap *bm )
{
gr_free_bitmap_data (bm);
if (bm!=NULL)
free(bm);
d_free(bm);
}

void gr_free_bitmap_data (grs_bitmap *bm) // TODO: virtulize
Expand All @@ -210,7 +127,7 @@ void gr_free_bitmap_data (grs_bitmap *bm) // TODO: virtulize
ogl_freebmtexture(bm);
#endif
if (bm->bm_data != NULL)
free (bm->bm_data);
d_free (bm->bm_data);
bm->bm_data = NULL;
}

Expand Down Expand Up @@ -251,21 +168,21 @@ void gr_free_sub_bitmap(grs_bitmap *bm )
#ifdef D1XD3D
bm->iMagic = 0;
#endif
free(bm);
d_free(bm);
}
}


grs_bitmap *gr_create_bitmap(int w, int h )
{
return gr_create_bitmap_raw (w, h, malloc(MAX_BMP_SIZE(w, h)));
return gr_create_bitmap_raw (w, h, d_malloc(MAX_BMP_SIZE(w, h)));
}

grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data )
{
grs_bitmap *new;

new = (grs_bitmap *)malloc( sizeof(grs_bitmap) );
new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) );
gr_init_bitmap (new, 0, 0, 0, w, h, w, raw_data);

return new;
Expand All @@ -276,7 +193,7 @@ grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm, int x, int y, int w, int h )
{
grs_bitmap *new;

new = (grs_bitmap *)malloc( sizeof(grs_bitmap) );
new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) );
gr_init_sub_bitmap (new, bm, x, y, w, h);

return new;
Expand Down
8 changes: 4 additions & 4 deletions 2d/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ grs_canvas *gr_create_canvas(int w, int h)
{
grs_canvas *new;

new = (grs_canvas *)malloc( sizeof(grs_canvas) );
new = (grs_canvas *)d_malloc( sizeof(grs_canvas) );
gr_init_bitmap_alloc (&new->cv_bitmap, BM_LINEAR, 0, 0, w, h, w);

new->cv_color = 0;
Expand All @@ -45,7 +45,7 @@ grs_canvas *gr_create_sub_canvas(grs_canvas *canv, int x, int y, int w, int h)
{
grs_canvas *new;

new = (grs_canvas *)malloc( sizeof(grs_canvas) );
new = (grs_canvas *)d_malloc( sizeof(grs_canvas) );
gr_init_sub_bitmap (&new->cv_bitmap, &canv->cv_bitmap, x, y, w, h);

new->cv_color = canv->cv_color;
Expand Down Expand Up @@ -88,12 +88,12 @@ void gr_init_sub_canvas(grs_canvas *new, grs_canvas *src, int x, int y, int w, i
void gr_free_canvas(grs_canvas *canv)
{
gr_free_bitmap_data(&canv->cv_bitmap);
free(canv);
d_free(canv);
}

void gr_free_sub_canvas(grs_canvas *canv)
{
free(canv);
d_free(canv);
}

void gr_set_current_canvas( grs_canvas *canv )
Expand Down
20 changes: 10 additions & 10 deletions 2d/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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.
*/
/* $Source: /cvsroot/dxx-rebirth/d1x-rebirth/2d/font.c,v $
/*
*
* Graphical routines for drawing fonts.
*
Expand Down Expand Up @@ -896,7 +896,7 @@ void ogl_init_font(grs_font * font){
int gap=0;//having a gap just wastes ram, since we don't filter text textures at all.
// char s[2];
ogl_font_choose_size(font,gap,&tw,&th);
data=malloc(tw*th);
data=d_malloc(tw*th);
memset(data, 0, tw * th);
gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data);
gr_set_transparent(&font->ft_parent_bitmap, 1);
Expand All @@ -905,7 +905,7 @@ void ogl_init_font(grs_font * font){
oglflags |= OGL_FLAG_NOCOLOR;
ogl_init_texture(font->ft_parent_bitmap.gltexture = ogl_get_free_texture(), tw, th, oglflags); // have to init the gltexture here so the subbitmaps will find it.

font->ft_bitmaps=(grs_bitmap*)malloc( nchars * sizeof(grs_bitmap));
font->ft_bitmaps=(grs_bitmap*)d_malloc( nchars * sizeof(grs_bitmap));
mprintf((0,"ogl_init_font %s, %s, nchars=%i, (%ix%i tex)\n",(font->ft_flags & FT_PROPORTIONAL)?"proportional":"fixedwidth",(font->ft_flags & FT_COLOR)?"color":"mono",nchars,tw,th));
// s[1]=0;
h=font->ft_h;
Expand Down Expand Up @@ -1208,15 +1208,15 @@ void gr_close_font( grs_font * font )
if (font)
{
if ( font->ft_chars )
free( font->ft_chars );
free( font->oldfont );
d_free( font->ft_chars );
d_free( font->oldfont );
#ifdef OGL
if (font->ft_bitmaps)
free( font->ft_bitmaps );
d_free( font->ft_bitmaps );
gr_free_bitmap_data(&font->ft_parent_bitmap);
// ogl_freebmtexture(&font->ft_parent_bitmap);
#endif
free( font );
d_free( font );
}
}

Expand Down Expand Up @@ -1260,8 +1260,8 @@ grs_font * gr_init_font( char * fontname )

datasize = cfile_read_int(fontfile);

font = (old_grs_font *) malloc(datasize);
newfont = (grs_font *) malloc(sizeof(grs_font));
font = (old_grs_font *) d_malloc(datasize);
newfont = (grs_font *) d_malloc(sizeof(grs_font));
newfont->oldfont=font;

cfread(font,1,datasize,fontfile);
Expand All @@ -1285,7 +1285,7 @@ grs_font * gr_init_font( char * fontname )

newfont->ft_data = (INTEL_INT(font->ft_data)) + ((ubyte *) font);

newfont->ft_chars = (unsigned char **)malloc( nchars * sizeof(unsigned char *));
newfont->ft_chars = (unsigned char **)d_malloc( nchars * sizeof(unsigned char *));

ptr = newfont->ft_data;

Expand Down

0 comments on commit d9e2337

Please sign in to comment.