summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus')
-rw-r--r--src/devices/bus/nes_ctrl/ctrl.cpp1
-rw-r--r--src/devices/bus/nes_ctrl/ctrl.h16
-rw-r--r--src/devices/bus/nes_ctrl/zapper.cpp12
-rw-r--r--src/devices/bus/nes_ctrl/zapper.h1
4 files changed, 11 insertions, 19 deletions
diff --git a/src/devices/bus/nes_ctrl/ctrl.cpp b/src/devices/bus/nes_ctrl/ctrl.cpp
index 2724e86dcaf..bacbd952c8a 100644
--- a/src/devices/bus/nes_ctrl/ctrl.cpp
+++ b/src/devices/bus/nes_ctrl/ctrl.cpp
@@ -125,7 +125,6 @@ nes_control_port_device::~nes_control_port_device()
void nes_control_port_device::device_start()
{
m_device = dynamic_cast<device_nes_control_port_interface *>(get_card_device());
- m_brightpixel_cb.bind_relative_to(*owner());
}
diff --git a/src/devices/bus/nes_ctrl/ctrl.h b/src/devices/bus/nes_ctrl/ctrl.h
index 24a58b4f53c..27579717878 100644
--- a/src/devices/bus/nes_ctrl/ctrl.h
+++ b/src/devices/bus/nes_ctrl/ctrl.h
@@ -43,8 +43,6 @@ protected:
nes_control_port_device *m_port;
};
-#define NESCTRL_BRIGHTPIXEL_CB(name) bool name(int x, int y)
-
// ======================> nes_control_port_device
@@ -65,25 +63,11 @@ public:
nes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~nes_control_port_device();
- typedef device_delegate<bool (int x, int y)> nesctrl_brightpixel_delegate;
-
- void set_brightpixel_callback(nesctrl_brightpixel_delegate callback) { m_brightpixel_cb = callback; }
- template <class FunctionClass> void set_brightpixel_callback(const char *devname, bool (FunctionClass::*callback)(int, int), const char *name)
- {
- set_brightpixel_callback(nesctrl_brightpixel_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr)));
- }
- template <class FunctionClass> void set_brightpixel_callback(bool (FunctionClass::*callback)(int, int), const char *name)
- {
- set_brightpixel_callback(nesctrl_brightpixel_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr)));
- }
-
uint8_t read_bit0();
uint8_t read_bit34();
uint8_t read_exp(offs_t offset);
void write(uint8_t data);
- nesctrl_brightpixel_delegate m_brightpixel_cb;
-
protected:
// device-level overrides
virtual void device_start() override;
diff --git a/src/devices/bus/nes_ctrl/zapper.cpp b/src/devices/bus/nes_ctrl/zapper.cpp
index 0996c893f0f..195ed891300 100644
--- a/src/devices/bus/nes_ctrl/zapper.cpp
+++ b/src/devices/bus/nes_ctrl/zapper.cpp
@@ -8,6 +8,7 @@
#include "emu.h"
#include "zapper.h"
+#include "screen.h"
//**************************************************************************
// DEVICE DEFINITIONS
@@ -47,6 +48,7 @@ ioport_constructor nes_zapper_device::device_input_ports() const
nes_zapper_device::nes_zapper_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, NES_ZAPPER, tag, owner, clock),
+ device_video_interface(mconfig, *this),
device_nes_control_port_interface(mconfig, *this),
m_lightx(*this, "ZAPPER_X"),
m_lighty(*this, "ZAPPER_Y"),
@@ -80,11 +82,17 @@ void nes_zapper_device::device_reset()
uint8_t nes_zapper_device::read_bit34()
{
uint8_t ret = m_trigger->read();
- if (!m_port->m_brightpixel_cb.isnull() &&
- m_port->m_brightpixel_cb(m_lightx->read(), m_lighty->read()))
+
+ // get the pixel at the gun position
+ rgb_t pix = screen().pixel(m_lightx->read(), m_lighty->read());
+
+ // check if the cursor is over a bright pixel
+ // FIXME: still a gross hack
+ if (pix.r() == 0xff && pix.b() == 0xff && pix.g() > 0x90)
ret &= ~0x08; // sprite hit
else
ret |= 0x08; // no sprite hit
+
return ret;
}
diff --git a/src/devices/bus/nes_ctrl/zapper.h b/src/devices/bus/nes_ctrl/zapper.h
index 5ae68fd0a6e..5c5c60c9386 100644
--- a/src/devices/bus/nes_ctrl/zapper.h
+++ b/src/devices/bus/nes_ctrl/zapper.h
@@ -21,6 +21,7 @@
// ======================> nes_zapper_device
class nes_zapper_device : public device_t,
+ public device_video_interface,
public device_nes_control_port_interface
{
public: