From 5b86e887792a60a2e3f572fccdf2c3b542af3533 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 16 Jan 2023 04:31:31 +0900 Subject: [PATCH] less CPU demanding InputStrobing --- assets/disk0/tvdos/TVDOS.SYS | 6 ++++-- assets/disk0/tvdos/bin/playmp3.js | 6 +++++- assets/disk0/tvdos/{tuidev => bin}/zfm.js | 0 .../disk0/tvdos/include/{mp3dec.js => mp3dec.js.deprecated} | 0 doc/implementation.tex | 5 ++++- doc/tvdos.tex | 6 ++++++ 6 files changed, 19 insertions(+), 4 deletions(-) rename assets/disk0/tvdos/{tuidev => bin}/zfm.js (100%) rename assets/disk0/tvdos/include/{mp3dec.js => mp3dec.js.deprecated} (100%) diff --git a/assets/disk0/tvdos/TVDOS.SYS b/assets/disk0/tvdos/TVDOS.SYS index b6c9f15..354b5ca 100644 --- a/assets/disk0/tvdos/TVDOS.SYS +++ b/assets/disk0/tvdos/TVDOS.SYS @@ -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; diff --git a/assets/disk0/tvdos/bin/playmp3.js b/assets/disk0/tvdos/bin/playmp3.js index fb7b8c6..62f8f3a 100644 --- a/assets/disk0/tvdos/bin/playmp3.js +++ b/assets/disk0/tvdos/bin/playmp3.js @@ -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) { diff --git a/assets/disk0/tvdos/tuidev/zfm.js b/assets/disk0/tvdos/bin/zfm.js similarity index 100% rename from assets/disk0/tvdos/tuidev/zfm.js rename to assets/disk0/tvdos/bin/zfm.js diff --git a/assets/disk0/tvdos/include/mp3dec.js b/assets/disk0/tvdos/include/mp3dec.js.deprecated similarity index 100% rename from assets/disk0/tvdos/include/mp3dec.js rename to assets/disk0/tvdos/include/mp3dec.js.deprecated diff --git a/doc/implementation.tex b/doc/implementation.tex index b924977..ad8b59f 100644 --- a/doc/implementation.tex +++ b/doc/implementation.tex @@ -557,13 +557,16 @@ Address & RW & Description \\ -39 & RW & Text Input Stream control. Write nonzero value to open it. The Keyboard Input Buffer will be cleared whenever the Input Stream is opened. \\ -40 & WO & Latch Keyboard and Mouse input \\ -41..-48 & RO & List of pressed keys (latched by -40) \\ --49 & RO & System Flags A (code{0b r000 000t}, where r: RESET button held, t: STOP button held) \\ +-49 & RO & System Flags A (\code{0b r000 000t}, where r: RESET button held, t: STOP button held) \\ -50..-52 & RO & Unused System Flags \\ -65..-68 & RO & Size of the Scratchpad Memory \\ -69 & WO & Counter Latch (\code{0b01}--Uptime, \code{0b10}--RTC) \\ -73..-80 & RO & System Uptime in nanoseconds (latched by -69) \\ -81..-88 & RO & RTC in nanoseconds (latched by -69) \\ -89 & RW & ROM Mapping \\ +-90 & RW & Power Management Flags (\code{0b P000 b0ca}), where P: CPU halted, b: the device is battery-operated, c: a battery is detected, a: the battery is charging \\ +-91 & RO & BMS Battery Percentage \\ +-92 & RO & BMS Battery Voltage multiplied by 10 \\ -1025..-2048 & RW & Reserved for the integrated peripherals \\ -4077..-20480 & $ \ast $ & See \ref{comm-mmio} \\ -65537..-131072 & RO & Contents in the mapped ROM diff --git a/doc/tvdos.tex b/doc/tvdos.tex index ae7918c..b446974 100644 --- a/doc/tvdos.tex +++ b/doc/tvdos.tex @@ -82,11 +82,17 @@ This chapter will only briefly list and describe the applications. \1\dossynopsis{edit}[file]{The interactive full-screen text editor.} \1\dossynopsis{encodeipf}[1/2 imagefile ipffile]{Encodes the given image file (.jpg, .png, .bmp, .tga) to the IPF format using the graphics hardware.} \1\dossynopsis{false}{Returns errorlevel 1 upon execution.} +\1\dossynopsis{geturl}[url]{Reads contents on the web address and store it to the disk. Requires Internet adapter.} \1\dossynopsis{hexdump}[file]{Prints out the contents of a file in hexadecimal view. Supports pipe.} \1\dossynopsis{less}[file]{Allows user to read the long text, even if they are wider and/or taller than the screen. Supports pipe.} +\1\dossynopsis{playmov}[file]{Plays tsvmmov-formatted video. Use /i flag for playback control.} +\1\dossynopsis{playmp2}[file]{Plays MP2 (MPEG-1 Audio Layer II) formatted audio. Use /i flag for playback control.} +\1\dossynopsis{playpcm}[file]{Plays raw PCM audio. Use /i flag for playback control.} +\1\dossynopsis{playwav}[file]{Plays linear PCM/ADPCM audio. Use /i flag for playback control.} \1\dossynopsis{printfile}[file]{Prints out the contents of a textfile with line numbers. Useful for making descriptive screenshots.} \1\dossynopsis{touch}[file]{Updates a file's modification date. New file will be created if the specified file does not exist.} \1\dossynopsis{true}{Returns errorlevel 0 upon execution.} +\1\dossynopsis{zfm}{Z File Manager. A two-panel graphical user interface to navigate the system using arrow keys. Hit Z to switch panels.} \end{outline}