Skip to content

Commit af50705

Browse files
committed
rg_display: reverse some changes
1 parent 2498a89 commit af50705

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

components/retro-go/rg_display.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static inline void write_update(const rg_surface_t *update)
343343
lcd_sync();
344344
}
345345

346-
if (lines_updated > display.screen.height * 0.80f)
346+
if (lines_updated > draw_height * 0.80f)
347347
counters.fullFrames++;
348348
else
349349
counters.partFrames++;
@@ -352,23 +352,25 @@ static inline void write_update(const rg_surface_t *update)
352352

353353
static void update_viewport_scaling(void)
354354
{
355+
int screen_width = display.screen.width;
356+
int screen_height = display.screen.height;
355357
int src_width = display.source.width;
356358
int src_height = display.source.height;
357359
int new_width = src_width;
358360
int new_height = src_height;
359361

360362
if (config.scaling == RG_DISPLAY_SCALING_FULL)
361363
{
362-
new_width = display.screen.width;
364+
new_width = screen_width;
363365
new_height = display.screen.height;
364366
}
365367
else if (config.scaling == RG_DISPLAY_SCALING_FIT)
366368
{
367-
new_width = FLOAT_TO_INT(display.screen.height * ((float)src_width / src_height));
368-
new_height = display.screen.height;
369-
if (new_width > display.screen.width) {
370-
new_width = display.screen.width;
371-
new_height = FLOAT_TO_INT(display.screen.width * ((float)src_height / src_width));
369+
new_width = FLOAT_TO_INT(screen_height * ((float)src_width / src_height));
370+
new_height = screen_height;
371+
if (new_width > screen_width) {
372+
new_width = screen_width;
373+
new_height = FLOAT_TO_INT(screen_width * ((float)src_height / src_width));
372374
}
373375
}
374376
else if (config.scaling == RG_DISPLAY_SCALING_ZOOM)
@@ -381,8 +383,8 @@ static void update_viewport_scaling(void)
381383
new_width &= ~1;
382384
new_height &= ~1;
383385

384-
display.viewport.left = (display.screen.width - new_width) / 2;
385-
display.viewport.top = (display.screen.height - new_height) / 2;
386+
display.viewport.left = (screen_width - new_width) / 2;
387+
display.viewport.top = (screen_height - new_height) / 2;
386388
display.viewport.width = new_width;
387389
display.viewport.height = new_height;
388390

@@ -396,9 +398,9 @@ static void update_viewport_scaling(void)
396398

397399
memset(screen_line_checksum, 0, sizeof(screen_line_checksum));
398400

399-
for (int x = 0; x < display.screen.width; ++x)
401+
for (int x = 0; x < screen_width; ++x)
400402
map_viewport_to_source_x[x] = FLOAT_TO_INT(x * display.viewport.step_x);
401-
for (int y = 0; y < display.screen.height; ++y)
403+
for (int y = 0; y < screen_height; ++y)
402404
map_viewport_to_source_y[y] = FLOAT_TO_INT(y * display.viewport.step_y);
403405

404406
RG_LOGI("%dx%d@%.3f => %dx%d@%.3f left:%d top:%d step_x:%.2f step_y:%.2f", src_width, src_height,
@@ -415,9 +417,9 @@ static bool load_border_file(const char *filename)
415417

416418
if (filename && (border = rg_surface_load_image_file(filename, 0)))
417419
{
418-
if (border->width != display.screen.width || border->height != display.screen.height)
420+
if (border->width != rg_display_get_width() || border->height != rg_display_get_height())
419421
{
420-
rg_surface_t *resized = rg_surface_resize(border, display.screen.width, display.screen.height);
422+
rg_surface_t *resized = rg_surface_resize(border, rg_display_get_width(), rg_display_get_height());
421423
if (resized)
422424
{
423425
rg_surface_free(border);
@@ -480,6 +482,16 @@ rg_display_counters_t rg_display_get_counters(void)
480482
return counters;
481483
}
482484

485+
int rg_display_get_width(void)
486+
{
487+
return display.screen.width;
488+
}
489+
490+
int rg_display_get_height(void)
491+
{
492+
return display.screen.height;
493+
}
494+
483495
void rg_display_set_scaling(display_scaling_t scaling)
484496
{
485497
config.scaling = RG_MIN(RG_MAX(0, scaling), RG_DISPLAY_SCALING_COUNT - 1);

components/retro-go/rg_display.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ void rg_display_submit(const rg_surface_t *update, uint32_t flags);
131131

132132
rg_display_counters_t rg_display_get_counters(void);
133133
const rg_display_t *rg_display_get_info(void);
134+
int rg_display_get_width(void);
135+
int rg_display_get_height(void);
134136

135137
void rg_display_set_scaling(display_scaling_t scaling);
136138
display_scaling_t rg_display_get_scaling(void);

launcher/main/gui.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void gui_init(bool cold_boot)
3838
.start_screen = rg_settings_get_number(NS_APP, SETTING_START_SCREEN, START_SCREEN_AUTO),
3939
.show_preview = rg_settings_get_number(NS_APP, SETTING_SHOW_PREVIEW, PREVIEW_MODE_SAVE_COVER),
4040
.scroll_mode = rg_settings_get_number(NS_APP, SETTING_SCROLL_MODE, SCROLL_MODE_CENTER),
41-
.width = rg_display_get_info()->screen.width,
42-
.height = rg_display_get_info()->screen.height,
41+
.width = rg_display_get_width(),
42+
.height = rg_display_get_height(),
4343
};
4444
// Auto: Show carousel on cold boot, browser on warm boot (after cleanly exiting an emulator)
4545
gui.browse = gui.start_screen == START_SCREEN_BROWSER || (gui.start_screen == START_SCREEN_AUTO && !cold_boot);

retro-core/components/snes9x/src/memmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ void InitROM(bool Interleaved)
609609
Sanitize(Memory.ROMId, sizeof(Memory.ROMId));
610610
Sanitize(Memory.CompanyId, sizeof(Memory.CompanyId));
611611

612-
printf("Rom loaded: name: %s, id: %s, company: %s, size: %ldKB\n", Memory.ROMName, Memory.ROMId, Memory.CompanyId, Memory.CalculatedSize / 1024);
612+
printf("Rom loaded: name: %s, id: %s, company: %s, size: %dKB\n", Memory.ROMName, Memory.ROMId, Memory.CompanyId, Memory.CalculatedSize / 1024);
613613
Settings.ForceHeader = Settings.ForceHiROM = Settings.ForceLoROM = Settings.ForceInterleaved = Settings.ForceNoHeader = Settings.ForceNotInterleaved = Settings.ForceInterleaved2 = false;
614614
}
615615

0 commit comments

Comments
 (0)