trunk/src/mess/drivers/psx.c
| r20447 | r20448 | |
| 72 | 72 | ( p_uint8[ 3 ] << 24 ); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | | static int load_psxexe( device_t *cpu, unsigned char *p_n_file, int n_len ) |
| 75 | static int load_psxexe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 76 | 76 | { |
| 77 | 77 | struct PSXEXE_HEADER |
| 78 | 78 | { |
| r20447 | r20448 | |
| 151 | 151 | n_size--; |
| 152 | 152 | } |
| 153 | 153 | |
| 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 ); |
| 156 | 156 | n_stack = psxexe_header->s_addr + psxexe_header->s_size; |
| 157 | 157 | if( n_stack != 0 ) |
| 158 | 158 | { |
| 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 ); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return 1; |
| r20447 | r20448 | |
| 165 | 165 | return 0; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | | static void cpe_set_register( device_t *cpu, int n_reg, int n_value ) |
| 168 | static void cpe_set_register( cpu_device *cpu, int n_reg, int n_value ) |
| 169 | 169 | { |
| 170 | 170 | if( n_reg < 0x80 && ( n_reg % 4 ) == 0 ) |
| 171 | 171 | { |
| 172 | 172 | 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 ); |
| 174 | 174 | } |
| 175 | 175 | else if( n_reg == 0x80 ) |
| 176 | 176 | { |
| 177 | 177 | 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 ); |
| 179 | 179 | } |
| 180 | 180 | else if( n_reg == 0x84 ) |
| 181 | 181 | { |
| 182 | 182 | 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 ); |
| 184 | 184 | } |
| 185 | 185 | else if( n_reg == 0x88 ) |
| 186 | 186 | { |
| 187 | 187 | 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 ); |
| 189 | 189 | } |
| 190 | 190 | else if( n_reg == 0x8c ) |
| 191 | 191 | { |
| 192 | 192 | 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 ); |
| 194 | 194 | } |
| 195 | 195 | else if( n_reg == 0x90 ) |
| 196 | 196 | { |
| 197 | 197 | 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 ); |
| 199 | 199 | } |
| 200 | 200 | else if( n_reg == 0x94 ) |
| 201 | 201 | { |
| 202 | 202 | 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 ); |
| 204 | 204 | } |
| 205 | 205 | else |
| 206 | 206 | { |
| r20447 | r20448 | |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | static int load_cpe( device_t *cpu, unsigned char *p_n_file, int n_len ) |
| 211 | static int load_cpe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 212 | 212 | { |
| 213 | 213 | if( n_len >= 4 && |
| 214 | 214 | memcmp( p_n_file, "CPE\001", 4 ) == 0 ) |
| r20447 | r20448 | |
| 343 | 343 | return 0; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | | static int load_psf( device_t *cpu, unsigned char *p_n_file, int n_len ) |
| 346 | static int load_psf( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 347 | 347 | { |
| 348 | 348 | int n_return; |
| 349 | 349 | unsigned long n_crc; |
| r20447 | r20448 | |
| 415 | 415 | { |
| 416 | 416 | if( address == 0x80030000 ) |
| 417 | 417 | { |
| 418 | | device_t *cpu = machine().device("maincpu"); |
| 418 | cpu_device *cpu = machine().device<cpu_device>("maincpu"); |
| 419 | 419 | |
| 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)); |
| 421 | 421 | |
| 422 | 422 | if( load_psxexe( cpu, m_exe_buffer, m_exe_size ) || |
| 423 | 423 | load_cpe( cpu, m_exe_buffer, m_exe_size ) || |
| r20447 | r20448 | |
| 425 | 425 | { |
| 426 | 426 | /* DEBUGGER_BREAK; */ |
| 427 | 427 | |
| 428 | | address = cpu->state().state_int( PSXCPU_PC ); |
| 428 | address = cpu->state_int( PSXCPU_PC ); |
| 429 | 429 | } |
| 430 | 430 | else |
| 431 | 431 | { |