changeset 1694:9e4dd1595f37

Fix aspect ratio for H32 games
author Michael Pavone <pavone@retrodev.com>
date Wed, 23 Jan 2019 19:25:50 -0800
parents ba3fb7a3be6b
children 3c34122754ac
files libblastem.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libblastem.c	Tue Jan 22 21:15:38 2019 -0800
+++ b/libblastem.c	Wed Jan 23 19:25:50 2019 -0800
@@ -76,8 +76,10 @@
 }
 
 static vid_std video_standard;
+static uint32_t last_width;
 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info)
 {
+	last_width = LINEBUF_SIZE;
 	info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE;
 	info->geometry.base_height = info->geometry.max_height = video_standard == VID_NTSC ? 243 : 294;
 	info->geometry.aspect_ratio = 0;
@@ -242,9 +244,18 @@
 
 void render_framebuffer_updated(uint8_t which, int width)
 {
-	//TODO: Deal with 256 px wide modes
 	//TODO: deal with interlace
-	retro_video_refresh(fb, LINEBUF_SIZE, video_standard == VID_NTSC ? 243 : 294, LINEBUF_SIZE * sizeof(uint32_t));
+	unsigned height = video_standard == VID_NTSC ? 243 : 294;
+	if (width != last_width) {
+		struct retro_game_geometry geometry = {
+			.base_width = width,
+			.base_height = height,
+			.aspect_ratio = (float)LINEBUF_SIZE / height
+		};
+		retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
+		last_width = width;
+	}
+	retro_video_refresh(fb, width, height, LINEBUF_SIZE * sizeof(uint32_t));
 	current_system->request_exit(current_system);
 }