annotate scn2k/scn2kdump.cc @ 2:422f3cb3614b

Enabled voice playing with "%04d/%04d%05d.ogg" format. Don't use a cache for this
author thib
date Fri, 01 Aug 2008 19:17:15 +0000
parents 223b71206888
children 3a6aaeab7b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 *
223b71206888 Initial import
thib
parents:
diff changeset
3 * Copyright (C) 2002- Kazunori Ueno(JAGARL) <jagarl@creator.club.ne.jp>
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
223b71206888 Initial import
thib
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
223b71206888 Initial import
thib
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
223b71206888 Initial import
thib
parents:
diff changeset
8 * (at your option) any later version.
223b71206888 Initial import
thib
parents:
diff changeset
9 *
223b71206888 Initial import
thib
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
223b71206888 Initial import
thib
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
223b71206888 Initial import
thib
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223b71206888 Initial import
thib
parents:
diff changeset
13 * GNU General Public License for more details.
223b71206888 Initial import
thib
parents:
diff changeset
14 *
223b71206888 Initial import
thib
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
223b71206888 Initial import
thib
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
223b71206888 Initial import
thib
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
223b71206888 Initial import
thib
parents:
diff changeset
18 *
223b71206888 Initial import
thib
parents:
diff changeset
19 */
223b71206888 Initial import
thib
parents:
diff changeset
20
223b71206888 Initial import
thib
parents:
diff changeset
21 #include<stdlib.h>
223b71206888 Initial import
thib
parents:
diff changeset
22 #include<stdarg.h>
223b71206888 Initial import
thib
parents:
diff changeset
23 #include<stdio.h>
223b71206888 Initial import
thib
parents:
diff changeset
24 #include<string.h>
223b71206888 Initial import
thib
parents:
diff changeset
25 #include<string>
223b71206888 Initial import
thib
parents:
diff changeset
26 #include<vector>
223b71206888 Initial import
thib
parents:
diff changeset
27 #include<map>
223b71206888 Initial import
thib
parents:
diff changeset
28
223b71206888 Initial import
thib
parents:
diff changeset
29 using namespace std;
223b71206888 Initial import
thib
parents:
diff changeset
30
223b71206888 Initial import
thib
parents:
diff changeset
31 #include"system/file.h"
223b71206888 Initial import
thib
parents:
diff changeset
32 #include"system/file_impl.h"
223b71206888 Initial import
thib
parents:
diff changeset
33
223b71206888 Initial import
thib
parents:
diff changeset
34 /* 注意点: @@@ で表記 */
223b71206888 Initial import
thib
parents:
diff changeset
35
223b71206888 Initial import
thib
parents:
diff changeset
36 struct VarInfo {
223b71206888 Initial import
thib
parents:
diff changeset
37 #define TYPE_VARSTR 18
223b71206888 Initial import
thib
parents:
diff changeset
38 #define TYPE_VARMAX 7
223b71206888 Initial import
thib
parents:
diff changeset
39 #define TYPE_STR 58
223b71206888 Initial import
thib
parents:
diff changeset
40 #define TYPE_VAL 68
223b71206888 Initial import
thib
parents:
diff changeset
41 #define TYPE_SYS 0xc8
223b71206888 Initial import
thib
parents:
diff changeset
42 int type;
223b71206888 Initial import
thib
parents:
diff changeset
43 int number;
223b71206888 Initial import
thib
parents:
diff changeset
44 int value;
223b71206888 Initial import
thib
parents:
diff changeset
45 VarInfo() { type = TYPE_VAL; value = 0;}
223b71206888 Initial import
thib
parents:
diff changeset
46 VarInfo(int n) { type = TYPE_VAL; value = n;}
223b71206888 Initial import
thib
parents:
diff changeset
47 VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;}
223b71206888 Initial import
thib
parents:
diff changeset
48 };
223b71206888 Initial import
thib
parents:
diff changeset
49 class Flags {
223b71206888 Initial import
thib
parents:
diff changeset
50 /* flag:
223b71206888 Initial import
thib
parents:
diff changeset
51 ** type 0-5 : ローカル整数、各2000個
223b71206888 Initial import
thib
parents:
diff changeset
52 ** type 6, 25 : グローバル整数、2000個
223b71206888 Initial import
thib
parents:
diff changeset
53 ** type 12 : グローバル文字列、2000個 (今は無視しても良いが)
223b71206888 Initial import
thib
parents:
diff changeset
54 ** type 18 : ローカル文字列、2000個
223b71206888 Initial import
thib
parents:
diff changeset
55 ** type 25: システム変数(マウス座標など?) 1000 個?
223b71206888 Initial import
thib
parents:
diff changeset
56 ** type 26-32, 51 : 1-bit access to 0-6, 25
223b71206888 Initial import
thib
parents:
diff changeset
57 ** type 52-58, 77 : 2-bit access to 0-6, 25
223b71206888 Initial import
thib
parents:
diff changeset
58 ** type 78-84, 103 : 4-bit access to 0-6, 25
223b71206888 Initial import
thib
parents:
diff changeset
59 ** type 104-110, 129 : 8-bit access to 0-6, 25
223b71206888 Initial import
thib
parents:
diff changeset
60 */
223b71206888 Initial import
thib
parents:
diff changeset
61 typedef unsigned int uint;
223b71206888 Initial import
thib
parents:
diff changeset
62 int sys;
223b71206888 Initial import
thib
parents:
diff changeset
63 int var[8][2000];
223b71206888 Initial import
thib
parents:
diff changeset
64 string str[2000];
223b71206888 Initial import
thib
parents:
diff changeset
65 public:
223b71206888 Initial import
thib
parents:
diff changeset
66 int operator () () const;
223b71206888 Initial import
thib
parents:
diff changeset
67 int operator () (VarInfo info) const;
223b71206888 Initial import
thib
parents:
diff changeset
68 void Str(unsigned int number, char* buf, int sz) const;
223b71206888 Initial import
thib
parents:
diff changeset
69
223b71206888 Initial import
thib
parents:
diff changeset
70 bool IsInt(int type) const;
223b71206888 Initial import
thib
parents:
diff changeset
71 int MaxIndex(int type) const;
223b71206888 Initial import
thib
parents:
diff changeset
72
223b71206888 Initial import
thib
parents:
diff changeset
73 void Set(VarInfo info, int value);
223b71206888 Initial import
thib
parents:
diff changeset
74 int Get(int type, int number) const;
223b71206888 Initial import
thib
parents:
diff changeset
75 void SetSys(int value);
223b71206888 Initial import
thib
parents:
diff changeset
76 void SetStr(unsigned int number, string val);
223b71206888 Initial import
thib
parents:
diff changeset
77 };
223b71206888 Initial import
thib
parents:
diff changeset
78
223b71206888 Initial import
thib
parents:
diff changeset
79 bool Flags::IsInt(int type) const {
223b71206888 Initial import
thib
parents:
diff changeset
80 int v = type % 26;
223b71206888 Initial import
thib
parents:
diff changeset
81 return v >= 0 && v < 7 || v == 25;
223b71206888 Initial import
thib
parents:
diff changeset
82 }
223b71206888 Initial import
thib
parents:
diff changeset
83
223b71206888 Initial import
thib
parents:
diff changeset
84 int Flags::MaxIndex(int type) const {
223b71206888 Initial import
thib
parents:
diff changeset
85 switch (type / 26) {
223b71206888 Initial import
thib
parents:
diff changeset
86 case 1:
223b71206888 Initial import
thib
parents:
diff changeset
87 return 63999;
223b71206888 Initial import
thib
parents:
diff changeset
88 case 2:
223b71206888 Initial import
thib
parents:
diff changeset
89 return 31999;
223b71206888 Initial import
thib
parents:
diff changeset
90 case 3:
223b71206888 Initial import
thib
parents:
diff changeset
91 return 15999;
223b71206888 Initial import
thib
parents:
diff changeset
92 case 4:
223b71206888 Initial import
thib
parents:
diff changeset
93 return 7999;
223b71206888 Initial import
thib
parents:
diff changeset
94 default:
223b71206888 Initial import
thib
parents:
diff changeset
95 return 1999;
223b71206888 Initial import
thib
parents:
diff changeset
96 }
223b71206888 Initial import
thib
parents:
diff changeset
97 }
223b71206888 Initial import
thib
parents:
diff changeset
98
223b71206888 Initial import
thib
parents:
diff changeset
99 int Flags::operator()() const {
223b71206888 Initial import
thib
parents:
diff changeset
100 return rand() % 10000;
223b71206888 Initial import
thib
parents:
diff changeset
101 }
223b71206888 Initial import
thib
parents:
diff changeset
102 int Flags::operator() (VarInfo info) const {
223b71206888 Initial import
thib
parents:
diff changeset
103 return Get(info.type, info.number);
223b71206888 Initial import
thib
parents:
diff changeset
104 }
223b71206888 Initial import
thib
parents:
diff changeset
105 int Flags::Get(int type, int number) const {
223b71206888 Initial import
thib
parents:
diff changeset
106 int index = type % 26;
223b71206888 Initial import
thib
parents:
diff changeset
107 type /= 26;
223b71206888 Initial import
thib
parents:
diff changeset
108 if (index == 25) index = 7;
223b71206888 Initial import
thib
parents:
diff changeset
109 if (index > 7 || uint(type) > 4) return 0;
223b71206888 Initial import
thib
parents:
diff changeset
110 if (type == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
111 // A[]..G[], Z[] を直に読む
223b71206888 Initial import
thib
parents:
diff changeset
112 if (uint(number) >= 2000) return 0;
223b71206888 Initial import
thib
parents:
diff changeset
113 return var[index][number];
223b71206888 Initial import
thib
parents:
diff changeset
114 } else {
223b71206888 Initial import
thib
parents:
diff changeset
115 // Ab[]..G4b[], Z8b[] などを読む
223b71206888 Initial import
thib
parents:
diff changeset
116 int factor = 1 << (type - 1);
223b71206888 Initial import
thib
parents:
diff changeset
117 int eltsize = 32 / factor;
223b71206888 Initial import
thib
parents:
diff changeset
118 if (uint(number) >= (64000 / factor)) return 0;
223b71206888 Initial import
thib
parents:
diff changeset
119 return (var[index][number / eltsize] >> ((number % eltsize) * factor)) & ((1 << factor) - 1);
223b71206888 Initial import
thib
parents:
diff changeset
120 }
223b71206888 Initial import
thib
parents:
diff changeset
121 }
223b71206888 Initial import
thib
parents:
diff changeset
122
223b71206888 Initial import
thib
parents:
diff changeset
123 void Flags::Set(VarInfo info, int value) {
223b71206888 Initial import
thib
parents:
diff changeset
124 int type = info.type / 26;
223b71206888 Initial import
thib
parents:
diff changeset
125 int index = info.type % 26;
223b71206888 Initial import
thib
parents:
diff changeset
126 if (index == 25) index = 7;
223b71206888 Initial import
thib
parents:
diff changeset
127 if (type == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
128 // A[]..G[], Z[] を直に書く
223b71206888 Initial import
thib
parents:
diff changeset
129 if (uint(info.number) >= 2000) return;
223b71206888 Initial import
thib
parents:
diff changeset
130 var[index][info.number] = value;
223b71206888 Initial import
thib
parents:
diff changeset
131 } else {
223b71206888 Initial import
thib
parents:
diff changeset
132 // Ab[]..G4b[], Z8b[] などを書く
223b71206888 Initial import
thib
parents:
diff changeset
133 int factor = 1 << (type - 1);
223b71206888 Initial import
thib
parents:
diff changeset
134 int eltsize = 32 / factor;
223b71206888 Initial import
thib
parents:
diff changeset
135 int eltmask = (1 << factor) - 1;
223b71206888 Initial import
thib
parents:
diff changeset
136 int shift = (info.number % eltsize) * factor;
223b71206888 Initial import
thib
parents:
diff changeset
137 if (uint(info.number) >= (64000 / factor)) return;
223b71206888 Initial import
thib
parents:
diff changeset
138 var[index][info.number / eltsize] =
223b71206888 Initial import
thib
parents:
diff changeset
139 (var[index][info.number / eltsize] & ~(eltmask << shift))
223b71206888 Initial import
thib
parents:
diff changeset
140 | (value & eltmask) << shift;
223b71206888 Initial import
thib
parents:
diff changeset
141 }
223b71206888 Initial import
thib
parents:
diff changeset
142 }
223b71206888 Initial import
thib
parents:
diff changeset
143
223b71206888 Initial import
thib
parents:
diff changeset
144 void Flags::SetSys(int value) {
223b71206888 Initial import
thib
parents:
diff changeset
145 sys = value;
223b71206888 Initial import
thib
parents:
diff changeset
146 }
223b71206888 Initial import
thib
parents:
diff changeset
147 void Flags::SetStr(unsigned int number, string val) {
223b71206888 Initial import
thib
parents:
diff changeset
148 if (number >= 2000) return;
223b71206888 Initial import
thib
parents:
diff changeset
149 str[number] = val;
223b71206888 Initial import
thib
parents:
diff changeset
150 }
223b71206888 Initial import
thib
parents:
diff changeset
151 void Flags::Str(unsigned int number, char* buf, int sz) const {
223b71206888 Initial import
thib
parents:
diff changeset
152 if (number >= 2000) {if(sz>0) buf[0] = 0; return;}
223b71206888 Initial import
thib
parents:
diff changeset
153 const string& s = str[number];
223b71206888 Initial import
thib
parents:
diff changeset
154 int len = s.length();
223b71206888 Initial import
thib
parents:
diff changeset
155 if (sz-1 > len) sz = len;
223b71206888 Initial import
thib
parents:
diff changeset
156 s.copy(buf, sz, 0);
223b71206888 Initial import
thib
parents:
diff changeset
157 buf[sz] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
158 return;
223b71206888 Initial import
thib
parents:
diff changeset
159 }
223b71206888 Initial import
thib
parents:
diff changeset
160
223b71206888 Initial import
thib
parents:
diff changeset
161 /* commands */
223b71206888 Initial import
thib
parents:
diff changeset
162 enum Cmdtype { CMD_FLAGS, CMD_JMP, CMD_TEXT, CMD_OTHER};
223b71206888 Initial import
thib
parents:
diff changeset
163 class Cmd {
223b71206888 Initial import
thib
parents:
diff changeset
164 Cmdtype cmd_type;
223b71206888 Initial import
thib
parents:
diff changeset
165 int cmd1, cmd2, cmd3, cmd4;
223b71206888 Initial import
thib
parents:
diff changeset
166 int argc;
223b71206888 Initial import
thib
parents:
diff changeset
167 bool errorflag;
223b71206888 Initial import
thib
parents:
diff changeset
168 char cmdstr[1024];
223b71206888 Initial import
thib
parents:
diff changeset
169 const Flags& flags;
223b71206888 Initial import
thib
parents:
diff changeset
170 vector<VarInfo> args;
223b71206888 Initial import
thib
parents:
diff changeset
171
223b71206888 Initial import
thib
parents:
diff changeset
172 int GetArgs(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
173 int GetArgsSpecial(int normal_args,const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
174 void GetSelection(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
175 int GetSwitch(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
176 int GetSimpleSwitch(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
177 int GetExpression(const char*& d, struct VarInfo* info = 0);
223b71206888 Initial import
thib
parents:
diff changeset
178 int GetExpressionCond(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
179 int GetLeftToken(const char*& d, struct VarInfo& info);
223b71206888 Initial import
thib
parents:
diff changeset
180 static int GetString(const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
181 int StrVar(int number);
223b71206888 Initial import
thib
parents:
diff changeset
182 static char strtype[256];
223b71206888 Initial import
thib
parents:
diff changeset
183 static int StrType(const char* d) { return strtype[*(unsigned const char*)d];}
223b71206888 Initial import
thib
parents:
diff changeset
184 int AddStr(char* s) {
223b71206888 Initial import
thib
parents:
diff changeset
185 // 1-0a-0064 はこういうものが必要らしい
223b71206888 Initial import
thib
parents:
diff changeset
186 int start = strend;
223b71206888 Initial import
thib
parents:
diff changeset
187 while (*s) strheap[strend++] = *s++;
223b71206888 Initial import
thib
parents:
diff changeset
188 strheap[strend++] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
189 return start;
223b71206888 Initial import
thib
parents:
diff changeset
190 }
223b71206888 Initial import
thib
parents:
diff changeset
191 #define STRHEAP_SIZE 10000
223b71206888 Initial import
thib
parents:
diff changeset
192 static char strheap[STRHEAP_SIZE];
223b71206888 Initial import
thib
parents:
diff changeset
193 static int strend;
223b71206888 Initial import
thib
parents:
diff changeset
194 void SetError(void) { errorflag = true;}
223b71206888 Initial import
thib
parents:
diff changeset
195 static void ResetString(void) {
223b71206888 Initial import
thib
parents:
diff changeset
196 strend = 0;
223b71206888 Initial import
thib
parents:
diff changeset
197 }
223b71206888 Initial import
thib
parents:
diff changeset
198 static map<int, struct CmdDescrItem*> cmd_descr;
223b71206888 Initial import
thib
parents:
diff changeset
199 const char* CmdDescr(int cmd1, int cmd2, int cmd3, int cmd4);
223b71206888 Initial import
thib
parents:
diff changeset
200 public:
223b71206888 Initial import
thib
parents:
diff changeset
201 void GetCmd(Flags& f, const char*& d);
223b71206888 Initial import
thib
parents:
diff changeset
202 bool IsError() { return errorflag;}
223b71206888 Initial import
thib
parents:
diff changeset
203 bool ClearError() { errorflag = false;}
223b71206888 Initial import
thib
parents:
diff changeset
204 Cmd(const Flags& f) : flags(f) { argc = 0; errorflag = false; cmdstr[0] = 0;}
223b71206888 Initial import
thib
parents:
diff changeset
205
223b71206888 Initial import
thib
parents:
diff changeset
206 };
223b71206888 Initial import
thib
parents:
diff changeset
207
223b71206888 Initial import
thib
parents:
diff changeset
208 bool debug_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
209 void dprintf(const char* fmt, ...) {
223b71206888 Initial import
thib
parents:
diff changeset
210 if (debug_flag) {
223b71206888 Initial import
thib
parents:
diff changeset
211 va_list ap; va_start(ap, fmt);
223b71206888 Initial import
thib
parents:
diff changeset
212 vprintf(fmt, ap);
223b71206888 Initial import
thib
parents:
diff changeset
213 va_end(ap);
223b71206888 Initial import
thib
parents:
diff changeset
214 }
223b71206888 Initial import
thib
parents:
diff changeset
215 }
223b71206888 Initial import
thib
parents:
diff changeset
216
223b71206888 Initial import
thib
parents:
diff changeset
217
223b71206888 Initial import
thib
parents:
diff changeset
218 #define SCN_DUMP
223b71206888 Initial import
thib
parents:
diff changeset
219
223b71206888 Initial import
thib
parents:
diff changeset
220 int system_version = 0;
223b71206888 Initial import
thib
parents:
diff changeset
221 bool ruby_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
222 bool ret_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
223 bool text_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
224 bool selection_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
225 char Cmd::strheap[STRHEAP_SIZE];
223b71206888 Initial import
thib
parents:
diff changeset
226 int Cmd::strend = 0;
223b71206888 Initial import
thib
parents:
diff changeset
227
223b71206888 Initial import
thib
parents:
diff changeset
228 /* 数値 num := 0x24 0xff <int num> */
223b71206888 Initial import
thib
parents:
diff changeset
229 /* 変数 var := 0x24 <uchar type> 0x5b <exp> 0x5d */
223b71206888 Initial import
thib
parents:
diff changeset
230 /* 項 token := num | var | 0x28 <exp> 0x29 | <plus|minus> token */
223b71206888 Initial import
thib
parents:
diff changeset
231
223b71206888 Initial import
thib
parents:
diff changeset
232 int Cmd::GetLeftToken(const char*& d, VarInfo& info) {
223b71206888 Initial import
thib
parents:
diff changeset
233 bool var_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
234 int minus_flag = 0;
223b71206888 Initial import
thib
parents:
diff changeset
235 int value = 0;
223b71206888 Initial import
thib
parents:
diff changeset
236 if (d[0] == 0x5c && (d[1] == 1 || d[1] == 0) ) {
223b71206888 Initial import
thib
parents:
diff changeset
237 if (d[1] == 1) {dprintf("minus-"); minus_flag ^= 1;}
223b71206888 Initial import
thib
parents:
diff changeset
238 else dprintf("plus-");
223b71206888 Initial import
thib
parents:
diff changeset
239 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
240 var_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
241 }
223b71206888 Initial import
thib
parents:
diff changeset
242 if (d[0] == 0x24 && ((unsigned const char*)d)[1] == 0xff) {
223b71206888 Initial import
thib
parents:
diff changeset
243 // if ( (d[0] == 0x30 || d[0] == 0x31) && d[1] == 0x24 && ((unsigned const char*)d)[2] == 0xff) /* @@@ not supported; selection 内で、0x30|0x31 が付随することがある */
223b71206888 Initial import
thib
parents:
diff changeset
244 // numerical atom
223b71206888 Initial import
thib
parents:
diff changeset
245 d += 6;
223b71206888 Initial import
thib
parents:
diff changeset
246 value = read_little_endian_int(d-4);
223b71206888 Initial import
thib
parents:
diff changeset
247 dprintf("%d",value);
223b71206888 Initial import
thib
parents:
diff changeset
248 var_flag = false;
223b71206888 Initial import
thib
parents:
diff changeset
249 } else if (d[0] == 0x24 && *(unsigned char*)(d+1) == 0xc8) {
223b71206888 Initial import
thib
parents:
diff changeset
250 dprintf("V<sys>");
223b71206888 Initial import
thib
parents:
diff changeset
251 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
252 info.type = TYPE_SYS; info.number = 0;
223b71206888 Initial import
thib
parents:
diff changeset
253 value = info.value = flags();
223b71206888 Initial import
thib
parents:
diff changeset
254 } else if (d[0] == 0x24 && d[2] == 0x5b) {
223b71206888 Initial import
thib
parents:
diff changeset
255 // 0x24,<type>,0x5b,<expr>,0x5d-terminated term
223b71206888 Initial import
thib
parents:
diff changeset
256 info.type = *(unsigned char*)(d+1);
223b71206888 Initial import
thib
parents:
diff changeset
257 d += 3;
223b71206888 Initial import
thib
parents:
diff changeset
258 dprintf("V<%d>[",info.type);
223b71206888 Initial import
thib
parents:
diff changeset
259 info.number = GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
260 dprintf("]");
223b71206888 Initial import
thib
parents:
diff changeset
261 if (*d == 0x5d) d++;
223b71206888 Initial import
thib
parents:
diff changeset
262 else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
263 if (info.type == TYPE_VARSTR) {
223b71206888 Initial import
thib
parents:
diff changeset
264 value = 0;
223b71206888 Initial import
thib
parents:
diff changeset
265 info.value = StrVar(info.number);
223b71206888 Initial import
thib
parents:
diff changeset
266 } else {
223b71206888 Initial import
thib
parents:
diff changeset
267 value = info.value = flags(info);
223b71206888 Initial import
thib
parents:
diff changeset
268 }
223b71206888 Initial import
thib
parents:
diff changeset
269 dprintf("(=%d)",value);
223b71206888 Initial import
thib
parents:
diff changeset
270 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
271
223b71206888 Initial import
thib
parents:
diff changeset
272 if (minus_flag) value = -value;
223b71206888 Initial import
thib
parents:
diff changeset
273 if (!var_flag) {
223b71206888 Initial import
thib
parents:
diff changeset
274 info.type = TYPE_VAL;
223b71206888 Initial import
thib
parents:
diff changeset
275 info.value = value;
223b71206888 Initial import
thib
parents:
diff changeset
276 }
223b71206888 Initial import
thib
parents:
diff changeset
277 return value;
223b71206888 Initial import
thib
parents:
diff changeset
278 }
223b71206888 Initial import
thib
parents:
diff changeset
279
223b71206888 Initial import
thib
parents:
diff changeset
280 static char* op_str[70] = {
223b71206888 Initial import
thib
parents:
diff changeset
281 // 0 1 2 3 4 5 6 7 8 9
223b71206888 Initial import
thib
parents:
diff changeset
282 "+", "-", "*", "/", "%", "&", "|", "^", "<<", ">>", // +00
223b71206888 Initial import
thib
parents:
diff changeset
283 "err.","err.","err.","err.","err.","err.","err.","err.","err.","err.", // +10
223b71206888 Initial import
thib
parents:
diff changeset
284 "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", // +20
223b71206888 Initial import
thib
parents:
diff changeset
285 "=", "err.","err.","err.","err.","err.","err.","err.","err.","err.", // +30
223b71206888 Initial import
thib
parents:
diff changeset
286 "==", "!=", "<=", "<", ">=", ">", "err.","err.","err.","err.", // +40
223b71206888 Initial import
thib
parents:
diff changeset
287 "err.","err.","err.","err.","err.","err.","err.","err.","err.","err.", // +50
223b71206888 Initial import
thib
parents:
diff changeset
288 "&&", "||", "err.","err.","err.","err.","err.","err.","err.","err.", // +60
223b71206888 Initial import
thib
parents:
diff changeset
289 };
223b71206888 Initial import
thib
parents:
diff changeset
290
223b71206888 Initial import
thib
parents:
diff changeset
291 static int op_pri_tbl[12] = {
223b71206888 Initial import
thib
parents:
diff changeset
292 // + - * / % & | ^ << >>
223b71206888 Initial import
thib
parents:
diff changeset
293 1, 1, 0, 0, 0, 3, 5, 4, 2, 2, 10, 10};
223b71206888 Initial import
thib
parents:
diff changeset
294
223b71206888 Initial import
thib
parents:
diff changeset
295 inline int op_pri(int op) {
223b71206888 Initial import
thib
parents:
diff changeset
296 if (op > 11) return 10;
223b71206888 Initial import
thib
parents:
diff changeset
297 return op_pri_tbl[op];
223b71206888 Initial import
thib
parents:
diff changeset
298 }
223b71206888 Initial import
thib
parents:
diff changeset
299 inline int op_pri_cond(int op) {
223b71206888 Initial import
thib
parents:
diff changeset
300 if (op <= 11) return op_pri_tbl[op];
223b71206888 Initial import
thib
parents:
diff changeset
301 else if (op < 50) return 7;
223b71206888 Initial import
thib
parents:
diff changeset
302 else if (op == 60) return 8;
223b71206888 Initial import
thib
parents:
diff changeset
303 else if (op == 61) return 9;
223b71206888 Initial import
thib
parents:
diff changeset
304 else return 10;
223b71206888 Initial import
thib
parents:
diff changeset
305 }
223b71206888 Initial import
thib
parents:
diff changeset
306
223b71206888 Initial import
thib
parents:
diff changeset
307
223b71206888 Initial import
thib
parents:
diff changeset
308 inline int eval(int v1, int op, int v2) {
223b71206888 Initial import
thib
parents:
diff changeset
309 switch(op) {
223b71206888 Initial import
thib
parents:
diff changeset
310 case 0: return v1+v2;
223b71206888 Initial import
thib
parents:
diff changeset
311 case 1: return v1-v2;
223b71206888 Initial import
thib
parents:
diff changeset
312 case 2: return v1*v2;
223b71206888 Initial import
thib
parents:
diff changeset
313 case 3: return v2!=0 ? v1/v2 : v1;
223b71206888 Initial import
thib
parents:
diff changeset
314 case 4: return v2!=0 ? v1%v2 : v1;
223b71206888 Initial import
thib
parents:
diff changeset
315 case 5: return v1&v2;
223b71206888 Initial import
thib
parents:
diff changeset
316 case 6: return v1|v2;
223b71206888 Initial import
thib
parents:
diff changeset
317 case 7: return v1^v2;
223b71206888 Initial import
thib
parents:
diff changeset
318 case 8: return v1<<v2;
223b71206888 Initial import
thib
parents:
diff changeset
319 case 9: return v1>>v2;
223b71206888 Initial import
thib
parents:
diff changeset
320 case 40: return v1 == v2;
223b71206888 Initial import
thib
parents:
diff changeset
321 case 41: return v1 != v2;
223b71206888 Initial import
thib
parents:
diff changeset
322 case 42: return v1 <= v2;
223b71206888 Initial import
thib
parents:
diff changeset
323 case 43: return v1 < v2;
223b71206888 Initial import
thib
parents:
diff changeset
324 case 44: return v1 >= v2;
223b71206888 Initial import
thib
parents:
diff changeset
325 case 45: return v1 > v2;
223b71206888 Initial import
thib
parents:
diff changeset
326 case 60: return v1 && v2;
223b71206888 Initial import
thib
parents:
diff changeset
327 case 61: return v1 || v2;
223b71206888 Initial import
thib
parents:
diff changeset
328 }
223b71206888 Initial import
thib
parents:
diff changeset
329 return v2;
223b71206888 Initial import
thib
parents:
diff changeset
330 }
223b71206888 Initial import
thib
parents:
diff changeset
331
223b71206888 Initial import
thib
parents:
diff changeset
332 /* 演算子 op := 0x5c <uchar op> */
223b71206888 Initial import
thib
parents:
diff changeset
333 /* 数式 exp: [op] <token> [op <token> [...]] */
223b71206888 Initial import
thib
parents:
diff changeset
334 int Cmd::GetExpression(const char*& d, VarInfo* info_ptr) {
223b71206888 Initial import
thib
parents:
diff changeset
335 #define STACK_DEPTH 1024
223b71206888 Initial import
thib
parents:
diff changeset
336 #define OP_LB 11
223b71206888 Initial import
thib
parents:
diff changeset
337 char op_stack[STACK_DEPTH];
223b71206888 Initial import
thib
parents:
diff changeset
338 int val_stack[STACK_DEPTH];
223b71206888 Initial import
thib
parents:
diff changeset
339 int stack_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
340
223b71206888 Initial import
thib
parents:
diff changeset
341 // 第一項の読み込み
223b71206888 Initial import
thib
parents:
diff changeset
342 while(*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
343 d++;
223b71206888 Initial import
thib
parents:
diff changeset
344 dprintf("(");
223b71206888 Initial import
thib
parents:
diff changeset
345 op_stack[stack_count++] = OP_LB;
223b71206888 Initial import
thib
parents:
diff changeset
346 }
223b71206888 Initial import
thib
parents:
diff changeset
347 VarInfo info;
223b71206888 Initial import
thib
parents:
diff changeset
348 int value = GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
349
223b71206888 Initial import
thib
parents:
diff changeset
350 while(*d == 0x29 && stack_count > 0 && op_stack[stack_count-1] == OP_LB) {
223b71206888 Initial import
thib
parents:
diff changeset
351 d++;
223b71206888 Initial import
thib
parents:
diff changeset
352 dprintf(")");
223b71206888 Initial import
thib
parents:
diff changeset
353 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
354 }
223b71206888 Initial import
thib
parents:
diff changeset
355
223b71206888 Initial import
thib
parents:
diff changeset
356 if (*d != 0x5c && stack_count == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
357 if (info_ptr) *info_ptr = info;
223b71206888 Initial import
thib
parents:
diff changeset
358 return value; // 単純なleft-termはここで終了。有効なinfo_ptrを帰す(可能性がある)
223b71206888 Initial import
thib
parents:
diff changeset
359 }
223b71206888 Initial import
thib
parents:
diff changeset
360
223b71206888 Initial import
thib
parents:
diff changeset
361 while(*d == 0x5c) {
223b71206888 Initial import
thib
parents:
diff changeset
362 int op_type = *(unsigned char*)(d+1);
223b71206888 Initial import
thib
parents:
diff changeset
363 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
364 if (op_type < 70) dprintf("%s",op_str[op_type]);
223b71206888 Initial import
thib
parents:
diff changeset
365 else dprintf("err.");
223b71206888 Initial import
thib
parents:
diff changeset
366 if (op_type >= 10) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
367 int cur_pri = op_pri(op_type);
223b71206888 Initial import
thib
parents:
diff changeset
368 while(stack_count != 0 && op_pri(op_stack[stack_count-1]) <= cur_pri) {
223b71206888 Initial import
thib
parents:
diff changeset
369 // 優先順位の高い、先行する演算を行う
223b71206888 Initial import
thib
parents:
diff changeset
370 value = eval(val_stack[stack_count-1], op_stack[stack_count-1], value);
223b71206888 Initial import
thib
parents:
diff changeset
371 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
372 }
223b71206888 Initial import
thib
parents:
diff changeset
373 val_stack[stack_count] = value;
223b71206888 Initial import
thib
parents:
diff changeset
374 op_stack[stack_count++] = op_type;
223b71206888 Initial import
thib
parents:
diff changeset
375 while(*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
376 d++;
223b71206888 Initial import
thib
parents:
diff changeset
377 dprintf("(");
223b71206888 Initial import
thib
parents:
diff changeset
378 op_stack[stack_count++] = OP_LB;
223b71206888 Initial import
thib
parents:
diff changeset
379 }
223b71206888 Initial import
thib
parents:
diff changeset
380 if (stack_count >= STACK_DEPTH) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
381 value = GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
382
223b71206888 Initial import
thib
parents:
diff changeset
383 while (*d != 0x5c && stack_count > 0) {
223b71206888 Initial import
thib
parents:
diff changeset
384 // 未実行の演算を終わらせる
223b71206888 Initial import
thib
parents:
diff changeset
385 if (op_stack[stack_count-1] != OP_LB) {
223b71206888 Initial import
thib
parents:
diff changeset
386 value = eval(val_stack[stack_count-1], op_stack[stack_count-1], value);
223b71206888 Initial import
thib
parents:
diff changeset
387 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
388 } else if (*d == 0x29) { /* op_stack == OP_LB */
223b71206888 Initial import
thib
parents:
diff changeset
389 // bracket 終端があれば、閉じておく
223b71206888 Initial import
thib
parents:
diff changeset
390 d++;
223b71206888 Initial import
thib
parents:
diff changeset
391 dprintf(")");
223b71206888 Initial import
thib
parents:
diff changeset
392 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
393 } else break; // error
223b71206888 Initial import
thib
parents:
diff changeset
394 }
223b71206888 Initial import
thib
parents:
diff changeset
395 }
223b71206888 Initial import
thib
parents:
diff changeset
396 if (stack_count) SetError(); // unbalanced bracket
223b71206888 Initial import
thib
parents:
diff changeset
397 dprintf("(=%d)",value);
223b71206888 Initial import
thib
parents:
diff changeset
398 if (info_ptr) {
223b71206888 Initial import
thib
parents:
diff changeset
399 info_ptr->type = TYPE_VAL;
223b71206888 Initial import
thib
parents:
diff changeset
400 info_ptr->value = value;
223b71206888 Initial import
thib
parents:
diff changeset
401 }
223b71206888 Initial import
thib
parents:
diff changeset
402 return value;
223b71206888 Initial import
thib
parents:
diff changeset
403 }
223b71206888 Initial import
thib
parents:
diff changeset
404
223b71206888 Initial import
thib
parents:
diff changeset
405 // 条件分岐専用に、条件演算と算術演算の混合を検知できる専用ルーチン(本来はGetExpressionで差し支えない)
223b71206888 Initial import
thib
parents:
diff changeset
406 int Cmd::GetExpressionCond(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
407 char op_stack[STACK_DEPTH];
223b71206888 Initial import
thib
parents:
diff changeset
408 int val_stack[STACK_DEPTH];
223b71206888 Initial import
thib
parents:
diff changeset
409 int valattr_stack[STACK_DEPTH];
223b71206888 Initial import
thib
parents:
diff changeset
410 #define ATTR_VAL 0
223b71206888 Initial import
thib
parents:
diff changeset
411 #define ATTR_FLAG 1
223b71206888 Initial import
thib
parents:
diff changeset
412 int stack_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
413
223b71206888 Initial import
thib
parents:
diff changeset
414 // 第一項の読み込み
223b71206888 Initial import
thib
parents:
diff changeset
415 while(*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
416 d++;
223b71206888 Initial import
thib
parents:
diff changeset
417 dprintf("(");
223b71206888 Initial import
thib
parents:
diff changeset
418 op_stack[stack_count++] = OP_LB;
223b71206888 Initial import
thib
parents:
diff changeset
419 }
223b71206888 Initial import
thib
parents:
diff changeset
420 VarInfo info;
223b71206888 Initial import
thib
parents:
diff changeset
421 int value = GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
422 bool valattr = ATTR_VAL;
223b71206888 Initial import
thib
parents:
diff changeset
423
223b71206888 Initial import
thib
parents:
diff changeset
424 while(*d == 0x5c) {
223b71206888 Initial import
thib
parents:
diff changeset
425 int op_type = *(unsigned char*)(d+1);
223b71206888 Initial import
thib
parents:
diff changeset
426 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
427 if (op_type < 70) dprintf("%s",op_str[op_type]);
223b71206888 Initial import
thib
parents:
diff changeset
428 else dprintf("err.");
223b71206888 Initial import
thib
parents:
diff changeset
429 int cur_pri = op_pri_cond(op_type);
223b71206888 Initial import
thib
parents:
diff changeset
430 while(stack_count != 0 && op_pri_cond(op_stack[stack_count-1]) <= cur_pri) {
223b71206888 Initial import
thib
parents:
diff changeset
431 // 優先順位の高い、先行する演算を行う
223b71206888 Initial import
thib
parents:
diff changeset
432 if (op_stack[stack_count-1] >= 60) {
223b71206888 Initial import
thib
parents:
diff changeset
433 if (valattr_stack[stack_count-1] != ATTR_FLAG || valattr != ATTR_FLAG) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
434 } else {
223b71206888 Initial import
thib
parents:
diff changeset
435 if (valattr_stack[stack_count-1] != ATTR_VAL || valattr != ATTR_VAL) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
436 }
223b71206888 Initial import
thib
parents:
diff changeset
437 value = eval(val_stack[stack_count-1], op_stack[stack_count-1], value);
223b71206888 Initial import
thib
parents:
diff changeset
438 if (op_stack[stack_count-1] >= 40) valattr = ATTR_FLAG;
223b71206888 Initial import
thib
parents:
diff changeset
439 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
440 }
223b71206888 Initial import
thib
parents:
diff changeset
441 val_stack[stack_count] = value;
223b71206888 Initial import
thib
parents:
diff changeset
442 valattr_stack[stack_count] = valattr;
223b71206888 Initial import
thib
parents:
diff changeset
443 op_stack[stack_count++] = op_type;
223b71206888 Initial import
thib
parents:
diff changeset
444 while(*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
445 d++;
223b71206888 Initial import
thib
parents:
diff changeset
446 dprintf("(");
223b71206888 Initial import
thib
parents:
diff changeset
447 op_stack[stack_count++] = OP_LB;
223b71206888 Initial import
thib
parents:
diff changeset
448 }
223b71206888 Initial import
thib
parents:
diff changeset
449 if (stack_count >= STACK_DEPTH) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
450 value = GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
451 valattr = ATTR_VAL;
223b71206888 Initial import
thib
parents:
diff changeset
452
223b71206888 Initial import
thib
parents:
diff changeset
453 while (*d != 0x5c && stack_count > 0) {
223b71206888 Initial import
thib
parents:
diff changeset
454 // 未実行の演算を終わらせる
223b71206888 Initial import
thib
parents:
diff changeset
455 if (op_stack[stack_count-1] != OP_LB) {
223b71206888 Initial import
thib
parents:
diff changeset
456 if (op_stack[stack_count-1] >= 60) {
223b71206888 Initial import
thib
parents:
diff changeset
457 if (valattr_stack[stack_count-1] != ATTR_FLAG || valattr != ATTR_FLAG) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
458 } else {
223b71206888 Initial import
thib
parents:
diff changeset
459 if (valattr_stack[stack_count-1] != ATTR_VAL || valattr != ATTR_VAL) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
460 }
223b71206888 Initial import
thib
parents:
diff changeset
461 value = eval(val_stack[stack_count-1], op_stack[stack_count-1], value);
223b71206888 Initial import
thib
parents:
diff changeset
462 if (op_stack[stack_count-1] >= 40) valattr = ATTR_FLAG;
223b71206888 Initial import
thib
parents:
diff changeset
463 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
464 // bracket 終端があれば、閉じておく
223b71206888 Initial import
thib
parents:
diff changeset
465 } else if (*d == 0x29) { /* op_stack == OP_LB */
223b71206888 Initial import
thib
parents:
diff changeset
466 d++;
223b71206888 Initial import
thib
parents:
diff changeset
467 dprintf(")");
223b71206888 Initial import
thib
parents:
diff changeset
468 stack_count--;
223b71206888 Initial import
thib
parents:
diff changeset
469 } else break; // error
223b71206888 Initial import
thib
parents:
diff changeset
470 }
223b71206888 Initial import
thib
parents:
diff changeset
471 }
223b71206888 Initial import
thib
parents:
diff changeset
472 if (stack_count) SetError(); // unbalanced bracket
223b71206888 Initial import
thib
parents:
diff changeset
473 if (value) dprintf("(=true)");
223b71206888 Initial import
thib
parents:
diff changeset
474 else dprintf("(=false)");
223b71206888 Initial import
thib
parents:
diff changeset
475 return value;
223b71206888 Initial import
thib
parents:
diff changeset
476 }
223b71206888 Initial import
thib
parents:
diff changeset
477
223b71206888 Initial import
thib
parents:
diff changeset
478
223b71206888 Initial import
thib
parents:
diff changeset
479 /*
223b71206888 Initial import
thib
parents:
diff changeset
480 str =
223b71206888 Initial import
thib
parents:
diff changeset
481 arg =
223b71206888 Initial import
thib
parents:
diff changeset
482 args = 0x28 <exp> [[0x2c] <exp> [[0x2c] <exp> [...] ]]
223b71206888 Initial import
thib
parents:
diff changeset
483 */
223b71206888 Initial import
thib
parents:
diff changeset
484
223b71206888 Initial import
thib
parents:
diff changeset
485 int Cmd::GetArgs(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
486 if (*d != 0x28) return 0; /* 引数なし */
223b71206888 Initial import
thib
parents:
diff changeset
487 d++;
223b71206888 Initial import
thib
parents:
diff changeset
488 dprintf("args:");
223b71206888 Initial import
thib
parents:
diff changeset
489 VarInfo var;
223b71206888 Initial import
thib
parents:
diff changeset
490 int i; for (i=0; i<100 ; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
491 /* number, variable, string の種別なく値を得る */
223b71206888 Initial import
thib
parents:
diff changeset
492 if (*d == 0x61) { // よくわからない(智代アフター)
223b71206888 Initial import
thib
parents:
diff changeset
493 dprintf("@%d",d[1]);
223b71206888 Initial import
thib
parents:
diff changeset
494 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
495 if (*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
496 dprintf("{");
223b71206888 Initial import
thib
parents:
diff changeset
497 GetArgs(d); // (A,B,C)節が含まれることがある
223b71206888 Initial import
thib
parents:
diff changeset
498 dprintf("}");
223b71206888 Initial import
thib
parents:
diff changeset
499 } else {
223b71206888 Initial import
thib
parents:
diff changeset
500 dprintf("{}");
223b71206888 Initial import
thib
parents:
diff changeset
501 }
223b71206888 Initial import
thib
parents:
diff changeset
502 } else if (d[0] == 0x0a || d[0] == 0x40) { // よくわからない (Little Busters!)
223b71206888 Initial import
thib
parents:
diff changeset
503 int var;
223b71206888 Initial import
thib
parents:
diff changeset
504 if (system_version == 0) { var = read_little_endian_int(d+1); d += 5;}
223b71206888 Initial import
thib
parents:
diff changeset
505 else { var = read_little_endian_short(d+1); d += 3;}
223b71206888 Initial import
thib
parents:
diff changeset
506 dprintf("line %d; ",var);
223b71206888 Initial import
thib
parents:
diff changeset
507 } else if (*d == 0x24 || (*d == 0x5c && (d[1] == 1 || d[1] == 0)) || *d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
508 GetExpression(d, &var);
223b71206888 Initial import
thib
parents:
diff changeset
509 args.push_back(var);
223b71206888 Initial import
thib
parents:
diff changeset
510 } else if (StrType(d)) {
223b71206888 Initial import
thib
parents:
diff changeset
511 var.type = TYPE_STR;
223b71206888 Initial import
thib
parents:
diff changeset
512 var.value = GetString(d);
223b71206888 Initial import
thib
parents:
diff changeset
513 args.push_back(var);
223b71206888 Initial import
thib
parents:
diff changeset
514 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
515 if (*d == 0x29) break;
223b71206888 Initial import
thib
parents:
diff changeset
516 if (*d == 0x2c) {d++;} // 次の arg が演算子で始まる、などがなければ存在しない
223b71206888 Initial import
thib
parents:
diff changeset
517 dprintf(",");
223b71206888 Initial import
thib
parents:
diff changeset
518 }
223b71206888 Initial import
thib
parents:
diff changeset
519 if (*d == 0x29) d++;
223b71206888 Initial import
thib
parents:
diff changeset
520 else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
521 return i;
223b71206888 Initial import
thib
parents:
diff changeset
522 }
223b71206888 Initial import
thib
parents:
diff changeset
523
223b71206888 Initial import
thib
parents:
diff changeset
524 int Cmd::GetArgsSpecial(int normal_args,const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
525 if (*d != 0x28) return 0; /* 引数なし */
223b71206888 Initial import
thib
parents:
diff changeset
526 d++;
223b71206888 Initial import
thib
parents:
diff changeset
527 dprintf("args:");
223b71206888 Initial import
thib
parents:
diff changeset
528 int i; for (i=0; i<normal_args; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
529 /* number, variable, string の種別なく値を得る */
223b71206888 Initial import
thib
parents:
diff changeset
530 if (*d == 0x24 || (*d == 0x5c && (d[1] == 1 || d[1] == 0)) || *d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
531 GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
532 } else if (StrType(d)) {
223b71206888 Initial import
thib
parents:
diff changeset
533 GetString(d);
223b71206888 Initial import
thib
parents:
diff changeset
534 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
535 if (*d == 0x29) break;
223b71206888 Initial import
thib
parents:
diff changeset
536 if (*d == 0x2c) {d++;} // 次の arg が演算子で始まる、などがなければ存在しない
223b71206888 Initial import
thib
parents:
diff changeset
537 dprintf(",");
223b71206888 Initial import
thib
parents:
diff changeset
538 }
223b71206888 Initial import
thib
parents:
diff changeset
539 for (i=0; i<argc ; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
540 if (*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
541 /*
223b71206888 Initial import
thib
parents:
diff changeset
542 ** cmd 01-22:0c1c, 01-22:0835
223b71206888 Initial import
thib
parents:
diff changeset
543 ** Princess Bride のカードが落ちるアニメの場面
223b71206888 Initial import
thib
parents:
diff changeset
544 ** なお、_PBCARDANM* の画像はこのコマンドでのみ使われているので、特殊処理として無視することも可能
223b71206888 Initial import
thib
parents:
diff changeset
545 **
223b71206888 Initial import
thib
parents:
diff changeset
546 ** cmd 01-04:0276, 026c, 0270
223b71206888 Initial import
thib
parents:
diff changeset
547 ** 複数の enum が args の数だけ続く処理。特殊処理として分離する
223b71206888 Initial import
thib
parents:
diff changeset
548 */
223b71206888 Initial import
thib
parents:
diff changeset
549 dprintf("enum.<");
223b71206888 Initial import
thib
parents:
diff changeset
550 /* (...) は列挙型 or 構造体の可能性がある */
223b71206888 Initial import
thib
parents:
diff changeset
551 const char* d_orig = d;
223b71206888 Initial import
thib
parents:
diff changeset
552 int pt = args.size(); args.push_back(VarInfo(0));
223b71206888 Initial import
thib
parents:
diff changeset
553 int count = GetArgs(d);
223b71206888 Initial import
thib
parents:
diff changeset
554 args[pt] = VarInfo(count);
223b71206888 Initial import
thib
parents:
diff changeset
555 dprintf(">");
223b71206888 Initial import
thib
parents:
diff changeset
556 } else if (*d == 0x61 && (d[1] >= 0x00 && d[1] <= 0x04) && d[2] == 0x28 ) {
223b71206888 Initial import
thib
parents:
diff changeset
557 /* 使われるコマンドは 01-21:004b, 01-28:0064 のいずれか(R,C,PB,LO)
223b71206888 Initial import
thib
parents:
diff changeset
558 ** それらのコマンドは
223b71206888 Initial import
thib
parents:
diff changeset
559 ** arg1: 画像ファイル名
223b71206888 Initial import
thib
parents:
diff changeset
560 ** arg2 : Sel 番号
223b71206888 Initial import
thib
parents:
diff changeset
561 ** らしく、arg3 以降が 0x61 <00-04> (a,b,c,...) となる(ダンプ上は enum と表記される)
223b71206888 Initial import
thib
parents:
diff changeset
562 ** () 内の引数はさまざまで、a のみ(画像ファイル名)、
223b71206888 Initial import
thib
parents:
diff changeset
563 ** a,b b=SEL?
223b71206888 Initial import
thib
parents:
diff changeset
564 ** a,b,c (b,c)=座標?
223b71206888 Initial import
thib
parents:
diff changeset
565 ** a,(b,c,d,e,f,g) b-g = src / dest?
223b71206888 Initial import
thib
parents:
diff changeset
566 ** らしい
223b71206888 Initial import
thib
parents:
diff changeset
567 */
223b71206888 Initial import
thib
parents:
diff changeset
568 dprintf("kasane. #%d <",d[1]);
223b71206888 Initial import
thib
parents:
diff changeset
569 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
570 int pt = args.size(); args.push_back(VarInfo(0));
223b71206888 Initial import
thib
parents:
diff changeset
571 int count = GetArgs(d);
223b71206888 Initial import
thib
parents:
diff changeset
572 args[pt] = VarInfo(count);
223b71206888 Initial import
thib
parents:
diff changeset
573 dprintf(">");
223b71206888 Initial import
thib
parents:
diff changeset
574 } else if (*d == 0x24 || (*d == 0x5c && (d[1] == 1 || d[1] == 0))) {
223b71206888 Initial import
thib
parents:
diff changeset
575 /* cmd 01-15:0028 ; 始めに 0x24 節があり、続いて 0x28 節になる */
223b71206888 Initial import
thib
parents:
diff changeset
576 VarInfo var;
223b71206888 Initial import
thib
parents:
diff changeset
577 GetExpression(d, &var);
223b71206888 Initial import
thib
parents:
diff changeset
578 args.push_back(var);
223b71206888 Initial import
thib
parents:
diff changeset
579 i--; // この引数はargc の数には入らない
223b71206888 Initial import
thib
parents:
diff changeset
580 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
581 if (d[0] == 0x0a || d[0] == 0x40) {
223b71206888 Initial import
thib
parents:
diff changeset
582 /* cmd 01-15:0028 ; 0x28 節の後に毎回 0x0a 節が来る */
223b71206888 Initial import
thib
parents:
diff changeset
583 int var;
223b71206888 Initial import
thib
parents:
diff changeset
584 if (system_version == 0) { var = read_little_endian_int(d+1); d += 5;}
223b71206888 Initial import
thib
parents:
diff changeset
585 else { var = read_little_endian_short(d+1); d += 3;}
223b71206888 Initial import
thib
parents:
diff changeset
586 dprintf("line %d; ",var);
223b71206888 Initial import
thib
parents:
diff changeset
587 }
223b71206888 Initial import
thib
parents:
diff changeset
588 if (*d == 0x29) break;
223b71206888 Initial import
thib
parents:
diff changeset
589 if (*d == 0x2c) {d++;} // 次の arg が演算子で始まる、などがなければ存在しない
223b71206888 Initial import
thib
parents:
diff changeset
590 dprintf(",");
223b71206888 Initial import
thib
parents:
diff changeset
591 }
223b71206888 Initial import
thib
parents:
diff changeset
592 if (*d == 0x29) d++;
223b71206888 Initial import
thib
parents:
diff changeset
593 else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
594 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
595 }
223b71206888 Initial import
thib
parents:
diff changeset
596
223b71206888 Initial import
thib
parents:
diff changeset
597 /* switch
223b71206888 Initial import
thib
parents:
diff changeset
598 <exp>
223b71206888 Initial import
thib
parents:
diff changeset
599 0x7b
223b71206888 Initial import
thib
parents:
diff changeset
600 <exp> <int>
223b71206888 Initial import
thib
parents:
diff changeset
601 ...
223b71206888 Initial import
thib
parents:
diff changeset
602 0x7d
223b71206888 Initial import
thib
parents:
diff changeset
603 */
223b71206888 Initial import
thib
parents:
diff changeset
604
223b71206888 Initial import
thib
parents:
diff changeset
605 int Cmd::GetSwitch(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
606 if (*d != 0x28) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
607 d++;
223b71206888 Initial import
thib
parents:
diff changeset
608 dprintf("switch. ");
223b71206888 Initial import
thib
parents:
diff changeset
609 int var = GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
610 if (*d != 0x29) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
611 d++;
223b71206888 Initial import
thib
parents:
diff changeset
612 dprintf("->\n");
223b71206888 Initial import
thib
parents:
diff changeset
613 if (*d == 0x7b) {
223b71206888 Initial import
thib
parents:
diff changeset
614 d++;
223b71206888 Initial import
thib
parents:
diff changeset
615 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
616
223b71206888 Initial import
thib
parents:
diff changeset
617 int default_jmp = -1; int jmpto = -1;
223b71206888 Initial import
thib
parents:
diff changeset
618 int i; for (i=0; i<argc; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
619 dprintf("\t");
223b71206888 Initial import
thib
parents:
diff changeset
620 if (*d++ != 0x28) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
621 int item = -1; // default
223b71206888 Initial import
thib
parents:
diff changeset
622 if (*d != 0x29) {
223b71206888 Initial import
thib
parents:
diff changeset
623 int item = GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
624 if (*d++ != 0x29) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
625 int jmp = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
626 if (var == item) {
223b71206888 Initial import
thib
parents:
diff changeset
627 dprintf("(selected)");
223b71206888 Initial import
thib
parents:
diff changeset
628 jmpto = jmp;
223b71206888 Initial import
thib
parents:
diff changeset
629 }
223b71206888 Initial import
thib
parents:
diff changeset
630 dprintf(" -> %d\n", jmp);
223b71206888 Initial import
thib
parents:
diff changeset
631 } else {
223b71206888 Initial import
thib
parents:
diff changeset
632 d++;
223b71206888 Initial import
thib
parents:
diff changeset
633 default_jmp = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
634 }
223b71206888 Initial import
thib
parents:
diff changeset
635 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
636 }
223b71206888 Initial import
thib
parents:
diff changeset
637 if (default_jmp != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
638 dprintf("default -> %d\n",default_jmp);
223b71206888 Initial import
thib
parents:
diff changeset
639 if (jmpto == -1) jmpto = default_jmp;
223b71206888 Initial import
thib
parents:
diff changeset
640 }
223b71206888 Initial import
thib
parents:
diff changeset
641 if (*d == 0x7d) {
223b71206888 Initial import
thib
parents:
diff changeset
642 d++;
223b71206888 Initial import
thib
parents:
diff changeset
643 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
644 return jmpto;
223b71206888 Initial import
thib
parents:
diff changeset
645 }
223b71206888 Initial import
thib
parents:
diff changeset
646 /* simple switch
223b71206888 Initial import
thib
parents:
diff changeset
647 <exp>
223b71206888 Initial import
thib
parents:
diff changeset
648 0x7b
223b71206888 Initial import
thib
parents:
diff changeset
649 <int>
223b71206888 Initial import
thib
parents:
diff changeset
650 ...
223b71206888 Initial import
thib
parents:
diff changeset
651 0x7d
223b71206888 Initial import
thib
parents:
diff changeset
652 */
223b71206888 Initial import
thib
parents:
diff changeset
653 int Cmd::GetSimpleSwitch(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
654 if (*d != 0x28) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
655 d++;
223b71206888 Initial import
thib
parents:
diff changeset
656 dprintf("simple switch. ");
223b71206888 Initial import
thib
parents:
diff changeset
657 int var = GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
658 if (*d != 0x29) {SetError(); return -1;}
223b71206888 Initial import
thib
parents:
diff changeset
659 d++;
223b71206888 Initial import
thib
parents:
diff changeset
660 dprintf(" ->\n");
223b71206888 Initial import
thib
parents:
diff changeset
661 int jumpto = -1;
223b71206888 Initial import
thib
parents:
diff changeset
662 if (*d == 0x7b) {
223b71206888 Initial import
thib
parents:
diff changeset
663 d++;
223b71206888 Initial import
thib
parents:
diff changeset
664 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
665 int i; for (i=0; i<argc; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
666 int j = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
667 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
668 dprintf("\t%d -> %d\n", i+1, j);
223b71206888 Initial import
thib
parents:
diff changeset
669 if (var == i+1) jumpto = j;
223b71206888 Initial import
thib
parents:
diff changeset
670 }
223b71206888 Initial import
thib
parents:
diff changeset
671 if (*d == 0x7d) {
223b71206888 Initial import
thib
parents:
diff changeset
672 d++;
223b71206888 Initial import
thib
parents:
diff changeset
673 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
674 return jumpto;
223b71206888 Initial import
thib
parents:
diff changeset
675 }
223b71206888 Initial import
thib
parents:
diff changeset
676
223b71206888 Initial import
thib
parents:
diff changeset
677 /*
223b71206888 Initial import
thib
parents:
diff changeset
678 selection
223b71206888 Initial import
thib
parents:
diff changeset
679 ? <exp>
223b71206888 Initial import
thib
parents:
diff changeset
680 0x7b
223b71206888 Initial import
thib
parents:
diff changeset
681 <0x0a|0x40> <ushort | uint>
223b71206888 Initial import
thib
parents:
diff changeset
682 */
223b71206888 Initial import
thib
parents:
diff changeset
683 void Cmd::GetSelection(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
684 dprintf("selection. ");
223b71206888 Initial import
thib
parents:
diff changeset
685 if (*d == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
686 d++;
223b71206888 Initial import
thib
parents:
diff changeset
687 GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
688 if (*d != 0x29) { SetError(); return;}
223b71206888 Initial import
thib
parents:
diff changeset
689 d++;
223b71206888 Initial import
thib
parents:
diff changeset
690 }
223b71206888 Initial import
thib
parents:
diff changeset
691 if (*d == 0x7b) {
223b71206888 Initial import
thib
parents:
diff changeset
692 d++;
223b71206888 Initial import
thib
parents:
diff changeset
693 dprintf("{\n\t");
223b71206888 Initial import
thib
parents:
diff changeset
694 } else SetError();
223b71206888 Initial import
thib
parents:
diff changeset
695 int arg_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
696 while(*d != 0x7d) {
223b71206888 Initial import
thib
parents:
diff changeset
697 if (d[0] == 0x0a || d[0] == 0x40) {
223b71206888 Initial import
thib
parents:
diff changeset
698 int var;
223b71206888 Initial import
thib
parents:
diff changeset
699 if (system_version == 0) { var = read_little_endian_int(d+1); d += 5;}
223b71206888 Initial import
thib
parents:
diff changeset
700 else { var = read_little_endian_short(d+1); d += 3;}
223b71206888 Initial import
thib
parents:
diff changeset
701 dprintf("line %d; ",var);
223b71206888 Initial import
thib
parents:
diff changeset
702 } else if (d[0] == 0x2c) {
223b71206888 Initial import
thib
parents:
diff changeset
703 dprintf(":comma:");
223b71206888 Initial import
thib
parents:
diff changeset
704 } else if (d[0] == 0x28) {
223b71206888 Initial import
thib
parents:
diff changeset
705 dprintf(":cond:");
223b71206888 Initial import
thib
parents:
diff changeset
706 d++;
223b71206888 Initial import
thib
parents:
diff changeset
707 while(d[0] != 0x29) {
223b71206888 Initial import
thib
parents:
diff changeset
708 GetExpressionCond(d); // PRINT- 節でないばあい、条件表示。次は文字節、またはPRINT節のはず
223b71206888 Initial import
thib
parents:
diff changeset
709 if (IsError()) break;
223b71206888 Initial import
thib
parents:
diff changeset
710 if (*d == 0x32) { d++; dprintf("##");} // 0x32 なら、現在の条件節を表示しない
223b71206888 Initial import
thib
parents:
diff changeset
711 if (*d == 0x31) { d++; dprintf("**");} // 0x31 なら、現在の条件節を表示する(Little Busters! : 処理が正しいかは分からない)
223b71206888 Initial import
thib
parents:
diff changeset
712 dprintf(":");
223b71206888 Initial import
thib
parents:
diff changeset
713 }
223b71206888 Initial import
thib
parents:
diff changeset
714 d++;
223b71206888 Initial import
thib
parents:
diff changeset
715 } else if (StrType(d)) {
223b71206888 Initial import
thib
parents:
diff changeset
716 GetString(d);
223b71206888 Initial import
thib
parents:
diff changeset
717 arg_count++;
223b71206888 Initial import
thib
parents:
diff changeset
718 dprintf("\n\t");
223b71206888 Initial import
thib
parents:
diff changeset
719 } else if (*d == 0x23 && strncmp(d,"###PRINT",8) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
720 d += 8;
223b71206888 Initial import
thib
parents:
diff changeset
721 if (d[0] != 0x28) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
722 else { // 文字変数の内容の表示
223b71206888 Initial import
thib
parents:
diff changeset
723 d++;
223b71206888 Initial import
thib
parents:
diff changeset
724 dprintf("Print.");
223b71206888 Initial import
thib
parents:
diff changeset
725 VarInfo info;
223b71206888 Initial import
thib
parents:
diff changeset
726 GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
727 if (d[0] != 0x29 || info.type == -1) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
728 d++;
223b71206888 Initial import
thib
parents:
diff changeset
729 dprintf(";");
223b71206888 Initial import
thib
parents:
diff changeset
730 }
223b71206888 Initial import
thib
parents:
diff changeset
731 } else { SetError(); break;}
223b71206888 Initial import
thib
parents:
diff changeset
732 }
223b71206888 Initial import
thib
parents:
diff changeset
733 d++;
223b71206888 Initial import
thib
parents:
diff changeset
734 /* @@@ */
223b71206888 Initial import
thib
parents:
diff changeset
735 /* 一致しない場合があるのでコメントアウト */
223b71206888 Initial import
thib
parents:
diff changeset
736 // if (arg_count != argc) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
737 dprintf("\n}\n");
223b71206888 Initial import
thib
parents:
diff changeset
738 return;
223b71206888 Initial import
thib
parents:
diff changeset
739 }
223b71206888 Initial import
thib
parents:
diff changeset
740
223b71206888 Initial import
thib
parents:
diff changeset
741 char* op_str3[11] = { "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "="};
223b71206888 Initial import
thib
parents:
diff changeset
742 void Cmd::GetCmd(Flags& flags_orig, const char*& d ) {
223b71206888 Initial import
thib
parents:
diff changeset
743 ResetString();
223b71206888 Initial import
thib
parents:
diff changeset
744
223b71206888 Initial import
thib
parents:
diff changeset
745 cmdstr[0] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
746 debug_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
747 if (*d == 0x23) { /* コマンド */
223b71206888 Initial import
thib
parents:
diff changeset
748 cmd_type = CMD_OTHER;
223b71206888 Initial import
thib
parents:
diff changeset
749 cmd1 = *(unsigned const char*)(d+1);
223b71206888 Initial import
thib
parents:
diff changeset
750 cmd2 = *(unsigned const char*)(d+2);
223b71206888 Initial import
thib
parents:
diff changeset
751 cmd3 = read_little_endian_short(d+3);
223b71206888 Initial import
thib
parents:
diff changeset
752 argc = read_little_endian_short(d+5);
223b71206888 Initial import
thib
parents:
diff changeset
753 cmd4 = *(unsigned const char*)(d+7);
223b71206888 Initial import
thib
parents:
diff changeset
754 d += 8;
223b71206888 Initial import
thib
parents:
diff changeset
755 /* verbose */
223b71206888 Initial import
thib
parents:
diff changeset
756 // dprintf(" 0x23 - cmd %02x-%02x:%04x:%02x[%2d] \n",cmd1,cmd2,cmd3,cmd4,argc);
223b71206888 Initial import
thib
parents:
diff changeset
757 sprintf(cmdstr, "%02x-%02x:%04x:%02x : %s",cmd1,cmd2,cmd3,cmd4,CmdDescr(cmd1,cmd2,cmd3,cmd4));
223b71206888 Initial import
thib
parents:
diff changeset
758 /* 引数を得る */
223b71206888 Initial import
thib
parents:
diff changeset
759 /* 特殊引数のもの */
223b71206888 Initial import
thib
parents:
diff changeset
760 int is_special = 0;
223b71206888 Initial import
thib
parents:
diff changeset
761 if (cmd1 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
762 if (cmd2 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
763 int jump_arg = -1;
223b71206888 Initial import
thib
parents:
diff changeset
764 if (cmd3 == 0 || cmd3 == 5) {
223b71206888 Initial import
thib
parents:
diff changeset
765 /* gosub / goto */
223b71206888 Initial import
thib
parents:
diff changeset
766 jump_arg =read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
767 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
768 dprintf("\tjmp -> %d\n", jump_arg);
223b71206888 Initial import
thib
parents:
diff changeset
769 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
770 } else if (cmd3 == 1 || cmd3 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
771 /* conditional jump (if / unless) */
223b71206888 Initial import
thib
parents:
diff changeset
772 if (*d++ != 0x28) { SetError(); return;}
223b71206888 Initial import
thib
parents:
diff changeset
773 dprintf("\t");
223b71206888 Initial import
thib
parents:
diff changeset
774 int cond = GetExpressionCond(d);
223b71206888 Initial import
thib
parents:
diff changeset
775 if (IsError()) return;
223b71206888 Initial import
thib
parents:
diff changeset
776 if (*d++ != 0x29) { SetError(); return; }
223b71206888 Initial import
thib
parents:
diff changeset
777 int jumpto = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
778 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
779 dprintf("-> %d\n", jumpto);
223b71206888 Initial import
thib
parents:
diff changeset
780 if (cond) jump_arg = jumpto;
223b71206888 Initial import
thib
parents:
diff changeset
781 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
782 } else if (cmd3 == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
783 /* switch to */
223b71206888 Initial import
thib
parents:
diff changeset
784 jump_arg = GetSwitch(d);
223b71206888 Initial import
thib
parents:
diff changeset
785 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
786 } else if (cmd3 == 16) {
223b71206888 Initial import
thib
parents:
diff changeset
787 dprintf("local call with paramters;\n");
223b71206888 Initial import
thib
parents:
diff changeset
788 GetArgs(d);
223b71206888 Initial import
thib
parents:
diff changeset
789 int jumpto = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
790 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
791 dprintf("\tjmp -> %d\n",jumpto);
223b71206888 Initial import
thib
parents:
diff changeset
792 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
793 } else if (cmd3 == 8 || cmd3 == 3) {
223b71206888 Initial import
thib
parents:
diff changeset
794 /* switch to */
223b71206888 Initial import
thib
parents:
diff changeset
795 jump_arg = GetSimpleSwitch(d);
223b71206888 Initial import
thib
parents:
diff changeset
796 dprintf("\tjmp -> %d\n",jump_arg);
223b71206888 Initial import
thib
parents:
diff changeset
797 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
798 }
223b71206888 Initial import
thib
parents:
diff changeset
799 cmd_type = CMD_OTHER;
223b71206888 Initial import
thib
parents:
diff changeset
800 args.push_back(VarInfo(jump_arg));
223b71206888 Initial import
thib
parents:
diff changeset
801 } else if (cmd2 == 2 && (cmd3 == 0 || cmd3 == 1 || cmd3 == 2 || cmd3 == 3 || cmd3 == 0x0d) ) {
223b71206888 Initial import
thib
parents:
diff changeset
802 /* selection */
223b71206888 Initial import
thib
parents:
diff changeset
803 GetSelection(d);
223b71206888 Initial import
thib
parents:
diff changeset
804 is_special = 1;
223b71206888 Initial import
thib
parents:
diff changeset
805 }
223b71206888 Initial import
thib
parents:
diff changeset
806 }
223b71206888 Initial import
thib
parents:
diff changeset
807 /* 一般引数のもの */
223b71206888 Initial import
thib
parents:
diff changeset
808 if (!is_special) {
223b71206888 Initial import
thib
parents:
diff changeset
809 dprintf(" 0x23 - cmd %02x-%02x:%04x:%02x[%2d] : %s\n",cmd1,cmd2,cmd3,cmd4,argc,CmdDescr(cmd1,cmd2,cmd3,cmd4));
223b71206888 Initial import
thib
parents:
diff changeset
810 dprintf("\t");
223b71206888 Initial import
thib
parents:
diff changeset
811 if (cmd1 == 1 && cmd2 == 0x22 && (cmd3 == 0xc1c || cmd3 == 0x835)) GetArgsSpecial(3, d);
223b71206888 Initial import
thib
parents:
diff changeset
812 else if (cmd1 == 1 && cmd2 == 0x0b && cmd3 == 0x65) GetArgsSpecial(0, d);
223b71206888 Initial import
thib
parents:
diff changeset
813 else if (cmd1 == 1 && cmd2 == 0x15 && cmd3 == 0x28) GetArgsSpecial(0, d);
223b71206888 Initial import
thib
parents:
diff changeset
814 else if (cmd1 == 1 && cmd2 == 4 && (cmd3 == 0x26c || cmd3 == 0x26d || cmd3 == 0x270 || cmd3 == 0x276)) GetArgsSpecial(0, d);
223b71206888 Initial import
thib
parents:
diff changeset
815 else if (cmd1 == 1 && (cmd2 == 0x21 && cmd3 == 0x4b) || (cmd2 == 0x28 && cmd3 == 0x64)) GetArgsSpecial(2,d);
223b71206888 Initial import
thib
parents:
diff changeset
816 else GetArgs(d);
223b71206888 Initial import
thib
parents:
diff changeset
817 dprintf("\n");
223b71206888 Initial import
thib
parents:
diff changeset
818
223b71206888 Initial import
thib
parents:
diff changeset
819 }
223b71206888 Initial import
thib
parents:
diff changeset
820 if (cmd2 == 3 && cmd3 == 0x78 && cmd4 == 0) ruby_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
821 if (cmd2 == 3 && cmd3 == 0x11) ret_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
822 } else if (*d == 0x24) { /* 代入演算 */
223b71206888 Initial import
thib
parents:
diff changeset
823 if (d[1] == 0x12 || d[2] != 0x5b) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
824 dprintf("expr: ");
223b71206888 Initial import
thib
parents:
diff changeset
825 sprintf(cmdstr, "expr");
223b71206888 Initial import
thib
parents:
diff changeset
826
223b71206888 Initial import
thib
parents:
diff changeset
827 VarInfo info;
223b71206888 Initial import
thib
parents:
diff changeset
828 int value = GetLeftToken(d, info);
223b71206888 Initial import
thib
parents:
diff changeset
829 if (d[0] != 0x5c) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
830 int type = d[1];
223b71206888 Initial import
thib
parents:
diff changeset
831 if (type < 20 || type > 30) SetError();
223b71206888 Initial import
thib
parents:
diff changeset
832 else dprintf("%s",op_str[type]);
223b71206888 Initial import
thib
parents:
diff changeset
833 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
834 int value2 = GetExpression(d);
223b71206888 Initial import
thib
parents:
diff changeset
835 // 代入情報を埋め込む
223b71206888 Initial import
thib
parents:
diff changeset
836 if (type != 30) value2 = eval(value, type-20, value2);
223b71206888 Initial import
thib
parents:
diff changeset
837 cmd_type = CMD_FLAGS;
223b71206888 Initial import
thib
parents:
diff changeset
838 args.push_back(info);
223b71206888 Initial import
thib
parents:
diff changeset
839 args.push_back(value2);
223b71206888 Initial import
thib
parents:
diff changeset
840 dprintf("\n");
223b71206888 Initial import
thib
parents:
diff changeset
841 } else if (StrType(d)) { /* 文字出力 */
223b71206888 Initial import
thib
parents:
diff changeset
842 VarInfo info;
223b71206888 Initial import
thib
parents:
diff changeset
843 info.type = TYPE_STR;
223b71206888 Initial import
thib
parents:
diff changeset
844 info.value = GetString(d);
223b71206888 Initial import
thib
parents:
diff changeset
845 args.push_back(info);
223b71206888 Initial import
thib
parents:
diff changeset
846 cmd_type = CMD_TEXT;
223b71206888 Initial import
thib
parents:
diff changeset
847 text_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
848 dprintf("\n");
223b71206888 Initial import
thib
parents:
diff changeset
849 } else if (*d == 0x0a || *d == 0x40 || *d == 0x21) { /* デバッグ用データと既読フラグ */
223b71206888 Initial import
thib
parents:
diff changeset
850 cmd_type = CMD_OTHER;
223b71206888 Initial import
thib
parents:
diff changeset
851 if (*d == 0x0a) {
223b71206888 Initial import
thib
parents:
diff changeset
852 dprintf("line ");
223b71206888 Initial import
thib
parents:
diff changeset
853 d++;
223b71206888 Initial import
thib
parents:
diff changeset
854 int l;
223b71206888 Initial import
thib
parents:
diff changeset
855 if (system_version == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
856 l = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
857 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
858 } else {
223b71206888 Initial import
thib
parents:
diff changeset
859 l = read_little_endian_short(d);
223b71206888 Initial import
thib
parents:
diff changeset
860 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
861 }
223b71206888 Initial import
thib
parents:
diff changeset
862 dprintf("%d\n", l);
223b71206888 Initial import
thib
parents:
diff changeset
863 } else { /* 0x40, 0x21 */
223b71206888 Initial import
thib
parents:
diff changeset
864 // 既読マーカーらしい。エントリーポイントとセーブポイントも使われる。
223b71206888 Initial import
thib
parents:
diff changeset
865 // RealLive 1.2.5から、0x40はセーブポイント、0x21はエントリーポイント。
223b71206888 Initial import
thib
parents:
diff changeset
866 // 1.2.5以前、どちらも0x40が使われる。
223b71206888 Initial import
thib
parents:
diff changeset
867 int kidoku_index;
223b71206888 Initial import
thib
parents:
diff changeset
868 d++;
223b71206888 Initial import
thib
parents:
diff changeset
869 if (system_version == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
870 kidoku_index = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
871 d += 4;
223b71206888 Initial import
thib
parents:
diff changeset
872 } else {
223b71206888 Initial import
thib
parents:
diff changeset
873 kidoku_index = read_little_endian_short(d);
223b71206888 Initial import
thib
parents:
diff changeset
874 d += 2;
223b71206888 Initial import
thib
parents:
diff changeset
875 }
223b71206888 Initial import
thib
parents:
diff changeset
876 dprintf("kidoku marker %d\n", kidoku_index);
223b71206888 Initial import
thib
parents:
diff changeset
877 // text_readflagは、このkidoku_indexを使ったら良いかな。
223b71206888 Initial import
thib
parents:
diff changeset
878 }
223b71206888 Initial import
thib
parents:
diff changeset
879 } else if (*d == 0x2c) { /* ??? */
223b71206888 Initial import
thib
parents:
diff changeset
880 dprintf("commd;0x2c\n"); // conditional jump の行き先によくあるらしい(常に、かはわからない)
223b71206888 Initial import
thib
parents:
diff changeset
881 d++;
223b71206888 Initial import
thib
parents:
diff changeset
882 } else {
223b71206888 Initial import
thib
parents:
diff changeset
883 SetError();
223b71206888 Initial import
thib
parents:
diff changeset
884 }
223b71206888 Initial import
thib
parents:
diff changeset
885 return;
223b71206888 Initial import
thib
parents:
diff changeset
886 }
223b71206888 Initial import
thib
parents:
diff changeset
887
223b71206888 Initial import
thib
parents:
diff changeset
888 char Cmd::strtype[256] = {
223b71206888 Initial import
thib
parents:
diff changeset
889 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +00 */
223b71206888 Initial import
thib
parents:
diff changeset
890 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +10 */
223b71206888 Initial import
thib
parents:
diff changeset
891 0,0,3,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +20 */
223b71206888 Initial import
thib
parents:
diff changeset
892 1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,1, /* +30 */
223b71206888 Initial import
thib
parents:
diff changeset
893 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, /* +40 */
223b71206888 Initial import
thib
parents:
diff changeset
894 1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, /* +50 */
223b71206888 Initial import
thib
parents:
diff changeset
895 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +60 */
223b71206888 Initial import
thib
parents:
diff changeset
896 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +70 */
223b71206888 Initial import
thib
parents:
diff changeset
897 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, /* +80 */
223b71206888 Initial import
thib
parents:
diff changeset
898 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, /* +90 */
223b71206888 Initial import
thib
parents:
diff changeset
899 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +A0 */
223b71206888 Initial import
thib
parents:
diff changeset
900 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +B0 */
223b71206888 Initial import
thib
parents:
diff changeset
901 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +C0 */
223b71206888 Initial import
thib
parents:
diff changeset
902 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* +D0 */
223b71206888 Initial import
thib
parents:
diff changeset
903 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, /* +E0 */
223b71206888 Initial import
thib
parents:
diff changeset
904 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,0,0 /* +F0 */
223b71206888 Initial import
thib
parents:
diff changeset
905 };
223b71206888 Initial import
thib
parents:
diff changeset
906
223b71206888 Initial import
thib
parents:
diff changeset
907 int Cmd::GetString(const char*& d) {
223b71206888 Initial import
thib
parents:
diff changeset
908 int retnum = -1;
223b71206888 Initial import
thib
parents:
diff changeset
909 while(1) {
223b71206888 Initial import
thib
parents:
diff changeset
910 if (*d == '\\') {
223b71206888 Initial import
thib
parents:
diff changeset
911 d++;
223b71206888 Initial import
thib
parents:
diff changeset
912 strheap[strend++] = *d++;
223b71206888 Initial import
thib
parents:
diff changeset
913 } else if (*d == '"') {
223b71206888 Initial import
thib
parents:
diff changeset
914 d++;
223b71206888 Initial import
thib
parents:
diff changeset
915 if (retnum == -1) retnum = strend;
223b71206888 Initial import
thib
parents:
diff changeset
916 while(*d != '"') strheap[strend++] = *d++;
223b71206888 Initial import
thib
parents:
diff changeset
917 d++;
223b71206888 Initial import
thib
parents:
diff changeset
918 } else if (StrType(d)) {
223b71206888 Initial import
thib
parents:
diff changeset
919 if (retnum == -1) retnum = strend;
223b71206888 Initial import
thib
parents:
diff changeset
920 int stype;
223b71206888 Initial import
thib
parents:
diff changeset
921 while( (stype = StrType(d)) ) {
223b71206888 Initial import
thib
parents:
diff changeset
922 if (stype == 3) break; // 文中に '"' が現れた場合
223b71206888 Initial import
thib
parents:
diff changeset
923 strheap[strend++] = *d++;
223b71206888 Initial import
thib
parents:
diff changeset
924 if (stype == 2) strheap[strend++] = *d++;
223b71206888 Initial import
thib
parents:
diff changeset
925 }
223b71206888 Initial import
thib
parents:
diff changeset
926 } else break;
223b71206888 Initial import
thib
parents:
diff changeset
927 }
223b71206888 Initial import
thib
parents:
diff changeset
928 if (retnum != -1) strheap[strend++] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
929 dprintf("\"%s\"", strheap + retnum);
223b71206888 Initial import
thib
parents:
diff changeset
930 if (strend >= STRHEAP_SIZE) {
223b71206888 Initial import
thib
parents:
diff changeset
931 dprintf("Error: string heap overflow\n");
223b71206888 Initial import
thib
parents:
diff changeset
932 }
223b71206888 Initial import
thib
parents:
diff changeset
933 return retnum;
223b71206888 Initial import
thib
parents:
diff changeset
934 }
223b71206888 Initial import
thib
parents:
diff changeset
935
223b71206888 Initial import
thib
parents:
diff changeset
936 int Cmd::StrVar(int var_num) {
223b71206888 Initial import
thib
parents:
diff changeset
937 int retnum = strend;
223b71206888 Initial import
thib
parents:
diff changeset
938 flags.Str(var_num, strheap+strend, STRHEAP_SIZE-strend);
223b71206888 Initial import
thib
parents:
diff changeset
939 strend += strlen(strheap+strend)+1;
223b71206888 Initial import
thib
parents:
diff changeset
940 return retnum;
223b71206888 Initial import
thib
parents:
diff changeset
941 }
223b71206888 Initial import
thib
parents:
diff changeset
942
223b71206888 Initial import
thib
parents:
diff changeset
943 void usage(void) {
223b71206888 Initial import
thib
parents:
diff changeset
944 fprintf(stderr,"usage : scn2kdump [inputfile] [outputfile]\n");
223b71206888 Initial import
thib
parents:
diff changeset
945 fprintf(stderr," inputfile: seen.txt(default)\n");
223b71206888 Initial import
thib
parents:
diff changeset
946 fprintf(stderr," outputfile: seen.txt_out(default)\n");
223b71206888 Initial import
thib
parents:
diff changeset
947 exit(-1);
223b71206888 Initial import
thib
parents:
diff changeset
948 }
223b71206888 Initial import
thib
parents:
diff changeset
949 int main(int argc, char** argv) {
223b71206888 Initial import
thib
parents:
diff changeset
950 /* determine file names */
223b71206888 Initial import
thib
parents:
diff changeset
951 bool verbose = false;
223b71206888 Initial import
thib
parents:
diff changeset
952 char* inname = "seen.txt";
223b71206888 Initial import
thib
parents:
diff changeset
953 char* outname = 0;
223b71206888 Initial import
thib
parents:
diff changeset
954 if (argc > 2 && strcmp(argv[1],"-v") == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
955 int i; for (i=1; i<argc; i++) argv[i] = argv[i+1];
223b71206888 Initial import
thib
parents:
diff changeset
956 argc--;
223b71206888 Initial import
thib
parents:
diff changeset
957 verbose = true;
223b71206888 Initial import
thib
parents:
diff changeset
958 }
223b71206888 Initial import
thib
parents:
diff changeset
959 switch(argc) {
223b71206888 Initial import
thib
parents:
diff changeset
960 case 1: break;
223b71206888 Initial import
thib
parents:
diff changeset
961 case 2: inname = argv[1]; break;
223b71206888 Initial import
thib
parents:
diff changeset
962 case 3: inname = argv[1]; outname = argv[2]; break;
223b71206888 Initial import
thib
parents:
diff changeset
963 default: usage();
223b71206888 Initial import
thib
parents:
diff changeset
964 }
223b71206888 Initial import
thib
parents:
diff changeset
965 /* open output file */
223b71206888 Initial import
thib
parents:
diff changeset
966 FILE* outstream = stdout;
223b71206888 Initial import
thib
parents:
diff changeset
967 /* create archive instance */
223b71206888 Initial import
thib
parents:
diff changeset
968 SCN2kFILE archive(inname);
223b71206888 Initial import
thib
parents:
diff changeset
969 archive.Init();
223b71206888 Initial import
thib
parents:
diff changeset
970 if (archive.Deal() == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
971 fprintf(stderr,"Cannot open / Invalid archive file %s\n",inname);
223b71206888 Initial import
thib
parents:
diff changeset
972 usage();
223b71206888 Initial import
thib
parents:
diff changeset
973 }
223b71206888 Initial import
thib
parents:
diff changeset
974 /* dump files */
223b71206888 Initial import
thib
parents:
diff changeset
975 archive.InitList();
223b71206888 Initial import
thib
parents:
diff changeset
976 char* fname;
223b71206888 Initial import
thib
parents:
diff changeset
977 fprintf(stderr,"Dump start\n");
223b71206888 Initial import
thib
parents:
diff changeset
978 while( (fname = archive.ListItem()) != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
979 ARCINFO* info = archive.Find(fname,"");
223b71206888 Initial import
thib
parents:
diff changeset
980 if (info == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
981 char* data = info->CopyRead();
223b71206888 Initial import
thib
parents:
diff changeset
982 char* d = data;
223b71206888 Initial import
thib
parents:
diff changeset
983 char* dend = d + info->Size();
223b71206888 Initial import
thib
parents:
diff changeset
984 /* version 確認 */
223b71206888 Initial import
thib
parents:
diff changeset
985 if (read_little_endian_int(d) == 0x1cc) {
223b71206888 Initial import
thib
parents:
diff changeset
986 system_version = 0;
223b71206888 Initial import
thib
parents:
diff changeset
987 } else if (read_little_endian_int(d) == 0x1d0) {
223b71206888 Initial import
thib
parents:
diff changeset
988 system_version = 1;
223b71206888 Initial import
thib
parents:
diff changeset
989 } else {
223b71206888 Initial import
thib
parents:
diff changeset
990 continue;
223b71206888 Initial import
thib
parents:
diff changeset
991 }
223b71206888 Initial import
thib
parents:
diff changeset
992 if (read_little_endian_int(d+4) == 0x1adb2) ; // little busters!
223b71206888 Initial import
thib
parents:
diff changeset
993 else if (read_little_endian_int(d+4) != 0x2712) continue;
223b71206888 Initial import
thib
parents:
diff changeset
994 int header_size;
223b71206888 Initial import
thib
parents:
diff changeset
995 if (system_version == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
996 header_size = 0x1cc + read_little_endian_int(d+0x20) * 4;
223b71206888 Initial import
thib
parents:
diff changeset
997 } else {
223b71206888 Initial import
thib
parents:
diff changeset
998 header_size = read_little_endian_int(d+0x20);
223b71206888 Initial import
thib
parents:
diff changeset
999 }
223b71206888 Initial import
thib
parents:
diff changeset
1000 d += header_size;
223b71206888 Initial import
thib
parents:
diff changeset
1001
223b71206888 Initial import
thib
parents:
diff changeset
1002 const char* dcur = d;
223b71206888 Initial import
thib
parents:
diff changeset
1003 const char* dstart = d;
223b71206888 Initial import
thib
parents:
diff changeset
1004 fprintf(stderr,"Dumping %s\n",fname);
223b71206888 Initial import
thib
parents:
diff changeset
1005 fprintf(stdout,"Dumping %s\n",fname);
223b71206888 Initial import
thib
parents:
diff changeset
1006 { int i; for (i=0; i<100; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1007 int n = read_little_endian_int(data + 0x34 + i*4);
223b71206888 Initial import
thib
parents:
diff changeset
1008 if (n != 6) fprintf(stdout,"subroutine table %2d: %6d\n",i,n);
223b71206888 Initial import
thib
parents:
diff changeset
1009 }}
223b71206888 Initial import
thib
parents:
diff changeset
1010 Flags flags;
223b71206888 Initial import
thib
parents:
diff changeset
1011 /* 最初から最後までコマンド取得 -> 出力を繰り返す */
223b71206888 Initial import
thib
parents:
diff changeset
1012 while(dcur<dend) {
223b71206888 Initial import
thib
parents:
diff changeset
1013 const char* dprev = dcur;
223b71206888 Initial import
thib
parents:
diff changeset
1014 Cmd cmd(flags); cmd.ClearError();
223b71206888 Initial import
thib
parents:
diff changeset
1015
223b71206888 Initial import
thib
parents:
diff changeset
1016 /* end? */
223b71206888 Initial import
thib
parents:
diff changeset
1017 if (*dcur == -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1018 /* 0xff x 32byte + 0x00 : end sign */
223b71206888 Initial import
thib
parents:
diff changeset
1019 int i; for (i=0; i<0x20; i++)
223b71206888 Initial import
thib
parents:
diff changeset
1020 if (dcur[i] != -1) break;
223b71206888 Initial import
thib
parents:
diff changeset
1021 if (i == 0x20 && dcur[i] == 0) break;
223b71206888 Initial import
thib
parents:
diff changeset
1022 }
223b71206888 Initial import
thib
parents:
diff changeset
1023 dprintf("%d : ",dcur-dstart);
223b71206888 Initial import
thib
parents:
diff changeset
1024 cmd.GetCmd(flags, dcur);
223b71206888 Initial import
thib
parents:
diff changeset
1025 if (cmd.IsError()) {
223b71206888 Initial import
thib
parents:
diff changeset
1026 fprintf(outstream, "Error at %6d\n",dprev-dstart);
223b71206888 Initial import
thib
parents:
diff changeset
1027 while(dcur < dend) {
223b71206888 Initial import
thib
parents:
diff changeset
1028 if (*dcur == 0x29 && dcur[1] == 0x0a) {dcur++;break;}
223b71206888 Initial import
thib
parents:
diff changeset
1029 if (*dcur == 0 && dcur[1] == 0x0a) {dcur++;break;}
223b71206888 Initial import
thib
parents:
diff changeset
1030 if (*dcur == 0 && dcur[1] == 0x23) {dcur++;break;}
223b71206888 Initial import
thib
parents:
diff changeset
1031 dcur++;
223b71206888 Initial import
thib
parents:
diff changeset
1032 }
223b71206888 Initial import
thib
parents:
diff changeset
1033 dprev -= 2*16;
223b71206888 Initial import
thib
parents:
diff changeset
1034 int ilen = (dcur-dprev+15)/16;
223b71206888 Initial import
thib
parents:
diff changeset
1035 int i; for (i=0; i<ilen; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1036 fprintf(outstream, "%6d: ",dprev-dstart);
223b71206888 Initial import
thib
parents:
diff changeset
1037 int j; for (j=0; j<16; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
1038 if (dprev >= dend) break;
223b71206888 Initial import
thib
parents:
diff changeset
1039 if (dprev < data) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1040 fprintf(outstream, "%02x ",*(unsigned char*)(dprev));
223b71206888 Initial import
thib
parents:
diff changeset
1041 dprev++;
223b71206888 Initial import
thib
parents:
diff changeset
1042 }
223b71206888 Initial import
thib
parents:
diff changeset
1043 fprintf(outstream, "\n");
223b71206888 Initial import
thib
parents:
diff changeset
1044 }
223b71206888 Initial import
thib
parents:
diff changeset
1045 }
223b71206888 Initial import
thib
parents:
diff changeset
1046 }
223b71206888 Initial import
thib
parents:
diff changeset
1047 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
1048 }
223b71206888 Initial import
thib
parents:
diff changeset
1049 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
1050 }
223b71206888 Initial import
thib
parents:
diff changeset
1051
223b71206888 Initial import
thib
parents:
diff changeset
1052 /*
223b71206888 Initial import
thib
parents:
diff changeset
1053 SetStr
223b71206888 Initial import
thib
parents:
diff changeset
1054 0x23 - cmd 01-0a:0000:00[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
1055 args:V<18>[17],"PB47"
223b71206888 Initial import
thib
parents:
diff changeset
1056 CatStr
223b71206888 Initial import
thib
parents:
diff changeset
1057 0x23 - cmd 01-0a:0002:00[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
1058 args:V<18>[17],V<18>[20]
223b71206888 Initial import
thib
parents:
diff changeset
1059
223b71206888 Initial import
thib
parents:
diff changeset
1060 WaitClick
223b71206888 Initial import
thib
parents:
diff changeset
1061 0x23 - cmd 00-03:0011:00[ 0]
223b71206888 Initial import
thib
parents:
diff changeset
1062
223b71206888 Initial import
thib
parents:
diff changeset
1063 ChangeFaceGraphics
223b71206888 Initial import
thib
parents:
diff changeset
1064 0x23 - cmd 00-03:03e8:00[ 1]
223b71206888 Initial import
thib
parents:
diff changeset
1065 args:V<18>[17]
223b71206888 Initial import
thib
parents:
diff changeset
1066 DeleteFaceGraphics
223b71206888 Initial import
thib
parents:
diff changeset
1067 0x23 - cmd 00-03:03e9:01[ 0]
223b71206888 Initial import
thib
parents:
diff changeset
1068 KoePlay
223b71206888 Initial import
thib
parents:
diff changeset
1069 0x23 - cmd 01-17:0000:01[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
1070 args:100000026,5
223b71206888 Initial import
thib
parents:
diff changeset
1071 DrawGraphics(前景画あり)
223b71206888 Initial import
thib
parents:
diff changeset
1072 0x23 - cmd 01-21:004b:00[ 1]
223b71206888 Initial import
thib
parents:
diff changeset
1073 args:V<18>[1],10,kasane. #1 <args:V<18>[17],11>
223b71206888 Initial import
thib
parents:
diff changeset
1074
223b71206888 Initial import
thib
parents:
diff changeset
1075 DrawGraphics(背景のみ)
223b71206888 Initial import
thib
parents:
diff changeset
1076 0x23 - cmd 01-21:0049:00[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
1077 args:V<18>[1],10
223b71206888 Initial import
thib
parents:
diff changeset
1078
223b71206888 Initial import
thib
parents:
diff changeset
1079 Ruby
223b71206888 Initial import
thib
parents:
diff changeset
1080 0x23 - cmd 00-03:0078:01[ 0]
223b71206888 Initial import
thib
parents:
diff changeset
1081 "理由"
223b71206888 Initial import
thib
parents:
diff changeset
1082 0x23 - cmd 00-03:0078:00[ 1]
223b71206888 Initial import
thib
parents:
diff changeset
1083 "わけ"
223b71206888 Initial import
thib
parents:
diff changeset
1084 SetTitle
223b71206888 Initial import
thib
parents:
diff changeset
1085 0x23 - cmd 01-04:0000:00[ 1]
223b71206888 Initial import
thib
parents:
diff changeset
1086 args:"Long Long Time Ago..."
223b71206888 Initial import
thib
parents:
diff changeset
1087 WaitTime
223b71206888 Initial import
thib
parents:
diff changeset
1088 0x23 - cmd 01-14:0069:00[ 1]
223b71206888 Initial import
thib
parents:
diff changeset
1089 args:3000
223b71206888 Initial import
thib
parents:
diff changeset
1090 ChangeBGM 数値引数はフェードアウト、インの時間と推測
223b71206888 Initial import
thib
parents:
diff changeset
1091 0x23 - cmd 01-14:0000:02[ 3]
223b71206888 Initial import
thib
parents:
diff changeset
1092 args:"BGM18",700,700
223b71206888 Initial import
thib
parents:
diff changeset
1093 */
223b71206888 Initial import
thib
parents:
diff changeset
1094
223b71206888 Initial import
thib
parents:
diff changeset
1095 struct CmdDescrItem {
223b71206888 Initial import
thib
parents:
diff changeset
1096 CmdDescrItem* next;
223b71206888 Initial import
thib
parents:
diff changeset
1097 int cmd4;
223b71206888 Initial import
thib
parents:
diff changeset
1098 int cmd1;
223b71206888 Initial import
thib
parents:
diff changeset
1099 int cmd2;
223b71206888 Initial import
thib
parents:
diff changeset
1100 int cmd3;
223b71206888 Initial import
thib
parents:
diff changeset
1101 const char* cmd_descr;
223b71206888 Initial import
thib
parents:
diff changeset
1102 };
223b71206888 Initial import
thib
parents:
diff changeset
1103 CmdDescrItem cmd_descr_orig[] = {
223b71206888 Initial import
thib
parents:
diff changeset
1104 // scn2k_impl.cc; Scn2k::SysExec()
223b71206888 Initial import
thib
parents:
diff changeset
1105 {0,0,0x00,0x01,0x0a, "local return"},
223b71206888 Initial import
thib
parents:
diff changeset
1106 {0,0,0x00,0x01,0x0b, "global jump"},
223b71206888 Initial import
thib
parents:
diff changeset
1107 {0,0,0x00,0x01,0x0c, "global call"},
223b71206888 Initial import
thib
parents:
diff changeset
1108 {0,0,0x00,0x01,0x0d, "global return"},
223b71206888 Initial import
thib
parents:
diff changeset
1109 {0,0,0x00,0x01,0x12, "global call"},
223b71206888 Initial import
thib
parents:
diff changeset
1110 {0,0,0x00,0x01,0x13, "global return(?)"},
223b71206888 Initial import
thib
parents:
diff changeset
1111 {0,0,0x00,0x04,0x0d, "Menu_return"},
223b71206888 Initial import
thib
parents:
diff changeset
1112 {0,0,0x01,0x04,0x00, "SetWindowCaption"},
223b71206888 Initial import
thib
parents:
diff changeset
1113 {0,0,0x01,0x04,0x82, "ClearMousePress"},
223b71206888 Initial import
thib
parents:
diff changeset
1114 {0,0,0x01,0x04,0x83, "GetMouse(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1115 {0,0,0x01,0x04,0x85, "GetMouse"},
223b71206888 Initial import
thib
parents:
diff changeset
1116 {0,0,0x01,0x04,0x4b0,"QuitGame"},
223b71206888 Initial import
thib
parents:
diff changeset
1117 {0,0,0x01,0x04,0x58d,"PrevSaveNumber"},
223b71206888 Initial import
thib
parents:
diff changeset
1118 {0,0,0x01,0x04,0x585,"SavedDate"},
223b71206888 Initial import
thib
parents:
diff changeset
1119 {0,0,0x01,0x04,0xc23,"Save"},
223b71206888 Initial import
thib
parents:
diff changeset
1120 {0,0,0x01,0x04,0xc25,"Load"},
223b71206888 Initial import
thib
parents:
diff changeset
1121 {0,0,0x01,0x04,0x4b1,"GoMenu"},
223b71206888 Initial import
thib
parents:
diff changeset
1122 {0,0,0x01,0x04,0x4b3,"GoMenu_Badend"},
223b71206888 Initial import
thib
parents:
diff changeset
1123 {0,0,0x01,0x04,0xcc, "ShowMouseCursor"},
223b71206888 Initial import
thib
parents:
diff changeset
1124 {0,0,0x01,0x04,0xcd, "HideMouseCursor"},
223b71206888 Initial import
thib
parents:
diff changeset
1125 {0,0,0x01,0x04,0xcf, "SetCursorType"},
223b71206888 Initial import
thib
parents:
diff changeset
1126 // scn2k_cmd.cc; Cmd::GetCmd()
223b71206888 Initial import
thib
parents:
diff changeset
1127 {0,0,0x00,0x01,0, "local jump"},
223b71206888 Initial import
thib
parents:
diff changeset
1128 {0,0,0x00,0x01,1, "local jump-if"},
223b71206888 Initial import
thib
parents:
diff changeset
1129 {0,0,0x00,0x01,2, "local jump-unless"},
223b71206888 Initial import
thib
parents:
diff changeset
1130 {0,0,0x00,0x01,3, "local jump-switch??"},
223b71206888 Initial import
thib
parents:
diff changeset
1131 {0,0,0x00,0x01,4, "local switch"},
223b71206888 Initial import
thib
parents:
diff changeset
1132 {0,0,0x00,0x01,5, "local call"},
223b71206888 Initial import
thib
parents:
diff changeset
1133 {0,0,0x00,0x01,8, "local switch(simple form)"},
223b71206888 Initial import
thib
parents:
diff changeset
1134 {0,0,0x01,0x0b,0, "set multiple variables"},
223b71206888 Initial import
thib
parents:
diff changeset
1135 {0,0,0x01,0x0b,1, "set variables in a range"},
223b71206888 Initial import
thib
parents:
diff changeset
1136 {0,0,0x01,0x0b,4, "clear variables in a range"},
223b71206888 Initial import
thib
parents:
diff changeset
1137 {0,0,0x01,0x0b,0x64, "get summation of variables in a range"},
223b71206888 Initial import
thib
parents:
diff changeset
1138 // scn2k_cmd.cc; Flags::Exec()
223b71206888 Initial import
thib
parents:
diff changeset
1139 {0,0,0x01,0x0a,0, "SetStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1140 {0,0,0x01,0x0a,1, "ClearStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1141 {0,0,0x01,0x0a,2, "AppendStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1142 {0,0,0x01,0x0a,3, "StrLen"},
223b71206888 Initial import
thib
parents:
diff changeset
1143 {0,0,0x01,0x0a,4, "StrCmp"},
223b71206888 Initial import
thib
parents:
diff changeset
1144 {0,0,0x01,0x0a,5, "SubStrL"},
223b71206888 Initial import
thib
parents:
diff changeset
1145 {0,0,0x01,0x0a,6, "SubStrR"},
223b71206888 Initial import
thib
parents:
diff changeset
1146 {0,0,0x01,0x0a,7, "StrLenWideChar"},
223b71206888 Initial import
thib
parents:
diff changeset
1147 {0,0,0x01,0x0a,8, "TrimStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1148 {0,0,0x01,0x0a,0x0f, "IntToStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1149 {0,0,0x01,0x0a,0x11, "IntToStr_Fill"},
223b71206888 Initial import
thib
parents:
diff changeset
1150 {0,0,0x01,0x0a,0x64, "ShowStr"},
223b71206888 Initial import
thib
parents:
diff changeset
1151 // scn2k_text.cc; TextImpl::Exec()
223b71206888 Initial import
thib
parents:
diff changeset
1152 {0,0,0x01,0x21,0x49, "SetFaceGraphic"},
223b71206888 Initial import
thib
parents:
diff changeset
1153 {0,0,0x01,0x21,0x4b, "SetFaceGraphic"},
223b71206888 Initial import
thib
parents:
diff changeset
1154 {0,0,0x01,0x21,0x4c, "SetFaceGraphic"},
223b71206888 Initial import
thib
parents:
diff changeset
1155 {0,0,0x00,0x03,0x97, "CloseTextWindow"},
223b71206888 Initial import
thib
parents:
diff changeset
1156 {0,0,0x00,0x03,0x11, "WaitText"},
223b71206888 Initial import
thib
parents:
diff changeset
1157 {0,0,0x00,0x03,0x03, "TextReturn"},
223b71206888 Initial import
thib
parents:
diff changeset
1158 {0,0,0x00,0x03,0xc9, "TextReturn"},
223b71206888 Initial import
thib
parents:
diff changeset
1159 {0,0,0x00,0x03,0x3e8,"SetFaceGraphic"},
223b71206888 Initial import
thib
parents:
diff changeset
1160 {0,0,0x00,0x03,0x3e9,"SetFaceGraphic"},
223b71206888 Initial import
thib
parents:
diff changeset
1161 {0,0,0x00,0x03,0x78, "TextRuby"},
223b71206888 Initial import
thib
parents:
diff changeset
1162 {0,0,0x00,0x03,0x66, "SetTextWindowType"},
223b71206888 Initial import
thib
parents:
diff changeset
1163 {0,0,0x00,0x03,0x67, "OpenTextWindow"},
223b71206888 Initial import
thib
parents:
diff changeset
1164 {0,0,0x00,0x03,0x98, "ClearTextWindow"},
223b71206888 Initial import
thib
parents:
diff changeset
1165 {0,0,0x00,0x03,0x68, "ShowText"},
223b71206888 Initial import
thib
parents:
diff changeset
1166 {0,0,0x00,0x02,0x01, "Select"},
223b71206888 Initial import
thib
parents:
diff changeset
1167 {0,0,0x00,0x02,0x03, "Select"},
223b71206888 Initial import
thib
parents:
diff changeset
1168 {0,0,0x00,0x04,0x44c,"TextSkipStart"},
223b71206888 Initial import
thib
parents:
diff changeset
1169 {0,0,0x00,0x04,0x3e8,"CloseTextWindow"},
223b71206888 Initial import
thib
parents:
diff changeset
1170 {0,0,0x01,0x04,0x64, "WaitTime"},
223b71206888 Initial import
thib
parents:
diff changeset
1171 {0,0,0x01,0x04,0x6f, "WaitTime"},
223b71206888 Initial import
thib
parents:
diff changeset
1172 {0,0,0x01,0x04,0x79, "WaitTime"},
223b71206888 Initial import
thib
parents:
diff changeset
1173 {0,0,0x01,0x04,0x65, "WaitTime w/ Cancel"},
223b71206888 Initial import
thib
parents:
diff changeset
1174 {0,0,0x01,0x04,0x70, "WaitTime w/ Cancel"},
223b71206888 Initial import
thib
parents:
diff changeset
1175 {0,0,0x01,0x04,0x1fe,"GetTimer"},
223b71206888 Initial import
thib
parents:
diff changeset
1176 {0,0,0x01,0x04,0x201,"ResetTimer (unsupported; see rldev)"},
223b71206888 Initial import
thib
parents:
diff changeset
1177 {0,0,0x01,0x04,0x202,"ResetTimerAll (unsupported; see rldev)"},
223b71206888 Initial import
thib
parents:
diff changeset
1178 {0,0,0x01,0x04,0x72, "GetTimer"},
223b71206888 Initial import
thib
parents:
diff changeset
1179 {0,0,0x01,0x04,0x7c, "GetTimer(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1180 {0,0,0x01,0x04,0x6e, "ClearTimer"},
223b71206888 Initial import
thib
parents:
diff changeset
1181 {0,0,0x01,0x04,0x78, "ClearTimer(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1182 {0,0,0x01,0x04,0x26c,"ClearTimer(multi)"},
223b71206888 Initial import
thib
parents:
diff changeset
1183 {0,0,0x01,0x04,0x270,"ClearTimer(multi)"},
223b71206888 Initial import
thib
parents:
diff changeset
1184 {0,0,0x01,0x04,0x276,"GetTimer(multi)"},
223b71206888 Initial import
thib
parents:
diff changeset
1185 {0,0,0x01,0x04,0x1f4,"SetTimer"},
223b71206888 Initial import
thib
parents:
diff changeset
1186 {0,0,0x01,0x04,0x3e8,"rand(x,y)"},
223b71206888 Initial import
thib
parents:
diff changeset
1187 {0,0,0x01,0x04,0x3ec,"min(x,y)"},
223b71206888 Initial import
thib
parents:
diff changeset
1188 {0,0,0x01,0x04,0x3ef,"min(x,y)"},
223b71206888 Initial import
thib
parents:
diff changeset
1189 {0,0,0x01,0x04,0x320,"range conversion(V,?,ResultMin,ValMin,ValMax,ResultMax,?)"},
223b71206888 Initial import
thib
parents:
diff changeset
1190 {0,0,0x01,0x04,0x3f1,"in_range(x,y,a)"},
223b71206888 Initial import
thib
parents:
diff changeset
1191 {0,0,0x01,0x04,0x16c,"SetCursorType?"},
223b71206888 Initial import
thib
parents:
diff changeset
1192 {0,0,0x01,0x04,0xbc1,"LoadFromMenu"},
223b71206888 Initial import
thib
parents:
diff changeset
1193 {0,0,0x01,0x04,0x8d4,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1194 {0,0,0x01,0x04,0x8d5,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1195 {0,0,0x01,0x04,0x8d6,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1196 {0,0,0x01,0x04,0x8d7,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1197 {0,0,0x01,0x04,0x8d8,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1198 {0,0,0x01,0x04,0x8db,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1199 {0,0,0x01,0x04,0x93f,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1200 {0,0,0x01,0x04,0xa39,"SetTextWindowColor"},
223b71206888 Initial import
thib
parents:
diff changeset
1201 {0,0,0x01,0x04,0xa28,"Get #INIT_MESSAGE_SPEED (original) from gameexe.ini"},
223b71206888 Initial import
thib
parents:
diff changeset
1202 {0,0,0x01,0x04,0xa29,"Get #INIT_MESSAGE_SPEED (original) from gameexe.ini"},
223b71206888 Initial import
thib
parents:
diff changeset
1203 {0,0,0x01,0x04,0xa2c,"Get #MESSAGE_KEY_WAIT_USE (original) from gameexe.ini"},
223b71206888 Initial import
thib
parents:
diff changeset
1204 {0,0,0x01,0x04,0xa2d,"Get #INIT_MESSAGE_SPEED (original) from gameexe.ini"},
223b71206888 Initial import
thib
parents:
diff changeset
1205 {0,0,0x01,0x04,0xa2e,"Get #MESSAGE_KEY_WAIT_TIME (original) from gameexe.ini"},
223b71206888 Initial import
thib
parents:
diff changeset
1206 {0,0,0x01,0x04,0x913,"Get #INIT_MESSAGE_SPEED"},
223b71206888 Initial import
thib
parents:
diff changeset
1207 {0,0,0x01,0x04,0x914,"Get #INIT_MESSAGE_SPEED_MOD"},
223b71206888 Initial import
thib
parents:
diff changeset
1208 {0,0,0x01,0x04,0x92e,"Get #MESSAGE_KEY_WAIT_USE"},
223b71206888 Initial import
thib
parents:
diff changeset
1209 {0,0,0x01,0x04,0x92f,"Get #INIT_MESSAGE_SPEED_MOD"},
223b71206888 Initial import
thib
parents:
diff changeset
1210 {0,0,0x01,0x04,0x930,"Get #MESSAGE_KEY_WAIT_TIME"},
223b71206888 Initial import
thib
parents:
diff changeset
1211 {0,0,0x01,0x04,0x8af,"Set #INIT_MESSAGE_SPEED"},
223b71206888 Initial import
thib
parents:
diff changeset
1212 {0,0,0x01,0x04,0x8b0,"Set #INIT_MESSAGE_SPEED_MOD"},
223b71206888 Initial import
thib
parents:
diff changeset
1213 {0,0,0x01,0x04,0x8ca,"Set #MESSAGE_KEY_WAIT_USE"},
223b71206888 Initial import
thib
parents:
diff changeset
1214 {0,0,0x01,0x04,0x8cb,"Set #INIT_MESSAGE_SPEED_MOD"},
223b71206888 Initial import
thib
parents:
diff changeset
1215 {0,0,0x01,0x04,0x8cc,"Set #MESSAGE_KEY_WAIT_USE"},
223b71206888 Initial import
thib
parents:
diff changeset
1216 {0,0,0x01,0x04,0x51f,"Set Name Text"},
223b71206888 Initial import
thib
parents:
diff changeset
1217 {0,0,0x01,0x04,0x51e,"Get Name Text"},
223b71206888 Initial import
thib
parents:
diff changeset
1218 {0,0,0x01,0x04,0x514,"Get Name Text"},
223b71206888 Initial import
thib
parents:
diff changeset
1219 // scn2k_grp.cc; GrpImpl::Exec()
223b71206888 Initial import
thib
parents:
diff changeset
1220 // music commands
223b71206888 Initial import
thib
parents:
diff changeset
1221 {0,0,0x01,0x14,0, "PlayBGM"},
223b71206888 Initial import
thib
parents:
diff changeset
1222 {0,0,0x01,0x14,2, "PlayBGM"},
223b71206888 Initial import
thib
parents:
diff changeset
1223 {0,0,0x01,0x14,0x05, "StopBGM"},
223b71206888 Initial import
thib
parents:
diff changeset
1224 {0,0,0x01,0x14,0x69, "FadeBGM"},
223b71206888 Initial import
thib
parents:
diff changeset
1225 {0,0,0x01,0x15,0, "PlaySE"},
223b71206888 Initial import
thib
parents:
diff changeset
1226 {0,0,0x01,0x15,2, "PlaySE"},
223b71206888 Initial import
thib
parents:
diff changeset
1227 {0,0,0x01,0x17,0, "PlayKoe"},
223b71206888 Initial import
thib
parents:
diff changeset
1228 {0,0,0x01,0x1a,1, "PlayMovie"},
223b71206888 Initial import
thib
parents:
diff changeset
1229 {0,0,0x01,0x1a,0x14, "PlayMovie"},
223b71206888 Initial import
thib
parents:
diff changeset
1230 // graphic commands
223b71206888 Initial import
thib
parents:
diff changeset
1231 {0,0,0x01,0x1e,0, "GraphicStackClear"},
223b71206888 Initial import
thib
parents:
diff changeset
1232 {0,0,0x01,0x1f,0, "GraphicStackClear"},
223b71206888 Initial import
thib
parents:
diff changeset
1233 {0,0,0x01,0x21,0x46, "LoadSurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1234 {0,0,0x01,0x21,0x49, "LoadBackSurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1235 {0,0,0x01,0x21,0x4b, "LoadForeSurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1236 {0,0,0x01,0x21,0x4c, "LoadSurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1237 {0,0,0x01,0x21,0x64, "CopySurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1238 {0,0,0x01,0x21,0x4b1,"ClearSurface"},
223b71206888 Initial import
thib
parents:
diff changeset
1239 {0,0,0x01,0x21,0x44c,"AlphaCopy"},
223b71206888 Initial import
thib
parents:
diff changeset
1240 {0,0,0x01,0x21,0x640,"SaturateCopy"},
223b71206888 Initial import
thib
parents:
diff changeset
1241 {0,0,0x01,0x21,0x196,"??? grp"},
223b71206888 Initial import
thib
parents:
diff changeset
1242 {0,0,0x01,0x22,0xc30,"ScrollEffect (Princess Bride)"},
223b71206888 Initial import
thib
parents:
diff changeset
1243 {0,0,0x01,0x22,0xc1c,"FallEffect (Princess Bride)"},
223b71206888 Initial import
thib
parents:
diff changeset
1244 {0,0,0x01,0x22,0x835,"FallEffect (Princess Bride)"},
223b71206888 Initial import
thib
parents:
diff changeset
1245 // grphic object commands
223b71206888 Initial import
thib
parents:
diff changeset
1246 {0,0,0x01,0x04,0xd2, "??? grp"},
223b71206888 Initial import
thib
parents:
diff changeset
1247 {0,0,0x01,0x04,0xd3, "??? grp"},
223b71206888 Initial import
thib
parents:
diff changeset
1248 {0,0,0x01,0x04,0xd7, "??? grp"},
223b71206888 Initial import
thib
parents:
diff changeset
1249 {0,0,0x01,0x04,0xd8, "??? grp"},
223b71206888 Initial import
thib
parents:
diff changeset
1250 {0,0,0x01,0x04,0x5e0,"GetShownGrpFlag"},
223b71206888 Initial import
thib
parents:
diff changeset
1251 {0,0,0x01,0x3d,0x0a, "ClearGrpObj"},
223b71206888 Initial import
thib
parents:
diff changeset
1252 {0,0,0x01,0x3d,0x0b, "ClearGrpObj"},
223b71206888 Initial import
thib
parents:
diff changeset
1253 {0,0,0x01,0x3e,0x0a, "ClearGrpObj"},
223b71206888 Initial import
thib
parents:
diff changeset
1254 {0,0,0x01,0x3e,0x0a, "ClearGrpObj"},
223b71206888 Initial import
thib
parents:
diff changeset
1255 {0,0,0x01,0x3c,0x01, "??? grp (CLANNAD)"},
223b71206888 Initial import
thib
parents:
diff changeset
1256 {0,0,0x01,0x47,0x3e8,"SetGrpObj_Fname"},
223b71206888 Initial import
thib
parents:
diff changeset
1257 {0,0,0x01,0x47,0x3eb,"SetGrpObj_GANname"},
223b71206888 Initial import
thib
parents:
diff changeset
1258 {0,0,0x01,0x47,0x4b0,"SetGrpObj_Text"},
223b71206888 Initial import
thib
parents:
diff changeset
1259 {0,0,0x01,0x48,0x3e8,"SetGrpObj_ForeGrp?"},
223b71206888 Initial import
thib
parents:
diff changeset
1260 {0,0,0x01,0x49,0, "StopAnimation"},
223b71206888 Initial import
thib
parents:
diff changeset
1261 {0,0,0x01,0x49,3, "QueryExecAnimation"},
223b71206888 Initial import
thib
parents:
diff changeset
1262 {0,0,0x01,0x49,0x7d3,"SetGrpObj_GAN?"},
223b71206888 Initial import
thib
parents:
diff changeset
1263 {0,0,0x01,0x49,0xbb9,"StartAnimation"},
223b71206888 Initial import
thib
parents:
diff changeset
1264 {0,0,0x01,0x49,0xbbb,"StartAnimation"},
223b71206888 Initial import
thib
parents:
diff changeset
1265 {0,0,0x01,0x49,0xbbd,"StartAnimation"},
223b71206888 Initial import
thib
parents:
diff changeset
1266 {0,0,0x01,0x51,0x3e8,"SetGrpObj_xy"},
223b71206888 Initial import
thib
parents:
diff changeset
1267 {0,0,0x01,0x51,0x3e9,"SetGrpObj_x"},
223b71206888 Initial import
thib
parents:
diff changeset
1268 {0,0,0x01,0x51,0x3ea,"SetGrpObj_y"},
223b71206888 Initial import
thib
parents:
diff changeset
1269 {0,0,0x01,0x51,0x3eb,"SetGrpObj_alpha"},
223b71206888 Initial import
thib
parents:
diff changeset
1270 {0,0,0x01,0x51,0x3ec,"SetGrpObj_visible"},
223b71206888 Initial import
thib
parents:
diff changeset
1271 {0,0,0x01,0x51,0x3ee,"SetGrpObj_xy?"},
223b71206888 Initial import
thib
parents:
diff changeset
1272 {0,0,0x01,0x51,0x3fd,"SetGrpObj_centering?"},
223b71206888 Initial import
thib
parents:
diff changeset
1273 {0,0,0x01,0x51,0x401,"SetGrpObj_textsize"},
223b71206888 Initial import
thib
parents:
diff changeset
1274 {0,0,0x01,0x51,0x40a,"SetGrpObj_clipregion"},
223b71206888 Initial import
thib
parents:
diff changeset
1275 {0,0,0x01,0x51,0x40f,"SetGrpObj_surfacenum"},
223b71206888 Initial import
thib
parents:
diff changeset
1276 {0,0,0x01,0x51,0x416,"SetGrpObj_expand"},
223b71206888 Initial import
thib
parents:
diff changeset
1277 {0,0,0x01,0x51,0x419,"SetGrpObj_rotate"},
223b71206888 Initial import
thib
parents:
diff changeset
1278 {0,0,0x01,0x52,0x3e8,"SetGrpObj_xy(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1279 {0,0,0x01,0x52,0x3ea,"SetGrpObj_y(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1280 {0,0,0x01,0x52,0x3eb,"SetGrpObj_alpha(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1281 {0,0,0x01,0x52,0x3ec,"SetGrpObj_visible(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1282 {0,0,0x01,0x52,0x3ee,"SetGrpObj_xy?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1283 {0,0,0x01,0x52,0x3fd,"SetGrpObj_centering?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1284 {0,0,0x01,0x52,0x401,"SetGrpObj_textsize(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1285 {0,0,0x01,0x52,0x408,"SetGrpObj_order (not supported)"},
223b71206888 Initial import
thib
parents:
diff changeset
1286 {0,0,0x01,0x52,0x40a,"SetGrpObj_clipregion(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1287 {0,0,0x01,0x52,0x40f,"SetGrpObj_surfacenum(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1288 {0,0,0x01,0x52,0x416,"SetGrpObj_expand(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1289 {0,0,0x01,0x52,0x419,"SetGrpObj_rotate(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1290 {0,0,0x01,0x54,0x3e8,"GetGrpObj_xy"},
223b71206888 Initial import
thib
parents:
diff changeset
1291 {0,0,0x01,0x54,0x44c,"GetGrpObj_wh"},
223b71206888 Initial import
thib
parents:
diff changeset
1292
223b71206888 Initial import
thib
parents:
diff changeset
1293 {0,0,0x02,0x3d,0x0a, "ClearGrpObj(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1294 {0,0,0x02,0x3d,0x0b, "ClearGrpObj(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1295 {0,0,0x02,0x3e,0x0a, "ClearGrpObj(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1296 {0,0,0x02,0x3e,0x0a, "ClearGrpObj(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1297 {0,0,0x02,0x3c,0x01, "??? grp (CLANNAD)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1298 {0,0,0x02,0x47,0x3e8,"SetGrpObj_Fname(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1299 {0,0,0x02,0x47,0x3eb,"SetGrpObj_GANname(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1300 {0,0,0x02,0x47,0x4b0,"SetGrpObj_Text(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1301 {0,0,0x02,0x48,0x3e8,"SetGrpObj_ForeGrp?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1302 {0,0,0x02,0x49,0, "StopAnimation(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1303 {0,0,0x02,0x49,3, "QueryExecAnimation(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1304 {0,0,0x02,0x49,0x7d3,"SetGrpObj_GAN?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1305 {0,0,0x02,0x49,0xbb9,"StartAnimation(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1306 {0,0,0x02,0x49,0xbbb,"StartAnimation(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1307 {0,0,0x02,0x49,0xbbd,"StartAnimation(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1308 {0,0,0x02,0x51,0x3e8,"SetGrpObj_xy(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1309 {0,0,0x02,0x51,0x3ea,"SetGrpObj_y(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1310 {0,0,0x02,0x51,0x3eb,"SetGrpObj_alpha(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1311 {0,0,0x02,0x51,0x3ec,"SetGrpObj_visible(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1312 {0,0,0x02,0x51,0x3ee,"SetGrpObj_xy?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1313 {0,0,0x02,0x51,0x3fd,"SetGrpObj_centering?(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1314 {0,0,0x02,0x51,0x401,"SetGrpObj_textsize(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1315 {0,0,0x02,0x51,0x40a,"SetGrpObj_clipregion(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1316 {0,0,0x02,0x51,0x40f,"SetGrpObj_surfacenum(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1317 {0,0,0x02,0x51,0x416,"SetGrpObj_expand(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1318 {0,0,0x02,0x51,0x419,"SetGrpObj_rotate(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1319 {0,0,0x02,0x52,0x3e8,"SetGrpObj_xy(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1320 {0,0,0x02,0x52,0x3ea,"SetGrpObj_y(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1321 {0,0,0x02,0x52,0x3eb,"SetGrpObj_alpha(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1322 {0,0,0x02,0x52,0x3ec,"SetGrpObj_visible(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1323 {0,0,0x02,0x52,0x3ee,"SetGrpObj_xy?(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1324 {0,0,0x02,0x52,0x3fd,"SetGrpObj_centering?(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1325 {0,0,0x02,0x52,0x401,"SetGrpObj_textsize(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1326 {0,0,0x02,0x52,0x40a,"SetGrpObj_clipregion(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1327 {0,0,0x02,0x52,0x40f,"SetGrpObj_surfacenum(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1328 {0,0,0x02,0x52,0x416,"SetGrpObj_expand(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1329 {0,0,0x02,0x52,0x419,"SetGrpObj_rotate(2)(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1330 {0,0,0x02,0x54,0x3e8,"GetGrpObj_xy(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1331 {0,0,0x02,0x54,0x44c,"GetGrpObj_wh(2)"},
223b71206888 Initial import
thib
parents:
diff changeset
1332 {0,0,0,0,0,0}
223b71206888 Initial import
thib
parents:
diff changeset
1333 };
223b71206888 Initial import
thib
parents:
diff changeset
1334 map<int, CmdDescrItem*> Cmd::cmd_descr;
223b71206888 Initial import
thib
parents:
diff changeset
1335 const char* Cmd::CmdDescr(int cmd1, int cmd2, int cmd3, int cmd4) {
223b71206888 Initial import
thib
parents:
diff changeset
1336 if (cmd_descr.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
1337 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1338 for (i=0; cmd_descr_orig[i].cmd_descr != 0; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1339 CmdDescrItem& cur = cmd_descr_orig[i];
223b71206888 Initial import
thib
parents:
diff changeset
1340 int item_num = cur.cmd1*1000000+cur.cmd2*10000+cur.cmd3;
223b71206888 Initial import
thib
parents:
diff changeset
1341 map<int,CmdDescrItem*>::iterator it = cmd_descr.find(item_num);
223b71206888 Initial import
thib
parents:
diff changeset
1342 if (it == cmd_descr.end()) cmd_descr[item_num] = &cur;
223b71206888 Initial import
thib
parents:
diff changeset
1343 else {
223b71206888 Initial import
thib
parents:
diff changeset
1344 cur.next = it->second;
223b71206888 Initial import
thib
parents:
diff changeset
1345 it->second = &cur;
223b71206888 Initial import
thib
parents:
diff changeset
1346 }
223b71206888 Initial import
thib
parents:
diff changeset
1347 }
223b71206888 Initial import
thib
parents:
diff changeset
1348 }
223b71206888 Initial import
thib
parents:
diff changeset
1349 int item_num = cmd1*1000000+cmd2*10000+cmd3;
223b71206888 Initial import
thib
parents:
diff changeset
1350 map<int,CmdDescrItem*>::iterator it = cmd_descr.find(item_num);
223b71206888 Initial import
thib
parents:
diff changeset
1351 if (it == cmd_descr.end()) return "No descr (unsupported)";
223b71206888 Initial import
thib
parents:
diff changeset
1352 CmdDescrItem* cur = it->second;
223b71206888 Initial import
thib
parents:
diff changeset
1353 do {
223b71206888 Initial import
thib
parents:
diff changeset
1354 if (cur->cmd1 == cmd1 && cur->cmd2 == cmd2 && cur->cmd3 == cmd3) {
223b71206888 Initial import
thib
parents:
diff changeset
1355 return cur->cmd_descr;
223b71206888 Initial import
thib
parents:
diff changeset
1356 }
223b71206888 Initial import
thib
parents:
diff changeset
1357 cur = cur->next;
223b71206888 Initial import
thib
parents:
diff changeset
1358 } while(cur != 0);
223b71206888 Initial import
thib
parents:
diff changeset
1359 return "No descr (unsupported)";
223b71206888 Initial import
thib
parents:
diff changeset
1360 }