revision 1124:aacaae9812ea
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1124:aacaae9812ea |
parent | 1123:b072c961c729 |
child | 1125:9dd5dee45db9 |
author | nkeynes |
date | Sat Sep 11 09:58:22 2010 +1000 (12 years ago) |
GTK: Force file extension when creating files
![]() | src/gtkui/gtk_ctrl.c | view | annotate | diff | log | |
![]() | src/gtkui/gtkcb.c | view | annotate | diff | log | |
![]() | src/gtkui/gtkui.h | view | annotate | diff | log | |
![]() | src/sh4/timer.c | view | annotate | diff | log | |
![]() | test/Makefile.in | view | annotate | diff | log |
1.1 --- a/src/gtkui/gtk_ctrl.c Sat Sep 11 09:44:21 2010 +10001.2 +++ b/src/gtkui/gtk_ctrl.c Sat Sep 11 09:58:22 2010 +10001.3 @@ -113,7 +113,7 @@1.4 }1.5 } else if( devclz == CREATE_VMU_TAG ) {1.6 devclz = NULL;1.7 - vmu_filename = save_file_dialog( _("Create VMU"), "*.vmu", "VMU Files",1.8 + vmu_filename = save_file_dialog( _("Create VMU"), "*.vmu", "VMU Files", ".vmu",1.9 CONFIG_VMU_PATH );1.10 if( vmu_filename != NULL ) {1.11 devclz = &vmu_class;
2.1 --- a/src/gtkui/gtkcb.c Sat Sep 11 09:44:21 2010 +10002.2 +++ b/src/gtkui/gtkcb.c Sat Sep 11 09:58:22 2010 +10002.3 @@ -76,7 +76,7 @@2.4 }2.6 gchar *save_file_dialog( const char *title, const char *pattern, const char *patname,2.7 - int initial_dir_key )2.8 + const char *mandatory_ext, int initial_dir_key )2.9 {2.10 GtkWidget *file;2.11 gchar *filename = NULL;2.12 @@ -97,6 +97,15 @@2.13 int result = gtk_dialog_run( GTK_DIALOG(file) );2.14 if( result == GTK_RESPONSE_ACCEPT ) {2.15 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );2.16 + if( mandatory_ext ) {2.17 + int extlen = strlen(mandatory_ext);2.18 + int fnlen = strlen(filename);2.19 + if( fnlen < extlen || strcmp(filename + (fnlen - extlen), mandatory_ext) != 0 ) {2.20 + gchar *f2 = g_strdup_printf("%s%s",filename, mandatory_ext);2.21 + g_free(filename);2.22 + filename = f2;2.23 + }2.24 + }2.25 if( initial_dir_key != -1 ) {2.26 gchar *end_path = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(file) );2.27 set_gui_path(initial_dir_key,end_path);2.28 @@ -118,9 +127,9 @@2.29 }2.31 void save_file_dialog_cb( const char *title, file_callback_t action, const char *pattern, const char *patname,2.32 - int initial_dir_key )2.33 + const char *mandatory_ext, int initial_dir_key )2.34 {2.35 - gchar *filename = save_file_dialog( title, pattern, patname, initial_dir_key );2.36 + gchar *filename = save_file_dialog( title, pattern, patname, mandatory_ext, initial_dir_key );2.37 if( filename != NULL ) {2.38 action(filename);2.39 g_free(filename);2.40 @@ -224,7 +233,7 @@2.42 void save_state_action_callback( GtkAction *action, gpointer user_data)2.43 {2.44 - save_file_dialog_cb( "Save state...", dreamcast_save_state, "*.dst", _("lxDream Save State (*.dst)"), CONFIG_SAVE_PATH );2.45 + save_file_dialog_cb( "Save state...", dreamcast_save_state, "*.dst", _("lxDream Save State (*.dst)"), ".dst", CONFIG_SAVE_PATH );2.46 }2.48 void quick_state_action_callback( GtkRadioAction *action, GtkRadioAction *current, gpointer user_data)2.49 @@ -316,7 +325,7 @@2.51 void save_scene_action_callback( GtkAction *action, gpointer user_data)2.52 {2.53 - save_file_dialog_cb( _("Save next scene..."), pvr2_save_next_scene, "*.dsc", _("lxdream scene file (*.dsc)"), CONFIG_SAVE_PATH );2.54 + save_file_dialog_cb( _("Save next scene..."), pvr2_save_next_scene, "*.dsc", _("lxdream scene file (*.dsc)"), ".dsc", CONFIG_SAVE_PATH );2.55 }2.57 int debug_window_get_selected_row( debug_window_t data );
3.1 --- a/src/gtkui/gtkui.h Sat Sep 11 09:44:21 2010 +10003.2 +++ b/src/gtkui/gtkui.h Sat Sep 11 09:58:22 2010 +10003.3 @@ -93,11 +93,11 @@3.4 gchar *open_file_dialog( const char *title, const char *pattern, const char *patname,3.5 int initial_dir_key );3.6 gchar *save_file_dialog( const char *title, const char *pattern, const char *patname,3.7 - int initial_dir_key );3.8 + const char *mandatory_ext, int initial_dir_key );3.9 void open_file_dialog_cb( const char *title, file_callback_t action, const char *pattern, const char *patname,3.10 int initial_dir_key );3.11 void save_file_dialog_cb( const char *title, file_callback_t action, const char *pattern, const char *patname,3.12 - int initial_dir_key );3.13 + const char *mandatory_ext, int initial_dir_key );3.14 gboolean gtk_gui_gdrom_mount_image( const char *filename );3.15 /**3.16 * Extract the keyval of the key event if no modifier keys were pressed -
4.1 --- a/src/sh4/timer.c Sat Sep 11 09:44:21 2010 +10004.2 +++ b/src/sh4/timer.c Sat Sep 11 09:58:22 2010 +10004.3 @@ -42,7 +42,7 @@4.5 uint32_t sh4_cpu_period = 1000 / SH4_BASE_RATE; /* in nanoseconds */4.6 uint32_t sh4_bus_period = 2* 1000 / SH4_BASE_RATE;4.7 -uint32_t sh4_peripheral_period = 4 * 2000 / SH4_BASE_RATE;4.8 +uint32_t sh4_peripheral_period = 4 * 1000 / SH4_BASE_RATE;4.10 MMIO_REGION_READ_FN( CPG, reg )4.11 {4.12 @@ -112,13 +112,29 @@4.14 /********************************** TMU *************************************/4.16 +#define TCR_ICPF 0x02004.17 +#define TCR_UNF 0x01004.18 +#define TCR_UNIE 0x00204.19 +4.20 +#define TCR_IRQ_ACTIVE (TCR_UNF|TCR_UNIE)4.21 +4.22 #define TMU_IS_RUNNING(timer) (MMIO_READ(TMU,TSTR) & (1<<timer))4.24 +struct TMU_timer {4.25 + uint32_t timer_period;4.26 + uint32_t timer_remainder; /* left-over cycles from last count */4.27 + uint32_t timer_run; /* cycles already run from this slice */4.28 +};4.29 +4.30 +static struct TMU_timer TMU_timers[3];4.31 +4.32 uint32_t TMU_count( int timer, uint32_t nanosecs );4.33 +void TMU_schedule_timer( int timer );4.35 void TMU_event_callback( int eventid )4.36 {4.37 TMU_count( eventid - EVENT_TMU0, sh4r.slice_cycle );4.38 + assert( MMIO_READ( TMU, TCR0 + (eventid - EVENT_TMU0)*12 ) & 0x100 );4.39 }4.41 void TMU_init(void)4.42 @@ -128,19 +144,16 @@4.43 register_event_callback( EVENT_TMU2, TMU_event_callback );4.44 }4.46 -#define TCR_ICPF 0x02004.47 -#define TCR_UNF 0x01004.48 -#define TCR_UNIE 0x00204.49 +void TMU_dump(unsigned timer)4.50 +{4.51 + fprintf(stderr, "Timer %d: %s %08x/%08x %dns run: %08X - %08X\n",4.52 + timer, TMU_IS_RUNNING(timer) ? "running" : "stopped",4.53 + MMIO_READ(TMU, TCNT0 + (timer*12)), MMIO_READ(TMU, TCOR0 + (timer*12)),4.54 + TMU_timers[timer].timer_period,4.55 + TMU_timers[timer].timer_run,4.56 + TMU_timers[timer].timer_remainder );4.57 +}4.59 -#define TCR_IRQ_ACTIVE (TCR_UNF|TCR_UNIE)4.60 -4.61 -struct TMU_timer {4.62 - uint32_t timer_period;4.63 - uint32_t timer_remainder; /* left-over cycles from last count */4.64 - uint32_t timer_run; /* cycles already run from this slice */4.65 -};4.66 -4.67 -static struct TMU_timer TMU_timers[3];4.69 void TMU_set_timer_control( int timer, int tcr )4.70 {4.71 @@ -188,17 +201,31 @@4.72 period = sh4_peripheral_period; /* I dunno... */4.73 break;4.74 }4.75 - TMU_timers[timer].timer_period = period;4.76 +4.77 + if( period != TMU_timers[timer].timer_period ) {4.78 + if( TMU_IS_RUNNING(timer) ) {4.79 + /* If we're changing clock speed while counting, sync up and reschedule */4.80 + TMU_count(timer, sh4r.slice_cycle);4.81 + TMU_timers[timer].timer_period = period;4.82 + TMU_schedule_timer(timer);4.83 + } else {4.84 + TMU_timers[timer].timer_period = period;4.85 + }4.86 + }4.88 MMIO_WRITE( TMU, TCR0 + (12*timer), tcr );4.89 }4.91 void TMU_schedule_timer( int timer )4.92 {4.93 - uint64_t duration = (uint64_t)((uint32_t)(MMIO_READ( TMU, TCNT0 + 12*timer )+1)) *4.94 + uint64_t duration = ((uint64_t)((uint32_t)(MMIO_READ( TMU, TCNT0 + 12*timer )))+1) *4.95 (uint64_t)TMU_timers[timer].timer_period - TMU_timers[timer].timer_remainder;4.96 event_schedule_long( EVENT_TMU0+timer, (uint32_t)(duration / 1000000000),4.97 (uint32_t)(duration % 1000000000) );4.98 +// if( timer == 2 ) {4.99 +// WARN( "Schedule timer %d: %lldns", timer, duration );4.100 +// TMU_dump(timer);4.101 +// }4.102 }4.104 void TMU_start( int timer )4.105 @@ -230,6 +257,8 @@4.106 uint32_t count = run_ns / TMU_timers[timer].timer_period;4.107 uint32_t value = MMIO_READ( TMU, TCNT0 + 12*timer );4.108 uint32_t reset = MMIO_READ( TMU, TCOR0 + 12*timer );4.109 +// if( timer == 2 )4.110 +// WARN( "Counting timer %d: %d ns, %d ticks", timer, run_ns, count );4.111 if( count > value ) {4.112 uint32_t tcr = MMIO_READ( TMU, TCR0 + 12*timer );4.113 tcr |= TCR_UNF;4.114 @@ -239,6 +268,8 @@4.115 if( tcr & TCR_UNIE )4.116 intc_raise_interrupt( INT_TMU_TUNI0 + timer );4.117 MMIO_WRITE( TMU, TCNT0 + 12*timer, value );4.118 +// if( timer == 2 )4.119 +// WARN( "Underflowed timer %d", timer );4.120 TMU_schedule_timer(timer);4.121 } else {4.122 value -= count;
5.1 --- a/test/Makefile.in Sat Sep 11 09:44:21 2010 +10005.2 +++ b/test/Makefile.in Sat Sep 11 09:58:22 2010 +10005.3 @@ -73,6 +73,7 @@5.4 @BUILD_SYSTEST_TRUE@check: build-tests5.5 @BUILD_SYSTEST_TRUE@ $(RUNTEST) testsh45.6 @BUILD_SYSTEST_TRUE@ $(RUNTESTX) testsh45.7 +@BUILD_SYSTEST_TRUE@ $(RUNTEST) randmath < $(srcdir)/random.dat > randmath.out && diff -u randmath.out randmath.expect5.8 @BUILD_SYSTEST_TRUE@ $(RUNTEST) testmmu5.9 @BUILD_SYSTEST_TRUE@ $(RUNTEST) testregs5.10 @BUILD_SYSTEST_TRUE@ cat $(srcdir)/testta.data $(srcdir)/testta2.data $(srcdir)/testta3.data $(srcdir)/testta4.data $(srcdir)/testta5.data | $(RUNTEST) testta5.11 @@ -80,7 +81,7 @@5.12 # $(RUNTEST) testide -d ../disc/test.nrg5.15 -build-tests: testsh4 testmmu testmath testide testta testregs testrend testdisp testspu testmmu5.16 +build-tests: testsh4 testmmu testmath testide testta testregs testrend testdisp testspu testmmu randmath randmath.expect5.18 lib/crt0.so: lib/crt0.s5.19 $(mkdir_p) lib5.20 @@ -161,6 +162,14 @@5.21 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)5.22 $(SH4OBJCOPY) testFF10 testFF10.bin5.24 +randmath: lib/crt0.so $(SHARED_OBJECTS) randmath.so5.25 + $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)5.26 + $(SH4OBJCOPY) randmath randmath.bin5.27 +5.28 +randmath.expect: randmath.c5.29 + $(HOSTCC) $^ -o randmath.native5.30 + ./randmath.native < $(srcdir)/random.dat > $@5.31 +5.32 .PHONY : clean5.33 clean:5.34 rm -f *.o *.so *.ao *.ac *.bin sh4/*.so lib/*.so lib-arm/*.ao mapleid \5.35 @@ -184,10 +193,10 @@5.36 sh4/subv.s sh4/tas.s sh4/testsh4.c sh4/tlb.s sh4/vmexit.s sh4/trapa.s sh4/undef.s \5.37 sh4/xtrct.s sh4/utlb.c sh4/utlb.h sh4/testutlb.s testdata.c testdata.h testdisp.c \5.38 testide.c testmath.c testaica.c sh4/testmmu.c sh4/mmummio.c testregs.c testrend.c \5.39 - testspu.c testta.c testyuv.c timer.c timer.h \5.40 + testspu.c testta.c testyuv.c timer.c timer.h randmath.c \5.41 testta.data testta2.data testta3.data testta4.data testta5.data testsort.data \5.42 lxdream.rc dc.x lib/crt0.s lib/libc.a lib/libm.a lib/newlib-1.8.2-dc.patch \5.43 - aica.x lib-arm/libc.a lib-arm/libm.a lib-arm/crt0.s \5.44 + aica.x lib-arm/libc.a lib-arm/libm.a lib-arm/crt0.s random.dat \5.45 include/_ansi.h include/_syslist.h include/ar.h include/assert.h include/ctype.h \5.46 include/dirent.h include/errno.h include/fastmath.h include/fcntl.h include/grp.h \5.47 include/ieeefp.h include/locale.h include/machine/fastmath.h include/machine/ieeefp.h \
.