src/mess/machine/gamecom.c
| r7038 | r7039 | |
| 44 | 44 | int check_value; |
| 45 | 45 | } GAMECOM_TIMER; |
| 46 | 46 | |
| 47 | typedef struct |
| 48 | { |
| 49 | UINT8 sgc; |
| 50 | UINT8 sg0l; |
| 51 | UINT8 sg1l; |
| 52 | UINT8 sg2l; |
| 53 | UINT16 sg0t; |
| 54 | UINT16 sg1t; |
| 55 | UINT16 sg2t; |
| 56 | UINT8 sgda; |
| 57 | UINT8 sg0w[16]; |
| 58 | UINT8 sg1w[16]; |
| 59 | } gamecom_sound_t; |
| 60 | |
| 47 | 61 | UINT8 gamecom_internal_registers[0x80]; |
| 48 | 62 | static UINT8 *cartridge1 = NULL; |
| 49 | 63 | static UINT8 *cartridge2 = NULL; |
| r7038 | r7039 | |
| 52 | 66 | static emu_timer *gamecom_clock_timer = NULL; |
| 53 | 67 | static GAMECOM_DMA gamecom_dma; |
| 54 | 68 | static GAMECOM_TIMER gamecom_timer[2]; |
| 69 | static gamecom_sound_t gamecom_sound; |
| 55 | 70 | |
| 56 | 71 | //static const int gamecom_timer_limit[8] = { 2/2, 1024/2, 2048/2, 4096/2, 8192/2, 16384/2, 32768/2, 65536/2 }; |
| 57 | 72 | static const int gamecom_timer_limit[8] = { 2, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }; |
| r7038 | r7039 | |
| 64 | 79 | { |
| 65 | 80 | UINT8 val = ( ( gamecom_internal_registers[SM8521_CLKT] & 0x3F ) + 1 ) & 0x3F; |
| 66 | 81 | gamecom_internal_registers[SM8521_CLKT] = ( gamecom_internal_registers[SM8521_CLKT] & 0xC0 ) | val; |
| 67 | | cputag_set_input_line(machine, "maincpu", CK_INT, HOLD_LINE ); |
| 82 | cputag_set_input_line(machine, "maincpu", CK_INT, ASSERT_LINE ); |
| 68 | 83 | } |
| 69 | 84 | |
| 70 | 85 | MACHINE_RESET( gamecom ) |
| r7038 | r7039 | |
| 342 | 357 | } |
| 343 | 358 | break; |
| 344 | 359 | |
| 360 | /* Sound */ |
| 361 | case SM8521_SGC: |
| 362 | gamecom_sound.sgc = data; |
| 363 | break; |
| 364 | case SM8521_SG0L: |
| 365 | gamecom_sound.sg0l = data; |
| 366 | break; |
| 367 | case SM8521_SG1L: |
| 368 | gamecom_sound.sg1l = data; |
| 369 | break; |
| 370 | case SM8521_SG0TH: |
| 371 | gamecom_sound.sg0t = ( gamecom_sound.sg0t & 0xFF ) | ( data << 8 ); |
| 372 | break; |
| 373 | case SM8521_SG0TL: |
| 374 | gamecom_sound.sg0t = ( gamecom_sound.sg0t & 0xFF00 ) | data; |
| 375 | break; |
| 376 | case SM8521_SG1TH: |
| 377 | gamecom_sound.sg1t = ( gamecom_sound.sg1t & 0xFF ) | ( data << 8 ); |
| 378 | break; |
| 379 | case SM8521_SG1TL: |
| 380 | gamecom_sound.sg1t = ( gamecom_sound.sg1t & 0xFF00 ) | data; |
| 381 | break; |
| 382 | case SM8521_SG2L: |
| 383 | gamecom_sound.sg2l = data; |
| 384 | break; |
| 385 | case SM8521_SG2TH: |
| 386 | gamecom_sound.sg2t = ( gamecom_sound.sg2t & 0xFF ) | ( data << 8 ); |
| 387 | break; |
| 388 | case SM8521_SG2TL: |
| 389 | gamecom_sound.sg2t = ( gamecom_sound.sg2t & 0xFF00 ) | data; |
| 390 | break; |
| 391 | case SM8521_SGDA: |
| 392 | gamecom_sound.sgda = data; |
| 393 | break; |
| 394 | |
| 395 | case SM8521_SG0W0: |
| 396 | case SM8521_SG0W1: |
| 397 | case SM8521_SG0W2: |
| 398 | case SM8521_SG0W3: |
| 399 | case SM8521_SG0W4: |
| 400 | case SM8521_SG0W5: |
| 401 | case SM8521_SG0W6: |
| 402 | case SM8521_SG0W7: |
| 403 | case SM8521_SG0W8: |
| 404 | case SM8521_SG0W9: |
| 405 | case SM8521_SG0W10: |
| 406 | case SM8521_SG0W11: |
| 407 | case SM8521_SG0W12: |
| 408 | case SM8521_SG0W13: |
| 409 | case SM8521_SG0W14: |
| 410 | case SM8521_SG0W15: |
| 411 | gamecom_sound.sg0w[offset - SM8521_SG0W0] = data; |
| 412 | break; |
| 413 | case SM8521_SG1W0: |
| 414 | case SM8521_SG1W1: |
| 415 | case SM8521_SG1W2: |
| 416 | case SM8521_SG1W3: |
| 417 | case SM8521_SG1W4: |
| 418 | case SM8521_SG1W5: |
| 419 | case SM8521_SG1W6: |
| 420 | case SM8521_SG1W7: |
| 421 | case SM8521_SG1W8: |
| 422 | case SM8521_SG1W9: |
| 423 | case SM8521_SG1W10: |
| 424 | case SM8521_SG1W11: |
| 425 | case SM8521_SG1W12: |
| 426 | case SM8521_SG1W13: |
| 427 | case SM8521_SG1W14: |
| 428 | case SM8521_SG1W15: |
| 429 | gamecom_sound.sg1w[offset - SM8521_SG1W0] = data; |
| 430 | break; |
| 431 | |
| 345 | 432 | /* Reserved addresses */ |
| 346 | 433 | case SM8521_18: case SM8521_1B: |
| 347 | 434 | case SM8521_29: case SM8521_2A: case SM8521_2F: |
| r7038 | r7039 | |
| 569 | 656 | gamecom_dma.dest_current = gamecom_dma.dest_line; |
| 570 | 657 | } |
| 571 | 658 | gamecom_dma.enabled = 0; |
| 572 | | cputag_set_input_line(device->machine, "maincpu", DMA_INT, HOLD_LINE ); |
| 659 | cputag_set_input_line(device->machine, "maincpu", DMA_INT, ASSERT_LINE ); |
| 573 | 660 | } |
| 574 | 661 | |
| 575 | 662 | void gamecom_update_timers( const device_config *device, int cycles ) |
| r7038 | r7039 | |
| 584 | 671 | if ( gamecom_timer[0].counter == gamecom_timer[0].check_value ) |
| 585 | 672 | { |
| 586 | 673 | gamecom_timer[0].counter = 0; |
| 587 | | cputag_set_input_line(device->machine, "maincpu", TIM0_INT, HOLD_LINE ); |
| 674 | cputag_set_input_line(device->machine, "maincpu", TIM0_INT, ASSERT_LINE ); |
| 588 | 675 | } |
| 589 | 676 | } |
| 590 | 677 | } |
| r7038 | r7039 | |
| 598 | 685 | if ( gamecom_timer[1].counter == gamecom_timer[1].check_value ) |
| 599 | 686 | { |
| 600 | 687 | gamecom_timer[1].counter = 0; |
| 601 | | cputag_set_input_line(device->machine, "maincpu", TIM1_INT, HOLD_LINE ); |
| 688 | cputag_set_input_line(device->machine, "maincpu", TIM1_INT, ASSERT_LINE ); |
| 602 | 689 | } |
| 603 | 690 | } |
| 604 | 691 | } |