Graphics data reading fixed. Palette colors put back to PGE's rgb order.

master
sigonasr2 5 months ago
parent 5f0a728fd8
commit b1cde6a168
  1. 10
      EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp
  2. BIN
      EarthboundBattleBackgrounds/x64/Debug/EarthboundBattleBackgrounds.exe

@ -162,15 +162,15 @@ struct Rom{
while(len--!=0)block[bpos++]=tmp++; while(len--!=0)block[bpos++]=tmp++;
}break; }break;
case REPEAT_PREVIOUS_DATA:{ case REPEAT_PREVIOUS_DATA:{
if(bpos+2*len>maxLength||bpos<0)return; if(bpos2+len>maxLength||bpos2<0)return;
for(int i:std::views::iota(0,len))block[bpos++]=block[bpos2+i]; for(int i:std::views::iota(0,len))block[bpos++]=block[bpos2+i];
}break; }break;
case REVERSE_BITS:{ case REVERSE_BITS:{
if(bpos+2*len>maxLength||bpos<0)return; if(bpos2+len>maxLength||bpos2<0)return;
while(len--!=0)block[bpos++]=Rom::reversedBytes[block[bpos2++]&0xFF]; while(len--!=0)block[bpos++]=Rom::reversedBytes[block[bpos2++]&0xFF];
}break; }break;
case UNKNOWN_1:{ case UNKNOWN_1:{
if(bpos+2*len>maxLength||bpos<0)return; if(bpos2-len+1<0)return;
while(len--!=0)block[bpos++]=block[bpos2--]; while(len--!=0)block[bpos++]=block[bpos2--];
}break; }break;
case UNKNOWN_2:{ case UNKNOWN_2:{
@ -224,9 +224,9 @@ struct Rom{
if(bpp!=2&&bpp!=4)throw std::invalid_argument{std::format("Palette Error: Incorrect color depth specified. Must be 2 or 4, provided {}",bpp)}; if(bpp!=2&&bpp!=4)throw std::invalid_argument{std::format("Palette Error: Incorrect color depth specified. Must be 2 or 4, provided {}",bpp)};
for(uint8_t i:std::views::iota(0,pow(2,bpp))){ for(uint8_t i:std::views::iota(0,pow(2,bpp))){
uint16_t clr16{dataBlock.readShort()}; uint16_t clr16{dataBlock.readShort()};
uint8_t r{((clr16>>10)&31)*8U}; uint8_t b{((clr16>>10)&31)*8U};
uint8_t g{((clr16>>5)&31)*8U}; uint8_t g{((clr16>>5)&31)*8U};
uint8_t b{(clr16&31)*8U}; uint8_t r{(clr16&31)*8U};
colors.emplace_back(r,g,b); colors.emplace_back(r,g,b);
} }
} }

Loading…
Cancel
Save