mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
TINSEL: Add isValidObject(OBJECT *obj) function; make objectList & currentCD static vars; merge two logic blocks ('ifs') in DoRestoreSceneFrame
svn-id: r45618
This commit is contained in:
parent
5cf868b757
commit
26981a5ffc
@ -45,8 +45,6 @@ namespace Tinsel {
|
|||||||
|
|
||||||
#define fAllCds (fCd1|fCd2|fCd3|fCd4|fCd5|fCd6|fCd7|fCd8)
|
#define fAllCds (fCd1|fCd2|fCd3|fCd4|fCd5|fCd6|fCd7|fCd8)
|
||||||
|
|
||||||
extern char currentCD;
|
|
||||||
|
|
||||||
void DoCdChange();
|
void DoCdChange();
|
||||||
|
|
||||||
void CdCD(CORO_PARAM);
|
void CdCD(CORO_PARAM);
|
||||||
|
@ -31,9 +31,6 @@
|
|||||||
|
|
||||||
namespace Tinsel {
|
namespace Tinsel {
|
||||||
|
|
||||||
// from object.c
|
|
||||||
extern OBJECT *objectList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise a multi-part object using a list of images to init
|
* Initialise a multi-part object using a list of images to init
|
||||||
* each object piece. One object is created for each image in the list.
|
* each object piece. One object is created for each image in the list.
|
||||||
@ -98,7 +95,7 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
|
|||||||
|
|
||||||
void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
|
void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pInsObj >= objectList && pInsObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pInsObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
@ -119,7 +116,7 @@ void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
|
|||||||
|
|
||||||
void MultiDeleteObject(OBJECT *pObjList, OBJECT *pMultiObj) {
|
void MultiDeleteObject(OBJECT *pObjList, OBJECT *pMultiObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
@ -140,7 +137,7 @@ void MultiDeleteObject(OBJECT *pObjList, OBJECT *pMultiObj) {
|
|||||||
|
|
||||||
void MultiHideObject(OBJECT *pMultiObj) {
|
void MultiHideObject(OBJECT *pMultiObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// set master shape to null animation frame
|
// set master shape to null animation frame
|
||||||
pMultiObj->hShape = 0;
|
pMultiObj->hShape = 0;
|
||||||
@ -156,7 +153,7 @@ void MultiHideObject(OBJECT *pMultiObj) {
|
|||||||
|
|
||||||
void MultiHorizontalFlip(OBJECT *pFlipObj) {
|
void MultiHorizontalFlip(OBJECT *pFlipObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pFlipObj >= objectList && pFlipObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pFlipObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
@ -176,7 +173,7 @@ void MultiHorizontalFlip(OBJECT *pFlipObj) {
|
|||||||
|
|
||||||
void MultiVerticalFlip(OBJECT *pFlipObj) {
|
void MultiVerticalFlip(OBJECT *pFlipObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pFlipObj >= objectList && pFlipObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pFlipObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
@ -200,7 +197,7 @@ void MultiVerticalFlip(OBJECT *pFlipObj) {
|
|||||||
|
|
||||||
void MultiAdjustXY(OBJECT *pMultiObj, int deltaX, int deltaY) {
|
void MultiAdjustXY(OBJECT *pMultiObj, int deltaX, int deltaY) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
if (deltaX == 0 && deltaY == 0)
|
if (deltaX == 0 && deltaY == 0)
|
||||||
return; // ignore no change
|
return; // ignore no change
|
||||||
@ -245,7 +242,7 @@ void MultiAdjustXY(OBJECT *pMultiObj, int deltaX, int deltaY) {
|
|||||||
|
|
||||||
void MultiMoveRelXY(OBJECT *pMultiObj, int deltaX, int deltaY) {
|
void MultiMoveRelXY(OBJECT *pMultiObj, int deltaX, int deltaY) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
if (deltaX == 0 && deltaY == 0)
|
if (deltaX == 0 && deltaY == 0)
|
||||||
return; // ignore no change
|
return; // ignore no change
|
||||||
@ -278,7 +275,7 @@ void MultiSetAniXY(OBJECT *pMultiObj, int newAniX, int newAniY) {
|
|||||||
int curAniX, curAniY; // objects current animation position
|
int curAniX, curAniY; // objects current animation position
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// get master objects current animation position
|
// get master objects current animation position
|
||||||
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
||||||
@ -301,7 +298,7 @@ void MultiSetAniX(OBJECT *pMultiObj, int newAniX) {
|
|||||||
int curAniX, curAniY; // objects current animation position
|
int curAniX, curAniY; // objects current animation position
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// get master objects current animation position
|
// get master objects current animation position
|
||||||
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
||||||
@ -324,7 +321,7 @@ void MultiSetAniY(OBJECT *pMultiObj, int newAniY) {
|
|||||||
int curAniX, curAniY; // objects current animation position
|
int curAniX, curAniY; // objects current animation position
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// get master objects current animation position
|
// get master objects current animation position
|
||||||
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
GetAniPosition(pMultiObj, &curAniX, &curAniY);
|
||||||
@ -345,7 +342,7 @@ void MultiSetAniY(OBJECT *pMultiObj, int newAniY) {
|
|||||||
|
|
||||||
void MultiSetZPosition(OBJECT *pMultiObj, int newZ) {
|
void MultiSetZPosition(OBJECT *pMultiObj, int newZ) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
@ -370,7 +367,7 @@ void MultiReshape(OBJECT *pMultiObj) {
|
|||||||
SCNHANDLE hFrame;
|
SCNHANDLE hFrame;
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// get objects current anim frame
|
// get objects current anim frame
|
||||||
hFrame = pMultiObj->hShape;
|
hFrame = pMultiObj->hShape;
|
||||||
@ -427,7 +424,7 @@ int MultiLeftmost(OBJECT *pMulti) {
|
|||||||
int left;
|
int left;
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMulti >= objectList && pMulti <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMulti));
|
||||||
|
|
||||||
// init leftmost point to first object
|
// init leftmost point to first object
|
||||||
left = fracToInt(pMulti->xPos);
|
left = fracToInt(pMulti->xPos);
|
||||||
@ -456,7 +453,7 @@ int MultiRightmost(OBJECT *pMulti) {
|
|||||||
int right;
|
int right;
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMulti >= objectList && pMulti <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMulti));
|
||||||
|
|
||||||
// init right-most point to first object
|
// init right-most point to first object
|
||||||
right = fracToInt(pMulti->xPos) + pMulti->width;
|
right = fracToInt(pMulti->xPos) + pMulti->width;
|
||||||
@ -485,7 +482,7 @@ int MultiHighest(OBJECT *pMulti) {
|
|||||||
int highest;
|
int highest;
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMulti >= objectList && pMulti <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMulti));
|
||||||
|
|
||||||
// init highest point to first object
|
// init highest point to first object
|
||||||
highest = fracToInt(pMulti->yPos);
|
highest = fracToInt(pMulti->yPos);
|
||||||
@ -514,7 +511,7 @@ int MultiLowest(OBJECT *pMulti) {
|
|||||||
int lowest;
|
int lowest;
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMulti >= objectList && pMulti <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMulti));
|
||||||
|
|
||||||
// init lowest point to first object
|
// init lowest point to first object
|
||||||
lowest = fracToInt(pMulti->yPos) + pMulti->height;
|
lowest = fracToInt(pMulti->yPos) + pMulti->height;
|
||||||
@ -550,7 +547,7 @@ bool MultiHasShape(POBJECT pMulti) {
|
|||||||
|
|
||||||
void MultiForceRedraw(POBJECT pMultiObj) {
|
void MultiForceRedraw(POBJECT pMultiObj) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pMultiObj >= objectList && pMultiObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pMultiObj));
|
||||||
|
|
||||||
// for all the objects that make up this multi-part
|
// for all the objects that make up this multi-part
|
||||||
do {
|
do {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
namespace Tinsel {
|
namespace Tinsel {
|
||||||
|
|
||||||
// list of all objects
|
// list of all objects
|
||||||
OBJECT *objectList = 0;
|
static OBJECT *objectList = 0;
|
||||||
|
|
||||||
// pointer to free object list
|
// pointer to free object list
|
||||||
static OBJECT *pFreeObjects = 0;
|
static OBJECT *pFreeObjects = 0;
|
||||||
@ -130,6 +130,10 @@ OBJECT *AllocObject() {
|
|||||||
return pObj;
|
return pObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValidObject(OBJECT *obj) {
|
||||||
|
return (obj >= objectList && obj <= objectList + NUM_OBJECTS - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy one object to another.
|
* Copy one object to another.
|
||||||
* @param pDest Destination object
|
* @param pDest Destination object
|
||||||
@ -163,7 +167,7 @@ void InsertObject(OBJECT *pObjList, OBJECT *pInsObj) {
|
|||||||
OBJECT *pPrev, *pObj; // object list traversal pointers
|
OBJECT *pPrev, *pObj; // object list traversal pointers
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pInsObj >= objectList && pInsObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pInsObj));
|
||||||
|
|
||||||
for (pPrev = pObjList, pObj = pObjList->pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) {
|
for (pPrev = pObjList, pObj = pObjList->pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) {
|
||||||
// check Z order
|
// check Z order
|
||||||
@ -196,7 +200,7 @@ void DelObject(OBJECT *pObjList, OBJECT *pDelObj) {
|
|||||||
const Common::Rect rcScreen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
const Common::Rect rcScreen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
|
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pDelObj >= objectList && pDelObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pDelObj));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// one less object in use
|
// one less object in use
|
||||||
@ -331,7 +335,7 @@ void GetAniOffset(SCNHANDLE hImg, int flags, int *pAniX, int *pAniY) {
|
|||||||
*/
|
*/
|
||||||
void GetAniPosition(OBJECT *pObj, int *pPosX, int *pPosY) {
|
void GetAniPosition(OBJECT *pObj, int *pPosX, int *pPosY) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pObj >= objectList && pObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pObj));
|
||||||
|
|
||||||
// get the animation offset of the object
|
// get the animation offset of the object
|
||||||
GetAniOffset(pObj->hImg, pObj->flags, pPosX, pPosY);
|
GetAniOffset(pObj->hImg, pObj->flags, pPosX, pPosY);
|
||||||
@ -419,7 +423,7 @@ OBJECT *InitObject(const OBJ_INIT *pInitTbl) {
|
|||||||
*/
|
*/
|
||||||
void AnimateObjectFlags(OBJECT *pAniObj, int newflags, SCNHANDLE hNewImg) {
|
void AnimateObjectFlags(OBJECT *pAniObj, int newflags, SCNHANDLE hNewImg) {
|
||||||
// validate object pointer
|
// validate object pointer
|
||||||
assert(pAniObj >= objectList && pAniObj <= objectList + NUM_OBJECTS - 1);
|
assert(isValidObject(pAniObj));
|
||||||
|
|
||||||
if (pAniObj->hImg != hNewImg
|
if (pAniObj->hImg != hNewImg
|
||||||
|| (pAniObj->flags & DMA_HARDFLAGS) != (newflags & DMA_HARDFLAGS)) {
|
|| (pAniObj->flags & DMA_HARDFLAGS) != (newflags & DMA_HARDFLAGS)) {
|
||||||
|
@ -130,6 +130,8 @@ OBJECT *AllocObject(); // allocate a object from the free list
|
|||||||
void FreeObject( // place a object back on the free list
|
void FreeObject( // place a object back on the free list
|
||||||
OBJECT *pFreeObj); // object to free
|
OBJECT *pFreeObj); // object to free
|
||||||
|
|
||||||
|
bool isValidObject(OBJECT *obj);
|
||||||
|
|
||||||
void CopyObject( // copy one object to another
|
void CopyObject( // copy one object to another
|
||||||
OBJECT *pDest, // destination object
|
OBJECT *pDest, // destination object
|
||||||
OBJECT *pSrc); // source object
|
OBJECT *pSrc); // source object
|
||||||
|
@ -311,14 +311,15 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
|
|||||||
_vm->_sound->stopAllSamples();
|
_vm->_sound->stopAllSamples();
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
|
|
||||||
// Master script only affected on restore game, not restore scene
|
|
||||||
if (TinselV2 && (sd == &sgData)) {
|
|
||||||
g_scheduler->killMatchingProcess(PID_MASTER_SCR);
|
|
||||||
KillGlobalProcesses();
|
|
||||||
FreeMasterInterpretContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TinselV2) {
|
if (TinselV2) {
|
||||||
|
|
||||||
|
// Master script only affected on restore game, not restore scene
|
||||||
|
if (sd == &sgData) {
|
||||||
|
g_scheduler->killMatchingProcess(PID_MASTER_SCR);
|
||||||
|
KillGlobalProcesses();
|
||||||
|
FreeMasterInterpretContext();
|
||||||
|
}
|
||||||
|
|
||||||
RestorePolygonStuff(sd->SavedPolygonStuff);
|
RestorePolygonStuff(sd->SavedPolygonStuff);
|
||||||
|
|
||||||
// Abandon temporarily if different CD
|
// Abandon temporarily if different CD
|
||||||
|
Loading…
x
Reference in New Issue
Block a user