-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvideo.go
61 lines (48 loc) · 1.12 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
package main
import (
"github.com/nsf/termbox-go"
)
type Video struct {}
func (v *Video) Init() (error) {
return termbox.Init()
}
func (v *Video) Close() {
termbox.Close()
}
func GetColor(color Word) (termbox.Attribute) {
switch color {
case 0x0:
return termbox.ColorBlack
case 0x1:
return termbox.ColorBlue
case 0x2:
return termbox.ColorGreen
case 0x3:
return termbox.ColorCyan
case 0x4:
return termbox.ColorRed
case 0x5:
return termbox.ColorMagenta
case 0x6:
return termbox.ColorYellow
case 0x7:
return termbox.ColorWhite
}
return termbox.ColorDefault
}
func (v *Video) DrawScreen() {
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
i := 0
for y := 0; y < 16; y++ {
for x := 0; x < 32; x++ {
data := Memory[0x8000 + i]
character := rune(data & 0x7f)
colors := data >> 8
fg := GetColor(colors & 0xf)
bg := GetColor(colors >> 4)
termbox.SetCell(x, y, character, bg, fg)
i++
}
}
termbox.Flush()
}