.removed unecessary images (use rotation instead)

.implemented interactive screen positioning & scaling in video option menu
.usual code cleanup
This commit is contained in:
ekeeke31 2009-12-30 15:31:50 +00:00
parent 46758ce339
commit 7dae5fc15a
11 changed files with 641 additions and 259 deletions

View File

@ -103,13 +103,12 @@ static gui_menu menu_browser =
{
"Game Selection",
-1,-1,
0,0,10,
0,0,10,0,
NULL,
NULL,
bg_filesel,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
{&arrow_up,&arrow_down}
};
/***************************************************************************

View File

@ -168,7 +168,7 @@ void GUI_DrawMenu(gui_menu *menu)
if (menu->screenshot)
{
gxClearScreen((GXColor)BLACK);
gxDrawScreenshot(128);
gxDrawScreenshot(menu->screenshot);
}
else
{
@ -287,33 +287,41 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out)
if (image->state & IMAGE_SLIDE_LEFT)
{
temp = image->x + image->w;
if (max_offset < temp) max_offset = temp;
if (max_offset < temp)
max_offset = temp;
}
else if (image->state & IMAGE_SLIDE_RIGHT)
{
temp = 640 - image->x;
if (max_offset < temp) max_offset = temp;
if (max_offset < temp)
max_offset = temp;
}
if (image->state & IMAGE_SLIDE_TOP)
{
temp = image->y + image->h;
if (max_offset < temp) max_offset = temp;
if (max_offset < temp)
max_offset = temp;
}
else if (image->state & IMAGE_SLIDE_BOTTOM)
{
temp = 480 - image->y;
if (max_offset < temp) max_offset = temp;
if (max_offset < temp)
max_offset = temp;
}
}
temp = max_offset;
/* Alpha steps */
int alpha = out ? 255 : 0;
int alpha = 0;
int alpha_step = (255 * speed) / max_offset;
if (out) alpha_step = -alpha_step;
if (out)
{
alpha = 255;
alpha_step = -alpha_step;
}
/* Let's loop until final position has been reached */
while (temp > 0)
@ -322,8 +330,10 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out)
if (menu->screenshot)
{
gxClearScreen((GXColor)BLACK);
if (alpha > 127) gxDrawScreenshot(128);
else gxDrawScreenshot(255 - alpha);
if (alpha >= menu->screenshot)
gxDrawScreenshot(menu->screenshot);
else
gxDrawScreenshot(255 - alpha);
}
else
{
@ -355,13 +365,17 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out)
if ((image->state & IMAGE_FADE) && ((out && (image->alpha > alpha)) || (!out && (image->alpha < alpha))))
{
/* FADE In-Out */
if (image->state & IMAGE_REPEAT) gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha);
else if (image->state & IMAGE_VISIBLE)gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha);
if (image->state & IMAGE_REPEAT)
gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha);
else if (image->state & IMAGE_VISIBLE)
gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha);
}
else
{
if (image->state & IMAGE_REPEAT) gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha);
else if (image->state & IMAGE_VISIBLE)gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha);
if (image->state & IMAGE_REPEAT)
gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha);
else if (image->state & IMAGE_VISIBLE)
gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha);
}
}
@ -413,7 +427,9 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out)
/* draw button + items */
item = &menu->items[menu->offset + i];
if (button->data) gxDrawTexture(button->data->texture[0],button->x+xoffset,button->y+yoffset,button->w, button->h,item_alpha);
if (button->data)
gxDrawTexture(button->data->texture[0],button->x+xoffset,button->y+yoffset,button->w, button->h,item_alpha);
if (item->texture)
{
gxDrawTexture(item->texture,item->x+xoffset,item->y+yoffset,item->w,item->h,item_alpha);
@ -431,8 +447,10 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out)
/* update alpha */
alpha += alpha_step;
if (alpha > 255) alpha = 255;
else if (alpha < 0) alpha = 0;
if (alpha > 255)
alpha = 255;
else if (alpha < 0)
alpha = 0;
/* copy EFB to XFB */
gxSetScreen();
@ -1187,12 +1205,9 @@ int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items)
/* Option Box */
void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type)
{
gx_texture *l_arrow[2];
gx_texture *r_arrow[2];
l_arrow[0] = gxTextureOpenPNG(Button_left_png,0);
l_arrow[1] = gxTextureOpenPNG(Button_left_over_png,0);
r_arrow[0] = gxTextureOpenPNG(Button_right_png,0);
r_arrow[1] = gxTextureOpenPNG(Button_right_over_png,0);
gx_texture *arrow[2];
arrow[0] = gxTextureOpenPNG(Button_arrow_png,0);
arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0);
gx_texture *window = gxTextureOpenPNG(Frame_s4_png,0);
gx_texture *top = gxTextureOpenPNG(Frame_s4_title_png,0);
@ -1200,17 +1215,15 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
int xwindow = 166;
int ywindow = 160;
/* text position */
int ypos = 248;
/* arrows position */
int xleft = 206;
int xright = 392;
int yleft = 238;
int yright = 238;
/* disable helper comment */
if (parent->helpers[1]) parent->helpers[1]->data = 0;
/* disable action button helper */
if (parent->helpers[1])
parent->helpers[1]->data = 0;
/* slide in */
char msg[16];
@ -1224,13 +1237,9 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230);
gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255);
/* draw title */
/* display title */
FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE);
/* draw buttons */
gxDrawTexture(l_arrow[0],xleft,yleft-yoffset,l_arrow[0]->width,l_arrow[0]->height,255);
gxDrawTexture(r_arrow[0],xright,yright-yoffset,r_arrow[0]->width,r_arrow[0]->height,255);
/* update display */
gxSetScreen();
@ -1240,6 +1249,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
/* display option box */
int quit = 0;
int modified = 0;
int selected = -1;
s16 p;
#ifdef HW_RVL
@ -1255,7 +1265,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230);
gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255);
/* draw title */
/* display title */
FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE);
/* option type */
@ -1273,7 +1283,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
}
/* draw option text */
FONT_writeCenter(msg,24,xwindow,xwindow+window->width,ypos+24,(GXColor)WHITE);
FONT_writeCenter(msg,24,xwindow,xwindow+window->width,272,(GXColor)WHITE);
/* update inputs */
p = m_input.keys;
@ -1282,31 +1292,29 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
if (selected < 0)
{
/* nothing selected */
gxDrawTexture(l_arrow[0],xleft,yleft,l_arrow[0]->width,l_arrow[0]->height,255);
gxDrawTexture(r_arrow[0],xright,yright,r_arrow[0]->width,r_arrow[0]->height,255);
gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255);
}
#ifdef HW_RVL
else if (selected)
{
/* right button selected */
gxDrawTexture(l_arrow[0],xleft,yleft,l_arrow[0]->width,l_arrow[0]->height,255);
gxDrawTexture(r_arrow[1],xright-4,yright-4,r_arrow[0]->width+8,r_arrow[0]->height+8,255);
gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[1],xright-4,yright-4,arrow[1]->width+8,arrow[1]->height+8,180.0,255);
}
else
{
/* left button selected */
gxDrawTexture(l_arrow[1],xleft-4,yleft-4,l_arrow[0]->width+8,l_arrow[0]->height+8,255);
gxDrawTexture(r_arrow[0],xright,yright,r_arrow[0]->width,r_arrow[0]->height,255);
gxDrawTexture(arrow[1],xleft-4,yleft-4,arrow[1]->width+8,arrow[1]->height+8,255);
gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255);
}
selected = -1;
if (Shutdown)
{
gxTextureClose(&l_arrow[0]);
gxTextureClose(&l_arrow[1]);
gxTextureClose(&r_arrow[0]);
gxTextureClose(&r_arrow[1]);
gxTextureClose(&arrow[0]);
gxTextureClose(&arrow[1]);
gxTextureClose(&window);
gxTextureClose(&top);
gxTextureClose(&w_pointer);
@ -1325,10 +1333,18 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255);
/* check for valid buttons */
if ((x>=xleft)&&(x<=(xleft+l_arrow[0]->width))&&(y>=yleft)&&(y<=(yleft+l_arrow[0]->height)))
if ((x>=xleft)&&(x<=(xleft+arrow[0]->width))&&(y>=yleft)&&(y<=(yleft+arrow[0]->height)))
{
selected = 0;
else if ((x>=xright)&&(x<=(xright+r_arrow[0]->width))&&(y>=yright)&&(y<=(yright+r_arrow[0]->height)))
if (p & PAD_BUTTON_A)
p |= PAD_BUTTON_LEFT;
}
else if ((x>=xright)&&(x<=(xright+arrow[0]->width))&&(y>=yright)&&(y<=(yright+arrow[0]->height)))
{
selected = 1;
if (p & PAD_BUTTON_A)
p |= PAD_BUTTON_RIGHT;
}
}
#endif
@ -1336,7 +1352,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
gxSetScreen();
/* check input */
if ((p&PAD_BUTTON_LEFT) || ((p & PAD_BUTTON_A) && (selected == 0)))
if (p&PAD_BUTTON_LEFT)
{
/* decrement option value */
if (type)
@ -1352,14 +1368,9 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
if (*(float *)option < min) *(float *)option = max;
}
/* play sound effect */
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
/* option callback */
if (cb) cb();
modified = 1;
}
else if ((p&PAD_BUTTON_RIGHT) || ((p & PAD_BUTTON_A) && (selected == 1)))
else if (p&PAD_BUTTON_RIGHT)
{
/* increment option value */
if (type)
@ -1375,6 +1386,17 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
if (*(float *)option > max) *(float *)option = min;
}
modified = 1;
}
else if (p & PAD_BUTTON_B)
{
quit = 1;
}
if (modified)
{
modified = 0;
/* play sound effect */
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
@ -1382,8 +1404,6 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
/* option callback */
if (cb) cb();
}
if (p & PAD_BUTTON_B) quit = 1;
}
/* slide out */
@ -1397,7 +1417,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230);
gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255);
/* draw title */
/* display title */
FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE);
/* update display */
@ -1407,22 +1427,253 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
yoffset += 60;
}
/* restore helper comment */
if (parent->helpers[1]) parent->helpers[1]->data = Key_A_png;
/* restore action button helper */
if (parent->helpers[1])
parent->helpers[1]->data = Key_A_png;
/* final position */
GUI_DrawMenu(parent);
gxSetScreen();
/* close textures */
gxTextureClose(&l_arrow[0]);
gxTextureClose(&l_arrow[1]);
gxTextureClose(&r_arrow[0]);
gxTextureClose(&r_arrow[1]);
gxTextureClose(&arrow[0]);
gxTextureClose(&arrow[1]);
gxTextureClose(&window);
gxTextureClose(&top);
}
/* Option Box with two parameters */
void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max)
{
gx_texture *arrow[2];
arrow[0] = gxTextureOpenPNG(Button_arrow_png,0);
arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0);
gx_texture *window = gxTextureOpenPNG(Frame_s4_png,0);
/* window position */
int xwindow = 166;
int ywindow = 160;
/* arrows position */
int arrow_pos[4][2] =
{
{144,218},
{452,218},
{298,138},
{298,298}
};
/* disable action button helper */
if (parent->helpers[1])
parent->helpers[1]->data = 0;
/* slide in */
char msg[16];
int yoffset = ywindow + window->height;
while (yoffset > 0)
{
/* draw parent menu */
GUI_DrawMenu(parent);
/* draw window */
gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230);
/* update display */
gxSetScreen();
/* slide speed */
yoffset -= 60;
}
/* display option box */
int quit = 0;
int modified = 0;
s16 p;
#ifdef HW_RVL
int selected = -1;
int i,x,y;
#endif
while (!quit)
{
/* draw parent menu */
GUI_DrawMenu(parent);
/* draw window */
gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230);
/* draw options text */
if (*option_1 < 0) sprintf(msg,"%s: -%02d",text_1,abs(*option_1));
else sprintf(msg,"%s: +%02d",text_1,abs(*option_1));
FONT_writeCenter(msg,24,xwindow,xwindow+window->width,240,(GXColor)WHITE);
if (*option_2 < 0) sprintf(msg,"%s: -%02d",text_2,abs(*option_2));
else sprintf(msg,"%s: +%02d",text_2,abs(*option_2));
FONT_writeCenter(msg,24,xwindow,xwindow+window->width,264,(GXColor)WHITE);
/* update inputs */
p = m_input.keys;
/* draw buttons */
#ifdef HW_RVL
switch (selected)
{
case 0: /* left button */
gxDrawTexture(arrow[1],arrow_pos[0][0]-4,arrow_pos[0][1]-4,arrow[0]->width+8,arrow[0]->height+8,255);
gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255);
if (p & PAD_BUTTON_A) p |= PAD_BUTTON_LEFT;
break;
case 1: /* right button */
gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[1],arrow_pos[1][0]-4,arrow_pos[1][1]-4,arrow[0]->width+8,arrow[0]->height+8,180.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255);
if (p & PAD_BUTTON_A) p |= PAD_BUTTON_RIGHT;
break;
case 2: /* up button */
gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255);
gxDrawTextureRotate(arrow[1],arrow_pos[2][0]-4,arrow_pos[2][1]-4,arrow[0]->width+8,arrow[0]->height+8,90.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255);
if (p & PAD_BUTTON_A) p |= PAD_BUTTON_UP;
break;
case 3: /* down button */
gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255);
gxDrawTextureRotate(arrow[1],arrow_pos[3][0]-4,arrow_pos[3][1]-4,arrow[0]->width+8,arrow[0]->height+8,270.0,255);
if (p & PAD_BUTTON_A) p |= PAD_BUTTON_DOWN;
break;
default: /* nothing selected */
gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255);
break;
}
if (Shutdown)
{
gxTextureClose(&arrow[0]);
gxTextureClose(&arrow[1]);
gxTextureClose(&window);
gxTextureClose(&w_pointer);
GUI_DeleteMenu(parent);
GUI_FadeOut();
shutdown();
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
}
/* update selection */
selected = -1;
if (m_input.ir.valid)
{
/* get cursor position */
x = m_input.ir.x;
y = m_input.ir.y;
/* draw wiimote pointer */
gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255);
/* check for valid buttons */
for (i=0; i<4; i++)
{
if ((x>=arrow_pos[i][0])&&(x<=(arrow_pos[i][0]+arrow[0]->width))&&(y>=arrow_pos[i][1])&&(y<=(arrow_pos[i][1]+arrow[0]->height)))
selected = i;
}
}
#else
gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255);
gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255);
gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255);
#endif
/* update screen */
gxSetScreen();
if (p&PAD_BUTTON_LEFT)
{
/* decrement option 1 value */
*option_1 -= step;
if (*option_1 < min)
*option_1 = max;
modified = 1;
}
else if (p&PAD_BUTTON_RIGHT)
{
/* decrement option 1 value */
*option_1 += step;
if (*option_1 > max)
*option_1 = min;
modified = 1;
}
else if (p&PAD_BUTTON_UP)
{
/* decrement option 2 value */
*option_2 -= step;
if (*option_2 < min)
*option_2 = max;
modified = 1;
}
else if (p&PAD_BUTTON_DOWN)
{
/* increment option 2 value */
*option_2 += step;
if (*option_2 > max)
*option_2 = min;
modified = 1;
}
else if (p & PAD_BUTTON_B)
{
quit = 1;
}
if (modified)
{
modified = 0;
/* play sound effect */
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
}
}
/* slide out */
yoffset = 0; ;
while (yoffset < (ywindow + window->height))
{
/* draw parent menu */
GUI_DrawMenu(parent);
/* draw window */
gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230);
/* update display */
gxSetScreen();
/* slide speed */
yoffset += 60;
}
/* restore action button helper */
if (parent->helpers[1])
parent->helpers[1]->data = Key_A_png;
/* final position */
GUI_DrawMenu(parent);
gxSetScreen();
/* close textures */
gxTextureClose(&arrow[0]);
gxTextureClose(&arrow[1]);
gxTextureClose(&window);
}
/* Interactive Message Box */
/* Message Box displays a message until a specific action is completed */

