Search
lxdream.org :: lxdream :: r27:1ef09a52cd1e
lxdream 0.9.1
released Jun 29
Download Now
changeset27:1ef09a52cd1e
parent26:ad258e3daaa5
child28:81c206f59dc7
authornkeynes
dateSun Dec 25 01:28:39 2005 +0000 (14 years ago)
Refactor all the GUI bits out of the main directory (except for a couple
lingering temporarily in loader.c
Fix a few timeslice issues
src/dreamcast.c
src/gui/callbacks.c
src/gui/gui.c
src/gui/gui.h
src/loader.c
src/main.c
src/modules.h
src/pvr2/pvr2.c
src/sh4/sh4core.c
src/sh4/sh4core.h
1.1 --- a/src/dreamcast.c Sat Dec 24 08:02:18 2005 +0000
1.2 +++ b/src/dreamcast.c Sun Dec 25 01:28:39 2005 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: dreamcast.c,v 1.9 2005-12-24 08:02:14 nkeynes Exp $
1.6 + * $Id: dreamcast.c,v 1.10 2005-12-25 01:28:36 nkeynes Exp $
1.7 * Central switchboard for the system. This pulls all the individual modules
1.8 * together into some kind of coherent structure. This is also where you'd
1.9 * add Naomi support, if I ever get a board to play with...
1.10 @@ -111,9 +111,10 @@
1.11 }
1.12 dreamcast_state = STATE_RUNNING;
1.13 while( dreamcast_state == STATE_RUNNING ) {
1.14 + int time_to_run = timeslice_length;
1.15 for( i=0; i<num_modules; i++ ) {
1.16 if( modules[i]->run_time_slice != NULL )
1.17 - modules[i]->run_time_slice( timeslice_length );
1.18 + time_to_run = modules[i]->run_time_slice( time_to_run );
1.19 }
1.20
1.21 }
1.22 @@ -123,7 +124,6 @@
1.23 modules[i]->stop();
1.24 }
1.25 dreamcast_state = STATE_STOPPED;
1.26 - update_gui();
1.27 }
1.28
1.29 void dreamcast_stop( void )
2.1 --- a/src/gui/callbacks.c Sat Dec 24 08:02:18 2005 +0000
2.2 +++ b/src/gui/callbacks.c Sun Dec 25 01:28:39 2005 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: callbacks.c,v 1.8 2005-12-24 08:02:18 nkeynes Exp $
2.6 + * $Id: callbacks.c,v 1.9 2005-12-25 01:28:39 nkeynes Exp $
2.7 *
2.8 * All GTK callbacks go here (stubs are autogenerated by Glade)
2.9 *
2.10 @@ -102,7 +102,6 @@
2.11 gpointer user_data)
2.12 {
2.13 dreamcast_reset();
2.14 - update_gui();
2.15 }
2.16
2.17
2.18 @@ -119,7 +118,7 @@
2.19 gpointer user_data)
2.20 {
2.21 sh4_execute_instruction();
2.22 - update_gui();
2.23 + gtk_gui_update();
2.24 }
2.25
2.26
3.1 --- a/src/gui/gui.c Sat Dec 24 08:02:18 2005 +0000
3.2 +++ b/src/gui/gui.c Sun Dec 25 01:28:39 2005 +0000
3.3 @@ -2,22 +2,40 @@
3.4 #include <stdarg.h>
3.5 #include <gnome.h>
3.6 #include <math.h>
3.7 +#include "dream.h"
3.8 #include "dreamcast.h"
3.9 -#include "gui.h"
3.10 #include "mem.h"
3.11 #include "sh4dasm.h"
3.12 #include "sh4core.h"
3.13 +#include "gui/gui.h"
3.14
3.15 #define REGISTER_FONT "-*-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-1"
3.16
3.17 GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;
3.18 PangoFontDescription *fixed_list_font;
3.19
3.20 +debug_info_t main_debug;
3.21 +
3.22 +
3.23 void open_file_callback(GtkWidget *btn, gint result, gpointer user_data);
3.24
3.25 -void init_gui() {
3.26 +void gtk_gui_init( void );
3.27 +void gtk_gui_update( void );
3.28 +int gtk_gui_run_slice( int microsecs );
3.29 +
3.30 +struct dreamcast_module gtk_gui_module = { "Debugger", gtk_gui_init,
3.31 + gtk_gui_update, NULL,
3.32 + gtk_gui_run_slice,
3.33 + gtk_gui_update,
3.34 + NULL, NULL };
3.35 +
3.36 +const cpu_desc_t cpu_descs[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };
3.37 +
3.38 +
3.39 +void gtk_gui_init() {
3.40 GdkColormap *map;
3.41 -
3.42 + GtkWidget *debug_win;
3.43 +
3.44 clrNormal.red = clrNormal.green = clrNormal.blue = 0;
3.45 clrChanged.red = clrChanged.green = 64*256;
3.46 clrChanged.blue = 154*256;
3.47 @@ -41,16 +59,23 @@
3.48 gdk_colormap_alloc_color(map, &clrDebug, TRUE, TRUE);
3.49 gdk_colormap_alloc_color(map, &clrTrace, TRUE, TRUE);
3.50 fixed_list_font = pango_font_description_from_string("Courier 10");
3.51 + debug_win = create_debug_win ();
3.52 + main_debug = init_debug_win(debug_win, cpu_descs);
3.53 + init_mmr_win();
3.54 +
3.55 + gtk_widget_show (debug_win);
3.56 +
3.57 }
3.58
3.59 -void gui_run_slice( int millisecs )
3.60 +int gtk_gui_run_slice( int microsecs )
3.61 {
3.62 while( gtk_events_pending() )
3.63 gtk_main_iteration();
3.64 update_icount(main_debug);
3.65 + return microsecs;
3.66 }
3.67
3.68 -void update_gui(void) {
3.69 +void gtk_gui_update(void) {
3.70 update_registers(main_debug);
3.71 update_icount(main_debug);
3.72 update_mmr_win();
4.1 --- a/src/gui/gui.h Sat Dec 24 08:02:18 2005 +0000
4.2 +++ b/src/gui/gui.h Sun Dec 25 01:28:39 2005 +0000
4.3 @@ -7,7 +7,10 @@
4.4 #include <gnome.h>
4.5 #include "dream.h"
4.6 #include "disasm.h"
4.7 +#include "modules.h"
4.8 #include "gui/interface.h"
4.9 +#include "sh4/sh4dasm.h"
4.10 +#include "aica/armdasm.h"
4.11
4.12 #ifdef __cplusplus
4.13 extern "C" {
4.14 @@ -16,8 +19,9 @@
4.15 #endif
4.16 #endif
4.17
4.18 -void init_gui(void);
4.19 -void update_gui(void);
4.20 +void gtk_gui_init(void);
4.21 +void gtk_gui_update(void);
4.22 +extern struct dreamcast_module gtk_gui_module;
4.23
4.24 typedef struct debug_info_struct *debug_info_t;
4.25 extern debug_info_t main_debug;
5.1 --- a/src/loader.c Sat Dec 24 08:02:18 2005 +0000
5.2 +++ b/src/loader.c Sun Dec 25 01:28:39 2005 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: loader.c,v 1.7 2005-12-24 08:02:14 nkeynes Exp $
5.6 + * $Id: loader.c,v 1.8 2005-12-25 01:28:36 nkeynes Exp $
5.7 *
5.8 * File loading routines, mostly for loading demos without going through the
5.9 * whole procedure of making a CD image for them.
5.10 @@ -76,9 +76,7 @@
5.11 read( fd, load, BOOTSTRAP_SIZE );
5.12 bootstrap_dump( load );
5.13 sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
5.14 - set_disassembly_region( main_debug, BOOTSTRAP_LOAD_ADDR );
5.15 - set_disassembly_pc( main_debug, sh4r.pc, TRUE );
5.16 - update_gui();
5.17 + gtk_gui_update();
5.18 } else {
5.19 /* look for a valid ISO9660 header */
5.20 lseek( fd, 32768, SEEK_SET );
5.21 @@ -103,7 +101,5 @@
5.22 int file_load_binary( const gchar *filename ) {
5.23 mem_load_block( filename, BINARY_LOAD_ADDR, -1 );
5.24 sh4_set_pc( BINARY_LOAD_ADDR );
5.25 - set_disassembly_region( main_debug, BINARY_LOAD_ADDR );
5.26 - set_disassembly_pc( main_debug, sh4r.pc, TRUE );
5.27 - update_gui();
5.28 + gtk_gui_update();
5.29 }
6.1 --- a/src/main.c Sat Dec 24 08:02:18 2005 +0000
6.2 +++ b/src/main.c Sun Dec 25 01:28:39 2005 +0000
6.3 @@ -10,35 +10,20 @@
6.4 #include <gnome.h>
6.5
6.6 #include "gui/gui.h"
6.7 -#include "sh4core.h"
6.8 -#include "sh4dasm.h"
6.9 -#include "aica/armdasm.h"
6.10 -#include "mem.h"
6.11 -
6.12 -debug_info_t main_debug;
6.13 -
6.14 -const cpu_desc_t cpu_descs[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };
6.15 +#include "dream.h"
6.16 +#include "dreamcast.h"
6.17
6.18 int
6.19 main (int argc, char *argv[])
6.20 {
6.21 - GtkWidget *debug_win;
6.22 -
6.23 #ifdef ENABLE_NLS
6.24 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
6.25 textdomain (PACKAGE);
6.26 #endif
6.27 + dreamcast_init();
6.28 gnome_init ("dreamon", VERSION, argc, argv);
6.29 - init_gui();
6.30 - debug_win = create_debug_win ();
6.31 - main_debug = init_debug_win(debug_win, cpu_descs);
6.32 + dreamcast_register_module( &gtk_gui_module );
6.33 video_open();
6.34 - dreamcast_init();
6.35 - init_mmr_win(); /* Note: must be done after sh4_init */
6.36 - sh4_reset();
6.37 - update_gui();
6.38 - gtk_widget_show (debug_win);
6.39 - set_disassembly_region( main_debug, 0xA0000000 );
6.40 // mem_new_watch( 0x0C204818, 0x0C204830, WATCH_WRITE );
6.41
6.42 emit( main_debug, EMIT_INFO, -1, "DreamOn! ready..." );
7.1 --- a/src/modules.h Sat Dec 24 08:02:18 2005 +0000
7.2 +++ b/src/modules.h Sun Dec 25 01:28:39 2005 +0000
7.3 @@ -33,7 +33,7 @@
7.4 * Execute one time-slice worth of operations, for the given number of
7.5 * micro-seconds.
7.6 */
7.7 - void (*run_time_slice)( int microsecs );
7.8 + int (*run_time_slice)( int microsecs );
7.9 /**
7.10 * Set the module into a stopped state (may be NULL)
7.11 */
8.1 --- a/src/pvr2/pvr2.c Sat Dec 24 08:02:18 2005 +0000
8.2 +++ b/src/pvr2/pvr2.c Sun Dec 25 01:28:39 2005 +0000
8.3 @@ -10,7 +10,7 @@
8.4 char *video_base;
8.5
8.6 void pvr2_init( void );
8.7 -void pvr2_run_slice( int );
8.8 +int pvr2_run_slice( int );
8.9 void pvr2_next_frame( void );
8.10
8.11 struct dreamcast_module pvr2_module = { "PVR2", pvr2_init, NULL, NULL,
8.12 @@ -26,13 +26,14 @@
8.13 uint32_t pvr2_time_counter = 0;
8.14 uint32_t pvr2_time_per_frame = 20000;
8.15
8.16 -void pvr2_run_slice( int microsecs )
8.17 +int pvr2_run_slice( int microsecs )
8.18 {
8.19 pvr2_time_counter += microsecs;
8.20 if( pvr2_time_counter >= pvr2_time_per_frame ) {
8.21 pvr2_next_frame();
8.22 pvr2_time_counter -= pvr2_time_per_frame;
8.23 }
8.24 + return microsecs;
8.25 }
8.26
8.27 uint32_t vid_stride, vid_lpf, vid_ppl, vid_hres, vid_vres, vid_col;
9.1 --- a/src/sh4/sh4core.c Sat Dec 24 08:02:18 2005 +0000
9.2 +++ b/src/sh4/sh4core.c Sun Dec 25 01:28:39 2005 +0000
9.3 @@ -1,5 +1,5 @@
9.4 /**
9.5 - * $Id: sh4core.c,v 1.9 2005-12-23 11:44:55 nkeynes Exp $
9.6 + * $Id: sh4core.c,v 1.10 2005-12-25 01:28:39 nkeynes Exp $
9.7 *
9.8 * SH4 emulation core, and parent module for all the SH4 peripheral
9.9 * modules.
9.10 @@ -26,6 +26,17 @@
9.11 #include "clock.h"
9.12 #include "intc.h"
9.13
9.14 +/* CPU-generated exception code/vector pairs */
9.15 +#define EXC_POWER_RESET 0x000 /* vector special */
9.16 +#define EXC_MANUAL_RESET 0x020
9.17 +#define EXC_SLOT_ILLEGAL 0x1A0
9.18 +#define EXC_ILLEGAL 0x180
9.19 +#define EXV_ILLEGAL 0x100
9.20 +#define EXC_TRAP 0x160
9.21 +#define EXV_TRAP 0x100
9.22 +#define EXC_FPDISABLE 0x800
9.23 +#define EXV_FPDISABLE 0x100
9.24 +
9.25 uint32_t sh4_freq = SH4_BASE_RATE;
9.26 uint32_t sh4_bus_freq = SH4_BASE_RATE;
9.27 uint32_t sh4_peripheral_freq = SH4_BASE_RATE / 2;
9.28 @@ -34,7 +45,7 @@
9.29
9.30 void sh4_init( void );
9.31 void sh4_reset( void );
9.32 -void sh4_run_slice( int );
9.33 +int sh4_run_slice( int );
9.34 void sh4_start( void );
9.35 void sh4_stop( void );
9.36 void sh4_save_state( FILE *f );
9.37 @@ -45,41 +56,65 @@
9.38 sh4_save_state, sh4_load_state };
9.39
9.40 struct sh4_registers sh4r;
9.41 -static int running = 0;
9.42
9.43 void sh4_init(void)
9.44 {
9.45 register_io_regions( mmio_list_sh4mmio );
9.46 mmu_init();
9.47 + sh4_reset();
9.48 }
9.49
9.50 void sh4_reset(void)
9.51 {
9.52 /* zero everything out, for the sake of having a consistent state. */
9.53 memset( &sh4r, 0, sizeof(sh4r) );
9.54 +
9.55 + /* Resume running if we were halted */
9.56 + sh4r.sh4_state = SH4_STATE_RUNNING;
9.57 +
9.58 sh4r.pc = 0xA0000000;
9.59 sh4r.new_pc= 0xA0000002;
9.60 sh4r.vbr = 0x00000000;
9.61 sh4r.fpscr = 0x00040001;
9.62 sh4r.sr = 0x700000F0;
9.63 +
9.64 + /* Mem reset will do this, but if we want to reset _just_ the SH4... */
9.65 + MMIO_WRITE( MMU, EXPEVT, EXC_POWER_RESET );
9.66 +
9.67 + /* Peripheral modules */
9.68 intc_reset();
9.69 }
9.70
9.71 -void sh4_run_slice( int microsecs )
9.72 +int sh4_run_slice( int microsecs )
9.73 {
9.74 - int count = sh4_freq * microsecs;
9.75 + int target = sh4r.icount + sh4_freq * microsecs;
9.76 + int start = sh4r.icount;
9.77 int i;
9.78
9.79 - for( i=0; i<count; i++ ) {
9.80 - sh4_execute_instruction();
9.81 + if( sh4r.sh4_state != SH4_STATE_RUNNING ) {
9.82 + if( sh4r.int_pending != 0 )
9.83 + sh4r.sh4_state = SH4_STATE_RUNNING;;
9.84 }
9.85 - TMU_run_slice( microsecs );
9.86 - SCIF_run_slice( microsecs );
9.87 +
9.88 + while( sh4r.icount < target && sh4r.sh4_state == SH4_STATE_RUNNING ) {
9.89 + sh4r.icount++;
9.90 + if( !sh4_execute_instruction() )
9.91 + break;
9.92 + }
9.93 + if( target != sh4r.icount ) {
9.94 + /* Halted - compute time actually executed */
9.95 + microsecs = (sh4r.icount - start) / sh4_freq;
9.96 + }
9.97 + if( sh4r.sh4_state != SH4_STATE_STANDBY ) {
9.98 + TMU_run_slice( microsecs );
9.99 + SCIF_run_slice( microsecs );
9.100 + }
9.101 + return microsecs;
9.102 }
9.103
9.104 void sh4_stop(void)
9.105 {
9.106 - running = 0;
9.107 +
9.108 }
9.109
9.110 void sh4_save_state( FILE *f )
9.111 @@ -94,14 +129,6 @@
9.112 return SCIF_load_state( f );
9.113 }
9.114
9.115 -void sh4_run(void)
9.116 -{
9.117 - running = 1;
9.118 - while( running ) {
9.119 - sh4_execute_instruction();
9.120 - }
9.121 -}
9.122 -
9.123 /********************** SH4 emulation core ****************************/
9.124
9.125 void sh4_set_pc( int pc )
9.126 @@ -115,40 +142,8 @@
9.127
9.128 }
9.129
9.130 -void sh4_runfor(uint32_t count)
9.131 -{
9.132 - running = 1;
9.133 - while( running && count--) {
9.134 - int pc = sh4r.pc;
9.135 - sh4_execute_instruction();
9.136 - /*
9.137 - if( sh4r.pc == 0x8C0C1636 ||
9.138 - sh4r.pc == 0x8C0C1634 ) {
9.139 - WARN( "Branching to %08X from %08X", sh4r.pc, pc );
9.140 - sh4_stop();
9.141 - }*/
9.142 - }
9.143 -}
9.144 -
9.145 -int sh4_isrunning(void)
9.146 -{
9.147 - return running;
9.148 -}
9.149 -
9.150 -void sh4_runto( uint32_t target_pc, uint32_t count )
9.151 -{
9.152 - running = 1;
9.153 - while( running && count--) {
9.154 - sh4_execute_instruction();
9.155 - if( sh4r.pc == target_pc ) {
9.156 - running = 0;
9.157 - break;
9.158 - }
9.159 - }
9.160 -}
9.161 -
9.162 -#define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", sh4r.pc, ir ); sh4_stop(); RAISE( EXC_ILLEGAL, EXV_ILLEGAL ); }while(0)
9.163 -#define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", sh4r.pc, ir ); sh4_stop(); return; }while(0)
9.164 +#define UNDEF(ir) do{ ERROR( "Raising exception on undefined instruction at %08x, opcode = %04x", sh4r.pc, ir ); RAISE( EXC_ILLEGAL, EXV_ILLEGAL ); }while(0)
9.165 +#define UNIMP(ir) do{ ERROR( "Halted on unimplemented instruction at %08x, opcode = %04x", sh4r.pc, ir ); dreamcast_stop(); return FALSE; }while(0)
9.166
9.167 #define RAISE( x, v ) do{ \
9.168 if( sh4r.vbr == 0 ) { \
9.169 @@ -163,7 +158,7 @@
9.170 sh4r.new_pc = sh4r.pc + 2; \
9.171 sh4_load_sr( sh4r.ssr |SR_MD|SR_BL|SR_RB ); \
9.172 } \
9.173 - return; } while(0)
9.174 + return TRUE; } while(0)
9.175
9.176 #define MEM_READ_BYTE( addr ) sh4_read_byte(addr)
9.177 #define MEM_READ_WORD( addr ) sh4_read_word(addr)
9.178 @@ -184,16 +179,6 @@
9.179
9.180 #define FP_WIDTH (IS_FPU_DOUBLESIZE() ? 8 : 4)
9.181
9.182 -#define EXC_POWER_RESET 0x000 /* vector special */
9.183 -#define EXC_MANUAL_RESET 0x020
9.184 -#define EXC_SLOT_ILLEGAL 0x1A0
9.185 -#define EXC_ILLEGAL 0x180
9.186 -#define EXV_ILLEGAL 0x100
9.187 -#define EXC_TRAP 0x160
9.188 -#define EXV_TRAP 0x100
9.189 -#define EXC_FPDISABLE 0x800
9.190 -#define EXV_FPDISABLE 0x100
9.191 -
9.192 #define CHECK( x, c, v ) if( !x ) RAISE( c, v )
9.193 #define CHECKPRIV() CHECK( IS_SH4_PRIVMODE(), EXC_ILLEGAL, EXV_ILLEGAL )
9.194 #define CHECKFPUEN() CHECK( IS_FPU_ENABLED(), EXC_FPDISABLE, EXV_FPDISABLE )
9.195 @@ -250,7 +235,7 @@
9.196 WARN( "Accepting interrupt %03X, from %08X => %08X", code, sh4r.spc, sh4r.pc );
9.197 }
9.198
9.199 -void sh4_execute_instruction( void )
9.200 +gboolean sh4_execute_instruction( void )
9.201 {
9.202 int pc;
9.203 unsigned short ir;
9.204 @@ -331,14 +316,14 @@
9.205 sh4r.pr = sh4r.pc + 4;
9.206 sh4r.pc = sh4r.new_pc;
9.207 sh4r.new_pc = pc + 4 + RN(ir);
9.208 - return;
9.209 + return TRUE;
9.210 case 2: /* BRAF Rn */
9.211 CHECKDEST( pc + 4 + RN(ir) );
9.212 CHECKSLOTILLEGAL();
9.213 sh4r.in_delay_slot = 1;
9.214 sh4r.pc = sh4r.new_pc;
9.215 sh4r.new_pc = pc + 4 + RN(ir);
9.216 - return;
9.217 + return TRUE;
9.218 case 8: /* PREF [Rn] */
9.219 tmp = RN(ir);
9.220 if( (tmp & 0xFC000000) == 0xE0000000 ) {
9.221 @@ -442,10 +427,14 @@
9.222 sh4r.in_delay_slot = 1;
9.223 sh4r.pc = sh4r.new_pc;
9.224 sh4r.new_pc = sh4r.pr;
9.225 - return;
9.226 + return TRUE;
9.227 case 1: /* SLEEP */
9.228 - running = 0;
9.229 - break;
9.230 + if( MMIO_READ( CPG, STBCR ) & 0x80 ) {
9.231 + sh4r.sh4_state = SH4_STATE_STANDBY;
9.232 + } else {
9.233 + sh4r.sh4_state = SH4_STATE_SLEEP;
9.234 + }
9.235 + return FALSE; /* Halt CPU */
9.236 case 2: /* RTE */
9.237 CHECKPRIV();
9.238 CHECKDEST( sh4r.spc );
9.239 @@ -455,7 +444,7 @@
9.240 sh4r.new_pc = sh4r.spc;
9.241 sh4_load_sr( sh4r.ssr );
9.242 WARN( "RTE => %08X", sh4r.new_pc );
9.243 - return;
9.244 + return TRUE;
9.245 default:UNDEF(ir);
9.246 }
9.247 break;
9.248 @@ -681,7 +670,7 @@
9.249 sh4r.pc = sh4r.new_pc;
9.250 sh4r.new_pc = RN(ir);
9.251 sh4r.pr = pc + 4;
9.252 - return;
9.253 + return TRUE;
9.254 case 0x0E: /* LDC Rn, SR */
9.255 CHECKPRIV();
9.256 sh4_load_sr( RN(ir) );
9.257 @@ -784,7 +773,7 @@
9.258 sh4r.in_delay_slot = 1;
9.259 sh4r.pc = sh4r.new_pc;
9.260 sh4r.new_pc = RN(ir);
9.261 - return;
9.262 + return TRUE;
9.263 case 0x2E: /* LDC Rn, VBR */
9.264 CHECKPRIV();
9.265 sh4r.vbr = RN(ir);
9.266 @@ -992,7 +981,7 @@
9.267 CHECKDEST( sh4r.pc + (PCDISP8(ir)<<1) + 4 )
9.268 sh4r.pc += (PCDISP8(ir)<<1) + 4;
9.269 sh4r.new_pc = sh4r.pc + 2;
9.270 - return;
9.271 + return TRUE;
9.272 }
9.273 break;
9.274 case 11:/* BF disp8 */
9.275 @@ -1001,7 +990,7 @@
9.276 CHECKDEST( sh4r.pc + (PCDISP8(ir)<<1) + 4 )
9.277 sh4r.pc += (PCDISP8(ir)<<1) + 4;
9.278 sh4r.new_pc = sh4r.pc + 2;
9.279 - return;
9.280 + return TRUE;
9.281 }
9.282 break;
9.283 case 13:/* BT/S disp8 */
9.284 @@ -1012,7 +1001,7 @@
9.285 sh4r.pc = sh4r.new_pc;
9.286 sh4r.new_pc = pc + (PCDISP8(ir)<<1) + 4;
9.287 sh4r.in_delay_slot = 1;
9.288 - return;
9.289 + return TRUE;
9.290 }
9.291 break;
9.292 case 15:/* BF/S disp8 */
9.293 @@ -1022,7 +1011,7 @@
9.294 sh4r.in_delay_slot = 1;
9.295 sh4r.pc = sh4r.new_pc;
9.296 sh4r.new_pc = pc + (PCDISP8(ir)<<1) + 4;
9.297 - return;
9.298 + return TRUE;
9.299 }
9.300 break;
9.301 default: UNDEF(ir);
9.302 @@ -1039,7 +1028,7 @@
9.303 sh4r.in_delay_slot = 1;
9.304 sh4r.pc = sh4r.new_pc;
9.305 sh4r.new_pc = pc + 4 + (DISP12(ir)<<1);
9.306 - return;
9.307 + return TRUE;
9.308 case 11:/* 1011dddddddddddd */
9.309 /* BSR disp12 */
9.310 CHECKDEST( sh4r.pc + (DISP12(ir)<<1) + 4 )
9.311 @@ -1048,7 +1037,7 @@
9.312 sh4r.pr = pc + 4;
9.313 sh4r.pc = sh4r.new_pc;
9.314 sh4r.new_pc = pc + 4 + (DISP12(ir)<<1);
9.315 - return;
9.316 + return TRUE;
9.317 case 12:/* 1100xxxxdddddddd */
9.318 switch( (ir&0x0F00)>>8 ) {
9.319 case 0: /* MOV.B R0, [GBR + disp8] */
10.1 --- a/src/sh4/sh4core.h Sat Dec 24 08:02:18 2005 +0000
10.2 +++ b/src/sh4/sh4core.h Sun Dec 25 01:28:39 2005 +0000
10.3 @@ -1,5 +1,5 @@
10.4 /**
10.5 - * $Id: sh4core.h,v 1.4 2005-12-23 11:44:55 nkeynes Exp $
10.6 + * $Id: sh4core.h,v 1.5 2005-12-25 01:28:39 nkeynes Exp $
10.7 *
10.8 * This file defines the public functions exported by the SH4 core, except
10.9 * for disassembly functions defined in sh4dasm.h
10.10 @@ -19,6 +19,7 @@
10.11 #ifndef sh4core_H
10.12 #define sh4core_H 1
10.13
10.14 +#include <glib/gtypes.h>
10.15 #include <stdint.h>
10.16 #include <stdio.h>
10.17
10.18 @@ -29,6 +30,29 @@
10.19 #endif
10.20 #endif
10.21
10.22 +
10.23 +/**
10.24 + * SH4 is running normally
10.25 + */
10.26 +#define SH4_STATE_RUNNING 1
10.27 +/**
10.28 + * SH4 is not executing instructions but all peripheral modules are still
10.29 + * running
10.30 + */
10.31 +#define SH4_STATE_SLEEP 2
10.32 +/**
10.33 + * SH4 is not executing instructions, DMAC is halted, but all other peripheral
10.34 + * modules are still running
10.35 + */
10.36 +#define SH4_STATE_DEEP_SLEEP 3
10.37 +/**
10.38 + * SH4 is not executing instructions and all peripheral modules are also
10.39 + * stopped. As close as you can get to powered-off without actually being
10.40 + * off.
10.41 + */
10.42 +#define SH4_STATE_STANDBY 4
10.43 +
10.44 +
10.45 struct sh4_registers {
10.46 uint32_t r[16];
10.47 uint32_t r_bank[8]; /* hidden banked registers */
10.48 @@ -45,6 +69,7 @@
10.49 uint32_t int_pending; /* flag set by the INTC = pending priority level */
10.50 int in_delay_slot; /* flag to indicate the current instruction is in
10.51 * a delay slot (certain rules apply) */
10.52 + int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */
10.53 };
10.54
10.55 extern struct sh4_registers sh4r;
10.56 @@ -59,7 +84,7 @@
10.57 int sh4_isrunning( void );
10.58 void sh4_stop( void );
10.59 void sh4_set_pc( int );
10.60 -void sh4_execute_instruction( void );
10.61 +gboolean sh4_execute_instruction( void );
10.62 void sh4_raise_exception( int, int );
10.63 void sh4_set_breakpoint( uint32_t pc, int type );
10.64
.