src/mess/machine/pce.c
| r3668 | r3669 | |
| 99 | 99 | static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ); |
| 100 | 100 | |
| 101 | 101 | |
| 102 | | static WRITE8_HANDLER( pce_sf2_banking_w ) { |
| 103 | | memory_set_bankptr( 2, memory_region(machine, "user1") + offset * 0x080000 + 0x080000 ); |
| 104 | | memory_set_bankptr( 3, memory_region(machine, "user1") + offset * 0x080000 + 0x088000 ); |
| 105 | | memory_set_bankptr( 4, memory_region(machine, "user1") + offset * 0x080000 + 0x0D0000 ); |
| 102 | static WRITE8_HANDLER( pce_sf2_banking_w ) |
| 103 | { |
| 104 | memory_set_bankptr( space->machine, 2, memory_region(space->machine, "user1") + offset * 0x080000 + 0x080000 ); |
| 105 | memory_set_bankptr( space->machine, 3, memory_region(space->machine, "user1") + offset * 0x080000 + 0x088000 ); |
| 106 | memory_set_bankptr( space->machine, 4, memory_region(space->machine, "user1") + offset * 0x080000 + 0x0D0000 ); |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | | static WRITE8_HANDLER( pce_cartridge_ram_w ) { |
| 109 | static WRITE8_HANDLER( pce_cartridge_ram_w ) |
| 110 | { |
| 109 | 111 | cartridge_ram[ offset ] = data; |
| 110 | 112 | } |
| 111 | 113 | |
| r3668 | r3669 | |
| 190 | 192 | memcpy( ROM + 0x080000, ROM, 0x080000 ); |
| 191 | 193 | } |
| 192 | 194 | |
| 193 | | memory_set_bankptr( 1, ROM ); |
| 194 | | memory_set_bankptr( 2, ROM + 0x080000 ); |
| 195 | | memory_set_bankptr( 3, ROM + 0x088000 ); |
| 196 | | memory_set_bankptr( 4, ROM + 0x0D0000 ); |
| 195 | memory_set_bankptr( image->machine, 1, ROM ); |
| 196 | memory_set_bankptr( image->machine, 2, ROM + 0x080000 ); |
| 197 | memory_set_bankptr( image->machine, 3, ROM + 0x088000 ); |
| 198 | memory_set_bankptr( image->machine, 4, ROM + 0x0D0000 ); |
| 197 | 199 | |
| 198 | 200 | /* Check for Street fighter 2 */ |
| 199 | | if ( size == PCE_ROM_MAXSIZE ) { |
| 200 | | memory_install_write8_handler(image->machine, 0, ADDRESS_SPACE_PROGRAM, 0x01ff0, 0x01ff3, 0, 0, pce_sf2_banking_w ); |
| 201 | if ( size == PCE_ROM_MAXSIZE ) |
| 202 | { |
| 203 | memory_install_write8_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x01ff0, 0x01ff3, 0, 0, pce_sf2_banking_w ); |
| 201 | 204 | } |
| 202 | 205 | |
| 203 | 206 | /* Check for Populous */ |
| 204 | | if ( ! memcmp( ROM + 0x1F26, "POPULOUS", 8 ) ) { |
| 207 | if ( ! memcmp( ROM + 0x1F26, "POPULOUS", 8 ) ) |
| 208 | { |
| 205 | 209 | cartridge_ram = auto_malloc( 0x8000 ); |
| 206 | | memory_set_bankptr( 2, cartridge_ram ); |
| 207 | | memory_install_write8_handler(image->machine, 0, ADDRESS_SPACE_PROGRAM, 0x080000, 0x087FFF, 0, 0, pce_cartridge_ram_w ); |
| 210 | memory_set_bankptr( image->machine, 2, cartridge_ram ); |
| 211 | memory_install_write8_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x080000, 0x087FFF, 0, 0, pce_cartridge_ram_w ); |
| 208 | 212 | } |
| 209 | 213 | |
| 210 | 214 | /* Check for CD system card */ |
| 211 | 215 | pce_sys3_card = 0; |
| 212 | | if ( ! memcmp( ROM + 0x3FFB6, "PC Engine CD-ROM SYSTEM", 23 ) ) { |
| 216 | if ( ! memcmp( ROM + 0x3FFB6, "PC Engine CD-ROM SYSTEM", 23 ) ) |
| 217 | { |
| 213 | 218 | /* Check if 192KB additional system card ram should be used */ |
| 214 | | if ( ! memcmp( ROM + 0x29D1, "VER. 3.", 7 ) || ! memcmp( ROM + 0x29C4, "VER. 3.", 7 ) ) { |
| 219 | if ( ! memcmp( ROM + 0x29D1, "VER. 3.", 7 ) || ! memcmp( ROM + 0x29C4, "VER. 3.", 7 ) ) |
| 220 | { |
| 215 | 221 | pce_sys3_card = 1; |
| 216 | 222 | cartridge_ram = auto_malloc( 0x30000 ); |
| 217 | | memory_set_bankptr( 4, cartridge_ram ); |
| 218 | | memory_install_write8_handler(image->machine, 0, ADDRESS_SPACE_PROGRAM, 0x0D0000, 0x0FFFFF, 0, 0, pce_cartridge_ram_w ); |
| 223 | memory_set_bankptr( image->machine, 4, cartridge_ram ); |
| 224 | memory_install_write8_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0D0000, 0x0FFFFF, 0, 0, pce_cartridge_ram_w ); |
| 219 | 225 | } |
| 220 | 226 | } |
| 221 | 227 | return 0; |
| 222 | 228 | } |
| 223 | 229 | |
| 224 | | DRIVER_INIT( pce ) { |
| 230 | DRIVER_INIT( pce ) |
| 231 | { |
| 225 | 232 | pce.io_port_options = PCE_JOY_SIG | CONST_SIG; |
| 226 | 233 | } |
| 227 | 234 | |
| 228 | | DRIVER_INIT( tg16 ) { |
| 235 | DRIVER_INIT( tg16 ) |
| 236 | { |
| 229 | 237 | pce.io_port_options = TG_16_JOY_SIG | CONST_SIG; |
| 230 | 238 | } |
| 231 | 239 | |
| 232 | | DRIVER_INIT( sgx ) { |
| 240 | DRIVER_INIT( sgx ) |
| 241 | { |
| 233 | 242 | pce.io_port_options = PCE_JOY_SIG | CONST_SIG; |
| 234 | 243 | } |
| 235 | 244 | |
| 236 | | MACHINE_RESET( pce ) { |
| 245 | MACHINE_RESET( pce ) |
| 246 | { |
| 237 | 247 | pce_cd_init( machine ); |
| 238 | 248 | } |
| 239 | 249 | |
| r3668 | r3669 | |
| 260 | 270 | READ8_HANDLER ( pce_joystick_r ) |
| 261 | 271 | { |
| 262 | 272 | UINT8 ret; |
| 263 | | int data = input_port_read(machine, "JOY"); |
| 273 | int data = input_port_read(space->machine, "JOY"); |
| 264 | 274 | if(joystick_data_select) data >>= 4; |
| 265 | 275 | ret = (data & 0x0F) | pce.io_port_options; |
| 266 | 276 | #ifdef UNIFIED_PCE |
| r3668 | r3669 | |
| 283 | 293 | } |
| 284 | 294 | } |
| 285 | 295 | |
| 286 | | static void pce_set_cd_bram( void ) { |
| 287 | | memory_set_bankptr( 10, pce_cd.bram + ( pce_cd.bram_locked ? PCE_BRAM_SIZE : 0 ) ); |
| 296 | static void pce_set_cd_bram( running_machine *machine ) |
| 297 | { |
| 298 | memory_set_bankptr( machine, 10, pce_cd.bram + ( pce_cd.bram_locked ? PCE_BRAM_SIZE : 0 ) ); |
| 288 | 299 | } |
| 289 | 300 | |
| 290 | 301 | /* Callback for new data from the MSM5205. |
| r3668 | r3669 | |
| 292 | 303 | the MSM5205. Currently we can only use static clocks for the |
| 293 | 304 | MSM5205. |
| 294 | 305 | */ |
| 295 | | static void pce_cd_msm5205_int( running_machine *machine, int chip ) { |
| 306 | static void pce_cd_msm5205_int( running_machine *machine, int chip ) |
| 307 | { |
| 296 | 308 | pce_cd.adpcm_clock_count = ( pce_cd.adpcm_clock_count + 1 ) % pce_cd.adpcm_clock_divider; |
| 297 | | if ( ! pce_cd.adpcm_clock_count ) { |
| 309 | if ( ! pce_cd.adpcm_clock_count ) |
| 310 | { |
| 298 | 311 | /* Supply new ADPCM data */ |
| 299 | | } else { |
| 312 | } |
| 313 | else |
| 314 | { |
| 300 | 315 | /* Make sure the sample does not change */ |
| 301 | 316 | } |
| 302 | 317 | } |
| r3668 | r3669 | |
| 304 | 319 | #define SCSI_STATUS_OK 0x00 |
| 305 | 320 | #define SCSI_CHECK_CONDITION 0x02 |
| 306 | 321 | |
| 307 | | static void pce_cd_reply_status_byte( UINT8 status ) { |
| 322 | static void pce_cd_reply_status_byte( UINT8 status ) |
| 323 | { |
| 308 | 324 | logerror("Setting CD in reply_status_byte\n"); |
| 309 | 325 | pce_cd.scsi_CD = pce_cd.scsi_IO = pce_cd.scsi_REQ = 1; |
| 310 | 326 | pce_cd.scsi_MSG = 0; |
| 311 | 327 | pce_cd.message_after_status = 1; |
| 312 | 328 | pce_cd.status_sent = pce_cd.message_sent = 0; |
| 313 | 329 | |
| 314 | | if ( status == SCSI_STATUS_OK ) { |
| 330 | if ( status == SCSI_STATUS_OK ) |
| 331 | { |
| 315 | 332 | pce_cd.regs[0x01] = 0x00; |
| 316 | | } else { |
| 333 | } |
| 334 | else |
| 335 | { |
| 317 | 336 | pce_cd.regs[0x01] = 0x01; |
| 318 | 337 | } |
| 319 | 338 | } |
| 320 | 339 | |
| 321 | 340 | /* 0x00 - TEST UNIT READY */ |
| 322 | | static void pce_cd_test_unit_ready( void ) { |
| 341 | static void pce_cd_test_unit_ready( void ) |
| 342 | { |
| 323 | 343 | logerror("test unit ready\n"); |
| 324 | | if ( pce_cd.cd ) { |
| 344 | if ( pce_cd.cd ) |
| 345 | { |
| 325 | 346 | logerror( "Sending STATUS_OK status\n" ); |
| 326 | 347 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 327 | | } else { |
| 348 | } |
| 349 | else |
| 350 | { |
| 328 | 351 | logerror( "Sending CHECK_CONDITION status\n" ); |
| 329 | 352 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 330 | 353 | } |
| 331 | 354 | } |
| 332 | 355 | |
| 333 | 356 | /* 0x08 - READ (6) */ |
| 334 | | static void pce_cd_read_6( void ) { |
| 357 | static void pce_cd_read_6( void ) |
| 358 | { |
| 335 | 359 | UINT32 frame = ( ( pce_cd.command_buffer[1] & 0x1F ) << 16 ) | ( pce_cd.command_buffer[2] << 8 ) | pce_cd.command_buffer[3]; |
| 336 | 360 | UINT32 frame_count = pce_cd.command_buffer[4]; |
| 337 | 361 | |
| 338 | 362 | /* Check for presence of a CD */ |
| 339 | | if ( ! pce_cd.cd ) { |
| 363 | if ( ! pce_cd.cd ) |
| 364 | { |
| 340 | 365 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 341 | 366 | return; |
| 342 | 367 | } |
| 343 | 368 | |
| 344 | | if ( pce_cd.cdda_status != PCE_CD_CDDA_OFF ) { |
| 369 | if ( pce_cd.cdda_status != PCE_CD_CDDA_OFF ) |
| 370 | { |
| 345 | 371 | pce_cd.cdda_status = PCE_CD_CDDA_OFF; |
| 346 | 372 | cdda_stop_audio( 0 ); |
| 347 | 373 | } |
| r3668 | r3669 | |
| 349 | 375 | pce_cd.current_frame = frame; |
| 350 | 376 | pce_cd.end_frame = frame + frame_count; |
| 351 | 377 | |
| 352 | | if ( frame_count == 0 ) { |
| 378 | if ( frame_count == 0 ) |
| 379 | { |
| 353 | 380 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 354 | | } else { |
| 381 | } |
| 382 | else |
| 383 | { |
| 355 | 384 | timer_adjust_periodic(pce_cd.data_timer, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND ), 0, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND )); |
| 356 | 385 | } |
| 357 | 386 | } |
| 358 | 387 | |
| 359 | 388 | /* 0xD8 - SET AUDIO PLAYBACK START POSITION (NEC) */ |
| 360 | | static void pce_cd_nec_set_audio_start_position( void ) { |
| 389 | static void pce_cd_nec_set_audio_start_position( void ) |
| 390 | { |
| 361 | 391 | UINT32 frame = 0; |
| 362 | 392 | |
| 363 | | if ( ! pce_cd.cd ) { |
| 393 | if ( ! pce_cd.cd ) |
| 394 | { |
| 364 | 395 | /* Throw some error here */ |
| 365 | 396 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 366 | 397 | return; |
| 367 | 398 | } |
| 368 | 399 | |
| 369 | | switch( pce_cd.command_buffer[9] & 0xC0 ) { |
| 400 | switch( pce_cd.command_buffer[9] & 0xC0 ) |
| 401 | { |
| 370 | 402 | case 0x00: |
| 371 | 403 | frame = ( pce_cd.command_buffer[3] << 16 ) | ( pce_cd.command_buffer[4] << 8 ) | pce_cd.command_buffer[5]; |
| 372 | 404 | break; |
| r3668 | r3669 | |
| 383 | 415 | |
| 384 | 416 | pce_cd.current_frame = frame; |
| 385 | 417 | pce_cd.cdda_play_mode = pce_cd.command_buffer[1]; |
| 386 | | if ( pce_cd.cdda_play_mode ) { |
| 418 | if ( pce_cd.cdda_play_mode ) |
| 419 | { |
| 387 | 420 | pce_cd.cdda_status = PCE_CD_CDDA_PLAYING; |
| 388 | 421 | cdda_start_audio( 0, pce_cd.current_frame, pce_cd.end_frame - pce_cd.current_frame ); |
| 389 | | } else { |
| 422 | } |
| 423 | else |
| 424 | { |
| 390 | 425 | pce_cd.cdda_status = PCE_CD_CDDA_OFF; |
| 391 | 426 | cdda_stop_audio( 0 ); |
| 392 | 427 | pce_cd.end_frame = pce_cd.last_frame; |
| r3668 | r3669 | |
| 397 | 432 | } |
| 398 | 433 | |
| 399 | 434 | /* 0xD9 - SET AUDIO PLAYBACK END POSITION (NEC) */ |
| 400 | | static void pce_cd_nec_set_audio_stop_position( void ) { |
| 435 | static void pce_cd_nec_set_audio_stop_position( void ) |
| 436 | { |
| 401 | 437 | UINT32 frame = 0; |
| 402 | 438 | |
| 403 | | if ( ! pce_cd.cd ) { |
| 439 | if ( ! pce_cd.cd ) |
| 440 | { |
| 404 | 441 | /* Throw some error here */ |
| 405 | 442 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 406 | 443 | return; |
| 407 | 444 | } |
| 408 | 445 | |
| 409 | | switch( pce_cd.command_buffer[9] & 0xC0 ) { |
| 446 | switch( pce_cd.command_buffer[9] & 0xC0 ) |
| 447 | { |
| 410 | 448 | case 0x00: |
| 411 | 449 | frame = ( pce_cd.command_buffer[3] << 16 ) | ( pce_cd.command_buffer[4] << 8 ) | pce_cd.command_buffer[5]; |
| 412 | 450 | break; |
| r3668 | r3669 | |
| 423 | 461 | |
| 424 | 462 | pce_cd.end_frame = frame; |
| 425 | 463 | pce_cd.cdda_play_mode = pce_cd.command_buffer[1]; |
| 426 | | if ( pce_cd.cdda_play_mode ) { |
| 427 | | if ( pce_cd.cdda_status == PCE_CD_CDDA_PAUSED ) { |
| 464 | if ( pce_cd.cdda_play_mode ) |
| 465 | { |
| 466 | if ( pce_cd.cdda_status == PCE_CD_CDDA_PAUSED ) |
| 467 | { |
| 428 | 468 | cdda_pause_audio( 0, 0 ); |
| 429 | | } else { |
| 469 | } |
| 470 | else |
| 471 | { |
| 430 | 472 | cdda_start_audio( 0, pce_cd.current_frame, pce_cd.end_frame - pce_cd.current_frame ); |
| 431 | 473 | } |
| 432 | 474 | pce_cd.cdda_status = PCE_CD_CDDA_PLAYING; |
| 433 | | } else { |
| 475 | } |
| 476 | else |
| 477 | { |
| 434 | 478 | pce_cd.cdda_status = PCE_CD_CDDA_OFF; |
| 435 | 479 | cdda_stop_audio( 0 ); |
| 436 | 480 | pce_cd.end_frame = pce_cd.last_frame; |
| r3668 | r3669 | |
| 442 | 486 | } |
| 443 | 487 | |
| 444 | 488 | /* 0xDA - PAUSE (NEC) */ |
| 445 | | static void pce_cd_nec_pause( void ) { |
| 489 | static void pce_cd_nec_pause( void ) |
| 490 | { |
| 446 | 491 | |
| 447 | 492 | /* If no cd mounted throw an error */ |
| 448 | | if ( ! pce_cd.cd ) { |
| 493 | if ( ! pce_cd.cd ) |
| 494 | { |
| 449 | 495 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 450 | 496 | return; |
| 451 | 497 | } |
| 452 | 498 | |
| 453 | 499 | /* If there was no cdda playing, throw an error */ |
| 454 | | if ( pce_cd.cdda_status == PCE_CD_CDDA_OFF ) { |
| 500 | if ( pce_cd.cdda_status == PCE_CD_CDDA_OFF ) |
| 501 | { |
| 455 | 502 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 456 | 503 | return; |
| 457 | 504 | } |
| r3668 | r3669 | |
| 463 | 510 | } |
| 464 | 511 | |
| 465 | 512 | /* 0xDD - READ SUBCHANNEL Q (NEC) */ |
| 466 | | static void pce_cd_nec_get_subq( void ) { |
| 513 | static void pce_cd_nec_get_subq( void ) |
| 514 | { |
| 467 | 515 | /* WP - I do not have access to chds with subchannel information yet, so I'm faking something here */ |
| 468 | 516 | UINT32 msf_abs, msf_rel, track, frame; |
| 469 | 517 | |
| 470 | | if ( ! pce_cd.cd ) { |
| 518 | if ( ! pce_cd.cd ) |
| 519 | { |
| 471 | 520 | /* Throw some error here */ |
| 472 | 521 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 473 | 522 | return; |
| r3668 | r3669 | |
| 475 | 524 | |
| 476 | 525 | frame = pce_cd.current_frame; |
| 477 | 526 | |
| 478 | | switch( pce_cd.cdda_status ) { |
| 527 | switch( pce_cd.cdda_status ) |
| 528 | { |
| 479 | 529 | case PCE_CD_CDDA_PAUSED: |
| 480 | 530 | pce_cd.data_buffer[0] = 2; |
| 481 | 531 | frame = cdda_get_audio_lba( 0 ); |
| r3668 | r3669 | |
| 511 | 561 | } |
| 512 | 562 | |
| 513 | 563 | /* 0xDE - GET DIR INFO (NEC) */ |
| 514 | | static void pce_cd_nec_get_dir_info( void ) { |
| 564 | static void pce_cd_nec_get_dir_info( void ) |
| 565 | { |
| 515 | 566 | UINT32 frame, msf, track = 0; |
| 516 | 567 | const cdrom_toc *toc; |
| 517 | 568 | logerror("nec get dir info\n"); |
| 518 | 569 | |
| 519 | | if ( ! pce_cd.cd ) { |
| 570 | if ( ! pce_cd.cd ) |
| 571 | { |
| 520 | 572 | /* Throw some error here */ |
| 521 | 573 | pce_cd_reply_status_byte( SCSI_CHECK_CONDITION ); |
| 522 | 574 | } |
| 523 | 575 | |
| 524 | 576 | toc = cdrom_get_toc( pce_cd.cd ); |
| 525 | 577 | |
| 526 | | switch( pce_cd.command_buffer[1] ) { |
| 578 | switch( pce_cd.command_buffer[1] ) |
| 579 | { |
| 527 | 580 | case 0x00: /* Get first and last track numbers */ |
| 528 | 581 | pce_cd.data_buffer[0] = dec_2_bcd(1); |
| 529 | 582 | pce_cd.data_buffer[1] = dec_2_bcd(toc->numtrks); |
| r3668 | r3669 | |
| 540 | 593 | pce_cd.data_buffer_size = 3; |
| 541 | 594 | break; |
| 542 | 595 | case 0x02: /* Get track information */ |
| 543 | | if ( pce_cd.command_buffer[2] == 0xAA ) { |
| 596 | if ( pce_cd.command_buffer[2] == 0xAA ) |
| 597 | { |
| 544 | 598 | frame = toc->tracks[toc->numtrks-1].physframeofs; |
| 545 | 599 | frame += toc->tracks[toc->numtrks-1].frames; |
| 546 | 600 | pce_cd.data_buffer[3] = 0x04; /* correct? */ |
| 547 | | } else { |
| 601 | } else |
| 602 | { |
| 548 | 603 | track = MAX( bcd_2_dec( pce_cd.command_buffer[2] ), 1 ); |
| 549 | 604 | frame = toc->tracks[track-1].physframeofs; |
| 550 | 605 | pce_cd.data_buffer[3] = ( toc->tracks[track-1].trktype == CD_TRACK_AUDIO ) ? 0x00 : 0x04; |
| r3668 | r3669 | |
| 567 | 622 | pce_cd.scsi_CD = 0; |
| 568 | 623 | } |
| 569 | 624 | |
| 570 | | static void pce_cd_handle_data_output( void ) { |
| 625 | static void pce_cd_handle_data_output( void ) |
| 626 | { |
| 571 | 627 | static const struct { |
| 572 | 628 | UINT8 command_byte; |
| 573 | 629 | UINT8 command_size; |
| r3668 | r3669 | |
| 583 | 639 | { 0xFF, 0, NULL } /* end of list marker */ |
| 584 | 640 | }; |
| 585 | 641 | |
| 586 | | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) { |
| 642 | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) |
| 643 | { |
| 587 | 644 | /* Command byte received */ |
| 588 | 645 | logerror( "Command byte $%02X received\n", pce_cd.regs[0x01] ); |
| 589 | 646 | |
| r3668 | r3669 | |
| 595 | 652 | pce_cd.scsi_REQ = 0; |
| 596 | 653 | } |
| 597 | 654 | |
| 598 | | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.command_buffer_index ) { |
| 655 | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.command_buffer_index ) |
| 656 | { |
| 599 | 657 | int i = 0; |
| 600 | 658 | |
| 601 | 659 | logerror( "Check if command done\n" ); |
| r3668 | r3669 | |
| 603 | 661 | for( i = 0; pce_cd.command_buffer[0] > pce_cd_commands[i].command_byte; i++ ); |
| 604 | 662 | |
| 605 | 663 | /* Check for unknown commands */ |
| 606 | | if ( pce_cd.command_buffer[0] != pce_cd_commands[i].command_byte ) { |
| 664 | if ( pce_cd.command_buffer[0] != pce_cd_commands[i].command_byte ) |
| 665 | { |
| 607 | 666 | logerror("Unrecognized command: %02X\n", pce_cd.command_buffer[0] ); |
| 608 | 667 | } |
| 609 | 668 | assert( pce_cd.command_buffer[0] == pce_cd_commands[i].command_byte ); |
| 610 | 669 | |
| 611 | | if ( pce_cd.command_buffer_index == pce_cd_commands[i].command_size ) { |
| 670 | if ( pce_cd.command_buffer_index == pce_cd_commands[i].command_size ) |
| 671 | { |
| 612 | 672 | (pce_cd_commands[i].command_handler)(); |
| 613 | 673 | pce_cd.command_buffer_index = 0; |
| 614 | | } else { |
| 674 | } |
| 675 | else |
| 676 | { |
| 615 | 677 | pce_cd.scsi_REQ = 1; |
| 616 | 678 | } |
| 617 | 679 | } |
| 618 | 680 | } |
| 619 | 681 | |
| 620 | | static void pce_cd_handle_data_input( void ) { |
| 621 | | if ( pce_cd.scsi_CD ) { |
| 682 | static void pce_cd_handle_data_input( void ) |
| 683 | { |
| 684 | if ( pce_cd.scsi_CD ) |
| 685 | { |
| 622 | 686 | /* Command / Status byte */ |
| 623 | | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) { |
| 687 | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) |
| 688 | { |
| 624 | 689 | logerror( "status sent\n" ); |
| 625 | 690 | pce_cd.scsi_REQ = 0; |
| 626 | 691 | pce_cd.status_sent = 1; |
| 627 | 692 | } |
| 628 | 693 | |
| 629 | | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.status_sent ) { |
| 694 | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.status_sent ) |
| 695 | { |
| 630 | 696 | pce_cd.status_sent = 0; |
| 631 | | if ( pce_cd.message_after_status ) { |
| 697 | if ( pce_cd.message_after_status ) |
| 698 | { |
| 632 | 699 | logerror( "message after status\n" ); |
| 633 | 700 | pce_cd.message_after_status = 0; |
| 634 | 701 | pce_cd.scsi_MSG = pce_cd.scsi_REQ = 1; |
| 635 | 702 | pce_cd.regs[0x01] = 0; |
| 636 | 703 | } |
| 637 | 704 | } |
| 638 | | } else { |
| 705 | } |
| 706 | else |
| 707 | { |
| 639 | 708 | /* Data */ |
| 640 | | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) { |
| 709 | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) |
| 710 | { |
| 641 | 711 | pce_cd.scsi_REQ = 0; |
| 642 | 712 | } |
| 643 | 713 | |
| 644 | | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK ) { |
| 645 | | if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) { |
| 714 | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK ) |
| 715 | { |
| 716 | if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) |
| 717 | { |
| 646 | 718 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_READY, CLEAR_LINE ); |
| 647 | | if ( pce_cd.data_transferred ) { |
| 719 | if ( pce_cd.data_transferred ) |
| 720 | { |
| 648 | 721 | pce_cd.data_transferred = 0; |
| 649 | 722 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 650 | 723 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 651 | 724 | } |
| 652 | | } else { |
| 725 | } |
| 726 | else |
| 727 | { |
| 653 | 728 | logerror("Transfer byte from offset %d\n", pce_cd.data_buffer_index); |
| 654 | 729 | pce_cd.regs[0x01] = pce_cd.data_buffer[pce_cd.data_buffer_index]; |
| 655 | 730 | pce_cd.data_buffer_index++; |
| r3668 | r3669 | |
| 659 | 734 | } |
| 660 | 735 | } |
| 661 | 736 | |
| 662 | | static void pce_cd_handle_message_output( void ) { |
| 663 | | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) { |
| 737 | static void pce_cd_handle_message_output( void ) |
| 738 | { |
| 739 | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) |
| 740 | { |
| 664 | 741 | pce_cd.scsi_REQ = 0; |
| 665 | 742 | } |
| 666 | 743 | } |
| 667 | 744 | |
| 668 | | static void pce_cd_handle_message_input( void ) { |
| 669 | | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) { |
| 745 | static void pce_cd_handle_message_input( void ) |
| 746 | { |
| 747 | if ( pce_cd.scsi_REQ && pce_cd.scsi_ACK ) |
| 748 | { |
| 670 | 749 | pce_cd.scsi_REQ = 0; |
| 671 | 750 | pce_cd.message_sent = 1; |
| 672 | 751 | } |
| 673 | 752 | |
| 674 | | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.message_sent ) { |
| 753 | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && pce_cd.message_sent ) |
| 754 | { |
| 675 | 755 | pce_cd.message_sent = 0; |
| 676 | 756 | pce_cd.scsi_BSY = 0; |
| 677 | 757 | } |
| 678 | 758 | } |
| 679 | 759 | |
| 680 | 760 | /* Update internal CD statuses */ |
| 681 | | static void pce_cd_update( running_machine *machine ) { |
| 761 | static void pce_cd_update( running_machine *machine ) |
| 762 | { |
| 682 | 763 | /* Check for reset of CD unit */ |
| 683 | | if ( pce_cd.scsi_RST != pce_cd.scsi_last_RST ) { |
| 684 | | if ( pce_cd.scsi_RST ) { |
| 764 | if ( pce_cd.scsi_RST != pce_cd.scsi_last_RST ) |
| 765 | { |
| 766 | if ( pce_cd.scsi_RST ) |
| 767 | { |
| 685 | 768 | logerror("Performing CD reset\n"); |
| 686 | 769 | /* Reset internal data */ |
| 687 | 770 | pce_cd.scsi_BSY = pce_cd.scsi_SEL = pce_cd.scsi_CD = pce_cd.scsi_IO = 0; |
| r3668 | r3669 | |
| 693 | 776 | } |
| 694 | 777 | |
| 695 | 778 | /* Check if bus can be freed */ |
| 696 | | if ( ! pce_cd.scsi_SEL && ! pce_cd.scsi_BSY && pce_cd.selected ) { |
| 779 | if ( ! pce_cd.scsi_SEL && ! pce_cd.scsi_BSY && pce_cd.selected ) |
| 780 | { |
| 697 | 781 | logerror( "freeing bus\n" ); |
| 698 | 782 | pce_cd.selected = 0; |
| 699 | 783 | pce_cd.scsi_CD = pce_cd.scsi_MSG = pce_cd.scsi_IO = pce_cd.scsi_REQ = 0; |
| r3668 | r3669 | |
| 701 | 785 | } |
| 702 | 786 | |
| 703 | 787 | /* Select the CD device */ |
| 704 | | if ( pce_cd.scsi_SEL ) { |
| 705 | | if ( ! pce_cd.selected ) { |
| 788 | if ( pce_cd.scsi_SEL ) |
| 789 | { |
| 790 | if ( ! pce_cd.selected ) |
| 791 | { |
| 706 | 792 | pce_cd.selected = 1; |
| 707 | 793 | logerror("Setting CD in device selection\n"); |
| 708 | 794 | pce_cd.scsi_BSY = pce_cd.scsi_REQ = pce_cd.scsi_CD = 1; |
| r3668 | r3669 | |
| 710 | 796 | } |
| 711 | 797 | } |
| 712 | 798 | |
| 713 | | if ( pce_cd.scsi_ATN ) { |
| 714 | | } else { |
| 799 | if ( pce_cd.scsi_ATN ) |
| 800 | { |
| 801 | } |
| 802 | else |
| 803 | { |
| 715 | 804 | /* Check for data and pessage phases */ |
| 716 | | if ( pce_cd.scsi_BSY ) { |
| 717 | | if ( pce_cd.scsi_MSG ) { |
| 805 | if ( pce_cd.scsi_BSY ) |
| 806 | { |
| 807 | if ( pce_cd.scsi_MSG ) |
| 808 | { |
| 718 | 809 | /* message phase */ |
| 719 | | if ( pce_cd.scsi_IO ) { |
| 810 | if ( pce_cd.scsi_IO ) |
| 811 | { |
| 720 | 812 | pce_cd_handle_message_input(); |
| 721 | | } else { |
| 813 | } |
| 814 | else |
| 815 | { |
| 722 | 816 | pce_cd_handle_message_output(); |
| 723 | 817 | } |
| 724 | | } else { |
| 818 | } |
| 819 | else |
| 820 | { |
| 725 | 821 | /* data phase */ |
| 726 | | if ( pce_cd.scsi_IO ) { |
| 822 | if ( pce_cd.scsi_IO ) |
| 823 | { |
| 727 | 824 | /* Reading data from target */ |
| 728 | 825 | pce_cd_handle_data_input(); |
| 729 | | } else { |
| 826 | } |
| 827 | else |
| 828 | { |
| 730 | 829 | /* Sending data to target */ |
| 731 | 830 | pce_cd_handle_data_output(); |
| 732 | 831 | } |
| r3668 | r3669 | |
| 735 | 834 | } |
| 736 | 835 | } |
| 737 | 836 | |
| 738 | | static void pce_cd_set_irq_line( running_machine *machine, int num, int state ) { |
| 739 | | switch( num ) { |
| 837 | static void pce_cd_set_irq_line( running_machine *machine, int num, int state ) |
| 838 | { |
| 839 | switch( num ) |
| 840 | { |
| 740 | 841 | case PCE_CD_IRQ_TRANSFER_DONE: |
| 741 | | if ( state == ASSERT_LINE ) { |
| 842 | if ( state == ASSERT_LINE ) |
| 843 | { |
| 742 | 844 | pce_cd.regs[0x03] |= PCE_CD_IRQ_TRANSFER_DONE; |
| 743 | | } else { |
| 845 | } |
| 846 | else |
| 847 | { |
| 744 | 848 | pce_cd.regs[0x03] &= ~ PCE_CD_IRQ_TRANSFER_DONE; |
| 745 | 849 | } |
| 746 | 850 | break; |
| 747 | 851 | case PCE_CD_IRQ_TRANSFER_READY: |
| 748 | | if ( state == ASSERT_LINE ) { |
| 852 | if ( state == ASSERT_LINE ) |
| 853 | { |
| 749 | 854 | pce_cd.regs[0x03] |= PCE_CD_IRQ_TRANSFER_READY; |
| 750 | | } else { |
| 855 | } |
| 856 | else |
| 857 | { |
| 751 | 858 | pce_cd.regs[0x03] &= ~ PCE_CD_IRQ_TRANSFER_READY; |
| 752 | 859 | } |
| 753 | 860 | break; |
| r3668 | r3669 | |
| 755 | 862 | break; |
| 756 | 863 | } |
| 757 | 864 | |
| 758 | | if ( pce_cd.regs[0x02] & pce_cd.regs[0x03] & ( PCE_CD_IRQ_TRANSFER_DONE | PCE_CD_IRQ_TRANSFER_READY ) ) { |
| 865 | if ( pce_cd.regs[0x02] & pce_cd.regs[0x03] & ( PCE_CD_IRQ_TRANSFER_DONE | PCE_CD_IRQ_TRANSFER_READY ) ) |
| 866 | { |
| 759 | 867 | cpu_set_input_line(machine->cpu[0], 1, ASSERT_LINE ); |
| 760 | | } else { |
| 868 | } |
| 869 | else |
| 870 | { |
| 761 | 871 | cpu_set_input_line(machine->cpu[0], 1, CLEAR_LINE ); |
| 762 | 872 | } |
| 763 | 873 | } |
| 764 | 874 | |
| 765 | | static TIMER_CALLBACK( pce_cd_data_timer_callback ) { |
| 766 | | if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) { |
| 875 | static TIMER_CALLBACK( pce_cd_data_timer_callback ) |
| 876 | { |
| 877 | if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) |
| 878 | { |
| 767 | 879 | /* Read next data sector */ |
| 768 | 880 | logerror("read sector %d\n", pce_cd.current_frame ); |
| 769 | | if ( ! cdrom_read_data( pce_cd.cd, pce_cd.current_frame, pce_cd.data_buffer, CD_TRACK_MODE1 ) ) { |
| 881 | if ( ! cdrom_read_data( pce_cd.cd, pce_cd.current_frame, pce_cd.data_buffer, CD_TRACK_MODE1 ) ) |
| 882 | { |
| 770 | 883 | logerror("Mode1 CD read failed for frame #%d\n", pce_cd.current_frame ); |
| 771 | | } else { |
| 884 | } |
| 885 | else |
| 886 | { |
| 772 | 887 | logerror("Succesfully read mode1 frame #%d\n", pce_cd.current_frame ); |
| 773 | 888 | } |
| 774 | 889 | |
| r3668 | r3669 | |
| 779 | 894 | pce_cd.scsi_IO = 1; |
| 780 | 895 | pce_cd.scsi_CD = 0; |
| 781 | 896 | |
| 782 | | if ( pce_cd.current_frame == pce_cd.end_frame ) { |
| 897 | if ( pce_cd.current_frame == pce_cd.end_frame ) |
| 898 | { |
| 783 | 899 | /* We are done, disable the timer */ |
| 784 | 900 | logerror("Last frame read from CD\n"); |
| 785 | 901 | pce_cd.data_transferred = 1; |
| 786 | 902 | timer_adjust_oneshot(pce_cd.data_timer, attotime_never, 0); |
| 787 | | } else { |
| 903 | } |
| 904 | else |
| 905 | { |
| 788 | 906 | pce_cd.data_transferred = 0; |
| 789 | 907 | } |
| 790 | 908 | } |
| 791 | 909 | } |
| 792 | 910 | |
| 793 | | static void pce_cd_init( running_machine *machine ) { |
| 911 | static void pce_cd_init( running_machine *machine ) |
| 912 | { |
| 794 | 913 | const device_config *device; |
| 795 | 914 | |
| 796 | 915 | /* Initialize pce_cd struct */ |
| r3668 | r3669 | |
| 801 | 920 | memset( pce_cd.bram, 0, PCE_BRAM_SIZE ); |
| 802 | 921 | memset( pce_cd.bram + PCE_BRAM_SIZE, 0xFF, PCE_BRAM_SIZE ); |
| 803 | 922 | pce_cd.bram_locked = 1; |
| 804 | | pce_set_cd_bram(); |
| 923 | pce_set_cd_bram(machine); |
| 805 | 924 | |
| 806 | 925 | /* set up adpcm related things */ |
| 807 | 926 | pce_cd.adpcm_ram = auto_malloc( PCE_ADPCM_RAM_SIZE ); |
| r3668 | r3669 | |
| 840 | 959 | timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime_never, 0); |
| 841 | 960 | } |
| 842 | 961 | |
| 843 | | WRITE8_HANDLER( pce_cd_bram_w ) { |
| 844 | | if ( ! pce_cd.bram_locked ) { |
| 962 | WRITE8_HANDLER( pce_cd_bram_w ) |
| 963 | { |
| 964 | if ( ! pce_cd.bram_locked ) |
| 965 | { |
| 845 | 966 | pce_cd.bram[ offset ] = data; |
| 846 | 967 | } |
| 847 | 968 | } |
| 848 | 969 | |
| 849 | | WRITE8_HANDLER( pce_cd_intf_w ) { |
| 850 | | logerror("%04X: write to CD interface offset %02X, data %02X\n", activecpu_get_pc(), offset, data ); |
| 851 | | pce_cd_update(machine); |
| 970 | WRITE8_HANDLER( pce_cd_intf_w ) |
| 971 | { |
| 972 | logerror("%04X: write to CD interface offset %02X, data %02X\n", cpu_get_pc(space->cpu), offset, data ); |
| 973 | pce_cd_update(space->machine); |
| 852 | 974 | |
| 853 | | switch( offset ) { |
| 975 | switch( offset ) |
| 976 | { |
| 854 | 977 | case 0x00: /* CDC status */ |
| 855 | 978 | /* select device (which bits??) */ |
| 856 | 979 | pce_cd.scsi_SEL = 1; |
| 857 | | pce_cd_update(machine); |
| 980 | pce_cd_update(space->machine); |
| 858 | 981 | pce_cd.scsi_SEL = 0; |
| 859 | 982 | break; |
| 860 | 983 | case 0x01: /* CDC command / status / data */ |
| r3668 | r3669 | |
| 867 | 990 | /* bit 2 - ?? irq */ |
| 868 | 991 | pce_cd.scsi_ACK = data & 0x80; |
| 869 | 992 | /* Don't set or reset any irq lines, but just verify the current state */ |
| 870 | | pce_cd_set_irq_line( machine, 0, 0 ); |
| 993 | pce_cd_set_irq_line( space->machine, 0, 0 ); |
| 871 | 994 | break; |
| 872 | 995 | case 0x03: /* BRAM lock / CD status / IRQ - Read Only register */ |
| 873 | 996 | break; |
| r3668 | r3669 | |
| 878 | 1001 | case 0x06: /* PCM data */ |
| 879 | 1002 | break; |
| 880 | 1003 | case 0x07: /* BRAM unlock / CD status */ |
| 881 | | if ( data & 0x80 ) { |
| 1004 | if ( data & 0x80 ) |
| 1005 | { |
| 882 | 1006 | pce_cd.bram_locked = 0; |
| 883 | | pce_set_cd_bram(); |
| 1007 | pce_set_cd_bram(space->machine); |
| 884 | 1008 | } |
| 885 | 1009 | break; |
| 886 | 1010 | case 0x08: /* ADPCM address (LSB) / CD data */ |
| r3668 | r3669 | |
| 889 | 1013 | case 0x0A: /* ADPCM RAM data port */ |
| 890 | 1014 | break; |
| 891 | 1015 | case 0x0B: /* ADPCM DMA control */ |
| 892 | | if ( ! ( pce_cd.regs[0x0B] & 0x02 ) && ( data & 0x02 ) ) { |
| 1016 | if ( ! ( pce_cd.regs[0x0B] & 0x02 ) && ( data & 0x02 ) ) |
| 1017 | { |
| 893 | 1018 | /* Start CD to ADPCM transfer */ |
| 894 | 1019 | timer_adjust_periodic(pce_cd.adpcm_dma_timer, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ), 0, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ) ); |
| 895 | 1020 | } |
| 896 | | if ( ( pce_cd.regs[0x0B] & 0x02 ) && ! ( data & 0x02 ) ) { |
| 1021 | if ( ( pce_cd.regs[0x0B] & 0x02 ) && ! ( data & 0x02 ) ) |
| 1022 | { |
| 897 | 1023 | /* Stop CD to ADPCM transfer (?) */ |
| 898 | 1024 | timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime_never, 0); |
| 899 | 1025 | } |
| r3668 | r3669 | |
| 901 | 1027 | case 0x0C: /* ADPCM status */ |
| 902 | 1028 | break; |
| 903 | 1029 | case 0x0D: /* ADPCM address control */ |
| 904 | | if ( ( pce_cd.regs[0x0D] & 0x80 ) && ! ( data & 0x80 ) ) { |
| 1030 | if ( ( pce_cd.regs[0x0D] & 0x80 ) && ! ( data & 0x80 ) ) |
| 1031 | { |
| 905 | 1032 | /* Reset ADPCM hardware */ |
| 906 | 1033 | pce_cd.adpcm_read_ptr = 0; |
| 907 | 1034 | pce_cd.adpcm_write_ptr = 0; |
| 908 | 1035 | msm5205_reset_w( 0, 0 ); |
| 909 | 1036 | } |
| 910 | | if ( data & 0x10 ) { |
| 1037 | if ( data & 0x10 ) |
| 1038 | { |
| 911 | 1039 | pce_cd.adpcm_length = ( pce_cd.regs[0x09] << 8 ) | pce_cd.regs[0x08]; |
| 912 | 1040 | } |
| 913 | | if ( data & 0x08 ) { |
| 1041 | if ( data & 0x08 ) |
| 1042 | { |
| 914 | 1043 | pce_cd.adpcm_read_ptr = ( pce_cd.regs[0x09] << 8 ) | pce_cd.regs[0x08]; |
| 915 | 1044 | } |
| 916 | | if ( ( data & 0x03 ) == 0x03 ) { |
| 1045 | if ( ( data & 0x03 ) == 0x03 ) |
| 1046 | { |
| 917 | 1047 | pce_cd.adpcm_write_ptr = ( pce_cd.regs[0x09] << 8 ) | pce_cd.regs[0x08]; |
| 918 | 1048 | } |
| 919 | 1049 | break; |
| r3668 | r3669 | |
| 927 | 1057 | return; |
| 928 | 1058 | } |
| 929 | 1059 | pce_cd.regs[offset] = data; |
| 930 | | pce_cd_update(machine); |
| 1060 | pce_cd_update(space->machine); |
| 931 | 1061 | } |
| 932 | 1062 | |
| 933 | | static TIMER_CALLBACK( pce_cd_clear_ack ) { |
| 1063 | static TIMER_CALLBACK( pce_cd_clear_ack ) |
| 1064 | { |
| 934 | 1065 | pce_cd_update(machine); |
| 935 | 1066 | pce_cd.scsi_ACK = 0; |
| 936 | 1067 | pce_cd_update(machine); |
| 937 | | if ( pce_cd.scsi_CD ) { |
| 1068 | if ( pce_cd.scsi_CD ) |
| 1069 | { |
| 938 | 1070 | pce_cd.regs[0x0B] &= 0xFE; |
| 939 | 1071 | } |
| 940 | 1072 | } |
| 941 | 1073 | |
| 942 | | static UINT8 pce_cd_get_cd_data_byte( void ) { |
| 1074 | static UINT8 pce_cd_get_cd_data_byte( void ) |
| 1075 | { |
| 943 | 1076 | UINT8 data = pce_cd.regs[0x01]; |
| 944 | | if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD ) { |
| 945 | | if ( pce_cd.scsi_IO ) { |
| 1077 | if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD ) |
| 1078 | { |
| 1079 | if ( pce_cd.scsi_IO ) |
| 1080 | { |
| 946 | 1081 | pce_cd.scsi_ACK = 1; |
| 947 | 1082 | timer_set( ATTOTIME_IN_CYCLES( 15, 0 ), NULL, 0, pce_cd_clear_ack ); |
| 948 | 1083 | } |
| r3668 | r3669 | |
| 950 | 1085 | return data; |
| 951 | 1086 | } |
| 952 | 1087 | |
| 953 | | static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ) { |
| 954 | | if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD && pce_cd.scsi_IO ) { |
| 1088 | |
| 1089 | static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ) |
| 1090 | { |
| 1091 | if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD && pce_cd.scsi_IO ) |
| 1092 | { |
| 955 | 1093 | pce_cd.adpcm_ram[pce_cd.adpcm_write_ptr] = pce_cd_get_cd_data_byte(); |
| 956 | 1094 | pce_cd.adpcm_write_ptr = ( pce_cd.adpcm_write_ptr + 1 ) & 0xFFFF; |
| 957 | 1095 | } |
| 958 | 1096 | } |
| 959 | 1097 | |
| 960 | | READ8_HANDLER( pce_cd_intf_r ) { |
| 1098 | READ8_HANDLER( pce_cd_intf_r ) |
| 1099 | { |
| 961 | 1100 | UINT8 data = pce_cd.regs[offset & 0x0F]; |
| 962 | 1101 | |
| 963 | | pce_cd_update(machine); |
| 1102 | pce_cd_update(space->machine); |
| 964 | 1103 | |
| 965 | | logerror("%04X: read from CD interface offset %02X\n", activecpu_get_pc(), offset ); |
| 966 | | switch( offset ) { |
| 1104 | logerror("%04X: read from CD interface offset %02X\n", cpu_get_pc(space->cpu), offset ); |
| 1105 | switch( offset ) |
| 1106 | { |
| 967 | 1107 | case 0x00: /* CDC status */ |
| 968 | 1108 | data &= 0x07; |
| 969 | 1109 | data |= pce_cd.scsi_BSY ? 0x80 : 0; |
| r3668 | r3669 | |
| 980 | 1120 | /* bit 4 set when CD motor is on */ |
| 981 | 1121 | /* bit 2 set when less than half of the ADPCM data is remaining ?? */ |
| 982 | 1122 | pce_cd.bram_locked = 1; |
| 983 | | pce_set_cd_bram(); |
| 1123 | pce_set_cd_bram(space->machine); |
| 984 | 1124 | data = data & 0x6E; |
| 985 | 1125 | data |= ( pce_cd.cd_motor_on ? 0x10 : 0 ); |
| 986 | 1126 | pce_cd.regs[0x03] ^= 0x02; /* TODO: get rid of this hack */ |
src/mess/drivers/pasogo.c
| r3668 | r3669 | |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | static struct { |
| 22 | | UINT8 index; |
| 23 | | UINT8 data[0x100]; |
| 24 | | struct { |
| 25 | | UINT16 data; |
| 26 | | } bios_timer; // 1.19mhz tclk signal |
| 27 | | struct { |
| 28 | | int seconds, minutes, hours, days; |
| 29 | | int alarm_seconds, alarm_minutes, alarm_hours, alarm_days; |
| 22 | UINT8 index; |
| 23 | UINT8 data[0x100]; |
| 24 | struct { |
| 25 | UINT16 data; |
| 26 | } bios_timer; // 1.19mhz tclk signal |
| 27 | struct { |
| 28 | int seconds, minutes, hours, days; |
| 29 | int alarm_seconds, alarm_minutes, alarm_hours, alarm_days; |
| 30 | 30 | |
| 31 | | int onehertz_interrupt_on; |
| 32 | | int onehertz_interrupt_request; |
| 33 | | int alarm_interrupt_on; |
| 34 | | int alarm_interrupt_request; |
| 35 | | } rtc; |
| 36 | | struct { |
| 37 | | int write_protected; |
| 38 | | } pmu; |
| 31 | int onehertz_interrupt_on; |
| 32 | int onehertz_interrupt_request; |
| 33 | int alarm_interrupt_on; |
| 34 | int alarm_interrupt_request; |
| 35 | } rtc; |
| 36 | struct { |
| 37 | int write_protected; |
| 38 | } pmu; |
| 39 | 39 | } vg230; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | static TIMER_CALLBACK( vg230_timer ) |
| 43 | 43 | { |
| 44 | | vg230.rtc.seconds+=1; |
| 45 | | if (vg230.rtc.seconds>=60) |
| 46 | | { |
| 47 | | vg230.rtc.seconds=00; |
| 48 | | vg230.rtc.minutes+=1; |
| 49 | | if (vg230.rtc.minutes>=60) { |
| 50 | | vg230.rtc.minutes=0; |
| 51 | | vg230.rtc.hours+=1; |
| 52 | | if (vg230.rtc.hours>=24) { |
| 53 | | vg230.rtc.hours=0; |
| 54 | | vg230.rtc.days=(vg230.rtc.days+1)&0xfff; |
| 44 | vg230.rtc.seconds+=1; |
| 45 | if (vg230.rtc.seconds>=60) |
| 46 | { |
| 47 | vg230.rtc.seconds=00; |
| 48 | vg230.rtc.minutes+=1; |
| 49 | if (vg230.rtc.minutes>=60) |
| 50 | { |
| 51 | vg230.rtc.minutes=0; |
| 52 | vg230.rtc.hours+=1; |
| 53 | if (vg230.rtc.hours>=24) |
| 54 | { |
| 55 | vg230.rtc.hours=0; |
| 56 | vg230.rtc.days=(vg230.rtc.days+1)&0xfff; |
| 57 | } |
| 58 | } |
| 55 | 59 | } |
| 56 | | } |
| 57 | | } |
| 58 | | if (vg230.rtc.seconds==vg230.rtc.alarm_seconds |
| 59 | | && vg230.rtc.minutes==vg230.rtc.alarm_minutes |
| 60 | | && vg230.rtc.hours==vg230.rtc.alarm_hours |
| 61 | | && (vg230.rtc.days&0x1f)==vg230.rtc.alarm_hours) { |
| 62 | | // generate alarm |
| 63 | | } |
| 60 | |
| 61 | if (vg230.rtc.seconds==vg230.rtc.alarm_seconds |
| 62 | && vg230.rtc.minutes==vg230.rtc.alarm_minutes |
| 63 | && vg230.rtc.hours==vg230.rtc.alarm_hours |
| 64 | && (vg230.rtc.days&0x1f)==vg230.rtc.alarm_hours) |
| 65 | { |
| 66 | // generate alarm |
| 67 | } |
| 64 | 68 | } |
| 65 | 69 | |
| 66 | 70 | static void vg230_reset(running_machine *machine) |
| 67 | 71 | { |
| 68 | | mame_system_time systime; |
| 72 | mame_system_time systime; |
| 69 | 73 | |
| 70 | | memset(&vg230, 0, sizeof(vg230)); |
| 71 | | vg230.pmu.write_protected=TRUE; |
| 72 | | timer_pulse(ATTOTIME_IN_HZ(1), NULL, 0, vg230_timer); |
| 74 | memset(&vg230, 0, sizeof(vg230)); |
| 75 | vg230.pmu.write_protected=TRUE; |
| 76 | timer_pulse(ATTOTIME_IN_HZ(1), NULL, 0, vg230_timer); |
| 73 | 77 | |
| 74 | 78 | |
| 75 | | mame_get_base_datetime(machine, &systime); |
| 79 | mame_get_base_datetime(machine, &systime); |
| 76 | 80 | |
| 77 | | vg230.rtc.seconds= systime.local_time.second; |
| 78 | | vg230.rtc.minutes= systime.local_time.minute; |
| 79 | | vg230.rtc.hours = systime.local_time.hour; |
| 80 | | vg230.rtc.days = 0; |
| 81 | vg230.rtc.seconds= systime.local_time.second; |
| 82 | vg230.rtc.minutes= systime.local_time.minute; |
| 83 | vg230.rtc.hours = systime.local_time.hour; |
| 84 | vg230.rtc.days = 0; |
| 81 | 85 | |
| 82 | | vg230.bios_timer.data=0x7200; // HACK |
| 86 | vg230.bios_timer.data=0x7200; // HACK |
| 83 | 87 | } |
| 84 | 88 | |
| 85 | 89 | static void vg230_init(running_machine *machine) |
| 86 | 90 | { |
| 87 | | vg230_reset(machine); |
| 91 | vg230_reset(machine); |
| 88 | 92 | } |
| 89 | 93 | |
| 90 | 94 | |
| 91 | 95 | static READ8_HANDLER( vg230_io_r ) |
| 92 | 96 | { |
| 93 | | int log=TRUE; |
| 94 | | UINT8 data=0; |
| 95 | | vg230.bios_timer.data+=0x100; //HACK |
| 96 | | if (offset&1) { |
| 97 | | data=vg230.data[vg230.index]; |
| 98 | | switch (vg230.index) { |
| 99 | | case 0x09: break; |
| 100 | | case 0x0a: |
| 101 | | if (vg230.data[9]&1) { |
| 102 | | data=input_port_read(machine, "JOY"); |
| 103 | | } else { |
| 104 | | data=0xff; |
| 105 | | } |
| 106 | | break; |
| 107 | | case 0x30: |
| 108 | | data=vg230.bios_timer.data&0xff; |
| 109 | | break; |
| 110 | | case 0x31: |
| 111 | | data=vg230.bios_timer.data>>8; |
| 112 | | log=FALSE; |
| 113 | | break; |
| 114 | | case 0x70: data=vg230.rtc.seconds; log=FALSE; break; |
| 115 | | case 0x71: data=vg230.rtc.minutes; log=FALSE; break; |
| 116 | | case 0x72: data=vg230.rtc.hours; log=FALSE; break; |
| 117 | | case 0x73: data=vg230.rtc.days; break; |
| 118 | | case 0x74: data=vg230.rtc.days>>8; break; |
| 119 | | case 0x79: /*rtc status*/log=FALSE; break; |
| 120 | | case 0x7a: |
| 121 | | data&=~3; |
| 122 | | if (vg230.rtc.alarm_interrupt_request) data|=1<<1; |
| 123 | | if (vg230.rtc.onehertz_interrupt_request) data|=1<<0; |
| 124 | | break; |
| 125 | | case 0xc1: |
| 126 | | data&=~1; |
| 127 | | if (vg230.pmu.write_protected) data|=1; |
| 128 | | vg230.pmu.write_protected=FALSE; |
| 129 | | log=FALSE; |
| 130 | | break; |
| 131 | | } |
| 132 | | if (log) |
| 133 | | logerror("%.5x vg230 %02x read %.2x\n",(int)activecpu_get_pc(),vg230.index,data); |
| 97 | int log=TRUE; |
| 98 | UINT8 data=0; |
| 99 | vg230.bios_timer.data+=0x100; //HACK |
| 100 | if (offset&1) |
| 101 | { |
| 102 | data=vg230.data[vg230.index]; |
| 103 | switch (vg230.index) |
| 104 | { |
| 105 | case 0x09: break; |
| 106 | case 0x0a: |
| 107 | if (vg230.data[9]&1) |
| 108 | { |
| 109 | data=input_port_read(space->machine, "JOY"); |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | data=0xff; |
| 114 | } |
| 115 | break; |
| 116 | |
| 117 | case 0x30: |
| 118 | data=vg230.bios_timer.data&0xff; |
| 119 | break; |
| 120 | |
| 121 | case 0x31: |
| 122 | data=vg230.bios_timer.data>>8; |
| 123 | log=FALSE; |
| 124 | break; |
| 125 | |
| 126 | case 0x70: data=vg230.rtc.seconds; log=FALSE; break; |
| 127 | case 0x71: data=vg230.rtc.minutes; log=FALSE; break; |
| 128 | case 0x72: data=vg230.rtc.hours; log=FALSE; break; |
| 129 | case 0x73: data=vg230.rtc.days; break; |
| 130 | case 0x74: data=vg230.rtc.days>>8; break; |
| 131 | case 0x79: /*rtc status*/log=FALSE; break; |
| 132 | case 0x7a: |
| 133 | data&=~3; |
| 134 | if (vg230.rtc.alarm_interrupt_request) data|=1<<1; |
| 135 | if (vg230.rtc.onehertz_interrupt_request) data|=1<<0; |
| 136 | break; |
| 137 | |
| 138 | case 0xc1: |
| 139 | data&=~1; |
| 140 | if (vg230.pmu.write_protected) data|=1; |
| 141 | vg230.pmu.write_protected=FALSE; |
| 142 | log=FALSE; |
| 143 | break; |
| 144 | } |
| 145 | |
| 146 | if (log) |
| 147 | logerror("%.5x vg230 %02x read %.2x\n",(int) cpu_get_pc(space->cpu),vg230.index,data); |
| 134 | 148 | // data=memory_region(machine, "main")[0x4000+offset]; |
| 135 | | } else { |
| 136 | | data=vg230.index; |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | data=vg230.index; |
| 137 | 153 | } |
| 138 | | return data; |
| 154 | return data; |
| 139 | 155 | } |
| 140 | 156 | |
| 141 | 157 | static WRITE8_HANDLER( vg230_io_w ) |
| 142 | 158 | { |
| 143 | | int log=TRUE; |
| 144 | | if (offset&1) { |
| 145 | | // memory_region(machine, "main")[0x4000+offset]=data; |
| 146 | | vg230.data[vg230.index]=data; |
| 147 | | switch (vg230.index) { |
| 148 | | case 0x09: break; |
| 149 | | case 0x70: vg230.rtc.seconds=data&0x3f; break; |
| 150 | | case 0x71: vg230.rtc.minutes=data&0x3f; break; |
| 151 | | case 0x72: vg230.rtc.hours=data&0x1f;break; |
| 152 | | case 0x73: vg230.rtc.days=(vg230.rtc.days&~0xff)|data; break; |
| 153 | | case 0x74: vg230.rtc.days=(vg230.rtc.days&0xff)|((data&0xf)<<8); break; |
| 154 | | case 0x75: vg230.rtc.alarm_seconds=data&0x3f; break; |
| 155 | | case 0x76: vg230.rtc.alarm_minutes=data&0x3f; break; |
| 156 | | case 0x77: vg230.rtc.alarm_hours=data&0x1f; break; |
| 157 | | case 0x78: vg230.rtc.days=data&0x1f; break; |
| 158 | | case 0x79: |
| 159 | | vg230.rtc.onehertz_interrupt_on=data&1; |
| 160 | | vg230.rtc.alarm_interrupt_on=data&2; |
| 161 | | log=FALSE; |
| 162 | | break; |
| 163 | | case 0x7a: |
| 164 | | if (data&2) { vg230.rtc.alarm_interrupt_request=FALSE; vg230.rtc.onehertz_interrupt_request=FALSE; /* update interrupt */ } |
| 165 | | break; |
| 166 | | } |
| 167 | | if (log) |
| 168 | | logerror("%.5x vg230 %02x write %.2x\n",(int)activecpu_get_pc(),vg230.index,data); |
| 169 | | } else { |
| 170 | | vg230.index=data; |
| 171 | | } |
| 159 | int log=TRUE; |
| 160 | if (offset&1) |
| 161 | { |
| 162 | // memory_region(machine, "main")[0x4000+offset]=data; |
| 163 | vg230.data[vg230.index]=data; |
| 164 | switch (vg230.index) |
| 165 | { |
| 166 | case 0x09: break; |
| 167 | case 0x70: vg230.rtc.seconds=data&0x3f; break; |
| 168 | case 0x71: vg230.rtc.minutes=data&0x3f; break; |
| 169 | case 0x72: vg230.rtc.hours=data&0x1f;break; |
| 170 | case 0x73: vg230.rtc.days=(vg230.rtc.days&~0xff)|data; break; |
| 171 | case 0x74: vg230.rtc.days=(vg230.rtc.days&0xff)|((data&0xf)<<8); break; |
| 172 | case 0x75: vg230.rtc.alarm_seconds=data&0x3f; break; |
| 173 | case 0x76: vg230.rtc.alarm_minutes=data&0x3f; break; |
| 174 | case 0x77: vg230.rtc.alarm_hours=data&0x1f; break; |
| 175 | case 0x78: vg230.rtc.days=data&0x1f; break; |
| 176 | case 0x79: |
| 177 | vg230.rtc.onehertz_interrupt_on=data&1; |
| 178 | vg230.rtc.alarm_interrupt_on=data&2; |
| 179 | log=FALSE; |
| 180 | break; |
| 181 | |
| 182 | case 0x7a: |
| 183 | if (data&2) |
| 184 | { |
| 185 | vg230.rtc.alarm_interrupt_request=FALSE; vg230.rtc.onehertz_interrupt_request=FALSE; /* update interrupt */ |
| 186 | } |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | if (log) |
| 191 | logerror("%.5x vg230 %02x write %.2x\n",(int)cpu_get_pc(space->cpu),vg230.index,data); |
| 192 | } |
| 193 | else |
| 194 | { |
| 195 | vg230.index=data; |
| 196 | } |
| 172 | 197 | } |
| 173 | 198 | |
| 174 | 199 | static struct { |
| 175 | | UINT8 data; |
| 176 | | int index; |
| 177 | | struct { |
| 178 | | UINT8 data[2]; |
| 179 | | int address; |
| 180 | | int type; |
| 181 | | int on; |
| 182 | | } mapper[26]; |
| 200 | UINT8 data; |
| 201 | int index; |
| 202 | struct { |
| 203 | UINT8 data[2]; |
| 204 | int address; |
| 205 | int type; |
| 206 | int on; |
| 207 | } mapper[26]; |
| 183 | 208 | } ems/*?*/; |
| 184 | 209 | |
| 185 | 210 | static READ8_HANDLER( ems_r ) |
| 186 | 211 | { |
| 187 | | UINT8 data=0; |
| 188 | | switch (offset) { |
| 189 | | case 0: data=ems.data; break; |
| 190 | | case 2: case 3: data=ems.mapper[ems.index].data[offset&1]; break; |
| 191 | | } |
| 192 | | return data; |
| 212 | UINT8 data=0; |
| 213 | switch (offset) |
| 214 | { |
| 215 | case 0: data=ems.data; break; |
| 216 | case 2: case 3: data=ems.mapper[ems.index].data[offset&1]; break; |
| 217 | } |
| 218 | return data; |
| 193 | 219 | } |
| 194 | 220 | |
| 195 | 221 | static WRITE8_HANDLER( ems_w ) |
| 196 | 222 | { |
| 197 | | switch (offset) { |
| 198 | | case 0: |
| 199 | | ems.data=data; |
| 200 | | switch (data&~3) { |
| 201 | | case 0x80: ems.index=0; break; |
| 202 | | case 0x84: ems.index=1; break; |
| 203 | | case 0x88: ems.index=2; break; |
| 204 | | case 0x8c: ems.index=3; break; |
| 205 | | case 0x90: ems.index=4; break; |
| 206 | | case 0x94: ems.index=5; break; |
| 207 | | case 0x98: ems.index=6; break; |
| 208 | | case 0x9c: ems.index=7; break; |
| 209 | | case 0xa0: ems.index=8; break; |
| 210 | | case 0xa4: ems.index=9; break; |
| 211 | | case 0xa8: ems.index=10; break; |
| 212 | | case 0xac: ems.index=11; break; |
| 213 | | case 0xb0: ems.index=12; break; |
| 214 | | case 0xb4: ems.index=13; break; |
| 223 | switch (offset) |
| 224 | { |
| 225 | case 0: |
| 226 | ems.data=data; |
| 227 | switch (data&~3) |
| 228 | { |
| 229 | case 0x80: ems.index=0; break; |
| 230 | case 0x84: ems.index=1; break; |
| 231 | case 0x88: ems.index=2; break; |
| 232 | case 0x8c: ems.index=3; break; |
| 233 | case 0x90: ems.index=4; break; |
| 234 | case 0x94: ems.index=5; break; |
| 235 | case 0x98: ems.index=6; break; |
| 236 | case 0x9c: ems.index=7; break; |
| 237 | case 0xa0: ems.index=8; break; |
| 238 | case 0xa4: ems.index=9; break; |
| 239 | case 0xa8: ems.index=10; break; |
| 240 | case 0xac: ems.index=11; break; |
| 241 | case 0xb0: ems.index=12; break; |
| 242 | case 0xb4: ems.index=13; break; |
| 215 | 243 | // case 0xb8: ems.index=14; break; |
| 216 | 244 | // case 0xbc: ems.index=15; break; |
| 217 | | case 0xc0: ems.index=14; break; |
| 218 | | case 0xc4: ems.index=15; break; |
| 219 | | case 0xc8: ems.index=16; break; |
| 220 | | case 0xcc: ems.index=17; break; |
| 221 | | case 0xd0: ems.index=18; break; |
| 222 | | case 0xd4: ems.index=19; break; |
| 223 | | case 0xd8: ems.index=20; break; |
| 224 | | case 0xdc: ems.index=21; break; |
| 225 | | case 0xe0: ems.index=22; break; |
| 226 | | case 0xe4: ems.index=23; break; |
| 227 | | case 0xe8: ems.index=24; break; |
| 228 | | case 0xec: ems.index=25; break; |
| 229 | | } |
| 230 | | break; |
| 231 | | case 2: |
| 232 | | case 3: |
| 233 | | ems.mapper[ems.index].data[offset&1]=data; |
| 234 | | ems.mapper[ems.index].address=(ems.mapper[ems.index].data[0]<<14)|((ems.mapper[ems.index].data[1]&0xf)<<22); |
| 235 | | ems.mapper[ems.index].on=ems.mapper[ems.index].data[1]&0x80; |
| 236 | | ems.mapper[ems.index].type=(ems.mapper[ems.index].data[1]&0x70)>>4; |
| 237 | | logerror("%.5x ems mapper %d(%05x)on:%d type:%d address:%07x\n",(int)activecpu_get_pc(),ems.index, ems.data<<12, |
| 238 | | ems.mapper[ems.index].on, ems.mapper[ems.index].type, ems.mapper[ems.index].address ); |
| 239 | | switch (ems.mapper[ems.index].type) { |
| 240 | | case 0: /*external*/ |
| 241 | | case 1: /*ram*/ |
| 242 | | memory_set_bankptr( ems.index+1, memory_region(machine, "main") + (ems.mapper[ems.index].address&0xfffff) ); |
| 243 | | break; |
| 244 | | case 3: /* rom 1 */ |
| 245 | | case 4: /* pc card a */ |
| 246 | | case 5: /* pc card b */ |
| 247 | | default: |
| 248 | | break; |
| 249 | | case 2: |
| 250 | | memory_set_bankptr( ems.index+1, memory_region(machine, "user1") + (ems.mapper[ems.index].address&0xfffff) ); |
| 251 | | break; |
| 252 | | } |
| 253 | | break; |
| 254 | | } |
| 245 | case 0xc0: ems.index=14; break; |
| 246 | case 0xc4: ems.index=15; break; |
| 247 | case 0xc8: ems.index=16; break; |
| 248 | case 0xcc: ems.index=17; break; |
| 249 | case 0xd0: ems.index=18; break; |
| 250 | case 0xd4: ems.index=19; break; |
| 251 | case 0xd8: ems.index=20; break; |
| 252 | case 0xdc: ems.index=21; break; |
| 253 | case 0xe0: ems.index=22; break; |
| 254 | case 0xe4: ems.index=23; break; |
| 255 | case 0xe8: ems.index=24; break; |
| 256 | case 0xec: ems.index=25; break; |
| 257 | } |
| 258 | break; |
| 259 | |
| 260 | case 2: |
| 261 | case 3: |
| 262 | ems.mapper[ems.index].data[offset&1]=data; |
| 263 | ems.mapper[ems.index].address=(ems.mapper[ems.index].data[0]<<14)|((ems.mapper[ems.index].data[1]&0xf)<<22); |
| 264 | ems.mapper[ems.index].on=ems.mapper[ems.index].data[1]&0x80; |
| 265 | ems.mapper[ems.index].type=(ems.mapper[ems.index].data[1]&0x70)>>4; |
| 266 | logerror("%.5x ems mapper %d(%05x)on:%d type:%d address:%07x\n",(int)cpu_get_pc(space->cpu),ems.index, ems.data<<12, |
| 267 | ems.mapper[ems.index].on, ems.mapper[ems.index].type, ems.mapper[ems.index].address ); |
| 268 | switch (ems.mapper[ems.index].type) |
| 269 | { |
| 270 | case 0: /*external*/ |
| 271 | case 1: /*ram*/ |
| 272 | memory_set_bankptr( space->machine, ems.index+1, memory_region(space->machine, "main") + (ems.mapper[ems.index].address&0xfffff) ); |
| 273 | break; |
| 274 | case 3: /* rom 1 */ |
| 275 | case 4: /* pc card a */ |
| 276 | case 5: /* pc card b */ |
| 277 | default: |
| 278 | break; |
| 279 | case 2: |
| 280 | memory_set_bankptr( space->machine, ems.index+1, memory_region(space->machine, "user1") + (ems.mapper[ems.index].address&0xfffff) ); |
| 281 | break; |
| 282 | } |
| 283 | break; |
| 284 | } |
| 255 | 285 | } |
| 256 | 286 | |
| 257 | 287 | static ADDRESS_MAP_START( pasogo_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 258 | | // AM_RANGE(0x00000, 0xfffff) AM_UNMAP AM_MASK(0xfffff) |
| 259 | | // AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w) |
| 288 | // AM_RANGE(0x00000, 0xfffff) AM_UNMAP AM_MASK(0xfffff) |
| 289 | // AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w) |
| 260 | 290 | ADDRESS_MAP_GLOBAL_MASK(0xffFFF) |
| 261 | | AM_RANGE(0x00000, 0x7ffff) AM_RAM |
| 262 | | AM_RANGE(0x80000, 0x83fff) AM_RAMBANK(1) |
| 263 | | AM_RANGE(0x84000, 0x87fff) AM_RAMBANK(2) |
| 264 | | AM_RANGE(0x88000, 0x8bfff) AM_RAMBANK(3) |
| 265 | | AM_RANGE(0x8c000, 0x8ffff) AM_RAMBANK(4) |
| 266 | | AM_RANGE(0x90000, 0x93fff) AM_RAMBANK(5) |
| 267 | | AM_RANGE(0x94000, 0x97fff) AM_RAMBANK(6) |
| 268 | | AM_RANGE(0x98000, 0x9bfff) AM_RAMBANK(7) |
| 269 | | AM_RANGE(0x9c000, 0x9ffff) AM_RAMBANK(8) |
| 270 | | AM_RANGE(0xa0000, 0xa3fff) AM_RAMBANK(9) |
| 271 | | AM_RANGE(0xa4000, 0xa7fff) AM_RAMBANK(10) |
| 272 | | AM_RANGE(0xa8000, 0xabfff) AM_RAMBANK(11) |
| 273 | | AM_RANGE(0xac000, 0xaffff) AM_RAMBANK(12) |
| 274 | | AM_RANGE(0xb0000, 0xb3fff) AM_RAMBANK(13) |
| 275 | | AM_RANGE(0xb4000, 0xb7fff) AM_RAMBANK(14) |
| 276 | | //AM_RANGE(0xb8000, 0xbffff) AM_RAM |
| 277 | | AM_RANGE(0xb8000, 0xbffff) AM_RAMBANK(28) |
| 278 | | AM_RANGE(0xc0000, 0xc3fff) AM_RAMBANK(15) |
| 279 | | AM_RANGE(0xc4000, 0xc7fff) AM_RAMBANK(16) |
| 280 | | AM_RANGE(0xc8000, 0xcbfff) AM_RAMBANK(17) |
| 281 | | AM_RANGE(0xcc000, 0xcffff) AM_RAMBANK(18) |
| 282 | | AM_RANGE(0xd0000, 0xd3fff) AM_RAMBANK(19) |
| 283 | | AM_RANGE(0xd4000, 0xd7fff) AM_RAMBANK(20) |
| 284 | | AM_RANGE(0xd8000, 0xdbfff) AM_RAMBANK(21) |
| 285 | | AM_RANGE(0xdc000, 0xdffff) AM_RAMBANK(22) |
| 286 | | AM_RANGE(0xe0000, 0xe3fff) AM_RAMBANK(23) |
| 287 | | AM_RANGE(0xe4000, 0xe7fff) AM_RAMBANK(24) |
| 288 | | AM_RANGE(0xe8000, 0xebfff) AM_RAMBANK(25) |
| 289 | | AM_RANGE(0xec000, 0xeffff) AM_RAMBANK(26) |
| 291 | AM_RANGE(0x00000, 0x7ffff) AM_RAM |
| 292 | AM_RANGE(0x80000, 0x83fff) AM_RAMBANK(1) |
| 293 | AM_RANGE(0x84000, 0x87fff) AM_RAMBANK(2) |
| 294 | AM_RANGE(0x88000, 0x8bfff) AM_RAMBANK(3) |
| 295 | AM_RANGE(0x8c000, 0x8ffff) AM_RAMBANK(4) |
| 296 | AM_RANGE(0x90000, 0x93fff) AM_RAMBANK(5) |
| 297 | AM_RANGE(0x94000, 0x97fff) AM_RAMBANK(6) |
| 298 | AM_RANGE(0x98000, 0x9bfff) AM_RAMBANK(7) |
| 299 | AM_RANGE(0x9c000, 0x9ffff) AM_RAMBANK(8) |
| 300 | AM_RANGE(0xa0000, 0xa3fff) AM_RAMBANK(9) |
| 301 | AM_RANGE(0xa4000, 0xa7fff) AM_RAMBANK(10) |
| 302 | AM_RANGE(0xa8000, 0xabfff) AM_RAMBANK(11) |
| 303 | AM_RANGE(0xac000, 0xaffff) AM_RAMBANK(12) |
| 304 | AM_RANGE(0xb0000, 0xb3fff) AM_RAMBANK(13) |
| 305 | AM_RANGE(0xb4000, 0xb7fff) AM_RAMBANK(14) |
| 306 | // AM_RANGE(0xb8000, 0xbffff) AM_RAM |
| 307 | AM_RANGE(0xb8000, 0xbffff) AM_RAMBANK(28) |
| 308 | AM_RANGE(0xc0000, 0xc3fff) AM_RAMBANK(15) |
| 309 | AM_RANGE(0xc4000, 0xc7fff) AM_RAMBANK(16) |
| 310 | AM_RANGE(0xc8000, 0xcbfff) AM_RAMBANK(17) |
| 311 | AM_RANGE(0xcc000, 0xcffff) AM_RAMBANK(18) |
| 312 | AM_RANGE(0xd0000, 0xd3fff) AM_RAMBANK(19) |
| 313 | AM_RANGE(0xd4000, 0xd7fff) AM_RAMBANK(20) |
| 314 | AM_RANGE(0xd8000, 0xdbfff) AM_RAMBANK(21) |
| 315 | AM_RANGE(0xdc000, 0xdffff) AM_RAMBANK(22) |
| 316 | AM_RANGE(0xe0000, 0xe3fff) AM_RAMBANK(23) |
| 317 | AM_RANGE(0xe4000, 0xe7fff) AM_RAMBANK(24) |
| 318 | AM_RANGE(0xe8000, 0xebfff) AM_RAMBANK(25) |
| 319 | AM_RANGE(0xec000, 0xeffff) AM_RAMBANK(26) |
| 290 | 320 | |
| 291 | | AM_RANGE(0xf0000, 0xfffff) AM_ROMBANK(27) |
| 321 | AM_RANGE(0xf0000, 0xfffff) AM_ROMBANK(27) |
| 292 | 322 | ADDRESS_MAP_END |
| 293 | 323 | |
| 294 | 324 | static ADDRESS_MAP_START(pasogo_io, ADDRESS_SPACE_IO, 8) |
| 295 | 325 | // ADDRESS_MAP_GLOBAL_MASK(0xfFFF) |
| 296 | 326 | AM_RANGE(0x0020, 0x0021) AM_DEVREADWRITE(PIC8259, "pic8259", pic8259_r, pic8259_w) |
| 297 | | AM_RANGE(0x26, 0x27) AM_READWRITE(vg230_io_r, vg230_io_w ) |
| 327 | AM_RANGE(0x26, 0x27) AM_READWRITE(vg230_io_r, vg230_io_w ) |
| 298 | 328 | AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE(PIT8254, "pit8254", pit8253_r, pit8253_w) |
| 299 | | AM_RANGE(0x6c, 0x6f) AM_READWRITE(ems_r, ems_w ) |
| 329 | AM_RANGE(0x6c, 0x6f) AM_READWRITE(ems_r, ems_w ) |
| 300 | 330 | ADDRESS_MAP_END |
| 301 | 331 | |
| 302 | 332 | static INPUT_PORTS_START( pasogo ) |
| 303 | 333 | PORT_START("JOY") |
| 304 | | // PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("select") |
| 305 | | // PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("start") |
| 306 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("O") /*?*/ |
| 307 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("X") /*?*/ |
| 308 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) |
| 309 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) |
| 310 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) |
| 311 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) |
| 312 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("a") PORT_CODE(KEYCODE_A) |
| 313 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("b") PORT_CODE(KEYCODE_B) |
| 334 | // PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("select") |
| 335 | // PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("start") |
| 336 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("O") /*?*/ |
| 337 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("X") /*?*/ |
| 338 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) |
| 339 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) |
| 340 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) |
| 341 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) |
| 342 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("a") PORT_CODE(KEYCODE_A) |
| 343 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("b") PORT_CODE(KEYCODE_B) |
| 314 | 344 | INPUT_PORTS_END |
| 315 | 345 | |
| 316 | 346 | /* palette in red, green, blue tribles */ |
| 317 | 347 | static unsigned char pasogo_palette[][3] = |
| 318 | 348 | { |
| 319 | | { 0, 0, 0 }, |
| 320 | | { 45,45,43 }, |
| 321 | | { 130, 159, 166 }, |
| 322 | | { 255,255,255 } |
| 349 | { 0, 0, 0 }, |
| 350 | { 45,45,43 }, |
| 351 | { 130, 159, 166 }, |
| 352 | { 255,255,255 } |
| 323 | 353 | }; |
| 324 | 354 | |
| 325 | 355 | static PALETTE_INIT( pasogo ) |
| 326 | 356 | { |
| 327 | 357 | int i; |
| 328 | 358 | |
| 329 | | for ( i = 0; i < ARRAY_LENGTH(pasogo_palette); i++ ) { |
| 359 | for ( i = 0; i < ARRAY_LENGTH(pasogo_palette); i++ ) |
| 360 | { |
| 330 | 361 | palette_set_color_rgb(machine, i, pasogo_palette[i][0], pasogo_palette[i][1], pasogo_palette[i][2]); |
| 331 | 362 | } |
| 332 | 363 | } |
| 333 | 364 | |
| 334 | 365 | static VIDEO_UPDATE( pasogo ) |
| 335 | 366 | { |
| 336 | | static int width=-1, height=-1; |
| 337 | | UINT8 *rom = memory_region(screen->machine, "main")+0xb8000; |
| 338 | | UINT16 c[]={ 3, 0 }; |
| 339 | | int x,y; |
| 340 | | // plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0); |
| 341 | | int w=640; |
| 342 | | int h=240; |
| 343 | | if (0) { |
| 344 | | w=320; |
| 345 | | h=240; |
| 346 | | for (y=0;y<h; y++) { |
| 347 | | for (x=0;x<w;x+=4) { |
| 348 | | int a=(y&1)*0x2000; |
| 349 | | UINT8 d=rom[a+(y&~1)*80/2+x/4]; |
| 350 | | UINT16 *line=BITMAP_ADDR16(bitmap, y, x); |
| 351 | | *line++=(d>>6)&3; |
| 352 | | *line++=(d>>4)&3; |
| 353 | | *line++=(d>>2)&3; |
| 354 | | *line++=(d>>0)&3; |
| 367 | static int width=-1, height=-1; |
| 368 | UINT8 *rom = memory_region(screen->machine, "main")+0xb8000; |
| 369 | UINT16 c[]={ 3, 0 }; |
| 370 | int x,y; |
| 371 | // plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0); |
| 372 | int w=640; |
| 373 | int h=240; |
| 374 | if (0) |
| 375 | { |
| 376 | w=320; |
| 377 | h=240; |
| 378 | for (y=0;y<h; y++) |
| 379 | { |
| 380 | for (x=0;x<w;x+=4) |
| 381 | { |
| 382 | int a=(y&1)*0x2000; |
| 383 | UINT8 d=rom[a+(y&~1)*80/2+x/4]; |
| 384 | UINT16 *line=BITMAP_ADDR16(bitmap, y, x); |
| 385 | *line++=(d>>6)&3; |
| 386 | *line++=(d>>4)&3; |
| 387 | *line++=(d>>2)&3; |
| 388 | *line++=(d>>0)&3; |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | for (y=0;y<h; y++) |
| 395 | { |
| 396 | for (x=0;x<w;x+=8) |
| 397 | { |
| 398 | int a=(y&3)*0x2000; |
| 399 | UINT8 d=rom[a+(y&~3)*80/4+x/8]; |
| 400 | UINT16 *line=BITMAP_ADDR16(bitmap, y, x); |
| 401 | *line++=c[(d>>7)&1]; |
| 402 | *line++=c[(d>>6)&1]; |
| 403 | *line++=c[(d>>5)&1]; |
| 404 | *line++=c[(d>>4)&1]; |
| 405 | *line++=c[(d>>3)&1]; |
| 406 | *line++=c[(d>>2)&1]; |
| 407 | *line++=c[(d>>1)&1]; |
| 408 | *line++=c[(d>>0)&1]; |
| 409 | } |
| 410 | } |
| 355 | 411 | } |
| 356 | | } |
| 357 | | } else { |
| 358 | | for (y=0;y<h; y++) { |
| 359 | | for (x=0;x<w;x+=8) { |
| 360 | | int a=(y&3)*0x2000; |
| 361 | | UINT8 d=rom[a+(y&~3)*80/4+x/8]; |
| 362 | | UINT16 *line=BITMAP_ADDR16(bitmap, y, x); |
| 363 | | *line++=c[(d>>7)&1]; |
| 364 | | *line++=c[(d>>6)&1]; |
| 365 | | *line++=c[(d>>5)&1]; |
| 366 | | *line++=c[(d>>4)&1]; |
| 367 | | *line++=c[(d>>3)&1]; |
| 368 | | *line++=c[(d>>2)&1]; |
| 369 | | *line++=c[(d>>1)&1]; |
| 370 | | *line++=c[(d>>0)&1]; |
| 412 | if (w!=width || h!=height) |
| 413 | { |
| 414 | width=w; height=h; |
| 415 | // video_screen_set_visarea(machine->primary_screen, 0, width-1, 0, height-1); |
| 416 | video_screen_set_visarea(screen, 0, width-1, 0, height-1); |
| 371 | 417 | } |
| 372 | | } |
| 373 | | } |
| 374 | | if (w!=width || h!=height) { |
| 375 | | width=w; height=h; |
| 376 | | // video_screen_set_visarea(machine->primary_screen, 0, width-1, 0, height-1); |
| 377 | | video_screen_set_visarea(screen, 0, width-1, 0, height-1); |
| 378 | | } |
| 379 | | return 0; |
| 418 | return 0; |
| 380 | 419 | } |
| 381 | 420 | |
| 382 | 421 | static INTERRUPT_GEN( pasogo_interrupt ) |
| 383 | 422 | { |
| 384 | | // cpu_set_input_line(machine->cpu[0], UPD7810_INTFE1, PULSE_LINE); |
| 423 | // cpu_set_input_line(machine->cpu[0], UPD7810_INTFE1, PULSE_LINE); |
| 385 | 424 | } |
| 386 | 425 | |
| 387 | 426 | #if 0 |
| r3668 | r3669 | |
| 393 | 432 | |
| 394 | 433 | static IRQ_CALLBACK(pasogo_irq_callback) |
| 395 | 434 | { |
| 396 | | return pic8259_acknowledge( (device_config*)device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259")); |
| 435 | return pic8259_acknowledge( (device_config*)device_list_find_by_tag( device->machine->config->devicelist, PIC8259, "pic8259")); |
| 397 | 436 | } |
| 398 | 437 | |
| 399 | 438 | static MACHINE_RESET( pasogo ) |
| 400 | 439 | { |
| 401 | | cpunum_set_irq_callback(0, pasogo_irq_callback); |
| 440 | cpu_set_irq_callback(machine->cpu[0], pasogo_irq_callback); |
| 402 | 441 | } |
| 403 | 442 | |
| 404 | 443 | //static const unsigned i86_address_mask = 0x000fffff; |
| r3668 | r3669 | |
| 425 | 464 | }; |
| 426 | 465 | |
| 427 | 466 | |
| 428 | | static PIC8259_SET_INT_LINE( pasogo_pic8259_set_int_line ) { |
| 467 | static PIC8259_SET_INT_LINE( pasogo_pic8259_set_int_line ) |
| 468 | { |
| 429 | 469 | cpu_set_input_line(device->machine->cpu[0], 0, interrupt ? HOLD_LINE : CLEAR_LINE); |
| 430 | 470 | } |
| 431 | 471 | |
| r3668 | r3669 | |
| 436 | 476 | |
| 437 | 477 | |
| 438 | 478 | static MACHINE_DRIVER_START( pasogo ) |
| 439 | | MDRV_CPU_ADD("main", I80188/*V30HL in vadem vg230*/, 10000000/*?*/) |
| 440 | | MDRV_CPU_PROGRAM_MAP(pasogo_mem, 0) |
| 441 | | MDRV_CPU_IO_MAP( pasogo_io, 0 ) |
| 442 | | MDRV_CPU_VBLANK_INT("main", pasogo_interrupt) |
| 479 | MDRV_CPU_ADD("main", I80188/*V30HL in vadem vg230*/, 10000000/*?*/) |
| 480 | MDRV_CPU_PROGRAM_MAP(pasogo_mem, 0) |
| 481 | MDRV_CPU_IO_MAP( pasogo_io, 0 ) |
| 482 | MDRV_CPU_VBLANK_INT("main", pasogo_interrupt) |
| 443 | 483 | // MDRV_CPU_CONFIG(i86_address_mask) |
| 444 | 484 | MDRV_MACHINE_RESET( pasogo ) |
| 445 | 485 | |
| r3668 | r3669 | |
| 449 | 489 | MDRV_DEVICE_ADD( "pic8259", PIC8259 ) |
| 450 | 490 | MDRV_DEVICE_CONFIG( pasogo_pic8259_config ) |
| 451 | 491 | |
| 452 | | MDRV_SCREEN_ADD("main", LCD) |
| 453 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 454 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 455 | | MDRV_SCREEN_SIZE(640, 400) |
| 456 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1) |
| 457 | | MDRV_PALETTE_LENGTH(ARRAY_LENGTH(pasogo_palette)) |
| 458 | | MDRV_VIDEO_UPDATE(pasogo) |
| 459 | | MDRV_PALETTE_INIT(pasogo) |
| 492 | MDRV_SCREEN_ADD("main", LCD) |
| 493 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 494 | MDRV_SCREEN_REFRESH_RATE(60) |
| 495 | MDRV_SCREEN_SIZE(640, 400) |
| 496 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1) |
| 497 | MDRV_PALETTE_LENGTH(ARRAY_LENGTH(pasogo_palette)) |
| 498 | MDRV_VIDEO_UPDATE(pasogo) |
| 499 | MDRV_PALETTE_INIT(pasogo) |
| 460 | 500 | #if 0 |
| 461 | | MDRV_SPEAKER_STANDARD_MONO("gmaster") |
| 462 | | MDRV_SOUND_ADD("custom", CUSTOM, 0) |
| 463 | | MDRV_SOUND_CONFIG(gmaster_sound_interface) |
| 464 | | MDRV_SOUND_ROUTE(0, "gmaster", 0.50) |
| 501 | MDRV_SPEAKER_STANDARD_MONO("gmaster") |
| 502 | MDRV_SOUND_ADD("custom", CUSTOM, 0) |
| 503 | MDRV_SOUND_CONFIG(gmaster_sound_interface) |
| 504 | MDRV_SOUND_ROUTE(0, "gmaster", 0.50) |
| 465 | 505 | #endif |
| 466 | 506 | MACHINE_DRIVER_END |
| 467 | 507 | |
| 468 | 508 | |
| 469 | 509 | ROM_START(pasogo) |
| 470 | | ROM_REGION(0x100000,"main", ROMREGION_ERASEFF) // 1 megabyte dram? |
| 471 | | // ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) ) |
| 472 | | // ROM_CART_LOAD(0, "bin", 0x8000, 0x8000, 0) |
| 510 | ROM_REGION(0x100000,"main", ROMREGION_ERASEFF) // 1 megabyte dram? |
| 511 | // ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) ) |
| 512 | // ROM_CART_LOAD(0, "bin", 0x8000, 0x8000, 0) |
| 473 | 513 | ROM_REGION(0x100000,"user1", ROMREGION_ERASEFF) |
| 474 | 514 | ROM_END |
| 475 | 515 | |
| r3668 | r3669 | |
| 478 | 518 | { |
| 479 | 519 | vg230_init(machine); |
| 480 | 520 | memset(&ems, 0, sizeof(ems)); |
| 481 | | memory_set_bankptr( 27, memory_region(machine, "user1") + 0x00000 ); |
| 482 | | memory_set_bankptr( 28, memory_region(machine, "main") + 0xb8000/*?*/ ); |
| 521 | memory_set_bankptr( machine, 27, memory_region(machine, "user1") + 0x00000 ); |
| 522 | memory_set_bankptr( machine, 28, memory_region(machine, "main") + 0xb8000/*?*/ ); |
| 483 | 523 | } |
| 484 | 524 | |
| 485 | 525 | |