View File

@ -110,12 +110,12 @@ typedef struct
u8 max_items; /* total number of items */
u8 max_buttons; /* total number of buttons */
u8 max_images; /* total number of background images */
u8 screenshot; /* game screen background */
gui_item *items; /* menu items */
gui_butn *buttons; /* menu buttons */
gui_image *bg_images; /* background images */
gui_item *helpers[2]; /* left & right key comments */
gui_butn *arrows[2]; /* arrows buttons */
bool screenshot; /* use gamescreen as background */
} gui_menu;
typedef struct
@ -217,13 +217,11 @@ extern const u8 Button_icon_over_png[];
extern const u8 Button_icon_sm_png[];
extern const u8 Button_icon_sm_over_png[];
extern const u8 Button_up_png[];
extern const u8 Button_down_png[];
extern const u8 Button_up_over_png[];
extern const u8 Button_down_png[];
extern const u8 Button_down_over_png[];
extern const u8 Button_right_png[];
extern const u8 Button_left_png[];
extern const u8 Button_right_over_png[];
extern const u8 Button_left_over_png[];
extern const u8 Button_arrow_png[];
extern const u8 Button_arrow_over_png[];
/* Controller Settings */
extern const u8 Ctrl_4wayplay_png[];
@ -286,6 +284,7 @@ extern int GUI_UpdateMenu(gui_menu *menu);
extern int GUI_RunMenu(gui_menu *menu);
extern int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items);
extern void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type);
extern void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max);
extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
extern void GUI_MsgBoxUpdate(char *title, char *msg);
extern void GUI_MsgBoxClose(void);

