diff --git a/src/emu/clifront.c b/src/emu/clifront.c index 5231d3079d3..c0258f75b62 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -24,6 +24,8 @@ #include "drivenum.h" +#include "osdepend.h" + #include #include diff --git a/src/emu/clifront.h b/src/emu/clifront.h index 81655e60a85..a4680d27dc8 100644 --- a/src/emu/clifront.h +++ b/src/emu/clifront.h @@ -15,8 +15,9 @@ #include "emu.h" #include "cliopts.h" -#include "osdepend.h" +// don't include osd_interface in header files +class osd_interface; //************************************************************************** // TYPE DEFINITIONS diff --git a/src/emu/ioport.c b/src/emu/ioport.c index bb3dc164513..17485e4dfdb 100644 --- a/src/emu/ioport.c +++ b/src/emu/ioport.c @@ -99,6 +99,8 @@ #include "uiinput.h" #include "debug/debugcon.h" +#include "osdepend.h" + #include #include diff --git a/src/emu/machine.c b/src/emu/machine.c index 9ab3452e963..d50667f365a 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -106,6 +106,11 @@ static char giant_string_buffer[65536] = { 0 }; // RUNNING MACHINE //************************************************************************** +osd_interface &running_machine::osd() const +{ + return m_manager.osd(); +} + //------------------------------------------------- // running_machine - constructor //------------------------------------------------- diff --git a/src/emu/machine.h b/src/emu/machine.h index 052eada1417..fb813938e05 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -19,7 +19,8 @@ #include - +// forward declaration instead of osdepend.h +class osd_interface; //************************************************************************** // CONSTANTS @@ -157,7 +158,7 @@ public: const machine_config &config() const { return m_config; } device_t &root_device() const { return m_config.root_device(); } const game_driver &system() const { return m_system; } - osd_interface &osd() const { return m_manager.osd(); } + osd_interface &osd() const; machine_manager &manager() const { return m_manager; } resource_pool &respool() { return m_respool; } device_scheduler &scheduler() { return m_scheduler; } diff --git a/src/emu/mame.c b/src/emu/mame.c index 827f9ca91df..885af0396fa 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -92,6 +92,12 @@ machine_manager* machine_manager::m_manager = NULL; +osd_interface &machine_manager::osd() const +{ + return m_osd; +} + + machine_manager* machine_manager::instance(emu_options &options,osd_interface &osd) { if(!m_manager) diff --git a/src/emu/mame.h b/src/emu/mame.h index 4f2e7747d8b..427d11a1000 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -22,6 +22,7 @@ #include "webengine.h" +class osd_interface; //************************************************************************** // CONSTANTS @@ -88,7 +89,7 @@ public: static machine_manager *instance(); ~machine_manager(); - osd_interface &osd() const { return m_osd; } + osd_interface &osd() const; emu_options &options() const { return m_options; } web_engine *web() { return &m_web; } lua_engine *lua() { return &m_lua; } diff --git a/src/emu/render.h b/src/emu/render.h index 244d0e2bd56..5666e6825ee 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -46,7 +46,7 @@ #ifndef __RENDER_H__ #define __RENDER_H__ -#include "osdepend.h" +//#include "osdepend.h" #include diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c index 444d8836d07..16a3d4cf446 100644 --- a/src/emu/rendfont.c +++ b/src/emu/rendfont.c @@ -14,6 +14,7 @@ #include "emuopts.h" #include +#include "osdepend.h" #include "uismall.fh" diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h index 62ce244d69a..4db45ca0a90 100644 --- a/src/emu/rendfont.h +++ b/src/emu/rendfont.h @@ -13,6 +13,8 @@ #include "render.h" +// forward instead of include +class osd_font; //************************************************************************** // TYPE DEFINITIONS @@ -91,7 +93,7 @@ private: dynamic_array m_glyphs[256]; // array of glyph subtables dynamic_array m_rawdata; // pointer to the raw data for the font UINT64 m_rawsize; // size of the raw font data - osd_font m_osdfont; // handle to the OSD font + osd_font *m_osdfont; // handle to the OSD font // constants static const int CACHED_CHAR_SIZE = 12; diff --git a/src/emu/rendutil.h b/src/emu/rendutil.h index 5912dd9ab13..a158ded0c2a 100644 --- a/src/emu/rendutil.h +++ b/src/emu/rendutil.h @@ -12,7 +12,6 @@ #ifndef __RENDUTIL_H__ #define __RENDUTIL_H__ -#include "osdepend.h" #include "render.h" #include diff --git a/src/emu/ui/miscmenu.c b/src/emu/ui/miscmenu.c index bd3b2812e27..5ee0d78acb3 100644 --- a/src/emu/ui/miscmenu.c +++ b/src/emu/ui/miscmenu.c @@ -23,6 +23,7 @@ #include "ui/miscmenu.h" #include "ui/filemngr.h" +#include "osdepend.h" /*------------------------------------------------- ui_slider_ui_handler - pushes the slider diff --git a/src/emu/video.c b/src/emu/video.c index 2cc4ff225f2..1a7983606b0 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -20,7 +20,7 @@ #include "snap.lh" - +#include "osdepend.h" //************************************************************************** // DEBUGGING diff --git a/src/emu/webengine.c b/src/emu/webengine.c index f049135687b..bc7c5fa39e8 100644 --- a/src/emu/webengine.c +++ b/src/emu/webengine.c @@ -16,7 +16,7 @@ #include "webengine.h" #include "lua.hpp" - +#include "osdepend.h" //************************************************************************** // WEB ENGINE diff --git a/src/lib/util/corefile.h b/src/lib/util/corefile.h index 8dc79ecf0a2..07ac491e1f2 100644 --- a/src/lib/util/corefile.h +++ b/src/lib/util/corefile.h @@ -14,7 +14,6 @@ #define __COREFILE_H__ #include -#include "osdcore.h" #include "astring.h" #include "coretmpl.h" diff --git a/src/lib/util/options.h b/src/lib/util/options.h index 97e062b028b..8c1f80bea93 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -11,7 +11,6 @@ #ifndef __OPTIONS_H__ #define __OPTIONS_H__ -#include "osdcore.h" #include "corefile.h" #include "tagmap.h" diff --git a/src/mess/includes/msx.h b/src/mess/includes/msx.h index 4274bafeabe..b2e73582297 100644 --- a/src/mess/includes/msx.h +++ b/src/mess/includes/msx.h @@ -24,7 +24,6 @@ #include "formats/basicdsk.h" #include "formats/fmsx_cas.h" #include "formats/msx_dsk.h" -//#include "osdepend.h" #include "hashfile.h" #include "machine/wd_fdc.h" #include "imagedev/floppy.h" diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c index 2395fa461df..74de4ec4540 100644 --- a/src/osd/modules/lib/osdobj_common.c +++ b/src/osd/modules/lib/osdobj_common.c @@ -346,7 +346,7 @@ void osd_common_t::customize_input_type_list(simple_list &type // font with the given name //------------------------------------------------- -osd_font osd_common_t::font_open(const char *name, int &height) +osd_font *osd_common_t::font_open(const char *name, int &height) { return NULL; } @@ -357,7 +357,7 @@ osd_font osd_common_t::font_open(const char *name, int &height) // a given OSD font //------------------------------------------------- -void osd_common_t::font_close(osd_font font) +void osd_common_t::font_close(osd_font *font) { } @@ -370,7 +370,7 @@ void osd_common_t::font_close(osd_font font) // pixel of a black & white font //------------------------------------------------- -bool osd_common_t::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) +bool osd_common_t::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { return false; } diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 3a9ee4d9783..42e211853d6 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -153,9 +153,9 @@ public: virtual void customize_input_type_list(simple_list &typelist); // font overridables - virtual osd_font font_open(const char *name, int &height); - virtual void font_close(osd_font font); - virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual osd_font *font_open(const char *name, int &height); + virtual void font_close(osd_font *font); + virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); // video overridables virtual void *get_slider_list(); diff --git a/src/osd/osdcore.c b/src/osd/osdcore.c index 41214b3c852..5079f8be2d6 100644 --- a/src/osd/osdcore.c +++ b/src/osd/osdcore.c @@ -53,8 +53,10 @@ static output_delegate output_cb[OSD_OUTPUT_CHANNEL_COUNT] = output_delegate osd_set_output_channel(output_channel channel, output_delegate callback) { - assert(channel < OSD_OUTPUT_CHANNEL_COUNT); - assert(!callback.isnull()); + if (!(channel < OSD_OUTPUT_CHANNEL_COUNT) || callback.isnull()) + { + throw std::exception(); + } /* return the originals if requested */ output_delegate prevcb = output_cb[channel]; diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 9e18bc9691f..4a1de30af1e 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -27,7 +27,7 @@ class input_type_entry; // FIXME: including emu.h does not work because emu. //============================================================ // FIXME: We can do better than this -typedef void *osd_font; +class osd_font; // ======================> osd_interface @@ -53,9 +53,9 @@ public: virtual void customize_input_type_list(simple_list &typelist) = 0; // font overridables - virtual osd_font font_open(const char *name, int &height) = 0; - virtual void font_close(osd_font font) = 0; - virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; + virtual osd_font *font_open(const char *name, int &height) = 0; + virtual void font_close(osd_font *font) = 0; + virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; // video overridables virtual void *get_slider_list() = 0; // FIXME: returns slider_state * diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index 57b21f8f02e..c6cc098592d 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -134,11 +134,12 @@ public: const HashT hash() const { return m_hash; } const UINT32 flags() const { return m_flags; } const bool is_pixels_owned() const { // do we own / allocated it ? - return m_sdl_access == SDL_TEXTUREACCESS_STATIC - && m_copyinfo->func != NULL ; + return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) + && (m_copyinfo->func != NULL)) ; } private: + Uint32 m_sdl_access; SDL_Renderer * m_renderer; render_texinfo m_texinfo; // copy of the texture info HashT m_hash; // hash value for the texture (must be >= pointer size) @@ -149,7 +150,6 @@ private: int m_format; // texture format SDL_BlendMode m_sdl_blendmode; - Uint32 m_sdl_access; texture_info * m_next; // next texture in the list }; @@ -490,6 +490,7 @@ static void expand_copy_info(copy_info_t *list) } } +// FIXME: machine only used to access options. int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks) { const char *stemp; @@ -1007,9 +1008,9 @@ texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsour texture_info::~texture_info() { - SDL_DestroyTexture(m_texture_id); - if ( is_pixels_owned() && m_pixels != NULL ) + if ( is_pixels_owned() && (m_pixels != NULL) ) free(m_pixels); + SDL_DestroyTexture(m_texture_id); } //============================================================ diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 2203f2c1a03..24c8d94703a 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -111,12 +111,6 @@ #endif -//============================================================ -// TYPE DEFINITIONS -//============================================================ - -typedef void *osd_font; - //============================================================ // TYPE DEFINITIONS //============================================================ @@ -193,9 +187,9 @@ public: virtual void customize_input_type_list(simple_list &typelist); // font overridables - virtual osd_font font_open(const char *name, int &height); - virtual void font_close(osd_font font); - virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual osd_font *font_open(const char *name, int &height); + virtual void font_close(osd_font *font); + virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual void video_register(); virtual void sound_register(); diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index fc402337a4a..d367e1d6d50 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -717,7 +717,13 @@ void sdl_osd_interface::init(running_machine &machine) // font with the given name //------------------------------------------------- -osd_font sdl_osd_interface::font_open(const char *_name, int &height) +class osd_font +{ +public: + CTFontRef m_font; +}; + +osd_font *sdl_osd_interface::font_open(const char *_name, int &height) { CFStringRef font_name = NULL; CTFontRef ct_font = NULL; @@ -770,7 +776,9 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) line_height += CTFontGetLeading(ct_font); height = ceilf(line_height * EXTRA_HEIGHT); - return (osd_font)ct_font; + osd_font *ret = global_alloc(osd_font); + ret->m_font = ct_font; + return ret; } //------------------------------------------------- @@ -778,14 +786,15 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) // a given OSD font //------------------------------------------------- -void sdl_osd_interface::font_close(osd_font font) +void sdl_osd_interface::font_close(osd_font *font) { - CTFontRef ct_font = (CTFontRef)font; + CTFontRef ct_font = font->m_font; if( ct_font != NULL ) { CFRelease( ct_font ); } + global_free(font); } //------------------------------------------------- @@ -796,11 +805,11 @@ void sdl_osd_interface::font_close(osd_font font) // pixel of a black & white font //------------------------------------------------- -bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) +bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { UniChar uni_char; CGGlyph glyph; - CTFontRef ct_font = (CTFontRef)font; + CTFontRef ct_font = font->m_font; const CFIndex count = 1; CGRect bounding_rect, success_rect; CGContextRef context_ref; @@ -1009,7 +1018,13 @@ static TTF_Font *search_font_config(astring name, bool bold, bool italic, bool u // font with the given name //------------------------------------------------- -osd_font sdl_osd_interface::font_open(const char *_name, int &height) +class osd_font +{ +public: + TTF_Font *m_font; +}; + +osd_font *sdl_osd_interface::font_open(const char *_name, int &height) { TTF_Font *font = (TTF_Font *)NULL; bool bakedstyles = false; @@ -1081,7 +1096,9 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) height = TTF_FontLineSkip(font); - return (osd_font)font; + osd_font *ret = global_alloc(osd_font); + ret->m_font = font; + return ret; } //------------------------------------------------- @@ -1089,13 +1106,10 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) // a given OSD font //------------------------------------------------- -void sdl_osd_interface::font_close(osd_font font) +void sdl_osd_interface::font_close(osd_font *font) { - TTF_Font *ttffont; - - ttffont = (TTF_Font *)font; - - TTF_CloseFont(ttffont); + TTF_CloseFont(font->m_font); + global_free(font); } //------------------------------------------------- @@ -1106,14 +1120,14 @@ void sdl_osd_interface::font_close(osd_font font) // pixel of a black & white font //------------------------------------------------- -bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) +bool sdl_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { TTF_Font *ttffont; SDL_Surface *drawsurf; SDL_Color fcol = { 0xff, 0xff, 0xff }; UINT16 ustr[16]; - ttffont = (TTF_Font *)font; + ttffont = font->m_font; memset(ustr,0,sizeof(ustr)); ustr[0] = (UINT16)chnum; diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 149adff2271..ef16debd34b 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -719,7 +719,7 @@ void windows_osd_interface::osd_exit() // font with the given name //------------------------------------------------- -osd_font windows_osd_interface::font_open(const char *_name, int &height) +osd_font *windows_osd_interface::font_open(const char *_name, int &height) { // accept qualifiers from the name astring name(_name); @@ -751,7 +751,7 @@ osd_font windows_osd_interface::font_open(const char *_name, int &height) // create the font height = logfont.lfHeight; - osd_font font = reinterpret_cast(CreateFontIndirect(&logfont)); + osd_font *font = reinterpret_cast(CreateFontIndirect(&logfont)); if (font == NULL) return NULL; @@ -783,7 +783,7 @@ osd_font windows_osd_interface::font_open(const char *_name, int &height) // a given OSD font //------------------------------------------------- -void windows_osd_interface::font_close(osd_font font) +void windows_osd_interface::font_close(osd_font *font) { // delete the font ojbect if (font != NULL) @@ -799,7 +799,7 @@ void windows_osd_interface::font_close(osd_font font) // pixel of a black & white font //------------------------------------------------- -bool windows_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) +bool windows_osd_interface::font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { // create a dummy DC to work with HDC dummyDC = CreateCompatibleDC(NULL); diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index f7db5752864..9d398286cbd 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -253,9 +253,9 @@ public: virtual void customize_input_type_list(simple_list &typelist); // font overridables - virtual osd_font font_open(const char *name, int &height); - virtual void font_close(osd_font font); - virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual osd_font *font_open(const char *name, int &height); + virtual void font_close(osd_font *font); + virtual bool font_get_bitmap(osd_font *font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); virtual void video_register(); virtual void sound_register();