1 // -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi:tw=80:et:ts=2:sts=2
3 //
4 // -----------------------------------------------------------------------
5 //
6 // This file is part of RLVM, a RealLive virtual machine clone.
7 //
8 // -----------------------------------------------------------------------
9 //
10 // Copyright (C) 2006, 2007 Elliot Glaysher
11 //
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 // -----------------------------------------------------------------------
27
28 // Contains definitions for object handling functions for the Modules 81
29 // "ObjFg", 82 "ObjBg", 90 "ObjRange", and 91 "ObjBgRange".
30
31 #include "modules/module_obj_fg_bg.h"
32
33 #include <cmath>
34 #include <functional>
35 #include <iomanip>
36 #include <iostream>
37 #include <memory>
38 #include <sstream>
39 #include <string>
40 #include <vector>
41
42 #include "libreallive/bytecode.h"
43 #include "libreallive/gameexe.h"
44 #include "machine/long_operation.h"
45 #include "machine/properties.h"
46 #include "machine/rlmachine.h"
47 #include "machine/rlmodule.h"
48 #include "machine/rloperation.h"
49 #include "machine/rloperation/default_value.h"
50 #include "machine/rloperation/rect_t.h"
51 #include "modules/module_obj.h"
52 #include "modules/object_mutator_operations.h"
53 #include "systems/base/colour_filter_object_data.h"
54 #include "systems/base/event_system.h"
55 #include "systems/base/graphics_object.h"
56 #include "systems/base/graphics_object_data.h"
57 #include "systems/base/graphics_system.h"
58 #include "systems/base/graphics_text_object.h"
59 #include "systems/base/object_mutator.h"
60 #include "systems/base/system.h"
61 #include "utilities/exception.h"
62 #include "utilities/graphics.h"
63 #include "utilities/string_utilities.h"
64
65 namespace {
66
67 struct dispArea_0 : public RLOpcode<IntConstant_T> {
operator ()__anon3e2ab1020111::dispArea_068 void operator()(RLMachine& machine, int buf) {
69 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
70 obj.ClearClipRect();
71 machine.system().graphics().mark_object_state_as_dirty();
72 }
73 };
74
75 struct dispArea_1 : RLOpcode<IntConstant_T,
76 IntConstant_T,
77 IntConstant_T,
78 IntConstant_T,
79 IntConstant_T> {
operator ()__anon3e2ab1020111::dispArea_180 void operator()(RLMachine& machine, int buf, int x1, int y1, int x2, int y2) {
81 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
82 obj.SetClipRect(Rect::GRP(x1, y1, x2, y2));
83 machine.system().graphics().mark_object_state_as_dirty();
84 }
85 };
86
87 struct dispRect_1 : RLOpcode<IntConstant_T,
88 IntConstant_T,
89 IntConstant_T,
90 IntConstant_T,
91 IntConstant_T> {
operator ()__anon3e2ab1020111::dispRect_192 void operator()(RLMachine& machine, int buf, int x, int y, int w, int h) {
93 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
94 obj.SetClipRect(Rect::REC(x, y, w, h));
95 machine.system().graphics().mark_object_state_as_dirty();
96 }
97 };
98
99 struct dispCorner_1 : RLOpcode<IntConstant_T, IntConstant_T, IntConstant_T> {
operator ()__anon3e2ab1020111::dispCorner_1100 void operator()(RLMachine& machine, int buf, int x, int y) {
101 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
102 obj.SetClipRect(Rect::GRP(0, 0, x, y));
103 machine.system().graphics().mark_object_state_as_dirty();
104 }
105 };
106
107 struct dispOwnArea_0 : public RLOpcode<IntConstant_T> {
operator ()__anon3e2ab1020111::dispOwnArea_0108 void operator()(RLMachine& machine, int buf) {
109 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
110 obj.ClearOwnClipRect();
111 machine.system().graphics().mark_object_state_as_dirty();
112 }
113 };
114
115 struct dispOwnArea_1 : RLOpcode<IntConstant_T,
116 IntConstant_T,
117 IntConstant_T,
118 IntConstant_T,
119 IntConstant_T> {
operator ()__anon3e2ab1020111::dispOwnArea_1120 void operator()(RLMachine& machine, int buf, int x1, int y1, int x2, int y2) {
121 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
122 obj.SetOwnClipRect(Rect::GRP(x1, y1, x2, y2));
123 machine.system().graphics().mark_object_state_as_dirty();
124 }
125 };
126
127 struct dispOwnRect_1 : RLOpcode<IntConstant_T,
128 IntConstant_T,
129 IntConstant_T,
130 IntConstant_T,
131 IntConstant_T> {
operator ()__anon3e2ab1020111::dispOwnRect_1132 void operator()(RLMachine& machine, int buf, int x, int y, int w, int h) {
133 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
134 obj.SetOwnClipRect(Rect::REC(x, y, w, h));
135 machine.system().graphics().mark_object_state_as_dirty();
136 }
137 };
138
139 struct adjust
140 : RLOpcode<IntConstant_T, IntConstant_T, IntConstant_T, IntConstant_T> {
operator ()__anon3e2ab1020111::adjust141 void operator()(RLMachine& machine, int buf, int idx, int x, int y) {
142 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
143 obj.SetXAdjustment(idx, x);
144 obj.SetYAdjustment(idx, y);
145 machine.system().graphics().mark_object_state_as_dirty();
146 }
147 };
148
149 struct tint
150 : RLOpcode<IntConstant_T, IntConstant_T, IntConstant_T, IntConstant_T> {
operator ()__anon3e2ab1020111::tint151 void operator()(RLMachine& machine, int buf, int r, int g, int b) {
152 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
153 obj.SetTint(RGBColour(r, g, b));
154 machine.system().graphics().mark_object_state_as_dirty();
155 }
156 };
157
158 struct colour : RLOpcode<IntConstant_T,
159 IntConstant_T,
160 IntConstant_T,
161 IntConstant_T,
162 IntConstant_T> {
operator ()__anon3e2ab1020111::colour163 void operator()(RLMachine& machine, int buf, int r, int g, int b, int level) {
164 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
165 obj.SetColour(RGBAColour(r, g, b, level));
166 machine.system().graphics().mark_object_state_as_dirty();
167 }
168 };
169
170 struct objSetRect_1
171 : public RLOpcode<IntConstant_T, Rect_T<rect_impl::GRP>> {
operator ()__anon3e2ab1020111::objSetRect_1172 void operator()(RLMachine& machine, int buf, Rect rect) {
173 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
174 if (obj.has_object_data()) {
175 ColourFilterObjectData* data =
176 dynamic_cast<ColourFilterObjectData*>(&obj.GetObjectData());
177 if (data) {
178 data->set_rect(rect);
179 machine.system().graphics().mark_object_state_as_dirty();
180 }
181 }
182 }
183 };
184
185 struct objSetRect_0 : public RLOpcode<IntConstant_T> {
operator ()__anon3e2ab1020111::objSetRect_0186 void operator()(RLMachine& machine, int buf) {
187 Rect rect(0, 0, GetScreenSize(machine.system().gameexe()));
188 objSetRect_1()(machine, buf, rect);
189 }
190 };
191
192 struct objSetText : public RLOpcode<IntConstant_T, DefaultStrValue_T> {
operator ()__anon3e2ab1020111::objSetText193 void operator()(RLMachine& machine, int buf, string val) {
194 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
195 std::string utf8str = cp932toUTF8(val, machine.GetTextEncoding());
196 obj.SetTextText(utf8str);
197 machine.system().graphics().mark_object_state_as_dirty();
198 }
199 };
200
201 // Note: It appears that the RealLive API changed sometime between when Haeleth
202 // was working on Kanon and RealLive Max. Previously, the zeroth overload took
203 // the shadow color. Now, the zeroth doesn't and a new first overload does. Use
204 // DefaultIntValue to try to handle both cases at once.
205 struct objTextOpts : public RLOpcode<IntConstant_T,
206 IntConstant_T,
207 IntConstant_T,
208 IntConstant_T,
209 IntConstant_T,
210 IntConstant_T,
211 DefaultIntValue_T<-1>> {
operator ()__anon3e2ab1020111::objTextOpts212 void operator()(RLMachine& machine,
213 int buf,
214 int size,
215 int xspace,
216 int yspace,
217 int char_count,
218 int colour,
219 int shadow) {
220 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
221 obj.SetTextOps(size, xspace, yspace, char_count, colour, shadow);
222 machine.system().graphics().mark_object_state_as_dirty();
223 }
224 };
225
226 struct objDriftOpts : public RLOpcode<IntConstant_T,
227 IntConstant_T,
228 IntConstant_T,
229 IntConstant_T,
230 IntConstant_T,
231 IntConstant_T,
232 IntConstant_T,
233 IntConstant_T,
234 IntConstant_T,
235 IntConstant_T,
236 IntConstant_T,
237 IntConstant_T,
238 Rect_T<rect_impl::GRP>> {
operator ()__anon3e2ab1020111::objDriftOpts239 void operator()(RLMachine& machine,
240 int buf,
241 int count,
242 int use_animation,
243 int start_pattern,
244 int end_pattern,
245 int total_animaton_time_ms,
246 int yspeed,
247 int period,
248 int amplitude,
249 int use_drift,
250 int unknown,
251 int driftspeed,
252 Rect drift_area) {
253 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
254 obj.SetDriftOpts(count,
255 use_animation,
256 start_pattern,
257 end_pattern,
258 total_animaton_time_ms,
259 yspeed,
260 period,
261 amplitude,
262 use_drift,
263 unknown,
264 driftspeed,
265 drift_area);
266 machine.system().graphics().mark_object_state_as_dirty();
267 }
268 };
269
270 struct objNumOpts : public RLOpcode<IntConstant_T,
271 IntConstant_T,
272 IntConstant_T,
273 IntConstant_T,
274 IntConstant_T,
275 IntConstant_T> {
operator ()__anon3e2ab1020111::objNumOpts276 void operator()(RLMachine& machine,
277 int buf,
278 int digits,
279 int zero,
280 int sign,
281 int pack,
282 int space) {
283 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
284 obj.SetDigitOpts(digits, zero, sign, pack, space);
285 machine.system().graphics().mark_object_state_as_dirty();
286 }
287 };
288
289 struct objAdjustAlpha
290 : public RLOpcode<IntConstant_T, IntConstant_T, IntConstant_T> {
operator ()__anon3e2ab1020111::objAdjustAlpha291 void operator()(RLMachine& machine, int buf, int idx, int alpha) {
292 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
293 obj.SetAlphaAdjustment(idx, alpha);
294 machine.system().graphics().mark_object_state_as_dirty();
295 }
296 };
297
298 struct objButtonOpts : public RLOpcode<IntConstant_T,
299 IntConstant_T,
300 IntConstant_T,
301 IntConstant_T,
302 IntConstant_T> {
operator ()__anon3e2ab1020111::objButtonOpts303 void operator()(RLMachine& machine,
304 int buf,
305 int action,
306 int se,
307 int group,
308 int button_number) {
309 GraphicsObject& obj = GetGraphicsObject(machine, this, buf);
310 obj.SetButtonOpts(action, se, group, button_number);
311 machine.system().graphics().mark_object_state_as_dirty();
312 }
313 };
314
315 // -----------------------------------------------------------------------
316
317 class objEveAdjust : public RLOpcode<IntConstant_T,
318 IntConstant_T,
319 IntConstant_T,
320 IntConstant_T,
321 IntConstant_T,
322 IntConstant_T,
323 IntConstant_T> {
324 public:
operator ()(RLMachine & machine,int obj,int repno,int x,int y,int duration_time,int delay,int type)325 virtual void operator()(RLMachine& machine,
326 int obj,
327 int repno,
328 int x,
329 int y,
330 int duration_time,
331 int delay,
332 int type) {
333 unsigned int creation_time = machine.system().event().GetTicks();
334
335 GraphicsObject& object = GetGraphicsObject(machine, this, obj);
336 int start_x = object.x_adjustment(repno);
337 int start_y = object.y_adjustment(repno);
338
339 object.AddObjectMutator(std::unique_ptr<ObjectMutator>(
340 new AdjustMutator(machine,
341 repno,
342 creation_time,
343 duration_time,
344 delay,
345 type,
346 start_x,
347 x,
348 start_y,
349 y)));
350 }
351
352 private:
353 // We need a custom mutator here. One of the parameters isn't varying.
354 class AdjustMutator : public ObjectMutator {
355 public:
AdjustMutator(RLMachine & machine,int repno,int creation_time,int duration_time,int delay,int type,int start_x,int target_x,int start_y,int target_y)356 AdjustMutator(RLMachine& machine,
357 int repno,
358 int creation_time,
359 int duration_time,
360 int delay,
361 int type,
362 int start_x,
363 int target_x,
364 int start_y,
365 int target_y)
366 : ObjectMutator(repno,
367 "objEveAdjust",
368 creation_time,
369 duration_time,
370 delay,
371 type),
372 repno_(repno),
373 start_x_(start_x),
374 end_x_(target_x),
375 start_y_(start_y),
376 end_y_(target_y) {}
377
378 private:
SetToEnd(RLMachine & machine,GraphicsObject & object)379 virtual void SetToEnd(RLMachine& machine,
380 GraphicsObject& object) override {
381 object.SetXAdjustment(repno_, end_x_);
382 object.SetYAdjustment(repno_, end_y_);
383 }
384
Clone() const385 virtual ObjectMutator* Clone() const override {
386 return new AdjustMutator(*this);
387 }
388
PerformSetting(RLMachine & machine,GraphicsObject & object)389 virtual void PerformSetting(RLMachine& machine,
390 GraphicsObject& object) override {
391 int x = GetValueForTime(machine, start_x_, end_x_);
392 object.SetXAdjustment(repno_, x);
393
394 int y = GetValueForTime(machine, start_y_, end_y_);
395 object.SetYAdjustment(repno_, y);
396 }
397
398 int repno_;
399 int start_x_;
400 int end_x_;
401 int start_y_;
402 int end_y_;
403 };
404 };
405
406 class DisplayMutator : public ObjectMutator {
407 public:
DisplayMutator(RLMachine & machine,GraphicsObject & object,int creation_time,int duration_time,int delay,int display,int dip_event_mod,int tr_mod,int move_mod,int move_len_x,int move_len_y,int rotate_mod,int rotate_count,int scale_x_mod,int scale_x_percent,int scale_y_mod,int scale_y_percent,int sin_mod,int sin_len,int sin_count)408 DisplayMutator(RLMachine& machine,
409 GraphicsObject& object,
410 int creation_time,
411 int duration_time,
412 int delay,
413 int display,
414 int dip_event_mod, // ignored
415 int tr_mod,
416 int move_mod,
417 int move_len_x,
418 int move_len_y,
419 int rotate_mod,
420 int rotate_count,
421 int scale_x_mod,
422 int scale_x_percent,
423 int scale_y_mod,
424 int scale_y_percent,
425 int sin_mod,
426 int sin_len,
427 int sin_count)
428 : ObjectMutator(-1,
429 "objEveDisplay",
430 creation_time,
431 duration_time,
432 delay,
433 0),
434 display_(display),
435 tr_mod_(tr_mod),
436 tr_start_(0),
437 tr_end_(0),
438 move_mod_(move_mod),
439 move_start_x_(0),
440 move_end_x_(0),
441 move_start_y_(0),
442 move_end_y_(0),
443 rotate_mod_(rotate_mod),
444 scale_x_mod_(scale_x_mod),
445 scale_y_mod_(scale_y_mod) {
446 if (tr_mod_) {
447 tr_start_ = display ? 0 : 255;
448 tr_end_ = display ? 255 : 0;
449 }
450
451 if (move_mod_) {
452 // I suspect this isn't right here. If I start at object.x() and end at
453 // (object.x() + move_len), then the "Episode" text ends up off the right
454 // hand of the screen. However, with this, the downward scrolling text
455 // jumps downward when it starts scrolling back up (that didn't used to
456 // happen.)
457 if (display) {
458 move_start_x_ = object.x() - move_len_x;
459 move_end_x_ = object.x();
460 move_start_y_ = object.y() - move_len_y;
461 move_end_y_ = object.y();
462 } else {
463 move_start_x_ = object.x();
464 move_end_x_ = object.x() + move_len_x;
465 move_start_y_ = object.y();
466 move_end_y_ = object.y() + move_len_y;
467 }
468 }
469
470 if (rotate_mod_) {
471 static bool printed = false;
472 if (!printed) {
473 std::cerr << "We don't support rotate mod yet." << std::endl;
474 printed = true;
475 }
476 }
477
478 if (scale_x_mod_) {
479 static bool printed = false;
480 if (!printed) {
481 std::cerr << "We don't support scale Y mod yet." << std::endl;
482 printed = true;
483 }
484 }
485
486 if (scale_y_mod_) {
487 static bool printed = false;
488 if (!printed) {
489 std::cerr << "We don't support scale X mod yet." << std::endl;
490 printed = true;
491 }
492 }
493
494 if (sin_mod) {
495 static bool printed = false;
496 if (!printed) {
497 std::cerr << " We don't support \"sin\" yet." << std::endl;
498 printed = true;
499 }
500 }
501 }
502
503 private:
SetToEnd(RLMachine & machine,GraphicsObject & object)504 virtual void SetToEnd(RLMachine& machine, GraphicsObject& object) override {
505 object.SetVisible(display_);
506
507 if (tr_mod_)
508 object.SetAlpha(tr_end_);
509
510 if (move_mod_) {
511 object.SetX(move_end_x_);
512 object.SetY(move_end_y_);
513 }
514 }
515
Clone() const516 virtual ObjectMutator* Clone() const override {
517 return new DisplayMutator(*this);
518 }
519
PerformSetting(RLMachine & machine,GraphicsObject & object)520 virtual void PerformSetting(RLMachine& machine,
521 GraphicsObject& object) override {
522 // While performing whatever visual transition, the object should be
523 // displayed.
524 object.SetVisible(true);
525
526 if (tr_mod_) {
527 int alpha = GetValueForTime(machine, tr_start_, tr_end_);
528 object.SetAlpha(alpha);
529 }
530
531 if (move_mod_) {
532 int x = GetValueForTime(machine, move_start_x_, move_end_x_);
533 object.SetX(x);
534
535 int y = GetValueForTime(machine, move_start_y_, move_end_y_);
536 object.SetY(y);
537 }
538 }
539
540 bool display_;
541
542 bool tr_mod_;
543 int tr_start_;
544 int tr_end_;
545
546 bool move_mod_;
547 int move_start_x_;
548 int move_end_x_;
549 int move_start_y_;
550 int move_end_y_;
551
552 bool rotate_mod_;
553 bool scale_x_mod_;
554 bool scale_y_mod_;
555 };
556
557 struct objEveDisplay_1 : public RLOpcode<IntConstant_T,
558 IntConstant_T,
559 IntConstant_T,
560 IntConstant_T,
561 IntConstant_T> {
operator ()__anon3e2ab1020111::objEveDisplay_1562 void operator()(RLMachine& machine,
563 int obj,
564 int display,
565 int duration_time,
566 int delay,
567 int param) {
568 Gameexe& gameexe = machine.system().gameexe();
569 const std::vector<int>& disp = gameexe("OBJDISP", param).ToIntVector();
570
571 GraphicsObject& object = GetGraphicsObject(machine, this, obj);
572 unsigned int creation_time = machine.system().event().GetTicks();
573 object.AddObjectMutator(std::unique_ptr<ObjectMutator>(
574 new DisplayMutator(machine,
575 object,
576 creation_time,
577 duration_time,
578 delay,
579 display,
580 disp.at(0),
581 disp.at(1),
582 disp.at(2),
583 disp.at(3),
584 disp.at(4),
585 disp.at(5),
586 disp.at(6),
587 disp.at(7),
588 disp.at(8),
589 disp.at(9),
590 disp.at(10),
591 disp.at(11),
592 disp.at(12),
593 disp.at(13))));
594 }
595 };
596
597 struct objEveDisplay_2 : public RLOpcode<IntConstant_T,
598 IntConstant_T,
599 IntConstant_T,
600 IntConstant_T,
601 IntConstant_T,
602 IntConstant_T,
603 IntConstant_T,
604 IntConstant_T,
605 IntConstant_T> {
operator ()__anon3e2ab1020111::objEveDisplay_2606 void operator()(RLMachine& machine,
607 int obj,
608 int display,
609 int duration_time,
610 int delay,
611 int disp_event_mod,
612 int tr_mod,
613 int move_mod,
614 int move_len_x,
615 int move_len_y) {
616 GraphicsObject& object = GetGraphicsObject(machine, this, obj);
617 unsigned int creation_time = machine.system().event().GetTicks();
618 object.AddObjectMutator(std::unique_ptr<ObjectMutator>(
619 new DisplayMutator(machine,
620 object,
621 creation_time,
622 duration_time,
623 delay,
624 display,
625 disp_event_mod,
626 tr_mod,
627 move_mod,
628 move_len_x,
629 move_len_y,
630 0,
631 0,
632 0,
633 0,
634 0,
635 0,
636 0,
637 0,
638 0)));
639 }
640 };
641
642 struct objEveDisplay_3 : public RLOpcode<IntConstant_T,
643 IntConstant_T,
644 IntConstant_T,
645 IntConstant_T,
646 IntConstant_T,
647 IntConstant_T,
648 IntConstant_T,
649 IntConstant_T,
650 IntConstant_T,
651 IntConstant_T,
652 IntConstant_T,
653 IntConstant_T,
654 IntConstant_T,
655 IntConstant_T,
656 IntConstant_T,
657 IntConstant_T,
658 IntConstant_T,
659 IntConstant_T> {
operator ()__anon3e2ab1020111::objEveDisplay_3660 void operator()(RLMachine& machine,
661 int obj,
662 int display,
663 int duration_time,
664 int delay,
665 int disp_event_mod,
666 int tr_mod,
667 int move_mod,
668 int move_len_x,
669 int move_len_y,
670 int rotate_mod,
671 int rotate_count,
672 int scale_x_mod,
673 int scale_x_percent,
674 int scale_y_mod,
675 int scale_y_percent,
676 int sin_mod,
677 int sin_len,
678 int sin_count) {
679 GraphicsObject& object = GetGraphicsObject(machine, this, obj);
680 unsigned int creation_time = machine.system().event().GetTicks();
681 object.AddObjectMutator(std::unique_ptr<ObjectMutator>(
682 new DisplayMutator(machine,
683 object,
684 creation_time,
685 duration_time,
686 delay,
687 display,
688 disp_event_mod,
689 tr_mod,
690 move_mod,
691 move_len_x,
692 move_len_y,
693 rotate_mod,
694 rotate_count,
695 scale_x_mod,
696 scale_x_percent,
697 scale_y_mod,
698 scale_y_percent,
699 sin_mod,
700 sin_len,
701 sin_count)));
702 }
703 };
704
705 // -----------------------------------------------------------------------
706 // -----------------------------------------------------------------------
707 // -----------------------------------------------------------------------
708
addUnifiedFunctions(ObjectModule & h)709 void addUnifiedFunctions(ObjectModule& h) {
710 h.AddDoubleObjectCommands(0, "Move",
711 &GraphicsObject::x,
712 &GraphicsObject::SetX,
713 &GraphicsObject::y,
714 &GraphicsObject::SetY);
715 h.AddSingleObjectCommands(1, "Left",
716 &GraphicsObject::x,
717 &GraphicsObject::SetX);
718 h.AddSingleObjectCommands(2, "Top",
719 &GraphicsObject::y,
720 &GraphicsObject::SetY);
721 h.AddSingleObjectCommands(3, "Alpha",
722 &GraphicsObject::raw_alpha,
723 &GraphicsObject::SetAlpha);
724
725 // ----
726
727 h.AddCustomRepno<adjust, objEveAdjust>(6, "Adjust");
728 h.AddRepnoObjectCommands(7, "AdjustX",
729 &GraphicsObject::x_adjustment,
730 &GraphicsObject::SetXAdjustment);
731 h.AddRepnoObjectCommands(8, "AdjustY",
732 &GraphicsObject::y_adjustment,
733 &GraphicsObject::SetYAdjustment);
734 h.AddSingleObjectCommands(9, "Mono",
735 &GraphicsObject::mono,
736 &GraphicsObject::SetMono);
737 h.AddSingleObjectCommands(10, "Invert",
738 &GraphicsObject::invert,
739 &GraphicsObject::SetInvert);
740 h.AddSingleObjectCommands(11, "Light",
741 &GraphicsObject::light,
742 &GraphicsObject::SetLight);
743
744 // ---
745
746 h.AddSingleObjectCommands(13, "TintR",
747 &GraphicsObject::tint_red,
748 &GraphicsObject::SetTintRed);
749 h.AddSingleObjectCommands(14, "TintG",
750 &GraphicsObject::tint_green,
751 &GraphicsObject::SetTintGreen);
752 h.AddSingleObjectCommands(15, "TintB",
753 &GraphicsObject::tint_blue,
754 &GraphicsObject::SetTintBlue);
755
756 // ---
757
758 h.AddSingleObjectCommands(17, "ColR",
759 &GraphicsObject::colour_red,
760 &GraphicsObject::SetColourRed);
761 h.AddSingleObjectCommands(18, "ColG",
762 &GraphicsObject::colour_green,
763 &GraphicsObject::SetColourGreen);
764 h.AddSingleObjectCommands(19, "ColB",
765 &GraphicsObject::colour_blue,
766 &GraphicsObject::SetColourBlue);
767 h.AddSingleObjectCommands(20, "ColLevel",
768 &GraphicsObject::colour_level,
769 &GraphicsObject::SetColourLevel);
770
771 // ---
772
773 h.AddSingleObjectCommands(36, "AdjustVert",
774 &GraphicsObject::vert,
775 &GraphicsObject::SetVert);
776
777 h.AddRepnoObjectCommands(40, "AdjustAlpha",
778 &GraphicsObject::alpha_adjustment,
779 &GraphicsObject::SetAlphaAdjustment);
780
781 // --
782 h.AddDoubleObjectCommands(46, "Scale",
783 &GraphicsObject::width,
784 &GraphicsObject::SetWidth,
785 &GraphicsObject::height,
786 &GraphicsObject::SetHeight);
787 h.AddSingleObjectCommands(47, "Width",
788 &GraphicsObject::width,
789 &GraphicsObject::SetWidth);
790 h.AddSingleObjectCommands(48, "Height",
791 &GraphicsObject::height,
792 &GraphicsObject::SetHeight);
793 h.AddSingleObjectCommands(49, "Rotate",
794 &GraphicsObject::rotation,
795 &GraphicsObject::SetRotation);
796 h.AddDoubleObjectCommands(50, "RepOrigin",
797 &GraphicsObject::rep_origin_x,
798 &GraphicsObject::SetRepOriginX,
799 &GraphicsObject::rep_origin_y,
800 &GraphicsObject::SetRepOriginY);
801 h.AddSingleObjectCommands(51, "RepOriginX",
802 &GraphicsObject::rep_origin_x,
803 &GraphicsObject::SetRepOriginX);
804 h.AddSingleObjectCommands(52, "RepOriginY",
805 &GraphicsObject::rep_origin_y,
806 &GraphicsObject::SetRepOriginY);
807 h.AddDoubleObjectCommands(53, "Origin",
808 &GraphicsObject::origin_x,
809 &GraphicsObject::SetOriginX,
810 &GraphicsObject::origin_y,
811 &GraphicsObject::SetOriginY);
812 h.AddSingleObjectCommands(54, "OriginX",
813 &GraphicsObject::origin_x,
814 &GraphicsObject::SetOriginX);
815 h.AddSingleObjectCommands(55, "OriginY",
816 &GraphicsObject::origin_y,
817 &GraphicsObject::SetOriginY);
818
819 // ---
820
821 h.AddDoubleObjectCommands(61, "HqScale",
822 &GraphicsObject::hq_width,
823 &GraphicsObject::SetHqWidth,
824 &GraphicsObject::hq_height,
825 &GraphicsObject::SetHqHeight);
826 h.AddSingleObjectCommands(62, "HqWidth",
827 &GraphicsObject::hq_width,
828 &GraphicsObject::SetHqWidth);
829 h.AddSingleObjectCommands(63, "HqHeight",
830 &GraphicsObject::hq_height,
831 &GraphicsObject::SetHqHeight);
832 }
833
addObjectFunctions(RLModule & m)834 void addObjectFunctions(RLModule& m) {
835 m.AddOpcode(
836 1004, 0, "objShow", new Obj_SetOneIntOnObj(&GraphicsObject::SetVisible));
837 m.AddOpcode(1005, 0, "objDispArea", new dispArea_0);
838 m.AddOpcode(1005, 1, "objDispArea", new dispArea_1);
839
840 m.AddOpcode(1012, 0, "objTint", new tint);
841
842 m.AddOpcode(1016, 0, "objColour", new colour);
843
844 m.AddOpcode(1021,
845 0,
846 "objComposite",
847 new Obj_SetOneIntOnObj(&GraphicsObject::SetCompositeMode));
848
849 m.AddOpcode(1022, 0, "objSetRect", new objSetRect_0);
850 m.AddOpcode(1022, 1, "objSetRect", new objSetRect_1);
851
852 m.AddOpcode(1024, 0, "objSetText", new objSetText);
853 m.AddOpcode(1024, 1, "objSetText", new objSetText);
854 m.AddOpcode(1025, 0, "objTextOpts", new objTextOpts);
855 m.AddOpcode(1025, 1, "objTextOpts", new objTextOpts);
856
857 m.AddOpcode(
858 1026, 0, "objLayer", new Obj_SetOneIntOnObj(&GraphicsObject::SetZLayer));
859 m.AddOpcode(
860 1027, 0, "objDepth", new Obj_SetOneIntOnObj(&GraphicsObject::SetZDepth));
861 m.AddUnsupportedOpcode(1028, 0, "objScrollRate");
862 m.AddOpcode(1029,
863 0,
864 "objScrollRateX",
865 new Obj_SetOneIntOnObj(&GraphicsObject::SetScrollRateX));
866 m.AddOpcode(1030,
867 0,
868 "objScrollRateY",
869 new Obj_SetOneIntOnObj(&GraphicsObject::SetScrollRateY));
870 m.AddOpcode(1031, 0, "objDriftOpts", new objDriftOpts);
871 m.AddOpcode(
872 1032, 0, "objOrder", new Obj_SetOneIntOnObj(&GraphicsObject::SetZOrder));
873 m.AddUnsupportedOpcode(1033, 0, "objQuarterView");
874
875 m.AddOpcode(1034, 0, "objDispRect", new dispArea_0);
876 m.AddOpcode(1034, 1, "objDispRect", new dispRect_1);
877 m.AddOpcode(1035, 0, "objDispCorner", new dispArea_0);
878 m.AddOpcode(1035, 1, "objDispCorner", new dispArea_1);
879 m.AddOpcode(1035, 2, "objDispCorner", new dispCorner_1);
880
881 m.AddOpcode(1037,
882 0,
883 "objSetDigits",
884 new Obj_SetOneIntOnObj(&GraphicsObject::SetDigitValue));
885 m.AddOpcode(1038, 0, "objNumOpts", new objNumOpts);
886 m.AddOpcode(
887 1039, 0, "objPattNo", new Obj_SetOneIntOnObj(&GraphicsObject::SetPattNo));
888
889 m.AddUnsupportedOpcode(1041, 0, "objAdjustAll");
890 m.AddUnsupportedOpcode(1042, 0, "objAdjustAllX");
891 m.AddUnsupportedOpcode(1043, 0, "objAdjustAllY");
892
893 m.AddUnsupportedOpcode(1056, 0, "objFadeOpts");
894
895 m.AddOpcode(1064, 2, "objButtonOpts", new objButtonOpts);
896 m.AddOpcode(1066,
897 0,
898 "objBtnState",
899 new Obj_SetOneIntOnObj(&GraphicsObject::SetButtonState));
900
901 m.AddOpcode(1070, 0, "objOwnDispArea", new dispOwnArea_0);
902 m.AddOpcode(1070, 1, "objOwnDispArea", new dispOwnArea_1);
903 m.AddOpcode(1071, 0, "objOwnDispRect", new dispOwnArea_0);
904 m.AddOpcode(1071, 1, "objOwnDispRect", new dispOwnRect_1);
905 }
906
addEveObjectFunctions(RLModule & m)907 void addEveObjectFunctions(RLModule& m) {
908 m.AddOpcode(2004,
909 0,
910 "objEveDisplay",
911 new Obj_SetOneIntOnObj(&GraphicsObject::SetVisible));
912 m.AddOpcode(2004, 1, "objEveDisplay", new objEveDisplay_1);
913 m.AddOpcode(2004, 2, "objEveDisplay", new objEveDisplay_2);
914 m.AddOpcode(2004, 3, "objEveDisplay", new objEveDisplay_3);
915
916 m.AddOpcode(
917 3004, 0, "objEveDisplayCheck", new Op_MutatorCheck("objEveDisplay"));
918
919 m.AddOpcode(
920 4004, 0, "objEveDisplayWait", new Op_MutatorWaitNormal("objEveDisplay"));
921
922 m.AddOpcode(5004,
923 0,
924 "objEveDisplayWaitC",
925 new Op_MutatorWaitCNormal("objEveDisplay"));
926
927 m.AddOpcode(6004,
928 0,
929 "objEveDisplayEnd",
930 new Op_EndObjectMutation_Normal("objEveDisplay"));
931 }
932
933 } // namespace
934
935 // -----------------------------------------------------------------------
936 // -----------------------------------------------------------------------
937 // -----------------------------------------------------------------------
938
ObjFgModule()939 ObjFgModule::ObjFgModule()
940 : RLModule("ObjFg", 1, 81),
941 helper_("obj", this) {
942 addUnifiedFunctions(helper_);
943
944 addObjectFunctions(*this);
945 addEveObjectFunctions(*this);
946 SetProperty(P_FGBG, OBJ_FG);
947 }
948
949 // -----------------------------------------------------------------------
950
ObjBgModule()951 ObjBgModule::ObjBgModule()
952 : RLModule("ObjBg", 1, 82),
953 helper_("objBg", this) {
954 addUnifiedFunctions(helper_);
955
956 addObjectFunctions(*this);
957 addEveObjectFunctions(*this);
958 SetProperty(P_FGBG, OBJ_BG);
959 }
960
961 // -----------------------------------------------------------------------
962
ChildObjFgModule()963 ChildObjFgModule::ChildObjFgModule()
964 : MappedRLModule(ChildObjMappingFun, "ChildObjFg", 2, 81),
965 helper_("objChild", this) {
966 addUnifiedFunctions(helper_);
967
968 addObjectFunctions(*this);
969 addEveObjectFunctions(*this);
970 SetProperty(P_FGBG, OBJ_FG);
971 }
972
973 // -----------------------------------------------------------------------
974
ChildObjBgModule()975 ChildObjBgModule::ChildObjBgModule()
976 : MappedRLModule(ChildObjMappingFun, "ChildObjBg", 2, 82),
977 helper_("objChildBg", this) {
978 addUnifiedFunctions(helper_);
979
980 addObjectFunctions(*this);
981 addEveObjectFunctions(*this);
982 SetProperty(P_FGBG, OBJ_BG);
983 }
984
985 // -----------------------------------------------------------------------
986
ObjRangeFgModule()987 ObjRangeFgModule::ObjRangeFgModule()
988 : MappedRLModule(RangeMappingFun, "ObjRangeFg", 1, 90),
989 helper_("objRange", this) {
990 addUnifiedFunctions(helper_);
991
992 addObjectFunctions(*this);
993 SetProperty(P_FGBG, OBJ_FG);
994 }
995
996 // -----------------------------------------------------------------------
997
ObjRangeBgModule()998 ObjRangeBgModule::ObjRangeBgModule()
999 : MappedRLModule(RangeMappingFun, "ObjRangeBg", 1, 91),
1000 helper_("objRangeBg", this) {
1001 addUnifiedFunctions(helper_);
1002
1003 addObjectFunctions(*this);
1004 SetProperty(P_FGBG, OBJ_BG);
1005 }
1006
1007 // -----------------------------------------------------------------------
1008
ChildObjRangeFgModule()1009 ChildObjRangeFgModule::ChildObjRangeFgModule()
1010 : MappedRLModule(ChildRangeMappingFun, "ObjChildRangeFg", 2, 90),
1011 helper_("objChildRange", this) {
1012 addUnifiedFunctions(helper_);
1013
1014 addObjectFunctions(*this);
1015 SetProperty(P_FGBG, OBJ_FG);
1016 }
1017
1018 // -----------------------------------------------------------------------
1019
ChildObjRangeBgModule()1020 ChildObjRangeBgModule::ChildObjRangeBgModule()
1021 : MappedRLModule(ChildRangeMappingFun, "ObjChildRangeBg", 2, 91),
1022 helper_("objChildRangeBg", this) {
1023 addUnifiedFunctions(helper_);
1024
1025 addObjectFunctions(*this);
1026 SetProperty(P_FGBG, OBJ_BG);
1027 }
1028