void cs4031_device::portb_w(uint8_t data) { if (0) logerror("cs4031_device::portb_w: %02x\n", data); m_portb = (m_portb & 0xf0) | (data & 0x0f); // bit 5 forced to 1 if timer disabled if (!BIT(m_portb, 0)) m_portb |= 1 << 5; m_ctc->write_gate2(BIT(m_portb, 0)); m_write_spkr(!BIT(m_portb, 1)); // clear channel check latch? if (BIT(m_portb, 3)) m_portb &= 0xbf; }
void upd65031_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_RTC: // if a key is pressed sets the interrupt if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_read_kb(0) != 0xff) { if (LOG) logerror("uPD65031 '%s': Keyboard interrupt!\n", tag()); // awakes CPU from snooze on key down if (m_mode == STATE_SNOOZE) set_mode(STATE_AWAKE); m_sta |= STA_KEY; } else { m_sta &= ~STA_KEY; } // hold clock at reset? - in this mode it doesn't update if (!(m_com & COM_RESTIM)) { bool irq_change = false; // update 5 millisecond counter m_tim[0]++; // tick if (m_tim[0] & 1) { // set tick int has occurred if (m_tmk & TSTA_TICK) { m_tsta |= TSTA_TICK; irq_change = true; } } if (m_tim[0] == 200) { m_tim[0] = 0; // set seconds int has occurred if (m_tmk & TSTA_SEC) { m_tsta |= TSTA_SEC; irq_change = true; } m_tim[1]++; if (m_tim[1] == 60) { // set minutes int has occurred if (m_tmk & TSTA_MIN) { m_tsta |= TSTA_MIN; irq_change = true; } m_tim[1] = 0; m_tim[2]++; if (m_tim[2] == 0) // overflowed from 255 { m_tim[3]++; if (m_tim[3] == 0) // overflowed from 255 { m_tim[4]++; if (m_tim[4] == 32) m_tim[4] = 0; } } } } if ((m_int & INT_GINT) && (m_int & INT_TIME) && irq_change && !(m_sta & STA_FLAPOPEN)) { set_mode(STATE_AWAKE); update_rtc_interrupt(); } // refresh interrupt interrupt_refresh(); } break; case TIMER_FLASH: m_flash = !m_flash; break; case TIMER_SPEAKER: m_speaker_state = !m_speaker_state; m_write_spkr(m_speaker_state ? 1 : 0); break; } }