summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2015-01-23 19:53:42 +0100
committer couriersud <couriersud@arcor.de>2015-01-23 19:53:42 +0100
commit4a4ae1d5ed8aaa37d5d6480ccb57eaca82fd6837 (patch)
treef59ed3b7db5c68d0b85435cf9eb559093439e9c4 /src
parentaf8034795539e015c710775a42292c52aa7fe64f (diff)
Added a generic module abstraction layer and migrated font modules to
use this layer. (nw)
Diffstat (limited to 'src')
-rw-r--r--src/osd/modules/font/font_module.h26
-rw-r--r--src/osd/modules/font/font_none.c25
-rw-r--r--src/osd/modules/font/font_osx.c32
-rw-r--r--src/osd/modules/font/font_sdl.c (renamed from src/osd/modules/font/font_unix.c)62
-rw-r--r--src/osd/modules/font/font_windows.c32
-rw-r--r--src/osd/modules/lib/osdobj_common.c33
-rw-r--r--src/osd/modules/lib/osdobj_common.h38
-rw-r--r--src/osd/modules/osdmodule.c116
-rw-r--r--src/osd/modules/osdmodule.h106
-rw-r--r--src/osd/osdepend.h11
-rw-r--r--src/osd/sdl/main.c13
-rw-r--r--src/osd/sdl/osdsdl.h3
-rw-r--r--src/osd/sdl/sdl.mak20
-rw-r--r--src/osd/sdl/sdlmain.c20
-rw-r--r--src/osd/sdl/strconv.h2
-rw-r--r--src/osd/windows/main.c22
-rw-r--r--src/osd/windows/netdev_pcap.h4
-rw-r--r--src/osd/windows/strconv.h8
-rw-r--r--src/osd/windows/windows.mak5
19 files changed, 492 insertions, 86 deletions
diff --git a/src/osd/modules/font/font_module.h b/src/osd/modules/font/font_module.h
new file mode 100644
index 00000000000..e5e5499a2f5
--- /dev/null
+++ b/src/osd/modules/font/font_module.h
@@ -0,0 +1,26 @@
+/*
+ * font_module.h
+ *
+ */
+
+#ifndef FONT_MODULE_H_
+#define FONT_MODULE_H_
+
+#include "osdepend.h"
+#include "modules/osdmodule.h"
+
+//============================================================
+// CONSTANTS
+//============================================================
+
+#define OSD_FONT_PROVIDER "uifontprovider"
+
+class font_module
+{
+public:
+ virtual ~font_module() { }
+ virtual osd_font *font_alloc() = 0;
+};
+
+
+#endif /* FONT_MODULE_H_ */
diff --git a/src/osd/modules/font/font_none.c b/src/osd/modules/font/font_none.c
index f48bf3876a2..e7a36a90732 100644
--- a/src/osd/modules/font/font_none.c
+++ b/src/osd/modules/font/font_none.c
@@ -3,7 +3,8 @@
*
*/
-#include "osdepend.h"
+#include "font_module.h"
+#include "modules/osdmodule.h"
#include "astring.h"
#include "corealloc.h"
@@ -25,11 +26,6 @@ public:
private:
};
-osd_font *osd_font_alloc()
-{
- return global_alloc(osd_font_none);
-}
-
bool osd_font_none::open(const char *font_path, const char *_name, int &height)
{
return false;
@@ -56,3 +52,20 @@ bool osd_font_none::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32
{
return false;
}
+
+class font_none : public osd_module, public font_module
+{
+public:
+ font_none()
+ : osd_module(OSD_FONT_PROVIDER, "none"), font_module()
+ {
+ }
+
+ osd_font *font_alloc()
+ {
+ return global_alloc(osd_font_none);
+ }
+};
+
+MODULE_DEFINITION(FONT_NONE, font_none)
+
diff --git a/src/osd/modules/font/font_osx.c b/src/osd/modules/font/font_osx.c
index 50858002535..6e7e62acedf 100644
--- a/src/osd/modules/font/font_osx.c
+++ b/src/osd/modules/font/font_osx.c
@@ -3,9 +3,12 @@
*
*/
-#include <Carbon/Carbon.h>
+#include "font_module.h"
+#include "modules/osdmodule.h"
+
+#ifdef SDLMAME_MACOSX
-#include "osdepend.h"
+#include <Carbon/Carbon.h>
#include "astring.h"
#include "corealloc.h"
@@ -32,11 +35,6 @@ private:
CTFontRef m_font;
};
-osd_font *osd_font_alloc()
-{
- return global_alloc(osd_font_osx);
-}
-
bool osd_font_osx::open(const char *font_path, const char *_name, int &height)
{
CFStringRef font_name = NULL;
@@ -183,3 +181,23 @@ bool osd_font_osx::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &
return bitmap.valid();
}
+
+class font_osx : public osd_module, public font_module
+{
+public:
+ font_osx()
+ : osd_module(OSD_FONT_PROVIDER, "osx"), font_module()
+ {
+ }
+
+ osd_font *font_alloc()
+ {
+ return global_alloc(osd_font_osx);
+ }
+
+};
+#else /* SDLMAME_UNIX */
+ MODULE_NOT_SUPPORTED(font_osx, OSD_FONT_PROVIDER, "osx")
+#endif
+
+MODULE_DEFINITION(FONT_OSX, font_osx)
diff --git a/src/osd/modules/font/font_unix.c b/src/osd/modules/font/font_sdl.c
index 22c60f34cca..4dcec403f1b 100644
--- a/src/osd/modules/font/font_unix.c
+++ b/src/osd/modules/font/font_sdl.c
@@ -3,6 +3,11 @@
*
*/
+#include "font_module.h"
+#include "modules/osdmodule.h"
+
+#if defined(SDLMAME_UNIX) && (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
+
#if (SDLMAME_SDL2)
#include <SDL2/SDL_ttf.h>
#else
@@ -12,7 +17,6 @@
#include <fontconfig/fontconfig.h>
#endif
-#include "osdepend.h"
#include "astring.h"
#include "corealloc.h"
@@ -25,10 +29,10 @@
// font with the given name
//-------------------------------------------------
-class osd_font_unix : public osd_font
+class osd_font_sdl : public osd_font
{
public:
- virtual ~osd_font_unix() {};
+ virtual ~osd_font_sdl() {};
virtual bool open(const char *font_path, const char *name, int &height);
virtual void close();
@@ -42,12 +46,7 @@ private:
TTF_Font *m_font;
};
-osd_font *osd_font_alloc()
-{
- return global_alloc(osd_font_unix);
-}
-
-bool osd_font_unix::open(const char *font_path, const char *_name, int &height)
+bool osd_font_sdl::open(const char *font_path, const char *_name, int &height)
{
TTF_Font *font = (TTF_Font *)NULL;
bool bakedstyles = false;
@@ -129,7 +128,7 @@ bool osd_font_unix::open(const char *font_path, const char *_name, int &height)
// a given OSD font
//-------------------------------------------------
-void osd_font_unix::close()
+void osd_font_sdl::close()
{
TTF_CloseFont(this->m_font);
}
@@ -142,7 +141,7 @@ void osd_font_unix::close()
// pixel of a black & white font
//-------------------------------------------------
-bool osd_font_unix::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
+bool osd_font_sdl::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
{
TTF_Font *ttffont;
SDL_Surface *drawsurf;
@@ -185,7 +184,7 @@ bool osd_font_unix::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT32
return bitmap.valid();
}
-TTF_Font * osd_font_unix::TTF_OpenFont_Magic(astring name, int fsize)
+TTF_Font * osd_font_sdl::TTF_OpenFont_Magic(astring name, int fsize)
{
emu_file file(OPEN_FLAG_READ);
if (file.open(name) == FILERR_NONE)
@@ -199,7 +198,7 @@ TTF_Font * osd_font_unix::TTF_OpenFont_Magic(astring name, int fsize)
return TTF_OpenFont(name.cstr(), POINT_SIZE);
}
-bool osd_font_unix::BDF_Check_Magic(astring name)
+bool osd_font_sdl::BDF_Check_Magic(astring name)
{
emu_file file(OPEN_FLAG_READ);
if (file.open(name) == FILERR_NONE)
@@ -216,7 +215,7 @@ bool osd_font_unix::BDF_Check_Magic(astring name)
}
#ifndef SDLMAME_HAIKU
-TTF_Font *osd_font_unix::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
+TTF_Font *osd_font_sdl::search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles)
{
TTF_Font *font = (TTF_Font *)NULL;
FcConfig *config;
@@ -324,3 +323,38 @@ TTF_Font *osd_font_unix::search_font_config(astring name, bool bold, bool italic
return font;
}
#endif
+
+
+class font_sdl : public osd_module, public font_module
+{
+public:
+ font_sdl()
+ : osd_module(OSD_FONT_PROVIDER, "sdl"), font_module()
+ {
+ }
+
+ osd_font *font_alloc()
+ {
+ return global_alloc(osd_font_sdl);
+ }
+
+ virtual void init()
+ {
+ if (TTF_Init() == -1)
+ {
+ osd_printf_error("SDL_ttf failed: %s\n", TTF_GetError());
+ }
+ }
+
+ virtual void exit()
+ {
+ TTF_Quit();
+ }
+};
+#else /* SDLMAME_UNIX */
+ MODULE_NOT_SUPPORTED(font_sdl, OSD_FONT_PROVIDER, "sdl")
+#endif
+
+MODULE_DEFINITION(FONT_SDL, font_sdl)
+
+
diff --git a/src/osd/modules/font/font_windows.c b/src/osd/modules/font/font_windows.c
index b42fc31cf0e..26533e1f19a 100644
--- a/src/osd/modules/font/font_windows.c
+++ b/src/osd/modules/font/font_windows.c
@@ -3,6 +3,11 @@
*
*/
+#include "font_module.h"
+#include "modules/osdmodule.h"
+
+#if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>
@@ -10,7 +15,8 @@
#include <tchar.h>
#include <io.h>
-#include "osdepend.h"
+#include "font_module.h"
+#include "modules/osdmodule.h"
#include "strconv.h"
#include "astring.h"
@@ -78,11 +84,6 @@ private:
HGDIOBJ m_font;
};
-osd_font *osd_font_alloc()
-{
- return global_alloc(osd_font_windows);
-}
-
bool osd_font_windows::open(const char *font_path, const char *_name, int &height)
{
// accept qualifiers from the name
@@ -298,3 +299,22 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT
return bitmap.valid();
}
+class font_win : public osd_module, public font_module
+{
+public:
+ font_win()
+ : osd_module(OSD_FONT_PROVIDER, "win"), font_module()
+ {
+ }
+
+ osd_font *font_alloc()
+ {
+ return global_alloc(osd_font_windows);
+ }
+
+};
+#else /* SDLMAME_UNIX */
+ MODULE_NOT_SUPPORTED(font_win, OSD_FONT_PROVIDER, "win")
+#endif
+
+MODULE_DEFINITION(FONT_WINDOWS, font_win)
diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c
index 74de4ec4540..82838700c70 100644
--- a/src/osd/modules/lib/osdobj_common.c
+++ b/src/osd/modules/lib/osdobj_common.c
@@ -20,6 +20,9 @@ extern bool g_print_verbose;
const options_entry osd_options::s_option_entries[] =
{
+ { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" },
+ { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " },
+
{ NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" },
{ OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" },
{ OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" },
@@ -106,9 +109,30 @@ osd_common_t::osd_common_t(osd_options &options)
{
}
+#define REGISTER_MODULE(_O, _X ) { extern const module_type _X; _O . register_module( _X ); }
void osd_common_t::register_options()
{
+
+ REGISTER_MODULE(m_mod_man, FONT_OSX);
+ REGISTER_MODULE(m_mod_man, FONT_WINDOWS);
+ REGISTER_MODULE(m_mod_man, FONT_SDL);
+ REGISTER_MODULE(m_mod_man, FONT_NONE);
+
+ // after initialization we know which modules are supported
+
+ const char *names[20];
+ int num;
+ m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names);
+ dynamic_array<const char *> dnames;
+ for (int i = 0; i < num; i++)
+ dnames.append(names[i]);
+ update_option(OSD_FONT_PROVIDER, dnames);
+
+
+
+
+
// Register video options and update options
video_options_add("none", NULL);
video_register();
@@ -209,6 +233,11 @@ void osd_common_t::init(running_machine &machine)
if (options.verbose())
g_print_verbose = true;
+ m_font_module = select_module_options<font_module *>(options, OSD_FONT_PROVIDER);
+
+ m_mod_man.init();
+
+
// ensure we get called on the way out
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
}
@@ -539,7 +568,9 @@ void osd_common_t::network_exit()
void osd_common_t::osd_exit()
{
- exit_subsystems();
+ m_mod_man.exit();
+
+ exit_subsystems();
}
void osd_common_t::video_options_add(const char *name, void *type)
diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h
index 42e211853d6..8ce422ea09c 100644
--- a/src/osd/modules/lib/osdobj_common.h
+++ b/src/osd/modules/lib/osdobj_common.h
@@ -14,6 +14,8 @@
#define __OSDOBJ_COMMON__
#include "osdepend.h"
+#include "modules/osdmodule.h"
+#include "modules/font/font_module.h"
#include "cliopts.h"
//============================================================
@@ -55,18 +57,6 @@
// TYPE DEFINITIONS
//============================================================
-/* FIXME: core_options inherits from osd_options. This will force any
- * future osd implementation to use the options below. Actually, these
- * options are *private* to the osd_core. This object should actually be an
- * accessor object. Later ...
- */
-
-/* FIXME: core_options inherits from osd_options. This will force any
- * future osd implementation to use the options below. Actually, these
- * options are *private* to the osd_core. This object should actually be an
- * accessor object. Later ...
- */
-
class osd_options : public cli_options
{
public:
@@ -163,6 +153,8 @@ public:
// command option overrides
virtual bool execute_command(const char *command);
+ osd_font *font_alloc() { return m_font_module->font_alloc(); }
+
// FIXME: everything below seems to be osd specific and not part of
// this INTERFACE but part of the osd IMPLEMENTATION
@@ -214,7 +206,29 @@ private:
running_machine * m_machine;
osd_options& m_options;
+ osd_module_manager m_mod_man;
+ font_module *m_font_module;
+
void update_option(const char * key, dynamic_array<const char *> &values);
+ // FIXME: should be elsewhere
+ osd_module *select_module_options(const core_options &opts, const astring &opt_name)
+ {
+ astring opt_val = opts.value(opt_name);
+ if (opt_val == "auto")
+ opt_val = "";
+ else if (!m_mod_man.type_has_name(opt_name, opt_val))
+ {
+ osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr());
+ opt_val = "";
+ }
+ return m_mod_man.select_module(opt_name, opt_val);
+ }
+
+ template<class C>
+ C select_module_options(const core_options &opts, const astring &opt_name)
+ {
+ return dynamic_cast<C>(select_module_options(opts, opt_name));
+ }
protected:
osd_sound_interface* m_sound;
diff --git a/src/osd/modules/osdmodule.c b/src/osd/modules/osdmodule.c
new file mode 100644
index 00000000000..8868d51dcea
--- /dev/null
+++ b/src/osd/modules/osdmodule.c
@@ -0,0 +1,116 @@
+/*
+ * osdmodule.c
+ *
+ */
+
+#include "modules/osdmodule.h"
+
+osd_module_manager::osd_module_manager()
+{
+ for (int i=0; i<MAX_MODULES; i++)
+ {
+ m_modules[i] = NULL;
+ m_selected[i] = NULL;
+ }
+}
+osd_module_manager::~osd_module_manager()
+{
+ for (int i = 0; m_modules[i] != NULL; i++)
+ {
+ m_modules[i]->~osd_module();
+ osd_free(m_modules[i]);
+ }
+}
+
+void osd_module_manager::register_module(const module_type &mod_type)
+{
+ osd_module *module = mod_type();
+ if (module->probe())
+ {
+ osd_printf_info("===> registered module %s %s\n", module->name(), module->type());
+
+ int i;
+ for (i = 0; m_modules[i] != NULL; i++)
+ ;
+ m_modules[i] = module;
+ }
+ else
+ {
+ osd_printf_info("===> not supported %s %s\n", module->name(), module->type());
+ module->~osd_module();
+ osd_free(module);
+ }
+}
+
+bool osd_module_manager::type_has_name(const char *type, const char *name)
+{
+ return (get_module_index(type, name) >= 0);
+}
+
+osd_module *osd_module_manager::get_module_generic(const char *type, const char *name)
+{
+ int i = get_module_index(type, name);
+ if (i>=0)
+ return m_modules[i];
+ else
+ return NULL;
+}
+
+osd_module *osd_module_manager::select_module(const char *type, const char *name)
+{
+ osd_module *m = get_module_generic(type, name);
+
+ // FIXME: check if already exists!
+ int i;
+ for (i = 0; m_selected[i] != NULL; i++)
+ ;
+ m_selected[i] = m;
+ return m;
+}
+
+void osd_module_manager::init()
+{
+ for (int i = 0; m_selected[i] != NULL; i++)
+ {
+ m_selected[i]->init();
+ }
+}
+
+void osd_module_manager::exit()
+{
+ // Find count
+ int cnt;
+ for (cnt = 0; m_selected[cnt] != NULL; cnt++)
+ ;
+ for (int i = cnt - 1; i >= 0; i--)
+ {
+ m_selected[i]->exit();
+ m_selected[i] = NULL;
+ }
+}
+
+int osd_module_manager::get_module_index(const char *type, const char *name)
+{
+ for (int i = 0; m_modules[i] != NULL; i++)
+ {
+ if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0)))
+ return i;
+ }
+ return -1;
+}
+
+void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[])
+{
+ *num = 0;
+ for (int i = 0; m_modules[i] != NULL; i++)
+ {
+ if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max))
+ {
+ names[*num] = m_modules[i]->name();
+ *num = *num + 1;
+ }
+
+ }
+}
+
+
diff --git a/src/osd/modules/osdmodule.h b/src/osd/modules/osdmodule.h
new file mode 100644
index 00000000000..06a3beab8eb
--- /dev/null
+++ b/src/osd/modules/osdmodule.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+
+ osdmodule.h
+
+ OSD module manangement
+
+*******************************************************************c********/
+
+//#pragma once
+
+#ifndef __OSDMODULE_H__
+#define __OSDMODULE_H__
+
+#include "osdcore.h"
+#include "osdepend.h"
+
+//============================================================
+// TYPE DEFINITIONS
+//============================================================
+
+class osd_module;
+
+// ======================> osd_module
+
+class osd_module
+{
+public:
+
+ osd_module(const char *type, const char *name)
+ : m_name(name), m_type(type)
+ {}
+ virtual ~osd_module() { }
+
+ const char * name() const { return m_name; }
+ const char * type() const { return m_type; }
+
+ virtual bool probe() const { return true; }
+
+ virtual void init() { }
+ virtual void exit() { }
+
+private:
+ astring m_name;
+ astring m_type;
+};
+
+// a module_type is simply a pointer to its alloc function
+typedef osd_module *(*module_type)();
+
+// this template function creates a stub which constructs a module
+template<class _ModuleClass>
+osd_module *module_creator()
+{
+ void *p = osd_malloc(sizeof(_ModuleClass));
+ return new(p) _ModuleClass;
+}
+
+class osd_module_manager
+{
+public:
+
+ static const int MAX_MODULES = 32;
+
+ osd_module_manager();
+ ~osd_module_manager();
+
+ void register_module(const module_type &mod_type);
+ bool type_has_name(const char *type, const char *name);
+
+ osd_module *get_module_generic(const char *type, const char *name);
+
+ template<class C>
+ C select_module(const char *type, const char *name = "")
+ {
+ return dynamic_cast<C>(select_module(type, name));
+ }
+
+ osd_module *select_module(const char *type, const char *name = "");
+
+ void get_module_names(const char *type, const int max, int *num, const char *names[]);
+
+ void init();
+
+ void exit();
+
+private:
+ int get_module_index(const char *type, const char *name);
+
+ osd_module *m_modules[MAX_MODULES];
+ osd_module *m_selected[MAX_MODULES];
+};
+
+#define MODULE_DEFINITION(_id, _class) \
+ extern const module_type _id ; \
+ const module_type _id = &module_creator< _class >;
+
+
+#define MODULE_NOT_SUPPORTED(_mod, _type, _name) \
+ class _mod : public osd_module { \
+ public: \
+ _mod () \
+ : osd_module(_type, _name) {} \
+ bool probe() const { return false; } \
+ };
+
+#endif /* __OSDMODULE_H__ */
diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h
index c5c1aaf285d..4e2afcae223 100644
--- a/src/osd/osdepend.h
+++ b/src/osd/osdepend.h
@@ -18,6 +18,7 @@
#include "unicode.h"
#include "cliopts.h"
+
// forward references
class input_type_entry; // FIXME: including emu.h does not work because emu.h includes osdepend.h
@@ -40,12 +41,6 @@ public:
// ======================> osd_interface
-/* FIXME: this should be replaced by a proper module implementation
- * For the time being only one font provider can be linked
- */
-
-osd_font *osd_font_alloc();
-
// description of the currently-running machine
class osd_interface
{
@@ -71,9 +66,7 @@ public:
virtual void *get_slider_list() = 0; // FIXME: returns slider_state *
// font interface
-
- // font is allocated with global_alloc; therefore use global_free!
- osd_font *font_alloc() { return osd_font_alloc(); }
+ virtual osd_font *font_alloc() = 0;
// command option overrides
virtual bool execute_command(const char *command) = 0;
diff --git a/src/osd/sdl/main.c b/src/osd/sdl/main.c
index 801adb8ca3d..da27c9ba9ba 100644
--- a/src/osd/sdl/main.c
+++ b/src/osd/sdl/main.c
@@ -1,16 +1,15 @@
+// license:BSD-3-Clause
+// copyright-holders:Aaron Giles
//============================================================
//
// main.c - Win32 main program
//
-// Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
-// Visit http://mamedev.org for licensing and usage restrictions.
-//
-// SDLMAME by Olivier Galibert and R. Belmont
-//
//============================================================
// standard windows headers
+#ifdef OSD_SDL
#define _WIN32_WINNT 0x0400
+#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
@@ -38,11 +37,13 @@ extern "C" int _tmain(int argc, TCHAR **argv)
int i, rc;
char **utf8_argv;
+#ifdef OSD_SDL
#ifdef MALLOC_DEBUG
{
extern int winalloc_in_main_code;
winalloc_in_main_code = TRUE;
#endif
+#endif
/* convert arguments to UTF-8 */
utf8_argv = (char **) malloc(argc * sizeof(*argv));
@@ -63,6 +64,7 @@ extern "C" int _tmain(int argc, TCHAR **argv)
osd_free(utf8_argv[i]);
free(utf8_argv);
+#ifdef OSD_SDL
#ifdef MALLOC_DEBUG
{
void check_unfreed_mem(void);
@@ -71,6 +73,7 @@ extern "C" int _tmain(int argc, TCHAR **argv)
winalloc_in_main_code = FALSE;
}
#endif
+#endif
return rc;
}
diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h
index 05ccabaffe1..f24266dfc20 100644
--- a/src/osd/sdl/osdsdl.h
+++ b/src/osd/sdl/osdsdl.h
@@ -7,6 +7,8 @@
#include "clifront.h"
#include "modules/lib/osdobj_common.h"
#include "video.h"
+#include "modules/osdmodule.h"
+#include "modules/font/font_module.h"
//============================================================
// System dependent defines
@@ -220,7 +222,6 @@ private:
// FIXME: remove machine usage
void extract_video_config(running_machine &machine);
-
sdl_options &m_options;
watchdog *m_watchdog;
diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak
index 5a4a0151989..304d300b4a0 100644
--- a/src/osd/sdl/sdl.mak
+++ b/src/osd/sdl/sdl.mak
@@ -204,14 +204,14 @@ endif
ifeq ($(TARGETOS),unix)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
endif
ifeq ($(TARGETOS),linux)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
SDL_NETWORK = taptun
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
ifndef NO_USE_MIDI
INCPATH += `pkg-config --cflags alsa`
@@ -223,7 +223,7 @@ endif
ifeq ($(TARGETOS),freebsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
DEFS += -DNO_AFFINITY_NP
LIBS += -lutil
# /usr/local/include is not considered a system include directory
@@ -235,7 +235,7 @@ endif
ifeq ($(TARGETOS),openbsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
LIBS += -lutil
NO_USE_MIDI = 1
endif
@@ -243,7 +243,7 @@ endif
ifeq ($(TARGETOS),netbsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
LIBS += -lutil
NO_USE_MIDI = 1
endif
@@ -252,14 +252,14 @@ ifeq ($(TARGETOS),solaris)
BASE_TARGETOS = unix
DEFS += -DNO_AFFINITY_NP -UHAVE_VSNPRINTF -DNO_vsnprintf
SYNC_IMPLEMENTATION = tc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
NO_USE_MIDI = 1
endif
ifeq ($(TARGETOS),haiku)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
-FONT_IMPLEMENTATION = unix
+FONT_IMPLEMENTATION = sdl
NO_X11 = 1
NO_USE_XINPUT = 1
NO_USE_MIDI = 1
@@ -430,7 +430,7 @@ OSDCOREOBJS = \
$(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o \
$(OSDOBJ)/modules/lib/osdlib_$(SDLOS_TARGETOS).o \
$(OSDOBJ)/modules/sync/sync_$(SYNC_IMPLEMENTATION).o \
- $(OSDOBJ)/modules/font/font_$(FONT_IMPLEMENTATION).o \
+ $(OSDOBJ)/modules/osdmodule.o \
ifdef NOASM
OSDCOREOBJS += $(OSDOBJ)/modules/sync/work_mini.o
@@ -451,6 +451,10 @@ OSDOBJS = \
$(SDLOBJ)/output.o \
$(SDLOBJ)/watchdog.o \
$(OSDOBJ)/modules/lib/osdobj_common.o \
+ $(OSDOBJ)/modules/font/font_sdl.o \
+ $(OSDOBJ)/modules/font/font_windows.o \
+ $(OSDOBJ)/modules/font/font_osx.o \
+ $(OSDOBJ)/modules/font/font_none.o \
ifdef NO_USE_MIDI
OSDOBJS += $(OSDOBJ)/modules/midi/none.o
diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c
index 92dd676e216..09f56a4cc28 100644
--- a/src/osd/sdl/sdlmain.c
+++ b/src/osd/sdl/sdlmain.c
@@ -12,11 +12,6 @@
#ifdef SDLMAME_UNIX
#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_EMSCRIPTEN))
-#if (SDLMAME_SDL2)
-#include <SDL2/SDL_ttf.h>
-#else
-#include <SDL/SDL_ttf.h>
-#endif
#ifndef SDLMAME_HAIKU
#include <fontconfig/fontconfig.h>
#endif
@@ -61,7 +56,9 @@
#include "input.h"
#include "osdsdl.h"
#include "modules/lib/osdlib.h"
+
#include "modules/sound/sdl_sound.h"
+
#if defined(SDLMAME_EMSCRIPTEN)
#include "modules/sound/js_sound.h"
#endif
@@ -269,7 +266,6 @@ sdl_options::sdl_options()
set_default_value(SDLOPTION_INIPATH, ini_path.cstr());
}
-
//============================================================
// main
//============================================================
@@ -301,14 +297,11 @@ int main(int argc, char *argv[])
setvbuf(stdout, (char *) NULL, _IONBF, 0);
setvbuf(stderr, (char *) NULL, _IONBF, 0);
- //FIXME: move to font module
+ // FIXME: this should be done differently
+
#ifdef SDLMAME_UNIX
sdl_entered_debugger = 0;
#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
- if (TTF_Init() == -1)
- {
- printf("SDL_ttf failed: %s\n", TTF_GetError());
- }
FcInit();
#endif
#endif
@@ -355,12 +348,8 @@ int main(int argc, char *argv[])
}
#endif
- // already called...
- //SDL_Quit();
-
#ifdef SDLMAME_UNIX
#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN))
- TTF_Quit();
if (!sdl_entered_debugger)
{
FcFini();
@@ -591,6 +580,7 @@ void sdl_osd_interface::debugger_register()
// init
//============================================================
+
void sdl_osd_interface::init(running_machine &machine)
{
// call our parent
diff --git a/src/osd/sdl/strconv.h b/src/osd/sdl/strconv.h
index 9e9728be30f..4ad7e1e2e48 100644
--- a/src/osd/sdl/strconv.h
+++ b/src/osd/sdl/strconv.h
@@ -22,8 +22,10 @@
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
+#if defined(SDLMAME_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#endif
// the result of these functions has to be released with osd_free()
CHAR *astring_from_utf8(const char *s);
diff --git a/src/osd/windows/main.c b/src/osd/windows/main.c
index ccfddb27a0d..da27c9ba9ba 100644
--- a/src/osd/windows/main.c
+++ b/src/osd/windows/main.c
@@ -7,6 +7,9 @@
//============================================================
// standard windows headers
+#ifdef OSD_SDL
+#define _WIN32_WINNT 0x0400
+#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
@@ -34,6 +37,14 @@ extern "C" int _tmain(int argc, TCHAR **argv)
int i, rc;
char **utf8_argv;
+#ifdef OSD_SDL
+#ifdef MALLOC_DEBUG
+{
+ extern int winalloc_in_main_code;
+ winalloc_in_main_code = TRUE;
+#endif
+#endif
+
/* convert arguments to UTF-8 */
utf8_argv = (char **) malloc(argc * sizeof(*argv));
if (utf8_argv == NULL)
@@ -53,5 +64,16 @@ extern "C" int _tmain(int argc, TCHAR **argv)
osd_free(utf8_argv[i]);
free(utf8_argv);
+#ifdef OSD_SDL
+#ifdef MALLOC_DEBUG
+ {
+ void check_unfreed_mem(void);
+ check_unfreed_mem();
+ }
+ winalloc_in_main_code = FALSE;
+}
+#endif
+#endif
+
return rc;
}
diff --git a/src/osd/windows/netdev_pcap.h b/src/osd/windows/netdev_pcap.h
index f4a3241d4e9..ed136a42566 100644
--- a/src/osd/windows/netdev_pcap.h
+++ b/src/osd/windows/netdev_pcap.h
@@ -1,5 +1,5 @@
-#ifndef __NETDEV_H
-#define __NETDEV_H
+#ifndef __NETDEV_PCAP_H__
+#define __NETDEV_PCAP_H__
void init_pcap();
void deinit_pcap();
diff --git a/src/osd/windows/strconv.h b/src/osd/windows/strconv.h
index 3b27bfa2e79..4ad7e1e2e48 100644
--- a/src/osd/windows/strconv.h
+++ b/src/osd/windows/strconv.h
@@ -22,6 +22,10 @@
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
+#if defined(SDLMAME_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
// the result of these functions has to be released with osd_free()
CHAR *astring_from_utf8(const char *s);
@@ -38,6 +42,10 @@ char *utf8_from_wstring(const WCHAR *s);
#define utf8_from_tstring utf8_from_astring
#endif // UNICODE
+#if defined(SDLMAME_WIN32)
+#define _tcsncpy wcsncpy
+#endif
+
#endif //SDLMAME_WIN32
diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak
index 7341c081a34..bcf4a4f5ce4 100644
--- a/src/osd/windows/windows.mak
+++ b/src/osd/windows/windows.mak
@@ -358,6 +358,7 @@ OSDCOREOBJS = \
$(OSDOBJ)/modules/sync/work_osd.o \
$(OSDOBJ)/modules/lib/osdlib_win32.o \
$(OSDOBJ)/modules/font/font_windows.o \
+ $(OSDOBJ)/modules/osdmodule.o \
$(WINOBJ)/winptty.o \
@@ -381,6 +382,10 @@ OSDOBJS = \
$(WINOBJ)/winmain.o \
$(OSDOBJ)/modules/midi/portmidi.o \
$(OSDOBJ)/modules/lib/osdobj_common.o \
+ $(OSDOBJ)/modules/font/font_sdl.o \
+ $(OSDOBJ)/modules/font/font_windows.o \
+ $(OSDOBJ)/modules/font/font_osx.o \
+ $(OSDOBJ)/modules/font/font_none.o \
ifdef USE_SDL
OSDOBJS += \