Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CONFIG_H
#define CONFIG_H
#if defined(WIIU) || defined(__CELLOS_LV2__) || defined(GEKKO)
#undef SCUMM_LITTLE_ENDIAN
#define SCUMM_BIG_ENDIAN
#else
#define SCUMM_LITTLE_ENDIAN
#endif
#define SCUMM_NEED_ALIGNMENT
#endif /* CONFIG_H */

View File

@@ -0,0 +1,733 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_CORE_OPTIONS_INTL_H__
#define LIBRETRO_CORE_OPTIONS_INTL_H__
#if defined(_MSC_VER) && (_MSC_VER >= 1500 && _MSC_VER < 1900)
/* https://support.microsoft.com/en-us/kb/980263 */
#pragma execution_character_set("utf-8")
#pragma warning(disable : 4566)
#endif
#include <libretro.h>
/*
********************************
* VERSION: 2.0
********************************
*
* - 2.0: Add support for core options v2 interface
* - 1.3: Move translations to libretro_core_options_intl.h
* - libretro_core_options_intl.h includes BOM and utf-8
* fix for MSVC 2010-2013
* - Added HAVE_NO_LANGEXTRA flag to disable translations
* on platforms/compilers without BOM support
* - 1.2: Use core options v1 interface when
* RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
* (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
* - 1.1: Support generation of core options v0 retro_core_option_value
* arrays containing options with a single value
* - 1.0: First commit
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
********************************
* Core Option Definitions
********************************
*/
/* RETRO_LANGUAGE_JAPANESE */
/* RETRO_LANGUAGE_FRENCH */
/* RETRO_LANGUAGE_SPANISH */
/* RETRO_LANGUAGE_GERMAN */
/* RETRO_LANGUAGE_ITALIAN */
struct retro_core_option_v2_category option_cats_it[] = {
{
"video",
NULL,
"Configura le impostazioni video"
},
{
"cursor",
"Cursore",
"Impostazioni relative al movimento del cursore"
},
{
"timing",
NULL,
"Impostazioni relative al timing"
},
{
"retropad",
"Mappatura RetroPad",
"Configura la mappatura del RetroPad"
},
{ NULL, NULL, NULL },
};
struct retro_core_option_v2_definition option_defs_it[] = {
{
"scummvm_gamepad_cursor_only",
"Cursore > Controllo esclusivo del cursore con RetroPad",
"Controllo esclusivo del cursore con RetroPad",
"Consente di usare solo RetroPad per il controllo del cursore del mouse, escludento gli altri input (es. mouse fisico, touch screen).",
NULL,
"cursor",
{
{"disabled", NULL},
{"enabled", NULL},
{NULL, NULL},
},
"disabled"
},
{
"scummvm_gamepad_cursor_speed",
"Cursore > Velocità del cursore",
"Velocità del cursore",
"Moltiplicatore della velocità del cursore del mouse quando si usa la leva analogica sinistra o il D-Pad del RetroPad. Il valore di default di '1.0' è ottimizzato per i giochi con risoluzione nativa di '320x200' o '320x240'. Per i giochi ad 'alta definizione' con risoluzione di '640x400' or '640x480', si raccomanda il valore di '2.0'",
NULL,
NULL,
{
{NULL, NULL},
},
NULL
},
{
"scummvm_gamepad_cursor_acceleration_time",
"Cursore > Accelerazione del cursore",
"Accelerazione del cursore",
"Il tempo (in secondi) necessario al cursore del mouse per raggiungere la piena velocità quando si usa la leva analogica sinistra o il D-Pad del RetroPad.",
NULL,
NULL,
{
{NULL, NULL},
},
NULL
},
{
"scummvm_analog_response",
"Cursore > Risposta analogica del cursore",
"Risposta analogica del cursore",
"Modalità di risposta della velocità del cursore del mouse allo spostamento della leva analogica sinistra del RetroPad. 'Lineare': La velocità è direttamente proporzionale allo spostamento della leva. Questa è l'impostazione di default adatta alla maggior parte degli utenti. 'Quadratica': La velocità aumenta con il quadrato dello spostamento della leva. Questo permette maggior precisione nei piccoli movimenti senza sacrificare il raggiungimento della velocità massima a spostamento completo. Questa modalità può richiedere pratica per un uso efficace.",
NULL,
NULL,
{
{"linear", "Lineare"},
{"quadratic", "Quadratica"},
{NULL, NULL},
},
NULL
},
{
"scummvm_analog_deadzone",
"Cursore > Zona morta analogica",
"Zona morta analogica",
"Zona morta percentuale delle leve analogiche del RetroPad. Può essere usata per eliminare scorrimenti indesiderati del cursore.",
NULL,
NULL,
{
{NULL, NULL},
},
NULL
},
{
"scummvm_mouse_speed",
"Cursore > Velocità del mouse",
"Velocità del mouse",
"Moltiplicatore della velocità del cursore del mouse quando si usa RetroMouse.",
NULL,
NULL,
{
{NULL, NULL},
},
NULL
},
{
"scummvm_mouse_fine_control_speed_reduction",
"Cursore > Riduzione velocità con controllo fine del mouse",
"Riduzione velocità con controllo fine del mouse",
"Riduzione della velocità del cursore del mouse come percentuale della velocità normale quando il controllo fine è attivato.",
NULL,
NULL,
{
{NULL, NULL},
},
NULL
},
{
"scummvm_framerate",
"Timing > Tetto frequenza dei fotogrammi",
"Tetto frequenza dei fotogrammi",
"Imposta il limite superiore della frequenza dei fotogrammi. La riduzione del limite migliora le prestazioni sui dispositivi di fascia bassa. Il cambio di questa impostazione causerà il reset del core.",
NULL,
NULL,
{
{ NULL, NULL },
},
NULL
},
{
"scummvm_samplerate",
"Timing > Frequenza di campionamento",
"Frequenza di campionamento",
"Imposta la frequenza di campionamento. La riduzione della frequenza migliora leggermente le prestazioni sui dispositivi di fascia bassa. Il cambio di questa impostazione causerà il reset del core.",
NULL,
NULL,
{
{ NULL, NULL },
},
NULL
},
/* Button mappings */
{
"scummvm_mapper_up",
"RetroPad > Su",
"Su",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_down",
"RetroPad > Giù",
"Giù",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_left",
"RetroPad > Sinistra",
"Sinistra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_right",
"RetroPad > Destra",
"Destra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_a",
"RetroPad > A",
"A",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_b",
"RetroPad > B",
"B",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_x",
"RetroPad > X",
"X",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_y",
"RetroPad > Y",
"Y",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_select",
"RetroPad > Select",
"Select",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_start",
"RetroPad > Start",
"Start",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_l",
"RetroPad > L",
"L",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_r",
"RetroPad > R",
"R",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_l2",
"RetroPad > L2",
"L2",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_r2",
"RetroPad > R2",
"R2",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_l3",
"RetroPad > L3",
"L3",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_r3",
"RetroPad > R3",
"R3",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
/* Left Stick */
{
"scummvm_mapper_lu",
"RetroPad > Leva Analogica Sinistra > Su",
"Leva Analogica Sinistra > Su",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_ld",
"RetroPad > Leva Analogica Sinistra > Giù",
"Leva Analogica Sinistra > Giù",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_ll",
"RetroPad > Leva Analogica Sinistra > Sinistra",
"Leva Analogica Sinistra > Sinistra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_lr",
"RetroPad > Leva Analogica Sinistra > Destra",
"Leva Analogica Sinistra > Destra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
/* Right Stick */
{
"scummvm_mapper_ru",
"RetroPad > Leva Analogica Destra > Su",
"Leva Analogica Destra > Su",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_rd",
"RetroPad > Leva Analogica Destra > Giù",
"Leva Analogica Destra > Giù",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_rl",
"RetroPad > Leva Analogica Destra > Sinistra",
"Leva Analogica Destra > Sinistra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_mapper_rr",
"RetroPad > Leva Analogica Destra > Destra",
"Leva Analogica Destra > Destra",
NULL,
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_video_hw_acceleration",
"Video > Accelerazione hardware",
"Accelerazione hardware",
"Richiede accelerazione hardware (OpenGL or OpenGLES2) al frontend, se supportata. È necessario ricaricare il core per rendere effettiva questa opzione",
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
#ifdef USE_HIGHRES
{
"scummvm_gui_aspect_ratio",
"Video > Rapporto aspetto GUI",
"Rapporto aspetto ScummVM Launcher",
"Imposta il rapporto d'aspetto per ScummVM Launcher.",
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
{
"scummvm_gui_h_res",
"Video > Risoluzione GUI",
"Risoluzione ScummVM Launcher",
"Imposta la risoluzione per ScummVM Launcher.",
NULL,
NULL,
{
{ NULL, NULL }
},
NULL,
},
#endif
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
struct retro_core_options_v2 options_it = {
option_cats_it,
option_defs_it
};
/* List has been reduced to fit RETRO_NUM_CORE_OPTION_VALUES_MAX.
* Latest element {NULL, NULL} has been omitted in this case as the array is exactly sized
* RETRO_NUM_CORE_OPTION_VALUES_MAX; in case the array size will be reduced, {NULL, NULL}
* element to be uncommented.
*/
struct retro_core_option_value retro_keys_label_it [] = {
{"---", "---"},
{"RETROKE_VKBD", "Attiva/disattiva Tastiera Virtuale"},
{"RETROKE_LEFT", "Cursore Mouse Sinistra"},
{"RETROKE_UP", "Cursore Mouse Su"},
{"RETROKE_DOWN", "Cursore Mouse Giù"},
{"RETROKE_RIGHT", "Cursore Mouse Destra"},
{"RETROKE_LEFT_BUTTON", "Tasto Mouse Sinistra"},
{"RETROKE_RIGHT_BUTTON", "Tasto Mouse Destra"},
{"RETROKE_FINE_CONTROL", "Controllo Fine Cursore Mouse"},
{"RETROKE_SCUMMVM_GUI", "ScummVM GUI"},
{"RETROKE_SHIFT_MOD", "Tastiera Shift (Modificatore)"},
{"RETROKE_CTRL_MOD", "Tastiera Control (Modificatore)"},
{"RETROKE_ALT_MOD", "Tastiera Alt (Modificatore)"},
{"RETROK_BACKSPACE", "Tastiera Backspace"},
{"RETROK_TAB", "Tastiera Tab"},
{"RETROK_CLEAR", "Tastiera Clear"},
{"RETROK_RETURN", "Tastiera Return"},
{"RETROK_PAUSE", "Tastiera Pause"},
{"RETROK_ESCAPE", "Tastiera Escape"},
{"RETROK_SPACE", "Tastiera Space"},
{"RETROK_EXCLAIM", "Tastiera !"},
{"RETROK_QUOTEDBL", "Tastiera \""},
{"RETROK_HASH", "Tastiera #"},
{"RETROK_DOLLAR", "Tastiera $"},
{"RETROK_AMPERSAND", "Tastiera &"},
{"RETROK_QUOTE", "Tastiera \'"},
{"RETROK_LEFTPAREN", "Tastiera ("},
{"RETROK_RIGHTPAREN", "Tastiera )"},
{"RETROK_ASTERISK", "Tastiera *"},
{"RETROK_PLUS", "Tastiera +"},
{"RETROK_COMMA", "Tastiera ,"},
{"RETROK_MINUS", "Tastiera -"},
{"RETROK_PERIOD", "Tastiera ."},
{"RETROK_SLASH", "Tastiera /"},
{"RETROK_0", "Tastiera 0"},
{"RETROK_1", "Tastiera 1"},
{"RETROK_2", "Tastiera 2"},
{"RETROK_3", "Tastiera 3"},
{"RETROK_4", "Tastiera 4"},
{"RETROK_5", "Tastiera 5"},
{"RETROK_6", "Tastiera 6"},
{"RETROK_7", "Tastiera 7"},
{"RETROK_8", "Tastiera 8"},
{"RETROK_9", "Tastiera 9"},
{"RETROK_COLON", "Tastiera :"},
{"RETROK_SEMICOLON", "Tastiera ;"},
{"RETROK_LESS", "Tastiera <"},
{"RETROK_EQUALS", "Tastiera ="},
{"RETROK_GREATER", "Tastiera >"},
{"RETROK_QUESTION", "Tastiera ?"},
{"RETROK_AT", "Tastiera @"},
{"RETROK_LEFTBRACKET", "Tastiera ["},
{"RETROK_BACKSLASH", "Tastiera \\"},
{"RETROK_RIGHTBRACKET", "Tastiera ]"},
{"RETROK_CARET", "Tastiera ^"},
{"RETROK_UNDERSCORE", "Tastiera _"},
{"RETROK_BACKQUOTE", "Tastiera `"},
{"RETROK_a", "Tastiera a"},
{"RETROK_b", "Tastiera b"},
{"RETROK_c", "Tastiera c"},
{"RETROK_d", "Tastiera d"},
{"RETROK_e", "Tastiera e"},
{"RETROK_f", "Tastiera f"},
{"RETROK_g", "Tastiera g"},
{"RETROK_h", "Tastiera h"},
{"RETROK_i", "Tastiera i"},
{"RETROK_j", "Tastiera j"},
{"RETROK_k", "Tastiera k"},
{"RETROK_l", "Tastiera l"},
{"RETROK_m", "Tastiera m"},
{"RETROK_n", "Tastiera n"},
{"RETROK_o", "Tastiera o"},
{"RETROK_p", "Tastiera p"},
{"RETROK_q", "Tastiera q"},
{"RETROK_r", "Tastiera r"},
{"RETROK_s", "Tastiera s"},
{"RETROK_t", "Tastiera t"},
{"RETROK_u", "Tastiera u"},
{"RETROK_v", "Tastiera v"},
{"RETROK_w", "Tastiera w"},
{"RETROK_x", "Tastiera x"},
{"RETROK_y", "Tastiera y"},
{"RETROK_z", "Tastiera z"},
{"RETROK_KP0", "Tastiera Numpad 0"},
{"RETROK_KP1", "Tastiera Numpad 1"},
{"RETROK_KP2", "Tastiera Numpad 2"},
{"RETROK_KP3", "Tastiera Numpad 3"},
{"RETROK_KP4", "Tastiera Numpad 4"},
{"RETROK_KP5", "Tastiera Numpad 5"},
{"RETROK_KP6", "Tastiera Numpad 6"},
{"RETROK_KP7", "Tastiera Numpad 7"},
{"RETROK_KP8", "Tastiera Numpad 8"},
{"RETROK_KP9", "Tastiera Numpad 9"},
{"RETROK_KP_PERIOD", "Tastiera Numpad ."},
{"RETROK_KP_DIVIDE", "Tastiera Numpad /"},
{"RETROK_KP_MULTIPLY", "Tastiera Numpad *"},
{"RETROK_KP_MINUS", "Tastiera Numpad -"},
{"RETROK_KP_PLUS", "Tastiera Numpad +"},
{"RETROK_KP_ENTER", "Tastiera Numpad Enter"},
{"RETROK_KP_EQUALS", "Tastiera Numpad ="},
{"RETROK_UP", "Tastiera Su"},
{"RETROK_DOWN", "Tastiera Giù"},
{"RETROK_LEFT", "Tastiera Sinistra"},
{"RETROK_RIGHT", "Tastiera Destra"},
{"RETROK_INSERT", "Tastiera Insert"},
{"RETROK_DELETE", "Tastiera Delete"},
{"RETROK_HOME", "Tastiera Home"},
{"RETROK_END", "Tastiera End"},
{"RETROK_PAGEUP", "Tastiera PageUp"},
{"RETROK_PAGEDOWN", "Tastiera PageDown"},
{"RETROK_F1", "Tastiera F1"},
{"RETROK_F2", "Tastiera F2"},
{"RETROK_F3", "Tastiera F3"},
{"RETROK_F4", "Tastiera F4"},
{"RETROK_F5", "Tastiera F5"},
{"RETROK_F6", "Tastiera F6"},
{"RETROK_F7", "Tastiera F7"},
{"RETROK_F8", "Tastiera F8"},
{"RETROK_F9", "Tastiera F9"},
{"RETROK_F10", "Tastiera F10"},
{"RETROK_F11", "Tastiera F11"},
{"RETROK_F12", "Tastiera F12"},
//{"RETROK_F13","Tastiera F13"},
//{"RETROK_F14","Tastiera F14"},
//{"RETROK_F15","Tastiera F15"},
//{"RETROK_NUMLOCK","Tastiera NumLock"},
//{"RETROK_CAPSLOCK","Tastiera Caps Lock"},
//{"RETROK_SCROLLOCK","Tastiera Scroll Lock"},
{"RETROK_LSHIFT", "Tastiera Shift Sinistra"},
{"RETROK_RSHIFT", "Tastiera Shift Destra"},
{"RETROK_LCTRL", "Tastiera Control Sinistra"},
{"RETROK_RCTRL", "Tastiera Control Destra"},
{"RETROK_LALT", "Tastiera Alt Sinistra"},
{"RETROK_RALT", "Tastiera Alt Destra"},
//{"RETROK_LMETA","Tastiera Left Meta"},
//{"RETROK_RMETA","Tastiera Right Meta"},
//{"RETROK_LSUPER","Tastiera Left Super"},
//{"RETROK_RSUPER","Tastiera Right Super"},
//{"RETROK_MODE","Tastiera Mode"},
//{"RETROK_COMPOSE","Tastiera Compose"},
//{"RETROK_HELP","Tastiera Help"},
//{"RETROK_PRINT","Tastiera Print"},
//{"RETROK_SYSREQ","Tastiera SysReq"},
//{"RETROK_BREAK","Tastiera Break"},
//{"RETROK_MENU","Tastiera Menu"},
//{"RETROK_POWER","Tastiera Power"},
//{"RETROK_EURO","Tastiera Euro"},
//{"RETROK_UNDO","Tastiera Undo"},
};
/* RETRO_LANGUAGE_DUTCH */
/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
/* RETRO_LANGUAGE_RUSSIAN */
/* RETRO_LANGUAGE_KOREAN */
/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
/* RETRO_LANGUAGE_ESPERANTO */
/* RETRO_LANGUAGE_POLISH */
/* RETRO_LANGUAGE_VIETNAMESE */
/* RETRO_LANGUAGE_ARABIC */
/* RETRO_LANGUAGE_GREEK */
/* RETRO_LANGUAGE_TURKISH */
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_CORE_H
#define LIBRETRO_CORE_H
#include <libretro.h>
extern retro_log_printf_t retro_log_cb;
extern retro_input_state_t retro_input_cb;
bool retro_get_input_bitmask_supported(void);
void retro_osd_notification(const char *msg);
int retro_get_input_device(void);
const char *retro_get_core_dir(void);
const char *retro_get_system_dir(void);
const char *retro_get_save_dir(void);
const char *retro_get_playlist_dir(void);
float retro_setting_get_frame_rate(void);
uint16 retro_setting_get_sample_rate(void);
uint16 retro_setting_get_audio_samples_buffer_size(void);
int retro_setting_get_analog_deadzone(void);
bool retro_setting_get_analog_response_is_quadratic(void);
float retro_setting_get_mouse_speed(void);
int retro_setting_get_mouse_fine_control_speed_reduction(void);
bool retro_setting_get_gamepad_cursor_only(void);
float retro_setting_get_gamepad_cursor_speed(void);
float retro_setting_get_gamepad_acceleration_time(void);
int retro_setting_get_gui_res_w(void);
int retro_setting_get_gui_res_h(void);
void retro_set_size(unsigned width, unsigned height);
uint8 retro_get_video_hw_mode(void);
#ifdef USE_OPENGL
uintptr_t retro_get_hw_fb(void);
void *retro_get_proc_address(const char *name);
#endif
#endif // LIBRETRO_CORE_H

View File

@@ -0,0 +1,68 @@
/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_DEFS_H
#define LIBRETRO_DEFS_H
/* Workaround for a RetroArch audio driver
* limitation: a maximum of 1024 frames
* can be written per call of audio_batch_cb() */
#define AUDIO_BATCH_FRAMES_MAX 1024
// System analog stick range is -0x8000 to 0x8000
#define ANALOG_RANGE 0x8000
#define DEFAULT_SAMPLE_RATE 48000
#define DEFAULT_REFRESH_RATE 60
#define FRAMESKIP_MAX DEFAULT_REFRESH_RATE / 2
#define DEFAULT_SOUNDFONT_FILENAME "Roland_SC-55.sf2"
// Audio status
#define AUDIO_STATUS_MUTE (1 << 0)
#define AUDIO_STATUS_UPDATE_LATENCY (1 << 1)
#define AV_STATUS_UPDATE_AV_INFO (1 << 2)
#define AV_STATUS_RESET_PENDING (1 << 3)
#define AV_STATUS_UPDATE_GEOMETRY (1 << 4)
#define AV_STATUS_UPDATE_GUI (1 << 5)
// Video status
#define VIDEO_GRAPHIC_MODE_REQUEST_SW (1 << 0)
#define VIDEO_GRAPHIC_MODE_REQUEST_HW (1 << 1)
#define VIDEO_GRAPHIC_MODE_HAVE_OPENGL (1 << 2)
#define VIDEO_GRAPHIC_MODE_HAVE_OPENGLES2 (1 << 3)
#define VIDEO_GRAPHIC_MODE_RESET_PENDING (1 << 4)
// Preliminary scan results
#define TEST_GAME_OK_TARGET_FOUND 0
#define TEST_GAME_OK_ID_FOUND 1
#define TEST_GAME_OK_ID_AUTODETECTED 2
#define TEST_GAME_KO_NOT_FOUND 3
#define TEST_GAME_KO_MULTIPLE_RESULTS 4
#ifndef F_OK
#define F_OK 0
#endif
#ifndef W_OK
#define W_OK 2
#endif
#ifndef R_OK
#define R_OK 4
#endif
#endif

View File

@@ -0,0 +1,39 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_FILESYSTEM_FACTORY_H
#define LIBRETRO_FILESYSTEM_FACTORY_H
#include "backends/fs/fs-factory.h"
/**
* Creates LibRetroFilesystemNode objects.
*
* Parts of this class are documented in the base interface class, FilesystemFactory.
*/
class LibRetroFilesystemFactory : public FilesystemFactory {
protected:
virtual AbstractFSNode *makeRootFileNode() const;
virtual AbstractFSNode *makeCurrentDirectoryFileNode() const;
virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const;
};
#endif /*LIBRETRO_FILESYSTEM_FACTORY_H*/

View File

@@ -0,0 +1,101 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_FILESYSTEM_H
#define LIBRETRO_FILESYSTEM_H
#include "backends/fs/abstract-fs.h"
#ifdef MACOSX
#include <sys/types.h>
#endif
#include <unistd.h>
/**
* Implementation of the ScummVM file system API based on LibRetro.
*
* Parts of this class are documented in the base interface class, AbstractFSNode.
*/
class LibRetroFilesystemNode : public AbstractFSNode {
protected:
Common::String _displayName;
Common::String _path;
bool _isDirectory;
bool _isValid;
bool _isReadable;
bool _isWritable;
virtual AbstractFSNode *makeNode(const Common::String &path) const {
return new LibRetroFilesystemNode(path);
}
/**
* Plain constructor, for internal use only (hence protected).
*/
LibRetroFilesystemNode() : _isDirectory(false), _isValid(false) {}
public:
/**
* Creates a LibRetroFilesystemNode for a given path.
*
* @param path the path the new node should point to.
*/
LibRetroFilesystemNode(const Common::String &path);
virtual bool exists() const {
return access(_path.c_str(), F_OK) == 0;
}
virtual Common::U32String getDisplayName() const {
return _displayName;
}
virtual Common::String getName() const {
return _displayName;
}
virtual Common::String getPath() const {
return _path;
}
virtual bool isDirectory() const {
return _isDirectory && _isReadable;
}
virtual bool isReadable() const {
return _isReadable;
}
virtual bool isWritable() const {
return _isWritable;
}
virtual AbstractFSNode *getChild(const Common::String &n) const;
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *createReadStream();
virtual Common::SeekableWriteStream *createWriteStream(bool atomic);
virtual bool createDirectory();
static Common::String getHomeDir(void);
private:
/**
* Tests and sets the _isValid and _isDirectory flags, using the stat() function.
*/
virtual void setFlags();
};
#endif

View File

@@ -0,0 +1,57 @@
/* Copyright (C) 2024 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BACKENDS_LIBRETRO_GRAPHICS_OPENGL_H
#define BACKENDS_LIBRETRO_GRAPHICS_OPENGL_H
#include "backends/graphics/opengl/opengl-graphics.h"
#include "backends/graphics/opengl/texture.h"
namespace OpenGL {
class Surface;
}
class LibretroOpenGLGraphics : public OpenGL::OpenGLGraphicsManager {
public:
LibretroOpenGLGraphics(OpenGL::ContextType contextType);
bool loadVideoMode(uint requestedWidth, uint requestedHeight, bool resizable, int antialiasing) override {
return true;
}
void refreshScreen() override;
void setSystemMousePosition(const int x, const int y) override {};
void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format, const byte *mask) override;
void initSize(uint width, uint height, const Graphics::PixelFormat *format) override;
void setMousePosition(int x, int y);
void resetContext(OpenGL::ContextType contextType);
OSystem::TransactionError endGFXTransaction() override;
bool hasFeature(OSystem::Feature f) const override;
protected:
bool gameNeedsAspectRatioCorrection() const override {
return false;
}
void handleResizeImpl(const int width, const int height) override;
private:
void overrideCursorScaling(void);
};
class LibretroHWFramebuffer : public OpenGL::Backbuffer {
protected:
void activateInternal() override;
};
#endif //BACKENDS_LIBRETRO_GRAPHICS_OPENGL_H

View File

@@ -0,0 +1,114 @@
/* Copyright (C) 2024 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
#define BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
#include "common/system.h"
#include "graphics/palette.h"
#include "graphics/managed_surface.h"
#include "backends/graphics/windowed.h"
class LibretroGraphics : public WindowedGraphicsManager {
public:
Graphics::ManagedSurface _screen;
Graphics::Surface _gameScreen;
Graphics::Surface _overlay;
Graphics::Surface _cursor;
Graphics::Palette _cursorPalette;
Graphics::Palette _gamePalette;
private:
bool _cursorDontScale;
bool _cursorPaletteEnabled;
bool _screenUpdatePending;
int _cursorHotspotX;
int _cursorHotspotY;
int _cursorKeyColor;
int _screenChangeID;
int _cursorHotspotXScaled;
int _cursorHotspotYScaled;
float _cursorWidthScaled;
float _cursorHeightScaled;
public:
LibretroGraphics();
~LibretroGraphics();
Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
const OSystem::GraphicsMode *getSupportedGraphicsModes(void) const override;
void initSize(uint width, uint height, const Graphics::PixelFormat *format) override;
int16 getHeight(void) const override;
int16 getWidth(void) const override;
Graphics::PixelFormat getScreenFormat(void) const override;
void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
void updateScreen(void) override;
void clearOverlay(void) override;
void grabOverlay(Graphics::Surface &surface) const override;
void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
int16 getOverlayHeight(void) const override;
int16 getOverlayWidth(void) const override;
Graphics::PixelFormat getOverlayFormat() const override;
const Graphics::ManagedSurface *getScreen(void);
void warpMouse(int x, int y) override;
void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr) override;
void setCursorPalette(const byte *colors, uint start, uint num) override;
bool isOverlayInGUI(void);
bool hasFeature(OSystem::Feature f) const override;
void setFeatureState(OSystem::Feature f, bool enable) override;
bool getFeatureState(OSystem::Feature f) const override;
int getDefaultGraphicsMode() const override {
return 0;
}
bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override {
return true;
}
int getGraphicsMode() const override {
return 0;
}
Graphics::Surface *lockScreen() override {
return &_gameScreen;
}
void unlockScreen() override {}
int getScreenChangeID() const override;
void beginGFXTransaction() override {}
OSystem::TransactionError endGFXTransaction() override;
void fillScreen(uint32 col) override {}
void fillScreen(const Common::Rect &r, uint32 col) override {}
void setFocusRectangle(const Common::Rect &rect) override {}
void clearFocusRectangle() override {}
void realUpdateScreen(void);
bool gameNeedsAspectRatioCorrection() const override {
return false;
}
void handleResizeImpl(const int width, const int height) override;
void setSystemMousePosition(const int x, const int y) override {}
void setMousePosition(int x, int y);
void displayMessageOnOSD(const Common::U32String &msg) override;
protected:
void setPalette(const byte *colors, uint start, uint num) override;
void grabPalette(byte *colors, uint start, uint num) const override;
private:
void overrideCursorScaling();
};
#endif //BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H

View File

@@ -0,0 +1,262 @@
/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_MAPPER_H
#define LIBRETRO_MAPPER_H
#include <libretro.h>
#include "common/keyboard.h"
#define RETRO_DEVICE_KEY_STATUS 0
#define RETRO_DEVICE_KEY_PREV_STATUS 1
#define RETRO_DEVICE_KEY_CHANGED 2
#define RETRO_DEVICE_ID_JOYPAD_ANALOG 16
#define RETRO_DEVICE_ID_JOYPAD_LR 16
#define RETRO_DEVICE_ID_JOYPAD_LL 17
#define RETRO_DEVICE_ID_JOYPAD_LD 18
#define RETRO_DEVICE_ID_JOYPAD_LU 19
#define RETRO_DEVICE_ID_JOYPAD_RR 20
#define RETRO_DEVICE_ID_JOYPAD_RL 21
#define RETRO_DEVICE_ID_JOYPAD_RD 22
#define RETRO_DEVICE_ID_JOYPAD_RU 23
#define RETRO_DEVICE_ID_JOYPAD_LAST 24
#define RETROKE_VKBD -1
#define RETROKE_LEFT -2
#define RETROKE_UP -3
#define RETROKE_DOWN -4
#define RETROKE_RIGHT -5
#define RETROKE_LEFT_BUTTON -6
#define RETROKE_RIGHT_BUTTON -7
#define RETROKE_FINE_CONTROL -8
#define RETROKE_SCUMMVM_GUI -9
#define RETROKE_SHIFT_MOD -10
#define RETROKE_CTRL_MOD -11
#define RETROKE_ALT_MOD -12
/* libretro.cpp functions */
extern retro_input_state_t retro_input_cb;
extern int retro_setting_get_analog_deadzone(void);
extern bool retro_get_input_bitmask_supported(void);
struct retro_keymap {
int retro_id;
int scummvm_id;
const char *value;
};
static const struct retro_keymap retro_keys[] = {
{0, 0, "---"},
{RETROKE_VKBD, 0, "RETROKE_VKBD"},
{RETROKE_LEFT, 0, "RETROKE_LEFT"},
{RETROKE_UP, 0, "RETROKE_UP"},
{RETROKE_DOWN, 0, "RETROKE_DOWN"},
{RETROKE_RIGHT, 0, "RETROKE_RIGHT"},
{RETROKE_LEFT_BUTTON, 0, "RETROKE_LEFT_BUTTON"},
{RETROKE_RIGHT_BUTTON, 0, "RETROKE_RIGHT_BUTTON"},
{RETROKE_FINE_CONTROL, 0, "RETROKE_FINE_CONTROL"},
{RETROKE_SCUMMVM_GUI, 0, "RETROKE_SCUMMVM_GUI"},
{RETROKE_SHIFT_MOD, 0, "RETROKE_SHIFT_MOD"},
{RETROKE_CTRL_MOD, 0, "RETROKE_CTRL_MOD"},
{RETROKE_ALT_MOD, 0, "RETROKE_ALT_MOD"},
{RETROK_BACKSPACE, Common::KEYCODE_BACKSPACE, "RETROK_BACKSPACE"},
{RETROK_TAB, Common::KEYCODE_TAB, "RETROK_TAB"},
{RETROK_CLEAR, Common::KEYCODE_CLEAR, "RETROK_CLEAR"},
{RETROK_RETURN, Common::KEYCODE_RETURN, "RETROK_RETURN"},
{RETROK_PAUSE, Common::KEYCODE_PAUSE, "RETROK_PAUSE"},
{RETROK_ESCAPE, Common::KEYCODE_ESCAPE, "RETROK_ESCAPE"},
{RETROK_SPACE, Common::KEYCODE_SPACE, "RETROK_SPACE"},
{RETROK_EXCLAIM, Common::KEYCODE_EXCLAIM, "RETROK_EXCLAIM"},
{RETROK_QUOTEDBL, Common::KEYCODE_QUOTEDBL, "RETROK_QUOTEDBL"},
{RETROK_HASH, Common::KEYCODE_HASH, "RETROK_HASH"},
{RETROK_DOLLAR, Common::KEYCODE_DOLLAR, "RETROK_DOLLAR"},
{RETROK_AMPERSAND, Common::KEYCODE_AMPERSAND, "RETROK_AMPERSAND"},
{RETROK_QUOTE, Common::KEYCODE_QUOTE, "RETROK_QUOTE"},
{RETROK_LEFTPAREN, Common::KEYCODE_LEFTPAREN, "RETROK_LEFTPAREN"},
{RETROK_RIGHTPAREN, Common::KEYCODE_RIGHTPAREN, "RETROK_RIGHTPAREN"},
{RETROK_ASTERISK, Common::KEYCODE_ASTERISK, "RETROK_ASTERISK"},
{RETROK_PLUS, Common::KEYCODE_PLUS, "RETROK_PLUS"},
{RETROK_COMMA, Common::KEYCODE_COMMA, "RETROK_COMMA"},
{RETROK_MINUS, Common::KEYCODE_MINUS, "RETROK_MINUS"},
{RETROK_PERIOD, Common::KEYCODE_PERIOD, "RETROK_PERIOD"},
{RETROK_SLASH, Common::KEYCODE_SLASH, "RETROK_SLASH"},
{RETROK_0, Common::KEYCODE_0, "RETROK_0"},
{RETROK_1, Common::KEYCODE_1, "RETROK_1"},
{RETROK_2, Common::KEYCODE_2, "RETROK_2"},
{RETROK_3, Common::KEYCODE_3, "RETROK_3"},
{RETROK_4, Common::KEYCODE_4, "RETROK_4"},
{RETROK_5, Common::KEYCODE_5, "RETROK_5"},
{RETROK_6, Common::KEYCODE_6, "RETROK_6"},
{RETROK_7, Common::KEYCODE_7, "RETROK_7"},
{RETROK_8, Common::KEYCODE_8, "RETROK_8"},
{RETROK_9, Common::KEYCODE_9, "RETROK_9"},
{RETROK_COLON, Common::KEYCODE_COLON, "RETROK_COLON"},
{RETROK_SEMICOLON, Common::KEYCODE_SEMICOLON, "RETROK_SEMICOLON"},
{RETROK_LESS, Common::KEYCODE_LESS, "RETROK_LESS"},
{RETROK_EQUALS, Common::KEYCODE_EQUALS, "RETROK_EQUALS"},
{RETROK_GREATER, Common::KEYCODE_GREATER, "RETROK_GREATER"},
{RETROK_QUESTION, Common::KEYCODE_QUESTION, "RETROK_QUESTION"},
{RETROK_AT, Common::KEYCODE_AT, "RETROK_AT"},
{RETROK_LEFTBRACKET, Common::KEYCODE_LEFTBRACKET, "RETROK_LEFTBRACKET"},
{RETROK_BACKSLASH, Common::KEYCODE_BACKSLASH, "RETROK_BACKSLASH"},
{RETROK_RIGHTBRACKET, Common::KEYCODE_RIGHTBRACKET, "RETROK_RIGHTBRACKET"},
{RETROK_CARET, Common::KEYCODE_CARET, "RETROK_CARET"},
{RETROK_UNDERSCORE, Common::KEYCODE_UNDERSCORE, "RETROK_UNDERSCORE"},
{RETROK_BACKQUOTE, Common::KEYCODE_BACKQUOTE, "RETROK_BACKQUOTE"},
{RETROK_a, Common::KEYCODE_a, "RETROK_a"},
{RETROK_b, Common::KEYCODE_b, "RETROK_b"},
{RETROK_c, Common::KEYCODE_c, "RETROK_c"},
{RETROK_d, Common::KEYCODE_d, "RETROK_d"},
{RETROK_e, Common::KEYCODE_e, "RETROK_e"},
{RETROK_f, Common::KEYCODE_f, "RETROK_f"},
{RETROK_g, Common::KEYCODE_g, "RETROK_g"},
{RETROK_h, Common::KEYCODE_h, "RETROK_h"},
{RETROK_i, Common::KEYCODE_i, "RETROK_i"},
{RETROK_j, Common::KEYCODE_j, "RETROK_j"},
{RETROK_k, Common::KEYCODE_k, "RETROK_k"},
{RETROK_l, Common::KEYCODE_l, "RETROK_l"},
{RETROK_m, Common::KEYCODE_m, "RETROK_m"},
{RETROK_n, Common::KEYCODE_n, "RETROK_n"},
{RETROK_o, Common::KEYCODE_o, "RETROK_o"},
{RETROK_p, Common::KEYCODE_p, "RETROK_p"},
{RETROK_q, Common::KEYCODE_q, "RETROK_q"},
{RETROK_r, Common::KEYCODE_r, "RETROK_r"},
{RETROK_s, Common::KEYCODE_s, "RETROK_s"},
{RETROK_t, Common::KEYCODE_t, "RETROK_t"},
{RETROK_u, Common::KEYCODE_u, "RETROK_u"},
{RETROK_v, Common::KEYCODE_v, "RETROK_v"},
{RETROK_w, Common::KEYCODE_w, "RETROK_w"},
{RETROK_x, Common::KEYCODE_x, "RETROK_x"},
{RETROK_y, Common::KEYCODE_y, "RETROK_y"},
{RETROK_z, Common::KEYCODE_z, "RETROK_z"},
{RETROK_KP0, Common::KEYCODE_KP0, "RETROK_KP0"},
{RETROK_KP1, Common::KEYCODE_KP1, "RETROK_KP1"},
{RETROK_KP2, Common::KEYCODE_KP2, "RETROK_KP2"},
{RETROK_KP3, Common::KEYCODE_KP3, "RETROK_KP3"},
{RETROK_KP4, Common::KEYCODE_KP4, "RETROK_KP4"},
{RETROK_KP5, Common::KEYCODE_KP5, "RETROK_KP5"},
{RETROK_KP6, Common::KEYCODE_KP6, "RETROK_KP6"},
{RETROK_KP7, Common::KEYCODE_KP7, "RETROK_KP7"},
{RETROK_KP8, Common::KEYCODE_KP8, "RETROK_KP8"},
{RETROK_KP9, Common::KEYCODE_KP9, "RETROK_KP9"},
{RETROK_KP_PERIOD, Common::KEYCODE_KP_PERIOD, "RETROK_KP_PERIOD"},
{RETROK_KP_DIVIDE, Common::KEYCODE_KP_DIVIDE, "RETROK_KP_DIVIDE"},
{RETROK_KP_MULTIPLY, Common::KEYCODE_KP_MULTIPLY, "RETROK_KP_MULTIPLY"},
{RETROK_KP_MINUS, Common::KEYCODE_KP_MINUS, "RETROK_KP_MINUS"},
{RETROK_KP_PLUS, Common::KEYCODE_KP_PLUS, "RETROK_KP_PLUS"},
{RETROK_KP_ENTER, Common::KEYCODE_KP_ENTER, "RETROK_KP_ENTER"},
{RETROK_KP_EQUALS, Common::KEYCODE_KP_EQUALS, "RETROK_KP_EQUALS"},
{RETROK_UP, Common::KEYCODE_UP, "RETROK_UP"},
{RETROK_DOWN, Common::KEYCODE_DOWN, "RETROK_DOWN"},
{RETROK_LEFT, Common::KEYCODE_LEFT, "RETROK_LEFT"},
{RETROK_RIGHT, Common::KEYCODE_RIGHT, "RETROK_RIGHT"},
{RETROK_INSERT, Common::KEYCODE_INSERT, "RETROK_INSERT"},
{RETROK_DELETE, Common::KEYCODE_DELETE, "RETROK_DELETE"},
{RETROK_HOME, Common::KEYCODE_HOME, "RETROK_HOME"},
{RETROK_END, Common::KEYCODE_END, "RETROK_END"},
{RETROK_PAGEUP, Common::KEYCODE_PAGEUP, "RETROK_PAGEUP"},
{RETROK_PAGEDOWN, Common::KEYCODE_PAGEDOWN, "RETROK_PAGEDOWN"},
{RETROK_F1, Common::KEYCODE_F1, "RETROK_F1"},
{RETROK_F2, Common::KEYCODE_F2, "RETROK_F2"},
{RETROK_F3, Common::KEYCODE_F3, "RETROK_F3"},
{RETROK_F4, Common::KEYCODE_F4, "RETROK_F4"},
{RETROK_F5, Common::KEYCODE_F5, "RETROK_F5"},
{RETROK_F6, Common::KEYCODE_F6, "RETROK_F6"},
{RETROK_F7, Common::KEYCODE_F7, "RETROK_F7"},
{RETROK_F8, Common::KEYCODE_F8, "RETROK_F8"},
{RETROK_F9, Common::KEYCODE_F9, "RETROK_F9"},
{RETROK_F10, Common::KEYCODE_F10, "RETROK_F10"},
{RETROK_F11, Common::KEYCODE_F11, "RETROK_F11"},
{RETROK_F12, Common::KEYCODE_F12, "RETROK_F12"},
{RETROK_F13, Common::KEYCODE_F13, "RETROK_F13"},
{RETROK_F14, Common::KEYCODE_F14, "RETROK_F14"},
{RETROK_F15, Common::KEYCODE_F15, "RETROK_F15"},
{RETROK_NUMLOCK, Common::KEYCODE_NUMLOCK, "RETROK_NUMLOCK"},
{RETROK_CAPSLOCK, Common::KEYCODE_CAPSLOCK, "RETROK_CAPSLOCK"},
{RETROK_SCROLLOCK, Common::KEYCODE_SCROLLOCK, "RETROK_SCROLLOCK"},
{RETROK_LSHIFT, Common::KEYCODE_LSHIFT, "RETROK_LSHIFT"},
{RETROK_RSHIFT, Common::KEYCODE_RSHIFT, "RETROK_RSHIFT"},
{RETROK_LCTRL, Common::KEYCODE_LCTRL, "RETROK_LCTRL"},
{RETROK_RCTRL, Common::KEYCODE_RCTRL, "RETROK_RCTRL"},
{RETROK_LALT, Common::KEYCODE_LALT, "RETROK_LALT"},
{RETROK_RALT, Common::KEYCODE_RALT, "RETROK_RALT"},
{RETROK_LMETA, Common::KEYCODE_LMETA, "RETROK_LMETA"},
{RETROK_RMETA, Common::KEYCODE_RMETA, "RETROK_RMETA"},
{RETROK_LSUPER, Common::KEYCODE_LSUPER, "RETROK_LSUPER"},
{RETROK_RSUPER, Common::KEYCODE_RSUPER, "RETROK_RSUPER"},
{RETROK_MODE, Common::KEYCODE_MODE, "RETROK_MODE"},
{RETROK_COMPOSE, Common::KEYCODE_COMPOSE, "RETROK_COMPOSE"},
{RETROK_HELP, Common::KEYCODE_HELP, "RETROK_HELP"},
{RETROK_PRINT, Common::KEYCODE_PRINT, "RETROK_PRINT"},
{RETROK_SYSREQ, Common::KEYCODE_SYSREQ, "RETROK_SYSREQ"},
{RETROK_BREAK, Common::KEYCODE_BREAK, "RETROK_BREAK"},
{RETROK_MENU, Common::KEYCODE_MENU, "RETROK_MENU"},
{RETROK_POWER, Common::KEYCODE_POWER, "RETROK_POWER"},
{RETROK_EURO, Common::KEYCODE_EURO, "RETROK_EURO"},
{RETROK_UNDO, Common::KEYCODE_UNDO, "RETROK_UNDO"},
{RETROK_LAST, 0, ""}
};
const struct retro_controller_description retro_controller_list[] = {
{"None", RETRO_DEVICE_NONE},
{"Automatic", RETRO_DEVICE_JOYPAD},
{NULL, 0}
};
const struct retro_controller_info retro_controller_lists[] = {
{retro_controller_list, sizeof(retro_controller_list) / sizeof(retro_controller_list[0])},
{NULL, 0}
};
static struct retro_input_descriptor retro_input_desc[] = {
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Up"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Down"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Left"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "B / Fire / Red"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "A / 2nd fire / Blue"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Y / Green"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "X / Yellow"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start / Play"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "L / Rewind"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "R / Forward"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2, "L2"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3, "L3"},
{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3"},
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X"},
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y"},
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X"},
{0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y"},
{0}
};
void mapper_poll_device(void);
bool mapper_set_device_keys(unsigned int retro_device_id, const char *retro_key_value);
uint8 mapper_get_device_key_status(unsigned int retro_device_id);
int16 mapper_get_device_key_value(unsigned int retro_device_id);
int16 mapper_get_device_key_retro_id(unsigned int retro_device_id);
int16 mapper_get_device_key_scummvm_id(unsigned int retro_device_id);
int8 mapper_get_mapper_key_index(int16 key_retro_id, uint8 start_index = 0);
uint8 mapper_get_mapper_key_status(int16 key_retro_id);
int16 mapper_get_mapper_key_value(int16 key_retro_id);
#endif // LIBRETRO_MAPPER_H

View File

@@ -0,0 +1,46 @@
/* Copyright (C) 2024 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "gui/browser.h"
#include "gui/gui-manager.h"
#include "gui/ThemeEval.h"
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "gui/widgets/popup.h"
#include "gui/widgets/richtext.h"
#define COMMON_HOOKS_FOLDER "scummvm_hooks"
class LibretroOptionsWidget final : public GUI::OptionsContainerWidget {
public:
explicit LibretroOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
~LibretroOptionsWidget() override;
void load() override;
bool save() override;
private:
void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
bool generatePlaylist(Common::String playlistPath);
bool cleanFolder(Common::String &path);
GUI::StaticTextWidget *_playlistPath;
GUI::StaticTextWidget *_playlistStatus;
GUI::PopUpWidget *_playlistVersion;
GUI::PopUpWidget *_hooksLocation;
GUI::CheckboxWidget *_hooksClear;
};

View File

@@ -0,0 +1,138 @@
/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BACKENDS_LIBRETRO_OS_H
#define BACKENDS_LIBRETRO_OS_H
#include "audio/mixer_intern.h"
#include "base/main.h"
//#include "backends/base-backend.h"
#include "common/system.h"
#include "common/mutex.h"
#include "common/list.h"
#include "common/events.h"
#include "backends/modular-backend.h"
#include "graphics/managed_surface.h"
#define BASE_CURSOR_SPEED 4
#define CURSOR_STATUS_DOING_JOYSTICK (1 << 0)
#define CURSOR_STATUS_DOING_MOUSE (1 << 1)
#define CURSOR_STATUS_DOING_X (1 << 2)
#define CURSOR_STATUS_DOING_Y (1 << 3)
#define CURSOR_STATUS_DOING_SLOWER (1 << 4)
#define LIBRETRO_G_SYSTEM dynamic_cast<OSystem_libretro *>(g_system)
/**
* Dummy mutex implementation
*/
class LibretroMutexInternal final : public Common::MutexInternal {
public:
LibretroMutexInternal() {};
~LibretroMutexInternal() override {};
bool lock() override {
return 0;
}
bool unlock() override {
return 0;
};
};
class OSystem_libretro : public EventsBaseBackend, public ModularGraphicsBackend {
private:
int _relMouseX;
int _relMouseY;
float _mouseXAcc;
float _mouseYAcc;
float _dpadXAcc;
float _dpadYAcc;
float _dpadXVel;
float _dpadYVel;
float _adjusted_cursor_speed;
float _inverse_acceleration_time;
uint32 _startTime;
uint8 _cursorStatus;
Common::String s_systemDir;
Common::String s_saveDir;
Common::String s_playlistDir;
Common::List<Common::Event> _events;
public:
Audio::MixerImpl *_mixer;
bool _mouseButtons[2];
bool _ptrmouseButton;
int _mouseX;
int _mouseY;
/* Base */
OSystem_libretro(void);
~OSystem_libretro(void) override;
void initBackend(void) override;
void engineInit(void) override;
void refreshRetroSettings(void);
void refreshScreen(void);
void destroy(void);
void quit() override {}
void resetGraphicsManager(void);
void getScreen(const Graphics::ManagedSurface *&screen);
int16 getScreenWidth(void);
int16 getScreenHeight(void);
bool inLauncher(void);
#ifdef USE_OPENGL
void resetGraphicsContext(void);
#ifdef USE_GLAD
void *getOpenGLProcAddress(const char *name) const override;
#endif
#endif
/* Events */
public:
bool pollEvent(Common::Event &event) override;
uint32 getMillis(bool skipRecord = false) override;
void delayMillis(uint msecs) override;
Common::MutexInternal *createMutex(void) override;
void requestQuit(void);
void resetQuit(void);
void setMousePosition(int x, int y);
/* Utils */
void getTimeAndDate(TimeDate &t, bool skipRecord) const override;
Audio::Mixer *getMixer(void) override;
Common::Path getDefaultConfigFileName(void) override;
void logMessage(LogMessageType::Type type, const char *message) override;
int testGame(const char *filedata, bool autodetect);
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
const char *const *buildHelpDialogData() override;
Common::String getSaveDir(void);
GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
void applyBackendSettings() override;
private:
bool parseGameName(const Common::String &gameName, Common::String &engineId, Common::String &gameId);
bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
void setLibretroDir(const char *path, Common::String &var);
/* Inputs */
public:
void processInputs(void);
void processKeyEvent(bool down, unsigned keycode, uint32 character, uint16 key_modifiers);
private:
void updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int doing_x);
void getMouseXYFromAnalog(bool is_x, int16 coor);
void getMouseXYFromButton(bool is_x, int16 sign);
};
#endif

View File

@@ -0,0 +1,67 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_THREADS_H
#define LIBRETRO_THREADS_H
/* ScummVM doesn't have a top-level main loop that we can use, so instead we run it in its own thread
* and switch between it and the main thread. Calling these function will block the current thread
* and unblock the other. Each function should be called from the other thread.
*/
void retro_switch_to_emu_thread(void);
void retro_switch_to_main_thread(void);
/* Initialize the emulation thread and any related resources.
*
* This function should be called from the main thread.
*/
bool retro_init_emu_thread(void);
/* Destroy the emulation thread and any related resources. Only call this after the emulation thread
* has finished (or canceled) and joined.
*
* This function should be called from the main thread.
*/
void retro_deinit_emu_thread(void);
/* Returns true if the emulation thread was initialized successfully.
*
* This function should be called from the main thread.
*/
bool retro_emu_thread_initialized(void);
/* Returns true if the emulation thread has exited naturally.
*
* This function can be called from either the main or the emulation thread.
*/
bool retro_emu_thread_exited(void);
/* Returns scummvm_main return code or -1 if not available */
int retro_get_scummvm_res(void);
/* Returns true if the emulation thread was started successfully.
*
* This function should be called from the main thread.
*/
bool retro_emu_thread_started(void);
#endif

View File

@@ -0,0 +1,44 @@
/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRETRO_TIMER_H
#define LIBRETRO_TIMER_H
// Thread switch caller
#define THREAD_SWITCH_POLL (1 << 0)
#define THREAD_SWITCH_DELAY (1 << 1)
#define THREAD_SWITCH_UPDATE (1 << 2)
#include "backends/timer/default/default-timer.h"
#include "backends/platform/libretro/include/libretro-defs.h"
class LibretroTimerManager : public DefaultTimerManager {
uint32 _interval;
uint32 _nextSwitchTime;
uint32 _spentOnMainThread;
uint8 _threadSwitchCaller;
public:
LibretroTimerManager(uint32 refresh_rate);
~LibretroTimerManager(void) {};
void switchThread(uint8 caller = 0);
bool checkThread(uint8 caller = 0);
uint32 timeToNextSwitch(void);
uint32 spentOnMainThread(void);
uint8 getThreadSwitchCaller(void);
};
#endif // LIBRETRO_TIMER_H

View File

@@ -0,0 +1,60 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <new>
#include <limits>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
/* newlib ctype.h defines _X for hex digit flag.
This conflicts with the use of _X as a variable name. */
#undef _X
#ifndef USE_HIGHRES
#define RES_W_OVERLAY 320
#define RES_H_OVERLAY 200
#define RES_INIT_MAX_W 320
#define RES_INIT_MAX_H 200
#else
#define RES_W_OVERLAY 1280
#define RES_H_OVERLAY 720
#define RES_INIT_MAX_W 1280 /* crab engine */
#define RES_INIT_MAX_H 768 /* e.g. director engine */
#endif
// HACK: With MinGW, GRIM engine seems to crash when using setjmp and longjmp if not using builtin versions
#if defined __MINGW64__ || defined __MINGW32__
#include <setjmp.h>
#undef setjmp
#undef longjmp
#define setjmp(a) (__builtin_setjmp(a))
#define longjmp(a, b) (__builtin_longjmp(a, b))
#endif

View File

@@ -0,0 +1,277 @@
#pragma once
#include <wiiu/types.h>
#include "time.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OSThread OSThread;
typedef int (*OSThreadEntryPointFn)(int argc, const char **argv);
typedef void (*OSThreadCleanupCallbackFn)(OSThread *thread, void *stack);
typedef void (*OSThreadDeallocatorFn)(OSThread *thread, void *stack);
enum OS_THREAD_STATE
{
OS_THREAD_STATE_NONE = 0,
/*! Thread is ready to run */
OS_THREAD_STATE_READY = 1 << 0,
/*! Thread is running */
OS_THREAD_STATE_RUNNING = 1 << 1,
/*! Thread is waiting, i.e. on a mutex */
OS_THREAD_STATE_WAITING = 1 << 2,
/*! Thread is about to terminate */
OS_THREAD_STATE_MORIBUND = 1 << 3,
};
typedef uint8_t OSThreadState;
enum OS_THREAD_REQUEST
{
OS_THREAD_REQUEST_NONE = 0,
OS_THREAD_REQUEST_SUSPEND = 1,
OS_THREAD_REQUEST_CANCEL = 2,
};
typedef uint32_t OSThreadRequest;
enum OS_THREAD_ATTRIB
{
/*! Allow the thread to run on CPU0. */
OS_THREAD_ATTRIB_AFFINITY_CPU0 = 1 << 0,
/*! Allow the thread to run on CPU1. */
OS_THREAD_ATTRIB_AFFINITY_CPU1 = 1 << 1,
/*! Allow the thread to run on CPU2. */
OS_THREAD_ATTRIB_AFFINITY_CPU2 = 1 << 2,
/*! Allow the thread to run any CPU. */
OS_THREAD_ATTRIB_AFFINITY_ANY = ((1 << 0) | (1 << 1) | (1 << 2)),
/*! Start the thread detached. */
OS_THREAD_ATTRIB_DETACHED = 1 << 3,
/*! Enables tracking of stack usage. */
OS_THREAD_ATTRIB_STACK_USAGE = 1 << 5
};
typedef uint8_t OSThreadAttributes;
#define OS_CONTEXT_TAG 0x4F53436F6E747874ull
typedef struct OSContext
{
/*! Should always be set to the value OS_CONTEXT_TAG. */
uint64_t tag;
uint32_t gpr[32];
uint32_t cr;
uint32_t lr;
uint32_t ctr;
uint32_t xer;
uint32_t srr0;
uint32_t srr1;
uint32_t __unknown[0x5];
uint32_t fpscr;
double fpr[32];
uint16_t spinLockCount;
uint16_t state;
uint32_t gqr[8];
uint32_t __unknown0;
double psf[32];
uint64_t coretime[3];
uint64_t starttime;
uint32_t error;
uint32_t __unknown1;
uint32_t pmc1;
uint32_t pmc2;
uint32_t pmc3;
uint32_t pmc4;
uint32_t mmcr0;
uint32_t mmcr1;
} OSContext;
typedef struct OSMutex OSMutex;
typedef struct OSFastMutex OSFastMutex;
typedef struct OSMutexQueue
{
OSMutex *head;
OSMutex *tail;
void *parent;
uint32_t __unknown;
} OSMutexQueue;
typedef struct OSFastMutexQueue
{
OSFastMutex *head;
OSFastMutex *tail;
} OSFastMutexQueue;
typedef struct
{
OSThread *prev;
OSThread *next;
} OSThreadLink;
typedef struct
{
OSThread *head;
OSThread *tail;
void *parent;
uint32_t __unknown;
} OSThreadQueue;
typedef struct
{
OSThread *head;
OSThread *tail;
} OSThreadSimpleQueue;
#define OS_THREAD_TAG 0x74487244u
#pragma pack(push, 1)
typedef struct __attribute__ ((aligned (8))) OSThread
{
OSContext context;
/*! Should always be set to the value OS_THREAD_TAG. */
uint32_t tag;
/*! Bitfield of OS_THREAD_STATE */
OSThreadState state;
/*! Bitfield of OS_THREAD_ATTRIB */
OSThreadAttributes attr;
/*! Unique thread ID */
uint16_t id;
/*! Suspend count (increased by OSSuspendThread). */
int32_t suspendCounter;
/*! Actual priority of thread. */
int32_t priority;
/*! Base priority of thread, 0 is highest priority, 31 is lowest priority. */
int32_t basePriority;
/*! Exit value */
int32_t exitValue;
uint32_t unknown0[0x9];
/*! Queue the thread is currently waiting on */
OSThreadQueue *queue;
/*! Link used for thread queue */
OSThreadLink link;
/*! Queue of threads waiting to join this thread */
OSThreadQueue joinQueue;
/*! Mutex this thread is waiting to lock */
OSMutex *mutex;
/*! Queue of mutexes this thread owns */
OSMutexQueue mutexQueue;
/*! Link for global active thread queue */
OSThreadLink activeLink;
/*! Stack start (top, highest address) */
void *stackStart;
/*! Stack end (bottom, lowest address) */
void *stackEnd;
/*! Thread entry point */
OSThreadEntryPointFn entryPoint;
uint32_t unknown1[0x77];
/*! Thread specific values, accessed with OSSetThreadSpecific and OSGetThreadSpecific. */
uint32_t specific[0x10];
uint32_t unknown2;
/*! Thread name, accessed with OSSetThreadName and OSGetThreadName. */
const char *name;
uint32_t unknown3;
/*! The stack pointer passed in OSCreateThread. */
void *userStackPointer;
/*! Called just before thread is terminated, set with OSSetThreadCleanupCallback */
OSThreadCleanupCallbackFn cleanupCallback;
/*! Called just after a thread is terminated, set with OSSetThreadDeallocator */
OSThreadDeallocatorFn deallocator;
/*! If TRUE then a thread can be cancelled or suspended, set with OSSetThreadCancelState */
BOOL cancelState;
/*! Current thread request, used for cancelleing and suspending the thread. */
OSThreadRequest requestFlag;
/*! Pending suspend request count */
int32_t needSuspend;
/*! Result of thread suspend */
int32_t suspendResult;
/*! Queue of threads waiting for a thread to be suspended. */
OSThreadQueue suspendQueue;
uint32_t unknown4[0x2B];
} OSThread;
#pragma pack(pop)
void
OSCancelThread(OSThread *thread);
int32_t OSCheckActiveThreads();
int32_t OSCheckThreadStackUsage(OSThread *thread);
void OSClearThreadStackUsage(OSThread *thread);
void OSContinueThread(OSThread *thread);
BOOL OSCreateThread(OSThread *thread, OSThreadEntryPointFn entry, int32_t argc, char *argv,
void *stack, uint32_t stackSize, int32_t priority, OSThreadAttributes attributes);
void OSDetachThread(OSThread *thread);
void OSExitThread(int32_t result);
void OSGetActiveThreadLink(OSThread *thread, OSThreadLink *link);
OSThread *OSGetCurrentThread();
OSThread *OSGetDefaultThread(uint32_t coreID);
uint32_t OSGetStackPointer();
uint32_t OSGetThreadAffinity(OSThread *thread);
const char *OSGetThreadName(OSThread *thread);
int32_t OSGetThreadPriority(OSThread *thread);
uint32_t OSGetThreadSpecific(uint32_t id);
BOOL OSIsThreadSuspended(OSThread *thread);
BOOL OSIsThreadTerminated(OSThread *thread);
BOOL OSJoinThread(OSThread *thread, int *threadResult);
int32_t OSResumeThread(OSThread *thread);
BOOL OSRunThread(OSThread *thread, OSThreadEntryPointFn entry, int argc, const char **argv);
BOOL OSSetThreadAffinity(OSThread *thread, uint32_t affinity);
BOOL OSSetThreadCancelState(BOOL state);
OSThreadCleanupCallbackFn OSSetThreadCleanupCallback(OSThread *thread,
OSThreadCleanupCallbackFn callback);
OSThreadDeallocatorFn OSSetThreadDeallocator(OSThread *thread, OSThreadDeallocatorFn deallocator);
void OSSetThreadName(OSThread *thread, const char *name);
BOOL OSSetThreadPriority(OSThread *thread, int32_t priority);
BOOL OSSetThreadRunQuantum(OSThread *thread, uint32_t quantum);
void OSSetThreadSpecific(uint32_t id, uint32_t value);
BOOL OSSetThreadStackUsage(OSThread *thread);
void OSSleepThread(OSThreadQueue *queue);
void OSSleepTicks(OSTime ticks);
uint32_t OSSuspendThread(OSThread *thread);
void OSTestThreadCancel();
void OSWakeupThread(OSThreadQueue *queue);
void OSYieldThread();
void OSInitThreadQueue(OSThreadQueue *queue);
void OSInitThreadQueueEx(OSThreadQueue *queue, void *parent);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,49 @@
#pragma once
#include <wiiu/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OSOneSecond ((OSGetSystemInfo()->clockSpeed) / 4)
#define OSMilliseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000ull)
#define OSMicroseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000000ull)
#define OSNanoseconds(val) ((((uint64_t)(val)) * (uint64_t)(OSOneSecond)) / 1000000000ull)
#define wiiu_bus_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2*2*2) /* 248.625000 Mhz */
#define wiiu_cpu_clock (17 * 13 * 5*5*5 * 5*5*5 * 5 * 3*3 * 2*2*2) /* 1243.125000 Mhz */
#define wiiu_timer_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) /* 62.156250 Mhz */
#define sec_to_ticks(s) (((17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) * (uint64_t)(s)))
#define ms_to_ticks(ms) (((17 * 13 * 5*5*5 * 3*3) * (uint64_t)(ms)) / (2*2))
#define us_to_ticks(us) (((17 * 13 * 3*3) * (uint64_t)(us)) / (2*2* 2*2*2))
#define ns_to_ticks(ns) (((17 * 13 * 3*3) * (uint64_t)(ns)) / (2*2* 2*2*2* 2*2*2 *5*5*5))
#define ticks_to_sec(ticks) (((uint64_t)(ticks)) / (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2))
#define ticks_to_ms(ticks) (((uint64_t)(ticks) * (2*2)) / (17 * 13 * 5*5*5 * 3*3))
#define ticks_to_us(ticks) (((uint64_t)(ticks) * (2*2 * 2*2*2)) / (17 * 13 * 3*3))
#define ticks_to_ns(ticks) (((uint64_t)(ticks) * (2*2 * 2*2*2 * 2*2*2 * 5*5*5)) / (17 * 13 * 3*3))
typedef int32_t OSTick;
typedef int64_t OSTime;
typedef struct
{
int32_t tm_sec;
int32_t tm_min;
int32_t tm_hour;
int32_t tm_mday;
int32_t tm_mon;
int32_t tm_year;
}OSCalendarTime;
OSTime OSGetTime();
OSTime OSGetSystemTime();
OSTick OSGetTick();
OSTick OSGetSystemTick();
OSTime OSCalendarTimeToTicks(OSCalendarTime *calendarTime);
void OSTicksToCalendarTime(OSTime time, OSCalendarTime *calendarTime);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,41 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef int BOOL;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef float f32;
typedef double f64;
typedef volatile float vf32;
typedef volatile double vf64;
#define countof(array) (sizeof(array) / sizeof(*array))