removed hdmi-related code
This commit is contained in:
parent
5f60f9c26e
commit
1ea75a50e0
8 changed files with 22 additions and 139 deletions
|
|
@ -232,11 +232,10 @@ int main(int argc , char* argv[]) {
|
||||||
|
|
||||||
POW_update(&dirty, &show_setting, NULL,NULL);
|
POW_update(&dirty, &show_setting, NULL,NULL);
|
||||||
|
|
||||||
int resized = GFX_autosize(&screen, &dirty);
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
if (!resized) GFX_clear(screen); // resizing clears the screen
|
GFX_clear(screen);
|
||||||
|
|
||||||
GFX_blitHardwareGroup(screen, show_setting);
|
GFX_blitHardwareGroup(screen, show_setting);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -515,21 +515,6 @@ void GFX_setNearestNeighbor(int enabled) {
|
||||||
DE_setScaleCoef(gfx.de_mem, 2, scale_coef);
|
DE_setScaleCoef(gfx.de_mem, 2, scale_coef);
|
||||||
DE_setScaleCoef(gfx.de_mem, 3, scale_coef);
|
DE_setScaleCoef(gfx.de_mem, 3, scale_coef);
|
||||||
}
|
}
|
||||||
int GFX_autosize(SDL_Surface** screen, int* dirty) {
|
|
||||||
// TODO: remove this entirely?
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// static int had_hdmi = -1;
|
|
||||||
// int has_hdmi = GetHDMI();
|
|
||||||
// if (had_hdmi==has_hdmi) return 0;
|
|
||||||
//
|
|
||||||
// *dirty = 1;
|
|
||||||
// if (has_hdmi) *screen = GFX_resize(HDMI_MENU_WIDTH,FIXED_HEIGHT,HDMI_MENU_WIDTH*FIXED_BPP);
|
|
||||||
// else *screen = GFX_resize(FIXED_WIDTH,FIXED_HEIGHT,FIXED_PITCH);
|
|
||||||
// had_hdmi = has_hdmi;
|
|
||||||
//
|
|
||||||
// return 1;
|
|
||||||
}
|
|
||||||
static void POW_flipOverlay(void);
|
static void POW_flipOverlay(void);
|
||||||
void GFX_flip(SDL_Surface* screen) {
|
void GFX_flip(SDL_Surface* screen) {
|
||||||
gfx.de_mem[DE_OVL_BA0(0)/4] = gfx.de_mem[DE_OVL_BA0(2)/4] = (uintptr_t)(gfx.fb_info.padd + gfx.page * PAGE_SIZE);
|
gfx.de_mem[DE_OVL_BA0(0)/4] = gfx.de_mem[DE_OVL_BA0(2)/4] = (uintptr_t)(gfx.fb_info.padd + gfx.page * PAGE_SIZE);
|
||||||
|
|
@ -1124,16 +1109,6 @@ static void SND_selectResampler(void) { // plat_sound_select_resampler
|
||||||
size_t SND_batchSamples(const SND_Frame* frames, size_t frame_count) { // plat_sound_write / plat_sound_write_resample
|
size_t SND_batchSamples(const SND_Frame* frames, size_t frame_count) { // plat_sound_write / plat_sound_write_resample
|
||||||
if (snd.frame_count==0) return 0;
|
if (snd.frame_count==0) return 0;
|
||||||
|
|
||||||
// static int had_hdmi = -1;
|
|
||||||
// int has_hdmi = GetHDMI();
|
|
||||||
// if (had_hdmi<0) had_hdmi = has_hdmi;
|
|
||||||
// if (has_hdmi!=had_hdmi) {
|
|
||||||
// had_hdmi = has_hdmi;
|
|
||||||
// if (has_hdmi) sleep(2);
|
|
||||||
// SND_quit();
|
|
||||||
// SND_init(snd.sample_rate_in, snd.frame_rate);
|
|
||||||
// }
|
|
||||||
|
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
|
|
||||||
int consumed = 0;
|
int consumed = 0;
|
||||||
|
|
@ -1163,8 +1138,6 @@ size_t SND_batchSamples(const SND_Frame* frames, size_t frame_count) { // plat_s
|
||||||
void SND_init(double sample_rate, double frame_rate) { // plat_sound_init
|
void SND_init(double sample_rate, double frame_rate) { // plat_sound_init
|
||||||
LOG_info("SND_init\n");
|
LOG_info("SND_init\n");
|
||||||
|
|
||||||
// SDL_putenv(GetHDMI()?"AUDIODEV=plughw:0,1":"default");
|
|
||||||
|
|
||||||
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
snd.frame_rate = frame_rate;
|
snd.frame_rate = frame_rate;
|
||||||
|
|
@ -1417,6 +1390,8 @@ static void POW_quitOverlay(void) {
|
||||||
|
|
||||||
static void POW_updateBatteryStatus(void) {
|
static void POW_updateBatteryStatus(void) {
|
||||||
pow.is_charging = getInt("/sys/class/power_supply/battery/charger_online");
|
pow.is_charging = getInt("/sys/class/power_supply/battery/charger_online");
|
||||||
|
|
||||||
|
// TODO: newer batteries have a different range, ???-420
|
||||||
int i = getInt("/sys/class/power_supply/battery/voltage_now") / 10000; // 310-410
|
int i = getInt("/sys/class/power_supply/battery/voltage_now") / 10000; // 310-410
|
||||||
i -= 310; // ~0-100
|
i -= 310; // ~0-100
|
||||||
|
|
||||||
|
|
@ -1467,7 +1442,6 @@ void POW_warn(int enable) {
|
||||||
void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, POW_callback_t after_sleep) {
|
void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, POW_callback_t after_sleep) {
|
||||||
int dirty = _dirty ? *_dirty : 0;
|
int dirty = _dirty ? *_dirty : 0;
|
||||||
int show_setting = _show_setting ? *_show_setting : 0;
|
int show_setting = _show_setting ? *_show_setting : 0;
|
||||||
int has_hdmi = GetHDMI();
|
|
||||||
|
|
||||||
static uint32_t cancel_start = 0;
|
static uint32_t cancel_start = 0;
|
||||||
static uint32_t power_start = 0;
|
static uint32_t power_start = 0;
|
||||||
|
|
@ -1528,10 +1502,10 @@ void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, PO
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MENU_DELAY 250 // also in PAD_tappedMenu()
|
#define MENU_DELAY 250 // also in PAD_tappedMenu()
|
||||||
if (PAD_justRepeated(BTN_PLUS) || PAD_justRepeated(BTN_MINUS) || (PAD_isPressed(BTN_MENU) && now-menu_start>=MENU_DELAY && !has_hdmi)) {
|
if (PAD_justRepeated(BTN_PLUS) || PAD_justRepeated(BTN_MINUS) || (PAD_isPressed(BTN_MENU) && now-menu_start>=MENU_DELAY)) {
|
||||||
setting_start = now;
|
setting_start = now;
|
||||||
if (PAD_isPressed(BTN_MENU)) {
|
if (PAD_isPressed(BTN_MENU)) {
|
||||||
if (!has_hdmi) show_setting = 1;
|
show_setting = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
show_setting = 2;
|
show_setting = 2;
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,6 @@ void LOG_note(int level, const char* fmt, ...);
|
||||||
#define FIXED_PITCH (FIXED_WIDTH * FIXED_BPP)
|
#define FIXED_PITCH (FIXED_WIDTH * FIXED_BPP)
|
||||||
#define FIXED_SIZE (FIXED_PITCH * FIXED_HEIGHT)
|
#define FIXED_SIZE (FIXED_PITCH * FIXED_HEIGHT)
|
||||||
|
|
||||||
#define HDMI_WIDTH 1280
|
|
||||||
#define HDMI_HEIGHT 720
|
|
||||||
#define HDMI_PITCH HDMI_WIDTH * FIXED_BPP
|
|
||||||
#define HDMI_SIZE HDMI_HEIGHT * HDMI_PITCH
|
|
||||||
#define HDMI_MENU_WIDTH 856 // FIXED_WIDTH * FIXED_HEIGHT / HDMI_HEIGHT rounded up to nearest 8
|
|
||||||
|
|
||||||
#define PAGE_COUNT 2
|
#define PAGE_COUNT 2
|
||||||
#define PAGE_SCALE 3
|
#define PAGE_SCALE 3
|
||||||
#define PAGE_WIDTH (FIXED_WIDTH * PAGE_SCALE)
|
#define PAGE_WIDTH (FIXED_WIDTH * PAGE_SCALE)
|
||||||
|
|
@ -101,7 +95,6 @@ SDL_Surface* GFX_init(int mode);
|
||||||
SDL_Surface* GFX_resize(int width, int height, int pitch);
|
SDL_Surface* GFX_resize(int width, int height, int pitch);
|
||||||
void GFX_setScaleClip(int x, int y, int width, int height);
|
void GFX_setScaleClip(int x, int y, int width, int height);
|
||||||
void GFX_setNearestNeighbor(int enabled);
|
void GFX_setNearestNeighbor(int enabled);
|
||||||
int GFX_autosize(SDL_Surface** screen, int* dirty);
|
|
||||||
void GFX_setMode(int mode);
|
void GFX_setMode(int mode);
|
||||||
void GFX_clear(SDL_Surface* screen);
|
void GFX_clear(SDL_Surface* screen);
|
||||||
void GFX_clearAll(void);
|
void GFX_clearAll(void);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ static int jack_fd;
|
||||||
static pthread_t ports_pt;
|
static pthread_t ports_pt;
|
||||||
|
|
||||||
#define JACK_STATE_PATH "/sys/class/switch/h2w/state"
|
#define JACK_STATE_PATH "/sys/class/switch/h2w/state"
|
||||||
#define HDMI_STATE_PATH "/sys/class/switch/hdmi/state"
|
|
||||||
#define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power"
|
#define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power"
|
||||||
|
|
||||||
int getInt(char* path) {
|
int getInt(char* path) {
|
||||||
|
|
@ -44,16 +43,12 @@ int getInt(char* path) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test HDMI connect/disconnect
|
|
||||||
// TODO: still resetting between launches
|
// TODO: still resetting between launches
|
||||||
static void* watchPorts(void *arg) {
|
static void* watchPorts(void *arg) {
|
||||||
int has_headphones,had_headphones;
|
int has_headphones,had_headphones;
|
||||||
int has_hdmi,had_hdmi;
|
|
||||||
|
|
||||||
has_headphones = had_headphones = getInt(JACK_STATE_PATH);
|
has_headphones = had_headphones = getInt(JACK_STATE_PATH);
|
||||||
has_hdmi = had_hdmi = getInt(HDMI_STATE_PATH);
|
|
||||||
SetJack(has_headphones);
|
SetJack(has_headphones);
|
||||||
SetHDMI(has_hdmi);
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
@ -63,17 +58,6 @@ static void* watchPorts(void *arg) {
|
||||||
had_headphones = has_headphones;
|
had_headphones = has_headphones;
|
||||||
SetJack(has_headphones);
|
SetJack(has_headphones);
|
||||||
}
|
}
|
||||||
|
|
||||||
has_hdmi = getInt(HDMI_STATE_PATH);
|
|
||||||
if (had_hdmi!=has_hdmi) {
|
|
||||||
had_hdmi = has_hdmi;
|
|
||||||
SetHDMI(has_hdmi);
|
|
||||||
}
|
|
||||||
else if (has_hdmi && !getInt(BACKLIGHT_PATH)) {
|
|
||||||
SetHDMI(has_hdmi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ typedef struct Settings {
|
||||||
int unused[2]; // for future use
|
int unused[2]; // for future use
|
||||||
// NOTE: doesn't really need to be persisted but still needs to be shared
|
// NOTE: doesn't really need to be persisted but still needs to be shared
|
||||||
int jack;
|
int jack;
|
||||||
int hdmi;
|
|
||||||
} Settings;
|
} Settings;
|
||||||
static Settings DefaultSettings = {
|
static Settings DefaultSettings = {
|
||||||
.version = SETTINGS_VERSION,
|
.version = SETTINGS_VERSION,
|
||||||
|
|
@ -30,7 +29,6 @@ static Settings DefaultSettings = {
|
||||||
.headphones = 4,
|
.headphones = 4,
|
||||||
.speaker = 8,
|
.speaker = 8,
|
||||||
.jack = 0,
|
.jack = 0,
|
||||||
.hdmi = 0,
|
|
||||||
};
|
};
|
||||||
static Settings* settings;
|
static Settings* settings;
|
||||||
|
|
||||||
|
|
@ -43,7 +41,6 @@ static int shm_size = sizeof(Settings);
|
||||||
#define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power"
|
#define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power"
|
||||||
#define BRIGHTNESS_PATH "/sys/class/backlight/backlight.2/brightness"
|
#define BRIGHTNESS_PATH "/sys/class/backlight/backlight.2/brightness"
|
||||||
#define VOLUME_PATH "/sys/class/volume/value"
|
#define VOLUME_PATH "/sys/class/volume/value"
|
||||||
#define MIRROR_PATH "/sys/class/graphics/fb0/mirror_to_hdmi"
|
|
||||||
|
|
||||||
void InitSettings(void) {
|
void InitSettings(void) {
|
||||||
// sprintf(SettingsPath, "%s/msettings.bin", getenv("USERDATA_PATH"));
|
// sprintf(SettingsPath, "%s/msettings.bin", getenv("USERDATA_PATH"));
|
||||||
|
|
@ -74,12 +71,11 @@ void InitSettings(void) {
|
||||||
|
|
||||||
// these shouldn't be persisted
|
// these shouldn't be persisted
|
||||||
// settings->jack = 0;
|
// settings->jack = 0;
|
||||||
// settings->hdmi = 0;
|
|
||||||
}
|
}
|
||||||
printf("brightness: %i\nspeaker: %i \n", settings->brightness, settings->speaker);
|
printf("brightness: %i\nspeaker: %i \n", settings->brightness, settings->speaker);
|
||||||
|
|
||||||
SetVolume(GetVolume());
|
SetVolume(GetVolume());
|
||||||
SetBrightness(GetBrightness()); // also sets HDMI
|
SetBrightness(GetBrightness());
|
||||||
}
|
}
|
||||||
void QuitSettings(void) {
|
void QuitSettings(void) {
|
||||||
munmap(settings, shm_size);
|
munmap(settings, shm_size);
|
||||||
|
|
@ -98,8 +94,6 @@ int GetBrightness(void) { // 0-10
|
||||||
return settings->brightness;
|
return settings->brightness;
|
||||||
}
|
}
|
||||||
void SetBrightness(int value) {
|
void SetBrightness(int value) {
|
||||||
if (settings->hdmi) return;
|
|
||||||
|
|
||||||
int raw;
|
int raw;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: raw=16; break; // 0
|
case 0: raw=16; break; // 0
|
||||||
|
|
@ -132,8 +126,6 @@ void SetVolume(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRawBrightness(int val) { // 0 - 1024
|
void SetRawBrightness(int val) { // 0 - 1024
|
||||||
if (settings->hdmi) return;
|
|
||||||
|
|
||||||
// printf("SetRawBrightness(%i)\n", val); fflush(stdout);
|
// printf("SetRawBrightness(%i)\n", val); fflush(stdout);
|
||||||
int fd = open(BRIGHTNESS_PATH, O_WRONLY);
|
int fd = open(BRIGHTNESS_PATH, O_WRONLY);
|
||||||
if (fd>=0) {
|
if (fd>=0) {
|
||||||
|
|
@ -159,24 +151,3 @@ void SetJack(int value) {
|
||||||
settings->jack = value;
|
settings->jack = value;
|
||||||
SetVolume(GetVolume());
|
SetVolume(GetVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetHDMI(void) {
|
|
||||||
// printf("GetHDMI() %i\n", settings->hdmi); fflush(stdout);
|
|
||||||
return settings->hdmi;
|
|
||||||
}
|
|
||||||
void SetHDMI(int value) {
|
|
||||||
// printf("SetHDMI(%i)\n", value); fflush(stdout);
|
|
||||||
|
|
||||||
settings->hdmi = value;
|
|
||||||
int fd = open(MIRROR_PATH, O_WRONLY);
|
|
||||||
if (fd>=0) {
|
|
||||||
dprintf(fd,"%d",value);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open(BACKLIGHT_PATH, O_WRONLY);
|
|
||||||
if (fd>=0) {
|
|
||||||
dprintf(fd,"%d",value ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,4 @@ void SetVolume(int value); // 0-20
|
||||||
int GetJack(void);
|
int GetJack(void);
|
||||||
void SetJack(int value); // 0-1
|
void SetJack(int value); // 0-1
|
||||||
|
|
||||||
int GetHDMI(void);
|
|
||||||
void SetHDMI(int value); // 0-1
|
|
||||||
|
|
||||||
#endif // __msettings_h__
|
#endif // __msettings_h__
|
||||||
|
|
|
||||||
|
|
@ -2441,10 +2441,9 @@ static void scaleNN_text_scanline(void* __restrict src, void* __restrict dst, ui
|
||||||
|
|
||||||
static SDL_Surface* scaler_surface;
|
static SDL_Surface* scaler_surface;
|
||||||
static void selectScaler_PAR(int width, int height, int pitch) {
|
static void selectScaler_PAR(int width, int height, int pitch) {
|
||||||
int has_hdmi = GetHDMI();
|
int device_width = SCREEN_WIDTH;
|
||||||
int device_width = has_hdmi ? HDMI_WIDTH : SCREEN_WIDTH;
|
int device_height = SCREEN_HEIGHT;
|
||||||
int device_height = has_hdmi ? HDMI_HEIGHT : SCREEN_HEIGHT;
|
int device_pitch = SCREEN_PITCH;
|
||||||
int device_pitch = has_hdmi ? HDMI_PITCH : SCREEN_PITCH;
|
|
||||||
|
|
||||||
renderer.scaler = scaleNull;
|
renderer.scaler = scaleNull;
|
||||||
renderer.dst_p = device_pitch;
|
renderer.dst_p = device_pitch;
|
||||||
|
|
@ -2603,9 +2602,8 @@ static void selectScaler_AR(int width, int height, int pitch) {
|
||||||
int src_w = width;
|
int src_w = width;
|
||||||
int src_h = height;
|
int src_h = height;
|
||||||
|
|
||||||
int has_hdmi = GetHDMI();
|
int scale_x = CEIL_DIV(SCREEN_WIDTH, src_w);
|
||||||
int scale_x = CEIL_DIV(has_hdmi ? HDMI_WIDTH : SCREEN_WIDTH, src_w);
|
int scale_y = CEIL_DIV(SCREEN_HEIGHT,src_h);
|
||||||
int scale_y = CEIL_DIV(has_hdmi ? HDMI_HEIGHT: SCREEN_HEIGHT,src_h);
|
|
||||||
int scale = MAX(scale_x, scale_y);
|
int scale = MAX(scale_x, scale_y);
|
||||||
|
|
||||||
// TODO: this "logic" is a disaster
|
// TODO: this "logic" is a disaster
|
||||||
|
|
@ -2628,14 +2626,13 @@ static void selectScaler_AR(int width, int height, int pitch) {
|
||||||
|
|
||||||
char scaler_name[8];
|
char scaler_name[8];
|
||||||
#define FOUR_THREE 4.0f / 3
|
#define FOUR_THREE 4.0f / 3
|
||||||
#define SIXTEEN_NINE 16.0 / 9
|
|
||||||
|
|
||||||
double target_ratio = has_hdmi ? SIXTEEN_NINE : FOUR_THREE;
|
double target_ratio = FOUR_THREE;
|
||||||
|
|
||||||
// TODO: sotn moon is busted 512x240 ends up 2x but targeting 864x480
|
// TODO: sotn moon is busted 512x240 ends up 2x but targeting 864x480
|
||||||
|
|
||||||
if (screen_scaling==1) {
|
if (screen_scaling==1) {
|
||||||
sprintf(scaler_name, "AR_%iX%s", scale, has_hdmi?"W":"R");
|
sprintf(scaler_name, "AR_%iX%s", scale, "R");
|
||||||
if (core.aspect_ratio==target_ratio) {
|
if (core.aspect_ratio==target_ratio) {
|
||||||
LOG_info("already correct ratio\n");
|
LOG_info("already correct ratio\n");
|
||||||
}
|
}
|
||||||
|
|
@ -2643,10 +2640,10 @@ static void selectScaler_AR(int width, int height, int pitch) {
|
||||||
// TODO: is this ignoring the core's desired aspect ratio?
|
// TODO: is this ignoring the core's desired aspect ratio?
|
||||||
// see snes or SotN
|
// see snes or SotN
|
||||||
// I think it's acting more like PAR
|
// I think it's acting more like PAR
|
||||||
sprintf(scaler_name, "AR_%iX%sR", scale, has_hdmi?"W":"R");
|
sprintf(scaler_name, "AR_%iX%sR", scale, "R");
|
||||||
|
|
||||||
int ratio_left = target_ratio==SIXTEEN_NINE ? 16 : 4;
|
int ratio_left = 4;
|
||||||
int ratio_right = target_ratio==SIXTEEN_NINE ? 9 : 3;
|
int ratio_right = 3;
|
||||||
|
|
||||||
// TODO: why do these use CEIL_DIV?
|
// TODO: why do these use CEIL_DIV?
|
||||||
if (core.aspect_ratio<target_ratio) {
|
if (core.aspect_ratio<target_ratio) {
|
||||||
|
|
@ -2708,8 +2705,6 @@ static void selectScaler_AR(int width, int height, int pitch) {
|
||||||
renderer.dst_p = target_pitch;
|
renderer.dst_p = target_pitch;
|
||||||
renderer.dst_offset = (dy * target_pitch) + (dx * FIXED_BPP);
|
renderer.dst_offset = (dy * target_pitch) + (dx * FIXED_BPP);
|
||||||
|
|
||||||
if (has_hdmi) LOG_warn("dst offset: %i,%i (%i)\n", dx,dy, renderer.dst_offset);
|
|
||||||
|
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
case 6: renderer.scaler = scale6x6_n16; break;
|
case 6: renderer.scaler = scale6x6_n16; break;
|
||||||
case 5: renderer.scaler = scale5x5_n16; break;
|
case 5: renderer.scaler = scale5x5_n16; break;
|
||||||
|
|
@ -2746,14 +2741,6 @@ static void video_refresh_callback(const void *data, unsigned width, unsigned he
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
renderer.data = data; // this pointer isn't guaranteed to hang around but this approach worked on the Mini
|
renderer.data = data; // this pointer isn't guaranteed to hang around but this approach worked on the Mini
|
||||||
|
|
||||||
// force resize when hdmi status changes
|
|
||||||
static int had_hdmi = -1;
|
|
||||||
int has_hdmi = GetHDMI();
|
|
||||||
if (had_hdmi!=has_hdmi) {
|
|
||||||
renderer.src_w = 0;
|
|
||||||
had_hdmi = has_hdmi;
|
|
||||||
}
|
|
||||||
|
|
||||||
fps_ticks += 1;
|
fps_ticks += 1;
|
||||||
|
|
||||||
if (width!=renderer.src_w || height!=renderer.src_h) {
|
if (width!=renderer.src_w || height!=renderer.src_h) {
|
||||||
|
|
@ -3024,7 +3011,7 @@ static SDL_Surface* Menu_thumbnail(SDL_Surface* src_img) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu_init(void) {
|
void Menu_init(void) {
|
||||||
menu.overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, HDMI_WIDTH, HDMI_HEIGHT, FIXED_DEPTH, 0, 0, 0, 0);
|
menu.overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, FIXED_WIDTH, FIXED_HEIGHT, FIXED_DEPTH, 0, 0, 0, 0);
|
||||||
SDL_SetAlpha(menu.overlay, SDL_SRCALPHA, 0x80);
|
SDL_SetAlpha(menu.overlay, SDL_SRCALPHA, 0x80);
|
||||||
SDL_FillRect(menu.overlay, NULL, 0);
|
SDL_FillRect(menu.overlay, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -3088,9 +3075,7 @@ static int Menu_message(char* message, char** pairs) {
|
||||||
|
|
||||||
POW_update(&dirty, NULL, Menu_beforeSleep, Menu_afterSleep);
|
POW_update(&dirty, NULL, Menu_beforeSleep, Menu_afterSleep);
|
||||||
|
|
||||||
int resized = GFX_autosize(&screen, &dirty);
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
if (!resized) GFX_clear(screen); // resizing clears the screen
|
|
||||||
GFX_clear(screen);
|
GFX_clear(screen);
|
||||||
GFX_blitMessage(font.medium, message, screen, &(SDL_Rect){0,SCALE1(PADDING),screen->w,screen->h-SCALE1(PILL_SIZE+PADDING)});
|
GFX_blitMessage(font.medium, message, screen, &(SDL_Rect){0,SCALE1(PADDING),screen->w,screen->h-SCALE1(PILL_SIZE+PADDING)});
|
||||||
GFX_blitButtonGroup(pairs, screen, 1);
|
GFX_blitButtonGroup(pairs, screen, 1);
|
||||||
|
|
@ -3583,10 +3568,7 @@ static int Menu_options(MenuList* list) {
|
||||||
|
|
||||||
POW_update(&dirty, &show_settings, Menu_beforeSleep, Menu_afterSleep);
|
POW_update(&dirty, &show_settings, Menu_beforeSleep, Menu_afterSleep);
|
||||||
|
|
||||||
int resized = GFX_autosize(&screen, &dirty);
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
if (!resized) GFX_clear(screen); // resizing clears the screen
|
|
||||||
|
|
||||||
GFX_clear(screen);
|
GFX_clear(screen);
|
||||||
GFX_blitHardwareGroup(screen, show_settings);
|
GFX_blitHardwareGroup(screen, show_settings);
|
||||||
|
|
||||||
|
|
@ -3835,7 +3817,6 @@ static void downsample(void* __restrict src, void* __restrict dst, uint32_t w, u
|
||||||
static void Menu_loop(void) {
|
static void Menu_loop(void) {
|
||||||
// current screen is on the previous buffer
|
// current screen is on the previous buffer
|
||||||
|
|
||||||
// TODO: can we use renderer.src_w/h to reverse the stretch regardless of HDMI status?
|
|
||||||
// because we need an undeformed copy for save state screenshots
|
// because we need an undeformed copy for save state screenshots
|
||||||
SDL_Surface* backing = GFX_getBufferCopy();
|
SDL_Surface* backing = GFX_getBufferCopy();
|
||||||
SDL_Surface* snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, FIXED_WIDTH,FIXED_HEIGHT,FIXED_DEPTH,0,0,0,0);
|
SDL_Surface* snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, FIXED_WIDTH,FIXED_HEIGHT,FIXED_DEPTH,0,0,0,0);
|
||||||
|
|
@ -3847,25 +3828,14 @@ static void Menu_loop(void) {
|
||||||
downsample(backing->pixels,snapshot->pixels,backing->w,backing->h,backing->pitch,snapshot->pitch);
|
downsample(backing->pixels,snapshot->pixels,backing->w,backing->h,backing->pitch,snapshot->pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this to right before if (dirty) {} like in minui.elf
|
int target_w = FIXED_WIDTH; // 640 * 480 / 720 rounded up to nearest 8
|
||||||
// TODO: could move to a GFX_autosize(&dirty) -> has_hdmi
|
|
||||||
int has_hdmi = GetHDMI();
|
|
||||||
|
|
||||||
int target_w = has_hdmi ? HDMI_MENU_WIDTH : FIXED_WIDTH; // 640 * 480 / 720 rounded up to nearest 8
|
|
||||||
int target_h = FIXED_HEIGHT;
|
int target_h = FIXED_HEIGHT;
|
||||||
int target_p = target_w * FIXED_BPP;
|
int target_p = target_w * FIXED_BPP;
|
||||||
|
|
||||||
LOG_info("hdmi: %i %ix%i (%i)\n", has_hdmi,target_w,target_h,target_p);
|
if (screen->w!=SCREEN_WIDTH || screen->h!=SCREEN_HEIGHT) {
|
||||||
|
|
||||||
if (has_hdmi && (screen->w!=target_w || screen->h!=target_h)) {
|
|
||||||
screen = GFX_resize(target_w,target_h,target_p);
|
|
||||||
}
|
|
||||||
else if (screen->w!=SCREEN_WIDTH || screen->h!=SCREEN_HEIGHT) {
|
|
||||||
screen = GFX_resize(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_PITCH);
|
screen = GFX_resize(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: attempt to draw menu in center of screen when in hdmi
|
|
||||||
|
|
||||||
POW_warn(0);
|
POW_warn(0);
|
||||||
POW_setCPUSpeed(CPU_SPEED_MENU); // set Hz directly
|
POW_setCPUSpeed(CPU_SPEED_MENU); // set Hz directly
|
||||||
GFX_setVsync(VSYNC_STRICT);
|
GFX_setVsync(VSYNC_STRICT);
|
||||||
|
|
@ -4077,9 +4047,8 @@ static void Menu_loop(void) {
|
||||||
|
|
||||||
POW_update(&dirty, &show_setting, Menu_beforeSleep, Menu_afterSleep);
|
POW_update(&dirty, &show_setting, Menu_beforeSleep, Menu_afterSleep);
|
||||||
|
|
||||||
int resized = GFX_autosize(&screen, &dirty);
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
if (!resized) GFX_clear(screen); // resizing clears the screen
|
GFX_clear(screen);
|
||||||
|
|
||||||
SDL_BlitSurface(snapshot, NULL, screen, NULL);
|
SDL_BlitSurface(snapshot, NULL, screen, NULL);
|
||||||
SDL_BlitSurface(menu.overlay, NULL, screen, NULL);
|
SDL_BlitSurface(menu.overlay, NULL, screen, NULL);
|
||||||
|
|
@ -4227,10 +4196,7 @@ static void Menu_loop(void) {
|
||||||
|
|
||||||
GFX_clearAll();
|
GFX_clearAll();
|
||||||
if (!quit) {
|
if (!quit) {
|
||||||
if (GetHDMI() && screen_scaling==SCALE_NATIVE) {
|
if (backing->w!=FIXED_WIDTH || backing->h!=FIXED_HEIGHT) {
|
||||||
screen = GFX_resize(HDMI_WIDTH,HDMI_HEIGHT, HDMI_PITCH);
|
|
||||||
}
|
|
||||||
else if (backing->w!=FIXED_WIDTH || backing->h!=FIXED_HEIGHT) {
|
|
||||||
screen = GFX_resize(renderer.dst_w,renderer.dst_h, renderer.dst_p);
|
screen = GFX_resize(renderer.dst_w,renderer.dst_h, renderer.dst_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1320,9 +1320,8 @@ int main (int argc, char *argv[]) {
|
||||||
|
|
||||||
POW_update(&dirty, &show_setting, NULL, NULL);
|
POW_update(&dirty, &show_setting, NULL, NULL);
|
||||||
|
|
||||||
int resized = GFX_autosize(&screen, &dirty);
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
if (!resized) GFX_clear(screen); // resizing clears the screen
|
GFX_clear(screen);
|
||||||
|
|
||||||
int ox;
|
int ox;
|
||||||
int oy;
|
int oy;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue