Add slider for fullscreen ratio

This commit is contained in:
Chips 2016-05-15 18:44:29 +00:00
parent 996ac3dab2
commit 7773c9ccca
4 changed files with 115 additions and 43 deletions

View file

@ -397,6 +397,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
#ifdef RASPBERRY
cfgfile_write (f, _T("gfx_correct_aspect"), _T("%d"), p->gfx_correct_aspect);
cfgfile_write (f, _T("gfx_fullscreen_ratio"), _T("%d"), p->gfx_fullscreen_ratio);
#endif
cfgfile_write_bool (f, _T("immediate_blits"), p->immediate_blits);
@ -704,6 +705,9 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
#ifdef RASPBERRY
if (cfgfile_intval (option, value, "gfx_correct_aspect", &p->gfx_correct_aspect, 1))
return 1;
if (cfgfile_intval (option, value, "gfx_fullscreen_ratio", &p->gfx_fullscreen_ratio, 1))
return 1;
#endif
if (cfgfile_string (option, value, _T("config_info"), p->info, sizeof p->info / sizeof (TCHAR))
@ -1757,6 +1761,7 @@ void default_prefs (struct uae_prefs *p, int type)
p->gfx_resolution = RES_LORES;
#ifdef RASPBERRY
p->gfx_correct_aspect = 1;
p->gfx_fullscreen_ratio = 100;
#endif
p->immediate_blits = 0;
p->chipset_refreshrate = 50;

View file

@ -89,7 +89,8 @@ struct uae_prefs {
int gfx_resolution;
#ifdef RASPBERRY
int gfx_correct_aspect;
int gfx_correct_aspect;
int gfx_fullscreen_ratio;
#endif
bool immediate_blits;

View file

@ -20,6 +20,10 @@
const int amigawidth_values[] = { 320, 352, 384, 640, 704, 768 };
const int amigaheight_values[] = { 200, 216, 240, 256, 262, 270 };
#ifdef RASPBERRY
const int FullscreenRatio[] = { 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97 ,98, 99 ,100 };
#endif
static gcn::Window *grpAmigaScreen;
static gcn::Label* lblAmigaWidth;
@ -32,6 +36,11 @@ static gcn::Label* lblVertPos;
static gcn::Label* lblVertPosInfo;
static gcn::Slider* sldVertPos;
static gcn::UaeCheckBox* chkFrameskip;
#ifdef RASPBERRY
static gcn::Label* lblFSRatio;
static gcn::Label* lblFSRatioInfo;
static gcn::Slider* sldFSRatio;
#endif
class AmigaScreenActionListener : public gcn::ActionListener
@ -67,6 +76,16 @@ class AmigaScreenActionListener : public gcn::ActionListener
{
changed_prefs.gfx_framerate = chkFrameskip->isSelected() ? 1 : 0;
}
#ifdef RASPBERRY
else if (actionEvent.getSource() == sldFSRatio)
{
if(changed_prefs.gfx_fullscreen_ratio != FullscreenRatio[(int)(sldFSRatio->getValue())])
{
changed_prefs.gfx_fullscreen_ratio = FullscreenRatio[(int)(sldFSRatio->getValue())];
RefreshPanelDisplay();
}
}
#endif
}
};
AmigaScreenActionListener* amigaScreenActionListener;
@ -76,64 +95,87 @@ void InitPanelDisplay(const struct _ConfigCategory& category)
{
amigaScreenActionListener = new AmigaScreenActionListener();
lblAmigaWidth = new gcn::Label("Width:");
lblAmigaWidth->setSize(80, LABEL_HEIGHT);
lblAmigaWidth = new gcn::Label("Width:");
lblAmigaWidth->setSize(150, LABEL_HEIGHT);
lblAmigaWidth->setAlignment(gcn::Graphics::RIGHT);
sldAmigaWidth = new gcn::Slider(0, 5);
sldAmigaWidth->setSize(160, SLIDER_HEIGHT);
sldAmigaWidth->setBaseColor(gui_baseCol);
sldAmigaWidth->setMarkerLength(20);
sldAmigaWidth->setStepLength(1);
sldAmigaWidth->setId("sldWidth");
sldAmigaWidth->setMarkerLength(20);
sldAmigaWidth->setStepLength(1);
sldAmigaWidth->setId("sldWidth");
sldAmigaWidth->addActionListener(amigaScreenActionListener);
lblAmigaWidthInfo = new gcn::Label("320");
lblAmigaHeight = new gcn::Label("Height:");
lblAmigaHeight->setSize(80, LABEL_HEIGHT);
lblAmigaHeight = new gcn::Label("Height:");
lblAmigaHeight->setSize(150, LABEL_HEIGHT);
lblAmigaHeight->setAlignment(gcn::Graphics::RIGHT);
sldAmigaHeight = new gcn::Slider(0, 5);
sldAmigaHeight->setSize(160, SLIDER_HEIGHT);
sldAmigaHeight->setBaseColor(gui_baseCol);
sldAmigaHeight->setMarkerLength(20);
sldAmigaHeight->setStepLength(1);
sldAmigaHeight->setId("sldHeight");
sldAmigaHeight->setMarkerLength(20);
sldAmigaHeight->setStepLength(1);
sldAmigaHeight->setId("sldHeight");
sldAmigaHeight->addActionListener(amigaScreenActionListener);
lblAmigaHeightInfo = new gcn::Label("200");
lblVertPos = new gcn::Label("Vert. offset:");
lblVertPos->setSize(80, LABEL_HEIGHT);
lblVertPos = new gcn::Label("Vert. offset:");
lblVertPos->setSize(150, LABEL_HEIGHT);
lblVertPos->setAlignment(gcn::Graphics::RIGHT);
sldVertPos = new gcn::Slider(-16, 16);
sldVertPos->setSize(160, SLIDER_HEIGHT);
sldVertPos->setBaseColor(gui_baseCol);
sldVertPos->setMarkerLength(20);
sldVertPos->setStepLength(1);
sldVertPos->setId("sldVertPos");
sldVertPos->setMarkerLength(20);
sldVertPos->setStepLength(1);
sldVertPos->setId("sldVertPos");
sldVertPos->addActionListener(amigaScreenActionListener);
lblVertPosInfo = new gcn::Label("000");
chkFrameskip = new gcn::UaeCheckBox("Frameskip");
#ifdef RASPBERRY
lblFSRatio = new gcn::Label("Fullscreen Ratio:");
lblFSRatio->setSize(150, LABEL_HEIGHT);
lblFSRatio->setAlignment(gcn::Graphics::RIGHT);
sldFSRatio = new gcn::Slider(0, 20);
sldFSRatio->setSize(160, SLIDER_HEIGHT);
sldFSRatio->setBaseColor(gui_baseCol);
sldFSRatio->setMarkerLength(20);
sldFSRatio->setStepLength(1);
sldFSRatio->setId("FSRatio");
sldFSRatio->addActionListener(amigaScreenActionListener);
lblFSRatioInfo = new gcn::Label("100%%");
#endif
chkFrameskip = new gcn::UaeCheckBox("Frameskip");
chkFrameskip->addActionListener(amigaScreenActionListener);
grpAmigaScreen = new gcn::Window("Amiga Screen");
grpAmigaScreen->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
grpAmigaScreen = new gcn::Window("Amiga Screen");
grpAmigaScreen->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
int posY = 10;
grpAmigaScreen->add(lblAmigaWidth, 8, posY);
grpAmigaScreen->add(sldAmigaWidth, 100, posY);
grpAmigaScreen->add(lblAmigaWidthInfo, 100 + sldAmigaWidth->getWidth() + 12, posY);
posY += sldAmigaWidth->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblAmigaHeight, 8, posY);
grpAmigaScreen->add(sldAmigaHeight, 100, posY);
grpAmigaScreen->add(lblAmigaHeightInfo, 100 + sldAmigaHeight->getWidth() + 12, posY);
posY += sldAmigaHeight->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblVertPos, 8, posY);
grpAmigaScreen->add(sldVertPos, 100, posY);
grpAmigaScreen->add(lblVertPosInfo, 100 + sldVertPos->getWidth() + 12, posY);
posY += sldVertPos->getHeight() + DISTANCE_NEXT_Y;
int posY = 10;
grpAmigaScreen->add(lblAmigaWidth, 0, posY);
grpAmigaScreen->add(sldAmigaWidth, 160, posY);
grpAmigaScreen->add(lblAmigaWidthInfo, 160 + sldAmigaWidth->getWidth() + 12, posY);
posY += sldAmigaWidth->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblAmigaHeight, 0, posY);
grpAmigaScreen->add(sldAmigaHeight, 160, posY);
grpAmigaScreen->add(lblAmigaHeightInfo, 160 + sldAmigaHeight->getWidth() + 12, posY);
posY += sldAmigaHeight->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblVertPos, 0, posY);
grpAmigaScreen->add(sldVertPos, 160, posY);
grpAmigaScreen->add(lblVertPosInfo, 160 + sldVertPos->getWidth() + 12, posY);
posY += sldVertPos->getHeight() + DISTANCE_NEXT_Y;
#ifdef RASPBERRY
grpAmigaScreen->add(lblFSRatio, 0, posY);
grpAmigaScreen->add(sldFSRatio, 160, posY);
grpAmigaScreen->add(lblFSRatioInfo, 160 + sldFSRatio->getWidth() + 12, posY);
posY += sldFSRatio->getHeight() + DISTANCE_NEXT_Y;
#endif
grpAmigaScreen->setMovable(false);
grpAmigaScreen->setSize(320, posY + DISTANCE_BORDER);
grpAmigaScreen->setMovable(false);
grpAmigaScreen->setSize(460, posY + DISTANCE_BORDER);
grpAmigaScreen->setBaseColor(gui_baseCol);
category.panel->add(grpAmigaScreen);
@ -157,6 +199,11 @@ void ExitPanelDisplay(void)
delete grpAmigaScreen;
delete chkFrameskip;
delete amigaScreenActionListener;
#ifdef RASPBERRY
delete lblFSRatio;
delete sldFSRatio;
delete lblFSRatioInfo;
#endif
}
@ -187,6 +234,19 @@ void RefreshPanelDisplay(void)
}
}
#ifdef RASPBERRY
for(i=0; i<21; ++i)
{
if(changed_prefs.gfx_fullscreen_ratio == FullscreenRatio[i])
{
sldFSRatio->setValue(i);
snprintf(tmp, 32, "%d%%", changed_prefs.gfx_fullscreen_ratio);
lblFSRatioInfo->setCaption(tmp);
break;
}
}
#endif
sldVertPos->setValue(changed_prefs.pandora_vertical_offset);
snprintf(tmp, 32, "%d", changed_prefs.pandora_vertical_offset);
lblVertPosInfo->setCaption(tmp);

