mirror of
https://github.com/DarkStore-3DS/Universal-Core.git
synced 2026-07-06 00:39:18 +00:00
Couple more sprite fixes
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ private:
|
|||||||
bool _visibility;
|
bool _visibility;
|
||||||
u16 *_gfx;
|
u16 *_gfx;
|
||||||
|
|
||||||
static bool _assigned[2][127];
|
static bool _assigned[2][128];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|||||||
+10
-9
@@ -28,23 +28,24 @@
|
|||||||
|
|
||||||
#include "tonccpy.h"
|
#include "tonccpy.h"
|
||||||
|
|
||||||
bool Sprite::_assigned[2][127];
|
bool Sprite::_assigned[2][128] = {{false}, {false}};
|
||||||
|
|
||||||
Sprite::Sprite(bool top, SpriteSize size, SpriteColorFormat format, int x, int y, int priority, int id,
|
Sprite::Sprite(bool top, SpriteSize size, SpriteColorFormat format, int x, int y, int priority, int id,
|
||||||
int paletteAlpha, int rotationIndex, bool doubleSize, bool visible, bool vFlip, bool hFlip, bool mosaic)
|
int paletteAlpha, int rotationIndex, bool doubleSize, bool visible, bool vFlip, bool hFlip, bool mosaic)
|
||||||
: _top(top), _oam(top ? &oamMain : &oamSub), _size(size), _format(format), _x(x), _y(y), _priority(priority),
|
: _top(top), _oam(top ? &oamMain : &oamSub), _size(size), _format(format), _x(x), _y(y), _priority(priority),
|
||||||
_id(id), _rotationIndex(rotationIndex), _paletteAlpha(paletteAlpha) {
|
_id(id), _rotationIndex(rotationIndex), _paletteAlpha(paletteAlpha), _visibility(visible) {
|
||||||
// If the ID is -1, set it to the first free one
|
// If the ID is -1, set it to the first free one
|
||||||
if(_id == -1) {
|
if(_id == -1) {
|
||||||
for(uint i = 0; i < sizeof(_assigned[top]) / sizeof(_assigned[top][0]); i++) {
|
for(uint i = 0; i < sizeof(_assigned[_top]) / sizeof(_assigned[_top][0]); i++) {
|
||||||
if(!_assigned[top][i]) {
|
if(!_assigned[_top][i]) {
|
||||||
_assigned[top][i] = true;
|
_id = i;
|
||||||
_id = i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_assigned[top][_id] = true;
|
||||||
|
|
||||||
// Get the sprite width and height from the SpriteSize
|
// Get the sprite width and height from the SpriteSize
|
||||||
if(((_size >> 12) & 3) == OBJSHAPE_SQUARE) {
|
if(((_size >> 12) & 3) == OBJSHAPE_SQUARE) {
|
||||||
_width = 8 << ((_size >> 14) & 3);
|
_width = 8 << ((_size >> 14) & 3);
|
||||||
@@ -93,7 +94,7 @@ Sprite::Sprite(bool top, SpriteSize size, SpriteColorFormat format, int x, int y
|
|||||||
_gfx = oamAllocateGfx(_oam, _size, _format);
|
_gfx = oamAllocateGfx(_oam, _size, _format);
|
||||||
|
|
||||||
// Set sprite
|
// Set sprite
|
||||||
oamSet(_oam, _id, _x, _y, _priority, _paletteAlpha, _size, _format, _gfx, _rotationIndex, doubleSize, !visible,
|
oamSet(_oam, _id, _x, _y, _priority, _paletteAlpha, _size, _format, _gfx, _rotationIndex, doubleSize, !_visibility,
|
||||||
vFlip, hFlip, mosaic);
|
vFlip, hFlip, mosaic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ void Sprite::drawImageSegment(int x, int y, int imageX, int imageY, int w, int h
|
|||||||
if(scaleX == 1.0f && scaleY == 1.0f) {
|
if(scaleX == 1.0f && scaleY == 1.0f) {
|
||||||
for(int i = 0; i < h; i++) {
|
for(int i = 0; i < h; i++) {
|
||||||
for(int j = 0; j < w; j++) {
|
for(int j = 0; j < w; j++) {
|
||||||
u16 px = image.palette()[image.bitmap()[i * image.width() + j] - image.palOfs()];
|
u16 px = image.palette()[image.bitmap()[(imageY + i) * image.width() + imageX + j] - image.palOfs()];
|
||||||
if(px & 0x8000)
|
if(px & 0x8000)
|
||||||
toncset16(_gfx + ((y + i) * _height + x + j), px, 1);
|
toncset16(_gfx + ((y + i) * _height + x + j), px, 1);
|
||||||
}
|
}
|
||||||
@@ -173,7 +174,7 @@ void Sprite::drawImageSegment(int x, int y, int imageX, int imageY, int w, int h
|
|||||||
} else {
|
} else {
|
||||||
for(float i = 0; i < h; i += 1 / scaleX) {
|
for(float i = 0; i < h; i += 1 / scaleX) {
|
||||||
for(float j = 0; j < image.width(); j += 1 / scaleY) {
|
for(float j = 0; j < image.width(); j += 1 / scaleY) {
|
||||||
u16 px = image.palette()[image.bitmap()[i * image.width() + j] - image.palOfs()];
|
u16 px = image.palette()[image.bitmap()[(imageY + i) * image.width() + imageX + j] - image.palOfs()];
|
||||||
if(px & 0x8000)
|
if(px & 0x8000)
|
||||||
toncset16(_gfx + int((y + i) * _height + x + j), px, 1);
|
toncset16(_gfx + int((y + i) * _height + x + j), px, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user