diff --git a/scriptmodules/emulators/jzintv.sh b/scriptmodules/emulators/jzintv.sh index 1e5c4a067d..e7fa1048f0 100644 --- a/scriptmodules/emulators/jzintv.sh +++ b/scriptmodules/emulators/jzintv.sh @@ -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() { @@ -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 @@ -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" } @@ -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" } diff --git a/scriptmodules/emulators/jzintv/01_rpi_hide_cursor_sdl2.patch b/scriptmodules/emulators/jzintv/01_rpi_hide_cursor_sdl2.patch new file mode 100644 index 0000000000..baee3f5958 --- /dev/null +++ b/scriptmodules/emulators/jzintv/01_rpi_hide_cursor_sdl2.patch @@ -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, diff --git a/scriptmodules/emulators/jzintv/01_rpi_pillar_boxing_black_background_sdl2.patch b/scriptmodules/emulators/jzintv/01_rpi_pillar_boxing_black_background_sdl2.patch new file mode 100644 index 0000000000..5f3d5630c2 --- /dev/null +++ b/scriptmodules/emulators/jzintv/01_rpi_pillar_boxing_black_background_sdl2.patch @@ -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();