Mercurial > otakunoraifu
annotate scn2k/scn2k_grp.cc @ 18:4d7486cb20a9
Sync with upstream
author | thib |
---|---|
date | Tue, 16 Sep 2008 15:30:03 +0000 |
parents | 8da1d92ac8f8 |
children | 824b89018ea8 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
28 #include"scn2k.h" | |
29 #include"window/widget.h" | |
30 #include"system/file.h" | |
31 #include"system/system_config.h" | |
32 #include"font/text.h" | |
33 #include<set> | |
34 | |
35 using namespace std; | |
36 | |
37 extern void DSurfaceFill(Surface* dest, const Rect& rect, int r, int g, int b, int a=0xff); | |
38 extern void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstpos); | |
39 extern Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect, | |
40 Surface* dst, const Rect& dstrect); | |
41 extern XKFont::HorizLayout* DefaultLayout(int text_size); | |
42 | |
43 /******************************************************************* | |
44 ** GrpObj(interface) | |
45 */ | |
46 | |
47 struct SEL { | |
48 Rect from; | |
49 Rect to; | |
50 int time; | |
51 int sel_no; | |
52 int args[8]; | |
53 SEL() : from(0,0), to(0,0) {} | |
54 }; | |
55 | |
56 struct GrpObj { | |
57 string name; | |
58 string gan_name; | |
59 PicContainer* pic_parent; | |
60 PicBase* picture; | |
61 WidAnmTime* anm; | |
62 int _posx, _posy; | |
63 int posx[9],posy[9]; | |
64 Rect clip_area; | |
65 unsigned char alpha; | |
66 int order; | |
67 int surface_num; | |
68 | |
69 string print_moji; | |
70 int print_size, print_r, print_b, print_g; | |
71 | |
72 int dig_number, dig_digit; | |
73 | |
74 // zoom / rotate 関係 | |
75 int zoom; // 256 で 1 倍 | |
76 int rotate; // 0-360度 | |
77 | |
78 vector<Rect> src_pos; | |
79 enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; | |
80 enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, HIDDEN_GROUP=8, | |
18 | 81 UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, |
82 UPDATE_ALL = (16|32|64|128|256|512), | |
0 | 83 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000, |
84 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16 | |
85 }; | |
86 Attribute attr; | |
87 | |
88 GrpImpl* parent_pimpl; | |
89 | |
90 GrpObj(void); | |
91 ~GrpObj(void); | |
92 | |
93 void SetPos(int index, int x, int y); | |
94 void GetPos(int index, int& x, int& y); | |
95 int PosX(void); | |
96 int PosY(void); | |
97 void SetAlpha(void); | |
98 void SetAlpha(int alpha); | |
99 void SetSurfaceNum(int num = -1); | |
100 void SetZoomRotate(int zoom=-1, int rotate=-1); | |
101 void SetClipArea(int x, int y, int width, int height); | |
102 void GetSrcGeom(int& width, int& height); | |
103 void SetUpdate(void); | |
104 TextStream ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size); | |
105 void UpdateMoji(void); | |
106 void UpdateDigit(void); | |
107 void UpdateSurface(void); | |
108 void ZoomRotate(void); | |
109 void Update(void); | |
110 void CreateSurface(PicContainer* parent); | |
111 void CreateGan(Event::Container& event, int event_number); | |
112 void CreateGanSpecial(Event::Container& event, int event_number, int time); | |
113 PicBase* DeletePic(void); | |
114 }; | |
115 | |
116 /******************************************************************* | |
117 ** GrpObj(interface) | |
118 */ | |
119 | |
120 | |
121 struct GrpObjMap : std::map<int, GrpObj> { | |
122 typedef pair<const int, GrpObj> value_type; | |
123 class GrpImpl* parent; | |
124 GrpObj& operator[](const int& k) { | |
125 iterator it = lower_bound(k); | |
126 if (it == end() || it->first != k) { | |
127 GrpObj obj; | |
128 obj.parent_pimpl = parent; | |
129 it = insert(it, value_type(k, obj)); | |
130 } | |
131 return it->second; | |
132 } | |
133 GrpObjMap(class GrpImpl* p) { | |
134 parent = p; | |
135 } | |
136 }; | |
137 | |
138 class GrpImpl { | |
139 #define MAXPDT 256 | |
140 #define WORKPDT 255 | |
141 Event::Container& event; | |
142 const Flags& flags; | |
143 PicBase* screen; | |
144 PicBase* screen_front; | |
145 Surface* surface, *surface_update; | |
146 | |
147 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface | |
148 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface | |
149 PicContainer& parent; | |
150 | |
151 // 画像効果の保存用 | |
152 WidAnmTime* anm1, *anm2; | |
153 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; | |
154 Status status; | |
155 SkipMode skip_mode; | |
156 | |
157 std::string bg_name; | |
158 std::map<int, SEL> anmtype; | |
159 GrpObjMap grpobj; | |
160 GrpObjMap bs_obj; | |
161 void CreateObj(int number); | |
162 void ZMoveObj(int number); | |
163 void SetObjChanged(int number); | |
164 void SetObjChangedGroup(int number); | |
165 void SwapObj(int a1, int a2); | |
166 void DeleteObjPic(int num);// object の surface のみ削除 | |
167 void DeleteObj(int num); | |
168 void DeleteObjRange(int num_b, int num_e); | |
169 | |
170 std::set<int> changed_obj; | |
171 string reserved_load_surface0; | |
172 vector<PicBase*> deleted_pic; | |
173 void RefreshObj(void); | |
174 | |
175 Surface* Dsurface(int pdt); | |
176 Surface* Ssurface(int pdt); | |
177 | |
178 // cgmode 用画像処理関連 | |
179 void LoadCgm(AyuSysConfig& config); | |
180 std::map<std::string, int> cgm_info; | |
181 set<int>& cgm_data; | |
182 | |
183 class MuSys& music; | |
184 | |
185 public: | |
186 AyuSysConfig& config; | |
187 void LoadSurface(const char* str, int pdt); | |
188 private: | |
189 void LoadSurface(const char* str); | |
190 void LoadSurface(void); | |
191 void AddSurface(const char* str); | |
192 | |
193 void StartAnm(int type); | |
194 void StartShake(int total, const int* pattern); | |
195 void AbortAnm(void); | |
196 static bool Pressed(int x, int y, void* pointer); | |
197 public: | |
198 GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); | |
199 ~GrpImpl(); | |
200 bool Wait(unsigned int current_time, Cmd& cmd); | |
201 void Exec(Cmd& cmd); | |
202 void InitSel(AyuSysConfig& config); | |
203 void Save(std::string& str); | |
204 void Load(const char* str); | |
205 void SaveSys(std::string& str); | |
206 void LoadSys(const char* str); | |
207 void SetSkipMode(SkipMode _mode); | |
208 }; | |
209 /******************************************************************* | |
210 ** GrpObj(implementation) | |
211 */ | |
212 | |
213 GrpObj::GrpObj(void) : | |
214 name(""), gan_name(""), pic_parent(0), picture(0), anm(0), | |
215 _posx(0), _posy(0), clip_area(0,0,0,0), | |
216 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1), | |
217 dig_number(0), dig_digit(0), | |
218 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN), parent_pimpl(0) { | |
219 int i; | |
220 for (i=0; i<9; i++) { | |
221 posx[i] = posy[i] = 0; | |
222 } | |
223 } | |
224 GrpObj::~GrpObj() { | |
225 if (picture) delete picture; | |
226 if (parent_pimpl == 0) { | |
227 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n"); | |
228 } | |
229 } | |
230 int GrpObj::PosX() { | |
231 return _posx; | |
232 } | |
233 int GrpObj::PosY() { | |
234 return _posy; | |
235 } | |
236 void GrpObj::SetUpdate(void) { | |
237 attr = Attribute (attr | UPDATE_PICTURE); | |
18 | 238 //Update(); //FIXME |
0 | 239 } |
240 void GrpObj::SetPos(int index, int x,int y) { | |
241 if (index < 0 || index > 8) { | |
242 fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y); | |
243 return; | |
244 } | |
245 if (x == posx[index] && y == posy[index]) return; | |
246 attr = Attribute(attr | UPDATE_POS); | |
247 _posx += x-posx[index]; | |
248 _posy += y-posy[index]; | |
249 posx[index] = x; | |
250 posy[index] = y; | |
251 } | |
252 void GrpObj::GetPos(int index, int& x, int& y) { | |
253 if (index < 0 || index > 8) { | |
254 fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index); | |
255 x = 0; y = 0; | |
256 return; | |
257 } | |
258 x = posx[index]; | |
259 y = posy[index]; | |
260 return; | |
261 } | |
262 void GrpObj::SetAlpha(int new_alpha) { | |
263 if (alpha == new_alpha) return; | |
264 alpha = new_alpha; | |
265 attr = Attribute(attr | UPDATE_ALPHA); | |
266 return; | |
267 } | |
268 void GrpObj::SetSurfaceNum(int num) { | |
269 if (num != -1) { | |
270 if (surface_num == num) return; | |
271 surface_num = num; | |
272 } | |
273 attr = Attribute(attr | UPDATE_SNUM); | |
274 return; | |
275 } | |
276 | |
277 void GrpObj::SetClipArea(int x, int y, int w, int h) { | |
278 Rect new_clip(x,y,x+w,y+h); | |
279 if (clip_area == new_clip) return; | |
280 clip_area = new_clip; | |
281 attr = Attribute(attr | UPDATE_CLIP); | |
282 return; | |
283 } | |
284 PicBase* GrpObj::DeletePic(void) { | |
285 PicBase* p = picture; | |
286 anm = 0; | |
287 picture = 0; | |
288 src_pos.clear(); | |
289 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); | |
290 return p; | |
291 } | |
292 void GrpObj::GetSrcGeom(int& width, int& height) { | |
293 if (src_pos.empty()) { | |
294 width = 0; height = 0; | |
295 if (name.length() == 0) { | |
296 return; | |
297 } | |
298 /* ボタンの位置情報を求める */ | |
299 /* g00 ファイルのヘッダ部分に位置情報は入っている */ | |
300 string path(name); | |
301 path += ".g00"; | |
302 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00"); | |
303 if (info == 0) { // ファイルが見つからない | |
304 fprintf(stderr,"GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); | |
305 return; | |
306 } | |
307 const char* data = info->Read(); | |
308 int srclen = read_little_endian_int(data+5); | |
309 if (data && *data == 2) { // 画像ファイル内にボタン情報が存在する | |
310 int srclen = read_little_endian_int(data+5); | |
311 int i; | |
312 for (i=0; i<srclen; i++) { | |
313 int x1 = read_little_endian_int(data+9+i*24+0); | |
314 int y1 = read_little_endian_int(data+9+i*24+4); | |
315 int x2 = read_little_endian_int(data+9+i*24+8); | |
316 int y2 = read_little_endian_int(data+9+i*24+12); | |
317 src_pos.push_back(Rect(x1, y1, x2+1, y2+1)); | |
318 if (width < src_pos.back().width()) width = src_pos.back().width(); | |
319 if (height < src_pos.back().height()) height = src_pos.back().height(); | |
320 } | |
321 } else { // 画像ファイルから大きさ取得 | |
322 width = read_little_endian_short(data+1); | |
323 height = read_little_endian_short(data+3); | |
324 src_pos.push_back(Rect(0,0,width,height)); | |
325 } | |
326 delete info; | |
327 } | |
328 int sn = surface_num; | |
329 if (sn < 0 || sn > src_pos.size()) sn = 0; | |
330 width = src_pos[sn].width(); | |
331 height = src_pos[sn].height(); | |
332 return; | |
333 } | |
334 void GrpObj::Update(void) { | |
335 if (attr & UPDATE_PICTURE) { | |
336 UpdateSurface(); | |
337 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); | |
338 } | |
339 if (picture == 0) return; | |
340 if (attr & UPDATE_POS) { | |
18 | 341 if ( (attr & SATURATE) || zoom != -1) { |
0 | 342 int w=0, h=0; |
343 GetSrcGeom(w,h); | |
344 picture->Move(_posx-w/2, _posy-h/2); | |
345 } else { | |
346 picture->Move(_posx, _posy); | |
347 } | |
348 } | |
349 if (attr & UPDATE_ALPHA) { | |
350 if (alpha <= 0) { | |
351 picture->SetSurfaceAlpha(0, Rect(0,0)); | |
352 picture->hide(); | |
353 } else if (alpha >= ALPHA_MAX) { | |
354 picture->SetSurfaceAlpha(0, Rect(0,0)); | |
355 if (attr & HIDDEN) picture->hide(); | |
356 else picture->show(); | |
357 } else { | |
358 picture->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); | |
359 if (attr & HIDDEN) picture->hide(); | |
360 else picture->show(); | |
361 } | |
362 } | |
363 if ( (attr & UPDATE_SNUM) && (!src_pos.empty())) { | |
364 if (surface_num < 0 || surface_num >= src_pos.size()) surface_num = 0; | |
365 picture->SetSurfacePos(src_pos[surface_num].lx, src_pos[surface_num].ty); | |
366 } | |
367 if (attr & UPDATE_CLIP) { | |
368 picture->SetClipArea(clip_area); | |
369 } | |
370 attr = Attribute(attr & (~UPDATE_ALL)); | |
371 if (attr & ANM_PLAYSTART) { | |
372 if (anm) { | |
373 anm->Play(); | |
374 attr = Attribute(attr | ANM_PLAYING); | |
375 } | |
376 attr = Attribute(attr & (~ANM_PLAYSTART)); | |
377 } | |
378 } | |
379 void GrpObj::CreateSurface(PicContainer* parent) { | |
380 if (picture) { | |
381 PicBase* p = DeletePic(); | |
382 delete p; | |
383 } | |
384 src_pos.clear(); | |
385 // picture を作成 | |
386 pic_parent = parent; | |
387 picture = parent->create_leaf(Rect(_posx,_posy,_posx+1,_posy+1), 0); | |
388 picture->hide(); | |
389 UpdateSurface(); | |
390 } | |
391 | |
392 void GrpObj::UpdateSurface(void) { | |
393 if (pic_parent == 0 || picture == 0) return; | |
394 int width = 0, height = 0; | |
395 if (gtype == FILE || gtype == GAN) { | |
396 if (name.length() == 0) return; | |
397 // ファイル名が存在する場合、ファイルを読み込み | |
398 GetSrcGeom(width, height); | |
399 if (width <= 0 || height <= 0) return; | |
400 // surface の設定 | |
401 if (surface_num == 0 && ( (zoom > 0 && zoom != 256) || rotate > 0)) { | |
402 ZoomRotate(); | |
403 } else { | |
404 // 普通に surface を設定 | |
405 string path(name); | |
406 path += ".g00"; | |
407 picture->SetSurface(path.c_str(), 0, 0); | |
408 picture->SetSurfaceRect(Rect(0,0,width,height)); | |
409 } | |
410 if (attr & SATURATE) | |
411 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); | |
412 } else if (gtype == MOJI) { // テキスト描画 | |
413 if (print_moji.length() == 0) return; | |
414 UpdateMoji(); | |
415 } else if (gtype == DIGIT) { // 数値を画像表示 | |
416 UpdateDigit(); | |
417 } | |
418 } | |
419 void GrpObj::ZoomRotate(void) { | |
420 picture->SetSurface( (Surface*)0,0,0); | |
421 | |
422 // 回転、縮小拡大は座標原点が画像の中心になる | |
423 string path(name); | |
424 path += ".g00"; | |
425 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | |
426 if (surface_orig == 0) return; | |
427 | |
428 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); | |
429 Rect zoom_r (*zoom_surface); | |
430 picture->SetSurface(zoom_surface, 0, 0); | |
431 picture->SetSurfaceFreeFlag(); | |
432 //picture->Move(PosX() + - zoom_r.width()/2, PosY() + - zoom_r.height()/2); | |
433 // 中心座標がわからん・・・ | |
434 picture->Move(320 - zoom_r.width()/2, 240 - zoom_r.height()/2); | |
435 picture->SetSurfaceRect(Rect(0, 0, zoom_r.width(), zoom_r.height())); | |
436 | |
437 pic_parent->Root().DeleteSurface(surface_orig); | |
438 } | |
439 | |
440 static char* wstrchr(const char* s, unsigned int chr) { | |
441 int ws, wc; | |
442 while(*s != 0) { | |
443 if (*s < 0 && s[1] != 0) { | |
444 wc = int((unsigned char)(s[0]))*0x100 + int((unsigned char)(s[1])); | |
445 ws = 2; | |
446 } else { | |
447 wc = (unsigned char)(s[0]); | |
448 ws = 1; | |
449 } | |
450 if (wc == chr) return (char*)s; | |
451 s += ws; | |
452 } | |
453 return 0; | |
454 } | |
455 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse | |
456 TextStream ts; | |
457 ts.kanji_type = TextStream::sjis; | |
458 ts.SetColor(def_r, def_g, def_b); | |
459 char* copy_str = new char[strlen(str)+1]; | |
460 char* next_str; | |
461 char* retptr; | |
462 int var; | |
463 | |
464 while( (next_str = wstrchr(str, '#')) != 0) { | |
465 int len = next_str - str; | |
466 strncpy(copy_str, str, len); | |
467 copy_str[len] = 0; | |
468 ts.Add(copy_str); | |
469 str = next_str + 1; | |
470 | |
471 switch(str[0]) { | |
472 case '#': // separator | |
473 str += 1; | |
474 break; | |
475 case 'D': case 'd': // return | |
476 ts.AddReturn(); | |
477 str += 1; | |
478 break; | |
479 case 'C': case 'c': // color | |
480 str += 1; | |
481 var = strtol(str, &next_str,10); | |
482 if (var == 0 && str == next_str) { // no parameter | |
483 ts.SetColor(def_r, def_g, def_b); | |
484 } else { | |
485 int r,g,b; char key[1024]; | |
486 sprintf(key, "#COLOR_TABLE.%03d", var); | |
487 if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found | |
488 r = g = b = 0; | |
489 } | |
490 ts.SetColor(r,g,b); | |
491 str = next_str; | |
492 } | |
493 break; | |
494 case 'S': case 's': // size | |
495 str += 1; | |
496 var = strtol(str, &next_str, 10); | |
497 if (var == 0 && str == next_str) { // no parameter | |
498 ts.SetSize(1); | |
499 } else { | |
500 if (def_size == 0) def_size = 20; | |
501 if (var <= 0) var = 1; | |
502 ts.SetSize(double(var)/def_size); | |
503 } | |
504 break; | |
505 case 'X': case 'x': // xpos : not supported | |
506 case 'Y': case 'y': // ypos : not supported | |
507 default: | |
508 ts.Add("#"); | |
509 break; | |
510 } | |
511 } | |
512 ts.Add(str); | |
513 return ts; | |
514 } | |
515 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 | |
14
8da1d92ac8f8
Don't create fonts faces for size <= 0, and update objects when their font size is set
thib
parents:
11
diff
changeset
|
516 if (print_moji.length() == 0 || print_size <= 2) return; |
0 | 517 if (pic_parent == 0) return; |
518 /* テキストの大きさを得る */ | |
519 int r, g, b; | |
520 if (print_r == -1 || print_g == -1 || print_b == -1) {// 色設定なし | |
521 r = g = b = 0; // とりあえず黒(clannad のSave/Loadメニュー用) | |
522 } else { | |
523 r = print_r; | |
524 g = print_g; | |
525 b = print_b; | |
526 } | |
527 TextStream ts = ParseMoji(print_moji.c_str(), r, g, b, print_size); | |
528 TextGlyphStream gs; | |
529 vector<int> lh; | |
530 // とりあえず drawable width は充分に大きく(2048)取る | |
531 DefaultLayout(print_size-2)->Layout(ts, gs, lh, 2048); // print_size そのままだと弱干大きすぎるので -2 | |
532 int width = gs.width(); | |
533 int height = gs.height(); | |
534 Surface* surface = pic_parent->Root().NewSurface(width, height, ALPHA_MASK); | |
535 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | |
536 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0, 0, width, height), surface, Rect(0,0)); | |
537 picture->SetSurface(surface, 0, 0); | |
538 picture->SetSurfaceRect(Rect(0,0,width,height)); | |
539 picture->SetSurfaceFreeFlag(); | |
540 } | |
541 void GrpObj::UpdateDigit(void) { | |
542 // 画像表示の数値文字列を表示する | |
543 if (name.length() == 0) return; | |
544 // ファイル名が存在する場合、ファイルを読み込み | |
545 string path(name); | |
546 path += ".g00"; | |
547 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | |
548 if (surface_orig == 0) return; | |
549 | |
550 int width, height; | |
551 int i; | |
552 GetSrcGeom(width, height); | |
553 if (width <= 0 || height <= 0) return; | |
554 if (src_pos.size() < 14) { | |
555 // 必要な数の object がない | |
556 // 表示できない分の空の rect を追加しておく | |
557 for (i=src_pos.size(); i<14; i++) | |
558 src_pos.push_back(Rect(0,0,0,0)); | |
559 pic_parent->Root().DeleteSurface(surface_orig); | |
560 return; | |
561 } | |
562 // 桁数の計算 | |
563 char num_str[20]; | |
564 if (dig_number < 0) sprintf(num_str, "%d", -dig_number); | |
565 else sprintf(num_str, "%d", dig_number); | |
566 int sign_count = 0; | |
567 int space_count = 0; | |
568 int total_count; | |
569 int dig_count = strlen(num_str); | |
570 if (dig_number < 0 && (attr&DIG_SIGN) == 0) dig_count++; | |
571 if (dig_count < dig_digit) space_count = dig_digit - dig_count; | |
572 if (attr & DIG_SIGN) sign_count = 1; | |
573 total_count = dig_count + space_count + sign_count; | |
574 | |
575 Surface* surface = pic_parent->Root().NewSurface(width*total_count, height, ALPHA_MASK); | |
576 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | |
577 | |
578 /* surface にコピーする */ | |
579 int cur_x = 0; | |
580 if ( (attr & DIG_PACK) && !(attr & DIG_ZERO)) { // 始めに空白を挿入 | |
581 cur_x += space_count * width; | |
582 } | |
583 int plus = 10, minus = 11, plusminus = 12; | |
584 if (dig_number < 0) { | |
585 DSurfaceMove(surface, src_pos[minus], surface, Rect(cur_x,0)); | |
586 cur_x += width; | |
587 } else if (attr & DIG_SIGN) { | |
588 if (dig_number == 0) | |
589 DSurfaceMove(surface, src_pos[plusminus], surface, Rect(cur_x,0)); | |
590 else | |
591 DSurfaceMove(surface, src_pos[plus], surface, Rect(cur_x,0)); | |
592 cur_x += width; | |
593 } | |
594 if (attr & DIG_ZERO) { // ゼロ・パディング | |
595 for (i=0; i<space_count; i++) { | |
596 DSurfaceMove(surface, src_pos[0], surface, Rect(cur_x, 0)); | |
597 cur_x += width;; | |
598 } | |
599 } else if (!(attr & DIG_PACK)) { // PACK オプションなし | |
600 cur_x += space_count * width; | |
601 } | |
602 for (i=0; num_str[i] != 0; i++) { | |
603 DSurfaceMove(surface_orig, src_pos[num_str[i]-'0'], surface, Rect(cur_x, 0)); | |
604 cur_x += width; | |
605 } | |
606 | |
607 /* picture に設定 */ | |
608 picture->SetSurface(surface, 0, 0); | |
609 picture->SetSurfaceRect(Rect(0,0,width*total_count,height)); | |
610 picture->SetSurfaceFreeFlag(); | |
611 | |
612 pic_parent->Root().DeleteSurface(surface_orig); | |
613 } | |
614 void GrpObj::CreateGan(Event::Container& event, int event_number) { | |
615 if (picture == 0) { | |
616 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); | |
617 return; | |
618 } | |
619 if (anm) { | |
620 anm->Abort(); | |
621 delete anm; | |
622 } | |
623 if (gan_name.empty()) return; | |
624 /* アニーメション情報 (.GAN ファイル)を求める */ | |
625 string path(gan_name); | |
626 path += ".gan"; | |
627 ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan"); | |
628 if (info == 0) { | |
629 fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str()); | |
630 return; | |
631 } | |
632 const char* data = info->Read(); | |
633 if (read_little_endian_int(data) != 10000 || read_little_endian_int(data+4) != 10000) { | |
634 fprintf(stderr,"GrpObj::CreateGan: Invalid'GAN' file %s\n", path.c_str()); | |
635 delete info; | |
636 return; | |
637 } | |
638 | |
639 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); | |
640 attr = Attribute(attr | UPDATE_POS | SATURATE); | |
641 | |
642 const char* buf = data + 16; | |
643 buf += strlen(buf) + 1; // 画像ファイル名が入っている | |
644 buf += 4; // 定数 20000 | |
645 int pics = read_little_endian_int(buf); buf += 4; // 複数のアニメーション情報が入っている場合、情報数 | |
646 // 以下、pics 回繰り返し | |
647 // アニメーションを行う実体を作成 | |
648 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); | |
649 | |
650 if (event_number && event_number < pics) { // 複数のアニメーション情報がある場合、先の情報を読み飛ばす */ | |
651 int i; for (i=0; i<event_number; i++) { | |
652 buf += 4; // 定数 30000 | |
653 int ptns = read_little_endian_int(buf); buf += 4; | |
654 buf += ptns*52; | |
655 } | |
656 } | |
657 buf += 4; // 定数 30000 | |
658 int ptns = read_little_endian_int(buf); buf += 4; | |
659 int total_time = 0; | |
660 int i; | |
661 for (i=0; i<ptns; i++) { | |
662 int p = read_little_endian_int(buf+i*52+0*8+4); | |
663 int x = read_little_endian_int(buf+i*52+1*8+4); | |
664 int y = read_little_endian_int(buf+i*52+2*8+4); | |
665 int t = read_little_endian_int(buf+i*52+3*8+4); | |
666 int a = read_little_endian_int(buf+i*52+4*8+4); | |
667 x += PosX(); | |
668 y += PosY(); | |
669 if (p == -1) { a = 0; p = 0; } // p == -1 ならなにも表示しない | |
670 if (p >= src_pos.size()) { | |
671 fprintf(stderr,"Reading GAN file %s (G00 %s) : not enough pictures in .G00 file\n", path.c_str(), name.c_str()); | |
672 a = 0; p = 0; | |
673 } | |
674 total_time += t; | |
675 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), src_pos[p], a, total_time)); | |
676 } | |
677 wid->SetPtn(); // パターン登録終了 | |
678 attr = Attribute(attr | ANM_PLAYSTART); | |
679 anm = wid; | |
680 }; | |
681 void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) { | |
682 if (picture == 0) { | |
683 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); | |
684 return; | |
685 } | |
686 if (anm) { | |
687 anm->Abort(); | |
688 delete anm; | |
689 } | |
690 | |
691 // アニメーションを行う実体を作成 | |
692 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); | |
693 | |
694 int i; | |
695 switch(event_number) { | |
696 case 0: // pattern を 0 から最後まで変化させる | |
697 for (i=0; i<src_pos.size(); i++) { | |
698 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); | |
699 } | |
700 wid->SetPtn(); // パターン登録終了 | |
701 anm = wid; | |
702 attr = Attribute(attr | ANM_PLAYSTART); | |
703 break; | |
704 default: | |
705 break; | |
706 } | |
707 return; | |
708 }; | |
709 | |
710 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { | |
711 if (zoom == new_zoom && rotate == new_rotate) return; | |
18 | 712 if ( zoom == -1 || new_zoom == -1) { |
713 attr = Attribute(attr | UPDATE_POS); // centering する | |
714 } | |
715 zoom = new_zoom; | |
0 | 716 if (new_rotate != -1) rotate = new_rotate; |
717 if (zoom < 0) zoom = 256; | |
718 if (rotate < 0) rotate = 0; | |
719 else if (rotate > 360) rotate %= 360; | |
720 | |
721 attr = Attribute(attr | UPDATE_PICTURE); | |
722 return; | |
723 } | |
724 /****************************************************************** | |
725 ** | |
726 ** class ScnGrp* | |
727 */ | |
728 /* Princess Bride: 背景画の一部のみ移動、の実装 */ | |
729 struct ScnGrpMove : public WidAnmTime { | |
730 Surface* dest; | |
731 Surface* src; | |
732 PicRoot& root; | |
733 Rect dest_r, from, to; | |
734 ScnGrpMove(Event::Container& container, PicBase* _pic, PicRoot& root, Surface* dest, const Rect& _dest_r, Surface* src, const Rect& from, const Rect& to, int total_time); | |
735 void Exec(int count); | |
736 }; | |
737 ScnGrpMove::ScnGrpMove(Event::Container& container, PicBase* _pic, PicRoot& _root, Surface* _dest, const Rect& _dest_r, Surface* _src, const Rect& _from, const Rect& _to, int total_time) : | |
738 WidAnmTime(container, _pic, total_time), | |
739 dest(_dest), src(_src), root(_root),dest_r(_dest_r), from(_from), to(_to) { | |
740 int dx = to.lx - from.lx; | |
741 int dy = to.ty - from.ty; | |
742 if (dx < 0) dx = -dx; | |
743 if (dy < 0) dy = -dy; | |
744 if (dx < dy) dx = dy; | |
745 if (dx == 0) dx = 1; | |
746 SetAllCount(dx); | |
747 } | |
748 void ScnGrpMove::Exec(int count) { | |
749 Rect r(0,0,dest_r.width(),dest_r.height()); | |
750 int dx = to.lx - from.lx; | |
751 int dy = to.ty - from.ty; | |
752 int x = dx*count/all_count + from.lx; | |
753 int y = dy*count/all_count + from.ty; | |
754 r.rmove(x, y); | |
755 root.BlitSurface(src, r, dest, dest_r); | |
756 iterator it; | |
757 for (it=pic.begin(); it!=pic.end(); it++) | |
758 (*it)->SetSurface(dest, 0, 0); | |
759 } | |
760 | |
761 /* Princess Bride: カードがおちるアニメーション */ | |
762 | |
763 struct ScnGrpAnmAtom { | |
764 string name; | |
765 int time; | |
766 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} | |
767 }; | |
768 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { | |
769 GrpImpl& owner; | |
770 ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) : | |
771 WidAnmTime(container, _pic, 0), owner(_owner) { | |
772 } | |
773 void CalcTotal(void); | |
774 void Exec(int count); | |
775 }; | |
776 void ScnGrpAnm::CalcTotal(void) { | |
777 /* total time を計算 */ | |
778 if (empty()) return; | |
779 int tm = 0; | |
780 vector<ScnGrpAnmAtom>::iterator it; | |
781 for (it=begin(); it != end(); it++) tm += it->time; | |
782 total_time = tm; | |
783 SetAllCount(tm); | |
784 } | |
785 void ScnGrpAnm::Exec(int count) { | |
786 int tm = 0; vector<ScnGrpAnmAtom>::iterator it; | |
787 for (it=begin(); it != end(); it++) { | |
788 tm += it->time; | |
789 if (count < tm) break; | |
790 } | |
791 if (it == end()) it--; | |
792 owner.LoadSurface(it->name.c_str(), 0); | |
793 } | |
794 | |
795 | |
796 /***************************************************** | |
797 * | |
798 * GrpImpl(implementation) : 定義 | |
799 * | |
800 */ | |
801 | |
802 #include"music2/music.h" | |
803 | |
804 GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) : | |
805 event(_event), | |
806 flags(f), | |
807 parent(_parent), | |
808 status(NORMAL), | |
809 skip_mode(SKIP_NO), | |
810 music(_mu), | |
811 cgm_data(_cgm_data), | |
812 grpobj(this), | |
813 bs_obj(this), | |
814 config(_config) | |
815 { | |
816 int i; | |
817 for (i=0; i<MAXPDT; i++) { | |
818 ssurface[i] = 0; | |
819 dsurface[i] = 0; | |
820 } | |
821 screen = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
822 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
823 surface = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
824 surface_update = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
825 DSurfaceFill(surface, Rect(*surface), 0, 0, 0); | |
826 DSurfaceFill(surface_update, Rect(*surface), 0, 0, 0); | |
827 screen->SetSurface(surface, 0, 0); | |
828 screen->show(); | |
829 screen_front->hide(); | |
830 screen_front->ZMove(screen); | |
831 | |
832 LoadCgm(config); | |
833 | |
834 anm1 = 0; anm2 = 0; | |
835 } | |
836 | |
837 GrpImpl::~GrpImpl() { | |
838 | |
839 map<int,GrpObj>::iterator it; | |
840 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
841 PicBase* p = it->second.DeletePic(); | |
842 delete p; | |
843 } | |
844 | |
845 delete screen; | |
846 delete screen_front; | |
847 parent.Root().DeleteSurface(surface); | |
848 int i; | |
849 for (i=0; i<MAXPDT; i++) { | |
850 if (ssurface[i]) parent.Root().DeleteSurface(ssurface[i]); | |
851 if (dsurface[i]) parent.Root().DeleteSurface(dsurface[i]); | |
852 } | |
853 } | |
854 | |
855 Surface* GrpImpl::Dsurface(int pdt) { | |
856 if (pdt == 0) return surface; | |
857 if (dsurface[pdt] == 0) { // とりあえず画面の大きさということにする | |
858 if (pdt == WORKPDT) | |
859 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), ALPHA_MASK); | |
860 else | |
861 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
862 } | |
863 if (ssurface[pdt]) { // ssurface が存在すれば、dsurface にコピーして返す | |
864 DSurfaceMove(ssurface[pdt], Rect(*ssurface[pdt]), dsurface[pdt], Rect(0,0)); | |
865 parent.Root().DeleteSurface(ssurface[pdt]); | |
866 ssurface[pdt] = 0; | |
867 } | |
868 return dsurface[pdt]; | |
869 } | |
870 #include<SDL.h> | |
871 Surface* GrpImpl::Ssurface(int pdt) { | |
872 if (pdt == 0) return surface; | |
873 if (ssurface[pdt]) { | |
874 return ssurface[pdt]; | |
875 } | |
876 return Dsurface(pdt); | |
877 } | |
878 | |
879 void GrpImpl::LoadSurface(const char* str, int pdt) { | |
880 string s = str; | |
881 if (cgm_info.find(s) != cgm_info.end()) { | |
882 cgm_data.insert(cgm_info[s]); | |
883 } | |
884 Surface* bg = parent.Root().NewSurface(s.c_str()); | |
885 if (bg == 0) { | |
886 s += ".g00"; | |
887 bg = parent.Root().NewSurface(s.c_str()); | |
888 } | |
889 if (bg) { | |
890 if (ssurface[pdt]) parent.Root().DeleteSurface(ssurface[pdt]); | |
891 ssurface[pdt] = bg; | |
892 if (pdt == 0) { | |
893 /* とりあえず Princess Bride のアニメーション効果専用 */ | |
894 Rect r(*ssurface[0]); | |
895 Rect dr(*surface); | |
896 int x = (dr.width()-r.width())/2; | |
897 int y = (dr.height()-r.height())/2; | |
898 DSurfaceMove(ssurface[0], r, surface, Rect(x,y)); | |
899 parent.Root().DeleteSurface(ssurface[0]); | |
900 ssurface[0] = 0; | |
901 screen->SetSurface(surface, 0, 0); | |
902 } | |
903 } else { | |
904 if (str[0] != 0) | |
905 fprintf(stderr,"Cannot find surface %d <- '%s'\n",pdt,str); | |
906 } | |
907 return; | |
908 } | |
909 void GrpImpl::InitSel(AyuSysConfig& config) { | |
910 int i; int args[16]; char key[1024]; | |
911 for (i=0; i<999; i++) { | |
912 sprintf(key, "#SEL.%03d",i); | |
913 if (config.GetParam(key, 15, &args[0], &args[1], | |
914 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], | |
915 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], | |
916 &args[14])) { | |
917 | |
918 sprintf(key, "#SELR.%03d", i); | |
919 if (config.GetParam(key, 16, &args[0], &args[1], | |
920 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], | |
921 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], | |
922 &args[14], &args[15])) continue; | |
923 } | |
924 SEL& s = anmtype[i]; | |
925 s.from = Rect(args[0], args[1], args[2]+1, args[3]+1); | |
926 s.to = Rect(args[4], args[5]); | |
927 s.time = args[6]; | |
928 s.sel_no = args[7]; | |
929 int j; for (j=0; j<8; j++) s.args[j] = args[8+j]; | |
930 } | |
931 return; | |
932 } | |
933 void GrpImpl::SetSkipMode(SkipMode _mode) { | |
934 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { | |
935 RefreshObj(); | |
936 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) { | |
937 } | |
938 skip_mode = _mode; | |
939 } | |
940 void GrpImpl::SetObjChanged(int num) { | |
941 changed_obj.insert(num); | |
942 } | |
943 void GrpImpl::SetObjChangedGroup(int num) { | |
944 if (num % 1000 != 0) { | |
945 SetObjChanged(num); | |
946 return; | |
947 } | |
948 std::map<int, GrpObj>::iterator begin,end,it; | |
949 begin = grpobj.lower_bound(num); | |
950 end = grpobj.lower_bound(num+1000); | |
951 for (it=begin;it!=end;it++) { | |
952 changed_obj.insert(it->first); | |
953 } | |
954 } | |
955 void GrpImpl::RefreshObj(void) { | |
956 if (!deleted_pic.empty()) { | |
957 vector<PicBase*>::iterator it; | |
958 for (it=deleted_pic.begin(); it!=deleted_pic.end(); it++) { | |
959 if (*it) delete *it; | |
960 } | |
961 deleted_pic.clear(); | |
962 } | |
963 if (!changed_obj.empty()) { | |
964 set<int>::iterator it; | |
965 for (it=changed_obj.begin(); it != changed_obj.end(); it++) { | |
966 if (grpobj.find(*it) == grpobj.end()) continue; | |
967 GrpObj& obj = grpobj[*it]; | |
968 GrpObj& parent_obj = grpobj[ ((*it)/1000) * 1000]; | |
969 if (obj.picture == 0) continue; | |
970 if (obj.alpha == 0 || (obj.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) { | |
971 if (obj.attr & GrpObj::ANM_PLAYING) { | |
972 obj.attr = GrpObj::Attribute(obj.attr & ~(GrpObj::ANM_PLAYING)); | |
973 if (obj.anm) obj.anm->Abort(); | |
974 } | |
975 obj.picture->hide(); | |
976 } else { | |
977 obj.Update(); | |
978 obj.picture->show(); | |
979 } | |
980 } | |
981 changed_obj.clear(); | |
982 } | |
983 if (reserved_load_surface0.length() != 0) { | |
984 LoadSurface(reserved_load_surface0.c_str(), 0); | |
985 reserved_load_surface0 = ""; | |
986 } | |
987 screen->ReBlit(); | |
988 } | |
989 | |
990 | |
991 #include<SDL.h> | |
992 void GrpImpl::StartAnm(int type) { | |
993 SEL sel; | |
994 | |
995 if (anmtype.find(type) == anmtype.end()) { | |
996 if (anmtype.find(0) == anmtype.end()) { | |
997 sel.sel_no = 1; | |
998 sel.from = Rect(*surface); | |
999 sel.to = Rect(0,0); | |
1000 sel.time = 0; | |
1001 } else { | |
1002 sel = anmtype[0]; | |
1003 } | |
1004 } else { | |
1005 sel = anmtype[type]; | |
1006 } | |
1007 if (anm1) { | |
1008 fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n"); | |
1009 anm1->Abort(); | |
1010 delete anm1; | |
1011 anm1 = 0; | |
1012 } | |
1013 map<int,GrpObj>::iterator it; | |
1014 // 現在表示中のobjectを消去 | |
1015 deleted_pic.push_back(screen); | |
1016 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1017 if (! (it->second.attr & GrpObj::WIPEON)) { // 画像切り替え時に object 削除 | |
1018 deleted_pic.push_back(it->second.DeletePic()); | |
1019 } else { | |
1020 GrpObj& new_obj = bs_obj[it->first]; | |
1021 if (new_obj.name.empty()) { // 新しい object が存在しなければ内容を引き継ぐ | |
1022 new_obj = it->second; | |
1023 it->second.DeletePic(); | |
1024 } else { | |
1025 new_obj.attr = GrpObj::Attribute(new_obj.attr | GrpObj::WIPEON); | |
1026 deleted_pic.push_back(it->second.DeletePic()); | |
1027 } | |
1028 } | |
1029 } | |
1030 grpobj.clear(); // 全オブジェクト削除 | |
1031 | |
1032 // 全画像オブジェクトの前にscreen 移動 | |
1033 // 新しい screen_front を作成しておく | |
1034 screen = screen_front; | |
1035 screen->hide(); | |
1036 screen->SetSurface(surface_update, 0, 0); | |
1037 parent.Root().BlitSurface(Dsurface(1), Rect(*surface_update), surface_update, Rect(0,0)); | |
1038 | |
1039 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
1040 screen_front->hide(); | |
1041 screen_front->ZMove(screen); | |
1042 | |
1043 // 新しい object へ更新、surface_update へ新しい object を表示 | |
1044 // (object 作成時は picture は hide されている) | |
1045 for (it=bs_obj.begin(); it!=bs_obj.end(); it++) { | |
1046 grpobj[it->first] = it->second; | |
1047 it->second.DeletePic(); | |
1048 CreateObj(it->first); | |
1049 GrpObj& g = grpobj[it->first]; | |
1050 GrpObj& parent_obj = grpobj[ (it->first/1000) * 1000]; | |
1051 if (g.picture) { | |
1052 g.Update(); | |
1053 if (g.alpha == 0 || (g.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) ; | |
1054 else g.picture->SimpleBlit(surface_update); | |
1055 g.picture->hide(); | |
1056 } | |
1057 } | |
1058 bs_obj.clear(); | |
1059 // 画像効果開始 | |
1060 switch(sel.sel_no) { | |
1061 default: | |
1062 case 0: case 50: // 0 と 50 の違いが良くわからない | |
1063 if (skip_mode & SKIP_GRP_NOEFFEC) | |
1064 anm1 = new WidAnmAlpha(event, screen, ALPHA_MAX, ALPHA_MAX, 0); | |
1065 else if (skip_mode & SKIP_GRP_FAST) | |
1066 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time/4); | |
1067 else | |
1068 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time); | |
1069 break; | |
1070 } | |
1071 if (anm1) anm1->Play(); | |
1072 if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm(); | |
1073 } | |
1074 void GrpImpl::StartShake(int total, const int* pattern) { | |
1075 if (anm2) { | |
1076 fprintf(stderr,"Warning: StartShake() called before another animation finished\n"); | |
1077 anm2->Abort(); | |
1078 delete anm2; | |
1079 anm2 = 0; | |
1080 } | |
1081 if (skip_mode & SKIP_GRP_NOEFFEC) return; | |
1082 AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす | |
1083 int i; int tm = 0; | |
1084 for (i=0; i<total; i+=3) { | |
1085 int x = pattern[i]; | |
1086 int y = pattern[i+1]; | |
1087 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), Rect(0,0), 255, tm)); | |
1088 tm += pattern[i+2]; | |
1089 } | |
1090 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(0,0), Rect(0,0), 255, tm)); | |
1091 new_anm->SetPtn(); // パターン登録終了 | |
1092 new_anm->Play(); | |
1093 anm2 = new_anm; | |
1094 } | |
1095 void GrpImpl::AbortAnm(void) { | |
1096 if (anm1 == 0) return; | |
1097 anm1->Abort(); | |
1098 delete anm1; | |
1099 anm1 = 0; | |
1100 /* 画像効果終了 */ | |
1101 /* 古い画面への画像効果があれば消去 */ | |
1102 if (anm2 && anm2->pic[0] != screen) { | |
1103 anm2->Abort(); | |
1104 delete anm2; | |
1105 anm2 = 0; | |
1106 } | |
1107 /* pdt1 -> pdt0 へコピー */ | |
1108 DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0)); | |
1109 screen->SetSurface(surface, 0, 0); | |
1110 // 画像効果開始時に存在したobjectを消去 | |
1111 // 新しい object 表示 | |
1112 RefreshObj(); | |
1113 return; | |
1114 } | |
1115 void GrpImpl::LoadSurface(const char* str) { | |
1116 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1117 LoadSurface(str, 1); | |
1118 bg_name = str; | |
1119 } | |
1120 void GrpImpl::LoadSurface(void) { | |
1121 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1122 LoadSurface(bg_name.c_str(), 1); | |
1123 } | |
1124 void GrpImpl::AddSurface(const char* str) { | |
1125 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1126 LoadSurface(bg_name.c_str()); | |
1127 | |
1128 string s = str; | |
1129 Surface* front = parent.Root().NewSurface(s.c_str()); | |
1130 if (front == 0) { | |
1131 s += ".g00"; | |
1132 front = parent.Root().NewSurface(s.c_str()); | |
1133 } | |
1134 if (front) { | |
1135 parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0)); | |
1136 parent.Root().DeleteSurface(front); | |
1137 } else { | |
1138 fprintf(stderr,"Cannot find surface %s\n",str); | |
1139 } | |
1140 } | |
1141 | |
1142 void GrpImpl::CreateObj(int index) { | |
1143 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | |
1144 if (cur == grpobj.end()) return; | |
1145 GrpObj& g = grpobj[index]; | |
1146 g.CreateSurface(&parent); | |
1147 g.order = index; | |
1148 if (g.picture == 0) return; // エラー:surface が存在しない | |
1149 g.picture->hide(); | |
1150 SetObjChanged(index); | |
1151 ZMoveObj(index); | |
1152 return; | |
1153 } | |
1154 void GrpImpl::ZMoveObj(int index) { | |
1155 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | |
1156 if (cur == grpobj.end()) return; | |
1157 GrpObj& g = grpobj[index]; | |
1158 if (g.picture == 0) return; | |
1159 // 自分より前に object があれば、その前に表示 | |
1160 // そうでなければ screen の前に表示 | |
1161 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); | |
1162 std::map<int, GrpObj>::iterator it; | |
1163 for (it = grpobj.begin(); it != grpobj.end(); it++) { | |
1164 if (it == cur) continue; | |
1165 if (it->second.picture == 0) continue; | |
1166 if (it->second.order < g.order) { | |
1167 if (cur_backobj == grpobj.end()) { | |
1168 cur_backobj = it; | |
1169 } else if (cur_backobj->second.order < it->second.order) { | |
1170 cur_backobj = it; | |
1171 } | |
1172 } | |
1173 } | |
1174 if (cur_backobj == grpobj.end()) { | |
1175 g.picture->ZMove(screen); | |
1176 } else { | |
1177 g.picture->ZMove(cur_backobj->second.picture); | |
1178 } | |
1179 return; | |
1180 } | |
1181 void GrpImpl::SwapObj(int index1, int index2) { | |
1182 // デフォルト値から order が変更されていた場合のみ、order は保存される | |
1183 // まずは両方のobjectをswap | |
1184 if (grpobj.find(index1) == grpobj.end()) { | |
1185 if (grpobj.find(index2) == grpobj.end()) return; // どちらの object も存在しない | |
1186 grpobj[index1] = grpobj[index2]; | |
1187 if (grpobj[index1].order == index2) | |
1188 grpobj[index1].order = index1; | |
1189 grpobj[index2].DeletePic(); | |
1190 grpobj.erase(index2); | |
1191 ZMoveObj(index1); | |
1192 return; | |
1193 } else if (grpobj.find(index2) == grpobj.end()) { // index2 が存在しない場合 | |
1194 grpobj[index2] = grpobj[index1]; | |
1195 if (grpobj[index2].order == index1) | |
1196 grpobj[index2].order = index2; | |
1197 grpobj[index1].DeletePic(); | |
1198 grpobj.erase(index1); | |
1199 ZMoveObj(index2); | |
1200 return; | |
1201 } else { | |
1202 GrpObj obj = grpobj[index1]; | |
1203 grpobj[index1] = grpobj[index2]; | |
1204 grpobj[index2].DeletePic(); | |
1205 if (grpobj[index1].order == index2) | |
1206 grpobj[index1].order = index1; | |
1207 ZMoveObj(index1); | |
1208 grpobj[index2] = obj; | |
1209 if (grpobj[index2].order == index1) | |
1210 grpobj[index2].order = index2; | |
1211 ZMoveObj(index2); | |
1212 obj.DeletePic(); | |
1213 } | |
1214 } | |
1215 | |
1216 bool GrpImpl::Pressed(int x, int y, void* pointer) { // マウスクリックでキャンセル | |
1217 GrpImpl* g = (GrpImpl*)pointer; | |
1218 if (g->status == WAIT_MOVIE) | |
1219 g->music.StopMovie(); | |
1220 if (g->status == WAIT_ANM) | |
1221 g->AbortAnm(); | |
1222 if (g->status == WAIT_SHAKE && g->anm2 != 0) { | |
18 | 1223 g->anm2->Abort(); |
0 | 1224 delete g->anm2; |
1225 g->anm2 = 0; | |
1226 } | |
1227 return false; // event deleted | |
1228 } | |
1229 | |
1230 /* mode.cgm の decode 用 */ | |
1231 static unsigned char decode_char[256] = { | |
1232 0x8b, 0xe5, 0x5d, 0xc3, 0xa1, 0xe0, 0x30, 0x44, | |
1233 0x00, 0x85, 0xc0, 0x74, 0x09, 0x5f, 0x5e, 0x33, | |
1234 0xc0, 0x5b, 0x8b, 0xe5, 0x5d, 0xc3, 0x8b, 0x45, | |
1235 0x0c, 0x85, 0xc0, 0x75, 0x14, 0x8b, 0x55, 0xec, | |
1236 0x83, 0xc2, 0x20, 0x52, 0x6a, 0x00, 0xe8, 0xf5, | |
1237 0x28, 0x01, 0x00, 0x83, 0xc4, 0x08, 0x89, 0x45, | |
1238 0x0c, 0x8b, 0x45, 0xe4, 0x6a, 0x00, 0x6a, 0x00, | |
1239 0x50, 0x53, 0xff, 0x15, 0x34, 0xb1, 0x43, 0x00, | |
1240 0x8b, 0x45, 0x10, 0x85, 0xc0, 0x74, 0x05, 0x8b, | |
1241 0x4d, 0xec, 0x89, 0x08, 0x8a, 0x45, 0xf0, 0x84, | |
1242 0xc0, 0x75, 0x78, 0xa1, 0xe0, 0x30, 0x44, 0x00, | |
1243 0x8b, 0x7d, 0xe8, 0x8b, 0x75, 0x0c, 0x85, 0xc0, | |
1244 0x75, 0x44, 0x8b, 0x1d, 0xd0, 0xb0, 0x43, 0x00, | |
1245 0x85, 0xff, 0x76, 0x37, 0x81, 0xff, 0x00, 0x00, | |
1246 0x04, 0x00, 0x6a, 0x00, 0x76, 0x43, 0x8b, 0x45, | |
1247 0xf8, 0x8d, 0x55, 0xfc, 0x52, 0x68, 0x00, 0x00, | |
1248 0x04, 0x00, 0x56, 0x50, 0xff, 0x15, 0x2c, 0xb1, | |
1249 0x43, 0x00, 0x6a, 0x05, 0xff, 0xd3, 0xa1, 0xe0, | |
1250 0x30, 0x44, 0x00, 0x81, 0xef, 0x00, 0x00, 0x04, | |
1251 0x00, 0x81, 0xc6, 0x00, 0x00, 0x04, 0x00, 0x85, | |
1252 0xc0, 0x74, 0xc5, 0x8b, 0x5d, 0xf8, 0x53, 0xe8, | |
1253 0xf4, 0xfb, 0xff, 0xff, 0x8b, 0x45, 0x0c, 0x83, | |
1254 0xc4, 0x04, 0x5f, 0x5e, 0x5b, 0x8b, 0xe5, 0x5d, | |
1255 0xc3, 0x8b, 0x55, 0xf8, 0x8d, 0x4d, 0xfc, 0x51, | |
1256 0x57, 0x56, 0x52, 0xff, 0x15, 0x2c, 0xb1, 0x43, | |
1257 0x00, 0xeb, 0xd8, 0x8b, 0x45, 0xe8, 0x83, 0xc0, | |
1258 0x20, 0x50, 0x6a, 0x00, 0xe8, 0x47, 0x28, 0x01, | |
1259 0x00, 0x8b, 0x7d, 0xe8, 0x89, 0x45, 0xf4, 0x8b, | |
1260 0xf0, 0xa1, 0xe0, 0x30, 0x44, 0x00, 0x83, 0xc4, | |
1261 0x08, 0x85, 0xc0, 0x75, 0x56, 0x8b, 0x1d, 0xd0, | |
1262 0xb0, 0x43, 0x00, 0x85, 0xff, 0x76, 0x49, 0x81, | |
1263 0xff, 0x00, 0x00, 0x04, 0x00, 0x6a, 0x00, 0x76 | |
1264 }; | |
1265 | |
1266 void GrpImpl::LoadCgm(AyuSysConfig& config) { | |
1267 /* cgm ファイル読み込み */ | |
1268 const char* fname = config.GetParaStr("#CGTABLE_FILE"); | |
1269 if (fname == 0) return; | |
1270 ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, ""); | |
1271 if (info == 0) return; | |
1272 char* data = info->CopyRead(); | |
1273 int sz = info->Size(); | |
1274 delete info; | |
1275 | |
1276 | |
8 | 1277 if ( strncmp(data, "CGTABLE", 7) != 0) { |
1278 delete[] data; | |
1279 return; | |
1280 } | |
0 | 1281 int cgm_size = read_little_endian_int(data+0x10); |
1282 | |
1283 int i,j; | |
1284 // xor 解除 | |
1285 for (i=0;i<sz-0x20; i++) { | |
1286 data[i+0x20]^=decode_char[i&0xff]; | |
1287 } | |
1288 // 展開 | |
1289 int dest_size = cgm_size * 36; | |
1290 char* dest = new char[dest_size+1024]; | |
1291 char* src = data + 0x28; | |
1292 char* dest_orig = dest; | |
1293 ARCINFO::Extract2k(dest,src,dest+dest_size,data+sz); | |
1294 dest = dest_orig; | |
1295 for (i=0; i<cgm_size; i++) { | |
1296 char* s = dest + i * 36; | |
1297 int n = read_little_endian_int(dest + i * 36 + 32); | |
1298 cgm_info[s] = n; | |
1299 } | |
8 | 1300 delete[] data; |
0 | 1301 delete[] dest_orig; |
1302 } | |
1303 | |
1304 /***************************************************** | |
1305 * | |
1306 * GrpImpl :: Save, Load : セーブファイル処理 | |
1307 * | |
1308 */ | |
1309 void GrpImpl::Save(std::string& str) { | |
1310 } | |
1311 void GrpImpl::Load(const char* str) { | |
1312 status = NORMAL; | |
1313 if (anm1) { | |
1314 AbortAnm(); | |
1315 } | |
1316 if (anm2) { | |
1317 anm2->Abort(); | |
1318 delete anm2; | |
1319 anm2 = 0; | |
1320 } | |
1321 map<int,GrpObj>::iterator it; | |
1322 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1323 PicBase* p = it->second.DeletePic(); | |
1324 delete p; | |
1325 } | |
1326 grpobj.clear(); | |
1327 | |
1328 bg_name = ""; | |
1329 music.StopCDROM(100); | |
1330 } | |
1331 void GrpImpl::SaveSys(string& save) { | |
1332 char buf[1024]; | |
1333 save = "\n[Graphics]\n"; | |
1334 save += "CGM_CG="; | |
1335 | |
1336 set<int>::iterator it; | |
1337 for (it=cgm_data.begin(); it != cgm_data.end(); it++) { | |
1338 sprintf(buf,"%d,",*it); | |
1339 save += buf; | |
1340 } | |
1341 save += "\n"; | |
1342 } | |
1343 void GrpImpl::LoadSys(const char* save) { | |
1344 cgm_data.clear(); | |
1345 save = strstr(save, "\n[Graphics]\n"); | |
1346 | |
1347 if (save) { | |
1348 save += strlen("\n[Graphics]\n"); | |
1349 do { | |
1350 if (save[0] == '[') break; // next section | |
1351 if (strncmp(save, "CGM_CG=",7) == 0) { | |
1352 save += 7; | |
1353 while(isdigit(*save)) { | |
1354 int n = atoi(save); | |
1355 cgm_data.insert(n); | |
1356 save = strchr(save, ','); | |
1357 if (save) save++; | |
1358 } | |
1359 } | |
1360 save = strchr(save, '\n'); | |
1361 if (save) save++; | |
1362 } while (save); | |
1363 } | |
1364 return; | |
1365 } | |
1366 | |
1367 | |
1368 /***************************************************** | |
1369 * | |
1370 * GrpImpl :: Wait , Exec : コマンド実行部 | |
1371 * | |
1372 */ | |
1373 static vector<int> drawn_images; | |
1374 static int draw_n = 0; | |
1375 extern bool grpdump_req; | |
1376 bool GrpImpl::Wait(unsigned int current_time, Cmd& cmd) { | |
1377 if (grpdump_req) { | |
1378 grpdump_req = 0; | |
1379 std::map<int,GrpObj>::iterator it; | |
1380 fprintf(stderr,"front %08x(%d) / %08x(%d)\n",screen,screen->IsHidden(),screen_front,screen_front->IsHidden()); | |
1381 for (it=grpobj.begin(); it != grpobj.end(); it++) { | |
1382 GrpObj& obj = it->second; | |
1383 GrpObj& parent_obj = grpobj[ ((it->first)/1000) * 1000]; | |
1384 if (obj.picture) { | |
1385 if (!obj.name.empty()) { | |
1386 fprintf(stderr,"obj %06d(%08x): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", | |
1387 it->first,obj.picture,obj.name.c_str(), | |
1388 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1389 } else if (!obj.print_moji.empty()) { | |
1390 fprintf(stderr,"obj %06d(%08x): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", | |
1391 it->first,obj.picture,obj.print_moji.c_str(), | |
1392 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1393 } else { | |
1394 fprintf(stderr,"obj %06d(%08x): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", | |
1395 it->first,obj.picture,"<EMPTY>", | |
1396 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1397 } | |
1398 } | |
1399 } | |
1400 std::list<PicBase*>::iterator it2; | |
1401 for (it2=parent.children.begin(); it2!=parent.children.end();it2++) { | |
1402 fprintf(stderr,"%08x(%d)\n",*it2,(*it2)->IsHidden()); | |
1403 } | |
1404 RefreshObj(); | |
1405 | |
1406 } | |
1407 #if 0 | |
1408 if (event.presscount(MOUSE_UP)) { | |
1409 std::list<PicBase*>::iterator lit; | |
1410 draw_n++; int i=0; | |
1411 for (lit=parent.children.end(); lit!=parent.children.begin(); ) { | |
1412 lit--; | |
1413 (*lit)->hide(); | |
1414 i++; | |
1415 if (i >= draw_n) break; | |
1416 } | |
1417 if (drawn_images.empty()) { | |
1418 map<int, GrpObj>::iterator it; | |
1419 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1420 if (it->second.picture) { | |
1421 drawn_images.push_back(it->first); | |
1422 PicBase* p = it->second.DeletePic(); | |
1423 delete p; | |
1424 } | |
1425 } | |
1426 } else { | |
1427 vector<int>::iterator it; | |
1428 for (it=drawn_images.begin(); it!=drawn_images.end(); it++) { | |
1429 CreateObj(*it); | |
1430 } | |
1431 drawn_images.clear(); | |
1432 } | |
1433 } | |
1434 #endif | |
1435 if (status == WAIT_ANM) { | |
1436 if (anm1) { | |
1437 if (!anm1->IsEnd()) return true; | |
1438 AbortAnm(); | |
1439 } | |
1440 } else if (status == WAIT_SHAKE) { | |
1441 if (anm2) { | |
1442 if (!anm2->IsEnd()) return true; | |
1443 delete anm2; | |
1444 anm2 = 0; | |
1445 } | |
1446 status = NORMAL; | |
1447 } else if (status == WAIT_SE) { | |
1448 if (music.IsStopSE()) status = NORMAL; | |
1449 return true; | |
1450 } else if (status == WAIT_MOVIE) { | |
1451 if (music.IsStopMovie()) { | |
1452 music.StopMovie(); | |
1453 status = NORMAL; | |
1454 screen->ReBlit(); | |
1455 } | |
1456 return true; | |
1457 } | |
1458 if (anm2) { | |
1459 if (anm2->IsEnd()) { | |
1460 delete anm2; | |
1461 anm2 = 0; | |
1462 } | |
1463 } | |
1464 return false; | |
1465 } | |
1466 | |
1467 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 | |
1468 if (grpobj.find(num) == grpobj.end()) return; | |
1469 deleted_pic.push_back(grpobj[num].DeletePic()); | |
1470 } | |
1471 void GrpImpl::DeleteObj(int num) { | |
1472 if (grpobj.find(num) == grpobj.end()) return; | |
1473 deleted_pic.push_back(grpobj[num].DeletePic()); | |
1474 grpobj.erase(num); | |
1475 } | |
1476 void GrpImpl::DeleteObjRange(int num_first, int num_end) { | |
1477 std::map<int, GrpObj>::iterator begin,end,it; | |
1478 begin = grpobj.lower_bound(num_first); | |
1479 end = grpobj.lower_bound(num_end); | |
1480 for (it=begin;it!=end;it++) { | |
1481 deleted_pic.push_back(it->second.DeletePic()); | |
1482 } | |
1483 grpobj.erase(begin, end); | |
1484 } | |
1485 void GrpImpl::Exec(Cmd& cmd) { | |
1486 if (cmd.cmd_type == CMD_TEXTEND) { | |
1487 music.StopKoe(500); // テキスト終了で声を止める | |
1488 cmd.clear(); | |
1489 return; | |
1490 } | |
1491 if (cmd.cmd_type == CMD_WAITFRAMEUPDATE) { | |
1492 // wait する場合は RefreshObj() しておく | |
1493 RefreshObj(); | |
1494 } | |
1495 if (cmd.cmd_type != CMD_OTHER) return; | |
1496 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1e && cmd.cmd3 == 0) { | |
1497 cmd.cmd_type = CMD_SAVECMDGRP_START; // grp stack clear | |
1498 } | |
1499 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) { | |
1500 if (cmd.cmd3 == 0x46) { | |
1501 const char* name = cmd.Str(cmd.args[0]); | |
1502 int pdt = cmd.args[1].value; | |
1503 eprintf("load surface %s pdt %d\n",name, pdt); | |
1504 if (pdt == 0) | |
1505 reserved_load_surface0 = name; // 画像読み込みは 01-1f:0000 まで待つ | |
1506 else if (pdt == 1) | |
1507 LoadSurface(name); // 背景絵読み込み? | |
1508 else | |
1509 LoadSurface(name, pdt); | |
1510 cmd.cmd_type = CMD_SAVECMDGRP; | |
1511 } else if (cmd.cmd3 == 0x49) { | |
1512 const char* name = cmd.Str(cmd.args[0]); | |
1513 int sel = cmd.args[1].value; | |
1514 eprintf("set background %s sel %d\n",name, sel); | |
1515 if (name[0] == '?') { | |
1516 LoadSurface(); | |
1517 } else { | |
1518 LoadSurface(name); | |
1519 } | |
1520 StartAnm(sel); | |
1521 status = WAIT_ANM; | |
1522 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1523 if (name[0] == '?') | |
1524 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1525 else | |
1526 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
1527 } else if (cmd.cmd3 == 0x4b) { | |
1528 int pos = cmd.args[0].value; | |
1529 const char* name = cmd.Str(cmd.args[1]); | |
1530 int sel = cmd.args[2].value; | |
1531 eprintf("set foreground %s sel %d pos %d\n",name, sel, pos); | |
1532 AddSurface(name); | |
1533 StartAnm(sel); | |
1534 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1535 status = WAIT_ANM; | |
1536 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1537 } else if (cmd.cmd3 == 0x4c) { | |
1538 /* 0x46 との違いがわからない */ | |
1539 /* とりあえず bg として登録しないでみる */ | |
1540 /* 735 / 19438 : unsupported command; 0x23 - cmd 01-21:004c:00[ 2] | |
1541 ** "?",0 | |
1542 */ | |
1543 /* arg1 = "?" arg2 = 0 */ | |
1544 const char* name = cmd.Str(cmd.args[0]); | |
1545 int sel = cmd.args[1].value; | |
1546 if (name[0] == '?') { | |
1547 LoadSurface(); | |
1548 } else { | |
1549 LoadSurface(name, 1); | |
1550 } | |
1551 StartAnm(sel); | |
1552 status = WAIT_ANM; | |
1553 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1554 if (name[0] == '?') | |
1555 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1556 else | |
1557 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
1558 } else if (cmd.cmd3 == 0x20) { | |
1559 // shake screen | |
1560 char key[1024]; | |
1561 sprintf(key, "#SHAKE.%03d", cmd.args[0].value); | |
1562 if (config.SearchParam(key) != 2) { | |
1563 fprintf(stderr,"Cannot find shake pattern %d; use default pattern\n",cmd.args[0].value); | |
1564 strcpy(key, "#SHAKE.000"); // default key | |
1565 } | |
1566 int num; const int* pattern; | |
1567 pattern = config.GetParamArray(key, num); | |
1568 if (pattern) { | |
1569 StartShake(num, pattern); | |
1570 status = WAIT_SHAKE; | |
1571 } | |
1572 cmd.clear(); | |
1573 } else if (cmd.cmd3 == 0x64 && cmd.cmd4 == 2) { // copy (KANOGI) | |
1574 int sx = cmd.args[0].value; | |
1575 int sy = cmd.args[1].value; | |
1576 int w = cmd.args[2].value - sx; | |
1577 int h = cmd.args[3].value - sy; | |
1578 Rect rect(sx, sy, sx+w, sy+h); | |
1579 int src = cmd.args[4].value; | |
1580 int dx = cmd.args[5].value; | |
1581 int dy = cmd.args[6].value; | |
1582 int dest = cmd.args[7].value; | |
1583 unsigned char alpha; | |
1584 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1585 printf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1586 if (src == dest) { | |
1587 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1588 src = WORKPDT; | |
1589 } | |
1590 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy)); | |
1591 if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1592 cmd.clear(); | |
1593 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 2) { | |
1594 int x = cmd.args[0].value; | |
1595 int y = cmd.args[1].value; | |
1596 int w = cmd.args[2].value; | |
1597 int h = cmd.args[3].value; | |
1598 Rect rect(x,y,x+w,y+w); | |
1599 int pdt = cmd.args[4].value; | |
1600 int r = cmd.args[5].value; | |
1601 int g = cmd.args[6].value; | |
1602 int b = cmd.args[7].value; | |
1603 eprintf("clear %d:(%d,%d) size (%d,%d) r %d g %d b %d\n",pdt,x,y,w,h,r,g,b); | |
1604 DSurfaceFill(Dsurface(pdt), rect, r, g, b, 0xff); | |
1605 // if (pdt == 0) screen->ReBlit(rect); | |
1606 cmd.cmd_type = CMD_SAVECMDGRP; | |
1607 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 3) { // alpha つきfill | |
1608 int x = cmd.args[0].value; | |
1609 int y = cmd.args[1].value; | |
1610 int w = cmd.args[2].value; | |
1611 int h = cmd.args[3].value; | |
1612 Rect rect(x,y,x+w,y+h); | |
1613 int pdt = cmd.args[4].value; | |
1614 int r = cmd.args[5].value; | |
1615 int g = cmd.args[6].value; | |
1616 int b = cmd.args[7].value; | |
1617 int a = cmd.args[8].value; | |
1618 eprintf("alpha-clear %d:(%d,%d) size (%d,%d) r %d g %d b %d a %d\n",pdt,x,y,w,h,r,g,b,a); | |
1619 if (a <= 0) ; | |
1620 else if (a >= 255) DSurfaceFill(Dsurface(pdt), rect, r, g, b); | |
1621 else { | |
1622 DSurfaceFill(Dsurface(WORKPDT), rect, r, g, b, a); | |
1623 parent.Root().BlitSurface(Dsurface(WORKPDT), rect, Dsurface(pdt), rect); | |
1624 } | |
1625 // if (pdt == 0) screen->ReBlit(rect); | |
1626 cmd.clear(); | |
1627 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 2) { | |
1628 int sx = cmd.args[0].value; | |
1629 int sy = cmd.args[1].value; | |
1630 int w = cmd.args[2].value; | |
1631 int h = cmd.args[3].value; | |
1632 int src = cmd.args[4].value; | |
1633 int dx = cmd.args[5].value; | |
1634 int dy = cmd.args[6].value; | |
1635 int dest = cmd.args[7].value; | |
1636 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1637 parent.Root().BlitSurface(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy)); | |
1638 //DSurfaceMove(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy)); | |
1639 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1640 cmd.cmd_type = CMD_SAVECMDGRP; | |
1641 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 3) { // alpha つきcopy | |
1642 int sx = cmd.args[0].value; | |
1643 int sy = cmd.args[1].value; | |
1644 int w = cmd.args[2].value; | |
1645 int h = cmd.args[3].value; | |
1646 Rect rect(sx, sy, sx+w, sy+h); | |
1647 int src = cmd.args[4].value; | |
1648 int dx = cmd.args[5].value; | |
1649 int dy = cmd.args[6].value; | |
1650 int dest = cmd.args[7].value; | |
1651 unsigned char alpha; | |
1652 if (cmd.args[8].value < 0) alpha = 0; | |
1653 else if (cmd.args[8].value > 255) alpha = 255; | |
1654 else alpha = cmd.args[8].value; | |
1655 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1656 if (src == dest) { | |
1657 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1658 src = WORKPDT; | |
1659 } | |
1660 if (alpha != 0) | |
1661 parent.Root().BlitSurface(Ssurface(src), rect, &alpha, Rect(0,0,1,1), Dsurface(dest), Rect(dx,dy), 0); | |
1662 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1663 cmd.clear(); | |
1664 } else if (cmd.cmd3 == 0x640 && cmd.cmd4 == 3) { // saturate mode で alpha 付き copy | |
1665 int sx = cmd.args[0].value; | |
1666 int sy = cmd.args[1].value; | |
1667 int w = cmd.args[2].value; | |
1668 int h = cmd.args[3].value; | |
1669 Rect rect(sx, sy, sx+w, sy+h); | |
1670 int src = cmd.args[4].value; | |
1671 int dx = cmd.args[5].value; | |
1672 int dy = cmd.args[6].value; | |
1673 int dest = cmd.args[7].value; | |
1674 unsigned char alpha; | |
1675 if (cmd.args[8].value < 0) alpha = 0; | |
1676 else if (cmd.args[8].value > 255) alpha = 255; | |
1677 else alpha = cmd.args[8].value; | |
1678 eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1679 if (src == dest) { | |
1680 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1681 src = WORKPDT; | |
1682 } | |
1683 if (alpha != 0) { | |
1684 // saturate mode : screen (picture) を一時的に作成 | |
1685 PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
1686 screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE); | |
1687 screen_tmp->SetSurfaceRect(rect); | |
1688 screen_tmp->Move(dx, dy); | |
1689 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); | |
1690 screen_tmp->SimpleBlit(Dsurface(dest)); | |
1691 delete screen_tmp; | |
1692 } | |
1693 cmd.clear(); | |
1694 } else if (cmd.cmd3 == 0x196 && cmd.cmd4 == 0) { | |
1695 Rect r_from(cmd.args[0].value, cmd.args[1].value); | |
1696 Rect r_to(cmd.args[2].value, cmd.args[3].value); | |
1697 int src_pdt = cmd.args[4].value; | |
1698 Rect r(cmd.args[5].value,cmd.args[6].value,cmd.args[7].value+1,cmd.args[8].value+1); | |
1699 int tm = cmd.args[9].value; | |
1700 fprintf(stderr,"??? cmd time %d\n",tm); | |
1701 // anm1 = new ScnGrpMove(event, screen, parent.Root(), surface, r, Ssurface(2), r_from, r_to, tm); | |
1702 // status = WAIT_ANM; | |
1703 } | |
1704 } | |
1705 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x22) { | |
1706 if (cmd.cmd3 == 0x0c30 && cmd.cmd4 == 0) { // スクロールする画像効果(Princess Bride) | |
1707 if (anm2) { | |
1708 anm2->Abort(); | |
1709 delete anm2; | |
1710 } | |
1711 PicBase* pic; Surface* s; | |
1712 Rect r(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value+1, cmd.args[4].value+1); | |
1713 const char* name = cmd.Str(cmd.args[5]); | |
1714 Rect sr_start(cmd.args[6].value,cmd.args[7].value); | |
1715 Rect sr_end(cmd.args[8].value,cmd.args[9].value); | |
1716 int tm = cmd.args[10].value; | |
1717 LoadSurface(name, 2); /* PDT2 に読み込み、と決め打ち */ | |
1718 | |
1719 anm2 = new ScnGrpMove(event, screen, parent.Root(), Dsurface(1), r, Ssurface(2), sr_start, sr_end, tm); | |
1720 cmd.cmd_type = CMD_SAVECMDGRP; | |
1721 } | |
1722 if ( (cmd.cmd3 == 0xc1c && cmd.cmd4 == 0) || (cmd.cmd3 == 0x835 && cmd.cmd4 == 0) ) { | |
1723 // カードが落ちるアニメーション | |
1724 int i; | |
1725 ScnGrpAnm* new_anm = new ScnGrpAnm(event, screen, *this); | |
1726 if (cmd.cmd3 == 0x835) { | |
1727 AbortAnm(); | |
1728 anm1 = new_anm; | |
1729 status = WAIT_ANM; | |
1730 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1731 } else { | |
1732 anm2 = new_anm; | |
1733 } | |
1734 for (i=0; i<cmd.argc; i++) { | |
1735 const char* name = cmd.Str(cmd.args[i*3+1]); | |
1736 int tm = cmd.args[i*3+2].value; | |
1737 new_anm->push_back(ScnGrpAnmAtom(name,tm)); | |
1738 } | |
1739 new_anm->CalcTotal(); | |
1740 cmd.clear(); | |
1741 } | |
1742 } | |
1743 if (cmd.cmd1 == 1 && cmd.cmd2 == 4) { | |
1744 if (cmd.cmd3 == 0xd8 || cmd.cmd3 == 0xd3 || cmd.cmd3 == 0xd2 || cmd.cmd3 == 0xd7) { | |
1745 cmd.clear(); // いつも 0xd8 / 0xd7 と組で出てくる | |
1746 } | |
1747 if (cmd.cmd3 == 0x5e0) { // 画像既視フラグを得る | |
1748 string s = cmd.Str(cmd.args[0]); | |
1749 if (cgm_info.find(s) == cgm_info.end()) { | |
1750 fprintf(stderr,"cmd 01-04:05e0 : cannot find cgm-info of '%s'\n",s.c_str()); | |
1751 return; | |
1752 } | |
1753 int n = cgm_info[s]; | |
1754 if (cgm_data.find(n) == cgm_data.end()) cmd.SetSysvar(0); | |
1755 else cmd.SetSysvar(1); | |
1756 } | |
1757 } | |
1758 #if 1 | |
1759 /* object 操作 */ | |
1760 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x3d || cmd.cmd2 == 0x3e) && (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b || cmd.cmd3 == 0x0e)) { // clear object | |
1761 if (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b) { | |
1762 if (cmd.cmd1 == 2 && cmd.args.size() == 2) { | |
1763 int num = cmd.args[0].value*1000 + cmd.args[1].value + 500; | |
1764 DeleteObj(num); | |
1765 } else if (cmd.args.size() == 1) { // group ごと消去 | |
1766 int num_first = cmd.args[0].value * 1000; | |
1767 int num_end = num_first+1000; | |
1768 DeleteObjRange(num_first, num_end); | |
1769 } | |
1770 } else { // 0x0e | |
1771 if (cmd.cmd1 == 1 && cmd.args.size() == 2) { | |
1772 SwapObj(cmd.args[0].value * 1000, cmd.args[1].value * 1000); | |
1773 } else if (cmd.cmd1 == 2 && cmd.args.size() == 3) { | |
1774 int v1 = cmd.args[0].value*1000 + cmd.args[1].value + 500; | |
1775 int v2 = cmd.args[0].value*1000 + cmd.args[2].value + 500; | |
1776 SwapObj(v1, v2); | |
1777 } | |
1778 } | |
1779 cmd.clear(); | |
1780 } | |
1781 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0x01) { // ??? : CLANNAD | |
1782 cmd.clear(); | |
1783 } | |
1784 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0) { // ??? : KANOGI : 画像オブジェクトの削除? | |
1785 DeleteObjPic(cmd.args[0].value * 1000); // 旧ファイル名のsurfaceを削除 | |
1786 GrpObj& g = grpobj[cmd.args[0].value * 1000]; | |
1787 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1788 cmd.clear(); | |
1789 } | |
1790 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x47 || cmd.cmd2 == 0x48|| cmd.cmd2 == 0x49 || cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52 || cmd.cmd2 == 0x54)) { | |
1791 if (cmd.cmd1 == 1) { | |
1792 if (cmd.args.size() >= 1) cmd.args[0].value *= 1000; // とりあえず 1000倍しておく | |
1793 } else { // cmd.cmd2 == 2 | |
1794 // オブジェクト番号を指定するコマンド引数が一つ増えているのを消去 | |
1795 vector<VarInfo> args = cmd.args; | |
1796 cmd.args.clear(); | |
1797 if (args.size() >= 2) { | |
1798 cmd.args.push_back(args[0].value*1000 + args[1].value + 500); | |
1799 cmd.args.insert(cmd.args.end(), args.begin()+2, args.end()); | |
1800 } | |
1801 } | |
1802 if (cmd.cmd2 == 0x47) { | |
1803 /**************: | |
1804 0x47 : オブジェクト内容の設定 | |
1805 0x3e8: G00 ファイル | |
1806 0x3eb: GAN ファイル | |
1807 0x44c: 矩形領域 | |
1808 0x4b0: 文字列 | |
1809 0x514: 天候効果 | |
1810 0x578: 数字の画像表示 | |
1811 */ | |
1812 int base_argc = 0; | |
1813 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 | |
1814 GrpObj& g = grpobj[cmd.args[0].value]; | |
1815 if (cmd.cmd3 == 0x3e8) { /* ファイル名設定 */ | |
1816 g.gtype = GrpObj::FILE; | |
1817 string name = cmd.Str(cmd.args[1]); | |
1818 if (name.find('?') != -1) { | |
1819 name.erase(name.find('?')); // '?' 以降の意味がわからない | |
1820 } | |
1821 g.name = name; | |
1822 } else if (cmd.cmd3 == 0x3eb) { /* ファイル名設定(GAN含む) */ | |
1823 g.gtype = GrpObj::GAN; | |
1824 if (cmd.Str(cmd.args[1]) == string("???")) | |
1825 g.name = cmd.Str(cmd.args[2]); | |
1826 else | |
1827 g.name = cmd.Str(cmd.args[1]); | |
1828 g.gan_name = cmd.Str(cmd.args[2]); | |
5 | 1829 |
1830 if (cmd.cmd4 >= 1 && cmd.args[3].value == 0) | |
1831 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1832 else | |
1833 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN)); | |
1834 | |
1835 if (cmd.argc >= 5) | |
1836 g.SetPos(1, cmd.args[4].value, -cmd.args[5].value); | |
1837 | |
1838 if (g.name.find('?') != -1) { | |
4 | 1839 g.name.erase(g.name.find('?')); |
1840 g.gan_name = cmd.Str(cmd.args[2]); | |
1841 } | |
0 | 1842 } else if (cmd.cmd3 == 0x4b0) { // 画像を文字列として指定 |
1843 g.gtype = GrpObj::MOJI; | |
1844 g.print_moji = cmd.Str(cmd.args[1]); | |
1845 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト? | |
1846 cmd.clear(); | |
1847 } else if (cmd.cmd3 == 0x578) { // 数値を画像として表示 | |
1848 g.gtype = GrpObj::DIGIT; | |
1849 g.name = cmd.Str(cmd.args[1]); | |
1850 } | |
1851 CreateObj(cmd.args[0].value); | |
1852 if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb || cmd.cmd3 == 0x4b0 || cmd.cmd3 == 0x578) { | |
1853 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う | |
18 | 1854 if (cmd.cmd4 >= 1) { |
0 | 1855 if (cmd.args[2+base_argc].value == 0) { |
1856 if (cmd.cmd1 == 1) | |
1857 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP); | |
1858 else | |
1859 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1860 } else { | |
1861 if (cmd.cmd1 == 1) | |
1862 g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP))); | |
1863 else | |
1864 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1865 } | |
1866 if (cmd.cmd1 == 1) | |
1867 SetObjChangedGroup(cmd.args[0].value); | |
1868 } | |
18 | 1869 if (cmd.cmd4 >= 2) { // 座標等も設定 |
0 | 1870 g.SetPos(0,cmd.args[3+base_argc].value, cmd.args[4+base_argc].value); |
1871 } | |
18 | 1872 if ( (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb) && cmd.cmd4 >= 3) { // pattern 番号も設定 |
0 | 1873 g.SetSurfaceNum(cmd.args[5+base_argc].value); |
1874 base_argc++; // 0x3e8 (FILE) / 0x3eb (GAN) の場合のみこのオプションは存在する | |
1875 } | |
1876 cmd.clear(); | |
1877 } else { | |
1878 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3); | |
1879 } | |
1880 } else if (cmd.cmd2 == 0x48) { | |
1881 // 画面切り替え後の object (back screen object) 設定 | |
1882 if (cmd.cmd3 == 0x3e8) { | |
1883 // cmd.cmd4 == 0 : args = 2, CLANNAD : cg mode | |
1884 // cmd.cmd4 == 1 : args = 3, CLANNAD : 春原回想?のところで画面が黒くなってしまうので、とりあえず。 | |
1885 // cmd.cmd4 == 2 : args = 5, KANOGI : Fore Graphics | |
1886 // cmd.cmd4 == 3 : args = 6, KANOGI : CG mode | |
1887 GrpObj& g = bs_obj[cmd.args[0].value]; | |
1888 string name = cmd.Str(cmd.args[1]); | |
1889 if (name.find('?') != -1) { | |
1890 name.erase(name.find('?')); // '?' 以降の意味がわからない | |
1891 } | |
1892 g.gtype = GrpObj::FILE; | |
1893 g.name = name; | |
1894 if (cmd.cmd4 >= 1 && cmd.args[2].value == 0) | |
1895 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1896 else | |
1897 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN)); | |
1898 if (cmd.cmd4 >= 2) | |
1899 g.SetPos(0,cmd.args[3].value, cmd.args[4].value); | |
1900 if (cmd.cmd4 >= 3) | |
1901 g.SetSurfaceNum(cmd.args[5].value); | |
1902 if (cmd.cmd4 <= 3) | |
1903 cmd.cmd_type = CMD_SAVECMDGRP; | |
1904 } | |
1905 } else if (cmd.cmd2 == 0x49) { | |
1906 if (cmd.cmd3 == 0) { // アニメーションを強制終了 | |
1907 GrpObj& g = grpobj[cmd.args[0].value]; | |
1908 if (g.anm == 0 || g.anm->IsEnd()) ; | |
1909 else g.anm->Abort(); | |
1910 } else if (cmd.cmd3 == 3) { // アニメーション中か? | |
1911 GrpObj& g = grpobj[cmd.args[0].value]; | |
1912 if (g.anm == 0 || g.anm->IsEnd()) { | |
1913 cmd.SetSysvar(0); | |
1914 } else { | |
1915 cmd.SetSysvar(1); | |
1916 } | |
1917 } else if (cmd.cmd3 == 1000) { | |
1918 // アニメーションを途中で停止した状態にする | |
1919 GrpObj& g = grpobj[cmd.args[0].value]; | |
1920 if (g.anm == 0 || g.anm->IsEnd()) { | |
1921 // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value); | |
1922 g.SetSurfaceNum(cmd.args[1].value); | |
1923 } else { | |
1924 g.anm->Abort(); | |
1925 g.SetSurfaceNum(cmd.args[1].value); | |
1926 } | |
1927 SetObjChanged(cmd.args[0].value); | |
1928 cmd.clear(); | |
1929 } else if (cmd.cmd3 == 0x7d3) { // surface を増加させる画像効果 | |
1930 GrpObj& g = grpobj[cmd.args[0].value]; | |
1931 g.CreateGanSpecial(event, 0, cmd.args[1].value); | |
1932 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1933 SetObjChanged(cmd.args[0].value); | |
1934 cmd.clear(); | |
1935 } else if (cmd.cmd3 == 0xbbd || cmd.cmd3 == 0xbbb || cmd.cmd3 == 0xbb9) { // アニメーション開始 | |
1936 GrpObj& g = grpobj[cmd.args[0].value]; | |
1937 g.CreateGan(event, cmd.args[1].value); | |
1938 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1939 SetObjChanged(cmd.args[0].value); | |
1940 cmd.clear(); | |
1941 } | |
1942 } else if (cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52) { | |
1943 GrpObj& g = (cmd.cmd2 == 0x51) ? | |
1944 grpobj[cmd.args[0].value] : | |
1945 bs_obj[cmd.args[0].value]; | |
1946 if (cmd.cmd3 == 0x3e8) { /* 座標設定 */ | |
1947 g.SetPos(0,cmd.args[1].value, cmd.args[2].value); | |
1948 cmd.clear(); | |
1949 } else if (cmd.cmd3 == 0x3e9 || cmd.cmd3 == 0x3ea) { /* x / y 座標のみ設定 */ | |
1950 int x0, y0; | |
1951 g.GetPos(0, x0, y0); | |
1952 if (cmd.cmd3 == 0x3e9) | |
1953 g.SetPos(0,cmd.args[1].value, y0); | |
1954 else | |
1955 g.SetPos(0,x0, cmd.args[1].value); | |
1956 cmd.clear(); | |
1957 } else if (cmd.cmd3 == 0x3eb) { /* alpha */ | |
1958 g.SetAlpha(cmd.args[1].value); | |
1959 cmd.clear(); | |
1960 } else if (cmd.cmd3 == 0x3ec) { /* visible flag */ | |
1961 if (cmd.cmd1 == 1) { | |
1962 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP))); | |
1963 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP); | |
1964 } else { | |
1965 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1966 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1967 } | |
1968 g.attr = GrpObj::Attribute(g.attr | GrpObj::UPDATE_VISIBLE); | |
1969 // グループ単位で次の RefreshObj で表示・消去 | |
1970 if (cmd.cmd2 == 0x51 && cmd.cmd1 == 1) | |
1971 SetObjChangedGroup(cmd.args[0].value); | |
1972 cmd.clear(); | |
1973 } else if (cmd.cmd3 == 0x3ee || cmd.cmd3 == 0x7d6) { /* 座標設定その2? */ | |
1974 /* 0x7d6 : 画像側の基準座標を args[4,5] に入れているのかもしれない */ | |
1975 int index = cmd.args[1].value; | |
1976 int x = cmd.args[2].value; | |
1977 int y = cmd.args[3].value; | |
1978 g.SetPos(index+1, x, y); | |
1979 cmd.clear(); | |
1980 } else if (cmd.cmd3 == 0x3f8) { // 画像を文字列として設定:色の設定 | |
1981 g.print_r = cmd.args[1].value; | |
1982 g.print_g = cmd.args[2].value; | |
1983 g.print_b = cmd.args[3].value; | |
1984 g.SetUpdate(); | |
1985 // grpobj[cmd.args[0].value].print_a = cmd.args[4].value; | |
1986 /* args:229,18,minus-1,0,99,255,-1 */ | |
1987 /* args:102,26,minus-1,0,99,0,255 */ | |
1988 cmd.clear(); | |
1989 } else if (cmd.cmd3 == 0x3fd) { // centering mode などを設定? | |
1990 if (cmd.args[1].value == 1) { | |
1991 g.attr = GrpObj::Attribute(g.attr | GrpObj::SATURATE); | |
1992 cmd.clear(); | |
1993 } else if (cmd.args[1].value == 0) { | |
1994 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::SATURATE)); | |
1995 cmd.clear(); | |
1996 } | |
1997 g.SetUpdate(); | |
1998 /* cmd3 == 0x41c : ゲームの進行とともに | |
1999 args:10,105 | |
2000 args:10,133 | |
2001 args:10,144 | |
2002 args:10,144 | |
2003 と変化 | |
2004 | |
2005 cmd3 == 0x418 : | |
2006 args: 10, 400 -> 100 | |
2007 と、alpha の増加とともに変化 | |
2008 */ | |
2009 /* | |
2010 487 / 8047 : unsupported command; 0x23 - cmd 01-51:0419:00[ 2] | |
2011 81,-40, | |
2012 第二引数の 1/10 がオブジェクトの回転角 | |
2013 */ | |
2014 } else if (cmd.cmd3 == 0x400) { // 画像を文字列として指定 | |
2015 g.print_moji = cmd.Str(cmd.args[1]); | |
2016 g.SetUpdate(); | |
2017 cmd.clear(); | |
2018 } else if (cmd.cmd3 == 0x401) { // 画像を文字列として設定:文字の大きさなど | |
2019 /* args: size, xspace, yspace, vertical, color, shadow */ | |
2020 /* | |
2021 args:17, 0,0,-1, 0,-1 DT in Tomoyo | |
2022 args:17, 0,0,-1,200,-1 Save/Load in Tomoyo | |
2023 args:20, 0,0, 0,255,-1 "──ありがとう…。" (勝平Ed付近) | |
2024 args:16,-1,0,99,255,-1 "やあ、久しぶり──…。" (同上,Save/Load Menu) | |
2025 args:26,-1,0,99, 0,255 Kuma in CLANNAD | |
2026 */ | |
2027 g.print_size = cmd.args[1].value; | |
2028 /* 前景色を得る */ | |
2029 int cr,cg,cb; char key[1024]; | |
2030 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[5].value); | |
2031 if (config.GetParam(key, 3, &cr, &cg, &cb)) { // color not found | |
2032 cr = cg = cb = 0; | |
2033 } | |
2034 g.print_r = cr; | |
2035 g.print_g = cg; | |
2036 g.print_b = cb; | |
2037 g.SetUpdate(); | |
2038 cmd.clear(); | |
2039 } else if (cmd.cmd3 == 0x408) { // set order | |
2040 int order = cmd.args[1].value; | |
2041 if (cmd.cmd1 == 1) order *= 1000; // order も 1000 倍する必要がある? | |
2042 g.order = order; | |
2043 ZMoveObj(cmd.args[0].value); | |
2044 cmd.clear(); | |
2045 } else if (cmd.cmd3 == 0x40a && cmd.cmd4 == 1) { // set surface geometry? | |
2046 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定 | |
2047 int rx = cmd.args[1].value; | |
2048 int ry = cmd.args[2].value; | |
2049 g.SetClipArea(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value,cmd.args[4].value); | |
2050 cmd.clear(); | |
2051 } else if (cmd.cmd3 == 0x40d) { // set digit number | |
2052 g.dig_number = cmd.args[1].value; | |
2053 g.SetUpdate(); | |
2054 cmd.clear(); | |
2055 } else if (cmd.cmd3 == 0x40e) { // set digit option | |
2056 g.dig_digit = cmd.args[1].value; | |
2057 int attr = g.attr; | |
2058 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK); | |
2059 if (cmd.args[2].value) attr |= GrpObj::DIG_ZERO; | |
2060 if (cmd.args[3].value) attr |= GrpObj::DIG_SIGN; | |
2061 if (cmd.args[4].value) attr |= GrpObj::DIG_PACK; | |
2062 g.attr = GrpObj::Attribute(attr); | |
2063 g.SetUpdate(); | |
2064 cmd.clear(); | |
2065 } else if (cmd.cmd3 == 0x40f) { /* set surface number */ | |
2066 g.SetSurfaceNum(cmd.args[1].value); | |
2067 cmd.clear(); | |
2068 } else if (cmd.cmd3 == 0x416) { // オブジェクトの拡大率設定 | |
2069 int zoom = (cmd.args[1].value + cmd.args[2].value)/2; // x,y 別に設定できるらしい | |
2070 zoom = zoom*256/100; | |
2071 g.SetZoomRotate(zoom, -1); | |
2072 cmd.clear(); | |
2073 } else if (cmd.cmd3 == 0x419) { // オブジェクトの回転設定 | |
2074 int angle = cmd.args[1].value; | |
2075 angle /= 10; | |
2076 if (angle < 0) { | |
2077 angle %= 360; | |
2078 angle += 360; | |
2079 } | |
2080 angle %= 360; | |
2081 g.SetZoomRotate(-1, angle); | |
2082 cmd.clear(); | |
2083 } | |
2084 if (cmd.cmd2 == 0x51 && (g.attr & GrpObj::UPDATE_ALL)) { | |
2085 SetObjChanged(cmd.args[0].value); | |
2086 } | |
2087 } else if (cmd.cmd2 == 0x54) { | |
2088 /* 座標取得 */ | |
2089 if (cmd.cmd3 == 0x3e8) { | |
2090 GrpObj& obj = grpobj[cmd.args[0].value]; | |
2091 VarInfo arg1 = cmd.args[1]; | |
2092 VarInfo arg2 = cmd.args[2]; | |
2093 int x0, y0; | |
2094 obj.GetPos(0,x0, y0); | |
2095 cmd.SetFlagvar(arg1, x0); | |
2096 cmd.SetFlagvar(arg2, y0); | |
2097 } else if (cmd.cmd3 == 0x44c) { | |
2098 int w, h; | |
2099 GrpObj& obj = grpobj[cmd.args[0].value]; | |
2100 obj.GetSrcGeom(w, h); | |
2101 VarInfo arg1 = cmd.args[1]; | |
2102 VarInfo arg2 = cmd.args[2]; | |
2103 cmd.SetFlagvar(arg1, w); | |
2104 cmd.SetFlagvar(arg2, h); | |
2105 } | |
2106 } | |
2107 // セーブ用にコマンドを元に戻す | |
2108 if (cmd.args.size() != 0 && (cmd.cmd_type == CMD_SAVECMDGRP || cmd.cmd_type == CMD_SAVECMDGRP_ONCE)) { | |
2109 if (cmd.cmd1 == 1) cmd.args[0].value /= 1000; | |
2110 else if (cmd.cmd1 == 2) { | |
2111 vector<VarInfo> args = cmd.args; | |
2112 int value = args[0].value; | |
2113 cmd.args.clear(); | |
2114 args[0].value = value / 1000; | |
2115 cmd.args.push_back(args[0]); | |
2116 args[0].value = value % 1000 - 500; | |
2117 cmd.args.push_back(args[0]); | |
2118 cmd.args.insert(cmd.args.end(), args.begin()+1, args.end()); | |
2119 } | |
2120 } | |
2121 } | |
2122 #endif | |
2123 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1f) { // 本来は grpstack clear らしい | |
2124 RefreshObj(); | |
2125 // Princess Bride の中途 Staff roll | |
2126 // このタイミングで描画するのが都合がいいので、 | |
2127 //シナリオループを抜けて描画を起動 | |
2128 cmd.cmd_type = CMD_WAITFRAMEUPDATE; | |
2129 } | |
2130 | |
2131 /* XXX : GiGiGi */ | |
2132 /* 122 : 0x23 - cmd 01-04:0924:00[ 0] : V<sys> にBGM再生モードを返す (0/1) | |
2133 ** 256 : 0x23 - cmd 01-04:091a:00[ 0] : V<sys> にBGM音量を返す (0-255?) | |
2134 ** 278 : 0x23 - cmd 01-04:0926:00[ 0] : V<sys> にEff再生モードを返す (0/1) | |
2135 ** 412 : 0x23 - cmd 01-04:091c:00[ 0] : V<sys> にEff音量を返す (0-255?) | |
2136 ** 434 : 0x23 - cmd 01-04:0927:00[ 0] : V<sys> にSE 再生モードを返す (0/1) | |
2137 ** 568 : 0x23 - cmd 01-04:091d:00[ 0] : V<sys> にSE 音量を返す (0-255?) | |
2138 | |
2139 ** 122 : 0x23 - cmd 01-04:08c0:00[ 0] : V<sys> にBGM再生モードを設定 (0/1) | |
2140 ** 256 : 0x23 - cmd 01-04:08b6:00[ 0] : V<sys> にBGM音量を設定 (0-255?) | |
2141 ** 278 : 0x23 - cmd 01-04:08c2:00[ 0] : V<sys> にEff再生モードを設定 (0/1) | |
2142 ** 412 : 0x23 - cmd 01-04:08b8:00[ 0] : V<sys> にEff音量を設定 (0-255?) | |
2143 ** 434 : 0x23 - cmd 01-04:08c3:00[ 0] : V<sys> にSE 再生モードを設定 (0/1) | |
2144 ** 568 : 0x23 - cmd 01-04:08b9:00[ 0] : V<sys> にSE 音量を設定 (0-255?) | |
2145 */ | |
2146 // 本来は音楽関連のコマンド | |
2147 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x14) { | |
2148 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) { | |
2149 eprintf("play bgm %s\n",cmd.Str(cmd.args[0])); | |
2150 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000); | |
2151 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2152 } | |
2153 if (cmd.cmd3 == 2 && (cmd.cmd4 == 2 || cmd.cmd4 == 0) ) { /* ??? : ことみシナリオラストの音楽再生 */ | |
2154 eprintf("play bgm %s\n",cmd.Str(cmd.args[0])); | |
2155 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 1); | |
2156 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2157 } | |
2158 if (cmd.cmd3 == 0 && cmd.cmd4 == 2) { | |
2159 eprintf("fade bgm %d? and play bgm %s; %d\n",cmd.args[1].value, cmd.Str(cmd.args[0]), cmd.args[2].value); | |
2160 // music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000, cmd.args[2].value); | |
2161 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000); | |
2162 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2163 } | |
2164 if ( (cmd.cmd3 == 5 || cmd.cmd3 == 0x69) && cmd.cmd4 == 0) { | |
2165 if (cmd.cmd3 == 5) { | |
2166 music.StopCDROM(0); | |
2167 eprintf("stop bgm\n"); | |
2168 } else { | |
2169 music.StopCDROM(cmd.args[0].value); | |
2170 eprintf("fade bgm %d\n",cmd.args[0].value); | |
2171 } | |
2172 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2173 } | |
2174 } | |
2175 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x15) { | |
10 | 2176 if ((cmd.cmd3 == 2) || (cmd.cmd3 == 0 && (cmd.cmd4 == 1 || cmd.cmd4 == 2)) || (cmd.cmd3 == 0 && cmd.cmd4 == 0)) { |
11 | 2177 eprintf("play SE %s\n",cmd.Str(cmd.args[0])); |
0 | 2178 if (cmd.cmd3 == 2) { |
2179 music.PlaySE(cmd.Str(cmd.args[0]),1); | |
2180 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2181 } else { | |
2182 music.PlaySE(cmd.Str(cmd.args[0])); | |
2183 cmd.clear(); | |
2184 } | |
2185 } else if (cmd.cmd3 == 5) { | |
2186 eprintf("Stop SE\n"); | |
2187 music.StopSE(); | |
2188 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2189 } else if (cmd.cmd3 == 0x69) { | |
2190 eprintf("Stop SE with fade %d\n",cmd.args[0].value); | |
2191 music.StopSE(cmd.args[0].value); | |
2192 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2193 } | |
2194 } | |
2195 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && (cmd.cmd3 == 0x4bb || cmd.cmd3 == 0x4bc) ) { | |
2196 // 音楽を待ってみる(絶対に違うが)。本来、04-803 に対応してなにかの終わりをwaitするっぽい(風子/智代Ed付近) | |
2197 // EnableSyscom らしいが、よくわからない (rldev) | |
2198 // if (!music.IsStopSE()) status = WAIT_SE; | |
2199 cmd.clear(); | |
2200 } | |
2201 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && (cmd.cmd3 == 0x8b6 || cmd.cmd3 == 0x91a) ) { | |
2202 // 音楽モードで音量を上げるためのコマンド (SetBgmVolume) | |
2203 // とりあえず未実装 | |
2204 cmd.clear(); | |
2205 } | |
2206 | |
2207 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x16) { | |
2208 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) { | |
2209 eprintf("play SE %d\n",cmd.args[0].value); | |
2210 music.PlaySE(cmd.args[0].value); | |
2211 cmd.clear(); | |
2212 } | |
2213 } | |
2214 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17) { | |
2215 if (cmd.cmd3 == 0) { | |
2216 eprintf("play koe %d",cmd.args[0].value); | |
2217 if (cmd.cmd4 == 1) { | |
2218 eprintf(", para? %d",cmd.args[1].value); | |
2219 } | |
2220 eprintf("\n"); | |
2221 char buf[1024]; sprintf(buf, "%d",cmd.args[0].value); | |
2222 if ( !(skip_mode & SKIP_TEXT)) music.PlayKoe(buf); | |
2223 cmd.clear(); | |
2224 } | |
2225 } | |
2226 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1a) { | |
2227 if ( (cmd.cmd3 == 0x14 || cmd.cmd3 == 1) && cmd.cmd4 == 0) { | |
2228 const char* str = cmd.Str(cmd.args[0]); | |
2229 int x = cmd.args[1].value; | |
2230 int y = cmd.args[2].value; | |
2231 int x2 = cmd.args[3].value; | |
2232 int y2 = cmd.args[4].value; | |
2233 eprintf("play movie ; name %s pos %d,%d - %d,%d\n",str,x,y,x2,y2); | |
2234 music.PlayMovie(str, x, y, x2, y2,1); | |
2235 status = WAIT_MOVIE; | |
2236 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
2237 cmd.clear(); | |
2238 } | |
2239 } | |
2240 return; | |
2241 } | |
2242 | |
2243 | |
2244 /******************************************************** | |
2245 ** | |
2246 ** class Grp | |
2247 */ | |
2248 | |
2249 Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) { | |
2250 pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config); | |
2251 }; | |
2252 Grp::~Grp() { | |
2253 delete pimpl; | |
2254 } | |
2255 | |
2256 bool Grp::Wait(unsigned int current_time, Cmd& cmd) { | |
2257 return pimpl->Wait(current_time, cmd); | |
2258 } | |
2259 void Grp::Exec(Cmd& cmd) { | |
2260 pimpl->Exec(cmd); | |
2261 } | |
2262 void Grp::SetSkipMode(SkipMode mode) { | |
2263 pimpl->SetSkipMode(mode); | |
2264 } | |
2265 void Grp::InitSel(AyuSysConfig& config) { | |
2266 pimpl->InitSel(config); | |
2267 } | |
2268 void Grp::Save(std::string& str) { | |
2269 pimpl->Save(str); | |
2270 } | |
2271 | |
2272 void Grp::Load(const char* str) { | |
2273 pimpl->Load(str); | |
2274 } | |
2275 void Grp::SaveSys(std::string& str) { | |
2276 pimpl->SaveSys(str); | |
2277 } | |
2278 | |
2279 void Grp::LoadSys(const char* str) { | |
2280 pimpl->LoadSys(str); | |
2281 } |