2008-09-02 03:57:21 +02:00
/****************************************************************************
* FCE Ultra 0.98 .12
* Nintendo Wii / Gamecube Port
*
2009-03-28 18:23:08 +01:00
* Tantric 2008 - 2009
2008-09-02 03:57:21 +02:00
*
2009-03-28 18:23:08 +01:00
* gcvideo . cpp
2008-09-02 03:57:21 +02:00
*
* Video rendering
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include <gccore.h>
2008-10-18 17:58:54 +02:00
# include <unistd.h>
2008-09-02 03:57:21 +02:00
# include <ogcsys.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <wiiuse/wpad.h>
2009-03-28 18:23:08 +01:00
# include <malloc.h>
2008-09-02 03:57:21 +02:00
2008-10-08 06:53:06 +02:00
# include "driver.h"
2008-09-02 03:57:21 +02:00
# include "gcvideo.h"
2008-11-17 01:09:31 +01:00
# include "fceugx.h"
2009-03-28 18:23:08 +01:00
# include "menu.h"
# include "pad.h"
2009-04-13 10:43:20 +02:00
# include "gui/gui.h"
2008-09-02 03:57:21 +02:00
2009-01-25 07:53:21 +01:00
extern " C " {
2008-11-05 09:36:01 +01:00
extern void FCEU_ResetPalette ( void ) ;
2009-01-25 07:53:21 +01:00
}
2008-11-05 09:36:01 +01:00
2008-10-08 06:53:06 +02:00
int FDSTimer = 0 ;
2008-11-04 09:28:52 +01:00
u32 FrameTimer = 0 ;
2008-10-08 06:53:06 +02:00
int FDSSwitchRequested ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
/*** External 2D Video ***/
/*** 2D Video Globals ***/
2008-12-30 01:05:57 +01:00
static GXRModeObj * vmode ; // Graphics Mode Object
2009-04-06 08:30:47 +02:00
static unsigned int * xfb [ 2 ] ; // Framebuffers
static int whichfb = 0 ; // Frame buffer toggle
2008-09-02 03:57:21 +02:00
int screenheight ;
2009-03-28 18:23:08 +01:00
int screenwidth ;
2009-04-06 08:30:47 +02:00
bool progressive = false ;
2009-04-22 20:15:36 +02:00
static int currentVideoMode = - 1 ; // -1 - not set, 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz)
2008-10-23 10:18:40 +02:00
/*** 3D GX ***/
2008-10-25 17:58:59 +02:00
# define TEX_WIDTH 256
# define TEX_HEIGHT 240
2008-10-23 10:18:40 +02:00
# define DEFAULT_FIFO_SIZE ( 256 * 1024 )
static u8 gp_fifo [ DEFAULT_FIFO_SIZE ] ATTRIBUTE_ALIGN ( 32 ) ;
2008-10-25 17:58:59 +02:00
static u32 copynow = GX_FALSE ;
static GXTexObj texobj ;
static Mtx view ;
2009-03-28 18:23:08 +01:00
static Mtx GXmodelView2D ;
2008-10-23 10:18:40 +02:00
/*** Texture memory ***/
static unsigned char texturemem [ TEX_WIDTH * TEX_HEIGHT * 2 ] ATTRIBUTE_ALIGN ( 32 ) ;
2008-10-25 17:58:59 +02:00
static int updateScaling = 1 ;
static int vmode_60hz = 0 ;
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
u8 * gameScreenTex = NULL ; // a GX texture screen capture of the game
u8 * gameScreenTex2 = NULL ; // a GX texture screen capture of the game (copy)
2008-10-23 10:18:40 +02:00
# define HASPECT 256
# define VASPECT 240
// Need something to hold the PC palette
2008-09-02 03:57:21 +02:00
struct pcpal {
unsigned char r ;
unsigned char g ;
unsigned char b ;
} pcpalette [ 256 ] ;
2008-12-30 01:05:57 +01:00
static unsigned int gcpalette [ 256 ] ; // Much simpler GC palette
static unsigned short rgb565 [ 256 ] ; // Texture map palette
2008-10-22 01:07:16 +02:00
2008-12-30 01:05:57 +01:00
static long long prev ;
static long long now ;
2008-10-22 01:07:16 +02:00
2009-01-25 07:53:21 +01:00
extern " C "
{
2008-10-22 01:07:16 +02:00
long long gettime ( ) ;
u32 diff_usec ( long long start , long long end ) ;
2009-01-25 07:53:21 +01:00
}
2008-10-22 01:07:16 +02:00
2008-10-23 10:18:40 +02:00
/* New texture based scaler */
typedef struct tagcamera
{
Vector pos ;
Vector up ;
Vector view ;
}
camera ;
/*** Square Matrix
This structure controls the size of the image on the screen .
Think of the output as a - 80 x 80 by - 60 x 60 graph .
* * */
2008-12-30 01:05:57 +01:00
static s16 square [ ] ATTRIBUTE_ALIGN ( 32 ) =
2008-10-23 10:18:40 +02:00
{
/*
* X , Y , Z
* Values set are for roughly 4 : 3 aspect
*/
2008-11-04 09:28:52 +01:00
- HASPECT , VASPECT , 0 , // 0
HASPECT , VASPECT , 0 , // 1
2008-10-23 10:18:40 +02:00
HASPECT , - VASPECT , 0 , // 2
2008-11-04 09:28:52 +01:00
- HASPECT , - VASPECT , 0 // 3
2008-10-23 10:18:40 +02:00
} ;
static camera cam = { { 0.0F , 0.0F , 0.0F } ,
{ 0.0F , 0.5F , 0.0F } ,
{ 0.0F , 0.0F , - 0.5F }
} ;
/***
* * * Custom Video modes ( used to emulate original console video modes )
* * */
/** Original NES PAL Resolutions: **/
/* 240 lines progressive (PAL 50Hz) */
2008-12-30 01:05:57 +01:00
static GXRModeObj PAL_240p =
2008-10-23 10:18:40 +02:00
{
VI_TVMODE_PAL_DS , // viDisplayMode
2008-10-25 17:58:59 +02:00
640 , // fbWidth
2008-10-23 10:18:40 +02:00
240 , // efbHeight
240 , // xfbHeight
( VI_MAX_WIDTH_PAL - 640 ) / 2 , // viXOrigin
2008-10-24 18:11:51 +02:00
( VI_MAX_HEIGHT_PAL - 480 ) / 2 , // viYOrigin
2008-10-23 10:18:40 +02:00
640 , // viWidth
480 , // viHeight
VI_XFBMODE_SF , // xFBmode
GX_FALSE , // field_rendering
GX_FALSE , // aa
// sample points arranged in increasing Y order
{
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 0, 3 sample points, 1/12 units, 4 bits each
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 1
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 2
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } // pix 3
} ,
// vertical filter[7], 1/64 units, 6 bits each
{
0 , // line n-1
0 , // line n-1
21 , // line n
22 , // line n
21 , // line n
0 , // line n+1
0 // line n+1
}
} ;
/** Original NES NTSC Resolutions: **/
/* 240 lines progressive (NTSC or PAL 60Hz) */
2008-12-30 01:05:57 +01:00
static GXRModeObj NTSC_240p =
2008-10-23 10:18:40 +02:00
{
VI_TVMODE_EURGB60_DS , // viDisplayMode
2008-10-25 17:58:59 +02:00
640 , // fbWidth
2008-10-23 10:18:40 +02:00
240 , // efbHeight
240 , // xfbHeight
( VI_MAX_WIDTH_NTSC - 640 ) / 2 , // viXOrigin
2008-10-24 18:11:51 +02:00
( VI_MAX_HEIGHT_NTSC - 480 ) / 2 , // viYOrigin
2008-10-23 10:18:40 +02:00
640 , // viWidth
480 , // viHeight
VI_XFBMODE_SF , // xFBmode
GX_FALSE , // field_rendering
GX_FALSE , // aa
// sample points arranged in increasing Y order
{
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 0, 3 sample points, 1/12 units, 4 bits each
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 1
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } , // pix 2
{ 6 , 6 } , { 6 , 6 } , { 6 , 6 } // pix 3
} ,
// vertical filter[7], 1/64 units, 6 bits each
{
0 , // line n-1
0 , // line n-1
21 , // line n
22 , // line n
21 , // line n
0 , // line n+1
0 // line n+1
}
} ;
/* TV Modes table */
2008-12-30 01:05:57 +01:00
static GXRModeObj * tvmodes [ 2 ] = {
2008-10-25 17:58:59 +02:00
& NTSC_240p , & PAL_240p
2008-10-23 10:18:40 +02:00
} ;
2008-10-22 01:07:16 +02:00
/****************************************************************************
* setFrameTimer ( )
* change frame timings depending on whether ROM is NTSC or PAL
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-01-25 07:53:21 +01:00
static long long normaldiff ;
2008-10-22 01:07:16 +02:00
void setFrameTimer ( )
{
if ( GCSettings . timing = = 1 ) // PAL
normaldiff = 20000 ; // 50hz
else
normaldiff = 16667 ; // 60hz
prev = gettime ( ) ;
}
2008-12-30 01:05:57 +01:00
static void SyncSpeed ( )
2008-10-22 01:07:16 +02:00
{
now = gettime ( ) ;
2009-01-25 07:53:21 +01:00
while ( diff_usec ( prev , now ) < normaldiff )
now = gettime ( ) ;
2008-10-22 01:07:16 +02:00
prev = now ;
}
2008-09-02 03:57:21 +02:00
2008-10-18 17:58:54 +02:00
/****************************************************************************
* VideoThreading
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define TSTACK 16384
2008-12-30 01:05:57 +01:00
static lwpq_t videoblankqueue ;
2009-04-06 08:30:47 +02:00
static lwp_t vbthread = LWP_THREAD_NULL ;
2008-10-18 17:58:54 +02:00
static unsigned char vbstack [ TSTACK ] ;
/****************************************************************************
* vbgetback
*
2008-10-23 10:18:40 +02:00
* This callback enables the emulator to keep running while waiting for a
* vertical blank .
2008-10-18 17:58:54 +02:00
*
* Putting LWP to good use : )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void *
vbgetback ( void * arg )
{
while ( 1 )
{
2009-04-06 09:27:40 +02:00
VIDEO_WaitVSync ( ) ;
SyncSpeed ( ) ;
2008-10-18 17:58:54 +02:00
LWP_SuspendThread ( vbthread ) ;
}
return NULL ;
}
/****************************************************************************
* InitVideoThread
*
* libOGC provides a nice wrapper for LWP access .
* This function sets up a new local queue and attaches the thread to it .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
InitVideoThread ( )
{
/*** Initialise a new queue ***/
LWP_InitQueue ( & videoblankqueue ) ;
/*** Create the thread on this queue ***/
2009-04-06 09:27:40 +02:00
LWP_CreateThread ( & vbthread , vbgetback , NULL , vbstack , TSTACK , 100 ) ;
2008-10-18 17:58:54 +02:00
}
2008-09-02 03:57:21 +02:00
/****************************************************************************
2008-10-23 10:18:40 +02:00
* copy_to_xfb
*
* Stock code to copy the GX buffer to the current display mode .
* Also increments the frameticker , as it ' s called for each vb .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-06 08:33:34 +02:00
static inline void
2008-10-23 10:18:40 +02:00
copy_to_xfb ( u32 arg )
2008-10-18 17:58:54 +02:00
{
2008-10-23 10:18:40 +02:00
if ( copynow = = GX_TRUE )
{
2009-05-25 08:48:28 +02:00
if ( ScreenshotRequested )
{
TakeScreenshot ( ) ;
ScreenshotRequested = 0 ;
ConfigRequested = 1 ;
}
2008-10-23 10:18:40 +02:00
GX_CopyDisp ( xfb [ whichfb ] , GX_TRUE ) ;
GX_Flush ( ) ;
2008-10-21 09:50:37 +02:00
copynow = GX_FALSE ;
2008-10-23 10:18:40 +02:00
}
2008-11-04 09:28:52 +01:00
FrameTimer + + ;
2008-10-23 10:18:40 +02:00
// FDS switch disk requested - need to eject, select, and insert
// but not all at once!
if ( FDSSwitchRequested )
{
switch ( FDSSwitchRequested )
{
2008-10-08 06:53:06 +02:00
case 1 :
FCEUI_FDSEject ( ) ; // eject disk
FDSSwitchRequested + + ;
break ;
case 2 :
2008-10-09 06:44:23 +02:00
if ( FDSTimer > 60 )
2008-10-08 06:53:06 +02:00
{
FCEUI_FDSSelect ( ) ; // select other side
FCEUI_FDSInsert ( 0 ) ; // insert disk
FDSSwitchRequested = 0 ;
FDSTimer = 0 ;
}
break ;
2008-10-23 10:18:40 +02:00
}
FDSTimer + + ;
}
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
2008-10-23 10:18:40 +02:00
* Scaler Support Functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-06 08:33:34 +02:00
static inline void
2008-10-23 10:18:40 +02:00
draw_init ( )
2008-10-18 17:58:54 +02:00
{
2008-10-23 10:18:40 +02:00
GX_ClearVtxDesc ( ) ;
GX_SetVtxDesc ( GX_VA_POS , GX_INDEX8 ) ;
GX_SetVtxDesc ( GX_VA_CLR0 , GX_INDEX8 ) ;
GX_SetVtxDesc ( GX_VA_TEX0 , GX_DIRECT ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetVtxAttrFmt ( GX_VTXFMT0 , GX_VA_POS , GX_POS_XYZ , GX_S16 , 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 ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetArray ( GX_VA_POS , square , 3 * sizeof ( s16 ) ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetNumTexGens ( 1 ) ;
GX_SetNumChans ( 0 ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetTexCoordGen ( GX_TEXCOORD0 , GX_TG_MTX2x4 , GX_TG_TEX0 , GX_IDENTITY ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetTevOp ( GX_TEVSTAGE0 , GX_REPLACE ) ;
GX_SetTevOrder ( GX_TEVSTAGE0 , GX_TEXCOORD0 , GX_TEXMAP0 , GX_COLORNULL ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
memset ( & view , 0 , sizeof ( Mtx ) ) ;
guLookAt ( view , & cam . pos , & cam . up , & cam . view ) ;
GX_LoadPosMtxImm ( view , GX_PNMTX0 ) ;
2008-10-27 14:49:35 +01:00
2008-10-27 23:33:18 +01:00
GX_InvVtxCache ( ) ; // update vertex cache
2008-10-23 10:18:40 +02:00
}
2008-09-02 03:57:21 +02:00
2009-05-06 08:33:34 +02:00
static inline void
2008-10-23 10:18:40 +02:00
draw_vert ( u8 pos , u8 c , f32 s , f32 t )
{
GX_Position1x8 ( pos ) ;
GX_Color1x8 ( c ) ;
GX_TexCoord2f32 ( s , t ) ;
}
2008-09-02 03:57:21 +02:00
2009-05-06 08:33:34 +02:00
static inline void
2008-10-23 10:18:40 +02:00
draw_square ( Mtx v )
{
Mtx m ; // model matrix.
Mtx mv ; // modelview matrix.
guMtxIdentity ( m ) ;
guMtxTransApply ( m , m , 0 , 0 , - 100 ) ;
guMtxConcat ( v , m , mv ) ;
GX_LoadPosMtxImm ( mv , GX_PNMTX0 ) ;
GX_Begin ( GX_QUADS , GX_VTXFMT0 , 4 ) ;
draw_vert ( 0 , 0 , 0.0 , 0.0 ) ;
draw_vert ( 1 , 0 , 1.0 , 0.0 ) ;
draw_vert ( 2 , 0 , 1.0 , 1.0 ) ;
draw_vert ( 3 , 0 , 0.0 , 1.0 ) ;
GX_End ( ) ;
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
2008-10-23 10:18:40 +02:00
* StartGX
2008-09-02 03:57:21 +02:00
*
2009-03-28 18:23:08 +01:00
* This function initialises GX and sets it up for use
2008-10-23 10:18:40 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void
StartGX ( )
2008-10-18 17:58:54 +02:00
{
2008-10-23 10:18:40 +02:00
GXColor background = { 0 , 0 , 0 , 0xff } ;
/*** Clear out FIFO area ***/
memset ( & gp_fifo , 0 , DEFAULT_FIFO_SIZE ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
/*** Initialise GX ***/
GX_Init ( & gp_fifo , DEFAULT_FIFO_SIZE ) ;
GX_SetCopyClear ( background , 0x00ffffff ) ;
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
GX_SetDispCopyGamma ( GX_GM_1_0 ) ;
2009-03-28 18:23:08 +01:00
GX_SetCullMode ( GX_CULL_NONE ) ;
}
2008-10-23 10:18:40 +02:00
2009-03-28 18:23:08 +01:00
/****************************************************************************
* StopGX
*
* Stops GX ( when exiting )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void StopGX ( )
{
GX_AbortFrame ( ) ;
GX_Flush ( ) ;
2008-10-23 10:18:40 +02:00
2009-03-28 18:23:08 +01:00
VIDEO_SetBlack ( TRUE ) ;
VIDEO_Flush ( ) ;
2008-09-02 03:57:21 +02:00
}
2008-10-27 14:49:35 +01:00
/****************************************************************************
* UpdateScaling
*
* This function updates the quad aspect ratio .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-05-06 08:33:34 +02:00
static inline void
2008-10-27 14:49:35 +01:00
UpdateScaling ( )
{
int xscale , yscale ;
2008-10-27 15:08:43 +01:00
// update scaling
2008-10-27 14:49:35 +01:00
if ( GCSettings . render = = 0 ) // original render mode
{
2008-10-27 15:08:43 +01:00
xscale = 640 / 2 ; // use GX scaler instead VI
2008-10-27 14:49:35 +01:00
yscale = 240 / 2 ;
}
else // unfiltered and filtered mode
{
xscale = vmode - > fbWidth / 2 ;
yscale = vmode - > efbHeight / 2 ;
}
// aspect ratio scaling (change width scale)
// yes its pretty cheap and ugly, but its easy!
if ( GCSettings . widescreen )
xscale = ( 3 * xscale ) / 4 ;
xscale * = GCSettings . ZoomLevel ;
yscale * = GCSettings . ZoomLevel ;
// update vertex position matrix
2009-01-26 08:10:20 +01:00
square [ 0 ] = square [ 9 ] = ( - xscale ) + GCSettings . xshift ;
square [ 3 ] = square [ 6 ] = ( xscale ) + GCSettings . xshift ;
square [ 1 ] = square [ 4 ] = ( yscale ) - GCSettings . yshift ;
square [ 7 ] = square [ 10 ] = ( - yscale ) - GCSettings . yshift ;
2008-11-10 04:36:21 +01:00
DCFlushRange ( square , 32 ) ; // update memory BEFORE the GPU accesses it!
2008-10-27 23:33:18 +01:00
draw_init ( ) ;
if ( updateScaling )
updateScaling - - ;
2008-10-27 14:49:35 +01:00
}
2008-09-02 03:57:21 +02:00
/****************************************************************************
* UpdatePadsCB
*
* called by postRetraceCallback in InitGCVideo - scans gcpad and wpad
2008-10-23 10:18:40 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-12-30 01:05:57 +01:00
static void
2008-09-02 03:57:21 +02:00
UpdatePadsCB ( )
{
2009-03-28 18:23:08 +01:00
# ifdef HW_RVL
2008-09-02 03:57:21 +02:00
WPAD_ScanPads ( ) ;
2009-03-28 18:23:08 +01:00
# endif
2008-09-02 03:57:21 +02:00
PAD_ScanPads ( ) ;
2009-03-28 18:23:08 +01:00
for ( int i = 3 ; i > = 0 ; i - - )
{
# ifdef HW_RVL
memcpy ( & userInput [ i ] . wpad , WPAD_Data ( i ) , sizeof ( WPADData ) ) ;
# endif
userInput [ i ] . chan = i ;
userInput [ i ] . pad . btns_d = PAD_ButtonsDown ( i ) ;
userInput [ i ] . pad . btns_u = PAD_ButtonsUp ( i ) ;
userInput [ i ] . pad . btns_h = PAD_ButtonsHeld ( i ) ;
userInput [ i ] . pad . stickX = PAD_StickX ( i ) ;
userInput [ i ] . pad . stickY = PAD_StickY ( i ) ;
userInput [ i ] . pad . substickX = PAD_SubStickX ( i ) ;
userInput [ i ] . pad . substickY = PAD_SubStickY ( i ) ;
userInput [ i ] . pad . triggerL = PAD_TriggerL ( i ) ;
userInput [ i ] . pad . triggerR = PAD_TriggerR ( i ) ;
}
2008-09-02 03:57:21 +02:00
}
2009-04-22 20:15:36 +02:00
2008-09-02 03:57:21 +02:00
/****************************************************************************
2009-04-22 20:15:36 +02:00
* SetupVideoMode
2008-09-02 03:57:21 +02:00
*
2009-04-22 20:15:36 +02:00
* Finds the optimal video mode , or uses the user - specified one
* Also configures original video modes
2008-10-23 10:18:40 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-04-22 20:15:36 +02:00
static void SetupVideoMode ( )
2008-10-18 17:58:54 +02:00
{
2009-04-22 20:15:36 +02:00
if ( currentVideoMode = = GCSettings . videomode )
return ; // no need to do anything
2008-10-01 07:16:59 +02:00
2009-04-22 20:15:36 +02:00
// choose the desired video mode
switch ( GCSettings . videomode )
{
case 1 : // NTSC (480i)
vmode = & TVNtsc480IntDf ;
break ;
case 2 : // Progressive (480p)
vmode = & TVNtsc480Prog ;
break ;
case 3 : // PAL (50Hz)
vmode = & TVPal574IntDfScale ;
break ;
case 4 : // PAL (60Hz)
vmode = & TVEurgb60Hz480IntDf ;
break ;
default :
vmode = VIDEO_GetPreferredMode ( NULL ) ;
# ifdef HW_DOL
/* we have component cables, but the preferred mode is interlaced
* why don ' t we switch into progressive ?
* on the Wii , the user can do this themselves on their Wii Settings */
if ( VIDEO_HaveComponentCable ( ) )
vmode = & TVNtsc480Prog ;
# endif
// use hardware vertical scaling to fill screen
if ( vmode - > viTVMode > > 2 = = VI_PAL )
vmode = & TVPal574IntDfScale ;
break ;
}
// configure original modes
2008-10-23 10:18:40 +02:00
switch ( vmode - > viTVMode > > 2 )
2008-10-21 09:50:37 +02:00
{
2009-04-22 20:15:36 +02:00
case VI_PAL :
// 576 lines (PAL 50Hz)
2008-10-21 09:50:37 +02:00
vmode_60hz = 0 ;
2009-04-22 20:15:36 +02:00
// Original Video modes (forced to PAL 50Hz)
// set video signal mode
2009-04-22 00:08:23 +02:00
NTSC_240p . viTVMode = VI_TVMODE_PAL_DS ;
NTSC_240p . viYOrigin = ( VI_MAX_HEIGHT_PAL - 480 ) / 2 ;
2008-10-21 09:50:37 +02:00
break ;
2009-04-22 20:15:36 +02:00
case VI_NTSC :
// 480 lines (NTSC 60Hz)
2008-10-21 09:50:37 +02:00
vmode_60hz = 1 ;
2009-04-22 20:15:36 +02:00
// Original Video modes (forced to NTSC 60Hz)
// set video signal mode
2009-04-22 00:08:23 +02:00
PAL_240p . viTVMode = VI_TVMODE_NTSC_DS ;
PAL_240p . viYOrigin = ( VI_MAX_HEIGHT_NTSC - 480 ) / 2 ;
NTSC_240p . viTVMode = VI_TVMODE_NTSC_DS ;
2008-10-21 09:50:37 +02:00
break ;
2009-04-22 20:15:36 +02:00
default :
// 480 lines (PAL 60Hz)
2008-10-21 09:50:37 +02:00
vmode_60hz = 1 ;
2009-04-22 20:15:36 +02:00
// Original Video modes (forced to PAL 60Hz)
// set video signal mode
2009-04-22 00:08:23 +02:00
PAL_240p . viTVMode = VI_TVMODE ( vmode - > viTVMode > > 2 , VI_NON_INTERLACE ) ;
PAL_240p . viYOrigin = ( VI_MAX_HEIGHT_NTSC - 480 ) / 2 ;
NTSC_240p . viTVMode = VI_TVMODE ( vmode - > viTVMode > > 2 , VI_NON_INTERLACE ) ;
2008-10-21 09:50:37 +02:00
break ;
}
// check for progressive scan
if ( vmode - > viTVMode = = VI_TVMODE_NTSC_PROG )
progressive = true ;
2009-04-22 20:15:36 +02:00
else
progressive = false ;
2008-10-21 09:50:37 +02:00
2009-04-22 20:15:36 +02:00
# ifdef HW_RVL
2008-11-05 09:36:01 +01:00
// widescreen fix
2009-04-06 08:30:47 +02:00
if ( CONF_GetAspectRatio ( ) = = CONF_ASPECT_16_9 )
2008-11-05 18:28:22 +01:00
{
2009-04-05 05:11:38 +02:00
vmode - > viWidth = VI_MAX_WIDTH_PAL - 12 ;
vmode - > viXOrigin = ( ( VI_MAX_WIDTH_PAL - vmode - > viWidth ) / 2 ) + 2 ;
2008-11-05 18:28:22 +01:00
}
2009-04-22 20:15:36 +02:00
# endif
currentVideoMode = GCSettings . videomode ;
}
/****************************************************************************
* InitGCVideo
*
* This function MUST be called at startup .
* - also sets up menu video mode
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
InitGCVideo ( )
{
SetupVideoMode ( ) ;
2008-11-05 09:36:01 +01:00
2008-10-27 23:33:18 +01:00
// configure VI
VIDEO_Configure ( vmode ) ;
2008-10-23 10:18:40 +02:00
2009-04-09 09:49:28 +02:00
screenheight = 480 ;
2009-04-22 00:08:23 +02:00
screenwidth = 640 ;
2008-10-23 10:18:40 +02:00
// Allocate the video buffers
2008-10-27 23:33:18 +01:00
xfb [ 0 ] = ( u32 * ) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) ) ;
xfb [ 1 ] = ( u32 * ) MEM_K0_TO_K1 ( SYS_AllocateFramebuffer ( vmode ) ) ;
2008-10-23 10:18:40 +02:00
2008-10-27 23:33:18 +01:00
// A console is always useful while debugging.
console_init ( xfb [ 0 ] , 20 , 64 , vmode - > fbWidth , vmode - > xfbHeight , vmode - > fbWidth * 2 ) ;
2008-10-23 10:18:40 +02:00
2008-10-27 23:33:18 +01:00
// Clear framebuffers etc.
VIDEO_ClearFrameBuffer ( vmode , xfb [ 0 ] , COLOR_BLACK ) ;
VIDEO_ClearFrameBuffer ( vmode , xfb [ 1 ] , COLOR_BLACK ) ;
VIDEO_SetNextFramebuffer ( xfb [ 0 ] ) ;
2008-10-23 10:18:40 +02:00
// video callbacks
VIDEO_SetPostRetraceCallback ( ( VIRetraceCallback ) UpdatePadsCB ) ;
2008-10-27 23:33:18 +01:00
VIDEO_SetPreRetraceCallback ( ( VIRetraceCallback ) copy_to_xfb ) ;
2008-10-23 10:18:40 +02:00
2008-10-27 23:33:18 +01:00
VIDEO_SetBlack ( FALSE ) ;
VIDEO_Flush ( ) ;
VIDEO_WaitVSync ( ) ;
if ( vmode - > viTVMode & VI_NON_INTERLACE )
VIDEO_WaitVSync ( ) ;
2008-10-23 10:18:40 +02:00
2008-10-27 23:33:18 +01:00
copynow = GX_FALSE ;
2008-10-23 10:18:40 +02:00
2009-03-28 18:23:08 +01:00
StartGX ( ) ;
2008-10-27 23:33:18 +01:00
InitVideoThread ( ) ;
// Finally, the video is up and ready for use :)
2008-10-23 10:18:40 +02:00
}
2008-09-02 03:57:21 +02:00
2008-10-23 10:18:40 +02:00
/****************************************************************************
* ResetVideo_Emu
*
* Reset the video / rendering mode for the emulator rendering
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
ResetVideo_Emu ( )
{
2009-04-22 20:15:36 +02:00
SetupVideoMode ( ) ;
GXRModeObj * rmode = vmode ; // same mode as menu
2008-12-30 08:31:00 +01:00
Mtx44 p ;
2008-10-23 10:18:40 +02:00
2009-04-22 20:15:36 +02:00
// change current VI mode if using original render mode
if ( GCSettings . render = = 0 )
2008-10-25 17:58:59 +02:00
rmode = tvmodes [ GCSettings . timing ] ;
2009-04-22 00:08:23 +02:00
2008-10-27 15:08:43 +01:00
// reconfigure VI
2008-10-27 23:33:18 +01:00
VIDEO_Configure ( rmode ) ;
2008-10-22 01:07:16 +02:00
VIDEO_Flush ( ) ;
VIDEO_WaitVSync ( ) ;
2008-10-27 23:33:18 +01:00
if ( rmode - > viTVMode & VI_NON_INTERLACE )
VIDEO_WaitVSync ( ) ;
else
while ( VIDEO_GetNextField ( ) )
VIDEO_WaitVSync ( ) ;
2008-10-23 10:18:40 +02:00
2009-03-30 10:22:55 +02:00
GXColor background = { 0 , 0 , 0 , 255 } ;
GX_SetCopyClear ( background , 0x00ffffff ) ;
2008-10-27 15:08:43 +01:00
// reconfigure GX
2008-10-27 23:33:18 +01:00
GX_SetViewport ( 0 , 0 , rmode - > fbWidth , rmode - > efbHeight , 0 , 1 ) ;
2008-10-23 10:18:40 +02:00
GX_SetDispCopyYScale ( ( f32 ) rmode - > xfbHeight / ( f32 ) rmode - > efbHeight ) ;
GX_SetScissor ( 0 , 0 , rmode - > fbWidth , rmode - > efbHeight ) ;
2009-03-28 18:23:08 +01:00
2008-10-23 10:18:40 +02:00
GX_SetDispCopySrc ( 0 , 0 , rmode - > fbWidth , rmode - > efbHeight ) ;
GX_SetDispCopyDst ( rmode - > fbWidth , rmode - > xfbHeight ) ;
2009-04-01 10:02:59 +02:00
GX_SetCopyFilter ( rmode - > aa , rmode - > sample_pattern , ( GCSettings . render = = 1 ) ? GX_TRUE : GX_FALSE , rmode - > vfilter ) ; // deflicker ON only for filtered mode
2009-03-28 18:23:08 +01:00
2008-10-23 10:18:40 +02:00
GX_SetFieldMode ( rmode - > field_rendering , ( ( rmode - > viHeight = = 2 * rmode - > xfbHeight ) ? GX_ENABLE : GX_DISABLE ) ) ;
GX_SetPixelFmt ( GX_PF_RGB8_Z24 , GX_ZC_LINEAR ) ;
2009-03-28 18:23:08 +01:00
GX_SetZMode ( GX_TRUE , GX_LEQUAL , GX_TRUE ) ;
GX_SetColorUpdate ( GX_TRUE ) ;
2009-04-22 00:08:23 +02:00
guOrtho ( p , rmode - > efbHeight / 2 , - ( rmode - > efbHeight / 2 ) , - ( rmode - > fbWidth / 2 ) , rmode - > fbWidth / 2 , 100 , 1000 ) ; // matrix, t, b, l, r, n, f
2008-10-23 10:18:40 +02:00
GX_LoadProjectionMtx ( p , GX_ORTHOGRAPHIC ) ;
2008-10-27 23:33:18 +01:00
// reinitialize texture
GX_InvalidateTexAll ( ) ;
GX_InitTexObj ( & texobj , texturemem , TEX_WIDTH , TEX_HEIGHT , GX_TF_RGB565 , GX_CLAMP , GX_CLAMP , GX_FALSE ) ; // initialize the texture obj we are going to use
2008-10-27 14:49:35 +01:00
if ( ! ( GCSettings . render & 1 ) )
GX_InitTexObjLOD ( & texobj , GX_NEAR , GX_NEAR_MIP_NEAR , 2.5 , 9.0 , 0.0 , GX_FALSE , GX_FALSE , GX_ANISO_1 ) ; // original/unfiltered video mode: force texture filtering OFF
2008-11-10 04:36:21 +01:00
memset ( texturemem , 0 , TEX_WIDTH * TEX_HEIGHT * 2 ) ; // clear texture memory
2008-10-27 14:49:35 +01:00
2008-10-27 23:33:18 +01:00
// set aspect ratio
updateScaling = 5 ;
2009-03-31 09:13:20 +02:00
draw_init ( ) ;
2008-10-23 10:18:40 +02:00
}
2008-09-02 03:57:21 +02:00
/****************************************************************************
* RenderFrame
*
2008-10-23 10:18:40 +02:00
* Render a single frame
2008-09-02 03:57:21 +02:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-10-18 17:58:54 +02:00
2008-10-23 10:18:40 +02:00
void RenderFrame ( unsigned char * XBuf )
2008-10-18 17:58:54 +02:00
{
2008-10-27 23:33:18 +01:00
// Ensure previous vb has complete
2008-10-18 17:58:54 +02:00
while ( ( LWP_ThreadIsSuspended ( vbthread ) = = 0 ) | | ( copynow = = GX_TRUE ) )
usleep ( 50 ) ;
2008-10-27 23:33:18 +01:00
// swap framebuffers
whichfb ^ = 1 ;
// zoom has changed
if ( updateScaling )
UpdateScaling ( ) ;
2008-10-23 10:18:40 +02:00
2008-10-25 20:20:13 +02:00
int width , height ;
2008-11-07 08:48:17 +01:00
2009-01-26 07:36:19 +01:00
u8 borderheight = 0 ;
u8 borderwidth = 0 ;
// 0 = off, 1 = vertical, 2 = horizontal, 3 = both
if ( GCSettings . hideoverscan = = 1 | | GCSettings . hideoverscan = = 3 )
borderheight = 8 ;
if ( GCSettings . hideoverscan > = 2 )
borderwidth = 8 ;
2008-11-07 08:48:17 +01:00
2008-11-10 04:36:21 +01:00
u16 * texture = ( unsigned short * ) texturemem + ( borderheight < < 8 ) + ( borderwidth < < 2 ) ;
u8 * src1 = XBuf + ( borderheight < < 8 ) + borderwidth ;
u8 * src2 = XBuf + ( borderheight < < 8 ) + borderwidth + 256 ;
u8 * src3 = XBuf + ( borderheight < < 8 ) + borderwidth + 512 ;
u8 * src4 = XBuf + ( borderheight < < 8 ) + borderwidth + 768 ;
2008-10-23 10:18:40 +02:00
2008-10-27 15:08:43 +01:00
// clear texture objects
2008-10-27 23:33:18 +01:00
GX_InvalidateTexAll ( ) ;
2008-10-27 14:57:12 +01:00
2008-10-27 23:33:18 +01:00
// fill the texture
2008-11-10 04:36:21 +01:00
for ( height = 0 ; height < 240 - ( borderheight < < 1 ) ; height + = 4 )
2008-10-23 10:18:40 +02:00
{
2008-11-07 08:48:17 +01:00
for ( width = 0 ; width < 256 - ( borderwidth < < 1 ) ; width + = 4 )
2008-10-23 10:18:40 +02:00
{
// Row one
2008-10-25 17:58:59 +02:00
* texture + + = rgb565 [ * src1 + + ] ;
* texture + + = rgb565 [ * src1 + + ] ;
* texture + + = rgb565 [ * src1 + + ] ;
* texture + + = rgb565 [ * src1 + + ] ;
2008-10-23 10:18:40 +02:00
// Row two
2008-10-25 17:58:59 +02:00
* texture + + = rgb565 [ * src2 + + ] ;
* texture + + = rgb565 [ * src2 + + ] ;
* texture + + = rgb565 [ * src2 + + ] ;
* texture + + = rgb565 [ * src2 + + ] ;
2008-10-23 10:18:40 +02:00
// Row three
2008-10-25 17:58:59 +02:00
* texture + + = rgb565 [ * src3 + + ] ;
* texture + + = rgb565 [ * src3 + + ] ;
* texture + + = rgb565 [ * src3 + + ] ;
* texture + + = rgb565 [ * src3 + + ] ;
2008-10-23 10:18:40 +02:00
// Row four
2008-10-25 17:58:59 +02:00
* texture + + = rgb565 [ * src4 + + ] ;
* texture + + = rgb565 [ * src4 + + ] ;
* texture + + = rgb565 [ * src4 + + ] ;
* texture + + = rgb565 [ * src4 + + ] ;
2008-10-23 10:18:40 +02:00
}
2008-11-07 08:48:17 +01:00
src1 + = 768 + ( borderwidth < < 1 ) ; // line 4*N
src2 + = 768 + ( borderwidth < < 1 ) ; // line 4*(N+1)
src3 + = 768 + ( borderwidth < < 1 ) ; // line 4*(N+2)
src4 + = 768 + ( borderwidth < < 1 ) ; // line 4*(N+3)
texture + = ( borderwidth < < 3 ) ;
2008-10-23 10:18:40 +02:00
}
2008-10-27 23:33:18 +01:00
// load texture into GX
DCFlushRange ( texturemem , TEX_WIDTH * TEX_HEIGHT * 2 ) ;
2008-10-27 14:57:12 +01:00
GX_LoadTexObj ( & texobj , GX_TEXMAP0 ) ;
2008-10-23 10:18:40 +02:00
2008-10-27 15:08:43 +01:00
// render textured quad
2008-10-23 10:18:40 +02:00
draw_square ( view ) ;
GX_DrawDone ( ) ;
2009-04-06 09:27:40 +02:00
// EFB is ready to be copied into XFB
2008-10-27 23:33:18 +01:00
VIDEO_SetNextFramebuffer ( xfb [ whichfb ] ) ;
2008-10-18 17:58:54 +02:00
VIDEO_Flush ( ) ;
2008-10-23 10:18:40 +02:00
copynow = GX_TRUE ;
2008-10-18 17:58:54 +02:00
// Return to caller, don't waste time waiting for vb
LWP_ResumeThread ( vbthread ) ;
2008-09-02 03:57:21 +02:00
}
2008-10-23 10:18:40 +02:00
/****************************************************************************
* Zoom Functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void
zoom ( float speed )
{
2008-10-24 07:38:46 +02:00
if ( GCSettings . ZoomLevel > 1 )
GCSettings . ZoomLevel + = ( speed / - 100.0 ) ;
2008-10-23 10:18:40 +02:00
else
2008-10-24 07:38:46 +02:00
GCSettings . ZoomLevel + = ( speed / - 200.0 ) ;
2008-10-23 10:18:40 +02:00
2008-10-24 07:38:46 +02:00
if ( GCSettings . ZoomLevel < 0.5 )
GCSettings . ZoomLevel = 0.5 ;
else if ( GCSettings . ZoomLevel > 2.0 )
GCSettings . ZoomLevel = 2.0 ;
2008-10-23 10:18:40 +02:00
2008-10-25 20:20:13 +02:00
updateScaling = 5 ; // update video
2008-10-23 10:18:40 +02:00
}
void
zoom_reset ( )
{
2008-10-24 07:38:46 +02:00
GCSettings . ZoomLevel = 1.0 ;
2008-10-25 20:20:13 +02:00
updateScaling = 5 ; // update video
2008-10-23 10:18:40 +02:00
}
2009-03-28 18:23:08 +01:00
/****************************************************************************
* TakeScreenshot
*
* Copies the current screen into a GX texture
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void TakeScreenshot ( )
2008-10-23 10:18:40 +02:00
{
2009-03-28 18:23:08 +01:00
int texSize = vmode - > fbWidth * vmode - > efbHeight * 4 ;
if ( gameScreenTex ) free ( gameScreenTex ) ;
gameScreenTex = ( u8 * ) memalign ( 32 , texSize ) ;
if ( gameScreenTex = = NULL ) return ;
GX_SetTexCopySrc ( 0 , 0 , vmode - > fbWidth , vmode - > efbHeight ) ;
GX_SetTexCopyDst ( vmode - > fbWidth , vmode - > efbHeight , GX_TF_RGBA8 , GX_FALSE ) ;
GX_CopyTex ( gameScreenTex , GX_FALSE ) ;
GX_PixModeSync ( ) ;
DCFlushRange ( gameScreenTex , texSize ) ;
# ifdef HW_RVL
if ( gameScreenTex2 ) free ( gameScreenTex2 ) ;
gameScreenTex2 = ( u8 * ) memalign ( 32 , texSize ) ;
if ( gameScreenTex2 = = NULL ) return ;
GX_CopyTex ( gameScreenTex2 , GX_FALSE ) ;
GX_PixModeSync ( ) ;
DCFlushRange ( gameScreenTex2 , texSize ) ;
# endif
2008-10-23 10:18:40 +02:00
}
2009-03-28 18:23:08 +01:00
/****************************************************************************
* ResetVideo_Menu
*
* Reset the video / rendering mode for the menu
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-10-23 10:18:40 +02:00
void
2009-03-28 18:23:08 +01:00
ResetVideo_Menu ( )
2008-10-23 10:18:40 +02:00
{
2009-03-28 18:23:08 +01:00
Mtx44 p ;
f32 yscale ;
u32 xfbHeight ;
2009-04-22 20:15:36 +02:00
SetupVideoMode ( ) ;
2009-03-28 18:23:08 +01:00
VIDEO_Configure ( vmode ) ;
VIDEO_Flush ( ) ;
VIDEO_WaitVSync ( ) ;
if ( vmode - > viTVMode & VI_NON_INTERLACE )
VIDEO_WaitVSync ( ) ;
else
while ( VIDEO_GetNextField ( ) )
VIDEO_WaitVSync ( ) ;
// clears the bg to color and clears the z buffer
GXColor background = { 0 , 0 , 0 , 255 } ;
GX_SetCopyClear ( background , 0x00ffffff ) ;
yscale = GX_GetYScaleFactor ( vmode - > efbHeight , vmode - > xfbHeight ) ;
xfbHeight = GX_SetDispCopyYScale ( yscale ) ;
GX_SetScissor ( 0 , 0 , vmode - > fbWidth , vmode - > efbHeight ) ;
GX_SetDispCopySrc ( 0 , 0 , vmode - > fbWidth , vmode - > efbHeight ) ;
GX_SetDispCopyDst ( vmode - > fbWidth , xfbHeight ) ;
GX_SetCopyFilter ( vmode - > aa , vmode - > sample_pattern , GX_TRUE , vmode - > vfilter ) ;
GX_SetFieldMode ( vmode - > field_rendering , ( ( vmode - > viHeight = = 2 * vmode - > xfbHeight ) ? GX_ENABLE : GX_DISABLE ) ) ;
if ( vmode - > aa )
GX_SetPixelFmt ( GX_PF_RGB565_Z16 , GX_ZC_LINEAR ) ;
else
GX_SetPixelFmt ( GX_PF_RGB8_Z24 , GX_ZC_LINEAR ) ;
// setup the vertex descriptor
// tells the flipper to expect direct data
GX_ClearVtxDesc ( ) ;
GX_InvVtxCache ( ) ;
GX_InvalidateTexAll ( ) ;
GX_SetVtxDesc ( GX_VA_TEX0 , GX_NONE ) ;
GX_SetVtxDesc ( GX_VA_POS , GX_DIRECT ) ;
GX_SetVtxDesc ( GX_VA_CLR0 , 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_SetZMode ( GX_FALSE , GX_LEQUAL , GX_TRUE ) ;
GX_SetNumChans ( 1 ) ;
GX_SetNumTexGens ( 1 ) ;
GX_SetTevOp ( GX_TEVSTAGE0 , GX_PASSCLR ) ;
GX_SetTevOrder ( GX_TEVSTAGE0 , GX_TEXCOORD0 , GX_TEXMAP0 , GX_COLOR0A0 ) ;
GX_SetTexCoordGen ( GX_TEXCOORD0 , GX_TG_MTX2x4 , GX_TG_TEX0 , GX_IDENTITY ) ;
guMtxIdentity ( GXmodelView2D ) ;
guMtxTransApply ( GXmodelView2D , GXmodelView2D , 0.0F , 0.0F , - 50.0F ) ;
GX_LoadPosMtxImm ( GXmodelView2D , GX_PNMTX0 ) ;
guOrtho ( p , 0 , 479 , 0 , 639 , 0 , 300 ) ;
GX_LoadProjectionMtx ( p , GX_ORTHOGRAPHIC ) ;
GX_SetViewport ( 0 , 0 , vmode - > fbWidth , vmode - > efbHeight , 0 , 1 ) ;
GX_SetBlendMode ( GX_BM_BLEND , GX_BL_SRCALPHA , GX_BL_INVSRCALPHA , GX_LO_CLEAR ) ;
GX_SetAlphaUpdate ( GX_TRUE ) ;
}
/****************************************************************************
* Menu_Render
*
* Renders everything current sent to GX , and flushes video
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void Menu_Render ( )
{
GX_DrawDone ( ) ;
whichfb ^ = 1 ; // flip framebuffer
GX_SetZMode ( GX_TRUE , GX_LEQUAL , GX_TRUE ) ;
GX_SetColorUpdate ( GX_TRUE ) ;
GX_CopyDisp ( xfb [ whichfb ] , GX_TRUE ) ;
VIDEO_SetNextFramebuffer ( xfb [ whichfb ] ) ;
VIDEO_Flush ( ) ;
VIDEO_WaitVSync ( ) ;
}
/****************************************************************************
* Menu_DrawImg
*
* Draws the specified image on screen using GX
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void Menu_DrawImg ( f32 xpos , f32 ypos , u16 width , u16 height , u8 data [ ] ,
f32 degrees , f32 scaleX , f32 scaleY , u8 alpha )
{
if ( data = = NULL )
return ;
GXTexObj texObj ;
GX_InitTexObj ( & texObj , data , width , height , GX_TF_RGBA8 , GX_CLAMP , GX_CLAMP , GX_FALSE ) ;
GX_LoadTexObj ( & texObj , GX_TEXMAP0 ) ;
GX_InvalidateTexAll ( ) ;
GX_SetTevOp ( GX_TEVSTAGE0 , GX_MODULATE ) ;
GX_SetVtxDesc ( GX_VA_TEX0 , GX_DIRECT ) ;
Mtx m , m1 , m2 , mv ;
width * = .5 ;
height * = .5 ;
guMtxIdentity ( m1 ) ;
guMtxScaleApply ( m1 , m1 , scaleX , scaleY , 1.0 ) ;
Vector axis = ( Vector ) { 0 , 0 , 1 } ;
guMtxRotAxisDeg ( m2 , & axis , degrees ) ;
guMtxConcat ( m2 , m1 , m ) ;
guMtxTransApply ( m , m , xpos + width , ypos + height , 0 ) ;
guMtxConcat ( GXmodelView2D , m , mv ) ;
GX_LoadPosMtxImm ( mv , GX_PNMTX0 ) ;
GX_Begin ( GX_QUADS , GX_VTXFMT0 , 4 ) ;
GX_Position3f32 ( - width , - height , 0 ) ;
GX_Color4u8 ( 0xFF , 0xFF , 0xFF , alpha ) ;
GX_TexCoord2f32 ( 0 , 0 ) ;
GX_Position3f32 ( width , - height , 0 ) ;
GX_Color4u8 ( 0xFF , 0xFF , 0xFF , alpha ) ;
GX_TexCoord2f32 ( 1 , 0 ) ;
GX_Position3f32 ( width , height , 0 ) ;
GX_Color4u8 ( 0xFF , 0xFF , 0xFF , alpha ) ;
GX_TexCoord2f32 ( 1 , 1 ) ;
GX_Position3f32 ( - width , height , 0 ) ;
GX_Color4u8 ( 0xFF , 0xFF , 0xFF , alpha ) ;
GX_TexCoord2f32 ( 0 , 1 ) ;
GX_End ( ) ;
GX_LoadPosMtxImm ( GXmodelView2D , GX_PNMTX0 ) ;
GX_SetTevOp ( GX_TEVSTAGE0 , GX_PASSCLR ) ;
GX_SetVtxDesc ( GX_VA_TEX0 , GX_NONE ) ;
}
/****************************************************************************
* Menu_DrawRectangle
*
* Draws a rectangle at the specified coordinates using GX
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void Menu_DrawRectangle ( f32 x , f32 y , f32 width , f32 height , GXColor color , u8 filled )
{
u8 fmt ;
long n ;
int i ;
f32 x2 = x + width ;
f32 y2 = y + height ;
Vector v [ ] = { { x , y , 0.0f } , { x2 , y , 0.0f } , { x2 , y2 , 0.0f } , { x , y2 , 0.0f } , { x , y , 0.0f } } ;
if ( ! filled )
{
fmt = GX_LINESTRIP ;
n = 5 ;
}
else
{
fmt = GX_TRIANGLEFAN ;
n = 4 ;
}
GX_Begin ( fmt , GX_VTXFMT0 , n ) ;
for ( i = 0 ; i < n ; i + + )
{
GX_Position3f32 ( v [ i ] . x , v [ i ] . y , v [ i ] . z ) ;
GX_Color4u8 ( color . r , color . g , color . b , color . a ) ;
}
GX_End ( ) ;
2008-10-23 10:18:40 +02:00
}
2008-09-02 03:57:21 +02:00
/****************************************************************************
* rgbcolor
*
* Support routine for gcpalette
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-12-30 01:05:57 +01:00
static unsigned int rgbcolor ( unsigned char r1 , unsigned char g1 , unsigned char b1 ,
2008-09-02 03:57:21 +02:00
unsigned char r2 , unsigned char g2 , unsigned char b2 ) {
int y1 , cb1 , cr1 , y2 , cb2 , cr2 , cb , cr ;
y1 = ( 299 * r1 + 587 * g1 + 114 * b1 ) / 1000 ;
cb1 = ( - 16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000 ) / 100000 ;
cr1 = ( 50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000 ) / 100000 ;
y2 = ( 299 * r2 + 587 * g2 + 114 * b2 ) / 1000 ;
cb2 = ( - 16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000 ) / 100000 ;
cr2 = ( 50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000 ) / 100000 ;
cb = ( cb1 + cb2 ) > > 1 ;
cr = ( cr1 + cr2 ) > > 1 ;
return ( ( y1 < < 24 ) | ( cb < < 16 ) | ( y2 < < 8 ) | cr ) ;
}
/****************************************************************************
* SetPalette
*
* A shadow copy of the palette is maintained , in case the NES Emu kernel
* requests a copy .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void FCEUD_SetPalette ( unsigned char index , unsigned char r , unsigned char g ,
unsigned char b ) {
/*** Make PC compatible copy ***/
pcpalette [ index ] . r = r ;
pcpalette [ index ] . g = g ;
pcpalette [ index ] . b = b ;
/*** Generate Gamecube palette ***/
gcpalette [ index ] = rgbcolor ( r , g , b , r , g , b ) ;
/*** Generate RGB565 texture palette ***/
rgb565 [ index ] = ( ( r & 0xf8 ) < < 8 ) |
( ( g & 0xfc ) < < 3 ) |
( ( b & 0xf8 ) > > 3 ) ;
}
/****************************************************************************
* GetPalette
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void FCEUD_GetPalette ( unsigned char i , unsigned char * r , unsigned char * g ,
unsigned char * b ) {
* r = pcpalette [ i ] . r ;
* g = pcpalette [ i ] . g ;
* b = pcpalette [ i ] . b ;
}
2008-11-05 09:36:01 +01:00
void SetPalette ( )
{
if ( GCSettings . currpal = = 0 )
{
// Do palette reset
FCEU_ResetPalette ( ) ;
}
else
{
// Now setup this palette
unsigned char i , r , g , b ;
for ( i = 0 ; i < 64 ; i + + )
{
r = palettes [ GCSettings . currpal - 1 ] . data [ i ] > > 16 ;
g = ( palettes [ GCSettings . currpal - 1 ] . data [ i ] & 0xff00 ) > > 8 ;
b = ( palettes [ GCSettings . currpal - 1 ] . data [ i ] & 0xff ) ;
FCEUD_SetPalette ( i , r , g , b ) ;
FCEUD_SetPalette ( i + 64 , r , g , b ) ;
FCEUD_SetPalette ( i + 128 , r , g , b ) ;
FCEUD_SetPalette ( i + 192 , r , g , b ) ;
}
}
}
2008-09-02 03:57:21 +02:00
struct st_palettes palettes [ ] = {
/* The default NES palette must be the first entry in the array */
{ " loopy " , " Loopy's NES palette " ,
{ 0x757575 , 0x271b8f , 0x0000ab , 0x47009f ,
0x8f0077 , 0xab0013 , 0xa70000 , 0x7f0b00 ,
0x432f00 , 0x004700 , 0x005100 , 0x003f17 ,
0x1b3f5f , 0x000000 , 0x000000 , 0x000000 ,
0xbcbcbc , 0x0073ef , 0x233bef , 0x8300f3 ,
0xbf00bf , 0xe7005b , 0xdb2b00 , 0xcb4f0f ,
0x8b7300 , 0x009700 , 0x00ab00 , 0x00933b ,
0x00838b , 0x000000 , 0x000000 , 0x000000 ,
0xffffff , 0x3fbfff , 0x5f97ff , 0xa78bfd ,
0xf77bff , 0xff77b7 , 0xff7763 , 0xff9b3b ,
0xf3bf3f , 0x83d313 , 0x4fdf4b , 0x58f898 ,
0x00ebdb , 0x000000 , 0x000000 , 0x000000 ,
0xffffff , 0xabe7ff , 0xc7d7ff , 0xd7cbff ,
0xffc7ff , 0xffc7db , 0xffbfb3 , 0xffdbab ,
0xffe7a3 , 0xe3ffa3 , 0xabf3bf , 0xb3ffcf ,
0x9ffff3 , 0x000000 , 0x000000 , 0x000000 }
} ,
{ " quor " , " Quor's palette from Nestra 0.63 " ,
{ 0x3f3f3f , 0x001f3f , 0x00003f , 0x1f003f ,
0x3f003f , 0x3f0020 , 0x3f0000 , 0x3f2000 ,
0x3f3f00 , 0x203f00 , 0x003f00 , 0x003f20 ,
0x003f3f , 0x000000 , 0x000000 , 0x000000 ,
0x7f7f7f , 0x405f7f , 0x40407f , 0x5f407f ,
0x7f407f , 0x7f4060 , 0x7f4040 , 0x7f6040 ,
0x7f7f40 , 0x607f40 , 0x407f40 , 0x407f60 ,
0x407f7f , 0x000000 , 0x000000 , 0x000000 ,
0xbfbfbf , 0x809fbf , 0x8080bf , 0x9f80bf ,
0xbf80bf , 0xbf80a0 , 0xbf8080 , 0xbfa080 ,
0xbfbf80 , 0xa0bf80 , 0x80bf80 , 0x80bfa0 ,
0x80bfbf , 0x000000 , 0x000000 , 0x000000 ,
0xffffff , 0xc0dfff , 0xc0c0ff , 0xdfc0ff ,
0xffc0ff , 0xffc0e0 , 0xffc0c0 , 0xffe0c0 ,
0xffffc0 , 0xe0ffc0 , 0xc0ffc0 , 0xc0ffe0 ,
0xc0ffff , 0x000000 , 0x000000 , 0x000000 }
} ,
{ " chris " , " Chris Covell's NES palette " ,
{ 0x808080 , 0x003DA6 , 0x0012B0 , 0x440096 ,
0xA1005E , 0xC70028 , 0xBA0600 , 0x8C1700 ,
0x5C2F00 , 0x104500 , 0x054A00 , 0x00472E ,
0x004166 , 0x000000 , 0x050505 , 0x050505 ,
0xC7C7C7 , 0x0077FF , 0x2155FF , 0x8237FA ,
0xEB2FB5 , 0xFF2950 , 0xFF2200 , 0xD63200 ,
0xC46200 , 0x358000 , 0x058F00 , 0x008A55 ,
0x0099CC , 0x212121 , 0x090909 , 0x090909 ,
0xFFFFFF , 0x0FD7FF , 0x69A2FF , 0xD480FF ,
0xFF45F3 , 0xFF618B , 0xFF8833 , 0xFF9C12 ,
0xFABC20 , 0x9FE30E , 0x2BF035 , 0x0CF0A4 ,
0x05FBFF , 0x5E5E5E , 0x0D0D0D , 0x0D0D0D ,
0xFFFFFF , 0xA6FCFF , 0xB3ECFF , 0xDAABEB ,
0xFFA8F9 , 0xFFABB3 , 0xFFD2B0 , 0xFFEFA6 ,
0xFFF79C , 0xD7E895 , 0xA6EDAF , 0xA2F2DA ,
0x99FFFC , 0xDDDDDD , 0x111111 , 0x111111 }
} ,
{ " matt " , " Matthew Conte's NES palette " ,
{ 0x808080 , 0x0000bb , 0x3700bf , 0x8400a6 ,
0xbb006a , 0xb7001e , 0xb30000 , 0x912600 ,
0x7b2b00 , 0x003e00 , 0x00480d , 0x003c22 ,
0x002f66 , 0x000000 , 0x050505 , 0x050505 ,
0xc8c8c8 , 0x0059ff , 0x443cff , 0xb733cc ,
0xff33aa , 0xff375e , 0xff371a , 0xd54b00 ,
0xc46200 , 0x3c7b00 , 0x1e8415 , 0x009566 ,
0x0084c4 , 0x111111 , 0x090909 , 0x090909 ,
0xffffff , 0x0095ff , 0x6f84ff , 0xd56fff ,
0xff77cc , 0xff6f99 , 0xff7b59 , 0xff915f ,
0xffa233 , 0xa6bf00 , 0x51d96a , 0x4dd5ae ,
0x00d9ff , 0x666666 , 0x0d0d0d , 0x0d0d0d ,
0xffffff , 0x84bfff , 0xbbbbff , 0xd0bbff ,
0xffbfea , 0xffbfcc , 0xffc4b7 , 0xffccae ,
0xffd9a2 , 0xcce199 , 0xaeeeb7 , 0xaaf7ee ,
0xb3eeff , 0xdddddd , 0x111111 , 0x111111 }
} ,
{ " pasofami " , " Palette from PasoFami/99 " ,
{ 0x7f7f7f , 0x0000ff , 0x0000bf , 0x472bbf ,
0x970087 , 0xab0023 , 0xab1300 , 0x8b1700 ,
0x533000 , 0x007800 , 0x006b00 , 0x005b00 ,
0x004358 , 0x000000 , 0x000000 , 0x000000 ,
0xbfbfbf , 0x0078f8 , 0x0058f8 , 0x6b47ff ,
0xdb00cd , 0xe7005b , 0xf83800 , 0xe75f13 ,
0xaf7f00 , 0x00b800 , 0x00ab00 , 0x00ab47 ,
0x008b8b , 0x000000 , 0x000000 , 0x000000 ,
0xf8f8f8 , 0x3fbfff , 0x6b88ff , 0x9878f8 ,
0xf878f8 , 0xf85898 , 0xf87858 , 0xffa347 ,
0xf8b800 , 0xb8f818 , 0x5bdb57 , 0x58f898 ,
0x00ebdb , 0x787878 , 0x000000 , 0x000000 ,
0xffffff , 0xa7e7ff , 0xb8b8f8 , 0xd8b8f8 ,
0xf8b8f8 , 0xfba7c3 , 0xf0d0b0 , 0xffe3ab ,
0xfbdb7b , 0xd8f878 , 0xb8f8b8 , 0xb8f8d8 ,
0x00ffff , 0xf8d8f8 , 0x000000 , 0x000000 }
} ,
{ " crashman " , " CrashMan's NES palette " ,
{ 0x585858 , 0x001173 , 0x000062 , 0x472bbf ,
0x970087 , 0x910009 , 0x6f1100 , 0x4c1008 ,
0x371e00 , 0x002f00 , 0x005500 , 0x004d15 ,
0x002840 , 0x000000 , 0x000000 , 0x000000 ,
0xa0a0a0 , 0x004499 , 0x2c2cc8 , 0x590daa ,
0xae006a , 0xb00040 , 0xb83418 , 0x983010 ,
0x704000 , 0x308000 , 0x207808 , 0x007b33 ,
0x1c6888 , 0x000000 , 0x000000 , 0x000000 ,
0xf8f8f8 , 0x267be1 , 0x5870f0 , 0x9878f8 ,
0xff73c8 , 0xf060a8 , 0xd07b37 , 0xe09040 ,
0xf8b300 , 0x8cbc00 , 0x40a858 , 0x58f898 ,
0x00b7bf , 0x787878 , 0x000000 , 0x000000 ,
0xffffff , 0xa7e7ff , 0xb8b8f8 , 0xd8b8f8 ,
0xe6a6ff , 0xf29dc4 , 0xf0c0b0 , 0xfce4b0 ,
0xe0e01e , 0xd8f878 , 0xc0e890 , 0x95f7c8 ,
0x98e0e8 , 0xf8d8f8 , 0x000000 , 0x000000 }
} ,
2009-01-25 07:53:21 +01:00
{ " mess " , " palette from MESS NES driver " ,
2008-09-02 03:57:21 +02:00
{ 0x747474 , 0x24188c , 0x0000a8 , 0x44009c ,
0x8c0074 , 0xa80010 , 0xa40000 , 0x7c0800 ,
0x402c00 , 0x004400 , 0x005000 , 0x003c14 ,
0x183c5c , 0x000000 , 0x000000 , 0x000000 ,
0xbcbcbc , 0x0070ec , 0x2038ec , 0x8000f0 ,
0xbc00bc , 0xe40058 , 0xd82800 , 0xc84c0c ,
0x887000 , 0x009400 , 0x00a800 , 0x009038 ,
0x008088 , 0x000000 , 0x000000 , 0x000000 ,
0xfcfcfc , 0x3cbcfc , 0x5c94fc , 0x4088fc ,
0xf478fc , 0xfc74b4 , 0xfc7460 , 0xfc9838 ,
0xf0bc3c , 0x80d010 , 0x4cdc48 , 0x58f898 ,
0x00e8d8 , 0x000000 , 0x000000 , 0x000000 ,
0xfcfcfc , 0xa8e4fc , 0xc4d4fc , 0xd4c8fc ,
0xfcc4fc , 0xfcc4d8 , 0xfcbcb0 , 0xfcd8a8 ,
0xfce4a0 , 0xe0fca0 , 0xa8f0bc , 0xb0fccc ,
0x9cfcf0 , 0x000000 , 0x000000 , 0x000000 }
} ,
{ " zaphod-cv " , " Zaphod's VS Castlevania palette " ,
{ 0x7f7f7f , 0xffa347 , 0x0000bf , 0x472bbf ,
0x970087 , 0xf85898 , 0xab1300 , 0xf8b8f8 ,
0xbf0000 , 0x007800 , 0x006b00 , 0x005b00 ,
0xffffff , 0x9878f8 , 0x000000 , 0x000000 ,
0xbfbfbf , 0x0078f8 , 0xab1300 , 0x6b47ff ,
0x00ae00 , 0xe7005b , 0xf83800 , 0x7777ff ,
0xaf7f00 , 0x00b800 , 0x00ab00 , 0x00ab47 ,
0x008b8b , 0x000000 , 0x000000 , 0x472bbf ,
0xf8f8f8 , 0xffe3ab , 0xf87858 , 0x9878f8 ,
0x0078f8 , 0xf85898 , 0xbfbfbf , 0xffa347 ,
0xc800c8 , 0xb8f818 , 0x7f7f7f , 0x007800 ,
0x00ebdb , 0x000000 , 0x000000 , 0xffffff ,
0xffffff , 0xa7e7ff , 0x5bdb57 , 0xe75f13 ,
0x004358 , 0x0000ff , 0xe7005b , 0x00b800 ,
0xfbdb7b , 0xd8f878 , 0x8b1700 , 0xffe3ab ,
0x00ffff , 0xab0023 , 0x000000 , 0x000000 }
} ,
{ " zaphod-smb " , " Zaphod's VS SMB palette " ,
{ 0x626a00 , 0x0000ff , 0x006a77 , 0x472bbf ,
0x970087 , 0xab0023 , 0xab1300 , 0xb74800 ,
0xa2a2a2 , 0x007800 , 0x006b00 , 0x005b00 ,
0xffd599 , 0xffff00 , 0x009900 , 0x000000 ,
0xff66ff , 0x0078f8 , 0x0058f8 , 0x6b47ff ,
0x000000 , 0xe7005b , 0xf83800 , 0xe75f13 ,
0xaf7f00 , 0x00b800 , 0x5173ff , 0x00ab47 ,
0x008b8b , 0x000000 , 0x91ff88 , 0x000088 ,
0xf8f8f8 , 0x3fbfff , 0x6b0000 , 0x4855f8 ,
0xf878f8 , 0xf85898 , 0x595958 , 0xff009d ,
0x002f2f , 0xb8f818 , 0x5bdb57 , 0x58f898 ,
0x00ebdb , 0x787878 , 0x000000 , 0x000000 ,
0xffffff , 0xa7e7ff , 0x590400 , 0xbb0000 ,
0xf8b8f8 , 0xfba7c3 , 0xffffff , 0x00e3e1 ,
0xfbdb7b , 0xffae00 , 0xb8f8b8 , 0xb8f8d8 ,
0x00ff00 , 0xf8d8f8 , 0xffaaaa , 0x004000 }
} ,
{ " vs-drmar " , " VS Dr. Mario palette " ,
{ 0x5f97ff , 0x000000 , 0x000000 , 0x47009f ,
0x00ab00 , 0xffffff , 0xabe7ff , 0x000000 ,
0x000000 , 0x000000 , 0x000000 , 0x000000 ,
0xe7005b , 0x000000 , 0x000000 , 0x000000 ,
0x5f97ff , 0x000000 , 0x000000 , 0x000000 ,
0x000000 , 0x8b7300 , 0xcb4f0f , 0x000000 ,
0xbcbcbc , 0x000000 , 0x000000 , 0x000000 ,
0x000000 , 0x000000 , 0x000000 , 0x000000 ,
0x00ebdb , 0x000000 , 0x000000 , 0x000000 ,
0x000000 , 0xff9b3b , 0x000000 , 0x000000 ,
0x83d313 , 0x000000 , 0x3fbfff , 0x000000 ,
0x0073ef , 0x000000 , 0x000000 , 0x000000 ,
0x00ebdb , 0x000000 , 0x000000 , 0x000000 ,
0x000000 , 0x000000 , 0xf3bf3f , 0x000000 ,
0x005100 , 0x000000 , 0xc7d7ff , 0xffdbab ,
0x000000 , 0x000000 , 0x000000 , 0x000000 }
} ,
{ " vs-cv " , " VS Castlevania palette " ,
{ 0xaf7f00 , 0xffa347 , 0x008b8b , 0x472bbf ,
0x970087 , 0xf85898 , 0xab1300 , 0xf8b8f8 ,
0xf83800 , 0x007800 , 0x006b00 , 0x005b00 ,
0xffffff , 0x9878f8 , 0x00ab00 , 0x000000 ,
0xbfbfbf , 0x0078f8 , 0xab1300 , 0x6b47ff ,
0x000000 , 0xe7005b , 0xf83800 , 0x6b88ff ,
0xaf7f00 , 0x00b800 , 0x6b88ff , 0x00ab47 ,
0x008b8b , 0x000000 , 0x000000 , 0x472bbf ,
0xf8f8f8 , 0xffe3ab , 0xf87858 , 0x9878f8 ,
0x0078f8 , 0xf85898 , 0xbfbfbf , 0xffa347 ,
0x004358 , 0xb8f818 , 0x7f7f7f , 0x007800 ,
0x00ebdb , 0x000000 , 0x000000 , 0xffffff ,
0xffffff , 0xa7e7ff , 0x5bdb57 , 0x6b88ff ,
0x004358 , 0x0000ff , 0xe7005b , 0x00b800 ,
0xfbdb7b , 0xffa347 , 0x8b1700 , 0xffe3ab ,
0xb8f818 , 0xab0023 , 0x000000 , 0x007800 }
} ,
/* The default VS palette must be the last entry in the array */
{ " vs-smb " , " VS SMB/VS Ice Climber palette " ,
{ 0xaf7f00 , 0x0000ff , 0x008b8b , 0x472bbf ,
0x970087 , 0xab0023 , 0x0000ff , 0xe75f13 ,
0xbfbfbf , 0x007800 , 0x5bdb57 , 0x005b00 ,
0xf0d0b0 , 0xffe3ab , 0x00ab00 , 0x000000 ,
0xbfbfbf , 0x0078f8 , 0x0058f8 , 0x6b47ff ,
0x000000 , 0xe7005b , 0xf83800 , 0xf87858 ,
0xaf7f00 , 0x00b800 , 0x6b88ff , 0x00ab47 ,
0x008b8b , 0x000000 , 0x000000 , 0x3fbfff ,
0xf8f8f8 , 0x006b00 , 0x8b1700 , 0x9878f8 ,
0x6b47ff , 0xf85898 , 0x7f7f7f , 0xe7005b ,
0x004358 , 0xb8f818 , 0x0078f8 , 0x58f898 ,
0x00ebdb , 0xfbdb7b , 0x000000 , 0x000000 ,
0xffffff , 0xa7e7ff , 0xb8b8f8 , 0xf83800 ,
0xf8b8f8 , 0xfba7c3 , 0xffffff , 0x00ffff ,
0xfbdb7b , 0xffa347 , 0xb8f8b8 , 0xb8f8d8 ,
0xb8f818 , 0xf8d8f8 , 0x000000 , 0x007800 }
}
} ;