-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
100 lines (88 loc) · 1.92 KB
/
main.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
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/pkg/profile"
)
func main() {
fmt.Printf("bbz - Acorn MOS for 6502 adaptation layer, https://github.com/ivanizag/bbz\n")
fmt.Printf("(tip: uppercase is usually needed)\n")
fmt.Printf("(press control-c twice to exit)\n\n")
traceCPU := flag.Bool(
"c",
false,
"dump to the console the CPU execution operations")
traceMOS := flag.Bool(
"m",
false,
"dump to the console the MOS calls excluding console I/O calls")
traceMOSFull := flag.Bool(
"M",
false,
"dump to the console the MOS calls including console I/O calls")
traceMemory := flag.Bool(
"s",
false,
"dump to the console the accesses to Fred, Jim or Sheila")
panicOnErr := flag.Bool(
"p",
false,
"panic on not implemented MOS calls")
rawline := flag.Bool(
"r",
false,
"disable readline like input with history")
profileEnable := flag.Bool(
"profile",
false,
"generate profile information",
)
roms := make([]*string, 16)
for i := 0; i < 16; i++ {
roms[i] = flag.String(
fmt.Sprintf("rom%v", i),
"",
fmt.Sprintf("filename for rom %v (slot 0x%x)", i, 15-i))
}
flag.Parse()
if *roms[0] == "" {
romFile := flag.Arg(0)
if romFile == "" {
def := "BASIC.ROM"
roms[0] = &def
} else {
roms[0] = &romFile
}
}
if *profileEnable {
// See the log with:
// go tool pprof --pdf ~/go/bin/izapple2sdl /tmp/profile329536248/cpu.pprof > profile.pdf
defer profile.Start().Stop()
}
env := newEnvironment(roms, *traceCPU,
(*traceMOS) || (*traceMOSFull),
*traceMOSFull,
*traceMemory,
*panicOnErr)
defer env.close()
handleControlC(env)
if *rawline {
env.con = newConsoleSimple(env)
} else {
env.con = newConsoleLiner(env)
}
RunMOS(env)
}
func handleControlC(env *environment) {
c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
for {
<-c
env.escape()
}
}()
}