summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2gameio/computereyes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/a2gameio/computereyes.cpp')
-rw-r--r--src/devices/bus/a2gameio/computereyes.cpp79
1 files changed, 58 insertions, 21 deletions
diff --git a/src/devices/bus/a2gameio/computereyes.cpp b/src/devices/bus/a2gameio/computereyes.cpp
index 1c587f54254..03de502df9c 100644
--- a/src/devices/bus/a2gameio/computereyes.cpp
+++ b/src/devices/bus/a2gameio/computereyes.cpp
@@ -9,12 +9,40 @@
#include "emu.h"
#include "bus/a2gameio/computereyes.h"
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
+#include "imagedev/picture.h"
-// device type definition
-DEFINE_DEVICE_TYPE(APPLE2_COMPUTEREYES, apple2_compeyes_device, "a2ceyes", "Digital Vision ComputerEyes")
+#include "bitmap.h"
+
+
+namespace {
+
+// ======================> apple2_compeyes_device
+
+class apple2_compeyes_device : public device_t, public device_a2gameio_interface
+{
+public:
+ // construction/destruction
+ apple2_compeyes_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ // device-level overrides
+ virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
+ virtual void device_start() override ATTR_COLD;
+ virtual void device_reset() override ATTR_COLD;
+
+ // device_a2gameio_interface overrides
+ virtual int sw0_r() override;
+ virtual int sw1_r() override;
+ virtual void an0_w(int state) override;
+ virtual void an1_w(int state) override;
+ virtual void an2_w(int state) override;
+ virtual void an3_w(int state) override;
+
+private:
+ required_device<picture_image_device> m_picture;
+ int m_x, m_y, m_an1, m_an2, m_an3, m_level;
+ u8 m_a2_bitmap[280*192];
+};
//**************************************************************************
// DEVICE IMPLEMENTATION
@@ -47,12 +75,12 @@ void apple2_compeyes_device::device_reset()
m_x = m_y = m_an1 = m_an2 = m_an3 = m_level = 0;
}
-READ_LINE_MEMBER(apple2_compeyes_device::sw0_r)
+int apple2_compeyes_device::sw0_r()
{
return 0;
}
-READ_LINE_MEMBER(apple2_compeyes_device::sw1_r)
+int apple2_compeyes_device::sw1_r()
{
// to avoid triggering the self-test on //e, return only 0
// for the first 2 seconds of emulation.
@@ -76,48 +104,57 @@ READ_LINE_MEMBER(apple2_compeyes_device::sw1_r)
return res;
}
-WRITE_LINE_MEMBER(apple2_compeyes_device::an0_w)
+void apple2_compeyes_device::an0_w(int state)
{
m_x = m_y = 0;
std::fill_n(m_a2_bitmap, 280*192, 0);
- m_bitmap = &m_picture->get_bitmap();
- if (m_bitmap)
+ const bitmap_argb32 &bitmap = m_picture->get_bitmap();
+ if (bitmap.valid())
{
// convert arbitrary sized ARGB32 image to a 280x192 image with 256 levels of grayscale
- double stepx = (double)m_bitmap->width() / 280.0;
- double stepy = (double)m_bitmap->height() / 192.0;
-
+ double stepx = (double)bitmap.width() / 280.0;
+ double stepy = (double)bitmap.height() / 192.0;
for (int y = 0; y < 192; y++)
{
for (int x = 0; x < 280; x++)
{
- u32 pixel = m_bitmap->pix((int)((double)y * stepy), (int)((double)x * stepx));
- double mono = ((0.2126 * (double)(((pixel>>16) & 0xff) / 255.0)) +
- (0.7152 * (double)(((pixel>>8) & 0xff) / 255.0)) +
- (0.0722 * (double)((pixel& 0xff) / 255.0)));
- m_a2_bitmap[(y*280)+x] = (u8)(mono * 255.0);
+ u32 pixel = bitmap.pix(int((double)y * stepy), int((double)x * stepx));
+ double mono = ((0.2126 * double(((pixel>>16) & 0xff) / 255.0)) +
+ (0.7152 * double(((pixel>>8) & 0xff) / 255.0)) +
+ (0.0722 * double((pixel& 0xff) / 255.0)));
+ m_a2_bitmap[(y*280)+x] = u8(mono * 255.0);
}
}
}
}
-WRITE_LINE_MEMBER(apple2_compeyes_device::an1_w)
+void apple2_compeyes_device::an1_w(int state)
{
m_an1 = state;
m_level = (128 * m_an2) + (64 * m_an1) + (32 * m_an3);
}
-WRITE_LINE_MEMBER(apple2_compeyes_device::an2_w)
+void apple2_compeyes_device::an2_w(int state)
{
m_an2 = state;
m_level = (128 * m_an2) + (64 * m_an1) + (32 * m_an3);
}
-WRITE_LINE_MEMBER(apple2_compeyes_device::an3_w)
+void apple2_compeyes_device::an3_w(int state)
{
m_an3 = state;
m_level = (128 * m_an2) + (64 * m_an1) + (32 * m_an3);
}
+
+} // anonymous namespace
+
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE_PRIVATE(APPLE2_COMPUTEREYES, device_a2gameio_interface, apple2_compeyes_device, "a2ceyes", "Digital Vision ComputerEyes")