HSDPA supporting file larger than 2GB

This commit is contained in:
minjaesong
2025-10-07 22:41:34 +09:00
parent 00e390d879
commit 769b6481da
5 changed files with 106 additions and 66 deletions

View File

@@ -117,8 +117,9 @@ for (let tapeIndex = 0; tapeIndex < 4; tapeIndex++) {
// Get file size - for HSDPA tapes, we don't know the size ahead of time
// So we return a very large number to indicate it's available
// Using Number.MAX_SAFE_INTEGER to support files >2GB
driver.getFileLen = (fd) => {
return 0x7FFFFFFF // Return max positive 32-bit integer
return Number.MAX_SAFE_INTEGER // 2^53 - 1 (9007199254740991) - safe for JS arithmetic
}
// Sequential read from tape

View File

@@ -548,11 +548,20 @@ function tryReadNextTAVHeader() {
offsetBytes.push(seqread.readOneByte())
}
element.offset = 0
for (let j = 0; j < 6; j++) {
element.offset |= (offsetBytes[j] << (j * 8))
// Split into low 32 bits and high 16 bits
let low32 = 0
for (let j = 0; j < 4; j++) {
low32 |= (offsetBytes[j] << (j * 8))
}
let high16 = 0
for (let j = 4; j < 6; j++) {
high16 |= (offsetBytes[j] << ((j - 4) * 8))
}
// Combine using multiplication (avoids bitwise 32-bit limit)
element.offset = (high16 * 0x100000000) + (low32 >>> 0)
serial.println(`Element ${i + 1}: ${element.name} -> offset ${element.offset} (internal)`)
} else {
serial.println(`Error: Unknown addressing mode: ${element.addressingMode}`)
@@ -585,6 +594,7 @@ function tryReadNextTAVHeader() {
}
let lastKey = 0
let skipped = false
// Playback loop - properly adapted from TEV with multi-file support
try {
@@ -614,6 +624,7 @@ try {
akku = FRAME_TIME
akku2 = 0.0
audio.purgeQueue(0)
skipped = true
}
}
else if (keyCode == 20 && cueElements.length > 0) { // Down arrow - next cue
@@ -627,6 +638,7 @@ try {
akku = FRAME_TIME
akku2 = 0.0
audio.purgeQueue(0)
skipped = true
}
}
}
@@ -652,6 +664,11 @@ try {
FRAME_TIME = 1.0 / header.fps
audio.purgeQueue(0)
currentFileIndex++
if (skipped) {
skipped = false
} else {
currentCueIndex++
}
totalFilesProcessed++
console.log(`\nStarting file ${currentFileIndex}:`)
@@ -834,7 +851,6 @@ try {
notifHidden = true
}
con.color_pair(253, 0)
let guiStatus = {
fps: header.fps,
@@ -845,8 +861,8 @@ try {
qCo: decoderDbgInfo.qCo,
qCg: decoderDbgInfo.qCg,
akku: akku2,
fileName: fullFilePathStr,
fileOrd: currentFileIndex,
fileName: (cueElements.length > 0) ? `${cueElements[currentCueIndex].name}` : fullFilePathStr,
fileOrd: (cueElements.length > 0) ? currentCueIndex+1 : currentFileIndex,
resolution: `${header.width}x${header.height}${(isInterlaced) ? 'i' : ''}`,
colourSpace: header.version % 2 == 0 ? "ICtCp" : "YCoCg",
currentStatus: 1

View File

@@ -203,7 +203,7 @@ function skip(n0) {
let n = n0
while (n > 0) {
let skiplen = Math.min(n, 16777215)
serial.println(`skip ${skiplen}; remaining: ${n}`)
// serial.println(`skip ${skiplen}; remaining: ${n}`)
hsdpaSkip(skiplen)
n -= skiplen
}
@@ -237,14 +237,23 @@ function isReady() {
}
function seek(position) {
if (position < 0) {
throw Error("seek: position must be non-negative")
}
let relPos = position - readCount
if (position == 0) {
return
} else if (position > 0) {
skip(relPos)
if (relPos == 0) {
return // Already at target position
} else if (relPos < 0) {
// Seeking backward - must rewind and skip forward
hsdpaRewind() // This resets readCount to 0
if (position > 0) {
skip(position)
}
} else {
hsdpaRewind()
skip(position)
// Seeking forward - skip the difference
skip(relPos)
}
}