summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/r10788.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/r10788.cpp')
-rw-r--r--src/devices/machine/r10788.cpp53
1 files changed, 19 insertions, 34 deletions
diff --git a/src/devices/machine/r10788.cpp b/src/devices/machine/r10788.cpp
index 95b23c9ec9b..fd8e69c9b3c 100644
--- a/src/devices/machine/r10788.cpp
+++ b/src/devices/machine/r10788.cpp
@@ -13,7 +13,7 @@
KTR 1 1 x x x 1 1 0 0 Transfer Keyboard Return
KTS 1 1 x x x 1 0 1 0 Transfer Keyboard Strobe
KLA 1 1 x x x 1 1 1 0 Load Display Register A
- KLB 1 1 x x x 1 1 0 1 Load Display Register A
+ KLB 1 1 x x x 1 1 0 1 Load Display Register B
KDN 1 1 x x x 0 0 1 1 Turn On Display
KAF 1 1 x x x 1 0 1 1 Turn Off A
KBF 1 1 x x x 0 1 1 1 Turn Off B
@@ -34,10 +34,13 @@
7.) KER takes a maximum of 10-bit times to complete (= 80 clocks)
Therefore, there must be at least 10 bit times between KER
and the next KTS instruction.
+ 8.) This device has only been tested on the gts1 driver. It does
+ not use the keyboard. The digit data is inverted (so it stores
+ 6 when we want to display 9).
**********************************************************************/
#include "emu.h"
-#include "machine/r10788.h"
+#include "r10788.h"
//#define VERBOSE 1
#include "logmacro.h"
@@ -64,8 +67,6 @@ r10788_device::r10788_device(const machine_config &mconfig, const char *tag, dev
*/
void r10788_device::device_start()
{
- m_display.resolve();
-
save_item(NAME(m_reg));
save_item(NAME(m_ktr));
save_item(NAME(m_kts));
@@ -77,7 +78,7 @@ void r10788_device::device_start()
save_item(NAME(m_io_counter));
save_item(NAME(m_scan_counter));
- m_timer = timer_alloc(TIMER_DISPLAY);
+ m_timer = timer_alloc(FUNC(r10788_device::display_update), this);
// recurring timer every 36 cycles
m_timer->adjust(clocks_to_attotime(36), 0, clocks_to_attotime(36));
}
@@ -99,27 +100,11 @@ void r10788_device::device_reset()
}
-/**
- * @brief r10788_device::device_timer timer event callback
- * @param timer emu_timer which fired
- * @param id timer identifier
- * @param param parameter
- * @param ptr pointer parameter
- */
-void r10788_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(r10788_device::display_update)
{
- uint8_t data;
- switch (id)
- {
- case TIMER_DISPLAY:
- data = (m_reg[0][m_scan_counter] & m_mask_a) +
- 16 * (m_reg[1][m_scan_counter] & m_mask_b);
- LOG("%s: scan counter:%2d data:%02x\n", __FUNCTION__, m_scan_counter, data);
- m_display(m_scan_counter, data, 0xff);
- break;
- default:
- LOG("%s: invalid timer id:%d\n", __FUNCTION__, id);
- }
+ uint8_t data = ((m_reg[1][m_scan_counter] & m_mask_b) << 4) | (m_reg[0][m_scan_counter] & m_mask_a);
+ LOG("display_update: scan counter:%2d data:%02x\n", m_scan_counter, data);
+ m_display(m_scan_counter, data, 0xff);
m_scan_counter = (m_scan_counter + 1) % 16;
}
@@ -135,9 +120,9 @@ void r10788_device::device_timer(emu_timer &timer, device_timer_id id, int param
*
*************************************/
-WRITE8_MEMBER( r10788_device::io_w )
+void r10788_device::io_w(offs_t offset, uint8_t data)
{
- assert(offset < 16);
+ offset &= 15;
switch (offset)
{
case KTR: // Transfer Keyboard Return
@@ -149,6 +134,7 @@ WRITE8_MEMBER( r10788_device::io_w )
m_kts = data;
break;
case KLA: // Load Display Register A
+ m_io_counter = (m_io_counter + 1) % 16;
LOG("%s: KLA [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data);
m_kla = data;
m_reg[0][m_io_counter] = m_kla;
@@ -156,21 +142,22 @@ WRITE8_MEMBER( r10788_device::io_w )
case KLB: // Load Display Register B
LOG("%s: KLB [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data);
m_klb = data;
- m_reg[1][m_io_counter] = m_kla;
+ m_reg[1][m_io_counter] = m_klb;
break;
case KDN: // Turn On Display
LOG("%s: KDN data:%02x\n", __FUNCTION__, data);
m_mask_a = 15;
m_mask_b = 15;
+ m_io_counter = 15;
break;
case KAF: // Turn Off A
LOG("%s: KAF data:%02x\n", __FUNCTION__, data);
m_mask_a = 0;
- m_mask_b &= ~3;
+ m_mask_b &= 12;
break;
case KBF: // Turn Off B
LOG("%s: KBF data:%02x\n", __FUNCTION__, data);
- m_mask_b &= ~12;
+ m_mask_b &= 3;
break;
case KER: // Reset Keyboard Error
LOG("%s: KER data:%02x\n", __FUNCTION__, data);
@@ -180,9 +167,9 @@ WRITE8_MEMBER( r10788_device::io_w )
}
-READ8_MEMBER( r10788_device::io_r )
+uint8_t r10788_device::io_r(offs_t offset)
{
- assert(offset < 16);
+ offset &= 15;
uint8_t data = 0xf;
switch (offset)
{
@@ -203,8 +190,6 @@ READ8_MEMBER( r10788_device::io_r )
m_klb = m_reg[1][m_io_counter];
data = m_klb;
LOG("%s: KLB [%2d] data:%02x\n", __FUNCTION__, m_io_counter, data);
- // FIXME: does it automagically increment at KLB write?
- m_io_counter = (m_io_counter + 1) % 16;
break;
case KDN: // Turn On Display
LOG("%s: KDN data:%02x\n", __FUNCTION__, data);