aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2008-04-24 18:45:11 +0000
committerFilippos Karapetis2008-04-24 18:45:11 +0000
commitb861f38d1060b258d68020f8e3c9b401a1151b08 (patch)
treedcf4137a89b069b9d05df34c37f188074c6ee61e
parentdd1ae2dd4f89aaaba6767e3eecdd511d9f0086ee (diff)
downloadscummvm-rg350-b861f38d1060b258d68020f8e3c9b401a1151b08.tar.gz
scummvm-rg350-b861f38d1060b258d68020f8e3c9b401a1151b08.tar.bz2
scummvm-rg350-b861f38d1060b258d68020f8e3c9b401a1151b08.zip
Some initial code for font loading
Implemented opcode o1_LOADANIM svn-id: r31698
-rw-r--r--engines/made/resource.cpp20
-rw-r--r--engines/made/resource.h17
-rw-r--r--engines/made/screen.h2
-rw-r--r--engines/made/scriptfuncs.cpp15
4 files changed, 52 insertions, 2 deletions
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index 4450d86c31..f86c6ce371 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -221,6 +221,22 @@ void XmidiResource::load(byte *source, int size) {
memcpy(_data, source, size);
}
+/* FontResource */
+
+FontResource::FontResource() : _data(NULL), _size(0) {
+}
+
+FontResource::~FontResource() {
+ if (_data)
+ delete[] _data;
+}
+
+void FontResource::load(byte *source, int size) {
+ _data = new byte[size];
+ _size = size;
+ memcpy(_data, source, size);
+}
+
/* ProjectReader */
ProjectReader::ProjectReader() {
@@ -289,6 +305,10 @@ XmidiResource *ProjectReader::getXmidi(int index) {
return createResource<XmidiResource>(kResXMID, index);
}
+FontResource *ProjectReader::getFont(int index) {
+ return createResource<FontResource>(kResFONT, index);
+}
+
void ProjectReader::loadIndex(ResourceSlots *slots) {
_fd->readUint32LE(); // skip INDX
_fd->readUint32LE(); // skip index size
diff --git a/engines/made/resource.h b/engines/made/resource.h
index 5350ed5242..4e90673f09 100644
--- a/engines/made/resource.h
+++ b/engines/made/resource.h
@@ -45,7 +45,8 @@ enum ResourceType {
kResSNDS = MKID_BE('SNDS'),
kResANIM = MKID_BE('ANIM'),
kResMENU = MKID_BE('MENU'),
- kResXMID = MKID_BE('XMID')
+ kResXMID = MKID_BE('XMID'),
+ kResFONT = MKID_BE('FONT')
};
struct ResourceSlot;
@@ -123,6 +124,19 @@ protected:
int _size;
};
+// TODO
+class FontResource : public Resource {
+public:
+ FontResource();
+ ~FontResource();
+ void load(byte *source, int size);
+ byte *getData() const { return _data; }
+ int getSize() const { return _size; }
+protected:
+ byte *_data;
+ int _size;
+};
+
struct ResourceSlot {
uint32 offs;
uint32 size;
@@ -147,6 +161,7 @@ public:
SoundResource *getSound(int index);
MenuResource *getMenu(int index);
XmidiResource *getXmidi(int index);
+ FontResource *getFont(int index);
void freeResource(Resource *resource);
diff --git a/engines/made/screen.h b/engines/made/screen.h
index fa58dde88d..543af81bf8 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -70,6 +70,7 @@ public:
void setClip(uint16 clip) { _clip = clip; }
void setExclude(uint16 exclude) { _exclude = exclude; }
void setGround(uint16 ground) { _ground = ground; }
+ void setFont(uint16 font) { _currentFont = font; }
uint16 updateChannel(uint16 channelIndex);
void deleteChannel(uint16 channelIndex);
@@ -115,6 +116,7 @@ protected:
byte _palette[768], _newPalette[768], _fxPalette[768];
int _paletteColorCount, _oldPaletteColorCount;
bool _paletteInitialized, _needPalette;
+ uint16 _currentFont;
uint16 _clip, _exclude, _ground;
int _visualEffectNum;
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 57b0d57118..7a75e4551c 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -422,6 +422,10 @@ int16 ScriptFunctionsRtz::o1_PALETTELOCK(int16 argc, int16 *argv) {
int16 ScriptFunctionsRtz::o1_FONT(int16 argc, int16 *argv) {
warning("Unimplemented opcode: o1_FONT");
+
+ uint16 fontID = argv[0];
+ printf("Set font to %i\n", fontID);
+ _vm->_screen->setFont(fontID);
return 0;
}
@@ -442,6 +446,11 @@ int16 ScriptFunctionsRtz::o1_TEXTRECT(int16 argc, int16 *argv) {
int16 ScriptFunctionsRtz::o1_TEXTXY(int16 argc, int16 *argv) {
warning("Unimplemented opcode: o1_TEXTXY");
+
+ int16 x = CLIP<int16>(argv[0], 1, 318);
+ int16 y = CLIP<int16>(argv[1], 1, 198);
+
+ printf("Text: x = %i, y = %i\n", x, y);
return 0;
}
@@ -717,7 +726,11 @@ int16 ScriptFunctionsRtz::o1_DRAWANIMPIC(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_LOADANIM(int16 argc, int16 *argv) {
- warning("Unimplemented opcode: o1_LOADANIM");
+ AnimationResource *anim = _vm->_res->getAnimation(argv[0]);
+ if (anim) {
+ _vm->_res->freeResource(anim);
+ return 1;
+ }
return 0;
}