Mercurial > otakunoraifu
comparison scn2k/scn2k_grpimpl.cc @ 56:c7bcc0ec2267
* replaced Grp and Text classes by the TextImpl and GrpImpl ones
* splitted scn2k.h into smaller header files
* moved some definitions from scn2k_*.cc to the header files
* moved opcode implementation to scn2k_*impl.cc
author | thib |
---|---|
date | Thu, 30 Apr 2009 19:05:09 +0000 |
parents | |
children | e16e13d8cd68 |
comparison
equal
deleted
inserted
replaced
55:f1a27ee7e03c | 56:c7bcc0ec2267 |
---|---|
1 /* | |
2 * Copyright (c) 2009 Thibaut GIRKA | |
3 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
4 * All rights reserved. | |
5 * | |
6 * Redistribution and use in source and binary forms, with or without | |
7 * modification, are permitted provided that the following conditions | |
8 * are met: | |
9 * 1. Redistributions of source code must retain the above copyright | |
10 * notice, this list of conditions and the following disclaimer. | |
11 * 2. Redistributions in binary form must reproduce the above copyright | |
12 * notice, this list of conditions and the following disclaimer in the | |
13 * documentation and/or other materials provided with the distribution. | |
14 * 3. The name of the author may not be used to endorse or promote products | |
15 * derived from this software without specific prior written permission. | |
16 * | |
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #include "scn2k_grp.h" | |
30 #include "system/system_config.h" | |
31 #include "music2/music.h" | |
32 #include "window/render.h" | |
33 | |
34 void Grp::impl_stackClear (Cmd& cmd) { | |
35 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
36 } | |
37 | |
38 void Grp::impl_grpBuffer (Cmd& cmd) { | |
39 const char* name = cmd.Str(cmd.args[0]); | |
40 int pdt = cmd.args[1].value; | |
41 eprintf("load surface %s pdt %d\n",name, pdt); | |
42 if (pdt == 0) | |
43 reserved_load_surface0 = name; // 画像読み込みは 01-1f:0000 まで待つ | |
44 else if (pdt == 1) | |
45 LoadSurface(name); // 背景絵読み込み? | |
46 else | |
47 LoadSurface(name, pdt); | |
48 cmd.cmd_type = CMD_SAVECMDGRP; | |
49 } | |
50 | |
51 void Grp::impl_grpMulti(Cmd& cmd) { | |
52 int pos = cmd.args[0].value; | |
53 const char* name = cmd.Str(cmd.args[1]); | |
54 int sel = cmd.args[2].value; | |
55 eprintf("set foreground %s sel %d pos %d\n",name, sel, pos); | |
56 AddSurface(name); | |
57 StartAnm(sel); | |
58 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
59 status = WAIT_ANM; | |
60 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
61 } | |
62 | |
63 void Grp::impl_grpOpen(Cmd& cmd) { | |
64 const char* name = cmd.Str(cmd.args[0]); | |
65 int sel = cmd.args[1].value; | |
66 | |
67 if (name[0] == '?') | |
68 LoadSurface(); | |
69 else if(cmd.cmd3 == 73) | |
70 LoadSurface(name, 1); | |
71 else | |
72 LoadSurface(name); | |
73 | |
74 StartAnm(sel); | |
75 status = WAIT_ANM; | |
76 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
77 | |
78 if (name[0] == '?') | |
79 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
80 else | |
81 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
82 } | |
83 | |
84 void Grp::impl_shake(Cmd& cmd) { | |
85 // shake screen | |
86 char key[11]; | |
87 sprintf(key, "#SHAKE.%03d", cmd.args[0].value); | |
88 if (config->SearchParam(key) != 2) { | |
89 fprintf(stderr,"Cannot find shake pattern %d; use default pattern\n",cmd.args[0].value); | |
90 strcpy(key, "#SHAKE.000"); // default key | |
91 } | |
92 int num; | |
93 const int* pattern; | |
94 pattern = config->GetParamArray(key, num); | |
95 if (pattern) { | |
96 StartShake(num, pattern); | |
97 status = WAIT_SHAKE; | |
98 } | |
99 cmd.clear(); | |
100 } | |
101 | |
102 void Grp::impl_grpCopy(Cmd& cmd) { | |
103 if (cmd.cmd4 == 2) { // copy (KANOGI) | |
104 int sx = cmd.args[0].value; | |
105 int sy = cmd.args[1].value; | |
106 int w = cmd.args[2].value - sx; | |
107 int h = cmd.args[3].value - sy; | |
108 Rect rect(sx, sy, sx+w, sy+h); | |
109 int src = cmd.args[4].value; | |
110 int dx = cmd.args[5].value; | |
111 int dy = cmd.args[6].value; | |
112 int dest = cmd.args[7].value; | |
113 unsigned char alpha; | |
114 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
115 printf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
116 if (src == dest) { | |
117 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
118 src = WORKPDT; | |
119 } | |
120 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy)); | |
121 if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
122 cmd.clear(); | |
123 } | |
124 } | |
125 | |
126 void Grp::impl_recFill(Cmd& cmd) { | |
127 int x = cmd.args[0].value; | |
128 int y = cmd.args[1].value; | |
129 int w = cmd.args[2].value; | |
130 int h = cmd.args[3].value; | |
131 Rect rect(x, y, x+w, y+w); | |
132 int pdt = cmd.args[4].value; | |
133 int r = cmd.args[5].value; | |
134 int g = cmd.args[6].value; | |
135 int b = cmd.args[7].value; | |
136 | |
137 if (cmd.cmd4 == 2) { | |
138 eprintf("clear %d:(%d,%d) size (%d,%d) r %d g %d b %d\n",pdt,x,y,w,h,r,g,b); | |
139 DSurfaceFill(Dsurface(pdt), rect, r, g, b); | |
140 // if (pdt == 0) screen->ReBlit(rect); | |
141 cmd.cmd_type = CMD_SAVECMDGRP; | |
142 } | |
143 else if (cmd.cmd4 == 3) { // alpha つきfill | |
144 int a = cmd.args[8].value; | |
145 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); | |
146 if (a <= 0) ; | |
147 else if (a >= 255) DSurfaceFill(Dsurface(pdt), rect, r, g, b); | |
148 else { | |
149 DSurfaceFill(Dsurface(WORKPDT), rect, r, g, b, a); | |
150 parent.Root().BlitSurface(Dsurface(WORKPDT), rect, Dsurface(pdt), rect); | |
151 } | |
152 // if (pdt == 0) screen->ReBlit(rect); | |
153 cmd.clear(); | |
154 } | |
155 } | |
156 | |
157 void Grp::impl_recCopy(Cmd& cmd) { | |
158 int sx = cmd.args[0].value; | |
159 int sy = cmd.args[1].value; | |
160 int w = cmd.args[2].value; | |
161 int h = cmd.args[3].value; | |
162 Rect rect(sx, sy, sx + w, sy + h); | |
163 int src = cmd.args[4].value; | |
164 int dx = cmd.args[5].value; | |
165 int dy = cmd.args[6].value; | |
166 int dest = cmd.args[7].value; | |
167 | |
168 if (cmd.cmd4 == 2) { | |
169 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
170 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy)); | |
171 //DSurfaceMove(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy)); | |
172 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
173 cmd.cmd_type = CMD_SAVECMDGRP; | |
174 } | |
175 | |
176 else if (cmd.cmd4 == 3) { // alpha つきcopy | |
177 unsigned char alpha; | |
178 if (cmd.args[8].value < 0) alpha = 0; | |
179 else if (cmd.args[8].value > 255) alpha = 255; | |
180 else alpha = cmd.args[8].value; | |
181 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
182 if (src == dest) { | |
183 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
184 src = WORKPDT; | |
185 } | |
186 if (alpha != 0) | |
187 parent.Root().BlitSurface(Ssurface(src), rect, &alpha, Rect(0,0,1,1), Dsurface(dest), Rect(dx,dy), 0); | |
188 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
189 cmd.clear(); | |
190 } | |
191 } | |
192 | |
193 void Grp::impl_recAdd(Cmd& cmd) { | |
194 if (cmd.cmd4 == 3) { // saturate mode で alpha 付き copy | |
195 int sx = cmd.args[0].value; | |
196 int sy = cmd.args[1].value; | |
197 int w = cmd.args[2].value; | |
198 int h = cmd.args[3].value; | |
199 Rect rect(sx, sy, sx+w, sy+h); | |
200 int src = cmd.args[4].value; | |
201 int dx = cmd.args[5].value; | |
202 int dy = cmd.args[6].value; | |
203 int dest = cmd.args[7].value; | |
204 unsigned char alpha; | |
205 if (cmd.args[8].value < 0) alpha = 0; | |
206 else if (cmd.args[8].value > 255) alpha = 255; | |
207 else alpha = cmd.args[8].value; | |
208 eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
209 if (src == dest) { | |
210 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
211 src = WORKPDT; | |
212 } | |
213 if (alpha != 0) { | |
214 // saturate mode : screen (picture) を一時的に作成 | |
215 PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
216 screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE); | |
217 screen_tmp->SetSurfaceRect(rect); | |
218 screen_tmp->Move(dx, dy); | |
219 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); | |
220 screen_tmp->SimpleBlit(Dsurface(dest)); | |
221 delete screen_tmp; | |
222 } | |
223 cmd.clear(); | |
224 } | |
225 } | |
226 | |
227 void Grp::impl_grpPan(Cmd& cmd) { | |
228 if (cmd.cmd4 == 0) { | |
229 Rect r_from(cmd.args[0].value, cmd.args[1].value); | |
230 Rect r_to(cmd.args[2].value, cmd.args[3].value); | |
231 int src_pdt = cmd.args[4].value; | |
232 Rect r(cmd.args[5].value,cmd.args[6].value,cmd.args[7].value+1,cmd.args[8].value+1); | |
233 int tm = cmd.args[9].value; | |
234 fprintf(stderr,"??? cmd time %d\n",tm); | |
235 // anm1 = new ScnGrpMove(event, screen, parent.Root(), surface, r, Ssurface(2), r_from, r_to, tm); | |
236 // status = WAIT_ANM; | |
237 } | |
238 } | |
239 | |
240 void Grp::impl_snmBgScroll(Cmd& cmd) { | |
241 if (cmd.cmd4 == 0) { // スクロールする画像効果(Princess Bride) | |
242 if (anm2 != NULL) { | |
243 anm2->Abort(); | |
244 delete anm2; | |
245 anm2 = NULL; | |
246 } | |
247 PicBase* pic; Surface* s; | |
248 Rect r(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value+1, cmd.args[4].value+1); | |
249 const char* name = cmd.Str(cmd.args[5]); | |
250 Rect sr_start(cmd.args[6].value,cmd.args[7].value); | |
251 Rect sr_end(cmd.args[8].value,cmd.args[9].value); | |
252 int tm = cmd.args[10].value; | |
253 LoadSurface(name, 2); /* PDT2 に読み込み、と決め打ち */ | |
254 | |
255 anm2 = new ScnGrpMove(event, screen, parent.Root(), Dsurface(1), r, Ssurface(2), sr_start, sr_end, tm); | |
256 cmd.cmd_type = CMD_SAVECMDGRP; | |
257 } | |
258 } | |
259 | |
260 void Grp::impl_snmPlay(Cmd& cmd) { | |
261 if (cmd.cmd4 == 0) { | |
262 // カードが落ちるアニメーション | |
263 int i; | |
264 ScnGrpAnm* new_anm = new ScnGrpAnm(event, screen, *this); | |
265 if (cmd.cmd3 == 0x834 || cmd.cmd3 == 0x835) { | |
266 AbortAnm(); | |
267 anm1 = new_anm; | |
268 if (cmd.cmd3 == 0x835) { | |
269 status = WAIT_ANM; | |
270 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
271 } | |
272 } else { | |
273 anm2 = new_anm; | |
274 } | |
275 for (i=0; i<cmd.argc; i++) { | |
276 const char* name = cmd.Str(cmd.args[i*3+1]); | |
277 int tm = cmd.args[i*3+2].value; | |
278 new_anm->push_back(ScnGrpAnmAtom(name,tm)); | |
279 } | |
280 new_anm->CalcTotal(); | |
281 cmd.clear(); | |
282 } | |
283 } | |
284 | |
285 void Grp::impl_cgGet(Cmd& cmd) { | |
286 if (cmd.cmd3 == 0x5dc) // Total number of CG | |
287 cmd.SetSysvar(cgm_size); | |
288 | |
289 if (cmd.cmd3 == 0x5dd) // Number of CG viewed | |
290 cmd.SetSysvar(cgm_data.size()); | |
291 | |
292 if (cmd.cmd3 == 0x5de) // Percentage of CG viewed | |
293 cmd.SetSysvar(cgm_data.size() * 100 / cgm_size); | |
294 } | |
295 | |
296 void Grp::impl_cgStatus(Cmd& cmd) { | |
297 string s = cmd.Str(cmd.args[0]); | |
298 if (cgm_info.find(s) == cgm_info.end()) { | |
299 fprintf(stderr,"cmd 01-04:05e0 : cannot find cgm-info of '%s'\n",s.c_str()); | |
300 cmd.SetSysvar(-1); | |
301 } | |
302 else { | |
303 int n = cgm_info[s]; | |
304 if (cmd.cmd3 == 1503) cmd.SetSysvar(n); | |
305 else { | |
306 if (cgm_data.find(n) == cgm_data.end()) cmd.SetSysvar(0); | |
307 else cmd.SetSysvar(1); | |
308 } | |
309 } | |
310 } | |
311 | |
312 void Grp::impl_objClear(Cmd& cmd) { //FIXME: may be broken (doesn't reflect what Haeleth says) | |
313 if (cmd.cmd1 == 1) | |
314 DeleteObj(cmd.args[0].value); | |
315 if (cmd.cmd1 == 2) | |
316 DeleteSubObj(cmd.args[0].value, cmd.args[1].value); | |
317 cmd.clear(); | |
318 } | |
319 | |
320 void Grp::impl_createObj(Cmd& cmd) { | |
321 /**************: | |
322 0x47 : オブジェクト内容の設定 | |
323 1100: G00 file | |
324 1003: GAN file | |
325 1100: rect | |
326 1200: string | |
327 1300: weather effects | |
328 1400: number | |
329 */ | |
330 int base_argc = 0; | |
331 | |
332 if (cmd.cmd1 == 1) { // 1: group object | |
333 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 | |
334 if (cmd.cmd2 == 71) | |
335 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 | |
336 } | |
337 else { // 2: single object in group | |
338 DeleteSubObjPic(cmd.args[0].value, cmd.args[1].value); // 旧ファイル名のsurfaceを削除 | |
339 if (cmd.cmd2 == 71) | |
340 DeleteSubObjPic(cmd.args[0].value, cmd.args[1].value); // 旧ファイル名のsurfaceを削除 | |
341 } | |
342 | |
343 GrpObj* g = (cmd.cmd2 == 71) ? &grpobj[cmd.args[0].value] : &bs_obj[cmd.args[0].value]; | |
344 if (cmd.cmd1 == 2) // 2: single object in a group | |
345 g = &g->children_obj[cmd.args[1].value]; | |
346 | |
347 if (cmd.cmd1 == 2) | |
348 base_argc = 1; | |
349 | |
350 if (cmd.cmd3 == 1000) { /* ファイル名設定 */ | |
351 g->gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu; that happens with objComposite | |
352 string name = cmd.Str(cmd.args[base_argc + 1]); | |
353 if (name.find('?') != -1) {//TODO | |
354 //Used for shading, with DAT/tcdata.tcc or other filename provided by #TONECURVE_FILENAME | |
355 printf("Warning: the part after the '?' was removed: '%s'\n", name.c_str()); | |
356 name.erase(name.find('?')); // '?' 以降の意味がわからない | |
357 } | |
358 g->name = name; | |
359 } else if (cmd.cmd3 == 1003) { /* ファイル名設定(GAN含む) */ | |
360 g->gtype = GrpObj::GAN; | |
361 if (cmd.Str(cmd.args[base_argc + 1]) == string("???")) | |
362 g->name = cmd.Str(cmd.args[base_argc + 2]); | |
363 else | |
364 g->name = cmd.Str(cmd.args[base_argc + 1]); | |
365 g->gan_name = cmd.Str(cmd.args[base_argc + 2]); | |
366 | |
367 if (cmd.cmd4 >= 1 && cmd.args[base_argc + 3].value == 0) | |
368 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN); | |
369 else | |
370 g->attr = GrpObj::Attribute(g->attr & ~(GrpObj::HIDDEN)); | |
371 | |
372 if (cmd.argc >= base_argc + 5) | |
373 g->SetPos(1, cmd.args[base_argc + 4].value, -cmd.args[base_argc + 5].value); | |
374 | |
375 if (g->name.find('?') != -1) { | |
376 g->name.erase(g->name.find('?')); | |
377 g->gan_name = cmd.Str(cmd.args[base_argc + 2]); | |
378 } | |
379 } else if (cmd.cmd3 == 1200) { // 画像を文字列として指定 | |
380 g->gtype = GrpObj::MOJI; | |
381 g->print_moji = cmd.Str(cmd.args[base_argc + 1]); | |
382 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト? | |
383 cmd.clear(); | |
384 } else if (cmd.cmd3 == 1400) { // 数値を画像として表示 | |
385 g->gtype = GrpObj::DIGIT; | |
386 g->name = cmd.Str(cmd.args[base_argc + 1]); | |
387 } | |
388 | |
389 CreateObj(cmd.args[0].value); | |
390 if (cmd.cmd1 == 2) | |
391 CreateSubObj(cmd.args[0].value, cmd.args[1].value); | |
392 | |
393 if (cmd.cmd3 == 1000 || cmd.cmd3 == 1003 || cmd.cmd3 == 1200 || cmd.cmd3 == 1400) { | |
394 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う | |
395 if (cmd.cmd4 >= 1) { | |
396 if (cmd.args[2+base_argc].value == 0) { | |
397 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN); | |
398 } else { | |
399 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN)); | |
400 } | |
401 SetObjChanged(cmd.args[0].value); | |
402 } | |
403 if (cmd.cmd4 >= 2) { // 座標等も設定 | |
404 g->SetPos(0, cmd.args[3+base_argc].value, cmd.args[4+base_argc].value); | |
405 } | |
406 if ( (cmd.cmd3 == 1000 || cmd.cmd3 == 1003) && cmd.cmd4 >= 3) { // pattern 番号も設定 | |
407 g->SetSurfaceNum(cmd.args[5+base_argc].value); | |
408 base_argc++; // 1000 (FILE) / 1003 (GAN) の場合のみこのオプションは存在する | |
409 } | |
410 cmd.clear(); | |
411 } else { | |
412 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3); | |
413 } | |
414 } | |
415 | |
416 void Grp::impl_gan(Cmd& cmd) { | |
417 int base_arg = 0; | |
418 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg); | |
419 | |
420 if (cmd.cmd3 == 3) { // ganIsPlaying | |
421 if (g->anm == NULL || g->anm->IsEnd()) | |
422 cmd.SetSysvar(0); | |
423 else | |
424 cmd.SetSysvar(1); | |
425 } | |
426 else if (cmd.cmd3 == 1000) { // ganStop | |
427 if (g->anm == NULL || g->anm->IsEnd()) | |
428 g->SetSurfaceNum(cmd.args[1].value); | |
429 else { | |
430 g->anm->Abort(); | |
431 g->SetSurfaceNum(cmd.args[1].value); | |
432 } | |
433 SetObjChanged(cmd.args[0].value); | |
434 cmd.clear(); | |
435 } | |
436 else if (cmd.cmd3 == 2003) { // objPlay | |
437 g->CreateGanSpecial(event, 0, cmd.args[1].value); | |
438 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
439 SetObjChanged(cmd.args[0].value); | |
440 cmd.clear(); | |
441 } | |
442 else if (cmd.cmd3 == 3001 || cmd.cmd3 == 3003 || cmd.cmd3 == 3005 || | |
443 cmd.cmd3 == 1001 || cmd.cmd3 == 1003 || cmd.cmd3 == 1005) { // ganPlay* | |
444 g->CreateGan(event, cmd.args[1].value); | |
445 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
446 SetObjChanged(cmd.args[0].value); | |
447 cmd.clear(); | |
448 } | |
449 } | |
450 | |
451 void Grp::impl_objSetPos(Cmd& cmd) { | |
452 //obj or objBg | |
453 int base_arg = 0; | |
454 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
455 | |
456 int index, x, y; | |
457 if (cmd.cmd3 == 1006 || cmd.cmd3 == 2006) { //objAdjust | |
458 index = cmd.args[1+base_arg].value + 1; | |
459 x = cmd.args[2+base_arg].value; | |
460 y = cmd.args[3+base_arg].value; | |
461 } | |
462 else { | |
463 index = 0; | |
464 if (cmd.cmd3 == 1000) { | |
465 x = cmd.args[1+base_arg].value; | |
466 y = cmd.args[2+base_arg].value; | |
467 } | |
468 else { | |
469 g->GetPos(index, x, y); | |
470 if (cmd.cmd3 == 1001) | |
471 x = cmd.args[1+base_arg].value; | |
472 else | |
473 y = cmd.args[1+base_arg].value; | |
474 } | |
475 } | |
476 | |
477 g->SetPos(index, x, y); | |
478 cmd.clear(); | |
479 } | |
480 | |
481 void Grp::impl_objAlpha(Cmd& cmd) { | |
482 int base_arg = 0; | |
483 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
484 | |
485 g->SetAlpha(cmd.args[base_arg + 1].value); | |
486 cmd.clear(); | |
487 } | |
488 | |
489 void Grp::impl_objShow(Cmd& cmd) { | |
490 int base_arg = 0; | |
491 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
492 | |
493 if (cmd.args[base_arg + 1].value) | |
494 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN)); | |
495 else | |
496 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN); | |
497 | |
498 g->attr = GrpObj::Attribute(g->attr | GrpObj::UPDATE_VISIBLE); | |
499 // グループ単位で次の RefreshObj で表示・消去 | |
500 if (cmd.cmd2 == 0x51) //not Bg | |
501 SetObjChanged(cmd.args[0].value); | |
502 cmd.clear(); | |
503 } | |
504 | |
505 void Grp::impl_objColour(Cmd& cmd) { | |
506 int base_arg = 0; | |
507 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
508 | |
509 g->print_r = cmd.args[base_arg+1].value; | |
510 g->print_g = cmd.args[base_arg+2].value; | |
511 g->print_b = cmd.args[base_arg+3].value; | |
512 g->SetUpdate(); | |
513 cmd.clear(); | |
514 } | |
515 | |
516 void Grp::impl_objComposite(Cmd& cmd) {//FIXME | |
517 int base_arg = 0; | |
518 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
519 | |
520 if (cmd.args[base_arg + 1].value == 1) { | |
521 g->attr = GrpObj::Attribute(g->attr | GrpObj::SATURATE); | |
522 cmd.clear(); | |
523 } else if (cmd.args[base_arg + 1].value == 0) { | |
524 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::SATURATE)); | |
525 cmd.clear(); | |
526 } | |
527 g->SetUpdate(); | |
528 } | |
529 | |
530 void Grp::impl_objSetText(Cmd& cmd) { | |
531 int base_arg = 0; | |
532 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
533 | |
534 g->print_moji = cmd.Str(cmd.args[base_arg + 1]); | |
535 g->SetUpdate(); | |
536 cmd.clear(); | |
537 } | |
538 | |
539 void Grp::impl_objTextOpts(Cmd& cmd) { | |
540 int base_arg = 0; | |
541 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
542 | |
543 // 画像を文字列として設定:文字の大きさなど | |
544 g->print_size = cmd.args[base_arg + 1].value; | |
545 /* 前景色を得る */ | |
546 int cr, cg, cb; | |
547 char key[17]; | |
548 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[base_arg + 5].value); | |
549 if (config->GetParam(key, 3, &cr, &cg, &cb)) { // color not found | |
550 cr = cg = cb = 0; | |
551 } | |
552 g->print_r = cr; | |
553 g->print_g = cg; | |
554 g->print_b = cb; | |
555 g->SetUpdate(); | |
556 cmd.clear(); | |
557 } | |
558 | |
559 void Grp::impl_objOrder(Cmd& cmd) { | |
560 int base_arg = 0; | |
561 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
562 | |
563 int order = cmd.args[base_arg + 1].value; | |
564 g->order = order; | |
565 ZMoveObj(cmd.args[0].value); | |
566 cmd.clear(); | |
567 } | |
568 | |
569 void Grp::impl_objDispArea(Cmd& cmd) { | |
570 int base_arg = 0; | |
571 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
572 | |
573 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定 | |
574 int rx, ry, w, h; | |
575 if (cmd.args.size() == base_arg + 5) { | |
576 int rx = cmd.args[base_arg + 1].value; | |
577 int ry = cmd.args[base_arg + 2].value; | |
578 int w = cmd.args[base_arg + 3].value; | |
579 int h = cmd.args[base_arg + 4].value; | |
580 if (cmd.cmd3 == 1005) { | |
581 w -= rx; | |
582 h -= ry; | |
583 } | |
584 } | |
585 else { | |
586 rx = ry = 0; | |
587 w = screen->Width(); | |
588 h = screen->Height(); | |
589 } | |
590 g->SetClipArea(rx, ry, w, h); //TODO: case when cmd.args.size() == 1 | |
591 cmd.clear(); | |
592 } | |
593 | |
594 void Grp::impl_objSetDigits(Cmd& cmd) { | |
595 int base_arg = 0; | |
596 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
597 | |
598 g->dig_number = cmd.args[base_arg + 1].value; | |
599 g->SetUpdate(); | |
600 cmd.clear(); | |
601 } | |
602 | |
603 void Grp::impl_objNumOpts(Cmd& cmd) { | |
604 int base_arg = 0; | |
605 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
606 | |
607 g->dig_digit = cmd.args[base_arg + 1].value; | |
608 int attr = g->attr; | |
609 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK); | |
610 if (cmd.args[base_arg + 2].value) attr |= GrpObj::DIG_ZERO; | |
611 if (cmd.args[base_arg + 3].value) attr |= GrpObj::DIG_SIGN; | |
612 if (cmd.args[base_arg + 4].value) attr |= GrpObj::DIG_PACK; | |
613 g->attr = GrpObj::Attribute(attr); | |
614 g->SetUpdate(); | |
615 cmd.clear(); | |
616 } | |
617 | |
618 void Grp::impl_objPattNo(Cmd& cmd) { | |
619 int base_arg = 0; | |
620 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
621 | |
622 g->SetSurfaceNum(cmd.args[base_arg + 1].value); | |
623 cmd.clear(); | |
624 } | |
625 | |
626 void Grp::impl_objScale(Cmd& cmd) { | |
627 int base_arg = 0; | |
628 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
629 | |
630 int zoom = (cmd.args[base_arg + 1].value + cmd.args[base_arg + 2].value)/2; //FIXME: eurk | |
631 zoom = zoom*256/100; | |
632 g->SetZoomRotate(zoom, -1); | |
633 cmd.clear(); | |
634 } | |
635 | |
636 void Grp::impl_objRotate(Cmd& cmd) { | |
637 int base_arg = 0; | |
638 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); | |
639 | |
640 int angle = cmd.args[base_arg + 1].value; | |
641 angle /= 10; | |
642 if (angle < 0) { | |
643 angle %= 360; | |
644 angle += 360; | |
645 } | |
646 angle %= 360; | |
647 g->SetZoomRotate(-1, angle); | |
648 cmd.clear(); | |
649 } | |
650 | |
651 void Grp::impl_objPosDims(Cmd& cmd) { | |
652 int base_arg = 0; | |
653 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, true); | |
654 | |
655 VarInfo arg1 = cmd.args[base_arg + 1]; | |
656 VarInfo arg2 = cmd.args[base_arg + 2]; | |
657 | |
658 int val1, val2; | |
659 | |
660 if (cmd.cmd3 == 1000) | |
661 g->GetPos(0, val1, val2); | |
662 else if (cmd.cmd3 == 1100) | |
663 g->GetSrcGeom(val1, val2); | |
664 | |
665 cmd.SetFlagvar(arg1, val1); | |
666 cmd.SetFlagvar(arg2, val2); | |
667 } | |
668 | |
669 void Grp::impl_refresh(Cmd& cmd) { | |
670 // 本来は grpstack clear らしい | |
671 RefreshObj(); | |
672 // Princess Bride の中途 Staff roll | |
673 // このタイミングで描画するのが都合がいいので、 | |
674 //シナリオループを抜けて描画を起動 | |
675 cmd.cmd_type = CMD_WAITFRAMEUPDATE; | |
676 } | |
677 | |
678 void Grp::impl_bgmLoop(Cmd& cmd) { | |
679 if (cmd.cmd4 == 0 || cmd.cmd4 == 2) { | |
680 int count = 8000; | |
681 if (cmd.cmd3 == 2) | |
682 count = 0; //bgmPlay, play once | |
683 music->PlayCDROM((char*)cmd.Str(cmd.args[0]), count); | |
684 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
685 } | |
686 } | |
687 | |
688 void Grp::impl_bgmStop(Cmd& cmd) { | |
689 if (cmd.cmd4 == 0) { | |
690 if (cmd.cmd3 == 5) | |
691 music->StopCDROM(0); | |
692 else if (cmd.cmd3 == 105) | |
693 music->StopCDROM(cmd.args[0].value); | |
694 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
695 } | |
696 } | |
697 | |
698 void Grp::impl_playWav(Cmd& cmd) { | |
699 if (cmd.cmd3 == 2) { | |
700 music->PlaySE(cmd.Str(cmd.args[0]), 1); //loop | |
701 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
702 } | |
703 else { | |
704 music->PlaySE(cmd.Str(cmd.args[0])); | |
705 cmd.clear(); | |
706 } | |
707 if (cmd.cmd3 == 1) | |
708 status = WAIT_SE; | |
709 } | |
710 | |
711 void Grp::impl_playSE(Cmd& cmd) { | |
712 music->PlaySE(cmd.args[0].value); | |
713 cmd.clear(); | |
714 } | |
715 | |
716 void Grp::impl_stopWav(Cmd& cmd) { | |
717 if (cmd.cmd3 == 5) | |
718 music->StopSE(); | |
719 else if (cmd.cmd3 == 105) | |
720 music->StopSE(cmd.args[0].value); | |
721 | |
722 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
723 } | |
724 | |
725 void Grp::impl_SetVolMod(Cmd& cmd) { | |
726 music->volmod[cmd.cmd3-0x8b6] = cmd.args[0].value; | |
727 config->SetParam("#VOLMOD", 4, music->volmod[0], music->volmod[1], music->volmod[2], music->volmod[3]); | |
728 cmd.clear(); | |
729 } | |
730 | |
731 void Grp::impl_GetVolMod(Cmd& cmd) { | |
732 cmd.SetSysvar(music->volmod[cmd.cmd3-0x91a]); | |
733 } | |
734 | |
735 void Grp::impl_koePlay(Cmd& cmd) { | |
736 eprintf("play koe %d",cmd.args[0].value); | |
737 if (cmd.cmd4 == 1) { | |
738 eprintf(", para? %d",cmd.args[1].value); | |
739 } | |
740 eprintf("\n"); | |
741 char buf[1024]; sprintf(buf, "%d",cmd.args[0].value); | |
742 if ( !(skip_mode & SKIP_TEXT)) music->PlayKoe(buf); | |
743 cmd.clear(); | |
744 } | |
745 | |
746 /*It may be useful... or not. | |
747 void Grp::impl_objSwap(Cmd& cmd) { | |
748 if (cmd.cmd1 == 1 && cmd.args.size() == 2) { | |
749 SwapObj(cmd.args[0].value, cmd.args[1].value); | |
750 } | |
751 cmd.clear(); | |
752 }*/ | |
753 | |
754 void Grp::impl_movPlay(Cmd& cmd) { | |
755 if ( cmd.cmd4 == 0) { | |
756 const char* str = cmd.Str(cmd.args[0]); | |
757 int x = cmd.args[1].value; | |
758 int y = cmd.args[2].value; | |
759 int x2 = cmd.args[3].value; | |
760 int y2 = cmd.args[4].value; | |
761 eprintf("play movie ; name %s pos %d,%d - %d,%d\n",str,x,y,x2,y2); | |
762 music->PlayMovie(str, x, y, x2, y2,1); | |
763 status = WAIT_MOVIE; | |
764 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
765 cmd.clear(); | |
766 } | |
767 } |