Ejemplo n.º 1
0
PSZ Settings :: GetFileEAType( SHORT type = BMF_INVALID )
{
    if( type == BMF_INVALID )
        type = SHORT( QueryFileFormat() );
    if( ( type >= BMF_12 ) && ( type < BMF_INVALID ) )
        return ifi[ type ].eaType;
    return "";
}
Ejemplo n.º 2
0
// Draws "Entering <LevelName>"
void WI_drawEL(void)
{
	int y = WI_TITLEY;

	// draw "Entering"
	V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2,
				y,
				entering);

	// draw level
	y += (5*SHORT(lnames[wbs->next]->height))/4;

	V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2,
				y, 
				lnames[wbs->next]);

}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void __fastcall TFileViewDlg::TabSChange(TObject *Sender)
{
	if( m_DisEvent ) return;

	m_DisEvent++;
	m_CurFile = -1;
	m_CurPage = pTabS->TabIndex;
	pCurPage = pFileV[m_CurPage];
	UD->Max = SHORT(pCurPage->m_MaxPage-1);
	UD->Position = SHORT(pCurPage->m_CurPage);
	if( (pCurPage->pList == NULL) || (pCurPage->pBitmapS == NULL) ){
		LoadImage();
	}
	UpdateBitmap();
	UpdateStat();
	m_DisEvent--;
}
Ejemplo n.º 4
0
FOURCC Settings :: GetFOURCC( SHORT type = BMF_INVALID )
{
    if( type == BMF_INVALID )
        type = SHORT( QueryFileFormat() );
    if( ( type >= BMF_12 ) && ( type < BMF_INVALID ) )
        return ifi[ type ].fourcc;
    return 0L;
}
Ejemplo n.º 5
0
uint16_t
vncrdshort(Vnc *v)
{
	uint8_t buf[2];

	vncrdbytes(v, buf, 2);
	return SHORT(buf);
}
Ejemplo n.º 6
0
ushort
vncrdshort(Vnc *v)
{
	uchar buf[2];

	vncrdbytes(v, buf, 2);
	return SHORT(buf);
}
Ejemplo n.º 7
0
void
WI_drawOnLnode
( int           n,
  patch_t*      c[] )
{

	int         i;
	int         left;
	int         top;
	int         right;
	int         bottom;
	boolean     fits = false;

	i = 0;
	do
	{
		left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset);
		top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset);
		right = left + SHORT(c[i]->width);
		bottom = top + SHORT(c[i]->height);

		if (left >= 0
			&& right < SCREENWIDTH
			&& top >= 0
			&& bottom < SCREENHEIGHT)
		{
			fits = true;
		}
		else
		{
			i++;
		}
	} while (!fits && i!=2 && c[i] != NULL);

	if (fits && i<2)
	{
		V_DrawPatch(lnodes[wbs->epsd][n].x,
					lnodes[wbs->epsd][n].y,
					c[i]);
	}
	else
	{
		// DEBUG
		printf("Could not place patch on level %d", n+1); 
	}
}
Ejemplo n.º 8
0
//
// R_GenerateComposite
// Using the texture definition,
//  the composite texture is created from the patches,
//  and each column is cached.
//
void R_GenerateComposite (int texnum)
{
    byte*			block;
    texture_t*		texture;
    texpatch_t*		patch;	
    patch_t*		realpatch;
    int				x;
    int				x1;
    int				x2;
    int				i;
    postColumn_t*	patchcol;
    short*			collump;
    unsigned short*	colofs;
	
    texture = ::g->s_textures[texnum];

    block = (byte*)DoomLib::Z_Malloc (::g->s_texturecompositesize[texnum],
		      PU_CACHE_SHARED, 
		      &::g->s_texturecomposite[texnum]);	

    collump = ::g->s_texturecolumnlump[texnum];
    colofs = ::g->s_texturecolumnofs[texnum];
    
    // Composite the columns together.
    patch = texture->patches;
		
    for (i=0 , patch = texture->patches;
	 i<texture->patchcount;
	 i++, patch++)
    {
	realpatch = (patch_t*)W_CacheLumpNum (patch->patch, PU_CACHE_SHARED);
	x1 = patch->originx;
	x2 = x1 + SHORT(realpatch->width);

	if (x1<0)
	    x = 0;
	else
	    x = x1;
	
	if (x2 > texture->width)
	    x2 = texture->width;

	for ( ; x<x2 ; x++)
	{
	    // Column does not have multiple patches?
	    if (collump[x] >= 0)
		continue;
	    
	    patchcol = (postColumn_t *)((byte *)realpatch
				    + LONG(realpatch->columnofs[x-x1]));
	    R_DrawColumnInCache (patchcol,
				 block + colofs[x],
				 patch->originy,
				 texture->height);
	}
						
    }
}
Ejemplo n.º 9
0
void WI_drawNetgameStats(void)
{
    int		i;
    int		x;
    int		y;
    int		pwidth = SHORT(::g->percent->width);

    WI_slamBackground();
    
    // draw animated background
    WI_drawAnimatedBack(); 

    WI_drawLF();

    // draw stat titles (top line)
    V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(::g->kills->width),
		NG_STATSY, FB, ::g->kills);

    V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(::g->items->width),
		NG_STATSY, FB, ::g->items);

    V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(::g->secret->width),
		NG_STATSY, FB, ::g->secret);
    
    if (::g->dofrags)
	V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(::g->wistuff_frags->width),
		    NG_STATSY, FB, ::g->wistuff_frags);

    // draw stats
    y = NG_STATSY + SHORT(::g->kills->height);

    for (i=0 ; i<MAXPLAYERS ; i++)
    {
	if (!::g->playeringame[i])
	    continue;

	x = NG_STATSX;
	V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width), y, FB, ::g->wistuff_p[i]);

	// No splitscreen on PC
	if (i == ::g->me /* && !gameLocal->IsSplitscreen() */ )
	    V_DrawPatch(x-SHORT(::g->wistuff_p[i]->width), y, FB, ::g->star);

	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, ::g->cnt_kills[i]);	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, ::g->cnt_items[i]);	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, ::g->cnt_secret[i]);	x += NG_SPACINGX;

	if (::g->dofrags)
	    WI_drawNum(x, y+10, ::g->cnt_frags[i], -1);

	y += WI_SPACINGY;
    }

}
Ejemplo n.º 10
0
/*
==================
=
= V_DrawShadowedPatch
=
= Masks a column based masked pic to the screen.
=
==================
*/

