2 * $Id: gtkui.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
4 * Core GTK-based user interface
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #include "dreamcast.h"
21 #include "gui/gtkui.h"
24 void gtk_gui_update( void );
25 void gtk_gui_start( void );
26 void gtk_gui_stop( void );
27 void gtk_gui_alloc_resources ( void );
28 uint32_t gtk_gui_run_slice( uint32_t nanosecs );
30 struct dreamcast_module gtk_gui_module = { "gui", NULL,
38 * Single-instance windows (at most one)
40 static main_window_t main_win = NULL;
41 static debug_window_t debug_win = NULL;
42 static mmio_window_t mmio_win = NULL;
45 * Count of running nanoseconds - used to cut back on the GUI runtime
47 static uint32_t gtk_gui_nanos = 0;
50 gboolean gui_parse_cmdline( int *argc, char **argv[] )
52 return gtk_init_check( argc, argv );
55 gboolean gui_init( gboolean withDebug )
57 dreamcast_register_module( >k_gui_module );
58 gtk_gui_alloc_resources();
60 debug_win = debug_window_new();
62 main_win = main_window_new( APP_NAME " " APP_VERSION );
66 void gui_main_loop(void)
71 void gui_update_io_activity( io_activity_type io, gboolean active )
76 void gtk_gui_show_debugger()
79 debug_window_show(debug_win, TRUE);
81 debug_win = debug_window_new();
85 GtkWidget *gtk_gui_get_renderarea()
87 return main_window_get_renderarea(main_win);
91 * Hook called when DC starts running. Just disables the run/step buttons
92 * and enables the stop button.
94 void gtk_gui_start( void )
96 main_window_set_running( main_win, TRUE );
97 if( debug_win != NULL ) {
98 debug_window_set_running( debug_win, TRUE );
103 * Hook called when DC stops running. Enables the run/step buttons
104 * and disables the stop button.
106 void gtk_gui_stop( void )
108 main_window_set_running( main_win, FALSE );
112 void gtk_gui_update( void )
115 debug_window_set_running( debug_win, FALSE );
116 debug_window_update(debug_win);
119 mmio_win_update(mmio_win);
121 dump_win_update_all();
125 * Module run-slice. Because UI processing is fairly expensive, only
126 * run the processing about 10 times a second while we're emulating.
128 uint32_t gtk_gui_run_slice( uint32_t nanosecs )
130 gtk_gui_nanos += nanosecs;
131 if( gtk_gui_nanos > 100000000 ) {
133 while( gtk_events_pending() )
134 gtk_main_iteration();
135 // main_window_set_framerate( main_win, pvr2_get_frame_rate() );
141 PangoFontDescription *gui_fixed_font;
142 GdkColor gui_colour_normal, gui_colour_changed, gui_colour_error;
143 GdkColor gui_colour_warn, gui_colour_pc, gui_colour_debug;
144 GdkColor gui_colour_trace, gui_colour_break, gui_colour_temp_break;
145 GdkColor gui_colour_white;
147 void gtk_gui_alloc_resources() {
150 gui_colour_normal.red = gui_colour_normal.green = gui_colour_normal.blue = 0;
151 gui_colour_changed.red = gui_colour_changed.green = 64*256;
152 gui_colour_changed.blue = 154*256;
153 gui_colour_error.red = 65535;
154 gui_colour_error.green = gui_colour_error.blue = 64*256;
155 gui_colour_pc.red = 32*256;
156 gui_colour_pc.green = 170*256;
157 gui_colour_pc.blue = 52*256;
158 gui_colour_warn = gui_colour_changed;
159 gui_colour_trace.red = 156*256;
160 gui_colour_trace.green = 78*256;
161 gui_colour_trace.blue = 201*256;
162 gui_colour_debug = gui_colour_pc;
163 gui_colour_break.red = 65535;
164 gui_colour_break.green = gui_colour_break.blue = 192*256;
165 gui_colour_temp_break.red = gui_colour_temp_break.green = 128*256;
166 gui_colour_temp_break.blue = 32*256;
167 gui_colour_white.red = gui_colour_white.green = gui_colour_white.blue = 65535;
169 map = gdk_colormap_new(gdk_visual_get_best(), TRUE);
170 gdk_colormap_alloc_color(map, &gui_colour_normal, TRUE, TRUE);
171 gdk_colormap_alloc_color(map, &gui_colour_changed, TRUE, TRUE);
172 gdk_colormap_alloc_color(map, &gui_colour_error, TRUE, TRUE);
173 gdk_colormap_alloc_color(map, &gui_colour_warn, TRUE, TRUE);
174 gdk_colormap_alloc_color(map, &gui_colour_pc, TRUE, TRUE);
175 gdk_colormap_alloc_color(map, &gui_colour_debug, TRUE, TRUE);
176 gdk_colormap_alloc_color(map, &gui_colour_trace, TRUE, TRUE);
177 gdk_colormap_alloc_color(map, &gui_colour_break, TRUE, TRUE);
178 gdk_colormap_alloc_color(map, &gui_colour_temp_break, TRUE, TRUE);
179 gdk_colormap_alloc_color(map, &gui_colour_white, TRUE, TRUE);
180 gui_fixed_font = pango_font_description_from_string("Courier 10");
.