-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.pde
More file actions
99 lines (85 loc) · 2.33 KB
/
Copy pathLog.pde
File metadata and controls
99 lines (85 loc) · 2.33 KB
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
class Log {
PrintWriter log;
String logname;
boolean mode; // on (true) or off (false)
int lines;
int logfromaddr;
int pc;
int id;
// ********************************************************************
Log () {
this.id = 0;
this.construct("LogFile.txt");
}
Log (String lname) {
this.id = 0;
this.construct(lname);
}
void construct(String lname) {
this.logname = lname;
this.log = createWriter("data/Logs/" + lname); // Create a new file in the sketch directory
this.lines = 0;
this.logfromaddr = -2;
this.pc = -1;
this.logln("MEM : PCADDR : OPCODES : DISASM ; SZ-H-PNC ; PC |SP |B C |D E |H L |A F |I R |IX |IY ; Comment");
}
// ********************************************************************
void logModeON () {
this.mode = true;
this.logfromaddr = -2;
}
void logModeON (int addr) {
this.mode = false;
this.logfromaddr = addr;
}
void logModeOFF () {
this.mode = false;
}
boolean getLogMode () {
return this.mode;
}
void setPC (int tpc) {
this.pc = tpc;
this.mode |= (this.logfromaddr == this.pc);
}
// ********************************************************************
void logIt (String str, boolean ln) {
if (this.mode) { //if (this.mode == true)
this.isNextOneReq();
if (ln) {
this.log.println(str);
} else {
this.log.print(str);
}
this.lines++;
if ((this.lines % 10) == 0) {
this.logFlush();
}
}
}
void logln (String str) {
this.logIt(str, true);
}
void lognnl (String str) {
this.logIt(str, false);
}
void isNextOneReq () {
if (this.lines >= 1000000) {
this.logFlush();
this.logClose();
String fn = this.logname;
String[] nameext = split(fn, '.');
String[] namenb = split(nameext[0], '_');
this.id++;
this.logname = namenb[0] + "_" + str(this.id) + "." + nameext[1];
this.construct(this.logname);
}
}
// ********************************************************************
void logFlush () {
this.log.flush(); // Writes the remaining data to the file
}
void logClose () {
this.log.close(); // Writes the remaining data to the file
}
}