[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.140,1.141 boxes.cpp,1.47,1.48 charset.cpp,2.57,2.58 gfx.cpp,2.176,2.177 resource.cpp,1.110,1.111 scumm.h,1.270,1.271 scummvm.cpp,2.288,2.289 string.cpp,1.150,1.151
Max Horn
fingolfin at users.sourceforge.net
Sat Jul 19 11:19:02 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv3359
Modified Files:
actor.cpp boxes.cpp charset.cpp gfx.cpp resource.cpp scumm.h
scummvm.cpp string.cpp
Log Message:
moved some functions out of scummvm.cpp into more appropriate files; rearranged stuff inside scummvm.cpp to be grouped a bit more logical
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- actor.cpp 15 Jul 2003 19:09:11 -0000 1.140
+++ actor.cpp 19 Jul 2003 18:18:01 -0000 1.141
@@ -812,6 +812,25 @@
}
}
+Actor *Scumm::derefActor(int id, const char *errmsg) const {
+ if (id < 1 || id >= _numActors || _actors[id].number != id) {
+ if (errmsg)
+ error("Invalid actor %d in %s", id, errmsg);
+ else
+ error("Invalid actor %d", id);
+ }
+ return &_actors[id];
+}
+
+Actor *Scumm::derefActorSafe(int id, const char *errmsg) const {
+ if (id < 1 || id >= _numActors || _actors[id].number != id) {
+ debug(2, "Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.",
+ id, errmsg, vm.slot[_curExecScript].number, _opcode);
+ return NULL;
+ }
+ return &_actors[id];
+}
+
static int compareDrawOrder(const void* a, const void* b)
{
const Actor* actor1 = *(const Actor *const*)a;
Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- boxes.cpp 15 Jul 2003 19:20:40 -0000 1.47
+++ boxes.cpp 19 Jul 2003 18:18:01 -0000 1.48
@@ -216,6 +216,50 @@
return READ_LE_UINT16(&ptr->old.scale);
}
+/*
+ FIXME: It seems that scale items and scale slots are the same thing after
+ all - they only differ in some details (scale item is used to precompute
+ a scale table, while for the scale slots the computations are done on the
+ fly; also for scale slots, the scale along the x axis can vary, too).
+
+ Now, there are various known scale glitches in FT (and apparently also
+ in The Dig, see FIXME comments in Actor::setupActorScale). In this context
+ it is very interesting that for V5, there is an opcode which invokes
+ setScaleItem, and for V8 one that invokes setScaleSlot. But there is no
+ such opcode to be found for V6/V7 games.
+
+ Hypothesis: we simple are missing this opcode, and implementing it might
+ fix some or all of the Dig/FT scaling issues.
+*/
+void Scumm::setScaleItem(int slot, int y1, int scale1, int y2, int scale2) {
+ byte *ptr;
+ int y, tmp;
+
+ if (y1 == y2)
+ return;
+
+ ptr = createResource(rtScaleTable, slot, 200);
+
+ for (y = 0; y < 200; y++) {
+ tmp = ((scale2 - scale1) * (y - y1)) / (y2 - y1) + scale1;
+ if (tmp < 1)
+ tmp = 1;
+ if (tmp > 255)
+ tmp = 255;
+ *ptr++ = tmp;
+ }
+}
+
+void Scumm::setScaleSlot(int slot, int x1, int y1, int scale1, int x2, int y2, int scale2) {
+ assert(1 <= slot && slot <= 20);
+ _scaleSlots[slot-1].x2 = x2;
+ _scaleSlots[slot-1].y2 = y2;
+ _scaleSlots[slot-1].scale2 = scale2;
+ _scaleSlots[slot-1].x1 = x1;
+ _scaleSlots[slot-1].y1 = y1;
+ _scaleSlots[slot-1].scale1 = scale1;
+}
+
byte Scumm::getNumBoxes() {
byte *ptr = getResourceAddress(rtMatrix, 2);
if (!ptr)
Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.57
retrieving revision 2.58
diff -u -d -r2.57 -r2.58
--- charset.cpp 19 Jul 2003 03:54:32 -0000 2.57
+++ charset.cpp 19 Jul 2003 18:18:01 -0000 2.58
@@ -49,7 +49,7 @@
}
void CharsetRendererCommon::setCurID(byte id) {
- _vm->checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d");
+ checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d");
_curId = id;
@@ -64,7 +64,7 @@
}
void CharsetRendererV3::setCurID(byte id) {
- _vm->checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d");
+ checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d");
_curId = id;
@@ -947,7 +947,7 @@
int w, h;
int drawTop;
- _vm->checkRange(_vm->_maxCharsets - 1, 0, _curId, "Printing with bad charset %d");
+ checkRange(_vm->_maxCharsets - 1, 0, _curId, "Printing with bad charset %d");
if ((vs = _vm->findVirtScreen(_top)) == NULL)
return;
@@ -1003,7 +1003,7 @@
const byte *charPtr;
int is2byte = (chr >= 0x80 && _vm->_CJKMode) ? 1 : 0;
- _vm->checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d");
+ checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d");
if ((vs = _vm->findVirtScreen(_top)) == NULL && (vs = _vm->findVirtScreen(_top + getFontHeight())) == NULL)
return;
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.176
retrieving revision 2.177
diff -u -d -r2.176 -r2.177
--- gfx.cpp 17 Jul 2003 05:06:59 -0000 2.176
+++ gfx.cpp 19 Jul 2003 18:18:01 -0000 2.177
@@ -3319,6 +3319,57 @@
return cptr;
}
+void Scumm::updatePalette() {
+ if (_palDirtyMax == -1)
+ return;
+
+ bool noir_mode = (_gameId == GID_SAMNMAX && readVar(0x8000));
+ int first = _palDirtyMin;
+ int num = _palDirtyMax - first + 1;
+ int i;
+
+ byte palette_colors[1024];
+ byte *p = palette_colors;
+
+ for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
+ byte *data;
+
+ if (_features & GF_SMALL_HEADER)
+ data = _currentPalette + _shadowPalette[i] * 3;
+ else
+ data = _currentPalette + i * 3;
+
+ // Sam & Max film noir mode. Convert the colours to grayscale
+ // before uploading them to the backend.
+
+ if (noir_mode) {
+ int r, g, b;
+ byte brightness;
+
+ r = data[0];
+ g = data[1];
+ b = data[2];
+
+ brightness = (byte)((0.299 * r + 0.587 * g + 0.114 * b) + 0.5);
+
+ *p++ = brightness;
+ *p++ = brightness;
+ *p++ = brightness;
+ *p++ = 0;
+ } else {
+ *p++ = data[0];
+ *p++ = data[1];
+ *p++ = data[2];
+ *p++ = 0;
+ }
+ }
+
+ _system->set_palette(palette_colors, first, num);
+
+ _palDirtyMax = -1;
+ _palDirtyMin = 256;
+}
+
#pragma mark -
#pragma mark --- Cursor ---
#pragma mark -
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- resource.cpp 19 Jul 2003 14:26:25 -0000 1.110
+++ resource.cpp 19 Jul 2003 18:18:01 -0000 1.111
@@ -1701,6 +1701,36 @@
return res.address[type][idx] != NULL;
}
+void Scumm::dumpResource(const char *tag, int idx, const byte *ptr, int length) {
+ char buf[256];
+ File out;
+
+ uint32 size;
+ if (length >= 0)
+ size = length;
+ else if (_features & GF_OLD_BUNDLE)
+ size = READ_LE_UINT16(ptr);
+ else if (_features & GF_SMALL_HEADER)
+ size = READ_LE_UINT32(ptr);
+ else
+ size = READ_BE_UINT32(ptr + 4);
+
+#if defined(MACOS_CARBON)
+ sprintf(buf, ":dumps:%s%d.dmp", tag, idx);
+#else
+ sprintf(buf, "dumps/%s%d.dmp", tag, idx);
+#endif
+
+ out.open(buf, "", 1);
+ if (out.isOpen() == false) {
+ out.open(buf, "", 2);
+ if (out.isOpen() == false)
+ return;
+ out.write(ptr, size);
+ }
+ out.close();
+}
+
ResourceIterator::ResourceIterator(const byte *searchin, bool smallHeader)
: _ptr(searchin), _smallHeader(smallHeader) {
assert(searchin);
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -d -r1.270 -r1.271
--- scumm.h 18 Jul 2003 05:49:21 -0000 1.270
+++ scumm.h 19 Jul 2003 18:18:01 -0000 1.271
@@ -366,7 +366,6 @@
void clearClickedStatus();
// Misc utility functions
- void checkRange(int max, int min, int no, const char *str) const;
const char *getExeName() const { return _exe_name; }
const char *getGameDataPath() const;
@@ -384,7 +383,6 @@
void pauseGame();
void restart();
void shutDown();
- void setOptions(void);
/** We keep running until this is set to true. */
bool _quit;
@@ -1251,6 +1249,8 @@
int normalizeAngle(int angle);
int fromSimpleDir(int dirtype, int dir);
int toSimpleDir(int dirtype, int dir);
+
+void checkRange(int max, int min, int no, const char *str);
#endif
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.288
retrieving revision 2.289
diff -u -d -r2.288 -r2.289
--- scummvm.cpp 18 Jul 2003 05:49:21 -0000 2.288
+++ scummvm.cpp 19 Jul 2003 18:18:01 -0000 2.289
@@ -60,21 +60,6 @@
Scumm *g_scumm = 0;
ScummDebugger *g_debugger;
-byte *Scumm::get2byteCharPtr(int idx) {
- /*
- switch(language)
- case korean:
- return ( (idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1;
- case japanese:
- ...
- case taiwan:
[...1297 lines suppressed...]
+ * change it to the closest multiple of 45 degree by abusing toSimpleDir.
+ */
+int normalizeAngle(int angle) {
+ int temp;
- _sound->setupSound();
+ temp = (angle + 360) % 360;
- // If requested, load a save game instead of running the boot script
- if (_saveLoadFlag != 2 || !loadState(_saveLoadSlot, _saveLoadCompatible)) {
- runScript(1, 0, 0, &_bootParam);
- }
- _saveLoadFlag = 0;
+ return toSimpleDir(1, temp) * 45;
}
-void Scumm::go() {
- launch();
- mainRun();
-}
Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- string.cpp 19 Jul 2003 14:26:25 -0000 1.150
+++ string.cpp 19 Jul 2003 18:18:01 -0000 1.151
@@ -28,6 +28,18 @@
#include "verbs.h"
#include "scumm/sound.h"
+void Scumm::setStringVars(int slot) {
+ StringTab *st = &_string[slot];
+ st->xpos = st->t_xpos;
+ st->ypos = st->t_ypos;
+ st->center = st->t_center;
+ st->overhead = st->t_overhead;
+ st->no_talk_anim = st->t_no_talk_anim;
+ st->right = st->t_right;
+ st->color = st->t_color;
+ st->charset = st->t_charset;
+}
+
void Scumm::unkMessage1() {
byte buffer[100];
_msgPtrToAdd = buffer;
More information about the Scummvm-git-logs
mailing list