summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/main.h
blob: b13bdee5dc3cb4a960dc062dd4f2a67111749676 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, Aaron Giles
/***************************************************************************

    main.h

    Controls execution of the core emulator system.
***************************************************************************/

#pragma once

#ifndef __EMU_H__
#error Dont include this file directly; include emu.h instead.
#endif

#ifndef MAME_EMU_MAIN_H
#define MAME_EMU_MAIN_H

#include <thread>
#include <time.h>

//**************************************************************************
//    CONSTANTS
//**************************************************************************

enum
{
	EMU_ERR_NONE             = 0,    /* no error */
	EMU_ERR_FAILED_VALIDITY  = 1,    /* failed validity checks */
	EMU_ERR_MISSING_FILES    = 2,    /* missing files */
	EMU_ERR_FATALERROR       = 3,    /* some other fatal error */
	EMU_ERR_DEVICE           = 4,    /* device initialization error (MESS-specific) */
	EMU_ERR_NO_SUCH_GAME     = 5,    /* game was specified but doesn't exist */
	EMU_ERR_INVALID_CONFIG   = 6,    /* some sort of error in configuration */
	EMU_ERR_IDENT_NONROMS    = 7,    /* identified all non-ROM files */
	EMU_ERR_IDENT_PARTIAL    = 8,    /* identified some files but not all */
	EMU_ERR_IDENT_NONE       = 9     /* identified no files */
};

//**************************************************************************
//    TYPE DEFINITIONS
//**************************************************************************
class osd_interface;

class emulator_info
{
public:
	// construction/destruction
	emulator_info() {};

	static const char * get_appname();
	static const char * get_appname_lower();
	static const char * get_configname();
	static const char * get_copyright();
	static const char * get_copyright_info();
	static const char * get_bare_build_version();
	static const char * get_build_version();
	static void display_ui_chooser(running_machine& machine);
	static int start_frontend(emu_options &options, osd_interface &osd, std::vector<std::string> &args);
	static int start_frontend(emu_options &options, osd_interface &osd, int argc, char *argv[]);
	static void draw_user_interface(running_machine& machine);
	static void periodic_check();
	static bool frame_hook();
	static void layout_file_cb(util::xml::data_node &layout);
	static bool standalone();
};

// ======================> machine_manager
class ui_manager;
namespace asio
{
	class io_context;
}
namespace webpp
{
	class http_server;
	class ws_server;
}

class machine_manager
{
	DISABLE_COPYING(machine_manager);
protected:
	// construction/destruction
	machine_manager(emu_options& options, osd_interface& osd);
public:
	virtual ~machine_manager();

	osd_interface &osd() const { return m_osd; }
	emu_options &options() const { return m_options; }

	running_machine *machine() const { return m_machine; }

	void set_machine(running_machine *machine) { m_machine = machine; }

	virtual ui_manager* create_ui(running_machine& machine) { return nullptr;  }
	virtual void create_custom(running_machine& machine) { }
	virtual void load_cheatfiles(running_machine& machine) { }
	virtual void ui_initialize(running_machine& machine) { }

	virtual void update_machine() { }

	void start_http_server();
	void start_context();
	webpp::http_server* http_server() const { return m_server.get(); }
protected:
	osd_interface &         m_osd;                  // reference to OSD system
	emu_options &           m_options;              // reference to options
	running_machine *       m_machine;
	std::shared_ptr<asio::io_context>   m_io_context;
	std::unique_ptr<webpp::http_server> m_server;
	std::unique_ptr<webpp::ws_server>   m_wsserver;
	std::thread                         m_server_thread;
};


#endif  /* MAME_EMU_MAIN_H */