Ejemplo n.º 1
0
void SetRange(int start, int range)
{
	int i;

	for (i = 0; i < 8; i++)
		gPalette[start + i] = cColorRanges[range].range[i];
	CDogsSetPalette(gPalette);
}
Ejemplo n.º 2
0
void SetRange(int start, int range)
{
	int i;

	for (i = 0; i < 8; i++)
	{
		gPicManager.palette[start + i] = cColorRanges[range].range[i];
	}
	CDogsSetPalette(gPicManager.palette);
}
Ejemplo n.º 3
0
// Initialises the video subsystem.
// To prevent needless screen flickering, config is compared with cache
// to see if anything changed. If not, don't recreate the screen.
void GraphicsInitialize(
	GraphicsDevice *device, GraphicsConfig *config, TPalette palette,
	int force)
{
	int sdl_flags = 0;
	unsigned int w, h = 0;
	unsigned int rw, rh;

	if (!IsRestartRequiredForConfig(device, config))
	{
		return;
	}

	if (!device->IsWindowInitialized)
	{
		/* only do this the first time */
		char title[32];
		debug(D_NORMAL, "setting caption and icon...\n");
		sprintf(title, "C-Dogs SDL %s%s",
			config->IsEditor ? "Editor " : "",
			CDOGS_SDL_VERSION);
		SDL_WM_SetCaption(title, NULL);
		device->icon = SDL_LoadBMP(GetDataFilePath("cdogs_icon.bmp"));
		SDL_WM_SetIcon(device->icon, NULL);
		AddSupportedGraphicsModes(device);
	}

	device->IsInitialized = 0;

	sdl_flags |= SDL_SWSURFACE;
	sdl_flags |= config->IsEditor ? SDL_RESIZABLE : 0;
	if (config->Fullscreen)
	{
		sdl_flags |= SDL_FULLSCREEN;
	}

	rw = w = config->Res.x;
	rh = h = config->Res.y;

	if (config->ScaleFactor > 1)
	{
		rw *= config->ScaleFactor;
		rh *= config->ScaleFactor;
	}

	if (!force && !config->IsEditor)
	{
		device->modeIndex = FindValidMode(device, w, h, config->ScaleFactor);
		if (device->modeIndex == -1)
		{
			device->modeIndex = 0;
			printf("!!! Invalid Video Mode %dx%d\n", w, h);
			return;
		}
	}
	else
	{
		printf("\n");
		printf("  BIG FAT WARNING: If this blows up in your face,\n");
		printf("  and mutilates your cat, please don't cry.\n");
		printf("\n");
	}

	printf("Graphics mode:\t%dx%d %dx (actual %dx%d)\n",
		w, h, config->ScaleFactor, rw, rh);
	SDL_FreeSurface(device->screen);
	device->screen = SDL_SetVideoMode(rw, rh, 32, sdl_flags);
	if (device->screen == NULL)
	{
		printf("ERROR: InitVideo: %s\n", SDL_GetError());
		return;
	}
	SDL_PixelFormat *f = device->screen->format;
	device->Amask = -1 & ~(f->Rmask | f->Gmask | f->Bmask);
	Uint32 aMask = device->Amask;
	device->Ashift = 0;
	while (aMask != 0xff)
	{
		device->Ashift += 8;
		aMask >>= 8;
	}

	CFREE(device->buf);
	CCALLOC(device->buf, GraphicsGetMemSize(config));
	CFREE(device->bkg);
	CCALLOC(device->bkg, GraphicsGetMemSize(config));

	debug(D_NORMAL, "Changed video mode...\n");

	GraphicsSetBlitClip(
		device,
		0, 0, config->Res.x - 1,config->Res.y - 1);
	debug(D_NORMAL, "Internal dimensions:\t%dx%d\n",
		config->Res.x, config->Res.y);

	device->IsInitialized = 1;
	device->IsWindowInitialized = 1;
	device->cachedConfig = *config;
	device->cachedConfig.Res.x = w;
	device->cachedConfig.Res.y = h;
	CDogsSetPalette(palette);
}