comparison vdp.c @ 1649:b500e971da75

Allow closing VDP debug windows with the close button in the window title bar
author Michael Pavone <pavone@retrodev.com>
date Tue, 18 Dec 2018 19:58:00 -0800
parents cf4e387a8db6
children d0a69348add8
comparison
equal deleted inserted replaced
1647:5a662692c215 1649:b500e971da75
3 This file is part of BlastEm. 3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. 4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5 */ 5 */
6 #include "vdp.h" 6 #include "vdp.h"
7 #include "blastem.h" 7 #include "blastem.h"
8 #include "genesis.h"
9 #include <stdlib.h> 8 #include <stdlib.h>
10 #include <string.h> 9 #include <string.h>
11 #include "render.h" 10 #include "render.h"
12 #include "util.h" 11 #include "util.h"
13 12
3873 context->pending_vint_start = load_int32(buf); 3872 context->pending_vint_start = load_int32(buf);
3874 context->pending_hint_start = load_int32(buf); 3873 context->pending_hint_start = load_int32(buf);
3875 update_video_params(context); 3874 update_video_params(context);
3876 } 3875 }
3877 3876
3877 static vdp_context *current_vdp;
3878 static void vdp_debug_window_close(uint8_t which)
3879 {
3880 //TODO: remove need for current_vdp global, and find the VDP via current_system instead
3881 for (int i = 0; i < VDP_NUM_DEBUG_TYPES; i++)
3882 {
3883 if (current_vdp->enabled_debuggers & (1 << i) && which == current_vdp->debug_fb_indices[i]) {
3884 vdp_toggle_debug_view(current_vdp, i);
3885 break;
3886 }
3887 }
3888 }
3889
3878 void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type) 3890 void vdp_toggle_debug_view(vdp_context *context, uint8_t debug_type)
3879 { 3891 {
3880 if (context->enabled_debuggers & 1 << debug_type) { 3892 if (context->enabled_debuggers & 1 << debug_type) {
3881 render_destroy_window(context->debug_fb_indices[debug_type]); 3893 render_destroy_window(context->debug_fb_indices[debug_type]);
3882 context->enabled_debuggers &= ~(1 << debug_type); 3894 context->enabled_debuggers &= ~(1 << debug_type);
3908 fetch_immediately = 1; 3920 fetch_immediately = 1;
3909 break; 3921 break;
3910 default: 3922 default:
3911 return; 3923 return;
3912 } 3924 }
3913 context->debug_fb_indices[debug_type] = render_create_window(caption, width, height); 3925 current_vdp = context;
3926 context->debug_fb_indices[debug_type] = render_create_window(caption, width, height, vdp_debug_window_close);
3914 if (context->debug_fb_indices[debug_type]) { 3927 if (context->debug_fb_indices[debug_type]) {
3915 context->enabled_debuggers |= 1 << debug_type; 3928 context->enabled_debuggers |= 1 << debug_type;
3916 } 3929 }
3917 if (fetch_immediately) { 3930 if (fetch_immediately) {
3918 context->debug_fbs[debug_type] = render_get_framebuffer(context->debug_fb_indices[debug_type], &context->debug_fb_pitch[debug_type]); 3931 context->debug_fbs[debug_type] = render_get_framebuffer(context->debug_fb_indices[debug_type], &context->debug_fb_pitch[debug_type]);