예제 #1
0
void Video::WriteByte(Byte value, Word address)
{
	if (address < 0x9800)//Tile data
	{
		vram[address & 0x1FFF] = value;
		if (address > 0x8FFF){ if (isDebugging) std::cout << "Writing to bg tile data" << std::endl;; }
		else{ if (isDebugging)std::cout << "Writing to spr/bg/win tile data" << std::endl;; }

		UpdateTileData(value, address);
	}
	else if (address < 0xA000)//Tile map
	{
		if (isDebugging) std::cout << (address & 0x1FFF) << "Bg tile map, updating to use tile " << value << " from " << vram[address & 0x1FFF] << std::endl;
		vram[address & 0x1FFF] = value;
	}
	else if (address >= 0xFE00 && address < 0xFEA0)
	{
		if (isDebugging) std::cout << "Writing to oam" << std::endl;
		oam[address & 0xFE9F] = value;
		UpdateObject(value, address);
	}
	else
	{
		if (isDebugging) std::cout << "Writing to flag:" << GameBoyHelper::HexFormatOutX(address) << std::endl;
		switch (address)
		{
		case 0xFF40: lcdc = value; break;
		case 0xFF41: lcdc_stat = value; break;
		case 0xFF42: scroll_y = value; break;
		case 0xFF43: scroll_x = value; break;
		case 0xFF44: vert_line = 0; break;
		case 0xFF45: vert_line_cp = value; break;
		case 0xFF4A: window_y = value; break;
		case 0xFF4B: window_x = value; break;
		case 0xFF47: bg_palette = value; UpdatePalette(backgroundPalette, value); break;
		case 0xFF48: obj_palette0 = value; UpdatePalette(objectPalette0, value); break;
		case 0xFF49: obj_palette1 = value; UpdatePalette(objectPalette1, value); break;
		case 0xFF46:
		{
			Word baseAdrs = value;
			for (int i = 0x0; i < 0xF9; i++)
			{
				Byte val = Memory::GetInstance().ReadByte(baseAdrs + i);
				oam[i] = val;
				UpdateObject(val, baseAdrs+i);
			}
			break;
		}
		}
	}
}
예제 #2
0
/** Do palette animation and blit to the window. */
static void PaintWindow(HDC dc)
{
	HDC dc2 = CreateCompatibleDC(dc);
	HBITMAP old_bmp = (HBITMAP)SelectObject(dc2, _wnd.dib_sect);
	HPALETTE old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE);

	if (_cur_palette.count_dirty != 0) {
		Blitter *blitter = BlitterFactory::GetCurrentBlitter();

		switch (blitter->UsePaletteAnimation()) {
			case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
				UpdatePalette(dc2, _local_palette.first_dirty, _local_palette.count_dirty);
				break;

			case Blitter::PALETTE_ANIMATION_BLITTER:
				blitter->PaletteAnimate(_local_palette);
				break;

			case Blitter::PALETTE_ANIMATION_NONE:
				break;

			default:
				NOT_REACHED();
		}
		_cur_palette.count_dirty = 0;
	}

	BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY);
	SelectPalette(dc, old_palette, TRUE);
	SelectObject(dc2, old_bmp);
	DeleteDC(dc2);
}
예제 #3
0
void Colours_Update(void)
{
	UpdatePalette();
#if SUPPORTS_PLATFORM_PALETTEUPDATE
	PLATFORM_PaletteUpdate();
#endif
}
예제 #4
0
static void InitPalette()
{
	_local_palette = _cur_palette;
	_local_palette.first_dirty = 0;
	_local_palette.count_dirty = 256;
	UpdatePalette(true);
}
예제 #5
0
void DrawSTextV(int t)
{
	int offset = 540 + (t / 2);
	int i, c;
	t = t * 350 / 500;
	int cl = 350 - t;
	
	for (i = 0; i < 64; i++) {
		DrawRect(0, i * 15 - offset, 640, 15, (64 - i) * cl / 350);
	}
	for (i = 64; i < 128; i++) {
		DrawRect(0, i * 15 - offset, 640, 15, (i - 64) * cl / 350);
	}
	
	if (t < 300) {
		for (i = 0; i < 15; i++) {
			c = (255 + (i * 100) - t*10);
			if (c < 0) c = 0;
			if (c > 255) c = 255;
			
			draw_text(68, 150+i*12, STextV[i], 255-c);
		}
	} else {
		for (i = 0; i < 15; i++) {
			c = 5 + (t-300) * 5;
			
			draw_text(68, 150+i*12, STextV[i], 255-c);
		}
	}
	
	UpdatePalette();
	VideoUpdate();
}
예제 #6
0
void OpenGLFrameBuffer::GameRestart()
{
	memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
	UpdatePalette ();
	ScreenshotBuffer = NULL;
	LastCamera = NULL;
	gl_GenerateGlobalBrightmapFromColormap();
}
예제 #7
0
void DrawPText(int t)
{
	int i;
	int c;
	
	int x, y;
	
	for (i = 0; i < 256; i++) {
		ending_pal[i].r = i;
		ending_pal[i].g = i;
		ending_pal[i].b = (i * 3 / 4) + 64;
	}
	
	if (t < 300) {
	
		for (i = 0; i < 10; i++) {
			c = (255 + (i * 100) - t*10);
			if (c < 0) c = 0;
			if (c > 255) c = 255;
			
			if (player_shield != 30) {
				draw_text(68, 180+i*12, PText[i], c);
			} else {
				draw_text(68, 180+i*12, PTextV[i], c);
			}
		}
	} else {
		for (i = 0; i < 10; i++) {
			c = 5 + (t-300) * 5;
			
			if (player_shield != 30) {
				draw_text(68, 180+i*12, PText[i], c);
			} else {
				draw_text(68, 180+i*12, PTextV[i], c);
			}
		}
	}
	
	for (i = 0; i < (32 * 8); i++) {
		x = (i % 32)*20;
		y = (i / 32)*20;
		
		c = 237 + (i/32*2) + (rand()% (19 - (i/32) *2));
		DrawRect(x, y, 20, 20, c);
		c = 237 + (i/32*2) + (rand()% (19 - (i/32) *2));
		DrawRect(x, 460 - y, 20, 20, c);
	}
	
	
	UpdatePalette();
	VideoUpdate();
}
예제 #8
0
void DrawCircuitFlash(int t, int method)
{
	static SDL_Surface *circ = NULL;
	static int xpos, ypos;
	int i, j;
	SDL_Rect from;
	
	if (circ == NULL) {
		circ = IMG_Load("dat/i/circuits_1.png");
	}
	
	if (t == 0) {
		if (method == 0) {
			xpos = rand()%641;
			ypos = rand()%481;
		} else {
			xpos = 320;
			ypos = 240;
		}
	}
	
	from.x = xpos;
	from.y = ypos;
	from.w = 640;
	from.h = 480;
	
	SDL_BlitSurface(circ, &from, screen, NULL);
	
	for (i = 0; i < 256; i++) {
		if (method == 0) {
			j = i * t / 4;
		} else {
			j = i * t / 8;
			if (t >= 20) {
				j += t * 25;
			}
		}
		
		if (j > 255) j = 255;
		ending_pal[i].r = j;
		ending_pal[i].g = j;
		ending_pal[i].b = j;
	}
	
	UpdatePalette();
	VideoUpdate();
}
예제 #9
0
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : 
	Super(hMonitor, width, height, bits, refreshHz, fullscreen) 
{
	GLRenderer = new FGLRenderer(this);
	memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
	UpdatePalette ();
	ScreenshotBuffer = NULL;
	LastCamera = NULL;

	InitializeState();
	gl_SetupMenu();
	gl_GenerateGlobalBrightmapFromColormap();
	DoSetGamma();
	needsetgamma = true;
	swapped = false;
	Accel2D = true;
	SetVSync(vid_vsync);
}
예제 #10
0
void RunParticleStorm(int offset)
{
	SDL_Rect draw_from, draw_to;
	int i;
	
	for (i = 0; i < 64; i++) {
		DrawRect(0, i * 15 - offset, 640, 15, 64 - i);
	}
	
	for (i = 0; i < 500; i++) {
		if (pt_t[i] > 0) {
			pt_t[i]--;
		} else {
			pt_vy[i] += 0.1;
			pt_x[i] += pt_vx[i];
			pt_y[i] += pt_vy[i];
		}
		
		draw_from.x = (rand()%3)*32;
		draw_from.y = 0;
		draw_from.w = 32;
		draw_from.h = 32;
	
		draw_to.x = (int)pt_x[i] - 16;
		draw_to.y = (int)pt_y[i] - 16 - offset;
		SDL_BlitSurface(glitter, &draw_from, screen, &draw_to);
	}

	for (i = 0; i < 128; i++) {
		ending_pal[i].r = i*2;
		ending_pal[i].g = i*2;
		ending_pal[i].b = 0;
	}
	for (i = 128; i < 256; i++) {
		ending_pal[i].r = 255;
		ending_pal[i].g = 255;
		ending_pal[i].b = (i - 128)*2+1;
	}
	
	UpdatePalette();
	VideoUpdate();
}
예제 #11
0
	void ColorThemeEngine::SetTheme (const QString& themeName)
	{
		const auto& themePath = Loader_->GetPath (QStringList (themeName));

		if (themePath.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "no theme"
					<< themeName;
			return;
		}

		auto palette = StartupPalette_;
		if (QFile::exists (themePath + "/colors.rc"))
		{
			QSettings settings (themePath + "/colors.rc", QSettings::IniFormat);
			if (settings.childGroups ().isEmpty ())
			{
				qWarning () << Q_FUNC_INFO
						<< "error opening colors file for"
						<< themeName;
				return;
			}

			palette = UpdatePalette (StartupPalette_, settings);
		}
		QApplication::setPalette (palette);
		const auto rootWinMgr = Core::Instance ().GetRootWindowsManager ();
		for (int i = 0; i < rootWinMgr->GetWindowsCount (); ++i)
		{
			const auto win = rootWinMgr->GetMainWindow (i);
			win->setPalette (palette);

			for (auto w : win->findChildren<QWidget*> ())
				w->setPalette (palette);
		}

		QSettings qmlSettings (themePath + "/qml.rc", QSettings::IniFormat);
		FillQML (qmlSettings);

		emit themeChanged ();
	}
