1 #ifndef INNOCENT_ACTOR_H
2 #define INNOCENT_ACTOR_H
6 #include "common/endian.h"
7 #include "common/queue.h"
9 #include "innocent/animation.h"
10 #include "innocent/value.h"
25 Puppeteer() : _offset(0), _actorId(0) {}
26 Puppeteer(const byte
*data
) { parse(data
); }
28 uint16
mainCodeOffset() const { return _offset
; }
29 uint16
actorId() const { return _actorId
; }
32 void parse(const byte
*data
) {
33 _actorId
= READ_LE_UINT16(data
+ kActorId
);
34 _offset
= READ_LE_UINT16(data
+ kMainCode
);
41 class Actor
: public Animation
{
46 Frame() : _left(999), _top(999), _nexts(8) {}
47 Frame(int16 l
, int16 t
, std::vector
<byte
> nexts
) : _left(l
), _top(t
), _nexts(nexts
) {}
49 int16
left() const { return _left
; }
50 int16
top() const { return _top
; }
55 std::vector
<byte
> _nexts
;
68 kOffsetMainSprite
= 8,
69 kOffsetTicksLeft
= 0xa,
71 kOffsetInterval
= 0x10,
75 void setFrame(uint16 f
);
77 uint16
room() const { return _room
; }
78 void setRoom(uint16
, uint16 frame
= 0, uint16 nextFrame
= 0);
82 void setAnimation(const CodePointer
&anim
);
85 void callMe(const CodePointer
&cp
);
86 void tellMe(const CodePointer
&cp
, uint16 timeout
);
88 Animation::Status
tick();
92 void setPuppeteer(const Puppeteer
&p
) { _puppeteer
= p
; }
94 Actor(const CodePointer
&code
);
96 // just in case, we'll explicitly add those if needed
99 Actor
&operator=(const Actor
&);
101 void readHeader(const byte
*code
);
107 uint16 _nextAnimator
; // to change to whenever possible
108 bool _attentionNeeded
;
109 Puppeteer _puppeteer
;
111 Common::Queue
<CodePointer
> _callBacks
;
114 struct RoomCallback
{
116 CodePointer callback
;
117 RoomCallback(uint16 t
, const CodePointer
&p
) : timeout(t
), callback(p
) {}
119 Common::List
<RoomCallback
> _roomCallbacks
;
123 template <int opcode
>
124 Animation::Status
opcodeHandler();
129 virtual Animation::Status
op(byte code
);
131 typedef Animation::Status (Actor::*OpcodeHandler
)();
132 OpcodeHandler _handlers
[38];