trunk/src/mess/drivers/psx.c
| r21161 | r21162 | |
| 41 | 41 | DECLARE_DIRECT_UPDATE_MEMBER(psx_setopbase); |
| 42 | 42 | DECLARE_DRIVER_INIT(psx); |
| 43 | 43 | DECLARE_MACHINE_RESET(psx); |
| 44 | inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... ); |
| 45 | void psxexe_conv32( UINT32 *p_uint32 ); |
| 46 | int load_psxexe( cpu_device *cpu, unsigned char *p_n_file, int n_len ); |
| 47 | void cpe_set_register( cpu_device *cpu, int n_reg, int n_value ); |
| 48 | int load_cpe( cpu_device *cpu, unsigned char *p_n_file, int n_len ); |
| 49 | int load_psf( cpu_device *cpu, unsigned char *p_n_file, int n_len ); |
| 50 | void cd_dma_read( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ); |
| 51 | void cd_dma_write( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ); |
| 44 | 52 | }; |
| 45 | 53 | |
| 46 | 54 | |
| 47 | 55 | #define VERBOSE_LEVEL ( 0 ) |
| 48 | 56 | |
| 49 | | INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... ) |
| 57 | inline void ATTR_PRINTF(3,4) psx1_state::verboselog( int n_level, const char *s_fmt, ... ) |
| 50 | 58 | { |
| 51 | 59 | if( VERBOSE_LEVEL >= n_level ) |
| 52 | 60 | { |
| r21161 | r21162 | |
| 55 | 63 | va_start( v, s_fmt ); |
| 56 | 64 | vsprintf( buf, s_fmt, v ); |
| 57 | 65 | va_end( v ); |
| 58 | | logerror( "%s: %s", machine.describe_context(), buf ); |
| 66 | logerror( "%s: %s", machine().describe_context(), buf ); |
| 59 | 67 | } |
| 60 | 68 | } |
| 61 | 69 | |
| 62 | 70 | |
| 63 | | static void psxexe_conv32( UINT32 *p_uint32 ) |
| 71 | void psx1_state::psxexe_conv32( UINT32 *p_uint32 ) |
| 64 | 72 | { |
| 65 | 73 | UINT8 *p_uint8; |
| 66 | 74 | |
| r21161 | r21162 | |
| 72 | 80 | ( p_uint8[ 3 ] << 24 ); |
| 73 | 81 | } |
| 74 | 82 | |
| 75 | | static int load_psxexe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 83 | int psx1_state::load_psxexe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 76 | 84 | { |
| 77 | 85 | struct PSXEXE_HEADER |
| 78 | 86 | { |
| r21161 | r21162 | |
| 165 | 173 | return 0; |
| 166 | 174 | } |
| 167 | 175 | |
| 168 | | static void cpe_set_register( cpu_device *cpu, int n_reg, int n_value ) |
| 176 | void psx1_state::cpe_set_register( cpu_device *cpu, int n_reg, int n_value ) |
| 169 | 177 | { |
| 170 | 178 | if( n_reg < 0x80 && ( n_reg % 4 ) == 0 ) |
| 171 | 179 | { |
| r21161 | r21162 | |
| 208 | 216 | } |
| 209 | 217 | } |
| 210 | 218 | |
| 211 | | static int load_cpe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 219 | int psx1_state::load_cpe( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 212 | 220 | { |
| 213 | 221 | if( n_len >= 4 && |
| 214 | 222 | memcmp( p_n_file, "CPE\001", 4 ) == 0 ) |
| r21161 | r21162 | |
| 343 | 351 | return 0; |
| 344 | 352 | } |
| 345 | 353 | |
| 346 | | static int load_psf( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 354 | int psx1_state::load_psf( cpu_device *cpu, unsigned char *p_n_file, int n_len ) |
| 347 | 355 | { |
| 348 | 356 | int n_return; |
| 349 | 357 | unsigned long n_crc; |
| r21161 | r21162 | |
| 463 | 471 | |
| 464 | 472 | /* ----------------------------------------------------------------------- */ |
| 465 | 473 | |
| 466 | | static void cd_dma_read( psxcd_device *psxcd, UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ) |
| 474 | void psx1_state::cd_dma_read( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ) |
| 467 | 475 | { |
| 468 | 476 | UINT8 *psxram = (UINT8 *) p_n_psxram; |
| 469 | | |
| 477 | psxcd_device *psxcd = machine().device<psxcd_device>("cdrom"); |
| 470 | 478 | psxcd->start_dma(psxram + n_address, n_size*4); |
| 471 | 479 | } |
| 472 | 480 | |
| 473 | | static void cd_dma_write( psxcd_device *psxcd, UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ) |
| 481 | void psx1_state::cd_dma_write( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size ) |
| 474 | 482 | { |
| 475 | 483 | printf("cd_dma_write?!: addr %x, size %x\n", n_address, n_size); |
| 476 | 484 | } |
| r21161 | r21162 | |
| 524 | 532 | |
| 525 | 533 | MCFG_PSXCD_ADD("cdrom") |
| 526 | 534 | MCFG_PSXCD_IRQ_HANDLER(DEVWRITELINE("maincpu:irq", psxirq_device, intin2)) |
| 527 | | MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( cd_dma_read ), (psxcd_device *) device ) ) |
| 528 | | MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 3, psx_dma_write_delegate( FUNC( cd_dma_write ), (psxcd_device *) device ) ) |
| 535 | MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( psx1_state::cd_dma_read ), (psx1_state *) owner ) ) |
| 536 | MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 3, psx_dma_write_delegate( FUNC( psx1_state::cd_dma_write ), (psx1_state *) owner ) ) |
| 529 | 537 | MACHINE_CONFIG_END |
| 530 | 538 | |
| 531 | 539 | static MACHINE_CONFIG_START( psxpal, psx1_state ) |
| r21161 | r21162 | |
| 559 | 567 | |
| 560 | 568 | MCFG_PSXCD_ADD("cdrom") |
| 561 | 569 | MCFG_PSXCD_IRQ_HANDLER(DEVWRITELINE("maincpu:irq", psxirq_device, intin2)) |
| 562 | | MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( cd_dma_read ), (psxcd_device *) device ) ) |
| 563 | | MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 3, psx_dma_write_delegate( FUNC( cd_dma_write ), (psxcd_device *) device ) ) |
| 570 | MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( psx1_state::cd_dma_read ), (psx1_state *) owner ) ) |
| 571 | MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 3, psx_dma_write_delegate( FUNC( psx1_state::cd_dma_write ), (psx1_state *) owner ) ) |
| 564 | 572 | MACHINE_CONFIG_END |
| 565 | 573 | |
| 566 | 574 | ROM_START( psj ) |