OSD: filters/gamma/mask quick switch by +/-
This commit is contained in:
13
audio.cpp
13
audio.cpp
@@ -234,12 +234,19 @@ int audio_filter_en()
|
||||
return has_filter ? filter_cfg[0] : -1;
|
||||
}
|
||||
|
||||
char* audio_get_filter()
|
||||
char* audio_get_filter(int only_name)
|
||||
{
|
||||
return filter_cfg + 1;
|
||||
char *path = filter_cfg + 1;
|
||||
if (only_name)
|
||||
{
|
||||
char *p = strrchr(path, '/');
|
||||
if (p) return p + 1;
|
||||
}
|
||||
return path;
|
||||
|
||||
}
|
||||
|
||||
void audio_set_filter(char *name)
|
||||
void audio_set_filter(const char *name)
|
||||
{
|
||||
strcpy(filter_cfg + 1, name);
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name());
|
||||
|
||||
4
audio.h
4
audio.h
@@ -10,8 +10,8 @@ void save_volume();
|
||||
void load_volume();
|
||||
|
||||
int audio_filter_en();
|
||||
char* audio_get_filter();
|
||||
void audio_set_filter(char *name);
|
||||
char* audio_get_filter(int only_name);
|
||||
void audio_set_filter(const char *name);
|
||||
void audio_set_filter_en(int n);
|
||||
|
||||
#endif
|
||||
|
||||
36
file_io.cpp
36
file_io.cpp
@@ -57,6 +57,8 @@ static mz_zip_archive last_zip_archive = {};
|
||||
static int last_zip_fd = -1;
|
||||
static FILE *last_zip_cfile = NULL;
|
||||
static char last_zip_fname[256] = {};
|
||||
static char scanned_path[1024] = {};
|
||||
static int scanned_opts = 0;
|
||||
|
||||
static int iSelectedEntry = 0; // selected entry index
|
||||
static int iFirstEntry = 0;
|
||||
@@ -1357,7 +1359,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
iFirstEntry = 0;
|
||||
iSelectedEntry = 0;
|
||||
DirItem.clear();
|
||||
DirNames.clear();
|
||||
DirNames.clear();
|
||||
|
||||
file_name[0] = 0;
|
||||
|
||||
@@ -1377,6 +1379,8 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
}
|
||||
|
||||
if (!isPathDirectory(path)) return 0;
|
||||
snprintf(scanned_path, sizeof(scanned_path), "%s", path);
|
||||
scanned_opts = options;
|
||||
|
||||
if (options & SCANO_NEOGEO) neogeo_scan_xml(path);
|
||||
|
||||
@@ -1830,6 +1834,11 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* flist_Path()
|
||||
{
|
||||
return scanned_path;
|
||||
}
|
||||
|
||||
int flist_nDirEntries()
|
||||
{
|
||||
return DirItem.size();
|
||||
@@ -1860,10 +1869,31 @@ direntext_t* flist_SelectedItem()
|
||||
return &DirItem[iSelectedEntry];
|
||||
}
|
||||
|
||||
char* flist_GetPrevNext(const char* base_path, const char* file, const char* ext, int next)
|
||||
{
|
||||
static char path[1024];
|
||||
snprintf(path, sizeof(path), "%s/%s", base_path, file);
|
||||
char *p = strrchr(path, '/');
|
||||
if (!FileExists(path))
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s", base_path);
|
||||
p = 0;
|
||||
}
|
||||
|
||||
int len = (p) ? p - path : strlen(path);
|
||||
if (strncasecmp(scanned_path, path, len) || (scanned_opts & SCANO_DIR)) ScanDirectory(path, SCANF_INIT, ext, 0);
|
||||
|
||||
if (!DirItem.size()) return NULL;
|
||||
if (p) ScanDirectory(path, next ? SCANF_NEXT : SCANF_PREV, "", 0);
|
||||
snprintf(path, sizeof(path), "%s/%s", scanned_path, DirItem[iSelectedEntry].de.d_name);
|
||||
|
||||
return path + strlen(base_path) + 1;
|
||||
}
|
||||
|
||||
bool isMraName(char *path)
|
||||
{
|
||||
char *spl = strrchr(path, '.');
|
||||
return (spl && !strcmp(spl, ".mra"));
|
||||
char *spl = strrchr(path, '.');
|
||||
return (spl && !strcmp(spl, ".mra"));
|
||||
}
|
||||
|
||||
fileTextReader::fileTextReader()
|
||||
|
||||
@@ -50,6 +50,8 @@ void flist_iFirstEntryInc();
|
||||
int flist_iSelectedEntry();
|
||||
direntext_t* flist_DirItem(int n);
|
||||
direntext_t* flist_SelectedItem();
|
||||
char* flist_Path();
|
||||
char* flist_GetPrevNext(const char* base_path, const char* file, const char* ext, int next);
|
||||
|
||||
// scanning flags
|
||||
#define SCANF_INIT 0 // start search from beginning of directory
|
||||
|
||||
70
menu.cpp
70
menu.cpp
@@ -2321,7 +2321,7 @@ void HandleUI(void)
|
||||
|
||||
memset(s, 0, sizeof(s));
|
||||
s[0] = ' ';
|
||||
if (strlen(audio_get_filter())) strncpy(s + 1, audio_get_filter(), 25);
|
||||
if (strlen(audio_get_filter(1))) strncpy(s + 1, audio_get_filter(1), 25);
|
||||
else strcpy(s, " < none >");
|
||||
|
||||
while (strlen(s) < 26) strcat(s, " ");
|
||||
@@ -2443,7 +2443,7 @@ void HandleUI(void)
|
||||
case 10:
|
||||
if (audio_filter_en())
|
||||
{
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), AFILTER_DIR"/%s", audio_get_filter());
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), AFILTER_DIR"/%s", audio_get_filter(0));
|
||||
if (!FileExists(Selected_tmp)) snprintf(Selected_tmp, sizeof(Selected_tmp), AFILTER_DIR);
|
||||
SelectFile(Selected_tmp, 0, SCANO_DIR | SCANO_TXT, MENU_AFILTER_FILE_SELECTED, MENU_COMMON1);
|
||||
}
|
||||
@@ -2543,6 +2543,15 @@ void HandleUI(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (minus || plus)
|
||||
{
|
||||
if (menusub == 10 && audio_filter_en())
|
||||
{
|
||||
const char *newfile = flist_GetPrevNext(AFILTER_DIR, audio_get_filter(0), "TXT", plus);
|
||||
audio_set_filter(newfile ? newfile : "");
|
||||
menustate = MENU_COMMON1;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hold_cnt && reboot_req) fpga_load_rbf("menu.rbf");
|
||||
break;
|
||||
@@ -2628,16 +2637,6 @@ void HandleUI(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (plus || minus)
|
||||
{
|
||||
if (menusub == 9)
|
||||
{
|
||||
video_set_shadow_mask_mode(video_get_shadow_mask_mode() + (plus ? 1 : -1));
|
||||
}
|
||||
menustate = parentstate;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((select || recent) && menusub == 0)
|
||||
{
|
||||
fs_Options = SCANO_DIR | SCANO_TXT;
|
||||
@@ -2650,6 +2649,47 @@ void HandleUI(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (plus || minus)
|
||||
{
|
||||
if (menusub == 9)
|
||||
{
|
||||
video_set_shadow_mask_mode(video_get_shadow_mask_mode() + (plus ? 1 : -1));
|
||||
}
|
||||
|
||||
switch (menusub)
|
||||
{
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
vfilter_type = (menusub == 2) ? VFILTER_HORZ : (menusub == 4) ? VFILTER_VERT : VFILTER_SCAN;
|
||||
if(video_get_scaler_flt(VFILTER_HORZ) && video_get_scaler_flt(vfilter_type))
|
||||
{
|
||||
const char *newfile = flist_GetPrevNext(COEFF_DIR, video_get_scaler_coeff(vfilter_type, 0), "TXT", plus);
|
||||
video_set_scaler_coeff(vfilter_type, newfile ? newfile : "");
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if(video_get_gamma_en() > 0)
|
||||
{
|
||||
const char *newfile = flist_GetPrevNext(GAMMA_DIR, video_get_gamma_curve(0), "TXT", plus);
|
||||
video_set_gamma_curve(newfile ? newfile : "");
|
||||
}
|
||||
break;
|
||||
|
||||
case 10:
|
||||
if (video_get_shadow_mask_mode() > 0)
|
||||
{
|
||||
const char *newfile = flist_GetPrevNext(SMASK_DIR, video_get_shadow_mask(0), "TXT", plus);
|
||||
video_set_shadow_mask(newfile ? newfile : "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
menustate = parentstate;
|
||||
break;
|
||||
}
|
||||
|
||||
if (select)
|
||||
{
|
||||
switch (menusub)
|
||||
@@ -2668,7 +2708,7 @@ void HandleUI(void)
|
||||
vfilter_type = (menusub == 2) ? VFILTER_HORZ : (menusub == 4) ? VFILTER_VERT : VFILTER_SCAN;
|
||||
if (video_get_scaler_flt(VFILTER_HORZ))
|
||||
{
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), COEFF_DIR"/%s", video_get_scaler_coeff(vfilter_type));
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), COEFF_DIR"/%s", video_get_scaler_coeff(vfilter_type, 0));
|
||||
if (!FileExists(Selected_tmp)) snprintf(Selected_tmp, sizeof(Selected_tmp), COEFF_DIR);
|
||||
SelectFile(Selected_tmp, 0, SCANO_DIR | SCANO_TXT, MENU_COEFF_FILE_SELECTED, parentstate);
|
||||
}
|
||||
@@ -2698,7 +2738,7 @@ void HandleUI(void)
|
||||
case 8:
|
||||
if (video_get_gamma_en() > 0)
|
||||
{
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), GAMMA_DIR"/%s", video_get_gamma_curve());
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), GAMMA_DIR"/%s", video_get_gamma_curve(0));
|
||||
if (!FileExists(Selected_tmp)) snprintf(Selected_tmp, sizeof(Selected_tmp), GAMMA_DIR);
|
||||
SelectFile(Selected_tmp, 0, SCANO_DIR | SCANO_TXT, MENU_GAMMA_FILE_SELECTED, parentstate);
|
||||
}
|
||||
@@ -2712,7 +2752,7 @@ void HandleUI(void)
|
||||
case 10:
|
||||
if (video_get_shadow_mask_mode() > 0)
|
||||
{
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), SMASK_DIR"/%s", video_get_shadow_mask());
|
||||
snprintf(Selected_tmp, sizeof(Selected_tmp), SMASK_DIR"/%s", video_get_shadow_mask(0));
|
||||
if (!FileExists(Selected_tmp)) snprintf(Selected_tmp, sizeof(Selected_tmp), SMASK_DIR);
|
||||
SelectFile(Selected_tmp, 0, SCANO_DIR | SCANO_TXT, MENU_SMASK_FILE_SELECTED, parentstate);
|
||||
}
|
||||
|
||||
34
video.cpp
34
video.cpp
@@ -323,9 +323,15 @@ int video_get_scaler_flt(int type)
|
||||
return scaler_flt[type][0];
|
||||
}
|
||||
|
||||
char* video_get_scaler_coeff(int type)
|
||||
char* video_get_scaler_coeff(int type, int only_name)
|
||||
{
|
||||
return scaler_flt[type] + 1;
|
||||
char *path = scaler_flt[type] + 1;
|
||||
if (only_name)
|
||||
{
|
||||
char *p = strrchr(path, '/');
|
||||
if (p) return p + 1;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static char scaler_cfg[128] = { 0 };
|
||||
@@ -434,9 +440,15 @@ int video_get_gamma_en()
|
||||
return has_gamma ? gamma_cfg[0] : -1;
|
||||
}
|
||||
|
||||
char* video_get_gamma_curve()
|
||||
char* video_get_gamma_curve(int only_name)
|
||||
{
|
||||
return gamma_cfg + 1;
|
||||
char *path = gamma_cfg + 1;
|
||||
if (only_name)
|
||||
{
|
||||
char *p = strrchr(path, '/');
|
||||
if (p) return p + 1;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static char gamma_cfg_path[1024] = { 0 };
|
||||
@@ -448,7 +460,7 @@ void video_set_gamma_en(int n)
|
||||
setGamma();
|
||||
}
|
||||
|
||||
void video_set_gamma_curve(char *name)
|
||||
void video_set_gamma_curve(const char *name)
|
||||
{
|
||||
strcpy(gamma_cfg + 1, name);
|
||||
FileSaveConfig(gamma_cfg_path, &gamma_cfg, sizeof(gamma_cfg));
|
||||
@@ -593,9 +605,15 @@ int video_get_shadow_mask_mode()
|
||||
return has_shadow_mask ? shadow_mask_cfg[0] : -1;
|
||||
}
|
||||
|
||||
char* video_get_shadow_mask()
|
||||
char* video_get_shadow_mask(int only_name)
|
||||
{
|
||||
return shadow_mask_cfg + 1;
|
||||
char *path = shadow_mask_cfg + 1;
|
||||
if (only_name)
|
||||
{
|
||||
char *p = strrchr(path, '/');
|
||||
if (p) return p + 1;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
static char shadow_mask_cfg_path[1024] = { 0 };
|
||||
@@ -616,7 +634,7 @@ void video_set_shadow_mask_mode(int n)
|
||||
setShadowMask();
|
||||
}
|
||||
|
||||
void video_set_shadow_mask(char *name)
|
||||
void video_set_shadow_mask(const char *name)
|
||||
{
|
||||
strcpy(shadow_mask_cfg + 1, name);
|
||||
FileSaveConfig(shadow_mask_cfg_path, &shadow_mask_cfg, sizeof(shadow_mask_cfg));
|
||||
|
||||
10
video.h
10
video.h
@@ -7,18 +7,18 @@
|
||||
|
||||
int video_get_scaler_flt(int type);
|
||||
void video_set_scaler_flt(int type, int n);
|
||||
char* video_get_scaler_coeff(int type);
|
||||
char* video_get_scaler_coeff(int type, int only_name = 1);
|
||||
void video_set_scaler_coeff(int type, const char *name);
|
||||
|
||||
int video_get_gamma_en();
|
||||
void video_set_gamma_en(int n);
|
||||
char* video_get_gamma_curve();
|
||||
void video_set_gamma_curve(char *name);
|
||||
char* video_get_gamma_curve(int only_name = 1);
|
||||
void video_set_gamma_curve(const char *name);
|
||||
|
||||
int video_get_shadow_mask_mode();
|
||||
void video_set_shadow_mask_mode(int n);
|
||||
char* video_get_shadow_mask();
|
||||
void video_set_shadow_mask(char *name);
|
||||
char* video_get_shadow_mask(int only_name = 1);
|
||||
void video_set_shadow_mask(const char *name);
|
||||
void video_loadPreset(char *name);
|
||||
|
||||
void video_mode_load();
|
||||
|
||||
Reference in New Issue
Block a user