-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCarmen Sandiego.tcl
103 lines (71 loc) · 1.56 KB
/
Carmen Sandiego.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
little_endian
# Where in the world is Carmen Sandiego GS Resource file.
# Presumably inspired by the MacOS Resource format.
# Resource types are 32-bit (4cc) and resource ids are 16-bit.
# Where in the USA uses a different format.
# header
uint32 "???"
uint32 "???"
uint32 "???"
uint32 "???"
uint32 "???"
uint32 "???"
uint32 "???"
uint32 "???"
set rCount [uint16 "Count"]
uint16 "???"
set Index {}
set Data {}
section "Resources" {
for { set i 0 } { $i < $rCount } { incr i } {
section "xxx" {
set name [ascii 4 "Type"]
set length [uint32 "Size"]
set offset [uint32 "Offset"]
set name [string reverse $name]
sectionname $name
lappend Index [list $name $offset $length]
}
}
}
section "Index" {
set Index [lsort -integer -index 1 $Index]
foreach e $Index {
set name [ lindex $e 0 ]
set offset [ lindex $e 1 ]
set length [ lindex $e 2 ]
goto $offset
section $name {
sectioncollapse
uint16 "???"
uint16 "???"
uint16 "???"
uint16 "???"
set count [uint16 "Count"]
uint16 "???"
for { set i 0 } { $i < $count } { incr i } {
set id [uint16 "ID"]
set length [uint16 "Size"]
uint16 "???"
set offset [uint32 "Offset"]
uint32 "Handle"
lappend Data [list $name $id $offset $length]
}
}
}
}
section "Data" {
set Data [lsort -integer -index 2 $Data]
foreach e $Data {
set name [ lindex $e 0 ]
set id [ lindex $e 1 ]
set offset [ lindex $e 2 ]
set length [ lindex $e 3 ]
goto $offset
section $name {
sectioncollapse
sectionvalue $id
bytes $length "Data"
}
}
}