void V_DrawShadowedPatch(int x, int y, patch_t *patch)
{
	int			count,col;
	column_t	*column;
	byte		*desttop, *dest, *source;
	byte		*desttop2, *dest2;
	int			w;
	
	y -= SHORT(patch->topoffset);
	x -= SHORT(patch->leftoffset);

	if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 || y+SHORT(patch->height)>SCREENHEIGHT
)
		I_Error ("Bad V_DrawPatch");

	col = 0;
	desttop = screen+y*SCREENWIDTH+x;
	desttop2 = screen+(y+2)*SCREENWIDTH+x+2;
	
	w = SHORT(patch->width);
	for ( ; col<w ; x++, col++, desttop++, desttop2++)
	{
		column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));

// step through the posts in a column
	
		while (column->topdelta != 0xff )
		{
			source = (byte *)column + 3;
			dest = desttop + column->topdelta*SCREENWIDTH;
			dest2 = desttop2 + column->topdelta*SCREENWIDTH;
			count = column->length;
			
			while (count--)
			{
				*dest2 = tinttable[((*dest2)<<8)];
				dest2 += SCREENWIDTH;
				*dest = *source++;
				dest += SCREENWIDTH;

			}
			column = (column_t *)(  (byte *)column + column->length
+ 4 );
		}
