This file is indexed.

/usr/share/openmsx/scripts/info_panel.tcl is in openmsx-data 0.8.2-2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Shows an info panel similar to the blueMSX DIGIblue theme
#
# TODO:
# - make layout more flexible?
# - make sure it doesn't interfere with LEDs?

namespace eval info_panel {

variable info_panel_active false
variable textheight 15
variable panel_margin 2
variable sub_panel_height [expr {$textheight * 2 + $panel_margin}]
variable panel_info

proc info_panel_init {} {
	variable info_panel_active
	variable textheight
	variable panel_margin
	variable sub_panel_height
	variable panel_info

	set panel_info [dict create \
		software [dict create \
			title "Running software" width 400 row 0 \
			method guess_title] \
		mapper [dict create \
			title "Mapper type" width 170 row 0 \
			method {set val ""; catch {set val [openmsx_info romtype [lindex [machine_info device [guess_title]] 1]]}; set val}] \
		fps [dict create \
			title "FPS" width 38 row 1 \
			method {format "%2.1f" [openmsx_info fps]}] \
		screen [dict create \
			title "Screen" width 50 row 1 \
			method {get_screen_mode}] \
		vram [dict create \
			title "VRAM" width 42 row 1 \
			method {format "%dkB" [expr {[debug size "physical VRAM"] / 1024}]}] \
		ram [dict create \
			title "RAM" width 51 row 1 \
			method {set ramsize 0; foreach device [debug list] {set desc [debug desc $device]; if {$desc eq "memory mapper" || $desc eq "ram"} {incr ramsize [debug size $device]}}; format "%dkB" [expr {$ramsize / 1024}]}] \
		mtime [dict create \
			title "Time" width 60 row 1 \
			method {utils::get_machine_time}] \
		speed [dict create \
			title "Speed" width 48 row 1 \
			method {format "%d%%" [expr {round([get_actual_speed] * 100)}]}] \
		machine [dict create \
			title "Machine" width 250 row 1 \
			method {utils::get_machine_display_name}]]

	# calc width of software item
	set software_width 0
	dict for {name info} $panel_info {
		if {[dict get $info row] == 1} {
			incr software_width [dict get $info width]
			incr software_width $panel_margin
		} elseif {$name ne "software"} {
			incr software_width -[dict get $info width]
			incr software_width -$panel_margin
		}
	}
	incr software_width -$panel_margin
	dict set panel_info software width $software_width

	# set base element
	osd create rectangle info_panel \
		-x $panel_margin \
		-y [expr {-($sub_panel_height * 2 + (2 * $panel_margin))}] \
		-rely 1.0 \
		-alpha 0

	# create subpanels
	set curpos [dict create 0 0 1 0]
	dict for {name info} $panel_info {
		set row [dict get $info row]
		create_sub_panel $name \
		                 [dict get $info title] \
		                 [dict get $info width] \
		                 [dict get $info row] \
		                 [dict get $curpos $row]
		dict incr curpos $row [expr {[dict get $info width] + $panel_margin}]
	}
}

proc create_sub_panel {name title width row pos} {
	variable textheight
	variable panel_margin
	variable sub_panel_height

	osd create rectangle info_panel.$name \
		-x $pos \
		-y [expr {($sub_panel_height + $panel_margin) * $row}] \
		-h $sub_panel_height \
		-w $width \
		-rgba 0x00005080 \
		-clip true
	osd create text info_panel.$name.title \
		-x 2 \
		-y 0 \
		-rgba 0xddddffff \
		-text $title \
		-size [expr {int($textheight * 0.8)}]
	osd create text info_panel.$name.value \
		-x 2 \
		-y $textheight \
		-rgba 0xffffffff \
		-text $name \
		-size [expr {int($textheight * 0.9)}]
}

proc update_info_panel {} {
	variable info_panel_active
	variable panel_info

	if {!$info_panel_active} return

	dict for {name info} $panel_info {
		osd configure info_panel.$name.value -text [eval [dict get $info method]]
	}
	after realtime 1 [namespace code update_info_panel]
}

proc toggle_info_panel {} {
	variable info_panel_active

	if {$info_panel_active} {
		set info_panel_active false
		osd destroy info_panel
	} else {
		set info_panel_active true
		info_panel_init
		update_info_panel
	}
	return ""
}

## Stuff to calculate the actual speed (could be made public later)

# We keep two past data points (a data point consist out of a measured
# emutime and realtime). These two data points are at least 1 second
# apart in realtime.
variable last_emutime1  -1.0
variable last_realtime1 -1.0
variable last_emutime2   0.0
variable last_realtime2  0.0

proc get_actual_speed {} {
	variable last_emutime1
	variable last_emutime2
	variable last_realtime1
	variable last_realtime2

	set curr_emutime  [machine_info time]
	set curr_realtime [openmsx_info realtime]

	set diff_realtime [expr {$curr_realtime - $last_realtime2}]
	if {$diff_realtime > 1.0} {
		# Younger data point is old enough. Drop older data point and
		# make current measurement a new data point.
		set last_emutime   $last_emutime2
		set last_emutime1  $last_emutime2
		set last_emutime2  $curr_emutime
		set last_realtime1 $last_realtime2
		set last_realtime2 $curr_realtime
	} else {
		# Take older data point, don't change recorded data.
		set last_emutime  $last_emutime1
		set diff_realtime [expr {$curr_realtime - $last_realtime1}]
	}
	return [expr {($curr_emutime - $last_emutime) / $diff_realtime}]
}

namespace export toggle_info_panel

} ;# namespace info_panel

namespace import info_panel::*