comparison libblastem.c @ 1882:62e8a8833e39

Implement overscan crop in libretro target
author Michael Pavone <pavone@retrodev.com>
date Tue, 17 Sep 2019 21:04:17 -0700
parents 55198fc9cc1f
children 377f110e4cea
comparison
equal deleted inserted replaced
1881:55198fc9cc1f 1882:62e8a8833e39
35 input_descriptor_macro(6) 35 input_descriptor_macro(6)
36 input_descriptor_macro(7) 36 input_descriptor_macro(7)
37 { 0 }, 37 { 0 },
38 }; 38 };
39 39
40 re(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, (void*)desc); 40 re(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, (void *)desc);
41 } 41 }
42 42
43 static retro_video_refresh_t retro_video_refresh; 43 static retro_video_refresh_t retro_video_refresh;
44 RETRO_API void retro_set_video_refresh(retro_video_refresh_t rvf) 44 RETRO_API void retro_set_video_refresh(retro_video_refresh_t rvf)
45 { 45 {
102 info->block_extract = 0; 102 info->block_extract = 0;
103 } 103 }
104 104
105 static vid_std video_standard; 105 static vid_std video_standard;
106 static uint32_t last_width, last_height; 106 static uint32_t last_width, last_height;
107 static uint32_t overscan_top, overscan_bot, overscan_left, overscan_right;
108 static void update_overscan(void)
109 {
110 uint8_t overscan;
111 retro_environment(RETRO_ENVIRONMENT_GET_OVERSCAN, &overscan);
112 if (overscan) {
113 overscan_top = overscan_bot = overscan_left = overscan_right = 0;
114 } else {
115 if (video_standard == VID_NTSC) {
116 overscan_top = 11;
117 overscan_bot = 8;
118 overscan_left = 13;
119 overscan_right = 14;
120 } else {
121 overscan_top = 30;
122 overscan_bot = 24;
123 overscan_left = 13;
124 overscan_right = 14;
125 }
126 }
127 }
128
107 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info) 129 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info)
108 { 130 {
131 update_overscan();
109 last_width = LINEBUF_SIZE; 132 last_width = LINEBUF_SIZE;
110 info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE; 133 info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE - (overscan_left + overscan_right);
111 info->geometry.base_height = video_standard == VID_NTSC ? 243 : 294; 134 info->geometry.base_height = (video_standard == VID_NTSC ? 243 : 294) - (overscan_top + overscan_bot);
112 last_height = info->geometry.base_height; 135 last_height = info->geometry.base_height;
113 info->geometry.max_height = info->geometry.base_height * 2; 136 info->geometry.max_height = info->geometry.base_height * 2;
114 info->geometry.aspect_ratio = 0; 137 info->geometry.aspect_ratio = 0;
115 info->timing.fps = video_standard == VID_NTSC ? 60 : 50; 138 info->timing.fps = video_standard == VID_NTSC ? 60 : 50;
116 info->timing.sample_rate = 53267; //approximate sample rate of YM2612 139 info->timing.sample_rate = 53267; //approximate sample rate of YM2612
279 } 302 }
280 } 303 }
281 304
282 void render_framebuffer_updated(uint8_t which, int width) 305 void render_framebuffer_updated(uint8_t which, int width)
283 { 306 {
284 unsigned height = video_standard == VID_NTSC ? 243 : 294; 307 unsigned height = (video_standard == VID_NTSC ? 243 : 294) - (overscan_top + overscan_bot);
308 width -= (overscan_left + overscan_right);
285 unsigned base_height = height; 309 unsigned base_height = height;
286 if (which != last_fb) { 310 if (which != last_fb) {
287 height *= 2; 311 height *= 2;
288 last_fb = which; 312 last_fb = which;
289 } 313 }
295 }; 319 };
296 retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry); 320 retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
297 last_width = width; 321 last_width = width;
298 last_height = height; 322 last_height = height;
299 } 323 }
300 retro_video_refresh(fb, width, height, LINEBUF_SIZE * sizeof(uint32_t)); 324 retro_video_refresh(fb + overscan_left + LINEBUF_SIZE * overscan_top, width, height, LINEBUF_SIZE * sizeof(uint32_t));
301 current_system->request_exit(current_system); 325 current_system->request_exit(current_system);
302 } 326 }
303 327
304 uint8_t render_get_active_framebuffer(void) 328 uint8_t render_get_active_framebuffer(void)
305 { 329 {
316 return 1; 340 return 1;
317 } 341 }
318 342
319 uint32_t render_overscan_top() 343 uint32_t render_overscan_top()
320 { 344 {
321 return 0; 345 return overscan_top;
322 } 346 }
323 347
324 uint32_t render_overscan_bot() 348 uint32_t render_overscan_bot()
325 { 349 {
326 return 0; 350 return overscan_bot;
327 } 351 }
328 352
329 void process_events() 353 void process_events()
330 { 354 {
331 static int16_t prev_state[2][RETRO_DEVICE_ID_JOYPAD_L2]; 355 static int16_t prev_state[2][RETRO_DEVICE_ID_JOYPAD_L2];