Ability to disable console and logos. Logos added. Audio buffer reduced.

This commit is contained in:
Scott Duensing 2020-01-08 19:42:55 -06:00
parent 21596d97ec
commit 675e54462b
12 changed files with 140 additions and 22 deletions

1
.gitattributes vendored
View file

@ -1 +1,2 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.xcf filter=lfs diff=lfs merge=lfs -text

2
.gitignore vendored
View file

@ -37,3 +37,5 @@ build/
singe/source.inc.sh
singe/font.h
singe/icon.h
singe/kangarooPunchLogo.h
singe/singeLogo.h

BIN
singe/kangarooPunchLogo.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -78,19 +78,20 @@ void showUsage(char *name, char *message) {
utilSay(" -v, --framefile=FILENAME use an alternate video file");
utilSay(" -d, --datadir=PATHNAME alternate location for written files");
utilSay(" -m, --nomouse disable mouse");
utilSay(" -n, --noserversend do not send usage statistics");
//utilSay(" -n, --noserversend do not send usage statistics");
utilSay(" -s, --nosound, --mutesound mutes all sound");
utilSay(" -f, --fullscreen run in full screen mode");
utilSay(" -w, --fullscreen_window run in windowed full screen mode");
utilSay(" -l, --volume_vldp=PERCENT specify laserdisc volume in percent");
utilSay(" -e, --volume_nonvldp=PERCENT specify sound effects volume in percent");
utilSay(" -z, --scalefactor=PERCENT reduce screen size for overscan compensation");
//utilSay(" -o, --scalefactor=PERCENT reduce screen size for overscan compensation");
utilSay(" -a, --aspect=N:D force aspect ratio");
utilSay(" -u, --stretch use ugly stretched video");
utilSay(" -x, --xresolution=VALUE specify horizontal resolution");
utilSay(" -y, --yresolution=VALUE specify vertical resolution");
utilSay(" -t, --trace trace script execution to screen and file");
utilSay(" -c, --showcalculated show calculated framefile values for debugging");
utilSay(" -z, --noconsole zero console output, no splash screens");
utilSay(" -h, --help this display");
utilSay("");
if (message) {
@ -126,7 +127,7 @@ int main(int argc, char *argv[]) {
SDL_DisplayMode mode;
static struct option options[] = {
{ "nomouse", no_argument, NULL, 'm' },
{ "noserversend", no_argument, NULL, 'n' },
// { "noserversend", no_argument, NULL, 'n' },
{ "nosound", no_argument, NULL, 's' },
{ "mutesound", no_argument, NULL, 's' },
{ "fullscreen", no_argument, NULL, 'f' },
@ -136,13 +137,14 @@ int main(int argc, char *argv[]) {
{ "framefile", optional_argument, NULL, 'v' },
{ "volume_vldp", optional_argument, NULL, 'l' },
{ "volume_nonlvdp", optional_argument, NULL, 'e' },
{ "scalefactor", optional_argument, NULL, 'z' },
// { "scalefactor", optional_argument, NULL, 'o' },
{ "aspect", optional_argument, NULL, 'a' },
{ "xresolution", optional_argument, NULL, 'x' },
{ "yresolution", optional_argument, NULL, 'y' },
{ "help", no_argument, NULL, 'h' },
{ "trace", no_argument, NULL, 't' },
{ "showcalculated", no_argument, NULL, 'c' },
{ "noconsole", no_argument, NULL, 'z' },
{ NULL, 0, NULL, 0 }
};
static ModeT modes[] = {
@ -240,8 +242,8 @@ int main(int argc, char *argv[]) {
_confVolumeNonVldp = atoi(optarg);
break;
// Zoom
case 'z':
// Overscan Zoom
case 'o':
_confScaleFactor = atoi(optarg);
break;
@ -271,6 +273,11 @@ int main(int argc, char *argv[]) {
tracing = true;
break;
// No console output or splash screens
case 'z':
_confNoConsole = true;
break;
// Show Calculated Frame File Values
case 'c':
_confShowCalculated = true;

View file

@ -408,3 +408,13 @@ createEmbeddedBinary font.png font.h FONT_H
# === Window Icon ===
createEmbeddedBinary icon.png icon.h ICON_H
# === Kangaroo Punch Logo ===
createEmbeddedBinary kangarooPunchLogo.png kangarooPunchLogo.h KANGAROOPUNCHLOGO_H
# === Singe Logo ===
if [[ ! -e singeLogo.h ]]; then
xcf2png singeLogo.xcf -o singeLogo.png
createEmbeddedBinary singeLogo.png singeLogo.h SINGELOGO_H
rm singeLogo.png
fi

View file

@ -38,6 +38,8 @@
#include "videoPlayer.h"
#include "singe.h"
#include "font.h"
#include "kangarooPunchLogo.h"
#include "singeLogo.h"
#define AUDIO_MAX_VOLUME 63
@ -154,6 +156,7 @@ bool _confNoSound = false;
bool _confFullScreen = false;
bool _confFullScreenWindow = false;
bool _confShowCalculated = false;
bool _confNoConsole = false;
int32_t _confVolumeVldp = 100;
int32_t _confVolumeNonVldp = 100;
int32_t _confScaleFactor = 100;
@ -304,6 +307,7 @@ int32_t apiSingeQuit(lua_State *L);
int32_t apiSingeVersion(lua_State *L);
int32_t apiSingeSetGameName(lua_State *L);
int32_t apiSingeGetScriptPath(lua_State *L);
void doLogos(void);
void callLua(const char *func, const char *sig, ...);
void channelFinished(int channel);
void luaDie(lua_State *L, char *method, char *fmt, ...);
@ -1843,6 +1847,74 @@ void channelFinished(int channel) {
}
void doLogos(void) {
int32_t i = 0;
int32_t w = 0;
int32_t h = 0;
SDL_Surface *surfKangaroo = NULL;
SDL_Surface *surfSinge = NULL;
SDL_Texture *texKangaroo = NULL;
SDL_Texture *texSinge = NULL;
SDL_RenderGetLogicalSize(_renderer, &w, &h);
surfKangaroo = IMG_LoadPNG_RW(SDL_RWFromMem(kangarooPunchLogo_png, kangarooPunchLogo_png_len));
if (!surfKangaroo) utilDie("%s", IMG_GetError());
surfSinge = IMG_LoadPNG_RW(SDL_RWFromMem(singeLogo_png, singeLogo_png_len));
if (!surfSinge) utilDie("%s", IMG_GetError());
texKangaroo = SDL_CreateTextureFromSurface(_renderer, surfKangaroo);
if (!texKangaroo) utilDie("%s", SDL_GetError());
texSinge = SDL_CreateTextureFromSurface(_renderer, surfSinge);
if (!texSinge) utilDie("%s", SDL_GetError());
// Fade in to white with Kangaroo logo
SDL_RenderSetLogicalSize(_renderer, surfKangaroo->w, surfKangaroo->h);
for (i=0; i<256; i++) {
SDL_SetRenderDrawColor(_renderer, i, i, i, 255);
SDL_RenderClear(_renderer);
SDL_SetTextureAlphaMod(texKangaroo, i);
SDL_RenderCopy(_renderer, texKangaroo, NULL, NULL);
SDL_RenderPresent(_renderer);
SDL_Delay(5);
}
SDL_Delay(1000);
// Cross fade to Singe logo
for (i=0; i<256; i++) {
SDL_RenderClear(_renderer);
SDL_SetTextureAlphaMod(texKangaroo, 255 - i);
SDL_RenderCopy(_renderer, texKangaroo, NULL, NULL);
SDL_SetTextureAlphaMod(texSinge, i);
SDL_RenderCopy(_renderer, texSinge, NULL, NULL);
SDL_RenderPresent(_renderer);
SDL_Delay(5);
}
SDL_Delay(1000);
// Fade to black
SDL_RenderSetLogicalSize(_renderer, surfSinge->w, surfSinge->h);
for (i=255; i>=0; i--) {
SDL_SetRenderDrawColor(_renderer, i, i, i, 255);
SDL_RenderClear(_renderer);
SDL_SetTextureAlphaMod(texSinge, i);
SDL_RenderCopy(_renderer, texSinge, NULL, NULL);
SDL_RenderPresent(_renderer);
SDL_Delay(5);
}
SDL_DestroyTexture(texSinge);
SDL_DestroyTexture(texKangaroo);
SDL_FreeSurface(surfSinge);
SDL_FreeSurface(surfKangaroo);
SDL_RenderSetLogicalSize(_renderer, w, h);
}
void luaDie(lua_State *L, char *method, char *fmt, ...) {
va_list args;
lua_Debug ar;
@ -2002,6 +2074,10 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
_window = window;
_renderer = renderer;
if (!_confNoConsole) {
doLogos();
}
// Start Lua
_luaContext = luaL_newstate();
luaL_openlibs(_luaContext);
@ -2305,10 +2381,10 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
if (_refreshDisplay || _discStopped) {
if (_discStopped) {
// Stopped discs display blue like the good old days
SDL_SetRenderTarget(renderer, _videoTexture);
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
SDL_RenderClear(renderer);
SDL_SetRenderTarget(renderer, NULL);
SDL_SetRenderTarget(_renderer, _videoTexture);
SDL_SetRenderDrawColor(_renderer, 0, 0, 255, 255);
SDL_RenderClear(_renderer);
SDL_SetRenderTarget(_renderer, NULL);
}
SDL_RenderCopy(_renderer, _videoTexture, NULL, NULL);
overlayTexture = SDL_CreateTextureFromSurface(_renderer, _overlay);

View file

@ -31,7 +31,7 @@
// Don't forget to update singe.rc!
#define SINGE_VERSION 2.00
#define VERSION_STRING "v2.00b6"
#define VERSION_STRING "v2.00b7"
#define COPYRIGHT_END_YEAR "2020"
@ -47,6 +47,7 @@ extern bool _confNoSound;
extern bool _confFullScreen;
extern bool _confFullScreenWindow;
extern bool _confShowCalculated;
extern bool _confNoConsole;
extern int32_t _confVolumeVldp;
extern int32_t _confVolumeNonVldp;
extern int32_t _confScaleFactor;

View file

@ -89,7 +89,9 @@ HEADERS += \
videoPlayer.h \
singe.h \
extensions.h \
font.h
font.h \
singeLogo.h \
kangarooPunchLogo.h
SOURCES += \
$$MANYMOUSE_SOURCES \

View file

@ -1,7 +1,7 @@
101 ICON "/tmp/icon.ico"
1 VERSIONINFO
FILEVERSION 2,0,0,6
PRODUCTVERSION 2,0,0,6
FILEVERSION 2,0,0,7
PRODUCTVERSION 2,0,0,7
BEGIN
BLOCK "StringFileInfo"
BEGIN
@ -9,12 +9,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Kangaroo Punch Studios"
VALUE "FileDescription", "Somewhat Interactive Nostalgic Game Emulator"
VALUE "FileVersion", "2.00b6"
VALUE "FileVersion", "2.00b7"
VALUE "InternalName", "Singe"
VALUE "LegalCopyright", "Copyright 2006-2020 Scott C. Duensing"
VALUE "OriginalFilename", "singe.exe"
VALUE "ProductName", "Singe"
VALUE "ProductVersion", "2.00b6"
VALUE "ProductVersion", "2.00b7"
END
END
BLOCK "VarFileInfo"

BIN
singe/singeLogo.xcf (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -37,6 +37,9 @@ static const int CONSOLE_LINES = 1000;
#include "util.h"
extern bool _confNoConsole;
FILE *utilTraceFile = NULL;
@ -77,11 +80,13 @@ void utilDie(char *fmt, ...) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
printf("\n");
fflush(stderr);
if (!_confNoConsole) {
printf("\n");
fflush(stderr);
#ifdef _WIN32
getchar();
getchar();
#endif
}
exit(1);
}
@ -288,8 +293,10 @@ void utilSay(char *fmt, ...) {
va_start(args, fmt);
vfprintf(stdout, fmt, args);
va_end(args);
printf("\n");
fflush(stdout);
if (!_confNoConsole) {
printf("\n");
fflush(stdout);
}
}

View file

@ -29,7 +29,7 @@
#include "videoPlayer.h"
#define AUDIO_STREAM_LOW_WATERMARK (32 * 1024)
#define AUDIO_STREAM_LOW_WATERMARK (24 * 1024)
#define AUDIO_SAMPLE_PREREAD 1024
#define AUDIO_SILENCE_SECONDS 2
@ -110,6 +110,8 @@ void _dequeueVideoAudio(int channel, void *stream, int bytes, void *udata) { /
remainder = bytesToCopy % v->audioSampleSize;
bytesToCopy -= remainder;
//utilSay("B: %d R: %d W: %ld", bytes, remainder, SDL_AudioStreamAvailable(v->audioStream));
// Read audio data
bytesRead = SDL_AudioStreamGet(v->audioStream, stream, bytesToCopy);
if (bytesRead < 0) utilDie("%s", SDL_GetError());
@ -593,6 +595,10 @@ int32_t videoUpdate(int32_t playerHandle, SDL_Texture **texture) {
if (FFMS_GetAudio(v->audioSource, v->audioBuffer, v->audioPosition, count, &v->errInfo)) utilDie("%s", v->errInfo.Buffer);
// Feed it to the mixer stream
if (SDL_AudioStreamPut(v->audioStream, v->audioBuffer, (int32_t)(count * v->audioSampleSize)) < 0) utilDie("%s", SDL_GetError());
//int64_t temp = (int64_t)((double)(v->timestamp * 0.001) * (double)v->audioProps->SampleRate);
//utilSay("A: %ld C: %ld D: %ld W: %ld", v->audioPosition, temp, v->audioPosition - temp, SDL_AudioStreamAvailable(v->audioStream));
v->audioPosition += count;
}
}