-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo.go
84 lines (72 loc) · 1.53 KB
/
video.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
package main
var VideoMonochrome bool = false
func VideoInstall(columns int, backgroundColor uint8) {
if VideoMonochrome {
backgroundColor = 0
}
IVideoSetMode(columns)
IVideoClrScr(backgroundColor)
}
func colorToBw(color byte) byte {
// This is inspired on the ZZT 2.0/3.0 algorithm, not the ZZT 3.1/3.2 algorithm.
// TODO: Super ZZT prefers the ZZT 3.1/3.2 algorithm.
// FIX: Special handling of blinking solids
if (color & 0x80) == 0x80 {
if ((color >> 4) & 0x07) == (color & 0x0F) {
color = color & 0x7F
}
}
if (color & 0x09) == 0x09 {
color = (color & 0xF0) | 0x0F
} else if (color & 0x07) != 0 {
color = (color & 0xF0) | 0x07
}
if (color & 0x0F) == 0x00 {
if (color & 0x70) == 0x00 {
color = (color & 0x8F)
} else {
color = (color & 0x8F) | 0x70
}
} else if (color & 0x70) != 0x70 {
color = (color & 0x8F)
}
return color
}
func VideoConfigure() bool {
WriteLn("")
Write(" Video mode: C)olor, M)onochrome? ")
for {
for {
if KeyPressed() {
break
}
Idle(IdleUntilFrame)
}
charTyped := UpCase(ReadKey())
switch charTyped {
case 'C':
VideoMonochrome = false
return true
case 'M':
VideoMonochrome = true
return true
case KEY_ESCAPE:
return false
}
}
}
func VideoClrScr() {
IVideoClrScr(0)
}
func VideoWriteText(x, y int16, color byte, text string) {
if VideoMonochrome {
color = colorToBw(color)
}
IVideoWriteText(x, y, color, text)
}
func VideoShowCursor() {
IVideoSetCursorVisible(true)
}
func VideoHideCursor() {
IVideoSetCursorVisible(false)
}