Couple tweaks to Image

This commit is contained in:
Pk11
2021-08-26 21:01:59 -05:00
parent 4f6a0c579d
commit 118c9cc93d
2 changed files with 7 additions and 8 deletions
+2 -3
View File
@@ -72,13 +72,12 @@ public:
const std::vector<u8> &bitmap(void) const { return _bitmap; } const std::vector<u8> &bitmap(void) const { return _bitmap; }
const std::vector<u16> &palette(void) const { return _palette; } const std::vector<u16> &palette(void) const { return _palette; }
void changePaletteStart(u8 paletteStart); void paletteStart(u8 paletteStart);
/** /**
* @brief Copies the palette into VRAM * @brief Copies the palette into VRAM
* @param paletteStart Where to start the palette in VRAM
*/ */
void copyPalette(int paletteStart); void copyPalette(void);
/** /**
* @brief Draws the image to a background layer, slower but can skip alpha, scale, and offset the palette * @brief Draws the image to a background layer, slower but can skip alpha, scale, and offset the palette
+5 -5
View File
@@ -88,7 +88,7 @@ Image::Image(const u8 *grf, u8 paletteStart) {
load(grf, paletteStart); load(grf, paletteStart);
} }
void Image::load(const u8 *grf, u8 paletteStart) { void Image::load(const u8 *grf, u8 paletteStartLoc) {
const u32 *ptr = (u32 *)grf; const u32 *ptr = (u32 *)grf;
if(!ptr || ptr[0] != 0x46464952 || ptr[2] != 0x20465247) { if(!ptr || ptr[0] != 0x46464952 || ptr[2] != 0x20465247) {
return; return;
@@ -106,7 +106,7 @@ void Image::load(const u8 *grf, u8 paletteStart) {
} case 0x20584647: { // 'GFX ' } case 0x20584647: { // 'GFX '
_bitmap = std::vector<u8>(ptr[2] >> 8); _bitmap = std::vector<u8>(ptr[2] >> 8);
decompressGrf(_bitmap.data(), ptr + 2); decompressGrf(_bitmap.data(), ptr + 2);
changePaletteStart(paletteStart); paletteStart(paletteStartLoc);
break; break;
} case 0x204C4150: { // 'PAL ' } case 0x204C4150: { // 'PAL '
_palette = std::vector<u16>((ptr[2] >> 8) / 2); _palette = std::vector<u16>((ptr[2] >> 8) / 2);
@@ -126,7 +126,7 @@ void Image::load(const u8 *grf, u8 paletteStart) {
} }
} }
void Image::changePaletteStart(u8 paletteStart) { void Image::paletteStart(u8 paletteStart) {
int moveBy = paletteStart - _paletteStart; int moveBy = paletteStart - _paletteStart;
if(moveBy != 0) { if(moveBy != 0) {
@@ -138,8 +138,8 @@ void Image::changePaletteStart(u8 paletteStart) {
} }
} }
void Image::copyPalette(int paletteStart) { void Image::copyPalette(void) {
tonccpy((currentScreen ? BG_PALETTE : BG_PALETTE_SUB) + paletteStart, _palette.data(), _palette.size() * 2); tonccpy((currentScreen ? BG_PALETTE : BG_PALETTE_SUB) + _paletteStart, _palette.data(), _palette.size() * 2);
} }
void Image::draw(int x, int y, float scaleX, float scaleY, bool skipAlpha) { void Image::draw(int x, int y, float scaleX, float scaleY, bool skipAlpha) {