Пример #1
0
void OSystem_Wii::updateScreen() {
	static f32 ar;
	static gfx_screen_coords_t cc;
	static int cs;

	u32 now = getMillis();
	if (now - _lastScreenUpdate < 1000 / MAX_FPS)
		return;

	if (!gfx_frame_start()) {
		printf("last frame not done!\n");
		return;
	}

#ifdef DEBUG_WII_MEMSTATS
	wii_memstats();
#endif

	cs = _cursorScale;
	_lastScreenUpdate = now;

	if (_overlayVisible || _consoleVisible)
		gfx_set_colorop(COLOROP_SIMPLEFADE, gfx_color_none, gfx_color_none);

	if (_gameRunning) {
		if (_gameDirty) {
			gfx_tex_convert(&_texGame, _gamePixels);
			_gameDirty = false;
		}

		gfx_draw_tex(&_texGame, &_coordsGame);
	}

	if (_overlayVisible) {
		if (!_consoleVisible)
			gfx_set_colorop(COLOROP_NONE, gfx_color_none, gfx_color_none);

		if (_gameRunning)
			ar = gfx_set_ar(4.0 / 3.0);

		// ugly, but the modern theme sets a factor of 3, only god knows why
		if (cs > 2)
			cs = 1;
		else
			cs *= 2;

		if (_overlayDirty) {
			gfx_tex_convert(&_texOverlay, _overlayPixels);
			_overlayDirty = false;
		}

		gfx_draw_tex(&_texOverlay, &_coordsOverlay);
	}

	if (_mouseVisible) {
		cc.x = f32(_mouseX - cs * _mouseHotspotX) * _currentXScale;
		cc.y = f32(_mouseY - cs * _mouseHotspotY) * _currentYScale;
		cc.w = f32(_texMouse.width) * _currentXScale * cs;
		cc.h = f32(_texMouse.height) * _currentYScale * cs;

		if (_texMouse.palette && _cursorPaletteDirty) {
			_texMouse.palette[_mouseKeyColor] = 0;
			gfx_tex_flush_palette(&_texMouse);
			_cursorPaletteDirty = false;
		}

		gfx_draw_tex(&_texMouse, &cc);
	}

	if (_consoleVisible)
		gfx_con_draw();

	if (_overlayVisible && _gameRunning)
		gfx_set_ar(ar);

	gfx_frame_end();
}
Пример #2
0
void OSystem_Wii::updateScreen() {
	static u32 x, y, h, skip;
	static s16 msx, msy, mox, moy, mskip;
	static u16 mpx, mpy;
	static u8 *s;
	static u16 *d, *p;

	u32 now = getMillis();
	if (now - _lastScreenUpdate < 1000 / MAX_FPS)
		return;

#ifdef DEBUG_WII_MEMSTATS
	wii_memstats();
#endif

	_lastScreenUpdate = now;

	h = 0;
	if (_overlayVisible) {
		memcpy(_texture, _overlayPixels, _overlaySize);
	} else {
		for (y = 0; y < _gameHeight; ++y) {
			for (x = 0; x < _gameWidth; ++x)
				_texture[h + x] = _palette[_gamePixels[h + x]];

			h += _gameWidth;
		}
	}

	if (_mouseVisible) {
		msx = _mouseX - _mouseHotspotX;
		msy = _mouseY - _mouseHotspotY;
		mox = 0;
		moy = 0;
		mpx = _mouseWidth;
		mpy = _mouseHeight;

		if (msx < 0) {
			mox = -msx;
			mpx -= mox;
			msx = 0;
		} else
			if (msx + mpx > _currentWidth - 1)
				mpx = _currentWidth - msx - 1;

		if (msy < 0) {
			moy = -msy;
			mpy -= moy;
			msy = 0;
		} else
			if (msy + mpy + 1 > _currentHeight - 1)
				mpy = _currentHeight - msy - 1;


		if (_cursorPaletteDisabled)
			p = _palette;
		else
			p = _cursorPalette;

		skip = _currentWidth - mpx;
		mskip = _mouseWidth - mpx;

		s = _mouseCursor + moy * _mouseWidth + mox;
		d = _texture + (msy * _currentWidth + msx);

		for (y = 0; y < mpy; ++y) {
			for (x = 0; x < mpx; ++x) {
				if (*s == _mouseKeyColor) {
					s++;
					d++;

					continue;
				}

				*d++ = p[*s];
				s++;
			}

			d += skip;
			s += mskip;
		}
	}

	GX_Render(_currentWidth, _currentHeight, (u8 *) _texture,
				_currentWidth * 2);
}