static void draw_ball(int col,int row,int ibmp,int icolor)
{
    if(ipodc == 0 ){
	GrBitmap(ipobble_wid, ipobble_gc, col, row, BALL_WIDTH - 1,
		 BALL_WIDTH - 1, balls_bmp[ibmp]);
    } else {
        if (icolor!=-1)GrSetGCForeground(ipobble_gc, BallColors[icolor]);
	GrBitmap(ipobble_wid, ipobble_gc, col, row, BALL_WIDTH - 1,
		 BALL_WIDTH - 1, balls_bmp[ibmp]);
    }
    if(icolor!=-1)GrSetGCForeground(ipobble_gc, BLACK);
}
static void credits_blit_char(const int col, int cha, GR_COLOR colour,
                              const int fillbg)
{
	static int centre;
		
	if (!centre) {
		centre = (credits_info.height / 2) - (COL_H / 2);
	}
	
	if (fillbg) {
		GrSetGCUseBackground(credits_gc, GR_TRUE);
		GrSetGCBackground(credits_gc, BLACK);
	} else {
		GrSetGCUseBackground(credits_gc, GR_FALSE);
	}
	
	/* TRANSMUTATEULATE THE HOTDOG */
	if (cha == ' ') {
		cha = 0;
	} else if (cha >= '0' && cha <= '9') {
		cha = cha - 47;
	} else if (cha >= 'A' && cha <= 'Z') {
		cha = cha - 54;
	} else if (cha >= 'a' && cha <= 'z') { // lowercase -> upper
		cha = cha - 86;
	} else if (cha >= 1 && cha <= 26) { // c0d3
		cha = cha + 36;
	} else {
		cha = 34; // 'X'
	}

    GrSetGCForeground(credits_gc, colour);
	GrBitmap (credits_wid, credits_gc, COL_W*col, centre, COL_W, COL_H,
	          matrix_code_font[cha]);
}
Exemple #3
0
void closebutton_exposure(win *window, GR_EVENT_EXPOSURE *event)
{
	Dprintf("closebutton_exposure window %d\n", window->wid);

	GrBitmap(window->wid, buttonsgc, 0, 0, TITLE_BAR_HEIGHT, TITLE_BAR_HEIGHT,
		window->active ? closebutton_pressed : closebutton_notpressed);
}
Exemple #4
0
/* FIXME: fails with bitmapsize > 64k if sizeof(int) == 2*/
static void
GrBitmapWrapper(void *r)
{
	nxBitmapReq *req = r;

	GrBitmap(req->drawid, req->gcid, req->x, req->y, req->width,
		req->height, GetReqData(req));
}
static void fire_draw()
{
	int i;
	for(i = 0; i < me_firing; i++) {
		GrBitmap(invaders_wid, invaders_gc, myfire[i].posx,
				myfire[i].posy, MYFIRE_WIDTH, MYFIRE_HEIGHT,
				myfire_bmp[0]);
	}
	
	for(i = 0; i < alien_firing; i++) {
		Dprintf("alien posx,y %d,%d,%d\n", i, alienfire[i].posx,
			alienfire[i].posy);
		GrBitmap(invaders_wid,invaders_gc,
			alienfire[i].posx, alienfire[i].posy,
			ALIENFIRE_WIDTH, ALIENFIRE_HEIGHT, alienfire_bmp[0]);
	}
}
Exemple #6
0
void draw_eyes(nxeyes_state *state, int full_redraw)
{
	GR_COORD x, y;
	GR_BITMAP *bits;

	if(full_redraw) {
		if(state->eyes_closed) bits = eyeclose_bits;
		else bits = eyefg_bits;

		GrBitmap(state->wid, state->gc, 0, 0, EYEFG_WIDTH,
				EYEFG_HEIGHT, bits);
		GrBitmap(state->wid, state->gc, EYEFG_WIDTH + EYE_SPACING, 0,
				EYEFG_WIDTH, EYEFG_HEIGHT, bits);
	}

	if(state->mouse_moved) {
		x = EYEFG_WIDTH / 2;
		y = EYEFG_HEIGHT / 2;
		calculate_pupil_position(state->oldx, state->oldy,
			(EYEFG_WIDTH / 2),
			(EYEFG_HEIGHT / 2), state->mousex,
			state->mousey, &state->lx, &state->ly);
		calculate_pupil_position(state->oldx, state->oldy,
			(EYEFG_WIDTH / 2) + EYEFG_WIDTH
			+ EYE_SPACING, (EYEFG_WIDTH / 2),
			state->mousex, state->mousey, &state->rx, &state->ry);
	}

	if(state->eyes_closed) return;

	GrClearArea(state->wid, state->olx, state->oly, PUPIL_WIDTH,
			PUPIL_HEIGHT, 0);
	GrBitmap(state->wid, state->gc, state->lx, state->ly, PUPIL_WIDTH,
			PUPIL_HEIGHT, pupil_bits);
	GrClearArea(state->wid, state->orx, state->ory, PUPIL_WIDTH,
			PUPIL_HEIGHT, 0);
	GrBitmap(state->wid, state->gc, state->rx, state->ry, PUPIL_WIDTH,
			PUPIL_HEIGHT, pupil_bits);

	state->olx = state->lx;
	state->oly = state->ly;
	state->orx = state->rx;
	state->ory = state->ry;
}
static void aliens_draw(int ibmp)
{
	int i, j, ij, row, col;
	col = cell_minx;
	ij = 0;
	for(i = 0; i < ALIENS_COLS; i++) {
		row = cell_miny; 
		for(j = 0; j < aliens_rows; j++){
			if(alien_status[ij] > 0)
				GrBitmap(invaders_wid, invaders_gc, col, row,
						ALIEN_WIDTH, ALIEN_HEIGHT,
						alien_bmp[ibmp]);
			row += ALIEN_CELL_HEIGHT;
			ij++;
		}
		col += ALIEN_CELL_WIDTH;
	}
}
Exemple #8
0
void DrawModelPicture (int mn, vms_angvec *orient_angles)
{
    vms_vector	temp_pos=ZERO_VECTOR;
    vms_matrix	temp_orient = IDENTITY_MATRIX;
#if TEMP_CANV
    grs_canvas	*save_canv = grdCurCanv, *temp_canv;
#endif
    Assert (mn>=0 && mn<gameData.models.nPolyModels);
#if TEMP_CANV
    temp_canv = GrCreateCanvas (save_canv->cv_bitmap.bm_props.w, save_canv->cv_bitmap.bm_props.h);
    temp_canv->cv_bitmap.bm_props.x = grdCurCanv->cv_bitmap.bm_props.x;
    temp_canv->cv_bitmap.bm_props.y = grdCurCanv->cv_bitmap.bm_props.y;
    GrSetCurrentCanvas (temp_canv);
#endif
    GrClearCanvas (0);
    G3StartFrame (1, 0);
    glDisable (GL_BLEND);
    G3SetViewMatrix (&temp_pos, &temp_orient, 0x9000);
    if (gameData.models.polyModels [mn].rad != 0)
        temp_pos.z = FixMulDiv (DEFAULT_VIEW_DIST, gameData.models.polyModels [mn].rad, BASE_MODEL_SIZE);
    else
        temp_pos.z = DEFAULT_VIEW_DIST;
    VmAngles2Matrix (&temp_orient, orient_angles);
    PA_DFX (save_light = gameStates.render.nLighting);
    PA_DFX (gameStates.render.nLighting = 0);
    DrawPolygonModel (NULL, &temp_pos, &temp_orient, NULL, mn, 0, f1_0, NULL, NULL, NULL);
    PA_DFX (gameStates.render.nLighting = save_light);
#if TEMP_CANV
    GrSetCurrentCanvas (save_canv);
    glDisable (GL_BLEND);
    GrBitmap (0, 0, &temp_canv->cv_bitmap);
    glEnable (GL_BLEND);
    GrFreeCanvas (temp_canv);
#endif
    G3EndFrame ();
    if (curDrawBuffer != GL_BACK)
        GrUpdate (0);
}
Exemple #9
0
void redraw(GR_WINDOW_ID wid, GR_GC_ID gc)
{
    GrBitmap(wid, gc, 0, 0, BITMAPWIDTH, BITMAPHEIGHT, BITMAP);
}
Exemple #10
0
//if filename passed is NULL, show Normal credits
void ShowCredits(char *credits_filename)
{
	int			i, j, l, bDone;
	CFile			cf;
	char			buffer [NUM_LINES_HIRES][80];
	grsBitmap	bmBackdrop;
	int			nPcxError;
	unsigned int	nLine = 0;
	unsigned int	nXlLine = 0;
	fix			xTimeout, xDelay = X2I (2800 * 1000);
	int			nFirstLineOffs, nExtraInc = 0;
	int			bBinary = 0;
	char			*pszTemp;
	char			filename [32];
	int			xOffs, yOffs;
	box			dirtyBox [NUM_LINES_HIRES];
	gsrCanvas	*creditsOffscreenBuf = NULL;
	gsrCanvas	*saveCanv = grdCurCanv;

	// Clear out all tex buffer lines.
memset (buffer, 0, sizeof (buffer));
memset (dirtyBox, 0, sizeof (dirtyBox));

sprintf(filename, "%s", CREDITS_FILE);
bBinary = 0;
if (credits_filename) {
	strcpy(filename,credits_filename);
	bBinary = 1;
	}
if (!cf.Open (filename, gameFolders.szDataDir, "rb", 0)) {
	char nfile [32];

	if (credits_filename)
		return;		//ok to not find special filename

	if ((pszTemp = strchr (filename, '.')))
		*pszTemp = '\0';
	sprintf (nfile, "%s.txb", filename);
	if (!cf.Open (nfile, gameFolders.szDataDir, "rb", 0))
		Error("Missing CREDITS.TEX and CREDITS.TXB &cf\n");
	bBinary = 1;
	}
SetScreenMode(SCREEN_MENU);
xOffs = (grdCurCanv->cvBitmap.bmProps.w - 640) / 2;
yOffs = (grdCurCanv->cvBitmap.bmProps.h - 480) / 2;
if (xOffs < 0)
	xOffs = 0;
if (yOffs < 0)
	yOffs = 0;
creditsPalette = GrUsePaletteTable("credits.256", NULL);
GrPaletteStepLoad (NULL);
header_font = GrInitFont(gameStates.menus.bHires ? (char *) "font1-1h.fnt" : (char *) "font1-1.fnt");
title_font = GrInitFont(gameStates.menus.bHires ? (char *) "font2-3h.fnt" : (char *) "font2-3.fnt");
names_font = GrInitFont(gameStates.menus.bHires ? (char *) "font2-2h.fnt" : (char *) "font2-2.fnt");
bmBackdrop.bmTexBuf = NULL;
bmBackdrop.bmPalette = NULL;

//MWA  Made bmBackdrop bitmap linear since it should always be.  the current canvas may not
//MWA  be linear, so we can't rely on grdCurCanv->cvBitmap->bmProps.nType.

nPcxError = PCXReadBitmap ((char *) CREDITS_BACKGROUND_FILENAME, &bmBackdrop, BM_LINEAR, 0);
if (nPcxError != PCX_ERROR_NONE) {
	cf.Close();
	return;
	}
SongsPlaySong(SONG_CREDITS, 1);
GrRemapBitmapGood(&bmBackdrop, NULL, -1, -1);

if (!gameOpts->menus.nStyle) {
	GrSetCurrentCanvas(NULL);
	GrBitmap(xOffs,yOffs,&bmBackdrop);
	if ((grdCurCanv->cvBitmap.bmProps.w > 640) || (grdCurCanv->cvBitmap.bmProps.h > 480)) {
		GrSetColorRGBi (RGBA_PAL (0,0,32));
		GrUBox(xOffs,yOffs,xOffs+bmBackdrop.bmProps.w+1,yOffs+bmBackdrop.bmProps.h+1);
		}
	}
GrPaletteFadeIn(NULL, 32, 0);

//	Create a new offscreen buffer for the credits screen
//MWA  Let's be a little smarter about this and check the VR_offscreen buffer
//MWA  for size to determine if we can use that buffer.  If the game size
//MWA  matches what we need, then lets save memory.

if (gameStates.menus.bHires && !gameOpts->menus.nStyle && gameStates.render.vr.buffers.offscreen->cv_w == 640)
	creditsOffscreenBuf = gameStates.render.vr.buffers.offscreen;
else if (gameStates.menus.bHires)
	creditsOffscreenBuf = GrCreateCanvas(640,480);
else
	creditsOffscreenBuf = GrCreateCanvas(320,200);
if (!creditsOffscreenBuf)
	Error("Not enough memory to allocate Credits Buffer.");
creditsOffscreenBuf->cvBitmap.bmPalette = grdCurCanv->cvBitmap.bmPalette;
if (gameOpts->menus.nStyle)
	creditsOffscreenBuf->cvBitmap.bmProps.flags |= BM_FLAG_TRANSPARENT;
KeyFlush ();

bDone = 0;
nFirstLineOffs = 0;

xTimeout = SDL_GetTicks () + xDelay;
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gameStates.menus.nInMenu = 1;
while (1) {
	int k;

	do {
		nLine = (nLine + 1) % NUM_LINES;
get_line:;
		if (cf.GetS (buffer [nLine], 80)) {
			char *p = buffer [nLine];
			if (bBinary)				// is this a binary tbl &cf
				for (i = (int) strlen (buffer [nLine]); i > 0; i--, p++)
					*p = EncodeRotateLeft ((char) (EncodeRotateLeft (*p) ^ BITMAP_TBL_XOR));
			p = buffer [nLine];
			if (*p == ';')
				goto get_line;
			if (*p == '%') {
				if (p [1] == ALLOWED_CHAR)
					strcpy (p, p + 2);
				else
					goto get_line;
				}
			if ((p = strchr (buffer [nLine], '\n')))
				*p = '\0';
			} 
		else if (nXlLine < NUM_XL_LINES) {
			strcpy (buffer [nLine], xlCredits [nXlLine++]);
			}
		else {
			//fseek(&cf, 0, SEEK_SET);
			buffer [nLine][0] = 0;
			bDone++;
			}
		} while (nExtraInc--);
	nExtraInc = 0;

	//PrintLog ("%s\n", buffer [nLine]);
	for (i = 0; i < ROW_SPACING; i += gameStates.menus.bHires + 1) {
		int y;

		if (gameOpts->menus.nStyle) {
			GrSetCurrentCanvas (NULL);
			ShowFullscreenImage (&bmBackdrop);
	//			GrUpdate (0);
	#if 0
			if ((grdCurCanv->cvBitmap.bmProps.w > 640) || (grdCurCanv->cvBitmap.bmProps.h > 480)) {
				GrSetColorRGBi (RGBA_PAL (0,0,32));
				GrUBox (xOffs, yOffs, xOffs + bmBackdrop. bmProps.w + 1, yOffs + bmBackdrop.bmProps.h + 1);
				}
	#endif
			}
		y = nFirstLineOffs - i;
		GrSetCurrentCanvas (creditsOffscreenBuf);
		if (gameOpts->menus.nStyle)
			GrClearCanvas (0);	
		else
			GrBitmap (0, 0, &bmBackdrop);
		for (j = 0; j < NUM_LINES; j++)	{
			char *s;

			l = (nLine + j + 1) %  NUM_LINES;
			s = buffer [l];
			if (s[0] == '!') 
				s++;
			else if (s[0] == '$') {
				grdCurCanv->cvFont = header_font;
				s++;
				} 
			else if (s[0] == '*') {
				grdCurCanv->cvFont = title_font;
				s++;
				} 
			else
				grdCurCanv->cvFont = names_font;
			grBitBltFadeTable = (gameStates.menus.bHires ? fadeValues_hires : fadeValues);
			pszTemp = strchr (s, '\t');
			if (pszTemp) {	//	Wacky Credits thing
				int w, h, aw, w2, x1, x2;
				*pszTemp = 0;
				GrGetStringSize(s, &w, &h, &aw);
				x1 = ((gameStates.menus.bHires?320:160)-w)/2;
				cr_gr_printf (x1 , y, s);
				GrGetStringSize (pszTemp + 1, &w2, &h, &aw);
				x2 = (gameStates.menus.bHires ? 320 : 160) + (((gameStates.menus.bHires ? 320 : 160) - w2) / 2);
				cr_gr_printf(x2, y, &pszTemp[1]);
				dirtyBox [j].left = ((gameStates.menus.bHires?320:160)-w)/2;
				dirtyBox [j].top = y;
				dirtyBox [j].width =(x2+w2)-x1;
				dirtyBox [j].height = h;
				*pszTemp = '\t';
				} 
			else {
			// Wacky Fast Credits thing
				int w, h, aw;

				GrGetStringSize (s, &w, &h, &aw);
				dirtyBox [j].width = w;
        		dirtyBox [j].height = h;
        		dirtyBox [j].top = y;
        		dirtyBox [j].left = ((gameStates.menus.bHires?640:320) - w) / 2;
				cr_gr_printf (0x8000, y, s);
				}
			grBitBltFadeTable = NULL;
			if (buffer[l][0] == '!')
				y += ROW_SPACING / 2;
			else
				y += ROW_SPACING;
			}

		if (gameOpts->menus.nStyle) 
			GrSetCurrentCanvas (NULL);

		{	// Wacky Fast Credits Thing
		box	*newBox;
		grsBitmap *tempBmP;

		for (j = 0; j < NUM_LINES; j++) {
			newBox = dirtyBox + j;
			tempBmP = &creditsOffscreenBuf->cvBitmap;

			GrBmBitBlt (newBox->width + 1, newBox->height +4,
							newBox->left + xOffs, newBox->top + yOffs, 
							newBox->left, newBox->top,
							tempBmP, &grdCurScreen->scCanvas.cvBitmap);
			}
		}
	GrUpdate (0);
#if 1
	{
	int t = xTimeout - SDL_GetTicks ();
	if (t > 0)
		G3_SLEEP (t);
	xTimeout = SDL_GetTicks () + xDelay;
	}
#endif
	//see if redbook song needs to be restarted
	SongsCheckRedbookRepeat();
	k = KeyInKey ();
#if DBG
	if (k == KEY_BACKSP) {
		Int3();
		k = 0;
		}
#endif

	if ((k == KEY_PRINT_SCREEN) || (k == KEY_ALTED+KEY_F9)) {
		gameStates.app.bSaveScreenshot = 1;
		SaveScreenShot (NULL, 0);
		k = 0;
		}
	else if (k == KEY_PADPLUS)
		xDelay /= 2;
	else if (k == KEY_PADMINUS) {
		if (xDelay)
			xDelay *= 2;
		else
			xDelay = 1;
		}
	else if ((k == KEY_ESC) || (bDone > NUM_LINES)) {
		GrCloseFont (header_font);
		GrCloseFont (title_font);
		GrCloseFont (names_font);
		GrPaletteFadeOut (NULL, 32, 0);
		GrUsePaletteTable (D2_DEFAULT_PALETTE, NULL);
		D2_FREE (bmBackdrop.bmTexBuf);
		cf.Close ();
		GrSetCurrentCanvas (saveCanv);
		SongsPlaySong (SONG_TITLE, 1);

		if (creditsOffscreenBuf != gameStates.render.vr.buffers.offscreen)
			GrFreeCanvas (creditsOffscreenBuf);
		glDisable (GL_BLEND);
		gameStates.menus.nInMenu = 0;
		return;
		}
	}

	if (buffer [(nLine + 1) %  NUM_LINES][0] == '!') {
		nFirstLineOffs -= ROW_SPACING - ROW_SPACING / 2;
		if (nFirstLineOffs <= -ROW_SPACING) {
			nFirstLineOffs += ROW_SPACING;
			nExtraInc++;
			}
		}
	}
}
static void kmbitmap(void){
	
	GrSetGCUseBackground(keyman_gc, GR_FALSE); 
	GrSetGCForeground(keyman_gc, BLACK); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_black);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_black);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_black);break;
	}
	GrSetGCForeground(keyman_gc, GRAY); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_gray);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_gray);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_gray);break;
	} 
	GrSetGCForeground(keyman_gc, LTGRAY); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_ltgray);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_ltgray);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_ltgray);break;
	}
	GrSetGCForeground(keyman_gc, WHITE); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_white);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_white);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_white);break;
	}

}
static void draw_podzilla(int whichbmp)
{
	GrBitmap(ipobble_wid, ipobble_gc, me_posx - 18, me_posy - 5,
			11, 11, podzilla_bmp[whichbmp]);
	
}
static void me_draw()
{
	GrBitmap(invaders_wid,invaders_gc, me_posx, me_posy, ME_WIDTH,
			ME_HEIGHT, me_bmp[0]);
}
static void draw_alien(int col, int row, int ibmp)
{
	GrBitmap(invaders_wid, invaders_gc, cell_minx + col * ALIEN_CELL_WIDTH,
			cell_miny + row * ALIEN_CELL_HEIGHT, ALIEN_WIDTH,
			ALIEN_HEIGHT, alien_bmp[ibmp]);
}