src/mess/machine/matsucd.c
| r3923 | r3924 | |
| 47 | 47 | UINT16 xfer_offset; |
| 48 | 48 | UINT8 sector_buffer[CD_MAX_SECTOR_DATA]; |
| 49 | 49 | UINT8 cdda_set; |
| 50 | | void (*sten_cb)( int level ); /* Status enabled callback */ |
| 51 | | void (*stch_cb)( int level ); /* Status changed callback */ |
| 52 | | void (*scor_cb)( int level ); /* Subcode ready callback */ |
| 50 | void (*sten_cb)( running_machine *machine, int level ); /* Status enabled callback */ |
| 51 | void (*stch_cb)( running_machine *machine, int level ); /* Status changed callback */ |
| 52 | void (*scor_cb)( running_machine *machine, int level ); /* Subcode ready callback */ |
| 53 | 53 | cdrom_file *cdrom; |
| 54 | 54 | emu_timer *frame_timer; |
| 55 | 55 | } matsucd; |
| r3923 | r3924 | |
| 72 | 72 | cd.stch_signal = 1; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | | void matsucd_set_status_enabled_callback( void (*sten_cb)( int level ) ) |
| 75 | void matsucd_set_status_enabled_callback( void (*sten_cb)( running_machine *machine, int level ) ) |
| 76 | 76 | { |
| 77 | 77 | /* add the callback for status enabled signal */ |
| 78 | 78 | cd.sten_cb = sten_cb; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | | void matsucd_set_status_changed_callback( void (*stch_cb)( int level ) ) |
| 81 | void matsucd_set_status_changed_callback( void (*stch_cb)( running_machine *machine, int level ) ) |
| 82 | 82 | { |
| 83 | 83 | /* add the callback for status changed signal */ |
| 84 | 84 | cd.stch_cb = stch_cb; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | | void matsucd_set_subcode_ready_callback( void (*scor_cb)( int level ) ) |
| 87 | void matsucd_set_subcode_ready_callback( void (*scor_cb)( running_machine *machine, int level ) ) |
| 88 | 88 | { |
| 89 | 89 | /* add the callback for subcode ready signal */ |
| 90 | 90 | cd.scor_cb = scor_cb; |
| r3923 | r3924 | |
| 227 | 227 | return cd.scor_signal ? 0 : 1; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | | static void update_status_enable( int level ) |
| 230 | static void update_status_enable( running_machine *machine, int level ) |
| 231 | 231 | { |
| 232 | 232 | cd.sten_signal = level; |
| 233 | 233 | |
| 234 | 234 | if ( cd.sten_cb ) |
| 235 | 235 | { |
| 236 | | (*cd.sten_cb)(cd.sten_signal); |
| 236 | (*cd.sten_cb)(machine, cd.sten_signal); |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | | static void update_status_changed( int level ) |
| 240 | static void update_status_changed( running_machine *machine, int level ) |
| 241 | 241 | { |
| 242 | 242 | cd.stch_signal = level; |
| 243 | 243 | |
| 244 | 244 | if ( cd.stch_cb ) |
| 245 | 245 | { |
| 246 | | (*cd.stch_cb)(cd.stch_signal); |
| 246 | (*cd.stch_cb)(machine, cd.stch_signal); |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | | static void update_subcode_ready( int level ) |
| 250 | static void update_subcode_ready( running_machine *machine, int level ) |
| 251 | 251 | { |
| 252 | 252 | cd.scor_signal = level; |
| 253 | 253 | |
| 254 | 254 | if ( cd.scor_cb ) |
| 255 | 255 | { |
| 256 | | (*cd.scor_cb)(cd.scor_signal); |
| 256 | (*cd.scor_cb)(machine, cd.scor_signal); |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | static TIMER_CALLBACK(matsucd_set_status_end) |
| 261 | 261 | { |
| 262 | | update_status_changed( 1 ); |
| 262 | update_status_changed( machine, 1 ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | static void matsucd_set_status( running_machine *machine, UINT8 status ) |
| r3923 | r3924 | |
| 270 | 270 | |
| 271 | 271 | if ( cd.stch_signal != 0 ) |
| 272 | 272 | { |
| 273 | | update_status_changed( 0 ); |
| 273 | update_status_changed( machine, 0 ); |
| 274 | 274 | timer_set(machine, ATTOTIME_IN_MSEC(1), NULL, 0, matsucd_set_status_end ); |
| 275 | 275 | } |
| 276 | 276 | } |
| r3923 | r3924 | |
| 291 | 291 | { |
| 292 | 292 | if ( s == 0x11 ) |
| 293 | 293 | { |
| 294 | | update_subcode_ready( 1 ); |
| 295 | | update_subcode_ready( 0 ); |
| 294 | update_subcode_ready( machine, 1 ); |
| 295 | update_subcode_ready( machine, 0 ); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | newstatus |= MATSU_STATUS_PLAYING; |
| r3923 | r3924 | |
| 331 | 331 | |
| 332 | 332 | matsucd_set_status( machine, newstatus ); |
| 333 | 333 | |
| 334 | | update_status_enable( 1 ); |
| 335 | | update_status_enable( 0 ); |
| 334 | update_status_enable( machine, 1 ); |
| 335 | update_status_enable( machine, 0 ); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | | UINT8 matsucd_response_r( void ) |
| 338 | UINT8 matsucd_response_r( running_machine *machine ) |
| 339 | 339 | { |
| 340 | 340 | UINT8 v = cd.output[cd.output_pos++]; |
| 341 | 341 | |
| 342 | 342 | if ( cd.output_pos < cd.output_len ) |
| 343 | 343 | { |
| 344 | | update_status_enable( 1 ); |
| 345 | | update_status_enable( 0 ); |
| 344 | update_status_enable( machine, 1 ); |
| 345 | update_status_enable( machine, 0 ); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | return v; |
src/mess/machine/matsucd.h
| r3923 | r3924 | |
| 16 | 16 | extern int matsucd_scor_r( void ); /* /SCOR pin */ |
| 17 | 17 | |
| 18 | 18 | /* callback for signal changes */ |
| 19 | | extern void matsucd_set_status_enabled_callback( void (*sten_cb)( int level ) ); |
| 20 | | extern void matsucd_set_status_changed_callback( void (*stch_cb)( int level ) ); |
| 21 | | extern void matsucd_set_subcode_ready_callback( void (*scor_cb)( int level ) ); |
| 19 | extern void matsucd_set_status_enabled_callback( void (*sten_cb)( running_machine *machine, int level ) ); |
| 20 | extern void matsucd_set_status_changed_callback( void (*stch_cb)( running_machine *machine, int level ) ); |
| 21 | extern void matsucd_set_subcode_ready_callback( void (*scor_cb)( running_machine *machine, int level ) ); |
| 22 | 22 | |
| 23 | 23 | /* data transfer routines */ |
| 24 | 24 | extern void matsucd_read_next_block( void ); |
| r3923 | r3924 | |
| 26 | 26 | |
| 27 | 27 | /* main command interface */ |
| 28 | 28 | extern void matsucd_command_w( running_machine *machine, UINT8 data ); |
| 29 | | extern UINT8 matsucd_response_r( void ); |
| 29 | extern UINT8 matsucd_response_r( running_machine *machine ); |
src/mess/machine/amigacrt.c
| r3923 | r3924 | |
| 33 | 33 | |
| 34 | 34 | ***************************************************************************/ |
| 35 | 35 | |
| 36 | | static int check_kickstart_12_13( const char *cart_name ) |
| 36 | static int check_kickstart_12_13( running_machine *machine, const char *cart_name ) |
| 37 | 37 | { |
| 38 | | UINT16 * ksmem = (UINT16 *)memory_region( Machine, "user1" ); |
| 38 | UINT16 * ksmem = (UINT16 *)memory_region( machine, "user1" ); |
| 39 | 39 | |
| 40 | 40 | if ( ksmem[2] == 0x00FC ) |
| 41 | 41 | return 1; |
| r3923 | r3924 | |
| 136 | 136 | void *ar_ram; |
| 137 | 137 | |
| 138 | 138 | /* check kickstart version */ |
| 139 | | if ( !check_kickstart_12_13( "Amiga Action Replay" ) ) |
| 139 | if ( !check_kickstart_12_13( machine, "Amiga Action Replay" ) ) |
| 140 | 140 | { |
| 141 | 141 | amiga_cart_type = -1; |
| 142 | 142 | return; |
| r3923 | r3924 | |
| 344 | 344 | void *ar_ram; |
| 345 | 345 | |
| 346 | 346 | /* check kickstart version */ |
| 347 | | if ( !check_kickstart_12_13( "Action Replay MKII or MKIII" ) ) |
| 347 | if ( !check_kickstart_12_13( machine, "Action Replay MKII or MKIII" ) ) |
| 348 | 348 | { |
| 349 | 349 | amiga_cart_type = -1; |
| 350 | 350 | return; |
| r3923 | r3924 | |
| 441 | 441 | |
| 442 | 442 | void amiga_cart_nmi( void ) |
| 443 | 443 | { |
| 444 | running_machine *machine = Machine; |
| 444 | 445 | if ( amiga_cart_type < 0 ) |
| 445 | 446 | return; |
| 446 | 447 | |
| 447 | 448 | switch( amiga_cart_type ) |
| 448 | 449 | { |
| 449 | 450 | case ACTION_REPLAY: |
| 450 | | amiga_ar1_nmi(Machine); |
| 451 | amiga_ar1_nmi(machine); |
| 451 | 452 | break; |
| 452 | 453 | |
| 453 | 454 | case ACTION_REPLAY_MKII: |
| 454 | 455 | case ACTION_REPLAY_MKIII: |
| 455 | | amiga_ar23_nmi(Machine); |
| 456 | amiga_ar23_nmi(machine); |
| 456 | 457 | break; |
| 457 | 458 | } |
| 458 | 459 | } |
src/mess/machine/amigacd.c
| r3923 | r3924 | |
| 184 | 184 | case 0x50: |
| 185 | 185 | { |
| 186 | 186 | LOG(( "DMAC: PC=%08x - CDROM RESP Read\n", cpu_get_pc(space->cpu) )); |
| 187 | | return matsucd_response_r(); |
| 187 | return matsucd_response_r(space->machine); |
| 188 | 188 | } |
| 189 | 189 | break; |
| 190 | 190 | |
| r3923 | r3924 | |
| 387 | 387 | |
| 388 | 388 | static void dmac_install(offs_t base) |
| 389 | 389 | { |
| 390 | | memory_install_read16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, base + 0xFFFF, 0, 0, amiga_dmac_r); |
| 391 | | memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, base + 0xFFFF, 0, 0, amiga_dmac_w); |
| 390 | const address_space *space = cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 391 | memory_install_read16_handler(space, base, base + 0xFFFF, 0, 0, amiga_dmac_r); |
| 392 | memory_install_write16_handler(space, base, base + 0xFFFF, 0, 0, amiga_dmac_w); |
| 392 | 393 | } |
| 393 | 394 | |
| 394 | 395 | static void dmac_uninstall(offs_t base) |
| 395 | 396 | { |
| 396 | | memory_install_read16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, base + 0xFFFF, 0, 0, SMH_UNMAP); |
| 397 | | memory_install_write16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), base, base + 0xFFFF, 0, 0, SMH_UNMAP); |
| 397 | const address_space *space = cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 398 | memory_install_read16_handler(space, base, base + 0xFFFF, 0, 0, SMH_UNMAP); |
| 399 | memory_install_write16_handler(space, base, base + 0xFFFF, 0, 0, SMH_UNMAP); |
| 398 | 400 | } |
| 399 | 401 | |
| 400 | 402 | static const amiga_autoconfig_device dmac_device = |
| r3923 | r3924 | |
| 479 | 481 | } |
| 480 | 482 | } |
| 481 | 483 | |
| 482 | | static void cdrom_status_enabled( int level ) |
| 484 | static void cdrom_status_enabled( running_machine *machine, int level ) |
| 483 | 485 | { |
| 484 | 486 | /* PC3 on the 6525 */ |
| 485 | | tpi6525_0_irq3_level( Machine, level ); |
| 487 | tpi6525_0_irq3_level( machine, level ); |
| 486 | 488 | } |
| 487 | 489 | |
| 488 | | static void cdrom_status_change( int level ) |
| 490 | static void cdrom_status_change( running_machine *machine, int level ) |
| 489 | 491 | { |
| 490 | 492 | /* invert */ |
| 491 | 493 | level = level ? 0 : 1; |
| 492 | 494 | |
| 493 | 495 | /* PC2 on the 6525 */ |
| 494 | | tpi6525_0_irq2_level( Machine, level ); |
| 496 | tpi6525_0_irq2_level( machine, level ); |
| 495 | 497 | } |
| 496 | 498 | |
| 497 | | static void cdrom_subcode_ready( int level ) |
| 499 | static void cdrom_subcode_ready( running_machine *machine, int level ) |
| 498 | 500 | { |
| 499 | 501 | /* PC1 on the 6525 */ |
| 500 | | tpi6525_0_irq1_level( Machine, level ); |
| 502 | tpi6525_0_irq1_level( machine, level ); |
| 501 | 503 | } |
| 502 | 504 | |
| 503 | 505 | MACHINE_START( amigacd ) |
src/mess/drivers/amiga.c
| r3923 | r3924 | |
| 412 | 412 | |
| 413 | 413 | static UINT16 amiga_read_joy0dat(void) |
| 414 | 414 | { |
| 415 | | if ( input_port_read(Machine, "input") & 0x20 ) { |
| 415 | running_machine *machine = Machine; |
| 416 | if ( input_port_read(machine, "input") & 0x20 ) { |
| 416 | 417 | /* Joystick */ |
| 417 | | return input_port_read_safe(Machine, "JOY0DAT", 0xffff); |
| 418 | return input_port_read_safe(machine, "JOY0DAT", 0xffff); |
| 418 | 419 | } else { |
| 419 | 420 | /* Mouse */ |
| 420 | 421 | int input; |
| 421 | | input = ( input_port_read(Machine, "P0MOUSEX") & 0xff ); |
| 422 | | input |= ( input_port_read(Machine, "P0MOUSEY") & 0xff ) << 8; |
| 422 | input = ( input_port_read(machine, "P0MOUSEX") & 0xff ); |
| 423 | input |= ( input_port_read(machine, "P0MOUSEY") & 0xff ) << 8; |
| 423 | 424 | return input; |
| 424 | 425 | } |
| 425 | 426 | } |
| 426 | 427 | |
| 427 | 428 | static UINT16 amiga_read_joy1dat(void) |
| 428 | 429 | { |
| 429 | | if ( input_port_read(Machine, "input") & 0x10 ) { |
| 430 | running_machine *machine = Machine; |
| 431 | if ( input_port_read(machine, "input") & 0x10 ) { |
| 430 | 432 | /* Joystick */ |
| 431 | | return input_port_read_safe(Machine, "JOY1DAT", 0xffff); |
| 433 | return input_port_read_safe(machine, "JOY1DAT", 0xffff); |
| 432 | 434 | } else { |
| 433 | 435 | /* Mouse */ |
| 434 | 436 | int input; |
| 435 | | input = ( input_port_read(Machine, "P1MOUSEX") & 0xff ); |
| 436 | | input |= ( input_port_read(Machine, "P1MOUSEY") & 0xff ) << 8; |
| 437 | input = ( input_port_read(machine, "P1MOUSEX") & 0xff ); |
| 438 | input |= ( input_port_read(machine, "P1MOUSEY") & 0xff ) << 8; |
| 437 | 439 | return input; |
| 438 | 440 | } |
| 439 | 441 | } |
| r3923 | r3924 | |
| 454 | 456 | |
| 455 | 457 | static void amiga_reset(void) |
| 456 | 458 | { |
| 457 | | if (input_port_read(Machine, "hardware") & 0x08) |
| 459 | running_machine *machine = Machine; |
| 460 | if (input_port_read(machine, "hardware") & 0x08) |
| 458 | 461 | { |
| 459 | 462 | /* Install RTC */ |
| 460 | | memory_install_readwrite16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xdc0000, 0xdc003f, 0, 0, amiga_clock_r, amiga_clock_w); |
| 463 | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xdc0000, 0xdc003f, 0, 0, amiga_clock_r, amiga_clock_w); |
| 461 | 464 | } |
| 462 | 465 | else |
| 463 | 466 | { |
| 464 | 467 | /* No RTC support */ |
| 465 | | memory_install_readwrite16_handler(cpu_get_address_space(Machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xdc0000, 0xdc003f, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 468 | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xdc0000, 0xdc003f, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 466 | 469 | } |
| 467 | 470 | } |
| 468 | 471 | |