Skip to content

Commit

Permalink
use serial buffer for initialization messages when uploading games (#…
Browse files Browse the repository at this point in the history
…2062)

fix upload not working - use serial buffer

Co-authored-by: fayd <[email protected]>
  • Loading branch information
recursiveforte and faisalsayed10 authored Aug 6, 2024
1 parent afa02a6 commit 9867c34
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,20 @@ export const getIsLegacySerial = async (
await writer.ready
await writer.write(new Uint8Array([ 0, 1, 2, 3, 4 ]).buffer)

// 128-char buffer
let serialBuffer = " ".repeat(128)

while (true) {
const { value, done } = await reader.read()

if (done) return null
logSerialOutput(value)

if (value.indexOf('found startup seq!') >= 0) return true
if (value.indexOf('legacy detected') >= 0) return false
serialBuffer = serialBuffer.concat(value)
serialBuffer = serialBuffer.slice(serialBuffer.length - 128, serialBuffer.length)

if (serialBuffer.indexOf('found startup seq!') >= 0) return true
if (serialBuffer.indexOf('legacy detected') >= 0) return false
}
}

Expand Down

0 comments on commit 9867c34

Please sign in to comment.