mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 10:56:30 +00:00
slow motion
This commit is contained in:
parent
7e8c158e0a
commit
875f862221
2 changed files with 44 additions and 6 deletions
|
@ -27,7 +27,9 @@ class EJS_GameManager {
|
||||||
toggleFastForward: this.Module.cwrap('toggle_fastforward', 'null', ['number']),
|
toggleFastForward: this.Module.cwrap('toggle_fastforward', 'null', ['number']),
|
||||||
setFastForwardRatio: this.Module.cwrap('set_ff_ratio', 'null', ['number']),
|
setFastForwardRatio: this.Module.cwrap('set_ff_ratio', 'null', ['number']),
|
||||||
toggleRewind: this.Module.cwrap('toggle_rewind', 'null', ['number']),
|
toggleRewind: this.Module.cwrap('toggle_rewind', 'null', ['number']),
|
||||||
setRewindGranularity: this.Module.cwrap('set_rewind_granularity', 'null', ['number'])
|
setRewindGranularity: this.Module.cwrap('set_rewind_granularity', 'null', ['number']),
|
||||||
|
toggleSlowMotion: this.Module.cwrap('toggle_slow_motion', 'null', ['number']),
|
||||||
|
setSlowMotionRatio: this.Module.cwrap('set_sm_ratio', 'null', ['number'])
|
||||||
}
|
}
|
||||||
this.mkdir("/home");
|
this.mkdir("/home");
|
||||||
this.mkdir("/home/web_user");
|
this.mkdir("/home/web_user");
|
||||||
|
@ -67,6 +69,7 @@ class EJS_GameManager {
|
||||||
"video_vsync = true\n" +
|
"video_vsync = true\n" +
|
||||||
"video_smooth = false\n" +
|
"video_smooth = false\n" +
|
||||||
"fastforward_ratio = 3.0\n" +
|
"fastforward_ratio = 3.0\n" +
|
||||||
|
"slowmotion_ratio = 3.0\n" +
|
||||||
(this.EJS.rewindEnabled ? "rewind_enable = true\n" : "") +
|
(this.EJS.rewindEnabled ? "rewind_enable = true\n" : "") +
|
||||||
(this.EJS.rewindEnabled ? "rewind_granularity = 6\n" : "") +
|
(this.EJS.rewindEnabled ? "rewind_granularity = 6\n" : "") +
|
||||||
"savefile_directory = \"/data/saves\"\n";
|
"savefile_directory = \"/data/saves\"\n";
|
||||||
|
@ -146,7 +149,7 @@ class EJS_GameManager {
|
||||||
this.EJS.netplay.simulateInput(player, index, value);
|
this.EJS.netplay.simulateInput(player, index, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ([24, 25, 26, 27, 28].includes(index)) {
|
if ([24, 25, 26, 27, 28, 29].includes(index)) {
|
||||||
if (index === 24 && value === 1) {
|
if (index === 24 && value === 1) {
|
||||||
const slot = this.EJS.settings['save-state-slot'] ? this.EJS.settings['save-state-slot'] : "1";
|
const slot = this.EJS.settings['save-state-slot'] ? this.EJS.settings['save-state-slot'] : "1";
|
||||||
this.quickSave(slot);
|
this.quickSave(slot);
|
||||||
|
@ -171,6 +174,9 @@ class EJS_GameManager {
|
||||||
if (index === 27) {
|
if (index === 27) {
|
||||||
this.functions.toggleFastForward(this.EJS.isFastForward ? !value : value);
|
this.functions.toggleFastForward(this.EJS.isFastForward ? !value : value);
|
||||||
}
|
}
|
||||||
|
if (index === 29) {
|
||||||
|
this.functions.toggleSlowMotion(this.EJS.isSlowMotion ? !value : value);
|
||||||
|
}
|
||||||
if (index === 28) {
|
if (index === 28) {
|
||||||
if (this.EJS.rewindEnabled) {
|
if (this.EJS.rewindEnabled) {
|
||||||
this.functions.toggleRewind(value);
|
this.functions.toggleRewind(value);
|
||||||
|
@ -312,6 +318,12 @@ class EJS_GameManager {
|
||||||
toggleFastForward(active) {
|
toggleFastForward(active) {
|
||||||
this.functions.toggleFastForward(active);
|
this.functions.toggleFastForward(active);
|
||||||
}
|
}
|
||||||
|
setSlowMotionRatio(ratio) {
|
||||||
|
this.functions.setSlowMotionRatio(ratio);
|
||||||
|
}
|
||||||
|
toggleSlowMotion(active) {
|
||||||
|
this.functions.toggleSlowMotion(active);
|
||||||
|
}
|
||||||
setRewindGranularity(value) {
|
setRewindGranularity(value) {
|
||||||
this.functions.setRewindGranularity(value);
|
this.functions.setRewindGranularity(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,7 @@ class EmulatorJS {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.currentPopup = null;
|
this.currentPopup = null;
|
||||||
this.isFastForward = false;
|
this.isFastForward = false;
|
||||||
|
this.isSlowMotion = false;
|
||||||
this.rewindEnabled = this.loadRewindEnabled();
|
this.rewindEnabled = this.loadRewindEnabled();
|
||||||
this.touch = false;
|
this.touch = false;
|
||||||
this.cheats = [];
|
this.cheats = [];
|
||||||
|
@ -2038,6 +2039,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
{id: 27, label: this.localization('FAST FORWARD')},
|
{id: 27, label: this.localization('FAST FORWARD')},
|
||||||
|
{id: 29, label: this.localization('SLOW MOTION')},
|
||||||
{id: 28, label: this.localization('REWIND')}
|
{id: 28, label: this.localization('REWIND')}
|
||||||
);
|
);
|
||||||
//if (_this.statesSupported === false) {
|
//if (_this.statesSupported === false) {
|
||||||
|
@ -2318,6 +2320,7 @@ class EmulatorJS {
|
||||||
26: {},
|
26: {},
|
||||||
27: {},
|
27: {},
|
||||||
28: {},
|
28: {},
|
||||||
|
29: {},
|
||||||
},
|
},
|
||||||
1: {},
|
1: {},
|
||||||
2: {},
|
2: {},
|
||||||
|
@ -2343,7 +2346,7 @@ class EmulatorJS {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
||||||
for (let i=0; i<4; i++) {
|
for (let i=0; i<4; i++) {
|
||||||
for (let j=0; j<29; j++) {
|
for (let j=0; j<30; j++) {
|
||||||
if (this.controls[i][j] && this.controls[i][j].value === e.key.toLowerCase()) {
|
if (this.controls[i][j] && this.controls[i][j].value === e.key.toLowerCase()) {
|
||||||
this.gameManager.simulateInput(i, j, (e.type === 'keyup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
this.gameManager.simulateInput(i, j, (e.type === 'keyup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
||||||
}
|
}
|
||||||
|
@ -2375,7 +2378,7 @@ class EmulatorJS {
|
||||||
if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
|
if (this.settingsMenu.style.display !== "none" || this.isPopupOpen()) return;
|
||||||
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
const special = [16, 17, 18, 19, 20, 21, 22, 23];
|
||||||
for (let i=0; i<4; i++) {
|
for (let i=0; i<4; i++) {
|
||||||
for (let j=0; j<29; j++) {
|
for (let j=0; j<30; j++) {
|
||||||
if (['buttonup', 'buttondown'].includes(e.type) && (this.controls[i][j] && this.controls[i][j].value2 === e.index)) {
|
if (['buttonup', 'buttondown'].includes(e.type) && (this.controls[i][j] && this.controls[i][j].value2 === e.index)) {
|
||||||
this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
this.gameManager.simulateInput(i, j, (e.type === 'buttonup' ? 0 : (special.includes(j) ? 0x7fff : 1)));
|
||||||
} else if (e.type === "axischanged") {
|
} else if (e.type === "axischanged") {
|
||||||
|
@ -3133,6 +3136,20 @@ class EmulatorJS {
|
||||||
this.isFastForward = false;
|
this.isFastForward = false;
|
||||||
this.gameManager.toggleFastForward(0);
|
this.gameManager.toggleFastForward(0);
|
||||||
}
|
}
|
||||||
|
} else if (option === 'sm-ratio') {
|
||||||
|
if (this.isSlowMotion) this.gameManager.toggleSlowMotion(0);
|
||||||
|
this.gameManager.setSlowMotionRatio(parseFloat(value));
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.isSlowMotion) this.gameManager.toggleSlowMotion(1);
|
||||||
|
}, 10);
|
||||||
|
} else if (option === 'slowMotion') {
|
||||||
|
if (value === "enabled") {
|
||||||
|
this.isSlowMotion = true;
|
||||||
|
this.gameManager.toggleSlowMotion(1);
|
||||||
|
} else if (value === "disabled") {
|
||||||
|
this.isSlowMotion = false;
|
||||||
|
this.gameManager.toggleSlowMotion(0);
|
||||||
|
}
|
||||||
} else if (option === "rewind-granularity") {
|
} else if (option === "rewind-granularity") {
|
||||||
if (this.rewindEnabled) {
|
if (this.rewindEnabled) {
|
||||||
this.gameManager.setRewindGranularity(parseInt(value));
|
this.gameManager.setRewindGranularity(parseInt(value));
|
||||||
|
@ -3332,9 +3349,18 @@ class EmulatorJS {
|
||||||
"1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5", "10.0", "unlimited"
|
"1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5", "10.0", "unlimited"
|
||||||
], "3.0");
|
], "3.0");
|
||||||
|
|
||||||
|
addToMenu(this.localization('Slow Motion Ratio'), 'sm-ratio', [
|
||||||
|
"1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5", "10.0"
|
||||||
|
], "3.0");
|
||||||
|
|
||||||
addToMenu(this.localization('Fast Forward'), 'fastForward', {
|
addToMenu(this.localization('Fast Forward'), 'fastForward', {
|
||||||
'enabled': this.localization("Enabled"),
|
'enabled': this.localization("Enabled"),
|
||||||
'disabled': this.localization("Disabled")
|
'disabled': this.localization("Disabled")
|
||||||
|
}, "disabled");
|
||||||
|
|
||||||
|
addToMenu(this.localization('Slow Motion'), 'slowMotion', {
|
||||||
|
'enabled': this.localization("Enabled"),
|
||||||
|
'disabled': this.localization("Disabled")
|
||||||
}, "disabled");
|
}, "disabled");
|
||||||
|
|
||||||
addToMenu(this.localization('Rewind Enabled (requires restart)'), 'rewindEnabled', {
|
addToMenu(this.localization('Rewind Enabled (requires restart)'), 'rewindEnabled', {
|
||||||
|
|
Loading…
Reference in a new issue