diff options
author | David Haywood <28625134+DavidHaywood@users.noreply.github.com> | 2019-10-28 21:23:46 +0000 |
---|---|---|
committer | ajrhacker <ajrhacker@users.noreply.github.com> | 2019-10-28 17:23:46 -0400 |
commit | d660d1d5b3e7b9a39042bf6eb925294fd8a3bda1 (patch) | |
tree | 896d90a8bf50d769752b46e6d2b5e7ef563c640e /src/devices/machine | |
parent | bc1aba36e0b00f97d159e42ede1ab58603894338 (diff) |
promoted to WORKING (pvmil - SunPlus) (#5818)
* pvmil - map inputs, promote to working
* put SunPlus RNG on a timer, so that the pvmil questions are actually in a random order (nw)
Diffstat (limited to 'src/devices/machine')
-rw-r--r-- | src/devices/machine/spg2xx_io.cpp | 28 | ||||
-rw-r--r-- | src/devices/machine/spg2xx_io.h | 5 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/devices/machine/spg2xx_io.cpp b/src/devices/machine/spg2xx_io.cpp index f396567307a..37768895396 100644 --- a/src/devices/machine/spg2xx_io.cpp +++ b/src/devices/machine/spg2xx_io.cpp @@ -113,6 +113,9 @@ void spg2xx_io_device::device_start() m_timer_src_c = timer_alloc(TIMER_SRC_C); m_timer_src_c->adjust(attotime::never); + m_rng_timer = timer_alloc(TIMER_RNG); + m_rng_timer->adjust(attotime::never); + save_item(NAME(m_timer_a_preload)); save_item(NAME(m_timer_b_preload)); save_item(NAME(m_timer_b_divisor)); @@ -155,6 +158,9 @@ void spg2xx_io_device::device_reset() m_4khz_timer->adjust(attotime::from_hz(4096), 0, attotime::from_hz(4096)); + m_rng_timer->adjust(attotime::from_hz(1234), 0, attotime::from_hz(1234)); // timer value is arbitrary, maybe should match system clock, but that would result in heavy switching + + m_2khz_divider = 0; m_1khz_divider = 0; m_4hz_divider = 0; @@ -177,6 +183,15 @@ void spg2xx_io_device::uart_rx(uint8_t data) } } +uint16_t spg2xx_io_device::clock_rng(int which) +{ + const uint16_t value = m_io_regs[0x2c + which]; + m_io_regs[0x2c + which] = ((value << 1) | (BIT(value, 14) ^ BIT(value, 13))) & 0x7fff; + return value; +} + + + READ16_MEMBER(spg2xx_io_device::io_r) { static const char *const gpioregs[] = { "GPIO Data Port", "GPIO Buffer Port", "GPIO Direction Port", "GPIO Attribute Port", "GPIO IRQ/Latch Port" }; @@ -256,16 +271,12 @@ READ16_MEMBER(spg2xx_io_device::io_r) case 0x2c: // PRNG 0 { - const uint16_t value = m_io_regs[0x2c]; - m_io_regs[0x2c] = ((value << 1) | (BIT(value, 14) ^ BIT(value, 13))) & 0x7fff; - return value; + return clock_rng(0); } case 0x2d: // PRNG 1 { - const uint16_t value = m_io_regs[0x2d]; - m_io_regs[0x2d] = ((value << 1) | (BIT(value, 14) ^ BIT(value, 13))) & 0x7fff; - return value; + return clock_rng(1); } case 0x2e: // FIQ Source Select @@ -1099,6 +1110,11 @@ void spg2xx_io_device::device_timer(emu_timer &timer, device_timer_id id, int pa case TIMER_SRC_C: update_timer_c_src(); break; + + case TIMER_RNG: + clock_rng(0); + clock_rng(1); + break; } } diff --git a/src/devices/machine/spg2xx_io.h b/src/devices/machine/spg2xx_io.h index a077d8554be..d1ddd573283 100644 --- a/src/devices/machine/spg2xx_io.h +++ b/src/devices/machine/spg2xx_io.h @@ -66,11 +66,14 @@ protected: static const device_timer_id TIMER_4KHZ = 6; static const device_timer_id TIMER_SRC_AB = 7; static const device_timer_id TIMER_SRC_C = 8; + static const device_timer_id TIMER_RNG = 9; virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + uint16_t clock_rng(int which); + void update_porta_special_modes(); void update_portb_special_modes(); void do_gpio(uint32_t offset, bool write); @@ -135,6 +138,8 @@ protected: emu_timer *m_uart_tx_timer; emu_timer *m_uart_rx_timer; + emu_timer *m_rng_timer; + required_device<unsp_device> m_cpu; required_device<screen_device> m_screen; |