Moved the Wii gfx code to its own library. Added a onscreen console for stdout/err, toggable via pad keys.

svn-id: r44189
This commit is contained in:
Andre Heider 2009-09-18 18:56:16 +00:00
parent e1ad748f0d
commit 3e24220a19
10 changed files with 64 additions and 777 deletions

View file

@ -1,633 +0,0 @@
/*
* Gamecube/Wii VIDEO/GX subsystem wrapper
*
* Copyright (C) 2008, 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
*
* This code is licensed to you under the terms of the GNU GPL, version 2;
* see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*
*/
#include <malloc.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "gfx.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FIFO_SIZE (256 * 1024)
#define ORIGIN_Z (-500)
static GXRModeObj *_vm = NULL;
static bool _doublestrike = false;
static u32 *_fb[2] = { NULL, NULL };
static u8 _fb_active = 0;
static u8 *_fifo = NULL;
static u16 _underscan_x = 0;
static u16 _underscan_y = 0;
static f32 _ar = 4.0 / 3.0;
static bool _pillarboxing = false;
static Mtx _view;
static struct {
guVector pos;
guVector up;
guVector view;
} _camera = {
{ 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.5f, 0.0f },
{ 0.0f, 0.0f, -0.5f }
};
// Standard, DS
static GXRModeObj *mode_table[5][2] = {
{ &TVNtsc480Prog, &TVNtsc240Ds },
{ &TVNtsc480IntDf, &TVNtsc240Ds },
{ &TVPal574IntDfScale, &TVPal264Ds },
{ &TVEurgb60Hz480IntDf, &TVEurgb60Hz240Ds },
{ &TVMpal480IntDf, &TVMpal240Ds }
};
gfx_video_standard_t gfx_video_get_standard(void) {
gfx_video_standard_t standard;
#ifdef HW_RVL
if ((CONF_GetProgressiveScan() > 0) && VIDEO_HaveComponentCable()) {
standard = GFX_STANDARD_PROGRESSIVE;
} else {
switch (CONF_GetVideo()) {
case CONF_VIDEO_PAL:
if (CONF_GetEuRGB60() > 0)
standard = GFX_STANDARD_EURGB60;
else
standard = GFX_STANDARD_PAL;
break;
case CONF_VIDEO_MPAL:
standard = GFX_STANDARD_MPAL;
break;
default:
standard = GFX_STANDARD_NTSC;
break;
}
}
#else
switch (VIDEO_GetCurrentTvMode()) {
case VI_PAL:
standard = GFX_STANDARD_PAL;
break;
case VI_MPAL:
standard = GFX_STANDARD_MPAL;
break;
default:
standard = GFX_STANDARD_NTSC;
break;
}
#endif
return standard;
}
void gfx_video_init(gfx_video_standard_t standard, gfx_video_mode_t mode) {
u8 i;
if (standard == GFX_STANDARD_AUTO)
standard = gfx_video_get_standard();
_vm = mode_table[standard][mode];
_vm->viWidth = 672;
_vm->viXOrigin = (VI_MAX_WIDTH_NTSC - _vm->viWidth) / 2;
if (_vm)
VIDEO_WaitVSync();
VIDEO_Configure(_vm);
VIDEO_Flush();
if (_fb[0])
free(MEM_K1_TO_K0(_fb[0]));
if (_fb[1])
free(MEM_K1_TO_K0(_fb[1]));
_fb[0] = (u32 *) MEM_K0_TO_K1(SYS_AllocateFramebuffer(_vm));
_fb[1] = (u32 *) MEM_K0_TO_K1(SYS_AllocateFramebuffer(_vm));
VIDEO_ClearFrameBuffer(_vm, _fb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(_vm, _fb[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer(_fb[_fb_active]);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
for (i = 0; i < 4; ++i)
VIDEO_WaitVSync();
}
void gfx_video_deinit(void) {
u8 i;
VIDEO_WaitVSync();
VIDEO_SetBlack(TRUE);
VIDEO_SetNextFramebuffer(NULL);
VIDEO_Flush();
for (i = 0; i < 4; ++i)
VIDEO_WaitVSync();
if (_fb[0]) {
free(MEM_K1_TO_K0(_fb[0]));
_fb[0] = NULL;
}
if (_fb[1]) {
free(MEM_K1_TO_K0(_fb[1]));
_fb[1] = NULL;
}
}
u16 gfx_video_get_width(void) {
return _vm->fbWidth;
}
u16 gfx_video_get_height(void) {
return _vm->efbHeight;
}
static void _update_viewport(void) {
f32 ar;
u16 correction;
u16 usy = _underscan_y;
if (!_doublestrike)
usy *= 2;
u16 x1 = _underscan_x * 2;
u16 y1 = usy;
u16 x2 = _vm->fbWidth - _underscan_x * 4;
u16 y2 = _vm->efbHeight - usy * 2;
if (_pillarboxing)
ar = 16.0 / 9.0;
else
ar = 4.0 / 3.0;
if (fabs(ar - _ar) > 0.01) {
if (ar > _ar) {
correction = _vm->viWidth -
(u16) round((f32) _vm->viWidth * _ar / ar);
x1 += correction / 2;
x2 -= correction;
} else {
correction = _vm->efbHeight -
(u16) round((f32) _vm->efbHeight * ar / _ar);
if (_doublestrike)
correction /= 2;
y1 += correction / 2;
y2 -= correction;
}
}
GX_SetViewport(x1, y1, x2, y2, 0, 1);
GX_SetScissor(x1, y1, x2, y2);
}
void gfx_init(void) {
Mtx44 p;
GXColor bg = { 0, 0, 0, 0xff };
f32 yscale;
u32 xfbHeight;
GX_AbortFrame();
if (!_fifo)
_fifo = (u8 *) memalign(32, FIFO_SIZE);
memset(_fifo, 0, FIFO_SIZE);
GX_Init(_fifo, FIFO_SIZE);
GX_SetCopyClear(bg, 0x00ffffff);
_update_viewport();
_doublestrike = _vm->viHeight == 2 * _vm->xfbHeight;
yscale = GX_GetYScaleFactor(_vm->efbHeight, _vm->xfbHeight);
xfbHeight = GX_SetDispCopyYScale(yscale);
GX_SetDispCopySrc(0, 0, _vm->fbWidth, _vm->efbHeight);
GX_SetDispCopyDst(_vm->fbWidth, xfbHeight);
GX_SetCopyFilter(_vm->aa, _vm->sample_pattern, GX_TRUE, _vm->vfilter);
GX_SetFieldMode(_vm->field_rendering, _doublestrike ? GX_ENABLE : GX_DISABLE);
if (_vm->aa)
GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
else
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
GX_SetCullMode(GX_CULL_NONE);
GX_SetDispCopyGamma(GX_GM_1_0);
GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_InvVtxCache();
GX_InvalidateTexAll();
memset(&_view, 0, sizeof(Mtx));
guLookAt(_view, &_camera.pos, &_camera.up, &_camera.view);
guOrtho(p, 0, _vm->efbHeight, 0, _vm->fbWidth, 100, 1000);
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
GX_Flush();
}
void gfx_deinit(void) {
GX_AbortFrame();
free(_fifo);
_fifo = NULL;
}
void gfx_set_underscan(u16 underscan_x, u16 underscan_y) {
_underscan_x = underscan_x;
_underscan_y = underscan_y;
if (_underscan_x > 32)
_underscan_x = 32;
if (_underscan_y > 32)
_underscan_y = 32;
_update_viewport();
GX_Flush();
}
void gfx_set_ar(f32 ar) {
_ar = ar;
if (ar < 16.0 / 480.0)
ar = 16.0 / 480.0;
if (ar > 640.0 / 16.0)
ar = 640.0 / 16.0;
_update_viewport();
GX_Flush();
}
void gfx_set_pillarboxing(bool enable) {
_pillarboxing = enable;
_update_viewport();
GX_Flush();
}
bool gfx_tex_init(gfx_tex_t *tex, gfx_tex_format_t format, u32 tlut_name,
u16 width, u16 height) {
u8 bpp;
u8 fmt_tex;
bool tlut;
u8 fmt_tlut;
u32 ax, ay;
u32 memsize;
if (!tex)
return false;
switch(format) {
case GFX_TF_RGB565:
bpp = 2;
fmt_tex = GX_TF_RGB565;
tlut = false;
fmt_tlut = 0;
ax = 3;
ay = 3;
break;
case GFX_TF_RGB5A3:
bpp = 2;
fmt_tex = GX_TF_RGB5A3;
tlut = false;
fmt_tlut = 0;
ax = 3;
ay = 3;
break;
case GFX_TF_PALETTE_RGB565:
bpp = 1;
fmt_tex = GX_TF_CI8;
tlut = true;
fmt_tlut = GX_TL_RGB565;
ax = 7;
ay = 3;
break;
case GFX_TF_PALETTE_RGB5A3:
bpp = 1;
fmt_tex = GX_TF_CI8;
tlut = true;
fmt_tlut = GX_TL_RGB5A3;
ax = 7;
ay = 3;
break;
default:
gfx_tex_deinit(tex);
return false;
}
if ((width & ax) || (height & ay)) {
gfx_tex_deinit(tex);
return false;
}
if (tlut) {
if (!tex->palette) {
tex->palette = (u16 *) memalign(32, 256 * 2);
if (!tex->palette) {
gfx_tex_deinit(tex);
return false;
}
memset(tex->palette, 0, 256 * 2);
DCFlushRange(tex->palette, 256 * 2);
}
tex->tlut_name = tlut_name;
GX_InitTlutObj(&tex->tlut, tex->palette, fmt_tlut, 256);
} else {
tex->tlut_name = 0;
free(tex->palette);
tex->palette = NULL;
}
if (!tex->pixels || (width != tex->width) || (height != tex->height ||
bpp != tex->bpp)) {
free(tex->pixels);
memsize = width * height * bpp;
tex->pixels = memalign(32, memsize);
if (!tex->pixels) {
gfx_tex_deinit(tex);
return false;
}
memset(tex->pixels, 0, memsize);
DCFlushRange(tex->pixels, memsize);
}
tex->format = format;
tex->width = width;
tex->height = height;
tex->bpp = bpp;
if (tlut) {
GX_LoadTlut(&tex->tlut, tlut_name);
GX_InitTexObjCI(&tex->obj, tex->pixels, width, height, fmt_tex,
GX_CLAMP, GX_CLAMP, GX_FALSE, tlut_name);
} else {
GX_InitTexObj(&tex->obj, tex->pixels, width, height, fmt_tex,
GX_CLAMP, GX_CLAMP, GX_FALSE);
}
return true;
}
void gfx_tex_deinit(gfx_tex_t *tex) {
if (!tex)
return;
free(tex->pixels);
free(tex->palette);
memset(tex, 0, sizeof(gfx_tex_t));
}
void gfx_coords(gfx_coords_t *coords, gfx_tex_t *tex, gfx_coord_t type) {
if (!coords || !tex)
return;
switch(type) {
case GFX_COORD_FULLSCREEN:
coords->x = 0.0;
coords->y = 0.0;
coords->w = _vm->fbWidth;
coords->h = _vm->efbHeight;
break;
case GFX_COORD_CENTER:
coords->x = (_vm->fbWidth - tex->width) / 2;
coords->y = (_vm->efbHeight - tex->height) / 2;
coords->w = tex->width;
coords->h = tex->height;
break;
default:
break;
}
}
bool gfx_tex_set_bilinear_filter(gfx_tex_t *tex, bool enable) {
if (!tex)
return false;
if (enable) {
if (tex->palette)
GX_InitTexObjFilterMode(&tex->obj, GX_LIN_MIP_NEAR, GX_LINEAR);
else
GX_InitTexObjFilterMode(&tex->obj, GX_LIN_MIP_LIN, GX_LINEAR);
} else {
GX_InitTexObjFilterMode(&tex->obj, GX_NEAR, GX_NEAR);
}
return true;
}
bool gfx_tex_flush_texture(gfx_tex_t *tex) {
if (!tex)
return false;
DCFlushRange(tex->pixels, tex->width * tex->height * tex->bpp);
return true;
}
bool gfx_tex_flush_palette(gfx_tex_t *tex) {
if (!tex || !tex->palette)
return false;
DCFlushRange(tex->palette, 256 * 2);
GX_LoadTlut(&tex->tlut, tex->tlut_name);
return true;
}
bool gfx_tex_clear_palette(gfx_tex_t *tex) {
if (!tex || !tex->palette)
return false;
memset(tex->palette, 0, 256 * 2);
DCFlushRange(tex->palette, 256 * 2);
GX_LoadTlut(&tex->tlut, tex->tlut_name);
return true;
}
bool gfx_tex_convert(gfx_tex_t *tex, const void *src) {
bool ret;
u16 w, h, x, y;
u64 *dst, *src1, *src2, *src3, *src4;
u16 rowpitch;
u16 pitch;
const u8 *s = (const u8 *) src;
if (!tex)
return false;
ret = false;
w = tex->width;
h = tex->height;
switch(tex->format) {
case GFX_TF_RGB565:
case GFX_TF_RGB5A3:
pitch = w * 2;
dst = (u64 *) tex->pixels;
src1 = (u64 *) s;
src2 = (u64 *) (s + pitch);
src3 = (u64 *) (s + (pitch * 2));
src4 = (u64 *) (s + (pitch * 3));
rowpitch = (pitch >> 3) * 3 + pitch % 8;
for (y = 0; y < h; y += 4) {
for (x = 0; x < (w >> 2); x++) {
*dst++ = *src1++;
*dst++ = *src2++;
*dst++ = *src3++;
*dst++ = *src4++;
}
src1 += rowpitch;
src2 += rowpitch;
src3 += rowpitch;
src4 += rowpitch;
}
ret = true;
break;
case GFX_TF_PALETTE_RGB565:
case GFX_TF_PALETTE_RGB5A3:
pitch = w;
dst = (u64 *) tex->pixels;
src1 = (u64 *) s;
src2 = (u64 *) (s + pitch);
src3 = (u64 *) (s + (pitch * 2));
src4 = (u64 *) (s + (pitch * 3));
rowpitch = (pitch >> 3) * 3 + pitch % 8;
for (y = 0; y < h; y += 4) {
for (x = 0; x < (w >> 3); x++) {
*dst++ = *src1++;
*dst++ = *src2++;
*dst++ = *src3++;
*dst++ = *src4++;
}
src1 += rowpitch;
src2 += rowpitch;
src3 += rowpitch;
src4 += rowpitch;
}
ret = true;
break;
default:
break;
}
if (ret)
DCFlushRange(tex->pixels, w * h * tex->bpp);
return ret;
}
void gfx_frame_start(void) {
GX_InvVtxCache();
GX_InvalidateTexAll();
GX_SetNumChans(1);
GX_SetNumTexGens(1);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP);
}
void gfx_frame_end(void) {
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(_fb[_fb_active], GX_TRUE);
GX_Flush();
GX_DrawDone();
VIDEO_SetNextFramebuffer(_fb[_fb_active]);
VIDEO_Flush();
VIDEO_WaitVSync();
_fb_active ^= 1;
}
static void _tex_vert(f32 x, f32 y, f32 z, f32 s, f32 t, u32 c) {
GX_Position3f32(x, y, z);
GX_Color1u32(c);
GX_TexCoord2f32(s, t);
}
void gfx_draw_tex(gfx_tex_t *tex, gfx_coords_t *coords) {
Mtx m;
Mtx mv;
if (!tex || !coords)
return;
GX_LoadTexObj(&tex->obj, GX_TEXMAP0);
guMtxIdentity(m);
guMtxTrans(m, coords->x, coords->y, ORIGIN_Z);
guMtxConcat(_view, m, mv);
GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
_tex_vert(0.0, 0.0, 0.0, 0.0, 0.0, 0xffffffff);
_tex_vert(coords->w, 0.0, 0.0, 1.0, 0.0, 0xffffffff);
_tex_vert(coords->w, coords->h, 0.0, 1.0, 1.0, 0xffffffff);
_tex_vert(0.0, coords->h, 0.0, 0.0, 1.0, 0xffffffff);
GX_End();
}
#ifdef __cplusplus
}
#endif

View file

@ -1,102 +0,0 @@
/*
* Gamecube/Wii VIDEO/GX subsystem wrapper
*
* Copyright (C) 2008, 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
*
* This code is licensed to you under the terms of the GNU GPL, version 2;
* see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*
*/
#ifndef __GFX_H__
#define __GFX_H__
#include <gccore.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
GFX_STANDARD_AUTO = -1,
GFX_STANDARD_PROGRESSIVE = 0,
GFX_STANDARD_NTSC,
GFX_STANDARD_PAL,
GFX_STANDARD_EURGB60,
GFX_STANDARD_MPAL
} gfx_video_standard_t;
typedef enum {
GFX_MODE_DEFAULT = 0,
GFX_MODE_DS,
} gfx_video_mode_t;
typedef enum {
GFX_TF_RGB565 = 0,
GFX_TF_RGB5A3,
GFX_TF_PALETTE_RGB565,
GFX_TF_PALETTE_RGB5A3
} gfx_tex_format_t;
typedef struct {
void *pixels;
u16 *palette;
gfx_tex_format_t format;
u16 width;
u16 height;
u8 bpp;
GXTexObj obj;
GXTlutObj tlut;
u32 tlut_name;
} gfx_tex_t;
typedef enum {
GFX_COORD_FULLSCREEN = 0,
GFX_COORD_CENTER
} gfx_coord_t;
typedef struct {
f32 x, y;
f32 w, h;
} gfx_coords_t;
gfx_video_standard_t gfx_video_get_standard(void);
void gfx_video_init(gfx_video_standard_t standard, gfx_video_mode_t mode);
void gfx_video_deinit(void);
u16 gfx_video_get_width(void);
u16 gfx_video_get_height(void);
void gfx_init(void);
void gfx_deinit(void);
void gfx_set_underscan(u16 underscan_x, u16 underscan_y);
void gfx_set_ar(f32 ar);
void gfx_set_pillarboxing(bool enable);
bool gfx_tex_init(gfx_tex_t *tex, gfx_tex_format_t format, u32 tlut_name,
u16 width, u16 height);
void gfx_tex_deinit(gfx_tex_t *tex);
void gfx_coords(gfx_coords_t *coords, gfx_tex_t *tex, gfx_coord_t type);
bool gfx_tex_set_bilinear_filter(gfx_tex_t *tex, bool enable);
bool gfx_tex_flush_texture(gfx_tex_t *tex);
bool gfx_tex_flush_palette(gfx_tex_t *tex);
bool gfx_tex_clear_palette(gfx_tex_t *tex);
bool gfx_tex_convert(gfx_tex_t *tex, const void *src);
void gfx_frame_start(void);
void gfx_frame_end(void);
void gfx_draw_tex(gfx_tex_t *tex, gfx_coords_t *coords);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -24,20 +24,18 @@
#include <errno.h>
#include <unistd.h>
#include <ogc/machine/processor.h>
#include <fat.h>
#include "osystem.h"
#include <ogc/machine/processor.h>
#include <fat.h>
#ifdef USE_WII_DI
#include <di/di.h>
#endif
#ifdef DEBUG_WII_GDB
#include <debug.h>
#endif
#include "gfx.h"
#include <gfx/gfx.h>
#include <gfx/gfx_con.h>
#ifdef __cplusplus
extern "C" {
@ -93,9 +91,9 @@ int main(int argc, char *argv[]) {
PAD_Init();
AUDIO_Init(NULL);
#ifdef DEBUG_WII_USBGECKO
CON_EnableGecko(1, false);
#endif
gfx_video_init(GFX_STANDARD_AUTO, GFX_MODE_DEFAULT);
gfx_init();
gfx_con_init(NULL);
#ifdef DEBUG_WII_GDB
DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
@ -146,6 +144,8 @@ int main(int argc, char *argv[]) {
printf("reloading\n");
gfx_con_deinit();
gfx_deinit();
gfx_video_deinit();
return res;

View file

@ -2,7 +2,6 @@ MODULE := backends/platform/wii
MODULE_OBJS := \
main.o \
gfx.o \
options.o \
osystem.o \
osystem_gfx.o \

View file

@ -21,6 +21,7 @@
*/
#include <network.h>
#include <gfx/gfx.h>
#include "common/config-manager.h"
#include "gui/dialog.h"
@ -28,7 +29,6 @@
#include "backends/fs/wii/wii-fs-factory.h"
#include "options.h"
#include "gfx.h"
WiiOptionsDialog::WiiOptionsDialog(bool doubleStrike) :
Dialog((640 - 400) / 2, (480 - 340) / 2, 400, 340),

View file

@ -19,17 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <unistd.h>
#include <ogc/mutex.h>
#include <ogc/lwp_watchdog.h>
#include "common/config-manager.h"
#include "backends/fs/wii/wii-fs-factory.h"
#include "osystem.h"
#include "options.h"
#include <unistd.h>
#include <ogc/mutex.h>
#include <ogc/lwp_watchdog.h>
OSystem_Wii::OSystem_Wii() :
_startup_time(0),
@ -69,6 +69,7 @@ OSystem_Wii::OSystem_Wii() :
#endif
_optionsDlgActive(false),
_consoleVisible(false),
_fullscreen(false),
_arCorrection(false),

View file

@ -22,6 +22,12 @@
#ifndef _WII_OSYSTEM_H_
#define _WII_OSYSTEM_H_
#include <gctypes.h>
#include <gccore.h>
#include <ogcsys.h>
#include <gfx/gfx.h>
#include "base/main.h"
#include "common/fs.h"
#include "common/rect.h"
@ -33,12 +39,6 @@
#include "graphics/surface.h"
#include "sound/mixer_intern.h"
#include "gfx.h"
#include <gctypes.h>
#include <gccore.h>
#include <ogcsys.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -67,7 +67,7 @@ private:
u16 _gameWidth, _gameHeight;
u8 *_gamePixels;
Graphics::Surface _surface;
gfx_coords_t _coordsGame;
gfx_screen_coords_t _coordsGame;
gfx_tex_t _texGame;
bool _gameDirty;
@ -75,7 +75,7 @@ private:
u16 _overlayWidth, _overlayHeight;
u32 _overlaySize;
OverlayColor *_overlayPixels;
gfx_coords_t _coordsOverlay;
gfx_screen_coords_t _coordsOverlay;
gfx_tex_t _texOverlay;
bool _overlayDirty;
@ -94,6 +94,7 @@ private:
Graphics::PixelFormat _pfCursor;
#endif
bool _consoleVisible;
bool _optionsDlgActive;
bool _fullscreen;
bool _arCorrection;

View file

@ -24,6 +24,7 @@
#include "osystem.h"
#include <ogc/lwp_watchdog.h>
#ifndef GAMECUBE
#include <wiiuse/wpad.h>
#endif
@ -31,8 +32,6 @@
#include <wiikeyboard/keyboard.h>
#endif
#include <ogc/lwp_watchdog.h>
#define TIMER_THREAD_STACKSIZE (1024 * 32)
#define TIMER_THREAD_PRIO 64
@ -322,6 +321,12 @@ bool OSystem_Wii::pollEvent(Common::Event &event) {
if (bh & PADS_UP) {
PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5,
Common::KBD_CTRL);
if (bd & PADS_R) {
_consoleVisible = !_consoleVisible;
return false;
}
flags = Common::KBD_SHIFT;
}

View file

@ -21,12 +21,14 @@
#include <malloc.h>
#include <gfx/gfx.h>
#include <gfx/gfx_con.h>
#include "common/config-manager.h"
#include "graphics/conversion.h"
#include "backends/fs/wii/wii-fs-factory.h"
#include "osystem.h"
#include "gfx.h"
#define ROUNDUP(x,n) (-(-(x) & -(n)))
#define MAX_FPS 30
@ -58,8 +60,6 @@ static const OSystem::GraphicsMode _supportedGraphicsModes[] = {
};
void OSystem_Wii::initGfx() {
gfx_video_init(GFX_STANDARD_AUTO, GFX_MODE_DEFAULT);
gfx_init();
gfx_set_underscan(ConfMan.getInt("wii_video_default_underscan_x"),
ConfMan.getInt("wii_video_default_underscan_y"));
@ -96,8 +96,6 @@ void OSystem_Wii::initGfx() {
}
void OSystem_Wii::deinitGfx() {
gfx_deinit();
gfx_tex_deinit(&_texMouse);
gfx_tex_deinit(&_texGame);
gfx_tex_deinit(&_texOverlay);
@ -429,13 +427,19 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
void OSystem_Wii::updateScreen() {
static gfx_coords_t cc;
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
@ -443,8 +447,8 @@ void OSystem_Wii::updateScreen() {
cs = _cursorScale;
_lastScreenUpdate = now;
gfx_frame_start();
if (_overlayVisible || _consoleVisible)
gfx_set_colorop(COLOROP_SIMPLEFADE, gfx_color_none, gfx_color_none);
if (_gameRunning) {
if (_gameDirty) {
@ -456,6 +460,12 @@ void OSystem_Wii::updateScreen() {
}
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;
@ -485,6 +495,12 @@ void OSystem_Wii::updateScreen() {
gfx_draw_tex(&_texMouse, &cc);
}
if (_consoleVisible)
gfx_con_draw();
if (_overlayVisible && _gameRunning)
gfx_set_ar(ar);
gfx_frame_end();
}
@ -649,7 +665,7 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX,
if (!tmpBuf) {
gfx_tex_convert(&_texMouse, buf);
} else {
u8 bpp = _texMouse.bpp;
u8 bpp = _texMouse.bpp >> 3;
byte *tmp = (byte *) malloc(tw * th * bpp);
if (!tmp) {
@ -668,7 +684,7 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX,
tw * _pfRGB3444.bytesPerPixel,
w * _pfCursor.bytesPerPixel,
tw, th, _pfRGB3444, _pfCursor)) {
printf("crossBlit failed\n");
printf("crossBlit failed (cursor)\n");
::abort();
}

12
configure vendored
View file

@ -1208,14 +1208,14 @@ case $_host_os in
wii)
CXXFLAGS="$CXXFLAGS -Os -mrvl -mcpu=750 -meabi -mhard-float"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fmodulo-sched"
CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include"
LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -L$DEVKITPRO/libogc/lib/wii"
CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include -I$DEVKITPRO/wii/include"
LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -L$DEVKITPRO/libogc/lib/wii -L$DEVKITPRO/wii/lib"
;;
gamecube)
CXXFLAGS="$CXXFLAGS -Os -mogc -mcpu=750 -meabi -mhard-float"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fmodulo-sched"
CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include"
LDFLAGS="$LDFLAGS -mogc -mcpu=750 -L$DEVKITPRO/libogc/lib/cube"
CXXFLAGS="$CXXFLAGS -I$DEVKITPRO/libogc/include -I$DEVKITPRO/cube/include"
LDFLAGS="$LDFLAGS -mogc -mcpu=750 -L$DEVKITPRO/libogc/lib/cube -L$DEVKITPRO/cube/lib"
;;
nds)
# TODO nds
@ -2186,10 +2186,10 @@ case $_backend in
DEFINES="$DEFINES -D__WII__ -DGEKKO"
case $_host_os in
gamecube)
LIBS="$LIBS -lfat -logc -ldb"
LIBS="$LIBS -lgxflux -lfat -logc -ldb"
;;
*)
LIBS="$LIBS -ldi -ltinysmb -lfat -lwiiuse -lbte -logc -lwiikeyboard -ldb"
LIBS="$LIBS -lgxflux -ldi -ltinysmb -lfat -lwiiuse -lbte -logc -lwiikeyboard -ldb"
;;
esac
;;