comparison libblastem.c @ 1695:3c34122754ac

Properly support interlace in libretro build
author Michael Pavone <pavone@retrodev.com>
date Thu, 24 Jan 2019 19:14:16 -0800
parents 9e4dd1595f37
children 03895a4585c3
comparison
equal deleted inserted replaced
1694:9e4dd1595f37 1695:3c34122754ac
74 info->need_fullpath = 0; 74 info->need_fullpath = 0;
75 info->block_extract = 0; 75 info->block_extract = 0;
76 } 76 }
77 77
78 static vid_std video_standard; 78 static vid_std video_standard;
79 static uint32_t last_width; 79 static uint32_t last_width, last_height;
80 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info) 80 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info)
81 { 81 {
82 last_width = LINEBUF_SIZE; 82 last_width = LINEBUF_SIZE;
83 info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE; 83 info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE;
84 info->geometry.base_height = info->geometry.max_height = video_standard == VID_NTSC ? 243 : 294; 84 info->geometry.base_height = video_standard == VID_NTSC ? 243 : 294;
85 last_height = info->geometry.base_height;
86 info->geometry.max_height = info->geometry.base_height * 2;
85 info->geometry.aspect_ratio = 0; 87 info->geometry.aspect_ratio = 0;
86 info->timing.fps = video_standard == VID_NTSC ? 60 : 50; 88 info->timing.fps = video_standard == VID_NTSC ? 60 : 50;
87 info->timing.sample_rate = 53267; //approximate sample rate of YM2612 89 info->timing.sample_rate = 53267; //approximate sample rate of YM2612
88 } 90 }
89 91
233 { 235 {
234 //not supported in lib build 236 //not supported in lib build
235 } 237 }
236 238
237 static uint32_t fb[LINEBUF_SIZE * 294 * 2]; 239 static uint32_t fb[LINEBUF_SIZE * 294 * 2];
240 static uint8_t last_fb;
238 uint32_t *render_get_framebuffer(uint8_t which, int *pitch) 241 uint32_t *render_get_framebuffer(uint8_t which, int *pitch)
239 { 242 {
240 *pitch = LINEBUF_SIZE * sizeof(uint32_t); 243 *pitch = LINEBUF_SIZE * sizeof(uint32_t);
241 //TODO: deal with interlace 244 if (which != last_fb) {
242 return fb; 245 *pitch = *pitch * 2;
246 }
247
248 if (which) {
249 return fb + LINEBUF_SIZE;
250 } else {
251 return fb;
252 }
243 } 253 }
244 254
245 void render_framebuffer_updated(uint8_t which, int width) 255 void render_framebuffer_updated(uint8_t which, int width)
246 { 256 {
247 //TODO: deal with interlace
248 unsigned height = video_standard == VID_NTSC ? 243 : 294; 257 unsigned height = video_standard == VID_NTSC ? 243 : 294;
249 if (width != last_width) { 258 unsigned base_height = height;
259 if (which != last_fb) {
260 height *= 2;
261 last_fb = which;
262 }
263 if (width != last_width || height != last_height) {
250 struct retro_game_geometry geometry = { 264 struct retro_game_geometry geometry = {
251 .base_width = width, 265 .base_width = width,
252 .base_height = height, 266 .base_height = height,
253 .aspect_ratio = (float)LINEBUF_SIZE / height 267 .aspect_ratio = (float)LINEBUF_SIZE / base_height
254 }; 268 };
255 retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry); 269 retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
256 last_width = width; 270 last_width = width;
271 last_height = height;
257 } 272 }
258 retro_video_refresh(fb, width, height, LINEBUF_SIZE * sizeof(uint32_t)); 273 retro_video_refresh(fb, width, height, LINEBUF_SIZE * sizeof(uint32_t));
259 current_system->request_exit(current_system); 274 current_system->request_exit(current_system);
260 } 275 }
261 276