void OSystem_Wii::initSize(uint width, uint height, const Graphics::PixelFormat *format) { bool update = false; gfx_tex_format_t tex_format; #ifdef USE_RGB_COLOR Graphics::PixelFormat newFormat; if (format) newFormat = *format; else newFormat = Graphics::PixelFormat::createFormatCLUT8(); if (newFormat.bytesPerPixel > 2) newFormat = Graphics::PixelFormat::createFormatCLUT8(); if (_pfGame != newFormat) { _pfGame = newFormat; update = true; } #endif uint newWidth, newHeight; if (_pfGame.bytesPerPixel > 1) { newWidth = ROUNDUP(width, 4); newHeight = ROUNDUP(height, 4); } else { newWidth = ROUNDUP(width, 8); newHeight = ROUNDUP(height, 4); } if (_gameWidth != newWidth || _gameHeight != newHeight) { assert((newWidth <= 640) && (newHeight <= 480)); if (width != newWidth || height != newHeight) printf("extending texture for compability: %ux%u -> %ux%u\n", width, height, newWidth, newHeight); _gameWidth = newWidth; _gameHeight = newHeight; update = true; } if (_gameRunning) { switchVideoMode(_configGraphicsMode); if (_arCorrection && (_gameWidth == 320) && (_gameHeight == 200)) gfx_set_ar(320.0 / 240.0); else gfx_set_ar(f32(_gameWidth) / f32(_gameHeight)); } if (update) { free(_gamePixels); tex_format = GFX_TF_PALETTE_RGB565; #ifdef USE_RGB_COLOR if (_pfGame.bytesPerPixel > 1) { tex_format = GFX_TF_RGB565; _pfGameTexture = _pfRGB565; } printf("initSize %u*%u*%u (%u%u%u -> %u%u%u match: %d)\n", _gameWidth, _gameHeight, _pfGame.bytesPerPixel * 8, 8 - _pfGame.rLoss, 8 - _pfGame.gLoss, 8 - _pfGame.bLoss, 8 - _pfGameTexture.rLoss, 8 - _pfGameTexture.gLoss, 8 - _pfGameTexture.bLoss, _pfGame == _pfGameTexture); _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight * _pfGame.bytesPerPixel); memset(_gamePixels, 0, _gameWidth * _gameHeight * _pfGame.bytesPerPixel); #else printf("initSize %u*%u\n", _gameWidth, _gameHeight); _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight); memset(_gamePixels, 0, _gameWidth * _gameHeight); #endif if (!gfx_tex_init(&_texGame, tex_format, TLUT_GAME, _gameWidth, _gameHeight)) { printf("could not init the game texture\n"); ::abort(); } gfx_tex_set_bilinear_filter(&_texGame, _bilinearFilter); gfx_coords(&_coordsGame, &_texGame, GFX_COORD_FULLSCREEN); updateScreenResolution(); } }
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(); }
void OSystem_Wii::engineDone() { _gameRunning = false; switchVideoMode(gmStandard); gfx_set_ar(4.0 / 3.0); }