Ejemplo n.º 11
0
//
// P_InitSwitchList()
//
// Only called at game initialization in order to list the set of switches
// and buttons known to the engine. This enables their texture to change
// when activated, and in the case of buttons, change back after a timeout.
//
// This routine modified to read its data from a predefined lump or
// PWAD lump called SWITCHES rather than a static table in this module to
// allow wad designers to insert or modify switches.
//
// Lump format is an array of byte packed switchlist_t structures, terminated
// by a structure with episode == -0. The lump can be generated from a
// text source file using SWANTBLS.EXE, distributed with the BOOM utils.
// The standard list of switches and animations is contained in the example
// source text file DEFSWANI.DAT also in the BOOM util distribution.
//
// Rewritten by Lee Killough to remove limit 2/8/98
//
void P_InitSwitchList(void)
{
  int i, index = 0;
  int episode = (gamemode == registered || gamemode==retail) ?
                 2 : gamemode == commercial ? 3 : 1;
  const switchlist_t *alphSwitchList;         //jff 3/23/98 pointer to switch table
  int lump = W_GetNumForName("SWITCHES"); // cph - new wad lump handling

  //jff 3/23/98 read the switch table from a predefined lump
  alphSwitchList = (const switchlist_t *)W_CacheLumpNum(lump);

  for (i=0;;i++)
  {
    if (index+1 >= max_numswitches)
      switchlist = realloc(switchlist, sizeof *switchlist *
          (max_numswitches = max_numswitches ? max_numswitches*2 : 8));
    if (SHORT(alphSwitchList[i].episode) <= episode) //jff 5/11/98 endianess
    {
      int texture1, texture2;

      if (!SHORT(alphSwitchList[i].episode))
        break;

      // Ignore switches referencing unknown texture names, instead of exiting.
      // Warn if either one is missing, but only add if both are valid.
      texture1 = R_CheckTextureNumForName(alphSwitchList[i].name1);
      if (texture1 == -1)
        lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
            alphSwitchList[i].name1);
      texture2 = R_CheckTextureNumForName(alphSwitchList[i].name2);
      if (texture2 == -1)
        lprintf(LO_WARN, "P_InitSwitchList: unknown texture %s\n",
            alphSwitchList[i].name2);
      if (texture1 != -1 && texture2 != -1) {
        switchlist[index++] = texture1;
        switchlist[index++] = texture2;
      }
    }
  }

  numswitches = index/2;
  switchlist[index] = -1;
  W_UnlockLumpNum(lump);
}
Ejemplo n.º 12
0
void WI_drawNetgameStats(void)
{
    int		i;
    int		x;
    int		y;
    int		pwidth = SHORT(percent->width);

    WI_slamBackground();
    
    // draw animated background
    WI_drawAnimatedBack(); 

    WI_drawLF();

    // draw stat titles (top line)
    V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width),
		NG_STATSY, FB, kills);

    V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width),
		NG_STATSY, FB, items);

    V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width),
		NG_STATSY, FB, secret);
    
    if (dofrags)
	V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width),
		    NG_STATSY, FB, frags);

    // draw stats
    y = NG_STATSY + SHORT(kills->height);

    for (i=0 ; i<MAXPLAYERS ; i++)
    {
	if (!playeringame[i])
	    continue;

	x = NG_STATSX;
	V_DrawPatch(x-SHORT(p[i]->width), y, FB, p[i]);

	if (i == me)
	    V_DrawPatch(x-SHORT(p[i]->width), y, FB, star);

	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, cnt_kills[i]);	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, cnt_items[i]);	x += NG_SPACINGX;
	WI_drawPercent(x-pwidth, y+10, cnt_secret[i]);	x += NG_SPACINGX;

	if (dofrags)
	    WI_drawNum(x, y+10, cnt_frags[i], -1);

	y += WI_SPACINGY;
    }

}
Ejemplo n.º 13
0
static void F_CastPrint(char *text)
{
    const char  *ch = text;
    int         c;
    int         cx;
    int         w;
    int         width = 0;

    while (ch)
    {
        c = *ch++;
        if (!c)
            break;
        c = toupper(c) - HU_FONTSTART;
        if (c < 0 || c > HU_FONTSIZE)
        {
            width += 4;
            continue;
        }

        w = SHORT(hu_font[c]->width);
        width += w;
    }

    // draw it
    cx = (ORIGINALWIDTH - width) / 2;
    ch = text;
    while (ch)
    {
        c = *ch++;
        if (!c)
            break;
        c = toupper(c) - HU_FONTSTART;
        if (c < 0 || c > HU_FONTSIZE)
        {
            cx += 4;
            continue;
        }

        w = SHORT(hu_font[c]->width);
        V_DrawPatchWithShadow(cx + 1, 181, hu_font[c], false);
        cx += w;
    }
}
Ejemplo n.º 14
0
// Checks if the lump can be a Doom patch
static dboolean CheckIfPatch(int lump)
{
    int                 size;
    int                 width, height;
    const patch_t       *patch;
    dboolean            result;

    size = W_LumpLength(lump);

    // minimum length of a valid Doom patch
    if (size < 13)
        return false;

    patch = (const patch_t *)W_CacheLumpNum(lump, PU_STATIC);

    width = SHORT(patch->width);
    height = SHORT(patch->height);

    result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < size / 4);

    if (result)
    {
        // The dimensions seem like they might be valid for a patch, so
        // check the column directory for extra security. All columns 
        // must begin after the column directory, and none of them must
        // point past the end of the patch.
        int     x;

        for (x = 0; x < width; ++x)
        {
            unsigned int        ofs = LONG(patch->columnofs[x]);

            // Need one byte for an empty column (but there's patches that don't know that!)
            if (ofs < (unsigned int)width * 4 + 8 || ofs >= (unsigned int)size)
            {
                result = false;
                break;
            }
        }
    }

    W_ReleaseLumpNum(lump);
    return result;
}
Ejemplo n.º 15
0
//
// V_DrawPatchFlipped 
// Masks a column based masked pic to the screen.
// Flips horizontally, e.g. to mirror face.
//
void
V_DrawPatchFlipped
( int		x,
  int		y,
  int		scrn,
  patch_t*	patch ) 
{ 

    int		count;
    int		col; 
    column_t*	column; 
    byte*	desttop;
    byte*	dest;
    byte*	source; 
    int		w; 
	 
    y -= SHORT(patch->topoffset); 
    x -= SHORT(patch->leftoffset); 
#ifdef RANGECHECK 
    if (x<0
	||x+SHORT(patch->width) >SCREENWIDTH
	|| y<0
	|| y+SHORT(patch->height)>SCREENHEIGHT 
	|| (unsigned)scrn>4)
    {
      fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );
      I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
    }
