Search
lxdream.org :: lxdream :: r437:2c259474b474
lxdream 0.9.1
released Jun 29
Download Now
changeset437:2c259474b474
parent436:e8c461d2545e
child438:f4d7774967d1
authornkeynes
dateThu Oct 11 08:22:03 2007 +0000 (12 years ago)
Add speed meter to main window
Add sunken border around video area
Add debugger menu item
Move logging out to util.c
src/bootstrap.c
src/dream.h
src/gui/debug_win.c
src/gui/gtkcb.c
src/gui/gtkui.c
src/gui/gtkui.h
src/gui/main_win.c
src/util.c
1.1 --- a/src/bootstrap.c Thu Oct 11 08:20:38 2007 +0000
1.2 +++ b/src/bootstrap.c Thu Oct 11 08:22:03 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: bootstrap.c,v 1.7 2007-10-06 08:59:42 nkeynes Exp $
1.6 + * $Id: bootstrap.c,v 1.8 2007-10-11 08:22:03 nkeynes Exp $
1.7 *
1.8 * CD Bootstrap header parsing. Mostly for informational purposes.
1.9 *
1.10 @@ -128,8 +128,7 @@
1.11 INFO( " Product ID: %-10.10s Product Ver: %-6.6s Date: %-8.8s",
1.12 head->product_id, head->product_ver, head->product_date );
1.13 if( detail ) {
1.14 - emit( NULL, crc == hcrc ? EMIT_INFO : EMIT_WARN, "File",
1.15 - " Header CRC: %04X (Computed %04X)", hcrc, crc );
1.16 + INFO( " Header CRC: %04X (Computed %04X)", hcrc, crc );
1.17 INFO( " Boot File: %-16.16s", head->boot_file );
1.18 INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",
1.19 head->gdrom_id, head->regions, periph );
2.1 --- a/src/dream.h Thu Oct 11 08:20:38 2007 +0000
2.2 +++ b/src/dream.h Thu Oct 11 08:22:03 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: dream.h,v 1.14 2007-10-10 11:02:04 nkeynes Exp $
2.6 + * $Id: dream.h,v 1.15 2007-10-11 08:22:03 nkeynes Exp $
2.7 *
2.8 * Miscellaneous application-wide declarations (mainly logging atm)
2.9 *
2.10 @@ -103,14 +103,14 @@
2.11 #define MODULE unknown_module
2.12 #endif
2.13
2.14 -void emit( void *, int level, const char *source, const char *msg, ... );
2.15 +void log_message( void *, int level, const char *source, const char *msg, ... );
2.16
2.17 -#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
2.18 -#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
2.19 -#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
2.20 -#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
2.21 -#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
2.22 -#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
2.23 +#define FATAL( ... ) log_message( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
2.24 +#define ERROR( ... ) log_message( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
2.25 +#define WARN( ... ) log_message( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
2.26 +#define INFO( ... ) log_message( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
2.27 +#define DEBUG( ... ) log_message( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
2.28 +#define TRACE( ... ) log_message( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
2.29
2.30 void fwrite_string( const char *s, FILE *f );
2.31 int fread_string( char *s, int maxlen, FILE *f );
3.1 --- a/src/gui/debug_win.c Thu Oct 11 08:20:38 2007 +0000
3.2 +++ b/src/gui/debug_win.c Thu Oct 11 08:22:03 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: debug_win.c,v 1.23 2007-10-10 11:02:04 nkeynes Exp $
3.6 + * $Id: debug_win.c,v 1.24 2007-10-11 08:22:03 nkeynes Exp $
3.7 * This file is responsible for the main debugger gui frame.
3.8 *
3.9 * Copyright (c) 2005 Nathan Keynes.
3.10 @@ -28,8 +28,6 @@
3.11
3.12 GdkColor *msg_colors[] = { &gui_colour_error, &gui_colour_error, &gui_colour_warn,
3.13 &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };
3.14 -char *msg_levels[] = { "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
3.15 -int global_msg_level = EMIT_WARN;
3.16
3.17 const cpu_desc_t cpu_list[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };
3.18
3.19 @@ -292,7 +290,7 @@
3.20 return (address - data->disasm_from) / data->cpu->instr_size;
3.21 }
3.22
3.23 -
3.24 +#if 0
3.25 void emit( void *ptr, int level, const gchar *source, const char *msg, ... )
3.26 {
3.27 char buf[20], addr[10] = "", *p;
3.28 @@ -337,7 +335,7 @@
3.29 while( gtk_events_pending() )
3.30 gtk_main_iteration();
3.31 }
3.32 -
3.33 +#endif
3.34 debug_window_t get_debug_info( GtkWidget *widget ) {
3.35
3.36 GtkWidget *win = gtk_widget_get_toplevel(widget);
4.1 --- a/src/gui/gtkcb.c Thu Oct 11 08:20:38 2007 +0000
4.2 +++ b/src/gui/gtkcb.c Thu Oct 11 08:22:03 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: gtkcb.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
4.6 + * $Id: gtkcb.c,v 1.2 2007-10-11 08:22:03 nkeynes Exp $
4.7 *
4.8 * Action callbacks from the main window
4.9 *
4.10 @@ -159,6 +159,10 @@
4.11 exit(0);
4.12 }
4.13
4.14 +void debugger_action_callback( GtkAction *action, gpointer user_data)
4.15 +{
4.16 + gtk_gui_show_debugger();
4.17 +}
4.18
4.19 void audio_settings_callback( GtkAction *action, gpointer user_data)
4.20 {
5.1 --- a/src/gui/gtkui.c Thu Oct 11 08:20:38 2007 +0000
5.2 +++ b/src/gui/gtkui.c Thu Oct 11 08:22:03 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: gtkui.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
5.6 + * $Id: gtkui.c,v 1.2 2007-10-11 08:22:03 nkeynes Exp $
5.7 *
5.8 * Core GTK-based user interface
5.9 *
5.10 @@ -16,6 +16,8 @@
5.11 * GNU General Public License for more details.
5.12 */
5.13
5.14 +#include <sys/time.h>
5.15 +#include <time.h>
5.16 #include "dream.h"
5.17 #include "dreamcast.h"
5.18 #include "gui/gtkui.h"
5.19 @@ -45,7 +47,7 @@
5.20 * Count of running nanoseconds - used to cut back on the GUI runtime
5.21 */
5.22 static uint32_t gtk_gui_nanos = 0;
5.23 -
5.24 +static struct timeval gtk_gui_lasttv;
5.25
5.26 gboolean gui_parse_cmdline( int *argc, char **argv[] )
5.27 {
5.28 @@ -97,6 +99,8 @@
5.29 if( debug_win != NULL ) {
5.30 debug_window_set_running( debug_win, TRUE );
5.31 }
5.32 + gtk_gui_nanos = 0;
5.33 + gettimeofday(&gtk_gui_lasttv,NULL);
5.34 }
5.35
5.36 /**
5.37 @@ -129,10 +133,18 @@
5.38 {
5.39 gtk_gui_nanos += nanosecs;
5.40 if( gtk_gui_nanos > 100000000 ) {
5.41 - gtk_gui_nanos = 0;
5.42 + struct timeval tv;
5.43 while( gtk_events_pending() )
5.44 gtk_main_iteration();
5.45 - // main_window_set_framerate( main_win, pvr2_get_frame_rate() );
5.46 +
5.47 + gettimeofday(&tv,NULL);
5.48 + double ns = ((tv.tv_sec - gtk_gui_lasttv.tv_sec) * 1000000000.0) +
5.49 + ((tv.tv_usec - gtk_gui_lasttv.tv_usec)*1000.0);
5.50 + double speed = (float)( (double)gtk_gui_nanos * 100.0 / ns );
5.51 + gtk_gui_lasttv.tv_sec = tv.tv_sec;
5.52 + gtk_gui_lasttv.tv_usec = tv.tv_usec;
5.53 + main_window_set_speed( main_win, speed );
5.54 + gtk_gui_nanos = 0;
5.55 }
5.56 return nanosecs;
5.57 }
6.1 --- a/src/gui/gtkui.h Thu Oct 11 08:20:38 2007 +0000
6.2 +++ b/src/gui/gtkui.h Thu Oct 11 08:22:03 2007 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: gtkui.h,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
6.6 + * $Id: gtkui.h,v 1.2 2007-10-11 08:22:03 nkeynes Exp $
6.7 *
6.8 * Core GTK-based user interface
6.9 *
6.10 @@ -38,6 +38,7 @@
6.11 GtkWidget *main_window_get_renderarea( main_window_t win );
6.12 void main_window_set_running( main_window_t win, gboolean running );
6.13 void main_window_set_framerate( main_window_t win, float rate );
6.14 +void main_window_set_speed( main_window_t win, double speed );
6.15
6.16 debug_window_t debug_window_new();
6.17
6.18 @@ -62,6 +63,7 @@
6.19 void load_state_action_callback( GtkAction *action, gpointer user_data);
6.20 void save_state_action_callback( GtkAction *action, gpointer user_data);
6.21 void about_action_callback( GtkAction *action, gpointer user_data);
6.22 +void debugger_action_callback( GtkAction *action, gpointer user_data);
6.23 void exit_action_callback( GtkAction *action, gpointer user_data);
6.24
6.25 void audio_settings_callback( GtkAction *action, gpointer user_data);
7.1 --- a/src/gui/main_win.c Thu Oct 11 08:20:38 2007 +0000
7.2 +++ b/src/gui/main_win.c Thu Oct 11 08:22:03 2007 +0000
7.3 @@ -1,5 +1,5 @@
7.4 /**
7.5 - * $Id: main_win.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
7.6 + * $Id: main_win.c,v 1.2 2007-10-11 08:22:03 nkeynes Exp $
7.7 *
7.8 * Define the main (emu) GTK window, along with its menubars,
7.9 * toolbars, etc.
7.10 @@ -44,6 +44,7 @@
7.11 { "Run", GTK_STOCK_MEDIA_PLAY, "Resume", NULL, "Resume", G_CALLBACK(resume_action_callback) },
7.12 { "LoadState", GTK_STOCK_REVERT_TO_SAVED, "_Load state...", "F4", "Load an lxdream save state", G_CALLBACK(load_state_action_callback) },
7.13 { "SaveState", GTK_STOCK_SAVE_AS, "_Save state...", "F3", "Create an lxdream save state", G_CALLBACK(save_state_action_callback) },
7.14 + { "Debugger", NULL, "_Debugger", NULL, "Open debugger window", G_CALLBACK(debugger_action_callback) },
7.15 { "Exit", GTK_STOCK_QUIT, "E_xit", NULL, "Exit lxdream", G_CALLBACK(exit_action_callback) },
7.16 { "AudioSettings", NULL, "_Audio...", NULL, "Configure audio output", G_CALLBACK(audio_settings_callback) },
7.17 { "ControllerSettings", NULL, "_Controllers...", NULL, "Configure controllers", G_CALLBACK(controller_settings_callback) },
7.18 @@ -68,6 +69,7 @@
7.19 " <separator/>"
7.20 " <menuitem action='LoadState'/>"
7.21 " <menuitem action='SaveState'/>"
7.22 + " <menuitem action='Debugger'/>"
7.23 " <separator/>"
7.24 " <menuitem action='Exit'/>"
7.25 " </menu>"
7.26 @@ -109,6 +111,7 @@
7.27 GtkWidget *vbox;
7.28 GtkUIManager *ui_manager;
7.29 GtkAccelGroup *accel_group;
7.30 + GtkWidget *frame;
7.31 GError *error = NULL;
7.32 main_window_t win = g_malloc0( sizeof(struct main_window_info) );
7.33
7.34 @@ -141,17 +144,22 @@
7.35 win->video = gtk_drawing_area_new();
7.36 GTK_WIDGET_SET_FLAGS(win->video, GTK_CAN_FOCUS|GTK_CAN_DEFAULT);
7.37 gtk_widget_set_size_request( win->video, 640, 480 );
7.38 + frame = gtk_frame_new(NULL);
7.39 + gtk_frame_set_shadow_type( GTK_FRAME(frame), GTK_SHADOW_IN );
7.40 + gtk_container_add( GTK_CONTAINER(frame), win->video );
7.41 +
7.42 win->statusbar = gtk_statusbar_new();
7.43
7.44 vbox = gtk_vbox_new(FALSE, 0);
7.45 gtk_container_add( GTK_CONTAINER(win->window), vbox );
7.46 gtk_box_pack_start( GTK_BOX(vbox), win->menubar, FALSE, FALSE, 0 );
7.47 gtk_box_pack_start( GTK_BOX(vbox), win->toolbar, FALSE, FALSE, 0 );
7.48 - gtk_box_pack_start( GTK_BOX(vbox), win->video, TRUE, TRUE, 1 );
7.49 + gtk_box_pack_start( GTK_BOX(vbox), frame, TRUE, TRUE, 0 );
7.50 gtk_box_pack_start( GTK_BOX(vbox), win->statusbar, FALSE, FALSE, 0 );
7.51 gtk_widget_show_all( win->window );
7.52 gtk_widget_grab_focus( win->video );
7.53
7.54 + gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, "Stopped" );
7.55 return win;
7.56 }
7.57
7.58 @@ -159,6 +167,8 @@
7.59 {
7.60 SET_ACTION_ENABLED( win, "Pause", running );
7.61 SET_ACTION_ENABLED( win, "Run", !running );
7.62 + gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );
7.63 + gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, running ? "Running" : "Stopped" );
7.64 }
7.65
7.66 void main_window_set_framerate( main_window_t win, float rate )
7.67 @@ -167,6 +177,17 @@
7.68
7.69 }
7.70
7.71 +void main_window_set_speed( main_window_t win, double speed )
7.72 +{
7.73 + char buf[32];
7.74 +
7.75 + snprintf( buf, 32, "Running (%2.4f%)", speed );
7.76 + gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );
7.77 + gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, buf );
7.78 +
7.79 +
7.80 +}
7.81 +
7.82 GtkWidget *main_window_get_renderarea( main_window_t win )
7.83 {
7.84 return win->video;
8.1 --- a/src/util.c Thu Oct 11 08:20:38 2007 +0000
8.2 +++ b/src/util.c Thu Oct 11 08:22:03 2007 +0000
8.3 @@ -1,5 +1,5 @@
8.4 /**
8.5 - * $Id: util.c,v 1.8 2007-10-07 06:03:22 nkeynes Exp $
8.6 + * $Id: util.c,v 1.9 2007-10-11 08:22:03 nkeynes Exp $
8.7 *
8.8 * Miscellaneous utility functions.
8.9 *
8.10 @@ -17,7 +17,15 @@
8.11 */
8.12
8.13 #include <ctype.h>
8.14 +#include <stdarg.h>
8.15 +#include <stdio.h>
8.16 +#include <stdlib.h>
8.17 +#include <time.h>
8.18 #include "dream.h"
8.19 +#include "sh4/sh4core.h"
8.20 +
8.21 +char *msg_levels[] = { "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
8.22 +int global_msg_level = EMIT_WARN;
8.23
8.24 void fwrite_string( const char *s, FILE *f )
8.25 {
8.26 @@ -81,3 +89,25 @@
8.27 fprintf( f, "\n" );
8.28 }
8.29 }
8.30 +
8.31 +
8.32 +void log_message( void *ptr, int level, const gchar *source, const char *msg, ... )
8.33 +{
8.34 + char buf[20], addr[10] = "", *p;
8.35 + const gchar *arr[4] = {buf, source, addr};
8.36 + int posn;
8.37 + time_t tm = time(NULL);
8.38 + va_list ap;
8.39 +
8.40 + if( level > global_msg_level ) {
8.41 + return; // ignored
8.42 + }
8.43 + va_start(ap, msg);
8.44 +
8.45 + strftime( buf, sizeof(buf), "%H:%M:%S", localtime(&tm) );
8.46 +
8.47 + fprintf( stderr, "%s %08X %-5s ", buf, sh4r.pc, msg_levels[level] );
8.48 + vfprintf( stderr, msg, ap );
8.49 + fprintf( stderr, "\n" );
8.50 + va_end(ap);
8.51 +}
.