1
// -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi:tw=80:et:ts=2:sts=2
4
// -----------------------------------------------------------------------
6
// This file is part of RLVM, a RealLive virtual machine clone.
8
// -----------------------------------------------------------------------
10
// Copyright (C) 2006, 2007 Elliot Glaysher
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.
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.
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.
26
// -----------------------------------------------------------------------
28
#include "Module_Obj.hpp"
29
#include "Module_ObjPosDims.hpp"
31
#include "MachineBase/Properties.hpp"
32
#include "MachineBase/RLOperation.hpp"
33
#include "MachineBase/RLOperation/DefaultValue.hpp"
34
#include "MachineBase/RLOperation/References.hpp"
35
#include "MachineBase/RLOperation/RLOp_Store.hpp"
37
#include "Systems/Base/GraphicsObject.hpp"
39
// -----------------------------------------------------------------------
44
* Theoretically implements objGetPos. People don't actually
45
* understand what's going on in this module (more so then anything
46
* else in rldev/rlvm.)
48
* This is probably wrong or overlooks all sorts of weird corner cases
49
* that aren't immediatly obvious.
52
: public RLOp_Void_3< IntConstant_T, IntReference_T, IntReference_T > {
53
void operator()(RLMachine& machine, int objNum, IntReferenceIterator xIt,
54
IntReferenceIterator yIt) {
55
GraphicsObject& obj = getGraphicsObject(machine, this, objNum);
61
struct objGetPosX : public RLOp_Store_1< IntConstant_T> {
62
int operator()(RLMachine& machine, int objNum) {
63
GraphicsObject& obj = getGraphicsObject(machine, this, objNum);
68
struct objGetPosY : public RLOp_Store_1< IntConstant_T> {
69
int operator()(RLMachine& machine, int objNum) {
70
GraphicsObject& obj = getGraphicsObject(machine, this, objNum);
76
* @note objGetDims takes an integer as its fourth argument, but we
77
* have no idea what this is or how it affects things. Usually appears
81
: public RLOp_Void_4< IntConstant_T, IntReference_T, IntReference_T,
82
DefaultIntValue_T<4> > {
83
void operator()(RLMachine& machine, int objNum, IntReferenceIterator widthIt,
84
IntReferenceIterator heightIt, int unknown) {
85
GraphicsObject& obj = getGraphicsObject(machine, this, objNum);
86
*widthIt = obj.pixelWidth();
87
*heightIt = obj.pixelHeight();
91
void addFunctions(RLModule& m) {
92
m.addOpcode(1000, 0, "objGetPos", new objGetPos);
93
m.addOpcode(1001, 0, "objGetPosX", new objGetPosX);
94
m.addOpcode(1002, 0, "objGetPosY", new objGetPosY);
95
m.addOpcode(1100, 0, "objGetDims", new objGetDims);
96
m.addOpcode(1100, 1, "objGetDims", new objGetDims);
101
// -----------------------------------------------------------------------
103
ObjFgPosDimsModule::ObjFgPosDimsModule()
104
: RLModule("ObjFgPosDims", 1, 84) {
106
setProperty(P_FGBG, OBJ_FG);
109
// -----------------------------------------------------------------------
111
ObjBgPosDimsModule::ObjBgPosDimsModule()
112
: RLModule("ObjBgPosDims", 1, 85) {
114
setProperty(P_FGBG, OBJ_BG);
117
// -----------------------------------------------------------------------
119
ChildObjFgPosDimsModule::ChildObjFgPosDimsModule()
120
: MappedRLModule(childObjMappingFun, "ChildObjFgPosDims", 2, 84) {
122
setProperty(P_FGBG, OBJ_FG);
125
// -----------------------------------------------------------------------
127
ChildObjBgPosDimsModule::ChildObjBgPosDimsModule()
128
: MappedRLModule(childObjMappingFun, "ChildObjBgPosDims", 2, 85) {
130
setProperty(P_FGBG, OBJ_BG);