#endif 
 
    if (!scrn)
	V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 

    col = 0; 
    desttop = screens[scrn]+y*SCREENWIDTH+x; 
	 
    w = SHORT(patch->width); 

    for ( ; col<w ; x++, col++, desttop++) 
    { 
	column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); 
 
	// step through the posts in a column 
	while (column->topdelta != 0xff ) 
	{ 
	    source = (byte *)column + 3; 
	    dest = desttop + column->topdelta*SCREENWIDTH; 
	    count = column->length; 
			 
	    while (count--) 
	    { 
		*dest = *source++; 
		dest += SCREENWIDTH; 
	    } 
	    column = (column_t *)(  (byte *)column + column->length 
				    + 4 ); 
	} 
    }			 
} 
Ejemplo n.º 16
0
void F_TextWrite (void)
{
  {
    // erase the entire screen to a tiled background
    const byte *src; // cph - const
    int         x,y;
    int         lump;
    
    // killough 4/17/98: 
    src = W_CacheLumpNum(lump = firstflat + R_FlatNumForName(finaleflat));
    
    V_DrawBlock(0, 0, 0, 64, 64, src, 0);
    
    for (y=0 ; y<SCREENHEIGHT ; y+=64)
      for (x=y ? 0 : 64; x<SCREENWIDTH ; x+=64)
	V_CopyRect(0, 0, 0, ((SCREENWIDTH-x) < 64) ? (SCREENWIDTH-x) : 64, 
		   ((SCREENHEIGHT-y) < 64) ? (SCREENHEIGHT-y) : 64, x, y, 0);
    W_UnlockLumpNum(lump);
  }
  V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
  { // draw some of the text onto the screen
    int         cx = 10;
    int         cy = 10;
    const char* ch = finaletext; // CPhipps - const
    int         count = (finalecount - 10)/Get_TextSpeed();                 // phares
    int         w;
    
    if (count < 0)
      count = 0;
    
    for ( ; count ; count-- ) {
      int       c = *ch++;
      
      if (!c)
	break;
      if (c == '\n') {
	cx = 10;
	cy += 11;
	continue;
      }
              
      c = toupper(c) - HU_FONTSTART;
      if (c < 0 || c> HU_FONTSIZE) {
	cx += 4;
	continue;
      }
      
      w = SHORT (hu_font[c]->width);
      if (cx+w > SCREENWIDTH)
	break;
      // CPhipps - patch drawing updated
      V_DrawMemPatch(cx, cy, 0, hu_font[c], NULL, VPT_STRETCH);
      cx+=w;
    }
  }
}
Ejemplo n.º 17
0
int
WI_drawNum
( int		x,
  int		y,
  int		n,
  int		digits )
{

    int		fontwidth = SHORT(num[0]->width);
    int		neg;
    int		temp;

    if (digits < 0)
    {
	if (!n)
	{
	    // make variable-length zeros 1 digit long
	    digits = 1;
	}
	else
	{
	    // figure out # of digits in #
	    digits = 0;
	    temp = n;

	    while (temp)
	    {
		temp /= 10;
		digits++;
	    }
	}
    }

    neg = n < 0;
    if (neg)
	n = -n;

    // if non-number, do not draw it
    if (n == 1994)
	return 0;

    // draw the new number
    while (digits--)
    {
	x -= fontwidth;
	V_DrawPatch(x, y, FB, num[ n % 10 ]);
	n /= 10;
    }

    // draw a minus sign if necessary
    if (neg)
	V_DrawPatch(x-=8, y, FB, wiminus);

    return x;

}
Ejemplo n.º 18
0
 virtual void visitXformVar(XformVar* v) 
    { 
      XformVarInvoke *invoke = dynamic_cast<XformVarInvoke*>(v);
      if (invoke == 0) { res = v; return; }
      int userDebugSave = user_debug;
      int isInDebug = user_debug || debug_xform();
      if (isInDebug > 0) {
          user_debug = userDebugSave-1;
          if (user_debug) {
             std:: cerr << "Invoking " << SHORT(v->toString(DEBUG_NO_VAR),500) << "\n";
          }
      }
      res = invoke->eval(); 
      if (isInDebug) {
          std:: cerr << "Result of invoking " << SHORT(v->toString(DEBUG_NO_VAR),500) << "\n";
          std:: cerr << "===>" << res->toString() << "\n";
          user_debug = userDebugSave;
      }
   }
