add crude encoding of PSN chunks

This commit is contained in:
2024-12-19 18:28:12 -06:00
parent 03ec5a4019
commit e3bbb970be
17 changed files with 213 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package encoders
import "encoding/binary"
func EncodeChunk(id uint16, chunkData []byte, hasSubchunks bool) []byte {
header := []byte{}
header = binary.LittleEndian.AppendUint16(header, id)
hasSubchunksBit := 0
if hasSubchunks {
hasSubchunksBit = 1
}
hasSubchunksBit = hasSubchunksBit << 15
header = binary.LittleEndian.AppendUint16(header, uint16(len(chunkData)+hasSubchunksBit))
bytes := header
bytes = append(bytes, chunkData...)
return bytes
}