From 9527a89b2cb4cc6cc468e36113d2c087c58f1888 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 21 Feb 2016 08:52:18 +0100 Subject: [PATCH] cleanup (nw) --- src/emu/clifront.cpp | 64 ------------------------------------------- src/emu/clifront.h | 2 -- src/emu/emu.h | 1 + src/emu/language.cpp | 2 +- src/emu/language.h | 10 ++++++- src/emu/mame.h | 8 ------ src/emu/ui/custui.cpp | 1 - 7 files changed, 11 insertions(+), 77 deletions(-) diff --git a/src/emu/clifront.cpp b/src/emu/clifront.cpp index bda542693fa..6b75841df83 100644 --- a/src/emu/clifront.cpp +++ b/src/emu/clifront.cpp @@ -28,7 +28,6 @@ #include "softlist.h" #include "ui/moptions.h" -#include "language.h" #include #include @@ -89,70 +88,7 @@ cli_frontend::~cli_frontend() // nuke any device options since they will leak memory m_options.remove_device_options(); } -/* -const UINT32 MO_MAGIC = 0x950412de; -const UINT32 MO_MAGIC_REVERSED = 0xde120495; -inline UINT32 endianchange(UINT32 value) { - UINT32 b0 = (value >> 0) & 0xff; - UINT32 b1 = (value >> 8) & 0xff; - UINT32 b2 = (value >> 16) & 0xff; - UINT32 b3 = (value >> 24) & 0xff; - - return (b0 << 24) | (b1 << 16) |(b2 << 8) | b3; -} - -static std::unordered_map g_translation; - -const char *lang_translate(const char *word) -{ - if (g_translation.find(word) == g_translation.end()) - { - return word; - } - return g_translation[word].c_str(); -} - -void cli_frontend::load_translation() -{ - g_translation.empty(); - emu_file file(m_options.language_path(), OPEN_FLAG_READ); - if (file.open(m_options.language(), PATH_SEPARATOR "strings.mo") == FILERR_NONE) - { - UINT64 size = file.size(); - UINT32 *buffer = global_alloc_array(UINT32,size / 4 + 1); - file.read(buffer, size); - file.close(); - - if (buffer[0] != MO_MAGIC && buffer[0] != MO_MAGIC_REVERSED) - { - global_free_array(buffer); - return; - } - if (buffer[0] == MO_MAGIC_REVERSED) - { - for (auto i = 0; i < (size / 4)+1; ++i) - { - buffer[i] = endianchange(buffer[i]); - } - } - - UINT32 number_of_strings = buffer[2]; - UINT32 original_table_offset = buffer[3] >> 2; - UINT32 translation_table_offset = buffer[4] >> 2; - - const char *data = reinterpret_cast(buffer); - - for (auto i = 1; i < number_of_strings; ++i) - { - std::string original = (const char *)data + buffer[original_table_offset + 2 * i + 1]; - std::string translation= (const char *)data + buffer[translation_table_offset + 2 * i + 1]; - g_translation.insert(std::pair(original, translation)); - } - global_free_array(buffer); - } -} -*/ //------------------------------------------------- // execute - execute a game via the standard // command line interface diff --git a/src/emu/clifront.h b/src/emu/clifront.h index dfdc79a7638..584261660db 100644 --- a/src/emu/clifront.h +++ b/src/emu/clifront.h @@ -32,8 +32,6 @@ public: cli_frontend(cli_options &options, osd_interface &osd); ~cli_frontend(); -// void load_translation(); - // execute based on the incoming argc/argv int execute(int argc, char **argv); diff --git a/src/emu/emu.h b/src/emu/emu.h index 4e78d67282f..d45c08b3fef 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -92,6 +92,7 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_ // the running machine #include "mame.h" +#include "language.h" #include "machine.h" #include "driver.h" diff --git a/src/emu/language.cpp b/src/emu/language.cpp index 8d489f63009..d7135eda408 100644 --- a/src/emu/language.cpp +++ b/src/emu/language.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ -#include "language.h" +#include "emu.h" static std::unordered_map g_translation; diff --git a/src/emu/language.h b/src/emu/language.h index 5a885d1b05f..a2b57df75c0 100644 --- a/src/emu/language.h +++ b/src/emu/language.h @@ -9,10 +9,18 @@ ***************************************************************************/ #pragma once +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + #ifndef __LANGUAGE_H__ #define __LANGUAGE_H__ -#include "emu.h" +//************************************************************************** +// LOCALIZATION SUPPORT +//************************************************************************** + +#define _(param) lang_translate(param) void load_translation(emu_options &option); const char *lang_translate(const char *word); diff --git a/src/emu/mame.h b/src/emu/mame.h index ef25c28b641..bc21d805716 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -100,14 +100,6 @@ private: static machine_manager* m_manager; }; -//************************************************************************** -// LOCALIZATION SUPPORT -//************************************************************************** - -#define _(param) lang_translate(param) - -extern const char *lang_translate(const char *word); - //************************************************************************** // GLOBAL VARIABLES //************************************************************************** diff --git a/src/emu/ui/custui.cpp b/src/emu/ui/custui.cpp index a6987673aa9..caa455a4230 100644 --- a/src/emu/ui/custui.cpp +++ b/src/emu/ui/custui.cpp @@ -15,7 +15,6 @@ #include "ui/custui.h" #include "ui/utils.h" #include -#include "language.h" const char *ui_menu_custom_ui::hide_status[] = { "Show All", "Hide Filters", "Hide Info/Image", "Hide Both" };