-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.tcl
145 lines (119 loc) · 2.76 KB
/
compile.tcl
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
set fd [open "./blkfiles" "r"]
set blkfiles [read $fd]
#
# Wait for boot message "BOOT COMPLETED"
#
proc boot {} {
message "booting"
wait_boot call_forth83
}
proc wait_boot {{cmd ""}} {
if {[string first "BOOT COMPLETED" [get_screen]] >= 0} {
message "*match*"
$cmd
} elseif {$cmd != ""} {
after time 5 [list wait_boot $cmd]
}
}
#
# Get last message on terminal
#
proc get_last_line {} {
set nl2 [string last "\n" [get_screen]]
if {$nl2 < 0} {return ""}
set tmp [string range [get_screen] 0 [expr $nl2 - 1]]
set nl1 [string last "\n" $tmp]
if {$nl1 < 0} {return ""}
return [string range $tmp [expr $nl1 + 1] $nl2]
}
#
# Powered up version of type
#
proc _check_type {msg cmd} {
if {[string last $msg [get_last_line]] >= 0} {
message "*match*"
$cmd
} elseif {[llength $cmd] > 0} {
after time 5 [list _check_type "$msg" $cmd]
}
}
proc type! {str msg cmd} {
type "\b$str\r"
after time 5 [list _check_type "$msg" $cmd]
}
#
# Chain of reactions
#
proc call_forth83 {} {
message "Calling Forth83..."
type! "F83" "Version 2.1.0 Modified 01Jun84" open_blk_file
}
proc open_blk_file {} {
global blkfiles
set path [lindex $blkfiles 0]
set filename [string toupper [string range $path [expr {[string last "/" $path] + 1}] end]]
message "Opening $filename..."
type! "OPEN $filename" "OPEN $filename ok" compile
}
proc compile {} {
global blkfiles
set path [lindex $blkfiles 0]
set filename [string toupper [string range $path [expr {[string last "/" $path] + 1}] end]]
message "Compiling $filename..."
type! "OK" " ok" summarize
}
proc summarize {} {
global blkfiles
set blkfiles [lrange $blkfiles 1 end]
message "Done!"
if {[llength $blkfiles] > 0} {
open_blk_file
} else {
type "65 .debugc\r"
#save_system
}
}
proc save_system {} {
message "Writing F83MSX.COM..."
type! "SAVE-SYSTEM F83MSX.COM" "SAVE-SYSTEM F83MSX.COM ok" bye
}
proc bye {} {
message "Closing Forth83..."
type! "BYE" "Pages" replace_autoexec
}
proc replace_autoexec {} {
message "Replacing AUTOEXEC.BAT..."
type! "COPY AUTOEXEC.BA2 AUTOEXEC.BAT" "1 file copied" done
}
proc reset_speed {} {
global speed
message "value = $::wp_last_value"
#if {$::wp_last_value == 65} {
set speed 100
#}
}
proc done {} {
message "Finished!"
quit
}
#set renderer none
#machine C-BIOS_MSX2+
machine Sony_HB-F1XV
ext ram4mb
ext ide
set power off
diskmanipulator create hd.dsk 32M
hda hd.dsk
diskmanipulator import hda dsk/ [glob -type f dist/*.blk]
message "hd.dsk created"
set power on
# Speed up boot
set save_settings_on_exit off
set fullspeedwhenloading on
set speed 9999
# Debug
ext debugdevice
#set debugoutput stdout
debug set_watchpoint write_io {0x2f} {} {reset_speed}
message "Detecting boot..."
after time 10 boot