mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 23:31:57 +00:00
prevents bank re-loading (cutaways animations)
svn-id: r12524
This commit is contained in:
parent
7a53d9ba7b
commit
993fba68f1
@ -28,8 +28,7 @@ namespace Queen {
|
|||||||
|
|
||||||
BankManager::BankManager(Resource *res)
|
BankManager::BankManager(Resource *res)
|
||||||
: _res(res) {
|
: _res(res) {
|
||||||
memset(_frames, 0, sizeof(_frames));
|
flush();
|
||||||
memset(_banks, 0, sizeof(_banks));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BankManager::~BankManager() {
|
BankManager::~BankManager() {
|
||||||
@ -40,29 +39,38 @@ BankManager::~BankManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BankManager::load(const char *bankname, uint32 bankslot) {
|
void BankManager::load(const char *bankname, uint32 bankslot) {
|
||||||
close(bankslot);
|
debug(9, "BankManager::load(%s, %d)", bankname, bankslot);
|
||||||
|
assert(bankslot < MAX_BANKS_NUMBER);
|
||||||
|
|
||||||
|
if (!scumm_stricmp(bankname, _loadedBanks[bankslot])) {
|
||||||
|
debug(9, "BankManager::load() bank '%s' already loaded", bankname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(bankslot);
|
||||||
_banks[bankslot].data = _res->loadFile(bankname);
|
_banks[bankslot].data = _res->loadFile(bankname);
|
||||||
|
|
||||||
int16 entries = (int16)READ_LE_UINT16(_banks[bankslot].data);
|
uint16 entries = READ_LE_UINT16(_banks[bankslot].data);
|
||||||
if (entries < 0 || entries >= MAX_BANK_SIZE) {
|
assert(entries < MAX_BANK_SIZE);
|
||||||
error("Maximum bank size exceeded or negative bank size : %d", entries);
|
debug(9, "BankManager::load() entries = %d", entries);
|
||||||
}
|
|
||||||
debug(9, "BankManager::load(%s, %d) - entries = %d", bankname, bankslot, entries);
|
|
||||||
|
|
||||||
uint32 offset = 2;
|
uint32 offset = 2;
|
||||||
uint8 *p = _banks[bankslot].data;
|
uint8 *p = _banks[bankslot].data;
|
||||||
for (int16 i = 1; i <= entries; ++i) {
|
for (uint16 i = 1; i <= entries; ++i) {
|
||||||
_banks[bankslot].indexes[i] = offset;
|
_banks[bankslot].indexes[i] = offset;
|
||||||
uint16 w = READ_LE_UINT16(p + offset + 0);
|
uint16 w = READ_LE_UINT16(p + offset + 0);
|
||||||
uint16 h = READ_LE_UINT16(p + offset + 2);
|
uint16 h = READ_LE_UINT16(p + offset + 2);
|
||||||
// jump to next entry, skipping data & header
|
// jump to next entry, skipping data & header
|
||||||
offset += w * h + 8;
|
offset += w * h + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark this bank as loaded
|
||||||
|
strcpy(_loadedBanks[bankslot], bankname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BankManager::unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
void BankManager::unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
||||||
debug(9, "BankManager::unpack(%d, %d, %d)", srcframe, dstframe, bankslot);
|
debug(9, "BankManager::unpack(%d, %d, %d)", srcframe, dstframe, bankslot);
|
||||||
|
assert(bankslot < MAX_BANKS_NUMBER);
|
||||||
assert(_banks[bankslot].data != NULL);
|
assert(_banks[bankslot].data != NULL);
|
||||||
|
|
||||||
BobFrame *pbf = &_frames[dstframe];
|
BobFrame *pbf = &_frames[dstframe];
|
||||||
@ -80,6 +88,7 @@ void BankManager::unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
|||||||
|
|
||||||
void BankManager::overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
void BankManager::overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
||||||
debug(9, "BankManager::overpack(%d, %d, %d)", srcframe, dstframe, bankslot);
|
debug(9, "BankManager::overpack(%d, %d, %d)", srcframe, dstframe, bankslot);
|
||||||
|
assert(bankslot < MAX_BANKS_NUMBER);
|
||||||
assert(_banks[bankslot].data != NULL);
|
assert(_banks[bankslot].data != NULL);
|
||||||
|
|
||||||
uint8 *p = _banks[bankslot].data + _banks[bankslot].indexes[srcframe];
|
uint8 *p = _banks[bankslot].data + _banks[bankslot].indexes[srcframe];
|
||||||
@ -97,8 +106,16 @@ void BankManager::overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot) {
|
|||||||
|
|
||||||
void BankManager::close(uint32 bankslot) {
|
void BankManager::close(uint32 bankslot) {
|
||||||
debug(9, "BankManager::close(%d)", bankslot);
|
debug(9, "BankManager::close(%d)", bankslot);
|
||||||
|
assert(bankslot < MAX_BANKS_NUMBER);
|
||||||
delete[] _banks[bankslot].data;
|
delete[] _banks[bankslot].data;
|
||||||
memset(&_banks[bankslot], 0, sizeof(_banks[bankslot]));
|
memset(&_banks[bankslot], 0, sizeof(PackedBank));
|
||||||
|
_loadedBanks[bankslot][0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void BankManager::flush() {
|
||||||
|
memset(_frames, 0, sizeof(_frames));
|
||||||
|
memset(_banks, 0, sizeof(_banks));
|
||||||
|
memset(_loadedBanks, 0, sizeof(_loadedBanks));
|
||||||
}
|
}
|
||||||
|
|
||||||
BobFrame *BankManager::fetchFrame(uint32 index) {
|
BobFrame *BankManager::fetchFrame(uint32 index) {
|
||||||
@ -122,7 +139,7 @@ void BankManager::eraseFrames(bool joe) {
|
|||||||
if (!joe) {
|
if (!joe) {
|
||||||
i = FRAMES_JOE + FRAMES_JOE_XTRA;
|
i = FRAMES_JOE + FRAMES_JOE_XTRA;
|
||||||
}
|
}
|
||||||
while (i < 256) {
|
while (i < MAX_FRAMES_NUMBER) {
|
||||||
eraseFrame(i);
|
eraseFrame(i);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
void unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
|
void unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
|
||||||
void overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
|
void overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
|
||||||
void close(uint32 bankslot);
|
void close(uint32 bankslot);
|
||||||
|
void flush();
|
||||||
|
|
||||||
BobFrame *fetchFrame(uint32 index);
|
BobFrame *fetchFrame(uint32 index);
|
||||||
void eraseFrame(uint32 index);
|
void eraseFrame(uint32 index);
|
||||||
@ -63,6 +64,9 @@ private:
|
|||||||
//! banked bob frames
|
//! banked bob frames
|
||||||
PackedBank _banks[MAX_BANKS_NUMBER];
|
PackedBank _banks[MAX_BANKS_NUMBER];
|
||||||
|
|
||||||
|
//! loaded banks names
|
||||||
|
char _loadedBanks[MAX_BANKS_NUMBER][20];
|
||||||
|
|
||||||
Resource *_res;
|
Resource *_res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -535,12 +535,7 @@ byte *Cutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (anim.bank != 13) {
|
if (anim.bank != 13) {
|
||||||
/* XXX if (OLDBANK != T) */ {
|
_vm->bankMan()->load(_bankNames[anim.bank-1], CUTAWAY_BANK);
|
||||||
//debug(6, "Loading bank '%s'", _bankNames[anim.bank-1]);
|
|
||||||
_vm->bankMan()->load(_bankNames[anim.bank-1], CUTAWAY_BANK);
|
|
||||||
// XXX OLDBANK=T;
|
|
||||||
}
|
|
||||||
|
|
||||||
anim.bank = 8;
|
anim.bank = 8;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1150,10 +1145,7 @@ void Cutaway::stop() {
|
|||||||
if (0 == bank)
|
if (0 == bank)
|
||||||
bank = 15;
|
bank = 15;
|
||||||
else if (bank != 13) {
|
else if (bank != 13) {
|
||||||
// XXX if(bank != oldBank) {
|
|
||||||
_vm->bankMan()->load(_bankNames[bank-1], CUTAWAY_BANK);
|
_vm->bankMan()->load(_bankNames[bank-1], CUTAWAY_BANK);
|
||||||
// XXX oldBank = bank;
|
|
||||||
// XXX }
|
|
||||||
bank = 8;
|
bank = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user