mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
revived unicode print function
This commit is contained in:
@@ -1366,12 +1366,12 @@ unicode.getUniprint = (c) => {
|
||||
return unicode.uniprint[k]
|
||||
}}
|
||||
|
||||
print = function(str) {
|
||||
unicode.print = (str) => {
|
||||
if ((typeof str === 'string' || str instanceof String) && str.length > 0) {
|
||||
|
||||
let cp = unicode.utf8toCodepoints(str)
|
||||
cp.forEach(c => {
|
||||
let q = unicode.getUniprint(c)
|
||||
|
||||
if (q == undefined || !q[0](c)) {
|
||||
con.addch(4)
|
||||
con.curs_right()
|
||||
@@ -1381,6 +1381,13 @@ print = function(str) {
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
sys.print(str)
|
||||
}
|
||||
}
|
||||
|
||||
unicode.println = (str) => {
|
||||
unicode.print(str+'\n\n')
|
||||
}
|
||||
|
||||
Object.freeze(unicode);
|
||||
|
||||
@@ -103,6 +103,7 @@ graphics.setPalette(0, 0, 0, 0, 9)
|
||||
|
||||
|
||||
function processSubtitlePacket(packetSize) {
|
||||
|
||||
// Read subtitle packet data according to SSF format
|
||||
// uint24 index + uint8 opcode + variable arguments
|
||||
|
||||
@@ -168,11 +169,14 @@ function processSubtitlePacket(packetSize) {
|
||||
// Font upload - read payload length and font data
|
||||
if (remainingBytes >= 3) { // uint16 length + at least 1 byte data
|
||||
let payloadLen = seqread.readShort()
|
||||
|
||||
serial.println(`Uploading ${(opcode == SSF_OP_UPLOAD_LOW_FONT) ? 'low' : 'high'} font rom (${payloadLen} bytes)`)
|
||||
|
||||
if (remainingBytes >= payloadLen + 2) {
|
||||
let fontData = seqread.readBytes(payloadLen)
|
||||
|
||||
// upload font data
|
||||
for (let i = 0; i < Math.min(payloadLen, 1920); i++) sys.poke(-1300607 - i, sys.peek(fontData + i))
|
||||
for (let i = 0; i < Math.min(payloadLen, 1920); i++) sys.poke(-133121 - i, sys.peek(fontData + i))
|
||||
sys.poke(-1299460, (opcode == SSF_OP_UPLOAD_LOW_FONT) ? 18 : 19)
|
||||
|
||||
sys.free(fontData)
|
||||
@@ -571,6 +575,8 @@ try {
|
||||
// Read packet header
|
||||
var packetType = seqread.readOneByte()
|
||||
|
||||
// serial.println(`Packet ${packetType} at offset ${seqread.getReadCount() - 1}`)
|
||||
|
||||
// Try to read next TAV file header
|
||||
if (packetType == TAV_FILE_HEADER_FIRST) {
|
||||
let nextHeader = tryReadNextTAVHeader()
|
||||
@@ -766,6 +772,9 @@ finally {
|
||||
} else {
|
||||
console.log(`Playback failed with error ${errorlevel}`)
|
||||
}
|
||||
|
||||
sys.poke(-1299460, 20)
|
||||
sys.poke(-1299460, 21)
|
||||
}
|
||||
|
||||
graphics.setPalette(0, 0, 0, 0, 0)
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
let status = 0
|
||||
let workarea = sys.malloc(1920)
|
||||
|
||||
// install LOCHRROM
|
||||
let hangulRomL = files.open("A:/tvdos/i18n/hang_lo.chr")
|
||||
if (!hangulRomL.exists) {
|
||||
printerrln("hang_lo.chr not found")
|
||||
sys.free(workarea)
|
||||
return status
|
||||
}
|
||||
//dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
|
||||
hangulRomL.pread(workarea, 1920, 0)
|
||||
for (let i = 0; i < 1920; i++) sys.poke(-1300607 - i, sys.peek(workarea + i))
|
||||
sys.poke(-1299460, 18)
|
||||
|
||||
|
||||
// install HICHRROM
|
||||
let hangulRomH = files.open("A:/tvdos/i18n/hang_hi.chr")
|
||||
if (!hangulRomH.exists) {
|
||||
printerrln("hang_hi.chr not found")
|
||||
sys.free(workarea)
|
||||
sys.poke(-1299460, 20) // clean up the crap
|
||||
return status
|
||||
}
|
||||
//dma.comToRam(filesystem._toPorts("A")[0], 0, workarea, 1920)
|
||||
hangulRomH.pread(workarea, 1920, 0)
|
||||
for (let i = 0; i < 1920; i++) sys.poke(-1300607 - i, sys.peek(workarea + i))
|
||||
sys.poke(-1299460, 19)
|
||||
|
||||
|
||||
|
||||
sys.free(workarea)
|
||||
|
||||
graphics.setHalfrowMode(true)
|
||||
/*
|
||||
* A character is defined as one of:
|
||||
* 1. [I,x] (Initial only)
|
||||
@@ -222,12 +188,5 @@ if (unicode.uniprint) {
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
println("조합한글 커널모듈이 로드되었습니다.")
|
||||
return 0
|
||||
}
|
||||
else {
|
||||
println("Failed to load Assembly Hangul kernel module: incompatible DOS version")
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,15 @@ function displayFormattedLine(line) {
|
||||
|
||||
let i = 0
|
||||
let inBoldOrItalic = false
|
||||
let buffer = "" // Accumulate characters for batch printing
|
||||
|
||||
// Helper function to flush the buffer
|
||||
function flushBuffer() {
|
||||
if (buffer.length > 0) {
|
||||
unicode.print(buffer)
|
||||
buffer = ""
|
||||
}
|
||||
}
|
||||
|
||||
// insert initial padding block
|
||||
con.color_pair(0, 255)
|
||||
@@ -68,27 +77,32 @@ function displayFormattedLine(line) {
|
||||
// Check for opening tags
|
||||
if (line.substring(i, i + 3).toLowerCase() === '<b>' ||
|
||||
line.substring(i, i + 3).toLowerCase() === '<i>') {
|
||||
flushBuffer() // Flush before color change
|
||||
con.color_pair(254, 0) // Switch to white for formatted text
|
||||
inBoldOrItalic = true
|
||||
i += 3
|
||||
} else if (i < line.length - 3 &&
|
||||
(line.substring(i, i + 4).toLowerCase() === '</b>' ||
|
||||
line.substring(i, i + 4).toLowerCase() === '</i>')) {
|
||||
flushBuffer() // Flush before color change
|
||||
con.color_pair(231, 0) // Switch back to yellow for normal text
|
||||
inBoldOrItalic = false
|
||||
i += 4
|
||||
} else {
|
||||
// Not a formatting tag, print the character
|
||||
print(line[i])
|
||||
// Not a formatting tag, add to buffer
|
||||
buffer += line[i]
|
||||
i++
|
||||
}
|
||||
} else {
|
||||
// Regular character, print it
|
||||
print(line[i])
|
||||
// Regular character, add to buffer
|
||||
buffer += line[i]
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// Flush any remaining buffered text
|
||||
flushBuffer()
|
||||
|
||||
// insert final padding block
|
||||
con.color_pair(0, 255)
|
||||
con.prnch(0xDD)
|
||||
|
||||
Reference in New Issue
Block a user