I'm doing it almost exactly like that in new Critter, although it is hidden in ScorePair enum with overloaded operators:mcostalba wrote:Yes you guessed right. It saves both mid game and end game score in a 32 bit integer with a 16 bit word for each score.bob wrote: I think I heard someone mention that it might keep the EG and MG scores combined, 16 bits per value, so that one is left shifted 16 bits.
At the end the combined score is splitted and the two values merged in the usual way to get the final score.
Code: Select all
enum ScorePair;
inline ScorePair pair(Score mg, Score eg) {
return ScorePair((mg << 16) + eg);
}
inline ScorePair pair(int mg, int eg) {
return ScorePair((mg << 16) + eg);
}
inline ScorePair operator+ (ScorePair s1, ScorePair s2) { return ScorePair(int(s1) + int(s2)); }
inline ScorePair operator- (ScorePair s1, ScorePair s2) { return ScorePair(int(s1) - int(s2)); }
// same with +=; -=; *=
Code: Select all
inline Score eg_value(ScorePair s) { return Score(short(s & 0xffff)); }
inline Score mg_value(ScorePair s) {
return Score(short(((s >> 16) & 0xffff)) + (short(eg_value(s)) < 0));
}