Skip to content

Commit

Permalink
more prefs chunk parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrust committed Jan 7, 2025
1 parent 3f0ba16 commit df2ad30
Show file tree
Hide file tree
Showing 3 changed files with 689 additions and 3 deletions.
25 changes: 22 additions & 3 deletions internal/chunks/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ var structData = map[string]ChunkData{
"PREF.ICTL": {handlePrefIctl, "IControl Preferences"},
"PREF.INPT": {handlePrefInpt, "Input Preferences"},
"PREF.KMSW": {handlePrefKmsw, "Keyboard/Mouse Preferences"},
"PREF.LCLE": {nil, "Locale Preferences"},
"PREF.PALT": {nil, "Palette Preferences"},
"PREF.LCLE": {handlePrefLcle, "Locale Preferences"},
"PREF.OSCN": {handlePrefOscn, "Overscan Preferences"},
"PREF.PALT": {handlePrefPalt, "Palette Preferences"},
"PREF.CMAP": {handleIlbmCmap, "Color Map"},
"PREF.NPTR": {nil, "Pointer Preferences"},
"PREF.PNTR": {handlePrefPntr, "Pointer Preferences"},
"PREF.NPTR": {handlePrefNptr, "New Pointer Preferences"}, // AROS specific
"PREF.PTXT": {nil, "Printer Preferences"},
"PREF.PUNT": {nil, "Printer Unit Preferences"},
"PREF.PDEV": {nil, "Printer Device Preferences"},
Expand Down Expand Up @@ -275,3 +277,20 @@ func getStringBuffer(data []byte, offset *uint32, bufLen uint32) (string, error)
*offset += bufLen
return result, nil
}

// getStringBuffer reads a string from the data at the given offset.
// The numer of bytes to read is given by bufLen. The offset is incremented
// by the bufLen.
// In case of an error, it returns "" and the error. The offset is unchanged.
func getByteBuffer(data []byte, offset *uint32, bufLen uint32) ([]byte, error) {
var result []byte

if len(data) < int(*offset+bufLen) {
return nil, fmt.Errorf("data too short for []byte")
}
high := int(*offset + bufLen)
result = data[*offset:high]

*offset += bufLen
return result, nil
}
File renamed without changes.
Loading

0 comments on commit df2ad30

Please sign in to comment.