IMMORTAL: addSprite() moved out of utilities

This commit is contained in:
Quote58 2022-09-22 03:23:32 -04:00 committed by Eugene Sandulenko
parent 0467dbdb78
commit a2bd437c5e
2 changed files with 11 additions and 32 deletions

View File

@ -23,6 +23,14 @@
namespace Immortal {
/*
*
* ----- -----
* ----- General Use -----
* ----- -----
*
*/
void Utilities::delay(int j) { // Delay is measured in jiffies, which are 56.17ms
g_system->delayMillis(j * 56);
}
@ -98,35 +106,4 @@ bool Utilities::insideRect(uint8 rectX, uint8 rectY, uint8 w, uint8 h, uint8 poi
return false;
}
void Utilities::addSprite(Sprite *sprites, uint16 vpX, uint16 vpY, int *num, DataSprite *d, int img, uint16 x, uint16 y, uint16 p) {
debug("adding sprite...");
if (*num != kMaxSprites) {
if (x >= (kResH + kMaxSpriteLeft)) {
x |= kMaskHigh; // Make it negative
}
sprites[*num]._X = (x << 1) + vpX;
if (y >= (kMaxSpriteAbove + kResV)) {
y |= kMaskHigh;
}
sprites[*num]._Y = (y << 1) + vpY;
if (p >= 0x80) {
p |= kMaskHigh;
}
sprites[*num]._priority = ((p + y) ^ 0xFFFF) + 1;
sprites[*num]._image = img;
sprites[*num]._dSprite = d;
sprites[*num]._on = 1;
*num += 1;
debug("sprite added");
} else {
debug("Max sprites reached beeeeeep!!");
}
}
}; // namespace Immortal

View File

@ -25,7 +25,9 @@
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/system.h"
#include "immortal/sprite_list.h"
#include "immortal/definitions.h"
namespace Immortal {
@ -75,12 +77,12 @@ enum Screen { // These are constants t
namespace Utilities {
// Other
void delay(int j); // Delay engine by j jiffies (from driver originally, but makes more sense grouped with misc)
void delay4(int j); // || /4
void delay8(int j); // || /8
bool inside(uint8 dist, uint8 centX, uint8 centY, uint8 pointX, uint8 pointY);
bool insideRect(uint8 rectX, uint8 rectY, uint8 w, uint8 h, uint8 pointX, uint8 pointY);
void addSprite(Sprite *sprites, uint16 vpX, uint16 vpY, int *num, DataSprite *d, int img, uint16 x, uint16 y, uint16 p);
}; // namespace Util