comparison scn2k/scn2k_grpimpl.cc @ 60:e16e13d8cd68

Replaced SATURATE -> ADD, implemented objComposite, corrected minor things
author Thibaut GIRKA <thib@sitedethib.com>
date Fri, 18 Dec 2009 20:41:38 +0100
parents c7bcc0ec2267
children bdd8a5ff8f46
comparison
equal deleted inserted replaced
59:36d92d21300f 60:e16e13d8cd68
153 cmd.clear(); 153 cmd.clear();
154 } 154 }
155 } 155 }
156 156
157 void Grp::impl_recCopy(Cmd& cmd) { 157 void Grp::impl_recCopy(Cmd& cmd) {
158 //TODO: Handle forms 0 and 1
158 int sx = cmd.args[0].value; 159 int sx = cmd.args[0].value;
159 int sy = cmd.args[1].value; 160 int sy = cmd.args[1].value;
160 int w = cmd.args[2].value; 161 int w = cmd.args[2].value;
161 int h = cmd.args[3].value; 162 int h = cmd.args[3].value;
162 Rect rect(sx, sy, sx + w, sy + h); 163 Rect rect(sx, sy, sx + w, sy + h);
170 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy)); 171 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 //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 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h));
173 cmd.cmd_type = CMD_SAVECMDGRP; 174 cmd.cmd_type = CMD_SAVECMDGRP;
174 } 175 }
175
176 else if (cmd.cmd4 == 3) { // alpha つきcopy 176 else if (cmd.cmd4 == 3) { // alpha つきcopy
177 unsigned char alpha; 177 unsigned char alpha;
178 if (cmd.args[8].value < 0) alpha = 0; 178 if (cmd.args[8].value < 0) alpha = 0;
179 else if (cmd.args[8].value > 255) alpha = 255; 179 else if (cmd.args[8].value > 255) alpha = 255;
180 else alpha = cmd.args[8].value; 180 else alpha = cmd.args[8].value;
189 cmd.clear(); 189 cmd.clear();
190 } 190 }
191 } 191 }
192 192
193 void Grp::impl_recAdd(Cmd& cmd) { 193 void Grp::impl_recAdd(Cmd& cmd) {
194 if (cmd.cmd4 == 3) { // saturate mode で alpha 付き copy 194 if (cmd.cmd4 == 3) { // add mode で alpha 付き copy
195 int sx = cmd.args[0].value; 195 int sx = cmd.args[0].value;
196 int sy = cmd.args[1].value; 196 int sy = cmd.args[1].value;
197 int w = cmd.args[2].value; 197 int w = cmd.args[2].value;
198 int h = cmd.args[3].value; 198 int h = cmd.args[3].value;
199 Rect rect(sx, sy, sx+w, sy+h); 199 Rect rect(sx, sy, sx+w, sy+h);
203 int dest = cmd.args[7].value; 203 int dest = cmd.args[7].value;
204 unsigned char alpha; 204 unsigned char alpha;
205 if (cmd.args[8].value < 0) alpha = 0; 205 if (cmd.args[8].value < 0) alpha = 0;
206 else if (cmd.args[8].value > 255) alpha = 255; 206 else if (cmd.args[8].value > 255) alpha = 255;
207 else alpha = cmd.args[8].value; 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); 208 eprintf("copy surface w/ add %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
209 if (src == dest) { 209 if (src == dest) {
210 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); 210 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect);
211 src = WORKPDT; 211 src = WORKPDT;
212 } 212 }
213 if (alpha != 0) { 213 if (alpha != 0) {
214 // saturate mode : screen (picture) を一時的に作成 214 // add mode : screen (picture) を一時的に作成
215 PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); 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); 216 screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_ADD);
217 screen_tmp->SetSurfaceRect(rect); 217 screen_tmp->SetSurfaceRect(rect);
218 screen_tmp->Move(dx, dy); 218 screen_tmp->Move(dx, dy);
219 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); 219 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1));
220 screen_tmp->SimpleBlit(Dsurface(dest)); 220 screen_tmp->SimpleBlit(Dsurface(dest));
221 delete screen_tmp; 221 delete screen_tmp;
346 346
347 if (cmd.cmd1 == 2) 347 if (cmd.cmd1 == 2)
348 base_argc = 1; 348 base_argc = 1;
349 349
350 if (cmd.cmd3 == 1000) { /* ファイル名設定 */ 350 if (cmd.cmd3 == 1000) { /* ファイル名設定 */
351 g->gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu; that happens with objComposite 351 g->gtype = GrpObj::FILE;
352 string name = cmd.Str(cmd.args[base_argc + 1]); 352 string name = cmd.Str(cmd.args[base_argc + 1]);
353 if (name.find('?') != -1) {//TODO 353 if (name.find('?') != -1) {//TODO
354 //Used for shading, with DAT/tcdata.tcc or other filename provided by #TONECURVE_FILENAME 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()); 355 printf("Warning: the part after the '?' was removed: '%s'\n", name.c_str());
356 name.erase(name.find('?')); // '?' 以降の意味がわからない 356 name.erase(name.find('?')); // '?' 以降の意味がわからない
514 } 514 }
515 515
516 void Grp::impl_objComposite(Cmd& cmd) {//FIXME 516 void Grp::impl_objComposite(Cmd& cmd) {//FIXME
517 int base_arg = 0; 517 int base_arg = 0;
518 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51)); 518 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
519
520 if (cmd.args[base_arg + 1].value == 1) { 519 if (cmd.args[base_arg + 1].value == 1) {
521 g->attr = GrpObj::Attribute(g->attr | GrpObj::SATURATE); 520 g->attr = GrpObj::Attribute(g->attr | GrpObj::BLIT_ADD);
522 cmd.clear(); 521 cmd.clear();
523 } else if (cmd.args[base_arg + 1].value == 0) { 522 } else if (cmd.args[base_arg + 1].value == 0) {
524 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::SATURATE)); 523 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::BLIT_ADD));
525 cmd.clear(); 524 cmd.clear();
526 } 525 }
527 g->SetUpdate(); 526 g->SetUpdate();
528 } 527 }
529 528
763 status = WAIT_MOVIE; 762 status = WAIT_MOVIE;
764 event.RegisterGlobalPressFunc(&Pressed, (void*)this); 763 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
765 cmd.clear(); 764 cmd.clear();
766 } 765 }
767 } 766 }
767