예제 #12
0
  bool SetFormatFromSurface(IUnknown *surfPtr)
  {
    IDirectDrawSurface *surf = (IDirectDrawSurface *) surfPtr;

    DDPIXELFORMAT fmt;
    ZeroMemory(&fmt,sizeof(fmt));
    fmt.dwSize = sizeof(fmt);

    if(FAILED(surf->GetPixelFormat(&fmt)))
    {
      printLog("video: can't get pixel format\n");
      return false;
    }

    SetFormat(&fmt);
    if(IsPaletted())
      UpdatePalette();

    return true;
  }
예제 #13
0
HRESULT Direct3D9Video::CreateSurfaces ()
{
    HRESULT hr = 0;

    if (!m_pd3dDevice)
        return D3DERR_INVALIDDEVICE;

    if (m_pTexture) m_pTexture->Release(), m_pTexture = NULL;
    if (m_pScanlineTexture) m_pScanlineTexture->Release(), m_pScanlineTexture = NULL;

    if (FAILED(hr = m_pd3dDevice->CreateTexture(TEXTURE_SIZE, TEXTURE_SIZE, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTexture, NULL)))
        return hr;

    if (FAILED(hr = m_pd3dDevice->CreateTexture(TEXTURE_SIZE, TEXTURE_SIZE, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pScanlineTexture, NULL)))
    {
        m_pTexture->Release(), m_pTexture = NULL;
        return hr;
    }

    D3DSURFACE_DESC d3dsd;
    D3DLOCKED_RECT d3dlr;
    if (SUCCEEDED(hr = m_pTexture->GetLevelDesc(0, &d3dsd)) &&
        SUCCEEDED(hr = m_pTexture->LockRect(0, &d3dlr, 0, 0)))
    {
        for (UINT  y = 0; y < TEXTURE_SIZE ; y++)
        {
            BYTE *pb = reinterpret_cast<BYTE*>(d3dlr.pBits);
            memset(pb + y*d3dlr.Pitch, 0, TEXTURE_SIZE*4);
        }

        m_pTexture->UnlockRect(0);
    }

    UpdatePalette();
    Video::SetDirty();

    return hr;
}
예제 #14
0
static void CheckPaletteAnim()
{
	if (_cur_palette.count_dirty != 0) {
		Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();

		switch (blitter->UsePaletteAnimation()) {
			case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
				UpdatePalette();
				break;

			case Blitter::PALETTE_ANIMATION_BLITTER:
				blitter->PaletteAnimate(_local_palette);
				break;

			case Blitter::PALETTE_ANIMATION_NONE:
				break;

			default:
				NOT_REACHED();
		}
		_cur_palette.count_dirty = 0;
	}
}
예제 #15
0
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
{
	SDL_Surface *newscreen, *icon;
	char caption[50];
	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
	bool want_hwpalette;

	GetAvailableVideoMode(&w, &h);

	DEBUG(driver, 1, "SDL: using mode %ux%ux%d", w, h, bpp);

	if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");

	char icon_path[MAX_PATH];
	if (FioFindFullPath(icon_path, lengthof(icon_path), BASESET_DIR, "openttd.32.bmp") != NULL) {
		/* Give the application an icon */
		icon = SDL_CALL SDL_LoadBMP(icon_path);
		if (icon != NULL) {
			/* Get the colourkey, which will be magenta */
			uint32 rgbmap = SDL_CALL SDL_MapRGB(icon->format, 255, 0, 255);

			SDL_CALL SDL_SetColorKey(icon, SDL_SRCCOLORKEY, rgbmap);
			SDL_CALL SDL_WM_SetIcon(icon, NULL);
			SDL_CALL SDL_FreeSurface(icon);
		}
	}

	if (_use_hwpalette == 2) {
		/* Default is to autodetect when to use SDL_HWPALETTE.
		 * In this case, SDL_HWPALETTE is only used for 8bpp
		 * blitters in fullscreen.
		 *
		 * When using an 8bpp blitter on a 8bpp system in
		 * windowed mode with SDL_HWPALETTE, OpenTTD will claim
		 * the system palette, making all other applications
		 * get the wrong colours. In this case, we're better of
		 * trying to approximate the colors we need using system
		 * colors, using a shadow surface (see below).
		 *
		 * On a 32bpp system, SDL_HWPALETTE is ignored, so it
		 * doesn't matter what we do.
		 *
		 * When using a 32bpp blitter on a 8bpp system, setting
		 * SDL_HWPALETTE messes up rendering (at least on X11),
		 * so we don't do that. In this case, SDL takes care of
		 * color approximation using its own shadow surface
		 * (which we can't force in 8bpp on 8bpp mode,
		 * unfortunately).
		 */
		want_hwpalette = (bpp == 8 && _fullscreen);
	} else {
		/* User specified a value manually */
		want_hwpalette = _use_hwpalette;
	}

	if (want_hwpalette) DEBUG(driver, 1, "SDL: requesting hardware palete");

	/* Free any previously allocated shadow surface */
	if (_sdl_screen != NULL && _sdl_screen != _sdl_realscreen) SDL_CALL SDL_FreeSurface(_sdl_screen);

	if (_sdl_realscreen != NULL) {
		if (_requested_hwpalette != want_hwpalette) {
			/* SDL (at least the X11 driver), reuses the
			 * same window and palette settings when the bpp
			 * (and a few flags) are the same. Since we need
			 * to hwpalette value to change (in particular
			 * when switching between fullscreen and
			 * windowed), we restart the entire video
			 * subsystem to force creating a new window.
			 */
			DEBUG(driver, 0, "SDL: Restarting SDL video subsystem, to force hwpalette change");
			SDL_CALL SDL_QuitSubSystem(SDL_INIT_VIDEO);
			SDL_CALL SDL_InitSubSystem(SDL_INIT_VIDEO);
			ClaimMousePointer();
			SetupKeyboard();
		}
	}
	/* Remember if we wanted a hwpalette. We can't reliably query
	 * SDL for the SDL_HWPALETTE flag, since it might get set even
	 * though we didn't ask for it (when SDL creates a shadow
	 * surface, for example). */
	_requested_hwpalette = want_hwpalette;

	/* DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK */
	newscreen = SDL_CALL SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | (want_hwpalette ? SDL_HWPALETTE : 0) | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
	if (newscreen == NULL) {
		DEBUG(driver, 0, "SDL: Couldn't allocate a window to draw on");
		return false;
	}
	_sdl_realscreen = newscreen;

	if (bpp == 8 && (_sdl_realscreen->flags & SDL_HWPALETTE) != SDL_HWPALETTE) {
		/* Using an 8bpp blitter, if we didn't get a hardware
		 * palette (most likely because we didn't request one,
		 * see above), we'll have to set up a shadow surface to
		 * render on.
		 *
		 * Our palette will be applied to this shadow surface,
		 * while the real screen surface will use the shared
		 * system palette (which will partly contain our colors,
		 * but most likely will not have enough free color cells
		 * for all of our colors). SDL can use these two
		 * palettes at blit time to approximate colors used in
		 * the shadow surface using system colors automatically.
		 *
		 * Note that when using an 8bpp blitter on a 32bpp
		 * system, SDL will create an internal shadow surface.
		 * This shadow surface will have SDL_HWPALLETE set, so
		 * we won't create a second shadow surface in this case.
		 */
		DEBUG(driver, 1, "SDL: using shadow surface");
		newscreen = SDL_CALL SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bpp, 0, 0, 0, 0);
		if (newscreen == NULL) {
			DEBUG(driver, 0, "SDL: Couldn't allocate a shadow surface to draw on");
			return false;
		}
	}

	/* Delay drawing for this cycle; the next cycle will redraw the whole screen */
	_num_dirty_rects = 0;

	_screen.width = newscreen->w;
	_screen.height = newscreen->h;
	_screen.pitch = newscreen->pitch / (bpp / 8);
	_screen.dst_ptr = newscreen->pixels;
	_sdl_screen = newscreen;

	/* When in full screen, we will always have the mouse cursor
	 * within the window, even though SDL does not give us the
	 * appropriate event to know this. */
	if (_fullscreen) _cursor.in_window = true;

	Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
	blitter->PostResize();

	InitPalette();
	switch (blitter->UsePaletteAnimation()) {
		case Blitter::PALETTE_ANIMATION_NONE:
		case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
			UpdatePalette();
			break;

		case Blitter::PALETTE_ANIMATION_BLITTER:
			if (_video_driver != NULL) blitter->PaletteAnimate(_local_palette);
			break;

		default:
			NOT_REACHED();
	}

	snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
	SDL_CALL SDL_WM_SetCaption(caption, caption);

	GameSizeChanged();

	return true;
}
예제 #16
0
void DrawStream(int t)
{
	int i;
	int scr_x = 32;
	int scr_y = 0;
	int strm_scrl;
	SDL_Rect draw_from, draw_to;
	
	for (i = 0; i < 256; i++) {
		ending_pal[i].r = i;
		ending_pal[i].g = (i * 7 / 8) + 16 + sin( (float)t / 8 )*16;
		ending_pal[i].b = (i * 3 / 4) + 32 + sin( (float)t / 8 )*32;
	}
	

	if (t >= 300) {
		scr_x = 32 + rand()%32 - rand()%32;
		scr_y = rand()%8;
	}
	
	if (t < 10) {
		scr_y = (20 - t * 2);
	}
	
	DrawLevel(scr_x, scr_y, 0, 0);
	DrawPlayer(344 - scr_x, 228 - scr_y, 0, 0);
	
	for (i = 0; i < 7; i++) {
		strm_scrl = (t * 20) % 128;
		draw_to.x = 0 - strm_scrl - scr_x + (128*i);
		draw_to.y = 19 - scr_y;
		
		if (i >= 300) {
			draw_to.y += rand()%4;
			draw_to.y -= rand()%4;
		}
		SDL_BlitSurface(streamspr, NULL, screen, &draw_to);
	}
	
	// glitter
	for (i = 0; i < 20; i++) {
		draw_from.x = (rand()%3)*32;
		draw_from.y = 0;
		draw_from.w = 32;
		draw_from.h = 32;
	
		draw_to.x = rand()%(640+32)-32;
		draw_to.y = (rand()%(124)) + 3;
		
		SDL_BlitSurface(glitter, &draw_from, screen, &draw_to);
	}
	
	if (t > 250) {
		if (t < 300) {
			if (t == 251) {
				SND_CircuitRelease(1000);
			}
			DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 254) * 10, 255);
			DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 252) * 10, 225);
			DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 250) * 10, 195);
		}
	}
	
	UpdatePalette();
	VideoUpdate();
}
예제 #17
0
int Colours_Initialise(int *argc, char *argv[])
{
	int i;
	int j;

	for (i = j = 1; i < *argc; i++) {
		int i_a = (i + 1 < *argc);		/* is argument available? */
		int a_m = FALSE;			/* error, argument missing! */
		
		if (strcmp(argv[i], "-saturation") == 0) {
			if (i_a)
				COLOURS_NTSC_setup.saturation = COLOURS_PAL_setup.saturation = atof(argv[++i]);
			else a_m = TRUE;
		}
		else if (strcmp(argv[i], "-contrast") == 0) {
			if (i_a)
				COLOURS_NTSC_setup.contrast = COLOURS_PAL_setup.contrast = atof(argv[++i]);
			else a_m = TRUE;
		}
		else if (strcmp(argv[i], "-brightness") == 0) {
			if (i_a)
				COLOURS_NTSC_setup.brightness = COLOURS_PAL_setup.brightness = atof(argv[++i]);
			else a_m = TRUE;
		}
		else if (strcmp(argv[i], "-gamma") == 0) {
			if (i_a)
				COLOURS_NTSC_setup.gamma = COLOURS_PAL_setup.gamma = atof(argv[++i]);
			else a_m = TRUE;
		}
		else if (strcmp(argv[i], "-tint") == 0) {
			if (i_a)
				COLOURS_NTSC_setup.hue = COLOURS_PAL_setup.hue = atof(argv[++i]);
			else a_m = TRUE;
		}
		else if (strcmp(argv[i], "-colors-preset") == 0) {
			if (i_a) {
				int idx = CFG_MatchTextParameter(argv[++i], preset_cfg_strings, COLOURS_PRESET_SIZE);
				if (idx < 0) {
					Log_print("Invalid value for -colors-preset");
					return FALSE;
				}
				COLOURS_NTSC_setup = COLOURS_PAL_setup = presets[idx];
				COLOURS_NTSC_RestoreDefaults();
				COLOURS_PAL_RestoreDefaults();
			} else a_m = TRUE;
		}

		else {
			if (strcmp(argv[i], "-help") == 0) {
				Log_print("\t-colors-preset standard|deep-black|vibrant");
				Log_print("\t                       Use one of predefined color adjustments");
				Log_print("\t-saturation <num>      Set color saturation");
				Log_print("\t-contrast <num>        Set contrast");
				Log_print("\t-brightness <num>      Set brightness");
				Log_print("\t-gamma <num>           Set color gamma factor");
				Log_print("\t-tint <num>            Set tint");
			}
			argv[j++] = argv[i];
		}

		if (a_m) {
			Log_print("Missing argument for '%s'", argv[i]);
			return FALSE;
		}
	}
	*argc = j;

	if (!COLOURS_NTSC_Initialise(argc, argv) ||
	    !COLOURS_PAL_Initialise(argc, argv))
		return FALSE;

	/* Assume that Atari800_tv_mode has been already initialised. */
	UpdateModeDependentPointers(Atari800_tv_mode);
	UpdatePalette();
	return TRUE;
}
예제 #18
0
void DrawScrolly(int t)
{
	int xp;
	int yp;
	int i, j;
	float a_dir;
	float v_radius;
	int all_blue = 0;
	SDL_Rect draw_from, draw_to;
	
	int x, y, r;
	
	float bright;
	
	if (t < 795) {
		xp = 8192 - 320 - 3180 + (t * 4);
		yp = t * 20;
	} else {
		xp = 8192 - 320 + ( (t-795) * 10);
		yp = 795 * 20 - (t-795)*10;
	}
	
	// Palette
	
	
	if ((rand() % 10)==9) {
		all_blue = 1;
	}
	for (i = 0; i < 256; i++) {
		bright = sin((float)t / 10.0) * 0.2 + 0.4;
		ending_pal[i].r = (i * bright + (256*(1.0-bright))) * ((float)(all_blue == 0) * 0.5 + 0.5);
		ending_pal[i].g = (i * bright + (256*(1.0-bright))) * ((float)(all_blue == 0) * 0.5 + 0.5);
		ending_pal[i].b = i * bright + (256*(1.0-bright));
	}
	DrawLevel(xp, yp, 0, 0);
	
	v_radius = sin((float)t / 10.0)*20 + 100;
	
	for (i = 0; i < 5; i++) {
		x = rand()%640;
		y = rand()%480;
		r = rand()%500+100;
		
		DrawCircleEx(x, y, r+2, r-4, 128);
		DrawCircleEx(x, y, r, r-2, 255);
	}
	
	for (i = 0; i < 4; i++) {
		draw_from.x = (8 + i) * 32;
		draw_from.y = 0;
		draw_from.w = 32;
		draw_from.h = 32;
		
		a_dir = ((float)t / 10.0) + (M_PI*(float)i/2);
		
		for (j = 10; j >= 0; j--) {
			DrawCircleEx(320+cos(a_dir)*v_radius, 240+sin(a_dir)*v_radius, 22 + j * 2, 0, abs(j-3) * 15);
		}
		DrawCircleEx(320+cos(a_dir)*v_radius, 240+sin(a_dir)*v_radius, 20, 0, 0);
		
		draw_to.x = 320 + cos(a_dir) * v_radius - 16;
		draw_to.y = 240 + sin(a_dir) * v_radius - 16;
		SDL_BlitSurface(artifact_spr, &draw_from, screen, &draw_to);
	}
	
	UpdatePalette();
	VideoUpdate();
}
예제 #19
0
/* ---------------------------------------------------------------------- *
 * Public Functions
 * ---------------------------------------------------------------------- */
