-
Notifications
You must be signed in to change notification settings - Fork 0
/
errEmu.go
48 lines (41 loc) · 1.37 KB
/
errEmu.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
package segmago
import (
"fmt"
"os"
)
type errEmu struct {
terminal dbgTerminal
screen [256 * 240 * 4]byte
flipRequested bool
devMode bool
}
func (e *errEmu) InDevMode() bool { return e.devMode }
func (e *errEmu) SetDevMode(b bool) { e.devMode = b }
// NewErrEmu returns an emulator that only shows an error message
func NewErrEmu(msg string) Emulator {
emu := errEmu{}
emu.terminal = dbgTerminal{w: 256, h: 240, screen: emu.screen[:]}
os.Stderr.Write([]byte(msg + "\n"))
emu.terminal.newline()
emu.terminal.writeString(msg)
emu.flipRequested = true
return &emu
}
func (e *errEmu) IsPAL() bool { return false }
func (e *errEmu) GetCartRAM() []byte { return []byte{} }
func (e *errEmu) SetCartRAM([]byte) error { return nil }
func (e *errEmu) CartRAMModified() bool { return false }
func (e *errEmu) MakeSnapshot() []byte { return nil }
func (e *errEmu) LoadSnapshot([]byte) (Emulator, error) {
return nil, fmt.Errorf("snapshots not implemented for errEmu")
}
func (e *errEmu) ReadSoundBuffer(toFill []byte) {}
func (e *errEmu) GetSoundBufferUsed() int { return 0 }
func (e *errEmu) SetInput(input Input) {}
func (e *errEmu) Step() {}
func (e *errEmu) Framebuffer() []byte { return e.screen[:] }
func (e *errEmu) FlipRequested() bool {
result := e.flipRequested
e.flipRequested = false
return result
}