Ejemplo n.º 19
0
static int getPatchIsNotTileable(const patch_t *patch)
{
    int                 x = 0;
    int                 lastColumnDelta = 0;
    const column_t      *column;
    int                 cornerCount = 0;
    int                 hasAHole = 0;

    for (x = 0; x < SHORT(patch->width); ++x)
    {
        int             numPosts = 0;

        column = (const column_t *)((const byte *)patch + LONG(patch->columnofs[x]));

        if (!x)
            lastColumnDelta = column->topdelta;
        else if (lastColumnDelta != column->topdelta)
            hasAHole = 1;

        while (column->topdelta != 0xFF)
        {
            // check to see if a corner pixel filled
            if (!x && !column->topdelta)
                cornerCount++;
            else if (!x && column->topdelta + column->length >= SHORT(patch->height))
                cornerCount++;
            else if (x == SHORT(patch->width) - 1 && !column->topdelta)
                cornerCount++;
            else if (x == SHORT(patch->width) - 1
                && column->topdelta + column->length >= SHORT(patch->height))
                cornerCount++;

            if (numPosts++)
                hasAHole = 1;
            column = (const column_t *)((const byte *)column + column->length + 4);
        }
    }

    if (cornerCount == 4)
        return 0;

    return hasAHole;
}
Ejemplo n.º 20
0
void HUlib_initSText(hu_stext_t *s, int x, int y, int h, patch_t **font, int startchar, dboolean *on)
{
    s->h = h;
    s->on = on;
    s->laston = true;
    s->cl = 0;

    for (int i = 0; i < h; i++)
        HUlib_initTextLine(&s->l[i], x, y - i * (SHORT(font[0]->height) + 1), font, startchar);
}
Ejemplo n.º 21
0
/// get a genotype from a string
inline static C_Int16 getGeno(const char *p, const char *end, int num_allele)
{
	const char *start = p;
	if ((p < end) && (*p == '.'))
	{
		p ++;
		while ((p < end) && (*p == ' ')) p ++;
		if ((p < end) && VCF_RaiseError)
			throw ErrSeqArray(ERR_INT_CONV, SHORT(start, end).c_str());
		return -1;
	}

	int val = 0;
	while (p < end)
	{
		char ch = *p ++;
		if ('0' <= ch && ch <= '9')
		{
			val = val*10 + (ch - '0');
			if (VCF_RaiseError && (val > 32767))
				throw ErrSeqArray(ERR_INT_OUT_RANGE, SHORT(start, end).c_str());
		} else {
			if (ch == ' ')
			{
				while ((p < end) && (*p == ' '))
					p ++;
				if (p >= end) break;
			}
			if (VCF_RaiseError)
				throw ErrSeqArray(ERR_GENO_CONV, SHORT(start, end).c_str());
			return -1;
		}
	}

	if (val >= num_allele)
	{
		if (VCF_RaiseError)
			throw ErrSeqArray(ERR_GENO_OUT_RANGE, SHORT(start, end).c_str());
		val = -1;
	}

	return val;
}
Ejemplo n.º 22
0
void V_DrawPatch(int x, int y, patch_t *patch)
{
#if 1
	int count;
	int col;
	column_t *column;
	byte *desttop;
	byte *dest;
	byte *source;
	int w;

	y -= SHORT(patch->topoffset);
	x -= SHORT(patch->leftoffset);
	if(x < 0 || x+SHORT(patch->width) > SCREENWIDTH || y < 0
		|| y+SHORT(patch->height) > SCREENHEIGHT)
	{
		printf("x: %d y: %d\n",x,y);
		printf("w: %d h: %d\n",patch->width,patch->height);
		//I_Error("Bad V_DrawPatch");
		return;
	}
	col = 0;
	desttop = screen+y*SCREENWIDTH+x;
	w = SHORT(patch->width);
	for(; col < w; x++, col++, desttop++)
	{
		column = (column_t *)((byte *)patch+LONG(patch->columnofs[col]));
		// Step through the posts in a column
		while(column->topdelta != 0xff)
		{
			source = (byte *)column+3;
			dest = desttop+column->topdelta*SCREENWIDTH;
			count = column->length;
			while(count--)
			{
				*dest = *source++;
				dest += SCREENWIDTH;
			}
			column = (column_t *)((byte *)column+column->length+4);
		}
	}
#endif
}
Ejemplo n.º 23
0
static void WriteWAV(char *filename, byte *data,
                     uint32_t length, int samplerate)
{
    FILE *wav;
    unsigned int i;
    unsigned short s;

    wav = fopen(filename, "wb");

    // Header

    fwrite("RIFF", 1, 4, wav);
    i = LONG(36 + samplerate);
    fwrite(&i, 4, 1, wav);
    fwrite("WAVE", 1, 4, wav);

    // Subchunk 1

    fwrite("fmt ", 1, 4, wav);
    i = LONG(16);
    fwrite(&i, 4, 1, wav);           // Length
    s = SHORT(1);
    fwrite(&s, 2, 1, wav);           // Format (PCM)
    s = SHORT(2);
    fwrite(&s, 2, 1, wav);           // Channels (2=stereo)
    i = LONG(samplerate);
    fwrite(&i, 4, 1, wav);           // Sample rate
    i = LONG(samplerate * 2 * 2);
    fwrite(&i, 4, 1, wav);           // Byte rate (samplerate * stereo * 16 bit)
    s = SHORT(2 * 2);
    fwrite(&s, 2, 1, wav);           // Block align (stereo * 16 bit)
    s = SHORT(16);
    fwrite(&s, 2, 1, wav);           // Bits per sample (16 bit)

    // Data subchunk

    fwrite("data", 1, 4, wav);
    i = LONG(length);
    fwrite(&i, 4, 1, wav);           // Data length
    fwrite(data, 1, length, wav);    // Data

    fclose(wav);
}
Ejemplo n.º 24
0
 virtual void visitCodeVar(CodeVar* v) 
  {
    try {
      POETCode* _listsep = listsep;
      CodeVar* _listelem = listelem;
      POETCode* result = v->invoke_output(v->get_args());
      if (result != 0 && result != v) { 
          listsep = 0; listelem=0; 
          result->visit(this); 
          listsep = _listsep; listelem=_listelem;
          return; 
      }
      CvarSymbolTable::Entry e = v->get_entry();
      LvarSymbolTable *local = 0;
      POETCode* f = 0;
      POETCode *parse = e.get_parse();
      if (parse != 0 && parse->get_enum()==SRC_OP) { 
          POETOperator* op = static_cast<POETOperator*>(parse);
          if (op->get_op() == POET_OP_LIST || op->get_op()==POET_OP_LIST1)  {
              listsep = op->get_arg(1);
              listelem=dynamic_cast<CodeVar*>(op->get_arg(0));
              f = v->get_args();
           }
      }
      if (f == 0) { 
        listsep = 0; listelem=0;
        f = e.get_code();
        if (f == 0) { 
              if (parse==0) { CODE_SYNTAX_UNDEFINED(v->toString()); }
              else f = v->get_args(); 
        }
        else {
           local = e.get_symTable();
           if (local != 0) 
              local->push_table(false);
           POETCode* pars = e.get_param();
           if (pars != 0 && !match_parameters(pars, v->get_args(),MATCH_PAR_MOD_CODE))   
              CVAR_MISMATCH(v,pars, v->get_args());
           v->set_attr();
        }
      }
      if (f == 0) { CODE_SYNTAX_UNDEFINED(v->toString()); }
      int save = align;
      align = start_pos;
      f->visit(this); 
      align = save;
      if (local != 0)
          local->pop_table();
      listsep = _listsep; listelem=_listelem;
    }
    catch (Error err) { 
            std::cerr << " From unparsing code template " << SHORT(v->toString(),500) << "\n"; 
            throw err;
         }
    }
