Sinden border and overscan options added. Pi video working.

This commit is contained in:
Scott Duensing 2020-01-29 21:13:44 -06:00
parent 23b4b8f13a
commit ff45c64b7f
8 changed files with 195 additions and 17 deletions

View file

@ -26,5 +26,6 @@ sudo umount /tmp/mnt-${DIST}
proot -S ${DIST} -q qemu-arm apt-get -y update
proot -S ${DIST} -q qemu-arm apt-get -y upgrade
proot -S ${DIST} -q qemu-arm apt-get -y install libxv-dev libx11-dev libxext-dev libxi-dev
proot -S ${DIST} -q qemu-arm apt-get -y install libopenal-dev libasound2-dev
touch ${DIST}/usr/include/immintrin.h

View file

@ -65,7 +65,7 @@ function doBuild() {
popd
}
:<<SKIP
# 64 Bit Linux
CROSS="x86_64-linux-gnu"
EXTRA_CFLAGS=""
@ -83,10 +83,12 @@ x86_64-w64-mingw32-windres singe.rc -O coff -o /tmp/singe.res
doBuild Singe-Windows-x86_64 mingw 64 .exe
rm /tmp/icon.ico
rm /tmp/singe.res
SKIP
# 32 Bit Raspbian
SYSROOT="/opt/cross/pi/buster"
CROSS="arm-linux-gnueabihf"
EXTRA_CFLAGS="--sysroot /opt/cross/pi/buster"
EXTRA_CFLAGS="--sysroot ${SYSROOT}"
EXTRA_OFILES=""
EXTRA_LD_FLAGS="--sysroot /opt/cross/pi/buster -l:everything.a -lpthread -lXv -lX11 -lXext -lm -ldl -lrt"
EXTRA_LD_FLAGS="--sysroot ${SYSROOT} -l:everything.a -Wl,-rpath,/opt/vc/lib -L${SYSROOT}/opt/vc/lib -lbcm_host -lpthread -lXv -lX11 -lXext -lXi -lm -ldl -lrt"
doBuild Singe-Pi-armv6 pi 32

View file

