From e36d4041ce8ec00125ee98574d0674dcaa7c5186 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 7 Oct 2025 18:14:07 +0900 Subject: [PATCH] TAV: subtitle font handling --- assets/disk0/tvdos/bin/playtav.js | 8 ++++++-- assets/disk0/tvdos/include/playgui.mjs | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/assets/disk0/tvdos/bin/playtav.js b/assets/disk0/tvdos/bin/playtav.js index bc46651..66c1de6 100644 --- a/assets/disk0/tvdos/bin/playtav.js +++ b/assets/disk0/tvdos/bin/playtav.js @@ -76,6 +76,8 @@ let gui = require("playgui") let seqread = undefined let fullFilePathStr = fullFilePath.full +let fontUploaded = false + // Select seqread driver to use if (fullFilePathStr.startsWith('$:/TAPE') || fullFilePathStr.startsWith('$:\\TAPE')) { seqread = require("seqreadtape") @@ -133,7 +135,7 @@ function processSubtitlePacket(packetSize) { sys.free(textBytes) subtitleText = textStr subtitleVisible = true - gui.displaySubtitle(subtitleText, subtitlePosition) + gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition) } break } @@ -156,7 +158,7 @@ function processSubtitlePacket(packetSize) { // Re-display current subtitle at new position if visible if (subtitleVisible && subtitleText.length > 0) { gui.clearSubtitleArea() - gui.displaySubtitle(subtitleText, subtitlePosition) + gui.displaySubtitle(subtitleText, fontUploaded, subtitlePosition) } } } @@ -180,6 +182,8 @@ function processSubtitlePacket(packetSize) { sys.free(fontData) } + + fontUploaded = true } break } diff --git a/assets/disk0/tvdos/include/playgui.mjs b/assets/disk0/tvdos/include/playgui.mjs index 3e17b8f..a5e45a0 100644 --- a/assets/disk0/tvdos/include/playgui.mjs +++ b/assets/disk0/tvdos/include/playgui.mjs @@ -27,7 +27,7 @@ function getVisualLength(line) { return unicode.visualStrlen(withoutTags) } -function displayFormattedLine(line) { +function displayFormattedLine(line, useUnicode) { // Parse line and handle and tags with colour changes // Default subtitle colour: yellow (231), formatted text: white (254) @@ -38,7 +38,7 @@ function displayFormattedLine(line) { // Helper function to flush the buffer function flushBuffer() { if (buffer.length > 0) { - unicode.print(buffer) + useUnicode ? unicode.print(buffer) : print(buffer) buffer = "" } } @@ -85,7 +85,7 @@ function displayFormattedLine(line) { con.color_pair(231, 0) } -function displaySubtitle(text, position = 0) { +function displaySubtitle(text, useUnicode = false, position = 0) { if (!text || text.length === 0) { clearSubtitleArea() return @@ -156,7 +156,7 @@ function displaySubtitle(text, position = 0) { con.move(row, startCol) // Parse and display line with formatting tag support - displayFormattedLine(line) + displayFormattedLine(line, useUnicode) } con.color_pair(oldFgColour, oldBgColour)