Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Source/Amiga/Graphics_Amiga2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@ tSharedBuffer cGraphics_Amiga2::GetPalette(const std::string pFilename) {
auto Palette = g_Resource->fileGet(Filename);

auto a0 = Palette->data();
for (; a0 < Palette->data() + Palette->size(); ++a0) {
auto a0End = Palette->data() + Palette->size();
for (; a0 + 2 < a0End; a0 += 3) {

uint16 d0 = *a0++;
uint16 d1 = *a0++;
uint16 d0 = a0[0];
uint16 d1 = a0[1];

d0 &= 0xF0;
d0 <<= 4;

d1 &= 0xF0;
d0 |= d1;

d1 = *a0;
d1 = a0[2];
d1 &= 0xF0;
d1 >>= 4;
d0 |= d1;
Expand Down
8 changes: 7 additions & 1 deletion Source/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ struct sImage {

uint16 color;

for (size_t ColorID = pStartColorID; ColorID < pStartColorID + pCount; ColorID++) {
if (pStartColorID >= 256)
return;

const size_t MaxColors = 256 - pStartColorID;
const size_t PaletteCount = std::min(pCount, MaxColors);

for (size_t ColorID = pStartColorID; ColorID < pStartColorID + PaletteCount; ColorID++) {

// Get the next color codes
color = readBEWord(pFrom);
Expand Down
Loading