fix remaining compilation errors

This commit is contained in:
Kistaro Windrider 2023-12-09 21:16:12 -08:00
parent d78344808a
commit 79dfe7b85d
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -30,7 +30,7 @@ func HexByteAt(str string, index int) (byte, error) {
return byte(big), nil
}
func ParseRGBA(str string) RGBA, error {
func ParseRGBA(str string) (RGBA, error) {
s := strings.TrimSpace(str)
s = strings.ToLower(s)
s, _ = strings.CutPrefix(s, "#")
@ -83,7 +83,8 @@ func MustParseBGPal(strs []string) BGPal {
}
var ret BGPal
for i := 0; i < 4; i++ {
ret[i], err := ParseRGBA(strs[i])
var err error
ret[i], err = ParseRGBA(strs[i])
if err != nil {
log.Fatalf("MustParseBGPal can't parse at %d: %v", i, err)
}
@ -120,7 +121,8 @@ func MustParseOBJPal(strs []string) OBJPal {
}
var ret OBJPal
for i := 0; i < 3; i++ {
ret[i], err := ParseRGBA(strs[i])
var err error
ret[i], err = ParseRGBA(strs[i])
if err != nil {
log.Fatalf("MustParseOBJPal can't parse at %d: %v", i, err)
}
@ -149,16 +151,20 @@ func (a APGBPal) Bytes() [56]byte {
}
func main() {
f, err := os.OpenFile("test.pal", O_WRONLY|O_CREATE|O_EXCL, 0644)
f, err := os.OpenFile(
"test.pal",
os.O_WRONLY|os.O_CREATE|os.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"}),
OBJ0: MustParseOBJPal([]string{"7bff31", "008400", "000000"}),
OBJ1: MustParseOBJPal([]string{"63a5ff", "0000ff", "000000"}),
}
n, err := f.Write(aUpPal.Bytes()[:])
palb := aUpPal.Bytes()
n, err := f.Write(palb[:])
if err != nil {
log.Fatalf("can't save test.pal: %v", err)
}