Showing 3 of 11 files from the diff.

@@ -19,6 +19,8 @@
Loading
19 19
20 20
package platform
21 21
22 +
import "flag"
23 +
22 24
func ConfigWithWindowSize(w, h int) Config {
23 25
	return func(internalPlatform) error {
24 26
		return nil
@@ -34,5 +36,7 @@
Loading
34 36
}
35 37
36 38
func Start(mainLoop func(Platform), configs ...Config) {
39 +
	flag.Set("text", "true")
40 +
	flag.Parse()
37 41
	tcellStart(mainLoop, configs...)
38 42
}

@@ -27,6 +27,12 @@
Loading
27 27
	"github.com/gdamore/tcell"
28 28
)
29 29
30 +
type drawEvent struct {
31 +
	buffer     *bytes.Buffer
32 +
	blink      bool
33 +
	bg, cx, cy int
34 +
}
35 +
30 36
var cgaPalette = [16]tcell.Color{
31 37
	tcell.ColorBlack,
32 38
	tcell.ColorNavy,
@@ -48,7 +54,11 @@
Loading
48 54
49 55
func (p *tcellPlatform) initializeTcellEvents() error {
50 56
	go func() {
57 +
		currentCX, currentCY := -1, -1
58 +
		currentMX, currentMY := 0, 0
59 +
		currentBG := -1
51 60
		s := p.screen
61 +
52 62
		for {
53 63
			ev := s.PollEvent()
54 64
			switch ev := ev.(type) {
@@ -64,44 +74,51 @@
Loading
64 74
				p.pushKeyEvent(ev)
65 75
			case *tcell.EventResize:
66 76
				s.Sync()
77 +
			case *tcell.EventMouse:
78 +
				p.Lock()
79 +
				if h := p.mouseHandler; h != nil {
80 +
					btn := ev.Buttons()
81 +
82 +
					var buttons byte
83 +
					if btn&tcell.Button1 != 0 {
84 +
						buttons = 2
85 +
					}
86 +
					if btn&tcell.Button3 != 0 {
87 +
						buttons |= 1
88 +
					}
89 +
90 +
					mx, my := ev.Position()
91 +
					h(buttons, int8(mx-currentMX)*4, int8(my-currentMY)*8)
92 +
					currentMX, currentMY = mx, my
93 +
				}
94 +
				p.Unlock()
67 95
			case *tcell.EventInterrupt:
68 -
				switch data := ev.Data().(type) {
69 -
				//case quitEvent:
70 -
				//close(p.quitChan)
71 -
				//return
72 -
				case *bytes.Buffer:
96 +
				if data, ok := ev.Data().(drawEvent); ok {
73 97
					p.Lock()
74 98
75 -
					/*
76 -
						if bg := m.colorCtrlReg & 0xF; bg != m.oldColorCtrlReg {
77 -
							m.oldColorCtrlReg = bg
78 -
							s.Fill(' ', tcell.StyleDefault.Background(cgaPalette[bg]))
79 -
						}
80 -
					*/
99 +
					if currentBG != data.bg {
100 +
						currentBG = data.bg
101 +
						s.Fill(' ', tcell.StyleDefault.Background(cgaPalette[data.bg&0xF]))
102 +
					}
81 103
104 +
					buf := data.buffer
82 105
					numColumns := 80
83 -
					if data.Len() < 80*25*2 {
106 +
					if buf.Len() < 80*25*2 {
84 107
						numColumns = 40
85 108
					}
86 109
87 -
					mem := data.Bytes()
110 +
					mem := buf.Bytes()
88 111
					for y := 0; y < 25; y++ {
89 112
						for x := 0; x < numColumns; x++ {
90 113
							offset := y*numColumns*2 + x*2
91 -
							s.SetCell(x, y, p.createStyleFromAttrib(mem[offset+1]), codePage437[mem[offset]])
114 +
							s.SetCell(x, y, p.createStyleFromAttrib(mem[offset+1], data.blink), codePage437[mem[offset]])
92 115
						}
93 116
					}
94 117
95 -
					/*
96 -
						if m.cursor.update {
97 -
							m.cursor.update = false
98 -
							if m.cursor.visible {
99 -
								s.ShowCursor(int(m.cursor.x), int(m.cursor.y))
100 -
							} else {
101 -
								s.HideCursor()
102 -
							}
103 -
						}
104 -
					*/
118 +
					if currentCX != data.cx || currentCY != data.cy {
119 +
						currentCX, currentCY = data.cx, data.cy
120 +
						s.ShowCursor(data.cx, data.cy)
121 +
					}
105 122
106 123
					s.Show()
107 124
					p.Unlock()
@@ -112,15 +129,14 @@
Loading
112 129
	return nil
113 130
}
114 131
115 -
func (p *tcellPlatform) createStyleFromAttrib(attr byte) tcell.Style {
116 -
	blinkEnabled := true //m.modeCtrlReg&0x20 != 0
132 +
func (p *tcellPlatform) createStyleFromAttrib(attr byte, blink bool) tcell.Style {
117 133
	blinkAttrib := attr&0x80 != 0
118 134
	bgColorIndex := (attr & 0x70) >> 4
119 135
120 -
	if blinkAttrib && !blinkEnabled {
136 +
	if blinkAttrib && !blink {
121 137
		bgColorIndex += 8
122 138
	}
123 -
	return tcell.StyleDefault.Blink(blinkEnabled && blinkAttrib).Background(cgaPalette[bgColorIndex]).Foreground(cgaPalette[attr&0xF])
139 +
	return tcell.StyleDefault.Blink(blink && blinkAttrib).Background(cgaPalette[bgColorIndex]).Foreground(cgaPalette[attr&0xF])
124 140
}
125 141
126 142
func (p *tcellPlatform) pushKeyEvent(ev *tcell.EventKey) {

@@ -19,6 +19,7 @@
Loading
19 19
20 20
import (
21 21
	"bytes"
22 +
	"flag"
22 23
	"log"
23 24
	"sync"
24 25
@@ -38,6 +39,10 @@
Loading
38 39
var tcellPlatformInstance tcellPlatform
39 40
40 41
func tcellStart(mainLoop func(Platform), configs ...Config) {
42 +
	// Default to max speed in CLI mode.
43 +
	flag.Set("mips", "0")
44 +
	flag.Parse()
45 +
41 46
	for _, cfg := range configs {
42 47
		if err := cfg(&tcellPlatformInstance); err != nil {
43 48
			log.Fatal(err)
@@ -59,8 +64,8 @@
Loading
59 64
	}
60 65
	defer s.Fini()
61 66
62 -
	s.ShowCursor(0, 0)
63 -
	s.DisableMouse()
67 +
	s.ShowCursor(-1, -1)
68 +
	s.EnableMouse()
64 69
	s.Clear()
65 70
66 71
	if err := tcellPlatformInstance.initializeTcellEvents(); err != nil {
@@ -73,15 +78,16 @@
Loading
73 78
	return false
74 79
}
75 80
76 -
func (p *tcellPlatform) RenderGraphics(VideoMode, []byte) {
81 +
func (p *tcellPlatform) RenderGraphics([]byte, byte, byte, byte) {
82 +
	// Not supported for the Tcell platform.
77 83
}
78 84
79 -
func (p *tcellPlatform) RenderText(mem []byte) {
85 +
func (p *tcellPlatform) RenderText(mem []byte, blink bool, bg, cx, cy int) {
80 86
	p.Lock()
81 87
	p.buffer.Reset()
82 88
	p.buffer.Write(mem)
83 89
	p.Unlock()
84 -
	p.screen.PostEvent(tcell.NewEventInterrupt(&p.buffer))
90 +
	p.screen.PostEvent(tcell.NewEventInterrupt(drawEvent{&p.buffer, blink, bg, cx, cy}))
85 91
}
86 92
87 93
func (p *tcellPlatform) SetTitle(title string) {
Files Coverage
emulator/processor/cpu 80.52%
platform 0.00%
Project Totals (7 files) 71.74%
247.1
TRAVIS_OS_NAME=linux
1.15.x=.15.x
247.3
TRAVIS_OS_NAME=windows
1.15.x=.15.x
247.2
TRAVIS_OS_NAME=osx
1.15.x=.15.x

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading