Skip to content

Commit

Permalink
Organized image interpolation menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bubio committed Oct 23, 2023
1 parent 5fdd170 commit 9e25683
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 125 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"vector": "cpp",
"__config": "cpp",
"typeinfo": "cpp",
"ios": "cpp"
"ios": "cpp",
"new": "cpp",
"string": "cpp"
},
}
6 changes: 5 additions & 1 deletion Source/UI/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ bool App::Init()
}

// spcfiy scaling quality (all platforms)
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setting->GetScaleQuality());
if (setting->IsImageInterpolation()) {
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
} else {
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setting->GetScaleQuality());
}

// platform (1)
platform = new Platform(this);
Expand Down
171 changes: 89 additions & 82 deletions Source/UI/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,16 +691,10 @@ void Menu::EnterSystem(int id)
// EnterVideo()
// enter video menu
//
void Menu::EnterVideo()
void Menu::EnterVideo(int id)
{
int id;
const char *quality;

list->SetTitle("<< Video Options >>", MENU_VIDEO);

// default focus
id = MENU_VIDEO_SKIP0;

#ifndef __ANDROID__
// window size
list->AddRadioButton("Window x1.0 (640x400)", MENU_VIDEO_640, MENU_VIDEO_WINDOW);
Expand Down Expand Up @@ -728,11 +722,8 @@ void Menu::EnterVideo()
list->AddCheckButton("Status area", MENU_VIDEO_STATUSCHK);
list->AddSlider("Status transparency", MENU_VIDEO_STATUSALPHA, 0, 0xff, 1);

// scaling quality
list->AddCheckButton("Scaling filter", MENU_VIDEO_SCALEFILTER);

// interpolation
list->AddCheckButton("Interpolation", MENU_VIDEO_INTERPOLATION);
// scaling filter
list->AddButton("Scaling filter", MENU_VIDEO_SCALEFILTER);

#ifdef __ANDROID__
// force RGB565
Expand All @@ -743,19 +734,15 @@ void Menu::EnterVideo()
switch (setting->GetSkipFrame()) {
case 0:
list->SetRadio(MENU_VIDEO_SKIP0, MENU_VIDEO_SKIP);
id = MENU_VIDEO_SKIP0;
break;
case 1:
list->SetRadio(MENU_VIDEO_SKIP1, MENU_VIDEO_SKIP);
id = MENU_VIDEO_SKIP1;
break;
case 2:
list->SetRadio(MENU_VIDEO_SKIP2, MENU_VIDEO_SKIP);
id = MENU_VIDEO_SKIP2;
break;
case 3:
list->SetRadio(MENU_VIDEO_SKIP3, MENU_VIDEO_SKIP);
id = MENU_VIDEO_SKIP3;
break;
default:
break;
Expand All @@ -766,23 +753,18 @@ void Menu::EnterVideo()
switch (setting->GetWindowWidth()) {
case 640:
list->SetRadio(MENU_VIDEO_640, MENU_VIDEO_WINDOW);
id = MENU_VIDEO_640;
break;
case 960:
list->SetRadio(MENU_VIDEO_960, MENU_VIDEO_WINDOW);
id = MENU_VIDEO_960;
break;
case 1280:
list->SetRadio(MENU_VIDEO_1280, MENU_VIDEO_WINDOW);
id = MENU_VIDEO_1280;
break;
case 1600:
list->SetRadio(MENU_VIDEO_1600, MENU_VIDEO_WINDOW);
id = MENU_VIDEO_1600;
break;
case 1920:
list->SetRadio(MENU_VIDEO_1920, MENU_VIDEO_WINDOW);
id = MENU_VIDEO_1920;
break;
default:
break;
Expand All @@ -807,18 +789,6 @@ void Menu::EnterVideo()
list->SetCheck(MENU_VIDEO_STATUSCHK, setting->HasStatusLine());
list->SetSlider(MENU_VIDEO_STATUSALPHA, setting->GetStatusAlpha());

// scaling quality
quality = setting->GetScaleQuality();
if (quality[0] == '0') {
list->SetCheck(MENU_VIDEO_SCALEFILTER, false);
}
else {
list->SetCheck(MENU_VIDEO_SCALEFILTER, true);
}

// image interpolation
list->SetCheck(MENU_VIDEO_INTERPOLATION, setting->HasImageInterpolation());

#ifdef __ANDROID__
// force RGB565
list->SetCheck(MENU_VIDEO_FORCERGB565, setting->IsForceRGB565());
Expand All @@ -828,6 +798,58 @@ void Menu::EnterVideo()
list->SetFocus(id);
}

//
// EnterScalingFilter()
// enter scaling filter menu
//
void Menu::EnterScalingFilter()
{
int id;
const char *quality;

list->SetTitle("<< VIDEO SCALING FILTER >>", MENU_SCALEFILTER);


list->AddRadioButton("Nearest", MENU_SCALEFILTER_NEAREST, MENU_VIDEO_SCALEFILTER);
list->AddRadioButton("Linear", MENU_SCALEFILTER_LINEAR, MENU_VIDEO_SCALEFILTER);
#ifdef _WIN32
list->AddRadioButton("Anisotropic ", MENU_SCALEFILTER_ANISOTROPIC, MENU_VIDEO_SCALEFILTER);
#endif // _WIN32
list->AddRadioButton("xBRZ", MENU_SCALEFILTER_XBRZ, MENU_VIDEO_SCALEFILTER);

quality = setting->GetScaleQuality();
switch (*quality)
{
case '0':
list->SetRadio(MENU_SCALEFILTER_NEAREST, MENU_VIDEO_SCALEFILTER);
id = MENU_SCALEFILTER_NEAREST;
break;

case '1':
list->SetRadio(MENU_SCALEFILTER_LINEAR, MENU_VIDEO_SCALEFILTER);
id = MENU_SCALEFILTER_LINEAR;
break;

case '2':
list->SetRadio(MENU_SCALEFILTER_ANISOTROPIC, MENU_VIDEO_SCALEFILTER);
id = MENU_SCALEFILTER_ANISOTROPIC;
break;
case '3':
list->SetRadio(MENU_SCALEFILTER_XBRZ, MENU_VIDEO_SCALEFILTER);
id = MENU_SCALEFILTER_XBRZ;
break;

default:
list->SetRadio(MENU_SCALEFILTER_NEAREST, MENU_VIDEO_SCALEFILTER);
id = MENU_SCALEFILTER_NEAREST;
break;
}

// set focus
list->SetFocus(id);
}


//
// EnterAudio()
// enter audio menu
Expand Down Expand Up @@ -1494,7 +1516,9 @@ void Menu::Command(bool down, int id)

// video menu
if ((id >= MENU_VIDEO_MIN) && (id <= MENU_VIDEO_MAX)) {
CmdVideo(down, id);
if (down == false) {
CmdVideo(down, id);
}
return;
}

Expand Down Expand Up @@ -1570,6 +1594,14 @@ void Menu::Command(bool down, int id)
return;
}

// audio device menu
if ((id >= MENU_SCALEFILTER_MIN) && (id <= MENU_SCALEFILTER_MAX)) {
if (down == false) {
CmdScalingFilter(down, id);
}
return;
}

// file menu
if (id >= MENU_FILE_MIN) {
if (down == false) {
Expand Down Expand Up @@ -1633,7 +1665,6 @@ void Menu::CmdBack()
// audio output menu
case MENU_AUDIO_OUT:
EnterMain(MENU_MAIN_AUDIO_OUT);
// EnterAudio();
break;

// input menu
Expand Down Expand Up @@ -1684,6 +1715,11 @@ void Menu::CmdBack()
EnterInput(MENU_INPUT_JOYTEST);
break;

// video scaling filter menu
case MENU_SCALEFILTER:
EnterVideo(MENU_VIDEO_SCALEFILTER);
break;

// file menu
case MENU_FILE:
switch (file_id) {
Expand Down Expand Up @@ -1765,7 +1801,7 @@ void Menu::CmdMain(int id)

// video options
case MENU_MAIN_VIDEO:
EnterVideo();
EnterVideo(MENU_VIDEO_SKIP0);
break;

// audio options
Expand Down Expand Up @@ -2145,9 +2181,7 @@ void Menu::CmdVideo(bool down, int id)
bool lowreso;
bool radio;
bool scanline;
bool interpolation;
bool status;
const char *quality;
int width;

// initialize
Expand Down Expand Up @@ -2287,43 +2321,8 @@ void Menu::CmdVideo(bool down, int id)

// scaling quality
case MENU_VIDEO_SCALEFILTER:
if (down == false) {
quality = setting->GetScaleQuality();
if (quality[0] != '0') {
setting->SetScaleQuality(0);
list->SetCheck(MENU_VIDEO_SCALEFILTER, false);
video->RebuildTexture(false);
}
else {
#ifdef _WIN32
setting->SetScaleQuality(2);
#else
setting->SetScaleQuality(1);
#endif // _WIN32
list->SetCheck(MENU_VIDEO_SCALEFILTER, true);
video->RebuildTexture(false);
}
}
break;

// Image Interpolation
case MENU_VIDEO_INTERPOLATION:
if (down == false) {
interpolation = setting->HasImageInterpolation();
if (interpolation == true) {
setting->SetImageInterpolation(false);
list->SetCheck(MENU_VIDEO_INTERPOLATION, false);
video->RebuildTexture(false);
}
else {
setting->SetImageInterpolation(true);
list->SetCheck(MENU_VIDEO_INTERPOLATION, true);
video->RebuildTexture(false);
}
}
break;


EnterScalingFilter();
return;

#ifdef __ANDROID__
// force RGB565
Expand Down Expand Up @@ -3014,9 +3013,6 @@ void Menu::CmdAudioOut(bool down, int id)
// get current audio device
int current_audio_device = setting->GetAudioDevice();

// leave flag
bool leave = false;

if (down == false) {
list->SetRadio(id, MENU_AUDIO_DEVICE);
setting->SetAudioDevice(id - MENU_AUDIO_DEVICE_MIN);
Expand All @@ -3026,14 +3022,25 @@ void Menu::CmdAudioOut(bool down, int id)
if (setting->GetAudioDevice() != current_audio_device) {
app->ChangeAudio();
}
}

// leave menu
if (leave == true) {
app->LeaveMenu();
//
// CmdScalingFilter()
// command (Scaling Filter)
//
void Menu::CmdScalingFilter(bool down, int id)
{
const char* quality = setting->GetScaleQuality();
if (down == false) {
int filterId = (id - MENU_SCALEFILTER_MIN - 1);
if ((*quality - '0') != filterId) {
setting->SetScaleQuality(filterId);
EnterScalingFilter();
video->RebuildTexture(false);
}
}
}


//
// CmdFile()
// command (file)
Expand Down
6 changes: 5 additions & 1 deletion Source/UI/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Menu
// enter save menu
void EnterSystem(int id);
// enter system menu
void EnterVideo();
void EnterVideo(int id);
// enter video menu
void EnterAudio();
// enter audio menu
Expand All @@ -71,6 +71,8 @@ class Menu
// enter joymap menu
void EnterVmKey(int id);
// enter vmkey menu
void EnterScalingFilter();
// enter scaling filter menu
void EnterFile();
// enter file menu
void EnterJoyTest();
Expand Down Expand Up @@ -115,6 +117,8 @@ class Menu
// command (audio out)
void CmdFile(int id);
// command (file)
void CmdScalingFilter(bool down, int id);
// command (video scaling filter)
void JoyTest();
// joystick test
void Draw();
Expand Down
17 changes: 14 additions & 3 deletions Source/UI/menuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
// file menu
#define MENU_JOYTEST 22
// joystick test menu

#define MENU_SCALEFILTER 23
// video scale filter
//
// main menu
//
Expand Down Expand Up @@ -282,8 +283,6 @@
// scaling filter
#define MENU_VIDEO_FORCERGB565 817
// force RGB565
#define MENU_VIDEO_INTERPOLATION 818
// interpolation
#define MENU_VIDEO_WINDOW 896
// window radio
#define MENU_VIDEO_SKIP 897
Expand Down Expand Up @@ -738,7 +737,19 @@
// maximum

#define MENU_AUDIO_DEVICE_MIN 1800
// minimum
#define MENU_AUDIO_DEVICE_MAX 1899
// maximum

//
// video scaling filter menu
//
#define MENU_SCALEFILTER_MIN 1900
#define MENU_SCALEFILTER_NEAREST 1901
#define MENU_SCALEFILTER_LINEAR 1902
#define MENU_SCALEFILTER_ANISOTROPIC 1903
#define MENU_SCALEFILTER_XBRZ 1904
#define MENU_SCALEFILTER_MAX 1999

//
// file menu
Expand Down
Loading

0 comments on commit 9e25683

Please sign in to comment.