View File

@ -246,14 +246,14 @@ static gui_item items_system[7] =
/* Video options menu */
static gui_item items_video[8] =
{
{NULL,NULL,"Display: PROGRESSIVE", "Select video mode type", 52,132,276,48},
{NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 52,132,276,48},
{NULL,NULL,"Bilinear Filter: OFF", "Enable/disable hardware filtering", 52,132,276,48},
{NULL,NULL,"NTSC Filter: COMPOSITE","Enable/disable NTSC software filtering", 52,132,276,48},
{NULL,NULL,"Borders: OFF", "Enable/disable original overscan emulation",52,132,276,48},
{NULL,NULL,"Aspect: ORIGINAL (4:3)","Select display aspect ratio", 52,132,276,48},
{NULL,NULL,"DISPLAY POSITION", "Adjust display position", 52,132,276,48},
{NULL,NULL,"DISPLAY SIZE", "Adjust display size", 52,132,276,48}
{NULL,NULL,"Display: PROGRESSIVE", "Select video mode type", 52,132,276,48},
{NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 52,132,276,48},
{NULL,NULL,"Bilinear Filter: OFF", "Enable/disable hardware filtering", 52,132,276,48},
{NULL,NULL,"NTSC Filter: COMPOSITE", "Enable/disable NTSC software filtering", 52,132,276,48},
{NULL,NULL,"Borders: OFF", "Enable/disable original overscan emulation",52,132,276,48},
{NULL,NULL,"Aspect: ORIGINAL (4:3)", "Select display aspect ratio", 52,132,276,48},
{NULL,NULL,"Screen Position (+0,+0)", "Adjust display position", 52,132,276,48},
{NULL,NULL,"Screen Size (+0,+0)", "Adjust display size", 52,132,276,48}
};
/* Preferences menu */
@ -354,13 +354,12 @@ static gui_menu menu_main =
{
"",
0,0,
9,9,4,
9,9,4,0,
items_main,
buttons_main,
bg_main,
{NULL,NULL},
{NULL,NULL},
FALSE
{NULL,NULL}
};
/* Main menu */
@ -368,13 +367,12 @@ gui_menu menu_ctrls =
{
"Controller Settings",
0,0,
13,13,8,
13,13,8,0,
items_ctrls,
buttons_ctrls,
bg_ctrls,
{&action_cancel, &action_select},
{NULL,NULL},
FALSE
{NULL,NULL}
};
/* Load Game menu */
@ -383,16 +381,15 @@ static gui_menu menu_load =
"Load Game",
0,0,
#ifdef HW_RVL
4,4,5,
4,4,5,0,
#else
3,3,5,
3,3,5,0,
#endif
items_load,
buttons_load,
bg_misc,
{&action_cancel, &action_select},
{NULL,NULL},
FALSE
{NULL,NULL}
};
/* Options menu */
@ -400,13 +397,12 @@ static gui_menu menu_options =
{
"Settings",
0,0,
5,5,5,
5,5,5,0,
items_options,
buttons_options,
bg_misc,
{&action_cancel, &action_select},
{NULL,NULL},
FALSE
{NULL,NULL}
};
/* System Options menu */
@ -414,13 +410,12 @@ static gui_menu menu_system =
{
"System Settings",
0,0,
6,4,6,
6,4,6,0,
items_system,
buttons_list,
bg_list,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
{&arrow_up,&arrow_down}
};
/* Video Options menu */
@ -428,13 +423,12 @@ static gui_menu menu_video =
{
"Video Settings",
0,0,
8,4,6,
8,4,6,0,
items_video,
buttons_list,
bg_list,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
{&arrow_up,&arrow_down}
};
/* Sound Options menu */
@ -442,13 +436,12 @@ static gui_menu menu_audio =
{
"Audio Settings",
0,0,
10,4,6,
10,4,6,0,
items_audio,
buttons_list,
bg_list,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
{&arrow_up,&arrow_down}
};
/* Sound Options menu */
@ -456,13 +449,12 @@ static gui_menu menu_prefs =
{
"Menu Settings",
0,0,
7,4,6,
7,4,6,0,
items_prefs,
buttons_list,
bg_list,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
{&arrow_up,&arrow_down}
};
@ -750,7 +742,7 @@ static void soundmenu ()
{
unsigned char *temp = memalign(32,YM2612GetContextSize());
if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
audio_init(48000);
audio_init(48000,vdp_pal?50.0:(1000000.0/16715.0));
if (temp)
{
YM2612Restore(temp);
@ -870,17 +862,28 @@ static void systemmenu ()
gui_menu *m = &menu_system;
gui_item *items = m->items;
if (config.region_detect == 0) sprintf (items[0].text, "Console Region: AUTO");
else if (config.region_detect == 1) sprintf (items[0].text, "Console Region: USA");
else if (config.region_detect == 2) sprintf (items[0].text, "Console Region: EUR");
else if (config.region_detect == 3) sprintf (items[0].text, "Console Region: JAP");
if (config.region_detect == 0)
sprintf (items[0].text, "Console Region: AUTO");
else if (config.region_detect == 1)
sprintf (items[0].text, "Console Region: USA");
else if (config.region_detect == 2)
sprintf (items[0].text, "Console Region: EUR");
else if (config.region_detect == 3)
sprintf (items[0].text, "Console Region: JAP");
sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON");
sprintf (items[2].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF");
sprintf (items[3].text, "System BIOS: %s", (config.bios_enabled & 1) ? "ON":"OFF");
if (config.lock_on == TYPE_GG) sprintf (items[4].text, "Lock-On: GAME GENIE");
else if (config.lock_on == TYPE_AR) sprintf (items[4].text, "Lock-On: ACTION REPLAY");
else if (config.lock_on == TYPE_SK) sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES");
else sprintf (items[4].text, "Lock-On: OFF");
if (config.lock_on == TYPE_GG)
sprintf (items[4].text, "Lock-On: GAME GENIE");
else if (config.lock_on == TYPE_AR)
sprintf (items[4].text, "Lock-On: ACTION REPLAY");
else if (config.lock_on == TYPE_SK)
sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES");
else
sprintf (items[4].text, "Lock-On: OFF");
sprintf (items[5].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF");
if (svp)
@ -905,21 +908,28 @@ static void systemmenu ()
{
case 0: /*** Region Force ***/
config.region_detect = (config.region_detect + 1) % 4;
if (config.region_detect == 0) sprintf (items[0].text, "Console Region: AUTO");
else if (config.region_detect == 1) sprintf (items[0].text, "Console Region: USA");
else if (config.region_detect == 2) sprintf (items[0].text, "Console Region: EUR");
else if (config.region_detect == 3) sprintf (items[0].text, "Console Region: JAP");
if (config.region_detect == 0)
sprintf (items[0].text, "Console Region: AUTO");
else if (config.region_detect == 1)
sprintf (items[0].text, "Console Region: USA");
else if (config.region_detect == 2)
sprintf (items[0].text, "Console Region: EUR");
else if (config.region_detect == 3)
sprintf (items[0].text, "Console Region: JAP");
if (cart.romsize)
{
/* force region & cpu mode */
set_region();
/* reinitialize timings */
system_init ();
system_init();
memfile_autoload(config.sram_auto,-1);
unsigned char *temp = memalign(32,YM2612GetContextSize());
if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
audio_init(48000);
if (temp)
memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize());
audio_init(48000,vdp_pal?50.0:(1000000.0/16715.0));
if (temp)
{
YM2612Restore(temp);
@ -961,11 +971,17 @@ static void systemmenu ()
case 4: /*** Cart Lock-On ***/
config.lock_on++;
if (config.lock_on > TYPE_SK) config.lock_on = 0;
if (config.lock_on == TYPE_GG) sprintf (items[4].text, "Lock-On: GAME GENIE");
else if (config.lock_on == TYPE_AR) sprintf (items[4].text, "Lock-On: ACTION REPLAY");
else if (config.lock_on == TYPE_SK) sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES");
else sprintf (items[4].text, "Lock-On: OFF");
if (config.lock_on > TYPE_SK)
config.lock_on = 0;
if (config.lock_on == TYPE_GG)
sprintf (items[4].text, "Lock-On: GAME GENIE");
else if (config.lock_on == TYPE_AR)
sprintf (items[4].text, "Lock-On: ACTION REPLAY");
else if (config.lock_on == TYPE_SK)
sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES");
else
sprintf (items[4].text, "Lock-On: OFF");
if (cart.romsize)
{
system_reset (); /* clear any patches first */
@ -1000,25 +1016,53 @@ static void systemmenu ()
****************************************************************************/
static void videomenu ()
{
u16 state[2];
int ret, quit = 0;
gui_menu *m = &menu_video;
gui_item *items = m->items;
if (config.render == 1) sprintf (items[0].text,"Display: INTERLACED");
else if (config.render == 2) sprintf (items[0].text, "Display: PROGRESSIVE");
else sprintf (items[0].text, "Display: ORIGINAL");
if (config.tv_mode == 0) sprintf (items[1].text, "TV Mode: 60HZ");
else if (config.tv_mode == 1) sprintf (items[1].text, "TV Mode: 50HZ");
else sprintf (items[1].text, "TV Mode: 50/60HZ");
sprintf (items[2].text, "Bilinear Filter: %s", config.bilinear ? " ON" : "OFF");
if (config.ntsc == 1) sprintf (items[3].text, "NTSC Filter: COMPOSITE");
else if (config.ntsc == 2) sprintf (items[3].text, "NTSC Filter: S-VIDEO");
else if (config.ntsc == 3) sprintf (items[3].text, "NTSC Filter: RGB");
else sprintf (items[3].text, "NTSC Filter: OFF");
sprintf (items[4].text, "Borders: %s", config.overscan ? " ON" : "OFF");
if (config.aspect == 1) sprintf (items[5].text,"Aspect: ORIGINAL (4:3)");
else if (config.aspect == 2) sprintf (items[5].text, "Aspect: ORIGINAL (16:9)");
else sprintf (items[5].text, "Aspect: FIT SCREEN");
if (config.render == 1)
sprintf (items[0].text,"Display: INTERLACED");
else if (config.render == 2)
sprintf (items[0].text, "Display: PROGRESSIVE");
else
sprintf (items[0].text, "Display: ORIGINAL");
if (config.tv_mode == 0)
sprintf (items[1].text, "TV Mode: 60HZ");
else if (config.tv_mode == 1)
sprintf (items[1].text, "TV Mode: 50HZ");
else
sprintf (items[1].text, "TV Mode: 50/60HZ");
sprintf (items[2].text, "Bilinear Filter: %s",
config.bilinear ? " ON" : "OFF");
if (config.ntsc == 1)
sprintf (items[3].text, "NTSC Filter: COMPOSITE");
else if (config.ntsc == 2)
sprintf (items[3].text, "NTSC Filter: S-VIDEO");
else if (config.ntsc == 3)
sprintf (items[3].text, "NTSC Filter: RGB");
else
sprintf (items[3].text, "NTSC Filter: OFF");
sprintf (items[4].text, "Borders: %s",
config.overscan ? "ON" : "OFF");
if (config.aspect == 1)
sprintf (items[5].text,"Aspect: ORIGINAL (4:3)");
else if (config.aspect == 2)
sprintf (items[5].text, "Aspect: ORIGINAL (16:9)");
else
sprintf (items[5].text, "Aspect: SCALED");
sprintf (items[6].text, "Screen Position: (%s%02d,%s%02d)",
(config.xshift < 0) ? "":"+", config.xshift,
(config.yshift < 0) ? "":"+", config.yshift);
sprintf (items[7].text, "Screen Scaling: (%s%02d,%s%02d)",
(config.xscale < 0) ? "":"+", config.xscale,
(config.yscale < 0) ? "":"+", config.yscale);
GUI_InitMenu(m);
@ -1043,6 +1087,7 @@ static void videomenu ()
{
/* progressive mode (60hz only) */
config.tv_mode = 0;
sprintf (items[1].text, "TV Mode: 60HZ");
}
else
{
@ -1050,46 +1095,57 @@ static void videomenu ()
config.render = 0;
}
}
if (config.render == 1) sprintf (items[0].text,"Display: INTERLACED");
else if (config.render == 2) sprintf (items[0].text, "Display: PROGRESSIVE");
else sprintf (items[0].text, "Display: ORIGINAL");
if (config.tv_mode == 0) sprintf (items[1].text, "TV Mode: 60HZ");
else if (config.tv_mode == 1) sprintf (items[1].text, "TV Mode: 50HZ");
else sprintf (items[1].text, "TV Mode: 50/60HZ");
if (config.render == 1)
sprintf (items[0].text,"Display: INTERLACED");
else if (config.render == 2)
sprintf (items[0].text, "Display: PROGRESSIVE");
else
sprintf (items[0].text, "Display: ORIGINAL");
break;
case 1: /*** tv mode ***/
if (config.render != 2) config.tv_mode = (config.tv_mode + 1) % 3;
if (config.tv_mode == 0) sprintf (items[1].text, "TV Mode: 60HZ");
else if (config.tv_mode == 1) sprintf (items[1].text, "TV Mode: 50HZ");
else sprintf (items[1].text, "TV Mode: 50/60HZ");
if (config.render == 2) break;
config.tv_mode = (config.tv_mode + 1) % 3;
if (config.tv_mode == 0)
sprintf (items[1].text, "TV Mode: 60HZ");
else if (config.tv_mode == 1)
sprintf (items[1].text, "TV Mode: 50HZ");
else
sprintf (items[1].text, "TV Mode: 50/60HZ");
break;
case 2: /*** bilinear filtering ***/
config.bilinear ^= 1;
sprintf (items[2].text, "Bilinear Filter: %s", config.bilinear ? " ON" : "OFF");
sprintf (items[2].text, "Bilinear Filter: %s",
config.bilinear ? " ON" : "OFF");
break;
case 3: /*** NTSC filter ***/
config.ntsc ++;
if (config.ntsc > 3) config.ntsc = 0;
if (config.ntsc == 1) sprintf (items[3].text, "NTSC Filter: COMPOSITE");
else if (config.ntsc == 2) sprintf (items[3].text, "NTSC Filter: S-VIDEO");
else if (config.ntsc == 3) sprintf (items[3].text, "NTSC Filter: RGB");
else sprintf (items[3].text, "NTSC Filter: OFF");
config.ntsc = (config.ntsc + 1) % 4;
if (config.ntsc == 1)
sprintf (items[3].text, "NTSC Filter: COMPOSITE");
else if (config.ntsc == 2)
sprintf (items[3].text, "NTSC Filter: S-VIDEO");
else if (config.ntsc == 3)
sprintf (items[3].text, "NTSC Filter: RGB");
else
sprintf (items[3].text, "NTSC Filter: OFF");
break;
case 4: /*** overscan emulation ***/
config.overscan ^= 1;
sprintf (items[4].text, "Borders: %s", config.overscan ? " ON" : "OFF");
sprintf (items[4].text, "Overscan Color: %s",
config.overscan ? "ORIGINAL" : "BLACK");
break;
case 5: /*** config.aspect ratio ***/
config.aspect ++;
if (config.aspect > 2) config.aspect = 0;
if (config.aspect == 1) sprintf (items[5].text,"Aspect: ORIGINAL (4:3)");
else if (config.aspect == 2) sprintf (items[5].text, "Aspect: ORIGINAL (16:9)");
else sprintf (items[5].text, "Aspect: FIT SCREEN");
case 5: /*** aspect ratio ***/
config.aspect = (config.aspect + 1) % 3;
if (config.aspect == 1)
sprintf (items[5].text,"Aspect: ORIGINAL (4:3)");
else if (config.aspect == 2)
sprintf (items[5].text, "Aspect: ORIGINAL (16:9)");
else
sprintf (items[5].text, "Aspect: SCALED");
if (config.aspect)
{
@ -1111,10 +1167,52 @@ static void videomenu ()
break;
case 6:
case 6: /*** screen position ***/
if (cart.romsize)
{
state[0] = m->arrows[0]->state;
state[1] = m->arrows[1]->state;
m->max_buttons = 0;
m->max_images = 0;
m->arrows[0]->state = 0;
m->arrows[1]->state = 0;
m->screenshot = 255;
strcpy(m->title,"");
GUI_OptionBox2(m,"X Offset","Y Offset",&config.xshift,&config.yshift,1,-99,99);
m->max_buttons = 4;
m->max_images = 6;
m->arrows[0]->state = state[0];
m->arrows[1]->state = state[1];
m->screenshot = 0;
strcpy(m->title,"Video Settings");
sprintf (items[6].text, "Screen Position: (%s%02d,%s%02d)",
(config.xshift < 0) ? "":"+", config.xshift,
(config.yshift < 0) ? "":"+", config.yshift);
}
break;
case 7:
case 7: /*** screen scaling ***/
if (cart.romsize)
{
state[0] = m->arrows[0]->state;
state[1] = m->arrows[1]->state;
m->max_buttons = 0;
m->max_images = 0;
m->arrows[0]->state = 0;
m->arrows[1]->state = 0;
m->screenshot = 255;
strcpy(m->title,"");
GUI_OptionBox2(m,"X Scale","Y Scale",&config.xscale,&config.yscale,1,-99,99);
m->max_buttons = 4;
m->max_images = 6;
m->arrows[0]->state = state[0];
m->arrows[1]->state = state[1];
m->screenshot = 0;
strcpy(m->title,"Video Settings");
sprintf (items[7].text, "Screen Scaling: (%s%02d,%s%02d)",
(config.xscale < 0) ? "":"+", config.xscale,
(config.yscale < 0) ? "":"+", config.yscale);
}
break;
case -1:
@ -1161,20 +1259,35 @@ static void ctrlmenu_raz(void)
}
/* update buttons navigation */
if (input.dev[0] != NO_DEVICE) m->buttons[0].shift[3] = 2;
else if (input.dev[4] != NO_DEVICE) m->buttons[0].shift[3] = 6;
else m->buttons[0].shift[3] = 0;
if (input.dev[4] != NO_DEVICE) m->buttons[1].shift[3] = 5;
else if (input.dev[0] != NO_DEVICE) m->buttons[1].shift[3] = 1;
else m->buttons[1].shift[3] = 0;
if (input.dev[1] != NO_DEVICE) m->buttons[2].shift[1] = 1;
else if (input.dev[4] != NO_DEVICE) m->buttons[2].shift[1] = 4;
else m->buttons[2].shift[1] = 0;
if (input.dev[3] != NO_DEVICE) m->buttons[6].shift[0] = 1;
else if (input.dev[0] != NO_DEVICE) m->buttons[6].shift[0] = 4;
else m->buttons[6].shift[0] = 0;
if (input.dev[4] != NO_DEVICE) m->buttons[5].shift[1] = 1;
else m->buttons[5].shift[1] = 0;
if (input.dev[0] != NO_DEVICE)
m->buttons[0].shift[3] = 2;
else if (input.dev[4] != NO_DEVICE)
m->buttons[0].shift[3] = 6;
else
m->buttons[0].shift[3] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[1].shift[3] = 5;
else if (input.dev[0] != NO_DEVICE)
m->buttons[1].shift[3] = 1;
else
m->buttons[1].shift[3] = 0;
if (input.dev[1] != NO_DEVICE)
m->buttons[2].shift[1] = 1;
else if (input.dev[4] != NO_DEVICE)
m->buttons[2].shift[1] = 4;
else
m->buttons[2].shift[1] = 0;
if (input.dev[3] != NO_DEVICE)
m->buttons[6].shift[0] = 1;
else if (input.dev[0] != NO_DEVICE)
m->buttons[6].shift[0] = 4;
else
m->buttons[6].shift[0] = 0;
if (input.dev[4] != NO_DEVICE)
m->buttons[5].shift[1] = 1;
else
m->buttons[5].shift[1] = 0;
if (input.dev[5] != NO_DEVICE)
{
m->buttons[6].shift[1] = 1;
@ -1184,12 +1297,17 @@ static void ctrlmenu_raz(void)
if (input.dev[7] != NO_DEVICE) m->buttons[8].shift[1] = 1;
else m->buttons[8].shift[1] = 0;
}
else m->buttons[7].shift[1] = 0;
else
{
m->buttons[7].shift[1] = 0;
}
}
else
{
m->buttons[6].shift[1] = 0;
}
else m->buttons[6].shift[1] = 0;
}
static void ctrlmenu(void)
{
int player = 0;
@ -1328,10 +1446,14 @@ static void ctrlmenu(void)
{
case 0: /* update port 1 system */
if (cart.hw.jcart) break;
if (input.system[0] == SYSTEM_MOUSE) input.system[0] +=3; /* lightguns are never used on Port 1 */
else input.system[0] ++;
if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) input.system[0] +=3;
if (input.system[0] == SYSTEM_WAYPLAY) input.system[1] = SYSTEM_WAYPLAY;
if (input.system[0] == SYSTEM_MOUSE)
input.system[0] +=3; /* lightguns are never used on Port 1 */
else
input.system[0]++;
if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE))
input.system[0] +=3;
if (input.system[0] == SYSTEM_WAYPLAY)
input.system[1] = SYSTEM_WAYPLAY;
if (input.system[0] > SYSTEM_WAYPLAY)
{
input.system[0] = NO_SYSTEM;
@ -1380,8 +1502,10 @@ static void ctrlmenu(void)
case 1: /* update port 2 system */
if (cart.hw.jcart) break;
input.system[1] ++;
if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) input.system[1] ++;
if (input.system[1] == SYSTEM_WAYPLAY) input.system[0] = SYSTEM_WAYPLAY;
if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE))
input.system[1] ++;
if (input.system[1] == SYSTEM_WAYPLAY)
input.system[0] = SYSTEM_WAYPLAY;
if (input.system[1] > SYSTEM_WAYPLAY)
{
input.system[1] = NO_SYSTEM;
@ -2187,7 +2311,7 @@ void MainMenu (void)
/* check if a game is running */
if (cart.romsize)
{
m->screenshot = 1;
m->screenshot = 128;
m->bg_images[0].state &= ~IMAGE_VISIBLE;
m->buttons[3].state |= BUTTON_SELECT_SFX;
m->buttons[5].state |= BUTTON_SELECT_SFX;
@ -2279,7 +2403,7 @@ void MainMenu (void)
gxClearScreen((GXColor)BLACK);
gxSetScreen();
system_init();
audio_init(48000);
audio_init(48000,vdp_pal?50.0:(1000000.0/16715.0));
system_reset();
memfile_autoload(config.sram_auto,-1);
quit = 1;

View File

@ -24,7 +24,6 @@
#include "shared.h"
#include "font.h"
#include "sms_ntsc.h"
#include "aram.h"
#include "md_ntsc.h"
#include "sms_ntsc.h"
@ -446,109 +445,117 @@ static void gxResetView(GXRModeObj *tvmode)
GX_Flush();
}
/* Reset GX/VI scaler */
static void gxResetScale(u32 width, u32 height)
/* Manage Aspect Ratio */
static void gxSetAspectRatio(int *xscale, int *yscale)
{
int temp = 0;
int xscale, yscale, xshift, yshift;
/* Aspect Ratio (depends on current configuration) */
/* original aspect ratio */
/* the following values have been deducted from comparison with a real 50/60hz Mega Drive */
if (config.aspect)
{
/* original aspect ratio */
/* the following values have been deducted from comparison with a real 50/60hz Mega Drive */
if (config.overscan)
{
/* borders are emulated */
xscale = 358 + ((reg[12] & 1)*2) - gc_pal;
yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120);
*xscale = 358 + ((reg[12] & 1)*2) - gc_pal;
*yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120);
}
else
{
/* borders are simulated (black) */
xscale = 325 + ((reg[12] & 1)*2) - gc_pal;
yscale = bitmap.viewport.h / 2;
if (vdp_pal && (!gc_pal || config.render)) yscale = yscale * 240 / 288;
else if (!vdp_pal && gc_pal && !config.render) yscale = yscale * 288 / 240;
*xscale = 325 + ((reg[12] & 1)*2) - gc_pal;
*yscale = bitmap.viewport.h / 2;
if (vdp_pal && (!gc_pal || config.render)) *yscale = *yscale * 240 / 288;
else if (!vdp_pal && gc_pal && !config.render) *yscale = *yscale * 288 / 240;
}
/* 16/9 correction */
if (config.aspect & 2) xscale = (xscale * 3) / 4;
xshift = config.xshift;
yshift = 2 - vdp_pal + 2*(gc_pal & !config.render) + config.yshift;
if (config.aspect & 2)
*xscale = (*xscale * 3) / 4;
}
/* manual aspect ratio (default is fullscreen) */
else
{
/* manual aspect ratio (default is fullscreen) */
if (config.overscan)
{
/* borders are emulated */
xscale = 352;
yscale = (gc_pal && !config.render) ? (vdp_pal ? (268*144 / bitmap.viewport.h):143) : (vdp_pal ? (224*144 / bitmap.viewport.h):120);
*xscale = 352;
*yscale = (gc_pal && !config.render) ? (vdp_pal ? (268*144 / bitmap.viewport.h):143) : (vdp_pal ? (224*144 / bitmap.viewport.h):120);
}
else
{
/* borders are simulated (black) */
xscale = 320;
yscale = (gc_pal && !config.render) ? 134 : 112;
*xscale = 320;
*yscale = (gc_pal && !config.render) ? 134 : 112;
}
/* user scaling */
xscale += config.xscale;
yscale += config.yscale;
xshift = config.xshift;
yshift = config.yshift;
/* add user scaling */
*xscale += config.xscale;
*yscale += config.yscale;
}
}
/* double resolution modes */
if (config.render)
{
yscale *= 2;
yshift *= 2;
}
/* Reset GX/VI hardware scaler */
static void gxResetScaler(u32 width, u32 height)
{
/* get Aspect Ratio (depends on current configuration) */
int xscale,yscale;
gxSetAspectRatio(&xscale, &yscale);
/* GX scaler (by default, use EFB maximal width) */
/* GX horizontal scaling (done during EFB rendering) */
/* by default, use maximal EFB width */
rmode->fbWidth = 640;
if (!config.bilinear && !config.ntsc)
{
/* filtering (soft or hard) is disabled, let VI handles horizontal scaling */
/* if possible, let GX simply doubles the width, otherwise disable GX stretching completely */
if ((width * 2) <= 640) rmode->fbWidth = width * 2;
else if (width <= 640) rmode->fbWidth = width;
if ((width * 2) <= 640)
rmode->fbWidth = width * 2; /* GX scaling enabled (simple doubler) */
else if (width <= 640)
rmode->fbWidth = width; /* GX scaling disabled */
}
/* horizontal scaling (GX/VI) */
if (xscale > (rmode->fbWidth/2))
/* VI horizontal scaling (done during EFB->XFB copy) */
int offset = 0;
if ((xscale * 2) > rmode->fbWidth)
{
/* max width = 720 pixels */
if (xscale > 360)
{
/* save offset for later */
temp = xscale - 360;
offset = xscale - 360;
/* maximal width */
xscale = 360;
}
/* enable VI scaler */
/* VI horizontal scaling is enabled */
rmode->viWidth = xscale * 2;
rmode->viXOrigin = (720 - (xscale * 2)) / 2;
/* set GX scaling to max EFB width */
xscale = temp + (rmode->fbWidth/2);
/* update GX horizontal scaling (disabled if no offset) */
xscale = (rmode->fbWidth / 2) + ((offset * rmode->fbWidth) / rmode->viWidth);
}
else
{
/* disable VI scaler */
/* VI horizontal scaling is disabled */
rmode->viWidth = rmode->fbWidth;
rmode->viXOrigin = (720 - rmode->fbWidth) / 2;
}
/* update GX scaler (Vertex Position Matrix) */
square[6] = square[3] = xscale + xshift;
square[0] = square[9] = -xscale + xshift;
square[4] = square[1] = yscale + yshift;
square[7] = square[10] = -yscale + yshift;
/* Adjust screen position */
int xshift = (config.xshift * rmode->fbWidth) / rmode->viWidth;
int yshift = (config.yshift * rmode->efbHeight) / rmode->viHeight;
/* Configure GX vertical scaling (480i/576i/480p) */
if (config.render)
{
yscale = yscale * 2;
}
/* Set GX scaler (Vertex Position matrix) */
square[6] = square[3] = xshift + xscale;
square[0] = square[9] = xshift - xscale;
square[4] = square[1] = yshift + yscale;
square[7] = square[10] = yshift - yscale;
DCFlushRange(square, 32);
GX_InvVtxCache();
}
@ -759,26 +766,28 @@ void gxDrawScreenshot(u8 alpha)
{
if (!rmode) return;
/* retrieve gamescreen texture */
/* get current game screen texture */
GXTexObj texobj;
GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE);
GX_LoadTexObj(&texobj, GX_TEXMAP0);
GX_InvalidateTexAll();
/* retrieve current xscale/xshift values */
s32 xscale = (rmode->viWidth + square[6] - square[0] - rmode->fbWidth) / 2 - (vmode->viWidth - 640)/2;
s32 xshift = (square[6] + square[0]) / 2;
/* get current aspect ratio */
int xscale,yscale;
gxSetAspectRatio(&xscale, &yscale);
/* apply current position/size */
/* adjust horizontal scaling */
xscale = (xscale * vmode->fbWidth) / vmode->viWidth;
/* adjust screen position */
int xshift = (config.xshift * vmode->fbWidth) / vmode->viWidth;
int yshift = (config.yshift * vmode->efbHeight) / vmode->viHeight;
/* set vertices position & size */
s32 x = xshift - xscale;
s32 y = square[7];
s32 y = yshift - (yscale * 2);
s32 w = xscale * 2;
s32 h = square[4] - square[7];
if (rmode->efbHeight < 480)
{
y = y * 2;
h = h * 2;
}
s32 h = yscale * 4;
/* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
@ -808,7 +817,7 @@ void gxCopyScreenshot(gx_texture *texture)
GX_InvalidateTexAll();
/* scale texture to EFB width */
s32 w = bitmap.viewport.x ? (704) : (640);
s32 w = bitmap.viewport.x ? 704 : 640;
s32 h = (bitmap.viewport.h + 2*bitmap.viewport.y) * 2;
s32 x = -w/2;
s32 y = -(240+ 2*bitmap.viewport.y);
@ -1256,10 +1265,10 @@ void gx_video_Stop(void)
VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu);
/* reset VI & adjust overscan */
gxDrawScreenshot(0xff);
vmode->viWidth = config.screen_w;
vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth)/2;
VIDEO_Configure(vmode);
gxDrawScreenshot(0xff);
gxSetScreen();
}
@ -1379,7 +1388,7 @@ void gx_video_Update(void)
else rmode = tvmodes[gc_pal*3 + interlaced];
/* reset aspect ratio */
gxResetScale(vwidth,vheight);
gxResetScaler(vwidth,vheight);
/* reset GX */
gxResetView(rmode);

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB