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
178
179
180
181
182
183
184
|
-
|
|
!
-
|
|
!
-
|
|
!
-
|
|
-
|
|
!
-
|
|
!
-
|
-
|
!
-
|
-
|
!
| #include "hspcmp.as"
#define global TYPE_MARK 0
#define global TYPE_VAR 1
#define global TYPE_STRING 2
#define global TYPE_DNUM 3
#define global TYPE_INUM 4
#define global TYPE_STRUCT 5
#define global TYPE_XLABEL 6
#define global TYPE_LABEL 7
#define global TYPE_INTCMD 8
#define global TYPE_EXTCMD 9
#define global TYPE_EXTSYSVAR 10
#define global TYPE_CMPCMD 11
#define global TYPE_MODCMD 12
#define global TYPE_INTFUNC 13
#define global TYPE_SYSVAR 14
#define global TYPE_PROGCMD 15
#define global TYPE_DLLFUNC 16
#define global TYPE_DLLCTRL 17
#define global TYPE_USERDEF 18
#module
#defcfunc get_cstr var buf, int offset
dupptr ret, varptr(buf) + offset, 1, 2
return ret
#defcfunc get_double var buf, int offset
dupptr ret, varptr(buf) + offset, 8, 3
return ret
#global
dialog "hsp;*.as", 16, "HSP スクリプト"
if stat == 0 : end
path = refstr
script_file_name = getpath(path, 8)
obj_path = "obj"
hsc_ini script_file_name
hsc_objname obj_path
hsc_comp 1, 0
if stat {
dialog "コンパイルエラー"
end
}
exist obj_path
if strsize < 0 {
dialog "オブジェクトファイルが存在しません"
end
}
sdim ax, strsize
bload obj_path, ax
if lpeek(ax) != 0x33505348 { dialog "不正なオブジェクトファイルです"
end
}
gosub *initialize
pt_cs = lpeek(ax, 16)
max_cs = lpeek(ax, 20)
pt_ds = lpeek(ax, 24)
max_ds = lpeek(ax, 28)
pt_ot = lpeek(ax, 32)
max_ot = lpeek(ax, 36)
dupptr cs, varptr(ax) + pt_cs, max_cs, 2
dupptr ds, varptr(ax) + pt_ds, max_ds, 2
dupptr ot, varptr(ax) + pt_ot, max_ot, 2
output = "位置\tタイプ\t\t値\t単項\t文頭\tカンマ\tif/elseの飛び先\t値の意味\n"
output += hr + "\n"
repeat max_cs
c = wpeek(cs, cnt)
size = 2
type = c & 0x1fff
ex0 = (c & 0x1000) != 0
ex1 = (c & 0x2000) != 0
ex2 = (c & 0x4000) != 0
if c & 0x8000 {
code = lpeek(cs, cnt + size)
size += 4
} else {
code = wpeek(cs, cnt + size)
size += 2
}
if type == TYPE_CMPCMD { skip_offset = wpeek(cs, cnt + size)
size += 2
}
output += str(cnt / 2) + "\t" output += typenames.type + "\t" output += str(code) + "\t" if ex0 : output += "yes\t" : else : output += "-\t" if ex1 : output += "yes\t" : else : output += "-\t" if ex2 : output += "yes\t" : else : output += "-\t" if type == TYPE_CMPCMD { output += str((cnt + size) / 2 + skip_offset) + "\t\t"
} else {
output += "-\t\t"
}
gosub *get_code_meaning
output += refstr
output += "\n"
continue cnt + size
loop
mesbox output, 640, 480
stop
*initialize
typenames = "TYPE_MARK", "TYPE_VAR", "TYPE_STRING", "TYPE_DNUM", "TYPE_INUM", "TYPE_STRUCT", "TYPE_XLABEL", "TYPE_LABEL", "TYPE_INTCMD", "TYPE_EXTCMD", "TYPE_EXTSYSVAR", "TYPE_CMPCMD", "TYPE_MODCMD", "TYPE_INTFUNC", "TYPE_SYSVAR", "TYPE_PROGCMD", "TYPE_DLLFUNC", "TYPE_DLLCTRL", "TYPE_USERDEF"
calccode_names = "CALCCODE_ADD", "CALCCODE_SUB", "CALCCODE_MUL", "CALCCODE_DIV", "CALCCODE_MOD", "CALCCODE_AND", "CALCCODE_OR", "CALCCODE_XOR", "CALCCODE_EQ", "CALCCODE_NE", "CALCCODE_GT", "CALCCODE_LT", "CALCCODE_GTEQ", "CALCCODE_LTEQ", "CALCCODE_RR", "CALCCODE_LR", "CALCCODE_MAX"
intcmd_names = "onexit", "onerror", "onkey", "onclick", "oncmd"
intcmd_names(0x11) = "exist", "delete", "mkdir", "chdir", "dirlist", "bload", "bsave", "bcopy", "memfile", "poke", "wpoke", "lpoke", "getstr", "chdpm", "memexpand", "memcpy", "memset", "notesel", "noteadd","notedel", "noteload", "notesave", "randomize", "noteunsel", "noteget", "split"
extcmd_names = "button", "chgdisp", "exec", "dialog"
extcmd_names(0x08) = "mmload", "mmplay", "mmstop", "mci","pset", "pget", "syscolor", "mes", "title", "pos", "circle", "cls", "font", "sysfont", "objsize", "picload", "color", "palcolor", "palette", "redraw", "width","gsel", "gcopy", "gzoom", "gmode", "bmpsave", "hsvcolor", "getkey", "listbox", "chkbox", "combox", "input", "mesbox", "buffer", "screen", "bgscr", "mouse", "objsel", "groll", "line", "clrobj", "boxf", "objprm", "objmode", "stick", "grect","grotate", "gsquare", "gradf", "objimage", "objskip", "objenable"
extsysver_names_0 = "mousex", "mousey", "mousew", "hwnd", "hinstance", "hdc"
extsysver_names_1 = "ginfo", "objinfo", "dirinfo", "sysinfo"
cmpcmd_names = "if", "else"
intfunc_names_0 = "int", "rnd", "strlen", "length", "length2", "length3", "length4", "vartype", "gettime", "peek", "wpeek", "lpeek", "varptr", "varuse", "noteinfo", "instr", "abs", "limit"
intfunc_names_1 = "str", "strmid", "", "strf", "getpath", "strtrim"
intfunc_names_2 = "sin", "cos", "tan", "atan", "sqrt", "double", "absf", "expf", "logf", "limitf"
sysvar_names = "system", "hspstat", "hspver", "stat", "cnt", "err", "strsize", "looplev", "sublev", "iparam", "wparam", "lparam", "refstr", "refdval", ""
progcmd_names = "goto", "gosub", "return", "break", "repeat", "loop", "continue", "wait", "await", "dim", "sdim", "foreach", "eachchk", "dimtype", "dup", "dupptr", "end", "stop", "newmod", "setmod", "delmod", "", "mref", "run", "exgoto", "on", "mcall", "assert", "logmes"
dllctrl_names_0 = "newcom", "querycom", "delcom", "cnvstow", "comres", "axobj", "winobj", "sendmsg", "comevent", "comevarg", "sarrayconv"
dllctrl_names_1 = "callfunc", "cnvwtos", "comevdisp", "libptr"
sdim hr, 101
memset hr, '-', 100
return
*get_code_meaning
switch type
case TYPE_MARK
if code <= length(calccode_names) {
return calccode_names.code
} else {
return strf("'%c'", code)
}
swbreak
case TYPE_STRING
return "\"" + get_cstr(ds, code) + "\""
case TYPE_DNUM
return str(get_double(ds, code))
case TYPE_LABEL
return str(lpeek(ot, code * 4))
case TYPE_INTCMD
return intcmd_names(code)
case TYPE_EXTCMD
return extcmd_names(code)
case TYPE_EXTSYSVAR
if code >= 0x100 : return extsysver_names_1(code - 0x100)
return extsysvar_names_0(code)
case TYPE_CMPCMD
return cmpcmd_names(code)
case TYPE_INTFUNC
if code >= 0x180 : return intfunc_names_2(code - 0x180)
if code >= 0x100 : return intfunc_names_1(code - 0x100)
return intfunc_names_0(code)
case TYPE_SYSVAR
return sysvar_names(code)
case TYPE_PROGCMD
return progcmd_names(code)
case TYPE_DLLCTRL
if code >= 0x100 : return dllctrl_names_1(code - 0x100)
return dllctrl_names(code)
swend
return str(code)
|