1.1 --- a/src/sh4/sh4core.c Thu Dec 22 07:38:12 2005 +0000
1.2 +++ b/src/sh4/sh4core.c Fri Dec 23 11:44:55 2005 +0000
1.5 + * $Id: sh4core.c,v 1.9 2005-12-23 11:44:55 nkeynes Exp $
1.7 + * SH4 emulation core, and parent module for all the SH4 peripheral
1.10 + * Copyright (c) 2005 Nathan Keynes.
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.25 #include "modules.h"
1.26 #include "sh4core.h"
1.27 #include "sh4mmio.h"
1.32 -void sh4_save( FILE *f );
1.33 -int sh4_load( FILE *f );
1.34 +uint32_t sh4_freq = SH4_BASE_RATE;
1.35 +uint32_t sh4_bus_freq = SH4_BASE_RATE;
1.36 +uint32_t sh4_peripheral_freq = SH4_BASE_RATE / 2;
1.38 +/********************** SH4 Module Definition ****************************/
1.40 +void sh4_init( void );
1.41 +void sh4_reset( void );
1.42 +void sh4_run_slice( int );
1.43 +void sh4_start( void );
1.44 +void sh4_stop( void );
1.45 +void sh4_save_state( FILE *f );
1.46 +int sh4_load_state( FILE *f );
1.48 struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,
1.50 - sh4_save, sh4_load };
1.51 + NULL, sh4_run_slice, sh4_stop,
1.52 + sh4_save_state, sh4_load_state };
1.54 struct sh4_registers sh4r;
1.55 static int running = 0;
1.60 -void sh4_set_pc( int pc )
1.61 +void sh4_run_slice( int microsecs )
1.64 - sh4r.new_pc = pc+2;
1.65 + int count = sh4_freq * microsecs;
1.68 + for( i=0; i<count; i++ ) {
1.69 + sh4_execute_instruction();
1.71 + TMU_run_slice( microsecs );
1.72 + SCIF_run_slice( microsecs );
1.80 -void sh4_save( FILE *f )
1.81 +void sh4_save_state( FILE *f )
1.83 fwrite( &sh4r, sizeof(sh4r), 1, f );
1.84 - /* Save all additional on-board MMIO state */
1.85 + SCIF_save_state( f );
1.88 -int sh4_load( FILE * f )
1.89 +int sh4_load_state( FILE * f )
1.91 fread( &sh4r, sizeof(sh4r), 1, f );
1.93 + return SCIF_load_state( f );
1.101 +/********************** SH4 emulation core ****************************/
1.103 +void sh4_set_pc( int pc )
1.106 + sh4r.new_pc = pc+2;
1.109 +void sh4_set_breakpoint( uint32_t pc, int type )
1.114 void sh4_runfor(uint32_t count)