View file

@ -189,7 +189,8 @@ static void open_screen(struct uae_prefs *p)
// check if resolution hasn't change in menu. otherwise free the resources so that they will be re-generated with new resolution.
if ((dispmanxresource_amigafb_1 != 0) &&
((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect)))
((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect) ||
(currprefs.gfx_fullscreen_ratio != changed_prefs.gfx_fullscreen_ratio)))
{
printf("Emulation resolution change detected.\n");
if(prSDLScreen != NULL )
@ -208,6 +209,7 @@ static void open_screen(struct uae_prefs *p)
{
printf("Emulation resolution: Width %i Height: %i\n",width,height);
currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect;
currprefs.gfx_fullscreen_ratio = changed_prefs.gfx_fullscreen_ratio;
prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE,width,height,16,
Dummy_prSDLScreen->format->Rmask,
Dummy_prSDLScreen->format->Gmask,
@ -232,18 +234,22 @@ static void open_screen(struct uae_prefs *p)
if (currprefs.gfx_correct_aspect == 0)
{
// Fullscreen.
vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width * 1)/100,
(dispmanxdinfo.height * 2)/100 ,
dispmanxdinfo.width - (dispmanxdinfo.width * 2)/100 ,
dispmanxdinfo.height - (dispmanxdinfo.height * 4)/100 );
int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio/100;
int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio/100;
vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width)/2 ,
(dispmanxdinfo.height - scaled_height)/2 ,
scaled_width ,
scaled_height );
}
else
{
// 4/3 shrink.
vc_dispmanx_rect_set( &dst_rect, ((dispmanxdinfo.width * 13)/100) ,
(dispmanxdinfo.height * 2)/100 ,
(dispmanxdinfo.width - ((dispmanxdinfo.width * 26)/100)) ,
dispmanxdinfo.height - (dispmanxdinfo.height * 4)/100 );
int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio/100;
int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio/100;
vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width/16*12)/2 ,
(dispmanxdinfo.height - scaled_height)/2 ,
scaled_width/16*12 ,
scaled_height );
}
// For debug, in order to avoid full screen.