summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-09-28 13:33:30 +1000
committer Vas Crabb <vas@vastheman.com>2020-09-28 13:33:30 +1000
commit52514f1acd4c825aee93acb93b286af1c8712807 (patch)
tree41b6125ea21d7d348e5c1ed34ae37d85ddf5d893
parent264d0d19e04f21e7bfb78e7e71f14410cf1e8046 (diff)
-bus/hp_dio/hp98544.cpp: Don't crash when cursor is outside screen area.
-imagedev/picture.cpp: Get rid of indirection to the bitmap.
-rw-r--r--src/devices/bus/a2bus/computereyes2.cpp4
-rw-r--r--src/devices/bus/a2gameio/computereyes.cpp4
-rw-r--r--src/devices/bus/hp_dio/hp98544.cpp5
-rw-r--r--src/devices/imagedev/picture.cpp19
-rw-r--r--src/devices/imagedev/picture.h4
5 files changed, 12 insertions, 24 deletions
diff --git a/src/devices/bus/a2bus/computereyes2.cpp b/src/devices/bus/a2bus/computereyes2.cpp
index 4247f2f38df..02197e964d1 100644
--- a/src/devices/bus/a2bus/computereyes2.cpp
+++ b/src/devices/bus/a2bus/computereyes2.cpp
@@ -196,8 +196,8 @@ void a2bus_computereyes2_device::write_c0nx(uint8_t offset, uint8_t data)
m_x = m_y = 0;
std::fill_n(m_a2_bitmap, 280*193, 0);
- m_bitmap = m_picture->get_bitmap();
- if (m_bitmap)
+ m_bitmap = &m_picture->get_bitmap();
+ if (m_bitmap->valid())
{
// convert arbitrary sized ARGB32 image to a 188x193 image with 256 levels of grayscale
double stepx = (double)m_bitmap->width() / 188.0;
diff --git a/src/devices/bus/a2gameio/computereyes.cpp b/src/devices/bus/a2gameio/computereyes.cpp
index 799564de0a6..2b3065e76a0 100644
--- a/src/devices/bus/a2gameio/computereyes.cpp
+++ b/src/devices/bus/a2gameio/computereyes.cpp
@@ -82,8 +82,8 @@ WRITE_LINE_MEMBER(apple2_compeyes_device::an0_w)
std::fill_n(m_a2_bitmap, 280*192, 0);
- m_bitmap = m_picture->get_bitmap();
- if (m_bitmap)
+ m_bitmap = &m_picture->get_bitmap();
+ if (m_bitmap->valid())
{
// convert arbitrary sized ARGB32 image to a 280x192 image with 256 levels of grayscale
double stepx = (double)m_bitmap->width() / 280.0;
diff --git a/src/devices/bus/hp_dio/hp98544.cpp b/src/devices/bus/hp_dio/hp98544.cpp
index fe83f227ad9..e5aced877d8 100644
--- a/src/devices/bus/hp_dio/hp98544.cpp
+++ b/src/devices/bus/hp_dio/hp98544.cpp
@@ -178,10 +178,7 @@ uint32_t dio16_98544_device::screen_update(screen_device &screen, bitmap_rgb32 &
int startx, starty, endx, endy;
m_topcat->get_cursor_pos(startx, starty, endx, endy);
-
- for (int y = starty; y <= endy; y++) {
- std::fill_n(&bitmap.pix(y, startx), endx - startx + 1, rgb_t(255,255,255));
- }
+ bitmap.fill(rgb_t(255, 255, 255), rectangle(startx, endx, starty, endy));
return 0;
}
diff --git a/src/devices/imagedev/picture.cpp b/src/devices/imagedev/picture.cpp
index f80bfb2885e..e50f2c0d4c6 100644
--- a/src/devices/imagedev/picture.cpp
+++ b/src/devices/imagedev/picture.cpp
@@ -25,8 +25,7 @@ DEFINE_DEVICE_TYPE(IMAGE_PICTURE, picture_image_device, "picture_image", "Still
picture_image_device::picture_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, IMAGE_PICTURE, tag, owner, clock),
- device_image_interface(mconfig, *this),
- m_picture(nullptr)
+ device_image_interface(mconfig, *this)
{
}
@@ -36,11 +35,6 @@ picture_image_device::picture_image_device(const machine_config &mconfig, const
picture_image_device::~picture_image_device()
{
- if (m_picture)
- {
- delete m_picture;
- m_picture = nullptr;
- }
}
@@ -50,11 +44,9 @@ void picture_image_device::device_start()
image_init_result picture_image_device::call_load()
{
- m_picture = new bitmap_argb32;
- if (png_read_bitmap(image_core_file(), *m_picture) != PNGERR_NONE)
+ if (png_read_bitmap(image_core_file(), m_picture) != PNGERR_NONE)
{
- delete m_picture;
- m_picture = nullptr;
+ m_picture.reset();
// todo: try JPEG here.
return image_init_result::FAIL;
@@ -65,9 +57,8 @@ image_init_result picture_image_device::call_load()
void picture_image_device::call_unload()
{
- if (m_picture)
+ if (m_picture.valid())
{
- delete m_picture;
- m_picture = nullptr;
+ m_picture.reset();
}
}
diff --git a/src/devices/imagedev/picture.h b/src/devices/imagedev/picture.h
index 60f0eb8224a..ce9b71c57a6 100644
--- a/src/devices/imagedev/picture.h
+++ b/src/devices/imagedev/picture.h
@@ -41,14 +41,14 @@ public:
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "png"; }
- bitmap_argb32 *get_bitmap() { return m_picture; }
+ bitmap_argb32 &get_bitmap() { return m_picture; }
protected:
// device-level overrides
virtual void device_start() override;
private:
- bitmap_argb32 *m_picture;
+ bitmap_argb32 m_picture;
};