Skip to content

Commit

Permalink
fixes bg color to black on pillarboxed 4:3 on a 16:9 display and
Browse files Browse the repository at this point in the history
- sets 4:3 display format for jzintv automagically (launcher file)
- fixes a UI freeze bug when a mouse is attached and moved on a RPI3 when jzintv is running

ref: https://retropie.org.uk/forum/topic/32433/jzintv-has-black-border-or-full-screen-color
  • Loading branch information
Gemba committed Jul 8, 2023
1 parent 75f6dc0 commit 1d83718
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 11 deletions.
71 changes: 60 additions & 11 deletions scriptmodules/emulators/jzintv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rp_module_section="opt"
rp_module_flags="sdl2"

function depends_jzintv() {
getDepends libsdl2-dev libreadline-dev
getDepends libsdl2-dev libreadline-dev dos2unix
}

function sources_jzintv() {
Expand All @@ -28,6 +28,12 @@ function sources_jzintv() {
mv jzintv-[0-9]* jzintv
cd jzintv/src

if isPlatform "rpi" ; then
dos2unix $(find "$md_data" -iname "*.patch" -exec grep -h "^+++" {} \+ | cut -f2- -d '/' | uniq | xargs)
applyPatch "$md_data/01_rpi_hide_cursor_sdl2.patch"
applyPatch "$md_data/01_rpi_pillar_boxing_black_background_sdl2.patch"
fi

# Add source release date information to build
mv buildcfg/90-svn.mak buildcfg/90-svn.mak.txt
echo "SVN_REV := $(echo $md_repo_url | grep -o -P '[\d]{8}')" > buildcfg/90-src_releasedate.mak
Expand All @@ -44,8 +50,13 @@ function build_jzintv() {
mkdir -p jzintv/bin
cd jzintv/src

if isPlatform "rpi" ; then
local -r extra='EXTRA=-DPLAT_LINUX_RPI'
else
local -r extra=''
fi
make clean
DISTCC_HOSTS="" make
DISTCC_HOSTS="" make $extra

md_ret_require="$md_build/jzintv/bin/jzintv"
}
Expand All @@ -63,15 +74,53 @@ function install_jzintv() {
function configure_jzintv() {
mkRomDir "intellivision"

local options=(
--displaysize="%XRES%x%YRES%"
--quiet
--rom-path="$biosdir"
--voice=1
)
local -r start_script="$md_inst/jzintv_launcher.sh"
cat > "$start_script" << _EOF_
#! /usr/bin/env bash
# \$1: width of display
# \$2: height of display
# \$3: --ecs=1, optional
# \$4,5,6...: more optional parameters
# last parameter: %ROM%
jzintv_bin="$md_inst/bin/jzintv"
# regular case: w>=h (rotation 90/270 not supported by jzintv)
disp_w=\$1; shift
disp_h=\$1; shift
ratio="4/3"
do_pillarboxing='\$(python3 -c "print(\$disp_w / \$disp_h >= \$ratio)")'
if [[ "\$do_pillarboxing" == "True" ]] ; then
# le/ri padding
intv_w=\$(python3 -c "print(round(\$disp_h * \$ratio))")
intv_h=\$disp_h
else
# top/btm padding (letterboxing; e.g., on 5:4 displays)
intv_w=\$disp_w
intv_h=\$(python3 -c "print(round(\$disp_w / (\$ratio)))")
fi
# set --gfx-verbose instead of --quiet for verbose output
options=(
-f1 # fullscreen
--quiet
# --gfx-verbose
--displaysize="\${intv_w}x\${intv_h}"
--rom-path="$biosdir"
--voice=1
)
echo "Launching: \$jzintv_bin \${options[@]} \"\$@\"" >> /dev/shm/runcommand.log
pushd "$romdir/intellivision" > /dev/null
\$jzintv_bin \${options[@]} "\$@"
popd
_EOF_
chown $user:$user "$start_script"
chmod u+x "$start_script"

addEmulator 1 "$md_id" "intellivision" "$md_inst/bin/jzintv ${options[*]} %ROM%"
options+=(--ecs=1)
addEmulator 0 "${md_id}-ecs" "intellivision" "$md_inst/bin/jzintv ${options[*]} %ROM%"
addEmulator 1 "$md_id" "intellivision" "'$start_script' %XRES% %YRES% %ROM%"
addEmulator 0 "$md_id-ecs" "intellivision" "'$start_script' %XRES% %YRES% --ecs=1 %ROM%"
addSystem "intellivision"
}
15 changes: 15 additions & 0 deletions scriptmodules/emulators/jzintv/01_rpi_hide_cursor_sdl2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/gfx/gfx_sdl2.c
+++ a/gfx/gfx_sdl2.c
@@ -420,7 +420,12 @@ LOCAL int gfx_setup_sdl_display
/* Hide the mouse if full screen. */
/* -------------------------------------------------------------------- */
SDL_ShowCursor(
+#ifndef PLAT_LINUX_RPI
+ /* SDL_GetNumVideoDisplays() may return two on rpi3, thus disable */
+ /* this clause on rpi. This is not only cosmetic, it fixes the */
+ /* UI freeze (not of jzintv itself), if mouse is attached and moved.*/
SDL_GetNumVideoDisplays() == 1 &&
+#endif
(act_wind_flags & SDL_WINDOW_FULLSCREEN) ? SDL_DISABLE : SDL_ENABLE);

SDL_PumpEvents();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/gfx/gfx_sdl2.c
+++ b/gfx/gfx_sdl2.c
@@ -506,7 +511,7 @@ LOCAL int gfx_flip(const gfx_t *const gfx)
/* need to clear the backdrop to our border color before copying the */
/* texture to the display. */
/* -------------------------------------------------------------------- */
- SDL_SetRenderDrawColor(rend, bord_color.r, bord_color.g, bord_color.b, 255);
+ SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderClear(rend);
if (pvt->vid_enable || gfx->debug_blank)
SDL_RenderCopy(rend, text, NULL,

0 comments on commit 1d83718

Please sign in to comment.