less CPU demanding InputStrobing

This commit is contained in:
minjaesong
2023-01-16 04:31:31 +09:00
parent af03ab23aa
commit 5b86e88779
6 changed files with 19 additions and 4 deletions

View File

@@ -964,8 +964,10 @@ input.withEvent = function(callback) {
inputwork.stroboStatus = 0;
inputwork.repeatCount = 0;
if (keys[0] == 0)
if (keys[0] == 0) {
inputwork.keyChanged = false;
sys.sleep(25)
}
if (keyChanged) {
//callback(["key_change", keysToStr(arrayDiff(keys, inputwork.oldKeys)), inputwork.repeatCount].concat(keys));
@@ -977,7 +979,7 @@ input.withEvent = function(callback) {
}
}
else if (inputwork.stroboStatus % 2 == 1 && sys.nanoTime() - inputwork.stroboTime < inputwork.stroboDelays[inputwork.stroboStatus]) {
sys.spin();
sys.sleep(25);
}
else {
inputwork.stroboStatus += 1;

View File

@@ -1,3 +1,8 @@
println("DEPRECATION NOTICE: MP3 Playback function will be removed for following reason")
println("\tMP3 does not really fit in the time TSVM targets to emulate")
return 1
const Mp3 = require('mp3dec')
const pcm = require("pcm")
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i"
@@ -114,7 +119,6 @@ let readPtr = sys.malloc(8000)
let decodePtr = sys.malloc(12000)
function bytesToSec(i) {
// using fixed value: FRAME_SIZE(216) bytes for 36 ms on sampling rate 32000 Hz
return i / (FRAME_SIZE * 1000 / bufRealTimeLen)
}
function secToReadable(n) {