File: _text_echo.tcl

package info (click to toggle)
openmsx 20.0%2Bdfsg-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,544 kB
  • sloc: cpp: 236,922; xml: 49,948; tcl: 15,056; python: 5,385; perl: 281; sh: 77; makefile: 53
file content (60 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (6)
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
# TODO: add a way to turn this off...

namespace eval text_echo {

set_help_text text_echo \
{Echoes all characters printed in text mode to stderr, meaning they will appear on the command line that openMSX was started from.
}

variable graph
variable escape
variable escape_count

proc text_echo {} {
	variable graph 0
	variable escape 0
	variable escape_count 0
	debug set_bp 0x0018 {[pc_in_slot 0 0]} {text_echo::print}
	debug set_bp 0x00A2 {[pc_in_slot 0 0]} {text_echo::print}
	return ""
}

proc print {} {
	variable graph
	variable escape
	variable escape_count

	set char [reg A]
	if {$graph} {
		#puts -nonewline stderr [format "\[G%x\]" $char]
		set graph 0
	} elseif {$escape} {
		#puts -nonewline stderr [format "\[E%x\]" $char]
		if {$escape_count == 0} {
			if {$char == 0x59} {
				set escape_count 2
			} else {
				set escape_count 1
			}
		} else {
			incr escape_count -1
			if {$escape_count == 0} {
				set escape 0
			}
		}
	} elseif {$char == 0x01} {
		set graph 1
	} elseif {$char == 0x1B} {
		set escape 1
	} elseif {$char == 0x0A || $char >= 0x20} {
		puts -nonewline stderr [format %c $char]
	} else {
		#puts -nonewline stderr [format "\[N%x\]" $char]
	}
}

namespace export text_echo

} ;# namespace text_echo

namespace import text_echo::*