2013-01-05 09:19:09 +02:00
|
|
|
#ifndef _interface__romtype__hpp__included__
|
|
|
|
#define _interface__romtype__hpp__included__
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
#include "interface/controller.hpp"
|
|
|
|
#include "interface/setting.hpp"
|
2013-01-08 05:47:42 +02:00
|
|
|
#include "library/framebuffer.hpp"
|
2013-06-30 13:20:23 +03:00
|
|
|
#include "library/threadtypes.hpp"
|
2013-01-05 09:19:09 +02:00
|
|
|
|
|
|
|
struct core_region;
|
|
|
|
struct core_type;
|
|
|
|
struct core_sysregion;
|
|
|
|
struct core_romimage;
|
|
|
|
struct core_romimage_info;
|
2013-01-05 23:15:32 +02:00
|
|
|
struct core_core;
|
2013-01-05 09:19:09 +02:00
|
|
|
|
2013-07-03 04:06:40 +03:00
|
|
|
/**
|
|
|
|
* Interface device register.
|
|
|
|
*/
|
|
|
|
struct interface_device_reg
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
uint64_t (*read)();
|
|
|
|
void (*write)(uint64_t v);
|
|
|
|
bool boolean;
|
|
|
|
};
|
|
|
|
|
2013-06-30 13:20:23 +03:00
|
|
|
/**
|
|
|
|
* An parameter for action in interface.
|
|
|
|
*/
|
|
|
|
struct interface_action_param
|
|
|
|
{
|
|
|
|
//Name of the action parameter.
|
|
|
|
const char* name;
|
|
|
|
//Model of the action parameter.
|
|
|
|
//bool: Boolean.
|
|
|
|
//int:<val>,<val>: Integer in specified range.
|
|
|
|
//string[:<regex>]: String with regex.
|
2013-07-04 18:17:07 +03:00
|
|
|
//enum:<json-array>: Enumeration.
|
|
|
|
//toggle: Not a real parameter, boolean toggle, must be the first.
|
2013-06-30 13:20:23 +03:00
|
|
|
const char* model;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Value for action in interface.
|
|
|
|
*/
|
|
|
|
struct interface_action_paramval
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
int64_t i;
|
|
|
|
bool b;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An action for interface.
|
|
|
|
*/
|
|
|
|
struct interface_action
|
|
|
|
{
|
|
|
|
interface_action(struct core_core& _core, unsigned id, const std::string& title, const std::string& symbol,
|
|
|
|
std::initializer_list<interface_action_param> p);
|
|
|
|
~interface_action();
|
|
|
|
unsigned id;
|
|
|
|
std::string title;
|
|
|
|
std::string symbol;
|
|
|
|
std::list<interface_action_param> params;
|
|
|
|
struct core_core& core;
|
2013-07-04 18:17:07 +03:00
|
|
|
bool is_toggle() const;
|
2013-06-30 13:20:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Parameters about a region (e.g. NTSC, PAL, World).
|
|
|
|
*
|
|
|
|
* Both movies ("run region") and ROMs ("cart region") have regions. The set of regions allowed for latter is superset
|
|
|
|
* of former, since autodetection regions are allowed for carts but not runs.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
struct core_region_params
|
|
|
|
{
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Internal name of the region. Should be all-lowercase.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* iname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Human-readable name of the region.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* hname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Priority of region. Higher numbers are more preferred when tiebreaking.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
unsigned priority;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* ID number of region. Unique among regions allowed for given core type.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
unsigned handle;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Multi-region flag. If set, this region gets further resolved by autodetection.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
bool multi;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Nominal framerate. The first number is numerator, the second is denominator.
|
|
|
|
*/
|
2013-01-13 11:57:40 +02:00
|
|
|
uint64_t framemagic[2];
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* ID numbers of regions of runs compatible with this cartridge region.
|
|
|
|
*/
|
2013-06-15 12:53:18 +03:00
|
|
|
std::vector<unsigned> compatible_runs;
|
2013-01-05 09:19:09 +02:00
|
|
|
};
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Parameters about individual ROM image.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
struct core_romimage_info_params
|
|
|
|
{
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Internal name of ROM image.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* iname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Human-readable name of ROM image.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* hname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Upon loading a set of ROM images, the OR of mandatory fields of all present ROM images must equal OR of mandatory
|
|
|
|
* fields of all possible ROM images.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
unsigned mandatory;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* The way image is passed:
|
|
|
|
* 0 => Pass by content.
|
|
|
|
* 1 => Pass by filename.
|
|
|
|
* 2 => Pass by directory.
|
|
|
|
*/
|
|
|
|
int pass_mode;
|
|
|
|
/**
|
|
|
|
* Size of optional copier header to remove. 0 means there never is copier header.
|
|
|
|
*/
|
|
|
|
unsigned headersize;
|
2013-01-05 09:19:09 +02:00
|
|
|
};
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* A Virtual Memory Area (VMA), which is a chunk of lsnes memory space.
|
|
|
|
*
|
|
|
|
* Mapping stuff above 4PB should be avoided.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
struct core_vma_info
|
|
|
|
{
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Name of the VMA.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
std::string name;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Base address of the VMA.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
uint64_t base;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Size of the VMA.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
uint64_t size;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Direct backing RAM for the VMA. May be NULL.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
void* backing_ram;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* If true, the VMA can't be written to.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
bool readonly;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Default endianess. -1 => Little endian, 0 => The same as host system, 1 => Big endian.
|
|
|
|
*/
|
2013-02-17 10:27:00 +02:00
|
|
|
int endian;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* If backing_ram is NULL, this routine is used to access the memory one byte at a time.
|
|
|
|
*
|
|
|
|
* Parameter offset: The offset into VMA to access.
|
|
|
|
* Parameter data: Byte to write. Ignored if write = false.
|
|
|
|
* Parameter write: If true, do write, otherwise do read.
|
|
|
|
* Returns: The read value. Only valid if write = false.
|
|
|
|
*/
|
2013-01-06 20:36:31 +02:00
|
|
|
uint8_t (*iospace_rw)(uint64_t offset, uint8_t data, bool write);
|
|
|
|
};
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Parameters about system type.
|
|
|
|
*
|
|
|
|
* Each system type may have its own regions, image slots and controller configuration.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
struct core_type_params
|
|
|
|
{
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Internal name of the system type.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* iname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Human-readable name of the system type.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
const char* hname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* ID of system type. Must be unique among core system is valid for.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
unsigned id;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
2013-06-30 13:20:23 +03:00
|
|
|
* System menu name.
|
2013-06-15 14:20:00 +03:00
|
|
|
*/
|
2013-06-30 13:20:23 +03:00
|
|
|
const char* sysname;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Semicolon-separated list of extensions this system type uses.
|
|
|
|
*/
|
|
|
|
const char* extensions;
|
|
|
|
/**
|
|
|
|
* The name of BIOS for this system. NULL if there is no bios.
|
|
|
|
*/
|
|
|
|
const char* bios;
|
|
|
|
/**
|
|
|
|
* List of regions valid for this system type.
|
|
|
|
*/
|
|
|
|
std::vector<core_region*> regions;
|
|
|
|
/**
|
|
|
|
* List of image slots for this system type.
|
|
|
|
*/
|
|
|
|
std::vector<core_romimage_info*> images;
|
|
|
|
/**
|
|
|
|
* Description of settings for this system type.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
core_setting_group* settings;
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Core this system is emulated by.
|
|
|
|
*/
|
2013-01-05 23:15:32 +02:00
|
|
|
core_core* core;
|
|
|
|
};
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Core type parameters.
|
|
|
|
*
|
|
|
|
* Each core type has its own loaded ROM.
|
|
|
|
*/
|
2013-01-05 23:15:32 +02:00
|
|
|
struct core_core_params
|
|
|
|
{
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Set of valid port types for the core.
|
|
|
|
*/
|
2013-06-15 12:53:18 +03:00
|
|
|
std::vector<port_type*> port_types;
|
2013-01-05 09:19:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct core_region
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
core_region(const core_region_params& params);
|
2013-06-15 12:53:18 +03:00
|
|
|
core_region(std::initializer_list<core_region_params> p) : core_region(*p.begin()) {}
|
2013-01-05 09:19:09 +02:00
|
|
|
const std::string& get_iname();
|
|
|
|
const std::string& get_hname();
|
|
|
|
unsigned get_priority();
|
|
|
|
unsigned get_handle();
|
|
|
|
bool is_multi();
|
|
|
|
void fill_framerate_magic(uint64_t* magic); //4 elements filled.
|
|
|
|
double approx_framerate();
|
|
|
|
bool compatible_with(core_region& run);
|
|
|
|
private:
|
|
|
|
core_region(const core_region&);
|
|
|
|
core_region& operator=(const core_region&);
|
|
|
|
std::string iname;
|
|
|
|
std::string hname;
|
|
|
|
bool multi;
|
|
|
|
unsigned handle;
|
|
|
|
unsigned priority;
|
|
|
|
uint64_t magic[4];
|
|
|
|
std::vector<unsigned> compatible;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct core_romimage_info
|
|
|
|
{
|
|
|
|
core_romimage_info(const core_romimage_info_params& params);
|
2013-06-15 12:53:18 +03:00
|
|
|
core_romimage_info(std::initializer_list<core_romimage_info_params> p) : core_romimage_info(*p.begin()) {};
|
2013-01-05 09:19:09 +02:00
|
|
|
std::string iname;
|
|
|
|
std::string hname;
|
|
|
|
unsigned mandatory;
|
|
|
|
int pass_mode;
|
|
|
|
unsigned headersize;
|
|
|
|
size_t get_headnersize(size_t imagesize);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct core_romimage
|
|
|
|
{
|
|
|
|
const char* markup;
|
|
|
|
const unsigned char* data;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2013-01-05 23:15:32 +02:00
|
|
|
struct core_core
|
|
|
|
{
|
2013-06-15 12:53:18 +03:00
|
|
|
core_core(const core_core_params& params);
|
|
|
|
core_core(std::initializer_list<core_core_params> p) : core_core(*p.begin()) {}
|
2013-01-06 23:06:08 +02:00
|
|
|
~core_core() throw();
|
2013-01-05 23:15:32 +02:00
|
|
|
bool set_region(core_region& region);
|
|
|
|
std::pair<uint32_t, uint32_t> get_video_rate();
|
|
|
|
std::pair<uint32_t, uint32_t> get_audio_rate();
|
|
|
|
std::string get_core_identifier();
|
|
|
|
std::map<std::string, std::vector<char>> save_sram() throw(std::bad_alloc);
|
|
|
|
void load_sram(std::map<std::string, std::vector<char>>& sram) throw(std::bad_alloc);
|
|
|
|
void serialize(std::vector<char>& out);
|
|
|
|
void unserialize(const char* in, size_t insize);
|
2013-01-06 12:30:32 +02:00
|
|
|
core_region& get_region();
|
|
|
|
void power();
|
|
|
|
void unload_cartridge();
|
|
|
|
std::pair<uint32_t, uint32_t> get_scale_factors(uint32_t width, uint32_t height);
|
2013-01-06 19:59:45 +02:00
|
|
|
void install_handler();
|
|
|
|
void uninstall_handler();
|
|
|
|
void emulate();
|
|
|
|
void runtosave();
|
2013-01-11 22:56:45 +02:00
|
|
|
bool get_pflag();
|
|
|
|
void set_pflag(bool pflag);
|
2013-01-08 05:47:42 +02:00
|
|
|
framebuffer_raw& draw_cover();
|
2013-06-15 12:53:18 +03:00
|
|
|
std::vector<port_type*> get_port_types() { return port_types; }
|
2013-01-16 17:12:05 +02:00
|
|
|
std::string get_core_shortname();
|
2013-03-13 00:36:44 +02:00
|
|
|
void pre_emulate_frame(controller_frame& cf);
|
2013-06-30 13:20:23 +03:00
|
|
|
void execute_action(unsigned id, const std::vector<interface_action_paramval>& p);
|
2013-07-04 18:17:07 +03:00
|
|
|
unsigned action_flags(unsigned id);
|
2013-01-06 23:06:08 +02:00
|
|
|
static std::set<core_core*> all_cores();
|
|
|
|
static void install_all_handlers();
|
|
|
|
static void uninstall_all_handlers();
|
2013-02-26 13:09:03 +02:00
|
|
|
void hide() { hidden = true; }
|
|
|
|
bool is_hidden() { return hidden; }
|
2013-06-30 13:20:23 +03:00
|
|
|
struct _param_register_proxy
|
|
|
|
{
|
|
|
|
_param_register_proxy(core_core& _c) : cre(_c) {}
|
|
|
|
void do_register(const std::string& key, interface_action& act)
|
|
|
|
{
|
|
|
|
cre.do_register_action(key, act);
|
|
|
|
}
|
|
|
|
void do_unregister(const std::string& key)
|
|
|
|
{
|
|
|
|
cre.do_unregister_action(key);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
core_core& cre;
|
|
|
|
};
|
|
|
|
void do_register_action(const std::string& key, interface_action& act);
|
|
|
|
void do_unregister_action(const std::string& key);
|
|
|
|
std::set<const interface_action*> get_actions();
|
|
|
|
_param_register_proxy param_register_proxy;
|
2013-07-03 04:06:40 +03:00
|
|
|
const interface_device_reg* get_registers();
|
2013-07-03 18:21:16 +03:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Get the name of the core.
|
|
|
|
*/
|
|
|
|
virtual std::string c_core_identifier() = 0;
|
|
|
|
/**
|
|
|
|
* Set the current region.
|
|
|
|
*
|
|
|
|
* Parameter region: The new region.
|
|
|
|
* Returns: True on success, false on failure (bad region).
|
|
|
|
*/
|
|
|
|
virtual bool c_set_region(core_region& region) = 0;
|
|
|
|
/**
|
|
|
|
* Get current video frame rate as (numerator, denominator).
|
|
|
|
*/
|
|
|
|
virtual std::pair<uint32_t, uint32_t> c_video_rate() = 0;
|
|
|
|
/**
|
|
|
|
* Get audio sampling rate as (numerator, denominator).
|
|
|
|
*
|
|
|
|
* Note: This value should not be changed while ROM is running, since video dumper may malfunction.
|
|
|
|
*/
|
|
|
|
virtual std::pair<uint32_t, uint32_t> c_audio_rate() = 0;
|
|
|
|
/**
|
|
|
|
* Save all SRAMs.
|
|
|
|
*/
|
|
|
|
virtual std::map<std::string, std::vector<char>> c_save_sram() throw(std::bad_alloc) = 0;
|
|
|
|
/**
|
|
|
|
* Load all SRAMs.
|
|
|
|
*
|
|
|
|
* Note: Must handle SRAM being missing or shorter or longer than expected.
|
|
|
|
*/
|
|
|
|
virtual void c_load_sram(std::map<std::string, std::vector<char>>& sram) throw(std::bad_alloc) = 0;
|
|
|
|
/**
|
|
|
|
* Serialize the system state.
|
|
|
|
*/
|
|
|
|
virtual void c_serialize(std::vector<char>& out) = 0;
|
|
|
|
/**
|
|
|
|
* Unserialize the system state.
|
|
|
|
*/
|
|
|
|
virtual void c_unserialize(const char* in, size_t insize) = 0;
|
|
|
|
/**
|
|
|
|
* Get current region.
|
|
|
|
*/
|
|
|
|
virtual core_region& c_get_region() = 0;
|
|
|
|
/**
|
|
|
|
* Poweron the console.
|
|
|
|
*/
|
|
|
|
virtual void c_power() = 0;
|
|
|
|
/**
|
|
|
|
* Unload the cartridge from the console.
|
|
|
|
*/
|
|
|
|
virtual void c_unload_cartridge() = 0;
|
|
|
|
/**
|
|
|
|
* Get the current scale factors for screen as (xscale, yscale).
|
|
|
|
*/
|
|
|
|
virtual std::pair<uint32_t, uint32_t> c_get_scale_factors(uint32_t width, uint32_t height) = 0;
|
|
|
|
/**
|
|
|
|
* Do basic core initialization. Called on lsnes startup.
|
|
|
|
*/
|
|
|
|
virtual void c_install_handler() = 0;
|
|
|
|
/**
|
|
|
|
* Do basic core uninitialization. Called on lsnes shutdown.
|
|
|
|
*/
|
|
|
|
virtual void c_uninstall_handler() = 0;
|
|
|
|
/**
|
|
|
|
* Emulate one frame.
|
|
|
|
*/
|
|
|
|
virtual void c_emulate() = 0;
|
|
|
|
/**
|
|
|
|
* Get core into state where saving is possible. Must run less than one frame.
|
|
|
|
*/
|
|
|
|
virtual void c_runtosave() = 0;
|
|
|
|
/**
|
|
|
|
* Get the polled flag.
|
|
|
|
*
|
|
|
|
* The emulator core sets polled flag when the game asks for input.
|
|
|
|
*
|
|
|
|
* If polled flag is clear when frame ends, the frame is marked as lag.
|
|
|
|
*/
|
|
|
|
virtual bool c_get_pflag() = 0;
|
|
|
|
/**
|
|
|
|
* Set the polled flag.
|
|
|
|
*/
|
|
|
|
virtual void c_set_pflag(bool pflag) = 0;
|
|
|
|
/**
|
|
|
|
* Draw run cover screen.
|
|
|
|
*
|
|
|
|
* Should display information about the ROM loaded.
|
|
|
|
*/
|
|
|
|
virtual framebuffer_raw& c_draw_cover() = 0;
|
|
|
|
/**
|
|
|
|
* Get shortened name of the core.
|
|
|
|
*/
|
|
|
|
virtual std::string c_get_core_shortname() = 0;
|
|
|
|
/**
|
|
|
|
* Set the system controls to appropriate values for next frame.
|
|
|
|
*
|
|
|
|
* E.g. if core supports resetting, set the reset button in the frame to pressed if reset is wanted.
|
|
|
|
*/
|
|
|
|
virtual void c_pre_emulate_frame(controller_frame& cf) = 0;
|
|
|
|
/**
|
|
|
|
* Execute action.
|
|
|
|
*/
|
|
|
|
virtual void c_execute_action(unsigned id, const std::vector<interface_action_paramval>& p) = 0;
|
|
|
|
/**
|
|
|
|
* Get set of interface device registers.
|
|
|
|
*/
|
|
|
|
virtual const struct interface_device_reg* c_get_registers() = 0;
|
2013-07-04 18:17:07 +03:00
|
|
|
/**
|
|
|
|
* Get action flags on specified action.
|
|
|
|
*
|
|
|
|
* Bit 0: Enabled.
|
|
|
|
* Bit 1: Selected.
|
|
|
|
*/
|
|
|
|
virtual unsigned c_action_flags(unsigned id) = 0;
|
2013-01-05 23:15:32 +02:00
|
|
|
private:
|
2013-06-15 12:53:18 +03:00
|
|
|
std::vector<port_type*> port_types;
|
2013-02-26 13:09:03 +02:00
|
|
|
bool hidden;
|
2013-06-30 13:20:23 +03:00
|
|
|
std::map<std::string, interface_action*> actions;
|
|
|
|
mutex_class actions_lock;
|
2013-01-05 23:15:32 +02:00
|
|
|
};
|
|
|
|
|
2013-01-05 09:19:09 +02:00
|
|
|
struct core_type
|
|
|
|
{
|
|
|
|
public:
|
2013-06-15 12:53:18 +03:00
|
|
|
core_type(const core_type_params& params);
|
|
|
|
core_type(std::initializer_list<core_type_params> p) : core_type(*p.begin()) {}
|
2013-07-03 18:21:16 +03:00
|
|
|
virtual ~core_type() throw();
|
2013-01-05 09:19:09 +02:00
|
|
|
static std::list<core_type*> get_core_types();
|
|
|
|
core_region& get_preferred_region();
|
|
|
|
std::list<core_region*> get_regions();
|
|
|
|
core_sysregion& combine_region(core_region& reg);
|
|
|
|
const std::string& get_iname();
|
|
|
|
const std::string& get_hname();
|
|
|
|
const std::list<std::string>& get_extensions();
|
|
|
|
bool is_known_extension(const std::string& ext);
|
2013-01-11 22:31:13 +02:00
|
|
|
core_sysregion& lookup_sysregion(const std::string& sysreg);
|
2013-01-05 09:19:09 +02:00
|
|
|
std::string get_biosname();
|
|
|
|
unsigned get_id();
|
|
|
|
unsigned get_image_count();
|
|
|
|
core_romimage_info get_image_info(unsigned index);
|
|
|
|
bool load(core_romimage* images, std::map<std::string, std::string>& settings, uint64_t rtc_sec,
|
|
|
|
uint64_t rtc_subsec);
|
|
|
|
controller_set controllerconfig(std::map<std::string, std::string>& settings);
|
|
|
|
core_setting_group& get_settings();
|
2013-01-06 12:30:32 +02:00
|
|
|
std::pair<uint64_t, uint64_t> get_bus_map();
|
2013-01-06 20:36:31 +02:00
|
|
|
std::list<core_vma_info> vma_list();
|
|
|
|
std::set<std::string> srams();
|
2013-05-23 01:00:23 +03:00
|
|
|
core_core* get_core() { return core; }
|
2013-01-05 23:15:32 +02:00
|
|
|
bool set_region(core_region& region) { return core->set_region(region); }
|
|
|
|
std::pair<uint32_t, uint32_t> get_video_rate() { return core->get_video_rate(); }
|
|
|
|
std::pair<uint32_t, uint32_t> get_audio_rate() { return core->get_audio_rate(); }
|
|
|
|
std::string get_core_identifier() { return core->get_core_identifier(); }
|
2013-01-16 17:12:05 +02:00
|
|
|
std::string get_core_shortname() { return core->get_core_shortname(); }
|
2013-01-05 23:15:32 +02:00
|
|
|
std::map<std::string, std::vector<char>> save_sram() throw(std::bad_alloc) { return core->save_sram(); }
|
|
|
|
void load_sram(std::map<std::string, std::vector<char>>& sram) throw(std::bad_alloc)
|
|
|
|
{
|
|
|
|
core->load_sram(sram);
|
|
|
|
}
|
|
|
|
void serialize(std::vector<char>& out) { core->serialize(out); }
|
|
|
|
void unserialize(const char* in, size_t insize) { core->unserialize(in, insize); }
|
2013-01-06 12:30:32 +02:00
|
|
|
core_region& get_region() { return core->get_region(); }
|
|
|
|
void power() { core->power(); }
|
|
|
|
void unload_cartridge() { core->unload_cartridge(); }
|
|
|
|
std::pair<uint32_t, uint32_t> get_scale_factors(uint32_t width, uint32_t height)
|
|
|
|
{
|
|
|
|
return core->get_scale_factors(width, height);
|
|
|
|
}
|
2013-01-06 19:59:45 +02:00
|
|
|
void install_handler() { core->install_handler(); }
|
|
|
|
void uninstall_handler() { core->uninstall_handler(); }
|
|
|
|
void emulate() { core->emulate(); }
|
|
|
|
void runtosave() { core->runtosave(); }
|
2013-01-11 22:56:45 +02:00
|
|
|
bool get_pflag() { return core->get_pflag(); }
|
|
|
|
void set_pflag(bool pflag) { core->set_pflag(pflag); }
|
2013-01-08 05:47:42 +02:00
|
|
|
framebuffer_raw& draw_cover() { return core->draw_cover(); }
|
2013-06-30 13:20:23 +03:00
|
|
|
std::string get_systemmenu_name() { return sysname; }
|
|
|
|
void execute_action(unsigned id, const std::vector<interface_action_paramval>& p)
|
|
|
|
{
|
|
|
|
return core->execute_action(id, p);
|
|
|
|
}
|
2013-07-04 18:17:07 +03:00
|
|
|
unsigned action_flags(unsigned id) { return core->action_flags(id); }
|
2013-02-26 13:09:03 +02:00
|
|
|
bool is_hidden() { return core->is_hidden(); }
|
2013-03-13 00:36:44 +02:00
|
|
|
void pre_emulate_frame(controller_frame& cf) { return core->pre_emulate_frame(cf); }
|
2013-06-30 13:20:23 +03:00
|
|
|
std::set<const interface_action*> get_actions() { return core->get_actions(); }
|
2013-07-03 04:06:40 +03:00
|
|
|
const interface_device_reg* get_registers() { return core->get_registers(); }
|
2013-07-03 18:21:16 +03:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Load a ROM slot set. Changes the ROM currently loaded for core.
|
|
|
|
*
|
|
|
|
* Parameter images: The set of images to load.
|
|
|
|
* Parameter settings: The settings to use.
|
|
|
|
* Parameter rtc_sec: The initial RTC seconds value.
|
|
|
|
* Parameter rtc_subsec: The initial RTC subseconds value.
|
|
|
|
* Returns: -1 on failure, 0 on success.
|
|
|
|
*/
|
|
|
|
virtual int t_load_rom(core_romimage* images, std::map<std::string, std::string>& settings, uint64_t rtc_sec,
|
|
|
|
uint64_t rtc_subsec) = 0;
|
|
|
|
/**
|
|
|
|
* Obtain controller config for given settings.
|
|
|
|
*
|
|
|
|
* Parameter settings: The settings to use.
|
|
|
|
* Returns: The controller configuration.
|
|
|
|
*/
|
|
|
|
virtual controller_set t_controllerconfig(std::map<std::string, std::string>& settings) = 0;
|
|
|
|
/**
|
|
|
|
* Get bus mapping.
|
|
|
|
*
|
|
|
|
* Returns: The bus mapping (base,size), or (0,0) if this system does not have bus mapping.
|
|
|
|
*/
|
|
|
|
virtual std::pair<uint64_t, uint64_t> t_get_bus_map() = 0;
|
|
|
|
/**
|
|
|
|
* Get list of valid VMAs. ROM must be loaded.
|
|
|
|
*
|
|
|
|
* Returns: The list of VMAs.
|
|
|
|
*/
|
|
|
|
virtual std::list<core_vma_info> t_vma_list() = 0;
|
|
|
|
/**
|
|
|
|
* Get list of valid SRAM names. ROM must be loaded.
|
|
|
|
*
|
|
|
|
* Returns: The list of SRAMs.
|
|
|
|
*/
|
|
|
|
virtual std::set<std::string> t_srams() = 0;
|
2013-01-05 09:19:09 +02:00
|
|
|
private:
|
|
|
|
core_type(const core_type&);
|
|
|
|
core_type& operator=(const core_type&);
|
|
|
|
unsigned id;
|
|
|
|
std::string iname;
|
|
|
|
std::string hname;
|
|
|
|
std::string biosname;
|
2013-06-30 13:20:23 +03:00
|
|
|
std::string sysname;
|
2013-01-05 09:19:09 +02:00
|
|
|
std::list<std::string> extensions;
|
|
|
|
std::list<core_region*> regions;
|
|
|
|
std::vector<core_romimage_info*> imageinfo;
|
|
|
|
core_setting_group* settings;
|
2013-01-05 23:15:32 +02:00
|
|
|
core_core* core;
|
2013-01-05 09:19:09 +02:00
|
|
|
};
|
|
|
|
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* System type / region pair.
|
|
|
|
*
|
|
|
|
* All run regions for given system must have valid pairs.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
struct core_sysregion
|
|
|
|
{
|
|
|
|
public:
|
2013-06-15 14:20:00 +03:00
|
|
|
/**
|
|
|
|
* Create a new system type / region pair.
|
|
|
|
*
|
|
|
|
* Parameter name: The internal name of the pair.
|
|
|
|
* Parameter type: The system.
|
|
|
|
* Parameter region: The region.
|
|
|
|
*/
|
2013-01-05 09:19:09 +02:00
|
|
|
core_sysregion(const std::string& name, core_type& type, core_region& region);
|
2013-01-11 22:31:13 +02:00
|
|
|
~core_sysregion() throw();
|
2013-01-05 09:19:09 +02:00
|
|
|
const std::string& get_name();
|
|
|
|
core_region& get_region();
|
|
|
|
core_type& get_type();
|
|
|
|
void fill_framerate_magic(uint64_t* magic); //4 elements filled.
|
|
|
|
private:
|
|
|
|
core_sysregion(const core_sysregion&);
|
|
|
|
core_sysregion& operator=(const core_sysregion&);
|
|
|
|
std::string name;
|
|
|
|
core_type& type;
|
|
|
|
core_region& region;
|
|
|
|
};
|
|
|
|
|
2013-01-07 20:29:03 +02:00
|
|
|
//Set to true if new core is detected.
|
|
|
|
extern bool new_core_flag;
|
|
|
|
|
2013-01-05 09:19:09 +02:00
|
|
|
#endif
|