Ejemplo n.º 25
0
bool NetDemo::readHeader()
{
    fseek(demofp, 0, SEEK_SET);

    size_t cnt = 0;
    cnt += sizeof(header.identifier) *
           fread(&header.identifier, sizeof(header.identifier), 1, demofp);
    cnt += sizeof(header.version) *
           fread(&header.version, sizeof(header.version), 1, demofp);
    cnt += sizeof(header.compression) *
           fread(&header.compression, sizeof(header.compression), 1, demofp);
    cnt += sizeof(header.snapshot_index_size) *
           fread(&header.snapshot_index_size, sizeof(header.snapshot_index_size), 1, demofp);
    cnt += sizeof(header.snapshot_index_offset)*
           fread(&header.snapshot_index_offset, sizeof(header.snapshot_index_offset), 1, demofp);
    cnt += sizeof(header.map_index_size) *
           fread(&header.map_index_size, sizeof(header.map_index_size), 1, demofp);
    cnt += sizeof(header.map_index_offset)*
           fread(&header.map_index_offset, sizeof(header.map_index_offset), 1, demofp);
    cnt += sizeof(header.snapshot_spacing) *
           fread(&header.snapshot_spacing, sizeof(header.snapshot_spacing), 1, demofp);
    cnt += sizeof(header.starting_gametic) *
           fread(&header.starting_gametic, sizeof(header.starting_gametic), 1, demofp);
    cnt += sizeof(header.ending_gametic) *
           fread(&header.ending_gametic, sizeof(header.ending_gametic), 1, demofp);
    cnt += sizeof(header.reserved) *
           fread(&header.reserved, sizeof(header.reserved), 1, demofp);

    if (cnt < NetDemo::HEADER_SIZE)
        return false;

    // convert from little-endian to native byte ordering
    header.snapshot_index_size 		= SHORT(header.snapshot_index_size);
    header.snapshot_index_offset 	= LONG(header.snapshot_index_offset);
    header.map_index_size 			= SHORT(header.map_index_size);
    header.map_index_offset 		= LONG(header.map_index_offset);
    header.snapshot_spacing 		= SHORT(header.snapshot_spacing);
    header.starting_gametic 		= LONG(header.starting_gametic);
    header.ending_gametic			= LONG(header.ending_gametic);

    return true;
}
Ejemplo n.º 26
0
/// get an integer from a string
inline static int getInt32(const char *p, const char *end)
{
	while ((p < end) && (*p == ' '))
		p ++;
	const char *start = p;

	if ((p < end) && (*p == '.'))
	{
		p ++;
		while ((p < end) && (*p == ' ')) p ++;
		if ((p < end) && VCF_RaiseError)
			throw ErrSeqArray(ERR_INT_CONV, SHORT(start, end).c_str());
		return NA_INTEGER;
	}

	bool sign = ((p < end) && (*p == '-'));
	if (sign) p ++;

	C_Int64 val = 0;
	while (p < end)
	{
		char ch = *p ++;
		if ('0' <= ch && ch <= '9')
		{
			val = val*10 + (ch - '0');
			if (VCF_RaiseError && (val > INT_MAX))
				throw ErrSeqArray(ERR_INT_OUT_RANGE, SHORT(start, end).c_str());
		} else {
			if (ch == ' ')
			{
				while ((p < end) && (*p == ' '))
					p ++;
				if (p >= end) break;
			}
			if (VCF_RaiseError)
				throw ErrSeqArray(ERR_INT_CONV, SHORT(start, end).c_str());
			return NA_INTEGER;
		}
	}

	return sign ? -val : val;
}
Ejemplo n.º 27
0
void R_DrawVisSprite(vissprite_t *vis, int x1, int x2)
{
  column_t *column;
  int      texturecolumn;
  fixed_t  frac;
  patch_t  *patch = W_CacheLumpNum (vis->patch+firstspritelump, PU_CACHE);

  dc_colormap = vis->colormap;

  // killough 4/11/98: rearrange and handle translucent sprites
  // mixed with translucent/non-translucent 2s normals

  // sf: shadow draw now done by mobj flags, not a null colormap

  if (vis->mobjflags & MF_SHADOW)   // shadow draw
    {
      colfunc = R_DrawFuzzColumn;    // killough 3/14/98
    }
  else
    if (vis->colour)
      {
        colfunc = R_DrawTranslatedColumn;
        dc_translation = translationtables + vis->colour*256 - 256;
      }
    else
      if (vis->mobjflags & MF_TRANSLUCENT && general_translucency) // phares
        {
          colfunc = R_DrawTLColumn;
          tranmap = main_tranmap;       // killough 4/11/98
        }
      else
        colfunc = R_DrawColumn;         // killough 3/14/98, 4/11/98

  dc_iscale = abs(vis->xiscale);
  dc_texturemid = vis->texturemid;
  frac = vis->startfrac;
  spryscale = vis->scale;
  sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale);

  for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale)
    {
      texturecolumn = frac>>FRACBITS;

#ifdef RANGECHECK
      if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
        I_Error ("R_DrawSpriteRange: bad texturecolumn");
#endif

      column = (column_t *)((byte *) patch +
                            LONG(patch->columnofs[texturecolumn]));
      R_DrawMaskedColumn (column);
    }
  colfunc = R_DrawColumn;         // killough 3/14/98
}
Ejemplo n.º 28
0
static void DrawAltHUDNumber2(int x, int y, int val, int color)
{
    int         oldval = val;
    patch_t     *patch;

    if (val > 99)
    {
        patch = altnum2[val / 100];
        althudfunc(x, y, patch, WHITE, color);
        x += SHORT(patch->width) + 1;
    }
    val %= 100;
    if (val > 9 || oldval > 99)
    {
        patch = altnum2[val / 10];
        althudfunc(x, y, patch, WHITE, color);
        x += SHORT(patch->width) + 1;
    }
    althudfunc(x, y, altnum2[val % 10], WHITE, color);
}
Ejemplo n.º 29
0
void
HUlib_drawTextLine
( hu_textline_t*	l,
  boolean		drawcursor )
{

    int			i;
    int			w;
    int			x;
    unsigned char	c;

    // draw the new stuff
    x = l->x;
    for (i=0;i<l->len;i++)
    {
	c = toupper((int)l->l[i]);
	if (c != ' '
	    && c >= l->sc
	    && c <= '_')
	{
	    w = SHORT(l->f[c - l->sc]->width);
	    if (x+w > SCREENWIDTH)
		break;
	    V_DrawPatchDirect(x, l->y, l->f[c - l->sc]);
	    x += w;
	}
	else
	{
	    x += 4;
	    if (x >= SCREENWIDTH)
		break;
	}
    }

    // draw the cursor if requested
    if (drawcursor
	&& x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH)
    {
	V_DrawPatchDirect(x, l->y, l->f['_' - l->sc]);
    }
}
Ejemplo n.º 30
0
void P_LoadVertexes(int lump)
{
    byte *data;
    int i;
    mapvertex_t *ml;
    vertex_t *li;

    numvertexes = W_LumpLength(lump) / sizeof(mapvertex_t);
    vertexes = Z_Malloc(numvertexes * sizeof(vertex_t), PU_LEVEL, 0);
    data = W_CacheLumpNum(lump, PU_STATIC);

    ml = (mapvertex_t *) data;
    li = vertexes;
    for (i = 0; i < numvertexes; i++, li++, ml++)
    {
        li->x = SHORT(ml->x) << FRACBITS;
        li->y = SHORT(ml->y) << FRACBITS;
    }

    W_ReleaseLumpNum(lump);
}