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

View File

@ -2,9 +2,9 @@ package main
import ( import (
"fmt" "fmt"
"strings"
"log" "log"
"os" "os"
"strings"
) )
type RGBA struct { type RGBA struct {
@ -15,11 +15,11 @@ type RGBA struct {
} }
func (c RGBA) Bytes() [4]byte { func (c RGBA) Bytes() [4]byte {
return [4]byte {c.R, c.G, cB, c.A} return [4]byte{c.R, c.G, cB, c.A}
} }
func HexByteAt(str string, index int) (byte, error) { func HexByteAt(str string, index int) (byte, error) {
if len(string) < index + 2 { if len(string) < index+2 {
return 0, fmt.Errorf("no hex byte at %d in too short string %q", index, str) return 0, fmt.Errorf("no hex byte at %d in too short string %q", index, str)
} }
big, err := strconv.ParseUint(str[index:index+1], 16, 8) big, err := strconv.ParseUint(str[index:index+1], 16, 8)
@ -67,7 +67,7 @@ func (b BGPal) Bytes() [20]byte {
for c := 0; c < 4; c++ { for c := 0; c < 4; c++ {
bb := b[c].Bytes() bb := b[c].Bytes()
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
ret[3+i+4*c]=bb[i] ret[3+i+4*c] = bb[i]
} }
} }
ret[19] = '\n' ret[19] = '\n'
@ -100,7 +100,7 @@ func (o OBJPal) Bytes(indexchar byte) [18]byte {
for c := 0; c < 3; c++ { for c := 0; c < 3; c++ {
oo := o[c].Bytes() oo := o[c].Bytes()
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
ret[5+i+4*c]=oo[i] ret[5+i+4*c] = oo[i]
} }
} }
ret[17] = '\n' ret[17] = '\n'
@ -150,7 +150,7 @@ func main() {
if err != nil { if err != nil {
log.Fatalf("can't create test.pal: %v", err) log.Fatalf("can't create test.pal: %v", err)
} }
aUpPal := APGBPal { aUpPal := APGBPal{
BG: MustParseBGPal([]string{"ffffff", "ff8484", "943a3a", "000000"}), BG: MustParseBGPal([]string{"ffffff", "ff8484", "943a3a", "000000"}),
OBJ0: MustParseObjPal([]string{"7bff31", "008400", "000000"}), OBJ0: MustParseObjPal([]string{"7bff31", "008400", "000000"}),
OBJ1: MustParseObjPal([]string{"63a5ff", "0000ff", "000000"}), OBJ1: MustParseObjPal([]string{"63a5ff", "0000ff", "000000"}),