added initial system page to ui

This commit is contained in:
Anthony Pesch 2017-12-04 00:16:35 -05:00
parent 4009efb586
commit e4087c56a8
7 changed files with 154 additions and 98 deletions

View File

@ -14,19 +14,6 @@
#include "guest/sh4/sh4.h"
#include "options.h"
/* system settings */
static const char *regions[] = {
"japan", "usa", "europe",
};
static const char *languages[] = {
"japanese", "english", "german", "french", "spanish", "italian",
};
static const char *broadcasts[] = {
"ntsc", "pal", "pal_m", "pal_n",
};
/* address of syscall vectors */
enum {
VECTOR_SYSINFO = 0x0c0000b0,
@ -77,29 +64,29 @@ static void bios_override_settings(struct bios *bios) {
int bcast = 0;
uint32_t time = bios_local_time();
for (int i = 0; i < ARRAY_SIZE(regions); i++) {
if (!strcmp(OPTION_region, regions[i])) {
for (int i = 0; i < NUM_REGIONS; i++) {
if (!strcmp(OPTION_region, REGIONS[i])) {
region = i;
break;
}
}
for (int i = 0; i < ARRAY_SIZE(languages); i++) {
if (!strcmp(OPTION_language, languages[i])) {
for (int i = 0; i < NUM_LANGUAGES; i++) {
if (!strcmp(OPTION_language, LANGUAGES[i])) {
lang = i;
break;
}
}
for (int i = 0; i < ARRAY_SIZE(broadcasts); i++) {
if (!strcmp(OPTION_broadcast, broadcasts[i])) {
for (int i = 0; i < NUM_BROADCASTS; i++) {
if (!strcmp(OPTION_broadcast, BROADCASTS[i])) {
bcast = i;
break;
}
}
LOG_INFO("bios_override_settings region=%s lang=%s bcast=%s time=0x%08x",
regions[region], languages[lang], broadcasts[bcast], time);
REGIONS[region], LANGUAGES[lang], BROADCASTS[bcast], time);
/* the region, language and broadcast settings exist in two locations:

View File

@ -694,43 +694,6 @@ static void host_debug_menu(struct host *host) {
if (igBeginMainMenuBar()) {
if (igBeginMenu("HOST", 1)) {
if (igBeginMenu("sync", 1)) {
struct {
const char *desc;
int enabled;
} options[] = {
{"audio", audio_sync_enabled()}, /* */
{"video", video_sync_enabled()}, /* */
};
int num_options = (int)ARRAY_SIZE(options);
for (int i = 0; i < num_options; i++) {
const char *desc = options[i].desc;
int enabled = options[i].enabled;
if (igMenuItem(desc, NULL, enabled, 1)) {
int len = (int)strlen(OPTION_sync);
if (enabled) {
for (int i = 0; i < len; i++) {
if (OPTION_sync[i] == desc[0]) {
OPTION_sync[i] = OPTION_sync[len - 1];
OPTION_sync[len - 1] = 0;
break;
}
}
} else {
OPTION_sync[len] = desc[0];
OPTION_sync[len + 1] = 0;
}
OPTION_sync_dirty = 1;
}
}
igEndMenu();
}
if (igMenuItem("frame times", NULL, host->dbg.show_times, 1)) {
host->dbg.show_times = !host->dbg.show_times;
}

View File

@ -16,12 +16,13 @@ enum {
IMFONT_NUM_FONTS,
};
/* note, any icon defined through IMICON_* must be listed here */
#define IMICON_RANGES \
0xf00d, 0xf00d, 0xf028, 0xf028, 0xf067, 0xf067, 0xf07c, 0xf07c, 0xf0a0, \
0xf00d, 0xf00d, 0xf2db, 0xf2db, 0xf067, 0xf067, 0xf07c, 0xf07c, 0xf0a0, \
0xf0a0, 0xf108, 0xf108, 0xf11b, 0xf11b
#define IMICON_TIMES u8"\uf00d"
#define IMICON_VOLUME_UP u8"\uf028"
#define IMICON_MICROCHIP u8"\uf2db"
#define IMICON_PLUS u8"\uf067"
#define IMICON_FOLDER_OPEN u8"\uf07c"
#define IMICON_HDD u8"\uf0a0"

View File

@ -8,8 +8,43 @@
#define DEFAULT_DEADZONE 4096
/* clang-format off */
const char *BROADCASTS[] = {
"ntsc",
"pal",
"pal_m",
"pal_n",
};
const int NUM_BROADCASTS = ARRAY_SIZE(BROADCASTS);
const char *REGIONS[] = {
"japan",
"usa",
"europe",
};
const int NUM_REGIONS = ARRAY_SIZE(REGIONS);
const char *LANGUAGES[] = {
"japanese",
"english",
"german",
"french",
"spanish",
"italian",
};
const int NUM_LANGUAGES = ARRAY_SIZE(LANGUAGES);
const char *TIMESYNCS[] = {
"audio and video",
"audio only",
"video only",
"none",
};
const int NUM_TIMESYNCS = ARRAY_SIZE(TIMESYNCS);
const char *ASPECT_RATIOS[] = {
"stretch", "16:9", "4:3",
"stretch",
"16:9",
"4:3",
};
const int NUM_ASPECT_RATIOS = ARRAY_SIZE(ASPECT_RATIOS);
@ -40,8 +75,8 @@ int *DEADZONES[] = {
};
/* host */
DEFINE_OPTION_STRING(sync, "av", "Sync control");
DEFINE_OPTION_INT(bios, 0, "Boot to bios");
DEFINE_PERSISTENT_OPTION_STRING(sync, "audio and video", "Time sync");
DEFINE_PERSISTENT_OPTION_INT(fullscreen, 0, "Start window fullscreen");
DEFINE_PERSISTENT_OPTION_INT(key_a, 'l', "A button mapping");
DEFINE_PERSISTENT_OPTION_INT(key_b, 'p', "B button mapping");

View File

@ -16,6 +16,18 @@ struct button_map {
int *dirty;
};
extern const char *BROADCASTS[];
extern const int NUM_BROADCASTS;
extern const char *LANGUAGES[];
extern const int NUM_LANGUAGES;
extern const char *REGIONS[];
extern const int NUM_REGIONS;
extern const char *TIMESYNCS[];
extern const int NUM_TIMESYNCS;
extern const char *ASPECT_RATIOS[];
extern const int NUM_ASPECT_RATIOS;

View File

@ -134,7 +134,7 @@ static struct page pages[UI_NUM_PAGES];
#define UI_STR_BTN_CANCEL "Cancel"
#define UI_STR_BTN_ADD "Add"
#define UI_STR_CARD_LIBRARY " " IMICON_HDD "\nLibrary"
#define UI_STR_CARD_AUDIO " " IMICON_VOLUME_UP "\nAudio"
#define UI_STR_CARD_SYSTEM " " IMICON_MICROCHIP "\nSystem"
#define UI_STR_CARD_VIDEO " " IMICON_DESKTOP "\nVideo"
#define UI_STR_CARD_INPUT " " IMICON_GAMEPAD "\nInput"
#define UI_STR_LIBRARY_ADD "Add Directory"
@ -945,9 +945,9 @@ static void ui_video_build(struct ui *ui) {
}
/*
* audio page
* system page
*/
static void ui_audio_build(struct ui *ui) {
static void ui_system_build(struct ui *ui) {
struct ImGuiIO *io = igGetIO();
struct ImVec2 size = {UI_PAGE_MAX_WIDTH, UI_PAGE_MAX_HEIGHT};
@ -956,9 +956,67 @@ static void ui_audio_build(struct ui *ui) {
struct ImVec2 btn_size = {-1.0f, VH(8.0f)};
igSetCursorPos(pos);
igBeginChild("audio", size, false, ImGuiWindowFlags_NavFlattened);
igBeginChild("system", size, false, ImGuiWindowFlags_NavFlattened);
igText("Not available yet.");
igPushStyle_Btn();
{
if (igOptionString("Time sync", OPTION_sync, btn_size)) {
int next = 0;
for (int i = 0; i < NUM_TIMESYNCS; i++) {
if (!strcmp(TIMESYNCS[i], OPTION_sync)) {
next = (i + 1) % NUM_TIMESYNCS;
break;
}
}
strncpy(OPTION_sync, TIMESYNCS[next], sizeof(OPTION_sync));
OPTION_sync_dirty = 1;
}
}
{
if (igOptionString("Region", OPTION_region, btn_size)) {
int next = 0;
for (int i = 0; i < NUM_REGIONS; i++) {
if (!strcmp(REGIONS[i], OPTION_region)) {
next = (i + 1) % NUM_REGIONS;
break;
}
}
strncpy(OPTION_region, REGIONS[next], sizeof(OPTION_region));
OPTION_region_dirty = 1;
}
}
{
if (igOptionString("Language", OPTION_language, btn_size)) {
int next = 0;
for (int i = 0; i < NUM_LANGUAGES; i++) {
if (!strcmp(LANGUAGES[i], OPTION_language)) {
next = (i + 1) % NUM_LANGUAGES;
break;
}
}
strncpy(OPTION_language, LANGUAGES[next], sizeof(OPTION_language));
OPTION_language_dirty = 1;
}
}
{
if (igOptionString("Broadcast", OPTION_broadcast, btn_size)) {
int next = 0;
for (int i = 0; i < NUM_BROADCASTS; i++) {
if (!strcmp(BROADCASTS[i], OPTION_broadcast)) {
next = (i + 1) % NUM_BROADCASTS;
break;
}
}
strncpy(OPTION_broadcast, BROADCASTS[next], sizeof(OPTION_broadcast));
OPTION_broadcast_dirty = 1;
}
}
igPopStyle_Btn();
igEndChild();
}
@ -1061,8 +1119,8 @@ static void ui_options_build(struct ui *ui) {
igSetCursorPosX(min.x + btn_size.x + btn_padding.x);
igSetCursorPosY(min.y);
if (igButton(UI_STR_CARD_AUDIO, btn_size)) {
ui_set_page(ui, UI_PAGE_AUDIO);
if (igButton(UI_STR_CARD_SYSTEM, btn_size)) {
ui_set_page(ui, UI_PAGE_SYSTEM);
}
igSetCursorPosX(min.x);
@ -1512,8 +1570,8 @@ struct ui *ui_create(struct host *host) {
pages[UI_PAGE_LIBRARY].name = NULL;
pages[UI_PAGE_LIBRARY].build = ui_library_build;
pages[UI_PAGE_AUDIO].name = NULL;
pages[UI_PAGE_AUDIO].build = ui_audio_build;
pages[UI_PAGE_SYSTEM].name = NULL;
pages[UI_PAGE_SYSTEM].build = ui_system_build;
pages[UI_PAGE_VIDEO].name = NULL;
pages[UI_PAGE_VIDEO].build = ui_video_build;

View File

@ -12,7 +12,7 @@ enum {
UI_PAGE_GAMES = 0,
UI_PAGE_OPTIONS,
UI_PAGE_LIBRARY,
UI_PAGE_AUDIO,
UI_PAGE_SYSTEM,
UI_PAGE_VIDEO,
UI_PAGE_INPUT,
UI_PAGE_CONTROLLERS,