New script* API methods. Untested.

This commit is contained in:
Scott Duensing 2020-03-22 19:38:23 -05:00
parent a1a54548d5
commit c885b533dd
7 changed files with 848 additions and 609 deletions

View file

@ -49,6 +49,7 @@ for dir in lfs.dir(".") do
end
end
table.sort(FOUND_GAMES, compareTitles)
scriptExecute(FOUND_GAMES[1])
font = fontLoad("ActionMax/font_LED_Real.ttf", 32);

View file

@ -8,9 +8,7 @@ GAMES = {
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = {
-- Sinden Args Here, comma separated.
},
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_38AmbushAlley.png",
MARQUEE = "ActionMax/marquee_38AmbushAlley.png",
ATTRACT = "ActionMax/38AmbushAlley.mkv",
@ -32,9 +30,7 @@ GAMES = {
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = {
-- Sinden Args Here, comma separated.
},
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_BlueThunder.png",
MARQUEE = "ActionMax/marquee_BlueThunder.png",
ATTRACT = "ActionMax/BlueThunder.mkv",
@ -56,9 +52,7 @@ GAMES = {
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = {
-- Sinden Args Here, comma separated.
},
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_Hydrosub2021.png",
MARQUEE = "ActionMax/marquee_Hydrosub2021.png",
ATTRACT = "ActionMax/Hydrosub2021.mkv",
@ -80,9 +74,7 @@ GAMES = {
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = {
-- Sinden Args Here, comma separated.
},
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_PopsGhostly.png",
MARQUEE = "ActionMax/marquee_PopsGhostly.png",
ATTRACT = "ActionMax/PopsGhostly.mkv",
@ -104,9 +96,7 @@ GAMES = {
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = {
-- Sinden Args Here, comma separated.
},
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_SonicFury.png",
MARQUEE = "ActionMax/marquee_SonicFury.png",
ATTRACT = "ActionMax/SonicFury.mkv",

File diff suppressed because it is too large Load diff

36
singe/main.h Normal file
View file

@ -0,0 +1,36 @@
/*
*
* Singe 2
* Copyright (C) 2006-2020 Scott Duensing <scott@kangaroopunch.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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef MAIN_H
#define MAIN_H
#include "common.h"
#include "singe.h"
bool parseSindenString(char **sindenStringPointer, ConfigT *conf);
void queueScript(ConfigT *conf);
#endif // MAIN_H

View file

@ -34,6 +34,7 @@
#include "thirdparty/manymouse/manymouse.h"
#include "thirdparty/luafilesystem/src/lfs.h"
#include "main.h"
#include "util.h"
#include "frameFile.h"
#include "videoPlayer.h"
@ -168,10 +169,6 @@ enum {
};
// Command line options
ConfigT _conf;
typedef struct GlobalS {
MouseT mice[MAX_MICE];
lua_State *luaContext;
@ -215,6 +212,7 @@ typedef struct GlobalS {
FontT *fontList;
FontT *fontCurrent;
MappingT controlMappings[INPUT_COUNT];
ConfigT conf; // Local copy of command line options
} GlobalT;
@ -277,6 +275,9 @@ int32_t apiOverlayPlot(lua_State *L);
int32_t apiOverlayPrint(lua_State *L);
int32_t apiOverlaySetResolution(lua_State *L);
int32_t apiScriptExecute(lua_State *L);
int32_t apiScriptPush(lua_State *L);
int32_t apiSingeDisablePauseKey(lua_State *L);
int32_t apiSingeEnablePauseKey(lua_State *L);
int32_t apiSingeGetPauseFlag(lua_State *L);
@ -322,6 +323,7 @@ int32_t apiVldpGetPixel(lua_State *L);
int32_t apiVldpGetWidth(lua_State *L);
int32_t apiVldpVerbose(lua_State *L);
ConfigT *buildConfFromTable(lua_State *L);
void doIndexDisplay(int32_t percent);
void doLogos(void);
void callLua(const char *func, const char *sig, ...);
@ -503,8 +505,8 @@ int32_t apiDiscAudio(lua_State *L) {
d = lua_tonumber(L, 1); channel = (int32_t)d;
d = lua_toboolean(L, 2); onOff = (bool)d;
videoGetVolume(_global.videoHandle, &left, &right);
if (channel == 1) left = (onOff ? _conf.volumeVldp : 0);
if (channel == 2) right = (onOff ? _conf.volumeVldp : 0);
if (channel == 1) left = (onOff ? _global.conf.volumeVldp : 0);
if (channel == 2) right = (onOff ? _global.conf.volumeVldp : 0);
videoSetVolume(_global.videoHandle, left, right);
result = true;
}
@ -534,7 +536,7 @@ int32_t apiDiscGetFrame(lua_State *L) {
int64_t frame = 0;
if (!_global.discStopped) {
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frame = frameFileGetFrame(_global.frameFileHandle, _global.videoHandle);
} else {
if (_global.videoHandle >= 0) frame = videoGetFrame(_global.videoHandle);
@ -587,7 +589,7 @@ int32_t apiDiscSearch(lua_State *L) {
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); frame = (int64_t)d;
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
if (_global.videoHandle >= 0) videoSeek(_global.videoHandle, frame);
@ -638,7 +640,7 @@ int32_t apiDiscSkipBackward(lua_State *L) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1);
if (_global.videoHandle >= 0) frame = videoGetFrame(_global.videoHandle) - (int64_t)d;
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
if (_global.videoHandle >= 0) videoSeek(_global.videoHandle, frame);
@ -682,7 +684,7 @@ int32_t apiDiscSkipForward(lua_State *L) {
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); if (_global.videoHandle >= 0) frame = videoGetFrame(_global.videoHandle) + (int64_t)d;
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
if (_global.videoHandle >= 0) videoSeek(_global.videoHandle, frame);
@ -717,7 +719,7 @@ int32_t apiDiscSkipToFrame(lua_State *L) {
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); frame = (int64_t)d;
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
if (_global.videoHandle >= 0) videoSeek(_global.videoHandle, frame);
@ -747,7 +749,7 @@ int32_t apiDiscStepBackward(lua_State *L) {
// No matter disc state, go back a frame. If playing, pause.
if (_global.videoHandle >= 0) {
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frame = frameFileGetFrame(_global.frameFileHandle, _global.videoHandle) - 1;
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
@ -771,7 +773,7 @@ int32_t apiDiscStepForward(lua_State *L) {
// No matter disc state, go forward a frame. If playing, pause.
if (_global.videoHandle >= 0) {
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frame = frameFileGetFrame(_global.frameFileHandle, _global.videoHandle) + 1;
frameFileSeek(_global.frameFileHandle, frame, &_global.videoHandle, &aFrame);
} else {
@ -2136,7 +2138,7 @@ int32_t apiVideoLoad(lua_State *L) {
luaDie(L, "videoLoad", "Optional second parameter must be a string.");
}
} else {
data = _conf.dataDir;
data = _global.conf.dataDir;
}
video = (VideoT *)calloc(1, sizeof(VideoT));
if (!video) luaDie(L, "videoLoad", "Unable to allocate new video.");
@ -2432,8 +2434,8 @@ int32_t apiKeyboardSetMode(lua_State *L) {
int32_t apiMouseEnable(lua_State *L) {
// Enables mouse monitoring
(void)L;
luaTrace(L, "mouseEnable", "%d", _conf.noMouse);
_global.mouseEnabled = (bool)!_conf.noMouse;
luaTrace(L, "mouseEnable", "%d", _global.conf.noMouse);
_global.mouseEnabled = (bool)!_global.conf.noMouse;
return 0;
}
@ -2500,7 +2502,7 @@ int32_t apiMouseGetPosition(lua_State *L) {
if (n == 1) {
if (lua_isnumber(L, 1)) {
d = lua_tonumber(L, 1); m = (int32_t)d;
if ((m < 0) || (m >= MAX_MICE)) luaDie(L, "apiMouseGetPosition", "Invalid mouse index: %d", m);
if ((m < 0) || (m >= MAX_MICE)) luaDie(L, "mouseGetPosition", "Invalid mouse index: %d", m);
x = _global.axisCache[MAX_CONTROLLERS * CONTROLLER_AXIS_COUNT + m * MOUSE_AXIS_COUNT];
y = _global.axisCache[MAX_CONTROLLERS * CONTROLLER_AXIS_COUNT + m * MOUSE_AXIS_COUNT + 1];
result = true;
@ -2508,11 +2510,11 @@ int32_t apiMouseGetPosition(lua_State *L) {
}
if (result) {
luaTrace(L, "apiMouseGetPosition", "%d %d %d", m, x, y);
luaTrace(L, "mouseGetPosition", "%d %d %d", m, x, y);
lua_pushinteger(L, x);
lua_pushinteger(L, y);
} else {
luaTrace(L, "apiMouseGetPosition", "Failed!");
luaTrace(L, "mouseGetPosition", "Failed!");
lua_pushinteger(L, -1);
lua_pushinteger(L, -1);
}
@ -2552,6 +2554,62 @@ int32_t apiDiscGetState(lua_State *L) {
}
int32_t apiScriptExecute(lua_State *L) {
int32_t n = lua_gettop(L);
ConfigT *conf = NULL;
bool result = false;
if (n == 1) {
if (lua_istable(L, 1)) {
// Push next script.
conf = buildConfFromTable(L);
queueScript(conf);
free(conf);
// Stop this script running.
_global.running = false;
result = true;
}
}
if (result) {
luaTrace(L, "scriptExecute", "Success.");
} else {
luaTrace(L, "scriptExecute", "Failed!");
}
return 0;
}
int32_t apiScriptPush(lua_State *L) {
int32_t n = lua_gettop(L);
ConfigT *conf = NULL;
bool result = false;
if (n == 1) {
if (lua_istable(L, 1)) {
// Push next script.
conf = buildConfFromTable(L);
queueScript(conf);
free(conf);
// Push this script.
queueScript(&_global.conf);
// Stop this script running.
_global.running = false;
result = true;
}
}
if (result) {
luaTrace(L, "scriptExecute", "Success.");
} else {
luaTrace(L, "scriptExecute", "Failed!");
}
return 0;
}
int32_t apiSingeGetPauseFlag(lua_State *L) {
/*
* This function returns _global.pauseState's value to the lua script.
@ -2664,12 +2722,93 @@ int32_t apiSingeGetScriptPath(lua_State *L) {
// sGameDirectory = singeGetScriptPath()
//
luaTrace(L, "singeSetScriptPath", "%s", _conf.scriptFile);
lua_pushstring(L, _conf.scriptFile);
luaTrace(L, "singeSetScriptPath", "%s", _global.conf.scriptFile);
lua_pushstring(L, _global.conf.scriptFile);
return 1;
}
ConfigT *buildConfFromTable(lua_State *L) {
const char *confKey = NULL;
const char *valueString = NULL;
char *sindenString = NULL;
bool valueBoolean = false;
int64_t valueNumber = 0;
ConfigT *c = NULL;
// Start with current config.
c = (ConfigT *)calloc(1, sizeof(ConfigT));
memcpy(c, &_global.conf, sizeof(ConfigT));
if (_global.conf.scriptFile) c->scriptFile = strdup(_global.conf.scriptFile);
if (_global.conf.videoFile) c->videoFile = strdup(_global.conf.videoFile);
if (_global.conf.dataDir) c->dataDir = strdup(_global.conf.dataDir);
// Update with data in the table on the top of the Lua stack.
lua_pushnil(L);
while (lua_next(L, 1)) {
// Get key
confKey = lua_tostring(L, 2);
// Get value
switch (lua_type(L, 3)) {
case LUA_TSTRING:
valueString = lua_tostring(L, 3);
valueBoolean = false;
valueNumber = 0;
break;
case LUA_TBOOLEAN:
valueString = NULL;
valueBoolean = lua_toboolean(L, 3);
valueNumber = 0;
break;
case LUA_TNUMBER:
valueString = NULL;
valueBoolean = false;
valueNumber = lua_tonumber(L, 3);
break;
default:
valueString = NULL;
valueBoolean = false;
valueNumber = 0;
break;
}
// Update config with new data
if (strcmp(confKey, "SCRIPT") == 0) {
if (c->scriptFile) free (c->scriptFile);
c->scriptFile = strdup(valueString);
} else if (strcmp(confKey, "VIDEO") == 0) {
if (c->videoFile) free(c->videoFile);
c->videoFile = strdup(valueString);
} else if (strcmp(confKey, "DATA") == 0) {
if (c->dataDir) free(c->dataDir);
c->dataDir = strdup(valueString);
} else if (strcmp(confKey, "STRETCH") == 0) {
c->stretchVideo = valueBoolean;
} else if (strcmp(confKey, "NO_MOUSE") == 0) {
c->noMouse = valueBoolean;
} else if (strcmp(confKey, "RESOLUTION_X") == 0) {
c->xResolution = valueNumber;
} else if (strcmp(confKey, "RESOLUTION_Y") == 0) {
c->yResolution = valueNumber;
} else if (strcmp(confKey, "SINDEN_GUN") == 0) {
if (sindenString) free(sindenString);
sindenString = strdup(valueString);
if (!parseSindenString(&sindenString, c)) c->sindenArgc = 0;
free(sindenString);
}
// Clean up for next pair
lua_pop(L, 1);
}
return c;
}
void callLua(const char *func, const char *sig, ...) {
va_list vl;
bool done = false;
@ -3136,7 +3275,7 @@ void putPixel(int32_t x, int32_t y) {
}
void singe(SDL_Window *window, SDL_Renderer *renderer) {
void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
int32_t x = 0;
int32_t y = 0;
int32_t xr = 0;
@ -3167,6 +3306,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Set up globals
memset(&_global, 0, sizeof(GlobalT));
memcpy(&_global.conf, conf, sizeof(ConfigT));
_global.colorForeground.r = 255;
_global.colorForeground.g = 255;
_global.colorForeground.b = 255;
@ -3227,15 +3367,15 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
if (luaL_loadbuffer(_global.luaContext, (char *)controls_cfg, controls_cfg_len, "Input Mappings") || lua_pcall(_global.luaContext, 0, 0, 0)) utilDie("%s", lua_tostring(_global.luaContext, -1));
if (utilFileExists("controls.cfg") && luaL_dofile(_global.luaContext, "controls.cfg")) utilDie("%s", lua_tostring(_global.luaContext, -1));
// Load mappings in main data dir
temp = utilCreateString("%s..%ccontrols.cfg", _conf.dataDir, utilGetPathSeparator());
temp = utilCreateString("%s..%ccontrols.cfg", _global.conf.dataDir, utilGetPathSeparator());
if (utilFileExists(temp) && luaL_dofile(_global.luaContext, temp)) utilDie("%s", lua_tostring(_global.luaContext, -1));
free(temp);
// Load mappings in game data dir
temp = utilCreateString("%scontrols.cfg", _conf.dataDir);
temp = utilCreateString("%scontrols.cfg", _global.conf.dataDir);
if (utilFileExists(temp) && luaL_dofile(_global.luaContext, temp)) utilDie("%s", lua_tostring(_global.luaContext, -1));
free(temp);
// Load mappings in game script dir
temp = strdup(_conf.scriptFile);
temp = strdup(_global.conf.scriptFile);
temp2 = utilStrndup(temp, strlen(temp) - strlen(utilGetLastPathComponent(temp)));
free(temp);
temp = utilCreateString("%scontrols.cfg", temp2);
@ -3292,7 +3432,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
lua_close(_global.luaContext);
// Show splash screens
if (!_conf.noLogos) {
if (!_global.conf.noLogos) {
doLogos();
}
@ -3358,6 +3498,9 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
lua_register(_global.luaContext, "overlayPrint", apiOverlayPrint);
lua_register(_global.luaContext, "overlaySetResolution", apiOverlaySetResolution);
lua_register(_global.luaContext, "scriptExecute", apiScriptExecute);
lua_register(_global.luaContext, "scriptPush", apiScriptPush);
lua_register(_global.luaContext, "singeGetPauseFlag", apiSingeGetPauseFlag);
lua_register(_global.luaContext, "singeSetPauseFlag", apiSingeSetPauseFlag);
lua_register(_global.luaContext, "singeEnablePauseKey", apiSingeEnablePauseKey);
@ -3406,15 +3549,15 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Open main video file
doIndexDisplay(-1);
videoSetIndexCallback(doIndexDisplay);
if (_conf.isFrameFile) {
_global.frameFileHandle = frameFileLoad(_conf.videoFile, _conf.dataDir, (bool)_conf.stretchVideo, _global.renderer, _conf.showCalculated);
if (_global.frameFileHandle < 0) utilDie("Unable to load framefile: %s", _conf.videoFile);
if (_global.conf.isFrameFile) {
_global.frameFileHandle = frameFileLoad(_global.conf.videoFile, _global.conf.dataDir, (bool)_global.conf.stretchVideo, _global.renderer, _global.conf.showCalculated);
if (_global.frameFileHandle < 0) utilDie("Unable to load framefile: %s", _global.conf.videoFile);
frameFileSeek(_global.frameFileHandle, 0, &_global.videoHandle, &thisFrame); // Fills in _global.videoHandle
} else {
_global.videoHandle = videoLoad(_conf.videoFile, _conf.dataDir, (bool)_conf.stretchVideo, _global.renderer);
_global.videoHandle = videoLoad(_global.conf.videoFile, _global.conf.dataDir, (bool)_global.conf.stretchVideo, _global.renderer);
}
if (_global.videoHandle < 0) utilDie("Unable to load video file: %s", _conf.videoFile);
videoSetVolume(_global.videoHandle, _conf.volumeVldp, _conf.volumeVldp);
if (_global.videoHandle < 0) utilDie("Unable to load video file: %s", _global.conf.videoFile);
videoSetVolume(_global.videoHandle, _global.conf.volumeVldp, _global.conf.volumeVldp);
videoSetIndexCallback(NULL);
doIndexDisplay(-2);
@ -3430,15 +3573,15 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
sindenBlack.x = -1;
// Overscan compensation
if (_conf.scaleFactor < 100) {
windowTarget.w = videoGetWidth(_global.videoHandle) * _conf.scaleFactor / 100;
windowTarget.h = videoGetHeight(_global.videoHandle) * _conf.scaleFactor / 100;
if (_global.conf.scaleFactor < 100) {
windowTarget.w = videoGetWidth(_global.videoHandle) * _global.conf.scaleFactor / 100;
windowTarget.h = videoGetHeight(_global.videoHandle) * _global.conf.scaleFactor / 100;
windowTarget.x = (videoGetWidth(_global.videoHandle) - windowTarget.w) / 2;
windowTarget.y = (videoGetHeight(_global.videoHandle) - windowTarget.h) / 2;
}
// Sinden Light Gun Border Setup
if (_conf.sindenArgc > 0) {
if (_global.conf.sindenArgc > 0) {
//***TODO*** ADD MOUSE SCALING TO COMPENSATE FOR BORDER
sindenWhiteColor.r = 255;
sindenWhiteColor.g = 255;
@ -3449,41 +3592,41 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
sindenBlackColor.b = 0;
sindenBlackColor.a = 255;
// Ok, this thing can have a mess of different arguments:
switch(_conf.sindenArgc) {
switch(_global.conf.sindenArgc) {
// WW - Just the width of the white border
case SINDEN_WHITE:
sindenWhite.x = _conf.sindenArgv[0];
sindenWhite.x = _global.conf.sindenArgv[0];
break;
// WW WB - Width of white border and then black border
case SINDEN_WHITE_BLACK:
sindenWhite.x = _conf.sindenArgv[0];
sindenBlack.x = _conf.sindenArgv[1];
sindenWhite.x = _global.conf.sindenArgv[0];
sindenBlack.x = _global.conf.sindenArgv[1];
break;
// RW GW BW WW - Custom color "white" border and width
case SINDEN_CUSTOM_WHITE:
sindenWhiteColor.r = _conf.sindenArgv[0];
sindenWhiteColor.g = _conf.sindenArgv[1];
sindenWhiteColor.b = _conf.sindenArgv[2];
sindenWhite.x = _conf.sindenArgv[3];
sindenWhiteColor.r = _global.conf.sindenArgv[0];
sindenWhiteColor.g = _global.conf.sindenArgv[1];
sindenWhiteColor.b = _global.conf.sindenArgv[2];
sindenWhite.x = _global.conf.sindenArgv[3];
break;
// RW GW BW WW WB - Custom color "white" border and width then width of black border
case SINDEN_CUSTOM_WHITE_BLACK:
sindenWhiteColor.r = _conf.sindenArgv[0];
sindenWhiteColor.g = _conf.sindenArgv[1];
sindenWhiteColor.b = _conf.sindenArgv[2];
sindenWhite.x = _conf.sindenArgv[3];
sindenBlack.x = _conf.sindenArgv[4];
sindenWhiteColor.r = _global.conf.sindenArgv[0];
sindenWhiteColor.g = _global.conf.sindenArgv[1];
sindenWhiteColor.b = _global.conf.sindenArgv[2];
sindenWhite.x = _global.conf.sindenArgv[3];
sindenBlack.x = _global.conf.sindenArgv[4];
break;
// RW GW BW WW RB GB BB WB - Custom color "white" border and width then custom color "black" border and width
case SINDEN_CUSTOM_WHITE_CUSTOM_BLACK:
sindenWhiteColor.r = _conf.sindenArgv[0];
sindenWhiteColor.g = _conf.sindenArgv[1];
sindenWhiteColor.b = _conf.sindenArgv[2];
sindenWhite.x = _conf.sindenArgv[3];
sindenBlackColor.r = _conf.sindenArgv[4];
sindenBlackColor.g = _conf.sindenArgv[5];
sindenBlackColor.b = _conf.sindenArgv[6];
sindenBlack.x = _conf.sindenArgv[7];
sindenWhiteColor.r = _global.conf.sindenArgv[0];
sindenWhiteColor.g = _global.conf.sindenArgv[1];
sindenWhiteColor.b = _global.conf.sindenArgv[2];
sindenWhite.x = _global.conf.sindenArgv[3];
sindenBlackColor.r = _global.conf.sindenArgv[4];
sindenBlackColor.g = _global.conf.sindenArgv[5];
sindenBlackColor.b = _global.conf.sindenArgv[6];
sindenBlack.x = _global.conf.sindenArgv[7];
break;
}
if (sindenWhite.x >= 0) {
@ -3521,7 +3664,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
_global.mouseCount = MAX_MICE;
}
memset(_global.mice, 0, sizeof(_global.mice));
_global.mouseEnabled = (bool)!_conf.noMouse;
_global.mouseEnabled = (bool)!_global.conf.noMouse;
for (x=0; x<_global.mouseCount; x++) {
strncpy(_global.mice[x].name, ManyMouse_DeviceName((unsigned)x), sizeof(_global.mice[x].name));
_global.mice[x].name[sizeof(_global.mice[x].name) - 1] = 0;
@ -3531,9 +3674,9 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
}
// Grab mouse
_global.mouseGrabbed = true;
SDL_SetWindowGrab(_global.window, SDL_TRUE);
SDL_ShowCursor(SDL_DISABLE);
// _global.mouseGrabbed = true;
// SDL_SetWindowGrab(_global.window, SDL_TRUE);
// SDL_ShowCursor(SDL_DISABLE);
// Clear axis cache
for (x=0; x<AXIS_COUNT; x++) {
@ -3543,7 +3686,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Controllers are started by the event loop
// Set volume
_global.effectsVolume = (int32_t)((float)AUDIO_MAX_VOLUME * (float)_conf.volumeNonVldp * (float)0.01);
_global.effectsVolume = (int32_t)((float)AUDIO_MAX_VOLUME * (float)_global.conf.volumeNonVldp * (float)0.01);
Mix_Volume(-1, _global.effectsVolume * 2);
// Let us know when sounds end
@ -3561,7 +3704,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
_global.discStopped = false;
// Start script
if (luaL_dofile(_global.luaContext, _conf.scriptFile) != 0) utilDie("Error compiling script: %s", lua_tostring(_global.luaContext, -1));
if (luaL_dofile(_global.luaContext, _global.conf.scriptFile) != 0) utilDie("Error compiling script: %s", lua_tostring(_global.luaContext, -1));
// Game Loop
while (_global.running) {
@ -3775,7 +3918,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Update video
thisFrame = videoUpdate(_global.videoHandle, &_global.videoTexture);
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileUpdate(_global.frameFileHandle, &_global.videoHandle);
}
// Did we get a new video frame?
@ -3823,7 +3966,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Overlay
overlayTexture = SDL_CreateTextureFromSurface(_global.renderer, _global.overlay);
if (!overlayTexture) utilDie("%s", SDL_GetError());
if (!_conf.stretchVideo) {
if (!_global.conf.stretchVideo) {
SDL_RenderSetLogicalSize(renderer, videoGetWidth(_global.videoHandle), videoGetHeight(_global.videoHandle));
}
SDL_RenderCopy(_global.renderer, overlayTexture, NULL, &windowTarget);
@ -3894,7 +4037,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
}
// Unload background video
if (_conf.isFrameFile) {
if (_global.conf.isFrameFile) {
frameFileUnload(_global.frameFileHandle);
} else {
videoUnload(_global.videoHandle);
@ -3965,7 +4108,7 @@ void takeScreenshot(void) {
SDL_Rect viewport;
while (x <= 999) {
snprintf(filename, 1024, "%ssinge%03d.png", _conf.dataDir, x);
snprintf(filename, 1024, "%ssinge%03d.png", _global.conf.dataDir, x);
if (!utilFileExists(filename)) break;
x++;
}

View file

@ -58,6 +58,8 @@ typedef struct ConfigS {
bool showCalculated;
bool noConsole;
bool noLogos;
bool tracing;
int32_t bestRatioIndex;
int32_t volumeVldp;
int32_t volumeNonVldp;
int32_t scaleFactor;
@ -68,11 +70,7 @@ typedef struct ConfigS {
} ConfigT;
// Command line options
extern ConfigT _conf;
void singe(SDL_Window *window, SDL_Renderer *renderer);
void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf);
#endif // SINGE_H

View file

@ -136,10 +136,12 @@ HEADERS += \
$$ARGPARSER_HEADERS \
$$MANYMOUSE_HEADERS \
$$LUAFILESYSTEM_HEADERS \
thirdparty/uthash.h \
thirdparty/utlist.h \
Framework_singe.h \
frameFile.h \
main.h \
stddclmr.h \
thirdparty/uthash.h \
common.h \
util.h \
videoPlayer.h \