@ -69,7 +69,7 @@ void showUsage(char *name, char *message) {
// 00000000011111111112222222222333333333344444444445555555555666666666677777777778
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
utilSay(" ___ ___ _ _ ___ ___");
utilSay("/ __|_ _| \\| |/ __| __| Somewhat Interactive Nostalgic Game Emulator %s", VERSION_STRING);
utilSay("/ __|_ _| \\| |/ __| __| Somewhat Interactive Nostalgic Game Engine %s", VERSION_STRING);
utilSay("\\__ \\| || .` | (_ | _| Copyright (c) 2006-%s Scott C. Duensing", COPYRIGHT_END_YEAR);
utilSay("|___/___|_|\\_|\\___|___| https://kangaroopunch.com");
utilSay("");
@ -84,7 +84,8 @@ void showUsage(char *name, char *message) {
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(" -o, --scalefactor=PERCENT reduce screen size for overscan compensation");
utilSay(" -o, --scalefactor=PERCENT reduce screen size for overscan compensation");
utilSay(" -g, --sindengun=PARAMS enable Sinden Light Gun support");
utilSay(" -a, --aspect=N:D force aspect ratio");
utilSay(" -u, --stretch use ugly stretched video");
utilSay(" -x, --xresolution=VALUE specify horizontal resolution");
@ -118,6 +119,7 @@ int main(int argc, char *argv[]) {
int32_t aspectDom = -1;
char *temp = NULL;
char *aspectString = NULL;
char *sindenString = NULL;
float thisRatio = 0;
float bestRatio = 9999;
bool tracing = false;
@ -137,7 +139,8 @@ 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, 'o' },
{ "scalefactor", optional_argument, NULL, 'o' },
{ "sinden", optional_argument, NULL, 'g' },
{ "aspect", optional_argument, NULL, 'a' },
{ "xresolution", optional_argument, NULL, 'x' },
{ "yresolution", optional_argument, NULL, 'y' },
@ -183,7 +186,7 @@ int main(int argc, char *argv[]) {
while (true) {
optionIndex = 0;
opterr = 0;
x = getopt_long(argc, argv, "cmnsfwha:d:v:l:e:z:x:y:", options, &optionIndex);
x = getopt_long(argc, argv, "cmnsfwha:d:v:l:e:z:x:y:o:g:", options, &optionIndex);
// Out of options?
if (x == -1) break;
@ -247,6 +250,12 @@ int main(int argc, char *argv[]) {
_confScaleFactor = atoi(optarg);
break;
// Sinden Light Gun
case 'g':
if (sindenString) free(sindenString);
sindenString = strdup(optarg);
break;
// Aspect
case 'a':
if (aspectString) free(aspectString);
@ -402,6 +411,30 @@ int main(int argc, char *argv[]) {
// Sane scale factor?
if ((_confScaleFactor < 50) || (_confScaleFactor > 100)) showUsage(argv[0], "Display scale must be between 50 and 100 percent.");
// Sinden light gun?
if (sindenString) {
if (_confScaleFactor != 100) showUsage(argv[0], "Cannot use --sinden and --scalefactor together.");
// Was it wrapped in quotes?
if ((sindenString[0] == '"') || (sindenString[0] == '\'')) {
sindenString[0] = ' ';
}
// Ok, this thing can have a mess of different arguments:
// WW - Just the width of the white border
// WW WB - Width of white border and then black border
// RW GW BW WW - Custom color "white" border and width
// RW GW BW WW WB - Custom color "white" border and width then width of black border
// RW GW BW WW RB GB BB WB - Custom color "white" border and width then custom color "black" border and width
temp = strtok(sindenString, " ");
while (temp != NULL) {
_confSindenArgv[_confSindenArgc++] = atoi(temp);
temp = strtok(NULL, " ");
if ((temp != NULL) && (_confSindenArgc > SINDEN_OPTION_COUNT)) showUsage(argv[0], "Too many arguments to --sinden.");
}
// Did we get a sane number of arguments?
if ((_confSindenArgc != SINDEN_WHITE) && (_confSindenArgc != SINDEN_WHITE_BLACK) && (_confSindenArgc != SINDEN_CUSTOM_WHITE) && (_confSindenArgc != SINDEN_CUSTOM_WHITE_BLACK) && (_confSindenArgc != SINDEN_CUSTOM_WHITE_CUSTOM_BLACK)) showUsage(argv[0], "Bad argument count to --sinden.");
free(sindenString);
}
// Init SDL
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) utilDie("%s", SDL_GetError());
if (SDL_GetCurrentDisplayMode(0, &mode) < 0) utilDie("%s", SDL_GetError());
@ -428,6 +461,7 @@ int main(int argc, char *argv[]) {
x++;
}
}
free(aspectString);
} else {
// Find our current aspect ratio
x = 0;

View file

@ -124,14 +124,15 @@ function autoBuild() {
if [[ ! -z ${G_SYSROOT} ]]; then
MORE_CFLAGS="--sysroot=${G_SYSROOT} ${MORE_CFLAGS}"
MORE_LIBS="--sysroot=${G_SYSROOT} ${MORE_LIBS}"
fi
export CC=${G_CCOMPILER}
export CXX=${G_CPPCOMPILER}
export CFLAGS="-isystem${G_INSTALLED}/include ${MORE_CFLAGS}"
export CXXFLAGS="-isystem${G_INSTALLED}/include ${MORE_CFLAGS}"
export CPPFLAGS="-isystem${G_INSTALLED}/include ${MORE_CFLAGS}"
export LDFLAGS="-L${G_INSTALLED}/lib ${MORE_LIBS}"
export CFLAGS="${MORE_CFLAGS} -isystem${G_INSTALLED}/include"
export CXXFLAGS="${MORE_CFLAGS} -isystem${G_INSTALLED}/include"
export CPPFLAGS="${MORE_CFLAGS} -isystem${G_INSTALLED}/include"
export LDFLAGS="${MORE_LIBS} -L${G_INSTALLED}/lib"
export LD_LIBRARY_PATH=${G_INSTALLED}/lib
export PKG_CONFIG_LIBDIR=${G_INSTALLED}/lib/pkgconfig
@ -162,6 +163,9 @@ function autoBuild() {
fi
fi
MORE_CFLAGS=""
MORE_LIBS=""
export CC=${O_CC}
export CXX=${O_CXX}
export CFLAGS=${O_CFLAGS}
@ -388,18 +392,36 @@ autoBuild libfreetype.a freetype2 --without-harfbuzz
autoBuild libharfbuzz.a harfbuzz "--with-glib=no --with-icu=builtin --with-cairo=no --with-fontconfig=no --with-freetype=yes -with-icu=no"
# === SDL2 ===
autoBuild libSDL2.a SDL2
if [[ "${G_PLATFORM}" == "pi" ]]; then
MORE_CFLAGS="-I${G_SYSROOT}/opt/vc/include -I${G_SYSROOT}/usr/include -I${G_SYSROOT}/opt/vc/include/interface/vcos/pthreads -I${G_SYSROOT}/opt/vc/include/interface/vmcs_host/linux"
MORE_LIBS="-Wl,-rpath,/opt/vc/lib -L${G_SYSROOT}/opt/vc/lib -lbcm_host -lpthread -lm -ldl -lrt"
autoBuild libSDL2.a SDL2 "--disable-pulseaudio --disable-esd --disable-video-wayland --enable-video-rpi --enable-alsa"
else
autoBuild libSDL2.a SDL2
fi
# === SDL2_image === *** Not finding libtiff ***
if [[ "${G_PLATFORM}" == "pi" ]]; then
MORE_CFLAGS="-I${G_SYSROOT}/opt/vc/include -I${G_SYSROOT}/usr/include -I${G_SYSROOT}/opt/vc/include/interface/vcos/pthreads -I${G_SYSROOT}/opt/vc/include/interface/vmcs_host/linux"
MORE_LIBS="-Wl,-rpath,/opt/vc/lib -L${G_SYSROOT}/opt/vc/lib -lbcm_host"
fi
autoBuild libSDL2_image.a SDL2_image "--disable-jpg-shared --disable-png-shared --disable-tif-shared --disable-webp-shared"
# === SDL2_mixer ===
if [[ "${G_PLATFORM}" == "pi" ]]; then
MORE_CFLAGS="-I${G_SYSROOT}/opt/vc/include -I${G_SYSROOT}/usr/include -I${G_SYSROOT}/opt/vc/include/interface/vcos/pthreads -I${G_SYSROOT}/opt/vc/include/interface/vmcs_host/linux"
MORE_LIBS="-Wl,-rpath,/opt/vc/lib -L${G_SYSROOT}/opt/vc/lib -lbcm_host"
fi
MODPLUG_CFLAGS="-I${G_INSTALLED}/include -DMODPLUG_STATIC" \
MODPLUG_LIBS="-L${G_INSTALLED}/lib -lmodplug -lstdc++ -lm" \
autoBuild libSDL2_mixer.a SDL2_mixer "--disable-music-midi-fluidsynth --disable-music-ogg-shared --disable-music-flac-shared --disable-music-mod-modplug-shared --disable-music-mp3-mpg123-shared --disable-music-opus-shared"
# === SDL2_ttf ===
MORE_CFLAGS="-I${G_INSTALLED}/include/SDL2" \
if [[ "${G_PLATFORM}" == "pi" ]]; then
MORE_CFLAGS="-I${G_SYSROOT}/opt/vc/include -I${G_SYSROOT}/usr/include -I${G_SYSROOT}/opt/vc/include/interface/vcos/pthreads -I${G_SYSROOT}/opt/vc/include/interface/vmcs_host/linux"
MORE_LIBS="-Wl,-rpath,/opt/vc/lib -L${G_SYSROOT}/opt/vc/lib -lbcm_host"
fi
MORE_CFLAGS="${MORE_CFLAGS} -I${G_INSTALLED}/include/SDL2" \
autoBuild libSDL2_ttf.a SDL2_ttf "--with-ft-prefix=\"${G_INSTALLED}\" --with-sdl-prefix=\"${G_INSTALLED}\"" "libSDL2_ttf.la install-libLTLIBRARIES install-libSDL2_ttfincludeHEADERS"
# === Combine all dependencies into one big mess ===

View file

@ -162,6 +162,8 @@ int32_t _confVolumeNonVldp = 100;
int32_t _confScaleFactor = 100;
int32_t _confXResolution = -1;
int32_t _confYResolution = -1;
int32_t _confSindenArgc = 0;
int32_t _confSindenArgv[SINDEN_OPTION_COUNT];
// Other globals
@ -2051,6 +2053,11 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
int32_t intReturn = 0;
int64_t thisFrame = -1;
int64_t lastFrame = -1;
SDL_Rect windowTarget;
SDL_Rect sindenWhite;
SDL_Rect sindenBlack;
SDL_Color sindenWhiteColor;
SDL_Color sindenBlackColor;
SDL_Texture *overlayTexture = NULL;
SpriteT *sprite = NULL;
SpriteT *spriteTemp = NULL;
@ -2172,6 +2179,88 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Should we resize the window?
//***TODO***
// Default render location is the entire window
windowTarget.x = 0;
windowTarget.y = 0;
windowTarget.w = videoGetWidth(_videoHandle);
windowTarget.h = videoGetHeight(_videoHandle);
sindenWhite.x = -1;
sindenBlack.x = -1;
// Overscan compensation
if (_confScaleFactor < 100) {
windowTarget.w = videoGetWidth(_videoHandle) * _confScaleFactor / 100;
windowTarget.h = videoGetHeight(_videoHandle) * _confScaleFactor / 100;
windowTarget.x = (videoGetWidth(_videoHandle) - windowTarget.w) / 2;
windowTarget.y = (videoGetHeight(_videoHandle) - windowTarget.h) / 2;
}
// Sinden Light Gun Border Setup
if (_confSindenArgc > 0) {
//***TODO*** ADD MOUSE SCALING TO COMPENSATE FOR BORDER
sindenWhiteColor.r = 255;
sindenWhiteColor.g = 255;
sindenWhiteColor.b = 255;
sindenWhiteColor.a = 255;
sindenBlackColor.r = 0;
sindenBlackColor.g = 0;
sindenBlackColor.b = 0;
sindenBlackColor.a = 255;
// Ok, this thing can have a mess of different arguments:
switch(_confSindenArgc) {
// WW - Just the width of the white border
case SINDEN_WHITE:
sindenWhite.x = _confSindenArgv[0];
break;
// WW WB - Width of white border and then black border
case SINDEN_WHITE_BLACK:
sindenWhite.x = _confSindenArgv[0];
sindenBlack.x = _confSindenArgv[1];
break;
// RW GW BW WW - Custom color "white" border and width
case SINDEN_CUSTOM_WHITE:
sindenWhiteColor.r = _confSindenArgv[0];
sindenWhiteColor.g = _confSindenArgv[1];
sindenWhiteColor.b = _confSindenArgv[2];
sindenWhite.x = _confSindenArgv[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 = _confSindenArgv[0];
sindenWhiteColor.g = _confSindenArgv[1];
sindenWhiteColor.b = _confSindenArgv[2];
sindenWhite.x = _confSindenArgv[3];
sindenBlack.x = _confSindenArgv[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 = _confSindenArgv[0];
sindenWhiteColor.g = _confSindenArgv[1];
sindenWhiteColor.b = _confSindenArgv[2];
sindenWhite.x = _confSindenArgv[3];
sindenBlackColor.r = _confSindenArgv[4];
sindenBlackColor.g = _confSindenArgv[5];
sindenBlackColor.b = _confSindenArgv[6];
sindenBlack.x = _confSindenArgv[7];
break;
}
if (sindenWhite.x >= 0) {
sindenWhite.y = sindenWhite.x;
sindenWhite.w = videoGetWidth(_videoHandle) - (sindenWhite.x * 2);
sindenWhite.h = videoGetHeight(_videoHandle) - (sindenWhite.y * 2);
}
if (sindenBlack.x >= 0) {
sindenBlack.y = sindenBlack.x;
sindenBlack.w = videoGetWidth(_videoHandle) - (sindenBlack.x * 2);
sindenBlack.h = videoGetHeight(_videoHandle) - (sindenBlack.y * 2);
sindenWhite.x += sindenBlack.x;
sindenWhite.y += sindenBlack.y;
sindenWhite.w -= (sindenBlack.x * 2);
sindenWhite.h -= (sindenBlack.y * 2);
}
windowTarget = sindenWhite; //***TODO*** We don't really need sindenWhite
}
// Create overlay surface
_overlayScaleX = 0.5;
_overlayScaleY = 0.5;
@ -2379,6 +2468,22 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
// Update display
if (_refreshDisplay || _discStopped) {
// Sinden Gun Border
if (sindenWhite.x >= 0) {
if (sindenBlack.x >= 0) {
// Black and White
SDL_SetRenderDrawColor(_renderer, sindenBlackColor.r, sindenBlackColor.g, sindenBlackColor.b, sindenBlackColor.a);
SDL_RenderClear(_renderer);
SDL_SetRenderDrawColor(_renderer, sindenWhiteColor.r, sindenWhiteColor.g, sindenWhiteColor.b, sindenWhiteColor.a);
SDL_RenderFillRect(_renderer, &sindenBlack);
} else {
// Only white
SDL_SetRenderDrawColor(_renderer, sindenWhiteColor.r, sindenWhiteColor.g, sindenWhiteColor.b, sindenWhiteColor.a);
SDL_RenderClear(_renderer);
}
SDL_RenderFillRect(_renderer, &windowTarget);
}
// Laserdisc Video
if (_discStopped) {
// Stopped discs display blue like the good old days
SDL_SetRenderTarget(_renderer, _videoTexture);
@ -2386,15 +2491,17 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
SDL_RenderClear(_renderer);
SDL_SetRenderTarget(_renderer, NULL);
}
SDL_RenderCopy(_renderer, _videoTexture, NULL, NULL);
SDL_RenderCopy(_renderer, _videoTexture, NULL, &windowTarget);
// Overlay
overlayTexture = SDL_CreateTextureFromSurface(_renderer, _overlay);
if (!overlayTexture) utilDie("%s", SDL_GetError());
if (!_confStretchVideo) {
SDL_RenderSetLogicalSize(renderer, videoGetWidth(_videoHandle), videoGetHeight(_videoHandle));
}
SDL_RenderCopy(_renderer, overlayTexture, NULL, NULL);
SDL_RenderCopy(_renderer, overlayTexture, NULL, &windowTarget);
SDL_DestroyTexture(overlayTexture);
overlayTexture = NULL;
// Show it
SDL_RenderPresent(_renderer);
_refreshDisplay = false;
}

View file

@ -35,6 +35,16 @@
#define COPYRIGHT_END_YEAR "2020"
enum {
SINDEN_WHITE = 1,
SINDEN_WHITE_BLACK = 2,
SINDEN_CUSTOM_WHITE = 4,
SINDEN_CUSTOM_WHITE_BLACK = 5,
SINDEN_CUSTOM_WHITE_CUSTOM_BLACK = 8,
SINDEN_OPTION_COUNT = 8
};
// Command line options
extern char *_confVideoFile;
extern char *_confScriptFile;
@ -53,6 +63,8 @@ extern int32_t _confVolumeNonVldp;
extern int32_t _confScaleFactor;
extern int32_t _confXResolution;
extern int32_t _confYResolution;
extern int32_t _confSindenArgc;
extern int32_t _confSindenArgv[SINDEN_OPTION_COUNT];
void singe(SDL_Window *window, SDL_Renderer *renderer);

View file

@ -8,7 +8,7 @@ BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Kangaroo Punch Studios"
VALUE "FileDescription", "Somewhat Interactive Nostalgic Game Emulator"
VALUE "FileDescription", "Somewhat Interactive Nostalgic Game Engine"
VALUE "FileVersion", "2.00b8"
VALUE "InternalName", "Singe"
VALUE "LegalCopyright", "Copyright 2006-2020 Scott C. Duensing"

View file

@ -1018,9 +1018,9 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
@HAVE_DOXYGEN_FALSE@install-data-local:
@HAVE_DOXYGEN_FALSE@clean-local:
@HAVE_DOXYGEN_FALSE@uninstall-local:
@HAVE_DOXYGEN_FALSE@install-data-local:
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \