mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 21:21:05 +00:00
SAGA2: Move global variables in beegee.cpp to Deejay class
This commit is contained in:
parent
00eab347c1
commit
db33d0ccac
@ -3557,8 +3557,8 @@ void cleanupActors(void) {
|
||||
|
||||
int16 AddFactionTally(int faction, enum factionTallyTypes act, int amt) {
|
||||
#if DEBUG
|
||||
if (faction >= maxFactions)
|
||||
error("Scripter: Tell Talin to increase maxFactions!\n");
|
||||
if (faction >= kMaxFactions)
|
||||
error("Scripter: Tell Talin to increase kMaxFactions!\n");
|
||||
assert(faction >= 0);
|
||||
assert(act >= 0);
|
||||
assert(act < factionNumColumns);
|
||||
@ -3588,8 +3588,8 @@ int16 AddFactionTally(int faction, enum factionTallyTypes act, int amt) {
|
||||
// Get the attitude a particular faction has for a char.
|
||||
int16 GetFactionTally(int faction, enum factionTallyTypes act) {
|
||||
#if DEBUG
|
||||
if (faction >= maxFactions)
|
||||
error("Scripter: Tell Talin to increase maxFactions!\n");
|
||||
if (faction >= kMaxFactions)
|
||||
error("Scripter: Tell Talin to increase kMaxFactions!\n");
|
||||
assert(faction >= 0);
|
||||
assert(act >= 0);
|
||||
assert(act < factionNumColumns);
|
||||
@ -3610,7 +3610,7 @@ void saveFactionTallies(Common::OutSaveFile *outS) {
|
||||
|
||||
outS->write("FACT", 4);
|
||||
CHUNK_BEGIN;
|
||||
for (int i = 0; i < maxFactions; ++i) {
|
||||
for (int i = 0; i < kMaxFactions; ++i) {
|
||||
for (int j = 0; j < factionNumColumns; ++j)
|
||||
out->writeSint16LE(g_vm->_act->_factionTable[i][j]);
|
||||
}
|
||||
@ -3620,7 +3620,7 @@ void saveFactionTallies(Common::OutSaveFile *outS) {
|
||||
void loadFactionTallies(Common::InSaveFile *in) {
|
||||
debugC(2, kDebugSaveload, "Loading Faction Tallies");
|
||||
|
||||
for (int i = 0; i < maxFactions; ++i) {
|
||||
for (int i = 0; i < kMaxFactions; ++i) {
|
||||
for (int j = 0; j < factionNumColumns; ++j)
|
||||
g_vm->_act->_factionTable[i][j] = in->readSint16LE();
|
||||
}
|
||||
|
@ -1097,9 +1097,6 @@ void addEnchantment(Actor *a, uint16 enchantmentID);
|
||||
Actor factions table
|
||||
* ============================================================================ */
|
||||
|
||||
// Let's assume 64 factions maximum for now
|
||||
const int maxFactions = 64;
|
||||
|
||||
enum factionTallyTypes {
|
||||
factionNumKills = 0, // # of times faction member killed by PC
|
||||
factionNumThefts, // # of times PC steals from faction member
|
||||
@ -1142,7 +1139,7 @@ public:
|
||||
|
||||
int32 _updatesViaScript;
|
||||
int32 _baseActorIndex;
|
||||
int16 _factionTable[maxFactions][factionNumColumns];
|
||||
int16 _factionTable[kMaxFactions][factionNumColumns];
|
||||
bool _actorStatesPaused;
|
||||
bool _combatBehaviorEnabled;
|
||||
|
||||
|
@ -35,19 +35,6 @@ namespace Saga2 {
|
||||
#define AUXTHEMES 2
|
||||
#define USEAUXTHEME 0xe0
|
||||
|
||||
struct auxAudioTheme {
|
||||
bool active;
|
||||
StaticLocation l;
|
||||
uint32 loopID;
|
||||
};
|
||||
|
||||
static const StaticTilePoint NullTile = {(int16)minint16, (int16)minint16, (int16)minint16};
|
||||
|
||||
static auxAudioTheme aats[AUXTHEMES] = {
|
||||
{false, {NullTile, 0}, 0},
|
||||
{false, {NullTile, 0}, 0}
|
||||
};
|
||||
|
||||
void addAuxTheme(Location loc, uint32 lid);
|
||||
void killAuxTheme(uint32 lid);
|
||||
void killAllAuxThemes(void);
|
||||
@ -138,45 +125,6 @@ extern GameObject *getViewCenterObject(void);
|
||||
extern bool debugAudioThemes;
|
||||
#endif
|
||||
|
||||
/* ===================================================================== *
|
||||
Locals
|
||||
* ===================================================================== */
|
||||
|
||||
static uint32 currentTheme = 0;
|
||||
static uint32 auxTheme = 0;
|
||||
static StaticPoint32 themeAt = {0, 0};
|
||||
|
||||
static int32 lastGameTime = 0;
|
||||
static int32 elapsedGameTime = 0;
|
||||
|
||||
static bool playingExternalLoop = false;
|
||||
|
||||
int activeFactions[maxFactions];
|
||||
|
||||
|
||||
static StaticTilePoint themeVectors[kMaxThemes] = {
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int16 themeCount[kMaxThemes];
|
||||
|
||||
/* ===================================================================== *
|
||||
Prototypes
|
||||
* ===================================================================== */
|
||||
@ -210,10 +158,10 @@ void initAudioEnvirons(void) {
|
||||
|
||||
void addAuxTheme(Location loc, uint32 lid) {
|
||||
for (int i = 0; i < AUXTHEMES; i++) {
|
||||
if (!aats[i].active) {
|
||||
aats[i].l.set(loc, loc.context);
|
||||
aats[i].loopID = lid;
|
||||
aats[i].active = true;
|
||||
if (!g_vm->_grandMasterFTA->_aats[i].active) {
|
||||
g_vm->_grandMasterFTA->_aats[i].l = loc;
|
||||
g_vm->_grandMasterFTA->_aats[i].loopID = lid;
|
||||
g_vm->_grandMasterFTA->_aats[i].active = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -221,15 +169,15 @@ void addAuxTheme(Location loc, uint32 lid) {
|
||||
|
||||
void killAuxTheme(uint32 lid) {
|
||||
for (int i = 0; i < AUXTHEMES; i++) {
|
||||
if (aats[i].active && aats[i].loopID == lid) {
|
||||
aats[i].active = false;
|
||||
if (g_vm->_grandMasterFTA->_aats[i].active && g_vm->_grandMasterFTA->_aats[i].loopID == lid) {
|
||||
g_vm->_grandMasterFTA->_aats[i].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void killAllAuxThemes(void) {
|
||||
for (int i = 0; i < AUXTHEMES; i++) {
|
||||
aats[i].active = false;
|
||||
g_vm->_grandMasterFTA->_aats[i].active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,24 +185,23 @@ void killAllAuxThemes(void) {
|
||||
// Hooks to allow other loops to play
|
||||
|
||||
void disableBGLoop(bool s) {
|
||||
playingExternalLoop = s;
|
||||
g_vm->_grandMasterFTA->_playingExternalLoop = s;
|
||||
}
|
||||
|
||||
void enableBGLoop(void) {
|
||||
uint32 cr = currentTheme;
|
||||
playingExternalLoop = false;
|
||||
currentTheme = 0;
|
||||
audioEnvironmentUseSet(cr, auxTheme, themeAt);
|
||||
uint32 cr = g_vm->_grandMasterFTA->_currentTheme;
|
||||
g_vm->_grandMasterFTA->_playingExternalLoop = false;
|
||||
g_vm->_grandMasterFTA->_currentTheme = 0;
|
||||
audioEnvironmentUseSet(cr, g_vm->_grandMasterFTA->_auxTheme, g_vm->_grandMasterFTA->_themeAt);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Main loop selection routine - called from Tile.cpp
|
||||
|
||||
static int32 pct = 0;
|
||||
void setAreaSound(const TilePoint &) {
|
||||
pct = (pct + 1) % 8;
|
||||
if (pct == 0) {
|
||||
if (!playingExternalLoop) {
|
||||
g_vm->_grandMasterFTA->_pct = (g_vm->_grandMasterFTA->_pct + 1) % 8;
|
||||
if (g_vm->_grandMasterFTA->_pct == 0) {
|
||||
if (!g_vm->_grandMasterFTA->_playingExternalLoop) {
|
||||
TilePoint baseCoords = centerActorCoords() >> kTileUVShift;
|
||||
TilePoint mtPos;
|
||||
metaTileNoise loopID = 0;
|
||||
@ -274,16 +221,11 @@ void setAreaSound(const TilePoint &) {
|
||||
themePos.x = dist.u;
|
||||
themePos.y = dist.v;
|
||||
MetaTilePtr mt = mIter.first(&mtPos);
|
||||
for (i = 0; i < 16; i++) {
|
||||
themeVectors[i].set(0, 0, 0);
|
||||
}
|
||||
while (mt) {
|
||||
i++;
|
||||
if (getSound(mt)) {
|
||||
j++;
|
||||
TilePoint thisDist = mtPos - baseCoords;
|
||||
int theme = getSound(mt);
|
||||
themeCount[theme]++;
|
||||
if (thisDist.magnitude() < dist.magnitude()) {
|
||||
dist = thisDist;
|
||||
loopID = getSound(mt);
|
||||
@ -294,14 +236,14 @@ void setAreaSound(const TilePoint &) {
|
||||
mt = mIter.next(&mtPos);
|
||||
}
|
||||
for (i = 0; i < AUXTHEMES; i++) {
|
||||
if (aats[i].active) {
|
||||
if (g_vm->_grandMasterFTA->_aats[i].active) {
|
||||
Location loc = getCenterActor()->notGetWorldLocation();
|
||||
if (aats[i].l.context == Nothing || loc.context == aats[i].l.context) {
|
||||
TilePoint tp = (aats[i].l.tile >> kTileUVShift) - baseCoords;
|
||||
if (g_vm->_grandMasterFTA->_aats[i].l.context == Nothing || loc.context == g_vm->_grandMasterFTA->_aats[i].l.context) {
|
||||
TilePoint tp = (g_vm->_grandMasterFTA->_aats[i].l >> kTileUVShift) - baseCoords;
|
||||
if (tp.magnitude() < dist.magnitude()) {
|
||||
dist = tp;
|
||||
loopID = USEAUXTHEME;
|
||||
ss = aats[i].loopID;
|
||||
ss = g_vm->_grandMasterFTA->_aats[i].loopID;
|
||||
themePos.x = tp.u;
|
||||
themePos.y = tp.v;
|
||||
}
|
||||
@ -313,8 +255,8 @@ void setAreaSound(const TilePoint &) {
|
||||
loopID = 0;
|
||||
}
|
||||
audioEnvironmentUseSet(loopID, ss, themePos << kPlatShift);
|
||||
} else if (playingExternalLoop) {
|
||||
audioEnvironmentUseSet(playingExternalLoop, 0, Point16(0, 0)); //themePos << kPlatShift);
|
||||
} else if (g_vm->_grandMasterFTA->_playingExternalLoop) {
|
||||
audioEnvironmentUseSet(g_vm->_grandMasterFTA->_playingExternalLoop, 0, Point16(0, 0)); //themePos << kPlatShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,24 +272,24 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
|
||||
res = metaNoiseID(audioSet);
|
||||
else
|
||||
res = 0;
|
||||
if (currentTheme != (uint16)audioSet || auxTheme != (uint32)auxID) {
|
||||
currentTheme = audioSet;
|
||||
auxTheme = auxID;
|
||||
themeAt.x = relPos.x;
|
||||
themeAt.y = relPos.y;
|
||||
if (g_vm->_grandMasterFTA->_currentTheme != (uint16)audioSet || g_vm->_grandMasterFTA->_auxTheme != (uint32)auxID) {
|
||||
g_vm->_grandMasterFTA->_currentTheme = audioSet;
|
||||
g_vm->_grandMasterFTA->_auxTheme = auxID;
|
||||
g_vm->_grandMasterFTA->_themeAt.x = relPos.x;
|
||||
g_vm->_grandMasterFTA->_themeAt.y = relPos.y;
|
||||
_playLoop(0);
|
||||
if (currentTheme)
|
||||
playLoopAt(res, themeAt);
|
||||
if (g_vm->_grandMasterFTA->_currentTheme)
|
||||
playLoopAt(res, g_vm->_grandMasterFTA->_themeAt);
|
||||
|
||||
} else if (currentTheme && themeAt != relPos) {
|
||||
} else if (g_vm->_grandMasterFTA->_currentTheme && g_vm->_grandMasterFTA->_themeAt != relPos) {
|
||||
#if DEBUG
|
||||
if (debugAudioThemes) {
|
||||
WriteStatusF(9, "Thm: %2.2d (%d,%d) was (%d,%d) ", audioSet, relPos.x, relPos.y, themeAt.x, themeAt.y);
|
||||
WriteStatusF(9, "Thm: %2.2d (%d,%d) was (%d,%d) ", audioSet, relPos.x, relPos.y, g_vm->_grandMasterFTA->_themeAt.x, g_vm->_grandMasterFTA->_themeAt.y);
|
||||
}
|
||||
#endif
|
||||
themeAt.x = relPos.x;
|
||||
themeAt.y = relPos.y;
|
||||
moveLoop(themeAt);
|
||||
g_vm->_grandMasterFTA->_themeAt.x = relPos.x;
|
||||
g_vm->_grandMasterFTA->_themeAt.y = relPos.y;
|
||||
moveLoop(g_vm->_grandMasterFTA->_themeAt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,14 +298,14 @@ void audioEnvironmentUseSet(int16 audioSet, int32 auxID, Point32 relPos) {
|
||||
|
||||
void audioEnvironmentCheck(void) {
|
||||
|
||||
uint32 delta = gameTime - lastGameTime;
|
||||
lastGameTime = gameTime;
|
||||
if (currentTheme > 0 && currentTheme <= kAudioTerrainLIMIT) {
|
||||
elapsedGameTime += delta;
|
||||
if (elapsedGameTime > kCheckGameTime) {
|
||||
uint32 delta = gameTime - g_vm->_grandMasterFTA->_lastGameTime;
|
||||
g_vm->_grandMasterFTA->_lastGameTime = gameTime;
|
||||
if (g_vm->_grandMasterFTA->_currentTheme > 0 && g_vm->_grandMasterFTA->_currentTheme <= kAudioTerrainLIMIT) {
|
||||
g_vm->_grandMasterFTA->_elapsedGameTime += delta;
|
||||
if (g_vm->_grandMasterFTA->_elapsedGameTime > kCheckGameTime) {
|
||||
int i;
|
||||
elapsedGameTime = 0;
|
||||
const IntermittentAudioRecord &iar = intermittentAudioRecords[currentTheme];
|
||||
g_vm->_grandMasterFTA->_elapsedGameTime = 0;
|
||||
const IntermittentAudioRecord &iar = intermittentAudioRecords[g_vm->_grandMasterFTA->_currentTheme];
|
||||
int16 totalProb = iar.noSoundOdds;
|
||||
for (i = 0; i < 4; i++)
|
||||
totalProb += iar.soundOdds[i];
|
||||
@ -376,17 +318,17 @@ void audioEnvironmentCheck(void) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (pval < iar.soundOdds[i]) {
|
||||
//GameObject *go=getViewCenterObject();
|
||||
//Location cal=Location(TilePoint(themeAt.x,themeAt.y,0),go->IDParent());
|
||||
//playSound(metaNoiseID((currentTheme*10)+i));
|
||||
playSoundAt(metaNoiseID((currentTheme * 10) + i), themeAt);
|
||||
//Location cal=Location(TilePoint(g_vm->_grandMasterFTA->_themeAt.x,g_vm->_grandMasterFTA->_themeAt.y,0),go->IDParent());
|
||||
//playSound(metaNoiseID((g_vm->_grandMasterFTA->_currentTheme*10)+i));
|
||||
playSoundAt(metaNoiseID((g_vm->_grandMasterFTA->_currentTheme * 10) + i), g_vm->_grandMasterFTA->_themeAt);
|
||||
return;
|
||||
} else
|
||||
pval -= iar.soundOdds[i];
|
||||
}
|
||||
|
||||
}
|
||||
} else if (currentTheme)
|
||||
warning("currentTheme out of range: %d", currentTheme);
|
||||
} else if (g_vm->_grandMasterFTA->_currentTheme)
|
||||
warning("currentTheme out of range: %d", g_vm->_grandMasterFTA->_currentTheme);
|
||||
|
||||
}
|
||||
|
||||
@ -440,20 +382,20 @@ void Deejay::select(void) {
|
||||
// Faction enumeration routines
|
||||
|
||||
void clearActiveFactions(void) {
|
||||
for (int i = 0; i < maxFactions; i++)
|
||||
activeFactions[i] = 0;
|
||||
for (int i = 0; i < kMaxFactions; i++)
|
||||
g_vm->_grandMasterFTA->_activeFactions[i] = 0;
|
||||
}
|
||||
|
||||
void incrementActiveFaction(Actor *a) {
|
||||
activeFactions[a->_faction]++;
|
||||
g_vm->_grandMasterFTA->_activeFactions[a->_faction]++;
|
||||
}
|
||||
|
||||
void useActiveFactions(void) {
|
||||
int highCount = 0;
|
||||
int highFaction = 0;
|
||||
for (int i = 0; i < maxFactions; i++) {
|
||||
if (activeFactions[i] > highCount) {
|
||||
highCount = activeFactions[i];
|
||||
for (int i = 0; i < kMaxFactions; i++) {
|
||||
if (g_vm->_grandMasterFTA->_activeFactions[i] > highCount) {
|
||||
highCount = g_vm->_grandMasterFTA->_activeFactions[i];
|
||||
highFaction = i;
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,13 @@
|
||||
#ifndef SAGA2_BEEGEE_H
|
||||
#define SAGA2_BEEGEE_H
|
||||
|
||||
#include "saga2/objproto.h"
|
||||
|
||||
namespace Saga2 {
|
||||
|
||||
enum {
|
||||
kNoEnemy = -1,
|
||||
kAuxThemes = 2,
|
||||
kMaxThemes = 16
|
||||
};
|
||||
|
||||
@ -41,6 +44,18 @@ enum {
|
||||
//-----------------------------------------------------------------------
|
||||
// Music selection brain
|
||||
|
||||
struct AuxAudioTheme {
|
||||
bool active;
|
||||
Location l;
|
||||
uint32 loopID;
|
||||
|
||||
AuxAudioTheme() {
|
||||
active = false;
|
||||
loopID = 0;
|
||||
l = Nowhere;
|
||||
}
|
||||
};
|
||||
|
||||
class Deejay {
|
||||
private:
|
||||
int _enemy;
|
||||
@ -51,8 +66,23 @@ private:
|
||||
|
||||
int _current;
|
||||
int _currentID;
|
||||
|
||||
public:
|
||||
|
||||
uint32 _currentTheme;
|
||||
uint32 _auxTheme;
|
||||
Point32 _themeAt;
|
||||
|
||||
int32 _lastGameTime;
|
||||
int32 _elapsedGameTime;
|
||||
|
||||
int32 _pct;
|
||||
|
||||
bool _playingExternalLoop;
|
||||
|
||||
int _activeFactions[kMaxFactions];
|
||||
|
||||
AuxAudioTheme _aats[kAuxThemes];
|
||||
|
||||
Deejay() {
|
||||
_enemy = -1;
|
||||
_aggr = false;
|
||||
@ -61,6 +91,14 @@ public:
|
||||
_ugd = false;
|
||||
_current = 0;
|
||||
_currentID = 0;
|
||||
|
||||
_currentTheme = 0;
|
||||
_auxTheme = 0;
|
||||
_lastGameTime = 0;
|
||||
_elapsedGameTime = 0;
|
||||
_pct = 0;
|
||||
_playingExternalLoop = false;
|
||||
memset(_activeFactions, 0, sizeof(_activeFactions));
|
||||
}
|
||||
~Deejay() {}
|
||||
|
||||
|
@ -468,6 +468,11 @@ enum {
|
||||
kDefaultReach = 24
|
||||
};
|
||||
|
||||
// Actor Constants
|
||||
enum {
|
||||
kMaxFactions = 64
|
||||
};
|
||||
|
||||
} // end of namespace Saga2
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user