Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit b8d63ec
Author: Alexey Nurgaliev <[email protected]>
Date:   Sun Dec 29 21:59:11 2024 +0300

    use threads for all cores

commit 795697e
Author: Alexey Nurgaliev <[email protected]>
Date:   Sun Dec 29 20:42:25 2024 +0300

    video rotation option

commit 024f2a9
Author: Alexey Nurgaliev <[email protected]>
Date:   Sun Dec 29 20:10:36 2024 +0300

    psp controls

commit 0a85bd2
Author: Alexey Nurgaliev <[email protected]>
Date:   Sun Dec 29 19:44:25 2024 +0300

    EJS 4.2.0, ppsspp, fuse
  • Loading branch information
n-at committed Dec 29, 2024
1 parent b886484 commit 9331eef
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea/
/.vscode/
/*.iml
/.scannerwork/
/app
Expand All @@ -7,3 +8,4 @@
/assets/node_modules/
/data/
/uploads/
/__debug*
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Platforms supported:
+ Arcade
+ Atari 2600
+ Atari 5200
+ Atari 7800
+ Atari 7800
+ Atari Jaguar
+ Atari Lynx
+ Bandai WonderSwan (Color)
Expand All @@ -42,7 +42,9 @@ Platforms supported:
+ Sega Master System
+ Sega Mega Drive / Genesis
+ Sega Saturn
+ Sinclair ZX Spectrum
+ Sony PlayStation
+ Sony PlayStation Portable

## Quick installation with script

Expand Down
1 change: 1 addition & 0 deletions assets/img/console/credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ https://commons.wikimedia.org/wiki/File:Sega-Master-System-Set.png
https://commons.wikimedia.org/wiki/File:Sega-Genesis-Mod2-Set.png
https://commons.wikimedia.org/wiki/File:Sega-Saturn-JP-Mk1-Console-Set.png
https://commons.wikimedia.org/wiki/File:PSX-Console-wController.png
https://commons.wikimedia.org/wiki/File:Sinclair-ZX81.png

Others

Expand Down
Binary file added assets/img/console/original/spectrum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/console/spectrum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/controller/credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ https://commons.wikimedia.org/wiki/File:Neo-Geo-Pocket-Color-Blue-Left.jpg
https://commons.wikimedia.org/wiki/File:WonderSwan-Color-Blue-Left.jpg
https://commons.wikimedia.org/wiki/File:ColecoVision-Controller-FL.jpg
https://commons.wikimedia.org/wiki/File:NEC-PC-FX-wController-R-Alt.jpg
https://commons.wikimedia.org/wiki/File:PSP-1000.png
Binary file added assets/img/controller/original/psp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/controller/psp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/l10n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"settings-platform.play.title": "Play",
"settings-platform.play.shader.label": "Display shader",
"settings-platform.play.volume.label": "Volume",
"settings-platform.play.video-rotation.label": "Video rotation",
"settings-platform.play.ff-ratio.label": "Fast Forward ratio",
"settings-platform.play.sm-ratio.label": "Slow Motion ratio",
"settings-platform.play.rewind-granularity.label": "Rewind granularity",
Expand Down
1 change: 1 addition & 0 deletions assets/l10n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"settings-platform.play.title": "Игра",
"settings-platform.play.shader.label": "Шейдер",
"settings-platform.play.volume.label": "Громкость",
"settings-platform.play.video-rotation.label": "Поворот видео",
"settings-platform.play.ff-ratio.label": "Степень ускорения",
"settings-platform.play.sm-ratio.label": "Степень замедления",
"settings-platform.play.rewind-granularity.label": "Скорость перемотки",
Expand Down
54 changes: 0 additions & 54 deletions assets/platform-settings-core.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,5 @@
(() => {

const coresWithThreads = [
'a5200',
'beetle_vb',
'desmume2015',
'desmume',
'fbalpha2012_cps1',
'fbalpha2012_cps2',
'fbneo',
'fceumm',
'gambatte',
'gearcoleco',
'handy',
'mame2003',
'mame2003_plus',
'mednafen_ngp',
'mednafen_pce',
'mednafen_pcfx',
'mednafen_psx_hw',
'mednafen_wswan',
'melonds',
'mgba',
'mupen64plus_next',
'nestopia',
'opera',
'parallel_n64',
'pcsx_rearmed',
'picodrive',
'prosystem',
'snes9x',
'stella2014',
'vice_x64',
'vice_x64sc',
'vice_x128',
'vice_xpet',
'vice_xplus4',
'vice_xvic',
'virtualjaguar',
'yabause',
];

function setupThreadsControl() {
const fieldThreads = document.getElementById('threads');
const fieldCores = document.getElementById('core');

if (coresWithThreads.includes(fieldCores.value)) {
fieldThreads.parentElement.classList.remove('d-none');
} else {
fieldThreads.parentElement.classList.add('d-none');
fieldThreads.checked = null;
}
}

function showCoreOptions() {
const value = document.getElementById('core').value;
document.querySelectorAll('.core-options').forEach(it => it.classList.add('d-none'));
Expand All @@ -60,10 +8,8 @@

window.addEventListener('load', () => {
document.getElementById('core').addEventListener('change', () => {
setupThreadsControl();
showCoreOptions();
});
setupThreadsControl();
showCoreOptions();
});

Expand Down
13 changes: 10 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

PLAYTIME_EJS_REPO_URL=${PLAYTIME_EJS_REPO_URL:-"https://github.com/EmulatorJS/EmulatorJS"}
PLAYTIME_EJS_REVISION=${PLAYTIME_EJS_REVISION:-"3a3eee7d85adb03b7659d9dcdab4d04d6a3e1380"}
PLAYTIME_EJS_CORES_URL=${PLAYTIME_EJS_CORES_URL:-"https://cdn.emulatorjs.org/nightly/data/cores"}
PLAYTIME_EJS_REVISION=${PLAYTIME_EJS_REVISION:-"be29680d57015482612f3b492b7952455494be5a"}
PLAYTIME_EJS_CORES_URL=${PLAYTIME_EJS_CORES_URL:-"https://cdn.emulatorjs.org/stable/data/cores"}

#

cd assets

npm install
npm install --no-fund --ignore-scripts

#download EmulatorJS

Expand Down Expand Up @@ -71,6 +71,10 @@ wget "${PLAYTIME_EJS_CORES_URL}/fceumm-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fceumm-thread-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fceumm-thread-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fceumm-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fuse-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fuse-thread-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fuse-thread-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/fuse-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/gambatte-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/gambatte-thread-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/gambatte-thread-wasm.data"
Expand Down Expand Up @@ -147,6 +151,8 @@ wget "${PLAYTIME_EJS_CORES_URL}/picodrive-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/picodrive-thread-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/picodrive-thread-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/picodrive-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/ppsspp-thread-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/ppsspp-assets.zip"
wget "${PLAYTIME_EJS_CORES_URL}/prboom-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/prboom-thread-legacy-wasm.data"
wget "${PLAYTIME_EJS_CORES_URL}/prboom-thread-wasm.data"
Expand Down Expand Up @@ -235,6 +241,7 @@ wget "${PLAYTIME_EJS_CORES_URL}/reports/opera.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/parallel_n64.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/pcsx_rearmed.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/picodrive.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/ppsspp.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/prboom.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/prosystem.json"
wget "${PLAYTIME_EJS_CORES_URL}/reports/puae.json"
Expand Down
28 changes: 28 additions & 0 deletions storage/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ var (
},
},
},
"psp": {
Id: "psp",
Name: "Sony PlayStation Portable",
Cores: []string{"ppsspp"},
Extensions: []string{"iso"},
Bios: []Bios{},
},
"jaguar": {
Id: "jaguar",
Name: "Atari Jaguar",
Expand Down Expand Up @@ -439,6 +446,13 @@ var (
Extensions: []string{},
Bios: []Bios{},
},
"spectrum": {
Id: "spectrum",
Name: "Sinclair ZX Spectrum",
Cores: []string{"fuse"},
Extensions: []string{"z80", "tzx", "tap", "rzx", "scl", "trd"},
Bios: []Bios{},
},
"": {
Id: "",
Name: "Undefined",
Expand Down Expand Up @@ -954,6 +968,14 @@ func DefaultEmulatorSettings(systemType string) EmulatorSettings {
}
controls = DefaultControlsOther

case "psp":
settings = EmulatorSettings{
Core: Platforms["psp"].Cores[0],
Bios: "",
Threads: true,
}
controls = DefaultControlsOther

case "jaguar":
settings = EmulatorSettings{
Core: Platforms["jaguar"].Cores[0],
Expand Down Expand Up @@ -1103,6 +1125,12 @@ func DefaultEmulatorSettings(systemType string) EmulatorSettings {
Core: Platforms["vic20"].Cores[0],
Bios: "",
}

case "spectrum":
settings = EmulatorSettings{
Core: Platforms["spectrum"].Cores[0],
Bios: "",
}
}

settings.ColorScheme = DefaultColorScheme
Expand Down
1 change: 1 addition & 0 deletions storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type EmulatorSettings struct {
FastForwardRatio string
SlowMotionRatio string
RewindGranularity string
VideoRotation int64
FastForwardMode bool
SlowMotionMode bool
Rewind bool
Expand Down
48 changes: 48 additions & 0 deletions templates/includes/platform_settings/controls/psp.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends "../controls_tab.twig" %}

{% block controls_definitions %}
{% set platform_id = platform_id %}
{% set player = player %}
{% set controller_img = "psp.png" %}
{% set controller_img_alt = "PlayStation Portable" %}
{% endblock %}

{% block controls_keyboard %}
{% include "control.twig" with input="keyboard" btn_id="a" btn_title="Circle" btn_value=controls.Keyboard.A %}
{% include "control.twig" with input="keyboard" btn_id="b" btn_title="Cross" btn_value=controls.Keyboard.B %}
{% include "control.twig" with input="keyboard" btn_id="x" btn_title="Triangle" btn_value=controls.Keyboard.X %}
{% include "control.twig" with input="keyboard" btn_id="y" btn_title="Square" btn_value=controls.Keyboard.Y %}
{% include "control.twig" with input="keyboard" btn_id="select" btn_title="Select" btn_value=controls.Keyboard.Select %}
{% include "control.twig" with input="keyboard" btn_id="start" btn_title="Start" btn_value=controls.Keyboard.Start %}
{% include "control.twig" with input="keyboard" btn_id="up" btn_title="Up" btn_value=controls.Keyboard.Up %}
{% include "control.twig" with input="keyboard" btn_id="down" btn_title="Down" btn_value=controls.Keyboard.Down %}
{% include "control.twig" with input="keyboard" btn_id="left" btn_title="Left" btn_value=controls.Keyboard.Left %}
{% include "control.twig" with input="keyboard" btn_id="right" btn_title="Right" btn_value=controls.Keyboard.Right %}
{% include "control.twig" with input="keyboard" btn_id="l" btn_title="L" btn_value=controls.Keyboard.L %}
{% include "control.twig" with input="keyboard" btn_id="r" btn_title="R" btn_value=controls.Keyboard.R %}
{% include "control.twig" with input="keyboard" btn_id="l-stick-up" btn_title="Stick Up" btn_value=controls.Keyboard.LStickUp %}
{% include "control.twig" with input="keyboard" btn_id="l-stick-down" btn_title="Stick Down" btn_value=controls.Keyboard.LStickDown %}
{% include "control.twig" with input="keyboard" btn_id="l-stick-left" btn_title="Stick Left" btn_value=controls.Keyboard.LStickLeft %}
{% include "control.twig" with input="keyboard" btn_id="l-stick-right" btn_title="Stick Right" btn_value=controls.Keyboard.LStickRight %}
{% include "common_keyboard_controls.twig" %}
{% endblock %}

{% block controls_gamepad %}
{% include "control.twig" with input="gamepad" btn_id="a" btn_title="Circle" btn_value=controls.Gamepad.A %}
{% include "control.twig" with input="gamepad" btn_id="b" btn_title="Cross" btn_value=controls.Gamepad.B %}
{% include "control.twig" with input="gamepad" btn_id="x" btn_title="Triangle" btn_value=controls.Gamepad.X %}
{% include "control.twig" with input="gamepad" btn_id="y" btn_title="Square" btn_value=controls.Gamepad.Y %}
{% include "control.twig" with input="gamepad" btn_id="select" btn_title="Select" btn_value=controls.Gamepad.Select %}
{% include "control.twig" with input="gamepad" btn_id="start" btn_title="Start" btn_value=controls.Gamepad.Start %}
{% include "control.twig" with input="gamepad" btn_id="up" btn_title="Up" btn_value=controls.Gamepad.Up %}
{% include "control.twig" with input="gamepad" btn_id="down" btn_title="Down" btn_value=controls.Gamepad.Down %}
{% include "control.twig" with input="gamepad" btn_id="left" btn_title="Left" btn_value=controls.Gamepad.Left %}
{% include "control.twig" with input="gamepad" btn_id="right" btn_title="Right" btn_value=controls.Gamepad.Right %}
{% include "control.twig" with input="gamepad" btn_id="l" btn_title="L" btn_value=controls.Gamepad.L %}
{% include "control.twig" with input="gamepad" btn_id="r" btn_title="R" btn_value=controls.Gamepad.R %}
{% include "control.twig" with input="gamepad" btn_id="l-stick-up" btn_title="Stick Up" btn_value=controls.Gamepad.LStickUp %}
{% include "control.twig" with input="gamepad" btn_id="l-stick-down" btn_title="Stick Down" btn_value=controls.Gamepad.LStickDown %}
{% include "control.twig" with input="gamepad" btn_id="l-stick-left" btn_title="Stick Left" btn_value=controls.Gamepad.LStickLeft %}
{% include "control.twig" with input="gamepad" btn_id="l-stick-right" btn_title="Stick Right" btn_value=controls.Gamepad.LStickRight %}
{% include "common_gamepad_controls.twig" %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
{% include "controls/segaSaturn.twig" %}
{% elif platform_id == "psx" %}
{% include "controls/psx.twig" %}
{% elif platform_id == "psp" %}
{% include "controls/psp.twig" %}
{% elif platform_id == "3do" %}
{% include "controls/3do.twig" %}
{% elif platform_id == "atari7800" %}
Expand All @@ -46,7 +48,7 @@
{% elif platform_id == "coleco" %}
{% include "controls/coleco.twig" %}
{% else %}
{# a5200, mame2003, arcade #}
{# a5200, mame2003, arcade, spectrum #}
{% if platform_id == "c64" %}
{% set console_img = "c64.png" %}
{% set console_img_alt = "Commodore 64" %}
Expand All @@ -62,6 +64,9 @@
{% elif platform_id == "a5200" %}
{% set console_img = "a5200.png" %}
{% set console_img_alt = "Atari 5200" %}
{% elif platform_id == "spectrum" %}
{% set console_img = "spectrum.png" %}
{% set console_img_alt = "Sinclair ZX81" %}
{% endif %}
{% include "controls/default.twig" %}
{% endif %}
Expand Down
9 changes: 9 additions & 0 deletions templates/includes/platform_settings/play.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<label for="volume">{{ loc("settings-platform.play.volume.label") }}</label>
<input type="range" id="volume" name="volume" class="form-range" min="0.0" max="1.0" step="0.01" value="{{ settings.Volume }}">
</div>
<div class="mb-3 form-floating">
<select id="video-rotation" name="video-rotation" class="form-select">
<option value="0" {% if settings.VideoRotation == 0 %}selected{% endif %}>0&deg;</option>
<option value="1" {% if settings.VideoRotation == 1 %}selected{% endif %}>90&deg;</option>
<option value="2" {% if settings.VideoRotation == 2 %}selected{% endif %}>180&deg;</option>
<option value="3" {% if settings.VideoRotation == 3 %}selected{% endif %}>270&deg;</option>
</select>
<label for="video-rotation">{{ loc("settings-platform.play.video-rotation.label") }}</label>
</div>
<div class="mb-3 form-floating">
<select id="ff-ratio" name="ff-ratio" class="form-select">
{% for ff_ratio in fast_forward_ratios %}
Expand Down
1 change: 1 addition & 0 deletions templates/play.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
window.EJS_startOnLoaded = true;
window.EJS_fullscreenOnLoaded = {{ emulator_settings.StartFullScreen | lower }};
window.EJS_disableLocalStorage = true;
window.EJS_videoRotation = {{ emulator_settings.VideoRotation }};
{% if emulator_debug %}
window.EJS_DEBUG_XX = true;
Expand Down
18 changes: 15 additions & 3 deletions web/handlers_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package web
import (
"errors"
"fmt"
"github.com/flosch/pongo2/v6"
"github.com/labstack/echo/v4"
log "github.com/sirupsen/logrus"
"net/http"
"playtime/storage"
"strconv"

"github.com/flosch/pongo2/v6"
"github.com/labstack/echo/v4"
log "github.com/sirupsen/logrus"
)

func (s *Server) settings(c echo.Context) error {
Expand Down Expand Up @@ -167,6 +168,16 @@ func settingsCollectFormData(c echo.Context) storage.EmulatorSettings {
volume = storage.DefaultVolume
}

videoRotation, err := strconv.ParseInt(c.FormValue("video-rotation"), 10, 64)
if err != nil {
log.Warnf("unable to read video rotation: %s", err)
videoRotation = 0
}
if videoRotation < 0 || videoRotation > 3 {
log.Warnf("wrong video rotation value: %d", videoRotation)
videoRotation = 0
}

buttons := storage.EmulatorButtons{
PlayPause: c.FormValue("button-play-pause") == "1",
Restart: c.FormValue("button-restart") == "1",
Expand Down Expand Up @@ -233,6 +244,7 @@ func settingsCollectFormData(c echo.Context) storage.EmulatorSettings {
DisableBrowserDB: c.FormValue("disable-browser-db") == "1",
DisableVSync: c.FormValue("disable-vsync") == "1",
CueEnabled: c.FormValue("cue-enabled") == "1",
VideoRotation: videoRotation,
Buttons: buttons,
Controls: settingsCollectControls(c),
CoreOptions: coreOptionsValues,
Expand Down

0 comments on commit 9331eef

Please sign in to comment.