aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actor.cpp18
-rw-r--r--debug.cpp2
-rw-r--r--gfx.cpp4
-rw-r--r--gui.h5
-rw-r--r--resource.cpp42
-rw-r--r--saveload.cpp12
-rw-r--r--script_v2.cpp2
-rw-r--r--scumm.h25
-rw-r--r--scummvm.cpp8
9 files changed, 64 insertions, 54 deletions
diff --git a/actor.cpp b/actor.cpp
index d8e3f229c8..2060457fa7 100644
--- a/actor.cpp
+++ b/actor.cpp
@@ -574,7 +574,7 @@ void Scumm::showActors() {
int i;
Actor *a;
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
if (a->room == _currentRoom)
showActor(a);
@@ -608,7 +608,7 @@ void Scumm::clearMsgQueue() {
void Scumm::walkActors() {
int i;
Actor *a;
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
if (a->room==_currentRoom)
walkActor(a);
@@ -620,12 +620,12 @@ void Scumm::playActorSounds() {
int i;
Actor *a;
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
if (a->cost.animCounter2 && a->room==_currentRoom && a->sound) {
_currentScript = 0xFF;
addSoundToQueue(a->sound[0]);
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
a->cost.animCounter2 = 0;
}
@@ -708,10 +708,10 @@ void Scumm::walkActor(Actor *a) {
void Scumm::processActors() {
int i;
- Actor *actors[13],*a,**ac,**ac2,*tmp;
+ Actor *actors[NUM_ACTORS],*a,**ac,**ac2,*tmp;
int numactors = 0, cnt,cnt2;
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
if (a->room == _currentRoom)
actors[numactors++] = a;
@@ -814,7 +814,7 @@ void Scumm::setActorRedrawFlags() {
for (i=0; i<40; i++) {
bits = actorDrawBits[_screenStartStrip+i];
if (bits&0x3FFF) {
- for(j=0; j<13; j++) {
+ for(j=0; j<NUM_ACTORS; j++) {
if ((bits&(1<<j)) && bits!=(1<<j)) {
Actor *a = derefActor(j);
a->needRedraw = true;
@@ -832,7 +832,7 @@ int Scumm::getActorFromPos(int x, int y) {
drawbits = actorDrawBits[x>>3];
if (!(drawbits & 0x3FFF))
return 0;
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
Actor *a = derefActor(i);
if (drawbits&(1<<i) && !getClass(i, 32) && y >= a->top && y <= a->bottom) {
return i;
@@ -966,7 +966,7 @@ bool Scumm::isCostumeInUse(int cost) {
Actor *a;
if (_roomResource!=0)
- for (i=1; i<13; i++) {
+ for (i=1; i<NUM_ACTORS; i++) {
a = derefActor(i);
if (a->room == _currentRoom && a->costume == cost)
return true;
diff --git a/debug.cpp b/debug.cpp
index a5688ba6a8..ed04faf699 100644
--- a/debug.cpp
+++ b/debug.cpp
@@ -165,7 +165,7 @@ void ScummDebugger::printActors(int act) {
printf("+--------------------------------------------------------------+\n");
printf("|# |room| x y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n");
printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n");
- for(i=1; i<13; i++) {
+ for(i=1; i<NUM_ACTORS; i++) {
if (act==-1 || act==i) {
a = &_s->actor[i];
if (a->visible)
diff --git a/gfx.cpp b/gfx.cpp
index cb93b96fdc..77a184c74e 100644
--- a/gfx.cpp
+++ b/gfx.cpp
@@ -295,7 +295,7 @@ void Scumm::setCameraFollows(Actor *a) {
t-_screenStartStrip > cd->_rightTrigger)
setCameraAt(a->x);
- for (i=1,a=getFirstActor(); ++a,i<13; i++) {
+ for (i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
if (a->room==_currentRoom)
a->needRedraw = true;
}
@@ -1632,7 +1632,7 @@ void Scumm::resetActorBgs() {
}
}
- for(i=1,a=getFirstActor(); ++a,i<13; i++) {
+ for(i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
a->needBgReset = false;
}
}
diff --git a/gui.h b/gui.h
index 75359d789f..b0c4c16448 100644
--- a/gui.h
+++ b/gui.h
@@ -1,3 +1,6 @@
+#if !defined(gui_h)
+#define gui_h
+
enum {
GUI_NONE = 0,
GUI_TEXT = 1,
@@ -73,3 +76,5 @@ struct Gui {
void queryMessage(const char *msg, const char *alts);
byte getDefaultColor(int color);
};
+
+#endif \ No newline at end of file
diff --git a/resource.cpp b/resource.cpp
index 0d408100e6..f60d7d8671 100644
--- a/resource.cpp
+++ b/resource.cpp
@@ -175,7 +175,7 @@ void Scumm::readIndexFileV5(int mode) {
switch(blocktype) {
case MKID('DCHR'):
- readResTypeList(6,MKID('CHAR'),"charset");
+ readResTypeList(rtCharset,MKID('CHAR'),"charset");
break;
case MKID('DOBJ'):
@@ -200,15 +200,15 @@ void Scumm::readIndexFileV5(int mode) {
break;
case MKID('DROO'):
- readResTypeList(1,MKID('ROOM'),"room");
+ readResTypeList(rtRoom,MKID('ROOM'),"room");
break;
case MKID('DSCR'):
- readResTypeList(2,MKID('SCRP'),"script");
+ readResTypeList(rtScript,MKID('SCRP'),"script");
break;
case MKID('DCOS'):
- readResTypeList(3,MKID('COST'),"costume");
+ readResTypeList(rtCostume,MKID('COST'),"costume");
break;
case MKID('MAXS'):
@@ -224,7 +224,7 @@ void Scumm::readIndexFileV5(int mode) {
break;
case MKID('DSOU'):
- readResTypeList(4,MKID('SOUN'),"sound");
+ readResTypeList(rtSound,MKID('SOUN'),"sound");
break;
default:
@@ -265,7 +265,7 @@ void Scumm::readIndexFileV6() {
switch(blocktype) {
case MKID('DCHR'):
- readResTypeList(6,MKID('CHAR'),"charset");
+ readResTypeList(rtCharset,MKID('CHAR'),"charset");
break;
case MKID('DOBJ'):
@@ -284,15 +284,15 @@ void Scumm::readIndexFileV6() {
break;
case MKID('DROO'):
- readResTypeList(1,MKID('ROOM'),"room");
+ readResTypeList(rtRoom,MKID('ROOM'),"room");
break;
case MKID('DSCR'):
- readResTypeList(2,MKID('SCRP'),"script");
+ readResTypeList(rtScript,MKID('SCRP'),"script");
break;
case MKID('DCOS'):
- readResTypeList(3,MKID('COST'),"costume");
+ readResTypeList(rtCostume,MKID('COST'),"costume");
break;
case MKID('MAXS'):
@@ -300,7 +300,7 @@ void Scumm::readIndexFileV6() {
break;
case MKID('DSOU'):
- readResTypeList(4,MKID('SOUN'),"sound");
+ readResTypeList(rtSound,MKID('SOUN'),"sound");
break;
case MKID('AARY'):
@@ -412,7 +412,7 @@ void Scumm::ensureResourceLoaded(int type, int i) {
debug(9, "ensureResourceLoaded(%d,%d)", type, i);
- if (type==1 && i>127) {
+ if (type==rtRoom && i>127) {
i = _resourceMapper[i&127];
}
@@ -425,7 +425,7 @@ void Scumm::ensureResourceLoaded(int type, int i) {
loadResource(type, i);
- if (type==1 && i==_roomResource)
+ if (type==rtRoom && i==_roomResource)
_vars[VAR_ROOM_FLAG] = 1;
}
@@ -442,7 +442,7 @@ int Scumm::loadResource(int type, int index) {
res.name[type],index);
}
- if (type==1) {
+ if (type==rtRoom) {
fileOffs = 0;
} else {
fileOffs = res.roomoffs[type][index];
@@ -455,7 +455,7 @@ int Scumm::loadResource(int type, int index) {
openRoom(roomNr);
fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET);
- if (type==4) {
+ if (type==rtSound) {
fileReadDwordLE();
fileReadDwordLE();
return readSoundResource(type, index);
@@ -475,7 +475,7 @@ int Scumm::loadResource(int type, int index) {
/* dump the resource */
#ifdef DUMP_SCRIPTS
- if(type==2) {
+ if(type==rtScript) {
dumpResource("script-", index, getResourceAddress(rtScript, index));
}
#endif
@@ -526,7 +526,7 @@ int Scumm::readSoundResource(int type, int index) {
}
int Scumm::getResourceRoomNr(int type, int index) {
- if (type==1)
+ if (type==rtRoom)
return index;
return res.roomno[type][index];
}
@@ -602,7 +602,7 @@ byte *Scumm::createResource(int type, int index, uint32 size) {
}
void Scumm::validateResource(const char *str, int type, int index) {
- if (type<1 || type>16 || index<0 || index >= res.num[type]) {
+ if (type<rtFirst || type>rtLast || (uint)index >= (uint)res.num[type]) {
error("%d Illegal Glob type %d num %d", str, type, index);
}
}
@@ -686,7 +686,7 @@ void Scumm::increaseResourceCounter() {
int i,j;
byte counter;
- for (i=1; i<=16; i++) {
+ for (i=rtFirst; i<=rtLast; i++) {
for(j=res.num[i]; --j>=0;) {
counter = res.flags[i][j] & 0x7F;
if (counter && counter < 0x7F) {
@@ -717,7 +717,7 @@ void Scumm::expireResources(uint32 size) {
best_type = 0;
best_counter = 2;
- for (i=1; i<=16; i++)
+ for (i=rtFirst; i<=rtLast; i++)
if (res.mode[i]) {
for(j=res.num[i]; --j>=0;) {
flag = res.flags[i][j];
@@ -741,7 +741,7 @@ void Scumm::expireResources(uint32 size) {
void Scumm::freeResources() {
int i,j;
- for (i=1; i<=16; i++) {
+ for (i=rtFirst; i<=rtLast; i++) {
for(j=res.num[i]; --j>=0;) {
if (isResourceLoaded(i,j))
nukeResource(i,j);
@@ -786,7 +786,7 @@ void Scumm::resourceStats() {
uint32 lockedSize = 0, lockedNum = 0;
byte flag;
- for (i=1; i<=16; i++)
+ for (i=rtFirst; i<=rtLast; i++)
for(j=res.num[i]; --j>=0;) {
flag = res.flags[i][j];
if (flag&0x80 && res.address[i][j]) {
diff --git a/saveload.cpp b/saveload.cpp
index 453c527985..446ec65f10 100644
--- a/saveload.cpp
+++ b/saveload.cpp
@@ -95,7 +95,7 @@ bool Scumm::loadState(int slot, bool compat) {
memset(_inventory, 0, sizeof(_inventory[0])*_numInventory);
/* Nuke all resources */
- for (i=1; i<=16; i++)
+ for (i=rtFirst; i<=rtLast; i++)
if (i!=rtTemp && i!=rtBuffer)
for(j=0; j<res.num[i]; j++) {
nukeResource(i,j);
@@ -452,7 +452,7 @@ void Scumm::saveOrLoad(Serializer *s) {
s->saveLoadArrayOf(string, 6, sizeof(string[0]), stringTabEntries);
s->saveLoadArrayOf(_colorCycle, 16, sizeof(_colorCycle[0]), colorCycleEntries);
- for (i=1; i<=16; i++)
+ for (i=rtFirst; i<=rtLast; i++)
if (res.mode[i]==0)
for(j=1; j<res.num[i]; j++)
saveLoadResource(s,i,j);
@@ -464,7 +464,7 @@ void Scumm::saveOrLoad(Serializer *s) {
/* Save or load a list of the locked objects */
if (s->isSaving()) {
- for (i=1; i<=16; i++)
+ for (i=rtFirst; i<=rtLast; i++)
for(j=1; j<res.num[i]; j++) {
if (res.flags[i][j]&0x80) {
s->saveByte(i);
@@ -486,7 +486,7 @@ void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
byte flag;
/* don't save/load these resource types */
- if (type==13 || type==12 || type==10 || res.mode[type])
+ if (type==rtFlObject || type==rtTemp || type==rtBuffer || res.mode[type])
return;
if (ser->isSaving()) {
@@ -501,7 +501,7 @@ void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
ser->saveUint32(size);
ser->saveLoadBytes(ptr+sizeof(ResHeader),size);
- if (type==5) {
+ if (type==rtInventory) {
ser->saveWord(_inventory[index]);
}
} else {
@@ -509,7 +509,7 @@ void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
if (size) {
createResource(type, index, size);
ser->saveLoadBytes(getResourceAddress(type, index), size);
- if (type==5) {
+ if (type==rtInventory) {
_inventory[index] = ser->loadWord();
}
}
diff --git a/script_v2.cpp b/script_v2.cpp
index 625f86f23b..e0fd6c8b9f 100644
--- a/script_v2.cpp
+++ b/script_v2.cpp
@@ -2004,7 +2004,7 @@ void Scumm::o6_miscOps() {
case 6:
_fullRedraw = 1;
redrawBGAreas();
- for (i=0; i<13; i++)
+ for (i=0; i<NUM_ACTORS; i++)
derefActor(i)->needRedraw = true;
processActors();
screenEffect(args[1]);
diff --git a/scumm.h b/scumm.h
index 6e4739d453..5ef1c978d1 100644
--- a/scumm.h
+++ b/scumm.h
@@ -29,6 +29,7 @@ struct Actor;
typedef void (Scumm::*OpcodeProc)();
#define NUM_SCRIPT_SLOT 25
+#define NUM_ACTORS 13
#pragma START_PACK_STRUCTS
@@ -289,6 +290,7 @@ enum ScummVars {
};
enum ResTypes {
+ rtFirst = 1,
rtRoom = 1,
rtScript = 2,
rtCostume = 3,
@@ -305,6 +307,9 @@ enum ResTypes {
rtMatrix = 14,
rtBox = 15,
rtObjectName = 16,
+ rtLast = 16,
+
+ rtNumTypes = 17,
};
@@ -759,14 +764,14 @@ struct Scumm {
int16 _palManipCounter;
struct {
- byte mode[17];
- uint16 num[17];
- uint32 tags[17];
- const char *name[17];
- byte **address[17];
- byte *flags[17];
- byte *roomno[17];
- uint32 *roomoffs[17];
+ byte mode[rtNumTypes];
+ uint16 num[rtNumTypes];
+ uint32 tags[rtNumTypes];
+ const char *name[rtNumTypes];
+ byte **address[rtNumTypes];
+ byte *flags[rtNumTypes];
+ byte *roomno[rtNumTypes];
+ uint32 *roomoffs[rtNumTypes];
} res;
struct {
@@ -784,7 +789,7 @@ struct Scumm {
int16 x,y;
} mouse;
- Actor actor[13];
+ Actor actor[NUM_ACTORS];
uint16 actorDrawBits[200];
@@ -1668,4 +1673,4 @@ void drawMouse(Scumm *s, int x, int y, int w, int h, byte *buf, bool visible);
void blit(byte *dst, byte *src, int w, int h);
byte *findResource(uint32 id, byte *searchin, int index);
void playSfxSound(void *sound, uint32 size, uint rate);
-bool isSfxFinished(); \ No newline at end of file
+bool isSfxFinished();
diff --git a/scummvm.cpp b/scummvm.cpp
index 6dd16a08d7..a03ab00205 100644
--- a/scummvm.cpp
+++ b/scummvm.cpp
@@ -72,7 +72,7 @@ void Scumm::scummInit() {
setShake(0);
setupCursor();
- for (i=1,a=getFirstActor(); ++a,i<13; i++) {
+ for (i=1,a=getFirstActor(); ++a,i<NUM_ACTORS; i++) {
a->number = i;
initActor(a, 1);
}
@@ -287,7 +287,7 @@ int Scumm::scummLoop(int delta) {
charset._hasMask = false;
redrawVerbs();
_fullRedraw = true;
- for (i=0,a=getFirstActor(); i<13; i++,a++)
+ for (i=0,a=getFirstActor(); i<NUM_ACTORS; i++,a++)
a->needRedraw = 1;
}
@@ -484,7 +484,7 @@ void Scumm::startScene(int room, Actor *a, int objectNr) {
killScriptsAndResources();
stopCycle(0);
- for(i=1,at=getFirstActor(); ++at,i<13; i++) {
+ for(i=1,at=getFirstActor(); ++at,i<NUM_ACTORS; i++) {
if (at->visible)
hideActor(at);
}
@@ -836,7 +836,7 @@ void Scumm::convertKeysToClicks() {
}
Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
- if (id<1 || id>=13)
+ if (id<1 || id>=NUM_ACTORS)
error("Invalid actor %d in %s", id, errmsg);
return derefActor(id);
}