Exemplo n.º 1
0
void gr_restore_mode()
{
	int i;

	//gr_set_text_25(); 

#ifndef NOGRAPH
	gr_palette_fade_out( gr_palette, 32, 0 );
	gr_palette_set_gamma(0);
	if ( gr_saved_screen.video_mode == 3 )	{
		switch( gr_saved_screen.height )	  {
		case 43:	gr_set_text_43(); break;
		case 50:	gr_set_text_50(); break;
		default:	gr_set_text_25(); break;
		}
	} else {
		gr_set_misc_mode(gr_saved_screen.video_mode);	
	}
	if (gr_saved_screen.is_graphics==0)	{
		gr_sync_display();
		gr_sync_display();
		gr_palette_read( gr_pal_default );
		gr_palette_clear();
		for (i=0; i < gr_saved_screen.width*gr_saved_screen.height; i++ )
			pTextMemory[i]=gr_saved_screen.video_memory[i];
		gr_setcursor( gr_saved_screen.cursor_x, gr_saved_screen.cursor_y, gr_saved_screen.cursor_sline, gr_saved_screen.cursor_eline );
		gr_palette_faded_out = 1;
		gr_palette_fade_in( gr_pal_default, 32, 0 );
	}
#endif

}
Exemplo n.º 2
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i;
	
	if (!gr_palette_faded_out) return 0;
	
#ifdef OGLES
	GLuint saved_screen_tex;
	grs_canvas *save_canvas;
	int darken_step;
	
	if (!grd_curscreen) {
		return 0;
	}
	
	save_canvas = grd_curcanv;
	gr_set_current_canvas(NULL);
	darken_step = GR_FADE_LEVELS / nsteps;
	Gr_scanline_darkening_level = 1;
	saved_screen_tex = ogles_save_screen();
	for (i = 0; i < nsteps; ++i) {
		ogles_draw_saved_screen(saved_screen_tex);
		Gr_scanline_darkening_level	+= darken_step;
		gr_urect(0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h);
		showRenderBuffer();
		gr_sync_display();
	}
	glDeleteTextures(1, &saved_screen_tex);
	Gr_scanline_darkening_level = GR_FADE_LEVELS;
	gr_set_current_canvas(save_canvas);
	gr_palette_apply(pal);
#else
	int j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];
	
	allow_keys  = allow_keys;
	
	for (i=0; i<768; i++ )	{
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;					
		}
		gr_palette_apply(c);
	}
#endif
	gr_palette_faded_out = 0;
	return 0;
}
Exemplo n.º 3
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i,j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;					
		}
		gr_palette_apply(c);
	}
	gr_palette_faded_out = 0;
	return 0;
}
Exemplo n.º 4
0
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys )	
{
	ubyte c[768];
	int i,j;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (gr_palette_faded_out)  return 0;

	for (i=0; i<768; i++ )	{
		fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
		fade_palette_delta[i] = fade_palette[i] / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;							
		}
		gr_palette_apply(c);
	}
	gr_palette_faded_out = 1;
	return 0;
}
Exemplo n.º 5
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)
{
	int i,j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];


	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c = f2i(fade_palette[i]);
                        if ( c > 63 ) c = 63;
			outp( 0x3c9, c );
		}
	}
	gr_palette_faded_out = 0;
	return 0;
}
Exemplo n.º 6
0
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys )
{
	ubyte c;
	int i,j;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	if (gr_palette_faded_out) return 0;

	if (!pal)
		pal = gr_current_pal;

	for (i=0; i<768; i++ )	{
		fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
		fade_palette_delta[i] = fade_palette[i] / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			c = f2i(fade_palette[i]);
			if ( c > 63 ) c = 63;
			outp( 0x3c9, c );
		}
	}
	gr_palette_faded_out = 1;
	return 0;
}
Exemplo n.º 7
0
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i,j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (!gr_palette_faded_out) return 0;

	#ifndef NDEBUG
	if (grd_fades_disabled) {
		gr_palette_load(pal);
		return 0;
	}
	#endif

#if defined(POLY_ACC)
        gr_palette_load(pal);
		return 0;
