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