Compare commits
2 Commits
11d015daf8
...
1db80485a6
| Author | SHA1 | Date | |
|---|---|---|---|
| 1db80485a6 | |||
| 25cd6b00eb |
@@ -29,6 +29,9 @@ add_executable(${PROJECT_NAME} ${SOURCES})
|
|||||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
||||||
|
|
||||||
|
# Definir _DEBUG en modo Debug
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:DEBUG>)
|
||||||
|
|
||||||
# Enlazar la librería SDL3
|
# Enlazar la librería SDL3
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3)
|
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3)
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
|
|||||||
| **F3** | Alterna entre mode de pantalla completa i finestra |
|
| **F3** | Alterna entre mode de pantalla completa i finestra |
|
||||||
| **F4** | Activa o desactiva el filtre de pantalla |
|
| **F4** | Activa o desactiva el filtre de pantalla |
|
||||||
| **F5** | Activa o desactiva el mode d'escalat sencer |
|
| **F5** | Activa o desactiva el mode d'escalat sencer |
|
||||||
| **F6** | Activa o desactiva l'àudio |
|
| **F6** | Activa o desactiva el sincronisme vertical |
|
||||||
| **F7** | Activa o desactiva el dispar automàtic |
|
| **F7** | Activa o desactiva l'àudio |
|
||||||
| **F8** | Canvia l'idioma del joc (Provoca el reinici) |
|
| **F8** | Activa o desactiva el dispar automàtic |
|
||||||
|
| **F9** | Canvia l'idioma del joc (Provoca el reinici) |
|
||||||
| **F10** | Reinicia el joc |
|
| **F10** | Reinicia el joc |
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
|||||||
@@ -404,4 +404,7 @@ Mode pantalla completa
|
|||||||
Mode d'escalat sencer
|
Mode d'escalat sencer
|
||||||
|
|
||||||
## 135 - VARIOS
|
## 135 - VARIOS
|
||||||
Filtre
|
Filtre
|
||||||
|
|
||||||
|
## 136 - VARIOS
|
||||||
|
Sincronisme vertical
|
||||||
@@ -404,4 +404,7 @@ Fullscreen mode
|
|||||||
Integer scale
|
Integer scale
|
||||||
|
|
||||||
## 135 - VARIOS
|
## 135 - VARIOS
|
||||||
Filter
|
Filter
|
||||||
|
|
||||||
|
## 136 - VARIOS
|
||||||
|
Vertical Sync
|
||||||
@@ -404,4 +404,7 @@ Modo pantalla completa
|
|||||||
Modo de escalado entero
|
Modo de escalado entero
|
||||||
|
|
||||||
## 135 - VARIOS
|
## 135 - VARIOS
|
||||||
Filtro
|
Filtro
|
||||||
|
|
||||||
|
## 136 - VARIOS
|
||||||
|
Sincronismo vertical
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <SDL3/SDL_error.h> // Para SDL_GetError
|
#include <SDL3/SDL_error.h> // Para SDL_GetError
|
||||||
#include <SDL3/SDL_gamepad.h> // Para SDL_GamepadButton
|
#include <SDL3/SDL_gamepad.h> // Para SDL_GamepadButton
|
||||||
#include <SDL3/SDL_init.h> // Para SDL_Init, SDL_Quit, SDL_INIT_AUDIO
|
#include <SDL3/SDL_init.h> // Para SDL_Init, SDL_Quit, SDL_INIT_AUDIO
|
||||||
#include <SDL3/SDL.h> // Para SDL_Log, SDL_LogCategory, SDL_LogE...
|
#include <SDL3/SDL.h> // Para SDL_Log, SDL_LogCategory, SDL_LogE...
|
||||||
#include <SDL3/SDL_scancode.h> // Para SDL_Scancode
|
#include <SDL3/SDL_scancode.h> // Para SDL_Scancode
|
||||||
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOOLONG
|
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOOLONG
|
||||||
#include <stdio.h> // Para printf, perror
|
#include <stdio.h> // Para printf, perror
|
||||||
@@ -49,12 +49,12 @@ Director::Director(int argc, const char *argv[])
|
|||||||
section::name = section::Name::GAME;
|
section::name = section::Name::GAME;
|
||||||
section::options = section::Options::GAME_PLAY_1P;
|
section::options = section::Options::GAME_PLAY_1P;
|
||||||
#elif DEBUG
|
#elif DEBUG
|
||||||
section::name = section::Name::LOGO;
|
section::name = section::Name::INTRO;
|
||||||
#else // NORMAL GAME
|
#else // NORMAL GAME
|
||||||
section::name = section::Name::LOGO;
|
section::name = section::Name::LOGO;
|
||||||
|
#endif
|
||||||
section::options = section::Options::NONE;
|
section::options = section::Options::NONE;
|
||||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Establece el nivel de prioridad de la categoría de registro
|
// Establece el nivel de prioridad de la categoría de registro
|
||||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||||
@@ -99,6 +99,10 @@ void Director::init()
|
|||||||
bindInputs();
|
bindInputs();
|
||||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
||||||
OnScreenHelp::init();
|
OnScreenHelp::init();
|
||||||
|
#ifdef DEBUG
|
||||||
|
Screen::get()->initDebugInfo();
|
||||||
|
Screen::get()->setDebugInfoEnabled(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra todo
|
// Cierra todo
|
||||||
@@ -171,12 +175,13 @@ void Director::bindInputs()
|
|||||||
Input::get()->bindKey(InputAction::WINDOW_DEC_SIZE, SDL_SCANCODE_F1);
|
Input::get()->bindKey(InputAction::WINDOW_DEC_SIZE, SDL_SCANCODE_F1);
|
||||||
Input::get()->bindKey(InputAction::WINDOW_INC_SIZE, SDL_SCANCODE_F2);
|
Input::get()->bindKey(InputAction::WINDOW_INC_SIZE, SDL_SCANCODE_F2);
|
||||||
Input::get()->bindKey(InputAction::WINDOW_FULLSCREEN, SDL_SCANCODE_F3);
|
Input::get()->bindKey(InputAction::WINDOW_FULLSCREEN, SDL_SCANCODE_F3);
|
||||||
Input::get()->bindKey(InputAction::VIDEO_SHADERS, SDL_SCANCODE_F4);
|
Input::get()->bindKey(InputAction::TOGGLE_VIDEO_SHADERS, SDL_SCANCODE_F4);
|
||||||
Input::get()->bindKey(InputAction::VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5);
|
Input::get()->bindKey(InputAction::TOGGLE_VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5);
|
||||||
|
Input::get()->bindKey(InputAction::TOGGLE_VIDEO_VSYNC, SDL_SCANCODE_F6);
|
||||||
|
|
||||||
Input::get()->bindKey(InputAction::MUTE, SDL_SCANCODE_F6);
|
Input::get()->bindKey(InputAction::TOGGLE_AUDIO, SDL_SCANCODE_F7);
|
||||||
Input::get()->bindKey(InputAction::AUTO_FIRE, SDL_SCANCODE_F7);
|
Input::get()->bindKey(InputAction::TOGGLE_AUTO_FIRE, SDL_SCANCODE_F8);
|
||||||
Input::get()->bindKey(InputAction::CHANGE_LANG, SDL_SCANCODE_F8);
|
Input::get()->bindKey(InputAction::CHANGE_LANG, SDL_SCANCODE_F9);
|
||||||
|
|
||||||
Input::get()->bindKey(InputAction::RESET, SDL_SCANCODE_F10);
|
Input::get()->bindKey(InputAction::RESET, SDL_SCANCODE_F10);
|
||||||
|
|
||||||
@@ -224,8 +229,8 @@ void Director::bindInputs()
|
|||||||
Input::get()->bindGameControllerButton(i, InputAction::EXIT, InputAction::START);
|
Input::get()->bindGameControllerButton(i, InputAction::EXIT, InputAction::START);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::RESET, InputAction::FIRE_CENTER);
|
Input::get()->bindGameControllerButton(i, InputAction::RESET, InputAction::FIRE_CENTER);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::PAUSE, InputAction::FIRE_RIGHT);
|
Input::get()->bindGameControllerButton(i, InputAction::PAUSE, InputAction::FIRE_RIGHT);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::VIDEO_SHADERS, InputAction::FIRE_LEFT);
|
Input::get()->bindGameControllerButton(i, InputAction::TOGGLE_VIDEO_SHADERS, InputAction::FIRE_LEFT);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::MUTE, InputAction::LEFT);
|
Input::get()->bindGameControllerButton(i, InputAction::TOGGLE_AUDIO, InputAction::LEFT);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::SHOW_INFO, InputAction::RIGHT);
|
Input::get()->bindGameControllerButton(i, InputAction::SHOW_INFO, InputAction::RIGHT);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::CONFIG, InputAction::DOWN);
|
Input::get()->bindGameControllerButton(i, InputAction::CONFIG, InputAction::DOWN);
|
||||||
Input::get()->bindGameControllerButton(i, InputAction::SWAP_CONTROLLERS, InputAction::UP);
|
Input::get()->bindGameControllerButton(i, InputAction::SWAP_CONTROLLERS, InputAction::UP);
|
||||||
@@ -262,7 +267,7 @@ void Director::initJailAudio()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** SDL_AUDIO: INITIALIZING\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_AUDIO: INITIALIZING\n");
|
||||||
|
|
||||||
JA_Init(48000, SDL_AUDIO_S16LE, 2);
|
JA_Init(48000, SDL_AUDIO_S16LE, 2);
|
||||||
if (options.audio.enabled)
|
if (options.audio.enabled)
|
||||||
@@ -276,7 +281,7 @@ void Director::initJailAudio()
|
|||||||
JA_SetSoundVolume(0);
|
JA_SetSoundVolume(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,14 +75,19 @@ namespace globalInputs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el modo de escalado entero
|
// Cambia el modo de escalado entero
|
||||||
void toggleintegerScale()
|
void toggleIntegerScale()
|
||||||
{
|
{
|
||||||
options.video.integer_scale = !options.video.integer_scale;
|
Screen::get()->toggleIntegerScale();
|
||||||
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, options.video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
|
||||||
Screen::get()->setFullscreenMode();
|
|
||||||
Notifier::get()->show({lang::getText(134) + " " + boolToOnOff(options.video.integer_scale)});
|
Notifier::get()->show({lang::getText(134) + " " + boolToOnOff(options.video.integer_scale)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activa / desactiva el vsync
|
||||||
|
void toggleVSync()
|
||||||
|
{
|
||||||
|
Screen::get()->toggleVSync();
|
||||||
|
Notifier::get()->show({lang::getText(136) + " " + boolToOnOff(options.video.v_sync)});
|
||||||
|
}
|
||||||
|
|
||||||
// Activa o desactiva los shaders
|
// Activa o desactiva los shaders
|
||||||
void toggleShaders()
|
void toggleShaders()
|
||||||
{
|
{
|
||||||
@@ -228,14 +233,14 @@ namespace globalInputs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
if (Input::get()->checkInput(InputAction::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputAction::TOGGLE_AUDIO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
toggleAudio();
|
toggleAudio();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autofire
|
// Autofire
|
||||||
if (Input::get()->checkInput(InputAction::AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputAction::TOGGLE_AUTO_FIRE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
toggleFireMode();
|
toggleFireMode();
|
||||||
return;
|
return;
|
||||||
@@ -249,20 +254,27 @@ namespace globalInputs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
if (Input::get()->checkInput(InputAction::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
toggleShaders();
|
toggleShaders();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input::get()->checkInput(InputAction::VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
// Integer Scale
|
||||||
|
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_INTEGER_SCALE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
toggleintegerScale();
|
toggleIntegerScale();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VSync
|
||||||
|
if (Input::get()->checkInput(InputAction::TOGGLE_VIDEO_VSYNC, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
|
{
|
||||||
|
toggleVSync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Comprueba el teclado para mostrar la información de debug
|
// Debug info
|
||||||
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
Screen::get()->toggleDebugInfo();
|
Screen::get()->toggleDebugInfo();
|
||||||
@@ -299,7 +311,7 @@ namespace globalInputs
|
|||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) &&
|
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) &&
|
||||||
Input::get()->checkInput(InputAction::MUTE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
Input::get()->checkInput(InputAction::TOGGLE_AUDIO, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
||||||
{
|
{
|
||||||
toggleAudio();
|
toggleAudio();
|
||||||
return;
|
return;
|
||||||
@@ -307,7 +319,7 @@ namespace globalInputs
|
|||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) &&
|
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) &&
|
||||||
Input::get()->checkInput(InputAction::VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
Input::get()->checkInput(InputAction::TOGGLE_VIDEO_SHADERS, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
||||||
{
|
{
|
||||||
toggleShaders();
|
toggleShaders();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ bool Input::discoverGameControllers()
|
|||||||
SDL_SetGamepadEventsEnabled(true);
|
SDL_SetGamepadEventsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, ">> FINISHED LOOKING FOR GAME CONTROLLERS");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> FINISHED LOOKING FOR GAME CONTROLLERS");
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,9 +437,9 @@ void Input::initSDL()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** SDL_GAMEPAD: INITIALIZING");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_GAMEPAD: INITIALIZING");
|
||||||
discoverGameControllers();
|
discoverGameControllers();
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** SDL_GAMEPAD: INITIALIZATION COMPLETE\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_GAMEPAD: INITIALIZATION COMPLETE\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,15 +37,16 @@ enum class InputAction : int
|
|||||||
WINDOW_FULLSCREEN,
|
WINDOW_FULLSCREEN,
|
||||||
WINDOW_INC_SIZE,
|
WINDOW_INC_SIZE,
|
||||||
WINDOW_DEC_SIZE,
|
WINDOW_DEC_SIZE,
|
||||||
VIDEO_SHADERS,
|
TOGGLE_VIDEO_SHADERS,
|
||||||
VIDEO_INTEGER_SCALE,
|
TOGGLE_VIDEO_INTEGER_SCALE,
|
||||||
|
TOGGLE_VIDEO_VSYNC,
|
||||||
RESET,
|
RESET,
|
||||||
MUTE,
|
TOGGLE_AUDIO,
|
||||||
CHANGE_LANG,
|
CHANGE_LANG,
|
||||||
SHOW_INFO,
|
SHOW_INFO,
|
||||||
CONFIG,
|
CONFIG,
|
||||||
SWAP_CONTROLLERS,
|
SWAP_CONTROLLERS,
|
||||||
AUTO_FIRE,
|
TOGGLE_AUTO_FIRE,
|
||||||
|
|
||||||
// Input obligatorio
|
// Input obligatorio
|
||||||
NONE,
|
NONE,
|
||||||
|
|||||||
@@ -144,8 +144,10 @@ Uint32 JA_UpdateCallback(void *userdata, SDL_TimerID timerID, Uint32 interval)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GetAudioStreamAvailable(channels[i].stream) == 0)
|
if (channels[i].stream && SDL_GetAudioStreamAvailable(channels[i].stream) == 0)
|
||||||
|
{
|
||||||
JA_StopChannel(i);
|
JA_StopChannel(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,12 +160,12 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int channels)
|
|||||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_Log("Iniciant JailAudio...");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "Iniciant JailAudio...");
|
||||||
JA_audioSpec = {format, channels, freq};
|
JA_audioSpec = {format, channels, freq};
|
||||||
if (!sdlAudioDevice)
|
if (!sdlAudioDevice)
|
||||||
SDL_CloseAudioDevice(sdlAudioDevice);
|
SDL_CloseAudioDevice(sdlAudioDevice);
|
||||||
sdlAudioDevice = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &JA_audioSpec);
|
sdlAudioDevice = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &JA_audioSpec);
|
||||||
SDL_Log((sdlAudioDevice == 0) ? "Failed to initialize SDL audio!\n" : "OK!\n");
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, (sdlAudioDevice == 0) ? "Failed to initialize SDL audio!\n" : "OK!\n");
|
||||||
// SDL_PauseAudioDevice(sdlAudioDevice);
|
// SDL_PauseAudioDevice(sdlAudioDevice);
|
||||||
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
|
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
|
||||||
}
|
}
|
||||||
@@ -484,7 +486,7 @@ void JA_StopChannel(const int channel)
|
|||||||
{
|
{
|
||||||
if (channels[i].state != JA_CHANNEL_FREE)
|
if (channels[i].state != JA_CHANNEL_FREE)
|
||||||
SDL_DestroyAudioStream(channels[i].stream);
|
SDL_DestroyAudioStream(channels[i].stream);
|
||||||
channels[channel].stream = nullptr;
|
channels[i].stream = nullptr;
|
||||||
channels[i].state = JA_CHANNEL_FREE;
|
channels[i].state = JA_CHANNEL_FREE;
|
||||||
channels[i].pos = 0;
|
channels[i].pos = 0;
|
||||||
channels[i].sound = NULL;
|
channels[i].sound = NULL;
|
||||||
|
|||||||
@@ -214,23 +214,21 @@ void Screen::renderShake()
|
|||||||
SDL_SetRenderTarget(renderer_, current_target);
|
SDL_SetRenderTarget(renderer_, current_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
// Muestra información por pantalla
|
// Muestra información por pantalla
|
||||||
void Screen::renderInfo()
|
void Screen::renderInfo()
|
||||||
{
|
{
|
||||||
if (show_debug_info_ && Resource::get())
|
if (debug_info_.show)
|
||||||
{
|
{
|
||||||
auto text = Resource::get()->getText("smb2");
|
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
||||||
text->writeColored(param.game.width - text->lenght(FPS_TEXT), 0, FPS_TEXT, ORANGE_SOFT_COLOR);
|
debug_info_.text->writeColored(param.game.width - debug_info_.text->lenght(FPS_TEXT), 0, FPS_TEXT, ORANGE_SOFT_COLOR);
|
||||||
|
|
||||||
// Resolution
|
// Resolution
|
||||||
text->writeColored(0, 0, options.video.info, ORANGE_SOFT_COLOR);
|
debug_info_.text->writeColored(0, 0, options.video.info, ORANGE_SOFT_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// Carga el contenido del archivo GLSL
|
// Carga el contenido del archivo GLSL
|
||||||
void Screen::loadShaders()
|
void Screen::loadShaders()
|
||||||
{
|
{
|
||||||
@@ -285,8 +283,10 @@ void Screen::renderOverlays()
|
|||||||
renderFlash();
|
renderFlash();
|
||||||
renderAttenuate();
|
renderAttenuate();
|
||||||
OnScreenHelp::get()->render();
|
OnScreenHelp::get()->render();
|
||||||
renderInfo();
|
|
||||||
Notifier::get()->render();
|
Notifier::get()->render();
|
||||||
|
#ifdef DEBUG
|
||||||
|
renderInfo();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atenua la pantalla
|
// Atenua la pantalla
|
||||||
@@ -313,7 +313,7 @@ bool Screen::initSDL()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** SDL_VIDEO: INITIALIZING\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_VIDEO: INITIALIZING\n");
|
||||||
|
|
||||||
getDisplayInfo();
|
getDisplayInfo();
|
||||||
|
|
||||||
@@ -331,16 +331,6 @@ bool Screen::initSDL()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Crea un renderizador para la ventana. El vsync se activa en función de las opciones
|
|
||||||
// Uint32 flags = 0;
|
|
||||||
if (options.video.v_sync)
|
|
||||||
{
|
|
||||||
// flags = SDL_RENDERER_PRESENTVSYNC;
|
|
||||||
}
|
|
||||||
|
|
||||||
// La aceleración se activa según el define
|
|
||||||
// flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
|
||||||
|
|
||||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||||
|
|
||||||
if (!renderer_)
|
if (!renderer_)
|
||||||
@@ -352,13 +342,14 @@ bool Screen::initSDL()
|
|||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||||
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||||
SDL_SetWindowFullscreen(window_, static_cast<Uint32>(options.video.fullscreen));
|
SDL_SetWindowFullscreen(window_, options.video.fullscreen);
|
||||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||||
|
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** SDL_VIDEO: INITIALIZATION COMPLETE\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_VIDEO: INITIALIZATION COMPLETE\n");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,4 +393,18 @@ void Screen::getDisplayInfo()
|
|||||||
|
|
||||||
SDL_free(displays);
|
SDL_free(displays);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activa / desactiva el escalado entero
|
||||||
|
void Screen::toggleIntegerScale()
|
||||||
|
{
|
||||||
|
options.video.integer_scale = !options.video.integer_scale;
|
||||||
|
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, options.video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activa / desactiva el vsync
|
||||||
|
void Screen::toggleVSync()
|
||||||
|
{
|
||||||
|
options.video.v_sync = !options.video.v_sync;
|
||||||
|
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
@@ -4,18 +4,25 @@
|
|||||||
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_SetRenderLogicalPrese...
|
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_SetRenderLogicalPrese...
|
||||||
#include <SDL3/SDL_stdinc.h> // Para Uint32
|
#include <SDL3/SDL_stdinc.h> // Para Uint32
|
||||||
#include <SDL3/SDL_video.h> // Para SDL_Window, SDL_HideWindow, SDL_ShowWindow
|
#include <SDL3/SDL_video.h> // Para SDL_Window, SDL_HideWindow, SDL_ShowWindow
|
||||||
|
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogError, SDL_L...
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
|
#include <memory> // Para shared_ptr
|
||||||
#include "options.h" // Para Options, VideoOptions, options
|
#include "options.h" // Para Options, VideoOptions, options
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.h" // Para Param, ParamGame, param
|
||||||
#include "utils.h" // Para Color
|
#include "utils.h" // Para Color
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "text.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Constantes
|
// Constantes
|
||||||
static constexpr int WINDOWS_DECORATIONS_ = 35;
|
static constexpr int WINDOWS_DECORATIONS_ = 35;
|
||||||
|
|
||||||
// Estructuras
|
// Estructura para gestionar los fotogramas por segundo
|
||||||
struct FPS
|
struct FPS
|
||||||
{
|
{
|
||||||
Uint32 ticks; // Tiempo en milisegundos desde que se comenzó a contar.
|
Uint32 ticks; // Tiempo en milisegundos desde que se comenzó a contar.
|
||||||
@@ -44,6 +51,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para gestionar el efecto de flash en la pantalla
|
||||||
struct FlashEffect
|
struct FlashEffect
|
||||||
{
|
{
|
||||||
bool enabled; // Indica si el efecto está activo
|
bool enabled; // Indica si el efecto está activo
|
||||||
@@ -63,6 +71,7 @@ private:
|
|||||||
bool isRendarable() { return enabled && counter < lenght - delay; }
|
bool isRendarable() { return enabled && counter < lenght - delay; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para agitar la pantalla
|
||||||
struct ShakeEffect
|
struct ShakeEffect
|
||||||
{
|
{
|
||||||
int desp; // Pixels de desplazamiento para agitar la pantalla en el eje x
|
int desp; // Pixels de desplazamiento para agitar la pantalla en el eje x
|
||||||
@@ -139,7 +148,27 @@ private:
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Estructura pra mostrar la información de debug
|
||||||
|
struct Debug
|
||||||
|
{
|
||||||
|
std::shared_ptr<Text> text = nullptr; // Objeto de texto para escribir
|
||||||
|
bool show = false; // Indica si se ha de mostrar la informacion por pantalla
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
if (Resource::get())
|
||||||
|
{
|
||||||
|
text = Resource::get()->getText("smb2");
|
||||||
|
if (!text)
|
||||||
|
{
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to retrieve debug_.text object!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
// [SINGLETON] Objeto privado
|
// [SINGLETON] Objeto privado
|
||||||
static Screen *screen_;
|
static Screen *screen_;
|
||||||
|
|
||||||
@@ -156,13 +185,9 @@ private:
|
|||||||
FlashEffect flash_effect_; // Variable para gestionar el efecto de flash
|
FlashEffect flash_effect_; // Variable para gestionar el efecto de flash
|
||||||
ShakeEffect shake_effect_; // Variable para gestionar el efecto de agitar la pantalla
|
ShakeEffect shake_effect_; // Variable para gestionar el efecto de agitar la pantalla
|
||||||
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
Debug debug_info_; // Variable para gestionar la informaciçón de debug
|
||||||
#else
|
|
||||||
bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Arranca SDL VIDEO y crea la ventana
|
// Arranca SDL VIDEO y crea la ventana
|
||||||
bool initSDL();
|
bool initSDL();
|
||||||
|
|
||||||
@@ -250,9 +275,17 @@ public:
|
|||||||
|
|
||||||
// Activa / desactiva los shaders
|
// Activa / desactiva los shaders
|
||||||
void toggleShaders() { options.video.shaders = !options.video.shaders; }
|
void toggleShaders() { options.video.shaders = !options.video.shaders; }
|
||||||
|
#ifdef DEBUG
|
||||||
// Activa / desactiva la información de debug
|
// Activa / desactiva la información de debug
|
||||||
void toggleDebugInfo() { show_debug_info_ = !show_debug_info_; }
|
void toggleDebugInfo() { debug_info_.show = !debug_info_.show; }
|
||||||
|
void setDebugInfoEnabled(bool value) { debug_info_.show = value; }
|
||||||
|
void initDebugInfo() { debug_info_.init(); }
|
||||||
|
#endif
|
||||||
|
// Activa / desactiva el escalado entero
|
||||||
|
void toggleIntegerScale();
|
||||||
|
|
||||||
|
// Activa / desactiva el vsync
|
||||||
|
void toggleVSync();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
SDL_Renderer *getRenderer() { return renderer_; }
|
SDL_Renderer *getRenderer() { return renderer_; }
|
||||||
|
|||||||
@@ -195,17 +195,17 @@ void Title::checkInput()
|
|||||||
if (!define_buttons_->isEnabled())
|
if (!define_buttons_->isEnabled())
|
||||||
{
|
{
|
||||||
// Comprueba todos los métodos de control
|
// Comprueba todos los métodos de control
|
||||||
for (const auto &controller : options.controllers)
|
for (const auto &CONTROLLER : options.controllers)
|
||||||
{
|
{
|
||||||
// START
|
// START
|
||||||
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
|
||||||
!Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
!Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
|
||||||
{
|
{
|
||||||
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
|
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
|
||||||
{
|
{
|
||||||
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
||||||
/*JA_FadeOutMusic(1500);*/
|
JA_FadeOutMusic(1500);
|
||||||
switch (controller.player_id)
|
switch (CONTROLLER.player_id)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
selection_ = section::Options::GAME_PLAY_1P;
|
selection_ = section::Options::GAME_PLAY_1P;
|
||||||
@@ -224,18 +224,18 @@ void Title::checkInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SWAP_CONTROLLERS
|
// SWAP_CONTROLLERS
|
||||||
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
|
||||||
Input::get()->checkInput(InputAction::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
Input::get()->checkInput(InputAction::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
|
||||||
{
|
{
|
||||||
swapControllers();
|
swapControllers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONFIG
|
// CONFIG
|
||||||
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
|
||||||
Input::get()->checkInput(InputAction::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
Input::get()->checkInput(InputAction::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
|
||||||
{
|
{
|
||||||
define_buttons_->enable(controller.index);
|
define_buttons_->enable(CONTROLLER.index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,9 @@ void Title::resetCounter() { counter_ = 0; }
|
|||||||
void Title::swapControllers()
|
void Title::swapControllers()
|
||||||
{
|
{
|
||||||
if (Input::get()->getNumControllers() == 0)
|
if (Input::get()->getNumControllers() == 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
swapOptionsControllers();
|
swapOptionsControllers();
|
||||||
showControllers();
|
showControllers();
|
||||||
@@ -284,19 +286,19 @@ void Title::showControllers()
|
|||||||
// Crea vectores de texto vacíos para un número máximo de mandos
|
// Crea vectores de texto vacíos para un número máximo de mandos
|
||||||
constexpr size_t NUM_CONTROLLERS = 2;
|
constexpr size_t NUM_CONTROLLERS = 2;
|
||||||
std::vector<std::string> text(NUM_CONTROLLERS);
|
std::vector<std::string> text(NUM_CONTROLLERS);
|
||||||
std::vector<int> playerControllerIndex(NUM_CONTROLLERS, -1);
|
std::vector<int> player_controller_index(NUM_CONTROLLERS, -1);
|
||||||
|
|
||||||
// Obtiene de cada jugador el índice del mando que tiene asignado
|
// Obtiene de cada jugador el índice del mando que tiene asignado
|
||||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||||
{
|
{
|
||||||
// Ejemplo: el jugador 1 tiene el mando 2
|
// Ejemplo: el jugador 1 tiene el mando 2
|
||||||
playerControllerIndex.at(options.controllers.at(i).player_id - 1) = i;
|
player_controller_index.at(options.controllers.at(i).player_id - 1) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Genera el texto correspondiente
|
// Genera el texto correspondiente
|
||||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||||
{
|
{
|
||||||
const size_t index = playerControllerIndex.at(i);
|
const size_t index = player_controller_index.at(i);
|
||||||
if (options.controllers.at(index).plugged)
|
if (options.controllers.at(index).plugged)
|
||||||
{
|
{
|
||||||
text.at(i) = lang::getText(100) + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
|
text.at(i) = lang::getText(100) + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
|
||||||
|
|||||||
Reference in New Issue
Block a user