Fixed driver_device OVERRIDE macros to work with devices, report_bad_device_cast contains the name of the device as well as the id & modernised psx palette_init. (nw)

This commit is contained in:
smf- 2013-07-15 15:30:44 +00:00
parent f42bf8d02e
commit 134615242c
4 changed files with 14 additions and 18 deletions

View File

@ -53,29 +53,29 @@
// core machine callbacks
#define MCFG_MACHINE_START_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_START, driver_callback_delegate(&_class::MACHINE_START_NAME(_func), #_class "::machine_start_" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_MACHINE_START, driver_callback_delegate(&_class::MACHINE_START_NAME(_func), #_class "::machine_start_" #_func, downcast<_class *>(owner)));
#define MCFG_MACHINE_RESET_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_MACHINE_RESET, driver_callback_delegate(&_class::MACHINE_RESET_NAME(_func), #_class "::machine_reset_" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_MACHINE_RESET, driver_callback_delegate(&_class::MACHINE_RESET_NAME(_func), #_class "::machine_reset_" #_func, downcast<_class *>(owner)));
// core sound callbacks
#define MCFG_SOUND_START_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_START, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_SOUND_START, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(owner)));
#define MCFG_SOUND_RESET_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_SOUND_RESET, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_SOUND_RESET, driver_callback_delegate(&_class::_func, #_class "::" #_func, downcast<_class *>(owner)));
// core video callbacks
#define MCFG_PALETTE_INIT_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_PALETTE_INIT, driver_callback_delegate(&_class::PALETTE_INIT_NAME(_func), #_class "::palette_init_" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_PALETTE_INIT, driver_callback_delegate(&_class::PALETTE_INIT_NAME(_func), #_class "::palette_init_" #_func, downcast<_class *>(owner)));
#define MCFG_VIDEO_START_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_START, driver_callback_delegate(&_class::VIDEO_START_NAME(_func), #_class "::video_start_" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_VIDEO_START, driver_callback_delegate(&_class::VIDEO_START_NAME(_func), #_class "::video_start_" #_func, downcast<_class *>(owner)));
#define MCFG_VIDEO_RESET_OVERRIDE(_class, _func) \
driver_device::static_set_callback(*owner, driver_device::CB_VIDEO_RESET, driver_callback_delegate(&_class::VIDEO_RESET_NAME(_func), #_class "::video_reset_" #_func, downcast<_class *>(&config.root_device())));
driver_device::static_set_callback(config.root_device(), driver_device::CB_VIDEO_RESET, driver_callback_delegate(&_class::VIDEO_RESET_NAME(_func), #_class "::video_reset_" #_func, downcast<_class *>(owner)));

View File

@ -20,6 +20,6 @@ void report_bad_cast(const std::type_info &src_type, const std::type_info &dst_t
void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type)
{
throw emu_fatalerror("Error: bad downcast<> or device<>. Tried to convert the device %s of type %s to a %s, which are incompatible.\n",
dev->tag(), src_type.name(), dst_type.name());
throw emu_fatalerror("Error: bad downcast<> or device<>. Tried to convert the device %s (%s) of type %s to a %s, which are incompatible.\n",
dev->tag(), dev->name(), src_type.name(), dst_type.name());
}

View File

@ -7,7 +7,6 @@
#include "emu.h"
#include "video/psx.h"
#include "drivlgcy.h"
#define VERBOSE_LEVEL ( 0 )
@ -3779,13 +3778,13 @@ void psxgpu_device::lightgun_set( int n_x, int n_y )
n_lightgun_y = n_y;
}
PALETTE_INIT( psx )
PALETTE_INIT_MEMBER( psxgpu_device, psx )
{
UINT32 n_colour;
for( n_colour = 0; n_colour < 0x10000; n_colour++ )
{
palette_set_color_rgb( machine, n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
palette_set_color_rgb( machine(), n_colour, pal5bit(n_colour >> 0), pal5bit(n_colour >> 5), pal5bit(n_colour >> 10) );
}
}
@ -3799,12 +3798,7 @@ MACHINE_CONFIG_FRAGMENT( psxgpu )
((screen_device *)device)->register_vblank_callback(vblank_state_delegate(FUNC(psxgpu_device::vblank), (psxgpu_device *) owner));
MCFG_PALETTE_LENGTH( 65536 )
{
device_t *original_owner = owner;
owner = owner->owner();
MCFG_PALETTE_INIT(psx)
owner = original_owner;
}
MCFG_PALETTE_INIT_OVERRIDE(psxgpu_device, psx)
MACHINE_CONFIG_END
//-------------------------------------------------

View File

@ -201,11 +201,13 @@ public:
void lightgun_set( int, int );
int vramSize;
void vblank(screen_device &screen, bool vblank_state);
DECLARE_PALETTE_INIT( psx );
protected:
virtual void device_start();
virtual void device_reset();
private:
void updatevisiblearea();
void decode_tpage( UINT32 tpage );
void FlatPolygon( int n_points );