comparison scn2k/scn2k_grp.cc @ 55:f1a27ee7e03c

* started the same changes on scn2k_text.cc * handle opcodes childObj*. In fact, it was handled (in a strange way, but it worked) before the previous changeset
author thib
date Wed, 22 Apr 2009 15:01:42 +0000
parents d7cde171a1de
children c7bcc0ec2267
comparison
equal deleted inserted replaced
54:d7cde171a1de 55:f1a27ee7e03c
51 int sel_no; 51 int sel_no;
52 int args[8]; 52 int args[8];
53 SEL() : from(0,0), to(0,0) {} 53 SEL() : from(0,0), to(0,0) {}
54 }; 54 };
55 55
56 struct GrpObj;
57 typedef std::map<int, GrpObj> GrpObjMap;
58
56 struct GrpObj { 59 struct GrpObj {
57 string name; 60 string name;
58 string gan_name; 61 string gan_name;
59 PicContainer* pic_parent; 62 PicContainer* pic_parent;
60 PicBase* picture; 63 PicBase* picture;
64 Rect clip_area; 67 Rect clip_area;
65 unsigned char alpha; 68 unsigned char alpha;
66 int order; 69 int order;
67 int surface_num; 70 int surface_num;
68 71
72 GrpObjMap children_obj;
73
69 string print_moji; 74 string print_moji;
70 int print_size, print_r, print_b, print_g; 75 int print_size, print_r, print_b, print_g;
71 76
72 int dig_number, dig_digit; 77 int dig_number, dig_digit;
73 78
75 int zoom; // 256 で 1 倍 80 int zoom; // 256 で 1 倍
76 int rotate; // 0-360度 81 int rotate; // 0-360度
77 82
78 vector<Rect> src_pos; 83 vector<Rect> src_pos;
79 enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; 84 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, 85 enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4,
81 UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, 86 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), 87 UPDATE_ALL = (UPDATE_PICTURE | UPDATE_POS | UPDATE_ALPHA | UPDATE_SNUM | UPDATE_CLIP | UPDATE_VISIBLE),
83 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000, 88 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000,
84 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16 89 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16
85 }; 90 };
86 Attribute attr; 91 Attribute attr;
87
88 GrpImpl* parent_pimpl;
89 92
90 GrpObj(void); 93 GrpObj(void);
91 ~GrpObj(void); 94 ~GrpObj(void);
92 95
93 void SetPos(int index, int x, int y); 96 void SetPos(int index, int x, int y);
103 void SetUpdate(void); 106 void SetUpdate(void);
104 void UpdateMoji(void); 107 void UpdateMoji(void);
105 void UpdateDigit(void); 108 void UpdateDigit(void);
106 void UpdateSurface(void); 109 void UpdateSurface(void);
107 void ZoomRotate(void); 110 void ZoomRotate(void);
111 void Refresh(GrpObj& parent_obj);
112 void _debug_Dump(int, int);
108 void Update(void); 113 void Update(void);
109 void CreateSurface(PicContainer* parent); 114 void CreateSurface(PicContainer* parent);
110 void CreateGan(Event::Container& event, int event_number); 115 void CreateGan(Event::Container& event, int event_number);
111 void CreateGanSpecial(Event::Container& event, int event_number, int time); 116 void CreateGanSpecial(Event::Container& event, int event_number, int time);
112 PicBase* DeletePic(void); 117 PicBase* DeletePic(void);
114 119
115 /******************************************************************* 120 /*******************************************************************
116 ** GrpObj(interface) 121 ** GrpObj(interface)
117 */ 122 */
118 123
119
120 struct GrpObjMap : std::map<int, GrpObj> {
121 typedef pair<const int, GrpObj> value_type;
122 class GrpImpl* parent;
123 GrpObj& operator[](const int& k) {
124 iterator it = lower_bound(k);
125 if (it == end() || it->first != k) {
126 GrpObj obj;
127 obj.parent_pimpl = parent;
128 it = insert(it, value_type(k, obj));
129 }
130 return it->second;
131 }
132 GrpObjMap(class GrpImpl* p) {
133 parent = p;
134 }
135 };
136
137 class GrpImpl : public CommandHandler { 124 class GrpImpl : public CommandHandler {
138 #define MAXPDT 256 125 #define MAXPDT 256
139 #define WORKPDT 255 126 #define WORKPDT 255
140 private: 127 private:
141 void CreateObj(int number); 128 void CreateObj(int number);
129 void CreateSubObj(int grp_num, int number);
142 void ZMoveObj(int number); 130 void ZMoveObj(int number);
143 void SetObjChanged(int number); 131 void SetObjChanged(int number);
144 void SwapObj(int a1, int a2); 132 void SwapObj(int a1, int a2);
145 void DeleteObjPic(int num);// object の surface のみ削除 133 void DeleteObjPic(int num);// object の surface のみ削除
134 void DeleteSubObjPic(int grp_num, int num);
146 void DeleteObj(int num); 135 void DeleteObj(int num);
136 void DeleteSubObj(int grp_num, int num);
147 void RefreshObj(void); 137 void RefreshObj(void);
148 138
149 Surface* Dsurface(int pdt); 139 Surface* Dsurface(int pdt);
150 Surface* Ssurface(int pdt); 140 Surface* Ssurface(int pdt);
151 141
172 162
173 void StartAnm(int type); 163 void StartAnm(int type);
174 void StartShake(int total, const int* pattern); 164 void StartShake(int total, const int* pattern);
175 void AbortAnm(void); 165 void AbortAnm(void);
176 static bool Pressed(int x, int y, void* pointer); 166 static bool Pressed(int x, int y, void* pointer);
167
168 GrpObj* GetGraphicObj(int grp, bool fg=true);
169 GrpObj* GetGraphicObj(int grp, int index, bool fg=true);
170 GrpObj* GetGraphicObjVarMode(Cmd& cmd, int &base_arg, bool fg=true);
177 171
178 // Opcode handling 172 // Opcode handling
179 void impl_stackClear(Cmd& cmd); 173 void impl_stackClear(Cmd& cmd);
180 void impl_grpBuffer(Cmd& cmd); 174 void impl_grpBuffer(Cmd& cmd);
181 void impl_grpMulti(Cmd &cmd); 175 void impl_grpMulti(Cmd &cmd);
261 GrpObj::GrpObj(void) : 255 GrpObj::GrpObj(void) :
262 name(""), gan_name(""), pic_parent(0), picture(0), anm(0), 256 name(""), gan_name(""), pic_parent(0), picture(0), anm(0),
263 _posx(0), _posy(0), clip_area(0,0,0,0), 257 _posx(0), _posy(0), clip_area(0,0,0,0),
264 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1), 258 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1),
265 dig_number(0), dig_digit(0), 259 dig_number(0), dig_digit(0),
266 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN), parent_pimpl(NULL) { 260 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN) {
267 int i; 261 int i;
268 for (i=0; i<9; i++) { 262 for (i=0; i<9; i++) {
269 posx[i] = posy[i] = 0; 263 posx[i] = posy[i] = 0;
270 } 264 }
271 } 265 }
272 266
273 GrpObj::~GrpObj() { 267 GrpObj::~GrpObj() {
274 if (picture) delete picture; 268 if (picture != NULL) delete picture;
275 if (parent_pimpl == NULL) {
276 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n");
277 }
278 } 269 }
279 270
280 int GrpObj::PosX() { 271 int GrpObj::PosX() {
281 return _posx; 272 return _posx;
282 } 273 }
309 x = 0; y = 0; 300 x = 0; y = 0;
310 return; 301 return;
311 } 302 }
312 x = posx[index]; 303 x = posx[index];
313 y = posy[index]; 304 y = posy[index];
314 return;
315 } 305 }
316 306
317 void GrpObj::SetAlpha(int new_alpha) { 307 void GrpObj::SetAlpha(int new_alpha) {
318 if (alpha == new_alpha) return; 308 if (alpha == new_alpha) return;
319 alpha = new_alpha; 309 alpha = new_alpha;
325 if (num != -1) { 315 if (num != -1) {
326 if (surface_num == num) return; 316 if (surface_num == num) return;
327 surface_num = num; 317 surface_num = num;
328 } 318 }
329 attr = Attribute(attr | UPDATE_SNUM); 319 attr = Attribute(attr | UPDATE_SNUM);
330 return;
331 } 320 }
332 321
333 void GrpObj::SetClipArea(int x, int y, int w, int h) { 322 void GrpObj::SetClipArea(int x, int y, int w, int h) {
334 Rect new_clip(x,y,x+w,y+h); 323 Rect new_clip(x,y,x+w,y+h);
335 if (clip_area == new_clip) return; 324 if (clip_area == new_clip) return;
336 clip_area = new_clip; 325 clip_area = new_clip;
337 attr = Attribute(attr | UPDATE_CLIP); 326 attr = Attribute(attr | UPDATE_CLIP);
338 return;
339 } 327 }
340 328
341 PicBase* GrpObj::DeletePic(void) { 329 PicBase* GrpObj::DeletePic(void) {
342 PicBase* p = picture; 330 PicBase* p = picture;
343 anm = 0; 331 anm = NULL;
344 picture = 0; 332 picture = NULL;
345 src_pos.clear(); 333 src_pos.clear();
346 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); 334 attr = Attribute(attr & HIDDEN);
347 return p; 335 return p;
348 } 336 }
349 337
350 void GrpObj::GetSrcGeom(int& width, int& height) { 338 void GrpObj::GetSrcGeom(int& width, int& height) {
351 if (src_pos.empty()) { 339 if (src_pos.empty()) {
384 } 372 }
385 int sn = surface_num; 373 int sn = surface_num;
386 if (sn < 0 || sn > src_pos.size()) sn = 0; 374 if (sn < 0 || sn > src_pos.size()) sn = 0;
387 width = src_pos[sn].width(); 375 width = src_pos[sn].width();
388 height = src_pos[sn].height(); 376 height = src_pos[sn].height();
389 return;
390 } 377 }
391 378
392 void GrpObj::Update(void) { 379 void GrpObj::Update(void) {
393 if (attr & UPDATE_PICTURE) { 380 if (attr & UPDATE_PICTURE) {
394 UpdateSurface(); 381 UpdateSurface();
395 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); 382 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE));
396 } 383 }
397 if (picture == 0) return; 384 if (picture == NULL) return;
398 if (attr & UPDATE_POS) { 385 if (attr & UPDATE_POS) {
399 if ( (attr & SATURATE) || zoom != -1) { 386 if ( (attr & SATURATE) || zoom != -1) {
400 int w=0, h=0; 387 int w=0, h=0;
401 GetSrcGeom(w,h); 388 GetSrcGeom(w,h);
402 picture->Move(_posx-w/2, _posy-h/2); 389 picture->Move(_posx-w/2, _posy-h/2);
707 if (rotate < 0) rotate = 0; 694 if (rotate < 0) rotate = 0;
708 else if (rotate > 360) rotate %= 360; 695 else if (rotate > 360) rotate %= 360;
709 696
710 attr = Attribute(attr | UPDATE_PICTURE); 697 attr = Attribute(attr | UPDATE_PICTURE);
711 } 698 }
699
700 void GrpObj::Refresh(GrpObj& parent_obj) {
701 //if (&parent_obj != this) printf("Toto\n"); //FIXME
702
703 GrpObjMap::iterator it;
704
705 for (it = children_obj.begin(); it != children_obj.end(); it++)
706 it->second.Refresh(parent_obj);
707
708 if (picture == NULL) return;
709 if (alpha == 0 || (attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN)) {
710 if (attr & GrpObj::ANM_PLAYING) {
711 attr = GrpObj::Attribute(attr & ~(GrpObj::ANM_PLAYING));
712 if (anm != NULL) anm->Abort();
713 }
714 picture->hide();
715 } else {
716 Update();
717 picture->show();
718 }
719 }
720
721 void GrpObj::_debug_Dump(int id, int indent)
722 {
723 const char* repr;
724
725 if (indent == 0)
726 repr = "obj %04d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n";
727 else
728 repr = " * obj %04d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n";
729
730 if (picture != NULL) {
731 if (!name.empty())
732 fprintf(stderr, repr,
733 id, this, name.c_str(), PosX(), PosY(), alpha, attr&GrpObj::HIDDEN ? 1 : 0, 0,
734 picture->IsHidden());
735 else if (!print_moji.empty())
736 fprintf(stderr, repr,
737 id, this, print_moji.c_str(), PosX(), PosY(), alpha, attr&GrpObj::HIDDEN ? 1 : 0,
738 0, picture->IsHidden());
739 else
740 fprintf(stderr, repr,
741 id, this, "<EMPTY>", PosX(), PosY(), alpha, attr&GrpObj::HIDDEN ? 1 : 0, 0,
742 picture->IsHidden());
743 }
744
745 GrpObjMap::iterator it;
746 for (it = children_obj.begin(); it != children_obj.end(); it++)
747 it->second._debug_Dump(it->first, indent+1);
748 }
749
712 /****************************************************************** 750 /******************************************************************
713 ** 751 **
714 ** class ScnGrp* 752 ** class ScnGrp*
715 */ 753 */
716 /* Princess Bride: 背景画の一部のみ移動、の実装 */ 754 /* Princess Bride: 背景画の一部のみ移動、の実装 */
797 event(_event), 835 event(_event),
798 flags(f), 836 flags(f),
799 parent(_parent), 837 parent(_parent),
800 status(NORMAL), 838 status(NORMAL),
801 skip_mode(SKIP_NO), 839 skip_mode(SKIP_NO),
802 cgm_data(_cgm_data), 840 cgm_data(_cgm_data)
803 grpobj(this),
804 bs_obj(this)
805 { 841 {
806 int i; 842 int i;
807 for (i=0; i<MAXPDT; i++) { 843 for (i=0; i<MAXPDT; i++) {
808 ssurface[i] = 0; 844 ssurface[i] = 0;
809 dsurface[i] = 0; 845 dsurface[i] = 0;
832 RegisterCommand(1, 33, 76, "grpOpen", (CmdImpl) &GrpImpl::impl_grpOpen); 868 RegisterCommand(1, 33, 76, "grpOpen", (CmdImpl) &GrpImpl::impl_grpOpen);
833 RegisterCommand(1, 33, 32, "shake", (CmdImpl) &GrpImpl::impl_shake); 869 RegisterCommand(1, 33, 32, "shake", (CmdImpl) &GrpImpl::impl_shake);
834 RegisterCommand(1, 33, 100, "grpCopy", (CmdImpl) &GrpImpl::impl_grpCopy); 870 RegisterCommand(1, 33, 100, "grpCopy", (CmdImpl) &GrpImpl::impl_grpCopy);
835 RegisterCommand(1, 33, 1201, "recFill", (CmdImpl) &GrpImpl::impl_recFill); 871 RegisterCommand(1, 33, 1201, "recFill", (CmdImpl) &GrpImpl::impl_recFill);
836 RegisterCommand(1, 33, 1100, "recCopy", (CmdImpl) &GrpImpl::impl_recCopy); 872 RegisterCommand(1, 33, 1100, "recCopy", (CmdImpl) &GrpImpl::impl_recCopy);
873 RegisterCommand(1, 33, 1101, "recMaskCopy", NULL); //FIXME
837 RegisterCommand(1, 33, 1600, "recAdd", (CmdImpl) &GrpImpl::impl_recAdd); 874 RegisterCommand(1, 33, 1600, "recAdd", (CmdImpl) &GrpImpl::impl_recAdd);
838 RegisterCommand(1, 33, 406, "grpPan", (CmdImpl) &GrpImpl::impl_grpPan); 875 RegisterCommand(1, 33, 406, "grpPan", (CmdImpl) &GrpImpl::impl_grpPan);
839 876
840 RegisterCommand(1, 34, 3120, "snmBgScroll", (CmdImpl) &GrpImpl::impl_snmBgScroll); 877 RegisterCommand(1, 34, 3120, "snmBgScroll", (CmdImpl) &GrpImpl::impl_snmBgScroll);
841 RegisterCommand(1, 34, 3100, "snmBgPlay", (CmdImpl) &GrpImpl::impl_snmPlay); 878 RegisterCommand(1, 34, 3100, "snmBgPlay", (CmdImpl) &GrpImpl::impl_snmPlay);
858 RegisterCommand(1, 71, 1003, "createObjGAN", (CmdImpl) &GrpImpl::impl_createObj); 895 RegisterCommand(1, 71, 1003, "createObjGAN", (CmdImpl) &GrpImpl::impl_createObj);
859 RegisterCommand(1, 71, 1100, "createObjRect", (CmdImpl) &GrpImpl::impl_createObj); 896 RegisterCommand(1, 71, 1100, "createObjRect", (CmdImpl) &GrpImpl::impl_createObj);
860 RegisterCommand(1, 71, 1200, "createObjText", (CmdImpl) &GrpImpl::impl_createObj); 897 RegisterCommand(1, 71, 1200, "createObjText", (CmdImpl) &GrpImpl::impl_createObj);
861 RegisterCommand(1, 71, 1300, "createObjWeaver", (CmdImpl) &GrpImpl::impl_createObj); 898 RegisterCommand(1, 71, 1300, "createObjWeaver", (CmdImpl) &GrpImpl::impl_createObj);
862 RegisterCommand(1, 71, 1400, "createObjDigit", (CmdImpl) &GrpImpl::impl_createObj); 899 RegisterCommand(1, 71, 1400, "createObjDigit", (CmdImpl) &GrpImpl::impl_createObj);
900
901 RegisterCommand(2, 71, 1000, "createSubObjG00", (CmdImpl) &GrpImpl::impl_createObj);
902 RegisterCommand(2, 71, 1003, "createSubObjGAN", (CmdImpl) &GrpImpl::impl_createObj);
903 RegisterCommand(2, 71, 1100, "createSubObjRect", (CmdImpl) &GrpImpl::impl_createObj);
904 RegisterCommand(2, 71, 1200, "createSubObjText", (CmdImpl) &GrpImpl::impl_createObj);
905 RegisterCommand(2, 71, 1300, "createSubObjWeaver", (CmdImpl) &GrpImpl::impl_createObj);
906 RegisterCommand(2, 71, 1400, "createSubObjDigit", (CmdImpl) &GrpImpl::impl_createObj);
863 907
864 //I suppose it's the same thing as createObj*, but I didn't see it in action. For now, mark it unhandled. 908 //I suppose it's the same thing as createObj*, but I didn't see it in action. For now, mark it unhandled.
865 RegisterCommand(1, 72, 1000, "createBgObjG00", (CmdImpl) &GrpImpl::impl_createObj); 909 RegisterCommand(1, 72, 1000, "createBgObjG00", (CmdImpl) &GrpImpl::impl_createObj);
866 RegisterCommand(1, 72, 1003, "createBgObjGAN", (CmdImpl) &GrpImpl::impl_createObj); 910 RegisterCommand(1, 72, 1003, "createBgObjGAN", (CmdImpl) &GrpImpl::impl_createObj);
867 RegisterCommand(1, 72, 1100, "createBgObjRect", (CmdImpl) &GrpImpl::impl_createObj); 911 RegisterCommand(1, 72, 1100, "createBgObjRect", (CmdImpl) &GrpImpl::impl_createObj);
868 RegisterCommand(1, 72, 1200, "createBgObjText", (CmdImpl) &GrpImpl::impl_createObj); 912 RegisterCommand(1, 72, 1200, "createBgObjText", (CmdImpl) &GrpImpl::impl_createObj);
869 RegisterCommand(1, 72, 1300, "createBgObjWeaver", (CmdImpl) &GrpImpl::impl_createObj); 913 RegisterCommand(1, 72, 1300, "createBgObjWeaver", (CmdImpl) &GrpImpl::impl_createObj);
870 RegisterCommand(1, 72, 1400, "createBgObjDigit", (CmdImpl) &GrpImpl::impl_createObj); 914 RegisterCommand(1, 72, 1400, "createBgObjDigit", (CmdImpl) &GrpImpl::impl_createObj);
915
916 RegisterCommand(2, 72, 1000, "createBgSubObjG00", NULL);//FIXME
917 RegisterCommand(2, 72, 1003, "createBgSubObjGAN", NULL);//FIXME
918 RegisterCommand(2, 72, 1100, "createBgSubObjRect", NULL);//FIXME
919 RegisterCommand(2, 72, 1200, "createBgSubObjText", NULL);//FIXME
920 RegisterCommand(2, 72, 1300, "createBgSubObjWeaver", NULL);//FIXME
921 RegisterCommand(2, 72, 1400, "createBgSubObjDigit", NULL);//FIXME
922
871 923
872 RegisterCommand(1, 73, 0, "ganStop?", NULL); //That's what xclannad says, but I'm not sure... 924 RegisterCommand(1, 73, 0, "ganStop?", NULL); //That's what xclannad says, but I'm not sure...
873 RegisterCommand(1, 73, 1000, "ganStop", (CmdImpl) &GrpImpl::impl_gan); //That's what rldev says 925 RegisterCommand(1, 73, 1000, "ganStop", (CmdImpl) &GrpImpl::impl_gan); //That's what rldev says
874 RegisterCommand(1, 73, 3, "ganIsPlaying", (CmdImpl) &GrpImpl::impl_gan); 926 RegisterCommand(1, 73, 3, "ganIsPlaying", (CmdImpl) &GrpImpl::impl_gan);
875 RegisterCommand(1, 73, 2003, "objPlay", (CmdImpl) &GrpImpl::impl_gan); 927 RegisterCommand(1, 73, 2003, "objPlay", (CmdImpl) &GrpImpl::impl_gan);
878 RegisterCommand(1, 73, 1005, "ganPlayOnce", (CmdImpl) &GrpImpl::impl_gan); 930 RegisterCommand(1, 73, 1005, "ganPlayOnce", (CmdImpl) &GrpImpl::impl_gan);
879 RegisterCommand(1, 73, 3001, "ganLoop2", (CmdImpl) &GrpImpl::impl_gan); 931 RegisterCommand(1, 73, 3001, "ganLoop2", (CmdImpl) &GrpImpl::impl_gan);
880 RegisterCommand(1, 73, 3003, "ganPlay2", (CmdImpl) &GrpImpl::impl_gan); 932 RegisterCommand(1, 73, 3003, "ganPlay2", (CmdImpl) &GrpImpl::impl_gan);
881 RegisterCommand(1, 73, 3005, "ganPlayOnce2", (CmdImpl) &GrpImpl::impl_gan); 933 RegisterCommand(1, 73, 3005, "ganPlayOnce2", (CmdImpl) &GrpImpl::impl_gan);
882 934
935 RegisterCommand(2, 73, 0, "ganSubStop?", NULL); //FIXME
936 RegisterCommand(2, 73, 1000, "ganSubStop", NULL); //FIXME
937 RegisterCommand(2, 73, 3, "ganSubIsPlaying", NULL); //FIXME
938 RegisterCommand(2, 73, 2003, "objSubPlay", NULL); //FIXME
939 RegisterCommand(2, 73, 1001, "ganSubLoop", NULL); //FIXME
940 RegisterCommand(2, 73, 1003, "ganSubPlay", NULL); //FIXME
941 RegisterCommand(2, 73, 1005, "ganSubPlayOnce", NULL); //FIXME
942 RegisterCommand(2, 73, 3001, "ganSubLoop2", (CmdImpl) &GrpImpl::impl_gan); //FIXME
943 RegisterCommand(2, 73, 3003, "ganSubPlay2", NULL); //FIXME
944 RegisterCommand(2, 73, 3005, "ganSubPlayOnce2", NULL); //FIXME
945
946
883 RegisterCommand(1, 81, 1000, "objMove", (CmdImpl) &GrpImpl::impl_objSetPos); 947 RegisterCommand(1, 81, 1000, "objMove", (CmdImpl) &GrpImpl::impl_objSetPos);
884 RegisterCommand(1, 82, 1000, "objBgMove", (CmdImpl) &GrpImpl::impl_objSetPos); 948 RegisterCommand(1, 82, 1000, "objBgMove", (CmdImpl) &GrpImpl::impl_objSetPos);
885 RegisterCommand(1, 81, 1001, "objLeft", (CmdImpl) &GrpImpl::impl_objSetPos); 949 RegisterCommand(1, 81, 1001, "objLeft", (CmdImpl) &GrpImpl::impl_objSetPos);
886 RegisterCommand(1, 82, 1001, "objBgLeft", (CmdImpl) &GrpImpl::impl_objSetPos); 950 RegisterCommand(1, 82, 1001, "objBgLeft", (CmdImpl) &GrpImpl::impl_objSetPos);
887 RegisterCommand(1, 81, 1002, "objTop", (CmdImpl) &GrpImpl::impl_objSetPos); 951 RegisterCommand(1, 81, 1002, "objTop", (CmdImpl) &GrpImpl::impl_objSetPos);
888 RegisterCommand(1, 82, 1002, "objBgTop", (CmdImpl) &GrpImpl::impl_objSetPos); 952 RegisterCommand(1, 82, 1002, "objBgTop", (CmdImpl) &GrpImpl::impl_objSetPos);
889
890 RegisterCommand(1, 81, 1003, "objAlpha", (CmdImpl) &GrpImpl::impl_objAlpha); 953 RegisterCommand(1, 81, 1003, "objAlpha", (CmdImpl) &GrpImpl::impl_objAlpha);
891 RegisterCommand(1, 82, 1003, "objBgAlpha", (CmdImpl) &GrpImpl::impl_objAlpha); 954 RegisterCommand(1, 82, 1003, "objBgAlpha", (CmdImpl) &GrpImpl::impl_objAlpha);
892 RegisterCommand(1, 81, 1004, "objShow", (CmdImpl) &GrpImpl::impl_objShow); 955 RegisterCommand(1, 81, 1004, "objShow", (CmdImpl) &GrpImpl::impl_objShow);
893 RegisterCommand(1, 82, 1004, "objBgShow", (CmdImpl) &GrpImpl::impl_objShow); 956 RegisterCommand(1, 82, 1004, "objBgShow", (CmdImpl) &GrpImpl::impl_objShow);
894
895 RegisterCommand(1, 81, 1005, "objDispArea", NULL); 957 RegisterCommand(1, 81, 1005, "objDispArea", NULL);
896 RegisterCommand(1, 82, 1005, "objBgDispArea", NULL); 958 RegisterCommand(1, 82, 1005, "objBgDispArea", NULL);
897 RegisterCommand(1, 81, 1006, "objAdjust", (CmdImpl) &GrpImpl::impl_objSetPos); 959 RegisterCommand(1, 81, 1006, "objAdjust", (CmdImpl) &GrpImpl::impl_objSetPos);
898 RegisterCommand(1, 82, 1006, "objBgAdjust", NULL); //FIXME: (CmdImpl) &GrpImpl::impl_objSetPos); 960 RegisterCommand(1, 82, 1006, "objBgAdjust", NULL); //FIXME: (CmdImpl) &GrpImpl::impl_objSetPos);
899 RegisterCommand(1, 81, 1007, "objAdjustX", NULL); 961 RegisterCommand(1, 81, 1007, "objAdjustX", NULL);
910 RegisterCommand(1, 82, 1018, "objBgColG", NULL); 972 RegisterCommand(1, 82, 1018, "objBgColG", NULL);
911 RegisterCommand(1, 81, 1019, "objColB", NULL); 973 RegisterCommand(1, 81, 1019, "objColB", NULL);
912 RegisterCommand(1, 82, 1019, "objBgColB", NULL); 974 RegisterCommand(1, 82, 1019, "objBgColB", NULL);
913 RegisterCommand(1, 81, 1020, "objColLevel", NULL); 975 RegisterCommand(1, 81, 1020, "objColLevel", NULL);
914 RegisterCommand(1, 82, 1020, "objBgColLevel", NULL); 976 RegisterCommand(1, 82, 1020, "objBgColLevel", NULL);
915 RegisterCommand(1, 81, 1021, "objComposite", (CmdImpl) &GrpImpl::impl_objComposite); //FIXME: May be broken 977 RegisterCommand(1, 81, 1021, "objComposite", NULL);//(CmdImpl) &GrpImpl::impl_objComposite); //FIXME: May be broken
916 RegisterCommand(1, 82, 1021, "objBgComposite", (CmdImpl) &GrpImpl::impl_objComposite); 978 RegisterCommand(1, 82, 1021, "objBgComposite", (CmdImpl) &GrpImpl::impl_objComposite);
917 RegisterCommand(1, 81, 1024, "objSetText", (CmdImpl) &GrpImpl::impl_objSetText); 979 RegisterCommand(1, 81, 1024, "objSetText", (CmdImpl) &GrpImpl::impl_objSetText);
918 RegisterCommand(1, 82, 1024, "objBgSetText", (CmdImpl) &GrpImpl::impl_objSetText); 980 RegisterCommand(1, 82, 1024, "objBgSetText", (CmdImpl) &GrpImpl::impl_objSetText);
919 RegisterCommand(1, 81, 1025, "objTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts); //FIXME: Incomplete 981 RegisterCommand(1, 81, 1025, "objTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts); //FIXME: Incomplete
920 RegisterCommand(1, 82, 1025, "objBgTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts); 982 RegisterCommand(1, 82, 1025, "objBgTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts);
933 RegisterCommand(1, 81, 1047, "objWidth", NULL); 995 RegisterCommand(1, 81, 1047, "objWidth", NULL);
934 RegisterCommand(1, 82, 1047, "objBgWidth", NULL); 996 RegisterCommand(1, 82, 1047, "objBgWidth", NULL);
935 RegisterCommand(1, 81, 1049, "objRotate", (CmdImpl) &GrpImpl::impl_objRotate); 997 RegisterCommand(1, 81, 1049, "objRotate", (CmdImpl) &GrpImpl::impl_objRotate);
936 RegisterCommand(1, 82, 1049, "objBgRotate", (CmdImpl) &GrpImpl::impl_objRotate); 998 RegisterCommand(1, 82, 1049, "objBgRotate", (CmdImpl) &GrpImpl::impl_objRotate);
937 999
1000 RegisterCommand(2, 81, 1000, "childObjMove", (CmdImpl) &GrpImpl::impl_objSetPos);
1001 RegisterCommand(2, 82, 1000, "childObjBgMove", (CmdImpl) &GrpImpl::impl_objSetPos);
1002 RegisterCommand(2, 81, 1001, "childObjLeft", NULL);
1003 RegisterCommand(2, 82, 1001, "childObjBgLeft", NULL);
1004 RegisterCommand(2, 81, 1002, "childObjTop", NULL);
1005 RegisterCommand(2, 82, 1002, "childObjBgTop", NULL);
1006 RegisterCommand(2, 81, 1003, "childObjAlpha", (CmdImpl) &GrpImpl::impl_objAlpha);
1007 RegisterCommand(2, 82, 1003, "childObjBgAlpha", (CmdImpl) &GrpImpl::impl_objAlpha);
1008 RegisterCommand(2, 81, 1004, "childObjShow", (CmdImpl) &GrpImpl::impl_objShow);
1009 RegisterCommand(2, 82, 1004, "childObjBgShow", (CmdImpl) &GrpImpl::impl_objShow);
1010 RegisterCommand(2, 81, 1005, "childObjDispArea", NULL);
1011 RegisterCommand(2, 82, 1005, "childObjBgDispArea", NULL);
1012 RegisterCommand(2, 81, 1006, "childObjAdjust", (CmdImpl) &GrpImpl::impl_objSetPos);
1013 RegisterCommand(2, 82, 1006, "childObjBgAdjust", (CmdImpl) &GrpImpl::impl_objSetPos);
1014 RegisterCommand(2, 81, 1007, "childObjAdjustX", NULL);
1015 RegisterCommand(2, 82, 1007, "childObjBgAdjustX", NULL);
1016 RegisterCommand(2, 81, 1008, "childObjAdjustY", NULL);
1017 RegisterCommand(2, 82, 1008, "childObjBgAdjustY", NULL);
1018 RegisterCommand(2, 81, 2006, "childObjAdjust2?", NULL);
1019 RegisterCommand(2, 82, 2006, "childObjBgAdjust2?", NULL);
1020 RegisterCommand(2, 81, 1016, "childObjColour", NULL);
1021 RegisterCommand(2, 82, 1016, "childObjBgColour", NULL);
1022 RegisterCommand(2, 81, 1017, "childObjColR", NULL);
1023 RegisterCommand(2, 82, 1017, "childObjBgColR", NULL);
1024 RegisterCommand(2, 81, 1018, "childObjColG", NULL);
1025 RegisterCommand(2, 82, 1018, "childObjBgColG", NULL);
1026 RegisterCommand(2, 81, 1019, "childObjColB", NULL);
1027 RegisterCommand(2, 82, 1019, "childObjBgColB", NULL);
1028 RegisterCommand(2, 81, 1020, "childObjColLevel", NULL);
1029 RegisterCommand(2, 82, 1020, "childObjBgColLevel", NULL);
1030 RegisterCommand(2, 81, 1021, "childObjComposite", NULL);
1031 RegisterCommand(2, 82, 1021, "childObjBgComposite", NULL);
1032 RegisterCommand(2, 81, 1024, "childObjSetText", (CmdImpl) &GrpImpl::impl_objSetText);
1033 RegisterCommand(2, 82, 1024, "childObjBgSetText", (CmdImpl) &GrpImpl::impl_objSetText);
1034 RegisterCommand(2, 81, 1025, "childObjTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts);
1035 RegisterCommand(2, 82, 1025, "childObjBgTextOpts", (CmdImpl) &GrpImpl::impl_objTextOpts);
1036 RegisterCommand(2, 81, 1032, "childObjOrder", NULL);
1037 RegisterCommand(2, 82, 1032, "childObjBgOrder", NULL);
1038 RegisterCommand(2, 81, 1034, "childObjDispRect", NULL);
1039 RegisterCommand(2, 82, 1034, "childObjBgDispRect", NULL);
1040 RegisterCommand(2, 81, 1037, "childObjSetDigits", (CmdImpl) &GrpImpl::impl_objSetDigits);
1041 RegisterCommand(2, 82, 1037, "childObjBgSetDigits", (CmdImpl) &GrpImpl::impl_objSetDigits);
1042 RegisterCommand(2, 81, 1038, "childObjNumOpts", (CmdImpl) &GrpImpl::impl_objNumOpts);
1043 RegisterCommand(2, 82, 1038, "childObjBgNumOpts", (CmdImpl) &GrpImpl::impl_objNumOpts);
1044 RegisterCommand(2, 81, 1039, "childObjPattNo", (CmdImpl) &GrpImpl::impl_objPattNo);
1045 RegisterCommand(2, 82, 1039, "childObjBgPattNo", (CmdImpl) &GrpImpl::impl_objPattNo);
1046 RegisterCommand(2, 81, 1046, "childObjScale", (CmdImpl) &GrpImpl::impl_objScale);
1047 RegisterCommand(2, 82, 1046, "childObjBgScale", (CmdImpl) &GrpImpl::impl_objScale);
1048 RegisterCommand(2, 81, 1047, "childObjWidth", NULL);
1049 RegisterCommand(2, 82, 1047, "childObjBgWidth", NULL);
1050 RegisterCommand(2, 81, 1049, "childObjRotate", NULL);
1051 RegisterCommand(2, 82, 1049, "childObjBgRotate", NULL);
1052
938 RegisterCommand(1, 84, 1000, "objGetPos", (CmdImpl) &GrpImpl::impl_objPosDims); 1053 RegisterCommand(1, 84, 1000, "objGetPos", (CmdImpl) &GrpImpl::impl_objPosDims);
939 RegisterCommand(1, 84, 1100, "objGetDims", (CmdImpl) &GrpImpl::impl_objPosDims); 1054 RegisterCommand(1, 84, 1100, "objGetDims", (CmdImpl) &GrpImpl::impl_objPosDims);
1055
1056 RegisterCommand(2, 84, 1000, "childObjGetPos", (CmdImpl) &GrpImpl::impl_objPosDims);
1057 RegisterCommand(2, 84, 1100, "childObjGetDims", (CmdImpl) &GrpImpl::impl_objPosDims);
940 1058
941 RegisterCommand(1, 31, 0, "refresh", (CmdImpl) &GrpImpl::impl_refresh); 1059 RegisterCommand(1, 31, 0, "refresh", (CmdImpl) &GrpImpl::impl_refresh);
942 1060
943 RegisterCommand(1, 20, 0, "bgmLoop", (CmdImpl) &GrpImpl::impl_bgmLoop); 1061 RegisterCommand(1, 20, 0, "bgmLoop", (CmdImpl) &GrpImpl::impl_bgmLoop);
944 RegisterCommand(1, 20, 1, "bgmPlayEx", (CmdImpl) &GrpImpl::impl_bgmLoop); //FIXME: wait 1062 RegisterCommand(1, 20, 1, "bgmPlayEx", (CmdImpl) &GrpImpl::impl_bgmLoop); //FIXME: wait
976 RegisterCommand(1, 26, 20, "movPlayExC", (CmdImpl) &GrpImpl::impl_movPlay); 1094 RegisterCommand(1, 26, 20, "movPlayExC", (CmdImpl) &GrpImpl::impl_movPlay);
977 1095
978 RegisterCommand(1, 61, 14, "objSwap?", NULL); 1096 RegisterCommand(1, 61, 14, "objSwap?", NULL);
979 RegisterCommand(1, 62, 14, "objSwap?", NULL); 1097 RegisterCommand(1, 62, 14, "objSwap?", NULL);
980 1098
1099 RegisterCommand(1, 4, 1211, "EnableSyscom", NULL);
1100 RegisterCommand(1, 4, 1212, "HideSyscom", NULL);
1101 RegisterCommand(1, 4, 1213, "DisableSyscom", NULL);
1102
981 anm1 = NULL; 1103 anm1 = NULL;
982 anm2 = NULL; 1104 anm2 = NULL;
983 } 1105 }
984 1106
985 GrpImpl::~GrpImpl() { 1107 GrpImpl::~GrpImpl() {
1013 DSurfaceMove(ssurface[pdt], Rect(*ssurface[pdt]), dsurface[pdt], Rect(0,0)); 1135 DSurfaceMove(ssurface[pdt], Rect(*ssurface[pdt]), dsurface[pdt], Rect(0,0));
1014 parent.Root().DeleteSurface(ssurface[pdt]); 1136 parent.Root().DeleteSurface(ssurface[pdt]);
1015 ssurface[pdt] = 0; 1137 ssurface[pdt] = 0;
1016 } 1138 }
1017 return dsurface[pdt]; 1139 return dsurface[pdt];
1140 }
1141
1142 GrpObj* GrpImpl::GetGraphicObj(int grp, bool fg) {
1143 if (fg)
1144 return &grpobj[grp];
1145 else
1146 return &bs_obj[grp];
1147 }
1148
1149 GrpObj* GrpImpl::GetGraphicObj(int grp, int index, bool fg) {
1150 GrpObj* g = GetGraphicObj(grp, fg);
1151 return &g->children_obj[index];
1152 }
1153
1154 GrpObj* GrpImpl::GetGraphicObjVarMode(Cmd& cmd, int &base_arg, bool fg) {
1155 GrpObj* g;
1156 if (cmd.cmd1 == 2) {
1157 g = GetGraphicObj(cmd.args[base_arg].value, cmd.args[base_arg+1].value, fg);
1158 base_arg += 1;
1159 }
1160 else
1161 g = GetGraphicObj(cmd.args[base_arg].value, fg);
1162 return g;
1018 } 1163 }
1019 1164
1020 #include <SDL.h> 1165 #include <SDL.h>
1021 Surface* GrpImpl::Ssurface(int pdt) { 1166 Surface* GrpImpl::Ssurface(int pdt) {
1022 if (pdt == 0) return surface; 1167 if (pdt == 0) return surface;
1106 if (!changed_obj.empty()) { 1251 if (!changed_obj.empty()) {
1107 set<int>::iterator it; 1252 set<int>::iterator it;
1108 for (it=changed_obj.begin(); it != changed_obj.end(); it++) { 1253 for (it=changed_obj.begin(); it != changed_obj.end(); it++) {
1109 if (grpobj.find(*it) == grpobj.end()) continue; 1254 if (grpobj.find(*it) == grpobj.end()) continue;
1110 GrpObj& obj = grpobj[*it]; 1255 GrpObj& obj = grpobj[*it];
1111 if (obj.picture == NULL) continue; 1256 obj.Refresh(obj);
1112 if (obj.alpha == 0 || (obj.attr & GrpObj::HIDDEN)) {
1113 if (obj.attr & GrpObj::ANM_PLAYING) {
1114 obj.attr = GrpObj::Attribute(obj.attr & ~(GrpObj::ANM_PLAYING));
1115 if (obj.anm) obj.anm->Abort();
1116 }
1117 obj.picture->hide();
1118 } else {
1119 obj.Update();
1120 obj.picture->show();
1121 }
1122 } 1257 }
1123 changed_obj.clear(); 1258 changed_obj.clear();
1124 } 1259 }
1125 if (reserved_load_surface0.length() != 0) { 1260 if (reserved_load_surface0.length() != 0) {
1126 LoadSurface(reserved_load_surface0.c_str(), 0); 1261 LoadSurface(reserved_load_surface0.c_str(), 0);
1185 // 新しい object へ更新、surface_update へ新しい object を表示 1320 // 新しい object へ更新、surface_update へ新しい object を表示
1186 // (object 作成時は picture は hide されている) 1321 // (object 作成時は picture は hide されている)
1187 for (it=bs_obj.begin(); it!=bs_obj.end(); it++) { 1322 for (it=bs_obj.begin(); it!=bs_obj.end(); it++) {
1188 grpobj[it->first] = it->second; 1323 grpobj[it->first] = it->second;
1189 it->second.DeletePic(); 1324 it->second.DeletePic();
1190 CreateObj(it->first); 1325 CreateObj(it->first);//FIXME: Adapt to groups
1191 GrpObj& g = grpobj[it->first]; 1326 GrpObj& g = grpobj[it->first];
1192 if (g.picture) { 1327 if (g.picture) {
1193 g.Update(); 1328 g.Update();
1194 if (g.alpha == 0 || (g.attr & GrpObj::HIDDEN)) ; 1329 if (g.alpha == 0 || (g.attr & GrpObj::HIDDEN)) ;
1195 else g.picture->SimpleBlit(surface_update); 1330 else g.picture->SimpleBlit(surface_update);
1285 fprintf(stderr,"Cannot find surface %s\n",str); 1420 fprintf(stderr,"Cannot find surface %s\n",str);
1286 } 1421 }
1287 } 1422 }
1288 1423
1289 void GrpImpl::CreateObj(int index) { 1424 void GrpImpl::CreateObj(int index) {
1290 std::map<int, GrpObj>::iterator cur = grpobj.find(index); 1425 GrpObjMap::iterator cur = grpobj.find(index);
1291 if (cur == grpobj.end()) return; 1426 if (cur == grpobj.end()) return;
1292 GrpObj& g = grpobj[index]; 1427 GrpObj& g = grpobj[index];
1293 g.CreateSurface(&parent); 1428 g.CreateSurface(&parent);
1294 g.order = index; 1429 g.order = index;
1295 if (g.picture == NULL) return; // エラー:surface が存在しない 1430 if (g.picture == NULL) return; // エラー:surface が存在しない
1296 g.picture->hide(); 1431 g.picture->hide();
1297 SetObjChanged(index); 1432 SetObjChanged(index);
1298 ZMoveObj(index); 1433 ZMoveObj(index);
1299 } 1434 }
1300 1435
1436 void GrpImpl::CreateSubObj(int grp_index, int index) {
1437 GrpObjMap::iterator cur = grpobj.find(grp_index);
1438 if (cur == grpobj.end()) return;
1439 GrpObj* g = &grpobj[grp_index];
1440 cur = g->children_obj.find(index);
1441 if (cur == g->children_obj.end()) return;
1442 g = &g->children_obj[index];
1443 g->CreateSurface(&parent);
1444 g->order = index;
1445 if (g->picture == NULL) return; // エラー:surface が存在しない
1446 g->picture->hide();
1447 //TODO
1448 SetObjChanged(grp_index);
1449 /*ZMoveObj(index);*/
1450 }
1451
1301 void GrpImpl::ZMoveObj(int index) { 1452 void GrpImpl::ZMoveObj(int index) {
1302 std::map<int, GrpObj>::iterator cur = grpobj.find(index); 1453 GrpObjMap::iterator cur = grpobj.find(index);
1303 if (cur == grpobj.end()) return; 1454 if (cur == grpobj.end()) return;
1304 GrpObj& g = grpobj[index]; 1455 GrpObj& g = grpobj[index];
1305 if (g.picture == NULL) return; 1456 if (g.picture == NULL) return;
1306 // 自分より前に object があれば、その前に表示 1457 // 自分より前に object があれば、その前に表示
1307 // そうでなければ screen の前に表示 1458 // そうでなければ screen の前に表示
1308 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); 1459 GrpObjMap::iterator cur_backobj = grpobj.end();
1309 std::map<int, GrpObj>::iterator it; 1460 GrpObjMap::iterator it;
1310 for (it = grpobj.begin(); it != grpobj.end(); it++) { 1461 for (it = grpobj.begin(); it != grpobj.end(); it++) {
1311 if (it == cur) continue; 1462 if (it == cur) continue;
1312 if (it->second.picture == NULL) continue; 1463 if (it->second.picture == NULL) continue;
1313 if (it->second.order < g.order) { 1464 if (it->second.order < g.order) {
1314 if (cur_backobj == grpobj.end()) { 1465 if (cur_backobj == grpobj.end()) {
1524 static int draw_n = 0; 1675 static int draw_n = 0;
1525 extern bool grpdump_req; 1676 extern bool grpdump_req;
1526 bool GrpImpl::Wait(unsigned int current_time, Cmd& cmd) { 1677 bool GrpImpl::Wait(unsigned int current_time, Cmd& cmd) {
1527 if (grpdump_req) { 1678 if (grpdump_req) {
1528 grpdump_req = 0; 1679 grpdump_req = 0;
1529 std::map<int,GrpObj>::iterator it; 1680 GrpObjMap::iterator it;
1530 fprintf(stderr,"front %p(%d) / %p(%d)\n",screen,screen->IsHidden(),screen_front,screen_front->IsHidden()); 1681 fprintf(stderr,"front %p(%d) / %p(%d)\n",screen,screen->IsHidden(),screen_front,screen_front->IsHidden());
1531 for (it=grpobj.begin(); it != grpobj.end(); it++) { 1682 for (it=grpobj.begin(); it != grpobj.end(); it++) {
1532 GrpObj& obj = it->second; 1683 GrpObj& obj = it->second;
1533 if (obj.picture) { 1684 obj._debug_Dump(it->first, 0);
1534 if (!obj.name.empty()) {
1535 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
1536 it->first,obj.picture,obj.name.c_str(),
1537 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0, 0, obj.picture->IsHidden());
1538 } else if (!obj.print_moji.empty()) {
1539 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
1540 it->first,obj.picture,obj.print_moji.c_str(),
1541 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0, 0, obj.picture->IsHidden());
1542 } else {
1543 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
1544 it->first,obj.picture,"<EMPTY>",
1545 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0, 0, obj.picture->IsHidden());
1546 }
1547 }
1548 } 1685 }
1549 std::list<PicBase*>::iterator it2; 1686 std::list<PicBase*>::iterator it2;
1550 for (it2=parent.children.begin(); it2!=parent.children.end();it2++) { 1687 for (it2=parent.children.begin(); it2!=parent.children.end();it2++) {
1551 fprintf(stderr,"%p(%d)\n",*it2,(*it2)->IsHidden()); 1688 fprintf(stderr,"%p(%d)\n",*it2,(*it2)->IsHidden());
1552 } 1689 }
1617 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 1754 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除
1618 if (grpobj.find(num) == grpobj.end()) return; 1755 if (grpobj.find(num) == grpobj.end()) return;
1619 deleted_pic.push_back(grpobj[num].DeletePic()); 1756 deleted_pic.push_back(grpobj[num].DeletePic());
1620 } 1757 }
1621 1758
1759 void GrpImpl::DeleteSubObjPic(int num_grp, int num) {
1760 if (grpobj.find(num_grp) == grpobj.end()) return;
1761 if (grpobj[num_grp].children_obj.find(num) == grpobj[num_grp].children_obj.end()) return;
1762 deleted_pic.push_back(grpobj[num_grp].children_obj[num].DeletePic());
1763 }
1764
1622 void GrpImpl::DeleteObj(int num) { 1765 void GrpImpl::DeleteObj(int num) {
1623 if (grpobj.find(num) == grpobj.end()) return; 1766 if (grpobj.find(num) == grpobj.end()) return;
1624 deleted_pic.push_back(grpobj[num].DeletePic()); 1767 deleted_pic.push_back(grpobj[num].DeletePic());
1768 GrpObjMap::iterator it;
1769 for (it = grpobj[num].children_obj.begin(); it != grpobj[num].children_obj.end(); it++) {
1770 deleted_pic.push_back(it->second.DeletePic());
1771 }
1625 grpobj.erase(num); 1772 grpobj.erase(num);
1773 }
1774
1775 void GrpImpl::DeleteSubObj(int num_grp, int num) {
1776 if (grpobj.find(num_grp) == grpobj.end()) return;
1777 if (grpobj[num_grp].children_obj.find(num) == grpobj[num_grp].children_obj.end()) return;
1778 deleted_pic.push_back(grpobj[num_grp].children_obj[num].DeletePic());
1779 grpobj[num_grp].children_obj.erase(num);
1626 } 1780 }
1627 1781
1628 void GrpImpl::impl_stackClear (Cmd& cmd) { 1782 void GrpImpl::impl_stackClear (Cmd& cmd) {
1629 cmd.cmd_type = CMD_SAVECMDGRP_START; 1783 cmd.cmd_type = CMD_SAVECMDGRP_START;
1630 } 1784 }
1902 } 2056 }
1903 } 2057 }
1904 } 2058 }
1905 2059
1906 void GrpImpl::impl_objClear(Cmd& cmd) { //FIXME: may be broken (doesn't reflect what Haeleth says) 2060 void GrpImpl::impl_objClear(Cmd& cmd) { //FIXME: may be broken (doesn't reflect what Haeleth says)
1907 DeleteObj(cmd.args[0].value); 2061 if (cmd.cmd1 == 1)
2062 DeleteObj(cmd.args[0].value);
2063 if (cmd.cmd1 == 2)
2064 DeleteSubObj(cmd.args[0].value, cmd.args[1].value);
1908 cmd.clear(); 2065 cmd.clear();
1909 } 2066 }
1910 2067
1911 void GrpImpl::impl_createObj(Cmd& cmd) { 2068 void GrpImpl::impl_createObj(Cmd& cmd) {
1912 /**************: 2069 /**************:
1917 1200: string 2074 1200: string
1918 1300: weather effects 2075 1300: weather effects
1919 1400: number 2076 1400: number
1920 */ 2077 */
1921 int base_argc = 0; 2078 int base_argc = 0;
1922 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 2079
1923 if (cmd.cmd2 == 71) 2080 if (cmd.cmd1 == 1) { // 1: group object
1924 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 2081 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除
1925 2082 if (cmd.cmd2 == 71)
1926 GrpObj& g = (cmd.cmd2 == 71) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2083 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除
2084 }
2085 else { // 2: single object in group
2086 DeleteSubObjPic(cmd.args[0].value, cmd.args[1].value); // 旧ファイル名のsurfaceを削除
2087 if (cmd.cmd2 == 71)
2088 DeleteSubObjPic(cmd.args[0].value, cmd.args[1].value); // 旧ファイル名のsurfaceを削除
2089 }
2090
2091 GrpObj* g = (cmd.cmd2 == 71) ? &grpobj[cmd.args[0].value] : &bs_obj[cmd.args[0].value];
2092 if (cmd.cmd1 == 2) // 2: single object in a group
2093 g = &g->children_obj[cmd.args[1].value];
2094
2095 if (cmd.cmd1 == 2)
2096 base_argc = 1;
1927 2097
1928 if (cmd.cmd3 == 1000) { /* ファイル名設定 */ 2098 if (cmd.cmd3 == 1000) { /* ファイル名設定 */
1929 g.gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu 2099 g->gtype = GrpObj::FILE; //FIXME: Strange thing in the main menu; that happens with objComposite
1930 string name = cmd.Str(cmd.args[1]); 2100 string name = cmd.Str(cmd.args[base_argc + 1]);
1931 if (name.find('?') != -1) { 2101 if (name.find('?') != -1) {
2102 //Maybe it's for shading or something like that?
2103 printf("Warning: the part after the '?' was removed: '%s'\n", name.c_str());
1932 name.erase(name.find('?')); // '?' 以降の意味がわからない 2104 name.erase(name.find('?')); // '?' 以降の意味がわからない
1933 } 2105 }
1934 g.name = name; 2106 g->name = name;
1935 } else if (cmd.cmd3 == 1003) { /* ファイル名設定(GAN含む) */ 2107 } else if (cmd.cmd3 == 1003) { /* ファイル名設定(GAN含む) */
1936 g.gtype = GrpObj::GAN; 2108 g->gtype = GrpObj::GAN;
1937 if (cmd.Str(cmd.args[1]) == string("???")) 2109 if (cmd.Str(cmd.args[base_argc + 1]) == string("???"))
1938 g.name = cmd.Str(cmd.args[2]); 2110 g->name = cmd.Str(cmd.args[base_argc + 2]);
1939 else 2111 else
1940 g.name = cmd.Str(cmd.args[1]); 2112 g->name = cmd.Str(cmd.args[base_argc + 1]);
1941 g.gan_name = cmd.Str(cmd.args[2]); 2113 g->gan_name = cmd.Str(cmd.args[base_argc + 2]);
1942 if (cmd.cmd4 >= 1 && cmd.args[3].value == 0) 2114
1943 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); 2115 if (cmd.cmd4 >= 1 && cmd.args[base_argc + 3].value == 0)
2116 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN);
1944 else 2117 else
1945 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN)); 2118 g->attr = GrpObj::Attribute(g->attr & ~(GrpObj::HIDDEN));
1946 2119
1947 if (cmd.argc >= 5) 2120 if (cmd.argc >= base_argc + 5)
1948 g.SetPos(1, cmd.args[4].value, -cmd.args[5].value); 2121 g->SetPos(1, cmd.args[base_argc + 4].value, -cmd.args[base_argc + 5].value);
1949 2122
1950 if (g.name.find('?') != -1) { 2123 if (g->name.find('?') != -1) {
1951 g.name.erase(g.name.find('?')); 2124 g->name.erase(g->name.find('?'));
1952 g.gan_name = cmd.Str(cmd.args[2]); 2125 g->gan_name = cmd.Str(cmd.args[base_argc + 2]);
1953 } 2126 }
1954 } else if (cmd.cmd3 == 1200) { // 画像を文字列として指定 2127 } else if (cmd.cmd3 == 1200) { // 画像を文字列として指定
1955 g.gtype = GrpObj::MOJI; 2128 g->gtype = GrpObj::MOJI;
1956 g.print_moji = cmd.Str(cmd.args[1]); 2129 g->print_moji = cmd.Str(cmd.args[base_argc + 1]);
1957 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト? 2130 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト?
1958 cmd.clear(); 2131 cmd.clear();
1959 } else if (cmd.cmd3 == 1400) { // 数値を画像として表示 2132 } else if (cmd.cmd3 == 1400) { // 数値を画像として表示
1960 g.gtype = GrpObj::DIGIT; 2133 g->gtype = GrpObj::DIGIT;
1961 g.name = cmd.Str(cmd.args[1]); 2134 g->name = cmd.Str(cmd.args[base_argc + 1]);
1962 } 2135 }
2136
1963 CreateObj(cmd.args[0].value); 2137 CreateObj(cmd.args[0].value);
2138 if (cmd.cmd1 == 2)
2139 CreateSubObj(cmd.args[0].value, cmd.args[1].value);
2140
1964 if (cmd.cmd3 == 1000 || cmd.cmd3 == 1003 || cmd.cmd3 == 1200 || cmd.cmd3 == 1400) { 2141 if (cmd.cmd3 == 1000 || cmd.cmd3 == 1003 || cmd.cmd3 == 1200 || cmd.cmd3 == 1400) {
1965 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う 2142 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う
1966 if (cmd.cmd4 >= 1) { 2143 if (cmd.cmd4 >= 1) {
1967 if (cmd.args[2+base_argc].value == 0) { 2144 if (cmd.args[2+base_argc].value == 0) {
1968 if (cmd.cmd1 == 1) 2145 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN);
1969 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP);
1970 else
1971 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
1972 } else { 2146 } else {
1973 if (cmd.cmd1 == 1) 2147 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN));
1974 g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP)));
1975 else
1976 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
1977 } 2148 }
1978 if (cmd.cmd1 == 1) 2149 SetObjChanged(cmd.args[0].value);
1979 SetObjChanged(cmd.args[0].value);
1980 } 2150 }
1981 if (cmd.cmd4 >= 2) { // 座標等も設定 2151 if (cmd.cmd4 >= 2) { // 座標等も設定
1982 g.SetPos(0, cmd.args[3+base_argc].value, cmd.args[4+base_argc].value); 2152 g->SetPos(0, cmd.args[3+base_argc].value, cmd.args[4+base_argc].value);
1983 } 2153 }
1984 if ( (cmd.cmd3 == 1000 || cmd.cmd3 == 1003) && cmd.cmd4 >= 3) { // pattern 番号も設定 2154 if ( (cmd.cmd3 == 1000 || cmd.cmd3 == 1003) && cmd.cmd4 >= 3) { // pattern 番号も設定
1985 g.SetSurfaceNum(cmd.args[5+base_argc].value); 2155 g->SetSurfaceNum(cmd.args[5+base_argc].value);
1986 base_argc++; // 1000 (FILE) / 1003 (GAN) の場合のみこのオプションは存在する 2156 base_argc++; // 1000 (FILE) / 1003 (GAN) の場合のみこのオプションは存在する
1987 } 2157 }
1988 cmd.clear(); 2158 cmd.clear();
1989 } else { 2159 } else {
1990 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3); 2160 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3);
1991 } 2161 }
1992 } 2162 }
1993 2163
1994 void GrpImpl::impl_gan(Cmd& cmd) { 2164 void GrpImpl::impl_gan(Cmd& cmd) {
1995 GrpObj& g = grpobj[cmd.args[0].value]; 2165 int base_arg = 0;
2166 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg);
1996 2167
1997 if (cmd.cmd3 == 3) { // ganIsPlaying 2168 if (cmd.cmd3 == 3) { // ganIsPlaying
1998 if (g.anm == NULL || g.anm->IsEnd()) 2169 if (g->anm == NULL || g->anm->IsEnd())
1999 cmd.SetSysvar(0); 2170 cmd.SetSysvar(0);
2000 else 2171 else
2001 cmd.SetSysvar(1); 2172 cmd.SetSysvar(1);
2002 } 2173 }
2003 else if (cmd.cmd3 == 1000) { // ganStop 2174 else if (cmd.cmd3 == 1000) { // ganStop
2004 if (g.anm == NULL || g.anm->IsEnd()) 2175 if (g->anm == NULL || g->anm->IsEnd())
2005 g.SetSurfaceNum(cmd.args[1].value); 2176 g->SetSurfaceNum(cmd.args[1].value);
2006 else { 2177 else {
2007 g.anm->Abort(); 2178 g->anm->Abort();
2008 g.SetSurfaceNum(cmd.args[1].value); 2179 g->SetSurfaceNum(cmd.args[1].value);
2009 } 2180 }
2010 SetObjChanged(cmd.args[0].value); 2181 SetObjChanged(cmd.args[0].value);
2011 cmd.clear(); 2182 cmd.clear();
2012 } 2183 }
2013 else if (cmd.cmd3 == 2003) { // objPlay 2184 else if (cmd.cmd3 == 2003) { // objPlay
2014 g.CreateGanSpecial(event, 0, cmd.args[1].value); 2185 g->CreateGanSpecial(event, 0, cmd.args[1].value);
2015 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); 2186 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
2016 SetObjChanged(cmd.args[0].value); 2187 SetObjChanged(cmd.args[0].value);
2017 cmd.clear(); 2188 cmd.clear();
2018 } 2189 }
2019 else if (cmd.cmd3 == 3001 || cmd.cmd3 == 3003 || cmd.cmd3 == 3005 || 2190 else if (cmd.cmd3 == 3001 || cmd.cmd3 == 3003 || cmd.cmd3 == 3005 ||
2020 cmd.cmd3 == 1001 || cmd.cmd3 == 1003 || cmd.cmd3 == 1005) { // ganPlay* 2191 cmd.cmd3 == 1001 || cmd.cmd3 == 1003 || cmd.cmd3 == 1005) { // ganPlay*
2021 g.CreateGan(event, cmd.args[1].value); 2192 g->CreateGan(event, cmd.args[1].value);
2022 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); 2193 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
2023 SetObjChanged(cmd.args[0].value); 2194 SetObjChanged(cmd.args[0].value);
2024 cmd.clear(); 2195 cmd.clear();
2025 } 2196 }
2026 } 2197 }
2027 2198
2028 void GrpImpl::impl_objSetPos(Cmd& cmd) { 2199 void GrpImpl::impl_objSetPos(Cmd& cmd) {
2029 //obj or objBg 2200 //obj or objBg
2030 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2201 int base_arg = 0;
2202 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2031 2203
2032 int index, x, y; 2204 int index, x, y;
2033 if (cmd.cmd3 == 1006 || cmd.cmd3 == 2006) { //objAdjust 2205 if (cmd.cmd3 == 1006 || cmd.cmd3 == 2006) { //objAdjust
2034 index = cmd.args[1].value + 1; 2206 index = cmd.args[1+base_arg].value + 1;
2035 x = cmd.args[2].value; 2207 x = cmd.args[2+base_arg].value;
2036 y = cmd.args[3].value; 2208 y = cmd.args[3+base_arg].value;
2037 } 2209 }
2038 else { 2210 else {
2039 index = 0; 2211 index = 0;
2040 if (cmd.cmd3 == 1000) { 2212 if (cmd.cmd3 == 1000) {
2041 x = cmd.args[1].value; 2213 x = cmd.args[1+base_arg].value;
2042 y = cmd.args[2].value; 2214 y = cmd.args[2+base_arg].value;
2043 } 2215 }
2044 else { 2216 else {
2045 g.GetPos(index, x, y); 2217 g->GetPos(index, x, y);
2046 if (cmd.cmd3 == 1001) 2218 if (cmd.cmd3 == 1001)
2047 x = cmd.args[1].value; 2219 x = cmd.args[1+base_arg].value;
2048 else 2220 else
2049 y = cmd.args[1].value; 2221 y = cmd.args[1+base_arg].value;
2050 } 2222 }
2051 } 2223 }
2052 2224
2053 g.SetPos(index, x, y); 2225 g->SetPos(index, x, y);
2054 cmd.clear(); 2226 cmd.clear();
2055 } 2227 }
2056 2228
2057 void GrpImpl::impl_objAlpha(Cmd& cmd) { 2229 void GrpImpl::impl_objAlpha(Cmd& cmd) {
2058 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2230 int base_arg = 0;
2059 g.SetAlpha(cmd.args[1].value); 2231 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2232
2233 g->SetAlpha(cmd.args[base_arg + 1].value);
2060 cmd.clear(); 2234 cmd.clear();
2061 } 2235 }
2062 2236
2063 void GrpImpl::impl_objShow(Cmd& cmd) { 2237 void GrpImpl::impl_objShow(Cmd& cmd) {
2064 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2238 int base_arg = 0;
2065 if (cmd.cmd1 == 1) { 2239 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2066 if (cmd.args[1].value) 2240
2067 g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP))); 2241 if (cmd.args[base_arg + 1].value)
2068 else 2242 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::HIDDEN));
2069 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP); 2243 else
2070 } else { 2244 g->attr = GrpObj::Attribute(g->attr | GrpObj::HIDDEN);
2071 if (cmd.args[1].value) 2245
2072 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); 2246 g->attr = GrpObj::Attribute(g->attr | GrpObj::UPDATE_VISIBLE);
2073 else
2074 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
2075 }
2076 g.attr = GrpObj::Attribute(g.attr | GrpObj::UPDATE_VISIBLE);
2077 // グループ単位で次の RefreshObj で表示・消去 2247 // グループ単位で次の RefreshObj で表示・消去
2078 if (cmd.cmd2 == 0x51) //not Bg 2248 if (cmd.cmd2 == 0x51) //not Bg
2079 SetObjChanged(cmd.args[0].value); 2249 SetObjChanged(cmd.args[0].value);
2080 cmd.clear(); 2250 cmd.clear();
2081 } 2251 }
2082 2252
2083 void GrpImpl::impl_objColour(Cmd& cmd) { 2253 void GrpImpl::impl_objColour(Cmd& cmd) {
2084 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2254 int base_arg = 0;
2085 g.print_r = cmd.args[1].value; 2255 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2086 g.print_g = cmd.args[2].value; 2256
2087 g.print_b = cmd.args[3].value; 2257 g->print_r = cmd.args[base_arg+1].value;
2088 g.SetUpdate(); 2258 g->print_g = cmd.args[base_arg+2].value;
2089 // grpobj[cmd.args[0].value].print_a = cmd.args[4].value; 2259 g->print_b = cmd.args[base_arg+3].value;
2090 /* args:229,18,minus-1,0,99,255,-1 */ 2260 g->SetUpdate();
2091 /* args:102,26,minus-1,0,99,0,255 */
2092 cmd.clear(); 2261 cmd.clear();
2093 } 2262 }
2094 2263
2095 void GrpImpl::impl_objComposite(Cmd& cmd) { 2264 void GrpImpl::impl_objComposite(Cmd& cmd) {//FIXME
2096 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2265 int base_arg = 0;
2097 // centering mode などを設定? 2266 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2098 if (cmd.args[1].value == 1) { 2267
2099 g.attr = GrpObj::Attribute(g.attr | GrpObj::SATURATE); 2268 if (cmd.args[base_arg + 1].value == 1) {
2269 g->attr = GrpObj::Attribute(g->attr | GrpObj::SATURATE);
2100 cmd.clear(); 2270 cmd.clear();
2101 } else if (cmd.args[1].value == 0) { 2271 } else if (cmd.args[base_arg + 1].value == 0) {
2102 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::SATURATE)); 2272 g->attr = GrpObj::Attribute(g->attr & (~GrpObj::SATURATE));
2103 cmd.clear(); 2273 cmd.clear();
2104 } 2274 }
2105 g.SetUpdate(); 2275 g->SetUpdate();
2106 } 2276 }
2107 2277
2108 void GrpImpl::impl_objSetText(Cmd& cmd) { 2278 void GrpImpl::impl_objSetText(Cmd& cmd) {
2109 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2279 int base_arg = 0;
2110 2280 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2111 g.print_moji = cmd.Str(cmd.args[1]); 2281
2112 g.SetUpdate(); 2282 g->print_moji = cmd.Str(cmd.args[base_arg + 1]);
2283 g->SetUpdate();
2113 cmd.clear(); 2284 cmd.clear();
2114 } 2285 }
2115 2286
2116 void GrpImpl::impl_objTextOpts(Cmd& cmd) { 2287 void GrpImpl::impl_objTextOpts(Cmd& cmd) {
2117 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2288 int base_arg = 0;
2289 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2290
2118 // 画像を文字列として設定:文字の大きさなど 2291 // 画像を文字列として設定:文字の大きさなど
2119 g.print_size = cmd.args[1].value; 2292 g->print_size = cmd.args[base_arg + 1].value;
2120 /* 前景色を得る */ 2293 /* 前景色を得る */
2121 int cr, cg, cb; 2294 int cr, cg, cb;
2122 char key[17]; 2295 char key[17];
2123 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[5].value); 2296 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[base_arg + 5].value);
2124 if (config->GetParam(key, 3, &cr, &cg, &cb)) { // color not found 2297 if (config->GetParam(key, 3, &cr, &cg, &cb)) { // color not found
2125 cr = cg = cb = 0; 2298 cr = cg = cb = 0;
2126 } 2299 }
2127 g.print_r = cr; 2300 g->print_r = cr;
2128 g.print_g = cg; 2301 g->print_g = cg;
2129 g.print_b = cb; 2302 g->print_b = cb;
2130 g.SetUpdate(); 2303 g->SetUpdate();
2131 cmd.clear(); 2304 cmd.clear();
2132 } 2305 }
2133 2306
2134 void GrpImpl::impl_objOrder(Cmd& cmd) { 2307 void GrpImpl::impl_objOrder(Cmd& cmd) {
2135 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2308 int base_arg = 0;
2136 int order = cmd.args[1].value; 2309 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2137 g.order = order; 2310
2311 int order = cmd.args[base_arg + 1].value;
2312 g->order = order;
2138 ZMoveObj(cmd.args[0].value); 2313 ZMoveObj(cmd.args[0].value);
2139 cmd.clear(); 2314 cmd.clear();
2140 } 2315 }
2141 2316
2142 void GrpImpl::impl_objDispArea(Cmd& cmd) { 2317 void GrpImpl::impl_objDispArea(Cmd& cmd) {
2143 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2318 int base_arg = 0;
2319 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2320
2144 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定 2321 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定
2145 int rx, ry, w, h; 2322 int rx, ry, w, h;
2146 if (cmd.args.size() == 5) { 2323 if (cmd.args.size() == base_arg + 5) {
2147 int rx = cmd.args[1].value; 2324 int rx = cmd.args[base_arg + 1].value;
2148 int ry = cmd.args[2].value; 2325 int ry = cmd.args[base_arg + 2].value;
2149 int w = cmd.args[3].value; 2326 int w = cmd.args[base_arg + 3].value;
2150 int h = cmd.args[4].value; 2327 int h = cmd.args[base_arg + 4].value;
2151 if (cmd.cmd3 == 1005) { 2328 if (cmd.cmd3 == 1005) {
2152 w -= rx; 2329 w -= rx;
2153 h -= ry; 2330 h -= ry;
2154 } 2331 }
2155 } 2332 }
2156 else { 2333 else {
2157 rx = ry = 0; 2334 rx = ry = 0;
2158 w = screen->Width(); 2335 w = screen->Width();
2159 h = screen->Height(); 2336 h = screen->Height();
2160 } 2337 }
2161 g.SetClipArea(rx, ry, w, h); //TODO: case when cmd.args.size() == 1 2338 g->SetClipArea(rx, ry, w, h); //TODO: case when cmd.args.size() == 1
2162 cmd.clear(); 2339 cmd.clear();
2163 } 2340 }
2164 2341
2165 void GrpImpl::impl_objSetDigits(Cmd& cmd) { 2342 void GrpImpl::impl_objSetDigits(Cmd& cmd) {
2166 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2343 int base_arg = 0;
2167 g.dig_number = cmd.args[1].value; 2344 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2168 g.SetUpdate(); 2345
2346 g->dig_number = cmd.args[base_arg + 1].value;
2347 g->SetUpdate();
2169 cmd.clear(); 2348 cmd.clear();
2170 } 2349 }
2171 2350
2172 void GrpImpl::impl_objNumOpts(Cmd& cmd) { 2351 void GrpImpl::impl_objNumOpts(Cmd& cmd) {
2173 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2352 int base_arg = 0;
2174 g.dig_digit = cmd.args[1].value; 2353 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2175 int attr = g.attr; 2354
2355 g->dig_digit = cmd.args[base_arg + 1].value;
2356 int attr = g->attr;
2176 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK); 2357 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK);
2177 if (cmd.args[2].value) attr |= GrpObj::DIG_ZERO; 2358 if (cmd.args[base_arg + 2].value) attr |= GrpObj::DIG_ZERO;
2178 if (cmd.args[3].value) attr |= GrpObj::DIG_SIGN; 2359 if (cmd.args[base_arg + 3].value) attr |= GrpObj::DIG_SIGN;
2179 if (cmd.args[4].value) attr |= GrpObj::DIG_PACK; 2360 if (cmd.args[base_arg + 4].value) attr |= GrpObj::DIG_PACK;
2180 g.attr = GrpObj::Attribute(attr); 2361 g->attr = GrpObj::Attribute(attr);
2181 g.SetUpdate(); 2362 g->SetUpdate();
2182 cmd.clear(); 2363 cmd.clear();
2183 } 2364 }
2184 2365
2185 void GrpImpl::impl_objPattNo(Cmd& cmd) { 2366 void GrpImpl::impl_objPattNo(Cmd& cmd) {
2186 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2367 int base_arg = 0;
2187 g.SetSurfaceNum(cmd.args[1].value); 2368 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2369
2370 g->SetSurfaceNum(cmd.args[base_arg + 1].value);
2188 cmd.clear(); 2371 cmd.clear();
2189 } 2372 }
2190 2373
2191 void GrpImpl::impl_objScale(Cmd& cmd) { 2374 void GrpImpl::impl_objScale(Cmd& cmd) {
2192 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2375 int base_arg = 0;
2193 int zoom = (cmd.args[1].value + cmd.args[2].value)/2; //FIXME: eurk 2376 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2377
2378 int zoom = (cmd.args[base_arg + 1].value + cmd.args[base_arg + 2].value)/2; //FIXME: eurk
2194 zoom = zoom*256/100; 2379 zoom = zoom*256/100;
2195 g.SetZoomRotate(zoom, -1); 2380 g->SetZoomRotate(zoom, -1);
2196 cmd.clear(); 2381 cmd.clear();
2197 } 2382 }
2198 2383
2199 void GrpImpl::impl_objRotate(Cmd& cmd) { 2384 void GrpImpl::impl_objRotate(Cmd& cmd) {
2200 GrpObj& g = (cmd.cmd2 == 0x51) ? grpobj[cmd.args[0].value] : bs_obj[cmd.args[0].value]; 2385 int base_arg = 0;
2201 int angle = cmd.args[1].value; 2386 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, (cmd.cmd2 == 0x51));
2387
2388 int angle = cmd.args[base_arg + 1].value;
2202 angle /= 10; 2389 angle /= 10;
2203 if (angle < 0) { 2390 if (angle < 0) {
2204 angle %= 360; 2391 angle %= 360;
2205 angle += 360; 2392 angle += 360;
2206 } 2393 }
2207 angle %= 360; 2394 angle %= 360;
2208 g.SetZoomRotate(-1, angle); 2395 g->SetZoomRotate(-1, angle);
2209 cmd.clear(); 2396 cmd.clear();
2210 } 2397 }
2211 2398
2212 void GrpImpl::impl_objPosDims(Cmd& cmd) { 2399 void GrpImpl::impl_objPosDims(Cmd& cmd) {
2213 GrpObj& obj = grpobj[cmd.args[0].value]; 2400 int base_arg = 0;
2214 2401 GrpObj* g = GetGraphicObjVarMode(cmd, base_arg, true);
2215 VarInfo arg1 = cmd.args[1]; 2402
2216 VarInfo arg2 = cmd.args[2]; 2403 VarInfo arg1 = cmd.args[base_arg + 1];
2404 VarInfo arg2 = cmd.args[base_arg + 2];
2217 2405
2218 int val1, val2; 2406 int val1, val2;
2219 2407
2220 if (cmd.cmd3 == 1000) 2408 if (cmd.cmd3 == 1000)
2221 obj.GetPos(0, val1, val2); 2409 g->GetPos(0, val1, val2);
2222 else if (cmd.cmd3 == 1100) 2410 else if (cmd.cmd3 == 1100)
2223 obj.GetSrcGeom(val1, val2); 2411 g->GetSrcGeom(val1, val2);
2224 2412
2225 cmd.SetFlagvar(arg1, val1); 2413 cmd.SetFlagvar(arg1, val1);
2226 cmd.SetFlagvar(arg2, val2); 2414 cmd.SetFlagvar(arg2, val2);
2227 } 2415 }
2228 2416
2348 cmd.clear(); 2536 cmd.clear();
2349 } 2537 }
2350 2538
2351 //TODO: ??? 2539 //TODO: ???
2352 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 0x51) { 2540 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && cmd.cmd2 == 0x51) {
2353 GrpObj& g = grpobj[cmd.args[0].value]; 2541 /*GrpObj& g = grpobj[cmd.args[0].value];
2354 if (g.attr & GrpObj::UPDATE_ALL) { 2542 int attr;
2543 GrpObjMap::iterator it;
2544 for (it = g.children_obj.begin(); it != g.children_obj.end(); it++)
2545 attr |= it->second.attr;
2546 if (attr & GrpObj::UPDATE_ALL)
2547 SetObjChanged(cmd.args[0].value);*/
2548 GrpObj* g;
2549 if (cmd.cmd1 == 2)
2550 g = GetGraphicObj(cmd.args[0].value, cmd.args[1].value);
2551 else
2552 g = GetGraphicObj(cmd.args[0].value);
2553 if (g->attr & GrpObj::UPDATE_ALL)
2355 SetObjChanged(cmd.args[0].value); 2554 SetObjChanged(cmd.args[0].value);
2356 }
2357 } 2555 }
2358 } 2556 }
2359 2557
2360 2558
2361 /******************************************************** 2559 /********************************************************