Previous 199869 Revisions Next

r20448 Thursday 24th January, 2013 at 19:36:41 UTC by smf
uses cpu_device instead of device_t and one less lookup [smf]
[src/mess/drivers]psx.c

trunk/src/mess/drivers/psx.c
r20447r20448
7272      ( p_uint8[ 3 ] << 24 );
7373}
7474
75static int load_psxexe( device_t *cpu, unsigned char *p_n_file, int n_len )
75static int load_psxexe( cpu_device *cpu, unsigned char *p_n_file, int n_len )
7676{
7777   struct PSXEXE_HEADER
7878   {
r20447r20448
151151         n_size--;
152152      }
153153
154      cpu->state().set_state_int( PSXCPU_PC, psxexe_header->pc0 );
155      cpu->state().set_state_int( PSXCPU_R28, psxexe_header->gp0 );
154      cpu->set_state_int( PSXCPU_PC, psxexe_header->pc0 );
155      cpu->set_state_int( PSXCPU_R28, psxexe_header->gp0 );
156156      n_stack = psxexe_header->s_addr + psxexe_header->s_size;
157157      if( n_stack != 0 )
158158      {
159         cpu->state().set_state_int( PSXCPU_R29, n_stack );
160         cpu->state().set_state_int( PSXCPU_R30, n_stack );
159         cpu->set_state_int( PSXCPU_R29, n_stack );
160         cpu->set_state_int( PSXCPU_R30, n_stack );
161161      }
162162
163163      return 1;
r20447r20448
165165   return 0;
166166}
167167
168static void cpe_set_register( device_t *cpu, int n_reg, int n_value )
168static void cpe_set_register( cpu_device *cpu, int n_reg, int n_value )
169169{
170170   if( n_reg < 0x80 && ( n_reg % 4 ) == 0 )
171171   {
172172      logerror( "psx_exe_load: r%-2d   %08x\n", n_reg / 4, n_value );
173      cpu->state().set_state_int( PSXCPU_R0 + ( n_reg / 4 ), n_value );
173      cpu->set_state_int( PSXCPU_R0 + ( n_reg / 4 ), n_value );
174174   }
175175   else if( n_reg == 0x80 )
176176   {
177177      logerror( "psx_exe_load: lo    %08x\n", n_value );
178      cpu->state().set_state_int( PSXCPU_LO, n_value );
178      cpu->set_state_int( PSXCPU_LO, n_value );
179179   }
180180   else if( n_reg == 0x84 )
181181   {
182182      logerror( "psx_exe_load: hi    %08x\n", n_value );
183      cpu->state().set_state_int( PSXCPU_HI, n_value );
183      cpu->set_state_int( PSXCPU_HI, n_value );
184184   }
185185   else if( n_reg == 0x88 )
186186   {
187187      logerror( "psx_exe_load: sr    %08x\n", n_value );
188      cpu->state().set_state_int( PSXCPU_CP0R12, n_value );
188      cpu->set_state_int( PSXCPU_CP0R12, n_value );
189189   }
190190   else if( n_reg == 0x8c )
191191   {
192192      logerror( "psx_exe_load: cause %08x\n", n_value );
193      cpu->state().set_state_int( PSXCPU_CP0R13, n_value );
193      cpu->set_state_int( PSXCPU_CP0R13, n_value );
194194   }
195195   else if( n_reg == 0x90 )
196196   {
197197      logerror( "psx_exe_load: pc    %08x\n", n_value );
198      cpu->state().set_state_int( PSXCPU_PC, n_value );
198      cpu->set_state_int( PSXCPU_PC, n_value );
199199   }
200200   else if( n_reg == 0x94 )
201201   {
202202      logerror( "psx_exe_load: prid  %08x\n", n_value );
203      cpu->state().set_state_int( PSXCPU_CP0R15, n_value );
203      cpu->set_state_int( PSXCPU_CP0R15, n_value );
204204   }
205205   else
206206   {
r20447r20448
208208   }
209209}
210210
211static int load_cpe( device_t *cpu, unsigned char *p_n_file, int n_len )
211static int load_cpe( cpu_device *cpu, unsigned char *p_n_file, int n_len )
212212{
213213   if( n_len >= 4 &&
214214      memcmp( p_n_file, "CPE\001", 4 ) == 0 )
r20447r20448
343343   return 0;
344344}
345345
346static int load_psf( device_t *cpu, unsigned char *p_n_file, int n_len )
346static int load_psf( cpu_device *cpu, unsigned char *p_n_file, int n_len )
347347{
348348   int n_return;
349349   unsigned long n_crc;
r20447r20448
415415{
416416   if( address == 0x80030000 )
417417   {
418      device_t *cpu = machine().device("maincpu");
418      cpu_device *cpu = machine().device<cpu_device>("maincpu");
419419
420      machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(psx1_state::psx_default), this));
420      cpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(psx1_state::psx_default), this));
421421
422422      if( load_psxexe( cpu, m_exe_buffer, m_exe_size ) ||
423423         load_cpe( cpu, m_exe_buffer, m_exe_size ) ||
r20447r20448
425425      {
426426/*          DEBUGGER_BREAK; */
427427
428         address = cpu->state().state_int( PSXCPU_PC );
428         address = cpu->state_int( PSXCPU_PC );
429429      }
430430      else
431431      {

Previous 199869 Revisions Next


© 1997-2024 The MAME Team