TWINE: started to implement holomap location loading

This commit is contained in:
Martin Gerhardy 2020-11-02 23:23:41 +01:00
parent a7f3a63454
commit d66db9ad12
2 changed files with 40 additions and 0 deletions

View File

@ -21,7 +21,9 @@
*/
#include "twine/holomap.h"
#include "common/memstream.h"
#include "twine/gamestate.h"
#include "twine/hqr.h"
#include "twine/interface.h"
#include "twine/renderer.h"
#include "twine/resources.h"
@ -35,6 +37,30 @@ namespace TwinE {
Holomap::Holomap(TwinEEngine *engine) : _engine(engine) {}
bool Holomap::loadLocations() {
uint8 *locationsPtr;
const int32 locationsSize = HQR::getAllocEntry(&locationsPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWINFO);
if (locationsSize == 0) {
warning("Could not find holomap locations at index %i in %s", RESSHQR_HOLOARROWINFO, Resources::HQR_RESS_FILE);
return false;
}
Common::MemoryReadStream stream(locationsPtr, locationsSize);
_numLocations = locationsSize / sizeof(Location);
if (_numLocations > NUM_LOCATIONS) {
warning("Amount of locations (%i) exceeds the maximum of %i", _numLocations, NUM_LOCATIONS);
return false;
}
for (int i = 0; i < _numLocations; i++) {
_locations[i].x = stream.readUint16LE();
_locations[i].y = stream.readUint16LE();
_locations[i].z = stream.readUint16LE();
_locations[i].textIndex = stream.readUint16LE();
}
return true;
}
void Holomap::setHolomapPosition(int32 locationIdx) {
assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->holomapFlags));
_engine->_gameState->holomapFlags[locationIdx] = 0x81;

View File

@ -28,12 +28,24 @@
namespace TwinE {
#define NUM_LOCATIONS 150
class TwinEEngine;
class Holomap {
private:
TwinEEngine *_engine;
struct Location {
uint16 x = 0;
uint16 y = 0;
uint16 z = 0;
uint16 textIndex = 0;
};
int32 _numLocations = 0;
Location _locations[NUM_LOCATIONS];
int32 needToLoadHolomapGFX = 0;
uint8 paletteHolomap[NUMOFCOLORS * 3]{0};
@ -46,6 +58,8 @@ public:
*/
void setHolomapPosition(int32 locationIdx);
bool loadLocations();
/**
* Clear Holomap location position
* @param locationIdx Scene where position must be cleared