ADL: Implement hires6 action opcode 0x12

This commit is contained in:
Walter van Niftrik 2017-02-18 22:24:23 +01:00
parent dc04cd4434
commit 2e3e425d5b
4 changed files with 33 additions and 9 deletions

View File

@ -238,6 +238,11 @@ void AdlEngine_v4::loadRegionInitDataOffsets(Common::ReadStream &stream, uint re
}
}
void AdlEngine_v4::initRoomState(RoomState &roomState) const {
roomState.picture = 1;
roomState.isFirstTime = 1;
}
void AdlEngine_v4::initRegions(const byte *roomsPerRegion, uint regions) {
_state.regions.resize(regions);
@ -247,12 +252,8 @@ void AdlEngine_v4::initRegions(const byte *roomsPerRegion, uint regions) {
regn.vars.resize(24);
regn.rooms.resize(roomsPerRegion[r]);
for (uint rm = 0; rm < roomsPerRegion[r]; ++rm) {
// TODO: hires6 uses 0xff and has slightly different
// code working on these values
regn.rooms[rm].picture = 1;
regn.rooms[rm].isFirstTime = 1;
}
for (uint rm = 0; rm < roomsPerRegion[r]; ++rm)
initRoomState(regn.rooms[rm]);
}
}

View File

@ -81,7 +81,8 @@ protected:
void loadRegion(byte region);
void loadItemPicIndex(Common::ReadStream &stream, uint items);
void backupRoomState(byte room);
void restoreRoomState(byte room);
virtual void initRoomState(RoomState &roomState) const;
virtual void restoreRoomState(byte room);
void backupVars();
void restoreVars();

View File

@ -33,6 +33,22 @@ AdlEngine_v5::AdlEngine_v5(OSystem *syst, const AdlGameDescription *gd) :
AdlEngine_v4(syst, gd) {
}
void AdlEngine_v5::initRoomState(RoomState &roomState) const {
roomState.picture = 0xff;
roomState.isFirstTime = 0xff;
}
void AdlEngine_v5::restoreRoomState(byte room) {
const RoomState &backup = getCurRegion().rooms[room - 1];
if (backup.isFirstTime != 0xff) {
getRoom(room).curPicture = getRoom(room).picture = backup.picture;
if (backup.isFirstTime != 1)
getRoom(room).isFirstTime = false;
}
}
AdlEngine_v5::RegionChunkType AdlEngine_v5::getRegionChunkType(const uint16 addr) const {
switch (addr) {
case 0x7b00:
@ -181,8 +197,12 @@ int AdlEngine_v5::o5_setTextMode(ScriptEnv &e) {
int AdlEngine_v5::o5_setRegionRoom(ScriptEnv &e) {
OP_DEBUG_2("\tSET_REGION_ROOM(%d, %d)", e.arg(1), e.arg(2));
// TODO
return 2;
getCurRoom().curPicture = getCurRoom().picture;
getCurRoom().isFirstTime = false;
switchRegion(e.arg(1));
_state.room = e.arg(2);
restoreRoomState(_state.room);
return -1;
}
int AdlEngine_v5::o_winGame(ScriptEnv &e) {

View File

@ -39,6 +39,8 @@ protected:
// AdlEngine_v4
virtual RegionChunkType getRegionChunkType(const uint16 addr) const;
virtual void initRoomState(RoomState &roomState) const;
virtual void restoreRoomState(byte room);
int o5_isNounNotInRoom(ScriptEnv &e);
int o5_abortScript(ScriptEnv &e);