full prototype

This commit is contained in:
Kistaro Windrider 2023-12-09 21:00:02 -08:00
parent e3443d57f5
commit 3bd611feab
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"log"
"os"
)
type RGBA struct {
@ -106,7 +107,11 @@ func (o OBJPal) Bytes(indexchar byte) [18]byte {
return ret
}
func MustParseOBJPal {
func MustParseOBJPal(strs []string) OBJPal {
if len(strs) == 4 {
log.Info("Discarding index 0 of OBJ pal")
strs = strs[1:]
}
if len(strs) != 3 {
log.Fatalf("MustParseObjPal requires length 3, got %d", len(strs))
}
@ -140,3 +145,23 @@ func (a APGBPal) Bytes() [56]byte {
return ret
}
func main() {
f, err := os.OpenFile("test.pal", O_WRONLY|O_CREATE|O_EXCL, 0644)
if err != nil {
log.Fatalf("can't create test.pal: %v", err)
}
aUpPal := APGBPal {
BG: MustParseBGPal([]string{"ffffff", "ff8484", "943a3a", "000000"}),
OBJ0: MustParseObjPal([]string{"7bff31", "008400", "000000"}),
OBJ1: MustParseObjPal([]string{"63a5ff", "0000ff", "000000"}),
}
n, err := f.Write(aUpPal.Bytes()[:])
if err != nil {
log.Fatalf("can't save test.pal: %v", err)
}
if n != 56 {
log.Fatalf("unexpected write length: %d", n)
}
f.Close()
os.Exit(0)
}