summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author arbee <rb6502@users.noreply.github.com>2019-08-10 07:15:48 -0400
committer arbee <rb6502@users.noreply.github.com>2019-08-10 07:15:48 -0400
commit65bcb3be2b6235f49049719243bbd37e07114f59 (patch)
treefde30a3dd94e7ccee2a1df1e8228bdb0d0d56643
parent52505e0d2fb59a37d8799900a7e5d6ac7fd673c2 (diff)
apple2: save states and file manager hotloading image support for ComputerEyes (nw)
-rw-r--r--src/devices/bus/a2gameio/computereyes.cpp48
-rw-r--r--src/devices/imagedev/picture.cpp5
2 files changed, 34 insertions, 19 deletions
diff --git a/src/devices/bus/a2gameio/computereyes.cpp b/src/devices/bus/a2gameio/computereyes.cpp
index 3614a5f0d2d..1c587f54254 100644
--- a/src/devices/bus/a2gameio/computereyes.cpp
+++ b/src/devices/bus/a2gameio/computereyes.cpp
@@ -34,30 +34,17 @@ void apple2_compeyes_device::device_add_mconfig(machine_config &config)
void apple2_compeyes_device::device_start()
{
+ save_item(NAME(m_x));
+ save_item(NAME(m_y));
+ save_item(NAME(m_an1));
+ save_item(NAME(m_an2));
+ save_item(NAME(m_an3));
+ save_item(NAME(m_level));
}
void apple2_compeyes_device::device_reset()
{
m_x = m_y = m_an1 = m_an2 = m_an3 = m_level = 0;
- m_bitmap = &m_picture->get_bitmap();
-
- // 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;
-
- std::fill_n(m_a2_bitmap, 280*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);
- }
- }
}
READ_LINE_MEMBER(apple2_compeyes_device::sw0_r)
@@ -92,6 +79,29 @@ READ_LINE_MEMBER(apple2_compeyes_device::sw1_r)
WRITE_LINE_MEMBER(apple2_compeyes_device::an0_w)
{
m_x = m_y = 0;
+
+ std::fill_n(m_a2_bitmap, 280*192, 0);
+
+ m_bitmap = &m_picture->get_bitmap();
+ if (m_bitmap)
+ {
+ // 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;
+
+
+ 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);
+ }
+ }
+ }
}
WRITE_LINE_MEMBER(apple2_compeyes_device::an1_w)
diff --git a/src/devices/imagedev/picture.cpp b/src/devices/imagedev/picture.cpp
index 2767d80a1d4..87524aa7457 100644
--- a/src/devices/imagedev/picture.cpp
+++ b/src/devices/imagedev/picture.cpp
@@ -61,4 +61,9 @@ image_init_result picture_image_device::call_load()
void picture_image_device::call_unload()
{
+ if (m_picture)
+ {
+ delete m_picture;
+ m_picture = nullptr;
+ }
}