src/mame/audio/leland.c
| r10326 | r10327 | |
| 834 | 834 | case 0x0d: state->i80186.intr.in_service &= ~0x20; break; |
| 835 | 835 | case 0x0e: state->i80186.intr.in_service &= ~0x40; break; |
| 836 | 836 | case 0x0f: state->i80186.intr.in_service &= ~0x80; break; |
| 837 | | default: logerror("%s:ERROR - 80186 EOI with unknown vector %02X\n", cpuexec_describe_context(machine), data & 0x1f); |
| 837 | default: logerror("%s:ERROR - 80186 EOI with unknown vector %02X\n", machine->describe_context(), data & 0x1f); |
| 838 | 838 | } |
| 839 | 839 | if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", machine->time().as_double(), data & 0x1f); |
| 840 | 840 | } |
| r10326 | r10327 | |
| 906 | 906 | if (t->control & 0x0001) |
| 907 | 907 | { |
| 908 | 908 | int count = t->maxA ? t->maxA : 0x10000; |
| 909 | | timer_adjust_oneshot(t->int_timer, attotime::from_hz(2000000) * count, which); |
| 909 | t->int_timer->adjust(attotime::from_hz(2000000) * count, which); |
| 910 | 910 | if (LOG_TIMER) logerror(" Repriming interrupt\n"); |
| 911 | 911 | } |
| 912 | 912 | else |
| 913 | | timer_adjust_oneshot(t->int_timer, attotime::never, which); |
| 913 | t->int_timer->adjust(attotime::never, which); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | |
| r10326 | r10327 | |
| 921 | 921 | /* if we have a timing timer running, adjust the count */ |
| 922 | 922 | if (t->time_timer_active) |
| 923 | 923 | { |
| 924 | | attotime current_time = timer_timeelapsed(t->time_timer); |
| 924 | attotime current_time = t->time_timer->elapsed(); |
| 925 | 925 | int net_clocks = ((current_time - t->last_time) * 2000000).as_double(); |
| 926 | 926 | t->last_time = current_time; |
| 927 | 927 | |
| r10326 | r10327 | |
| 1024 | 1024 | internal_timer_sync(state, which); |
| 1025 | 1025 | |
| 1026 | 1026 | /* nuke the timer and force the interrupt timer to be recomputed */ |
| 1027 | | timer_adjust_oneshot(t->time_timer, attotime::never, which); |
| 1027 | t->time_timer->adjust(attotime::never, which); |
| 1028 | 1028 | t->time_timer_active = 0; |
| 1029 | 1029 | update_int_timer = 1; |
| 1030 | 1030 | } |
| r10326 | r10327 | |
| 1033 | 1033 | else if ((diff & 0x8000) && (new_control & 0x8000)) |
| 1034 | 1034 | { |
| 1035 | 1035 | /* start the timing */ |
| 1036 | | timer_adjust_oneshot(t->time_timer, attotime::never, which); |
| 1036 | t->time_timer->adjust(attotime::never, which); |
| 1037 | 1037 | t->time_timer_active = 1; |
| 1038 | 1038 | update_int_timer = 1; |
| 1039 | 1039 | } |
| r10326 | r10327 | |
| 1062 | 1062 | { |
| 1063 | 1063 | int diff = t->maxA - t->count; |
| 1064 | 1064 | if (diff <= 0) diff += 0x10000; |
| 1065 | | timer_adjust_oneshot(t->int_timer, attotime::from_hz(2000000) * diff, which); |
| 1065 | t->int_timer->adjust(attotime::from_hz(2000000) * diff, which); |
| 1066 | 1066 | if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which); |
| 1067 | 1067 | } |
| 1068 | 1068 | else |
| 1069 | | timer_adjust_oneshot(t->int_timer, attotime::never, which); |
| 1069 | t->int_timer->adjust(attotime::never, which); |
| 1070 | 1070 | } |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| r10326 | r10327 | |
| 1153 | 1153 | if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest); |
| 1154 | 1154 | |
| 1155 | 1155 | d->finished = 0; |
| 1156 | | timer_adjust_oneshot(d->finish_timer, attotime::from_hz(state->dac[dacnum].frequency) * count, which); |
| 1156 | d->finish_timer->adjust(attotime::from_hz(state->dac[dacnum].frequency) * count, which); |
| 1157 | 1157 | } |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| r10326 | r10327 | |
| 1612 | 1612 | if (ctr->timer) |
| 1613 | 1613 | { |
| 1614 | 1614 | /* determine how many 2MHz cycles are remaining */ |
| 1615 | | int count = (timer_timeleft(ctr->timer) * 2000000).as_double(); |
| 1615 | int count = (ctr->timer->remaining() * 2000000).as_double(); |
| 1616 | 1616 | ctr->count = (count < 0) ? 0 : count; |
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| r10326 | r10327 | |
| 1696 | 1696 | if (ctr->count == 0) ctr->count = 0x10000; |
| 1697 | 1697 | |
| 1698 | 1698 | /* reset/start the timer */ |
| 1699 | | timer_adjust_oneshot(ctr->timer, attotime::never, 0); |
| 1699 | ctr->timer->adjust(attotime::never); |
| 1700 | 1700 | |
| 1701 | 1701 | if (LOG_PIT) logerror("PIT counter %d set to %d (%d Hz)\n", which, ctr->count, 4000000 / ctr->count); |
| 1702 | 1702 | |
| r10326 | r10327 | |
| 1807 | 1807 | { |
| 1808 | 1808 | device_t *device = (device_t *)ptr; |
| 1809 | 1809 | leland_sound_state *state = get_safe_token(device); |
| 1810 | | if (LOG_COMM) logerror("%s:Write sound command latch lo = %02X\n", cpuexec_describe_context(machine), param); |
| 1810 | if (LOG_COMM) logerror("%s:Write sound command latch lo = %02X\n", machine->describe_context(), param); |
| 1811 | 1811 | state->sound_command = (state->sound_command & 0xff00) | param; |
| 1812 | 1812 | } |
| 1813 | 1813 | |
src/mame/machine/leland.c
| r10326 | r10327 | |
| 372 | 372 | |
| 373 | 373 | MACHINE_RESET( leland ) |
| 374 | 374 | { |
| 375 | | timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(8), 8); |
| 375 | master_int_timer->adjust(machine->primary_screen->time_until_pos(8), 8); |
| 376 | 376 | |
| 377 | 377 | /* reset globals */ |
| 378 | 378 | leland_gfx_control = 0x00; |
| r10326 | r10327 | |
| 422 | 422 | MACHINE_RESET( ataxx ) |
| 423 | 423 | { |
| 424 | 424 | memset(extra_tram, 0, ATAXX_EXTRA_TRAM_SIZE); |
| 425 | | timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(8), 8); |
| 425 | master_int_timer->adjust(machine->primary_screen->time_until_pos(8), 8); |
| 426 | 426 | |
| 427 | 427 | /* initialize the XROM */ |
| 428 | 428 | xrom_length = machine->region("user1")->bytes(); |
| r10326 | r10327 | |
| 471 | 471 | scanline += 16; |
| 472 | 472 | if (scanline > 248) |
| 473 | 473 | scanline = 8; |
| 474 | | timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(scanline), scanline); |
| 474 | master_int_timer->adjust(machine->primary_screen->time_until_pos(scanline), scanline); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | |
| r10326 | r10327 | |
| 483 | 483 | cputag_set_input_line(machine, "master", 0, HOLD_LINE); |
| 484 | 484 | |
| 485 | 485 | /* set a timer for the next one */ |
| 486 | | timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(scanline), scanline); |
| 486 | master_int_timer->adjust(machine->primary_screen->time_until_pos(scanline), scanline); |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
| r10326 | r10327 | |
| 598 | 598 | address = &master_base[bank_list[alternate_bank & 3]]; |
| 599 | 599 | if (bank_list[alternate_bank & 3] >= master_length) |
| 600 | 600 | { |
| 601 | | logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 3); |
| 601 | logerror("%s:Master bank %02X out of range!\n", machine->describe_context(), alternate_bank & 3); |
| 602 | 602 | address = &master_base[bank_list[0]]; |
| 603 | 603 | } |
| 604 | 604 | memory_set_bankptr(machine, "bank1", address); |
| r10326 | r10327 | |
| 619 | 619 | address = &master_base[bank_list[alternate_bank & 7]]; |
| 620 | 620 | if (bank_list[alternate_bank & 7] >= master_length) |
| 621 | 621 | { |
| 622 | | logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), alternate_bank & 7); |
| 622 | logerror("%s:Master bank %02X out of range!\n", machine->describe_context(), alternate_bank & 7); |
| 623 | 623 | address = &master_base[bank_list[0]]; |
| 624 | 624 | } |
| 625 | 625 | memory_set_bankptr(machine, "bank1", address); |
| r10326 | r10327 | |
| 644 | 644 | address = &master_base[bank_list[master_bank & 15]]; |
| 645 | 645 | if (bank_list[master_bank & 15] >= master_length) |
| 646 | 646 | { |
| 647 | | logerror("%s:Master bank %02X out of range!\n", cpuexec_describe_context(machine), master_bank & 15); |
| 647 | logerror("%s:Master bank %02X out of range!\n", machine->describe_context(), master_bank & 15); |
| 648 | 648 | address = &master_base[bank_list[0]]; |
| 649 | 649 | } |
| 650 | 650 | memory_set_bankptr(machine, "bank1", address); |
| r10326 | r10327 | |
| 856 | 856 | READ8_DEVICE_HANDLER( ataxx_eeprom_r ) |
| 857 | 857 | { |
| 858 | 858 | int port = input_port_read(device->machine, "IN2"); |
| 859 | | if (LOG_EEPROM) logerror("%s:EE read\n", cpuexec_describe_context(device->machine)); |
| 859 | if (LOG_EEPROM) logerror("%s:EE read\n", device->machine->describe_context()); |
| 860 | 860 | return port; |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | |
| 864 | 864 | WRITE8_DEVICE_HANDLER( ataxx_eeprom_w ) |
| 865 | 865 | { |
| 866 | | if (LOG_EEPROM) logerror("%s:EE write %d%d%d\n", cpuexec_describe_context(device->machine), |
| 866 | if (LOG_EEPROM) logerror("%s:EE write %d%d%d\n", device->machine->describe_context(), |
| 867 | 867 | (data >> 6) & 1, (data >> 5) & 1, (data >> 4) & 1); |
| 868 | 868 | eeprom_write_bit (device, (data & 0x10) >> 4); |
| 869 | 869 | eeprom_set_clock_line(device, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE); |
| r10326 | r10327 | |
| 957 | 957 | { |
| 958 | 958 | int result = 0; |
| 959 | 959 | |
| 960 | | if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_r)\n", cpuexec_describe_context(machine)); |
| 960 | if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_r)\n", machine->describe_context()); |
| 961 | 961 | |
| 962 | 962 | /* if we have a valid keycard read state, we're reading from the keycard */ |
| 963 | 963 | if (keycard_state & 0x80) |
| r10326 | r10327 | |
| 981 | 981 | int new_state = data & 0xb0; |
| 982 | 982 | int new_clock = data & 0x40; |
| 983 | 983 | |
| 984 | | if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_w=%02X)\n", cpuexec_describe_context(machine), data); |
| 984 | if (LOG_KEYCARDS_FULL) logerror(" (%s:keycard_w=%02X)\n", machine->describe_context(), data); |
| 985 | 985 | |
| 986 | 986 | /* check for going active */ |
| 987 | 987 | if (!keycard_state && new_state) |
| r10326 | r10327 | |
| 1244 | 1244 | break; |
| 1245 | 1245 | |
| 1246 | 1246 | case 0x08: /* */ |
| 1247 | | timer_adjust_oneshot(master_int_timer, space->machine->primary_screen->time_until_pos(data + 1), data + 1); |
| 1247 | master_int_timer->adjust(space->machine->primary_screen->time_until_pos(data + 1), data + 1); |
| 1248 | 1248 | break; |
| 1249 | 1249 | |
| 1250 | 1250 | default: |
| r10326 | r10327 | |
| 1353 | 1353 | /* some bankswitching occurs here */ |
| 1354 | 1354 | if (LOG_BANKSWITCHING_M) |
| 1355 | 1355 | if ((sound_port_bank ^ data) & 0x24) |
| 1356 | | logerror("%s:sound_port_bank = %02X\n", cpuexec_describe_context(device->machine), data & 0x24); |
| 1356 | logerror("%s:sound_port_bank = %02X\n", device->machine->describe_context(), data & 0x24); |
| 1357 | 1357 | sound_port_bank = data & 0x24; |
| 1358 | 1358 | (*leland_update_master_bank)(device->machine); |
| 1359 | 1359 | } |
src/mame/machine/cdicdic.c
| r10326 | r10327 | |
| 574 | 574 | if(m_decode_addr == 0xffff) |
| 575 | 575 | { |
| 576 | 576 | verboselog(&m_machine, 0, "Decode stop requested, stopping playback\n" ); |
| 577 | | timer_adjust_oneshot(m_audio_sample_timer, attotime::never, 0); |
| 577 | m_audio_sample_timer->adjust(attotime::never); |
| 578 | 578 | return; |
| 579 | 579 | } |
| 580 | 580 | |
| r10326 | r10327 | |
| 609 | 609 | //// Delay for Frequency * (18*28*2*size in bytes) before requesting more data |
| 610 | 610 | verboselog(&m_machine, 0, "Data is valid, setting up a new callback\n" ); |
| 611 | 611 | m_decode_period = attotime::from_hz(CDIC_SAMPLE_BUF_FREQ(m_ram, m_decode_addr & 0x3ffe)) * (18*28*2*CDIC_SAMPLE_BUF_SIZE(m_ram, m_decode_addr & 0x3ffe)); |
| 612 | | timer_adjust_oneshot(m_audio_sample_timer, m_decode_period, 0); |
| 612 | m_audio_sample_timer->adjust(m_decode_period); |
| 613 | 613 | //dmadac_enable(&dmadac[0], 2, 0); |
| 614 | 614 | } |
| 615 | 615 | else |
| r10326 | r10327 | |
| 619 | 619 | |
| 620 | 620 | verboselog(&m_machine, 0, "Data is not valid, indicating to shut down on the next audio sample\n" ); |
| 621 | 621 | m_decode_addr = 0xffff; |
| 622 | | timer_adjust_oneshot(m_audio_sample_timer, m_decode_period, 0); |
| 622 | m_audio_sample_timer->adjust(m_decode_period); |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | |
| r10326 | r10327 | |
| 785 | 785 | |
| 786 | 786 | if((buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF) == 0 && m_command != 0x23) |
| 787 | 787 | { |
| 788 | | timer_adjust_oneshot(m_interrupt_timer, attotime::from_hz(75), 0); // 75Hz = 1x CD-ROM speed |
| 788 | m_interrupt_timer->adjust(attotime::from_hz(75)); // 75Hz = 1x CD-ROM speed |
| 789 | 789 | } |
| 790 | 790 | else |
| 791 | 791 | { |
| 792 | 792 | if(m_command == 0x23) // Mode 1 Reset |
| 793 | 793 | { |
| 794 | | timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); |
| 794 | m_interrupt_timer->adjust(attotime::never); |
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | } |
| r10326 | r10327 | |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | case 0x2e: // Abort |
| 803 | | timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); |
| 803 | m_interrupt_timer->adjust(attotime::never); |
| 804 | 804 | //m_data_buffer &= ~4; |
| 805 | 805 | break; |
| 806 | 806 | |
| r10326 | r10327 | |
| 863 | 863 | m_time = next_msf << 8; |
| 864 | 864 | |
| 865 | 865 | // the following line BREAKS 'The Apprentice', hangs when you attempt to start the game |
| 866 | | //timer_adjust_oneshot(m_interrupt_timer, attotime::from_hz(75), 0); |
| 866 | //m_interrupt_timer->adjust(attotime::from_hz(75)); |
| 867 | 867 | |
| 868 | 868 | m_x_buffer |= 0x8000; |
| 869 | 869 | //m_data_buffer |= 0x4000; |
| r10326 | r10327 | |
| 896 | 896 | }; |
| 897 | 897 | lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60); |
| 898 | 898 | |
| 899 | | timer_adjust_oneshot(m_interrupt_timer, attotime::from_hz(75), 0); |
| 899 | m_interrupt_timer->adjust(attotime::from_hz(75)); |
| 900 | 900 | |
| 901 | 901 | cdrom_read_data(m_cd, lba, buffer, CD_TRACK_RAW_DONTCARE); |
| 902 | 902 | |
| r10326 | r10327 | |
| 1001 | 1001 | |
| 1002 | 1002 | case 0x3ffa/2: // AUDCTL |
| 1003 | 1003 | { |
| 1004 | | if(timer_timeleft(m_audio_sample_timer).is_never()) |
| 1004 | if(m_audio_sample_timer->remaining().is_never()) |
| 1005 | 1005 | { |
| 1006 | 1006 | m_z_buffer ^= 0x0001; |
| 1007 | 1007 | } |
| r10326 | r10327 | |
| 1120 | 1120 | COMBINE_DATA(&m_z_buffer); |
| 1121 | 1121 | if(m_z_buffer & 0x2000) |
| 1122 | 1122 | { |
| 1123 | | attotime period = timer_timeleft(m_audio_sample_timer); |
| 1123 | attotime period = m_audio_sample_timer->remaining(); |
| 1124 | 1124 | if(period.is_never()) |
| 1125 | 1125 | { |
| 1126 | 1126 | m_decode_addr = m_z_buffer & 0x3a00; |
| 1127 | 1127 | m_decode_delay = 1; |
| 1128 | | timer_adjust_oneshot(m_audio_sample_timer, attotime::from_hz(75), 0); |
| 1128 | m_audio_sample_timer->adjust(attotime::from_hz(75)); |
| 1129 | 1129 | } |
| 1130 | 1130 | } |
| 1131 | 1131 | else |
| 1132 | 1132 | { |
| 1133 | 1133 | m_decode_addr = 0xffff; |
| 1134 | | timer_adjust_oneshot(m_audio_sample_timer, attotime::never, 0); |
| 1134 | m_audio_sample_timer->adjust(attotime::never); |
| 1135 | 1135 | } |
| 1136 | 1136 | break; |
| 1137 | 1137 | } |
| r10326 | r10327 | |
| 1150 | 1150 | //case 0x24: // Reset Mode 2 |
| 1151 | 1151 | case 0x2e: // Abort |
| 1152 | 1152 | { |
| 1153 | | timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); |
| 1153 | m_interrupt_timer->adjust(attotime::never); |
| 1154 | 1154 | dmadac_enable(&state->dmadac[0], 2, 0); |
| 1155 | 1155 | //m_data_buffer &= 0xbfff; |
| 1156 | 1156 | break; |
| 1157 | 1157 | } |
| 1158 | 1158 | case 0x2b: // Stop CDDA |
| 1159 | 1159 | cdda_stop_audio(m_machine.device("cdda")); |
| 1160 | | timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); |
| 1160 | m_interrupt_timer->adjust(attotime::never); |
| 1161 | 1161 | break; |
| 1162 | 1162 | case 0x23: // Reset Mode 1 |
| 1163 | 1163 | case 0x29: // Read Mode 1 |
| r10326 | r10327 | |
| 1165 | 1165 | case 0x28: // Play CDDA |
| 1166 | 1166 | case 0x2c: // Seek |
| 1167 | 1167 | { |
| 1168 | | attotime period = timer_timeleft(m_interrupt_timer); |
| 1168 | attotime period = m_interrupt_timer->remaining(); |
| 1169 | 1169 | if(!period.is_never()) |
| 1170 | 1170 | { |
| 1171 | | timer_adjust_oneshot(m_interrupt_timer, period, 0); |
| 1171 | m_interrupt_timer->adjust(period); |
| 1172 | 1172 | } |
| 1173 | 1173 | else |
| 1174 | 1174 | { |
| 1175 | 1175 | if(m_command != 0x23 && m_command != 0x24) |
| 1176 | 1176 | { |
| 1177 | | timer_adjust_oneshot(m_interrupt_timer, attotime::from_hz(75), 0); |
| 1177 | m_interrupt_timer->adjust(attotime::from_hz(75)); |
| 1178 | 1178 | } |
| 1179 | 1179 | } |
| 1180 | 1180 | break; |
| r10326 | r10327 | |
| 1217 | 1217 | register_globals(); |
| 1218 | 1218 | |
| 1219 | 1219 | m_interrupt_timer = m_machine.scheduler().timer_alloc(FUNC(trigger_readback_int)); |
| 1220 | | timer_adjust_oneshot(m_interrupt_timer, attotime::never, 0); |
| 1220 | m_interrupt_timer->adjust(attotime::never); |
| 1221 | 1221 | |
| 1222 | 1222 | m_audio_sample_timer = m_machine.scheduler().timer_alloc(FUNC(audio_sample_trigger)); |
| 1223 | | timer_adjust_oneshot(m_audio_sample_timer, attotime::never, 0); |
| 1223 | m_audio_sample_timer->adjust(attotime::never); |
| 1224 | 1224 | |
| 1225 | 1225 | m_ram = auto_alloc_array(&m_machine, UINT16, 0x3c00/2); |
| 1226 | 1226 | } |
src/mame/machine/stvcd.c
| r10326 | r10327 | |
| 377 | 377 | |
| 378 | 378 | hirqreg = rv; |
| 379 | 379 | |
| 380 | | // CDROM_LOG(("%s:RW HIRQ: %04x\n", cpuexec_describe_context(Machine), rv)) |
| 380 | // CDROM_LOG(("%s:RW HIRQ: %04x\n", Machine->describe_context(), rv)) |
| 381 | 381 | |
| 382 | 382 | return rv; |
| 383 | 383 | |
| r10326 | r10327 | |
| 443 | 443 | return rv; |
| 444 | 444 | |
| 445 | 445 | default: |
| 446 | | CDROM_LOG(("%s:CD: RW %08x\n", cpuexec_describe_context(machine), addr)) |
| 446 | CDROM_LOG(("%s:CD: RW %08x\n", machine->describe_context(), addr)) |
| 447 | 447 | return 0xffff; |
| 448 | 448 | } |
| 449 | 449 | |
| r10326 | r10327 | |
| 517 | 517 | return rv; |
| 518 | 518 | |
| 519 | 519 | default: |
| 520 | | CDROM_LOG(("%s:CD: RL %08x\n", cpuexec_describe_context(machine), addr)) |
| 520 | CDROM_LOG(("%s:CD: RL %08x\n", machine->describe_context(), addr)) |
| 521 | 521 | return 0xffff; |
| 522 | 522 | } |
| 523 | 523 | } |
| r10326 | r10327 | |
| 530 | 530 | { |
| 531 | 531 | case 0x0008: |
| 532 | 532 | case 0x000a: |
| 533 | | // CDROM_LOG(("%s:WW HIRQ: %04x & %04x => %04x\n", cpuexec_describe_context(machine), hirqreg, data, hirqreg & data)) |
| 533 | // CDROM_LOG(("%s:WW HIRQ: %04x & %04x => %04x\n", machine->describe_context(), hirqreg, data, hirqreg & data)) |
| 534 | 534 | hirqreg &= data; |
| 535 | 535 | return; |
| 536 | 536 | case 0x000c: |
| r10326 | r10327 | |
| 573 | 573 | switch (cr1 & 0xff00) |
| 574 | 574 | { |
| 575 | 575 | case 0x0000: |
| 576 | | CDROM_LOG(("%s:CD: Get Status\n", cpuexec_describe_context(machine))) |
| 576 | CDROM_LOG(("%s:CD: Get Status\n", machine->describe_context())) |
| 577 | 577 | |
| 578 | 578 | // values taken from a US saturn with a disc in and the lid closed |
| 579 | 579 | hirqreg |= CMOK; |
| r10326 | r10327 | |
| 585 | 585 | break; |
| 586 | 586 | |
| 587 | 587 | case 0x0100: |
| 588 | | CDROM_LOG(("%s:CD: Get Hardware Info\n", cpuexec_describe_context(machine))) |
| 588 | CDROM_LOG(("%s:CD: Get Hardware Info\n", machine->describe_context())) |
| 589 | 589 | hirqreg |= CMOK; |
| 590 | 590 | cr1 = cd_stat; |
| 591 | 591 | cr2 = 0x0201; |
| r10326 | r10327 | |
| 594 | 594 | break; |
| 595 | 595 | |
| 596 | 596 | case 0x200: // Get TOC |
| 597 | | CDROM_LOG(("%s:CD: Get TOC\n", cpuexec_describe_context(machine))) |
| 597 | CDROM_LOG(("%s:CD: Get TOC\n", machine->describe_context())) |
| 598 | 598 | cd_readTOC(); |
| 599 | 599 | cd_stat = CD_STAT_TRANS|CD_STAT_PAUSE; |
| 600 | 600 | cr2 = 102*2; // TOC length in words (102 entries @ 2 words/4bytes each) |
| r10326 | r10327 | |
| 608 | 608 | // bios is interested in returns in cr3 and cr4 |
| 609 | 609 | // cr3 should be data track # |
| 610 | 610 | // cr4 must be > 1 and < 100 or bios gets angry. |
| 611 | | CDROM_LOG(("%s:CD: Get Session Info\n", cpuexec_describe_context(machine))) |
| 611 | CDROM_LOG(("%s:CD: Get Session Info\n", machine->describe_context())) |
| 612 | 612 | cd_readTOC(); |
| 613 | 613 | switch (cr1 & 0xff) |
| 614 | 614 | { |
| r10326 | r10327 | |
| 639 | 639 | // CR1 & 4 = don't confirm mode 2 subheader |
| 640 | 640 | // CR1 & 8 = retry reading mode 2 sectors |
| 641 | 641 | // CR1 & 10 = force single-speed |
| 642 | | CDROM_LOG(("%s:CD: Initialize CD system\n", cpuexec_describe_context(machine))) |
| 642 | CDROM_LOG(("%s:CD: Initialize CD system\n", machine->describe_context())) |
| 643 | 643 | hirqreg |= (CMOK|DRDY|ESEL); |
| 644 | 644 | cd_stat = CD_STAT_PAUSE; |
| 645 | 645 | cd_curfad = 150; |
| r10326 | r10327 | |
| 653 | 653 | case 0x0600: // end data transfer |
| 654 | 654 | // returns # of bytes transfered (24 bits) in |
| 655 | 655 | // low byte of cr1 (MSB) and cr2 (middle byte, LSB) |
| 656 | | CDROM_LOG(("%s:CD: End data transfer (%d bytes xfer'd)\n", cpuexec_describe_context(machine), xferdnum)) |
| 656 | CDROM_LOG(("%s:CD: End data transfer (%d bytes xfer'd)\n", machine->describe_context(), xferdnum)) |
| 657 | 657 | |
| 658 | 658 | // clear the "transfer" flag |
| 659 | 659 | cd_stat &= ~CD_STAT_TRANS; |
| r10326 | r10327 | |
| 730 | 730 | break; |
| 731 | 731 | |
| 732 | 732 | case 0x1000: // Play Disk. FAD is in lowest 7 bits of cr1 and all of cr2. |
| 733 | | CDROM_LOG(("%s:CD: Play Disk\n", cpuexec_describe_context(machine))) |
| 733 | CDROM_LOG(("%s:CD: Play Disk\n", machine->describe_context())) |
| 734 | 734 | cd_stat = CD_STAT_PLAY; //|0x80; // set "cd-rom" bit? |
| 735 | 735 | cd_curfad = ((cr1&0xff)<<16) | cr2; |
| 736 | 736 | fadstoplay = ((cr3&0xff)<<16) | cr4; |
| r10326 | r10327 | |
| 768 | 768 | break; |
| 769 | 769 | |
| 770 | 770 | case 0x1100: // disk seek |
| 771 | | CDROM_LOG(("%s:CD: Disk seek\n", cpuexec_describe_context(machine))) |
| 771 | CDROM_LOG(("%s:CD: Disk seek\n", machine->describe_context())) |
| 772 | 772 | if (cr1 & 0x80) |
| 773 | 773 | { |
| 774 | 774 | temp = (cr1&0x7f)<<16; // get FAD to seek to |
| r10326 | r10327 | |
| 814 | 814 | // get operation |
| 815 | 815 | parm = cr3>>8; |
| 816 | 816 | |
| 817 | | CDROM_LOG(("%s:CD: Set CD Device Connection filter # %x\n", cpuexec_describe_context(machine), parm)) |
| 817 | CDROM_LOG(("%s:CD: Set CD Device Connection filter # %x\n", machine->describe_context(), parm)) |
| 818 | 818 | |
| 819 | 819 | cddevicenum = parm; |
| 820 | 820 | |
| r10326 | r10327 | |
| 840 | 840 | { |
| 841 | 841 | UINT8 fnum = (cr3>>8)&0xff; |
| 842 | 842 | |
| 843 | | CDROM_LOG(("%s:CD: Set Filter Range\n", cpuexec_describe_context(machine))) |
| 843 | CDROM_LOG(("%s:CD: Set Filter Range\n", machine->describe_context())) |
| 844 | 844 | |
| 845 | 845 | filters[fnum].fad = ((cr1 & 0xff)<<16) | cr2; |
| 846 | 846 | filters[fnum].range = ((cr3 & 0xff)<<16) | cr4; |
| r10326 | r10327 | |
| 856 | 856 | { |
| 857 | 857 | UINT8 fnum = (cr3>>8)&0xff; |
| 858 | 858 | |
| 859 | | CDROM_LOG(("%s:CD: Set Filter Subheader conditions %x => chan %x masks %x fid %x vals %x\n", cpuexec_describe_context(machine), fnum, cr1&0xff, cr2, cr3&0xff, cr4)) |
| 859 | CDROM_LOG(("%s:CD: Set Filter Subheader conditions %x => chan %x masks %x fid %x vals %x\n", machine->describe_context(), fnum, cr1&0xff, cr2, cr3&0xff, cr4)) |
| 860 | 860 | |
| 861 | 861 | filters[fnum].chan = cr1 & 0xff; |
| 862 | 862 | filters[fnum].smmask = (cr2>>8)&0xff; |
| r10326 | r10327 | |
| 887 | 887 | filters[fnum].mode = mode; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | | CDROM_LOG(("%s:CD: Set Filter Mode filt %x mode %x\n", cpuexec_describe_context(machine), fnum, mode)) |
| 890 | CDROM_LOG(("%s:CD: Set Filter Mode filt %x mode %x\n", machine->describe_context(), fnum, mode)) |
| 891 | 891 | hirqreg |= (CMOK|ESEL|DRDY); |
| 892 | 892 | cr2 = 0x4101; // ctrl/adr in hi byte, track # in low byte |
| 893 | 893 | cr3 = 0x0100|((cd_curfad>>16)&0xff); |
| r10326 | r10327 | |
| 899 | 899 | { |
| 900 | 900 | UINT8 fnum = (cr3>>8)&0xff; |
| 901 | 901 | |
| 902 | | CDROM_LOG(("%s:CD: Set Filter Connection %x => mode %x parm %04x\n", cpuexec_describe_context(machine), fnum, cr1 & 0xf, cr2)) |
| 902 | CDROM_LOG(("%s:CD: Set Filter Connection %x => mode %x parm %04x\n", machine->describe_context(), fnum, cr1 & 0xf, cr2)) |
| 903 | 903 | |
| 904 | 904 | // set true condition? |
| 905 | 905 | if (cr1 & 1) |
| r10326 | r10327 | |
| 919 | 919 | break; |
| 920 | 920 | |
| 921 | 921 | case 0x4800: // Reset Selector |
| 922 | | CDROM_LOG(("%s:CD: Reset Selector\n", cpuexec_describe_context(machine))) |
| 922 | CDROM_LOG(("%s:CD: Reset Selector\n", machine->describe_context())) |
| 923 | 923 | hirqreg |= (CMOK|ESEL|DRDY); |
| 924 | 924 | cr2 = 0x4101; // ctrl/adr in hi byte, track # in low byte |
| 925 | 925 | cr3 = 0x0100|((cd_curfad>>16)&0xff); |
| r10326 | r10327 | |
| 933 | 933 | |
| 934 | 934 | cr3 = 0x1800; |
| 935 | 935 | cr4 = 200; |
| 936 | | CDROM_LOG(("%s:CD: Get Buffer Size = %d\n", cr2, cpuexec_describe_context(machine))) |
| 936 | CDROM_LOG(("%s:CD: Get Buffer Size = %d\n", cr2, machine->describe_context())) |
| 937 | 937 | hirqreg |= (CMOK|ESEL|DRDY); // DRDY is probably wrong |
| 938 | 938 | break; |
| 939 | 939 | |
| r10326 | r10327 | |
| 951 | 951 | cr4 = partitions[bufnum].numblks; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | | CDROM_LOG(("%s:CD: Get Sector Number (bufno %d) = %d blocks\n", cpuexec_describe_context(machine), bufnum, cr4)) |
| 954 | CDROM_LOG(("%s:CD: Get Sector Number (bufno %d) = %d blocks\n", machine->describe_context(), bufnum, cr4)) |
| 955 | 955 | |
| 956 | 956 | cr2 = 0; |
| 957 | 957 | cr3 = 0; |
| r10326 | r10327 | |
| 965 | 965 | UINT32 sectoffs = cr2; |
| 966 | 966 | UINT32 numsect = cr4; |
| 967 | 967 | |
| 968 | | CDROM_LOG(("%s:CD: Calculate actual size: buf %x offs %x numsect %x\n", cpuexec_describe_context(machine), bufnum, sectoffs, numsect)) |
| 968 | CDROM_LOG(("%s:CD: Calculate actual size: buf %x offs %x numsect %x\n", machine->describe_context(), bufnum, sectoffs, numsect)) |
| 969 | 969 | |
| 970 | 970 | calcsize = 0; |
| 971 | 971 | if (partitions[bufnum].size != -1) |
| r10326 | r10327 | |
| 990 | 990 | break; |
| 991 | 991 | |
| 992 | 992 | case 0x5300: // get actual block size |
| 993 | | CDROM_LOG(("%s:CD: Get actual block size\n", cpuexec_describe_context(machine))) |
| 993 | CDROM_LOG(("%s:CD: Get actual block size\n", machine->describe_context())) |
| 994 | 994 | hirqreg |= (CMOK|ESEL); |
| 995 | 995 | cr1 = cd_stat | ((calcsize>>16)&0xff); |
| 996 | 996 | cr2 = (calcsize & 0xffff); |
| r10326 | r10327 | |
| 999 | 999 | break; |
| 1000 | 1000 | |
| 1001 | 1001 | case 0x6000: // set sector length |
| 1002 | | CDROM_LOG(("%s:CD: Set sector length\n", cpuexec_describe_context(machine))) |
| 1002 | CDROM_LOG(("%s:CD: Set sector length\n", machine->describe_context())) |
| 1003 | 1003 | hirqreg |= (CMOK|ESEL|EFLS|SCDQ|DRDY); |
| 1004 | 1004 | |
| 1005 | 1005 | switch (cr1 & 0xff) |
| r10326 | r10327 | |
| 1041 | 1041 | UINT32 sectofs = cr2; |
| 1042 | 1042 | UINT32 bufnum = cr3>>8; |
| 1043 | 1043 | |
| 1044 | | CDROM_LOG(("%s:CD: Get sector data (SN %d SO %d BN %d)\n", cpuexec_describe_context(machine), sectnum, sectofs, bufnum)) |
| 1044 | CDROM_LOG(("%s:CD: Get sector data (SN %d SO %d BN %d)\n", machine->describe_context(), sectnum, sectofs, bufnum)) |
| 1045 | 1045 | |
| 1046 | 1046 | if (bufnum >= MAX_FILTERS) |
| 1047 | 1047 | { |
| r10326 | r10327 | |
| 1081 | 1081 | UINT32 bufnum = cr3>>8; |
| 1082 | 1082 | INT32 i; |
| 1083 | 1083 | |
| 1084 | | CDROM_LOG(("%s:CD: Delete sector data (SN %d SO %d BN %d)\n", cpuexec_describe_context(machine), sectnum, sectofs, bufnum)) |
| 1084 | CDROM_LOG(("%s:CD: Delete sector data (SN %d SO %d BN %d)\n", machine->describe_context(), sectnum, sectofs, bufnum)) |
| 1085 | 1085 | |
| 1086 | 1086 | if (bufnum >= MAX_FILTERS) |
| 1087 | 1087 | { |
| r10326 | r10327 | |
| 1124 | 1124 | UINT32 sectofs = cr2; |
| 1125 | 1125 | UINT32 bufnum = cr3>>8; |
| 1126 | 1126 | |
| 1127 | | CDROM_LOG(("%s:CD: Get and delete sector data (SN %d SO %d BN %d)\n", cpuexec_describe_context(machine), sectnum, sectofs, bufnum)) |
| 1127 | CDROM_LOG(("%s:CD: Get and delete sector data (SN %d SO %d BN %d)\n", machine->describe_context(), sectnum, sectofs, bufnum)) |
| 1128 | 1128 | |
| 1129 | 1129 | if (bufnum >= MAX_FILTERS) |
| 1130 | 1130 | { |
| r10326 | r10327 | |
| 1158 | 1158 | break; |
| 1159 | 1159 | |
| 1160 | 1160 | case 0x6700: // get copy error |
| 1161 | | CDROM_LOG(("%s:CD: Get copy error\n", cpuexec_describe_context(machine))) |
| 1161 | CDROM_LOG(("%s:CD: Get copy error\n", machine->describe_context())) |
| 1162 | 1162 | hirqreg |= (CMOK|ESEL|EFLS|SCDQ|DRDY); |
| 1163 | 1163 | break; |
| 1164 | 1164 | |
| 1165 | 1165 | case 0x7000: // change directory |
| 1166 | | CDROM_LOG(("%s:CD: Change Directory\n", cpuexec_describe_context(machine))) |
| 1166 | CDROM_LOG(("%s:CD: Change Directory\n", machine->describe_context())) |
| 1167 | 1167 | hirqreg |= (CMOK|EFLS); |
| 1168 | 1168 | |
| 1169 | 1169 | temp = (cr3&0xff)<<16; |
| r10326 | r10327 | |
| 1172 | 1172 | break; |
| 1173 | 1173 | |
| 1174 | 1174 | case 0x7100: // Read directory entry |
| 1175 | | CDROM_LOG(("%s:CD: Read Directory Entry\n", cpuexec_describe_context(machine))) |
| 1175 | CDROM_LOG(("%s:CD: Read Directory Entry\n", machine->describe_context())) |
| 1176 | 1176 | hirqreg |= (CMOK|DRDY); |
| 1177 | 1177 | |
| 1178 | 1178 | temp = (cr3&0xff)<<16; |
| r10326 | r10327 | |
| 1183 | 1183 | break; |
| 1184 | 1184 | |
| 1185 | 1185 | case 0x7200: // Get file system scope |
| 1186 | | CDROM_LOG(("%s:CD: Get file system scope(PC=%x)\n", cpuexec_describe_context(machine))) |
| 1186 | CDROM_LOG(("%s:CD: Get file system scope(PC=%x)\n", machine->describe_context())) |
| 1187 | 1187 | hirqreg |= (CMOK|DRDY); |
| 1188 | 1188 | cr2 = numfiles; // # of files in directory |
| 1189 | 1189 | cr3 = 0x0100; // report directory held |
| r10326 | r10327 | |
| 1191 | 1191 | break; |
| 1192 | 1192 | |
| 1193 | 1193 | case 0x7300: // Get File Info |
| 1194 | | CDROM_LOG(("%s:CD: Get File Info\n", cpuexec_describe_context(machine))) |
| 1194 | CDROM_LOG(("%s:CD: Get File Info\n", machine->describe_context())) |
| 1195 | 1195 | cd_stat |= CD_STAT_TRANS; |
| 1196 | 1196 | cd_stat &= 0xff00; // clear top byte of return value |
| 1197 | 1197 | hirqreg |= (CMOK|DRDY); |
| r10326 | r10327 | |
| 1245 | 1245 | break; |
| 1246 | 1246 | |
| 1247 | 1247 | case 0x7400: // Read File |
| 1248 | | CDROM_LOG(("%s:CD: Read File\n", cpuexec_describe_context(machine))) |
| 1248 | CDROM_LOG(("%s:CD: Read File\n", machine->describe_context())) |
| 1249 | 1249 | temp = (cr3&0xff)<<16; |
| 1250 | 1250 | temp |= cr4; |
| 1251 | 1251 | |
| r10326 | r10327 | |
| 1276 | 1276 | break; |
| 1277 | 1277 | |
| 1278 | 1278 | case 0x7500: |
| 1279 | | CDROM_LOG(("%s:CD: Abort File\n", cpuexec_describe_context(machine))) |
| 1279 | CDROM_LOG(("%s:CD: Abort File\n", machine->describe_context())) |
| 1280 | 1280 | // bios expects "2bc" mask to work against this |
| 1281 | 1281 | hirqreg |= (CMOK|EFLS|EHST|ESEL|DCHG|PEND|BFUL|CSCT|DRDY); |
| 1282 | 1282 | cd_stat = CD_STAT_PERI|CD_STAT_PAUSE; // force to pause |
| 1283 | 1283 | break; |
| 1284 | 1284 | |
| 1285 | 1285 | case 0xe000: // appears to be copy protection check. needs only to return OK. |
| 1286 | | CDROM_LOG(("%s:CD: Verify copy protection\n", cpuexec_describe_context(machine))) |
| 1286 | CDROM_LOG(("%s:CD: Verify copy protection\n", machine->describe_context())) |
| 1287 | 1287 | cd_stat = CD_STAT_PAUSE; |
| 1288 | 1288 | cr1 = cd_stat; // necessary to pass |
| 1289 | 1289 | cr2 = 0x4; |
| r10326 | r10327 | |
| 1293 | 1293 | break; |
| 1294 | 1294 | |
| 1295 | 1295 | case 0xe100: // get disc region |
| 1296 | | CDROM_LOG(("%s:CD: Get disc region\n", cpuexec_describe_context(machine))) |
| 1296 | CDROM_LOG(("%s:CD: Get disc region\n", machine->describe_context())) |
| 1297 | 1297 | cd_stat = CD_STAT_PAUSE; |
| 1298 | 1298 | cr1 = cd_stat; // necessary to pass |
| 1299 | 1299 | cr2 = 0x4; // (must return this value to pass bios checks) |
| r10326 | r10327 | |
| 1301 | 1301 | break; |
| 1302 | 1302 | |
| 1303 | 1303 | default: |
| 1304 | | CDROM_LOG(("%s:CD: Unknown command %04x\n", cr1, cpuexec_describe_context(machine))) |
| 1304 | CDROM_LOG(("%s:CD: Unknown command %04x\n", cr1, machine->describe_context())) |
| 1305 | 1305 | hirqreg |= (CMOK); |
| 1306 | 1306 | break; |
| 1307 | 1307 | } |
| 1308 | 1308 | // CDROM_LOG(("ret: %04x %04x %04x %04x %04x\n", hirqreg, cr1, cr2, cr3, cr4)) |
| 1309 | 1309 | break; |
| 1310 | 1310 | default: |
| 1311 | | CDROM_LOG(("%s:CD: WW %08x %04x\n", addr, data, cpuexec_describe_context(machine))) |
| 1311 | CDROM_LOG(("%s:CD: WW %08x %04x\n", addr, data, machine->describe_context())) |
| 1312 | 1312 | break; |
| 1313 | 1313 | } |
| 1314 | 1314 | } |
src/mame/machine/megadriv.c
| r10326 | r10327 | |
| 815 | 815 | // if (regnum == 0x0a) |
| 816 | 816 | // mame_printf_debug("Set HINT Reload Register to %d on scanline %d\n",value, genesis_scanline_counter); |
| 817 | 817 | |
| 818 | | // mame_printf_debug("%s: Setting VDP Register #%02x to %02x\n",cpuexec_describe_context(machine), regnum,value); |
| 818 | // mame_printf_debug("%s: Setting VDP Register #%02x to %02x\n",machine->describe_context(), regnum,value); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | static void update_megadrive_vdp_code_and_address(void) |
| r10326 | r10327 | |
| 1012 | 1012 | UINT16 length; |
| 1013 | 1013 | source = (MEGADRIVE_REG15_DMASOURCE1 | (MEGADRIVE_REG16_DMASOURCE2<<8) | ((MEGADRIVE_REG17_DMASOURCE3&0xff)<<16))<<1; |
| 1014 | 1014 | length = (MEGADRIVE_REG13_DMALENGTH1 | (MEGADRIVE_REG14_DMALENGTH2<<8))<<1; |
| 1015 | | // mame_printf_debug("%s 68k DMAtran set source %06x length %04x dest %04x enabled %01x code %02x %02x\n", cpuexec_describe_context(machine), source, length, megadrive_vdp_address,MEGADRIVE_REG01_DMA_ENABLE, megadrive_vdp_code,MEGADRIVE_REG0F_AUTO_INC); |
| 1015 | // mame_printf_debug("%s 68k DMAtran set source %06x length %04x dest %04x enabled %01x code %02x %02x\n", machine->describe_context(), source, length, megadrive_vdp_address,MEGADRIVE_REG01_DMA_ENABLE, megadrive_vdp_code,MEGADRIVE_REG0F_AUTO_INC); |
| 1016 | 1016 | |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| r10326 | r10327 | |
| 1622 | 1622 | } |
| 1623 | 1623 | else |
| 1624 | 1624 | { |
| 1625 | | logerror("%s: 68000 attempting to access YM2612 (read) without bus\n", cpuexec_describe_context(device->machine)); |
| 1625 | logerror("%s: 68000 attempting to access YM2612 (read) without bus\n", device->machine->describe_context()); |
| 1626 | 1626 | return 0; |
| 1627 | 1627 | } |
| 1628 | 1628 | |
| r10326 | r10327 | |
| 1640 | 1640 | } |
| 1641 | 1641 | else |
| 1642 | 1642 | { |
| 1643 | | logerror("%s: 68000 attempting to access YM2612 (write) without bus\n", cpuexec_describe_context(device->machine)); |
| 1643 | logerror("%s: 68000 attempting to access YM2612 (write) without bus\n", device->machine->describe_context()); |
| 1644 | 1644 | } |
| 1645 | 1645 | } |
| 1646 | 1646 | |
| r10326 | r10327 | |
| 1999 | 1999 | if (((megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40)) |
| 2000 | 2000 | { |
| 2001 | 2001 | io_stage[portnum]++; |
| 2002 | | timer_adjust_oneshot(io_timeout[portnum], machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192), 0); |
| 2002 | io_timeout[portnum]->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192)); |
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | 2005 | } |
| r10326 | r10327 | |
| 3019 | 3019 | |
| 3020 | 3020 | /* if both RMD and LMD are set to OFF or pwm cycle register is one, then PWM timer ticks doesn't occur */ |
| 3021 | 3021 | if(pwm_cycle == 1 || ((pwm_ctrl & 0xf) == 0)) |
| 3022 | | timer_adjust_oneshot(_32x_pwm_timer, attotime::never, 0); |
| 3022 | _32x_pwm_timer->adjust(attotime::never); |
| 3023 | 3023 | else |
| 3024 | 3024 | { |
| 3025 | 3025 | pwm_timer_tick = 0; |
| 3026 | 3026 | lch_fifo_state = rch_fifo_state = 0x4000; |
| 3027 | 3027 | lch_index_r = rch_index_r = 0; |
| 3028 | 3028 | lch_index_w = rch_index_w = 0; |
| 3029 | | timer_adjust_oneshot(_32x_pwm_timer, attotime::from_hz((PWM_CLOCK) / (pwm_cycle - 1)), 0); |
| 3029 | _32x_pwm_timer->adjust(attotime::from_hz((PWM_CLOCK) / (pwm_cycle - 1))); |
| 3030 | 3030 | } |
| 3031 | 3031 | } |
| 3032 | 3032 | |
| r10326 | r10327 | |
| 3071 | 3071 | if(sh2_slave_pwmint_enable) { cpu_set_input_line(_32x_slave_cpu, SH2_PINT_IRQ_LEVEL,ASSERT_LINE); } |
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | | timer_adjust_oneshot(_32x_pwm_timer, attotime::from_hz((PWM_CLOCK) / (pwm_cycle - 1)), 0); |
| 3074 | _32x_pwm_timer->adjust(attotime::from_hz((PWM_CLOCK) / (pwm_cycle - 1))); |
| 3075 | 3075 | } |
| 3076 | 3076 | |
| 3077 | 3077 | static READ16_HANDLER( _32x_pwm_r ) |
| r10326 | r10327 | |
| 3983 | 3983 | //printf("main cpu dmna set dmna: %d ret: %d\n", segacd_dmna, segacd_ret); |
| 3984 | 3984 | if (segacd_ram_mode==0) |
| 3985 | 3985 | { |
| 3986 | | if (!timer_enabled(segacd_dmna_ret_timer)) |
| 3986 | if (!segacd_dmna_ret_timer->enabled()) |
| 3987 | 3987 | { |
| 3988 | 3988 | if (!segacd_dmna) |
| 3989 | 3989 | { |
| 3990 | 3990 | //printf("main dmna\n"); |
| 3991 | 3991 | segacd_dmna = 1; |
| 3992 | | timer_adjust_oneshot(segacd_dmna_ret_timer, attotime::from_usec(100), 0); |
| 3992 | segacd_dmna_ret_timer->adjust(attotime::from_usec(100)); |
| 3993 | 3993 | } |
| 3994 | 3994 | } |
| 3995 | 3995 | } |
| r10326 | r10327 | |
| 4051 | 4051 | |
| 4052 | 4052 | if (segacd_ram_mode==0) |
| 4053 | 4053 | { |
| 4054 | | if (!timer_enabled(segacd_dmna_ret_timer)) |
| 4054 | if (!segacd_dmna_ret_timer->enabled()) |
| 4055 | 4055 | { |
| 4056 | 4056 | if (segacd_dmna) |
| 4057 | 4057 | { |
| 4058 | 4058 | // printf("sub ret\n"); |
| 4059 | 4059 | // segacd_ret = 1; |
| 4060 | 4060 | // segacd_dmna = 0; |
| 4061 | | timer_adjust_oneshot(segacd_dmna_ret_timer, attotime::from_usec(100), 0); |
| 4061 | segacd_dmna_ret_timer->adjust(attotime::from_usec(100)); |
| 4062 | 4062 | } |
| 4063 | 4063 | } |
| 4064 | 4064 | } |
| r10326 | r10327 | |
| 4098 | 4098 | // reset it flags etc.? |
| 4099 | 4099 | segacd_ret = 0; |
| 4100 | 4100 | segacd_dmna = 0; |
| 4101 | | timer_adjust_oneshot(segacd_dmna_ret_timer, attotime::from_usec(100), 0); |
| 4101 | segacd_dmna_ret_timer->adjust(attotime::from_usec(100)); |
| 4102 | 4102 | } |
| 4103 | 4103 | else |
| 4104 | 4104 | { |
| r10326 | r10327 | |
| 4983 | 4983 | hock_cmd = 0; |
| 4984 | 4984 | } |
| 4985 | 4985 | |
| 4986 | | timer_adjust_oneshot(segacd_hock_timer, attotime::from_hz(75), 0); |
| 4986 | segacd_hock_timer->adjust(attotime::from_hz(75)); |
| 4987 | 4987 | } |
| 4988 | 4988 | |
| 4989 | 4989 | |
| r10326 | r10327 | |
| 5022 | 5022 | memory_install_read16_handler (space, 0x0000070, 0x0000073, 0, 0, scd_hint_vector_r ); |
| 5023 | 5023 | |
| 5024 | 5024 | segacd_gfx_conversion_timer = machine->scheduler().timer_alloc(FUNC(segacd_gfx_conversion_timer_callback)); |
| 5025 | | timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime::never, 0); |
| 5025 | segacd_gfx_conversion_timer->adjust(attotime::never); |
| 5026 | 5026 | |
| 5027 | 5027 | segacd_dmna_ret_timer = machine->scheduler().timer_alloc(FUNC(segacd_dmna_ret_timer_callback)); |
| 5028 | | timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime::never, 0); |
| 5028 | segacd_gfx_conversion_timer->adjust(attotime::never); |
| 5029 | 5029 | |
| 5030 | 5030 | segacd_hock_timer = machine->scheduler().timer_alloc(FUNC(segacd_hock_callback)); |
| 5031 | | timer_adjust_oneshot(segacd_hock_timer, attotime::never, 0); |
| 5031 | segacd_hock_timer->adjust(attotime::never); |
| 5032 | 5032 | |
| 5033 | 5033 | segacd_irq3_timer = machine->scheduler().timer_alloc(FUNC(segacd_irq3_timer_callback)); |
| 5034 | | timer_adjust_oneshot(segacd_irq3_timer, attotime::never, 0); |
| 5034 | segacd_irq3_timer->adjust(attotime::never); |
| 5035 | 5035 | |
| 5036 | 5036 | |
| 5037 | 5037 | |
| r10326 | r10327 | |
| 5112 | 5112 | segacd_ram_mode = 0; |
| 5113 | 5113 | segacd_ram_mode_old = 0; |
| 5114 | 5114 | |
| 5115 | | timer_adjust_oneshot(segacd_dmna_ret_timer, attotime::zero, 0); |
| 5116 | | timer_adjust_oneshot(segacd_hock_timer, attotime::zero, 0); |
| 5115 | segacd_dmna_ret_timer->adjust(attotime::zero); |
| 5116 | segacd_hock_timer->adjust(attotime::zero); |
| 5117 | 5117 | hock_cmd = 0; |
| 5118 | 5118 | } |
| 5119 | 5119 | |
| r10326 | r10327 | |
| 5288 | 5288 | hock_cmd = (data & 4) >> 2; |
| 5289 | 5289 | |
| 5290 | 5290 | if(data & 4) // enable Hock timer |
| 5291 | | timer_adjust_oneshot(segacd_hock_timer, attotime::from_hz(75), 0); |
| 5291 | segacd_hock_timer->adjust(attotime::from_hz(75)); |
| 5292 | 5292 | else |
| 5293 | | timer_adjust_oneshot(segacd_hock_timer, attotime::never, 0); |
| 5293 | segacd_hock_timer->adjust(attotime::never); |
| 5294 | 5294 | } |
| 5295 | 5295 | |
| 5296 | 5296 | /* 68k <- CDD communication comms are 4-bit wide */ |
| r10326 | r10327 | |
| 5724 | 5724 | segacd_conversion_active = 1; |
| 5725 | 5725 | |
| 5726 | 5726 | // todo: proper time calculation |
| 5727 | | timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime::from_hz(500), 0); |
| 5727 | segacd_gfx_conversion_timer->adjust(attotime::from_hz(500)); |
| 5728 | 5728 | |
| 5729 | 5729 | |
| 5730 | 5730 | int line; |
| r10326 | r10327 | |
| 5873 | 5873 | // time = reg * 30.72 us |
| 5874 | 5874 | |
| 5875 | 5875 | if (segacd_irq3_timer_reg) |
| 5876 | | timer_adjust_oneshot(segacd_irq3_timer, SEGACD_IRQ3_TIMER_SPEED, 0); |
| 5876 | segacd_irq3_timer->adjust(SEGACD_IRQ3_TIMER_SPEED); |
| 5877 | 5877 | else |
| 5878 | | timer_adjust_oneshot(segacd_irq3_timer, attotime::never, 0); |
| 5878 | segacd_irq3_timer->adjust(attotime::never); |
| 5879 | 5879 | |
| 5880 | 5880 | printf("segacd_irq3timer_w %02x\n", segacd_irq3_timer_reg); |
| 5881 | 5881 | } |
| r10326 | r10327 | |
| 5886 | 5886 | if (segacd_irq_mask & 0x08) |
| 5887 | 5887 | cputag_set_input_line(machine, "segacd_68k", 3, HOLD_LINE); |
| 5888 | 5888 | |
| 5889 | | timer_adjust_oneshot(segacd_irq3_timer, SEGACD_IRQ3_TIMER_SPEED, 0); |
| 5889 | segacd_irq3_timer->adjust(SEGACD_IRQ3_TIMER_SPEED); |
| 5890 | 5890 | } |
| 5891 | 5891 | |
| 5892 | 5892 | |
| r10326 | r10327 | |
| 8960 | 8960 | if(_32x_is_connected) |
| 8961 | 8961 | { |
| 8962 | 8962 | _32x_pwm_timer = machine->scheduler().timer_alloc(FUNC(_32x_pwm_callback)); |
| 8963 | | timer_adjust_oneshot(_32x_pwm_timer, attotime::never, 0); |
| 8963 | _32x_pwm_timer->adjust(attotime::never); |
| 8964 | 8964 | } |
| 8965 | 8965 | |
| 8966 | 8966 | sega_cd_connected = 0; |
src/mame/machine/snes.c
| r10326 | r10327 | |
| 107 | 107 | cpu_set_input_line(state->maincpu, G65816_LINE_NMI, ASSERT_LINE); |
| 108 | 108 | |
| 109 | 109 | // don't happen again |
| 110 | | timer_adjust_oneshot(state->nmi_timer, attotime::never, 0); |
| 110 | state->nmi_timer->adjust(attotime::never); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | static void snes_hirq_tick( running_machine *machine ) |
| r10326 | r10327 | |
| 121 | 121 | cpu_set_input_line(state->maincpu, G65816_LINE_IRQ, ASSERT_LINE); |
| 122 | 122 | |
| 123 | 123 | // don't happen again |
| 124 | | timer_adjust_oneshot(state->hirq_timer, attotime::never, 0); |
| 124 | state->hirq_timer->adjust(attotime::never); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | static TIMER_CALLBACK( snes_hirq_tick_callback ) |
| r10326 | r10327 | |
| 157 | 157 | state->io_read(cpu0space->machine); |
| 158 | 158 | snes_ram[HVBJOY] &= 0xfe; /* Clear busy bit */ |
| 159 | 159 | |
| 160 | | timer_adjust_oneshot(state->io_timer, attotime::never, 0); |
| 160 | state->io_timer->adjust(attotime::never); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | static TIMER_CALLBACK( snes_scanline_tick ) |
| r10326 | r10327 | |
| 205 | 205 | } |
| 206 | 206 | else |
| 207 | 207 | { |
| 208 | | timer_adjust_oneshot(state->hirq_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, pixel * state->htmult), 0); |
| 208 | state->hirq_timer->adjust(machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, pixel * state->htmult)); |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | } |
| r10326 | r10327 | |
| 221 | 221 | if (snes_ram[NMITIMEN] & 0x80) /* NMI only signaled if this bit set */ |
| 222 | 222 | { |
| 223 | 223 | // NMI goes off about 12 cycles after this (otherwise Chrono Trigger, NFL QB Club, etc. lock up) |
| 224 | | timer_adjust_oneshot(state->nmi_timer, state->maincpu->cycles_to_attotime(12), 0); |
| 224 | state->nmi_timer->adjust(state->maincpu->cycles_to_attotime(12)); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /* three lines after start of vblank we update the controllers (value from snes9x) */ |
| 228 | | timer_adjust_oneshot(state->io_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 2, state->hblank_offset * state->htmult), 0); |
| 228 | state->io_timer->adjust(machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 2, state->hblank_offset * state->htmult)); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // hdma reset happens at scanline 0, H=~6 |
| r10326 | r10327 | |
| 245 | 245 | cpu_set_input_line(state->maincpu, G65816_LINE_NMI, CLEAR_LINE ); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | | timer_adjust_oneshot(state->scanline_timer, attotime::never, 0); |
| 249 | | timer_adjust_oneshot(state->hblank_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, state->hblank_offset * state->htmult), 0); |
| 248 | state->scanline_timer->adjust(attotime::never); |
| 249 | state->hblank_timer->adjust(machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, state->hblank_offset * state->htmult)); |
| 250 | 250 | |
| 251 | 251 | // printf("%02x %d\n",snes_ram[HVBJOY],snes_ppu.beam.current_vert); |
| 252 | 252 | } |
| r10326 | r10327 | |
| 261 | 261 | snes_ppu.beam.current_vert = machine->primary_screen->vpos(); |
| 262 | 262 | |
| 263 | 263 | /* make sure we halt */ |
| 264 | | timer_adjust_oneshot(state->hblank_timer, attotime::never, 0); |
| 264 | state->hblank_timer->adjust(attotime::never); |
| 265 | 265 | |
| 266 | 266 | /* draw a scanline */ |
| 267 | 267 | if (snes_ppu.beam.current_vert <= snes_ppu.beam.last_visible_line) |
| r10326 | r10327 | |
| 286 | 286 | nextscan = 0; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | | timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(nextscan), 0); |
| 289 | state->scanline_timer->adjust(machine->primary_screen->time_until_pos(nextscan)); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /* FIXME: multiplication should take 8 CPU cycles & division 16 CPU cycles, but |
| r10326 | r10327 | |
| 616 | 616 | { |
| 617 | 617 | // printf("816: %02x to APU @ %d (PC=%06x)\n", data, offset & 3,cpu_get_pc(space->cpu)); |
| 618 | 618 | spc_port_in(state->spc700, offset & 0x3, data); |
| 619 | | cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(20)); |
| 619 | space->machine->scheduler().boost_interleave(attotime::zero, attotime::from_usec(20)); |
| 620 | 620 | return; |
| 621 | 621 | } |
| 622 | 622 | |
| r10326 | r10327 | |
| 711 | 711 | break; |
| 712 | 712 | case WRMPYB: /* Multiplier B */ |
| 713 | 713 | snes_ram[WRMPYB] = data; |
| 714 | | // timer_adjust_oneshot(state->mult_timer, state->maincpu->cycles_to_attotime(8), 0); |
| 714 | // state->mult_timer->adjust(state->maincpu->cycles_to_attotime(8)); |
| 715 | 715 | { |
| 716 | 716 | UINT32 c = snes_ram[WRMPYA] * snes_ram[WRMPYB]; |
| 717 | 717 | snes_ram[RDMPYL] = c & 0xff; |
| r10326 | r10327 | |
| 723 | 723 | break; |
| 724 | 724 | case WRDVDD: /* Divisor */ |
| 725 | 725 | snes_ram[WRDVDD] = data; |
| 726 | | // timer_adjust_oneshot(state->div_timer, state->maincpu->cycles_to_attotime(16), 0); |
| 726 | // state->div_timer->adjust(state->maincpu->cycles_to_attotime(16)); |
| 727 | 727 | { |
| 728 | 728 | UINT16 value, dividend, remainder; |
| 729 | 729 | dividend = remainder = 0; |
| r10326 | r10327 | |
| 1709 | 1709 | |
| 1710 | 1710 | /* init timers and stop them */ |
| 1711 | 1711 | state->scanline_timer = machine->scheduler().timer_alloc(FUNC(snes_scanline_tick)); |
| 1712 | | timer_adjust_oneshot(state->scanline_timer, attotime::never, 0); |
| 1712 | state->scanline_timer->adjust(attotime::never); |
| 1713 | 1713 | state->hblank_timer = machine->scheduler().timer_alloc(FUNC(snes_hblank_tick)); |
| 1714 | | timer_adjust_oneshot(state->hblank_timer, attotime::never, 0); |
| 1714 | state->hblank_timer->adjust(attotime::never); |
| 1715 | 1715 | state->nmi_timer = machine->scheduler().timer_alloc(FUNC(snes_nmi_tick)); |
| 1716 | | timer_adjust_oneshot(state->nmi_timer, attotime::never, 0); |
| 1716 | state->nmi_timer->adjust(attotime::never); |
| 1717 | 1717 | state->hirq_timer = machine->scheduler().timer_alloc(FUNC(snes_hirq_tick_callback)); |
| 1718 | | timer_adjust_oneshot(state->hirq_timer, attotime::never, 0); |
| 1718 | state->hirq_timer->adjust(attotime::never); |
| 1719 | 1719 | state->div_timer = machine->scheduler().timer_alloc(FUNC(snes_div_callback)); |
| 1720 | | timer_adjust_oneshot(state->div_timer, attotime::never, 0); |
| 1720 | state->div_timer->adjust(attotime::never); |
| 1721 | 1721 | state->mult_timer = machine->scheduler().timer_alloc(FUNC(snes_mult_callback)); |
| 1722 | | timer_adjust_oneshot(state->mult_timer, attotime::never, 0); |
| 1722 | state->mult_timer->adjust(attotime::never); |
| 1723 | 1723 | state->io_timer = machine->scheduler().timer_alloc(FUNC(snes_update_io)); |
| 1724 | | timer_adjust_oneshot(state->io_timer, attotime::never, 0); |
| 1724 | state->io_timer->adjust(attotime::never); |
| 1725 | 1725 | |
| 1726 | 1726 | // SNES hcounter has a 0-339 range. hblank starts at counter 260. |
| 1727 | 1727 | // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels. |
| 1728 | 1728 | state->hblank_offset = 274; |
| 1729 | | timer_adjust_oneshot(state->hblank_timer, machine->primary_screen->time_until_pos(((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->hblank_offset), 0); |
| 1729 | state->hblank_timer->adjust(machine->primary_screen->time_until_pos(((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->hblank_offset)); |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | static void snes_init_ram( running_machine *machine ) |
src/mame/machine/archimds.c
| r10326 | r10327 | |
| 111 | 111 | archimedes_request_irq_a(machine, ARCHIMEDES_IRQA_VBL); |
| 112 | 112 | |
| 113 | 113 | // set up for next vbl |
| 114 | | timer_adjust_oneshot(vbl_timer, machine->primary_screen->time_until_pos(vidc_regs[0xb4]), 0); |
| 114 | vbl_timer->adjust(machine->primary_screen->time_until_pos(vidc_regs[0xb4])); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /* video DMA */ |
| r10326 | r10327 | |
| 128 | 128 | vram[vidc_vidcur] = (space->read_byte(vidc_vidstart+vidc_vidcur+vidc_vidinit)); |
| 129 | 129 | |
| 130 | 130 | if(video_dma_on) |
| 131 | | timer_adjust_oneshot(vid_timer, space->machine->primary_screen->time_until_pos(vidc_regs[0xb4]), 0); |
| 131 | vid_timer->adjust(space->machine->primary_screen->time_until_pos(vidc_regs[0xb4])); |
| 132 | 132 | else |
| 133 | | timer_adjust_oneshot(vid_timer, attotime::never, 0); |
| 133 | vid_timer->adjust(attotime::never); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /* audio DMA */ |
| r10326 | r10327 | |
| 162 | 162 | |
| 163 | 163 | if(!audio_dma_on) |
| 164 | 164 | { |
| 165 | | timer_adjust_oneshot(snd_timer, attotime::never, 0); |
| 165 | snd_timer->adjust(attotime::never); |
| 166 | 166 | for(ch=0;ch<8;ch++) |
| 167 | 167 | dac_signed_data_16_w(space->machine->device(dac_port[ch & 7]), 0x8000); |
| 168 | 168 | } |
| r10326 | r10327 | |
| 177 | 177 | { |
| 178 | 178 | case 0: |
| 179 | 179 | case 1: |
| 180 | | timer_adjust_oneshot(timer[tmr], attotime::from_usec(ioc_timercnt[tmr]/8), tmr); // TODO: ARM timings are quite off there, it should be latch and not latch/8 |
| 180 | timer[tmr]->adjust(attotime::from_usec(ioc_timercnt[tmr]/8), tmr); // TODO: ARM timings are quite off there, it should be latch and not latch/8 |
| 181 | 181 | break; |
| 182 | 182 | case 2: |
| 183 | 183 | freq = 1000000.0 / (double)(ioc_timercnt[tmr]+1); |
| 184 | | timer_adjust_oneshot(timer[tmr], attotime::from_hz(freq), tmr); |
| 184 | timer[tmr]->adjust(attotime::from_hz(freq), tmr); |
| 185 | 185 | break; |
| 186 | 186 | case 3: |
| 187 | 187 | freq = 1000000.0 / (double)((ioc_timercnt[tmr]+1)*16); |
| 188 | | timer_adjust_oneshot(timer[tmr], attotime::from_hz(freq), tmr); |
| 188 | timer[tmr]->adjust(attotime::from_hz(freq), tmr); |
| 189 | 189 | break; |
| 190 | 190 | } |
| 191 | 191 | } |
| r10326 | r10327 | |
| 232 | 232 | memc_pagesize = 0; |
| 233 | 233 | |
| 234 | 234 | vbl_timer = machine->scheduler().timer_alloc(FUNC(vidc_vblank)); |
| 235 | | timer_adjust_oneshot(vbl_timer, attotime::never, 0); |
| 235 | vbl_timer->adjust(attotime::never); |
| 236 | 236 | |
| 237 | 237 | timer[0] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); |
| 238 | 238 | timer[1] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); |
| 239 | 239 | timer[2] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); |
| 240 | 240 | timer[3] = machine->scheduler().timer_alloc(FUNC(ioc_timer)); |
| 241 | | timer_adjust_oneshot(timer[0], attotime::never, 0); |
| 242 | | timer_adjust_oneshot(timer[1], attotime::never, 0); |
| 243 | | timer_adjust_oneshot(timer[2], attotime::never, 0); |
| 244 | | timer_adjust_oneshot(timer[3], attotime::never, 0); |
| 241 | timer[0]->adjust(attotime::never); |
| 242 | timer[1]->adjust(attotime::never); |
| 243 | timer[2]->adjust(attotime::never); |
| 244 | timer[3]->adjust(attotime::never); |
| 245 | 245 | |
| 246 | 246 | vid_timer = machine->scheduler().timer_alloc(FUNC(vidc_video_tick)); |
| 247 | 247 | snd_timer = machine->scheduler().timer_alloc(FUNC(vidc_audio_tick)); |
| 248 | | timer_adjust_oneshot(snd_timer, attotime::never, 0); |
| 248 | snd_timer->adjust(attotime::never); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | READ32_HANDLER(archimedes_memc_logical_r) |
| r10326 | r10327 | |
| 381 | 381 | |
| 382 | 382 | static void latch_timer_cnt(int tmr) |
| 383 | 383 | { |
| 384 | | double time = timer_timeelapsed(timer[tmr]).as_double(); |
| 384 | double time = timer[tmr]->elapsed().as_double(); |
| 385 | 385 | time *= 2000000.0; // find out how many 2 MHz ticks have gone by |
| 386 | 386 | ioc_timerout[tmr] = ioc_timercnt[tmr] - (UINT32)time; |
| 387 | 387 | } |
| r10326 | r10327 | |
| 490 | 490 | archimedes_request_irq_a(space->machine,ARCHIMEDES_IRQA_FORCE); |
| 491 | 491 | |
| 492 | 492 | if(data & 0x08) //set up the VBLANK timer |
| 493 | | timer_adjust_oneshot(vbl_timer, space->machine->primary_screen->time_until_pos(vidc_regs[0xb4]), 0); |
| 493 | vbl_timer->adjust(space->machine->primary_screen->time_until_pos(vidc_regs[0xb4])); |
| 494 | 494 | |
| 495 | 495 | break; |
| 496 | 496 | |
| r10326 | r10327 | |
| 911 | 911 | if ((data>>10)&1) |
| 912 | 912 | { |
| 913 | 913 | vidc_vidcur = 0; |
| 914 | | timer_adjust_oneshot(vid_timer, space->machine->primary_screen->time_until_pos(vidc_regs[0xb4]), 0); |
| 914 | vid_timer->adjust(space->machine->primary_screen->time_until_pos(vidc_regs[0xb4])); |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | if ((data>>11)&1) |
| r10326 | r10327 | |
| 923 | 923 | |
| 924 | 924 | printf("MEMC: Starting audio DMA at %f Hz, buffer from %x to %x\n", sndhz, vidc_sndstart, vidc_sndend); |
| 925 | 925 | |
| 926 | | timer_adjust_periodic(snd_timer, attotime::zero, 0, attotime::from_hz(sndhz)); |
| 926 | snd_timer->adjust(attotime::zero, 0, attotime::from_hz(sndhz)); |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | break; |
src/mame/machine/kaneko16.c
| r10326 | r10327 | |
| 2121 | 2121 | if (mcu_command == 0) return; |
| 2122 | 2122 | |
| 2123 | 2123 | logerror("%s : MCU executed command at %04X: %04X\n", |
| 2124 | | cpuexec_describe_context(machine),calc3_mcu_command_offset,mcu_command); |
| 2124 | machine->describe_context(),calc3_mcu_command_offset,mcu_command); |
| 2125 | 2125 | |
| 2126 | 2126 | |
| 2127 | 2127 | if (mcu_command>0) |
| r10326 | r10327 | |
| 2453 | 2453 | mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 2454 | 2454 | mame_fclose(f); |
| 2455 | 2455 | } |
| 2456 | | logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2456 | logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2457 | 2457 | } |
| 2458 | 2458 | break; |
| 2459 | 2459 | |
| r10326 | r10327 | |
| 2465 | 2465 | mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 2466 | 2466 | mame_fclose(f); |
| 2467 | 2467 | } |
| 2468 | | logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2468 | logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2469 | 2469 | } |
| 2470 | 2470 | break; |
| 2471 | 2471 | |
| 2472 | 2472 | case 0x03: // DSW |
| 2473 | 2473 | { |
| 2474 | 2474 | kaneko16_mcu_ram[mcu_offset] = input_port_read(machine, "DSW1"); |
| 2475 | | logerror("%s : MCU executed command: %04X %04X (read DSW)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2475 | logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2476 | 2476 | } |
| 2477 | 2477 | break; |
| 2478 | 2478 | |
| 2479 | 2479 | case 0x04: // Protection |
| 2480 | 2480 | { |
| 2481 | | logerror("%s : MCU executed command: %04X %04X %04X\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data); |
| 2481 | logerror("%s : MCU executed command: %04X %04X %04X\n", machine->describe_context(), mcu_command, mcu_offset*2, mcu_data); |
| 2482 | 2482 | |
| 2483 | 2483 | toxboy_handle_04_subcommand(machine, mcu_data, kaneko16_mcu_ram); |
| 2484 | 2484 | |
| r10326 | r10327 | |
| 2486 | 2486 | break; |
| 2487 | 2487 | |
| 2488 | 2488 | default: |
| 2489 | | logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data); |
| 2489 | logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine->describe_context(), mcu_command, mcu_offset*2, mcu_data); |
| 2490 | 2490 | break; |
| 2491 | 2491 | } |
| 2492 | 2492 | } |
| r10326 | r10327 | |
| 2512 | 2512 | mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 2513 | 2513 | mame_fclose(f); |
| 2514 | 2514 | } |
| 2515 | | logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2515 | logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2516 | 2516 | } |
| 2517 | 2517 | break; |
| 2518 | 2518 | |
| r10326 | r10327 | |
| 2524 | 2524 | mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 2525 | 2525 | mame_fclose(f); |
| 2526 | 2526 | } |
| 2527 | | logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2527 | logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2528 | 2528 | } |
| 2529 | 2529 | break; |
| 2530 | 2530 | |
| r10326 | r10327 | |
| 2536 | 2536 | mame_fwrite(f, bonkadv_mcu_43, sizeof(bonkadv_mcu_43)); |
| 2537 | 2537 | mame_fclose(f); |
| 2538 | 2538 | } |
| 2539 | | logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2539 | logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2540 | 2540 | } |
| 2541 | 2541 | break; |
| 2542 | 2542 | |
| 2543 | 2543 | case 0x03: // DSW |
| 2544 | 2544 | { |
| 2545 | 2545 | kaneko16_mcu_ram[mcu_offset] = input_port_read(machine, "DSW1"); |
| 2546 | | logerror("%s : MCU executed command: %04X %04X (read DSW)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2); |
| 2546 | logerror("%s : MCU executed command: %04X %04X (read DSW)\n", machine->describe_context(), mcu_command, mcu_offset*2); |
| 2547 | 2547 | } |
| 2548 | 2548 | break; |
| 2549 | 2549 | |
| 2550 | 2550 | case 0x04: // Protection |
| 2551 | 2551 | { |
| 2552 | | logerror("%s : MCU executed command: %04X %04X %04X\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data); |
| 2552 | logerror("%s : MCU executed command: %04X %04X %04X\n", machine->describe_context(), mcu_command, mcu_offset*2, mcu_data); |
| 2553 | 2553 | |
| 2554 | 2554 | |
| 2555 | 2555 | switch(mcu_data) |
| r10326 | r10327 | |
| 2571 | 2571 | break; |
| 2572 | 2572 | |
| 2573 | 2573 | default: |
| 2574 | | logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data); |
| 2574 | logerror("%s : MCU executed command: %04X %04X %04X (UNKNOWN COMMAND)\n", machine->describe_context(), mcu_command, mcu_offset*2, mcu_data); |
| 2575 | 2575 | break; |
| 2576 | 2576 | } |
| 2577 | 2577 | } |
| r10326 | r10327 | |
| 2594 | 2594 | UINT16 mcu_offset = kaneko16_mcu_ram[0x0012/2] / 2; |
| 2595 | 2595 | UINT16 mcu_data = kaneko16_mcu_ram[0x0014/2]; |
| 2596 | 2596 | |
| 2597 | | logerror("%s : MCU executed command: %04X %04X %04X\n", cpuexec_describe_context(machine), mcu_command, mcu_offset*2, mcu_data); |
| 2597 | logerror("%s : MCU executed command: %04X %04X %04X\n", machine->describe_context(), mcu_command, mcu_offset*2, mcu_data); |
| 2598 | 2598 | |
| 2599 | 2599 | switch (mcu_command >> 8) |
| 2600 | 2600 | { |
src/mame/machine/cdi070.c
| r10326 | r10327 | |
| 53 | 53 | case 0: |
| 54 | 54 | compare = 0x10000 - scc68070->timers.timer0; |
| 55 | 55 | period = attotime::from_hz(CLOCK_A/192) * compare; |
| 56 | | timer_adjust_oneshot(scc68070->timers.timer0_timer, period, 0); |
| 56 | scc68070->timers.timer0_timer->adjust(period); |
| 57 | 57 | break; |
| 58 | 58 | default: |
| 59 | 59 | fatalerror( "Unsupported timer channel to scc68070_set_timer_callback!" ); |
| r10326 | r10327 | |
| 96 | 96 | if((scc68070->uart.command_register & 3) == 1) |
| 97 | 97 | { |
| 98 | 98 | UINT32 div = 0x10000 >> ((scc68070->uart.clock_select >> 4) & 7); |
| 99 | | timer_adjust_oneshot(scc68070->uart.rx_timer, attotime::from_hz((49152000 / div) / 8), 0); |
| 99 | scc68070->uart.rx_timer->adjust(attotime::from_hz((49152000 / div) / 8)); |
| 100 | 100 | } |
| 101 | 101 | else |
| 102 | 102 | { |
| 103 | 103 | scc68070->uart.status_register &= ~USR_RXRDY; |
| 104 | | timer_adjust_oneshot(scc68070->uart.rx_timer, attotime::never, 0); |
| 104 | scc68070->uart.rx_timer->adjust(attotime::never); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| r10326 | r10327 | |
| 118 | 118 | scc68070->uart.status_register |= USR_TXRDY; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | | if(timer_timeleft(scc68070->uart.tx_timer) == attotime::never) |
| 121 | if(scc68070->uart.tx_timer->remaining() == attotime::never) |
| 122 | 122 | { |
| 123 | 123 | UINT32 div = 0x10000 >> (scc68070->uart.clock_select & 7); |
| 124 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::from_hz((49152000 / div) / 8), 0); |
| 124 | scc68070->uart.tx_timer->adjust(attotime::from_hz((49152000 / div) / 8)); |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | else |
| 128 | 128 | { |
| 129 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::never, 0); |
| 129 | scc68070->uart.tx_timer->adjust(attotime::never); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| r10326 | r10327 | |
| 176 | 176 | |
| 177 | 177 | scc68070->uart.status_register |= USR_RXRDY; |
| 178 | 178 | UINT32 div = 0x10000 >> ((scc68070->uart.clock_select >> 4) & 7); |
| 179 | | timer_adjust_oneshot(scc68070->uart.rx_timer, attotime::from_hz((49152000 / div) / 8), 0); |
| 179 | scc68070->uart.rx_timer->adjust(attotime::from_hz((49152000 / div) / 8)); |
| 180 | 180 | } |
| 181 | 181 | else |
| 182 | 182 | { |
| r10326 | r10327 | |
| 389 | 389 | scc68070->uart.transmit_pointer--; |
| 390 | 390 | |
| 391 | 391 | UINT32 div = 0x10000 >> (scc68070->uart.clock_select & 7); |
| 392 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::from_hz((49152000 / div) / 8), 0); |
| 392 | scc68070->uart.tx_timer->adjust(attotime::from_hz((49152000 / div) / 8)); |
| 393 | 393 | } |
| 394 | 394 | else |
| 395 | 395 | { |
| 396 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::never, 0); |
| 396 | scc68070->uart.tx_timer->adjust(attotime::never); |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | else |
| 400 | 400 | { |
| 401 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::never, 0); |
| 401 | scc68070->uart.tx_timer->adjust(attotime::never); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | scc68070_uart_tx_check(machine, scc68070); |
| r10326 | r10327 | |
| 1144 | 1144 | state_save_register_global(machine, scc68070->mmu.desc[7].base); |
| 1145 | 1145 | |
| 1146 | 1146 | scc68070->timers.timer0_timer = machine->scheduler().timer_alloc(FUNC(scc68070_timer0_callback)); |
| 1147 | | timer_adjust_oneshot(scc68070->timers.timer0_timer, attotime::never, 0); |
| 1147 | scc68070->timers.timer0_timer->adjust(attotime::never); |
| 1148 | 1148 | |
| 1149 | 1149 | scc68070->uart.rx_timer = machine->scheduler().timer_alloc(FUNC(scc68070_rx_callback)); |
| 1150 | | timer_adjust_oneshot(scc68070->uart.rx_timer, attotime::never, 0); |
| 1150 | scc68070->uart.rx_timer->adjust(attotime::never); |
| 1151 | 1151 | |
| 1152 | 1152 | scc68070->uart.tx_timer = machine->scheduler().timer_alloc(FUNC(scc68070_tx_callback)); |
| 1153 | | timer_adjust_oneshot(scc68070->uart.tx_timer, attotime::never, 0); |
| 1153 | scc68070->uart.tx_timer->adjust(attotime::never); |
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | #if ENABLE_UART_PRINTING |
src/mame/video/dc.c
| r10326 | r10327 | |
| 1092 | 1092 | // this should really be done for each tile! |
| 1093 | 1093 | render_to_accumulation_buffer(space->machine,fake_accumulationbuffer_bitmap,&clip); |
| 1094 | 1094 | |
| 1095 | | timer_adjust_oneshot(endofrender_timer_isp, attotime::from_usec(4000) , 0); // hack, make sure render takes some amount of time |
| 1095 | endofrender_timer_isp->adjust(attotime::from_usec(4000) ); // hack, make sure render takes some amount of time |
| 1096 | 1096 | |
| 1097 | 1097 | /* copy the tiles to the framebuffer (really the rendering should be in this loop too) */ |
| 1098 | 1098 | if (pvrta_regs[FPU_PARAM_CFG] & 0x200000) |
| r10326 | r10327 | |
| 1241 | 1241 | |
| 1242 | 1242 | case SPG_VBLANK_INT: |
| 1243 | 1243 | /* clear pending irqs and modify them with the updated ones */ |
| 1244 | | timer_adjust_oneshot(vbin_timer, attotime::never, 0); |
| 1245 | | timer_adjust_oneshot(vbout_timer, attotime::never, 0); |
| 1244 | vbin_timer->adjust(attotime::never); |
| 1245 | vbout_timer->adjust(attotime::never); |
| 1246 | 1246 | |
| 1247 | | timer_adjust_oneshot(vbin_timer, space->machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); |
| 1248 | | timer_adjust_oneshot(vbout_timer, space->machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); |
| 1247 | vbin_timer->adjust(space->machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num)); |
| 1248 | vbout_timer->adjust(space->machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num)); |
| 1249 | 1249 | break; |
| 1250 | 1250 | /* TODO: timer adjust for SPG_HBLANK_INT too */ |
| 1251 | 1251 | case TA_LIST_CONT: |
| r10326 | r10327 | |
| 2451 | 2451 | dc_sysctrl_regs[SB_ISTNRM] |= IST_VBL_IN; // V Blank-in interrupt |
| 2452 | 2452 | dc_update_interrupt_status(machine); |
| 2453 | 2453 | |
| 2454 | | timer_adjust_oneshot(vbin_timer, machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); |
| 2454 | vbin_timer->adjust(machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num)); |
| 2455 | 2455 | } |
| 2456 | 2456 | |
| 2457 | 2457 | static TIMER_CALLBACK(vbout) |
| r10326 | r10327 | |
| 2459 | 2459 | dc_sysctrl_regs[SB_ISTNRM] |= IST_VBL_OUT; // V Blank-out interrupt |
| 2460 | 2460 | dc_update_interrupt_status(machine); |
| 2461 | 2461 | |
| 2462 | | timer_adjust_oneshot(vbout_timer, machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); |
| 2462 | vbout_timer->adjust(machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num)); |
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | static TIMER_CALLBACK(hbin) |
| r10326 | r10327 | |
| 2489 | 2489 | next_y = spg_line_comp_val; |
| 2490 | 2490 | } |
| 2491 | 2491 | |
| 2492 | | timer_adjust_oneshot(hbin_timer, machine->primary_screen->time_until_pos(scanline, spg_hblank_in_irq-1), 0); |
| 2492 | hbin_timer->adjust(machine->primary_screen->time_until_pos(scanline, spg_hblank_in_irq-1)); |
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | 2495 | |
| r10326 | r10327 | |
| 2498 | 2498 | { |
| 2499 | 2499 | dc_sysctrl_regs[SB_ISTNRM] |= IST_EOR_VIDEO;// VIDEO end of render |
| 2500 | 2500 | dc_update_interrupt_status(machine); |
| 2501 | | timer_adjust_oneshot(endofrender_timer_video, attotime::never, 0); |
| 2501 | endofrender_timer_video->adjust(attotime::never); |
| 2502 | 2502 | } |
| 2503 | 2503 | |
| 2504 | 2504 | static TIMER_CALLBACK(endofrender_tsp) |
| r10326 | r10327 | |
| 2506 | 2506 | dc_sysctrl_regs[SB_ISTNRM] |= IST_EOR_TSP; // TSP end of render |
| 2507 | 2507 | dc_update_interrupt_status(machine); |
| 2508 | 2508 | |
| 2509 | | timer_adjust_oneshot(endofrender_timer_tsp, attotime::never, 0); |
| 2510 | | timer_adjust_oneshot(endofrender_timer_video, attotime::from_usec(500) , 0); |
| 2509 | endofrender_timer_tsp->adjust(attotime::never); |
| 2510 | endofrender_timer_video->adjust(attotime::from_usec(500) ); |
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | static TIMER_CALLBACK(endofrender_isp) |
| r10326 | r10327 | |
| 2515 | 2515 | dc_sysctrl_regs[SB_ISTNRM] |= IST_EOR_ISP; // ISP end of render |
| 2516 | 2516 | dc_update_interrupt_status(machine); |
| 2517 | 2517 | |
| 2518 | | timer_adjust_oneshot(endofrender_timer_isp, attotime::never, 0); |
| 2519 | | timer_adjust_oneshot(endofrender_timer_tsp, attotime::from_usec(500) , 0); |
| 2518 | endofrender_timer_isp->adjust(attotime::never); |
| 2519 | endofrender_timer_tsp->adjust(attotime::from_usec(500) ); |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | 2522 | |
| r10326 | r10327 | |
| 2552 | 2552 | computedilated(); |
| 2553 | 2553 | |
| 2554 | 2554 | vbout_timer = machine->scheduler().timer_alloc(FUNC(vbout)); |
| 2555 | | timer_adjust_oneshot(vbout_timer, machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); |
| 2555 | vbout_timer->adjust(machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num)); |
| 2556 | 2556 | |
| 2557 | 2557 | vbin_timer = machine->scheduler().timer_alloc(FUNC(vbin)); |
| 2558 | | timer_adjust_oneshot(vbin_timer, machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); |
| 2558 | vbin_timer->adjust(machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num)); |
| 2559 | 2559 | |
| 2560 | 2560 | hbin_timer = machine->scheduler().timer_alloc(FUNC(hbin)); |
| 2561 | | timer_adjust_oneshot(hbin_timer, machine->primary_screen->time_until_pos(0, spg_hblank_in_irq-1), 0); |
| 2561 | hbin_timer->adjust(machine->primary_screen->time_until_pos(0, spg_hblank_in_irq-1)); |
| 2562 | 2562 | |
| 2563 | 2563 | scanline = 0; |
| 2564 | 2564 | next_y = 0; |
| r10326 | r10327 | |
| 2567 | 2567 | endofrender_timer_tsp = machine->scheduler().timer_alloc(FUNC(endofrender_tsp)); |
| 2568 | 2568 | endofrender_timer_video = machine->scheduler().timer_alloc(FUNC(endofrender_video)); |
| 2569 | 2569 | |
| 2570 | | timer_adjust_oneshot(endofrender_timer_isp, attotime::never, 0); |
| 2571 | | timer_adjust_oneshot(endofrender_timer_tsp, attotime::never, 0); |
| 2572 | | timer_adjust_oneshot(endofrender_timer_video, attotime::never, 0); |
| 2570 | endofrender_timer_isp->adjust(attotime::never); |
| 2571 | endofrender_timer_tsp->adjust(attotime::never); |
| 2572 | endofrender_timer_video->adjust(attotime::never); |
| 2573 | 2573 | |
| 2574 | 2574 | fake_accumulationbuffer_bitmap = auto_bitmap_alloc(machine,1024,1024,BITMAP_FORMAT_RGB32); |
| 2575 | 2575 | |
src/mame/drivers/mpu4.c
| r10326 | r10327 | |
| 717 | 717 | /* IC3, lamp data lines + alpha numeric display */ |
| 718 | 718 | static WRITE8_DEVICE_HANDLER( pia_ic3_porta_w ) |
| 719 | 719 | { |
| 720 | | LOG_IC3(("%s: IC3 PIA Port A Set to %2x (lamp strobes 1 - 9)\n", cpuexec_describe_context(device->machine),data)); |
| 720 | LOG_IC3(("%s: IC3 PIA Port A Set to %2x (lamp strobes 1 - 9)\n", device->machine->describe_context(),data)); |
| 721 | 721 | |
| 722 | 722 | if(ic23_active) |
| 723 | 723 | { |
| r10326 | r10327 | |
| 728 | 728 | |
| 729 | 729 | static WRITE8_DEVICE_HANDLER( pia_ic3_portb_w ) |
| 730 | 730 | { |
| 731 | | LOG_IC3(("%s: IC3 PIA Port B Set to %2x (lamp strobes 10 - 17)\n", cpuexec_describe_context(device->machine),data)); |
| 731 | LOG_IC3(("%s: IC3 PIA Port B Set to %2x (lamp strobes 10 - 17)\n", device->machine->describe_context(),data)); |
| 732 | 732 | |
| 733 | 733 | if(ic23_active) |
| 734 | 734 | { |
| r10326 | r10327 | |
| 739 | 739 | |
| 740 | 740 | static WRITE_LINE_DEVICE_HANDLER( pia_ic3_ca2_w ) |
| 741 | 741 | { |
| 742 | | LOG_IC3(("%s: IC3 PIA Write CA2 (alpha data), %02X\n", cpuexec_describe_context(device->machine),state)); |
| 742 | LOG_IC3(("%s: IC3 PIA Write CA2 (alpha data), %02X\n", device->machine->describe_context(),state)); |
| 743 | 743 | |
| 744 | 744 | alpha_data_line = state; |
| 745 | 745 | ROC10937_draw_16seg(0); |
| r10326 | r10327 | |
| 748 | 748 | |
| 749 | 749 | static WRITE_LINE_DEVICE_HANDLER( pia_ic3_cb2_w ) |
| 750 | 750 | { |
| 751 | | LOG_IC3(("%s: IC3 PIA Write CB (alpha reset), %02X\n",cpuexec_describe_context(device->machine),state)); |
| 751 | LOG_IC3(("%s: IC3 PIA Write CB (alpha reset), %02X\n",device->machine->describe_context(),state)); |
| 752 | 752 | |
| 753 | 753 | if ( state ) ROC10937_reset(0); |
| 754 | 754 | ROC10937_draw_16seg(0); |
| r10326 | r10327 | |
| 829 | 829 | { |
| 830 | 830 | ic23_active=1; |
| 831 | 831 | ic24_output(0); |
| 832 | | timer_adjust_oneshot(ic24_timer, attotime::from_double(duration), 0); |
| 832 | ic24_timer->adjust(attotime::from_double(duration)); |
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | } |
| r10326 | r10327 | |
| 923 | 923 | if ( lamp_undercurrent ) ic4_input_b |= 0x01; |
| 924 | 924 | #endif |
| 925 | 925 | |
| 926 | | LOG_IC3(("%s: IC4 PIA Read of Port B %x\n",cpuexec_describe_context(device->machine),ic4_input_b)); |
| 926 | LOG_IC3(("%s: IC4 PIA Read of Port B %x\n",device->machine->describe_context(),ic4_input_b)); |
| 927 | 927 | return ic4_input_b; |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | |
| 931 | 931 | static WRITE_LINE_DEVICE_HANDLER( pia_ic4_ca2_w ) |
| 932 | 932 | { |
| 933 | | LOG_IC3(("%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", cpuexec_describe_context(device->machine),state)); |
| 933 | LOG_IC3(("%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", device->machine->describe_context(),state)); |
| 934 | 934 | |
| 935 | 935 | IC23GB = state; |
| 936 | 936 | ic23_update(); |
| r10326 | r10327 | |
| 938 | 938 | |
| 939 | 939 | static WRITE_LINE_DEVICE_HANDLER( pia_ic4_cb2_w ) |
| 940 | 940 | { |
| 941 | | LOG_IC3(("%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", cpuexec_describe_context(device->machine),state)); |
| 941 | LOG_IC3(("%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", device->machine->describe_context(),state)); |
| 942 | 942 | reel_flag=state; |
| 943 | 943 | } |
| 944 | 944 | static const pia6821_interface pia_ic4_intf = |
| r10326 | r10327 | |
| 982 | 982 | aux1_input &= ~0x04; |
| 983 | 983 | }*/ |
| 984 | 984 | } |
| 985 | | LOG(("%s: IC5 PIA Read of Port A (AUX1)\n",cpuexec_describe_context(device->machine))); |
| 985 | LOG(("%s: IC5 PIA Read of Port A (AUX1)\n",device->machine->describe_context())); |
| 986 | 986 | |
| 987 | 987 | return input_port_read(device->machine, "AUX1")|aux1_input; |
| 988 | 988 | } |
| r10326 | r10327 | |
| 1071 | 1071 | }*/ |
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | | LOG(("%s: IC5 PIA Read of Port B (coin input AUX2)\n",cpuexec_describe_context(device->machine))); |
| 1074 | LOG(("%s: IC5 PIA Read of Port B (coin input AUX2)\n",device->machine->describe_context())); |
| 1075 | 1075 | coin_lockout_w(device->machine, 0, (pia6821_get_output_b(pia_ic5) & 0x01) ); |
| 1076 | 1076 | coin_lockout_w(device->machine, 1, (pia6821_get_output_b(pia_ic5) & 0x02) ); |
| 1077 | 1077 | coin_lockout_w(device->machine, 2, (pia6821_get_output_b(pia_ic5) & 0x04) ); |
| r10326 | r10327 | |
| 1082 | 1082 | |
| 1083 | 1083 | static WRITE_LINE_DEVICE_HANDLER( pia_ic5_ca2_w ) |
| 1084 | 1084 | { |
| 1085 | | LOG(("%s: IC5 PIA Write CA2 (Serial Tx) %2x\n",cpuexec_describe_context(device->machine),state)); |
| 1085 | LOG(("%s: IC5 PIA Write CA2 (Serial Tx) %2x\n",device->machine->describe_context(),state)); |
| 1086 | 1086 | serial_data = state; |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| r10326 | r10327 | |
| 1179 | 1179 | /* IC6, Reel A and B and AY registers (MODs below 4 only) */ |
| 1180 | 1180 | static WRITE8_DEVICE_HANDLER( pia_ic6_portb_w ) |
| 1181 | 1181 | { |
| 1182 | | LOG(("%s: IC6 PIA Port B Set to %2x (Reel A and B)\n", cpuexec_describe_context(device->machine),data)); |
| 1182 | LOG(("%s: IC6 PIA Port B Set to %2x (Reel A and B)\n", device->machine->describe_context(),data)); |
| 1183 | 1183 | |
| 1184 | 1184 | if (reel_mux == SEVEN_REEL) |
| 1185 | 1185 | { |
| r10326 | r10327 | |
| 1209 | 1209 | |
| 1210 | 1210 | static WRITE8_DEVICE_HANDLER( pia_ic6_porta_w ) |
| 1211 | 1211 | { |
| 1212 | | LOG(("%s: IC6 PIA Write A %2x\n", cpuexec_describe_context(device->machine),data)); |
| 1212 | LOG(("%s: IC6 PIA Write A %2x\n", device->machine->describe_context(),data)); |
| 1213 | 1213 | if (mod_number <4) |
| 1214 | 1214 | { |
| 1215 | 1215 | ay_data = data; |
| r10326 | r10327 | |
| 1220 | 1220 | |
| 1221 | 1221 | static WRITE_LINE_DEVICE_HANDLER( pia_ic6_ca2_w ) |
| 1222 | 1222 | { |
| 1223 | | LOG(("%s: IC6 PIA write CA2 %2x (AY8913 BC1)\n", cpuexec_describe_context(device->machine),state)); |
| 1223 | LOG(("%s: IC6 PIA write CA2 %2x (AY8913 BC1)\n", device->machine->describe_context(),state)); |
| 1224 | 1224 | if (mod_number <4) |
| 1225 | 1225 | { |
| 1226 | 1226 | if ( state ) ay8913_address |= 0x01; |
| r10326 | r10327 | |
| 1232 | 1232 | |
| 1233 | 1233 | static WRITE_LINE_DEVICE_HANDLER( pia_ic6_cb2_w ) |
| 1234 | 1234 | { |
| 1235 | | LOG(("%s: IC6 PIA write CB2 %2x (AY8913 BCDIR)\n", cpuexec_describe_context(device->machine),state)); |
| 1235 | LOG(("%s: IC6 PIA write CB2 %2x (AY8913 BCDIR)\n", device->machine->describe_context(),state)); |
| 1236 | 1236 | if (mod_number <4) |
| 1237 | 1237 | { |
| 1238 | 1238 | if ( state ) ay8913_address |= 0x02; |
| r10326 | r10327 | |
| 1262 | 1262 | /* IC7 Reel C and D, mechanical meters/Reel E and F, input strobe bit A */ |
| 1263 | 1263 | static WRITE8_DEVICE_HANDLER( pia_ic7_porta_w ) |
| 1264 | 1264 | { |
| 1265 | | LOG(("%s: IC7 PIA Port A Set to %2x (Reel C and D)\n", cpuexec_describe_context(device->machine),data)); |
| 1265 | LOG(("%s: IC7 PIA Port A Set to %2x (Reel C and D)\n", device->machine->describe_context(),data)); |
| 1266 | 1266 | if (reel_mux == SEVEN_REEL) |
| 1267 | 1267 | { |
| 1268 | 1268 | stepper_update(5, data&0x0F); |
| r10326 | r10327 | |
| 1338 | 1338 | |
| 1339 | 1339 | static WRITE_LINE_DEVICE_HANDLER( pia_ic7_ca2_w ) |
| 1340 | 1340 | { |
| 1341 | | LOG(("%s: IC7 PIA write CA2 %2x (input strobe bit 0 / LED A)\n", cpuexec_describe_context(device->machine),state)); |
| 1341 | LOG(("%s: IC7 PIA write CA2 %2x (input strobe bit 0 / LED A)\n", device->machine->describe_context(),state)); |
| 1342 | 1342 | |
| 1343 | 1343 | IC23GA = state; |
| 1344 | 1344 | ic24_setup(); |
| r10326 | r10327 | |
| 1373 | 1373 | static const char *const portnames[] = { "ORANGE1", "ORANGE2", "BLACK1", "BLACK2", "ORANGE1", "ORANGE2", "DIL1", "DIL2" }; |
| 1374 | 1374 | device_t *pia_ic5 = device->machine->device("pia_ic5"); |
| 1375 | 1375 | |
| 1376 | | LOG_IC8(("%s: IC8 PIA Read of Port A (MUX input data)\n", cpuexec_describe_context(device->machine))); |
| 1376 | LOG_IC8(("%s: IC8 PIA Read of Port A (MUX input data)\n", device->machine->describe_context())); |
| 1377 | 1377 | /* The orange inputs are polled twice as often as the black ones, for reasons of efficiency. |
| 1378 | 1378 | This is achieved via connecting every input line to an AND gate, thus allowing two strobes |
| 1379 | 1379 | to represent each orange input bank (strobes are active low). */ |
| r10326 | r10327 | |
| 1393 | 1393 | // duart.drive_sensor(data & 0x04, data & 0x01, data & 0x04, data & 0x02); |
| 1394 | 1394 | } |
| 1395 | 1395 | int i; |
| 1396 | | LOG_IC8(("%s: IC8 PIA Port B Set to %2x (OUTPUT PORT, TRIACS)\n", cpuexec_describe_context(device->machine),data)); |
| 1396 | LOG_IC8(("%s: IC8 PIA Port B Set to %2x (OUTPUT PORT, TRIACS)\n", device->machine->describe_context(),data)); |
| 1397 | 1397 | for (i = 0; i < 8; i++) |
| 1398 | 1398 | { |
| 1399 | 1399 | output_set_indexed_value("triac", i, data & (1 << i)); |
| r10326 | r10327 | |
| 1402 | 1402 | |
| 1403 | 1403 | static WRITE_LINE_DEVICE_HANDLER( pia_ic8_ca2_w ) |
| 1404 | 1404 | { |
| 1405 | | LOG_IC8(("%s: IC8 PIA write CA2 (input_strobe bit 2 / LED C) %02X\n", cpuexec_describe_context(device->machine), state & 0xFF)); |
| 1405 | LOG_IC8(("%s: IC8 PIA write CA2 (input_strobe bit 2 / LED C) %02X\n", device->machine->describe_context(), state & 0xFF)); |
| 1406 | 1406 | |
| 1407 | 1407 | IC23GC = state; |
| 1408 | 1408 | ic23_update(); |
| r10326 | r10327 | |
| 1411 | 1411 | |
| 1412 | 1412 | static WRITE_LINE_DEVICE_HANDLER( pia_ic8_cb2_w ) |
| 1413 | 1413 | { |
| 1414 | | LOG_IC8(("%s: IC8 PIA write CB2 (alpha clock) %02X\n", cpuexec_describe_context(device->machine), state & 0xFF)); |
| 1414 | LOG_IC8(("%s: IC8 PIA write CB2 (alpha clock) %02X\n", device->machine->describe_context(), state & 0xFF)); |
| 1415 | 1415 | |
| 1416 | 1416 | if ( !alpha_clock && (state) ) |
| 1417 | 1417 | { |
| r10326 | r10327 | |
| 1443 | 1443 | static WRITE8_DEVICE_HANDLER( pia_gb_porta_w ) |
| 1444 | 1444 | { |
| 1445 | 1445 | device_t *msm6376 = device->machine->device("msm6376"); |
| 1446 | | LOG_SS(("%s: GAMEBOARD: PIA Port A Set to %2x\n", cpuexec_describe_context(device->machine),data)); |
| 1446 | LOG_SS(("%s: GAMEBOARD: PIA Port A Set to %2x\n", device->machine->describe_context(),data)); |
| 1447 | 1447 | okim6376_w(msm6376, 0, data); |
| 1448 | 1448 | } |
| 1449 | 1449 | |
| r10326 | r10327 | |
| 1451 | 1451 | { |
| 1452 | 1452 | int changed = expansion_latch^data; |
| 1453 | 1453 | |
| 1454 | | LOG_SS(("%s: GAMEBOARD: PIA Port A Set to %2x\n", cpuexec_describe_context(device->machine),data)); |
| 1454 | LOG_SS(("%s: GAMEBOARD: PIA Port A Set to %2x\n", device->machine->describe_context(),data)); |
| 1455 | 1455 | |
| 1456 | 1456 | expansion_latch = data; |
| 1457 | 1457 | |
| r10326 | r10327 | |
| 1478 | 1478 | static READ8_DEVICE_HANDLER( pia_gb_portb_r ) |
| 1479 | 1479 | { |
| 1480 | 1480 | device_t *msm6376 = device->machine->device("msm6376"); |
| 1481 | | LOG_SS(("%s: GAMEBOARD: PIA Read of Port B\n",cpuexec_describe_context(device->machine))); |
| 1481 | LOG_SS(("%s: GAMEBOARD: PIA Read of Port B\n",device->machine->describe_context())); |
| 1482 | 1482 | // |
| 1483 | 1483 | // b7, 1 = OKI ready, 0 = OKI busy |
| 1484 | 1484 | // b5, vol clock |
| r10326 | r10327 | |
| 1490 | 1490 | |
| 1491 | 1491 | static WRITE_LINE_DEVICE_HANDLER( pia_gb_ca2_w ) |
| 1492 | 1492 | { |
| 1493 | | LOG_SS(("%s: GAMEBOARD: OKI RESET data = %02X\n", cpuexec_describe_context(device->machine), state)); |
| 1493 | LOG_SS(("%s: GAMEBOARD: OKI RESET data = %02X\n", device->machine->describe_context(), state)); |
| 1494 | 1494 | |
| 1495 | 1495 | // reset line |
| 1496 | 1496 | } |
src/mame/drivers/39in1.c
| r10326 | r10327 | |
| 95 | 95 | va_start( v, s_fmt ); |
| 96 | 96 | vsprintf( buf, s_fmt, v ); |
| 97 | 97 | va_end( v ); |
| 98 | | logerror( "%s: %s", cpuexec_describe_context(machine), buf ); |
| 99 | | //printf( "%s: %s", cpuexec_describe_context(machine), buf ); |
| 98 | logerror( "%s: %s", machine->describe_context(), buf ); |
| 99 | //printf( "%s: %s", machine->describe_context(), buf ); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| r10326 | r10327 | |
| 253 | 253 | |
| 254 | 254 | // Shut down any transfers that are currently going on, software should be smart enough to check if a |
| 255 | 255 | // transfer is running before starting another one on the same channel. |
| 256 | | if (timer_enabled(dma_regs->timer[channel])) |
| 256 | if (dma_regs->timer[channel]->enabled()) |
| 257 | 257 | { |
| 258 | | timer_adjust_oneshot(dma_regs->timer[channel], attotime::never, 0); |
| 258 | dma_regs->timer[channel]->adjust(attotime::never); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // Load the next descriptor |
| r10326 | r10327 | |
| 277 | 277 | break; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | | timer_adjust_oneshot(dma_regs->timer[channel], period, channel); |
| 280 | dma_regs->timer[channel]->adjust(period, channel); |
| 281 | 281 | |
| 282 | 282 | // Interrupt as necessary |
| 283 | 283 | if(dma_regs->dcmd[channel] & PXA255_DCMD_STARTIRQEN) |
| r10326 | r10327 | |
| 627 | 627 | attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[0] - ostimer_regs->oscr); |
| 628 | 628 | |
| 629 | 629 | //printf( "Adjusting one-shot timer to 200MHz * %08x\n", ostimer_regs->osmr[0]); |
| 630 | | timer_adjust_oneshot(ostimer_regs->timer[0], period, 0); |
| 630 | ostimer_regs->timer[0]->adjust(period); |
| 631 | 631 | } |
| 632 | 632 | break; |
| 633 | 633 | case PXA255_OSMR1: |
| r10326 | r10327 | |
| 637 | 637 | { |
| 638 | 638 | attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[1] - ostimer_regs->oscr); |
| 639 | 639 | |
| 640 | | timer_adjust_oneshot(ostimer_regs->timer[1], period, 1); |
| 640 | ostimer_regs->timer[1]->adjust(period, 1); |
| 641 | 641 | } |
| 642 | 642 | break; |
| 643 | 643 | case PXA255_OSMR2: |
| r10326 | r10327 | |
| 647 | 647 | { |
| 648 | 648 | attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[2] - ostimer_regs->oscr); |
| 649 | 649 | |
| 650 | | timer_adjust_oneshot(ostimer_regs->timer[2], period, 2); |
| 650 | ostimer_regs->timer[2]->adjust(period, 2); |
| 651 | 651 | } |
| 652 | 652 | break; |
| 653 | 653 | case PXA255_OSMR3: |
| r10326 | r10327 | |
| 657 | 657 | { |
| 658 | 658 | //attotime period = attotime::from_hz(3846400) * (ostimer_regs->osmr[3] - ostimer_regs->oscr); |
| 659 | 659 | |
| 660 | | //timer_adjust_oneshot(ostimer_regs->timer[3], period, 3); |
| 660 | //ostimer_regs->timer[3]->adjust(period, 3); |
| 661 | 661 | } |
| 662 | 662 | break; |
| 663 | 663 | case PXA255_OSCR: |
| r10326 | r10327 | |
| 684 | 684 | { |
| 685 | 685 | //attotime period = attotime::from_hz(200000000) * ostimer_regs->osmr[index]; |
| 686 | 686 | |
| 687 | | //timer_adjust_oneshot(ostimer_regs->timer[index], period, index); |
| 687 | //ostimer_regs->timer[index]->adjust(period, index); |
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | |
| r10326 | r10327 | |
| 1090 | 1090 | { |
| 1091 | 1091 | attotime period = attotime::from_hz(20000000) * (lcd_regs->dma[channel].ldcmd & 0x000fffff); |
| 1092 | 1092 | |
| 1093 | | timer_adjust_oneshot(lcd_regs->dma[channel].eof, period, channel); |
| 1093 | lcd_regs->dma[channel].eof->adjust(period, channel); |
| 1094 | 1094 | |
| 1095 | 1095 | if(lcd_regs->dma[channel].ldcmd & PXA255_LDCMD_SOFINT) |
| 1096 | 1096 | { |
| r10326 | r10327 | |
| 1263 | 1263 | case PXA255_FBR0: // 0x44000020 |
| 1264 | 1264 | verboselog( space->machine, 4l, "pxa255_lcd_w: LCD Frame Branch Register 0: %08x & %08x\n", data, mem_mask ); |
| 1265 | 1265 | lcd_regs->fbr[0] = data & 0xfffffff3; |
| 1266 | | if(!timer_enabled(lcd_regs->dma[0].eof)) |
| 1266 | if(!lcd_regs->dma[0].eof->enabled()) |
| 1267 | 1267 | { |
| 1268 | 1268 | if (0) verboselog( space->machine, 3, "ch0 EOF timer is not enabled, taking branch now\n" ); |
| 1269 | 1269 | pxa255_lcd_check_load_next_branch(space->machine, 0); |
| r10326 | r10327 | |
| 1273 | 1273 | case PXA255_FBR1: // 0x44000024 |
| 1274 | 1274 | verboselog( space->machine, 3, "pxa255_lcd_w: LCD Frame Branch Register 1: %08x & %08x\n", data, mem_mask ); |
| 1275 | 1275 | lcd_regs->fbr[1] = data & 0xfffffff3; |
| 1276 | | if(!timer_enabled(lcd_regs->dma[1].eof)) |
| 1276 | if(!lcd_regs->dma[1].eof->enabled()) |
| 1277 | 1277 | { |
| 1278 | 1278 | verboselog( space->machine, 3, "ch1 EOF timer is not enabled, taking branch now\n" ); |
| 1279 | 1279 | pxa255_lcd_check_load_next_branch(space->machine, 1); |
| r10326 | r10327 | |
| 1298 | 1298 | break; |
| 1299 | 1299 | case PXA255_FDADR0: // 0x44000200 |
| 1300 | 1300 | verboselog( space->machine, 4, "pxa255_lcd_w: LCD DMA Frame Descriptor Address Register 0: %08x & %08x\n", data, mem_mask ); |
| 1301 | | if(!timer_enabled(lcd_regs->dma[0].eof)) |
| 1301 | if(!lcd_regs->dma[0].eof->enabled()) |
| 1302 | 1302 | { |
| 1303 | 1303 | pxa255_lcd_load_dma_descriptor(space, data & 0xfffffff0, 0); |
| 1304 | 1304 | } |
| r10326 | r10327 | |
| 1319 | 1319 | break; |
| 1320 | 1320 | case PXA255_FDADR1: // 0x44000210 |
| 1321 | 1321 | verboselog( space->machine, 4, "pxa255_lcd_w: LCD DMA Frame Descriptor Address Register 1: %08x & %08x\n", data, mem_mask ); |
| 1322 | | if(!timer_enabled(lcd_regs->dma[1].eof)) |
| 1322 | if(!lcd_regs->dma[1].eof->enabled()) |
| 1323 | 1323 | { |
| 1324 | 1324 | pxa255_lcd_load_dma_descriptor(space, data & 0xfffffff0, 1); |
| 1325 | 1325 | } |
src/mame/drivers/galpani2.c
| r10326 | r10327 | |
| 77 | 77 | |
| 78 | 78 | kaneko16_sprite_xoffs = 0x10000 - 0x16c0 + 0xc00; |
| 79 | 79 | kaneko16_sprite_yoffs = 0x000; |
| 80 | | cpuexec_boost_interleave(machine, attotime::zero, attotime::from_usec(50)); //initial mcu xchk |
| 80 | machine->scheduler().boost_interleave(attotime::zero, attotime::from_usec(50)); //initial mcu xchk |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | static void galpani2_write_kaneko(device_t *device) |
| r10326 | r10327 | |
| 143 | 143 | if (mcu_command != 0) |
| 144 | 144 | { |
| 145 | 145 | logerror("%s : MCU [$%06X] endidx = $%02X / command = $%02X addr = $%04X ? = $%02X.\n", |
| 146 | | cpuexec_describe_context(machine), |
| 146 | machine->describe_context(), |
| 147 | 147 | mcu_list, |
| 148 | 148 | srcspace->read_byte(0x100020), |
| 149 | 149 | mcu_command, |
| r10326 | r10327 | |
| 166 | 166 | |
| 167 | 167 | mcu_size = (srcspace->read_byte(mcu_address + 8)<<8) + |
| 168 | 168 | (srcspace->read_byte(mcu_address + 9)<<0) ; |
| 169 | | logerror("%s : MCU executes command $%02X, %04X %02X-> %04x\n",cpuexec_describe_context(machine),mcu_command,mcu_src,mcu_size,mcu_dst); |
| 169 | logerror("%s : MCU executes command $%02X, %04X %02X-> %04x\n",machine->describe_context(),mcu_command,mcu_src,mcu_size,mcu_dst); |
| 170 | 170 | |
| 171 | 171 | for( ; mcu_size > 0 ; mcu_size-- ) |
| 172 | 172 | { |
| r10326 | r10327 | |
| 191 | 191 | mcu_size = (srcspace->read_byte(mcu_address + 8)<<8) + |
| 192 | 192 | (srcspace->read_byte(mcu_address + 9)<<0) ; |
| 193 | 193 | |
| 194 | | logerror("%s : MCU executes command $%02X, %04X %02X-> %04x\n",cpuexec_describe_context(machine),mcu_command,mcu_src,mcu_size,mcu_dst); |
| 194 | logerror("%s : MCU executes command $%02X, %04X %02X-> %04x\n",machine->describe_context(),mcu_command,mcu_src,mcu_size,mcu_dst); |
| 195 | 195 | |
| 196 | 196 | for( ; mcu_size > 0 ; mcu_size-- ) |
| 197 | 197 | { |
| r10326 | r10327 | |
| 219 | 219 | srcspace->write_byte(mcu_address+0,0xff); |
| 220 | 220 | srcspace->write_byte(mcu_address+1,0xff); |
| 221 | 221 | |
| 222 | | logerror("%s : MCU ERROR, unknown command $%02X\n",cpuexec_describe_context(machine),mcu_command); |
| 222 | logerror("%s : MCU ERROR, unknown command $%02X\n",machine->describe_context(),mcu_command); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /* Erase command (so that it won't be processed again)? */ |
| r10326 | r10327 | |
| 230 | 230 | static void galpani2_mcu_nmi2(running_machine *machine) |
| 231 | 231 | { |
| 232 | 232 | galpani2_write_kaneko(machine->device("maincpu")); |
| 233 | | //logerror("%s : MCU executes CHECKs synchro\n", cpuexec_describe_context(machine)); |
| 233 | //logerror("%s : MCU executes CHECKs synchro\n", machine->describe_context()); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | static WRITE8_HANDLER( galpani2_mcu_nmi1_w ) //driven by CPU1's int5 ISR |
| r10326 | r10327 | |
| 276 | 276 | static WRITE8_DEVICE_HANDLER( galpani2_oki1_bank_w ) |
| 277 | 277 | { |
| 278 | 278 | UINT8 *ROM = device->machine->region("oki1")->base(); |
| 279 | | logerror("%s : %s bank %08X\n",cpuexec_describe_context(device->machine),device->tag(),data); |
| 279 | logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); |
| 280 | 280 | memcpy(ROM + 0x30000, ROM + 0x40000 + 0x10000 * (~data & 0xf), 0x10000); |
| 281 | 281 | } |
| 282 | 282 | |
| r10326 | r10327 | |
| 284 | 284 | { |
| 285 | 285 | okim6295_device *oki = downcast<okim6295_device *>(device); |
| 286 | 286 | oki->set_bank_base(0x40000 * (data & 0xf) ); |
| 287 | | logerror("%s : %s bank %08X\n",cpuexec_describe_context(device->machine),device->tag(),data); |
| 287 | logerror("%s : %s bank %08X\n",device->machine->describe_context(),device->tag(),data); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | |
src/mame/drivers/blitz68k.c
| r10326 | r10327 | |
| 451 | 451 | int x, y, x_size, y_size; |
| 452 | 452 | UINT32 src; |
| 453 | 453 | |
| 454 | | logerror("%s: blit x=%02x y=%02x w=%02x h=%02x addr=%02x%02x%02x pens=%02x %02x %02x %02x flag=%02x %02x %02x %02x - %02x %02x %02x %02x\n", cpuexec_describe_context(space->machine), |
| 454 | logerror("%s: blit x=%02x y=%02x w=%02x h=%02x addr=%02x%02x%02x pens=%02x %02x %02x %02x flag=%02x %02x %02x %02x - %02x %02x %02x %02x\n", space->machine->describe_context(), |
| 455 | 455 | blit.x, blit.y, blit.w, blit.h, |
| 456 | 456 | blit.addr[2], blit.addr[1], blit.addr[0], |
| 457 | 457 | blit.pen[0], blit.pen[1], blit.pen[2], blit.pen[3], |
| r10326 | r10327 | |
| 645 | 645 | static READ8_HANDLER( bankrob_mcu1_r ) |
| 646 | 646 | { |
| 647 | 647 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 648 | | logerror("%s: mcu1 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 648 | logerror("%s: mcu1 reads %02x\n", space->machine->describe_context(), ret); |
| 649 | 649 | return ret; |
| 650 | 650 | } |
| 651 | 651 | static READ8_HANDLER( bankrob_mcu2_r ) |
| 652 | 652 | { |
| 653 | 653 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 654 | | logerror("%s: mcu2 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 654 | logerror("%s: mcu2 reads %02x\n", space->machine->describe_context(), ret); |
| 655 | 655 | return ret; |
| 656 | 656 | } |
| 657 | 657 | |
| r10326 | r10327 | |
| 667 | 667 | |
| 668 | 668 | static WRITE8_HANDLER( bankrob_mcu1_w ) |
| 669 | 669 | { |
| 670 | | logerror("%s: mcu1 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 670 | logerror("%s: mcu1 written with %02x\n", space->machine->describe_context(), data); |
| 671 | 671 | } |
| 672 | 672 | static WRITE8_HANDLER( bankrob_mcu2_w ) |
| 673 | 673 | { |
| 674 | | logerror("%s: mcu2 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 674 | logerror("%s: mcu2 written with %02x\n", space->machine->describe_context(), data); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | static ADDRESS_MAP_START( bankrob_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r10326 | r10327 | |
| 728 | 728 | static READ8_HANDLER( bankroba_mcu1_r ) |
| 729 | 729 | { |
| 730 | 730 | UINT8 ret = space->machine->rand(); // space->machine->rand() gives "interesting" results |
| 731 | | logerror("%s: mcu1 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 731 | logerror("%s: mcu1 reads %02x\n", space->machine->describe_context(), ret); |
| 732 | 732 | return ret; |
| 733 | 733 | } |
| 734 | 734 | static READ8_HANDLER( bankroba_mcu2_r ) |
| 735 | 735 | { |
| 736 | 736 | UINT8 ret = space->machine->rand(); // space->machine->rand() gives "interesting" results |
| 737 | | logerror("%s: mcu2 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 737 | logerror("%s: mcu2 reads %02x\n", space->machine->describe_context(), ret); |
| 738 | 738 | return ret; |
| 739 | 739 | } |
| 740 | 740 | |
| r10326 | r10327 | |
| 749 | 749 | |
| 750 | 750 | static WRITE8_HANDLER( bankroba_mcu1_w ) |
| 751 | 751 | { |
| 752 | | logerror("%s: mcu1 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 752 | logerror("%s: mcu1 written with %02x\n", space->machine->describe_context(), data); |
| 753 | 753 | } |
| 754 | 754 | static WRITE8_HANDLER( bankroba_mcu2_w ) |
| 755 | 755 | { |
| 756 | | logerror("%s: mcu2 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 756 | logerror("%s: mcu2 written with %02x\n", space->machine->describe_context(), data); |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | static ADDRESS_MAP_START( bankroba_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r10326 | r10327 | |
| 884 | 884 | static READ16_HANDLER( cjffruit_mcu_r ) |
| 885 | 885 | { |
| 886 | 886 | UINT8 ret = 0x00; // space->machine->rand() gives "interesting" results |
| 887 | | logerror("%s: mcu reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 887 | logerror("%s: mcu reads %02x\n", space->machine->describe_context(), ret); |
| 888 | 888 | return ret << 8; |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | static WRITE16_HANDLER( cjffruit_mcu_w ) |
| 892 | 892 | { |
| 893 | | logerror("%s: mcu written with %02x\n", cpuexec_describe_context(space->machine),data >> 8); |
| 893 | logerror("%s: mcu written with %02x\n", space->machine->describe_context(),data >> 8); |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | static ADDRESS_MAP_START( cjffruit_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r10326 | r10327 | |
| 935 | 935 | static READ16_HANDLER( deucesw2_mcu_r ) |
| 936 | 936 | { |
| 937 | 937 | UINT8 ret = 0x00; // space->machine->rand() gives "interesting" results |
| 938 | | logerror("%s: mcu reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 938 | logerror("%s: mcu reads %02x\n", space->machine->describe_context(), ret); |
| 939 | 939 | return ret << 8; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | static WRITE16_HANDLER( deucesw2_mcu_w ) |
| 943 | 943 | { |
| 944 | | logerror("%s: mcu written with %02x\n", cpuexec_describe_context(space->machine),data >> 8); |
| 944 | logerror("%s: mcu written with %02x\n", space->machine->describe_context(),data >> 8); |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | static WRITE16_HANDLER( deucesw2_leds1_w ) |
| r10326 | r10327 | |
| 1031 | 1031 | static READ8_HANDLER( dualgame_mcu1_r ) |
| 1032 | 1032 | { |
| 1033 | 1033 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 1034 | | logerror("%s: mcu1 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 1034 | logerror("%s: mcu1 reads %02x\n", space->machine->describe_context(), ret); |
| 1035 | 1035 | return ret; |
| 1036 | 1036 | } |
| 1037 | 1037 | static READ8_HANDLER( dualgame_mcu2_r ) |
| 1038 | 1038 | { |
| 1039 | 1039 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 1040 | | logerror("%s: mcu2 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 1040 | logerror("%s: mcu2 reads %02x\n", space->machine->describe_context(), ret); |
| 1041 | 1041 | return ret; |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| r10326 | r10327 | |
| 1053 | 1053 | |
| 1054 | 1054 | static WRITE8_HANDLER( dualgame_mcu1_w ) |
| 1055 | 1055 | { |
| 1056 | | logerror("%s: mcu1 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 1056 | logerror("%s: mcu1 written with %02x\n", space->machine->describe_context(), data); |
| 1057 | 1057 | } |
| 1058 | 1058 | static WRITE8_HANDLER( dualgame_mcu2_w ) |
| 1059 | 1059 | { |
| 1060 | | logerror("%s: mcu2 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 1060 | logerror("%s: mcu2 written with %02x\n", space->machine->describe_context(), data); |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | static ADDRESS_MAP_START( dualgame_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r10326 | r10327 | |
| 1119 | 1119 | static READ16_HANDLER( hermit_mcu_r ) |
| 1120 | 1120 | { |
| 1121 | 1121 | UINT8 ret = 0x00; // space->machine->rand() gives "interesting" results |
| 1122 | | logerror("%s: mcu reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 1122 | logerror("%s: mcu reads %02x\n", space->machine->describe_context(), ret); |
| 1123 | 1123 | return ret << 8; |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | static WRITE16_HANDLER( hermit_mcu_w ) |
| 1127 | 1127 | { |
| 1128 | | logerror("%s: mcu written with %02x\n", cpuexec_describe_context(space->machine),data >> 8); |
| 1128 | logerror("%s: mcu written with %02x\n", space->machine->describe_context(),data >> 8); |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | static WRITE16_HANDLER( hermit_leds1_w ) |
| r10326 | r10327 | |
| 1198 | 1198 | static READ8_HANDLER( maxidbl_mcu1_r ) |
| 1199 | 1199 | { |
| 1200 | 1200 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 1201 | | logerror("%s: mcu1 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 1201 | logerror("%s: mcu1 reads %02x\n", space->machine->describe_context(), ret); |
| 1202 | 1202 | return ret; |
| 1203 | 1203 | } |
| 1204 | 1204 | static READ8_HANDLER( maxidbl_mcu2_r ) |
| 1205 | 1205 | { |
| 1206 | 1206 | UINT8 ret = 0; // space->machine->rand() gives "interesting" results |
| 1207 | | logerror("%s: mcu2 reads %02x\n", cpuexec_describe_context(space->machine), ret); |
| 1207 | logerror("%s: mcu2 reads %02x\n", space->machine->describe_context(), ret); |
| 1208 | 1208 | return ret; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| r10326 | r10327 | |
| 1220 | 1220 | |
| 1221 | 1221 | static WRITE8_HANDLER( maxidbl_mcu1_w ) |
| 1222 | 1222 | { |
| 1223 | | logerror("%s: mcu1 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 1223 | logerror("%s: mcu1 written with %02x\n", space->machine->describe_context(), data); |
| 1224 | 1224 | } |
| 1225 | 1225 | static WRITE8_HANDLER( maxidbl_mcu2_w ) |
| 1226 | 1226 | { |
| 1227 | | logerror("%s: mcu2 written with %02x\n", cpuexec_describe_context(space->machine), data); |
| 1227 | logerror("%s: mcu2 written with %02x\n", space->machine->describe_context(), data); |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | static ADDRESS_MAP_START( maxidbl_map, ADDRESS_SPACE_PROGRAM, 16 ) |
src/mame/drivers/equites.c
| r10326 | r10327 | |
| 381 | 381 | #define FRQ_ADJUSTER_TAG "FRQ" |
| 382 | 382 | |
| 383 | 383 | // MSM5232 clock is generated by a transistor oscillator circuit, not by the pcb xtal |
| 384 | | // The circuit is controlled by a pot to allow adjusting the frequency |
| 384 | // The circuit is controlled by a pot to allow adjusting the frequency. All games |
| 385 | // have been hand-tuned to a recording claiming to be an original recording from the |
| 386 | // boards. You can adjust this in the Slider Controls while using -cheat if needed. |
| 387 | |
| 385 | 388 | #define MSM5232_MAX_CLOCK 6144000 |
| 386 | 389 | #define MSM5232_MIN_CLOCK 214000 // unstable |
| 387 | 390 | |
| 388 | 391 | |
| 392 | |
| 393 | |
| 389 | 394 | /******************************************************************************/ |
| 390 | 395 | // Sound |
| 391 | 396 | |
| r10326 | r10327 | |
| 417 | 422 | state->nmi_timer = machine->scheduler().timer_alloc(FUNC(equites_nmi_callback)); |
| 418 | 423 | |
| 419 | 424 | state->adjuster_timer = machine->scheduler().timer_alloc(FUNC(equites_frq_adjuster_callback)); |
| 420 | | timer_adjust_periodic(state->adjuster_timer, attotime::from_hz(60), 0, attotime::from_hz(60)); |
| 425 | state->adjuster_timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60)); |
| 421 | 426 | } |
| 422 | 427 | |
| 423 | 428 | static WRITE8_HANDLER(equites_c0f8_w) |
| r10326 | r10327 | |
| 592 | 597 | { |
| 593 | 598 | case 0: //logerror( "8155 Command register write %x, timer command = %x, interrupt enable = %x, ports = %x\n", data, (data >> 6) & 3, (data >> 4) & 3, data & 0xf ); |
| 594 | 599 | if (((data >> 6) & 3) == 3) |
| 595 | | timer_adjust_periodic(state->nmi_timer, attotime::from_hz(XTAL_6_144MHz/2 / state->timer_count), 0, attotime::from_hz(XTAL_6_144MHz/2 / state->timer_count)); |
| 600 | state->nmi_timer->adjust(attotime::from_hz(XTAL_6_144MHz/2 / state->timer_count), 0, attotime::from_hz(XTAL_6_144MHz/2 / state->timer_count)); |
| 596 | 601 | break; |
| 597 | 602 | case 1: //logerror( "8155 I/O Port A write %x\n", data ); |
| 598 | 603 | state->eq8155_port_a = data; |
| r10326 | r10327 | |
| 820 | 825 | |
| 821 | 826 | /* this is actually a variable resistor */ |
| 822 | 827 | PORT_START(FRQ_ADJUSTER_TAG) |
| 823 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 828 | PORT_ADJUSTER(25, "MSM5232 Clock") |
| 824 | 829 | INPUT_PORTS_END |
| 825 | 830 | |
| 826 | 831 | /******************************************************************************/ |
| r10326 | r10327 | |
| 846 | 851 | |
| 847 | 852 | /* this is actually a variable resistor */ |
| 848 | 853 | PORT_START(FRQ_ADJUSTER_TAG) |
| 849 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 854 | PORT_ADJUSTER(24, "MSM5232 Clock") |
| 850 | 855 | INPUT_PORTS_END |
| 851 | 856 | |
| 852 | 857 | /******************************************************************************/ |
| r10326 | r10327 | |
| 882 | 887 | |
| 883 | 888 | /* this is actually a variable resistor */ |
| 884 | 889 | PORT_START(FRQ_ADJUSTER_TAG) |
| 885 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 890 | PORT_ADJUSTER(33, "MSM5232 Clock") |
| 886 | 891 | INPUT_PORTS_END |
| 887 | 892 | |
| 888 | 893 | /******************************************************************************/ |
| r10326 | r10327 | |
| 894 | 899 | EQUITES_PLAYER_INPUT_MSB( IPT_BUTTON1, IPT_BUTTON2, IPT_BUTTON3, IPT_START2 ) |
| 895 | 900 | |
| 896 | 901 | PORT_START("IN1") |
| 897 | | // PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_COIN1 ) |
| 898 | | // PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 902 | // PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_COIN1 ) |
| 903 | // PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 899 | 904 | PORT_BIT( 0x0300, IP_ACTIVE_HIGH, IPT_COIN1 ) |
| 900 | 905 | #if EASY_TEST_MODE |
| 901 | 906 | PORT_SERVICE( 0x0300, IP_ACTIVE_HIGH ) |
| r10326 | r10327 | |
| 919 | 924 | |
| 920 | 925 | /* this is actually a variable resistor */ |
| 921 | 926 | PORT_START(FRQ_ADJUSTER_TAG) |
| 922 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 927 | PORT_ADJUSTER(33, "MSM5232 Clock") |
| 923 | 928 | INPUT_PORTS_END |
| 924 | 929 | |
| 925 | 930 | /******************************************************************************/ |
| r10326 | r10327 | |
| 955 | 960 | |
| 956 | 961 | /* this is actually a variable resistor */ |
| 957 | 962 | PORT_START(FRQ_ADJUSTER_TAG) |
| 958 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 963 | PORT_ADJUSTER(28, "MSM5232 Clock") |
| 959 | 964 | INPUT_PORTS_END |
| 960 | 965 | |
| 961 | 966 | /******************************************************************************/ |
| r10326 | r10327 | |
| 1024 | 1029 | |
| 1025 | 1030 | /* this is actually a variable resistor */ |
| 1026 | 1031 | PORT_START(FRQ_ADJUSTER_TAG) |
| 1027 | | PORT_ADJUSTER(50, "MSM5232 Clock") |
| 1032 | PORT_ADJUSTER(27, "MSM5232 Clock") |
| 1028 | 1033 | INPUT_PORTS_END |
| 1029 | 1034 | |
| 1030 | 1035 | /******************************************************************************/ |
src/mame/drivers/igs011.c
| r10326 | r10327 | |
| 865 | 865 | break; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | | logerror("%s: warning, unknown igs011_prot1_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 868 | logerror("%s: warning, unknown igs011_prot1_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 869 | 869 | } |
| 870 | 870 | static READ16_HANDLER( igs011_prot1_r ) |
| 871 | 871 | { |
| r10326 | r10327 | |
| 937 | 937 | igs011_prot2++; |
| 938 | 938 | } |
| 939 | 939 | // else |
| 940 | | // logerror("%s: warning, unknown igs011_prot2_inc_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 940 | // logerror("%s: warning, unknown igs011_prot2_inc_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | // vbowl (33) |
| r10326 | r10327 | |
| 948 | 948 | igs011_prot2--; |
| 949 | 949 | } |
| 950 | 950 | // else |
| 951 | | // logerror("%s: warning, unknown igs011_prot2_dec_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 951 | // logerror("%s: warning, unknown igs011_prot2_dec_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | |
| r10326 | r10327 | |
| 964 | 964 | igs011_prot2 = ((BIT(x,3)&BIT(x,0))<<4) | (BIT(x,2)<<3) | ((BIT(x,0)|BIT(x,1))<<2) | ((BIT(x,2)^BIT(x,4)^1)<<1) | (BIT(x,1)^1^BIT(x,3)); |
| 965 | 965 | } |
| 966 | 966 | // else |
| 967 | | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 967 | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | // lhb, xymg, lhb2 |
| r10326 | r10327 | |
| 979 | 979 | igs011_prot2 = (((BIT(x,0)^1)|BIT(x,1))<<2) | (BIT(x,2)<<1) | (BIT(x,0)&BIT(x,1)); |
| 980 | 980 | } |
| 981 | 981 | // else |
| 982 | | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 982 | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | // wlcc |
| r10326 | r10327 | |
| 994 | 994 | igs011_prot2 = ((BIT(x,3)^BIT(x,2))<<4) | ((BIT(x,2)^BIT(x,1))<<3) | ((BIT(x,1)^BIT(x,0))<<2) | ((BIT(x,4)^BIT(x,0)^1)<<1) | (BIT(x,4)^BIT(x,3)^1); |
| 995 | 995 | } |
| 996 | 996 | // else |
| 997 | | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 997 | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | // vbowl |
| r10326 | r10327 | |
| 1009 | 1009 | igs011_prot2 = ((BIT(x,3)^BIT(x,2))<<4) | ((BIT(x,2)^BIT(x,1))<<3) | ((BIT(x,1)^BIT(x,0))<<2) | ((BIT(x,4)^BIT(x,0))<<1) | (BIT(x,4)^BIT(x,3)); |
| 1010 | 1010 | } |
| 1011 | 1011 | // else |
| 1012 | | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", cpuexec_describe_context(space->machine), offset, data); |
| 1012 | // logerror("%s: warning, unknown igs011_prot2_swap_w( %04x, %04x )\n", space->machine->describe_context(), offset, data); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | |
| r10326 | r10327 | |
| 1128 | 1128 | igs012_prot_mode = igs012_prot_mode ^ 1; |
| 1129 | 1129 | } |
| 1130 | 1130 | else |
| 1131 | | logerror("%s: warning, unknown igs012_prot_mode_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1131 | logerror("%s: warning, unknown igs012_prot_mode_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | static WRITE16_HANDLER( igs012_prot_inc_w ) |
| r10326 | r10327 | |
| 1138 | 1138 | igs012_prot = (igs012_prot + 1) & 0x1f; |
| 1139 | 1139 | } |
| 1140 | 1140 | else |
| 1141 | | logerror("%s: warning, unknown igs012_prot_inc_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1141 | logerror("%s: warning, unknown igs012_prot_inc_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | static WRITE16_HANDLER( igs012_prot_dec_inc_w ) |
| r10326 | r10327 | |
| 1152 | 1152 | igs012_prot = (igs012_prot + 1) & 0x1f; |
| 1153 | 1153 | } |
| 1154 | 1154 | else |
| 1155 | | logerror("%s: warning, unknown igs012_prot_dec_inc_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1155 | logerror("%s: warning, unknown igs012_prot_dec_inc_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | static WRITE16_HANDLER( igs012_prot_dec_copy_w ) |
| r10326 | r10327 | |
| 1166 | 1166 | igs012_prot = (igs012_prot - 1) & 0x1f; |
| 1167 | 1167 | } |
| 1168 | 1168 | else |
| 1169 | | logerror("%s: warning, unknown igs012_prot_dec_copy_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1169 | logerror("%s: warning, unknown igs012_prot_dec_copy_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | 1172 | static WRITE16_HANDLER( igs012_prot_copy_w ) |
| r10326 | r10327 | |
| 1176 | 1176 | igs012_prot = igs012_prot_swap; |
| 1177 | 1177 | } |
| 1178 | 1178 | else |
| 1179 | | logerror("%s: warning, unknown igs012_prot_copy_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1179 | logerror("%s: warning, unknown igs012_prot_copy_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | static WRITE16_HANDLER( igs012_prot_swap_w ) |
| r10326 | r10327 | |
| 1188 | 1188 | igs012_prot_swap = (((BIT(x,3)|BIT(x,1))^1)<<3) | ((BIT(x,2)&BIT(x,1))<<2) | ((BIT(x,3)^BIT(x,0))<<1) | (BIT(x,2)^1); |
| 1189 | 1189 | } |
| 1190 | 1190 | else |
| 1191 | | logerror("%s: warning, unknown igs012_prot_swap_w( %04x, %04x ), mode %x\n", cpuexec_describe_context(space->machine), offset, data, igs012_prot_mode); |
| 1191 | logerror("%s: warning, unknown igs012_prot_swap_w( %04x, %04x ), mode %x\n", space->machine->describe_context(), offset, data, igs012_prot_mode); |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | static READ16_HANDLER( igs012_prot_r ) |
| r10326 | r10327 | |
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | if ( data & (~0x200) ) |
| 2079 | | logerror("%s: warning, unknown bits written in oki bank = %02x\n", cpuexec_describe_context(device->machine), data); |
| 2079 | logerror("%s: warning, unknown bits written in oki bank = %02x\n", device->machine->describe_context(), data); |
| 2080 | 2080 | |
| 2081 | 2081 | // popmessage("oki %04x",data); |
| 2082 | 2082 | } |
src/emu/cpu/tms57002/tms57002.c
| r10326 | r10327 | |
| 1 | 1 | #include "emu.h" |
| 2 | 2 | #include "debugger.h" |
| 3 | 3 | #include "tms57002.h" |
| 4 | #include "tms57kpr.h" |
| 4 | 5 | |
| 5 | | CPU_DISASSEMBLE(tms57002); |
| 6 | | |
| 7 | | #ifdef __GNUC__ |
| 8 | | #define noinline __attribute__((noinline)) |
| 9 | | #else |
| 10 | | #define noinline /* */ |
| 11 | | #endif |
| 12 | | |
| 13 | | enum { |
| 14 | | IN_PLOAD = 0x00000001, |
| 15 | | IN_CLOAD = 0x00000002, |
| 16 | | SU_CVAL = 0x00000004, |
| 17 | | SU_MASK = 0x00000018, SU_ST0 = 0x00, SU_ST1 = 0x08, SU_PRG = 0x10, |
| 18 | | S_IDLE = 0x00000020, |
| 19 | | S_READ = 0x00000040, |
| 20 | | S_WRITE = 0x00000080, |
| 21 | | S_BRANCH = 0x00000100, |
| 22 | | S_HOST = 0x00000200 |
| 23 | | }; |
| 24 | | |
| 25 | | enum { |
| 26 | | ST0_INCS = 0x000001, |
| 27 | | ST0_DIRI = 0x000002, |
| 28 | | ST0_FI = 0x000004, |
| 29 | | ST0_SIM = 0x000008, |
| 30 | | ST0_PLRI = 0x000020, |
| 31 | | ST0_PBCI = 0x000040, |
| 32 | | ST0_DIRO = 0x000080, |
| 33 | | ST0_FO = 0x000100, |
| 34 | | ST0_SOM = 0x000600, |
| 35 | | ST0_PLRO = 0x000800, |
| 36 | | ST0_PBCO = 0x001000, |
| 37 | | ST0_CNS = 0x002000, |
| 38 | | ST0_WORD = 0x004000, |
| 39 | | ST0_SEL = 0x008000, |
| 40 | | ST0_M = 0x030000, ST0_M_64K = 0x000000, ST0_M_256K = 0x010000, ST0_M_1M = 0x020000, |
| 41 | | ST0_SRAM = 0x200000, |
| 42 | | |
| 43 | | ST1_AOV = 0x000001, |
| 44 | | ST1_SFAI = 0x000002, |
| 45 | | ST1_SFAO = 0x000004, |
| 46 | | ST1_MOVM = 0x000020, |
| 47 | | ST1_MOV = 0x000040, |
| 48 | | ST1_SFMA = 0x000180, ST1_SFMA_SHIFT = 7, |
| 49 | | ST1_SFMO = 0x001800, ST1_SFMO_SHIFT = 11, |
| 50 | | ST1_RND = 0x038000, ST1_RND_SHIFT = 15, |
| 51 | | ST1_CRM = 0x0C0000, ST1_CRM_SHIFT = 18, ST1_CRM_32 = 0x000000, ST1_CRM_16H = 0x040000, ST1_CRM_16L = 0x080000, |
| 52 | | ST1_DBP = 0x100000, |
| 53 | | ST1_CAS = 0x200000, |
| 54 | | |
| 55 | | ST1_CACHE = ST1_SFAI|ST1_SFAO|ST1_MOVM|ST1_SFMA|ST1_SFMO|ST1_RND|ST1_CRM|ST1_DBP |
| 56 | | }; |
| 57 | | |
| 58 | | enum { BR_UB, BR_CB, BR_IDLE }; |
| 59 | | |
| 60 | | enum { IBS = 8192, HBS = 4096 }; |
| 61 | | |
| 62 | | typedef struct { |
| 63 | | unsigned short op; |
| 64 | | short next; |
| 65 | | unsigned char param; |
| 66 | | } icd; |
| 67 | | |
| 68 | | typedef struct { |
| 69 | | unsigned int st1; |
| 70 | | short ipc; |
| 71 | | short next; |
| 72 | | } hcd; |
| 73 | | |
| 74 | | typedef struct { |
| 75 | | short hashbase[256]; |
| 76 | | hcd hashnode[HBS]; |
| 77 | | icd inst[IBS]; |
| 78 | | int hused, iused; |
| 79 | | } cd; |
| 80 | | |
| 81 | | typedef struct { |
| 82 | | int branch; |
| 83 | | short hnode; |
| 84 | | short ipc; |
| 85 | | } cstate; |
| 86 | | |
| 87 | | typedef struct { |
| 88 | | INT64 macc; |
| 89 | | |
| 90 | | UINT32 cmem[256]; |
| 91 | | UINT32 dmem0[256]; |
| 92 | | UINT32 dmem1[32]; |
| 93 | | |
| 94 | | UINT32 si[4], so[4]; |
| 95 | | |
| 96 | | UINT32 st0, st1, sti; |
| 97 | | UINT32 aacc, xoa, xba, xwr, xrd, creg; |
| 98 | | |
| 99 | | UINT8 pc, ca, id, ba0, ba1, rptc, rptc_next, sa; |
| 100 | | |
| 101 | | UINT32 xm_adr; |
| 102 | | |
| 103 | | UINT8 host[4], hidx, allow_update; |
| 104 | | |
| 105 | | cd cache; |
| 106 | | |
| 107 | | address_space *program, *data; |
| 108 | | int icount; |
| 109 | | int unsupported_inst_warning; |
| 110 | | } tms57002_t; |
| 111 | | |
| 112 | 6 | INLINE tms57002_t *get_safe_token(device_t *device) |
| 113 | 7 | { |
| 114 | 8 | assert(device != NULL); |
| r10326 | r10327 | |
| 1018 | 912 | } |
| 1019 | 913 | #endif |
| 1020 | 914 | |
| 1021 | | INLINE int xmode(UINT32 opcode, char type) |
| 1022 | | { |
| 1023 | | if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) { |
| 1024 | | if(opcode & 0x100) |
| 1025 | | return 0; |
| 1026 | | else if(opcode & 0x80) |
| 1027 | | return 2; |
| 1028 | | else |
| 1029 | | return 1; |
| 1030 | | } else if(opcode & 0x200) |
| 1031 | | return 2; |
| 1032 | | |
| 1033 | | return 1; |
| 1034 | | } |
| 1035 | | |
| 1036 | | INLINE int sfao(UINT32 st1) |
| 1037 | | { |
| 1038 | | return st1 & ST1_SFAO ? 1 : 0; |
| 1039 | | } |
| 1040 | | |
| 1041 | | INLINE int dbp(UINT32 st1) |
| 1042 | | { |
| 1043 | | return st1 & ST1_DBP ? 1 : 0; |
| 1044 | | } |
| 1045 | | |
| 1046 | | INLINE int crm(UINT32 st1) |
| 1047 | | { |
| 1048 | | return (st1 & ST1_CRM) >> ST1_CRM_SHIFT; |
| 1049 | | } |
| 1050 | | |
| 1051 | | INLINE int sfai(UINT32 st1) |
| 1052 | | { |
| 1053 | | return st1 & ST1_SFAI ? 1 : 0; |
| 1054 | | } |
| 1055 | | |
| 1056 | | INLINE int sfmo(UINT32 st1) |
| 1057 | | { |
| 1058 | | return (st1 & ST1_SFMO) >> ST1_SFMO_SHIFT; |
| 1059 | | } |
| 1060 | | |
| 1061 | | INLINE int rnd(UINT32 st1) |
| 1062 | | { |
| 1063 | | return (st1 & ST1_RND) >> ST1_RND_SHIFT; |
| 1064 | | } |
| 1065 | | |
| 1066 | | INLINE int movm(UINT32 st1) |
| 1067 | | { |
| 1068 | | return st1 & ST1_MOVM ? 1 : 0; |
| 1069 | | } |
| 1070 | | |
| 1071 | | INLINE int sfma(UINT32 st1) |
| 1072 | | { |
| 1073 | | return (st1 & ST1_SFMA) >> ST1_SFMA_SHIFT; |
| 1074 | | } |
| 1075 | | |
| 1076 | 915 | static void tms57002_cache_flush(tms57002_t *s) |
| 1077 | 916 | { |
| 1078 | 917 | int i; |
| r10326 | r10327 | |
| 1091 | 930 | } |
| 1092 | 931 | } |
| 1093 | 932 | |
| 1094 | | static void tms57002_decode_error(tms57002_t *s, UINT32 opcode) |
| 1095 | | { |
| 1096 | | char buf[256]; |
| 1097 | | UINT8 opr[3]; |
| 1098 | | if(s->unsupported_inst_warning) |
| 1099 | | return; |
| 1100 | | |
| 1101 | | s->unsupported_inst_warning = 1; |
| 1102 | | opr[0] = opcode; |
| 1103 | | opr[1] = opcode >> 8; |
| 1104 | | opr[2] = opcode >> 16; |
| 1105 | | |
| 1106 | | CPU_DISASSEMBLE_NAME(tms57002)(0, buf, s->pc, opr, opr, 0); |
| 1107 | | popmessage("tms57002: %s - Contact Mamedev", buf); |
| 1108 | | } |
| 1109 | | |
| 1110 | | static void tms57002_decode_cat1(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs) |
| 1111 | | { |
| 1112 | | switch(opcode >> 18) { |
| 1113 | | case 0x00: // nop |
| 1114 | | break; |
| 1115 | | |
| 1116 | | #define CDEC1 |
| 1117 | | #include "cpu/tms57002/tms57002.inc" |
| 1118 | | #undef CDEC1 |
| 1119 | | |
| 1120 | | default: |
| 1121 | | tms57002_decode_error(s, opcode); |
| 1122 | | break; |
| 1123 | | } |
| 1124 | | } |
| 1125 | | |
| 1126 | | static void tms57002_decode_cat2_pre(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs) |
| 1127 | | { |
| 1128 | | switch((opcode >> 11) & 0x7f) { |
| 1129 | | case 0x00: // nop |
| 1130 | | break; |
| 1131 | | |
| 1132 | | #define CDEC2A |
| 1133 | | #include "cpu/tms57002/tms57002.inc" |
| 1134 | | #undef CDEC2A |
| 1135 | | |
| 1136 | | default: |
| 1137 | | tms57002_decode_error(s, opcode); |
| 1138 | | break; |
| 1139 | | } |
| 1140 | | } |
| 1141 | | |
| 1142 | | static void tms57002_decode_cat2_post(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs) |
| 1143 | | { |
| 1144 | | switch((opcode >> 11) & 0x7f) { |
| 1145 | | case 0x00: // nop |
| 1146 | | break; |
| 1147 | | |
| 1148 | | #define CDEC2B |
| 1149 | | #include "cpu/tms57002/tms57002.inc" |
| 1150 | | #undef CDEC2B |
| 1151 | | |
| 1152 | | default: |
| 1153 | | tms57002_decode_error(s, opcode); |
| 1154 | | break; |
| 1155 | | } |
| 1156 | | } |
| 1157 | | |
| 1158 | | static void tms57002_decode_cat3(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs) |
| 1159 | | { |
| 1160 | | switch((opcode >> 11) & 0x7f) { |
| 1161 | | case 0x00: // nop |
| 1162 | | break; |
| 1163 | | |
| 1164 | | #define CDEC3 |
| 1165 | | #include "cpu/tms57002/tms57002.inc" |
| 1166 | | #undef CDEC3 |
| 1167 | | |
| 1168 | | default: |
| 1169 | | tms57002_decode_error(s, opcode); |
| 1170 | | break; |
| 1171 | | } |
| 1172 | | } |
| 1173 | | |
| 1174 | 933 | static void tms57002_add_one(tms57002_t *s, cstate *cs, unsigned short op, UINT8 param) |
| 1175 | 934 | { |
| 1176 | 935 | short ipc = s->cache.iused++; |
src/emu/cpu/tms57002/tms57kpr.h
| r0 | r10327 | |
| 1 | #ifndef TMS57KPRIVATE_H |
| 2 | #define TMS57KPRIVATE_H |
| 3 | |
| 4 | CPU_DISASSEMBLE(tms57002); |
| 5 | |
| 6 | #ifdef __GNUC__ |
| 7 | #define noinline __attribute__((noinline)) |
| 8 | #else |
| 9 | #define noinline /* */ |
| 10 | #endif |
| 11 | |
| 12 | enum { |
| 13 | IN_PLOAD = 0x00000001, |
| 14 | IN_CLOAD = 0x00000002, |
| 15 | SU_CVAL = 0x00000004, |
| 16 | SU_MASK = 0x00000018, SU_ST0 = 0x00, SU_ST1 = 0x08, SU_PRG = 0x10, |
| 17 | S_IDLE = 0x00000020, |
| 18 | S_READ = 0x00000040, |
| 19 | S_WRITE = 0x00000080, |
| 20 | S_BRANCH = 0x00000100, |
| 21 | S_HOST = 0x00000200 |
| 22 | }; |
| 23 | |
| 24 | enum { |
| 25 | ST0_INCS = 0x000001, |
| 26 | ST0_DIRI = 0x000002, |
| 27 | ST0_FI = 0x000004, |
| 28 | ST0_SIM = 0x000008, |
| 29 | ST0_PLRI = 0x000020, |
| 30 | ST0_PBCI = 0x000040, |
| 31 | ST0_DIRO = 0x000080, |
| 32 | ST0_FO = 0x000100, |
| 33 | ST0_SOM = 0x000600, |
| 34 | ST0_PLRO = 0x000800, |
| 35 | ST0_PBCO = 0x001000, |
| 36 | ST0_CNS = 0x002000, |
| 37 | ST0_WORD = 0x004000, |
| 38 | ST0_SEL = 0x008000, |
| 39 | ST0_M = 0x030000, ST0_M_64K = 0x000000, ST0_M_256K = 0x010000, ST0_M_1M = 0x020000, |
| 40 | ST0_SRAM = 0x200000, |
| 41 | |
| 42 | ST1_AOV = 0x000001, |
| 43 | ST1_SFAI = 0x000002, |
| 44 | ST1_SFAO = 0x000004, |
| 45 | ST1_MOVM = 0x000020, |
| 46 | ST1_MOV = 0x000040, |
| 47 | ST1_SFMA = 0x000180, ST1_SFMA_SHIFT = 7, |
| 48 | ST1_SFMO = 0x001800, ST1_SFMO_SHIFT = 11, |
| 49 | ST1_RND = 0x038000, ST1_RND_SHIFT = 15, |
| 50 | ST1_CRM = 0x0C0000, ST1_CRM_SHIFT = 18, ST1_CRM_32 = 0x000000, ST1_CRM_16H = 0x040000, ST1_CRM_16L = 0x080000, |
| 51 | ST1_DBP = 0x100000, |
| 52 | ST1_CAS = 0x200000, |
| 53 | |
| 54 | ST1_CACHE = ST1_SFAI|ST1_SFAO|ST1_MOVM|ST1_SFMA|ST1_SFMO|ST1_RND|ST1_CRM|ST1_DBP |
| 55 | }; |
| 56 | |
| 57 | enum { BR_UB, BR_CB, BR_IDLE }; |
| 58 | |
| 59 | enum { IBS = 8192, HBS = 4096 }; |
| 60 | |
| 61 | typedef struct { |
| 62 | unsigned short op; |
| 63 | short next; |
| 64 | unsigned char param; |
| 65 | } icd; |
| 66 | |
| 67 | typedef struct { |
| 68 | unsigned int st1; |
| 69 | short ipc; |
| 70 | short next; |
| 71 | } hcd; |
| 72 | |
| 73 | typedef struct { |
| 74 | short hashbase[256]; |
| 75 | hcd hashnode[HBS]; |
| 76 | icd inst[IBS]; |
| 77 | int hused, iused; |
| 78 | } cd; |
| 79 | |
| 80 | typedef struct { |
| 81 | int branch; |
| 82 | short hnode; |
| 83 | short ipc; |
| 84 | } cstate; |
| 85 | |
| 86 | typedef struct { |
| 87 | INT64 macc; |
| 88 | |
| 89 | UINT32 cmem[256]; |
| 90 | UINT32 dmem0[256]; |
| 91 | UINT32 dmem1[32]; |
| 92 | |
| 93 | UINT32 si[4], so[4]; |
| 94 | |
| 95 | UINT32 st0, st1, sti; |
| 96 | UINT32 aacc, xoa, xba, xwr, xrd, creg; |
| 97 | |
| 98 | UINT8 pc, ca, id, ba0, ba1, rptc, rptc_next, sa; |
| 99 | |
| 100 | UINT32 xm_adr; |
| 101 | |
| 102 | UINT8 host[4], hidx, allow_update; |
| 103 | |
| 104 | cd cache; |
| 105 | |
| 106 | address_space *program, *data; |
| 107 | int icount; |
| 108 | int unsupported_inst_warning; |
| 109 | } tms57002_t; |
| 110 | |
| 111 | void tms57002_decode_cat1(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs); |
| 112 | void tms57002_decode_cat2_pre(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs); |
| 113 | void tms57002_decode_cat3(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs); |
| 114 | void tms57002_decode_cat2_post(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs); |
| 115 | |
| 116 | INLINE int xmode(UINT32 opcode, char type) |
| 117 | { |
| 118 | if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) { |
| 119 | if(opcode & 0x100) |
| 120 | return 0; |
| 121 | else if(opcode & 0x80) |
| 122 | return 2; |
| 123 | else |
| 124 | return 1; |
| 125 | } else if(opcode & 0x200) |
| 126 | return 2; |
| 127 | |
| 128 | return 1; |
| 129 | } |
| 130 | |
| 131 | INLINE int sfao(UINT32 st1) |
| 132 | { |
| 133 | return st1 & ST1_SFAO ? 1 : 0; |
| 134 | } |
| 135 | |
| 136 | INLINE int dbp(UINT32 st1) |
| 137 | { |
| 138 | return st1 & ST1_DBP ? 1 : 0; |
| 139 | } |
| 140 | |
| 141 | INLINE int crm(UINT32 st1) |
| 142 | { |
| 143 | return (st1 & ST1_CRM) >> ST1_CRM_SHIFT; |
| 144 | } |
| 145 | |
| 146 | INLINE int sfai(UINT32 st1) |
| 147 | { |
| 148 | return st1 & ST1_SFAI ? 1 : 0; |
| 149 | } |
| 150 | |
| 151 | INLINE int sfmo(UINT32 st1) |
| 152 | { |
| 153 | return (st1 & ST1_SFMO) >> ST1_SFMO_SHIFT; |
| 154 | } |
| 155 | |
| 156 | INLINE int rnd(UINT32 st1) |
| 157 | { |
| 158 | return (st1 & ST1_RND) >> ST1_RND_SHIFT; |
| 159 | } |
| 160 | |
| 161 | INLINE int movm(UINT32 st1) |
| 162 | { |
| 163 | return st1 & ST1_MOVM ? 1 : 0; |
| 164 | } |
| 165 | |
| 166 | INLINE int sfma(UINT32 st1) |
| 167 | { |
| 168 | return (st1 & ST1_SFMA) >> ST1_SFMA_SHIFT; |
| 169 | } |
| 170 | |
| 171 | #endif |
src/emu/cpu/sh2/sh2comn.c
| r10326 | r10327 | |
| 73 | 73 | int max_delta = 0xfffff; |
| 74 | 74 | UINT16 frc; |
| 75 | 75 | |
| 76 | | timer_adjust_oneshot(sh2->timer, attotime::never, 0); |
| 76 | sh2->timer->adjust(attotime::never); |
| 77 | 77 | |
| 78 | 78 | frc = sh2->frc; |
| 79 | 79 | if(!(sh2->m[4] & OCFA)) { |
| r10326 | r10327 | |
| 99 | 99 | if(divider) { |
| 100 | 100 | max_delta <<= divider; |
| 101 | 101 | sh2->frc_base = sh2->device->total_cycles(); |
| 102 | | timer_adjust_oneshot(sh2->timer, sh2->device->cycles_to_attotime(max_delta), 0); |
| 102 | sh2->timer->adjust(sh2->device->cycles_to_attotime(max_delta)); |
| 103 | 103 | } else { |
| 104 | 104 | logerror("SH2.%s: Timer event in %d cycles of external clock", sh2->device->tag(), max_delta); |
| 105 | 105 | } |
| r10326 | r10327 | |
| 172 | 172 | { |
| 173 | 173 | // printf("resuming stalled dma\n"); |
| 174 | 174 | sh2->dma_timer_active[dma]=1; |
| 175 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], attotime::zero, dma); |
| 175 | sh2->dma_current_active_timer[dma]->adjust(attotime::zero, dma); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| r10326 | r10327 | |
| 221 | 221 | |
| 222 | 222 | #ifdef USE_TIMER_FOR_DMA |
| 223 | 223 | //schedule next DMA callback |
| 224 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma); |
| 224 | sh2->dma_current_active_timer[dma]->adjust(sh2->device->cycles_to_attotime(2), dma); |
| 225 | 225 | #endif |
| 226 | 226 | |
| 227 | 227 | |
| r10326 | r10327 | |
| 269 | 269 | |
| 270 | 270 | #ifdef USE_TIMER_FOR_DMA |
| 271 | 271 | //schedule next DMA callback |
| 272 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma); |
| 272 | sh2->dma_current_active_timer[dma]->adjust(sh2->device->cycles_to_attotime(2), dma); |
| 273 | 273 | #endif |
| 274 | 274 | |
| 275 | 275 | // check: should this really be using read_word_32 / write_word_32? |
| r10326 | r10327 | |
| 316 | 316 | |
| 317 | 317 | #ifdef USE_TIMER_FOR_DMA |
| 318 | 318 | //schedule next DMA callback |
| 319 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma); |
| 319 | sh2->dma_current_active_timer[dma]->adjust(sh2->device->cycles_to_attotime(2), dma); |
| 320 | 320 | #endif |
| 321 | 321 | |
| 322 | 322 | dmadata = sh2->program->read_dword(tempsrc); |
| r10326 | r10327 | |
| 361 | 361 | |
| 362 | 362 | #ifdef USE_TIMER_FOR_DMA |
| 363 | 363 | //schedule next DMA callback |
| 364 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma); |
| 364 | sh2->dma_current_active_timer[dma]->adjust(sh2->device->cycles_to_attotime(2), dma); |
| 365 | 365 | #endif |
| 366 | 366 | |
| 367 | 367 | dmadata = sh2->program->read_dword(tempsrc); |
| r10326 | r10327 | |
| 483 | 483 | sh2->device->suspend(SUSPEND_REASON_HALT, 1 ); |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], sh2->device->cycles_to_attotime(2), dma); |
| 486 | sh2->dma_current_active_timer[dma]->adjust(sh2->device->cycles_to_attotime(2), dma); |
| 487 | 487 | #endif |
| 488 | 488 | |
| 489 | 489 | } |
| r10326 | r10327 | |
| 493 | 493 | if(sh2->dma_timer_active[dma]) |
| 494 | 494 | { |
| 495 | 495 | logerror("SH2: DMA %d cancelled in-flight\n", dma); |
| 496 | | //timer_adjust_oneshot(sh2->dma_complete_timer[dma], attotime::never, 0); |
| 497 | | timer_adjust_oneshot(sh2->dma_current_active_timer[dma], attotime::never, 0); |
| 496 | //sh2->dma_complete_timer[dma]->adjust(attotime::never); |
| 497 | sh2->dma_current_active_timer[dma]->adjust(attotime::never); |
| 498 | 498 | |
| 499 | 499 | sh2->dma_timer_active[dma] = 0; |
| 500 | 500 | } |
| r10326 | r10327 | |
| 924 | 924 | int i; |
| 925 | 925 | |
| 926 | 926 | sh2->timer = device->machine->scheduler().timer_alloc(FUNC(sh2_timer_callback), sh2); |
| 927 | | timer_adjust_oneshot(sh2->timer, attotime::never, 0); |
| 927 | sh2->timer->adjust(attotime::never); |
| 928 | 928 | |
| 929 | 929 | sh2->dma_current_active_timer[0] = device->machine->scheduler().timer_alloc(FUNC(sh2_dma_current_active_callback), sh2); |
| 930 | | timer_adjust_oneshot(sh2->dma_current_active_timer[0], attotime::never, 0); |
| 930 | sh2->dma_current_active_timer[0]->adjust(attotime::never); |
| 931 | 931 | |
| 932 | 932 | sh2->dma_current_active_timer[1] = device->machine->scheduler().timer_alloc(FUNC(sh2_dma_current_active_callback), sh2); |
| 933 | | timer_adjust_oneshot(sh2->dma_current_active_timer[1], attotime::never, 0); |
| 933 | sh2->dma_current_active_timer[1]->adjust(attotime::never); |
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | sh2->m = auto_alloc_array(device->machine, UINT32, 0x200/4); |
src/emu/cpu/sh4/sh4comn.c
| r10326 | r10327 | |
| 212 | 212 | // elapsed:total = x : ticks |
| 213 | 213 | // x=elapsed*tics/total -> x=elapsed*(double)100000000/rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] |
| 214 | 214 | // ticks/total=ticks / ((rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] * ticks) / 100000000)=1/((rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] / 100000000)=100000000/rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] |
| 215 | | return base + (UINT32)((timer_timeelapsed(timer).as_double() * (double)hertz) / (double)divisor); |
| 215 | return base + (UINT32)((timer->elapsed().as_double() * (double)hertz) / (double)divisor); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | static void sh4_refresh_timer_recompute(sh4_state *sh4) |
| r10326 | r10327 | |
| 224 | 224 | ticks = sh4->m[RTCOR]-sh4->m[RTCNT]; |
| 225 | 225 | if (ticks <= 0) |
| 226 | 226 | ticks = 256 + ticks; |
| 227 | | timer_adjust_oneshot(sh4->refresh_timer, attotime::from_hz(sh4->bus_clock) * rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] * ticks, 0); |
| 227 | sh4->refresh_timer->adjust(attotime::from_hz(sh4->bus_clock) * rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] * ticks); |
| 228 | 228 | sh4->refresh_timer_base = sh4->m[RTCNT]; |
| 229 | 229 | } |
| 230 | 230 | |
| r10326 | r10327 | |
| 242 | 242 | { |
| 243 | 243 | double ret; |
| 244 | 244 | |
| 245 | | ret=((timer_timeleft(timer).as_double() * (double)hertz) / (double)divisor) - 1; |
| 245 | ret=((timer->remaining().as_double() * (double)hertz) / (double)divisor) - 1; |
| 246 | 246 | return (UINT32)ret; |
| 247 | 247 | } |
| 248 | 248 | |
| r10326 | r10327 | |
| 251 | 251 | double ticks; |
| 252 | 252 | |
| 253 | 253 | ticks = sh4->m[tcnt[which]]; |
| 254 | | timer_adjust_oneshot(sh4->timer[which], sh4_scale_up_mame_time(attotime::from_hz(sh4->pm_clock) * tcnt_div[sh4->m[tcr[which]] & 7], ticks), which); |
| 254 | sh4->timer[which]->adjust(sh4_scale_up_mame_time(attotime::from_hz(sh4->pm_clock) * tcnt_div[sh4->m[tcr[which]] & 7], ticks), which); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | static TIMER_CALLBACK( sh4_refresh_timer_callback ) |
| r10326 | r10327 | |
| 369 | 369 | { |
| 370 | 370 | sh4_state *sh4 = (sh4_state *)ptr; |
| 371 | 371 | |
| 372 | | timer_adjust_oneshot(sh4->rtc_timer, attotime::from_hz(128), 0); |
| 372 | sh4->rtc_timer->adjust(attotime::from_hz(128)); |
| 373 | 373 | sh4->m[R64CNT] = (sh4->m[R64CNT]+1) & 0x7f; |
| 374 | 374 | if (sh4->m[R64CNT] == 64) |
| 375 | 375 | { |
| r10326 | r10327 | |
| 453 | 453 | if (timermode == 1) |
| 454 | 454 | { |
| 455 | 455 | sh4->dma_timer_active[channel] = 1; |
| 456 | | timer_adjust_oneshot(sh4->dma_timer[channel], sh4->device->cycles_to_attotime(2*count+1), channel); |
| 456 | sh4->dma_timer[channel]->adjust(sh4->device->cycles_to_attotime(2*count+1), channel); |
| 457 | 457 | } |
| 458 | 458 | else if (timermode == 2) |
| 459 | 459 | { |
| 460 | 460 | sh4->dma_timer_active[channel] = 1; |
| 461 | | timer_adjust_oneshot(sh4->dma_timer[channel], attotime::zero, channel); |
| 461 | sh4->dma_timer[channel]->adjust(attotime::zero, channel); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | src &= AM; |
| r10326 | r10327 | |
| 601 | 601 | if (sh4->dma_timer_active[channel]) |
| 602 | 602 | { |
| 603 | 603 | logerror("SH4: DMA %d cancelled in-flight but all data transferred", channel); |
| 604 | | timer_adjust_oneshot(sh4->dma_timer[channel], attotime::never, channel); |
| 604 | sh4->dma_timer[channel]->adjust(attotime::never, channel); |
| 605 | 605 | sh4->dma_timer_active[channel] = 0; |
| 606 | 606 | } |
| 607 | 607 | } |
| r10326 | r10327 | |
| 617 | 617 | if (sh4->dma_timer_active[s]) |
| 618 | 618 | { |
| 619 | 619 | logerror("SH4: DMA %d cancelled due to NMI but all data transferred", s); |
| 620 | | timer_adjust_oneshot(sh4->dma_timer[s], attotime::never, s); |
| 620 | sh4->dma_timer[s]->adjust(attotime::never, s); |
| 621 | 621 | sh4->dma_timer_active[s] = 0; |
| 622 | 622 | } |
| 623 | 623 | } |
| r10326 | r10327 | |
| 671 | 671 | } |
| 672 | 672 | else |
| 673 | 673 | { |
| 674 | | timer_adjust_oneshot(sh4->refresh_timer, attotime::never, 0); |
| 674 | sh4->refresh_timer->adjust(attotime::never); |
| 675 | 675 | } |
| 676 | 676 | break; |
| 677 | 677 | |
| r10326 | r10327 | |
| 717 | 717 | } |
| 718 | 718 | if ((sh4->m[RCR2] & 8) && (~old & 8)) |
| 719 | 719 | { // 0 -> 1 |
| 720 | | timer_adjust_oneshot(sh4->rtc_timer, attotime::from_hz(128), 0); |
| 720 | sh4->rtc_timer->adjust(attotime::from_hz(128)); |
| 721 | 721 | } |
| 722 | 722 | else if (~(sh4->m[RCR2]) & 8) |
| 723 | 723 | { // 0 |
| 724 | | timer_adjust_oneshot(sh4->rtc_timer, attotime::never, 0); |
| 724 | sh4->rtc_timer->adjust(attotime::never); |
| 725 | 725 | } |
| 726 | 726 | break; |
| 727 | 727 | |
| r10326 | r10327 | |
| 730 | 730 | if (old & 1) |
| 731 | 731 | sh4->m[TCNT0] = compute_ticks_timer(sh4->timer[0], sh4->pm_clock, tcnt_div[sh4->m[TCR0] & 7]); |
| 732 | 732 | if ((sh4->m[TSTR] & 1) == 0) { |
| 733 | | timer_adjust_oneshot(sh4->timer[0], attotime::never, 0); |
| 733 | sh4->timer[0]->adjust(attotime::never); |
| 734 | 734 | } else |
| 735 | 735 | sh4_timer_recompute(sh4, 0); |
| 736 | 736 | |
| 737 | 737 | if (old & 2) |
| 738 | 738 | sh4->m[TCNT1] = compute_ticks_timer(sh4->timer[1], sh4->pm_clock, tcnt_div[sh4->m[TCR1] & 7]); |
| 739 | 739 | if ((sh4->m[TSTR] & 2) == 0) { |
| 740 | | timer_adjust_oneshot(sh4->timer[1], attotime::never, 0); |
| 740 | sh4->timer[1]->adjust(attotime::never); |
| 741 | 741 | } else |
| 742 | 742 | sh4_timer_recompute(sh4, 1); |
| 743 | 743 | |
| 744 | 744 | if (old & 4) |
| 745 | 745 | sh4->m[TCNT2] = compute_ticks_timer(sh4->timer[2], sh4->pm_clock, tcnt_div[sh4->m[TCR2] & 7]); |
| 746 | 746 | if ((sh4->m[TSTR] & 4) == 0) { |
| 747 | | timer_adjust_oneshot(sh4->timer[2], attotime::never, 0); |
| 747 | sh4->timer[2]->adjust(attotime::never); |
| 748 | 748 | } else |
| 749 | 749 | sh4_timer_recompute(sh4, 2); |
| 750 | 750 | break; |
| r10326 | r10327 | |
| 945 | 945 | if ((sh4->m[RTCSR] >> 3) & 7) |
| 946 | 946 | { // activated |
| 947 | 947 | //((double)rtcnt_div[(sh4->m[RTCSR] >> 3) & 7] / (double)100000000) |
| 948 | | //return (refresh_timer_base + (timer_timeelapsed(sh4->refresh_timer) * (double)100000000) / (double)rtcnt_div[(sh4->m[RTCSR] >> 3) & 7]) & 0xff; |
| 948 | //return (refresh_timer_base + (sh4->refresh_timer->elapsed() * (double)100000000) / (double)rtcnt_div[(sh4->m[RTCSR] >> 3) & 7]) & 0xff; |
| 949 | 949 | return compute_ticks_refresh_timer(sh4->refresh_timer, sh4->bus_clock, sh4->refresh_timer_base, rtcnt_div[(sh4->m[RTCSR] >> 3) & 7]) & 0xff; |
| 950 | 950 | } |
| 951 | 951 | else |
| r10326 | r10327 | |
| 1161 | 1161 | for (i=0; i<3; i++) |
| 1162 | 1162 | { |
| 1163 | 1163 | sh4->timer[i] = device->machine->scheduler().timer_alloc(FUNC(sh4_timer_callback), sh4); |
| 1164 | | timer_adjust_oneshot(sh4->timer[i], attotime::never, i); |
| 1164 | sh4->timer[i]->adjust(attotime::never, i); |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | for (i=0; i<4; i++) |
| 1168 | 1168 | { |
| 1169 | 1169 | sh4->dma_timer[i] = device->machine->scheduler().timer_alloc(FUNC(sh4_dmac_callback), sh4); |
| 1170 | | timer_adjust_oneshot(sh4->dma_timer[i], attotime::never, i); |
| 1170 | sh4->dma_timer[i]->adjust(attotime::never, i); |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | sh4->refresh_timer = device->machine->scheduler().timer_alloc(FUNC(sh4_refresh_timer_callback), sh4); |
| 1174 | | timer_adjust_oneshot(sh4->refresh_timer, attotime::never, 0); |
| 1174 | sh4->refresh_timer->adjust(attotime::never); |
| 1175 | 1175 | sh4->refresh_timer_base = 0; |
| 1176 | 1176 | |
| 1177 | 1177 | sh4->rtc_timer = device->machine->scheduler().timer_alloc(FUNC(sh4_rtc_timer_callback), sh4); |
| 1178 | | timer_adjust_oneshot(sh4->rtc_timer, attotime::never, 0); |
| 1178 | sh4->rtc_timer->adjust(attotime::never); |
| 1179 | 1179 | |
| 1180 | 1180 | sh4->m = auto_alloc_array(device->machine, UINT32, 16384); |
| 1181 | 1181 | } |
src/emu/video/tms34061.c
| r10326 | r10327 | |
| 147 | 147 | static TIMER_CALLBACK( tms34061_interrupt ) |
| 148 | 148 | { |
| 149 | 149 | /* set timer for next frame */ |
| 150 | | timer_adjust_oneshot(tms34061.timer, tms34061.screen->frame_period(), 0); |
| 150 | tms34061.timer->adjust(tms34061.screen->frame_period()); |
| 151 | 151 | |
| 152 | 152 | /* set the interrupt bit in the status reg */ |
| 153 | 153 | tms34061.regs[TMS34061_STATUS] |= 1; |
| r10326 | r10327 | |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /* log it */ |
| 187 | | if (VERBOSE) logerror("%s:tms34061 %s = %04x\n", cpuexec_describe_context(space->machine), regnames[regnum], tms34061.regs[regnum]); |
| 187 | if (VERBOSE) logerror("%s:tms34061 %s = %04x\n", space->machine->describe_context(), regnames[regnum], tms34061.regs[regnum]); |
| 188 | 188 | |
| 189 | 189 | /* update the state of things */ |
| 190 | 190 | switch (regnum) |
| r10326 | r10327 | |
| 196 | 196 | if (scanline < 0) |
| 197 | 197 | scanline += tms34061.regs[TMS34061_VERTOTAL]; |
| 198 | 198 | |
| 199 | | timer_adjust_oneshot(tms34061.timer, tms34061.screen->time_until_pos(scanline, tms34061.regs[TMS34061_HORSTARTBLNK]), 0); |
| 199 | tms34061.timer->adjust(tms34061.screen->time_until_pos(scanline, tms34061.regs[TMS34061_HORSTARTBLNK])); |
| 200 | 200 | break; |
| 201 | 201 | |
| 202 | 202 | /* XY offset: set the X and Y masks */ |
| r10326 | r10327 | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /* log it */ |
| 265 | | if (VERBOSE) logerror("%s:tms34061 %s read = %04X\n", cpuexec_describe_context(space->machine), regnames[regnum], result); |
| 265 | if (VERBOSE) logerror("%s:tms34061 %s read = %04X\n", space->machine->describe_context(), regnames[regnum], result); |
| 266 | 266 | return (offset & 0x02) ? (result >> 8) : result; |
| 267 | 267 | } |
| 268 | 268 | |
| r10326 | r10327 | |
| 369 | 369 | |
| 370 | 370 | /* mask to the VRAM size */ |
| 371 | 371 | pixeloffs &= tms34061.vrammask; |
| 372 | | if (VERBOSE) logerror("%s:tms34061 xy (%04x) = %02x/%02x\n", cpuexec_describe_context(space->machine), pixeloffs, data, tms34061.latchdata); |
| 372 | if (VERBOSE) logerror("%s:tms34061 xy (%04x) = %02x/%02x\n", space->machine->describe_context(), pixeloffs, data, tms34061.latchdata); |
| 373 | 373 | |
| 374 | 374 | /* set the pixel data */ |
| 375 | 375 | tms34061.vram[pixeloffs] = data; |
| r10326 | r10327 | |
| 425 | 425 | offs = ((row << tms34061.intf.rowshift) | col) & tms34061.vrammask; |
| 426 | 426 | if (tms34061.regs[TMS34061_CONTROL2] & 0x0040) |
| 427 | 427 | offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16; |
| 428 | | if (VERBOSE) logerror("%s:tms34061 direct (%04x) = %02x/%02x\n", cpuexec_describe_context(space->machine), offs, data, tms34061.latchdata); |
| 428 | if (VERBOSE) logerror("%s:tms34061 direct (%04x) = %02x/%02x\n", space->machine->describe_context(), offs, data, tms34061.latchdata); |
| 429 | 429 | if (tms34061.vram[offs] != data || tms34061.latchram[offs] != tms34061.latchdata) |
| 430 | 430 | { |
| 431 | 431 | tms34061.vram[offs] = data; |
| r10326 | r10327 | |
| 439 | 439 | if (tms34061.regs[TMS34061_CONTROL2] & 0x0040) |
| 440 | 440 | offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16; |
| 441 | 441 | offs &= tms34061.vrammask; |
| 442 | | if (VERBOSE) logerror("%s:tms34061 shiftreg write (%04x)\n", cpuexec_describe_context(space->machine), offs); |
| 442 | if (VERBOSE) logerror("%s:tms34061 shiftreg write (%04x)\n", space->machine->describe_context(), offs); |
| 443 | 443 | |
| 444 | 444 | memcpy(&tms34061.vram[offs], tms34061.shiftreg, (size_t)1 << tms34061.intf.rowshift); |
| 445 | 445 | memset(&tms34061.latchram[offs], tms34061.latchdata, (size_t)1 << tms34061.intf.rowshift); |
| r10326 | r10327 | |
| 451 | 451 | if (tms34061.regs[TMS34061_CONTROL2] & 0x0040) |
| 452 | 452 | offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16; |
| 453 | 453 | offs &= tms34061.vrammask; |
| 454 | | if (VERBOSE) logerror("%s:tms34061 shiftreg read (%04x)\n", cpuexec_describe_context(space->machine), offs); |
| 454 | if (VERBOSE) logerror("%s:tms34061 shiftreg read (%04x)\n", space->machine->describe_context(), offs); |
| 455 | 455 | |
| 456 | 456 | tms34061.shiftreg = &tms34061.vram[offs]; |
| 457 | 457 | break; |
| 458 | 458 | |
| 459 | 459 | /* log anything else */ |
| 460 | 460 | default: |
| 461 | | logerror("%s:Unsupported TMS34061 function %d\n", cpuexec_describe_context(space->machine), func); |
| 461 | logerror("%s:Unsupported TMS34061 function %d\n", space->machine->describe_context(), func); |
| 462 | 462 | break; |
| 463 | 463 | } |
| 464 | 464 | } |
| r10326 | r10327 | |
| 512 | 512 | |
| 513 | 513 | /* log anything else */ |
| 514 | 514 | default: |
| 515 | | logerror("%s:Unsupported TMS34061 function %d\n", cpuexec_describe_context(space->machine), |
| 515 | logerror("%s:Unsupported TMS34061 function %d\n", space->machine->describe_context(), |
| 516 | 516 | func); |
| 517 | 517 | break; |
| 518 | 518 | } |
src/emu/video/mc6845.c
| r10326 | r10327 | |
| 289 | 289 | { |
| 290 | 290 | mc6845_t *mc6845 = get_safe_token(device); |
| 291 | 291 | |
| 292 | | if (LOG) logerror("%s:M6845 reg 0x%02x = 0x%02x\n", cpuexec_describe_context(device->machine), mc6845->register_address_latch, data); |
| 292 | if (LOG) logerror("%s:M6845 reg 0x%02x = 0x%02x\n", device->machine->describe_context(), mc6845->register_address_latch, data); |
| 293 | 293 | |
| 294 | 294 | switch (mc6845->register_address_latch) |
| 295 | 295 | { |
| r10326 | r10327 | |
| 447 | 447 | |
| 448 | 448 | INLINE void mc6845_update_counters(mc6845_t *mc6845) |
| 449 | 449 | { |
| 450 | | mc6845->character_counter = timer_timeelapsed( mc6845->line_timer ).as_ticks( mc6845->clock ); |
| 450 | mc6845->character_counter = mc6845->line_timer ->elapsed( ).as_ticks( mc6845->clock ); |
| 451 | 451 | |
| 452 | | if ( timer_enabled( mc6845->hsync_off_timer ) ) |
| 452 | if ( mc6845->hsync_off_timer ->enabled( ) ) |
| 453 | 453 | { |
| 454 | | mc6845->hsync_width_counter = timer_timeelapsed( mc6845->hsync_off_timer ).as_ticks( mc6845->clock ); |
| 454 | mc6845->hsync_width_counter = mc6845->hsync_off_timer ->elapsed( ).as_ticks( mc6845->clock ); |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| r10326 | r10327 | |
| 465 | 465 | if ( mc6845->de ) |
| 466 | 466 | { |
| 467 | 467 | /* If the upd_adr_timer was running, cancel it */ |
| 468 | | timer_adjust_oneshot(mc6845->upd_adr_timer, attotime::never, 0); |
| 468 | mc6845->upd_adr_timer->adjust(attotime::never); |
| 469 | 469 | } |
| 470 | 470 | else |
| 471 | 471 | { |
| r10326 | r10327 | |
| 519 | 519 | static void update_upd_adr_timer(mc6845_t *mc6845) |
| 520 | 520 | { |
| 521 | 521 | if (! mc6845->de && supports_transparent[mc6845->device_type]) |
| 522 | | timer_adjust_oneshot(mc6845->upd_adr_timer, mc6845->upd_time, 0); |
| 522 | mc6845->upd_adr_timer->adjust(mc6845->upd_time); |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | |
| r10326 | r10327 | |
| 549 | 549 | mc6845_set_cur( mc6845, TRUE ); |
| 550 | 550 | |
| 551 | 551 | /* Schedule CURSOR off signal */ |
| 552 | | timer_adjust_oneshot( mc6845->cur_off_timer, attotime::from_ticks( 1, mc6845->clock ), 0 ); |
| 552 | mc6845->cur_off_timer->adjust( attotime::from_ticks( 1, mc6845->clock ) ); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | |
| r10326 | r10327 | |
| 572 | 572 | mc6845_set_hsync( mc6845, TRUE ); |
| 573 | 573 | |
| 574 | 574 | /* Schedule HSYNC off signal */ |
| 575 | | timer_adjust_oneshot( mc6845->hsync_off_timer, attotime::from_ticks( hsync_width, mc6845->clock ), 0 ); |
| 575 | mc6845->hsync_off_timer->adjust( attotime::from_ticks( hsync_width, mc6845->clock ) ); |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | |
| r10326 | r10327 | |
| 668 | 668 | if ( mc6845->line_enable_ff ) |
| 669 | 669 | { |
| 670 | 670 | /* Schedule DE off signal change */ |
| 671 | | timer_adjust_oneshot(mc6845->de_off_timer, attotime::from_ticks( mc6845->horiz_disp, mc6845->clock ), 0); |
| 671 | mc6845->de_off_timer->adjust(attotime::from_ticks( mc6845->horiz_disp, mc6845->clock )); |
| 672 | 672 | |
| 673 | 673 | /* Is cursor visible on this line? */ |
| 674 | 674 | if ( mc6845->cursor_state && |
| r10326 | r10327 | |
| 680 | 680 | mc6845->cursor_x = mc6845->cursor_addr - mc6845->line_address; |
| 681 | 681 | |
| 682 | 682 | /* Schedule CURSOR ON signal */ |
| 683 | | timer_adjust_oneshot( mc6845->cur_on_timer, attotime::from_ticks( mc6845->cursor_x, mc6845->clock ), 0 ); |
| 683 | mc6845->cur_on_timer->adjust( attotime::from_ticks( mc6845->cursor_x, mc6845->clock ) ); |
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /* Schedule HSYNC on signal */ |
| 688 | | timer_adjust_oneshot( mc6845->hsync_on_timer, attotime::from_ticks( mc6845->horiz_sync_pos, mc6845->clock ), 0 ); |
| 688 | mc6845->hsync_on_timer->adjust( attotime::from_ticks( mc6845->horiz_sync_pos, mc6845->clock ) ); |
| 689 | 689 | |
| 690 | 690 | /* Schedule our next callback */ |
| 691 | | timer_adjust_oneshot( mc6845->line_timer, attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); |
| 691 | mc6845->line_timer->adjust( attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ) ); |
| 692 | 692 | |
| 693 | 693 | /* Set VSYNC and DE signals */ |
| 694 | 694 | mc6845_set_vsync( mc6845, new_vsync ); |
| r10326 | r10327 | |
| 730 | 730 | |
| 731 | 731 | /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */ |
| 732 | 732 | /* set the timer that will latch the display address into the light pen registers */ |
| 733 | | timer_adjust_oneshot(mc6845->light_pen_latch_timer, attotime::from_ticks( 1, mc6845->clock ), 0); |
| 733 | mc6845->light_pen_latch_timer->adjust(attotime::from_ticks( 1, mc6845->clock )); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | |
| r10326 | r10327 | |
| 1009 | 1009 | devcb_call_write_line(&mc6845->out_vsync_func, FALSE); |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | | if ( ! timer_enabled( mc6845->line_timer ) ) |
| 1012 | if ( ! mc6845->line_timer ->enabled( ) ) |
| 1013 | 1013 | { |
| 1014 | | timer_adjust_oneshot( mc6845->line_timer, attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ), 0 ); |
| 1014 | mc6845->line_timer->adjust( attotime::from_ticks( mc6845->horiz_char_total + 1, mc6845->clock ) ); |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | mc6845->light_pen_latched = FALSE; |
src/emu/video/voodoo.c
| r10326 | r10327 | |
| 986 | 986 | /* if zero, adjust to next frame, otherwise we may get stuck in an infinite loop */ |
| 987 | 987 | if (vblank_period == attotime::zero) |
| 988 | 988 | vblank_period = v->screen->frame_period(); |
| 989 | | timer_adjust_oneshot(v->fbi.vblank_timer, vblank_period, 0); |
| 989 | v->fbi.vblank_timer->adjust(vblank_period); |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | |
| r10326 | r10327 | |
| 2070 | 2070 | if (v->pci.stall_callback) |
| 2071 | 2071 | (*v->pci.stall_callback)(v->device, FALSE); |
| 2072 | 2072 | else |
| 2073 | | cpuexec_trigger(v->device->machine, v->trigger); |
| 2073 | v->device->machine->scheduler().trigger(v->trigger); |
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | /* if not, set a timer for the next one */ |
| 2077 | 2077 | else |
| 2078 | 2078 | { |
| 2079 | | timer_adjust_oneshot(v->pci.continue_timer, v->pci.op_end_time - current_time, 0); |
| 2079 | v->pci.continue_timer->adjust(v->pci.op_end_time - current_time); |
| 2080 | 2080 | } |
| 2081 | 2081 | } |
| 2082 | 2082 | |
| r10326 | r10327 | |
| 2097 | 2097 | cpu_spinuntil_trigger(v->cpu, v->trigger); |
| 2098 | 2098 | |
| 2099 | 2099 | /* set a timer to clear the stall */ |
| 2100 | | timer_adjust_oneshot(v->pci.continue_timer, v->pci.op_end_time - current_time, 0); |
| 2100 | v->pci.continue_timer->adjust(v->pci.op_end_time - current_time); |
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | |
| r10326 | r10327 | |
| 3967 | 3967 | } |
| 3968 | 3968 | |
| 3969 | 3969 | if (LOG_REGISTERS) |
| 3970 | | logerror("%s:banshee_r(AGP:%s)\n", cpuexec_describe_context(v->device->machine), banshee_agp_reg_name[offset]); |
| 3970 | logerror("%s:banshee_r(AGP:%s)\n", v->device->machine->describe_context(), banshee_agp_reg_name[offset]); |
| 3971 | 3971 | return result; |
| 3972 | 3972 | } |
| 3973 | 3973 | |
| r10326 | r10327 | |
| 3986 | 3986 | else if (offset < 0x100000/4) |
| 3987 | 3987 | result = banshee_agp_r(device, offset, mem_mask); |
| 3988 | 3988 | else if (offset < 0x200000/4) |
| 3989 | | logerror("%s:banshee_r(2D:%X)\n", cpuexec_describe_context(device->machine), (offset*4) & 0xfffff); |
| 3989 | logerror("%s:banshee_r(2D:%X)\n", device->machine->describe_context(), (offset*4) & 0xfffff); |
| 3990 | 3990 | else if (offset < 0x600000/4) |
| 3991 | 3991 | result = register_r(v, offset & 0x1fffff/4); |
| 3992 | 3992 | else if (offset < 0x800000/4) |
| 3993 | | logerror("%s:banshee_r(TEX:%X)\n", cpuexec_describe_context(device->machine), (offset*4) & 0x1fffff); |
| 3993 | logerror("%s:banshee_r(TEX:%X)\n", device->machine->describe_context(), (offset*4) & 0x1fffff); |
| 3994 | 3994 | else if (offset < 0xc00000/4) |
| 3995 | | logerror("%s:banshee_r(RES:%X)\n", cpuexec_describe_context(device->machine), (offset*4) & 0x3fffff); |
| 3995 | logerror("%s:banshee_r(RES:%X)\n", device->machine->describe_context(), (offset*4) & 0x3fffff); |
| 3996 | 3996 | else if (offset < 0x1000000/4) |
| 3997 | | logerror("%s:banshee_r(YUV:%X)\n", cpuexec_describe_context(device->machine), (offset*4) & 0x3fffff); |
| 3997 | logerror("%s:banshee_r(YUV:%X)\n", device->machine->describe_context(), (offset*4) & 0x3fffff); |
| 3998 | 3998 | else if (offset < 0x2000000/4) |
| 3999 | 3999 | { |
| 4000 | 4000 | UINT8 temp = v->fbi.lfb_stride; |
| r10326 | r10327 | |
| 4017 | 4017 | |
| 4018 | 4018 | if (offset < v->fbi.lfb_base) |
| 4019 | 4019 | { |
| 4020 | | logerror("%s:banshee_fb_r(%X)\n", cpuexec_describe_context(device->machine), offset*4); |
| 4020 | logerror("%s:banshee_fb_r(%X)\n", device->machine->describe_context(), offset*4); |
| 4021 | 4021 | if (offset*4 <= v->fbi.mask) |
| 4022 | 4022 | result = ((UINT32 *)v->fbi.ram)[offset]; |
| 4023 | 4023 | } |
| r10326 | r10327 | |
| 4042 | 4042 | if (v->banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(v->banshee.att)) |
| 4043 | 4043 | result = v->banshee.att[v->banshee.vga[0x3c1 & 0x1f]]; |
| 4044 | 4044 | if (LOG_REGISTERS) |
| 4045 | | logerror("%s:banshee_att_r(%X)\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3c1 & 0x1f]); |
| 4045 | logerror("%s:banshee_att_r(%X)\n", device->machine->describe_context(), v->banshee.vga[0x3c1 & 0x1f]); |
| 4046 | 4046 | break; |
| 4047 | 4047 | |
| 4048 | 4048 | /* Input status 0 */ |
| r10326 | r10327 | |
| 4055 | 4055 | */ |
| 4056 | 4056 | result = 0x00; |
| 4057 | 4057 | if (LOG_REGISTERS) |
| 4058 | | logerror("%s:banshee_vga_r(%X)\n", cpuexec_describe_context(device->machine), 0x300+offset); |
| 4058 | logerror("%s:banshee_vga_r(%X)\n", device->machine->describe_context(), 0x300+offset); |
| 4059 | 4059 | break; |
| 4060 | 4060 | |
| 4061 | 4061 | /* Sequencer access */ |
| r10326 | r10327 | |
| 4063 | 4063 | if (v->banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(v->banshee.seq)) |
| 4064 | 4064 | result = v->banshee.seq[v->banshee.vga[0x3c4 & 0x1f]]; |
| 4065 | 4065 | if (LOG_REGISTERS) |
| 4066 | | logerror("%s:banshee_seq_r(%X)\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3c4 & 0x1f]); |
| 4066 | logerror("%s:banshee_seq_r(%X)\n", device->machine->describe_context(), v->banshee.vga[0x3c4 & 0x1f]); |
| 4067 | 4067 | break; |
| 4068 | 4068 | |
| 4069 | 4069 | /* Feature control */ |
| r10326 | r10327 | |
| 4071 | 4071 | result = v->banshee.vga[0x3da & 0x1f]; |
| 4072 | 4072 | v->banshee.attff = 0; |
| 4073 | 4073 | if (LOG_REGISTERS) |
| 4074 | | logerror("%s:banshee_vga_r(%X)\n", cpuexec_describe_context(device->machine), 0x300+offset); |
| 4074 | logerror("%s:banshee_vga_r(%X)\n", device->machine->describe_context(), 0x300+offset); |
| 4075 | 4075 | break; |
| 4076 | 4076 | |
| 4077 | 4077 | /* Miscellaneous output */ |
| 4078 | 4078 | case 0x3cc: |
| 4079 | 4079 | result = v->banshee.vga[0x3c2 & 0x1f]; |
| 4080 | 4080 | if (LOG_REGISTERS) |
| 4081 | | logerror("%s:banshee_vga_r(%X)\n", cpuexec_describe_context(device->machine), 0x300+offset); |
| 4081 | logerror("%s:banshee_vga_r(%X)\n", device->machine->describe_context(), 0x300+offset); |
| 4082 | 4082 | break; |
| 4083 | 4083 | |
| 4084 | 4084 | /* Graphics controller access */ |
| r10326 | r10327 | |
| 4086 | 4086 | if (v->banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(v->banshee.gc)) |
| 4087 | 4087 | result = v->banshee.gc[v->banshee.vga[0x3ce & 0x1f]]; |
| 4088 | 4088 | if (LOG_REGISTERS) |
| 4089 | | logerror("%s:banshee_gc_r(%X)\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3ce & 0x1f]); |
| 4089 | logerror("%s:banshee_gc_r(%X)\n", device->machine->describe_context(), v->banshee.vga[0x3ce & 0x1f]); |
| 4090 | 4090 | break; |
| 4091 | 4091 | |
| 4092 | 4092 | /* CRTC access */ |
| r10326 | r10327 | |
| 4094 | 4094 | if (v->banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(v->banshee.crtc)) |
| 4095 | 4095 | result = v->banshee.crtc[v->banshee.vga[0x3d4 & 0x1f]]; |
| 4096 | 4096 | if (LOG_REGISTERS) |
| 4097 | | logerror("%s:banshee_crtc_r(%X)\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3d4 & 0x1f]); |
| 4097 | logerror("%s:banshee_crtc_r(%X)\n", device->machine->describe_context(), v->banshee.vga[0x3d4 & 0x1f]); |
| 4098 | 4098 | break; |
| 4099 | 4099 | |
| 4100 | 4100 | /* Input status 1 */ |
| r10326 | r10327 | |
| 4110 | 4110 | */ |
| 4111 | 4111 | result = 0x04; |
| 4112 | 4112 | if (LOG_REGISTERS) |
| 4113 | | logerror("%s:banshee_vga_r(%X)\n", cpuexec_describe_context(device->machine), 0x300+offset); |
| 4113 | logerror("%s:banshee_vga_r(%X)\n", device->machine->describe_context(), 0x300+offset); |
| 4114 | 4114 | break; |
| 4115 | 4115 | |
| 4116 | 4116 | default: |
| 4117 | 4117 | result = v->banshee.vga[offset]; |
| 4118 | 4118 | if (LOG_REGISTERS) |
| 4119 | | logerror("%s:banshee_vga_r(%X)\n", cpuexec_describe_context(device->machine), 0x300+offset); |
| 4119 | logerror("%s:banshee_vga_r(%X)\n", device->machine->describe_context(), 0x300+offset); |
| 4120 | 4120 | break; |
| 4121 | 4121 | } |
| 4122 | 4122 | return result; |
| r10326 | r10327 | |
| 4140 | 4140 | case io_dacData: |
| 4141 | 4141 | result = v->fbi.clut[v->banshee.io[io_dacAddr] & 0x1ff] = v->banshee.io[offset]; |
| 4142 | 4142 | if (LOG_REGISTERS) |
| 4143 | | logerror("%s:banshee_dac_r(%X)\n", cpuexec_describe_context(device->machine), v->banshee.io[io_dacAddr] & 0x1ff); |
| 4143 | logerror("%s:banshee_dac_r(%X)\n", device->machine->describe_context(), v->banshee.io[io_dacAddr] & 0x1ff); |
| 4144 | 4144 | break; |
| 4145 | 4145 | |
| 4146 | 4146 | case io_vgab0: case io_vgab4: case io_vgab8: case io_vgabc: |
| r10326 | r10327 | |
| 4160 | 4160 | default: |
| 4161 | 4161 | result = v->banshee.io[offset]; |
| 4162 | 4162 | if (LOG_REGISTERS) |
| 4163 | | logerror("%s:banshee_io_r(%s)\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset]); |
| 4163 | logerror("%s:banshee_io_r(%s)\n", device->machine->describe_context(), banshee_io_reg_name[offset]); |
| 4164 | 4164 | break; |
| 4165 | 4165 | } |
| 4166 | 4166 | |
| r10326 | r10327 | |
| 4170 | 4170 | |
| 4171 | 4171 | READ32_DEVICE_HANDLER( banshee_rom_r ) |
| 4172 | 4172 | { |
| 4173 | | logerror("%s:banshee_rom_r(%X)\n", cpuexec_describe_context(device->machine), offset*4); |
| 4173 | logerror("%s:banshee_rom_r(%X)\n", device->machine->describe_context(), offset*4); |
| 4174 | 4174 | return 0xffffffff; |
| 4175 | 4175 | } |
| 4176 | 4176 | |
| r10326 | r10327 | |
| 4264 | 4264 | } |
| 4265 | 4265 | |
| 4266 | 4266 | if (LOG_REGISTERS) |
| 4267 | | logerror("%s:banshee_w(AGP:%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_agp_reg_name[offset], data, mem_mask); |
| 4267 | logerror("%s:banshee_w(AGP:%s) = %08X & %08X\n", device->machine->describe_context(), banshee_agp_reg_name[offset], data, mem_mask); |
| 4268 | 4268 | } |
| 4269 | 4269 | |
| 4270 | 4270 | |
| r10326 | r10327 | |
| 4281 | 4281 | else if (offset < 0x100000/4) |
| 4282 | 4282 | banshee_agp_w(device, offset, data, mem_mask); |
| 4283 | 4283 | else if (offset < 0x200000/4) |
| 4284 | | logerror("%s:banshee_w(2D:%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), (offset*4) & 0xfffff, data, mem_mask); |
| 4284 | logerror("%s:banshee_w(2D:%X) = %08X & %08X\n", device->machine->describe_context(), (offset*4) & 0xfffff, data, mem_mask); |
| 4285 | 4285 | else if (offset < 0x600000/4) |
| 4286 | 4286 | register_w(v, offset & 0x1fffff/4, data); |
| 4287 | 4287 | else if (offset < 0x800000/4) |
| 4288 | | logerror("%s:banshee_w(TEX:%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), (offset*4) & 0x1fffff, data, mem_mask); |
| 4288 | logerror("%s:banshee_w(TEX:%X) = %08X & %08X\n", device->machine->describe_context(), (offset*4) & 0x1fffff, data, mem_mask); |
| 4289 | 4289 | else if (offset < 0xc00000/4) |
| 4290 | | logerror("%s:banshee_w(RES:%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), (offset*4) & 0x3fffff, data, mem_mask); |
| 4290 | logerror("%s:banshee_w(RES:%X) = %08X & %08X\n", device->machine->describe_context(), (offset*4) & 0x3fffff, data, mem_mask); |
| 4291 | 4291 | else if (offset < 0x1000000/4) |
| 4292 | | logerror("%s:banshee_w(YUV:%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), (offset*4) & 0x3fffff, data, mem_mask); |
| 4292 | logerror("%s:banshee_w(YUV:%X) = %08X & %08X\n", device->machine->describe_context(), (offset*4) & 0x3fffff, data, mem_mask); |
| 4293 | 4293 | else if (offset < 0x2000000/4) |
| 4294 | 4294 | { |
| 4295 | 4295 | UINT8 temp = v->fbi.lfb_stride; |
| r10326 | r10327 | |
| 4319 | 4319 | { |
| 4320 | 4320 | if (offset*4 <= v->fbi.mask) |
| 4321 | 4321 | COMBINE_DATA(&((UINT32 *)v->fbi.ram)[offset]); |
| 4322 | | logerror("%s:banshee_fb_w(%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), offset*4, data, mem_mask); |
| 4322 | logerror("%s:banshee_fb_w(%X) = %08X & %08X\n", device->machine->describe_context(), offset*4, data, mem_mask); |
| 4323 | 4323 | } |
| 4324 | 4324 | } |
| 4325 | 4325 | else |
| r10326 | r10327 | |
| 4342 | 4342 | { |
| 4343 | 4343 | v->banshee.vga[0x3c1 & 0x1f] = data; |
| 4344 | 4344 | if (LOG_REGISTERS) |
| 4345 | | logerror("%s:banshee_vga_w(%X) = %02X\n", cpuexec_describe_context(device->machine), 0x3c0+offset, data); |
| 4345 | logerror("%s:banshee_vga_w(%X) = %02X\n", device->machine->describe_context(), 0x3c0+offset, data); |
| 4346 | 4346 | } |
| 4347 | 4347 | else |
| 4348 | 4348 | { |
| 4349 | 4349 | if (v->banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(v->banshee.att)) |
| 4350 | 4350 | v->banshee.att[v->banshee.vga[0x3c1 & 0x1f]] = data; |
| 4351 | 4351 | if (LOG_REGISTERS) |
| 4352 | | logerror("%s:banshee_att_w(%X) = %02X\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3c1 & 0x1f], data); |
| 4352 | logerror("%s:banshee_att_w(%X) = %02X\n", device->machine->describe_context(), v->banshee.vga[0x3c1 & 0x1f], data); |
| 4353 | 4353 | } |
| 4354 | 4354 | v->banshee.attff ^= 1; |
| 4355 | 4355 | break; |
| r10326 | r10327 | |
| 4359 | 4359 | if (v->banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(v->banshee.seq)) |
| 4360 | 4360 | v->banshee.seq[v->banshee.vga[0x3c4 & 0x1f]] = data; |
| 4361 | 4361 | if (LOG_REGISTERS) |
| 4362 | | logerror("%s:banshee_seq_w(%X) = %02X\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3c4 & 0x1f], data); |
| 4362 | logerror("%s:banshee_seq_w(%X) = %02X\n", device->machine->describe_context(), v->banshee.vga[0x3c4 & 0x1f], data); |
| 4363 | 4363 | break; |
| 4364 | 4364 | |
| 4365 | 4365 | /* Graphics controller access */ |
| r10326 | r10327 | |
| 4367 | 4367 | if (v->banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(v->banshee.gc)) |
| 4368 | 4368 | v->banshee.gc[v->banshee.vga[0x3ce & 0x1f]] = data; |
| 4369 | 4369 | if (LOG_REGISTERS) |
| 4370 | | logerror("%s:banshee_gc_w(%X) = %02X\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3ce & 0x1f], data); |
| 4370 | logerror("%s:banshee_gc_w(%X) = %02X\n", device->machine->describe_context(), v->banshee.vga[0x3ce & 0x1f], data); |
| 4371 | 4371 | break; |
| 4372 | 4372 | |
| 4373 | 4373 | /* CRTC access */ |
| r10326 | r10327 | |
| 4375 | 4375 | if (v->banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(v->banshee.crtc)) |
| 4376 | 4376 | v->banshee.crtc[v->banshee.vga[0x3d4 & 0x1f]] = data; |
| 4377 | 4377 | if (LOG_REGISTERS) |
| 4378 | | logerror("%s:banshee_crtc_w(%X) = %02X\n", cpuexec_describe_context(device->machine), v->banshee.vga[0x3d4 & 0x1f], data); |
| 4378 | logerror("%s:banshee_crtc_w(%X) = %02X\n", device->machine->describe_context(), v->banshee.vga[0x3d4 & 0x1f], data); |
| 4379 | 4379 | break; |
| 4380 | 4380 | |
| 4381 | 4381 | default: |
| 4382 | 4382 | v->banshee.vga[offset] = data; |
| 4383 | 4383 | if (LOG_REGISTERS) |
| 4384 | | logerror("%s:banshee_vga_w(%X) = %02X\n", cpuexec_describe_context(device->machine), 0x3c0+offset, data); |
| 4384 | logerror("%s:banshee_vga_w(%X) = %02X\n", device->machine->describe_context(), 0x3c0+offset, data); |
| 4385 | 4385 | break; |
| 4386 | 4386 | } |
| 4387 | 4387 | } |
| r10326 | r10327 | |
| 4403 | 4403 | if ((v->banshee.io[offset] ^ old) & 0x2800) |
| 4404 | 4404 | v->fbi.clut_dirty = TRUE; |
| 4405 | 4405 | if (LOG_REGISTERS) |
| 4406 | | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); |
| 4406 | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", device->machine->describe_context(), banshee_io_reg_name[offset], data, mem_mask); |
| 4407 | 4407 | break; |
| 4408 | 4408 | |
| 4409 | 4409 | case io_dacData: |
| r10326 | r10327 | |
| 4414 | 4414 | v->fbi.clut_dirty = TRUE; |
| 4415 | 4415 | } |
| 4416 | 4416 | if (LOG_REGISTERS) |
| 4417 | | logerror("%s:banshee_dac_w(%X) = %08X & %08X\n", cpuexec_describe_context(device->machine), v->banshee.io[io_dacAddr] & 0x1ff, data, mem_mask); |
| 4417 | logerror("%s:banshee_dac_w(%X) = %08X & %08X\n", device->machine->describe_context(), v->banshee.io[io_dacAddr] & 0x1ff, data, mem_mask); |
| 4418 | 4418 | break; |
| 4419 | 4419 | |
| 4420 | 4420 | case io_miscInit0: |
| 4421 | 4421 | COMBINE_DATA(&v->banshee.io[offset]); |
| 4422 | 4422 | v->fbi.yorigin = (data >> 18) & 0xfff; |
| 4423 | 4423 | if (LOG_REGISTERS) |
| 4424 | | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); |
| 4424 | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", device->machine->describe_context(), banshee_io_reg_name[offset], data, mem_mask); |
| 4425 | 4425 | break; |
| 4426 | 4426 | |
| 4427 | 4427 | case io_vidScreenSize: |
| r10326 | r10327 | |
| 4435 | 4435 | v->screen->set_visible_area(0, v->fbi.width - 1, 0, v->fbi.height - 1); |
| 4436 | 4436 | adjust_vblank_timer(v); |
| 4437 | 4437 | if (LOG_REGISTERS) |
| 4438 | | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); |
| 4438 | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", device->machine->describe_context(), banshee_io_reg_name[offset], data, mem_mask); |
| 4439 | 4439 | break; |
| 4440 | 4440 | |
| 4441 | 4441 | case io_lfbMemoryConfig: |
| 4442 | 4442 | v->fbi.lfb_base = (data & 0x1fff) << 10; |
| 4443 | 4443 | v->fbi.lfb_stride = ((data >> 13) & 7) + 9; |
| 4444 | 4444 | if (LOG_REGISTERS) |
| 4445 | | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); |
| 4445 | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", device->machine->describe_context(), banshee_io_reg_name[offset], data, mem_mask); |
| 4446 | 4446 | break; |
| 4447 | 4447 | |
| 4448 | 4448 | case io_vgab0: case io_vgab4: case io_vgab8: case io_vgabc: |
| r10326 | r10327 | |
| 4461 | 4461 | default: |
| 4462 | 4462 | COMBINE_DATA(&v->banshee.io[offset]); |
| 4463 | 4463 | if (LOG_REGISTERS) |
| 4464 | | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); |
| 4464 | logerror("%s:banshee_io_w(%s) = %08X & %08X\n", device->machine->describe_context(), banshee_io_reg_name[offset], data, mem_mask); |
| 4465 | 4465 | break; |
| 4466 | 4466 | } |
| 4467 | 4467 | } |
| r10326 | r10327 | |
| 4576 | 4576 | } |
| 4577 | 4577 | |
| 4578 | 4578 | /* set the type, and initialize the chip mask */ |
| 4579 | | v->index = device->machine->m_devicelist.index(device->type(), device->tag()); |
| 4579 | v->index = device->machine->m_devicelist.indexof(device->type(), device->tag()); |
| 4580 | 4580 | v->screen = downcast<screen_device *>(device->machine->device(config->screen)); |
| 4581 | 4581 | assert_always(v->screen != NULL, "Unable to find screen attached to voodoo"); |
| 4582 | 4582 | v->cpu = device->machine->device(config->cputag); |
src/emu/sound/pokey.c
| r10326 | r10327 | |
| 465 | 465 | PROCESS_SAMPLE(chip); \ |
| 466 | 466 | } \ |
| 467 | 467 | } \ |
| 468 | | timer_adjust_oneshot(chip->rtimer, attotime::never, 0) |
| 468 | chip->rtimer->adjust(attotime::never) |
| 469 | 469 | |
| 470 | 470 | #else /* no HEAVY_MACRO_USAGE */ |
| 471 | 471 | /* |
| r10326 | r10327 | |
| 516 | 516 | PROCESS_CHANNEL(chip,channel); \ |
| 517 | 517 | } \ |
| 518 | 518 | } \ |
| 519 | | timer_adjust_oneshot(chip->rtimer, attotime::never, 0) |
| 519 | chip->rtimer->adjust(attotime::never) |
| 520 | 520 | |
| 521 | 521 | #endif |
| 522 | 522 | |
| r10326 | r10327 | |
| 781 | 781 | { |
| 782 | 782 | pokey_state *p = (pokey_state *)ptr; |
| 783 | 783 | int pot = param; |
| 784 | | LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * timer_timeelapsed(p->ptimer[pot]).as_double()))); |
| 784 | LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * p->ptimer[pot]->elapsed().as_double()))); |
| 785 | 785 | p->ALLPOT &= ~(1 << pot); /* set the enabled timer irq status bits */ |
| 786 | 786 | } |
| 787 | 787 | |
| r10326 | r10327 | |
| 810 | 810 | |
| 811 | 811 | /* final value */ |
| 812 | 812 | p->POTx[pot] = r; |
| 813 | | timer_adjust_oneshot(p->ptimer[pot], AD_TIME * r, pot); |
| 813 | p->ptimer[pot]->adjust(AD_TIME * r, pot); |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | } |
| r10326 | r10327 | |
| 836 | 836 | */ |
| 837 | 837 | if( p->ALLPOT & (1 << pot) ) |
| 838 | 838 | { |
| 839 | | data = timer_timeelapsed(p->ptimer[pot]).attoseconds / AD_TIME.attoseconds; |
| 839 | data = p->ptimer[pot]->elapsed().attoseconds / AD_TIME.attoseconds; |
| 840 | 840 | LOG(("POKEY '%s' read POT%d (interpolated) $%02x\n", p->device->tag(), pot, data)); |
| 841 | 841 | } |
| 842 | 842 | else |
| r10326 | r10327 | |
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | else |
| 849 | | logerror("%s: warning - read '%s' POT%d\n", cpuexec_describe_context(p->device->machine), p->device->tag(), pot); |
| 849 | logerror("%s: warning - read '%s' POT%d\n", p->device->machine->describe_context(), p->device->tag(), pot); |
| 850 | 850 | break; |
| 851 | 851 | |
| 852 | 852 | case ALLPOT_C: |
| r10326 | r10327 | |
| 886 | 886 | ****************************************************************/ |
| 887 | 887 | if( p->SKCTL & SK_RESET ) |
| 888 | 888 | { |
| 889 | | adjust = timer_timeelapsed(p->rtimer).as_double() / p->clock_period.as_double(); |
| 889 | adjust = p->rtimer->elapsed().as_double() / p->clock_period.as_double(); |
| 890 | 890 | p->r9 = (p->r9 + adjust) % 0x001ff; |
| 891 | 891 | p->r17 = (p->r17 + adjust) % 0x1ffff; |
| 892 | 892 | } |
| r10326 | r10327 | |
| 908 | 908 | LOG_RAND(("POKEY '%s' adjust %u rand17[$%05x]: $%02x\n", p->device->tag(), adjust, p->r17, p->RANDOM)); |
| 909 | 909 | } |
| 910 | 910 | if (adjust > 0) |
| 911 | | timer_adjust_oneshot(p->rtimer, attotime::never, 0); |
| 911 | p->rtimer->adjust(attotime::never); |
| 912 | 912 | data = p->RANDOM ^ 0xff; |
| 913 | 913 | break; |
| 914 | 914 | |
| r10326 | r10327 | |
| 1043 | 1043 | /* first remove any existing timers */ |
| 1044 | 1044 | LOG_TIMER(("POKEY '%s' STIMER $%02x\n", p->device->tag(), data)); |
| 1045 | 1045 | |
| 1046 | | timer_adjust_oneshot(p->timer[TIMER1], attotime::never, p->timer_param[TIMER1]); |
| 1047 | | timer_adjust_oneshot(p->timer[TIMER2], attotime::never, p->timer_param[TIMER2]); |
| 1048 | | timer_adjust_oneshot(p->timer[TIMER4], attotime::never, p->timer_param[TIMER4]); |
| 1046 | p->timer[TIMER1]->adjust(attotime::never, p->timer_param[TIMER1]); |
| 1047 | p->timer[TIMER2]->adjust(attotime::never, p->timer_param[TIMER2]); |
| 1048 | p->timer[TIMER4]->adjust(attotime::never, p->timer_param[TIMER4]); |
| 1049 | 1049 | |
| 1050 | 1050 | /* reset all counters to zero (side effect) */ |
| 1051 | 1051 | p->polyadjust = 0; |
| r10326 | r10327 | |
| 1063 | 1063 | /* set timer #1 _and_ #2 event after timer_div clocks of joined CHAN1+CHAN2 */ |
| 1064 | 1064 | p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2]; |
| 1065 | 1065 | p->timer_param[TIMER2] = IRQ_TIMR2|IRQ_TIMR1; |
| 1066 | | timer_adjust_periodic(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1066 | p->timer[TIMER2]->adjust(p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | else |
| r10326 | r10327 | |
| 1074 | 1074 | /* set timer #1 event after timer_div clocks of CHAN1 */ |
| 1075 | 1075 | p->timer_period[TIMER1] = p->clock_period * p->divisor[CHAN1]; |
| 1076 | 1076 | p->timer_param[TIMER1] = IRQ_TIMR1; |
| 1077 | | timer_adjust_periodic(p->timer[TIMER1], p->timer_period[TIMER1], p->timer_param[TIMER1], p->timer_period[TIMER1]); |
| 1077 | p->timer[TIMER1]->adjust(p->timer_period[TIMER1], p->timer_param[TIMER1], p->timer_period[TIMER1]); |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | if( p->divisor[CHAN2] > 4 ) |
| r10326 | r10327 | |
| 1083 | 1083 | /* set timer #2 event after timer_div clocks of CHAN2 */ |
| 1084 | 1084 | p->timer_period[TIMER2] = p->clock_period * p->divisor[CHAN2]; |
| 1085 | 1085 | p->timer_param[TIMER2] = IRQ_TIMR2; |
| 1086 | | timer_adjust_periodic(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1086 | p->timer[TIMER2]->adjust(p->timer_period[TIMER2], p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| r10326 | r10327 | |
| 1100 | 1100 | /* set timer #4 event after timer_div clocks of CHAN4 */ |
| 1101 | 1101 | p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4]; |
| 1102 | 1102 | p->timer_param[TIMER4] = IRQ_TIMR4; |
| 1103 | | timer_adjust_periodic(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1103 | p->timer[TIMER4]->adjust(p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| r10326 | r10327 | |
| 1112 | 1112 | /* set timer #4 event after timer_div clocks of CHAN4 */ |
| 1113 | 1113 | p->timer_period[TIMER4] = p->clock_period * p->divisor[CHAN4]; |
| 1114 | 1114 | p->timer_param[TIMER4] = IRQ_TIMR4; |
| 1115 | | timer_adjust_periodic(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1115 | p->timer[TIMER4]->adjust(p->timer_period[TIMER4], p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1116 | 1116 | } |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | | timer_enable(p->timer[TIMER1], p->IRQEN & IRQ_TIMR1); |
| 1120 | | timer_enable(p->timer[TIMER2], p->IRQEN & IRQ_TIMR2); |
| 1121 | | timer_enable(p->timer[TIMER4], p->IRQEN & IRQ_TIMR4); |
| 1119 | p->timer[TIMER1]->enable(p->IRQEN & IRQ_TIMR1); |
| 1120 | p->timer[TIMER2]->enable(p->IRQEN & IRQ_TIMR2); |
| 1121 | p->timer[TIMER4]->enable(p->IRQEN & IRQ_TIMR4); |
| 1122 | 1122 | break; |
| 1123 | 1123 | |
| 1124 | 1124 | case SKREST_C: |
| r10326 | r10327 | |
| 1160 | 1160 | /* enable/disable timers now to avoid unneeded |
| 1161 | 1161 | breaking of the CPU cores for masked timers */ |
| 1162 | 1162 | if( p->timer[TIMER1] && ((p->IRQEN^data) & IRQ_TIMR1) ) |
| 1163 | | timer_enable(p->timer[TIMER1], data & IRQ_TIMR1); |
| 1163 | p->timer[TIMER1]->enable(data & IRQ_TIMR1); |
| 1164 | 1164 | if( p->timer[TIMER2] && ((p->IRQEN^data) & IRQ_TIMR2) ) |
| 1165 | | timer_enable(p->timer[TIMER2], data & IRQ_TIMR2); |
| 1165 | p->timer[TIMER2]->enable(data & IRQ_TIMR2); |
| 1166 | 1166 | if( p->timer[TIMER4] && ((p->IRQEN^data) & IRQ_TIMR4) ) |
| 1167 | | timer_enable(p->timer[TIMER4], data & IRQ_TIMR4); |
| 1167 | p->timer[TIMER4]->enable(data & IRQ_TIMR4); |
| 1168 | 1168 | } |
| 1169 | 1169 | /* store irq enable */ |
| 1170 | 1170 | p->IRQEN = data; |
| r10326 | r10327 | |
| 1208 | 1208 | if( new_val < p->counter[CHAN1] ) |
| 1209 | 1209 | p->counter[CHAN1] = new_val; |
| 1210 | 1210 | if( p->interrupt_cb && p->timer[TIMER1] ) |
| 1211 | | timer_adjust_periodic(p->timer[TIMER1], p->clock_period * new_val, p->timer_param[TIMER1], p->timer_period[TIMER1]); |
| 1211 | p->timer[TIMER1]->adjust(p->clock_period * new_val, p->timer_param[TIMER1], p->timer_period[TIMER1]); |
| 1212 | 1212 | p->audible[CHAN1] = !( |
| 1213 | 1213 | (p->AUDC[CHAN1] & VOLUME_ONLY) || |
| 1214 | 1214 | (p->AUDC[CHAN1] & VOLUME_MASK) == 0 || |
| r10326 | r10327 | |
| 1244 | 1244 | if( new_val < p->counter[CHAN2] ) |
| 1245 | 1245 | p->counter[CHAN2] = new_val; |
| 1246 | 1246 | if( p->interrupt_cb && p->timer[TIMER2] ) |
| 1247 | | timer_adjust_periodic(p->timer[TIMER2], p->clock_period * new_val, p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1247 | p->timer[TIMER2]->adjust(p->clock_period * new_val, p->timer_param[TIMER2], p->timer_period[TIMER2]); |
| 1248 | 1248 | p->audible[CHAN2] = !( |
| 1249 | 1249 | (p->AUDC[CHAN2] & VOLUME_ONLY) || |
| 1250 | 1250 | (p->AUDC[CHAN2] & VOLUME_MASK) == 0 || |
| r10326 | r10327 | |
| 1309 | 1309 | if( new_val < p->counter[CHAN4] ) |
| 1310 | 1310 | p->counter[CHAN4] = new_val; |
| 1311 | 1311 | if( p->interrupt_cb && p->timer[TIMER4] ) |
| 1312 | | timer_adjust_periodic(p->timer[TIMER4], p->clock_period * new_val, p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1312 | p->timer[TIMER4]->adjust(p->clock_period * new_val, p->timer_param[TIMER4], p->timer_period[TIMER4]); |
| 1313 | 1313 | p->audible[CHAN4] = !( |
| 1314 | 1314 | (p->AUDC[CHAN4] & VOLUME_ONLY) || |
| 1315 | 1315 | (p->AUDC[CHAN4] & VOLUME_MASK) == 0 || |
src/emu/sound/es5506.c
| r10326 | r10327 | |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | if (LOG_COMMANDS && eslog) |
| 1622 | | fprintf(eslog, "%s:voice %d, control=%04x (raw=%04x & %04x)\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->control, data, mem_mask ^ 0xffff); |
| 1622 | fprintf(eslog, "%s:voice %d, control=%04x (raw=%04x & %04x)\n", machine->describe_context(), chip->current_page & 0x1f, voice->control, data, mem_mask ^ 0xffff); |
| 1623 | 1623 | break; |
| 1624 | 1624 | |
| 1625 | 1625 | case 0x01: /* FC */ |
| r10326 | r10327 | |
| 1628 | 1628 | if (ACCESSING_BITS_8_15) |
| 1629 | 1629 | voice->freqcount = (voice->freqcount & ~0x1fe00) | ((data & 0xff00) << 1); |
| 1630 | 1630 | if (LOG_COMMANDS && eslog) |
| 1631 | | fprintf(eslog, "%s:voice %d, freq count=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->freqcount); |
| 1631 | fprintf(eslog, "%s:voice %d, freq count=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->freqcount); |
| 1632 | 1632 | break; |
| 1633 | 1633 | |
| 1634 | 1634 | case 0x02: /* STRT (hi) */ |
| r10326 | r10327 | |
| 1637 | 1637 | if (ACCESSING_BITS_8_15) |
| 1638 | 1638 | voice->start = (voice->start & ~0x7c000000) | ((data & 0x1f00) << 18); |
| 1639 | 1639 | if (LOG_COMMANDS && eslog) |
| 1640 | | fprintf(eslog, "%s:voice %d, loop start=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->start); |
| 1640 | fprintf(eslog, "%s:voice %d, loop start=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->start); |
| 1641 | 1641 | break; |
| 1642 | 1642 | |
| 1643 | 1643 | case 0x03: /* STRT (lo) */ |
| r10326 | r10327 | |
| 1646 | 1646 | if (ACCESSING_BITS_8_15) |
| 1647 | 1647 | voice->start = (voice->start & ~0x0003fc00) | ((data & 0xff00) << 2); |
| 1648 | 1648 | if (LOG_COMMANDS && eslog) |
| 1649 | | fprintf(eslog, "%s:voice %d, loop start=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->start); |
| 1649 | fprintf(eslog, "%s:voice %d, loop start=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->start); |
| 1650 | 1650 | break; |
| 1651 | 1651 | |
| 1652 | 1652 | case 0x04: /* END (hi) */ |
| r10326 | r10327 | |
| 1658 | 1658 | voice->control |= CONTROL_STOP0; |
| 1659 | 1659 | #endif |
| 1660 | 1660 | if (LOG_COMMANDS && eslog) |
| 1661 | | fprintf(eslog, "%s:voice %d, loop end=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->end); |
| 1661 | fprintf(eslog, "%s:voice %d, loop end=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->end); |
| 1662 | 1662 | break; |
| 1663 | 1663 | |
| 1664 | 1664 | case 0x05: /* END (lo) */ |
| r10326 | r10327 | |
| 1670 | 1670 | voice->control |= CONTROL_STOP0; |
| 1671 | 1671 | #endif |
| 1672 | 1672 | if (LOG_COMMANDS && eslog) |
| 1673 | | fprintf(eslog, "%s:voice %d, loop end=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->end); |
| 1673 | fprintf(eslog, "%s:voice %d, loop end=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->end); |
| 1674 | 1674 | break; |
| 1675 | 1675 | |
| 1676 | 1676 | case 0x06: /* K2 */ |
| r10326 | r10327 | |
| 1679 | 1679 | if (ACCESSING_BITS_8_15) |
| 1680 | 1680 | voice->k2 = (voice->k2 & ~0xff00) | (data & 0xff00); |
| 1681 | 1681 | if (LOG_COMMANDS && eslog) |
| 1682 | | fprintf(eslog, "%s:voice %d, K2=%04x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->k2); |
| 1682 | fprintf(eslog, "%s:voice %d, K2=%04x\n", machine->describe_context(), chip->current_page & 0x1f, voice->k2); |
| 1683 | 1683 | break; |
| 1684 | 1684 | |
| 1685 | 1685 | case 0x07: /* K1 */ |
| r10326 | r10327 | |
| 1688 | 1688 | if (ACCESSING_BITS_8_15) |
| 1689 | 1689 | voice->k1 = (voice->k1 & ~0xff00) | (data & 0xff00); |
| 1690 | 1690 | if (LOG_COMMANDS && eslog) |
| 1691 | | fprintf(eslog, "%s:voice %d, K1=%04x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->k1); |
| 1691 | fprintf(eslog, "%s:voice %d, K1=%04x\n", machine->describe_context(), chip->current_page & 0x1f, voice->k1); |
| 1692 | 1692 | break; |
| 1693 | 1693 | |
| 1694 | 1694 | case 0x08: /* LVOL */ |
| 1695 | 1695 | if (ACCESSING_BITS_8_15) |
| 1696 | 1696 | voice->lvol = (voice->lvol & ~0xff00) | (data & 0xff00); |
| 1697 | 1697 | if (LOG_COMMANDS && eslog) |
| 1698 | | fprintf(eslog, "%s:voice %d, left vol=%04x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->lvol); |
| 1698 | fprintf(eslog, "%s:voice %d, left vol=%04x\n", machine->describe_context(), chip->current_page & 0x1f, voice->lvol); |
| 1699 | 1699 | break; |
| 1700 | 1700 | |
| 1701 | 1701 | case 0x09: /* RVOL */ |
| 1702 | 1702 | if (ACCESSING_BITS_8_15) |
| 1703 | 1703 | voice->rvol = (voice->rvol & ~0xff00) | (data & 0xff00); |
| 1704 | 1704 | if (LOG_COMMANDS && eslog) |
| 1705 | | fprintf(eslog, "%s:voice %d, right vol=%04x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->rvol); |
| 1705 | fprintf(eslog, "%s:voice %d, right vol=%04x\n", machine->describe_context(), chip->current_page & 0x1f, voice->rvol); |
| 1706 | 1706 | break; |
| 1707 | 1707 | |
| 1708 | 1708 | case 0x0a: /* ACC (hi) */ |
| r10326 | r10327 | |
| 1711 | 1711 | if (ACCESSING_BITS_8_15) |
| 1712 | 1712 | voice->accum = (voice->accum & ~0x7c000000) | ((data & 0x1f00) << 18); |
| 1713 | 1713 | if (LOG_COMMANDS && eslog) |
| 1714 | | fprintf(eslog, "%s:voice %d, accum=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->accum); |
| 1714 | fprintf(eslog, "%s:voice %d, accum=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->accum); |
| 1715 | 1715 | break; |
| 1716 | 1716 | |
| 1717 | 1717 | case 0x0b: /* ACC (lo) */ |
| r10326 | r10327 | |
| 1720 | 1720 | if (ACCESSING_BITS_8_15) |
| 1721 | 1721 | voice->accum = (voice->accum & ~0x0003fc00) | ((data & 0xff00) << 2); |
| 1722 | 1722 | if (LOG_COMMANDS && eslog) |
| 1723 | | fprintf(eslog, "%s:voice %d, accum=%08x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->accum); |
| 1723 | fprintf(eslog, "%s:voice %d, accum=%08x\n", machine->describe_context(), chip->current_page & 0x1f, voice->accum); |
| 1724 | 1724 | break; |
| 1725 | 1725 | |
| 1726 | 1726 | case 0x0c: /* unused */ |
| r10326 | r10327 | |
| 1769 | 1769 | ((data << 2) & (CONTROL_CA0 | CONTROL_CA1)); |
| 1770 | 1770 | } |
| 1771 | 1771 | if (LOG_COMMANDS && eslog) |
| 1772 | | fprintf(eslog, "%s:voice %d, control=%04x (raw=%04x & %04x)\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->control, data, mem_mask); |
| 1772 | fprintf(eslog, "%s:voice %d, control=%04x (raw=%04x & %04x)\n", machine->describe_context(), chip->current_page & 0x1f, voice->control, data, mem_mask); |
| 1773 | 1773 | break; |
| 1774 | 1774 | |
| 1775 | 1775 | case 0x01: /* O4(n-1) */ |
| r10326 | r10327 | |
| 1778 | 1778 | if (ACCESSING_BITS_8_15) |
| 1779 | 1779 | voice->o4n1 = (INT16)((voice->o4n1 & ~0xff00) | (data & 0xff00)); |
| 1780 | 1780 | if (LOG_COMMANDS && eslog) |
| 1781 | | fprintf(eslog, "%s:voice %d, O4(n-1)=%05x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o4n1 & 0x3ffff); |
| 1781 | fprintf(eslog, "%s:voice %d, O4(n-1)=%05x\n", machine->describe_context(), chip->current_page & 0x1f, voice->o4n1 & 0x3ffff); |
| 1782 | 1782 | break; |
| 1783 | 1783 | |
| 1784 | 1784 | case 0x02: /* O3(n-1) */ |
| r10326 | r10327 | |
| 1787 | 1787 | if (ACCESSING_BITS_8_15) |
| 1788 | 1788 | voice->o3n1 = (INT16)((voice->o3n1 & ~0xff00) | (data & 0xff00)); |
| 1789 | 1789 | if (LOG_COMMANDS && eslog) |
| 1790 | | fprintf(eslog, "%s:voice %d, O3(n-1)=%05x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o3n1 & 0x3ffff); |
| 1790 | fprintf(eslog, "%s:voice %d, O3(n-1)=%05x\n", machine->describe_context(), chip->current_page & 0x1f, voice->o3n1 & 0x3ffff); |
| 1791 | 1791 | break; |
| 1792 | 1792 | |
| 1793 | 1793 | case 0x03: /* O3(n-2) */ |
| r10326 | r10327 | |
| 1796 | 1796 | if (ACCESSING_BITS_8_15) |
| 1797 | 1797 | voice->o3n2 = (INT16)((voice->o3n2 & ~0xff00) | (data & 0xff00)); |
| 1798 | 1798 | if (LOG_COMMANDS && eslog) |
| 1799 | | fprintf(eslog, "%s:voice %d, O3(n-2)=%05x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o3n2 & 0x3ffff); |
| 1799 | fprintf(eslog, "%s:voice %d, O3(n-2)=%05x\n", machine->describe_context(), chip->current_page & 0x1f, voice->o3n2 & 0x3ffff); |
| 1800 | 1800 | break; |
| 1801 | 1801 | |
| 1802 | 1802 | case 0x04: /* O2(n-1) */ |
| r10326 | r10327 | |
| 1805 | 1805 | if (ACCESSING_BITS_8_15) |
| 1806 | 1806 | voice->o2n1 = (INT16)((voice->o2n1 & ~0xff00) | (data & 0xff00)); |
| 1807 | 1807 | if (LOG_COMMANDS && eslog) |
| 1808 | | fprintf(eslog, "%s:voice %d, O2(n-1)=%05x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o2n1 & 0x3ffff); |
| 1808 | fprintf(eslog, "%s:voice %d, O2(n-1)=%05x\n", machine->describe_context(), chip->current_page & 0x1f, voice->o2n1 & 0x3ffff); |
| 1809 | 1809 | break; |
| 1810 | 1810 | |
| 1811 | 1811 | case 0x05: /* O2(n-2) */ |
| r10326 | r10327 | |
| 1814 | 1814 | if (ACCESSING_BITS_8_15) |
| 1815 | 1815 | voice->o2n2 = (INT16)((voice->o2n2 & ~0xff00) | (data & 0xff00)); |
| 1816 | 1816 | if (LOG_COMMANDS && eslog) |
| 1817 | | fprintf(eslog, "%s:voice %d, O2(n-2)=%05x\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o2n2 & 0x3ffff); |
| 1817 | fprintf(eslog, "%s:voice %d, O2(n-2)=%05x\n", machine->describe_context(), chip->current_page & 0x1f, voice->o2n2 & 0x3ffff); |
| 1818 | 1818 | break; |
| 1819 | 1819 | |
| 1820 | 1820 | case 0x06: /* O1(n-1) */ |
| r10326 | r10327 | |
| 1823 | 1823 | if (ACCESSING_BITS_8_15) |
| 1824 | 1824 | voice->o1n1 = (INT16)((voice->o1n1 & ~0xff00) | (data & 0xff00)); |
| 1825 | 1825 | if (LOG_COMMANDS && eslog) |
| 1826 | | fprintf(eslog, "%s:voice %d, O1(n-1)=%05x (accum=%08x)\n", cpuexec_describe_context(machine), chip->current_page & 0x1f, voice->o2n1 & 0x3ffff, voice->accum); |
| 1826 | fprintf(eslog, "%s:voice %d, O1(n-1)=%05x (accum=%08x)\n", machine->describe_context(), chip->current_page & 0x1f, voice->o2n1 & 0x3ffff, voice->accum); |
| 1827 | 1827 | break; |
| 1828 | 1828 | |
| 1829 | 1829 | case 0x07: |
| r10326 | r10327 | |
| 1906 | 1906 | es5506_state *chip = get_safe_token(device); |
| 1907 | 1907 | es5506_voice *voice = &chip->voice[chip->current_page & 0x1f]; |
| 1908 | 1908 | |
| 1909 | | // logerror("%s:ES5505 write %02x/%02x = %04x & %04x\n", cpuexec_describe_context(machine), chip->current_page, offset, data, mem_mask); |
| 1909 | // logerror("%s:ES5505 write %02x/%02x = %04x & %04x\n", machine->describe_context(), chip->current_page, offset, data, mem_mask); |
| 1910 | 1910 | |
| 1911 | 1911 | /* force an update */ |
| 1912 | 1912 | chip->stream->update(); |
src/emu/emutempl.h
| r0 | r10327 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | emutempl.h |
| 4 | |
| 5 | Core templates for basic non-string types. |
| 6 | |
| 7 | **************************************************************************** |
| 8 | |
| 9 | Copyright Aaron Giles |
| 10 | All rights reserved. |
| 11 | |
| 12 | Redistribution and use in source and binary forms, with or without |
| 13 | modification, are permitted provided that the following conditions are |
| 14 | met: |
| 15 | |
| 16 | * Redistributions of source code must retain the above copyright |
| 17 | notice, this list of conditions and the following disclaimer. |
| 18 | * Redistributions in binary form must reproduce the above copyright |
| 19 | notice, this list of conditions and the following disclaimer in |
| 20 | the documentation and/or other materials provided with the |
| 21 | distribution. |
| 22 | * Neither the name 'MAME' nor the names of its contributors may be |
| 23 | used to endorse or promote products derived from this software |
| 24 | without specific prior written permission. |
| 25 | |
| 26 | THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR |
| 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 29 | DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, |
| 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 34 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 35 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 36 | POSSIBILITY OF SUCH DAMAGE. |
| 37 | |
| 38 | ***************************************************************************/ |
| 39 | |
| 40 | #pragma once |
| 41 | |
| 42 | #ifndef __EMUTEMPL_H__ |
| 43 | #define __EMUTEMPL_H__ |
| 44 | |
| 45 | |
| 46 | //************************************************************************** |
| 47 | // TYPE DEFINITIONS |
| 48 | //************************************************************************** |
| 49 | |
| 50 | // ======================> simple_list |
| 51 | |
| 52 | // a simple_list is a singly-linked list whose 'next' pointer is owned |
| 53 | // by the object |
| 54 | template<class T> |
| 55 | class simple_list |
| 56 | { |
| 57 | // we don't support deep copying |
| 58 | DISABLE_COPYING(simple_list); |
| 59 | |
| 60 | public: |
| 61 | // construction/destruction |
| 62 | simple_list(resource_pool &pool = global_resource_pool) : |
| 63 | m_head(NULL), |
| 64 | m_tail(NULL), |
| 65 | m_pool(pool), |
| 66 | m_count(0) { } |
| 67 | |
| 68 | virtual ~simple_list() { reset(); } |
| 69 | |
| 70 | // simple getters |
| 71 | resource_pool &pool() const { return m_pool; } |
| 72 | T *first() const { return m_head; } |
| 73 | T *last() const { return m_tail; } |
| 74 | int count() const { return m_count; } |
| 75 | |
| 76 | // remove (free) all objects in the list, leaving an empty list |
| 77 | void reset() |
| 78 | { |
| 79 | while (m_head != NULL) |
| 80 | remove(*m_head); |
| 81 | } |
| 82 | |
| 83 | // add the given object to the head of the list |
| 84 | T &prepend(T &object) |
| 85 | { |
| 86 | object.m_next = m_head; |
| 87 | m_head = &object; |
| 88 | if (m_tail == NULL) |
| 89 | m_tail = m_head; |
| 90 | m_count++; |
| 91 | return object; |
| 92 | } |
| 93 | |
| 94 | // add the given list to the head of the list |
| 95 | void prepend_list(simple_list<T> &list) |
| 96 | { |
| 97 | int count = list.count(); |
| 98 | if (count == 0) |
| 99 | return; |
| 100 | T *tail = list.last(); |
| 101 | T *head = list.detach_all(); |
| 102 | tail->m_next = m_head; |
| 103 | m_head = head; |
| 104 | if (m_tail == NULL) |
| 105 | m_tail = tail; |
| 106 | m_count += count; |
| 107 | } |
| 108 | |
| 109 | // add the given object to the tail of the list |
| 110 | T &append(T &object) |
| 111 | { |
| 112 | object.m_next = NULL; |
| 113 | if (m_tail != NULL) |
| 114 | m_tail = m_tail->m_next = &object; |
| 115 | else |
| 116 | m_tail = m_head = &object; |
| 117 | m_count++; |
| 118 | return object; |
| 119 | } |
| 120 | |
| 121 | // add the given list to the tail of the list |
| 122 | void append_list(simple_list<T> &list) |
| 123 | { |
| 124 | int count = list.count(); |
| 125 | if (count == 0) |
| 126 | return; |
| 127 | T *tail = list.last(); |
| 128 | T *head = list.detach_all(); |
| 129 | if (m_tail != NULL) |
| 130 | m_tail->m_next = head; |
| 131 | else |
| 132 | m_head = head; |
| 133 | m_tail = tail; |
| 134 | m_count += count; |
| 135 | } |
| 136 | |
| 137 | // insert the given object after a particular object (NULL means prepend) |
| 138 | T &insert_after(T &object, T *insert_after) |
| 139 | { |
| 140 | if (insert_after == NULL) |
| 141 | return prepend(object); |
| 142 | object.m_next = insert_after->m_next; |
| 143 | insert_after->m_next = &object; |
| 144 | m_count++; |
| 145 | return object; |
| 146 | } |
| 147 | |
| 148 | // replace an item in the list at the same location, and remove it |
| 149 | T &replace_and_remove(T &object, T &toreplace) |
| 150 | { |
| 151 | T *prev = NULL; |
| 152 | for (T *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) |
| 153 | if (cur == &toreplace) |
| 154 | { |
| 155 | if (prev != NULL) |
| 156 | prev->m_next = &object; |
| 157 | else |
| 158 | m_head = &object; |
| 159 | if (m_tail == &toreplace) |
| 160 | m_tail = &object; |
| 161 | object.m_next = toreplace.m_next; |
| 162 | pool_free(m_pool, &toreplace); |
| 163 | return object; |
| 164 | } |
| 165 | return append(object); |
| 166 | } |
| 167 | |
| 168 | // detach the head item from the list, but don't free its memory |
| 169 | T *detach_head() |
| 170 | { |
| 171 | T *result = m_head; |
| 172 | if (result != NULL) |
| 173 | { |
| 174 | m_head = result->m_next; |
| 175 | m_count--; |
| 176 | if (m_head == NULL) |
| 177 | m_tail = NULL; |
| 178 | } |
| 179 | return result; |
| 180 | } |
| 181 | |
| 182 | // detach the given item from the list, but don't free its memory |
| 183 | T &detach(T &object) |
| 184 | { |
| 185 | T *prev = NULL; |
| 186 | for (T *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) |
| 187 | if (cur == &object) |
| 188 | { |
| 189 | if (prev != NULL) |
| 190 | prev->m_next = object.m_next; |
| 191 | else |
| 192 | m_head = object.m_next; |
| 193 | if (m_tail == &object) |
| 194 | m_tail = prev; |
| 195 | m_count--; |
| 196 | return object; |
| 197 | } |
| 198 | return object; |
| 199 | } |
| 200 | |
| 201 | // deatch the entire list, returning the head, but don't free memory |
| 202 | T *detach_all() |
| 203 | { |
| 204 | T *result = m_head; |
| 205 | m_head = m_tail = NULL; |
| 206 | m_count = 0; |
| 207 | return result; |
| 208 | } |
| 209 | |
| 210 | // remove the given object and free its memory |
| 211 | void remove(T &object) |
| 212 | { |
| 213 | detach(object); |
| 214 | pool_free(m_pool, &object); |
| 215 | } |
| 216 | |
| 217 | // find an object by index in the list |
| 218 | T *find(int index) const |
| 219 | { |
| 220 | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 221 | if (index-- == 0) |
| 222 | return cur; |
| 223 | return NULL; |
| 224 | } |
| 225 | |
| 226 | // return the index of the given object in the list |
| 227 | int indexof(const T &object) const |
| 228 | { |
| 229 | int index = 0; |
| 230 | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 231 | { |
| 232 | if (cur == &object) |
| 233 | return index; |
| 234 | index++; |
| 235 | } |
| 236 | return -1; |
| 237 | } |
| 238 | |
| 239 | private: |
| 240 | // internal state |
| 241 | T * m_head; // head of the singly-linked list |
| 242 | T * m_tail; // tail of the singly-linked list |
| 243 | resource_pool & m_pool; // resource pool where objects are freed |
| 244 | int m_count; // number of objects in the list |
| 245 | }; |
| 246 | |
| 247 | |
| 248 | // ======================> fixed_allocator |
| 249 | |
| 250 | // a fixed_allocator is a simple class that maintains a free pool of objects |
| 251 | template<class T> |
| 252 | class fixed_allocator |
| 253 | { |
| 254 | // we don't support deep copying |
| 255 | DISABLE_COPYING(fixed_allocator); |
| 256 | |
| 257 | public: |
| 258 | // construction/destruction |
| 259 | fixed_allocator(resource_pool &pool = global_resource_pool) |
| 260 | : m_freelist(pool) { } |
| 261 | |
| 262 | // allocate a new item, either by recycling an old one, or by allocating a new one |
| 263 | T *alloc() |
| 264 | { |
| 265 | T *result = m_freelist.detach_head(); |
| 266 | if (result == NULL) |
| 267 | result = m_freelist.pool().add_object(new T); |
| 268 | return result; |
| 269 | } |
| 270 | |
| 271 | // reclaim an item by adding it to the free list |
| 272 | void reclaim(T *item) { if (item != NULL) m_freelist.append(*item); } |
| 273 | void reclaim(T &item) { m_freelist.append(item); } |
| 274 | |
| 275 | // reclaim all items from a list |
| 276 | void reclaim_all(simple_list<T> &list) { m_freelist.append_list(list); } |
| 277 | |
| 278 | private: |
| 279 | // internal state |
| 280 | simple_list<T> m_freelist; // list of free objects |
| 281 | }; |
| 282 | |
| 283 | |
| 284 | // ======================> tagged_list |
| 285 | |
| 286 | // a tagged_list is a class that maintains a list of objects that can be quickly looked up by tag |
| 287 | template<class T> |
| 288 | class tagged_list |
| 289 | { |
| 290 | // we don't support deep copying |
| 291 | DISABLE_COPYING(tagged_list); |
| 292 | |
| 293 | public: |
| 294 | // construction/destruction |
| 295 | tagged_list(resource_pool &pool = global_resource_pool) : |
| 296 | m_list(pool) { } |
| 297 | |
| 298 | // simple getters |
| 299 | resource_pool &pool() const { return m_list.pool(); } |
| 300 | T *first() const { return m_list.first(); } |
| 301 | T *last() const { return m_list.last(); } |
| 302 | int count() const { return m_list.count(); } |
| 303 | |
| 304 | // remove (free) all objects in the list, leaving an empty list |
| 305 | void reset() { m_list.reset(); m_map.reset(); } |
| 306 | |
| 307 | // add the given object to the head of the list |
| 308 | T &prepend(const char *tag, T &object) |
| 309 | { |
| 310 | if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE) |
| 311 | throw emu_fatalerror("Error adding object named '%s'", tag); |
| 312 | return m_list.prepend(object); |
| 313 | } |
| 314 | |
| 315 | // add the given object to the tail of the list |
| 316 | T &append(const char *tag, T &object) |
| 317 | { |
| 318 | if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE) |
| 319 | throw emu_fatalerror("Error adding object named '%s'", tag); |
| 320 | return m_list.append(object); |
| 321 | } |
| 322 | |
| 323 | // insert the given object after a particular object (NULL means prepend) |
| 324 | T &insert_after(const char *tag, T &object, T *insert_after) |
| 325 | { |
| 326 | if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE) |
| 327 | throw emu_fatalerror("Error adding object named '%s'", tag); |
| 328 | return m_list.insert_after(object, insert_after); |
| 329 | } |
| 330 | |
| 331 | // replace an item in the list at the same location, and remove it |
| 332 | T &replace_and_remove(const char *tag, T &object, T &toreplace) |
| 333 | { |
| 334 | m_map.remove(&toreplace); |
| 335 | m_list.replace_and_remove(object, toreplace); |
| 336 | if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE) |
| 337 | throw emu_fatalerror("Error replacing object named '%s'", tag); |
| 338 | return object; |
| 339 | } |
| 340 | |
| 341 | // detach the given item from the list, but don't free its memory |
| 342 | T &detach(T &object) |
| 343 | { |
| 344 | m_map.remove(&object); |
| 345 | return m_list.detach(object); |
| 346 | } |
| 347 | |
| 348 | // remove the given object and free its memory |
| 349 | void remove(T &object) |
| 350 | { |
| 351 | m_map.remove(&object); |
| 352 | return m_list.remove(object); |
| 353 | } |
| 354 | |
| 355 | // find an object by index in the list |
| 356 | T *find(int index) const |
| 357 | { |
| 358 | return m_list.find(index); |
| 359 | } |
| 360 | |
| 361 | // return the index of the given object in the list |
| 362 | int indexof(const T &object) const |
| 363 | { |
| 364 | return m_list.indexof(object); |
| 365 | } |
| 366 | |
| 367 | // operations by tag |
| 368 | T &replace_and_remove(const char *tag, T &object) { T *existing = find(tag); return (existing == NULL) ? append(tag, object) : replace_and_remove(tag, object, *existing); } |
| 369 | void remove(const char *tag) { T *object = find(tag); if (object != NULL) remove(*object); } |
| 370 | T *find(const char *tag) const { return m_map.find_hash_only(tag); } |
| 371 | int indexof(const char *tag) const { T *object = find(tag); return (object != NULL) ? m_list.indexof(*object) : NULL; } |
| 372 | |
| 373 | private: |
| 374 | // internal state |
| 375 | simple_list<T> m_list; |
| 376 | tagmap_t<T *> m_map; |
| 377 | }; |
| 378 | |
| 379 | |
| 380 | #endif /* __EMUTEMPL_H__ */ |
src/emu/machine/mc68901.c
| r10326 | r10327 | |
| 727 | 727 | case TCR_TIMER_PULSE_64:
|
| 728 | 728 | case TCR_TIMER_PULSE_100:
|
| 729 | 729 | case TCR_TIMER_PULSE_200:
|
| 730 | | timer_enable(m_timer[index], (value == aer));
|
| 730 | m_timer[index]->enable((value == aer));
|
| 731 | 731 | |
| 732 | 732 | if (((m_ti[index] ^ aer) == 0) && ((value ^ aer) == 1))
|
| 733 | 733 | {
|
| r10326 | r10327 | |
| 809 | 809 | if (m_config.rx_clock > 0)
|
| 810 | 810 | {
|
| 811 | 811 | m_rx_timer = timer_alloc(TIMER_RX);
|
| 812 | | timer_adjust_periodic(m_rx_timer, attotime::zero, 0, attotime::from_hz(m_config.rx_clock));
|
| 812 | m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_config.rx_clock));
|
| 813 | 813 | }
|
| 814 | 814 | |
| 815 | 815 | if (m_config.tx_clock > 0)
|
| 816 | 816 | {
|
| 817 | 817 | m_tx_timer = timer_alloc(TIMER_TX);
|
| 818 | | timer_adjust_periodic(m_tx_timer, attotime::zero, 0, attotime::from_hz(m_config.tx_clock));
|
| 818 | m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_config.tx_clock));
|
| 819 | 819 | }
|
| 820 | 820 | |
| 821 | 821 | /* register for state saving */
|
| r10326 | r10327 | |
| 1066 | 1066 | {
|
| 1067 | 1067 | case TCR_TIMER_STOPPED:
|
| 1068 | 1068 | if (LOG) logerror("MC68901 '%s' Timer A Stopped\n", tag());
|
| 1069 | | timer_enable(m_timer[TIMER_A], 0);
|
| 1069 | m_timer[TIMER_A]->enable(false);
|
| 1070 | 1070 | break;
|
| 1071 | 1071 | |
| 1072 | 1072 | case TCR_TIMER_DELAY_4:
|
| r10326 | r10327 | |
| 1079 | 1079 | {
|
| 1080 | 1080 | int divisor = PRESCALER[m_tacr & 0x07];
|
| 1081 | 1081 | if (LOG) logerror("MC68901 '%s' Timer A Delay Mode : %u Prescale\n", tag(), divisor);
|
| 1082 | | timer_adjust_periodic(m_timer[TIMER_A], attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1082 | m_timer[TIMER_A]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1083 | 1083 | }
|
| 1084 | 1084 | break;
|
| 1085 | 1085 | |
| 1086 | 1086 | case TCR_TIMER_EVENT:
|
| 1087 | 1087 | if (LOG) logerror("MC68901 '%s' Timer A Event Count Mode\n", tag());
|
| 1088 | | timer_enable(m_timer[TIMER_A], 0);
|
| 1088 | m_timer[TIMER_A]->enable(false);
|
| 1089 | 1089 | break;
|
| 1090 | 1090 | |
| 1091 | 1091 | case TCR_TIMER_PULSE_4:
|
| r10326 | r10327 | |
| 1098 | 1098 | {
|
| 1099 | 1099 | int divisor = PRESCALER[m_tacr & 0x07];
|
| 1100 | 1100 | if (LOG) logerror("MC68901 '%s' Timer A Pulse Width Mode : %u Prescale\n", tag(), divisor);
|
| 1101 | | timer_adjust_periodic(m_timer[TIMER_A], attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1102 | | timer_enable(m_timer[TIMER_A], 0);
|
| 1101 | m_timer[TIMER_A]->adjust(attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1102 | m_timer[TIMER_A]->enable(false);
|
| 1103 | 1103 | }
|
| 1104 | 1104 | break;
|
| 1105 | 1105 | }
|
| r10326 | r10327 | |
| 1121 | 1121 | {
|
| 1122 | 1122 | case TCR_TIMER_STOPPED:
|
| 1123 | 1123 | if (LOG) logerror("MC68901 '%s' Timer B Stopped\n", tag());
|
| 1124 | | timer_enable(m_timer[TIMER_B], 0);
|
| 1124 | m_timer[TIMER_B]->enable(false);
|
| 1125 | 1125 | break;
|
| 1126 | 1126 | |
| 1127 | 1127 | case TCR_TIMER_DELAY_4:
|
| r10326 | r10327 | |
| 1134 | 1134 | {
|
| 1135 | 1135 | int divisor = PRESCALER[m_tbcr & 0x07];
|
| 1136 | 1136 | if (LOG) logerror("MC68901 '%s' Timer B Delay Mode : %u Prescale\n", tag(), divisor);
|
| 1137 | | timer_adjust_periodic(m_timer[TIMER_B], attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1137 | m_timer[TIMER_B]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1138 | 1138 | }
|
| 1139 | 1139 | break;
|
| 1140 | 1140 | |
| 1141 | 1141 | case TCR_TIMER_EVENT:
|
| 1142 | 1142 | if (LOG) logerror("MC68901 '%s' Timer B Event Count Mode\n", tag());
|
| 1143 | | timer_enable(m_timer[TIMER_B], 0);
|
| 1143 | m_timer[TIMER_B]->enable(false);
|
| 1144 | 1144 | break;
|
| 1145 | 1145 | |
| 1146 | 1146 | case TCR_TIMER_PULSE_4:
|
| r10326 | r10327 | |
| 1153 | 1153 | {
|
| 1154 | 1154 | int divisor = PRESCALER[m_tbcr & 0x07];
|
| 1155 | 1155 | if (LOG) logerror("MC68901 '%s' Timer B Pulse Width Mode : %u Prescale\n", tag(), DIVISOR);
|
| 1156 | | timer_adjust_periodic(m_timer[TIMER_B], attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1157 | | timer_enable(m_timer[TIMER_B], 0);
|
| 1156 | m_timer[TIMER_B]->adjust(attotime::never, 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1157 | m_timer[TIMER_B]->enable(false);
|
| 1158 | 1158 | }
|
| 1159 | 1159 | break;
|
| 1160 | 1160 | }
|
| r10326 | r10327 | |
| 1176 | 1176 | {
|
| 1177 | 1177 | case TCR_TIMER_STOPPED:
|
| 1178 | 1178 | if (LOG) logerror("MC68901 '%s' Timer D Stopped\n", tag());
|
| 1179 | | timer_enable(m_timer[TIMER_D], 0);
|
| 1179 | m_timer[TIMER_D]->enable(false);
|
| 1180 | 1180 | break;
|
| 1181 | 1181 | |
| 1182 | 1182 | case TCR_TIMER_DELAY_4:
|
| r10326 | r10327 | |
| 1189 | 1189 | {
|
| 1190 | 1190 | int divisor = PRESCALER[m_tcdcr & 0x07];
|
| 1191 | 1191 | if (LOG) logerror("MC68901 '%s' Timer D Delay Mode : %u Prescale\n", tag(), divisor);
|
| 1192 | | timer_adjust_periodic(m_timer[TIMER_D], attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1192 | m_timer[TIMER_D]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1193 | 1193 | }
|
| 1194 | 1194 | break;
|
| 1195 | 1195 | }
|
| r10326 | r10327 | |
| 1198 | 1198 | {
|
| 1199 | 1199 | case TCR_TIMER_STOPPED:
|
| 1200 | 1200 | if (LOG) logerror("MC68901 '%s' Timer C Stopped\n", tag());
|
| 1201 | | timer_enable(m_timer[TIMER_C], 0);
|
| 1201 | m_timer[TIMER_C]->enable(false);
|
| 1202 | 1202 | break;
|
| 1203 | 1203 | |
| 1204 | 1204 | case TCR_TIMER_DELAY_4:
|
| r10326 | r10327 | |
| 1211 | 1211 | {
|
| 1212 | 1212 | int divisor = PRESCALER[(m_tcdcr >> 4) & 0x07];
|
| 1213 | 1213 | if (LOG) logerror("MC68901 '%s' Timer C Delay Mode : %u Prescale\n", tag(), divisor);
|
| 1214 | | timer_adjust_periodic(m_timer[TIMER_C], attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1214 | m_timer[TIMER_C]->adjust(attotime::from_hz(m_timer_clock / divisor), 0, attotime::from_hz(m_timer_clock / divisor));
|
| 1215 | 1215 | }
|
| 1216 | 1216 | break;
|
| 1217 | 1217 | }
|
| r10326 | r10327 | |
| 1222 | 1222 | |
| 1223 | 1223 | m_tdr[TIMER_A] = data;
|
| 1224 | 1224 | |
| 1225 | | if (!timer_enabled(m_timer[TIMER_A]))
|
| 1225 | if (!m_timer[TIMER_A]->enabled())
|
| 1226 | 1226 | {
|
| 1227 | 1227 | m_tmc[TIMER_A] = data;
|
| 1228 | 1228 | }
|
| r10326 | r10327 | |
| 1233 | 1233 | |
| 1234 | 1234 | m_tdr[TIMER_B] = data;
|
| 1235 | 1235 | |
| 1236 | | if (!timer_enabled(m_timer[TIMER_B]))
|
| 1236 | if (!m_timer[TIMER_B]->enabled())
|
| 1237 | 1237 | {
|
| 1238 | 1238 | m_tmc[TIMER_B] = data;
|
| 1239 | 1239 | }
|
| r10326 | r10327 | |
| 1244 | 1244 | |
| 1245 | 1245 | m_tdr[TIMER_C] = data;
|
| 1246 | 1246 | |
| 1247 | | if (!timer_enabled(m_timer[TIMER_C]))
|
| 1247 | if (!m_timer[TIMER_C]->enabled())
|
| 1248 | 1248 | {
|
| 1249 | 1249 | m_tmc[TIMER_C] = data;
|
| 1250 | 1250 | }
|
| r10326 | r10327 | |
| 1255 | 1255 | |
| 1256 | 1256 | m_tdr[TIMER_D] = data;
|
| 1257 | 1257 | |
| 1258 | | if (!timer_enabled(m_timer[TIMER_D]))
|
| 1258 | if (!m_timer[TIMER_D]->enabled())
|
| 1259 | 1259 | {
|
| 1260 | 1260 | m_tmc[TIMER_D] = data;
|
| 1261 | 1261 | }
|
src/emu/machine/idectrl.c
| r10326 | r10327 | |
| 1244 | 1244 | |
| 1245 | 1245 | /* logit */ |
| 1246 | 1246 | // if (BANK(bank, offset) != IDE_BANK0_DATA && BANK(bank, offset) != IDE_BANK0_STATUS_COMMAND && BANK(bank, offset) != IDE_BANK1_STATUS_CONTROL) |
| 1247 | | LOG(("%s:IDE read at %d:%X, size=%d\n", cpuexec_describe_context(device->machine), bank, offset, size)); |
| 1247 | LOG(("%s:IDE read at %d:%X, size=%d\n", device->machine->describe_context(), bank, offset, size)); |
| 1248 | 1248 | |
| 1249 | 1249 | switch (BANK(bank, offset)) |
| 1250 | 1250 | { |
| r10326 | r10327 | |
| 1279 | 1279 | /* if we're at the end of the buffer, handle it */ |
| 1280 | 1280 | if (ide->buffer_offset >= IDE_DISK_SECTOR_SIZE) |
| 1281 | 1281 | { |
| 1282 | | LOG(("%s:IDE completed PIO read\n", cpuexec_describe_context(device->machine))); |
| 1282 | LOG(("%s:IDE completed PIO read\n", device->machine->describe_context())); |
| 1283 | 1283 | continue_read(ide); |
| 1284 | 1284 | } |
| 1285 | 1285 | } |
| r10326 | r10327 | |
| 1314 | 1314 | /* return the current status but don't clear interrupts */ |
| 1315 | 1315 | case IDE_BANK1_STATUS_CONTROL: |
| 1316 | 1316 | result = ide->status; |
| 1317 | | if (timer_timeelapsed(ide->last_status_timer) > TIME_PER_ROTATION) |
| 1317 | if (ide->last_status_timer->elapsed() > TIME_PER_ROTATION) |
| 1318 | 1318 | { |
| 1319 | 1319 | result |= IDE_STATUS_HIT_INDEX; |
| 1320 | | timer_adjust_oneshot(ide->last_status_timer, attotime::never, 0); |
| 1320 | ide->last_status_timer->adjust(attotime::never); |
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | /* clear interrutps only when reading the real status */ |
| r10326 | r10327 | |
| 1330 | 1330 | |
| 1331 | 1331 | /* log anything else */ |
| 1332 | 1332 | default: |
| 1333 | | logerror("%s:unknown IDE read at %03X, size=%d\n", cpuexec_describe_context(device->machine), offset, size); |
| 1333 | logerror("%s:unknown IDE read at %03X, size=%d\n", device->machine->describe_context(), offset, size); |
| 1334 | 1334 | break; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| r10326 | r10327 | |
| 1352 | 1352 | |
| 1353 | 1353 | /* logit */ |
| 1354 | 1354 | if (BANK(bank, offset) != IDE_BANK0_DATA) |
| 1355 | | LOG(("%s:IDE write to %d:%X = %08X, size=%d\n", cpuexec_describe_context(device->machine), bank, offset, data, size)); |
| 1355 | LOG(("%s:IDE write to %d:%X = %08X, size=%d\n", device->machine->describe_context(), bank, offset, data, size)); |
| 1356 | 1356 | // fprintf(stderr, "ide write %03x %02x size=%d\n", offset, data, size); |
| 1357 | 1357 | switch (BANK(bank, offset)) |
| 1358 | 1358 | { |
| r10326 | r10327 | |
| 1389 | 1389 | /* if we're at the end of the buffer, handle it */ |
| 1390 | 1390 | if (ide->buffer_offset >= IDE_DISK_SECTOR_SIZE) |
| 1391 | 1391 | { |
| 1392 | | LOG(("%s:IDE completed PIO write\n", cpuexec_describe_context(device->machine))); |
| 1392 | LOG(("%s:IDE completed PIO write\n", device->machine->describe_context())); |
| 1393 | 1393 | if (ide->command == IDE_COMMAND_SECURITY_UNLOCK) |
| 1394 | 1394 | { |
| 1395 | 1395 | if (ide->user_password_enable && memcmp(ide->buffer, ide->user_password, 2 + 32) == 0) |
| r10326 | r10327 | |
| 1500 | 1500 | { |
| 1501 | 1501 | ide->status |= IDE_STATUS_BUSY; |
| 1502 | 1502 | ide->status &= ~IDE_STATUS_DRIVE_READY; |
| 1503 | | timer_adjust_oneshot(ide->reset_timer, attotime::from_msec(5), 0); |
| 1503 | ide->reset_timer->adjust(attotime::from_msec(5)); |
| 1504 | 1504 | } |
| 1505 | 1505 | break; |
| 1506 | 1506 | } |
| r10326 | r10327 | |
| 1518 | 1518 | { |
| 1519 | 1519 | ide_state *ide = get_safe_token(device); |
| 1520 | 1520 | |
| 1521 | | LOG(("%s:ide_bus_master_read(%d, %d)\n", cpuexec_describe_context(device->machine), offset, size)); |
| 1521 | LOG(("%s:ide_bus_master_read(%d, %d)\n", device->machine->describe_context(), offset, size)); |
| 1522 | 1522 | |
| 1523 | 1523 | /* command register */ |
| 1524 | 1524 | if (offset == 0) |
| r10326 | r10327 | |
| 1547 | 1547 | { |
| 1548 | 1548 | ide_state *ide = get_safe_token(device); |
| 1549 | 1549 | |
| 1550 | | LOG(("%s:ide_bus_master_write(%d, %d, %08X)\n", cpuexec_describe_context(device->machine), offset, size, data)); |
| 1550 | LOG(("%s:ide_bus_master_write(%d, %d, %08X)\n", device->machine->describe_context(), offset, size, data)); |
| 1551 | 1551 | |
| 1552 | 1552 | /* command register */ |
| 1553 | 1553 | if (offset == 0) |
src/emu/machine/68681.c
| r10326 | r10327 | |
| 335 | 335 | duart68681->ISR &= ~INT_TXRDYA; |
| 336 | 336 | else |
| 337 | 337 | duart68681->ISR &= ~INT_TXRDYB; |
| 338 | | timer_adjust_oneshot(duart68681->channel[ch].tx_timer, attotime::never, ch); |
| 338 | duart68681->channel[ch].tx_timer->adjust(attotime::never, ch); |
| 339 | 339 | break; |
| 340 | 340 | case 4: /* Reset Error Status */ |
| 341 | 341 | duart68681->channel[ch].SR &= ~(STATUS_RECEIVED_BREAK | STATUS_FRAMING_ERROR | STATUS_PARITY_ERROR | STATUS_OVERRUN_ERROR); |
| r10326 | r10327 | |
| 448 | 448 | duart68681->ISR |= INT_TXRDYB; |
| 449 | 449 | |
| 450 | 450 | duart68681_update_interrupts(duart68681); |
| 451 | | timer_adjust_oneshot(duart68681->channel[ch].tx_timer, attotime::never, ch); |
| 451 | duart68681->channel[ch].tx_timer->adjust(attotime::never, ch); |
| 452 | 452 | }; |
| 453 | 453 | |
| 454 | 454 | static void duart68681_write_TX(duart68681_state* duart68681, int ch, UINT8 data) |
| r10326 | r10327 | |
| 468 | 468 | duart68681_update_interrupts(duart68681); |
| 469 | 469 | |
| 470 | 470 | period = attotime::from_hz(duart68681->channel[ch].baud_rate / 10 ); |
| 471 | | timer_adjust_oneshot(duart68681->channel[ch].tx_timer, period, ch); |
| 471 | duart68681->channel[ch].tx_timer->adjust(period, ch); |
| 472 | 472 | |
| 473 | 473 | }; |
| 474 | 474 | |
| r10326 | r10327 | |
| 559 | 559 | case 0x03: /* Counter, CLK/16 */ |
| 560 | 560 | { |
| 561 | 561 | attotime rate = attotime::from_hz(2*device->clock()/(2*16*16*duart68681->CTR.w.l)); |
| 562 | | timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); |
| 562 | duart68681->duart_timer->adjust(rate, 0, rate); |
| 563 | 563 | } |
| 564 | 564 | break; |
| 565 | 565 | case 0x06: /* Timer, CLK/1 */ |
| 566 | 566 | { |
| 567 | 567 | attotime rate = attotime::from_hz(2*device->clock()/(2*16*duart68681->CTR.w.l)); |
| 568 | | timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); |
| 568 | duart68681->duart_timer->adjust(rate, 0, rate); |
| 569 | 569 | } |
| 570 | 570 | break; |
| 571 | 571 | case 0x07: /* Timer, CLK/16 */ |
| r10326 | r10327 | |
| 574 | 574 | //attotime rate = attotime::from_hz(duart68681->clock) * (16*duart68681->CTR.w.l); |
| 575 | 575 | attotime rate = attotime::from_hz(2*device->clock()/(2*16*16*duart68681->CTR.w.l)); |
| 576 | 576 | //hz = ATTOSECONDS_TO_HZ(rate.attoseconds); |
| 577 | | timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); |
| 577 | duart68681->duart_timer->adjust(rate, 0, rate); |
| 578 | 578 | } |
| 579 | 579 | break; |
| 580 | 580 | } |
| r10326 | r10327 | |
| 582 | 582 | case 0x0f: /* Stop counter command */ |
| 583 | 583 | duart68681->ISR &= ~INT_COUNTER_READY; |
| 584 | 584 | if (((duart68681->ACR >>4)& 0x07) < 4) // if in counter mode... |
| 585 | | timer_adjust_oneshot(duart68681->duart_timer, attotime::never, 0); // shut down timer |
| 585 | duart68681->duart_timer->adjust(attotime::never); // shut down timer |
| 586 | 586 | duart68681_update_interrupts(duart68681); |
| 587 | 587 | break; |
| 588 | 588 | default: |
| r10326 | r10327 | |
| 783 | 783 | duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff); |
| 784 | 784 | |
| 785 | 785 | // reset timers |
| 786 | | timer_adjust_oneshot(duart68681->channel[0].tx_timer, attotime::never, 0); |
| 787 | | timer_adjust_oneshot(duart68681->channel[1].tx_timer, attotime::never, 1); |
| 786 | duart68681->channel[0].tx_timer->adjust(attotime::never); |
| 787 | duart68681->channel[1].tx_timer->adjust(attotime::never, 1); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /*------------------------------------------------- |
src/emu/machine/6522via.c
| r10326 | r10327 | |
| 165 | 165 | |
| 166 | 166 | if(m_t1_active) |
| 167 | 167 | { |
| 168 | | val = time_to_cycles(timer_timeleft(m_t1)) - IFR_DELAY; |
| 168 | val = time_to_cycles(m_t1->remaining()) - IFR_DELAY; |
| 169 | 169 | } |
| 170 | 170 | else |
| 171 | 171 | { |
| r10326 | r10327 | |
| 304 | 304 | m_ifr |= data; |
| 305 | 305 | if (TRACE_VIA) |
| 306 | 306 | { |
| 307 | | logerror("%s:6522VIA chip %s: IFR = %02X\n", cpuexec_describe_context(&m_machine), tag(), m_ifr); |
| 307 | logerror("%s:6522VIA chip %s: IFR = %02X\n", m_machine.describe_context(), tag(), m_ifr); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | if (m_ier & m_ifr) |
| r10326 | r10327 | |
| 325 | 325 | |
| 326 | 326 | if (TRACE_VIA) |
| 327 | 327 | { |
| 328 | | logerror("%s:6522VIA chip %s: IFR = %02X\n", cpuexec_describe_context(&m_machine), tag(), m_ifr); |
| 328 | logerror("%s:6522VIA chip %s: IFR = %02X\n", m_machine.describe_context(), tag(), m_ifr); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | if (m_ifr & m_ier) |
| r10326 | r10327 | |
| 363 | 363 | if (m_shift_counter) |
| 364 | 364 | { |
| 365 | 365 | if (SO_O2_CONTROL(m_acr)) { |
| 366 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); |
| 366 | m_shift_timer->adjust(cycles_to_time(2)); |
| 367 | 367 | } else { |
| 368 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); |
| 368 | m_shift_timer->adjust(cycles_to_time((m_t2ll + 2)*2)); |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | else |
| r10326 | r10327 | |
| 432 | 432 | { |
| 433 | 433 | m_out_b ^= 0x80; |
| 434 | 434 | } |
| 435 | | timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0); |
| 435 | m_t1->adjust(cycles_to_time(TIMER1_VALUE + IFR_DELAY)); |
| 436 | 436 | } |
| 437 | 437 | else |
| 438 | 438 | { |
| r10326 | r10327 | |
| 492 | 492 | } |
| 493 | 493 | else |
| 494 | 494 | { |
| 495 | | logerror("%s:6522VIA chip %s: Port B is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag()); |
| 495 | logerror("%s:6522VIA chip %s: Port B is being read but has no handler\n", m_machine.describe_context(), tag()); |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | } |
| r10326 | r10327 | |
| 522 | 522 | } |
| 523 | 523 | else |
| 524 | 524 | { |
| 525 | | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag()); |
| 525 | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", m_machine.describe_context(), tag()); |
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
| r10326 | r10327 | |
| 558 | 558 | } |
| 559 | 559 | else |
| 560 | 560 | { |
| 561 | | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag()); |
| 561 | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", m_machine.describe_context(), tag()); |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | |
| r10326 | r10327 | |
| 595 | 595 | clear_int(INT_T2); |
| 596 | 596 | if (m_t2_active) |
| 597 | 597 | { |
| 598 | | val = time_to_cycles(timer_timeleft(m_t2)) & 0xff; |
| 598 | val = time_to_cycles(m_t2->remaining()) & 0xff; |
| 599 | 599 | } |
| 600 | 600 | else |
| 601 | 601 | { |
| r10326 | r10327 | |
| 613 | 613 | case VIA_T2CH: |
| 614 | 614 | if (m_t2_active) |
| 615 | 615 | { |
| 616 | | val = time_to_cycles(timer_timeleft(m_t2)) >> 8; |
| 616 | val = time_to_cycles(m_t2->remaining()) >> 8; |
| 617 | 617 | } |
| 618 | 618 | else |
| 619 | 619 | { |
| r10326 | r10327 | |
| 634 | 634 | clear_int(INT_SR); |
| 635 | 635 | if (SO_O2_CONTROL(m_acr)) |
| 636 | 636 | { |
| 637 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); |
| 637 | m_shift_timer->adjust(cycles_to_time(2)); |
| 638 | 638 | } |
| 639 | 639 | if (SO_T2_CONTROL(m_acr)) |
| 640 | 640 | { |
| 641 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); |
| 641 | m_shift_timer->adjust(cycles_to_time((m_t2ll + 2)*2)); |
| 642 | 642 | } |
| 643 | 643 | break; |
| 644 | 644 | |
| r10326 | r10327 | |
| 802 | 802 | devcb_call_write8(&m_out_b_func, 0, write_data); |
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | | timer_adjust_oneshot(m_t1, cycles_to_time(TIMER1_VALUE + IFR_DELAY), 0); |
| 805 | m_t1->adjust(cycles_to_time(TIMER1_VALUE + IFR_DELAY)); |
| 806 | 806 | m_t1_active = 1; |
| 807 | 807 | break; |
| 808 | 808 | |
| r10326 | r10327 | |
| 818 | 818 | |
| 819 | 819 | if (!T2_COUNT_PB6(m_acr)) |
| 820 | 820 | { |
| 821 | | timer_adjust_oneshot(m_t2, cycles_to_time(TIMER2_VALUE + IFR_DELAY), 0); |
| 821 | m_t2->adjust(cycles_to_time(TIMER2_VALUE + IFR_DELAY)); |
| 822 | 822 | m_t2_active = 1; |
| 823 | 823 | } |
| 824 | 824 | else |
| 825 | 825 | { |
| 826 | | timer_adjust_oneshot(m_t2, cycles_to_time(TIMER2_VALUE), 0); |
| 826 | m_t2->adjust(cycles_to_time(TIMER2_VALUE)); |
| 827 | 827 | m_t2_active = 1; |
| 828 | 828 | m_time2 = m_machine.time(); |
| 829 | 829 | } |
| r10326 | r10327 | |
| 835 | 835 | clear_int(INT_SR); |
| 836 | 836 | if (SO_O2_CONTROL(m_acr)) |
| 837 | 837 | { |
| 838 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time(2), 0); |
| 838 | m_shift_timer->adjust(cycles_to_time(2)); |
| 839 | 839 | } |
| 840 | 840 | if (SO_T2_CONTROL(m_acr)) |
| 841 | 841 | { |
| 842 | | timer_adjust_oneshot(m_shift_timer, cycles_to_time((m_t2ll + 2)*2), 0); |
| 842 | m_shift_timer->adjust(cycles_to_time((m_t2ll + 2)*2)); |
| 843 | 843 | } |
| 844 | 844 | break; |
| 845 | 845 | |
| r10326 | r10327 | |
| 848 | 848 | |
| 849 | 849 | if (TRACE_VIA) |
| 850 | 850 | { |
| 851 | | logerror("%s:6522VIA chip %s: PCR = %02X\n", cpuexec_describe_context(&m_machine), tag(), data); |
| 851 | logerror("%s:6522VIA chip %s: PCR = %02X\n", m_machine.describe_context(), tag(), data); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | if (CA2_FIX_OUTPUT(data) && CA2_OUTPUT_LEVEL(data) ^ m_out_ca2) |
| r10326 | r10327 | |
| 887 | 887 | } |
| 888 | 888 | if (T1_CONTINUOUS(data)) |
| 889 | 889 | { |
| 890 | | timer_adjust_oneshot(m_t1, cycles_to_time(counter1 + IFR_DELAY), 0); |
| 890 | m_t1->adjust(cycles_to_time(counter1 + IFR_DELAY)); |
| 891 | 891 | m_t1_active = 1; |
| 892 | 892 | } |
| 893 | 893 | } |
| r10326 | r10327 | |
| 942 | 942 | if (state != m_in_ca1) |
| 943 | 943 | { |
| 944 | 944 | if (TRACE_VIA) |
| 945 | | logerror("%s:6522VIA chip %s: CA1 = %02X\n", cpuexec_describe_context(&m_machine), tag(), state); |
| 945 | logerror("%s:6522VIA chip %s: CA1 = %02X\n", m_machine.describe_context(), tag(), state); |
| 946 | 946 | |
| 947 | 947 | if ((CA1_LOW_TO_HIGH(m_pcr) && state) || (CA1_HIGH_TO_LOW(m_pcr) && !state)) |
| 948 | 948 | { |
| r10326 | r10327 | |
| 954 | 954 | } |
| 955 | 955 | else |
| 956 | 956 | { |
| 957 | | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag()); |
| 957 | logerror("%s:6522VIA chip %s: Port A is being read but has no handler\n", m_machine.describe_context(), tag()); |
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | |
| r10326 | r10327 | |
| 1024 | 1024 | } |
| 1025 | 1025 | else |
| 1026 | 1026 | { |
| 1027 | | logerror("%s:6522VIA chip %s: Port B is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag()); |
| 1027 | logerror("%s:6522VIA chip %s: Port B is being read but has no handler\n", m_machine.describe_context(), tag()); |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
| 1030 | 1030 | if (SO_EXT_CONTROL(m_acr) || SI_EXT_CONTROL(m_acr)) |
src/emu/machine/6840ptm.c
| r10326 | r10327 | |
| 138 | 138 | |
| 139 | 139 | for (int i = 0; i < 3; i++) |
| 140 | 140 | { |
| 141 | | timer_enable(m_timer[i], FALSE); |
| 141 | m_timer[i]->enable(false); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | devcb_resolve_write_line(&m_irq_func, &m_config.m_irq_func, this); |
| r10326 | r10327 | |
| 299 | 299 | duration *= m_t3_divisor; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | | timer_adjust_oneshot(m_timer[counter], duration, 0); |
| 302 | m_timer[counter]->adjust(duration); |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| r10326 | r10327 | |
| 390 | 390 | PLOG(("MC6840 #%s: %d external clock freq %f \n", tag(), counter, clock)); |
| 391 | 391 | } |
| 392 | 392 | /* See how many are left */ |
| 393 | | int remaining = (timer_timeleft(m_timer[counter]) * clock).as_double(); |
| 393 | int remaining = (m_timer[counter]->remaining() * clock).as_double(); |
| 394 | 394 | |
| 395 | 395 | /* Adjust the count for dual byte mode */ |
| 396 | 396 | if (m_control_reg[counter] & 0x04) |
| r10326 | r10327 | |
| 468 | 468 | if (!m_external_clock[idx]) |
| 469 | 469 | { |
| 470 | 470 | m_enabled[idx] = 0; |
| 471 | | timer_enable(m_timer[idx],FALSE); |
| 471 | m_timer[idx]->enable(false); |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | else |
| 475 | 475 | #endif |
| 476 | 476 | { |
| 477 | 477 | m_enabled[idx] = 1; |
| 478 | | timer_adjust_oneshot(m_timer[idx], duration, 0); |
| 479 | | timer_enable(m_timer[idx], TRUE); |
| 478 | m_timer[idx]->adjust(duration); |
| 479 | m_timer[idx]->enable(true); |
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | |
| r10326 | r10327 | |
| 500 | 500 | |
| 501 | 501 | case PTM_6840_STATUS: |
| 502 | 502 | { |
| 503 | | PLOG(("%s: MC6840 #%s: Status read = %04X\n", cpuexec_describe_context(&m_machine), tag(), m_status_reg)); |
| 503 | PLOG(("%s: MC6840 #%s: Status read = %04X\n", m_machine.describe_context(), tag(), m_status_reg)); |
| 504 | 504 | m_status_read_since_int |= m_status_reg & 0x07; |
| 505 | 505 | val = m_status_reg; |
| 506 | 506 | break; |
| r10326 | r10327 | |
| 522 | 522 | |
| 523 | 523 | m_lsb_buffer = result & 0xff; |
| 524 | 524 | |
| 525 | | PLOG(("%s: MC6840 #%s: Counter %d read = %04X\n", cpuexec_describe_context(&m_machine), tag(), idx, result >> 8)); |
| 525 | PLOG(("%s: MC6840 #%s: Counter %d read = %04X\n", m_machine.describe_context(), tag(), idx, result >> 8)); |
| 526 | 526 | val = result >> 8; |
| 527 | 527 | break; |
| 528 | 528 | } |
| r10326 | r10327 | |
| 582 | 582 | PLOG(("MC6840 #%s : Timer reset\n", tag())); |
| 583 | 583 | for (int i = 0; i < 3; i++) |
| 584 | 584 | { |
| 585 | | timer_enable(m_timer[i], FALSE); |
| 585 | m_timer[i]->enable(false); |
| 586 | 586 | m_enabled[i] = 0; |
| 587 | 587 | } |
| 588 | 588 | } |
| r10326 | r10327 | |
| 633 | 633 | reload_count(idx); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | | PLOG(("%s:MC6840 #%s: Counter %d latch = %04X\n", cpuexec_describe_context(&m_machine), tag(), idx, m_latch[idx])); |
| 636 | PLOG(("%s:MC6840 #%s: Counter %d latch = %04X\n", m_machine.describe_context(), tag(), idx, m_latch[idx])); |
| 637 | 637 | break; |
| 638 | 638 | } |
| 639 | 639 | } |
| r10326 | r10327 | |
| 813 | 813 | if (!m_external_clock[counter]) |
| 814 | 814 | { |
| 815 | 815 | m_enabled[counter] = 0; |
| 816 | | timer_enable(m_timer[counter], FALSE); |
| 816 | m_timer[counter]->enable(false); |
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | else |
| r10326 | r10327 | |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | m_enabled[counter] = 1; |
| 844 | | timer_adjust_oneshot(m_timer[counter], duration, 0); |
| 845 | | timer_enable(m_timer[counter], TRUE); |
| 844 | m_timer[counter]->adjust(duration); |
| 845 | m_timer[counter]->enable(true); |
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | |
src/emu/machine/s3c24xx.c
| r10326 | r10327 | |
| 722 | 722 | { |
| 723 | 723 | s3c24xx_lcd_render_tpal( device); |
| 724 | 724 | } |
| 725 | | timer_adjust_oneshot( s3c24xx->lcd.timer, screen->time_until_pos( s3c24xx->lcd.vpos, s3c24xx->lcd.hpos), 0); |
| 725 | s3c24xx->lcd.timer->adjust( screen->time_until_pos( s3c24xx->lcd.vpos, s3c24xx->lcd.hpos)); |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | static void s3c24xx_video_start( device_t *device, running_machine *machine) |
| r10326 | r10327 | |
| 917 | 917 | verboselog( device->machine, 1, "LCD start\n"); |
| 918 | 918 | s3c24xx_lcd_configure( device); |
| 919 | 919 | s3c24xx_lcd_dma_init( device); |
| 920 | | timer_adjust_oneshot( s3c24xx->lcd.timer, screen->time_until_pos( s3c24xx->lcd.vpos_min, s3c24xx->lcd.hpos_min), 0); |
| 920 | s3c24xx->lcd.timer->adjust( screen->time_until_pos( s3c24xx->lcd.vpos_min, s3c24xx->lcd.hpos_min)); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | static void s3c24xx_lcd_stop( device_t *device) |
| 924 | 924 | { |
| 925 | 925 | s3c24xx_t *s3c24xx = get_token( device); |
| 926 | 926 | verboselog( device->machine, 1, "LCD stop\n"); |
| 927 | | timer_adjust_oneshot( s3c24xx->lcd.timer, attotime::never, 0); |
| 927 | s3c24xx->lcd.timer->adjust( attotime::never); |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | static void s3c24xx_lcd_recalc( device_t *device) |
| r10326 | r10327 | |
| 1232 | 1232 | s3c24xx_t *s3c24xx = get_token( device); |
| 1233 | 1233 | double timeleft, x1, x2; |
| 1234 | 1234 | UINT32 cnto; |
| 1235 | | timeleft = timer_timeleft( s3c24xx->pwm.timer[ch]).as_double(); |
| 1235 | timeleft = s3c24xx->pwm.timer[ch]->remaining( ).as_double(); |
| 1236 | 1236 | // printf( "timeleft %f freq %d cntb %d cmpb %d\n", timeleft, s3c24xx->pwm.freq[ch], s3c24xx->pwm.cnt[ch], s3c24xx->pwm.cmp[ch]); |
| 1237 | 1237 | x1 = 1 / ((double)s3c24xx->pwm.freq[ch] / (s3c24xx->pwm.cnt[ch]- s3c24xx->pwm.cmp[ch] + 1)); |
| 1238 | 1238 | x2 = x1 / timeleft; |
| r10326 | r10327 | |
| 1357 | 1357 | s3c24xx->pwm.freq[timer] = freq; |
| 1358 | 1358 | if (auto_reload) |
| 1359 | 1359 | { |
| 1360 | | timer_adjust_periodic( s3c24xx->pwm.timer[timer], attotime::from_hz( hz), timer, attotime::from_hz( hz)); |
| 1360 | s3c24xx->pwm.timer[timer]->adjust( attotime::from_hz( hz), timer, attotime::from_hz( hz)); |
| 1361 | 1361 | } |
| 1362 | 1362 | else |
| 1363 | 1363 | { |
| 1364 | | timer_adjust_oneshot( s3c24xx->pwm.timer[timer], attotime::from_hz( hz), timer); |
| 1364 | s3c24xx->pwm.timer[timer]->adjust( attotime::from_hz( hz), timer); |
| 1365 | 1365 | } |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| r10326 | r10327 | |
| 1369 | 1369 | { |
| 1370 | 1370 | s3c24xx_t *s3c24xx = get_token( device); |
| 1371 | 1371 | verboselog( device->machine, 1, "PWM %d stop\n", timer); |
| 1372 | | timer_adjust_oneshot( s3c24xx->pwm.timer[timer], attotime::never, 0); |
| 1372 | s3c24xx->pwm.timer[timer]->adjust( attotime::never); |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | static void s3c24xx_pwm_recalc( device_t *device, int timer) |
| r10326 | r10327 | |
| 2004 | 2004 | s3c24xx_t *s3c24xx = get_token( device); |
| 2005 | 2005 | double timeleft, x1, x2; |
| 2006 | 2006 | UINT32 cnt; |
| 2007 | | timeleft = timer_timeleft( s3c24xx->wdt.timer).as_double(); |
| 2007 | timeleft = s3c24xx->wdt.timer->remaining( ).as_double(); |
| 2008 | 2008 | // printf( "timeleft %f freq %d cnt %d\n", timeleft, s3c24xx->wdt.freq, s3c24xx->wdt.cnt); |
| 2009 | 2009 | x1 = 1 / ((double)s3c24xx->wdt.freq / s3c24xx->wdt.cnt); |
| 2010 | 2010 | x2 = x1 / timeleft; |
| r10326 | r10327 | |
| 2055 | 2055 | freq = (double)pclk / (prescaler + 1) / clock; |
| 2056 | 2056 | hz = freq / s3c24xx->wdt.regs.wtcnt; |
| 2057 | 2057 | verboselog( device->machine, 5, "WDT pclk %d prescaler %d clock %d freq %f hz %f\n", pclk, prescaler, clock, freq, hz); |
| 2058 | | timer_adjust_periodic( s3c24xx->wdt.timer, attotime::from_hz( hz), 0, attotime::from_hz( hz)); |
| 2058 | s3c24xx->wdt.timer->adjust( attotime::from_hz( hz), 0, attotime::from_hz( hz)); |
| 2059 | 2059 | #if defined(DEVICE_S3C2410) |
| 2060 | 2060 | s3c24xx->wdt.freq = freq; |
| 2061 | 2061 | s3c24xx->wdt.cnt = s3c24xx->wdt.regs.wtcnt; |
| r10326 | r10327 | |
| 2067 | 2067 | s3c24xx_t *s3c24xx = get_token( device); |
| 2068 | 2068 | verboselog( device->machine, 1, "WDT stop\n"); |
| 2069 | 2069 | s3c24xx->wdt.regs.wtcnt = s3c24xx_wdt_calc_current_count( device); |
| 2070 | | timer_adjust_oneshot( s3c24xx->wdt.timer, attotime::never, 0); |
| 2070 | s3c24xx->wdt.timer->adjust( attotime::never); |
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | static void s3c24xx_wdt_recalc( device_t *device) |
| r10326 | r10327 | |
| 2223 | 2223 | case 2 : i2c_send_byte( device, s3c24xx->iic.regs.iicds | 0x01); break; |
| 2224 | 2224 | case 3 : i2c_send_byte( device, s3c24xx->iic.regs.iicds & 0xFE); break; |
| 2225 | 2225 | } |
| 2226 | | timer_adjust_oneshot( s3c24xx->iic.timer, attotime::from_usec( 1), 0); |
| 2226 | s3c24xx->iic.timer->adjust( attotime::from_usec( 1)); |
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | static void iic_stop( device_t *device) |
| r10326 | r10327 | |
| 2231 | 2231 | s3c24xx_t *s3c24xx = get_token( device); |
| 2232 | 2232 | verboselog( device->machine, 1, "IIC stop\n"); |
| 2233 | 2233 | i2c_send_stop( device); |
| 2234 | | timer_adjust_oneshot( s3c24xx->iic.timer, attotime::never, 0); |
| 2234 | s3c24xx->iic.timer->adjust( attotime::never); |
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | 2237 | static void iic_resume( device_t *device) |
| r10326 | r10327 | |
| 2245 | 2245 | case 2 : s3c24xx->iic.regs.iicds = i2c_receive_byte( device, BIT( s3c24xx->iic.regs.iiccon, 7)); break; |
| 2246 | 2246 | case 3 : i2c_send_byte( device, s3c24xx->iic.regs.iicds & 0xFF); break; |
| 2247 | 2247 | } |
| 2248 | | timer_adjust_oneshot( s3c24xx->iic.timer, attotime::from_usec( 1), 0); |
| 2248 | s3c24xx->iic.timer->adjust( attotime::from_usec( 1)); |
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | 2251 | static READ32_DEVICE_HANDLER( s3c24xx_iic_r ) |
| r10326 | r10327 | |
| 2383 | 2383 | pclk = s3c24xx_get_pclk( device); |
| 2384 | 2384 | freq = ((double)pclk / (prescaler_control_a + 1) / codeclk_table[codeclk]) * 2; // why do I have to multiply by two? |
| 2385 | 2385 | verboselog( device->machine, 5, "IIS - pclk %d psc_enable %d psc_a %d psc_b %d codeclk %d freq %f\n", pclk, prescaler_enable, prescaler_control_a, prescaler_control_b, codeclk_table[codeclk], freq); |
| 2386 | | timer_adjust_periodic( s3c24xx->iis.timer, attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 2386 | s3c24xx->iis.timer->adjust( attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | static void s3c24xx_iis_stop( device_t *device) |
| 2390 | 2390 | { |
| 2391 | 2391 | s3c24xx_t *s3c24xx = get_token( device); |
| 2392 | 2392 | verboselog( device->machine, 1, "IIS stop\n"); |
| 2393 | | timer_adjust_oneshot( s3c24xx->iis.timer, attotime::never, 0); |
| 2393 | s3c24xx->iis.timer->adjust( attotime::never); |
| 2394 | 2394 | } |
| 2395 | 2395 | |
| 2396 | 2396 | static void s3c24xx_iis_recalc( device_t *device) |
| r10326 | r10327 | |
| 2500 | 2500 | ttc = BITS( s3c24xx->rtc.regs.ticnt, 6, 0); |
| 2501 | 2501 | freq = 128 / (ttc + 1); |
| 2502 | 2502 | // printf( "ttc %d freq %f\n", ttc, freq); |
| 2503 | | timer_adjust_periodic( s3c24xx->rtc.timer_tick_count, attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 2503 | s3c24xx->rtc.timer_tick_count->adjust( attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 2504 | 2504 | } |
| 2505 | 2505 | else |
| 2506 | 2506 | { |
| 2507 | | timer_adjust_oneshot( s3c24xx->rtc.timer_tick_count, attotime::never, 0); |
| 2507 | s3c24xx->rtc.timer_tick_count->adjust( attotime::never); |
| 2508 | 2508 | } |
| 2509 | 2509 | } |
| 2510 | 2510 | |
| r10326 | r10327 | |
| 3176 | 3176 | s3c24xx->rtc.timer_tick_count = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_rtc_timer_tick_count_exp), (void*)device); |
| 3177 | 3177 | s3c24xx->rtc.timer_update = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_rtc_timer_update_exp), (void*)device); |
| 3178 | 3178 | s3c24xx->wdt.timer = device->machine->scheduler().timer_alloc( FUNC(s3c24xx_wdt_timer_exp), (void*)device); |
| 3179 | | timer_adjust_periodic( s3c24xx->rtc.timer_update, attotime::from_msec( 1000), 0, attotime::from_msec( 1000)); |
| 3179 | s3c24xx->rtc.timer_update->adjust( attotime::from_msec( 1000), 0, attotime::from_msec( 1000)); |
| 3180 | 3180 | s3c24xx_rtc_init( device); |
| 3181 | 3181 | } |
| 3182 | 3182 | |
src/emu/emucore.h
| r10326 | r10327 | |
| 198 | 198 | inline void operator--(_Type &value, int) { value = (_Type)((int)value - 1); } |
| 199 | 199 | |
| 200 | 200 | |
| 201 | // this macro wraps a function 'x' and can be used to pass a function followed by its name |
| 202 | #define FUNC(x) x, #x |
| 203 | |
| 204 | // this macro wraps a member function 'x' from class 'c' |
| 205 | #define MFUNC(c,x) &c::x, #c "::" #x |
| 206 | |
| 207 | // this macro wraps a member function 'x' from class 'c' using a templatized stub of type 's' |
| 208 | #define MSTUB(s,c,x) s##_stub<c, &c::x>, #c "::" #x |
| 209 | |
| 210 | |
| 201 | 211 | // standard assertion macros |
| 202 | 212 | #undef assert |
| 203 | 213 | #undef assert_always |
| r10326 | r10327 | |
| 347 | 357 | |
| 348 | 358 | |
| 349 | 359 | //************************************************************************** |
| 350 | | // COMMON TEMPLATES |
| 351 | | //************************************************************************** |
| 352 | | |
| 353 | | // ======================> simple_list |
| 354 | | |
| 355 | | template<class T> |
| 356 | | class simple_list |
| 357 | | { |
| 358 | | DISABLE_COPYING(simple_list); |
| 359 | | |
| 360 | | T *m_head; |
| 361 | | T *m_tail; |
| 362 | | resource_pool &m_pool; |
| 363 | | int m_count; |
| 364 | | |
| 365 | | public: |
| 366 | | simple_list(resource_pool &pool = global_resource_pool) : |
| 367 | | m_head(NULL), |
| 368 | | m_tail(NULL), |
| 369 | | m_pool(pool), |
| 370 | | m_count(0) { } |
| 371 | | |
| 372 | | virtual ~simple_list() { reset(); } |
| 373 | | |
| 374 | | resource_pool &pool() const { return m_pool; } |
| 375 | | |
| 376 | | T *first() const { return m_head; } |
| 377 | | T *last() const { return m_tail; } |
| 378 | | int count() const { return m_count; } |
| 379 | | |
| 380 | | void reset() { while (m_head != NULL) remove(*m_head); } |
| 381 | | |
| 382 | | T &prepend(T &object) |
| 383 | | { |
| 384 | | object.m_next = m_head; |
| 385 | | m_head = &object; |
| 386 | | if (m_tail == NULL) |
| 387 | | m_tail = m_head; |
| 388 | | m_count++; |
| 389 | | return object; |
| 390 | | } |
| 391 | | |
| 392 | | void prepend_list(simple_list<T> &list) |
| 393 | | { |
| 394 | | int count = list.count(); |
| 395 | | if (count == 0) |
| 396 | | return; |
| 397 | | T *tail = list.last(); |
| 398 | | T *head = list.detach_all(); |
| 399 | | tail->m_next = m_head; |
| 400 | | m_head = head; |
| 401 | | if (m_tail == NULL) |
| 402 | | m_tail = tail; |
| 403 | | m_count += count; |
| 404 | | } |
| 405 | | |
| 406 | | T &append(T &object) |
| 407 | | { |
| 408 | | object.m_next = NULL; |
| 409 | | if (m_tail != NULL) |
| 410 | | m_tail = m_tail->m_next = &object; |
| 411 | | else |
| 412 | | m_tail = m_head = &object; |
| 413 | | m_count++; |
| 414 | | return object; |
| 415 | | } |
| 416 | | |
| 417 | | void append_list(simple_list<T> &list) |
| 418 | | { |
| 419 | | int count = list.count(); |
| 420 | | if (count == 0) |
| 421 | | return; |
| 422 | | T *tail = list.last(); |
| 423 | | T *head = list.detach_all(); |
| 424 | | if (m_tail != NULL) |
| 425 | | m_tail->m_next = head; |
| 426 | | else |
| 427 | | m_head = head; |
| 428 | | m_tail = tail; |
| 429 | | m_count += count; |
| 430 | | } |
| 431 | | |
| 432 | | T &insert_after(T &object, T *insert_after) |
| 433 | | { |
| 434 | | if (insert_after == NULL) |
| 435 | | return prepend(object); |
| 436 | | object.m_next = insert_after->m_next; |
| 437 | | insert_after->m_next = &object; |
| 438 | | m_count++; |
| 439 | | return object; |
| 440 | | } |
| 441 | | |
| 442 | | T *detach_head() |
| 443 | | { |
| 444 | | T *result = m_head; |
| 445 | | if (result != NULL) |
| 446 | | { |
| 447 | | m_head = result->m_next; |
| 448 | | m_count--; |
| 449 | | if (m_head == NULL) |
| 450 | | m_tail = NULL; |
| 451 | | } |
| 452 | | return result; |
| 453 | | } |
| 454 | | |
| 455 | | T &detach(T &object) |
| 456 | | { |
| 457 | | T *prev = NULL; |
| 458 | | for (T *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next) |
| 459 | | if (cur == &object) |
| 460 | | { |
| 461 | | if (prev != NULL) |
| 462 | | prev->m_next = object.m_next; |
| 463 | | else |
| 464 | | m_head = object.m_next; |
| 465 | | if (m_tail == &object) |
| 466 | | m_tail = prev; |
| 467 | | m_count--; |
| 468 | | return object; |
| 469 | | } |
| 470 | | return object; |
| 471 | | } |
| 472 | | |
| 473 | | T *detach_all() |
| 474 | | { |
| 475 | | T *result = m_head; |
| 476 | | m_head = m_tail = NULL; |
| 477 | | m_count = 0; |
| 478 | | return result; |
| 479 | | } |
| 480 | | |
| 481 | | void remove(T &object) |
| 482 | | { |
| 483 | | detach(object); |
| 484 | | pool_free(m_pool, &object); |
| 485 | | } |
| 486 | | |
| 487 | | T *find(int index) const |
| 488 | | { |
| 489 | | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 490 | | if (index-- == 0) |
| 491 | | return cur; |
| 492 | | return NULL; |
| 493 | | } |
| 494 | | |
| 495 | | int indexof(const T &object) const |
| 496 | | { |
| 497 | | int index = 0; |
| 498 | | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 499 | | { |
| 500 | | if (cur == &object) |
| 501 | | return index; |
| 502 | | index++; |
| 503 | | } |
| 504 | | return -1; |
| 505 | | } |
| 506 | | }; |
| 507 | | |
| 508 | | |
| 509 | | // ======================> fixed_allocator |
| 510 | | |
| 511 | | template<class T> |
| 512 | | class fixed_allocator |
| 513 | | { |
| 514 | | DISABLE_COPYING(fixed_allocator); |
| 515 | | |
| 516 | | public: |
| 517 | | fixed_allocator(resource_pool &pool = global_resource_pool) |
| 518 | | : m_pool(pool), |
| 519 | | m_freelist(pool) { } |
| 520 | | |
| 521 | | T *alloc() |
| 522 | | { |
| 523 | | T *result = m_freelist.detach_head(); |
| 524 | | if (result == NULL) |
| 525 | | result = m_pool.add_object(new T); |
| 526 | | return result; |
| 527 | | } |
| 528 | | |
| 529 | | void reclaim(T *item) { if (item != NULL) m_freelist.append(*item); } |
| 530 | | void reclaim(T &item) { m_freelist.append(item); } |
| 531 | | void reclaim_all(simple_list<T> &list) { m_freelist.append_list(list); } |
| 532 | | |
| 533 | | private: |
| 534 | | resource_pool &m_pool; |
| 535 | | simple_list<T> m_freelist; |
| 536 | | }; |
| 537 | | |
| 538 | | |
| 539 | | // ======================> tagged_list |
| 540 | | |
| 541 | | template<class T> |
| 542 | | class tagged_list |
| 543 | | { |
| 544 | | DISABLE_COPYING(tagged_list); |
| 545 | | |
| 546 | | T *m_head; |
| 547 | | T **m_tailptr; |
| 548 | | tagmap_t<T *> m_map; |
| 549 | | resource_pool &m_pool; |
| 550 | | |
| 551 | | public: |
| 552 | | tagged_list(resource_pool &pool = global_resource_pool) : |
| 553 | | m_head(NULL), |
| 554 | | m_tailptr(&m_head), |
| 555 | | m_pool(pool) { } |
| 556 | | |
| 557 | | virtual ~tagged_list() |
| 558 | | { |
| 559 | | reset(); |
| 560 | | } |
| 561 | | |
| 562 | | void reset() |
| 563 | | { |
| 564 | | while (m_head != NULL) |
| 565 | | remove(m_head); |
| 566 | | } |
| 567 | | |
| 568 | | T *first() const { return m_head; } |
| 569 | | |
| 570 | | int count() const |
| 571 | | { |
| 572 | | int num = 0; |
| 573 | | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 574 | | num++; |
| 575 | | return num; |
| 576 | | } |
| 577 | | |
| 578 | | int index(T *object) const |
| 579 | | { |
| 580 | | int num = 0; |
| 581 | | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 582 | | if (cur == object) |
| 583 | | return num; |
| 584 | | else |
| 585 | | num++; |
| 586 | | return -1; |
| 587 | | } |
| 588 | | |
| 589 | | int index(const char *tag) const |
| 590 | | { |
| 591 | | T *object = find(tag); |
| 592 | | return (object != NULL) ? index(object) : -1; |
| 593 | | } |
| 594 | | |
| 595 | | T *replace(const char *tag, T *object) |
| 596 | | { |
| 597 | | T *existing = find(tag); |
| 598 | | if (existing == NULL) |
| 599 | | return append(tag, object); |
| 600 | | |
| 601 | | for (T **objectptr = &m_head; *objectptr != NULL; objectptr = &(*objectptr)->m_next) |
| 602 | | if (*objectptr == existing) |
| 603 | | { |
| 604 | | *objectptr = object; |
| 605 | | object->m_next = existing->m_next; |
| 606 | | if (m_tailptr == &existing->m_next) |
| 607 | | m_tailptr = &object->m_next; |
| 608 | | m_map.remove(existing); |
| 609 | | pool_free(m_pool, existing); |
| 610 | | if (m_map.add_unique_hash(tag, object, false) != TMERR_NONE) |
| 611 | | throw emu_fatalerror("Error replacing object named '%s'", tag); |
| 612 | | break; |
| 613 | | } |
| 614 | | return object; |
| 615 | | } |
| 616 | | |
| 617 | | T *append(const char *tag, T *object, bool replace_if_duplicate = false) |
| 618 | | { |
| 619 | | if (m_map.add_unique_hash(tag, object, false) != TMERR_NONE) |
| 620 | | throw emu_fatalerror("Error adding object named '%s'", tag); |
| 621 | | *m_tailptr = object; |
| 622 | | object->m_next = NULL; |
| 623 | | m_tailptr = &object->m_next; |
| 624 | | return object; |
| 625 | | } |
| 626 | | |
| 627 | | void detach(T *object) |
| 628 | | { |
| 629 | | for (T **objectptr = &m_head; *objectptr != NULL; objectptr = &(*objectptr)->m_next) |
| 630 | | if (*objectptr == object) |
| 631 | | { |
| 632 | | *objectptr = object->m_next; |
| 633 | | if (m_tailptr == &object->m_next) |
| 634 | | m_tailptr = objectptr; |
| 635 | | m_map.remove(object); |
| 636 | | return; |
| 637 | | } |
| 638 | | } |
| 639 | | |
| 640 | | void remove(T *object) |
| 641 | | { |
| 642 | | detach(object); |
| 643 | | pool_free(m_pool, object); |
| 644 | | } |
| 645 | | |
| 646 | | void remove(const char *tag) |
| 647 | | { |
| 648 | | T *object = find(tag); |
| 649 | | if (object != NULL) |
| 650 | | remove(object); |
| 651 | | } |
| 652 | | |
| 653 | | T *find(const char *tag) const |
| 654 | | { |
| 655 | | return m_map.find_hash_only(tag); |
| 656 | | } |
| 657 | | |
| 658 | | T *find(int index) const |
| 659 | | { |
| 660 | | for (T *cur = m_head; cur != NULL; cur = cur->m_next) |
| 661 | | if (index-- == 0) |
| 662 | | return cur; |
| 663 | | return NULL; |
| 664 | | } |
| 665 | | }; |
| 666 | | |
| 667 | | |
| 668 | | |
| 669 | | //************************************************************************** |
| 670 | 360 | // FUNCTION PROTOTYPES |
| 671 | 361 | //************************************************************************** |
| 672 | 362 | |
src/mess/audio/ted7360.c
| r10326 | r10327 | |
| 562 | 562 | { |
| 563 | 563 | case 1: |
| 564 | 564 | // proved by digisound of several intros like eoroidpro |
| 565 | | timer_adjust_oneshot(ted7360->timer1, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER1), 1); |
| 565 | ted7360->timer1->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER1), 1); |
| 566 | 566 | ted7360->timer1_active = 1; |
| 567 | 567 | ted7360_set_interrupt(machine, 0x08, ted7360); |
| 568 | 568 | break; |
| 569 | 569 | case 2: |
| 570 | | timer_adjust_oneshot(ted7360->timer2, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), 0x10000), 2); |
| 570 | ted7360->timer2->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), 0x10000), 2); |
| 571 | 571 | ted7360->timer2_active = 1; |
| 572 | 572 | ted7360_set_interrupt(machine, 0x10, ted7360); |
| 573 | 573 | break; |
| 574 | 574 | case 3: |
| 575 | | timer_adjust_oneshot(ted7360->timer3, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), 0x10000), 3); |
| 575 | ted7360->timer3->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), 0x10000), 3); |
| 576 | 576 | ted7360->timer3_active = 1; |
| 577 | 577 | ted7360_set_interrupt(machine, 0x40, ted7360); |
| 578 | 578 | break; |
| r10326 | r10327 | |
| 858 | 858 | |
| 859 | 859 | if (ted7360->timer1_active) |
| 860 | 860 | { |
| 861 | | ted7360->reg[1] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer1)) >> 8; |
| 862 | | timer_reset(ted7360->timer1, attotime::never); |
| 861 | ted7360->reg[1] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer1->remaining()) >> 8; |
| 862 | ted7360->timer1->reset(); |
| 863 | 863 | ted7360->timer1_active = 0; |
| 864 | 864 | } |
| 865 | 865 | break; |
| 866 | 866 | case 1: /* start timer 1 */ |
| 867 | 867 | ted7360->reg[offset] = data; |
| 868 | | timer_adjust_oneshot(ted7360->timer1, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER1), 1); |
| 868 | ted7360->timer1->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER1), 1); |
| 869 | 869 | ted7360->timer1_active = 1; |
| 870 | 870 | break; |
| 871 | 871 | case 2: /* stop timer 2 */ |
| 872 | 872 | ted7360->reg[offset] = data; |
| 873 | 873 | if (ted7360->timer2_active) |
| 874 | 874 | { |
| 875 | | ted7360->reg[3] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer2)) >> 8; |
| 876 | | timer_reset(ted7360->timer2, attotime::never); |
| 875 | ted7360->reg[3] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer2->remaining()) >> 8; |
| 876 | ted7360->timer2->reset(); |
| 877 | 877 | ted7360->timer2_active = 0; |
| 878 | 878 | } |
| 879 | 879 | break; |
| 880 | 880 | case 3: /* start timer 2 */ |
| 881 | 881 | ted7360->reg[offset] = data; |
| 882 | | timer_adjust_oneshot(ted7360->timer2, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER2), 2); |
| 882 | ted7360->timer2->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER2), 2); |
| 883 | 883 | ted7360->timer2_active = 1; |
| 884 | 884 | break; |
| 885 | 885 | case 4: /* stop timer 3 */ |
| 886 | 886 | ted7360->reg[offset] = data; |
| 887 | 887 | if (ted7360->timer3_active) |
| 888 | 888 | { |
| 889 | | ted7360->reg[5] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer3)) >> 8; |
| 890 | | timer_reset(ted7360->timer3, attotime::never); |
| 889 | ted7360->reg[5] = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer3->remaining()) >> 8; |
| 890 | ted7360->timer3->reset(); |
| 891 | 891 | ted7360->timer3_active = 0; |
| 892 | 892 | } |
| 893 | 893 | break; |
| 894 | 894 | case 5: /* start timer 3 */ |
| 895 | 895 | ted7360->reg[offset] = data; |
| 896 | | timer_adjust_oneshot(ted7360->timer3, TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER3), 3); |
| 896 | ted7360->timer3->adjust(TEDTIME_IN_CYCLES((ted7360->type == TED7360_PAL), TIMER3), 3); |
| 897 | 897 | ted7360->timer3_active = 1; |
| 898 | 898 | break; |
| 899 | 899 | case 6: |
| r10326 | r10327 | |
| 1067 | 1067 | { |
| 1068 | 1068 | case 0: |
| 1069 | 1069 | if (ted7360->timer1) |
| 1070 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer1)) & 0xff; |
| 1070 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer1->remaining()) & 0xff; |
| 1071 | 1071 | else |
| 1072 | 1072 | val = ted7360->reg[offset]; |
| 1073 | 1073 | break; |
| 1074 | 1074 | case 1: |
| 1075 | 1075 | if (ted7360->timer1) |
| 1076 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer1)) >> 8; |
| 1076 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer1->remaining()) >> 8; |
| 1077 | 1077 | else |
| 1078 | 1078 | val = ted7360->reg[offset]; |
| 1079 | 1079 | break; |
| 1080 | 1080 | case 2: |
| 1081 | 1081 | if (ted7360->timer2) |
| 1082 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer2)) & 0xff; |
| 1082 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer2->remaining()) & 0xff; |
| 1083 | 1083 | else |
| 1084 | 1084 | val = ted7360->reg[offset]; |
| 1085 | 1085 | break; |
| 1086 | 1086 | case 3: |
| 1087 | 1087 | if (ted7360->timer2) |
| 1088 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer2)) >> 8; |
| 1088 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer2->remaining()) >> 8; |
| 1089 | 1089 | else |
| 1090 | 1090 | val = ted7360->reg[offset]; |
| 1091 | 1091 | break; |
| 1092 | 1092 | case 4: |
| 1093 | 1093 | if (ted7360->timer3) |
| 1094 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer3)) & 0xff; |
| 1094 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer3->remaining()) & 0xff; |
| 1095 | 1095 | else |
| 1096 | 1096 | val = ted7360->reg[offset]; |
| 1097 | 1097 | break; |
| 1098 | 1098 | case 5: |
| 1099 | 1099 | if (ted7360->timer3) |
| 1100 | | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), timer_timeleft(ted7360->timer3)) >> 8; |
| 1100 | val = TEDTIME_TO_CYCLES((ted7360->type == TED7360_PAL), ted7360->timer3->remaining()) >> 8; |
| 1101 | 1101 | else |
| 1102 | 1102 | val = ted7360->reg[offset]; |
| 1103 | 1103 | break; |
src/mess/machine/pdp1.c
| r10326 | r10327 | |
| 376 | 376 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 377 | 377 | { |
| 378 | 378 | /* delay is approximately 1/400s */ |
| 379 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 379 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 380 | 380 | } |
| 381 | 381 | else |
| 382 | 382 | { |
| 383 | | timer_enable(state->tape_reader.timer, 0); |
| 383 | state->tape_reader.timer->enable(0); |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | break; |
| r10326 | r10327 | |
| 409 | 409 | state->tape_reader.motor_on = 0; |
| 410 | 410 | |
| 411 | 411 | if (state->tape_reader.timer) |
| 412 | | timer_enable(state->tape_reader.timer, 0); |
| 412 | state->tape_reader.timer->enable(0); |
| 413 | 413 | break; |
| 414 | 414 | |
| 415 | 415 | case 1: |
| r10326 | r10327 | |
| 452 | 452 | |
| 453 | 453 | if (LOG_IOT_OVERLAP) |
| 454 | 454 | { |
| 455 | | if (timer_enable(state->tape_reader.timer, 0)) |
| 455 | if (state->tape_reader.timer->enable(0)) |
| 456 | 456 | logerror("Error: overlapped perforated tape reads (Read-in mode, RPA/RPB instruction)\n"); |
| 457 | 457 | } |
| 458 | 458 | /* set up delay if tape is advancing */ |
| 459 | 459 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 460 | 460 | { |
| 461 | 461 | /* delay is approximately 1/400s */ |
| 462 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 462 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 463 | 463 | } |
| 464 | 464 | else |
| 465 | 465 | { |
| 466 | | timer_enable(state->tape_reader.timer, 0); |
| 466 | state->tape_reader.timer->enable(0); |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
| r10326 | r10327 | |
| 513 | 513 | |
| 514 | 514 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 515 | 515 | /* delay is approximately 1/400s */ |
| 516 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 516 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 517 | 517 | else |
| 518 | | timer_enable(state->tape_reader.timer, 0); |
| 518 | state->tape_reader.timer->enable(0); |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /* |
| r10326 | r10327 | |
| 572 | 572 | { |
| 573 | 573 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 574 | 574 | if (LOG_IOT_EXTRA) |
| 575 | | logerror("Warning, RPA instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 575 | logerror("Warning, RPA instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 576 | 576 | |
| 577 | 577 | begin_tape_read(state, 0, nac); |
| 578 | 578 | } |
| r10326 | r10327 | |
| 610 | 610 | { |
| 611 | 611 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 612 | 612 | if (LOG_IOT_EXTRA) |
| 613 | | logerror("Warning, RPB instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 613 | logerror("Warning, RPB instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 614 | 614 | |
| 615 | 615 | begin_tape_read(state, 1, nac); |
| 616 | 616 | } |
| r10326 | r10327 | |
| 622 | 622 | { |
| 623 | 623 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 624 | 624 | if (LOG_IOT_EXTRA) |
| 625 | | logerror("RRB instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 625 | logerror("RRB instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 626 | 626 | |
| 627 | 627 | *io = state->tape_reader.rb; |
| 628 | 628 | state->io_status &= ~io_st_ptr; |
| r10326 | r10327 | |
| 646 | 646 | { |
| 647 | 647 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 648 | 648 | if (LOG_IOT_EXTRA) |
| 649 | | logerror("PPA instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 649 | logerror("PPA instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 650 | 650 | |
| 651 | 651 | tape_write(state, *io & 0377); |
| 652 | 652 | state->io_status &= ~io_st_ptp; |
| 653 | 653 | /* delay is approximately 1/63.3 second */ |
| 654 | 654 | if (LOG_IOT_OVERLAP) |
| 655 | 655 | { |
| 656 | | if (timer_enable(state->tape_puncher.timer, 0)) |
| 657 | | logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 656 | if (state->tape_puncher.timer->enable(0)) |
| 657 | logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | | timer_adjust_oneshot(state->tape_puncher.timer, attotime::from_usec(15800), nac); |
| 660 | state->tape_puncher.timer->adjust(attotime::from_usec(15800), nac); |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /* |
| r10326 | r10327 | |
| 675 | 675 | { |
| 676 | 676 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 677 | 677 | if (LOG_IOT_EXTRA) |
| 678 | | logerror("PPB instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 678 | logerror("PPB instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 679 | 679 | |
| 680 | 680 | tape_write(state, (*io >> 12) | 0200); |
| 681 | 681 | state->io_status &= ~io_st_ptp; |
| 682 | 682 | /* delay is approximately 1/63.3 second */ |
| 683 | 683 | if (LOG_IOT_OVERLAP) |
| 684 | 684 | { |
| 685 | | if (timer_enable(state->tape_puncher.timer, 0)) |
| 686 | | logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 685 | if (state->tape_puncher.timer->enable(0)) |
| 686 | logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 687 | 687 | } |
| 688 | | timer_adjust_oneshot(state->tape_puncher.timer, attotime::from_usec(15800), nac); |
| 688 | state->tape_puncher.timer->adjust(attotime::from_usec(15800), nac); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | |
| r10326 | r10327 | |
| 847 | 847 | int ch, delay; |
| 848 | 848 | |
| 849 | 849 | if (LOG_IOT_EXTRA) |
| 850 | | logerror("Warning, TYO instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 850 | logerror("Warning, TYO instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 851 | 851 | |
| 852 | 852 | ch = (*io) & 077; |
| 853 | 853 | |
| r10326 | r10327 | |
| 874 | 874 | } |
| 875 | 875 | if (LOG_IOT_OVERLAP) |
| 876 | 876 | { |
| 877 | | if (timer_enable(state->typewriter.tyo_timer, 0)) |
| 878 | | logerror("Error: overlapped TYO instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 877 | if (state->typewriter.tyo_timer->enable(0)) |
| 878 | logerror("Error: overlapped TYO instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | | timer_adjust_oneshot(state->typewriter.tyo_timer, attotime::from_msec(delay), nac); |
| 881 | state->typewriter.tyo_timer->adjust(attotime::from_msec(delay), nac); |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | /* |
| r10326 | r10327 | |
| 899 | 899 | { |
| 900 | 900 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 901 | 901 | if (LOG_IOT_EXTRA) |
| 902 | | logerror("Warning, TYI instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 902 | logerror("Warning, TYI instruction not fully emulated: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 903 | 903 | |
| 904 | 904 | *io = state->typewriter.tb; |
| 905 | 905 | if (! (state->io_status & io_st_tyi)) |
| r10326 | r10327 | |
| 989 | 989 | { |
| 990 | 990 | /* note that overlap detection is incomplete: it will only work if both DPY |
| 991 | 991 | instructions require a completion pulse */ |
| 992 | | if (timer_enable(state->dpy_timer, 0)) |
| 993 | | logerror("Error: overlapped DPY instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 992 | if (state->dpy_timer->enable(0)) |
| 993 | logerror("Error: overlapped DPY instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 994 | 994 | } |
| 995 | | timer_adjust_oneshot(state->dpy_timer, attotime::from_usec(50), 0); |
| 995 | state->dpy_timer->adjust(attotime::from_usec(50)); |
| 996 | 996 | } |
| 997 | 997 | } |
| 998 | 998 | |
| r10326 | r10327 | |
| 1008 | 1008 | |
| 1009 | 1009 | state->parallel_drum.il = il; |
| 1010 | 1010 | |
| 1011 | | il_phase = ((PARALLEL_DRUM_WORD_TIME * il) - timer_timeelapsed(state->parallel_drum.rotation_timer)); |
| 1011 | il_phase = ((PARALLEL_DRUM_WORD_TIME * il) - state->parallel_drum.rotation_timer->elapsed()); |
| 1012 | 1012 | if (il_phase < attotime::zero) |
| 1013 | 1013 | il_phase = il_phase + PARALLEL_DRUM_ROTATION_TIME; |
| 1014 | | timer_adjust_periodic(state->parallel_drum.il_timer, il_phase, 0, PARALLEL_DRUM_ROTATION_TIME); |
| 1014 | state->parallel_drum.il_timer->adjust(il_phase, 0, PARALLEL_DRUM_ROTATION_TIME); |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | #ifdef UNUSED_FUNCTION |
| r10326 | r10327 | |
| 1028 | 1028 | static void parallel_drum_init(pdp1_state *state) |
| 1029 | 1029 | { |
| 1030 | 1030 | state->parallel_drum.rotation_timer = machine->scheduler().timer_alloc(); |
| 1031 | | timer_adjust_periodic(state->parallel_drum.rotation_timer, PARALLEL_DRUM_ROTATION_TIME, 0, PARALLEL_DRUM_ROTATION_TIME); |
| 1031 | state->parallel_drum.rotation_timer->adjust(PARALLEL_DRUM_ROTATION_TIME, 0, PARALLEL_DRUM_ROTATION_TIME); |
| 1032 | 1032 | |
| 1033 | 1033 | state->parallel_drum.il_timer = machine->scheduler().timer_alloc(FUNC(il_timer_callback)); |
| 1034 | 1034 | parallel_drum_set_il(0); |
| r10326 | r10327 | |
| 1119 | 1119 | /* clear status bit 5... */ |
| 1120 | 1120 | |
| 1121 | 1121 | /* do transfer */ |
| 1122 | | delay = timer_timeleft(state->parallel_drum.il_timer); |
| 1122 | delay = state->parallel_drum.il_timer->remaining(); |
| 1123 | 1123 | dc = state->parallel_drum.il; |
| 1124 | 1124 | do |
| 1125 | 1125 | { |
| r10326 | r10327 | |
| 1147 | 1147 | static void iot_dra(device_t *device, int op2, int nac, int mb, int *io, int ac) |
| 1148 | 1148 | { |
| 1149 | 1149 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 1150 | | (*io) = (timer_timeelapsed(state->parallel_drum.rotation_timer) * |
| 1150 | (*io) = (state->parallel_drum.rotation_timer->elapsed() * |
| 1151 | 1151 | (ATTOSECONDS_PER_SECOND / (PARALLEL_DRUM_WORD_TIME.as_attoseconds()))).seconds & 0007777; |
| 1152 | 1152 | |
| 1153 | 1153 | /* set parity error and timing error... */ |
| r10326 | r10327 | |
| 1209 | 1209 | { |
| 1210 | 1210 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 1211 | 1211 | if (LOG_IOT_EXTRA) |
| 1212 | | logerror("CKS instruction: mb=0%06o, (%s)\n", (unsigned) mb, cpuexec_describe_context(device->machine)); |
| 1212 | logerror("CKS instruction: mb=0%06o, (%s)\n", (unsigned) mb, device->machine->describe_context()); |
| 1213 | 1213 | |
| 1214 | 1214 | *io = state->io_status; |
| 1215 | 1215 | } |
| r10326 | r10327 | |
| 1225 | 1225 | pdp1_state *state = device->machine->driver_data<pdp1_state>(); |
| 1226 | 1226 | state->tape_reader.rcl = state->tape_reader.rc = 0; |
| 1227 | 1227 | if (state->tape_reader.timer) |
| 1228 | | timer_enable(state->tape_reader.timer, 0); |
| 1228 | state->tape_reader.timer->enable(0); |
| 1229 | 1229 | |
| 1230 | 1230 | if (state->tape_puncher.timer) |
| 1231 | | timer_enable(state->tape_puncher.timer, 0); |
| 1231 | state->tape_puncher.timer->enable(0); |
| 1232 | 1232 | |
| 1233 | 1233 | if (state->typewriter.tyo_timer) |
| 1234 | | timer_enable(state->typewriter.tyo_timer, 0); |
| 1234 | state->typewriter.tyo_timer->enable(0); |
| 1235 | 1235 | |
| 1236 | 1236 | if (state->dpy_timer) |
| 1237 | | timer_enable(state->dpy_timer, 0); |
| 1237 | state->dpy_timer->enable(0); |
| 1238 | 1238 | |
| 1239 | 1239 | state->io_status = io_st_tyo | io_st_ptp; |
| 1240 | 1240 | } |
src/mess/machine/upd765.c
| r10326 | r10327 | |
| 349 | 349 | /* seek complete */ |
| 350 | 350 | upd765_seek_complete(device); |
| 351 | 351 | |
| 352 | | timer_reset(fdc->seek_timer, attotime::never); |
| 352 | fdc->seek_timer->reset(); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | static void upd765_timer_func(device_t *device, int timer_type) |
| r10326 | r10327 | |
| 368 | 368 | if (fdc->upd765_command_bytes[0] & UPD765_MF) |
| 369 | 369 | { |
| 370 | 370 | /* MFM */ |
| 371 | | timer_reset(fdc->timer, attotime::from_usec(13)); |
| 371 | fdc->timer->reset(attotime::from_usec(13)); |
| 372 | 372 | } |
| 373 | 373 | else |
| 374 | 374 | { |
| 375 | 375 | /* FM */ |
| 376 | | timer_reset(fdc->timer, attotime::from_usec(27)); |
| 376 | fdc->timer->reset(attotime::from_usec(27)); |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | else |
| r10326 | r10327 | |
| 406 | 406 | |
| 407 | 407 | upd765_set_data_request(device); |
| 408 | 408 | |
| 409 | | timer_reset(fdc->timer, attotime::never); |
| 409 | fdc->timer->reset(); |
| 410 | 410 | } |
| 411 | 411 | else if (fdc->timer_type == 4) |
| 412 | 412 | { |
| r10326 | r10327 | |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | | timer_reset(fdc->timer, attotime::never); |
| 428 | fdc->timer->reset(); |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| r10326 | r10327 | |
| 449 | 449 | |
| 450 | 450 | if (!(fdc->upd765_flags & UPD765_DMA_MODE)) |
| 451 | 451 | { |
| 452 | | timer_adjust_oneshot(fdc->timer, duration, 0); |
| 452 | fdc->timer->adjust(duration); |
| 453 | 453 | } |
| 454 | 454 | else |
| 455 | 455 | { |
| 456 | 456 | upd765_timer_func(device,fdc->timer_type); |
| 457 | | timer_reset(fdc->timer, attotime::never); |
| 457 | fdc->timer->reset(); |
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| r10326 | r10327 | |
| 477 | 477 | { |
| 478 | 478 | upd765_t *fdc = get_safe_token(device); |
| 479 | 479 | /* setup timer to signal after seek time is complete */ |
| 480 | | timer_adjust_oneshot(fdc->seek_timer, attotime::from_double(fdc->srt_in_ms*abs(signed_tracks)*0.001), 0); |
| 480 | fdc->seek_timer->adjust(attotime::from_double(fdc->srt_in_ms*abs(signed_tracks)*0.001)); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | static void upd765_seek_setup(device_t *device, int is_recalibrate) |
| r10326 | r10327 | |
| 760 | 760 | { |
| 761 | 761 | if (fdc->timer_type==0) |
| 762 | 762 | { |
| 763 | | timer_reset(fdc->timer, attotime::never); |
| 763 | fdc->timer->reset(); |
| 764 | 764 | |
| 765 | 765 | |
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | #ifdef NO_END_OF_CYLINDER |
| 770 | | timer_adjust_oneshot(fdc->command_timer, attotime::zero, 0); |
| 770 | fdc->command_timer->adjust(attotime::zero); |
| 771 | 771 | #else |
| 772 | 772 | upd765_update_state(device); |
| 773 | 773 | #endif |
| r10326 | r10327 | |
| 779 | 779 | { |
| 780 | 780 | upd765_t *fdc = get_safe_token(device); |
| 781 | 781 | if (LOG_EXTRA) |
| 782 | | logerror("%s: upd765_status_r: %02x\n", cpuexec_describe_context(device->machine), fdc->FDC_main); |
| 782 | logerror("%s: upd765_status_r: %02x\n", device->machine->describe_context(), fdc->FDC_main); |
| 783 | 783 | return fdc->FDC_main; |
| 784 | 784 | } |
| 785 | 785 | |
| r10326 | r10327 | |
| 1671 | 1671 | |
| 1672 | 1672 | if ((fdc->upd765_transfer_bytes_remaining==0) || (fdc->upd765_flags & UPD765_TC)) |
| 1673 | 1673 | { |
| 1674 | | timer_adjust_oneshot(fdc->command_timer, attotime::zero, 0); |
| 1674 | fdc->command_timer->adjust(attotime::zero); |
| 1675 | 1675 | } |
| 1676 | 1676 | else |
| 1677 | 1677 | { |
| r10326 | r10327 | |
| 1684 | 1684 | fdc->FDC_main |= 0x10; /* set BUSY */ |
| 1685 | 1685 | |
| 1686 | 1686 | if (LOG_VERBOSE) |
| 1687 | | logerror("%s: upd765(): command=0x%02x\n", cpuexec_describe_context(device->machine), fdc->upd765_data_reg); |
| 1687 | logerror("%s: upd765(): command=0x%02x\n", device->machine->describe_context(), fdc->upd765_data_reg); |
| 1688 | 1688 | |
| 1689 | 1689 | /* seek in progress? */ |
| 1690 | 1690 | if (fdc->upd765_flags & UPD765_SEEK_ACTIVE) |
| r10326 | r10327 | |
| 1716 | 1716 | |
| 1717 | 1717 | case UPD765_COMMAND_PHASE_BYTES: |
| 1718 | 1718 | if (LOG_VERBOSE) |
| 1719 | | logerror("%s: upd765(): command=0x%02x\n", cpuexec_describe_context(device->machine), fdc->upd765_data_reg); |
| 1719 | logerror("%s: upd765(): command=0x%02x\n", device->machine->describe_context(), fdc->upd765_data_reg); |
| 1720 | 1720 | |
| 1721 | 1721 | fdc->upd765_command_bytes[fdc->upd765_transfer_bytes_count] = fdc->upd765_data_reg; |
| 1722 | 1722 | fdc->upd765_transfer_bytes_count++; |
| r10326 | r10327 | |
| 1740 | 1740 | |
| 1741 | 1741 | if ((fdc->upd765_transfer_bytes_remaining == 0) || (fdc->upd765_flags & UPD765_TC)) |
| 1742 | 1742 | { |
| 1743 | | timer_adjust_oneshot(fdc->command_timer, attotime::zero, 0); |
| 1743 | fdc->command_timer->adjust(attotime::zero); |
| 1744 | 1744 | } |
| 1745 | 1745 | else |
| 1746 | 1746 | { |
src/mess/machine/pokemini.c
| r10326 | r10327 | |
| 466 | 466 | int index = data & 0x07; |
| 467 | 467 | int cycles = ( state->pm_reg[0x19] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 468 | 468 | |
| 469 | | timer_adjust_periodic(state->timers.timer1, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 469 | state->timers.timer1->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /* Check for prescaler change for the high counter */ |
| r10326 | r10327 | |
| 475 | 475 | int index = ( data >> 4 ) & 0x07; |
| 476 | 476 | int cycles = ( state->pm_reg[0x19] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 477 | 477 | |
| 478 | | timer_adjust_periodic(state->timers.timer1_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 478 | state->timers.timer1_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /* Check if timer1 low should be enabled */ |
| r10326 | r10327 | |
| 483 | 483 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x19] & 0x01 ) ) || |
| 484 | 484 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x19] & 0x01 ) ) ) ) |
| 485 | 485 | { |
| 486 | | timer_enable( state->timers.timer1, 1 ); |
| 486 | state->timers.timer1->enable( 1 ); |
| 487 | 487 | } |
| 488 | 488 | else |
| 489 | 489 | { |
| 490 | | timer_enable( state->timers.timer1, 0 ); |
| 490 | state->timers.timer1->enable( 0 ); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /* Check if timer1 high should be enabled */ |
| r10326 | r10327 | |
| 495 | 495 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x19] & 0x02 ) ) || |
| 496 | 496 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x19] & 0x02 ) ) ) ) |
| 497 | 497 | { |
| 498 | | timer_enable( state->timers.timer1_hi, 1 ); |
| 498 | state->timers.timer1_hi->enable( 1 ); |
| 499 | 499 | } |
| 500 | 500 | else |
| 501 | 501 | { |
| 502 | | timer_enable( state->timers.timer1_hi, 0 ); |
| 502 | state->timers.timer1_hi->enable( 0 ); |
| 503 | 503 | } |
| 504 | 504 | break; |
| 505 | 505 | case 0x19: /* Timers 1 speed |
| r10326 | r10327 | |
| 516 | 516 | int index = state->pm_reg[0x18] & 0x07; |
| 517 | 517 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 518 | 518 | |
| 519 | | timer_adjust_periodic(state->timers.timer1, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 519 | state->timers.timer1->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /* Check for prescaler change for the low counter */ |
| r10326 | r10327 | |
| 525 | 525 | int index = ( state->pm_reg[0x18] >> 4 ) & 0x07; |
| 526 | 526 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 527 | 527 | |
| 528 | | timer_adjust_periodic(state->timers.timer1_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 528 | state->timers.timer1_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | { |
| r10326 | r10327 | |
| 567 | 567 | if ( ( state->pm_reg[0x1C] & 0x08 ) && ( state->pm_reg[0x1D] & 0x01 ) ) |
| 568 | 568 | timer3_enable = 1; |
| 569 | 569 | } |
| 570 | | timer_enable( state->timers.timer1, timer1_enable ); |
| 571 | | timer_enable( state->timers.timer1_hi, timer1_hi_enable ); |
| 572 | | timer_enable( state->timers.timer2, timer2_enable ); |
| 573 | | timer_enable( state->timers.timer2_hi, timer2_hi_enable ); |
| 574 | | timer_enable( state->timers.timer3, timer3_enable ); |
| 575 | | timer_enable( state->timers.timer3_hi, timer3_hi_enable ); |
| 570 | state->timers.timer1->enable( timer1_enable ); |
| 571 | state->timers.timer1_hi->enable( timer1_hi_enable ); |
| 572 | state->timers.timer2->enable( timer2_enable ); |
| 573 | state->timers.timer2_hi->enable( timer2_hi_enable ); |
| 574 | state->timers.timer3->enable( timer3_enable ); |
| 575 | state->timers.timer3_hi->enable( timer3_hi_enable ); |
| 576 | 576 | } |
| 577 | 577 | break; |
| 578 | 578 | case 0x1A: /* Timer 2 pre-scale + enable |
| r10326 | r10327 | |
| 595 | 595 | int index = data & 0x07; |
| 596 | 596 | int cycles = ( state->pm_reg[0x1B] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 597 | 597 | |
| 598 | | timer_adjust_periodic(state->timers.timer2, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 598 | state->timers.timer2->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /* Check for prescaler change for the high counter */ |
| r10326 | r10327 | |
| 604 | 604 | int index = ( data >> 4 ) & 0x07; |
| 605 | 605 | int cycles = ( state->pm_reg[0x1B] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 606 | 606 | |
| 607 | | timer_adjust_periodic(state->timers.timer2_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 607 | state->timers.timer2_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /* Check if timer2 low should be enabled */ |
| r10326 | r10327 | |
| 612 | 612 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1B] & 0x01 ) ) || |
| 613 | 613 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1B] & 0x01 ) ) ) ) |
| 614 | 614 | { |
| 615 | | timer_enable( state->timers.timer2, 1 ); |
| 615 | state->timers.timer2->enable( 1 ); |
| 616 | 616 | } |
| 617 | 617 | else |
| 618 | 618 | { |
| 619 | | timer_enable( state->timers.timer2, 0 ); |
| 619 | state->timers.timer2->enable( 0 ); |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /* Check if timer2 high should be enabled */ |
| r10326 | r10327 | |
| 624 | 624 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1B] & 0x02 ) ) || |
| 625 | 625 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1B] & 0x02 ) ) ) ) |
| 626 | 626 | { |
| 627 | | timer_enable( state->timers.timer2_hi, 1 ); |
| 627 | state->timers.timer2_hi->enable( 1 ); |
| 628 | 628 | } |
| 629 | 629 | else |
| 630 | 630 | { |
| 631 | | timer_enable( state->timers.timer2_hi, 0 ); |
| 631 | state->timers.timer2_hi->enable( 0 ); |
| 632 | 632 | } |
| 633 | 633 | break; |
| 634 | 634 | case 0x1B: /* Timer 2 speeds |
| r10326 | r10327 | |
| 641 | 641 | int index = state->pm_reg[0x1A] & 0x07; |
| 642 | 642 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 643 | 643 | |
| 644 | | timer_adjust_periodic(state->timers.timer2, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 644 | state->timers.timer2->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 645 | 645 | |
| 646 | 646 | if ( ( state->pm_reg[0x1A] & 0x08 ) && ( state->pm_reg[0x38] & 0x04 ) && |
| 647 | 647 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) || |
| 648 | 648 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( data & 0x01 ) ) ) ) |
| 649 | 649 | { |
| 650 | | timer_enable( state->timers.timer2, 1 ); |
| 650 | state->timers.timer2->enable( 1 ); |
| 651 | 651 | } |
| 652 | 652 | else |
| 653 | 653 | { |
| 654 | | timer_enable( state->timers.timer2, 0 ); |
| 654 | state->timers.timer2->enable( 0 ); |
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
| r10326 | r10327 | |
| 661 | 661 | int index = ( state->pm_reg[0x1A] >> 4 ) & 0x07; |
| 662 | 662 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 663 | 663 | |
| 664 | | timer_adjust_periodic(state->timers.timer2_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 664 | state->timers.timer2_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 665 | 665 | |
| 666 | 666 | if ( ( state->pm_reg[0x1A] & 0x80 ) && ( state->pm_reg[0x39] & 0x04 ) && ! ( state->pm_reg[0x38] & 0x80 ) && |
| 667 | 667 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) || |
| 668 | 668 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( data & 0x02 ) ) ) ) |
| 669 | 669 | { |
| 670 | | timer_enable( state->timers.timer2_hi, 1 ); |
| 670 | state->timers.timer2_hi->enable( 1 ); |
| 671 | 671 | } |
| 672 | 672 | else |
| 673 | 673 | { |
| 674 | | timer_enable( state->timers.timer2_hi, 0 ); |
| 674 | state->timers.timer2_hi->enable( 0 ); |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | break; |
| r10326 | r10327 | |
| 695 | 695 | int index = data & 0x07; |
| 696 | 696 | int cycles = ( state->pm_reg[0x1D] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 697 | 697 | |
| 698 | | timer_adjust_periodic(state->timers.timer3, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 698 | state->timers.timer3->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /* Check for prescaler change for the high counter */ |
| r10326 | r10327 | |
| 704 | 704 | int index = ( data >> 4 ) & 0x07; |
| 705 | 705 | int cycles = ( state->pm_reg[0x1D] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 706 | 706 | |
| 707 | | timer_adjust_periodic(state->timers.timer3_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 707 | state->timers.timer3_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /* Check if timer2 low should be enabled */ |
| r10326 | r10327 | |
| 712 | 712 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1D] & 0x01 ) ) || |
| 713 | 713 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1D] & 0x01 ) ) ) ) |
| 714 | 714 | { |
| 715 | | timer_enable( state->timers.timer3, 1 ); |
| 715 | state->timers.timer3->enable( 1 ); |
| 716 | 716 | } |
| 717 | 717 | else |
| 718 | 718 | { |
| 719 | | timer_enable( state->timers.timer3, 0 ); |
| 719 | state->timers.timer3->enable( 0 ); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /* Check if timer2 high should be enabled */ |
| r10326 | r10327 | |
| 724 | 724 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1D] & 0x02 ) ) || |
| 725 | 725 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1D] & 0x02 ) ) ) ) |
| 726 | 726 | { |
| 727 | | timer_enable( state->timers.timer3_hi, 1 ); |
| 727 | state->timers.timer3_hi->enable( 1 ); |
| 728 | 728 | } |
| 729 | 729 | else |
| 730 | 730 | { |
| 731 | | timer_enable( state->timers.timer3_hi, 0 ); |
| 731 | state->timers.timer3_hi->enable( 0 ); |
| 732 | 732 | } |
| 733 | 733 | break; |
| 734 | 734 | case 0x1D: /* Timer 3 speeds |
| r10326 | r10327 | |
| 741 | 741 | int index = state->pm_reg[0x1C] & 0x07; |
| 742 | 742 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 743 | 743 | |
| 744 | | timer_adjust_periodic(state->timers.timer3, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 744 | state->timers.timer3->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 745 | 745 | |
| 746 | 746 | if ( ( state->pm_reg[0x1C] & 0x08 ) && ( state->pm_reg[0x48] & 0x04 ) && |
| 747 | 747 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) || |
| 748 | 748 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( data & 0x01 ) ) ) ) |
| 749 | 749 | { |
| 750 | | timer_enable( state->timers.timer3, 1 ); |
| 750 | state->timers.timer3->enable( 1 ); |
| 751 | 751 | } |
| 752 | 752 | else |
| 753 | 753 | { |
| 754 | | timer_enable( state->timers.timer3, 0 ); |
| 754 | state->timers.timer3->enable( 0 ); |
| 755 | 755 | } |
| 756 | 756 | } |
| 757 | 757 | |
| r10326 | r10327 | |
| 761 | 761 | int index = ( state->pm_reg[0x1C] >> 4 ) & 0x07; |
| 762 | 762 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 763 | 763 | |
| 764 | | timer_adjust_periodic(state->timers.timer3_hi, attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 764 | state->timers.timer3_hi->adjust(attotime::zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 765 | 765 | |
| 766 | 766 | if ( ( state->pm_reg[0x1C] & 0x80 ) && ( state->pm_reg[0x49] & 0x04 ) && ! ( state->pm_reg[0x48] & 0x80 ) && |
| 767 | 767 | ( ( ( state->pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) || |
| 768 | 768 | ( ( state->pm_reg[0x19] & 0x20 ) && ! ( data & 0x02 ) ) ) ) |
| 769 | 769 | { |
| 770 | | timer_enable( state->timers.timer3_hi, 1 ); |
| 770 | state->timers.timer3_hi->enable( 1 ); |
| 771 | 771 | } |
| 772 | 772 | else |
| 773 | 773 | { |
| 774 | | timer_enable( state->timers.timer3_hi, 0 ); |
| 774 | state->timers.timer3_hi->enable( 0 ); |
| 775 | 775 | } |
| 776 | 776 | } |
| 777 | 777 | break; |
| r10326 | r10327 | |
| 905 | 905 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x19] & 0x01 ) ) || |
| 906 | 906 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x19] & 0x01 ) ) ) ) |
| 907 | 907 | { |
| 908 | | timer_enable( state->timers.timer1, 1 ); |
| 908 | state->timers.timer1->enable( 1 ); |
| 909 | 909 | } |
| 910 | 910 | else |
| 911 | 911 | { |
| 912 | | timer_enable( state->timers.timer1, 0 ); |
| 912 | state->timers.timer1->enable( 0 ); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | if ( ( state->pm_reg[0x31] & 0x04 ) && ! ( data & 0x80 ) && ( state->pm_reg[0x18] & 0x80 ) && |
| 916 | 916 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x19] & 0x02 ) ) || |
| 917 | 917 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x19] & 0x02 ) ) ) ) |
| 918 | 918 | { |
| 919 | | timer_enable( state->timers.timer1_hi, 1 ); |
| 919 | state->timers.timer1_hi->enable( 1 ); |
| 920 | 920 | } |
| 921 | 921 | else |
| 922 | 922 | { |
| 923 | | timer_enable( state->timers.timer1_hi, 0 ); |
| 923 | state->timers.timer1_hi->enable( 0 ); |
| 924 | 924 | } |
| 925 | 925 | break; |
| 926 | 926 | case 0x31: /* Timer 1 control 2 |
| r10326 | r10327 | |
| 940 | 940 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x19] & 0x02 ) ) || |
| 941 | 941 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x19] & 0x02 ) ) ) ) |
| 942 | 942 | { |
| 943 | | timer_enable( state->timers.timer1_hi, 1 ); |
| 943 | state->timers.timer1_hi->enable( 1 ); |
| 944 | 944 | } |
| 945 | 945 | else |
| 946 | 946 | { |
| 947 | | timer_enable( state->timers.timer1_hi, 0 ); |
| 947 | state->timers.timer1_hi->enable( 0 ); |
| 948 | 948 | } |
| 949 | 949 | break; |
| 950 | 950 | case 0x32: /* Timer 1 preset value (low) |
| r10326 | r10327 | |
| 985 | 985 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1A] & 0x01 ) ) || |
| 986 | 986 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1A] & 0x01 ) ) ) ) |
| 987 | 987 | { |
| 988 | | timer_enable( state->timers.timer2, 1 ); |
| 988 | state->timers.timer2->enable( 1 ); |
| 989 | 989 | } |
| 990 | 990 | else |
| 991 | 991 | { |
| 992 | | timer_enable( state->timers.timer2, 0 ); |
| 992 | state->timers.timer2->enable( 0 ); |
| 993 | 993 | } |
| 994 | 994 | if ( ( state->pm_reg[0x39] & 0x04 ) && ! ( data & 0x80 ) && ( state->pm_reg[0x1A] & 0x80 ) && |
| 995 | 995 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1B] & 0x02 ) ) || |
| 996 | 996 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1B] & 0x02 ) ) ) ) |
| 997 | 997 | { |
| 998 | | timer_enable( state->timers.timer2_hi, 1 ); |
| 998 | state->timers.timer2_hi->enable( 1 ); |
| 999 | 999 | } |
| 1000 | 1000 | else |
| 1001 | 1001 | { |
| 1002 | | timer_enable( state->timers.timer2_hi, 0 ); |
| 1002 | state->timers.timer2_hi->enable( 0 ); |
| 1003 | 1003 | } |
| 1004 | 1004 | break; |
| 1005 | 1005 | case 0x39: /* Timer 2 control 2 |
| r10326 | r10327 | |
| 1019 | 1019 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1B] & 0x02 ) ) || |
| 1020 | 1020 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1B] & 0x02 ) ) ) ) |
| 1021 | 1021 | { |
| 1022 | | timer_enable( state->timers.timer2_hi, 1 ); |
| 1022 | state->timers.timer2_hi->enable( 1 ); |
| 1023 | 1023 | } |
| 1024 | 1024 | else |
| 1025 | 1025 | { |
| 1026 | | timer_enable( state->timers.timer2_hi, 0 ); |
| 1026 | state->timers.timer2_hi->enable( 0 ); |
| 1027 | 1027 | } |
| 1028 | 1028 | break; |
| 1029 | 1029 | case 0x3A: /* Timer 2 preset value (low) |
| r10326 | r10327 | |
| 1081 | 1081 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1D] & 0x01 ) ) || |
| 1082 | 1082 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1D] & 0x01 ) ) ) ) |
| 1083 | 1083 | { |
| 1084 | | timer_enable( state->timers.timer3, 1 ); |
| 1084 | state->timers.timer3->enable( 1 ); |
| 1085 | 1085 | } |
| 1086 | 1086 | else |
| 1087 | 1087 | { |
| 1088 | | timer_enable( state->timers.timer3, 0 ); |
| 1088 | state->timers.timer3->enable( 0 ); |
| 1089 | 1089 | } |
| 1090 | 1090 | if ( ( state->pm_reg[0x49] & 0x04 ) && ! ( data & 0x80 ) && ( state->pm_reg[0x1C] & 0x80 ) && |
| 1091 | 1091 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1D] & 0x02 ) ) || |
| 1092 | 1092 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1D] & 0x02 ) ) ) ) |
| 1093 | 1093 | { |
| 1094 | | timer_enable( state->timers.timer3_hi, 1 ); |
| 1094 | state->timers.timer3_hi->enable( 1 ); |
| 1095 | 1095 | } |
| 1096 | 1096 | else |
| 1097 | 1097 | { |
| 1098 | | timer_enable( state->timers.timer3_hi, 0 ); |
| 1098 | state->timers.timer3_hi->enable( 0 ); |
| 1099 | 1099 | } |
| 1100 | 1100 | state->pm_reg[0x48] = data; |
| 1101 | 1101 | pokemini_update_sound( device->machine ); |
| r10326 | r10327 | |
| 1117 | 1117 | ( ( ( state->pm_reg[0x19] & 0x20 ) && ! ( state->pm_reg[0x1D] & 0x02 ) ) || |
| 1118 | 1118 | ( ( state->pm_reg[0x19] & 0x10 ) && ( state->pm_reg[0x1D] & 0x02 ) ) ) ) |
| 1119 | 1119 | { |
| 1120 | | timer_enable( state->timers.timer3_hi, 1 ); |
| 1120 | state->timers.timer3_hi->enable( 1 ); |
| 1121 | 1121 | } |
| 1122 | 1122 | else |
| 1123 | 1123 | { |
| 1124 | | timer_enable( state->timers.timer3_hi, 0 ); |
| 1124 | state->timers.timer3_hi->enable( 0 ); |
| 1125 | 1125 | } |
| 1126 | 1126 | state->pm_reg[0x49] = data; |
| 1127 | 1127 | pokemini_update_sound( device->machine ); |
| r10326 | r10327 | |
| 1569 | 1569 | |
| 1570 | 1570 | /* Set up timers */ |
| 1571 | 1571 | state->timers.seconds_timer = machine->scheduler().timer_alloc(FUNC(pokemini_seconds_timer_callback)); |
| 1572 | | timer_adjust_periodic( state->timers.seconds_timer, attotime::zero, 0, attotime::from_seconds( 1 ) ); |
| 1572 | state->timers.seconds_timer->adjust( attotime::zero, 0, attotime::from_seconds( 1 ) ); |
| 1573 | 1573 | |
| 1574 | 1574 | state->timers.hz256_timer = machine->scheduler().timer_alloc(FUNC(pokemini_256hz_timer_callback)); |
| 1575 | | timer_adjust_periodic( state->timers.hz256_timer, attotime::zero, 0, attotime::from_hz( 256 ) ); |
| 1575 | state->timers.hz256_timer->adjust( attotime::zero, 0, attotime::from_hz( 256 ) ); |
| 1576 | 1576 | |
| 1577 | 1577 | state->timers.timer1 = machine->scheduler().timer_alloc(FUNC(pokemini_timer1_callback)); |
| 1578 | 1578 | state->timers.timer1_hi = machine->scheduler().timer_alloc(FUNC(pokemini_timer1_hi_callback)); |
| r10326 | r10327 | |
| 1584 | 1584 | /* Set up the PRC */ |
| 1585 | 1585 | state->prc.max_frame_count = 2; |
| 1586 | 1586 | state->prc.count_timer = machine->scheduler().timer_alloc(FUNC(pokemini_prc_counter_callback)); |
| 1587 | | timer_adjust_periodic( state->prc.count_timer, attotime::zero, 0, machine->device<cpu_device>("maincpu")->cycles_to_attotime(55640 / 65) ); |
| 1587 | state->prc.count_timer->adjust( attotime::zero, 0, machine->device<cpu_device>("maincpu")->cycles_to_attotime(55640 / 65) ); |
| 1588 | 1588 | } |
| 1589 | 1589 | |
src/mess/machine/thomson.c
| r10326 | r10327 | |
| 1247 | 1247 | { |
| 1248 | 1248 | LOG (( "to7_game_init called\n" )); |
| 1249 | 1249 | to7_game_timer = machine->scheduler().timer_alloc(FUNC(to7_game_update_cb)); |
| 1250 | | timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 1250 | to7_game_timer->adjust(TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 1251 | 1251 | state_save_register_global( machine, to7_game_sound ); |
| 1252 | 1252 | state_save_register_global( machine, to7_game_mute ); |
| 1253 | 1253 | } |
| r10326 | r10327 | |
| 1899 | 1899 | static void mo5_init_timer(running_machine *machine) |
| 1900 | 1900 | { |
| 1901 | 1901 | /* time is a little faster than 50 Hz to match video framerate */ |
| 1902 | | timer_adjust_periodic(mo5_periodic_timer, attotime::zero, 0, attotime::from_usec( 19968 )); |
| 1902 | mo5_periodic_timer->adjust(attotime::zero, 0, attotime::from_usec( 19968 )); |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | |
| r10326 | r10327 | |
| 2976 | 2976 | } |
| 2977 | 2977 | |
| 2978 | 2978 | to9_kbd_byte_count = ( to9_kbd_byte_count + 1 ) & 3; |
| 2979 | | timer_adjust_oneshot(to9_kbd_timer, to9_kbd_byte_count ? TO9_KBD_BYTE_SPACE : TO9_KBD_END_SPACE, 0); |
| 2979 | to9_kbd_timer->adjust(to9_kbd_byte_count ? TO9_KBD_BYTE_SPACE : TO9_KBD_END_SPACE); |
| 2980 | 2980 | } |
| 2981 | 2981 | else |
| 2982 | 2982 | { |
| r10326 | r10327 | |
| 2984 | 2984 | /* keyboard mode: send a byte only if a key is down */ |
| 2985 | 2985 | if ( key ) |
| 2986 | 2986 | to9_kbd_send( machine, key, 0 ); |
| 2987 | | timer_adjust_oneshot(to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0); |
| 2987 | to9_kbd_timer->adjust(TO9_KBD_POLL_PERIOD); |
| 2988 | 2988 | } |
| 2989 | 2989 | } |
| 2990 | 2990 | |
| r10326 | r10327 | |
| 3004 | 3004 | to9_kbd_key_count = 0; |
| 3005 | 3005 | to9_kbd_last_key = 0xff; |
| 3006 | 3006 | to9_kbd_update_irq(machine); |
| 3007 | | timer_adjust_oneshot(to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0); |
| 3007 | to9_kbd_timer->adjust(TO9_KBD_POLL_PERIOD); |
| 3008 | 3008 | } |
| 3009 | 3009 | |
| 3010 | 3010 | |
| r10326 | r10327 | |
| 3420 | 3420 | d = attotime::from_usec( bit ? 56 : 38 ); |
| 3421 | 3421 | to8_kbd_step++; |
| 3422 | 3422 | } |
| 3423 | | timer_adjust_oneshot(to8_kbd_timer, d, 0); |
| 3423 | to8_kbd_timer->adjust(d); |
| 3424 | 3424 | } |
| 3425 | 3425 | |
| 3426 | 3426 | |
| r10326 | r10327 | |
| 3441 | 3441 | |
| 3442 | 3442 | if ( data ) |
| 3443 | 3443 | { |
| 3444 | | double len = timer_timeelapsed( to8_kbd_signal).as_double() * 1000. - 2.; |
| 3444 | double len = to8_kbd_signal->elapsed( ).as_double() * 1000. - 2.; |
| 3445 | 3445 | LOG_KBD(( "%f to8_kbd_set_ack: CPU end ack, len=%f\n", machine->time().as_double(), len )); |
| 3446 | 3446 | if ( to8_kbd_data == 0xfff ) |
| 3447 | 3447 | { |
| r10326 | r10327 | |
| 3455 | 3455 | /* send back signal: TODO returned codes ? */ |
| 3456 | 3456 | to8_kbd_data = 0; |
| 3457 | 3457 | to8_kbd_step = 0; |
| 3458 | | timer_adjust_oneshot(to8_kbd_timer, attotime::from_msec( 1 ), 0); |
| 3458 | to8_kbd_timer->adjust(attotime::from_msec( 1 )); |
| 3459 | 3459 | } |
| 3460 | 3460 | else |
| 3461 | 3461 | { |
| 3462 | 3462 | to8_kbd_step = 0; |
| 3463 | | timer_adjust_oneshot(to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0); |
| 3463 | to8_kbd_timer->adjust(TO8_KBD_POLL_PERIOD); |
| 3464 | 3464 | if ( len >= 1.2 && len <= 1.4 ) |
| 3465 | 3465 | { |
| 3466 | 3466 | LOG (( "%f to8_kbd_set_ack: CAPS on signal\n", machine->time().as_double() )); |
| r10326 | r10327 | |
| 3478 | 3478 | { |
| 3479 | 3479 | /* end key transmission */ |
| 3480 | 3480 | to8_kbd_step = 0; |
| 3481 | | timer_adjust_oneshot(to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0); |
| 3481 | to8_kbd_timer->adjust(TO8_KBD_POLL_PERIOD); |
| 3482 | 3482 | } |
| 3483 | 3483 | } |
| 3484 | 3484 | |
| r10326 | r10327 | |
| 3488 | 3488 | { |
| 3489 | 3489 | /* CPU accepts key */ |
| 3490 | 3490 | to8_kbd_step = 99; |
| 3491 | | timer_adjust_oneshot(to8_kbd_timer, attotime::from_usec( 400 ), 0); |
| 3491 | to8_kbd_timer->adjust(attotime::from_usec( 400 )); |
| 3492 | 3492 | } |
| 3493 | 3493 | else |
| 3494 | 3494 | { |
| 3495 | 3495 | /* start signal from CPU */ |
| 3496 | 3496 | to8_kbd_data = 0xfff; |
| 3497 | 3497 | to8_kbd_step = 91; |
| 3498 | | timer_adjust_oneshot(to8_kbd_timer, attotime::from_usec( 400 ), 0); |
| 3499 | | timer_adjust_oneshot(to8_kbd_signal, attotime::never, 0); |
| 3498 | to8_kbd_timer->adjust(attotime::from_usec( 400 )); |
| 3499 | to8_kbd_signal->adjust(attotime::never); |
| 3500 | 3500 | } |
| 3501 | 3501 | LOG_KBD(( "%f to8_kbd_set_ack: CPU ack, data=$%03X\n", machine->time().as_double(), to8_kbd_data )); |
| 3502 | 3502 | } |
| r10326 | r10327 | |
| 4618 | 4618 | { |
| 4619 | 4619 | LOG (( "mo6_game_init called\n" )); |
| 4620 | 4620 | to7_game_timer = machine->scheduler().timer_alloc(FUNC(mo6_game_update_cb)); |
| 4621 | | timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 4621 | to7_game_timer->adjust(TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 4622 | 4622 | state_save_register_global( machine, to7_game_sound ); |
| 4623 | 4623 | state_save_register_global( machine, to7_game_mute ); |
| 4624 | 4624 | } |
| r10326 | r10327 | |
| 5131 | 5131 | { |
| 5132 | 5132 | LOG (( "mo5nr_game_init called\n" )); |
| 5133 | 5133 | to7_game_timer = machine->scheduler().timer_alloc(FUNC(mo6_game_update_cb)); |
| 5134 | | timer_adjust_periodic( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD ); |
| 5134 | to7_game_timer->adjust( TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD ); |
| 5135 | 5135 | state_save_register_global( machine, to7_game_sound ); |
| 5136 | 5136 | state_save_register_global( machine, to7_game_mute ); |
| 5137 | 5137 | } |
src/mess/machine/tx0.c
| r10326 | r10327 | |
| 119 | 119 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 120 | 120 | { |
| 121 | 121 | /* delay is approximately 1/400s */ |
| 122 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 122 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { |
| 126 | | timer_enable(state->tape_reader.timer, 0); |
| 126 | state->tape_reader.timer->enable(0); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | break; |
| r10326 | r10327 | |
| 152 | 152 | state->tape_reader.motor_on = 0; |
| 153 | 153 | |
| 154 | 154 | if (state->tape_reader.timer) |
| 155 | | timer_enable(state->tape_reader.timer, 0); |
| 155 | state->tape_reader.timer->enable(0); |
| 156 | 156 | break; |
| 157 | 157 | |
| 158 | 158 | case 1: |
| r10326 | r10327 | |
| 194 | 194 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 195 | 195 | { |
| 196 | 196 | /* delay is approximately 1/400s */ |
| 197 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 197 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 198 | 198 | } |
| 199 | 199 | else |
| 200 | 200 | { |
| 201 | | timer_enable(state->tape_reader.timer, 0); |
| 201 | state->tape_reader.timer->enable(0); |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| r10326 | r10327 | |
| 246 | 246 | |
| 247 | 247 | if (state->tape_reader.motor_on && state->tape_reader.rcl) |
| 248 | 248 | /* delay is approximately 1/400s */ |
| 249 | | timer_adjust_oneshot(state->tape_reader.timer, attotime::from_usec(2500), 0); |
| 249 | state->tape_reader.timer->adjust(attotime::from_usec(2500)); |
| 250 | 250 | else |
| 251 | | timer_enable(state->tape_reader.timer, 0); |
| 251 | state->tape_reader.timer->enable(0); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /* |
| r10326 | r10327 | |
| 290 | 290 | /* shuffle and punch 6-bit word */ |
| 291 | 291 | tape_write(state, ((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5)); |
| 292 | 292 | |
| 293 | | timer_adjust_oneshot(state->tape_puncher.timer, attotime::from_usec(15800), 0); |
| 293 | state->tape_puncher.timer->adjust(attotime::from_usec(15800)); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /* |
| r10326 | r10327 | |
| 306 | 306 | /* shuffle and punch 6-bit word */ |
| 307 | 307 | tape_write(state, ((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5) | 0100); |
| 308 | 308 | |
| 309 | | timer_adjust_oneshot(state->tape_puncher.timer, attotime::from_usec(15800), 0); |
| 309 | state->tape_puncher.timer->adjust(attotime::from_usec(15800)); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | |
| r10326 | r10327 | |
| 369 | 369 | ch = ((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5); |
| 370 | 370 | typewriter_out(device->machine, ch); |
| 371 | 371 | |
| 372 | | timer_adjust_oneshot(state->typewriter.prt_timer, attotime::from_msec(100), 0); |
| 372 | state->typewriter.prt_timer->adjust(attotime::from_msec(100)); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| r10326 | r10327 | |
| 396 | 396 | y = ac & 0777; |
| 397 | 397 | tx0_plot(device->machine, x, y); |
| 398 | 398 | |
| 399 | | timer_adjust_oneshot(state->dis_timer, attotime::from_usec(50), 0); |
| 399 | state->dis_timer->adjust(attotime::from_usec(50)); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | |
| r10326 | r10327 | |
| 429 | 429 | delay = attotime::from_usec(4600); |
| 430 | 430 | break; |
| 431 | 431 | } |
| 432 | | timer_adjust_oneshot(state->magtape.timer, delay, 0); |
| 432 | state->magtape.timer->adjust(delay); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | static void schedule_unselect(tx0_state *state) |
| r10326 | r10327 | |
| 451 | 451 | delay = attotime::from_usec(5750); |
| 452 | 452 | break; |
| 453 | 453 | } |
| 454 | | timer_adjust_oneshot(state->magtape.timer, delay, 0); |
| 454 | state->magtape.timer->adjust(delay); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | DEVICE_START( tx0_magtape ) |
| r10326 | r10327 | |
| 492 | 492 | { |
| 493 | 493 | if (state->magtape.state == MTS_SELECTING) |
| 494 | 494 | /* I/O has not actually started, we can cancel the selection */ |
| 495 | | timer_enable(state->tape_reader.timer, 0); |
| 495 | state->tape_reader.timer->enable(0); |
| 496 | 496 | if ((state->magtape.state == MTS_SELECTED) || ((state->magtape.state == MTS_SELECTING) && (state->magtape.command == 2))) |
| 497 | 497 | { /* unit has become unavailable */ |
| 498 | 498 | state->magtape.state = MTS_UNSELECTING; |
| r10326 | r10327 | |
| 681 | 681 | break; |
| 682 | 682 | } |
| 683 | 683 | if (state->magtape.state != MTS_UNSELECTING) |
| 684 | | timer_adjust_oneshot(state->magtape.timer, attotime::from_usec(66), 0); |
| 684 | state->magtape.timer->adjust(attotime::from_usec(66)); |
| 685 | 685 | } |
| 686 | 686 | break; |
| 687 | 687 | |
| r10326 | r10327 | |
| 840 | 840 | break; |
| 841 | 841 | } |
| 842 | 842 | if (state->magtape.state != MTS_UNSELECTING) |
| 843 | | timer_adjust_oneshot(state->magtape.timer, attotime::from_usec(66), 0); |
| 843 | state->magtape.timer->adjust(attotime::from_usec(66)); |
| 844 | 844 | } |
| 845 | 845 | break; |
| 846 | 846 | |
| 847 | 847 | case 2: /* rewind */ |
| 848 | 848 | state->magtape.state = MTS_UNSELECTING; |
| 849 | 849 | /* we rewind at 10*read speed (I don't know the real value) */ |
| 850 | | timer_adjust_oneshot(state->magtape.timer, (attotime::from_nsec(6600) * state->magtape.img->ftell()), 0); |
| 850 | state->magtape.timer->adjust((attotime::from_nsec(6600) * state->magtape.img->ftell())); |
| 851 | 851 | //schedule_unselect(state); |
| 852 | 852 | state->magtape.img->fseek( 0, SEEK_END); |
| 853 | 853 | state->magtape.irg_pos = MTIRGP_END; |
| r10326 | r10327 | |
| 935 | 935 | state->magtape.img->unload(); |
| 936 | 936 | } |
| 937 | 937 | else |
| 938 | | timer_adjust_oneshot(state->magtape.timer, attotime::from_usec(66), 0); |
| 938 | state->magtape.timer->adjust(attotime::from_usec(66)); |
| 939 | 939 | } |
| 940 | 940 | break; |
| 941 | 941 | } |
| r10326 | r10327 | |
| 952 | 952 | { |
| 953 | 953 | if (0) |
| 954 | 954 | magtape_callback(device); |
| 955 | | timer_adjust_oneshot(state->magtape.timer, attotime::zero, 0); |
| 955 | state->magtape.timer->adjust(attotime::zero); |
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | |
| r10326 | r10327 | |
| 996 | 996 | tx0_state *state = device->machine->driver_data<tx0_state>(); |
| 997 | 997 | state->tape_reader.rcl = state->tape_reader.rc = 0; |
| 998 | 998 | if (state->tape_reader.timer) |
| 999 | | timer_enable(state->tape_reader.timer, 0); |
| 999 | state->tape_reader.timer->enable(0); |
| 1000 | 1000 | |
| 1001 | 1001 | if (state->tape_puncher.timer) |
| 1002 | | timer_enable(state->tape_puncher.timer, 0); |
| 1002 | state->tape_puncher.timer->enable(0); |
| 1003 | 1003 | |
| 1004 | 1004 | if (state->typewriter.prt_timer) |
| 1005 | | timer_enable(state->typewriter.prt_timer, 0); |
| 1005 | state->typewriter.prt_timer->enable(0); |
| 1006 | 1006 | |
| 1007 | 1007 | if (state->dis_timer) |
| 1008 | | timer_enable(state->dis_timer, 0); |
| 1008 | state->dis_timer->enable(0); |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | |
src/mess/machine/fm_scsi.c
| r10326 | r10327 | |
| 187 | 187 | if(m_result_index >= m_result_length) |
| 188 | 188 | { |
| 189 | 189 | // end of data transfer |
| 190 | | timer_adjust_oneshot(m_transfer_timer,attotime::never,0); // stop timer |
| 191 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 190 | m_transfer_timer->adjust(attotime::never); // stop timer |
| 191 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 192 | 192 | if(m_output_lines & FMSCSI_LINE_DMAE) |
| 193 | 193 | { |
| 194 | 194 | devcb_call_write_line(&m_drq_func,0); |
| r10326 | r10327 | |
| 201 | 201 | if(m_phase == SCSI_PHASE_MESSAGE_IN) |
| 202 | 202 | { |
| 203 | 203 | m_data = 0; // command complete message |
| 204 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_BUS_FREE); |
| 204 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_BUS_FREE); |
| 205 | 205 | m_command_index = 0; |
| 206 | 206 | return m_data; |
| 207 | 207 | } |
| r10326 | r10327 | |
| 210 | 210 | { |
| 211 | 211 | m_data = 0; // GOOD status |
| 212 | 212 | // no command complete message? |
| 213 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_MESSAGE_IN); |
| 213 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_MESSAGE_IN); |
| 214 | 214 | m_command_index = 0; |
| 215 | 215 | //set_input_line(FMSCSI_LINE_REQ,1); // raise REQ yet again |
| 216 | 216 | return m_data; |
| r10326 | r10327 | |
| 251 | 251 | if(m_result_index >= m_result_length) |
| 252 | 252 | { |
| 253 | 253 | // end of data transfer |
| 254 | | timer_adjust_oneshot(m_transfer_timer,attotime::never,0); // stop timer |
| 255 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 254 | m_transfer_timer->adjust(attotime::never); // stop timer |
| 255 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 256 | 256 | if(m_output_lines & FMSCSI_LINE_DMAE) |
| 257 | 257 | { |
| 258 | 258 | devcb_call_write_line(&m_drq_func,0); |
| r10326 | r10327 | |
| 272 | 272 | SCSIExecCommand(m_SCSIdevices[m_target],&m_result_length); |
| 273 | 273 | SCSIGetPhase(m_SCSIdevices[m_target],&phase); |
| 274 | 274 | if(m_command[0] == 1) // rezero unit command - not implemented in SCSI code |
| 275 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 275 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 276 | 276 | else |
| 277 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),phase); |
| 277 | m_phase_timer->adjust(attotime::from_usec(800),phase); |
| 278 | 278 | |
| 279 | 279 | logerror("FMSCSI: Command %02x sent, result length = %i\n",m_command[0],m_result_length); |
| 280 | 280 | } |
| 281 | 281 | else |
| 282 | 282 | { |
| 283 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_COMMAND); |
| 283 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_COMMAND); |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | if(m_phase == SCSI_PHASE_MESSAGE_OUT) |
| 287 | 287 | { |
| 288 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 288 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_STATUS); |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| r10326 | r10327 | |
| 322 | 322 | set_input_line(FMSCSI_LINE_IO,1); |
| 323 | 323 | set_input_line(FMSCSI_LINE_REQ,1); |
| 324 | 324 | // start transfer timer |
| 325 | | timer_adjust_periodic(m_transfer_timer,attotime::zero,0,attotime::from_hz(3000000)); // arbitrary value for now |
| 325 | m_transfer_timer->adjust(attotime::zero,0,attotime::from_hz(3000000)); // arbitrary value for now |
| 326 | 326 | SCSIReadData(m_SCSIdevices[m_target],m_buffer,512); |
| 327 | 327 | m_result_index = 0; |
| 328 | 328 | logerror("FMSCSI: Starting transfer (%i)\n",m_result_length); |
| r10326 | r10327 | |
| 333 | 333 | set_input_line(FMSCSI_LINE_IO,0); |
| 334 | 334 | set_input_line(FMSCSI_LINE_REQ,1); |
| 335 | 335 | // start transfer timer |
| 336 | | timer_adjust_periodic(m_transfer_timer,attotime::zero,0,attotime::from_hz(3000000)); // arbitrary value for now |
| 336 | m_transfer_timer->adjust(attotime::zero,0,attotime::from_hz(3000000)); // arbitrary value for now |
| 337 | 337 | m_result_index = 0; |
| 338 | 338 | logerror("FMSCSI: Starting transfer (%i)\n",m_result_length); |
| 339 | 339 | break; |
| r10326 | r10327 | |
| 409 | 409 | { |
| 410 | 410 | if (image->exists()) // if device is mounted |
| 411 | 411 | { |
| 412 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_COMMAND); |
| 412 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_COMMAND); |
| 413 | 413 | m_data = 0x08; |
| 414 | 414 | } |
| 415 | 415 | } |
| r10326 | r10327 | |
| 418 | 418 | if(line == FMSCSI_LINE_ATN) |
| 419 | 419 | { |
| 420 | 420 | if(state != 0) |
| 421 | | timer_adjust_oneshot(m_phase_timer,attotime::from_usec(800),SCSI_PHASE_MESSAGE_OUT); |
| 421 | m_phase_timer->adjust(attotime::from_usec(800),SCSI_PHASE_MESSAGE_OUT); |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | if(state != 0) |
src/mess/machine/amigafdc.c
| r10326 | r10327 | |
| 98 | 98 | fdc->fdc_status[id].cached = -1; |
| 99 | 99 | fdc->fdc_status[id].motor_on = 0; |
| 100 | 100 | fdc->fdc_status[id].rev_timer_started = 0; |
| 101 | | timer_reset( fdc->fdc_status[id].rev_timer, attotime::never ); |
| 102 | | timer_reset( fdc->fdc_status[id].sync_timer, attotime::never ); |
| 103 | | timer_reset( fdc->fdc_status[id].dma_timer, attotime::never ); |
| 101 | fdc->fdc_status[id].rev_timer->reset( ); |
| 102 | fdc->fdc_status[id].sync_timer->reset( ); |
| 103 | fdc->fdc_status[id].dma_timer->reset( ); |
| 104 | 104 | fdc->fdc_rdy = 0; |
| 105 | 105 | |
| 106 | 106 | check_extended_image( image.device().owner(), id ); |
| r10326 | r10327 | |
| 115 | 115 | fdc->fdc_status[id].cached = -1; |
| 116 | 116 | fdc->fdc_status[id].motor_on = 0; |
| 117 | 117 | fdc->fdc_status[id].rev_timer_started = 0; |
| 118 | | timer_reset( fdc->fdc_status[id].rev_timer, attotime::never ); |
| 119 | | timer_reset( fdc->fdc_status[id].sync_timer, attotime::never ); |
| 120 | | timer_reset( fdc->fdc_status[id].dma_timer, attotime::never ); |
| 118 | fdc->fdc_status[id].rev_timer->reset( ); |
| 119 | fdc->fdc_status[id].sync_timer->reset( ); |
| 120 | fdc->fdc_status[id].dma_timer->reset( ); |
| 121 | 121 | fdc->fdc_rdy = 0; |
| 122 | 122 | } |
| 123 | 123 | |
| r10326 | r10327 | |
| 158 | 158 | fdc->fdc_status[id].is_ext_image = 0; |
| 159 | 159 | fdc->fdc_status[id].tracklen = MAX_TRACK_BYTES; |
| 160 | 160 | fdc->fdc_status[id].disk_changed = DISK_DETECT_DELAY; |
| 161 | | timer_reset( fdc->fdc_status[id].rev_timer, attotime::never ); |
| 162 | | timer_reset( fdc->fdc_status[id].sync_timer, attotime::never ); |
| 163 | | timer_reset( fdc->fdc_status[id].dma_timer, attotime::never ); |
| 161 | fdc->fdc_status[id].rev_timer->reset( ); |
| 162 | fdc->fdc_status[id].sync_timer->reset( ); |
| 163 | fdc->fdc_status[id].dma_timer->reset( ); |
| 164 | 164 | memset( fdc->fdc_status[id].mfm, 0xaa, MAX_MFM_TRACK_LEN ); |
| 165 | 165 | } |
| 166 | 166 | fdc->fdc_sel = 0x0f; |
| r10326 | r10327 | |
| 237 | 237 | return 0; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | | elapsed = timer_timeelapsed( fdc->fdc_status[drive].rev_timer ).as_double(); |
| 240 | elapsed = fdc->fdc_status[drive].rev_timer ->elapsed( ).as_double(); |
| 241 | 241 | speed = ( CUSTOM_REG(REG_ADKCON) & 0x100 ) ? 2 : 4; |
| 242 | 242 | |
| 243 | 243 | bytes = elapsed / attotime::from_usec( speed * 8 ).as_double(); |
| r10326 | r10327 | |
| 333 | 333 | time = ONE_SECTOR_BYTES; |
| 334 | 334 | time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4; |
| 335 | 335 | time *= 8; |
| 336 | | timer_adjust_oneshot(fdc->fdc_status[drive].sync_timer, attotime::from_usec( time ), drive); |
| 336 | fdc->fdc_status[drive].sync_timer->adjust(attotime::from_usec( time ), drive); |
| 337 | 337 | return; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | bail: |
| 341 | | timer_reset( fdc->fdc_status[drive].sync_timer, attotime::never ); |
| 341 | fdc->fdc_status[drive].sync_timer->reset( ); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | static TIMER_CALLBACK(fdc_dma_proc) |
| r10326 | r10327 | |
| 417 | 417 | time = len_words * 2; |
| 418 | 418 | time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4; |
| 419 | 419 | time *= 8; |
| 420 | | timer_adjust_oneshot(fdc->fdc_status[drive].dma_timer, attotime::from_usec( time ), drive); |
| 420 | fdc->fdc_status[drive].dma_timer->adjust(attotime::from_usec( time ), drive); |
| 421 | 421 | return; |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | bail: |
| 426 | | timer_reset( fdc->fdc_status[drive].dma_timer, attotime::never ); |
| 426 | fdc->fdc_status[drive].dma_timer->reset( ); |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | void amiga_fdc_setup_dma( device_t *device ) { |
| r10326 | r10327 | |
| 492 | 492 | time += len_words * 2; |
| 493 | 493 | time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4; |
| 494 | 494 | time *= 8; |
| 495 | | timer_adjust_oneshot(fdc->fdc_status[drive].dma_timer, attotime::from_usec( time ), drive); |
| 495 | fdc->fdc_status[drive].dma_timer->adjust(attotime::from_usec( time ), drive); |
| 496 | 496 | |
| 497 | 497 | return; |
| 498 | 498 | |
| 499 | 499 | bail: |
| 500 | | timer_reset( fdc->fdc_status[drive].dma_timer, attotime::never ); |
| 500 | fdc->fdc_status[drive].dma_timer->reset( ); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | static void setup_fdc_buffer( device_t *device,int drive ) |
| r10326 | r10327 | |
| 674 | 674 | mos6526_flag_w(cia, 0); |
| 675 | 675 | mos6526_flag_w(cia, 1); |
| 676 | 676 | |
| 677 | | timer_adjust_oneshot(fdc->fdc_status[drive].rev_timer, attotime::from_msec( ONE_REV_TIME ), drive); |
| 677 | fdc->fdc_status[drive].rev_timer->adjust(attotime::from_msec( ONE_REV_TIME ), drive); |
| 678 | 678 | fdc->fdc_status[drive].rev_timer_started = 1; |
| 679 | 679 | |
| 680 | 680 | if ( fdc->fdc_status[drive].is_ext_image == 0 ) |
| r10326 | r10327 | |
| 683 | 683 | time = GAP_TRACK_BYTES + 6; |
| 684 | 684 | time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4; |
| 685 | 685 | time *= 8; |
| 686 | | timer_adjust_oneshot(fdc->fdc_status[drive].sync_timer, attotime::from_usec( time ), drive); |
| 686 | fdc->fdc_status[drive].sync_timer->adjust(attotime::from_usec( time ), drive); |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
| r10326 | r10327 | |
| 696 | 696 | return; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | | timer_adjust_oneshot(fdc->fdc_status[drive].rev_timer, attotime::from_msec( ONE_REV_TIME ), drive); |
| 699 | fdc->fdc_status[drive].rev_timer->adjust(attotime::from_msec( ONE_REV_TIME ), drive); |
| 700 | 700 | fdc->fdc_status[drive].rev_timer_started = 1; |
| 701 | 701 | } |
| 702 | 702 | |
| r10326 | r10327 | |
| 708 | 708 | return; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | | timer_reset( fdc->fdc_status[drive].rev_timer, attotime::never ); |
| 711 | fdc->fdc_status[drive].rev_timer->reset( ); |
| 712 | 712 | fdc->fdc_status[drive].rev_timer_started = 0; |
| 713 | | timer_reset( fdc->fdc_status[drive].dma_timer, attotime::never ); |
| 714 | | timer_reset( fdc->fdc_status[drive].sync_timer, attotime::never ); |
| 713 | fdc->fdc_status[drive].dma_timer->reset( ); |
| 714 | fdc->fdc_status[drive].sync_timer->reset( ); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | static void fdc_setup_leds(device_t *device, int drive ) { |
src/mess/machine/upd1990a.c
| r10326 | r10327 | |
| 142 | 142 | if (LOG) logerror("UPD1990A Register Hold Mode\n"); |
| 143 | 143 | |
| 144 | 144 | /* enable time counter */ |
| 145 | | timer_enable(upd1990a->clock_timer, 1); |
| 145 | upd1990a->clock_timer->enable(1); |
| 146 | 146 | |
| 147 | 147 | /* 1 Hz data out pulse */ |
| 148 | 148 | upd1990a->data_out = 1; |
| 149 | | timer_adjust_periodic(upd1990a->data_out_timer, attotime::zero, 0, attotime::from_hz(1*2)); |
| 149 | upd1990a->data_out_timer->adjust(attotime::zero, 0, attotime::from_hz(1*2)); |
| 150 | 150 | |
| 151 | 151 | /* 64 Hz time pulse */ |
| 152 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(64*2)); |
| 152 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(64*2)); |
| 153 | 153 | break; |
| 154 | 154 | |
| 155 | 155 | case UPD1990A_MODE_SHIFT: |
| 156 | 156 | if (LOG) logerror("UPD1990A Shift Mode\n"); |
| 157 | 157 | |
| 158 | 158 | /* enable time counter */ |
| 159 | | timer_enable(upd1990a->clock_timer, 1); |
| 159 | upd1990a->clock_timer->enable(1); |
| 160 | 160 | |
| 161 | 161 | /* disable data out pulse */ |
| 162 | | timer_enable(upd1990a->data_out_timer, 0); |
| 162 | upd1990a->data_out_timer->enable(0); |
| 163 | 163 | |
| 164 | 164 | /* output LSB of shift register */ |
| 165 | 165 | upd1990a->data_out = BIT(upd1990a->shift_reg[0], 0); |
| 166 | 166 | devcb_call_write_line(&upd1990a->out_data_func, upd1990a->data_out); |
| 167 | 167 | |
| 168 | 168 | /* 32 Hz time pulse */ |
| 169 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(32*2)); |
| 169 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(32*2)); |
| 170 | 170 | break; |
| 171 | 171 | |
| 172 | 172 | case UPD1990A_MODE_TIME_SET: |
| r10326 | r10327 | |
| 177 | 177 | if (LOG) logerror("UPD1990A Shift Register %02x%02x%02x%02x%02x\n", upd1990a->shift_reg[4], upd1990a->shift_reg[3], upd1990a->shift_reg[2], upd1990a->shift_reg[1], upd1990a->shift_reg[0]); |
| 178 | 178 | |
| 179 | 179 | /* disable time counter */ |
| 180 | | timer_enable(upd1990a->clock_timer, 0); |
| 180 | upd1990a->clock_timer->enable(0); |
| 181 | 181 | |
| 182 | 182 | /* disable data out pulse */ |
| 183 | | timer_enable(upd1990a->data_out_timer, 0); |
| 183 | upd1990a->data_out_timer->enable(0); |
| 184 | 184 | |
| 185 | 185 | /* output LSB of shift register */ |
| 186 | 186 | upd1990a->data_out = BIT(upd1990a->shift_reg[0], 0); |
| r10326 | r10327 | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /* 32 Hz time pulse */ |
| 196 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(32*2)); |
| 196 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(32*2)); |
| 197 | 197 | } |
| 198 | 198 | break; |
| 199 | 199 | |
| r10326 | r10327 | |
| 204 | 204 | if (LOG) logerror("UPD1990A Time Read Mode\n"); |
| 205 | 205 | |
| 206 | 206 | /* enable time counter */ |
| 207 | | timer_enable(upd1990a->clock_timer, 1); |
| 207 | upd1990a->clock_timer->enable(1); |
| 208 | 208 | |
| 209 | 209 | /* load time counter data into shift register */ |
| 210 | 210 | for (i = 0; i < 5; i++) |
| r10326 | r10327 | |
| 216 | 216 | |
| 217 | 217 | /* 512 Hz data out pulse */ |
| 218 | 218 | upd1990a->data_out = 1; |
| 219 | | timer_adjust_periodic(upd1990a->data_out_timer, attotime::zero, 0, attotime::from_hz(512*2)); |
| 219 | upd1990a->data_out_timer->adjust(attotime::zero, 0, attotime::from_hz(512*2)); |
| 220 | 220 | |
| 221 | 221 | /* 32 Hz time pulse */ |
| 222 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(32*2)); |
| 222 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(32*2)); |
| 223 | 223 | } |
| 224 | 224 | break; |
| 225 | 225 | |
| r10326 | r10327 | |
| 227 | 227 | if (LOG) logerror("UPD1990A TP = 64 Hz Set Mode\n"); |
| 228 | 228 | |
| 229 | 229 | /* 64 Hz time pulse */ |
| 230 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(64*2)); |
| 230 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(64*2)); |
| 231 | 231 | break; |
| 232 | 232 | |
| 233 | 233 | case UPD1990A_MODE_TP_256HZ_SET: |
| 234 | 234 | if (LOG) logerror("UPD1990A TP = 256 Hz Set Mode\n"); |
| 235 | 235 | |
| 236 | 236 | /* 256 Hz time pulse */ |
| 237 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(256*2)); |
| 237 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(256*2)); |
| 238 | 238 | break; |
| 239 | 239 | |
| 240 | 240 | case UPD1990A_MODE_TP_2048HZ_SET: |
| 241 | 241 | if (LOG) logerror("UPD1990A TP = 2048 Hz Set Mode\n"); |
| 242 | 242 | |
| 243 | 243 | /* 2048 Hz time pulse */ |
| 244 | | timer_adjust_periodic(upd1990a->tp_timer, attotime::zero, 0, attotime::from_hz(2048*2)); |
| 244 | upd1990a->tp_timer->adjust(attotime::zero, 0, attotime::from_hz(2048*2)); |
| 245 | 245 | break; |
| 246 | 246 | |
| 247 | 247 | case UPD1990A_MODE_TEST: |
| r10326 | r10327 | |
| 496 | 496 | |
| 497 | 497 | /* create the timers */ |
| 498 | 498 | upd1990a->clock_timer = device->machine->scheduler().timer_alloc(FUNC(clock_tick), (void *)device); |
| 499 | | timer_adjust_periodic(upd1990a->clock_timer, attotime::zero, 0, attotime::from_hz(1)); |
| 499 | upd1990a->clock_timer->adjust(attotime::zero, 0, attotime::from_hz(1)); |
| 500 | 500 | |
| 501 | 501 | upd1990a->tp_timer = device->machine->scheduler().timer_alloc(FUNC(tp_tick), (void *)device); |
| 502 | 502 | |
src/mess/machine/mac.c
| r10326 | r10327 | |
| 778 | 778 | if (mac->m_keyboard_reply == 0x7B) |
| 779 | 779 | { |
| 780 | 780 | /* if NULL, wait until key pressed or timeout */ |
| 781 | | timer_adjust_oneshot(mac->m_inquiry_timeout, |
| 781 | mac->m_inquiry_timeout->adjust( |
| 782 | 782 | attotime(0, DOUBLE_TO_ATTOSECONDS(0.25)), 0); |
| 783 | 783 | } |
| 784 | 784 | break; |
| r10326 | r10327 | |
| 1909 | 1909 | mac->m_adb_timer_ticks--; |
| 1910 | 1910 | if (!mac->m_adb_timer_ticks) |
| 1911 | 1911 | { |
| 1912 | | timer_adjust_oneshot(mac->adb_timer, attotime::never, 0); |
| 1912 | mac->adb_timer->adjust(attotime::never); |
| 1913 | 1913 | |
| 1914 | 1914 | if ((mac->m_adb_direction) && (ADB_IS_BITBANG)) |
| 1915 | 1915 | { |
| r10326 | r10327 | |
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | // mac->m_adb_timer_ticks = 8; |
| 1960 | | // timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1960 | // mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 1961 | 1961 | |
| 1962 | 1962 | if ((mac->m_adb_datasize == 0) && (mac->m_adb_streaming == MCU_STREAMING_NONE)) |
| 1963 | 1963 | { |
| r10326 | r10327 | |
| 1983 | 1983 | } |
| 1984 | 1984 | else |
| 1985 | 1985 | { |
| 1986 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 1986 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); |
| 1987 | 1987 | } |
| 1988 | 1988 | } |
| 1989 | 1989 | |
| r10326 | r10327 | |
| 2027 | 2027 | mac->m_adb_direction = 1; // Mac is shifting us a command |
| 2028 | 2028 | mac->m_adb_waiting_cmd = 1; // we're going to get a command |
| 2029 | 2029 | mac->m_adb_irq_pending = 0; |
| 2030 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2030 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2031 | 2031 | break; |
| 2032 | 2032 | |
| 2033 | 2033 | case ADB_STATE_XFER_EVEN: |
| r10326 | r10327 | |
| 2057 | 2057 | mac->m_adb_irq_pending = 1; |
| 2058 | 2058 | } |
| 2059 | 2059 | |
| 2060 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2060 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2061 | 2061 | break; |
| 2062 | 2062 | |
| 2063 | 2063 | case ADB_STATE_IDLE: |
| r10326 | r10327 | |
| 2076 | 2076 | mac->m_adb_state |= 1; |
| 2077 | 2077 | mac->m_adb_timer_ticks = 8; |
| 2078 | 2078 | mac->m_adb_datasize = 3; |
| 2079 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2079 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | 2082 | static void mac_egret_response_adb(mac_state *mac, int type, int flag, int cmd, int extra) |
| r10326 | r10327 | |
| 2089 | 2089 | mac->m_adb_state |= 1; |
| 2090 | 2090 | mac->m_adb_timer_ticks = 8; |
| 2091 | 2091 | mac->m_adb_datasize = 4; |
| 2092 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2092 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2093 | 2093 | } |
| 2094 | 2094 | |
| 2095 | 2095 | static void mac_egret_response_read_pram(mac_state *mac, int cmd, int addr) |
| r10326 | r10327 | |
| 2104 | 2104 | |
| 2105 | 2105 | mac->m_adb_state |= 1; |
| 2106 | 2106 | mac->m_adb_timer_ticks = 8; |
| 2107 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2107 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2108 | 2108 | |
| 2109 | 2109 | // read PRAM is a "streaming" command, don't drop the state line when we're out of data |
| 2110 | 2110 | mac->m_adb_streaming = MCU_STREAMING_PRAMRD; |
| r10326 | r10327 | |
| 2126 | 2126 | |
| 2127 | 2127 | mac->m_adb_state |= 1; |
| 2128 | 2128 | mac->m_adb_timer_ticks = 8; |
| 2129 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2129 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | 2132 | static void mac_egret_mcu_exec(mac_state *mac) |
| r10326 | r10327 | |
| 2229 | 2229 | mac->m_adb_buffer[1] = 0; // spare |
| 2230 | 2230 | mac->m_adb_state |= 1; |
| 2231 | 2231 | mac->m_adb_timer_ticks = 8; |
| 2232 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2232 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2233 | 2233 | break; |
| 2234 | 2234 | |
| 2235 | 2235 | case 0x0e: // send to DFAC |
| r10326 | r10327 | |
| 2299 | 2299 | { |
| 2300 | 2300 | mac->m_adb_command = 0; |
| 2301 | 2301 | mac->m_adb_timer_ticks = 8; |
| 2302 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2302 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2303 | 2303 | } |
| 2304 | 2304 | |
| 2305 | 2305 | // if bit 2 is high and stays high, the falling edge of bit 1, and we're in send phase, the MCU should clock out a byte |
| 2306 | 2306 | if ((state & 0x04) && (mac->m_adb_state & 0x04) && !(state & 0x02) && (mac->m_adb_state & 0x02) && (mac->m_adb_state & 0x01)) |
| 2307 | 2307 | { |
| 2308 | 2308 | mac->m_adb_timer_ticks = 8; |
| 2309 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2309 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | // if bit 2 rises, bit 1 is 0, and MCU XS is high, the MCU should clock out a byte |
| 2313 | 2313 | if ((state & 0x04) && !(mac->m_adb_state & 0x04) && !(state & 0x02) && (mac->m_adb_state & 0x01)) |
| 2314 | 2314 | { |
| 2315 | 2315 | mac->m_adb_timer_ticks = 8; |
| 2316 | | timer_adjust_oneshot(mac->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2316 | mac->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | // if bit 2 drops and bit 1 is 1, terminate the command |
| r10326 | r10327 | |
| 2424 | 2424 | mac->m_pm_out[0] = 1; // length |
| 2425 | 2425 | mac->m_pm_out[1] = result; |
| 2426 | 2426 | mac->m_pm_slen = 2; |
| 2427 | | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2427 | mac->m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); |
| 2428 | 2428 | } |
| 2429 | 2429 | |
| 2430 | 2430 | static void pmu_exec(mac_state *mac) |
| r10326 | r10327 | |
| 2460 | 2460 | mac->m_pm_out[1 + i] = mac->m_rtc_ram[i]; |
| 2461 | 2461 | } |
| 2462 | 2462 | mac->m_pm_slen = 21; |
| 2463 | | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2463 | mac->m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); |
| 2464 | 2464 | } |
| 2465 | 2465 | break; |
| 2466 | 2466 | |
| r10326 | r10327 | |
| 2475 | 2475 | mac->m_pm_out[1 + i] = mac->m_rtc_ram[mac->m_pm_cmd[2] + i]; |
| 2476 | 2476 | } |
| 2477 | 2477 | mac->m_pm_slen = mac->m_pm_cmd[3] + 1; |
| 2478 | | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2478 | mac->m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(200))); |
| 2479 | 2479 | } |
| 2480 | 2480 | break; |
| 2481 | 2481 | |
| r10326 | r10327 | |
| 2517 | 2517 | this->adb_talk(); |
| 2518 | 2518 | |
| 2519 | 2519 | m_adb_timer_ticks = 8; |
| 2520 | | timer_adjust_oneshot(this->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2520 | this->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2521 | 2521 | } |
| 2522 | 2522 | else |
| 2523 | 2523 | { |
| 2524 | 2524 | m_adb_irq_pending = 1; |
| 2525 | 2525 | m_adb_command = m_adb_send = 0; |
| 2526 | 2526 | m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2527 | | timer_adjust_oneshot(this->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2527 | this->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2528 | 2528 | m_adb_srq_switch = 1; |
| 2529 | 2529 | } |
| 2530 | 2530 | } |
| r10326 | r10327 | |
| 2537 | 2537 | this->adb_talk(); |
| 2538 | 2538 | |
| 2539 | 2539 | m_adb_timer_ticks = 8; |
| 2540 | | timer_adjust_oneshot(this->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2540 | this->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2541 | 2541 | } |
| 2542 | 2542 | else |
| 2543 | 2543 | { |
| 2544 | 2544 | m_adb_irq_pending = 1; |
| 2545 | 2545 | m_adb_command = m_adb_send = 0; |
| 2546 | 2546 | m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2547 | | timer_adjust_oneshot(this->adb_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2547 | this->adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2548 | 2548 | m_adb_srq_switch = 1; |
| 2549 | 2549 | } |
| 2550 | 2550 | } |
| r10326 | r10327 | |
| 2839 | 2839 | // another byte to send? |
| 2840 | 2840 | if (mac->m_pm_slen) |
| 2841 | 2841 | { |
| 2842 | | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2842 | mac->m_pmu_send_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); |
| 2843 | 2843 | } |
| 2844 | 2844 | else |
| 2845 | 2845 | { |
| 2846 | 2846 | mac->m_pm_state = 0; // back to receive state |
| 2847 | | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime::never, 0); |
| 2847 | mac->m_pmu_send_timer->adjust(attotime::never); |
| 2848 | 2848 | } |
| 2849 | 2849 | } |
| 2850 | 2850 | } |
| r10326 | r10327 | |
| 3032 | 3032 | if (has_adb()) |
| 3033 | 3033 | { |
| 3034 | 3034 | this->adb_timer = machine->scheduler().timer_alloc(FUNC(mac_adb_tick)); |
| 3035 | | timer_adjust_oneshot(this->adb_timer, attotime::never, 0); |
| 3035 | this->adb_timer->adjust(attotime::never); |
| 3036 | 3036 | |
| 3037 | 3037 | // also allocate PMU timer |
| 3038 | 3038 | if (ADB_IS_PM_CLASS) |
| 3039 | 3039 | { |
| 3040 | 3040 | m_pmu_send_timer = machine->scheduler().timer_alloc(FUNC(mac_pmu_tick)); |
| 3041 | | timer_adjust_oneshot(this->adb_timer, attotime::never, 0); |
| 3041 | this->adb_timer->adjust(attotime::never); |
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | 3044 | } |
| 3045 | 3045 | this->scanline_timer = machine->scheduler().timer_alloc(FUNC(mac_scanline_tick)); |
| 3046 | | timer_adjust_oneshot(this->scanline_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 3046 | this->scanline_timer->adjust(machine->primary_screen->time_until_pos(0, 0)); |
| 3047 | 3047 | |
| 3048 | 3048 | m_6015_timer = machine->scheduler().timer_alloc(FUNC(mac_6015_tick)); |
| 3049 | | timer_adjust_oneshot(m_6015_timer, attotime::never, 0); |
| 3049 | m_6015_timer->adjust(attotime::never); |
| 3050 | 3050 | } |
| 3051 | 3051 | |
| 3052 | 3052 | void mac_state::machine_reset() |
| 3053 | 3053 | { |
| 3054 | 3054 | // stop 60.15 Hz timer |
| 3055 | | timer_adjust_oneshot(m_6015_timer, attotime::never, 0); |
| 3055 | m_6015_timer->adjust(attotime::never); |
| 3056 | 3056 | |
| 3057 | 3057 | // start 60.15 Hz timer for most systems |
| 3058 | 3058 | if (((m_model >= MODEL_MAC_IICI) && (m_model <= MODEL_MAC_IIVI)) || (m_model >= MODEL_MAC_LC)) |
| 3059 | 3059 | { |
| 3060 | | timer_adjust_periodic(m_6015_timer, attotime::from_hz(60.15), 0, attotime::from_hz(60.15)); |
| 3060 | m_6015_timer->adjust(attotime::from_hz(60.15), 0, attotime::from_hz(60.15)); |
| 3061 | 3061 | } |
| 3062 | 3062 | |
| 3063 | 3063 | // clear PMU response timer |
| 3064 | 3064 | if (ADB_IS_PM_CLASS) |
| 3065 | 3065 | { |
| 3066 | | timer_adjust_oneshot(this->adb_timer, attotime::never, 0); |
| 3066 | this->adb_timer->adjust(attotime::never); |
| 3067 | 3067 | } |
| 3068 | 3068 | |
| 3069 | 3069 | // default to 32-bit mode on LC |
| r10326 | r10327 | |
| 3342 | 3342 | |
| 3343 | 3343 | logerror("keyboard enquiry successful, keycode %X\n", keycode); |
| 3344 | 3344 | |
| 3345 | | timer_reset(m_inquiry_timeout, attotime::never); |
| 3345 | m_inquiry_timeout->reset(); |
| 3346 | 3346 | kbd_shift_out(machine, keycode); |
| 3347 | 3347 | } |
| 3348 | 3348 | } |
| r10326 | r10327 | |
| 3400 | 3400 | mac->mouse_callback(); |
| 3401 | 3401 | } |
| 3402 | 3402 | |
| 3403 | | timer_adjust_oneshot(mac->scanline_timer, machine->primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0), 0); |
| 3403 | mac->scanline_timer->adjust(machine->primary_screen->time_until_pos((scanline+1) % MAC_V_TOTAL, 0)); |
| 3404 | 3404 | } |
| 3405 | 3405 | |
| 3406 | 3406 | |
src/mess/machine/mc68328.c
| r10326 | r10327 | |
| 23 | 23 | va_start( v, s_fmt ); |
| 24 | 24 | vsprintf( buf, s_fmt, v ); |
| 25 | 25 | va_end( v ); |
| 26 | | logerror( "%s: %s", cpuexec_describe_context(machine), buf ); |
| 26 | logerror( "%s: %s", machine->describe_context(), buf ); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| r10326 | r10327 | |
| 191 | 191 | { |
| 192 | 192 | if((mc68328->regs.tctl[index] & TCTL_CLKSOURCE) == TCTL_CLKSOURCE_TIN) |
| 193 | 193 | { |
| 194 | | timer_adjust_oneshot(mc68328->gptimer[index], attotime::never, 0); |
| 194 | mc68328->gptimer[index]->adjust(attotime::never); |
| 195 | 195 | } |
| 196 | 196 | else if(mc68328->regs.tcmp[index] == 0) |
| 197 | 197 | { |
| 198 | | timer_adjust_oneshot(mc68328->gptimer[index], attotime::never, 0); |
| 198 | mc68328->gptimer[index]->adjust(attotime::never); |
| 199 | 199 | } |
| 200 | 200 | else |
| 201 | 201 | { |
| r10326 | r10327 | |
| 207 | 207 | mc68328->regs.tcn[index] = 0x0000; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | | timer_adjust_oneshot(mc68328->gptimer[index], period, 0); |
| 210 | mc68328->gptimer[index]->adjust(period); |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | else |
| 214 | 214 | { |
| 215 | | timer_adjust_oneshot(mc68328->gptimer[index], attotime::never, 0); |
| 215 | mc68328->gptimer[index]->adjust(attotime::never); |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| r10326 | r10327 | |
| 233 | 233 | |
| 234 | 234 | mc68328->regs.tcn[index] = 0x0000; |
| 235 | 235 | |
| 236 | | timer_adjust_oneshot(mc68328->gptimer[index], period, 0); |
| 236 | mc68328->gptimer[index]->adjust(period); |
| 237 | 237 | } |
| 238 | 238 | else |
| 239 | 239 | { |
| 240 | | timer_adjust_oneshot(mc68328->gptimer[index], attotime::never, 0); |
| 240 | mc68328->gptimer[index]->adjust(attotime::never); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | else |
| r10326 | r10327 | |
| 248 | 248 | { |
| 249 | 249 | attotime period = attotime::from_hz(frequency) * 0x10000; |
| 250 | 250 | |
| 251 | | timer_adjust_oneshot(mc68328->gptimer[index], period, 0); |
| 251 | mc68328->gptimer[index]->adjust(period); |
| 252 | 252 | } |
| 253 | 253 | else |
| 254 | 254 | { |
| 255 | | timer_adjust_oneshot(mc68328->gptimer[index], attotime::never, 0); |
| 255 | mc68328->gptimer[index]->adjust(attotime::never); |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | if((mc68328->regs.tctl[index] & TCTL_IRQEN) == TCTL_IRQEN_ENABLE) |
| r10326 | r10327 | |
| 282 | 282 | |
| 283 | 283 | if(mc68328->regs.pwmw >= mc68328->regs.pwmp || mc68328->regs.pwmw == 0 || mc68328->regs.pwmp == 0) |
| 284 | 284 | { |
| 285 | | timer_adjust_oneshot(mc68328->pwm, attotime::never, 0); |
| 285 | mc68328->pwm->adjust(attotime::never); |
| 286 | 286 | return; |
| 287 | 287 | } |
| 288 | 288 | |
| r10326 | r10327 | |
| 296 | 296 | frequency /= divisor; |
| 297 | 297 | period = attotime::from_hz(frequency) * (mc68328->regs.pwmp - mc68328->regs.pwmw); |
| 298 | 298 | |
| 299 | | timer_adjust_oneshot(mc68328->pwm, period, 0); |
| 299 | mc68328->pwm->adjust(period); |
| 300 | 300 | |
| 301 | 301 | if(mc68328->regs.pwmc & PWMC_IRQEN) |
| 302 | 302 | { |
| r10326 | r10327 | |
| 312 | 312 | frequency /= divisor; |
| 313 | 313 | period = attotime::from_hz(frequency) * mc68328->regs.pwmw; |
| 314 | 314 | |
| 315 | | timer_adjust_oneshot(mc68328->pwm, period, 0); |
| 315 | mc68328->pwm->adjust(period); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | mc68328->regs.pwmc ^= PWMC_PIN; |
| r10326 | r10327 | |
| 1114 | 1114 | attotime period; |
| 1115 | 1115 | frequency /= divisor; |
| 1116 | 1116 | period = attotime::from_hz(frequency) * mc68328->regs.pwmw; |
| 1117 | | timer_adjust_oneshot(mc68328->pwm, period, 0); |
| 1117 | mc68328->pwm->adjust(period); |
| 1118 | 1118 | if(mc68328->regs.pwmc & PWMC_IRQEN) |
| 1119 | 1119 | { |
| 1120 | 1120 | mc68328_set_interrupt_line(device, INT_PWM, 1); |
| r10326 | r10327 | |
| 1123 | 1123 | } |
| 1124 | 1124 | else |
| 1125 | 1125 | { |
| 1126 | | timer_adjust_oneshot(mc68328->pwm, attotime::never, 0); |
| 1126 | mc68328->pwm->adjust(attotime::never); |
| 1127 | 1127 | } |
| 1128 | 1128 | break; |
| 1129 | 1129 | |
| r10326 | r10327 | |
| 2651 | 2651 | mc68328->regs.rtcienr = 0x00; |
| 2652 | 2652 | mc68328->regs.stpwtch = 0x00; |
| 2653 | 2653 | |
| 2654 | | timer_adjust_periodic(mc68328->rtc, attotime::from_hz(1), 0, attotime::from_hz(1)); |
| 2654 | mc68328->rtc->adjust(attotime::from_hz(1), 0, attotime::from_hz(1)); |
| 2655 | 2655 | } |
| 2656 | 2656 | |
| 2657 | 2657 | static void mc68328_register_state_save(device_t *device) |
src/mess/machine/rmnimbus.c
| r10326 | r10327 | |
| 349 | 349 | if (!state->i186.intr.pending) |
| 350 | 350 | cputag_set_input_line(machine, MAINCPU_TAG, 0, ASSERT_LINE); |
| 351 | 351 | state->i186.intr.pending = 1; |
| 352 | | cpuexec_trigger(machine, CPU_RESUME_TRIGGER); |
| 352 | machine->scheduler().trigger(CPU_RESUME_TRIGGER); |
| 353 | 353 | if (LOG_OPTIMIZATION) logerror(" - trigger due to interrupt pending\n"); |
| 354 | 354 | if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", machine->time().as_double(), new_vector); |
| 355 | 355 | } |
| r10326 | r10327 | |
| 483 | 483 | if (t->control & 0x0001) |
| 484 | 484 | { |
| 485 | 485 | int count = t->maxA ? t->maxA : 0x10000; |
| 486 | | timer_adjust_oneshot(t->int_timer, (attotime::from_hz(2000000) * count), which); |
| 486 | t->int_timer->adjust((attotime::from_hz(2000000) * count), which); |
| 487 | 487 | if (LOG_TIMER) logerror(" Repriming interrupt\n"); |
| 488 | 488 | } |
| 489 | 489 | else |
| 490 | | timer_adjust_oneshot(t->int_timer, attotime::never, which); |
| 490 | t->int_timer->adjust(attotime::never, which); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | |
| r10326 | r10327 | |
| 499 | 499 | /* if we have a timing timer running, adjust the count */ |
| 500 | 500 | if (t->time_timer_active) |
| 501 | 501 | { |
| 502 | | attotime current_time = timer_timeelapsed(t->time_timer); |
| 502 | attotime current_time = t->time_timer->elapsed(); |
| 503 | 503 | int net_clocks = ((current_time - t->last_time) * 2000000).seconds; |
| 504 | 504 | t->last_time = current_time; |
| 505 | 505 | |
| r10326 | r10327 | |
| 604 | 604 | internal_timer_sync(machine, which); |
| 605 | 605 | |
| 606 | 606 | /* nuke the timer and force the interrupt timer to be recomputed */ |
| 607 | | timer_adjust_oneshot(t->time_timer, attotime::never, which); |
| 607 | t->time_timer->adjust(attotime::never, which); |
| 608 | 608 | t->time_timer_active = 0; |
| 609 | 609 | update_int_timer = 1; |
| 610 | 610 | } |
| r10326 | r10327 | |
| 613 | 613 | else if ((diff & 0x8000) && (new_control & 0x8000)) |
| 614 | 614 | { |
| 615 | 615 | /* start the timing */ |
| 616 | | timer_adjust_oneshot(t->time_timer, attotime::never, which); |
| 616 | t->time_timer->adjust(attotime::never, which); |
| 617 | 617 | t->time_timer_active = 1; |
| 618 | 618 | update_int_timer = 1; |
| 619 | 619 | } |
| r10326 | r10327 | |
| 638 | 638 | int diff = t->maxA - t->count; |
| 639 | 639 | if (diff <= 0) |
| 640 | 640 | diff += 0x10000; |
| 641 | | timer_adjust_oneshot(t->int_timer, attotime::from_hz(2000000) * diff, which); |
| 641 | t->int_timer->adjust(attotime::from_hz(2000000) * diff, which); |
| 642 | 642 | if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which); |
| 643 | 643 | } |
| 644 | 644 | else |
| 645 | 645 | { |
| 646 | | timer_adjust_oneshot(t->int_timer, attotime::never, which); |
| 646 | t->int_timer->adjust(attotime::never, which); |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | } |
| r10326 | r10327 | |
| 2125 | 2125 | memset(state->keyboard.keyrows,0xFF,NIMBUS_KEYROWS); |
| 2126 | 2126 | |
| 2127 | 2127 | // Setup timer to scan state->keyboard. |
| 2128 | | timer_adjust_periodic(state->keyboard.keyscan_timer, attotime::zero, 0, attotime::from_hz(50)); |
| 2128 | state->keyboard.keyscan_timer->adjust(attotime::zero, 0, attotime::from_hz(50)); |
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | static void queue_scancode(running_machine *machine, UINT8 scancode) |
| r10326 | r10327 | |
| 2844 | 2844 | state->reg0a4=0xC0; |
| 2845 | 2845 | |
| 2846 | 2846 | // Setup timer to poll the mouse |
| 2847 | | timer_adjust_periodic(state->mouse_timer, attotime::zero, 0, attotime::from_hz(1000)); |
| 2847 | state->mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000)); |
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | static TIMER_CALLBACK(mouse_callback) |
src/mess/machine/tf20.c
| r10326 | r10327 | |
| 83 | 83 | |
| 84 | 84 | static READ8_HANDLER( tf20_dip_r ) |
| 85 | 85 | { |
| 86 | | logerror("%s: tf20_dip_r\n", cpuexec_describe_context(space->machine)); |
| 86 | logerror("%s: tf20_dip_r\n", space->machine->describe_context()); |
| 87 | 87 | |
| 88 | 88 | return input_port_read(space->machine, "tf20_dip"); |
| 89 | 89 | } |
| r10326 | r10327 | |
| 95 | 95 | |
| 96 | 96 | static READ8_DEVICE_HANDLER( tf20_upd765_tc_r ) |
| 97 | 97 | { |
| 98 | | logerror("%s: tf20_upd765_tc_r\n", cpuexec_describe_context(device->machine)); |
| 98 | logerror("%s: tf20_upd765_tc_r\n", device->machine->describe_context()); |
| 99 | 99 | |
| 100 | 100 | /* toggle tc on read */ |
| 101 | 101 | upd765_tc_w(device, ASSERT_LINE); |
| r10326 | r10327 | |
| 107 | 107 | static WRITE8_HANDLER( tf20_fdc_control_w ) |
| 108 | 108 | { |
| 109 | 109 | tf20_state *tf20 = get_safe_token(space->cpu->owner()); |
| 110 | | logerror("%s: tf20_fdc_control_w %02x\n", cpuexec_describe_context(space->machine), data); |
| 110 | logerror("%s: tf20_fdc_control_w %02x\n", space->machine->describe_context(), data); |
| 111 | 111 | |
| 112 | 112 | /* bit 0, motor on signal */ |
| 113 | 113 | floppy_mon_w(tf20->floppy_0, !BIT(data, 0)); |
| r10326 | r10327 | |
| 128 | 128 | READ_LINE_DEVICE_HANDLER( tf20_rxs_r ) |
| 129 | 129 | { |
| 130 | 130 | tf20_state *tf20 = get_safe_token(device); |
| 131 | | logerror("%s: tf20_rxs_r\n", cpuexec_describe_context(device->machine)); |
| 131 | logerror("%s: tf20_rxs_r\n", device->machine->describe_context()); |
| 132 | 132 | |
| 133 | 133 | return upd7201_txda_r(tf20->upd7201); |
| 134 | 134 | } |
| r10326 | r10327 | |
| 136 | 136 | READ_LINE_DEVICE_HANDLER( tf20_pins_r ) |
| 137 | 137 | { |
| 138 | 138 | tf20_state *tf20 = get_safe_token(device); |
| 139 | | logerror("%s: tf20_pins_r\n", cpuexec_describe_context(device->machine)); |
| 139 | logerror("%s: tf20_pins_r\n", device->machine->describe_context()); |
| 140 | 140 | |
| 141 | 141 | return upd7201_dtra_r(tf20->upd7201); |
| 142 | 142 | } |
| r10326 | r10327 | |
| 145 | 145 | WRITE_LINE_DEVICE_HANDLER( tf20_txs_w ) |
| 146 | 146 | { |
| 147 | 147 | tf20_state *tf20 = get_safe_token(device); |
| 148 | | logerror("%s: tf20_txs_w %u\n", cpuexec_describe_context(device->machine), state); |
| 148 | logerror("%s: tf20_txs_w %u\n", device->machine->describe_context(), state); |
| 149 | 149 | |
| 150 | 150 | upd7201_rxda_w(tf20->upd7201, state); |
| 151 | 151 | } |
| r10326 | r10327 | |
| 153 | 153 | WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w ) |
| 154 | 154 | { |
| 155 | 155 | tf20_state *tf20 = get_safe_token(device); |
| 156 | | logerror("%s: tf20_pouts_w %u\n", cpuexec_describe_context(device->machine), state); |
| 156 | logerror("%s: tf20_pouts_w %u\n", device->machine->describe_context(), state); |
| 157 | 157 | |
| 158 | 158 | upd7201_ctsa_w(tf20->upd7201, state); |
| 159 | 159 | } |
| r10326 | r10327 | |
| 163 | 163 | WRITE_LINE_DEVICE_HANDLER( tf20_txc_w ) |
| 164 | 164 | { |
| 165 | 165 | tf20_state *tf20 = get_safe_token(device); |
| 166 | | logerror("%s: tf20_txc_w %u\n", cpuexec_describe_context(device->machine), state); |
| 166 | logerror("%s: tf20_txc_w %u\n", device->machine->describe_context(), state); |
| 167 | 167 | |
| 168 | 168 | upd7201_rxda_w(tf20->upd7201, state); |
| 169 | 169 | } |
| r10326 | r10327 | |
| 172 | 172 | READ_LINE_DEVICE_HANDLER( tf20_rxc_r ) |
| 173 | 173 | { |
| 174 | 174 | tf20_state *tf20 = get_safe_token(device); |
| 175 | | logerror("%s: tf20_rxc_r\n", cpuexec_describe_context(device->machine)); |
| 175 | logerror("%s: tf20_rxc_r\n", device->machine->describe_context()); |
| 176 | 176 | |
| 177 | 177 | return upd7201_txda_r(tf20->upd7201); |
| 178 | 178 | } |
| r10326 | r10327 | |
| 180 | 180 | WRITE_LINE_DEVICE_HANDLER( tf20_poutc_w ) |
| 181 | 181 | { |
| 182 | 182 | tf20_state *tf20 = get_safe_token(device); |
| 183 | | logerror("%s: tf20_poutc_w %u\n", cpuexec_describe_context(device->machine), state); |
| 183 | logerror("%s: tf20_poutc_w %u\n", device->machine->describe_context(), state); |
| 184 | 184 | |
| 185 | 185 | upd7201_ctsa_w(tf20->upd7201, state); |
| 186 | 186 | } |
| r10326 | r10327 | |
| 188 | 188 | READ_LINE_DEVICE_HANDLER( tf20_pinc_r ) |
| 189 | 189 | { |
| 190 | 190 | tf20_state *tf20 = get_safe_token(device); |
| 191 | | logerror("%s: tf20_pinc_r\n", cpuexec_describe_context(device->machine)); |
| 191 | logerror("%s: tf20_pinc_r\n", device->machine->describe_context()); |
| 192 | 192 | |
| 193 | 193 | return upd7201_dtra_r(tf20->upd7201); |
| 194 | 194 | } |
src/mess/machine/pce.c
| r10326 | r10327 | |
| 607 | 607 | } |
| 608 | 608 | else |
| 609 | 609 | { |
| 610 | | timer_adjust_periodic(pce_cd.data_timer, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND ), 0, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND )); |
| 610 | pce_cd.data_timer->adjust(attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND ), 0, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND )); |
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | |
| r10326 | r10327 | |
| 1048 | 1048 | pce_cd.selected = 0; |
| 1049 | 1049 | pce_cd.cdda_status = PCE_CD_CDDA_OFF; |
| 1050 | 1050 | cdda_stop_audio( machine->device( "cdda" ) ); |
| 1051 | | timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime::never, 0); // stop ADPCM DMA here |
| 1051 | pce_cd.adpcm_dma_timer->adjust(attotime::never); // stop ADPCM DMA here |
| 1052 | 1052 | } |
| 1053 | 1053 | pce_cd.scsi_last_RST = pce_cd.scsi_RST; |
| 1054 | 1054 | } |
| r10326 | r10327 | |
| 1210 | 1210 | /* We are done, disable the timer */ |
| 1211 | 1211 | logerror("Last frame read from CD\n"); |
| 1212 | 1212 | pce_cd.data_transferred = 1; |
| 1213 | | timer_adjust_oneshot(pce_cd.data_timer, attotime::never, 0); |
| 1213 | pce_cd.data_timer->adjust(attotime::never); |
| 1214 | 1214 | } |
| 1215 | 1215 | else |
| 1216 | 1216 | { |
| r10326 | r10327 | |
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | pce_cd.data_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_data_timer_callback)); |
| 1273 | | timer_adjust_oneshot(pce_cd.data_timer, attotime::never, 0); |
| 1273 | pce_cd.data_timer->adjust(attotime::never); |
| 1274 | 1274 | pce_cd.adpcm_dma_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_adpcm_dma_timer_callback)); |
| 1275 | | timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime::never, 0); |
| 1275 | pce_cd.adpcm_dma_timer->adjust(attotime::never); |
| 1276 | 1276 | |
| 1277 | 1277 | pce_cd.cdda_fadeout_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_cdda_fadeout_callback)); |
| 1278 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::never, 0); |
| 1278 | pce_cd.cdda_fadeout_timer->adjust(attotime::never); |
| 1279 | 1279 | pce_cd.cdda_fadein_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_cdda_fadein_callback)); |
| 1280 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1280 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1281 | 1281 | |
| 1282 | 1282 | pce_cd.adpcm_fadeout_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadeout_callback)); |
| 1283 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::never, 0); |
| 1283 | pce_cd.adpcm_fadeout_timer->adjust(attotime::never); |
| 1284 | 1284 | pce_cd.adpcm_fadein_timer = machine->scheduler().timer_alloc(FUNC(pce_cd_adpcm_fadein_callback)); |
| 1285 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::never, 0); |
| 1285 | pce_cd.adpcm_fadein_timer->adjust(attotime::never); |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | WRITE8_HANDLER( pce_cd_bram_w ) |
| r10326 | r10327 | |
| 1315 | 1315 | { |
| 1316 | 1316 | pce_cd.cdda_volume = 0.0; |
| 1317 | 1317 | cdda_set_volume(machine->device("cdda"), 0.0); |
| 1318 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::never, 0); |
| 1318 | pce_cd.cdda_fadeout_timer->adjust(attotime::never); |
| 1319 | 1319 | } |
| 1320 | 1320 | else |
| 1321 | 1321 | { |
| 1322 | 1322 | cdda_set_volume(machine->device("cdda"), pce_cd.cdda_volume); |
| 1323 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::from_usec(param), param); |
| 1323 | pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(param), param); |
| 1324 | 1324 | } |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| r10326 | r10327 | |
| 1332 | 1332 | { |
| 1333 | 1333 | pce_cd.cdda_volume = 100.0; |
| 1334 | 1334 | cdda_set_volume(machine->device("cdda"), 100.0); |
| 1335 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1335 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1336 | 1336 | } |
| 1337 | 1337 | else |
| 1338 | 1338 | { |
| 1339 | 1339 | cdda_set_volume(machine->device("cdda"), pce_cd.cdda_volume); |
| 1340 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::from_usec(param), param); |
| 1340 | pce_cd.cdda_fadein_timer->adjust(attotime::from_usec(param), param); |
| 1341 | 1341 | } |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| r10326 | r10327 | |
| 1349 | 1349 | { |
| 1350 | 1350 | pce_cd.adpcm_volume = 0.0; |
| 1351 | 1351 | msm5205_set_volume(machine->device("msm5205"), 0.0); |
| 1352 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::never, 0); |
| 1352 | pce_cd.adpcm_fadeout_timer->adjust(attotime::never); |
| 1353 | 1353 | } |
| 1354 | 1354 | else |
| 1355 | 1355 | { |
| 1356 | 1356 | msm5205_set_volume(machine->device("msm5205"), pce_cd.adpcm_volume); |
| 1357 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::from_usec(param), param); |
| 1357 | pce_cd.adpcm_fadeout_timer->adjust(attotime::from_usec(param), param); |
| 1358 | 1358 | } |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| r10326 | r10327 | |
| 1366 | 1366 | { |
| 1367 | 1367 | pce_cd.adpcm_volume = 100.0; |
| 1368 | 1368 | msm5205_set_volume(machine->device("msm5205"), 100.0); |
| 1369 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::never, 0); |
| 1369 | pce_cd.adpcm_fadein_timer->adjust(attotime::never); |
| 1370 | 1370 | } |
| 1371 | 1371 | else |
| 1372 | 1372 | { |
| 1373 | 1373 | msm5205_set_volume(machine->device("msm5205"), pce_cd.adpcm_volume); |
| 1374 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::from_usec(param), param); |
| 1374 | pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(param), param); |
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| r10326 | r10327 | |
| 1392 | 1392 | pce_cd.scsi_SEL = 1; |
| 1393 | 1393 | pce_cd_update(space->machine); |
| 1394 | 1394 | pce_cd.scsi_SEL = 0; |
| 1395 | | timer_adjust_oneshot(pce_cd.adpcm_dma_timer, attotime::never, 0); // stop ADPCM DMA here |
| 1395 | pce_cd.adpcm_dma_timer->adjust(attotime::never); // stop ADPCM DMA here |
| 1396 | 1396 | /* any write here clears CD transfer irqs */ |
| 1397 | 1397 | pce_cd.regs[0x03] &= ~0x70; |
| 1398 | 1398 | cputag_set_input_line(space->machine, "maincpu", 1, CLEAR_LINE ); |
| r10326 | r10327 | |
| 1435 | 1435 | if ( data & 0x03 ) |
| 1436 | 1436 | { |
| 1437 | 1437 | /* Start CD to ADPCM transfer */ |
| 1438 | | timer_adjust_periodic(pce_cd.adpcm_dma_timer, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ), 0, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ) ); |
| 1438 | pce_cd.adpcm_dma_timer->adjust(attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ), 0, attotime::from_hz( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ) ); |
| 1439 | 1439 | pce_cd.regs[0x0c] |= 4; |
| 1440 | 1440 | } |
| 1441 | 1441 | break; |
| r10326 | r10327 | |
| 1502 | 1502 | { |
| 1503 | 1503 | case 0x00: //CD-DA / ADPCM enable (100 msecs) |
| 1504 | 1504 | pce_cd.cdda_volume = 0.0; |
| 1505 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::from_usec(100), 100); |
| 1505 | pce_cd.cdda_fadein_timer->adjust(attotime::from_usec(100), 100); |
| 1506 | 1506 | pce_cd.adpcm_volume = 0.0; |
| 1507 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::from_usec(100), 100); |
| 1508 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::never, 0); |
| 1509 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::never, 0); |
| 1507 | pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(100), 100); |
| 1508 | pce_cd.cdda_fadeout_timer->adjust(attotime::never); |
| 1509 | pce_cd.adpcm_fadeout_timer->adjust(attotime::never); |
| 1510 | 1510 | break; |
| 1511 | 1511 | case 0x01: //CD-DA enable (100 msecs) |
| 1512 | 1512 | pce_cd.cdda_volume = 0.0; |
| 1513 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::from_usec(100), 100); |
| 1514 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::never, 0); |
| 1513 | pce_cd.cdda_fadein_timer->adjust(attotime::from_usec(100), 100); |
| 1514 | pce_cd.cdda_fadeout_timer->adjust(attotime::never); |
| 1515 | 1515 | break; |
| 1516 | 1516 | case 0x08: //CD-DA short (1500 msecs) fade out / ADPCM enable |
| 1517 | 1517 | pce_cd.cdda_volume = 100.0; |
| 1518 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::from_usec(1500), 1500); |
| 1518 | pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(1500), 1500); |
| 1519 | 1519 | pce_cd.adpcm_volume = 0.0; |
| 1520 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::from_usec(100), 100); |
| 1521 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1522 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::never, 0); |
| 1520 | pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(100), 100); |
| 1521 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1522 | pce_cd.adpcm_fadeout_timer->adjust(attotime::never); |
| 1523 | 1523 | break; |
| 1524 | 1524 | case 0x09: //CD-DA long (5000 msecs) fade out |
| 1525 | 1525 | pce_cd.cdda_volume = 100.0; |
| 1526 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::from_usec(5000), 5000); |
| 1527 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1526 | pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(5000), 5000); |
| 1527 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1528 | 1528 | break; |
| 1529 | 1529 | case 0x0a: //ADPCM long (5000 msecs) fade out |
| 1530 | 1530 | pce_cd.adpcm_volume = 100.0; |
| 1531 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::from_usec(5000), 5000); |
| 1532 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::never, 0); |
| 1531 | pce_cd.adpcm_fadeout_timer->adjust(attotime::from_usec(5000), 5000); |
| 1532 | pce_cd.adpcm_fadein_timer->adjust(attotime::never); |
| 1533 | 1533 | break; |
| 1534 | 1534 | case 0x0c: //CD-DA short (1500 msecs) fade out / ADPCM enable |
| 1535 | 1535 | pce_cd.cdda_volume = 100.0; |
| 1536 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::from_usec(1500), 1500); |
| 1536 | pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(1500), 1500); |
| 1537 | 1537 | pce_cd.adpcm_volume = 0.0; |
| 1538 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::from_usec(100), 100); |
| 1539 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1540 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::never, 0); |
| 1538 | pce_cd.adpcm_fadein_timer->adjust(attotime::from_usec(100), 100); |
| 1539 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1540 | pce_cd.adpcm_fadeout_timer->adjust(attotime::never); |
| 1541 | 1541 | break; |
| 1542 | 1542 | case 0x0d: //CD-DA short (1500 msecs) fade out |
| 1543 | 1543 | pce_cd.cdda_volume = 100.0; |
| 1544 | | timer_adjust_oneshot(pce_cd.cdda_fadeout_timer, attotime::from_usec(1500), 1500); |
| 1545 | | timer_adjust_oneshot(pce_cd.cdda_fadein_timer, attotime::never, 0); |
| 1544 | pce_cd.cdda_fadeout_timer->adjust(attotime::from_usec(1500), 1500); |
| 1545 | pce_cd.cdda_fadein_timer->adjust(attotime::never); |
| 1546 | 1546 | break; |
| 1547 | 1547 | case 0x0e: //ADPCM short (1500 msecs) fade out |
| 1548 | 1548 | pce_cd.adpcm_volume = 100.0; |
| 1549 | | timer_adjust_oneshot(pce_cd.adpcm_fadeout_timer, attotime::from_usec(1500), 1500); |
| 1550 | | timer_adjust_oneshot(pce_cd.adpcm_fadein_timer, attotime::never, 0); |
| 1549 | pce_cd.adpcm_fadeout_timer->adjust(attotime::from_usec(1500), 1500); |
| 1550 | pce_cd.adpcm_fadein_timer->adjust(attotime::never); |
| 1551 | 1551 | break; |
| 1552 | 1552 | default: |
| 1553 | 1553 | popmessage("CD-DA / ADPCM Fade effect mode %02x, contact MESSdev",data & 0x0f); |
src/mess/video/coco6847.c
| r10326 | r10327 | |
| 1450 | 1450 | attotime duration; |
| 1451 | 1451 | |
| 1452 | 1452 | /* get the time since last field sync */ |
| 1453 | | duration = timer_starttime(m6847->hs_rise_timer) - timer_starttime(m6847->fs_rise_timer); |
| 1453 | duration = m6847->hs_rise_timer->start() - m6847->fs_rise_timer->start(); |
| 1454 | 1454 | assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second"); |
| 1455 | 1455 | |
| 1456 | 1456 | if (duration.attoseconds < m6847->vblank_period) |
| r10326 | r10327 | |
| 1471 | 1471 | attotime scanline_time; |
| 1472 | 1472 | int result; |
| 1473 | 1473 | |
| 1474 | | scanline_time = timer_timeelapsed(m6847->hs_rise_timer); |
| 1474 | scanline_time = m6847->hs_rise_timer->elapsed(); |
| 1475 | 1475 | if (scanline_time.seconds != 0) |
| 1476 | 1476 | return 0; |
| 1477 | 1477 | assert(scanline_time.as_attoseconds() < m6847->scanline_period); |
| r10326 | r10327 | |
| 1587 | 1587 | |
| 1588 | 1588 | int m6847_get_horizontal_sync(running_machine *machine) |
| 1589 | 1589 | { |
| 1590 | | attotime fire_time = timer_firetime(m6847->hs_fall_timer); |
| 1590 | attotime fire_time = m6847->hs_fall_timer->expire(); |
| 1591 | 1591 | return fire_time > machine->time(); |
| 1592 | 1592 | } |
| 1593 | 1593 | |
| r10326 | r10327 | |
| 1595 | 1595 | |
| 1596 | 1596 | static void set_horizontal_sync(running_machine *machine) |
| 1597 | 1597 | { |
| 1598 | | attotime fire_time = timer_firetime(m6847->hs_fall_timer); |
| 1598 | attotime fire_time = m6847->hs_fall_timer->expire(); |
| 1599 | 1599 | int horizontal_sync = fire_time > machine->time(); |
| 1600 | 1600 | if (m6847->horizontal_sync_callback) |
| 1601 | 1601 | m6847->horizontal_sync_callback(machine, !horizontal_sync); |
| r10326 | r10327 | |
| 1605 | 1605 | |
| 1606 | 1606 | int m6847_get_field_sync(running_machine *machine) |
| 1607 | 1607 | { |
| 1608 | | attotime fire_time = timer_firetime(m6847->fs_fall_timer); |
| 1608 | attotime fire_time = m6847->fs_fall_timer->expire(); |
| 1609 | 1609 | return fire_time > machine->time(); |
| 1610 | 1610 | } |
| 1611 | 1611 | |
| r10326 | r10327 | |
| 1613 | 1613 | |
| 1614 | 1614 | static void set_field_sync(running_machine *machine) |
| 1615 | 1615 | { |
| 1616 | | attotime fire_time = timer_firetime(m6847->fs_fall_timer); |
| 1616 | attotime fire_time = m6847->fs_fall_timer->expire(); |
| 1617 | 1617 | int field_sync = fire_time > machine->time(); |
| 1618 | 1618 | if (m6847->field_sync_callback) |
| 1619 | 1619 | m6847->field_sync_callback(machine,field_sync); |
| r10326 | r10327 | |
| 1640 | 1640 | if (LOG_HS) |
| 1641 | 1641 | logerror("hs_rise(): time=%s\n", machine->time().as_string(ATTOTIME_STRING_PRECISION)); |
| 1642 | 1642 | |
| 1643 | | timer_adjust_oneshot(m6847->hs_rise_timer, |
| 1643 | m6847->hs_rise_timer->adjust( |
| 1644 | 1644 | attotime(0, m6847->scanline_period), 0); |
| 1645 | | timer_adjust_oneshot(m6847->hs_fall_timer, |
| 1645 | m6847->hs_fall_timer->adjust( |
| 1646 | 1646 | attotime(0, m6847->horizontal_sync_period), 0); |
| 1647 | 1647 | |
| 1648 | 1648 | set_horizontal_sync(machine); |
| r10326 | r10327 | |
| 1663 | 1663 | logerror("fs_rise(): time=%s scanline=%d\n", machine->time().as_string(ATTOTIME_STRING_PRECISION), get_scanline()); |
| 1664 | 1664 | |
| 1665 | 1665 | /* adjust field sync falling edge timer */ |
| 1666 | | timer_adjust_oneshot(m6847->fs_fall_timer, |
| 1666 | m6847->fs_fall_timer->adjust( |
| 1667 | 1667 | attotime(0, m6847->field_sync_period), 0); |
| 1668 | 1668 | |
| 1669 | 1669 | /* adjust horizontal sync rising timer */ |
| 1670 | | timer_adjust_oneshot(m6847->hs_rise_timer, attotime::zero, 0); |
| 1670 | m6847->hs_rise_timer->adjust(attotime::zero); |
| 1671 | 1671 | |
| 1672 | 1672 | /* this is a hook for the CoCo 3 code to extend this stuff */ |
| 1673 | 1673 | if (m6847->new_frame_callback) |
| r10326 | r10327 | |
| 1907 | 1907 | /* setup timing */ |
| 1908 | 1908 | frame_period = period * |
| 1909 | 1909 | (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR); |
| 1910 | | timer_adjust_periodic(m6847->fs_rise_timer, attotime::zero, 0, attotime(0, frame_period)); |
| 1910 | m6847->fs_rise_timer->adjust(attotime::zero, 0, attotime(0, frame_period)); |
| 1911 | 1911 | |
| 1912 | 1912 | /* setup save states */ |
| 1913 | 1913 | state_save_register_postload(machine, m6847_postload, NULL); |
src/mess/video/gb.c
| r10326 | r10327 | |
| 298 | 298 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 299 | 299 | { |
| 300 | 300 | /* Calculate number of pixels to render based on time still left on the timer */ |
| 301 | | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( state->lcd.lcd_timer ) ); |
| 301 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(state->lcd.lcd_timer ->remaining( ) ); |
| 302 | 302 | int l = 0; |
| 303 | 303 | |
| 304 | 304 | if ( state->lcd.start_x < 0 ) |
| r10326 | r10327 | |
| 623 | 623 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 624 | 624 | { |
| 625 | 625 | /* Calcuate number of pixels to render based on time still left on the timer */ |
| 626 | | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( state->lcd.lcd_timer ) ); |
| 626 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(state->lcd.lcd_timer ->remaining( ) ); |
| 627 | 627 | int l = 0; |
| 628 | 628 | |
| 629 | 629 | if ( state->lcd.start_x < 0 ) |
| r10326 | r10327 | |
| 931 | 931 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 932 | 932 | { |
| 933 | 933 | /* Calcuate number of pixels to render based on time still left on the timer */ |
| 934 | | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( state->lcd.lcd_timer ) ); |
| 934 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(state->lcd.lcd_timer ->remaining( ) ); |
| 935 | 935 | int l = 0; |
| 936 | 936 | |
| 937 | 937 | if ( state->lcd.start_x < 0 ) |
| r10326 | r10327 | |
| 1288 | 1288 | switch( mode ) |
| 1289 | 1289 | { |
| 1290 | 1290 | case GB_VIDEO_DMG: |
| 1291 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 1291 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(456)); |
| 1292 | 1292 | |
| 1293 | 1293 | /* set the scanline update function */ |
| 1294 | 1294 | state->update_scanline = gb_update_scanline; |
| r10326 | r10327 | |
| 1322 | 1322 | CURLINE = state->lcd.current_line = 0; |
| 1323 | 1323 | LCDSTAT = ( LCDSTAT & 0xF8 ) | 0x05; |
| 1324 | 1324 | state->lcd.mode = 1; |
| 1325 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(60), GB_LCD_STATE_LY00_M0); |
| 1325 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(60), GB_LCD_STATE_LY00_M0); |
| 1326 | 1326 | |
| 1327 | 1327 | break; |
| 1328 | 1328 | case GB_VIDEO_SGB: |
| r10326 | r10327 | |
| 1418 | 1418 | state->lcd.mode_irq = 0; |
| 1419 | 1419 | } |
| 1420 | 1420 | } |
| 1421 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1421 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1422 | 1422 | break; |
| 1423 | 1423 | case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ |
| 1424 | 1424 | /* update current scanline */ |
| r10326 | r10327 | |
| 1443 | 1443 | if ( ( SCROLLX & 0x03 ) == 0x03 ) |
| 1444 | 1444 | { |
| 1445 | 1445 | state->lcd.scrollx_adjust += 4; |
| 1446 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1446 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1447 | 1447 | break; |
| 1448 | 1448 | } |
| 1449 | 1449 | case GB_LCD_STATE_LYXX_M0_SCX3: |
| r10326 | r10327 | |
| 1453 | 1453 | { |
| 1454 | 1454 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1455 | 1455 | } |
| 1456 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(196 - state->lcd.scrollx_adjust - state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1456 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(196 - state->lcd.scrollx_adjust - state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1457 | 1457 | break; |
| 1458 | 1458 | case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ |
| 1459 | 1459 | if ( CURLINE < 143 ) |
| r10326 | r10327 | |
| 1476 | 1476 | } |
| 1477 | 1477 | } |
| 1478 | 1478 | } |
| 1479 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1479 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1480 | 1480 | break; |
| 1481 | 1481 | case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ |
| 1482 | 1482 | gb_increment_scanline(state); |
| r10326 | r10327 | |
| 1493 | 1493 | /* Check if we're going into VBlank next */ |
| 1494 | 1494 | if ( CURLINE == 144 ) |
| 1495 | 1495 | { |
| 1496 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1496 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1497 | 1497 | } |
| 1498 | 1498 | else |
| 1499 | 1499 | { |
| r10326 | r10327 | |
| 1506 | 1506 | state->lcd.mode_irq = 1; |
| 1507 | 1507 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1508 | 1508 | } |
| 1509 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1509 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1510 | 1510 | } |
| 1511 | 1511 | break; |
| 1512 | 1512 | case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ |
| r10326 | r10327 | |
| 1522 | 1522 | /* Check for regular compensation of x-scroll register */ |
| 1523 | 1523 | state->lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1524 | 1524 | /* Mode 2 lasts approximately 80 clock cycles */ |
| 1525 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1525 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1526 | 1526 | break; |
| 1527 | 1527 | case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ |
| 1528 | 1528 | /* Update STAT register to the correct state */ |
| r10326 | r10327 | |
| 1544 | 1544 | /* Check for regular compensation of x-scroll register */ |
| 1545 | 1545 | state->lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1546 | 1546 | /* Mode 2 last for approximately 80 clock cycles */ |
| 1547 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1547 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1548 | 1548 | break; |
| 1549 | 1549 | case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ |
| 1550 | 1550 | gb_select_sprites(state); |
| r10326 | r10327 | |
| 1555 | 1555 | state->lcd.vram_locked = LOCKED; |
| 1556 | 1556 | /* Check for compensations of x-scroll register */ |
| 1557 | 1557 | /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ |
| 1558 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->lcd.scrollx_adjust + state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1558 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->lcd.scrollx_adjust + state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1559 | 1559 | state->lcd.start_x = -1; |
| 1560 | 1560 | break; |
| 1561 | 1561 | case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ |
| r10326 | r10327 | |
| 1581 | 1581 | { |
| 1582 | 1582 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1583 | 1583 | } |
| 1584 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1584 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1585 | 1585 | break; |
| 1586 | 1586 | case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ |
| 1587 | 1587 | gb_increment_scanline(state); |
| r10326 | r10327 | |
| 1597 | 1597 | LCDSTAT &= 0xFB; |
| 1598 | 1598 | if ( state->lcd.current_line == 153 ) |
| 1599 | 1599 | { |
| 1600 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1600 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1601 | 1601 | } |
| 1602 | 1602 | else |
| 1603 | 1603 | { |
| 1604 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1604 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1605 | 1605 | } |
| 1606 | 1606 | break; |
| 1607 | 1607 | case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ |
| r10326 | r10327 | |
| 1622 | 1622 | state->lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0; |
| 1623 | 1623 | state->lcd.line_irq = 0; |
| 1624 | 1624 | LCDSTAT &= 0xFB; |
| 1625 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1); |
| 1625 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1); |
| 1626 | 1626 | break; |
| 1627 | 1627 | case GB_LCD_STATE_LY00_M1_1: |
| 1628 | 1628 | if ( ! state->lcd.delayed_line_irq && state->lcd.triggering_line_irq ) |
| r10326 | r10327 | |
| 1630 | 1630 | state->lcd.line_irq = state->lcd.triggering_line_irq; |
| 1631 | 1631 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1632 | 1632 | } |
| 1633 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1633 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1634 | 1634 | break; |
| 1635 | 1635 | case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ |
| 1636 | 1636 | if ( state->lcd.delayed_line_irq && state->lcd.triggering_line_irq ) |
| r10326 | r10327 | |
| 1642 | 1642 | { |
| 1643 | 1643 | LCDSTAT |= 0x04; |
| 1644 | 1644 | } |
| 1645 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 1645 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 1646 | 1646 | break; |
| 1647 | 1647 | case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ |
| 1648 | 1648 | /* Set Mode 0 lcdstat */ |
| 1649 | 1649 | state->lcd.mode = 0; |
| 1650 | 1650 | LCDSTAT = ( LCDSTAT & 0xFC ); |
| 1651 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 1651 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 1652 | 1652 | break; |
| 1653 | 1653 | } |
| 1654 | 1654 | } |
| r10326 | r10327 | |
| 1659 | 1659 | { |
| 1660 | 1660 | (*state->update_scanline)( machine ); |
| 1661 | 1661 | } |
| 1662 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 1662 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(456)); |
| 1663 | 1663 | } |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| r10326 | r10327 | |
| 1691 | 1691 | state->lcd.mode_irq = 0; |
| 1692 | 1692 | } |
| 1693 | 1693 | } |
| 1694 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1694 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1695 | 1695 | break; |
| 1696 | 1696 | case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ |
| 1697 | 1697 | /* update current scanline */ |
| r10326 | r10327 | |
| 1717 | 1717 | if ( ( SCROLLX & 0x03 ) == 0x03 ) |
| 1718 | 1718 | { |
| 1719 | 1719 | state->lcd.scrollx_adjust += 4; |
| 1720 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1720 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1721 | 1721 | break; |
| 1722 | 1722 | } |
| 1723 | 1723 | case GB_LCD_STATE_LYXX_M0_SCX3: |
| r10326 | r10327 | |
| 1732 | 1732 | { |
| 1733 | 1733 | state->lcd.pal_locked = UNLOCKED; |
| 1734 | 1734 | } |
| 1735 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL); |
| 1735 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL); |
| 1736 | 1736 | break; |
| 1737 | 1737 | case GB_LCD_STATE_LYXX_M0_GBC_PAL: |
| 1738 | 1738 | state->lcd.pal_locked = UNLOCKED; |
| r10326 | r10327 | |
| 1746 | 1746 | { |
| 1747 | 1747 | state->lcd.hdma_possible = 1; |
| 1748 | 1748 | } |
| 1749 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(192 - state->lcd.scrollx_adjust - state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1749 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(192 - state->lcd.scrollx_adjust - state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1750 | 1750 | break; |
| 1751 | 1751 | case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ |
| 1752 | 1752 | state->lcd.cmp_line = CMPLINE; |
| r10326 | r10327 | |
| 1769 | 1769 | } |
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1772 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1773 | 1773 | break; |
| 1774 | 1774 | case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ |
| 1775 | 1775 | gb_increment_scanline(state); |
| r10326 | r10327 | |
| 1785 | 1785 | /* Check if we're going into VBlank next */ |
| 1786 | 1786 | if ( CURLINE == 144 ) |
| 1787 | 1787 | { |
| 1788 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1788 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1789 | 1789 | } |
| 1790 | 1790 | else |
| 1791 | 1791 | { |
| r10326 | r10327 | |
| 1798 | 1798 | state->lcd.mode_irq = 1; |
| 1799 | 1799 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1800 | 1800 | } |
| 1801 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1801 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1802 | 1802 | } |
| 1803 | 1803 | break; |
| 1804 | 1804 | case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ |
| r10326 | r10327 | |
| 1814 | 1814 | /* Check for regular compensation of x-scroll register */ |
| 1815 | 1815 | state->lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1816 | 1816 | /* Mode 2 lasts approximately 80 clock cycles */ |
| 1817 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1817 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1818 | 1818 | break; |
| 1819 | 1819 | case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ |
| 1820 | 1820 | /* Update STAT register to the correct state */ |
| r10326 | r10327 | |
| 1839 | 1839 | /* Check for regular compensation of x-scroll register */ |
| 1840 | 1840 | state->lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1841 | 1841 | /* Mode 2 last for approximately 80 clock cycles */ |
| 1842 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1842 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1843 | 1843 | break; |
| 1844 | 1844 | case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ |
| 1845 | 1845 | gb_select_sprites(state); |
| r10326 | r10327 | |
| 1851 | 1851 | state->lcd.pal_locked = LOCKED; |
| 1852 | 1852 | /* Check for compensations of x-scroll register */ |
| 1853 | 1853 | /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ |
| 1854 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->lcd.scrollx_adjust + state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1854 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + state->lcd.scrollx_adjust + state->lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1855 | 1855 | state->lcd.start_x = -1; |
| 1856 | 1856 | break; |
| 1857 | 1857 | case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ |
| r10326 | r10327 | |
| 1881 | 1881 | { |
| 1882 | 1882 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1883 | 1883 | } |
| 1884 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1884 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1885 | 1885 | break; |
| 1886 | 1886 | case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ |
| 1887 | 1887 | gb_increment_scanline(state); |
| r10326 | r10327 | |
| 1895 | 1895 | } |
| 1896 | 1896 | if ( state->lcd.current_line == 153 ) |
| 1897 | 1897 | { |
| 1898 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1898 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1899 | 1899 | } |
| 1900 | 1900 | else |
| 1901 | 1901 | { |
| 1902 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1902 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1903 | 1903 | } |
| 1904 | 1904 | break; |
| 1905 | 1905 | case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ |
| r10326 | r10327 | |
| 1924 | 1924 | state->lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0; |
| 1925 | 1925 | state->lcd.line_irq = 0; |
| 1926 | 1926 | LCDSTAT &= 0xFB; |
| 1927 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1); |
| 1927 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1); |
| 1928 | 1928 | break; |
| 1929 | 1929 | case GB_LCD_STATE_LY00_M1_1: |
| 1930 | 1930 | if ( ! state->lcd.delayed_line_irq && state->lcd.triggering_line_irq ) |
| r10326 | r10327 | |
| 1932 | 1932 | state->lcd.line_irq = state->lcd.triggering_line_irq; |
| 1933 | 1933 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1934 | 1934 | } |
| 1935 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1935 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1936 | 1936 | break; |
| 1937 | 1937 | case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ |
| 1938 | 1938 | if ( state->lcd.delayed_line_irq && state->lcd.triggering_line_irq ) |
| r10326 | r10327 | |
| 1948 | 1948 | { |
| 1949 | 1949 | LCDSTAT &= ~0x04; |
| 1950 | 1950 | } |
| 1951 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 1951 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 1952 | 1952 | break; |
| 1953 | 1953 | case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ |
| 1954 | 1954 | /* Set Mode 0 lcdstat */ |
| 1955 | 1955 | state->lcd.mode = 0; |
| 1956 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 1956 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 1957 | 1957 | break; |
| 1958 | 1958 | } |
| 1959 | 1959 | } |
| r10326 | r10327 | |
| 1964 | 1964 | { |
| 1965 | 1965 | (*state->update_scanline)( machine ); |
| 1966 | 1966 | } |
| 1967 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 1967 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(456)); |
| 1968 | 1968 | } |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| r10326 | r10327 | |
| 1989 | 1989 | } |
| 1990 | 1990 | } |
| 1991 | 1991 | state->lcd.state = GB_LCD_STATE_LY00_M2; |
| 1992 | | timer_adjust_oneshot(state->lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1992 | state->lcd.lcd_timer->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1993 | 1993 | } |
| 1994 | 1994 | |
| 1995 | 1995 | READ8_HANDLER( gb_video_r ) |
src/mess/video/x68k.c
| r10326 | r10327 | |
| 191 | 191 | if(scan > state->crtc.vend) |
| 192 | 192 | scan = state->crtc.vbegin; |
| 193 | 193 | hsync_time = machine->primary_screen->time_until_pos(scan,(state->crtc.htotal + state->crtc.hend) / 2); |
| 194 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 0); |
| 194 | state->scanline_timer->adjust(hsync_time); |
| 195 | 195 | if(scan != 0) |
| 196 | 196 | { |
| 197 | 197 | if((input_port_read(machine, "options") & 0x04)) |
| r10326 | r10327 | |
| 206 | 206 | if(scan > state->crtc.vend) |
| 207 | 207 | scan = state->crtc.vbegin; |
| 208 | 208 | hsync_time = machine->primary_screen->time_until_pos(scan,state->crtc.hend / 2); |
| 209 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 0); |
| 209 | state->scanline_timer->adjust(hsync_time); |
| 210 | 210 | if(scan != 0) |
| 211 | 211 | { |
| 212 | 212 | if((input_port_read(machine, "options") & 0x04)) |
| r10326 | r10327 | |
| 226 | 226 | else |
| 227 | 227 | scan++; |
| 228 | 228 | hsync_time = machine->primary_screen->time_until_pos(scan,state->crtc.hbegin / 2); |
| 229 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 1); |
| 229 | state->scanline_timer->adjust(hsync_time, 1); |
| 230 | 230 | state->oddscanline = 0; |
| 231 | 231 | } |
| 232 | 232 | else |
| 233 | 233 | { |
| 234 | 234 | hsync_time = machine->primary_screen->time_until_pos(machine->primary_screen->vpos(),(state->crtc.htotal + state->crtc.hbegin) / 2); |
| 235 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 1); |
| 235 | state->scanline_timer->adjust(hsync_time, 1); |
| 236 | 236 | state->oddscanline = 1; |
| 237 | 237 | } |
| 238 | 238 | } |
| r10326 | r10327 | |
| 245 | 245 | if(scan > state->crtc.vend) |
| 246 | 246 | scan = 0; |
| 247 | 247 | hsync_time = machine->primary_screen->time_until_pos(scan,state->crtc.hend); |
| 248 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 0); |
| 248 | state->scanline_timer->adjust(hsync_time); |
| 249 | 249 | if(scan != 0) |
| 250 | 250 | { |
| 251 | 251 | if((input_port_read(machine, "options") & 0x04)) |
| r10326 | r10327 | |
| 257 | 257 | if(hstate == 0) |
| 258 | 258 | { |
| 259 | 259 | hsync_time = machine->primary_screen->time_until_pos(machine->primary_screen->vpos()+1,state->crtc.hbegin); |
| 260 | | timer_adjust_oneshot(state->scanline_timer, hsync_time, 1); |
| 260 | state->scanline_timer->adjust(hsync_time, 1); |
| 261 | 261 | // if(!(state->mfp.gpio & 0x40)) // if GPIP6 is active, clear it |
| 262 | 262 | // state->mfp.gpio |= 0x40; |
| 263 | 263 | } |
| r10326 | r10327 | |
| 286 | 286 | irq_time = machine->primary_screen->time_until_pos(scan,state->crtc.hbegin); |
| 287 | 287 | // end of HBlank period clears GPIP6 also? |
| 288 | 288 | end_time = machine->primary_screen->time_until_pos(scan,state->crtc.hend); |
| 289 | | timer_adjust_oneshot(state->raster_irq, irq_time, scan); |
| 289 | state->raster_irq->adjust(irq_time, scan); |
| 290 | 290 | machine->scheduler().timer_set(end_time, FUNC(x68k_crtc_raster_end)); |
| 291 | 291 | logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,machine->primary_screen->vpos()); |
| 292 | 292 | } |
| r10326 | r10327 | |
| 305 | 305 | state->crtc.vblank = 1; |
| 306 | 306 | vblank_line = state->crtc.vbegin; |
| 307 | 307 | irq_time = machine->primary_screen->time_until_pos(vblank_line,2); |
| 308 | | timer_adjust_oneshot(state->vblank_irq, irq_time, 0); |
| 308 | state->vblank_irq->adjust(irq_time); |
| 309 | 309 | logerror("CRTC: VBlank on\n"); |
| 310 | 310 | } |
| 311 | 311 | if(val == 0) // V-DISP off |
| r10326 | r10327 | |
| 315 | 315 | if(vblank_line > state->crtc.vtotal) |
| 316 | 316 | vblank_line = state->crtc.vtotal; |
| 317 | 317 | irq_time = machine->primary_screen->time_until_pos(vblank_line,2); |
| 318 | | timer_adjust_oneshot(state->vblank_irq, irq_time, 1); |
| 318 | state->vblank_irq->adjust(irq_time, 1); |
| 319 | 319 | logerror("CRTC: VBlank off\n"); |
| 320 | 320 | } |
| 321 | 321 | |
| r10326 | r10327 | |
| 397 | 397 | irq_time = space->machine->primary_screen->time_until_pos((data) / state->crtc.vmultiple,2); |
| 398 | 398 | |
| 399 | 399 | if(irq_time.as_double() > 0) |
| 400 | | timer_adjust_oneshot(state->raster_irq, irq_time, (data) / state->crtc.vmultiple); |
| 400 | state->raster_irq->adjust(irq_time, (data) / state->crtc.vmultiple); |
| 401 | 401 | } |
| 402 | 402 | logerror("CRTC: Write to raster IRQ register - %i\n",data); |
| 403 | 403 | break; |
| r10326 | r10327 | |
| 1111 | 1111 | tilemap_set_transparent_pen(state->bg0_16,0); |
| 1112 | 1112 | tilemap_set_transparent_pen(state->bg1_16,0); |
| 1113 | 1113 | |
| 1114 | | // timer_adjust_periodic(state->scanline_timer, attotime::zero, 0, attotime::from_hz(55.45)/568); |
| 1114 | // state->scanline_timer->adjust(attotime::zero, 0, attotime::from_hz(55.45)/568); |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | VIDEO_UPDATE( x68000 ) |
src/mess/video/cdp1861.c
| r10326 | r10327 | |
| 85 | 85 | devcb_call_write_line(&cdp1861->out_int_func, ASSERT_LINE); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | | timer_adjust_oneshot(cdp1861->int_timer, cdp1861->screen->time_until_pos( CDP1861_SCANLINE_INT_END, 0), 0); |
| 88 | cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos( CDP1861_SCANLINE_INT_END, 0)); |
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
| r10326 | r10327 | |
| 94 | 94 | devcb_call_write_line(&cdp1861->out_int_func, CLEAR_LINE); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | | timer_adjust_oneshot(cdp1861->int_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0), 0); |
| 97 | cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0)); |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| r10326 | r10327 | |
| 113 | 113 | { |
| 114 | 114 | case CDP1861_SCANLINE_EFX_TOP_START: |
| 115 | 115 | devcb_call_write_line(&cdp1861->out_efx_func, ASSERT_LINE); |
| 116 | | timer_adjust_oneshot(cdp1861->efx_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_END, 0), 0); |
| 116 | cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_END, 0)); |
| 117 | 117 | break; |
| 118 | 118 | |
| 119 | 119 | case CDP1861_SCANLINE_EFX_TOP_END: |
| 120 | 120 | devcb_call_write_line(&cdp1861->out_efx_func, CLEAR_LINE); |
| 121 | | timer_adjust_oneshot(cdp1861->efx_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_START, 0), 0); |
| 121 | cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_START, 0)); |
| 122 | 122 | break; |
| 123 | 123 | |
| 124 | 124 | case CDP1861_SCANLINE_EFX_BOTTOM_START: |
| 125 | 125 | devcb_call_write_line(&cdp1861->out_efx_func, ASSERT_LINE); |
| 126 | | timer_adjust_oneshot(cdp1861->efx_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_END, 0), 0); |
| 126 | cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_END, 0)); |
| 127 | 127 | break; |
| 128 | 128 | |
| 129 | 129 | case CDP1861_SCANLINE_EFX_BOTTOM_END: |
| 130 | 130 | devcb_call_write_line(&cdp1861->out_efx_func, CLEAR_LINE); |
| 131 | | timer_adjust_oneshot(cdp1861->efx_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 131 | cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0)); |
| 132 | 132 | break; |
| 133 | 133 | } |
| 134 | 134 | } |
| r10326 | r10327 | |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | | timer_adjust_oneshot(cdp1861->dma_timer, cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_WAIT), 0); |
| 157 | cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_WAIT)); |
| 158 | 158 | |
| 159 | 159 | cdp1861->dmaout = 0; |
| 160 | 160 | } |
| r10326 | r10327 | |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | | timer_adjust_oneshot(cdp1861->dma_timer, cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_ACTIVE), 0); |
| 171 | cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_ACTIVE)); |
| 172 | 172 | |
| 173 | 173 | cdp1861->dmaout = 1; |
| 174 | 174 | } |
| r10326 | r10327 | |
| 286 | 286 | { |
| 287 | 287 | cdp1861_t *cdp1861 = get_safe_token(device); |
| 288 | 288 | |
| 289 | | timer_adjust_oneshot(cdp1861->int_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0), 0); |
| 290 | | timer_adjust_oneshot(cdp1861->efx_timer, cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0), 0); |
| 291 | | timer_adjust_oneshot(cdp1861->dma_timer, cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_START), 0); |
| 289 | cdp1861->int_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0)); |
| 290 | cdp1861->efx_timer->adjust(cdp1861->screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0)); |
| 291 | cdp1861->dma_timer->adjust(cdp1861->cpu->cycles_to_attotime(CDP1861_CYCLES_DMA_START)); |
| 292 | 292 | |
| 293 | 293 | cdp1861->disp = 0; |
| 294 | 294 | cdp1861->dmaout = 0; |
src/mess/drivers/fmtowns.c
| r10326 | r10327 | |
| 918 | 918 | } |
| 919 | 919 | else |
| 920 | 920 | state->towns_mouse_output++; |
| 921 | | timer_adjust_periodic(state->towns_mouse_timer,attotime::from_usec(600),0,attotime::zero); |
| 921 | state->towns_mouse_timer->adjust(attotime::from_usec(600),0,attotime::zero); |
| 922 | 922 | } |
| 923 | 923 | if((state->towns_pad_mask & 0x10) == 0 && (state->prev_pad_mask & 0x10) != 0) |
| 924 | 924 | { |
| r10326 | r10327 | |
| 934 | 934 | } |
| 935 | 935 | else |
| 936 | 936 | state->towns_mouse_output++; |
| 937 | | timer_adjust_periodic(state->towns_mouse_timer,attotime::from_usec(600),0,attotime::zero); |
| 937 | state->towns_mouse_timer->adjust(attotime::from_usec(600),0,attotime::zero); |
| 938 | 938 | } |
| 939 | 939 | state->prev_pad_mask = state->towns_pad_mask; |
| 940 | 940 | } |
| r10326 | r10327 | |
| 954 | 954 | } |
| 955 | 955 | else |
| 956 | 956 | state->towns_mouse_output++; |
| 957 | | timer_adjust_periodic(state->towns_mouse_timer,attotime::from_usec(600),0,attotime::zero); |
| 957 | state->towns_mouse_timer->adjust(attotime::from_usec(600),0,attotime::zero); |
| 958 | 958 | } |
| 959 | 959 | if((state->towns_pad_mask & 0x20) == 0 && (state->prev_pad_mask & 0x20) != 0) |
| 960 | 960 | { |
| r10326 | r10327 | |
| 970 | 970 | } |
| 971 | 971 | else |
| 972 | 972 | state->towns_mouse_output++; |
| 973 | | timer_adjust_periodic(state->towns_mouse_timer,attotime::from_usec(600),0,attotime::zero); |
| 973 | state->towns_mouse_timer->adjust(attotime::from_usec(600),0,attotime::zero); |
| 974 | 974 | } |
| 975 | 975 | state->prev_pad_mask = state->towns_pad_mask; |
| 976 | 976 | } |
| r10326 | r10327 | |
| 1249 | 1249 | // logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,state->towns_cd.buffer_ptr); |
| 1250 | 1250 | if(param != 0) |
| 1251 | 1251 | { |
| 1252 | | timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),0); |
| 1252 | state->towns_cd.read_timer->adjust(attotime::from_hz(300000)); |
| 1253 | 1253 | } |
| 1254 | 1254 | else |
| 1255 | 1255 | { |
| 1256 | 1256 | if(masked != 0) // check if the DMA channel is masked |
| 1257 | 1257 | { |
| 1258 | | timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),1); |
| 1258 | state->towns_cd.read_timer->adjust(attotime::from_hz(300000),1); |
| 1259 | 1259 | return; |
| 1260 | 1260 | } |
| 1261 | 1261 | if(state->towns_cd.buffer_ptr < 2048) |
| 1262 | | timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),1); |
| 1262 | state->towns_cd.read_timer->adjust(attotime::from_hz(300000),1); |
| 1263 | 1263 | else |
| 1264 | 1264 | { // end of transfer |
| 1265 | 1265 | state->towns_cd.status &= ~0x10; // no longer transferring by DMA |
| r10326 | r10327 | |
| 1279 | 1279 | towns_cd_set_status(device->machine,0x22,0x00,0x00,0x00); |
| 1280 | 1280 | towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1); |
| 1281 | 1281 | cdrom_read_data(cd_get_cdrom_file(state->cdrom),++state->towns_cd.lba_current,state->towns_cd.buffer,CD_TRACK_MODE1); |
| 1282 | | timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),1); |
| 1282 | state->towns_cd.read_timer->adjust(attotime::from_hz(300000),1); |
| 1283 | 1283 | state->towns_cd.buffer_ptr = -1; |
| 1284 | 1284 | } |
| 1285 | 1285 | } |
| r10326 | r10327 | |
| 1332 | 1332 | state->towns_cd.status |= 0x10; // DMA transfer begin |
| 1333 | 1333 | state->towns_cd.status &= ~0x20; // not a software transfer |
| 1334 | 1334 | // state->towns_cd.buffer_ptr = 0; |
| 1335 | | // timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),1); |
| 1335 | // state->towns_cd.read_timer->adjust(attotime::from_hz(300000),1); |
| 1336 | 1336 | if(state->towns_cd.command & 0x20) |
| 1337 | 1337 | { |
| 1338 | 1338 | state->towns_cd.extra_status = 2; |
| r10326 | r10327 | |
| 1686 | 1686 | if(state->towns_cd.buffer_ptr < 0) |
| 1687 | 1687 | { |
| 1688 | 1688 | state->towns_cd.buffer_ptr = 0; |
| 1689 | | timer_adjust_oneshot(state->towns_cd.read_timer,attotime::from_hz(300000),1); |
| 1689 | state->towns_cd.read_timer->adjust(attotime::from_hz(300000),1); |
| 1690 | 1690 | } |
| 1691 | 1691 | } |
| 1692 | 1692 | logerror("CD: transfer mode write %02x\n",data); |
| r10326 | r10327 | |
| 2325 | 2325 | state->towns_cd.status = 0x01; // CDROM controller ready |
| 2326 | 2326 | state->towns_cd.buffer_ptr = -1; |
| 2327 | 2327 | state->towns_volume_select = 0; |
| 2328 | | timer_adjust_periodic(state->towns_rtc_timer,attotime::zero,0,attotime::from_hz(1)); |
| 2329 | | timer_adjust_periodic(state->towns_kb_timer,attotime::zero,0,attotime::from_msec(10)); |
| 2328 | state->towns_rtc_timer->adjust(attotime::zero,0,attotime::from_hz(1)); |
| 2329 | state->towns_kb_timer->adjust(attotime::zero,0,attotime::from_msec(10)); |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | 2332 | static const struct pit8253_config towns_pit8253_config = |
src/mess/drivers/x68k.c
| r10326 | r10327 | |
| 180 | 180 | mfp_timer[2] = machine->scheduler().timer_alloc(FUNC(mfp_timer_c_callback)); |
| 181 | 181 | mfp_timer[3] = machine->scheduler().timer_alloc(FUNC(mfp_timer_d_callback)); |
| 182 | 182 | mfp_irq = machine->scheduler().timer_alloc(FUNC(mfp_update_irq)); |
| 183 | | timer_adjust_periodic(mfp_irq, attotime::zero, 0, attotime::from_usec(32)); |
| 183 | mfp_irq->adjust(attotime::zero, 0, attotime::from_usec(32)); |
| 184 | 184 | #endif |
| 185 | 185 | } |
| 186 | 186 | |
| r10326 | r10327 | |
| 308 | 308 | { |
| 309 | 309 | if((data & 0x07) == 0x0000) |
| 310 | 310 | { // Timer stop |
| 311 | | timer_adjust_oneshot(mfp_timer[timer], attotime::zero, 0); |
| 311 | mfp_timer[timer]->adjust(attotime::zero); |
| 312 | 312 | logerror("MFP: Timer #%i stopped. \n",timer); |
| 313 | 313 | return; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | | timer_adjust_periodic(mfp_timer[timer], attotime::zero, 0, prescale(data & 0x07)); |
| 316 | mfp_timer[timer]->adjust(attotime::zero, 0, prescale(data & 0x07)); |
| 317 | 317 | logerror("MFP: Timer #%i set to %2.1fus\n",timer, prescale(data & 0x07).as_double() * 1000000); |
| 318 | 318 | |
| 319 | 319 | } |
| r10326 | r10327 | |
| 945 | 945 | if((state->ppi_prev & 0x10) == 0x00 && (data & 0x10) == 0x10) |
| 946 | 946 | { |
| 947 | 947 | state->mdctrl.seq1++; |
| 948 | | timer_adjust_oneshot(state->mdctrl.io_timeout1,device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192),0); |
| 948 | state->mdctrl.io_timeout1->adjust(device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192)); |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | state->joy.joy2_enable = data & 0x20; |
| r10326 | r10327 | |
| 953 | 953 | if((state->ppi_prev & 0x20) == 0x00 && (data & 0x20) == 0x20) |
| 954 | 954 | { |
| 955 | 955 | state->mdctrl.seq2++; |
| 956 | | timer_adjust_oneshot(state->mdctrl.io_timeout2,device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192),0); |
| 956 | state->mdctrl.io_timeout2->adjust(device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192)); |
| 957 | 957 | } |
| 958 | 958 | state->ppi_prev = data; |
| 959 | 959 | |
| r10326 | r10327 | |
| 2572 | 2572 | // start VBlank timer |
| 2573 | 2573 | state->crtc.vblank = 1; |
| 2574 | 2574 | irq_time = machine->primary_screen->time_until_pos(state->crtc.reg[6],2); |
| 2575 | | timer_adjust_oneshot(state->vblank_irq, irq_time, 0); |
| 2575 | state->vblank_irq->adjust(irq_time); |
| 2576 | 2576 | |
| 2577 | 2577 | // start HBlank timer |
| 2578 | | timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->scan_period(), 1); |
| 2578 | state->scanline_timer->adjust(machine->primary_screen->scan_period(), 1); |
| 2579 | 2579 | |
| 2580 | 2580 | state->mfp.gpio = 0xfb; |
| 2581 | 2581 | |
| r10326 | r10327 | |
| 2621 | 2621 | memory_set_bankptr(machine, "bank4",state->m_nvram); // so that code in SRAM is executable, there is an option for booting from SRAM |
| 2622 | 2622 | |
| 2623 | 2623 | // start keyboard timer |
| 2624 | | timer_adjust_periodic(state->kb_timer, attotime::zero, 0, attotime::from_msec(5)); // every 5ms |
| 2624 | state->kb_timer->adjust(attotime::zero, 0, attotime::from_msec(5)); // every 5ms |
| 2625 | 2625 | |
| 2626 | 2626 | // start mouse timer |
| 2627 | | timer_adjust_periodic(state->mouse_timer, attotime::zero, 0, attotime::from_msec(1)); // a guess for now |
| 2627 | state->mouse_timer->adjust(attotime::zero, 0, attotime::from_msec(1)); // a guess for now |
| 2628 | 2628 | state->mouse.inputtype = 0; |
| 2629 | 2629 | |
| 2630 | 2630 | // start LED timer |
| 2631 | | timer_adjust_periodic(state->led_timer, attotime::zero, 0, attotime::from_msec(400)); |
| 2631 | state->led_timer->adjust(attotime::zero, 0, attotime::from_msec(400)); |
| 2632 | 2632 | } |
| 2633 | 2633 | |
| 2634 | 2634 | static MACHINE_START( x68030 ) |
| r10326 | r10327 | |
| 2655 | 2655 | memory_set_bankptr(machine, "bank4",state->m_nvram); // so that code in SRAM is executable, there is an option for booting from SRAM |
| 2656 | 2656 | |
| 2657 | 2657 | // start keyboard timer |
| 2658 | | timer_adjust_periodic(state->kb_timer, attotime::zero, 0, attotime::from_msec(5)); // every 5ms |
| 2658 | state->kb_timer->adjust(attotime::zero, 0, attotime::from_msec(5)); // every 5ms |
| 2659 | 2659 | |
| 2660 | 2660 | // start mouse timer |
| 2661 | | timer_adjust_periodic(state->mouse_timer, attotime::zero, 0, attotime::from_msec(1)); // a guess for now |
| 2661 | state->mouse_timer->adjust(attotime::zero, 0, attotime::from_msec(1)); // a guess for now |
| 2662 | 2662 | state->mouse.inputtype = 0; |
| 2663 | 2663 | |
| 2664 | 2664 | // start LED timer |
| 2665 | | timer_adjust_periodic(state->led_timer, attotime::zero, 0, attotime::from_msec(400)); |
| 2665 | state->led_timer->adjust(attotime::zero, 0, attotime::from_msec(400)); |
| 2666 | 2666 | } |
| 2667 | 2667 | |
| 2668 | 2668 | static DRIVER_INIT( x68000 ) |
src/mess/drivers/px4.c
| r10326 | r10327 | |
| 321 | 321 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 322 | 322 | |
| 323 | 323 | if (VERBOSE) |
| 324 | | logerror("%s: px4_icrlc_r\n", cpuexec_describe_context(space->machine)); |
| 324 | logerror("%s: px4_icrlc_r\n", space->machine->describe_context()); |
| 325 | 325 | |
| 326 | 326 | /* latch value */ |
| 327 | 327 | px4->frc_latch = px4->frc_value; |
| r10326 | r10327 | |
| 336 | 336 | int baud; |
| 337 | 337 | |
| 338 | 338 | if (VERBOSE) |
| 339 | | logerror("%s: px4_ctrl1_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 339 | logerror("%s: px4_ctrl1_w (0x%02x)\n", space->machine->describe_context(), data); |
| 340 | 340 | |
| 341 | 341 | /* baudrate generator */ |
| 342 | 342 | baud = data >> 4; |
| 343 | 343 | |
| 344 | 344 | if (baud <= 12) |
| 345 | 345 | { |
| 346 | | timer_adjust_periodic(px4->transmit_timer, attotime::zero, 0, attotime::from_hz(XTAL_7_3728MHz/2/transmit_rate[baud])); |
| 347 | | timer_adjust_periodic(px4->receive_timer, attotime::zero, 0, attotime::from_hz(XTAL_7_3728MHz/2/receive_rate[baud])); |
| 346 | px4->transmit_timer->adjust(attotime::zero, 0, attotime::from_hz(XTAL_7_3728MHz/2/transmit_rate[baud])); |
| 347 | px4->receive_timer->adjust(attotime::zero, 0, attotime::from_hz(XTAL_7_3728MHz/2/receive_rate[baud])); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | px4->ctrl1 = data; |
| r10326 | r10327 | |
| 356 | 356 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 357 | 357 | |
| 358 | 358 | if (VERBOSE) |
| 359 | | logerror("%s: px4_icrhc_r\n", cpuexec_describe_context(space->machine)); |
| 359 | logerror("%s: px4_icrhc_r\n", space->machine->describe_context()); |
| 360 | 360 | |
| 361 | 361 | return (px4->frc_latch >> 8) & 0xff; |
| 362 | 362 | } |
| r10326 | r10327 | |
| 367 | 367 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 368 | 368 | |
| 369 | 369 | if (VERBOSE) |
| 370 | | logerror("%s: px4_cmdr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 370 | logerror("%s: px4_cmdr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 371 | 371 | |
| 372 | 372 | /* clear overflow interrupt? */ |
| 373 | 373 | if (BIT(data, 2)) |
| r10326 | r10327 | |
| 383 | 383 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 384 | 384 | |
| 385 | 385 | if (VERBOSE) |
| 386 | | logerror("%s: px4_icrlb_r\n", cpuexec_describe_context(space->machine)); |
| 386 | logerror("%s: px4_icrlb_r\n", space->machine->describe_context()); |
| 387 | 387 | |
| 388 | 388 | return px4->icrb & 0xff; |
| 389 | 389 | } |
| r10326 | r10327 | |
| 394 | 394 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 395 | 395 | |
| 396 | 396 | if (VERBOSE) |
| 397 | | logerror("%s: px4_ctrl2_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 397 | logerror("%s: px4_ctrl2_w (0x%02x)\n", space->machine->describe_context(), data); |
| 398 | 398 | |
| 399 | 399 | /* bit 0, MIC, cassette output */ |
| 400 | 400 | cassette_output(px4->ext_cas, BIT(data, 0) ? -1.0 : +1.0); |
| r10326 | r10327 | |
| 403 | 403 | if (BIT(data, 1)) |
| 404 | 404 | { |
| 405 | 405 | cassette_change_state(px4->ext_cas, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 406 | | timer_adjust_periodic(px4->ext_cas_timer, attotime::zero, 0, attotime::from_hz(44100)); |
| 406 | px4->ext_cas_timer->adjust(attotime::zero, 0, attotime::from_hz(44100)); |
| 407 | 407 | } |
| 408 | 408 | else |
| 409 | 409 | { |
| 410 | 410 | cassette_change_state(px4->ext_cas, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 411 | | timer_adjust_oneshot(px4->ext_cas_timer, attotime::zero, 0); |
| 411 | px4->ext_cas_timer->adjust(attotime::zero); |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| r10326 | r10327 | |
| 418 | 418 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 419 | 419 | |
| 420 | 420 | if (VERBOSE) |
| 421 | | logerror("%s: px4_icrhb_r\n", cpuexec_describe_context(space->machine)); |
| 421 | logerror("%s: px4_icrhb_r\n", space->machine->describe_context()); |
| 422 | 422 | |
| 423 | 423 | /* clear icf interrupt */ |
| 424 | 424 | px4->isr &= ~INT2_ICF; |
| r10326 | r10327 | |
| 433 | 433 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 434 | 434 | |
| 435 | 435 | if (VERBOSE) |
| 436 | | logerror("%s: px4_isr_r\n", cpuexec_describe_context(space->machine)); |
| 436 | logerror("%s: px4_isr_r\n", space->machine->describe_context()); |
| 437 | 437 | |
| 438 | 438 | return px4->isr; |
| 439 | 439 | } |
| r10326 | r10327 | |
| 444 | 444 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 445 | 445 | |
| 446 | 446 | if (VERBOSE) |
| 447 | | logerror("%s: px4_ier_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 447 | logerror("%s: px4_ier_w (0x%02x)\n", space->machine->describe_context(), data); |
| 448 | 448 | |
| 449 | 449 | px4->ier = data; |
| 450 | 450 | gapnit_interrupt(space->machine); |
| r10326 | r10327 | |
| 457 | 457 | UINT8 result = 0; |
| 458 | 458 | |
| 459 | 459 | if (VERBOSE) |
| 460 | | logerror("%s: px4_str_r\n", cpuexec_describe_context(space->machine)); |
| 460 | logerror("%s: px4_str_r\n", space->machine->describe_context()); |
| 461 | 461 | |
| 462 | 462 | result |= cassette_input(px4->ext_cas) > 0 ? 1 : 0; |
| 463 | 463 | result |= 1 << 1; /* BCRD, barcode reader input */ |
| r10326 | r10327 | |
| 502 | 502 | address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 503 | 503 | |
| 504 | 504 | if (VERBOSE) |
| 505 | | logerror("%s: px4_bankr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 505 | logerror("%s: px4_bankr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 506 | 506 | |
| 507 | 507 | px4->bankr = data; |
| 508 | 508 | |
| r10326 | r10327 | |
| 544 | 544 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 545 | 545 | |
| 546 | 546 | if (VERBOSE) |
| 547 | | logerror("%s: px4_sior_r 0x%02x\n", cpuexec_describe_context(space->machine), px4->sior); |
| 547 | logerror("%s: px4_sior_r 0x%02x\n", space->machine->describe_context(), px4->sior); |
| 548 | 548 | |
| 549 | 549 | return px4->sior; |
| 550 | 550 | } |
| r10326 | r10327 | |
| 555 | 555 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 556 | 556 | |
| 557 | 557 | if (VERBOSE) |
| 558 | | logerror("%s: px4_sior_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 558 | logerror("%s: px4_sior_w (0x%02x)\n", space->machine->describe_context(), data); |
| 559 | 559 | |
| 560 | 560 | px4->sior = data; |
| 561 | 561 | |
| r10326 | r10327 | |
| 687 | 687 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 688 | 688 | |
| 689 | 689 | if (VERBOSE) |
| 690 | | logerror("%s: px4_vadr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 690 | logerror("%s: px4_vadr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 691 | 691 | |
| 692 | 692 | px4->vadr = data; |
| 693 | 693 | } |
| r10326 | r10327 | |
| 698 | 698 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 699 | 699 | |
| 700 | 700 | if (VERBOSE) |
| 701 | | logerror("%s: px4_yoff_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 701 | logerror("%s: px4_yoff_w (0x%02x)\n", space->machine->describe_context(), data); |
| 702 | 702 | |
| 703 | 703 | px4->yoff = data; |
| 704 | 704 | } |
| r10326 | r10327 | |
| 707 | 707 | static WRITE8_HANDLER( px4_fr_w ) |
| 708 | 708 | { |
| 709 | 709 | if (VERBOSE) |
| 710 | | logerror("%s: px4_fr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 710 | logerror("%s: px4_fr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /* speed-up register */ |
| 714 | 714 | static WRITE8_HANDLER( px4_spur_w ) |
| 715 | 715 | { |
| 716 | 716 | if (VERBOSE) |
| 717 | | logerror("%s: px4_spur_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 717 | logerror("%s: px4_spur_w (0x%02x)\n", space->machine->describe_context(), data); |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | |
| r10326 | r10327 | |
| 746 | 746 | static READ8_HANDLER( px4_ctgif_r ) |
| 747 | 747 | { |
| 748 | 748 | if (VERBOSE) |
| 749 | | logerror("%s: px4_ctgif_r @ 0x%02x\n", cpuexec_describe_context(space->machine), offset); |
| 749 | logerror("%s: px4_ctgif_r @ 0x%02x\n", space->machine->describe_context(), offset); |
| 750 | 750 | |
| 751 | 751 | return 0xff; |
| 752 | 752 | } |
| r10326 | r10327 | |
| 755 | 755 | static WRITE8_HANDLER( px4_ctgif_w ) |
| 756 | 756 | { |
| 757 | 757 | if (VERBOSE) |
| 758 | | logerror("%s: px4_ctgif_w (0x%02x @ 0x%02x)\n", cpuexec_describe_context(space->machine), data, offset); |
| 758 | logerror("%s: px4_ctgif_w (0x%02x @ 0x%02x)\n", space->machine->describe_context(), data, offset); |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /* art data input register */ |
| r10326 | r10327 | |
| 764 | 764 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 765 | 765 | |
| 766 | 766 | if (VERBOSE) |
| 767 | | logerror("%s: px4_artdir_r\n", cpuexec_describe_context(space->machine)); |
| 767 | logerror("%s: px4_artdir_r\n", space->machine->describe_context()); |
| 768 | 768 | |
| 769 | 769 | return px4->artdir; |
| 770 | 770 | } |
| r10326 | r10327 | |
| 775 | 775 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 776 | 776 | |
| 777 | 777 | if (VERBOSE) |
| 778 | | logerror("%s: px4_artdor_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 778 | logerror("%s: px4_artdor_w (0x%02x)\n", space->machine->describe_context(), data); |
| 779 | 779 | |
| 780 | 780 | /* clear ready */ |
| 781 | 781 | px4->artsr &= ~ART_TXRDY; |
| r10326 | r10327 | |
| 790 | 790 | UINT8 result = 0; |
| 791 | 791 | |
| 792 | 792 | if (VERBOSE) |
| 793 | | logerror("%s: px4_artsr_r\n", cpuexec_describe_context(space->machine)); |
| 793 | logerror("%s: px4_artsr_r\n", space->machine->describe_context()); |
| 794 | 794 | |
| 795 | 795 | result |= px4_rs232c_dsr(px4->rs232c_device) << 7; |
| 796 | 796 | |
| r10326 | r10327 | |
| 803 | 803 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 804 | 804 | |
| 805 | 805 | if (VERBOSE) |
| 806 | | logerror("%s: px4_artmr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 806 | logerror("%s: px4_artmr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 807 | 807 | |
| 808 | 808 | px4->artmr = data; |
| 809 | 809 | } |
| r10326 | r10327 | |
| 815 | 815 | UINT8 result = 0; |
| 816 | 816 | |
| 817 | 817 | if (VERBOSE) |
| 818 | | logerror("%s: px4_iostr_r\n", cpuexec_describe_context(space->machine)); |
| 818 | logerror("%s: px4_iostr_r\n", space->machine->describe_context()); |
| 819 | 819 | |
| 820 | 820 | result |= centronics_busy_r(px4->printer) << 0; |
| 821 | 821 | result |= !centronics_pe_r(px4->printer) << 1; |
| r10326 | r10327 | |
| 835 | 835 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 836 | 836 | |
| 837 | 837 | if (VERBOSE) |
| 838 | | logerror("%s: px4_artcr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 838 | logerror("%s: px4_artcr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 839 | 839 | |
| 840 | 840 | px4->artcr = data; |
| 841 | 841 | |
| r10326 | r10327 | |
| 869 | 869 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 870 | 870 | |
| 871 | 871 | if (VERBOSE) |
| 872 | | logerror("%s: px4_swr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 872 | logerror("%s: px4_swr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 873 | 873 | |
| 874 | 874 | px4->swr = data; |
| 875 | 875 | } |
| r10326 | r10327 | |
| 880 | 880 | px4_state *px4 = space->machine->driver_data<px4_state>(); |
| 881 | 881 | |
| 882 | 882 | if (VERBOSE) |
| 883 | | logerror("%s: px4_ioctlr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| 883 | logerror("%s: px4_ioctlr_w (0x%02x)\n", space->machine->describe_context(), data); |
| 884 | 884 | |
| 885 | 885 | centronics_strobe_w(px4->printer, !BIT(data, 0)); |
| 886 | 886 | centronics_prime_w(px4->printer, BIT(data, 1)); |
src/mess/drivers/gp32.c
| r10326 | r10327 | |
| 35 | 35 | va_start( v, s_fmt); |
| 36 | 36 | vsprintf( buf, s_fmt, v); |
| 37 | 37 | va_end( v); |
| 38 | | logerror( "%s: %s", cpuexec_describe_context( machine), buf); |
| 38 | logerror( "%s: %s", machine->describe_context( ), buf); |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| r10326 | r10327 | |
| 284 | 284 | } |
| 285 | 285 | if ((state->s3c240x_lcd.vpos == 0) && (state->s3c240x_lcd.hpos == 0)) break; |
| 286 | 286 | } |
| 287 | | timer_adjust_oneshot( state->s3c240x_lcd_timer, screen->time_until_pos(state->s3c240x_lcd.vpos, state->s3c240x_lcd.hpos), 0); |
| 287 | state->s3c240x_lcd_timer->adjust( screen->time_until_pos(state->s3c240x_lcd.vpos, state->s3c240x_lcd.hpos)); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | static VIDEO_START( gp32 ) |
| r10326 | r10327 | |
| 357 | 357 | verboselog( machine, 1, "LCD start\n"); |
| 358 | 358 | s3c240x_lcd_configure( machine); |
| 359 | 359 | s3c240x_lcd_dma_init( machine); |
| 360 | | timer_adjust_oneshot( state->s3c240x_lcd_timer, screen->time_until_pos(0, 0), 0); |
| 360 | state->s3c240x_lcd_timer->adjust( screen->time_until_pos(0, 0)); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | static void s3c240x_lcd_stop( running_machine *machine) |
| 364 | 364 | { |
| 365 | 365 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 366 | 366 | verboselog( machine, 1, "LCD stop\n"); |
| 367 | | timer_adjust_oneshot( state->s3c240x_lcd_timer, attotime::never, 0); |
| 367 | state->s3c240x_lcd_timer->adjust( attotime::never); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | static void s3c240x_lcd_recalc( running_machine *machine) |
| r10326 | r10327 | |
| 632 | 632 | verboselog( machine, 5, "PWM %d - FCLK=%d HCLK=%d PCLK=%d prescaler=%d div=%d freq=%f cnt=%d cmp=%d auto_reload=%d hz=%f\n", timer, s3c240x_get_fclk(state, MPLLCON), s3c240x_get_hclk(state, MPLLCON), s3c240x_get_pclk(state, MPLLCON), prescaler, mux_table[mux], freq, cnt, cmp, auto_reload, hz); |
| 633 | 633 | if (auto_reload) |
| 634 | 634 | { |
| 635 | | timer_adjust_periodic( state->s3c240x_pwm_timer[timer], attotime::from_hz( hz), timer, attotime::from_hz( hz)); |
| 635 | state->s3c240x_pwm_timer[timer]->adjust( attotime::from_hz( hz), timer, attotime::from_hz( hz)); |
| 636 | 636 | } |
| 637 | 637 | else |
| 638 | 638 | { |
| 639 | | timer_adjust_oneshot( state->s3c240x_pwm_timer[timer], attotime::from_hz( hz), timer); |
| 639 | state->s3c240x_pwm_timer[timer]->adjust( attotime::from_hz( hz), timer); |
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | |
| r10326 | r10327 | |
| 644 | 644 | { |
| 645 | 645 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 646 | 646 | verboselog( machine, 1, "PWM %d stop\n", timer); |
| 647 | | timer_adjust_oneshot( state->s3c240x_pwm_timer[timer], attotime::never, 0); |
| 647 | state->s3c240x_pwm_timer[timer]->adjust( attotime::never); |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | static void s3c240x_pwm_recalc( running_machine *machine, int timer) |
| r10326 | r10327 | |
| 1413 | 1413 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 1414 | 1414 | verboselog( machine, 1, "IIC start\n"); |
| 1415 | 1415 | state->s3c240x_iic.data_index = 0; |
| 1416 | | timer_adjust_oneshot( state->s3c240x_iic_timer, attotime::from_msec( 1), 0); |
| 1416 | state->s3c240x_iic_timer->adjust( attotime::from_msec( 1)); |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | static void iic_stop( running_machine *machine) |
| 1420 | 1420 | { |
| 1421 | 1421 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 1422 | 1422 | verboselog( machine, 1, "IIC stop\n"); |
| 1423 | | timer_adjust_oneshot( state->s3c240x_iic_timer, attotime::never, 0); |
| 1423 | state->s3c240x_iic_timer->adjust( attotime::never); |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | static void iic_resume( running_machine *machine) |
| 1427 | 1427 | { |
| 1428 | 1428 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 1429 | 1429 | verboselog( machine, 1, "IIC resume\n"); |
| 1430 | | timer_adjust_oneshot( state->s3c240x_iic_timer, attotime::from_msec( 1), 0); |
| 1430 | state->s3c240x_iic_timer->adjust( attotime::from_msec( 1)); |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | static READ32_HANDLER( s3c240x_iic_r ) |
| r10326 | r10327 | |
| 1563 | 1563 | codeclk = BIT( state->s3c240x_iis_regs[1], 2); |
| 1564 | 1564 | freq = (double)(s3c240x_get_pclk(state, MPLLCON) / (prescaler_control_a + 1) / codeclk_table[codeclk]) * 2; // why do I have to multiply by two? |
| 1565 | 1565 | verboselog( machine, 5, "IIS - pclk %d psc_enable %d psc_a %d psc_b %d codeclk %d freq %f\n", s3c240x_get_pclk(state, MPLLCON), prescaler_enable, prescaler_control_a, prescaler_control_b, codeclk_table[codeclk], freq); |
| 1566 | | timer_adjust_periodic( state->s3c240x_iis_timer, attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 1566 | state->s3c240x_iis_timer->adjust( attotime::from_hz( freq), 0, attotime::from_hz( freq)); |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | static void s3c240x_iis_stop( running_machine *machine) |
| 1570 | 1570 | { |
| 1571 | 1571 | gp32_state *state = machine->driver_data<gp32_state>(); |
| 1572 | 1572 | verboselog( machine, 1, "IIS stop\n"); |
| 1573 | | timer_adjust_oneshot( state->s3c240x_iis_timer, attotime::never, 0); |
| 1573 | state->s3c240x_iis_timer->adjust( attotime::never); |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | static void s3c240x_iis_recalc( running_machine *machine) |
src/mess/drivers/gba.c
| r10326 | r10327 | |
| 117 | 117 | |
| 118 | 118 | // printf("dma complete: ch %d\n", ch); |
| 119 | 119 | |
| 120 | | timer_adjust_oneshot(state->dma_timer[ch], attotime::never, 0); |
| 120 | state->dma_timer[ch]->adjust(attotime::never); |
| 121 | 121 | |
| 122 | 122 | ctrl = state->dma_regs[(ch*3)+2] >> 16; |
| 123 | 123 | |
| r10326 | r10327 | |
| 279 | 279 | state->dma_dst[ch] = dst; |
| 280 | 280 | |
| 281 | 281 | // printf("settng DMA timer %d for %d cycs (tmr %x)\n", ch, cnt, (UINT32)state->dma_timer[ch]); |
| 282 | | // timer_adjust_oneshot(state->dma_timer[ch], ATTOTIME_IN_CYCLES(0, cnt), ch); |
| 282 | // state->dma_timer[ch]->adjust(ATTOTIME_IN_CYCLES(0, cnt), ch); |
| 283 | 283 | dma_complete(machine, NULL, ch); |
| 284 | 284 | } |
| 285 | 285 | |
| r10326 | r10327 | |
| 395 | 395 | state->timer_hz[tmr] = final; |
| 396 | 396 | time = attotime::from_hz(final); |
| 397 | 397 | GBA_ATTOTIME_NORMALIZE(time); |
| 398 | | timer_adjust_periodic(state->tmr_timer[tmr], time, tmr, time); |
| 398 | state->tmr_timer[tmr]->adjust(time, tmr, time); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // check if timers 0 or 1 are feeding directsound |
| r10326 | r10327 | |
| 521 | 521 | |
| 522 | 522 | gba_request_irq(machine, state->IF); |
| 523 | 523 | |
| 524 | | timer_adjust_oneshot(state->irq_timer, attotime::never, 0); |
| 524 | state->irq_timer->adjust(attotime::never); |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | static READ32_HANDLER( gba_io_r ) |
| r10326 | r10327 | |
| 884 | 884 | else |
| 885 | 885 | { |
| 886 | 886 | |
| 887 | | time = timer_timeelapsed(state->tmr_timer[timer]).as_double(); |
| 887 | time = state->tmr_timer[timer]->elapsed().as_double(); |
| 888 | 888 | |
| 889 | 889 | ticks = (double)(0x10000 - (state->timer_regs[timer] & 0xffff)); |
| 890 | 890 | |
| r10326 | r10327 | |
| 1711 | 1711 | { |
| 1712 | 1712 | attotime time = attotime::from_hz(final); |
| 1713 | 1713 | GBA_ATTOTIME_NORMALIZE(time); |
| 1714 | | timer_adjust_periodic(state->tmr_timer[offset], time, offset, time); |
| 1714 | state->tmr_timer[offset]->adjust(time, offset, time); |
| 1715 | 1715 | } |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| r10326 | r10327 | |
| 1852 | 1852 | // if we still have interrupts, yank the IRQ line again |
| 1853 | 1853 | if (state->IF) |
| 1854 | 1854 | { |
| 1855 | | timer_adjust_oneshot(state->irq_timer, machine->device<cpu_device>("maincpu")->clocks_to_attotime(120), 0); |
| 1855 | state->irq_timer->adjust(machine->device<cpu_device>("maincpu")->clocks_to_attotime(120)); |
| 1856 | 1856 | } |
| 1857 | 1857 | } |
| 1858 | 1858 | break; |
| r10326 | r10327 | |
| 1874 | 1874 | state->IME = ( state->IME & ~mem_mask ) | ( data & mem_mask ); |
| 1875 | 1875 | if (state->IF) |
| 1876 | 1876 | { |
| 1877 | | timer_adjust_oneshot(state->irq_timer, attotime::zero, 0); |
| 1877 | state->irq_timer->adjust(attotime::zero); |
| 1878 | 1878 | } |
| 1879 | 1879 | } |
| 1880 | 1880 | if( (mem_mask) & 0xffff0000 ) |
| r10326 | r10327 | |
| 1987 | 1987 | UINT16 insn = space->read_word( pc + 4); |
| 1988 | 1988 | data = (insn << 16) | (insn << 0); |
| 1989 | 1989 | } |
| 1990 | | logerror( "%s: unmapped program memory read from %08X = %08X & %08X\n", cpuexec_describe_context( space->machine), 0x10000000 + (offset << 2), data, mem_mask); |
| 1990 | logerror( "%s: unmapped program memory read from %08X = %08X & %08X\n", space->machine->describe_context( ), 0x10000000 + (offset << 2), data, mem_mask); |
| 1991 | 1991 | return data; |
| 1992 | 1992 | } |
| 1993 | 1993 | |
| r10326 | r10327 | |
| 2049 | 2049 | } |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | | timer_adjust_oneshot(state->hbl_timer, attotime::never, 0); |
| 2052 | state->hbl_timer->adjust(attotime::never); |
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | 2055 | static TIMER_CALLBACK( perform_scan ) |
| r10326 | r10327 | |
| 2104 | 2104 | } |
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | | timer_adjust_oneshot(state->hbl_timer, machine->primary_screen->time_until_pos(scanline, 240), 0); |
| 2108 | | timer_adjust_oneshot(state->scan_timer, machine->primary_screen->time_until_pos(( scanline + 1 ) % 228, 0), 0); |
| 2107 | state->hbl_timer->adjust(machine->primary_screen->time_until_pos(scanline, 240)); |
| 2108 | state->scan_timer->adjust(machine->primary_screen->time_until_pos(( scanline + 1 ) % 228, 0)); |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | static MACHINE_RESET( gba ) |
| r10326 | r10327 | |
| 2138 | 2138 | |
| 2139 | 2139 | state->bios_protected = 0; |
| 2140 | 2140 | |
| 2141 | | timer_adjust_oneshot(state->scan_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 2142 | | timer_adjust_oneshot(state->hbl_timer, attotime::never, 0); |
| 2143 | | timer_adjust_oneshot(state->dma_timer[0], attotime::never, 0); |
| 2144 | | timer_adjust_oneshot(state->dma_timer[1], attotime::never, 1); |
| 2145 | | timer_adjust_oneshot(state->dma_timer[2], attotime::never, 2); |
| 2146 | | timer_adjust_oneshot(state->dma_timer[3], attotime::never, 3); |
| 2141 | state->scan_timer->adjust(machine->primary_screen->time_until_pos(0, 0)); |
| 2142 | state->hbl_timer->adjust(attotime::never); |
| 2143 | state->dma_timer[0]->adjust(attotime::never); |
| 2144 | state->dma_timer[1]->adjust(attotime::never, 1); |
| 2145 | state->dma_timer[2]->adjust(attotime::never, 2); |
| 2146 | state->dma_timer[3]->adjust(attotime::never, 3); |
| 2147 | 2147 | |
| 2148 | 2148 | state->fifo_a_ptr = state->fifo_b_ptr = 17; // indicate empty |
| 2149 | 2149 | state->fifo_a_in = state->fifo_b_in = 17; |
| r10326 | r10327 | |
| 2178 | 2178 | /* create a timer to fire scanline functions */ |
| 2179 | 2179 | state->scan_timer = machine->scheduler().timer_alloc(FUNC(perform_scan)); |
| 2180 | 2180 | state->hbl_timer = machine->scheduler().timer_alloc(FUNC(perform_hbl)); |
| 2181 | | timer_adjust_oneshot(state->scan_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 2181 | state->scan_timer->adjust(machine->primary_screen->time_until_pos(0, 0)); |
| 2182 | 2182 | |
| 2183 | 2183 | /* and one for each DMA channel */ |
| 2184 | 2184 | state->dma_timer[0] = machine->scheduler().timer_alloc(FUNC(dma_complete)); |
| 2185 | 2185 | state->dma_timer[1] = machine->scheduler().timer_alloc(FUNC(dma_complete)); |
| 2186 | 2186 | state->dma_timer[2] = machine->scheduler().timer_alloc(FUNC(dma_complete)); |
| 2187 | 2187 | state->dma_timer[3] = machine->scheduler().timer_alloc(FUNC(dma_complete)); |
| 2188 | | timer_adjust_oneshot(state->dma_timer[0], attotime::never, 0); |
| 2189 | | timer_adjust_oneshot(state->dma_timer[1], attotime::never, 1); |
| 2190 | | timer_adjust_oneshot(state->dma_timer[2], attotime::never, 2); |
| 2191 | | timer_adjust_oneshot(state->dma_timer[3], attotime::never, 3); |
| 2188 | state->dma_timer[0]->adjust(attotime::never); |
| 2189 | state->dma_timer[1]->adjust(attotime::never, 1); |
| 2190 | state->dma_timer[2]->adjust(attotime::never, 2); |
| 2191 | state->dma_timer[3]->adjust(attotime::never, 3); |
| 2192 | 2192 | |
| 2193 | 2193 | /* also one for each timer (heh) */ |
| 2194 | 2194 | state->tmr_timer[0] = machine->scheduler().timer_alloc(FUNC(timer_expire)); |
| 2195 | 2195 | state->tmr_timer[1] = machine->scheduler().timer_alloc(FUNC(timer_expire)); |
| 2196 | 2196 | state->tmr_timer[2] = machine->scheduler().timer_alloc(FUNC(timer_expire)); |
| 2197 | 2197 | state->tmr_timer[3] = machine->scheduler().timer_alloc(FUNC(timer_expire)); |
| 2198 | | timer_adjust_oneshot(state->tmr_timer[0], attotime::never, 0); |
| 2199 | | timer_adjust_oneshot(state->tmr_timer[1], attotime::never, 1); |
| 2200 | | timer_adjust_oneshot(state->tmr_timer[2], attotime::never, 2); |
| 2201 | | timer_adjust_oneshot(state->tmr_timer[3], attotime::never, 3); |
| 2198 | state->tmr_timer[0]->adjust(attotime::never); |
| 2199 | state->tmr_timer[1]->adjust(attotime::never, 1); |
| 2200 | state->tmr_timer[2]->adjust(attotime::never, 2); |
| 2201 | state->tmr_timer[3]->adjust(attotime::never, 3); |
| 2202 | 2202 | |
| 2203 | 2203 | /* and an IRQ handling timer */ |
| 2204 | 2204 | state->irq_timer = machine->scheduler().timer_alloc(FUNC(handle_irq)); |
| 2205 | | timer_adjust_oneshot(state->irq_timer, attotime::never, 0); |
| 2205 | state->irq_timer->adjust(attotime::never); |
| 2206 | 2206 | |
| 2207 | 2207 | gba_video_start(machine); |
| 2208 | 2208 | } |