mirror of
https://github.com/DarkStore-3DS/Universal-Core.git
synced 2026-07-02 16:59:05 +00:00
Fix some sprite/image bugs
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ public:
|
||||
* @param x The X position
|
||||
* @param y The Y position
|
||||
*/
|
||||
void position(int x, int y) { _x = x, _y = y; if(_visibility) oamSetXY(_oam, _id, _x, _y); }
|
||||
void position(int x, int y);
|
||||
|
||||
/**
|
||||
* @brief Sets the priority of the sprite
|
||||
|
||||
+8
-4
@@ -111,6 +111,10 @@ void Image::load(const u8 *grf, u8 paletteStart) {
|
||||
} case 0x204C4150: { // 'PAL '
|
||||
_palette = std::vector<u16>((ptr[2] >> 8) / 2);
|
||||
decompressGrf(_palette.data(), ptr + 2);
|
||||
for(u16 &px : _palette) {
|
||||
if(px != 0x7C1F)
|
||||
px |= BIT(15);
|
||||
}
|
||||
break;
|
||||
} default: {
|
||||
// Not supported yet
|
||||
@@ -152,7 +156,7 @@ void Image::draw(int x, int y, float scaleX, float scaleY, bool skipAlpha) {
|
||||
u8 *src = _bitmap.data() + i * _width;
|
||||
u8 *dst = (u8 *)bgGetGfxPtr(currentScreen ? 3 : 7) + (y + i) * 256 + x;
|
||||
for(u32 j = 0; j < _width; j++) {
|
||||
if(_palette[src[j] - _paletteStart] != 0x7C1F)
|
||||
if(_palette[src[j] - _paletteStart] & 0x8000)
|
||||
toncset(dst + j, src[j], 1);
|
||||
}
|
||||
}
|
||||
@@ -167,7 +171,7 @@ void Image::draw(int x, int y, float scaleX, float scaleY, bool skipAlpha) {
|
||||
u8 *dst = (u8 *)bgGetGfxPtr(currentScreen ? 3 : 7) + (y + i) * 256 + x;
|
||||
for(u32 j = 0; j < _width * scaleX; j++) {
|
||||
u8 px = _bitmap[int(i / scaleY) * _width + int(j / scaleX)];
|
||||
if(_palette[px - _paletteStart] != 0x7C1F || !skipAlpha)
|
||||
if(_palette[px - _paletteStart] & 0x8000 || !skipAlpha)
|
||||
toncset(dst + j, px, 1);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +189,7 @@ void Image::drawSegment(int x, int y, int imageX, int imageY, int w, int h, floa
|
||||
u8 *src = _bitmap.data() + i * _width;
|
||||
u8 *dst = (u8 *)bgGetGfxPtr(currentScreen ? 3 : 7) + (y + i) * 256 + x;
|
||||
for(int j = 0; j < w; j++) {
|
||||
if(_palette[src[j] - _paletteStart] != 0x7C1F)
|
||||
if(_palette[src[j] - _paletteStart] & 0x8000)
|
||||
toncset(dst + j, src[j], 1);
|
||||
}
|
||||
}
|
||||
@@ -200,7 +204,7 @@ void Image::drawSegment(int x, int y, int imageX, int imageY, int w, int h, floa
|
||||
u8 *dst = (u8 *)bgGetGfxPtr(currentScreen ? 3 : 7) + (y + i) * 256 + x;
|
||||
for(u32 j = 0; j < w * scaleX; j++) {
|
||||
u8 px = _bitmap[(imageY + int(i / scaleY)) * _width + imageX + int(j / scaleX)];
|
||||
if(_palette[px - _paletteStart] != 0x7C1F || !skipAlpha)
|
||||
if(_palette[px - _paletteStart] & 0x8000 || !skipAlpha)
|
||||
toncset(dst + j, px, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "sprite.hpp"
|
||||
|
||||
#include "gui.hpp"
|
||||
#include "tonccpy.h"
|
||||
|
||||
u8 Sprite::_assigned[2][128] = {{false}, {false}};
|
||||
@@ -34,6 +35,9 @@ Sprite::Sprite(bool top, SpriteSize size, SpriteColorFormat format, int x, int y
|
||||
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),
|
||||
_id(id), _rotationIndex(rotationIndex), _paletteAlpha(paletteAlpha), _visibility(visible) {
|
||||
SCALE_3DS(_x);
|
||||
SCALE_3DS(_y);
|
||||
|
||||
// If the ID is -1, set it to the first free one
|
||||
if(_id == -1) {
|
||||
for(uint i = 0; i < sizeof(_assigned[_top]) / sizeof(_assigned[_top][0]); i++) {
|
||||
@@ -139,6 +143,17 @@ Sprite::~Sprite(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::position(int x, int y) {
|
||||
SCALE_3DS(x);
|
||||
SCALE_3DS(y);
|
||||
|
||||
_x = x;
|
||||
_y = y;
|
||||
|
||||
if(_visibility)
|
||||
oamSetXY(_oam, _id, _x, _y);
|
||||
}
|
||||
|
||||
void Sprite::rotation(int rotation) {
|
||||
_rotation = rotation;
|
||||
if(_rotationIndex != -1)
|
||||
|
||||
@@ -54,7 +54,6 @@ Spritesheet::Spritesheet(const std::vector<std::string> &paths, const std::vecto
|
||||
_images.resize(imageCount);
|
||||
|
||||
for(u32 i = 0; i < imageCount; i++) {
|
||||
nocashMessage(std::to_string(std::find(indexes.begin(), indexes.end(), i) - indexes.begin()).c_str());
|
||||
if(indexes.size() == 0 || std::find(indexes.begin(), indexes.end(), i) != indexes.end()) {
|
||||
fseek(file, 0x10 + i * 8, SEEK_SET);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user