void
load_start_image (void)
{
#ifdef LC_X11
  XColor pal[256];
  XEvent xev;
#endif
  long x, y, l, r, g, b;
  gzFile fp;

  fp = gzopen( opening_pic, "r" );
  if (fp == NULL) {
      return;
  }

  for (x = 0; x < 7; x++)
    l = gzgetc (fp);
  l &= 0xff;
  if (l == 0)
    l = 256;
  for (x = 0; x < l; x++)
    {
      r = gzgetc (fp);
      g = gzgetc (fp);
      b = gzgetc (fp);
#ifdef LC_X11
      pal[x].red = r;
      pal[x].green = g;
      pal[x].blue = b;
      pal[x].flags = DoRed | DoGreen | DoBlue;
#elif defined LC_SVGA
      gl_setpalettecolor (x, r, g, b);
#endif
    }
  /* use last 4 colours for text */
#ifdef LC_X11
  pal[SI_BLACK].red = 0;
  pal[SI_BLACK].green = 0;
  pal[SI_BLACK].blue = 0;
  pal[SI_BLACK].flags = DoRed | DoGreen | DoBlue;
  pal[SI_RED].red = 60;
  pal[SI_RED].green = 0;
  pal[SI_RED].blue = 0;
  pal[SI_RED].flags = DoRed | DoGreen | DoBlue;
  pal[SI_GREEN].red = 0;
  pal[SI_GREEN].green = 60;
  pal[SI_GREEN].blue = 0;
  pal[SI_GREEN].flags = DoRed | DoGreen | DoBlue;
  pal[SI_YELLOW].red = 60;
  pal[SI_YELLOW].green = 60;
  pal[SI_YELLOW].blue = 0;
  pal[SI_YELLOW].flags = DoRed | DoGreen | DoBlue;
  open_setcustompalette (pal);
  suppress_next_expose = 1;
  do
    {
      while (XPending (display.dpy) == 0);
      XNextEvent (display.dpy, &xev);
      HandleEvent (&xev);
    }
  while (xev.type != MapNotify);

#elif defined LC_SVGA
  gl_setpalettecolor (SI_BLACK, 0, 0, 0);
  gl_setpalettecolor (SI_RED, 60, 0, 0);
  gl_setpalettecolor (SI_GREEN, 0, 60, 0);
  gl_setpalettecolor (SI_YELLOW, 60, 60, 0);
#endif
#if defined (WIN32)
  UpdatePalette ();
#endif
  for (y = 0; y < 480; y++)
    for (x = 0; x < 640; x++)
      {
	l = gzgetc (fp);
	/*
	   //      printf("l=%d x=%d y=%d ",l,x,y);
	   // octree doesn't seem to want to generate images with 252 colours!
	   // So the next best thing (well the easyest) is to just map the pixels
	   // coloured as the last 4 colours to the 4 before that.
	   // If it looks OK, leave it.
	 */
	if (l == SI_BLACK)
	  l = SI_BLACK - 4;
	if (l == SI_RED)
	  l = SI_RED - 4;
	if (l == SI_GREEN)
	  l = SI_GREEN - 4;
	if (l == SI_YELLOW)
	  l = SI_YELLOW - 4;
	Fgl_setpixel (x, y, l);
      }

  gzclose(fp);

#if defined (WIN32)
  RefreshScreen ();
#endif
  start_image_text ();
}
예제 #20
0
static void InitPalette()
{
	UpdatePalette(0, 256);
}
예제 #21
0
void DrawCredits()
{
	static SDL_Surface *fin = NULL;
	static SDL_Surface *theend[2] = {NULL};
	SDL_Rect draw_to;
	int i;
	int ypos;
	int c;
	int n_credits = sizeof(credits)/sizeof(*credits);
	int finish_point;
	
	finish_point = 400 + (n_credits * 50);
	
	draw_to.x = 384;
	draw_to.y = 352;
	
	SDL_FillRect(screen, NULL, 0);
	
	if (fin == NULL) {
		fin = IMG_Load("dat/i/fin.png");
		
		theend[0] = IMG_Load("dat/i/theend.png");
		theend[1] = IMG_Load("dat/i/true_end.png");
	}
	
	if (credits_scroll >= (finish_point + 80)) {
		SDL_BlitSurface(theend[(player_shield == 30)], NULL, screen, NULL);
	} else {
		SDL_BlitSurface(fin, NULL, screen, &draw_to);
		
		// Show each line of credits
		
		for (i = 0; i < n_credits; i++) {
			ypos = 800 + (i * 100) - credits_scroll * 2;
			
			if ((ypos >= 0)&&(ypos < 480)) {
				c = 255 - abs(ypos - 240);
				draw_text(120, ypos, credits[i], c);
			}
		}
		
	}
	
	for (i = 0; i < 128; i++) {
		ending_pal[i].r = 0;
		ending_pal[i].g = i;
		ending_pal[i].b = i*2;
	}
	for (i = 128; i < 256; i++) {
		ending_pal[i].r = (i - 128)*2+1;
		ending_pal[i].g = i;
		ending_pal[i].b = 255;
	}
	
	// Dim palette if we're just starting
	
	if (credits_scroll < 80) {
		for (i = 0; i < 256; i++) {
			ending_pal[i].r = ending_pal[i].r * credits_scroll / 80;
			ending_pal[i].g = ending_pal[i].g * credits_scroll / 80;
			ending_pal[i].b = ending_pal[i].b * credits_scroll / 80;
		}
	}
	
	// Also palette if we're finishing
	
	if ((credits_scroll >= (finish_point))&&(credits_scroll < (finish_point + 80))) {
		for (i = 0; i < 256; i++) {
			ending_pal[i].r = ending_pal[i].r * (finish_point+80-credits_scroll) / 80;
			ending_pal[i].g = ending_pal[i].g * (finish_point+80-credits_scroll) / 80;
			ending_pal[i].b = ending_pal[i].b * (finish_point+80-credits_scroll) / 80;
		}
	}
	
	if ((credits_scroll >= (finish_point + 80))&&(credits_scroll < (finish_point + 160))) {
		for (i = 0; i < 256; i++) {
			ending_pal[i].r = ending_pal[i].r * (credits_scroll - (finish_point + 80)) / 80;
			ending_pal[i].g = ending_pal[i].g * (credits_scroll - (finish_point + 80)) / 80;
			ending_pal[i].b = ending_pal[i].b * (credits_scroll - (finish_point + 80)) / 80;
		}
	}
	
	credits_scroll++;
	
	UpdatePalette();
	VideoUpdate();
}