#endif

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c = f2i(fade_palette[i]);
			if ( c > 63 ) c = 63;
			outp( 0x3c9, c );								
		}
	}
	gr_palette_faded_out = 0;
	return 0;
}
Exemplo n.º 8
0
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys )	
{
	ubyte c;
	int i,j;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (gr_palette_faded_out) return 0;

	#ifndef NDEBUG
	if (grd_fades_disabled) {
		gr_palette_clear();
		return 0;
	}
	#endif

#if defined(POLY_ACC)
        return 0;
#endif

	for (i=0; i<768; i++ )	{
		fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
		fade_palette_delta[i] = fade_palette[i] / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{		
			fade_palette[i] -= fade_palette_delta[i];
			if (fade_palette[i] < 0 )
				fade_palette[i] = 0;
			c = f2i(fade_palette[i]);
			if ( c > 63 ) c = 63;
			outp( 0x3c9, c );								
		}
	}
	gr_palette_faded_out = 1;
	return 0;
}
Exemplo n.º 9
0
int gr_init(void)
{
	int org_gamma;
	int retcode;
        int mode = SM(320,200);

	// Only do this function once!
	if (gr_installed==1)
                return 3;

#ifdef __DJGPP__
	if (!__djgpp_nearptr_enable()) {
		printf("nearptr enable=%x\n", __dpmi_error);
		return 10;
	}
#ifndef SAVEGR
	gr_video_memory = (unsigned char *)(__djgpp_conventional_base + 0xa0000);
#else
	gr_video_memory=(unsigned char *)-1;
#endif
	pVideoMode =  (volatile ubyte *)(__djgpp_conventional_base+0x449);
	pNumColumns = (volatile ushort *)(__djgpp_conventional_base+0x44a);
	pNumRows = (volatile ubyte *)(__djgpp_conventional_base+0x484);
	pCharHeight = (volatile ushort *)(__djgpp_conventional_base+0x485);
	pCursorPos = (volatile ushort *)(__djgpp_conventional_base+0x450);
	pCursorType = (volatile ushort *)(__djgpp_conventional_base+0x460);
	pTextMemory = (volatile ushort *)(__djgpp_conventional_base+0xb8000);
#endif
#ifndef __DJGPP__
	if (gr_init_A0000())
		return 10;
#endif

	// Save the current text screen mode
	if (gr_save_mode()==1)
                return 2;

#ifndef NOGRAPH
	// Save the current palette, and fade it out to black.
	gr_palette_read( gr_pal_default );
	gr_palette_faded_out = 0;
	org_gamma = gr_palette_get_gamma();
	gr_palette_set_gamma( 0 );
	gr_palette_fade_out( gr_pal_default, 32, 0 );
	gr_palette_clear();
	gr_palette_set_gamma( org_gamma );
	gr_sync_display();
	gr_sync_display();
#endif

#ifdef __DJGPP__
#ifdef SAVEGR
	__djgpp_nearptr_disable();
#endif
#endif

	MALLOC( grd_curscreen,grs_screen,1 );
	memset( grd_curscreen, 0, sizeof(grs_screen));

	// Set the mode.
	if ((retcode=gr_set_mode(mode)))
	{
		gr_restore_mode();
		return retcode;
	}
	//JOHNgr_disable_default_palette_loading();

	// Set all the screen, canvas, and bitmap variables that
	// aren't set by the gr_set_mode call:
	grd_curscreen->sc_canvas.cv_color = 0;
	grd_curscreen->sc_canvas.cv_drawmode = 0;
	grd_curscreen->sc_canvas.cv_font = NULL;
	grd_curscreen->sc_canvas.cv_font_fg_color = 0;
	grd_curscreen->sc_canvas.cv_font_bg_color = 0;
	gr_set_current_canvas( &grd_curscreen->sc_canvas );

#if 0
	if (!dpmi_allocate_selector( &gr_fade_table, 256*GR_FADE_LEVELS, &gr_fade_table_selector ))
		Error( "Error allocating fade table selector!" );

	if (!dpmi_allocate_selector( &gr_palette, 256*3, &gr_palette_selector ))
		Error( "Error allocating palette selector!" );
#endif

//	if (!dpmi_allocate_selector( &gr_inverse_table, 32*32*32, &gr_inverse_table_selector ))
//		Error( "Error allocating inverse table selector!" );


	// Set flags indicating that this is installed.
	gr_installed = 1;
#ifdef __GNUC__

	atexit((void (*)) gr_close);
#else
	atexit(gr_close);
#endif
	return 0;
}