/
config.go
150 lines (141 loc) · 3.35 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package console
import (
"flag"
)
type Config struct {
BorderWidth int
ConsoleWidth int
ConsoleHeight int
WindowWidth int
WindowHeight int
FPS int
Verbose bool
ScreenshotScale int
GifScale int
GifLength int
// private vars
palette *palette
consoleType ConsoleType
fontWidth int
fontHeight int
BgColor Color
FgColor Color
BorderColor Color
errColor Color
cursorColor Color
}
var optVerbose bool
var screenshotScale int
var gifScale int
var gifLength int
func init() {
flag.BoolVar(&optVerbose, "v", false, "verbose logging")
flag.IntVar(&screenshotScale, "screenshot_scale", 3, "scale of screenshots")
flag.IntVar(&gifScale, "gif_scale", 2, "scale of gif captures.")
flag.IntVar(&gifLength, "gif_len", 10, "set the maximum gif length in seconds (1..120)")
flag.Parse()
}
func NewConfig(consoleType ConsoleType) Config {
switch consoleType {
case PICO8:
return newPico8Config()
case TIC80:
return newTic80Config()
case ZX_SPECTRUM:
return newZXSpectrumConfig()
case CBM64:
return newCBM64Config()
}
return newPico8Config() // always default to PICO8
}
// Default configs for different console types
func newPico8Config() Config {
config := Config{
ConsoleWidth: 128,
ConsoleHeight: 128,
WindowWidth: 400,
WindowHeight: 400,
FPS: 60,
Verbose: optVerbose,
ScreenshotScale: screenshotScale,
GifScale: gifScale,
GifLength: gifLength,
consoleType: PICO8,
fontWidth: 4,
fontHeight: 8,
BgColor: PICO8_BLACK,
FgColor: PICO8_WHITE,
errColor: PICO8_PINK,
BorderColor: PICO8_BLACK,
cursorColor: PICO8_RED,
}
return config
}
func newTic80Config() Config {
config := Config{
ConsoleWidth: 240,
ConsoleHeight: 136,
WindowWidth: 480,
WindowHeight: 272,
FPS: 60,
Verbose: optVerbose,
ScreenshotScale: screenshotScale,
GifScale: gifScale,
GifLength: gifLength,
consoleType: TIC80,
fontWidth: 8,
fontHeight: 8,
BgColor: TIC80_BLACK,
FgColor: TIC80_WHITE,
errColor: TIC80_YELLOW,
BorderColor: TIC80_BLACK,
cursorColor: TIC80_RED,
}
return config
}
func newZXSpectrumConfig() Config {
config := Config{
BorderWidth: 25,
ConsoleWidth: 256,
ConsoleHeight: 192,
WindowWidth: 512,
WindowHeight: 384,
FPS: 60,
Verbose: optVerbose,
ScreenshotScale: screenshotScale,
GifScale: gifScale,
GifLength: gifLength,
consoleType: ZX_SPECTRUM,
fontWidth: 8,
fontHeight: 8,
BgColor: ZX_WHITE,
FgColor: ZX_BLACK,
errColor: ZX_BLUE,
BorderColor: ZX_WHITE,
cursorColor: ZX_RED,
}
return config
}
func newCBM64Config() Config {
config := Config{
BorderWidth: 25,
ConsoleWidth: 320,
ConsoleHeight: 200,
WindowWidth: 640,
WindowHeight: 400,
FPS: 60,
Verbose: optVerbose,
ScreenshotScale: screenshotScale,
GifScale: gifScale,
GifLength: gifLength,
consoleType: CBM64,
fontWidth: 8,
fontHeight: 8,
BgColor: C64_BLUE,
FgColor: C64_LIGHT_BLUE,
errColor: C64_WHITE,
BorderColor: C64_LIGHT_BLUE,
cursorColor: C64_LIGHT_BLUE,
}
return config
}