src/mess/drivers/psx.c
| r4006 | r4007 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | 3 | Sony Playstaion |
| 4 | | ========------- |
| 4 | =============== |
| 5 | 5 | Preliminary driver by smf |
| 6 | 6 | |
| 7 | 7 | todo: |
| 8 | 8 | add memcard support |
| 9 | 9 | tidy up cd controller |
| 10 | | work out why bios schph1000 doesn't get past the first screen |
| 10 | work out why bios scph1000 doesn't get past the first screen |
| 11 | 11 | add cd image support |
| 12 | 12 | |
| 13 | 13 | ***************************************************************************/ |
| r4006 | r4007 | |
| 18 | 18 | #include "includes/psx.h" |
| 19 | 19 | #include "sound/psx.h" |
| 20 | 20 | #include "debugger.h" |
| 21 | #include "zlib.h" |
| 21 | 22 | |
| 22 | | static struct |
| 23 | static UINT8 *exe_buffer; |
| 24 | static int exe_size; |
| 25 | |
| 26 | static void psxexe_conv32( UINT32 *p_uint32 ) |
| 23 | 27 | { |
| 24 | | UINT8 id[ 8 ]; |
| 25 | | UINT32 text; /* SCE only */ |
| 26 | | UINT32 data; /* SCE only */ |
| 27 | | UINT32 pc0; |
| 28 | | UINT32 gp0; /* SCE only */ |
| 29 | | UINT32 t_addr; |
| 30 | | UINT32 t_size; |
| 31 | | UINT32 d_addr; /* SCE only */ |
| 32 | | UINT32 d_size; /* SCE only */ |
| 33 | | UINT32 b_addr; /* SCE only */ |
| 34 | | UINT32 b_size; /* SCE only */ |
| 35 | | UINT32 s_addr; |
| 36 | | UINT32 s_size; |
| 37 | | UINT32 SavedSP; |
| 38 | | UINT32 SavedFP; |
| 39 | | UINT32 SavedGP; |
| 40 | | UINT32 SavedRA; |
| 41 | | UINT32 SavedS0; |
| 42 | | UINT8 dummy[ 0x800 - 76 ]; |
| 43 | | } m_psxexe_header; |
| 28 | UINT8 *p_uint8; |
| 44 | 29 | |
| 45 | | static UINT8 *m_p_psxexe; |
| 30 | p_uint8 = (UINT8 *)p_uint32; |
| 46 | 31 | |
| 47 | | static DIRECT_UPDATE_HANDLER( psx_setopbase ) |
| 32 | *( p_uint32 ) = p_uint8[ 0 ] | |
| 33 | ( p_uint8[ 1 ] << 8 ) | |
| 34 | ( p_uint8[ 2 ] << 16 ) | |
| 35 | ( p_uint8[ 3 ] << 24 ); |
| 36 | } |
| 37 | |
| 38 | static int load_psxexe( const device_config *cpu, unsigned char *p_n_file, int n_len ) |
| 48 | 39 | { |
| 49 | | if( address == 0x80030000 ) |
| 40 | struct PSXEXE_HEADER |
| 50 | 41 | { |
| 42 | UINT8 id[ 8 ]; |
| 43 | UINT32 text; /* SCE only */ |
| 44 | UINT32 data; /* SCE only */ |
| 45 | UINT32 pc0; |
| 46 | UINT32 gp0; /* SCE only */ |
| 47 | UINT32 t_addr; |
| 48 | UINT32 t_size; |
| 49 | UINT32 d_addr; /* SCE only */ |
| 50 | UINT32 d_size; /* SCE only */ |
| 51 | UINT32 b_addr; /* SCE only */ |
| 52 | UINT32 b_size; /* SCE only */ |
| 53 | UINT32 s_addr; |
| 54 | UINT32 s_size; |
| 55 | UINT32 SavedSP; |
| 56 | UINT32 SavedFP; |
| 57 | UINT32 SavedGP; |
| 58 | UINT32 SavedRA; |
| 59 | UINT32 SavedS0; |
| 60 | UINT8 dummy[ 0x800 - 76 ]; |
| 61 | }; |
| 62 | |
| 63 | struct PSXEXE_HEADER *psxexe_header = (struct PSXEXE_HEADER *)p_n_file; |
| 64 | |
| 65 | if( n_len >= sizeof( struct PSXEXE_HEADER ) && |
| 66 | memcmp( psxexe_header->id, "PS-X EXE", 8 ) == 0 ) |
| 67 | { |
| 51 | 68 | UINT8 *p_ram; |
| 52 | 69 | UINT8 *p_psxexe; |
| 53 | 70 | UINT32 n_stack; |
| 54 | 71 | UINT32 n_ram; |
| 55 | | UINT32 n_left; |
| 56 | 72 | UINT32 n_address; |
| 73 | UINT32 n_size; |
| 57 | 74 | |
| 58 | | logerror( "psx_exe_load: pc %08x\n", m_psxexe_header.pc0 ); |
| 59 | | logerror( "psx_exe_load: org %08x\n", m_psxexe_header.t_addr ); |
| 60 | | logerror( "psx_exe_load: len %08x\n", m_psxexe_header.t_size ); |
| 61 | | logerror( "psx_exe_load: sp %08x\n", m_psxexe_header.s_addr ); |
| 62 | | logerror( "psx_exe_load: len %08x\n", m_psxexe_header.s_size ); |
| 75 | psxexe_conv32( &psxexe_header->text ); |
| 76 | psxexe_conv32( &psxexe_header->data ); |
| 77 | psxexe_conv32( &psxexe_header->pc0 ); |
| 78 | psxexe_conv32( &psxexe_header->gp0 ); |
| 79 | psxexe_conv32( &psxexe_header->t_addr ); |
| 80 | psxexe_conv32( &psxexe_header->t_size ); |
| 81 | psxexe_conv32( &psxexe_header->d_addr ); |
| 82 | psxexe_conv32( &psxexe_header->d_size ); |
| 83 | psxexe_conv32( &psxexe_header->b_addr ); |
| 84 | psxexe_conv32( &psxexe_header->b_size ); |
| 85 | psxexe_conv32( &psxexe_header->s_addr ); |
| 86 | psxexe_conv32( &psxexe_header->s_size ); |
| 87 | psxexe_conv32( &psxexe_header->SavedSP ); |
| 88 | psxexe_conv32( &psxexe_header->SavedFP ); |
| 89 | psxexe_conv32( &psxexe_header->SavedGP ); |
| 90 | psxexe_conv32( &psxexe_header->SavedRA ); |
| 91 | psxexe_conv32( &psxexe_header->SavedS0 ); |
| 63 | 92 | |
| 93 | /* todo: check size.. */ |
| 94 | |
| 95 | logerror( "psx_exe_load: pc %08x\n", psxexe_header->pc0 ); |
| 96 | logerror( "psx_exe_load: org %08x\n", psxexe_header->t_addr ); |
| 97 | logerror( "psx_exe_load: len %08x\n", psxexe_header->t_size ); |
| 98 | logerror( "psx_exe_load: sp %08x\n", psxexe_header->s_addr ); |
| 99 | logerror( "psx_exe_load: len %08x\n", psxexe_header->s_size ); |
| 100 | |
| 64 | 101 | p_ram = (UINT8 *)g_p_n_psxram; |
| 65 | 102 | n_ram = g_n_psxramsize; |
| 66 | 103 | |
| 67 | | p_psxexe = m_p_psxexe; |
| 104 | p_psxexe = p_n_file + sizeof( struct PSXEXE_HEADER ); |
| 68 | 105 | |
| 69 | | n_address = m_psxexe_header.t_addr; |
| 70 | | n_left = m_psxexe_header.t_size; |
| 71 | | while( n_left != 0 ) |
| 106 | n_address = psxexe_header->t_addr; |
| 107 | n_size = psxexe_header->t_size; |
| 108 | while( n_size != 0 ) |
| 72 | 109 | { |
| 73 | 110 | p_ram[ BYTE4_XOR_LE( n_address ) % n_ram ] = *( p_psxexe ); |
| 74 | 111 | n_address++; |
| 75 | 112 | p_psxexe++; |
| 76 | | n_left--; |
| 113 | n_size--; |
| 77 | 114 | } |
| 78 | 115 | |
| 79 | | free( m_p_psxexe ); |
| 80 | | |
| 81 | | cpu_set_reg( space->machine->cpu[0], PSXCPU_PC, m_psxexe_header.pc0 ); |
| 82 | | cpu_set_reg( space->machine->cpu[0], PSXCPU_R28, m_psxexe_header.gp0 ); |
| 83 | | n_stack = m_psxexe_header.s_addr + m_psxexe_header.s_size; |
| 116 | cpu_set_reg( cpu, PSXCPU_PC, psxexe_header->pc0 ); |
| 117 | cpu_set_reg( cpu, PSXCPU_R28, psxexe_header->gp0 ); |
| 118 | n_stack = psxexe_header->s_addr + psxexe_header->s_size; |
| 84 | 119 | if( n_stack != 0 ) |
| 85 | 120 | { |
| 86 | | cpu_set_reg( space->machine->cpu[0], PSXCPU_R29, n_stack ); |
| 87 | | cpu_set_reg( space->machine->cpu[0], PSXCPU_R30, n_stack ); |
| 121 | cpu_set_reg( cpu, PSXCPU_R29, n_stack ); |
| 122 | cpu_set_reg( cpu, PSXCPU_R30, n_stack ); |
| 88 | 123 | } |
| 89 | 124 | |
| 90 | | memory_set_direct_update_handler( space, NULL ); |
| 125 | return 1; |
| 126 | } |
| 127 | return 0; |
| 128 | } |
| 91 | 129 | |
| 92 | | return m_psxexe_header.pc0; |
| 130 | static void cpe_set_register( const device_config *cpu, int n_reg, int n_value ) |
| 131 | { |
| 132 | if( n_reg < 0x80 && ( n_reg % 4 ) == 0 ) |
| 133 | { |
| 134 | logerror( "psx_exe_load: r%-2d %08x\n", n_reg / 4, n_value ); |
| 135 | cpu_set_reg( cpu, PSXCPU_R0 + ( n_reg / 4 ), n_value ); |
| 93 | 136 | } |
| 94 | | |
| 95 | | return address; |
| 137 | else if( n_reg == 0x80 ) |
| 138 | { |
| 139 | logerror( "psx_exe_load: lo %08x\n", n_value ); |
| 140 | cpu_set_reg( cpu, PSXCPU_LO, n_value ); |
| 141 | } |
| 142 | else if( n_reg == 0x84 ) |
| 143 | { |
| 144 | logerror( "psx_exe_load: hi %08x\n", n_value ); |
| 145 | cpu_set_reg( cpu, PSXCPU_HI, n_value ); |
| 146 | } |
| 147 | else if( n_reg == 0x88 ) |
| 148 | { |
| 149 | logerror( "psx_exe_load: sr %08x\n", n_value ); |
| 150 | cpu_set_reg( cpu, PSXCPU_CP0R12, n_value ); |
| 151 | } |
| 152 | else if( n_reg == 0x8c ) |
| 153 | { |
| 154 | logerror( "psx_exe_load: cause %08x\n", n_value ); |
| 155 | cpu_set_reg( cpu, PSXCPU_CP0R13, n_value ); |
| 156 | } |
| 157 | else if( n_reg == 0x90 ) |
| 158 | { |
| 159 | logerror( "psx_exe_load: pc %08x\n", n_value ); |
| 160 | cpu_set_reg( cpu, PSXCPU_PC, n_value ); |
| 161 | } |
| 162 | else if( n_reg == 0x94 ) |
| 163 | { |
| 164 | logerror( "psx_exe_load: prid %08x\n", n_value ); |
| 165 | cpu_set_reg( cpu, PSXCPU_CP0R15, n_value ); |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | logerror( "psx_exe_load: invalid register %04x/%08x\n", n_reg, n_value ); |
| 170 | } |
| 96 | 171 | } |
| 97 | 172 | |
| 98 | | static void psxexe_conv32( UINT32 *p_uint32 ) |
| 173 | static int load_cpe( const device_config *cpu, unsigned char *p_n_file, int n_len ) |
| 99 | 174 | { |
| 100 | | UINT8 *p_uint8; |
| 175 | if( n_len >= 4 && |
| 176 | memcmp( p_n_file, "CPE\001", 4 ) == 0 ) |
| 177 | { |
| 178 | int n_offset = 4; |
| 101 | 179 | |
| 102 | | p_uint8 = (UINT8 *)p_uint32; |
| 180 | for( ;; ) |
| 181 | { |
| 182 | if( n_offset >= n_len || p_n_file[ n_offset ] > 8 ) |
| 183 | { |
| 184 | break; |
| 185 | } |
| 103 | 186 | |
| 104 | | *( p_uint32 ) = p_uint8[ 0 ] | |
| 105 | | ( p_uint8[ 1 ] << 8 ) | |
| 106 | | ( p_uint8[ 2 ] << 16 ) | |
| 107 | | ( p_uint8[ 3 ] << 24 ); |
| 187 | switch( p_n_file[ n_offset++ ] ) |
| 188 | { |
| 189 | case 0: |
| 190 | /* end of file */ |
| 191 | return 1; |
| 192 | case 1: |
| 193 | /* read bytes */ |
| 194 | { |
| 195 | int n_address = ( (int)p_n_file[ n_offset + 0 ] << 0 ) | |
| 196 | ( (int)p_n_file[ n_offset + 1 ] << 8 ) | |
| 197 | ( (int)p_n_file[ n_offset + 2 ] << 16 ) | |
| 198 | ( (int)p_n_file[ n_offset + 3 ] << 24 ); |
| 199 | int n_size = ( (int)p_n_file[ n_offset + 4 ] << 0 ) | |
| 200 | ( (int)p_n_file[ n_offset + 5 ] << 8 ) | |
| 201 | ( (int)p_n_file[ n_offset + 6 ] << 16 ) | |
| 202 | ( (int)p_n_file[ n_offset + 7 ] << 24 ); |
| 203 | |
| 204 | UINT8 *p_ram = (UINT8 *)g_p_n_psxram; |
| 205 | UINT32 n_ram = g_n_psxramsize; |
| 206 | |
| 207 | n_offset += 8; |
| 208 | |
| 209 | logerror( "psx_exe_load: org %08x\n", n_address ); |
| 210 | logerror( "psx_exe_load: len %08x\n", n_size ); |
| 211 | |
| 212 | while( n_size > 0 ) |
| 213 | { |
| 214 | p_ram[ BYTE4_XOR_LE( n_address ) % n_ram ] = p_n_file[ n_offset++ ]; |
| 215 | n_address++; |
| 216 | n_size--; |
| 217 | } |
| 218 | break; |
| 219 | } |
| 220 | case 2: |
| 221 | /* run address: not tested */ |
| 222 | { |
| 223 | int n_value = ( (int)p_n_file[ n_offset + 2 ] << 0 ) | |
| 224 | ( (int)p_n_file[ n_offset + 3 ] << 8 ) | |
| 225 | ( (int)p_n_file[ n_offset + 4 ] << 16 ) | |
| 226 | ( (int)p_n_file[ n_offset + 5 ] << 24 ); |
| 227 | |
| 228 | n_offset += 4; |
| 229 | |
| 230 | cpe_set_register( cpu, 0x90, n_value ); |
| 231 | break; |
| 232 | } |
| 233 | case 3: |
| 234 | /* set reg to longword */ |
| 235 | { |
| 236 | int n_reg = ( (int)p_n_file[ n_offset + 0 ] << 0 ) | |
| 237 | ( (int)p_n_file[ n_offset + 1 ] << 8 ); |
| 238 | int n_value = ( (int)p_n_file[ n_offset + 2 ] << 0 ) | |
| 239 | ( (int)p_n_file[ n_offset + 3 ] << 8 ) | |
| 240 | ( (int)p_n_file[ n_offset + 4 ] << 16 ) | |
| 241 | ( (int)p_n_file[ n_offset + 5 ] << 24 ); |
| 242 | |
| 243 | n_offset += 6; |
| 244 | |
| 245 | cpe_set_register( cpu, n_reg, n_value ); |
| 246 | break; |
| 247 | } |
| 248 | case 4: |
| 249 | /* set reg to word: not tested */ |
| 250 | { |
| 251 | int n_reg = ( (int)p_n_file[ n_offset + 0 ] << 0 ) | |
| 252 | ( (int)p_n_file[ n_offset + 1 ] << 8 ); |
| 253 | int n_value = ( (int)p_n_file[ n_offset + 2 ] << 0 ) | |
| 254 | ( (int)p_n_file[ n_offset + 3 ] << 8 ); |
| 255 | |
| 256 | n_offset += 4; |
| 257 | |
| 258 | cpe_set_register( cpu, n_reg, n_value ); |
| 259 | break; |
| 260 | } |
| 261 | case 5: |
| 262 | /* set reg to byte: not tested */ |
| 263 | { |
| 264 | int n_reg = ( (int)p_n_file[ n_offset + 0 ] << 0 ) | |
| 265 | ( (int)p_n_file[ n_offset + 1 ] << 8 ); |
| 266 | int n_value = ( (int)p_n_file[ n_offset + 2 ] << 0 ); |
| 267 | |
| 268 | n_offset += 3; |
| 269 | |
| 270 | cpe_set_register( cpu, n_reg, n_value ); |
| 271 | break; |
| 272 | } |
| 273 | case 6: |
| 274 | /* set reg to 3-byte: not tested */ |
| 275 | { |
| 276 | int n_reg = ( (int)p_n_file[ n_offset + 0 ] << 0 ) | |
| 277 | ( (int)p_n_file[ n_offset + 1 ] << 8 ); |
| 278 | int n_value = ( (int)p_n_file[ n_offset + 2 ] << 0 ) | |
| 279 | ( (int)p_n_file[ n_offset + 3 ] << 8 ) | |
| 280 | ( (int)p_n_file[ n_offset + 4 ] << 16 ); |
| 281 | |
| 282 | n_offset += 5; |
| 283 | |
| 284 | cpe_set_register( cpu, n_reg, n_value ); |
| 285 | break; |
| 286 | } |
| 287 | case 7: |
| 288 | /* workspace: not tested */ |
| 289 | n_offset += 4; |
| 290 | break; |
| 291 | case 8: |
| 292 | /* unit */ |
| 293 | { |
| 294 | int n_unit = p_n_file[ n_offset + 0 ]; |
| 295 | |
| 296 | n_offset++; |
| 297 | |
| 298 | logerror( "psx_exe_load: unit %08x\n", n_unit ); |
| 299 | } |
| 300 | break; |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | return 0; |
| 108 | 305 | } |
| 109 | 306 | |
| 110 | | static QUICKLOAD_LOAD( psx_exe_load ) |
| 307 | static int load_psf( const device_config *cpu, unsigned char *p_n_file, int n_len ) |
| 111 | 308 | { |
| 112 | | const address_space *space = cpu_get_address_space( image->machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 309 | int n_return; |
| 310 | unsigned long n_crc; |
| 311 | unsigned long n_compressed; |
| 312 | unsigned char *p_n_compressed; |
| 313 | unsigned long n_uncompressed; |
| 314 | unsigned char *p_n_uncompressed; |
| 113 | 315 | |
| 114 | | if( image_fread( image, &m_psxexe_header, sizeof( m_psxexe_header ) ) != sizeof( m_psxexe_header ) ) |
| 316 | struct PSF_HEADER |
| 115 | 317 | { |
| 116 | | logerror( "psx_exe_load: invalid exe\n" ); |
| 117 | | return INIT_FAIL; |
| 318 | unsigned char id[ 4 ]; |
| 319 | UINT32 reserved_size; |
| 320 | UINT32 exe_size; |
| 321 | UINT32 exe_crc; |
| 322 | }; |
| 323 | |
| 324 | struct PSF_HEADER *psf_header = (struct PSF_HEADER *)p_n_file; |
| 325 | |
| 326 | n_return = 0; |
| 327 | |
| 328 | if( n_len >= sizeof( struct PSF_HEADER ) && |
| 329 | memcmp( p_n_file, "PSF", 3 ) == 0 ) |
| 330 | { |
| 331 | psxexe_conv32( &psf_header->reserved_size ); |
| 332 | psxexe_conv32( &psf_header->exe_size ); |
| 333 | psxexe_conv32( &psf_header->exe_crc ); |
| 334 | |
| 335 | logerror( "psx_exe_load: reserved_size %08x\n", psf_header->reserved_size ); |
| 336 | logerror( "psx_exe_load: exe_size %08x\n", psf_header->exe_size ); |
| 337 | logerror( "psx_exe_load: exe_crc %08x\n", psf_header->exe_crc ); |
| 338 | |
| 339 | n_compressed = psf_header->exe_size; |
| 340 | p_n_compressed = p_n_file + sizeof( struct PSF_HEADER ) + psf_header->reserved_size; |
| 341 | |
| 342 | n_crc = crc32( crc32( 0L, Z_NULL, 0 ), p_n_compressed, n_compressed ); |
| 343 | if( n_crc != psf_header->exe_crc ) |
| 344 | { |
| 345 | logerror( "psx_exe_load: psf invalid crc\n" ); |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | n_uncompressed = 0x200000; |
| 350 | p_n_uncompressed = malloc( n_uncompressed ); |
| 351 | |
| 352 | if( uncompress( p_n_uncompressed, &n_uncompressed, p_n_compressed, n_compressed ) != Z_OK ) |
| 353 | { |
| 354 | logerror( "psx_exe_load: psf uncompress failed\n" ); |
| 355 | } |
| 356 | else if( !load_psxexe( cpu, p_n_uncompressed, n_uncompressed ) ) |
| 357 | { |
| 358 | logerror( "psx_exe_load: psf load failed\n" ); |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | n_return = 1; |
| 363 | } |
| 364 | |
| 365 | free( p_n_uncompressed ); |
| 118 | 366 | } |
| 119 | | if( memcmp( m_psxexe_header.id, "PS-X EXE", 8 ) != 0 ) |
| 367 | return n_return; |
| 368 | } |
| 369 | |
| 370 | static DIRECT_UPDATE_HANDLER( psx_setopbase ) |
| 371 | { |
| 372 | if( address == 0x80030000 ) |
| 120 | 373 | { |
| 121 | | logerror( "psx_exe_load: invalid header id\n" ); |
| 122 | | return INIT_FAIL; |
| 374 | const device_config *cpu = space->machine->cpu[ 0 ]; |
| 375 | |
| 376 | memory_set_direct_update_handler( space, NULL ); |
| 377 | |
| 378 | if( load_psxexe( cpu, exe_buffer, exe_size ) || |
| 379 | load_cpe( cpu, exe_buffer, exe_size ) || |
| 380 | load_psf( cpu, exe_buffer, exe_size ) ) |
| 381 | { |
| 382 | /* DEBUGGER_BREAK; */ |
| 383 | |
| 384 | address = cpu_get_reg( cpu, PSXCPU_PC ); |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | logerror( "psx_exe_load: invalid exe\n" ); |
| 389 | } |
| 390 | |
| 391 | exe_size = 0; |
| 392 | free( exe_buffer ); |
| 123 | 393 | } |
| 394 | return address; |
| 395 | } |
| 124 | 396 | |
| 125 | | psxexe_conv32( &m_psxexe_header.text ); |
| 126 | | psxexe_conv32( &m_psxexe_header.data ); |
| 127 | | psxexe_conv32( &m_psxexe_header.pc0 ); |
| 128 | | psxexe_conv32( &m_psxexe_header.gp0 ); |
| 129 | | psxexe_conv32( &m_psxexe_header.t_addr ); |
| 130 | | psxexe_conv32( &m_psxexe_header.t_size ); |
| 131 | | psxexe_conv32( &m_psxexe_header.d_addr ); |
| 132 | | psxexe_conv32( &m_psxexe_header.d_size ); |
| 133 | | psxexe_conv32( &m_psxexe_header.b_addr ); |
| 134 | | psxexe_conv32( &m_psxexe_header.b_size ); |
| 135 | | psxexe_conv32( &m_psxexe_header.s_addr ); |
| 136 | | psxexe_conv32( &m_psxexe_header.s_size ); |
| 137 | | psxexe_conv32( &m_psxexe_header.SavedSP ); |
| 138 | | psxexe_conv32( &m_psxexe_header.SavedFP ); |
| 139 | | psxexe_conv32( &m_psxexe_header.SavedGP ); |
| 140 | | psxexe_conv32( &m_psxexe_header.SavedRA ); |
| 141 | | psxexe_conv32( &m_psxexe_header.SavedS0 ); |
| 397 | static QUICKLOAD_LOAD( psx_exe_load ) |
| 398 | { |
| 399 | const address_space *space = cpu_get_address_space( image->machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 142 | 400 | |
| 143 | | m_p_psxexe = malloc( m_psxexe_header.t_size ); |
| 144 | | if( m_p_psxexe == NULL ) |
| 401 | exe_size = 0; |
| 402 | exe_buffer = malloc( quickload_size ); |
| 403 | if( exe_buffer == NULL ) |
| 145 | 404 | { |
| 146 | 405 | logerror( "psx_exe_load: out of memory\n" ); |
| 147 | 406 | return INIT_FAIL; |
| 148 | 407 | } |
| 149 | | image_fread( image, m_p_psxexe, m_psxexe_header.t_size ); |
| 408 | if( image_fread( image, exe_buffer, quickload_size ) != quickload_size ) |
| 409 | { |
| 410 | free( exe_buffer ); |
| 411 | return INIT_FAIL; |
| 412 | } |
| 413 | exe_size = quickload_size; |
| 150 | 414 | memory_set_direct_update_handler( space, psx_setopbase ); |
| 151 | 415 | return INIT_PASS; |
| 152 | 416 | } |
| 153 | 417 | |
| 418 | /* PAD emulation */ |
| 419 | |
| 154 | 420 | #define PAD_STATE_IDLE ( 0 ) |
| 155 | 421 | #define PAD_STATE_LISTEN ( 1 ) |
| 156 | 422 | #define PAD_STATE_ACTIVE ( 2 ) |
| r4006 | r4007 | |
| 805 | 1071 | MDRV_SOUND_ROUTE( 1, "right", 1.00 ) |
| 806 | 1072 | |
| 807 | 1073 | /* quickload */ |
| 808 | | MDRV_QUICKLOAD_ADD(psx_exe_load, "exe,psx", 0) |
| 1074 | MDRV_QUICKLOAD_ADD(psx_exe_load, "cpe,exe,psf,psx", 0) |
| 809 | 1075 | MACHINE_DRIVER_END |
| 810 | 1076 | |
| 811 | 1077 | static MACHINE_DRIVER_START( psxpal ) |
| r4006 | r4007 | |
| 838 | 1104 | MDRV_SOUND_ROUTE( 1, "right", 1.00 ) |
| 839 | 1105 | |
| 840 | 1106 | /* quickload */ |
| 841 | | MDRV_QUICKLOAD_ADD(psx_exe_load, "exe,psx", 0) |
| 1107 | MDRV_QUICKLOAD_ADD(psx_exe_load, "cpe,exe,psf,psx", 0) |
| 842 | 1108 | MACHINE_DRIVER_END |
| 843 | 1109 | |
| 844 | 1110 | ROM_START( psj ) |