diff options
author | 2011-04-27 05:11:18 +0000 | |
---|---|---|
committer | 2011-04-27 05:11:18 +0000 | |
commit | 919913f118760c0ca41ab63512bd5c106f6fd840 (patch) | |
tree | cd6c115c8e9c5280ac4bd16eabfe69c7341151c2 /src/emu/screen.h | |
parent | 84f2c31f7d6f6c667427b1d60c83e6dc9f420d60 (diff) |
Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this
environment. This in general greatly simplifies writing a modern
device. [Aaron Giles]
General notes:
* some more cleanup probably needs to happen behind this change,
but I needed to get it in before the next device modernization
or import from MESS :)
* new template function device_creator which automatically defines
the static function that creates the device; use this instead of
creating a static_alloc_device_config function
* added device_stop() method which is called at around the time
the previous device_t's destructor was called; if you auto_free
anything, do it here because the machine is gone when the
destructor is called
* changed the static_set_* calls to pass a device_t & instead of
a device_config *
* for many devices, the static config structure member names over-
lapped the device's names for devcb_* functions; in these cases
the members in the interface were renamed to have a _cb suffix
* changed the driver_enumerator to only cache 100 machine_configs
because caching them all took a ton of memory; fortunately this
implementation detail is completely hidden behind the
driver_enumerator interface
* got rid of the macros for creating derived classes; doing it
manually is now clean enough that it isn't worth hiding the
details in a macro
Diffstat (limited to 'src/emu/screen.h')
-rw-r--r-- | src/emu/screen.h | 177 |
1 files changed, 74 insertions, 103 deletions
diff --git a/src/emu/screen.h b/src/emu/screen.h index 28df0a4b524..c5cc935accd 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -71,39 +71,31 @@ class render_texture; class screen_device; -// device type definition -extern const device_type SCREEN; - - // callback that is called to notify of a change in the VBLANK state typedef void (*vblank_state_changed_func)(screen_device &device, void *param, bool vblank_state); typedef UINT32 (*screen_update_func)(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect); typedef void (*screen_eof_func)(screen_device *screen, running_machine &machine); -// ======================> screen_device_config +// ======================> screen_device -class screen_device_config : public device_config +class screen_device : public device_t { - friend class screen_device; - - // construction/destruction - screen_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); - + friend class render_manager; + public: - // allocators - static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); - virtual device_t *alloc_device(running_machine &machine) const; + // construction/destruction + screen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ~screen_device(); // configuration readers - screen_device_config *next_screen() const { return downcast<screen_device_config *>(typenext()); } screen_type_enum screen_type() const { return m_type; } int width() const { return m_width; } int height() const { return m_height; } const rectangle &visible_area() const { return m_visarea; } bool oldstyle_vblank_supplied() const { return m_oldstyle_vblank_supplied; } - attoseconds_t refresh() const { return m_refresh; } - attoseconds_t vblank() const { return m_vblank; } + attoseconds_t refresh_attoseconds() const { return m_refresh; } + attoseconds_t vblank_attoseconds() const { return m_vblank; } bitmap_format format() const { return m_format; } float xoffset() const { return m_xoffset; } float yoffset() const { return m_yoffset; } @@ -112,57 +104,19 @@ public: bool have_screen_update() const { return m_screen_update != NULL; } // inline configuration helpers - static void static_set_format(device_config *device, bitmap_format format); - static void static_set_type(device_config *device, screen_type_enum type); - static void static_set_raw(device_config *device, UINT32 pixclock, UINT16 htotal, UINT16 hbend, UINT16 hbstart, UINT16 vtotal, UINT16 vbend, UINT16 vbstart); - static void static_set_refresh(device_config *device, attoseconds_t rate); - static void static_set_vblank_time(device_config *device, attoseconds_t time); - static void static_set_size(device_config *device, UINT16 width, UINT16 height); - static void static_set_visarea(device_config *device, INT16 minx, INT16 maxx, INT16 miny, INT16 maxy); - static void static_set_default_position(device_config *device, double xscale, double xoffs, double yscale, double yoffs); - static void static_set_screen_update(device_config *device, screen_update_func callback); - static void static_set_screen_eof(device_config *device, screen_eof_func callback); - -private: - // device_config overrides - virtual bool device_validity_check(emu_options &options, const game_driver &driver) const; - - // inline configuration data - screen_type_enum m_type; // type of screen - int m_width, m_height; // default total width/height (HTOTAL, VTOTAL) - rectangle m_visarea; // default visible area (HBLANK end/start, VBLANK end/start) - bool m_oldstyle_vblank_supplied; // MCFG_SCREEN_VBLANK_TIME macro used - attoseconds_t m_refresh; // default refresh period - attoseconds_t m_vblank; // duration of a VBLANK - bitmap_format m_format; // bitmap format - float m_xoffset, m_yoffset; // default X/Y offsets - float m_xscale, m_yscale; // default X/Y scale factor - screen_update_func m_screen_update; // screen update callback - screen_eof_func m_screen_eof; // screen eof callback -}; - - -// ======================> screen_device - -class screen_device : public device_t -{ - friend class screen_device_config; - friend class render_manager; - friend resource_pool_object<screen_device>::~resource_pool_object(); - - // construction/destruction - screen_device(running_machine &_machine, const screen_device_config &config); - virtual ~screen_device(); + static void static_set_format(device_t &device, bitmap_format format); + static void static_set_type(device_t &device, screen_type_enum type); + static void static_set_raw(device_t &device, UINT32 pixclock, UINT16 htotal, UINT16 hbend, UINT16 hbstart, UINT16 vtotal, UINT16 vbend, UINT16 vbstart); + static void static_set_refresh(device_t &device, attoseconds_t rate); + static void static_set_vblank_time(device_t &device, attoseconds_t time); + static void static_set_size(device_t &device, UINT16 width, UINT16 height); + static void static_set_visarea(device_t &device, INT16 minx, INT16 maxx, INT16 miny, INT16 maxy); + static void static_set_default_position(device_t &device, double xscale, double xoffs, double yscale, double yoffs); + static void static_set_screen_update(device_t &device, screen_update_func callback); + static void static_set_screen_eof(device_t &device, screen_eof_func callback); -public: // information getters - const screen_device_config &config() const { return m_config; } screen_device *next_screen() const { return downcast<screen_device *>(typenext()); } - screen_type_enum screen_type() const { return m_config.m_type; } - int width() const { return m_width; } - int height() const { return m_height; } - const rectangle &visible_area() const { return m_visarea; } - bitmap_format format() const { return m_config.m_format; } render_container &container() const { assert(m_container != NULL); return *m_container; } bool screen_update(bitmap_t &bitmap, const rectangle &cliprect); void screen_eof(); @@ -194,7 +148,7 @@ public: // additional helpers void register_vblank_callback(vblank_state_changed_func vblank_callback, void *param); - bitmap_t *alloc_compatible_bitmap(int width = 0, int height = 0) { return auto_bitmap_alloc(machine(), (width == 0) ? m_width : width, (height == 0) ? m_height : height, m_config.m_format); } + bitmap_t *alloc_compatible_bitmap(int width = 0, int height = 0) { return auto_bitmap_alloc(machine(), (width == 0) ? m_width : width, (height == 0) ? m_height : height, format()); } // internal to the video system bool update_quads(); @@ -206,7 +160,9 @@ public: private: // device-level overrides + virtual bool device_validity_check(emu_options &options, const game_driver &driver) const; virtual void device_start(); + virtual void device_stop(); virtual void device_post_load(); // internal helpers @@ -230,39 +186,49 @@ private: void finalize_burnin(); void load_effect_overlay(const char *filename); + // inline configuration data + screen_type_enum m_type; // type of screen + bool m_oldstyle_vblank_supplied; // MCFG_SCREEN_VBLANK_TIME macro used + attoseconds_t m_refresh; // default refresh period + attoseconds_t m_vblank; // duration of a VBLANK + bitmap_format m_format; // bitmap format + float m_xoffset, m_yoffset; // default X/Y offsets + float m_xscale, m_yscale; // default X/Y scale factor + screen_update_func m_screen_update; // screen update callback + screen_eof_func m_screen_eof; // screen eof callback + // internal state - const screen_device_config &m_config; - render_container * m_container; // pointer to our container + render_container * m_container; // pointer to our container // dimensions - int m_width; // current width (HTOTAL) - int m_height; // current height (VTOTAL) - rectangle m_visarea; // current visible area (HBLANK end/start, VBLANK end/start) + int m_width; // current width (HTOTAL) + int m_height; // current height (VTOTAL) + rectangle m_visarea; // current visible area (HBLANK end/start, VBLANK end/start) // textures and bitmaps - render_texture * m_texture[2]; // 2x textures for the screen bitmap - bitmap_t * m_bitmap[2]; // 2x bitmaps for rendering - bitmap_t * m_burnin; // burn-in bitmap - UINT8 m_curbitmap; // current bitmap index - UINT8 m_curtexture; // current texture index - INT32 m_texture_format; // texture format of bitmap for this screen - bool m_changed; // has this bitmap changed? - INT32 m_last_partial_scan; // scanline of last partial update - bitmap_t * m_screen_overlay_bitmap;// screen overlay bitmap + render_texture * m_texture[2]; // 2x textures for the screen bitmap + bitmap_t * m_bitmap[2]; // 2x bitmaps for rendering + bitmap_t * m_burnin; // burn-in bitmap + UINT8 m_curbitmap; // current bitmap index + UINT8 m_curtexture; // current texture index + INT32 m_texture_format; // texture format of bitmap for this screen + bool m_changed; // has this bitmap changed? + INT32 m_last_partial_scan; // scanline of last partial update + bitmap_t * m_screen_overlay_bitmap; // screen overlay bitmap // screen timing - attoseconds_t m_frame_period; // attoseconds per frame - attoseconds_t m_scantime; // attoseconds per scanline - attoseconds_t m_pixeltime; // attoseconds per pixel - attoseconds_t m_vblank_period; // attoseconds per VBLANK period - attotime m_vblank_start_time; // time of last VBLANK start - attotime m_vblank_end_time; // time of last VBLANK end - emu_timer * m_vblank_begin_timer; // timer to signal VBLANK start - emu_timer * m_vblank_end_timer; // timer to signal VBLANK end - emu_timer * m_scanline0_timer; // scanline 0 timer - emu_timer * m_scanline_timer; // scanline timer - UINT64 m_frame_number; // the current frame number - UINT32 m_partial_updates_this_frame;// partial update counter this frame + attoseconds_t m_frame_period; // attoseconds per frame + attoseconds_t m_scantime; // attoseconds per scanline + attoseconds_t m_pixeltime; // attoseconds per pixel + attoseconds_t m_vblank_period; // attoseconds per VBLANK period + attotime m_vblank_start_time; // time of last VBLANK start + attotime m_vblank_end_time; // time of last VBLANK end + emu_timer * m_vblank_begin_timer; // timer to signal VBLANK start + emu_timer * m_vblank_end_timer; // timer to signal VBLANK end + emu_timer * m_scanline0_timer; // scanline 0 timer + emu_timer * m_scanline_timer; // scanline timer + UINT64 m_frame_number; // the current frame number + UINT32 m_partial_updates_this_frame;// partial update counter this frame struct callback_item { @@ -270,14 +236,18 @@ private: vblank_state_changed_func m_callback; void * m_param; }; - callback_item * m_callback_list; // list of VBLANK callbacks + callback_item * m_callback_list; // list of VBLANK callbacks }; +// device type definition +extern const device_type SCREEN; + //************************************************************************** // SCREEN DEVICE CONFIGURATION MACROS //************************************************************************** + #define SCREEN_UPDATE_NAME(name) screen_update_##name #define SCREEN_UPDATE(name) UINT32 SCREEN_UPDATE_NAME(name)(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect) #define SCREEN_UPDATE_CALL(name) SCREEN_UPDATE_NAME(name)(screen, bitmap, cliprect) @@ -296,33 +266,34 @@ private: MCFG_DEVICE_MODIFY(_tag) #define MCFG_SCREEN_FORMAT(_format) \ - screen_device_config::static_set_format(device, _format); \ + screen_device::static_set_format(*device, _format); \ #define MCFG_SCREEN_TYPE(_type) \ - screen_device_config::static_set_type(device, SCREEN_TYPE_##_type); \ + screen_device::static_set_type(*device, SCREEN_TYPE_##_type); \ #define MCFG_SCREEN_RAW_PARAMS(_pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart) \ - screen_device_config::static_set_raw(device, _pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart); + screen_device::static_set_raw(*device, _pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart); #define MCFG_SCREEN_REFRESH_RATE(_rate) \ - screen_device_config::static_set_refresh(device, HZ_TO_ATTOSECONDS(_rate)); \ + screen_device::static_set_refresh(*device, HZ_TO_ATTOSECONDS(_rate)); \ #define MCFG_SCREEN_VBLANK_TIME(_time) \ - screen_device_config::static_set_vblank_time(device, _time); \ + screen_device::static_set_vblank_time(*device, _time); \ #define MCFG_SCREEN_SIZE(_width, _height) \ - screen_device_config::static_set_size(device, _width, _height); \ + screen_device::static_set_size(*device, _width, _height); \ #define MCFG_SCREEN_VISIBLE_AREA(_minx, _maxx, _miny, _maxy) \ - screen_device_config::static_set_visarea(device, _minx, _maxx, _miny, _maxy); \ + screen_device::static_set_visarea(*device, _minx, _maxx, _miny, _maxy); \ #define MCFG_SCREEN_DEFAULT_POSITION(_xscale, _xoffs, _yscale, _yoffs) \ - screen_device_config::static_set_default_position(device, _xscale, _xoffs, _yscale, _yoffs); \ + screen_device::static_set_default_position(*device, _xscale, _xoffs, _yscale, _yoffs); \ #define MCFG_SCREEN_UPDATE(_func) \ - screen_device_config::static_set_screen_update(device, SCREEN_UPDATE_NAME(_func)); \ + screen_device::static_set_screen_update(*device, SCREEN_UPDATE_NAME(_func)); \ #define MCFG_SCREEN_EOF(_func) \ - screen_device_config::static_set_screen_eof(device, SCREEN_EOF_NAME(_func)); \ + screen_device::static_set_screen_eof(*device, SCREEN_EOF_NAME(_func)); \ + #endif /* __SCREEN_H__ */ |