|
|
@ -250,7 +250,7 @@ struct Rom{ |
|
|
|
int c{}; |
|
|
|
int c{}; |
|
|
|
for(int bp{};bp<bpp;bp++){ |
|
|
|
for(int bp{};bp<bpp;bp++){ |
|
|
|
int halfBp{bp/2}; |
|
|
|
int halfBp{bp/2}; |
|
|
|
int gfx{graphicsData[o+y*2+(halfBp*16+(bp&1))]}; |
|
|
|
int gfx{int(graphicsData[o+y*2+(halfBp*16+(bp&1))])}; |
|
|
|
c+=((gfx&(1<<7-x))>>7-x)<<bp; |
|
|
|
c+=((gfx&(1<<7-x))>>7-x)<<bp; |
|
|
|
} |
|
|
|
} |
|
|
|
tiles[i][x][y]=c; |
|
|
|
tiles[i][x][y]=c; |
|
|
@ -274,15 +274,6 @@ struct Rom{ |
|
|
|
|
|
|
|
|
|
|
|
struct BackgroundLayer{ |
|
|
|
struct BackgroundLayer{ |
|
|
|
|
|
|
|
|
|
|
|
struct Distorter{ |
|
|
|
|
|
|
|
const float c1{1/512.f}; |
|
|
|
|
|
|
|
const float c2{8*PI/(1024*256.f)}; |
|
|
|
|
|
|
|
const float c3{PI/60.f}; |
|
|
|
|
|
|
|
Sprite&bitmap; |
|
|
|
|
|
|
|
Distorter(Sprite&bitmap) |
|
|
|
|
|
|
|
:bitmap(bitmap){} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct DistortionEffect{ |
|
|
|
struct DistortionEffect{ |
|
|
|
enum{ |
|
|
|
enum{ |
|
|
|
HORIZONTAL=1, |
|
|
|
HORIZONTAL=1, |
|
|
@ -292,10 +283,47 @@ struct Rom{ |
|
|
|
uint_fast16_t type(){ |
|
|
|
uint_fast16_t type(){ |
|
|
|
return std::clamp(data[2],uint_fast8_t(1),uint_fast8_t(3U)); |
|
|
|
return std::clamp(data[2],uint_fast8_t(1),uint_fast8_t(3U)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t frequency(){ |
|
|
|
|
|
|
|
return data[3]+(data[4]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t amplitude(){ |
|
|
|
|
|
|
|
return data[5]+(data[6]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t compression(){ |
|
|
|
|
|
|
|
return data[8]+(data[9]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t frequencyAcceleration(){ |
|
|
|
|
|
|
|
return data[10]+(data[11]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t amplitudeAcceleration(){ |
|
|
|
|
|
|
|
return data[12]+(data[13]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t speed(){ |
|
|
|
|
|
|
|
return data[14]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint_fast16_t compressionAcceleration(){ |
|
|
|
|
|
|
|
return data[15]+(data[16]<<8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DistortionEffect(std::u8string_view data,uint16_t index){ |
|
|
|
|
|
|
|
DataBlock block{data,0xF708U+index*17}; |
|
|
|
|
|
|
|
for(int i:std::views::iota(0,17)){ |
|
|
|
|
|
|
|
this->data[i]=block.readInt8(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
private: |
|
|
|
private: |
|
|
|
std::array<uint_fast8_t,17>data; |
|
|
|
std::array<uint_fast8_t,17>data; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Distorter{ |
|
|
|
|
|
|
|
const float c1{1/512.f}; |
|
|
|
|
|
|
|
const float c2{8*PI/(1024*256.f)}; |
|
|
|
|
|
|
|
const float c3{PI/60.f}; |
|
|
|
|
|
|
|
Sprite&bitmap; |
|
|
|
|
|
|
|
std::unique_ptr<DistortionEffect>effect; |
|
|
|
|
|
|
|
Distorter(Sprite&bitmap) |
|
|
|
|
|
|
|
:bitmap(bitmap){} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct PaletteCycle{ |
|
|
|
struct PaletteCycle{ |
|
|
|
std::vector<Pixel>originalCols; |
|
|
|
std::vector<Pixel>originalCols; |
|
|
|
std::vector<Pixel>currentCols; |
|
|
|
std::vector<Pixel>currentCols; |
|
|
@ -311,35 +339,39 @@ struct Rom{ |
|
|
|
PixelGameEngine*pge; |
|
|
|
PixelGameEngine*pge; |
|
|
|
Sprite*spr; |
|
|
|
Sprite*spr; |
|
|
|
Distorter distorter; |
|
|
|
Distorter distorter; |
|
|
|
PaletteCycle cycle; |
|
|
|
|
|
|
|
BattleBackground&background; |
|
|
|
BattleBackground&background; |
|
|
|
BackgroundGraphics&graphics; |
|
|
|
BackgroundGraphics&graphics; |
|
|
|
BackgroundLayer(PixelGameEngine*pge,uint_fast16_t backgroundInd,std::vector<BattleBackground>&backgrounds,std::vector<BackgroundPalette>&palettes,std::vector<BackgroundGraphics>&graphics) |
|
|
|
PaletteCycle cycle; |
|
|
|
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){} |
|
|
|
BackgroundLayer(PixelGameEngine*pge,uint_fast16_t backgroundInd,std::vector<BattleBackground>&backgrounds,std::vector<BackgroundPalette>&palettes,std::vector<BackgroundGraphics>&graphics,std::u8string_view data) |
|
|
|
|
|
|
|
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){ |
|
|
|
|
|
|
|
uint_fast32_t effectVal{((background.GetAnimation()>>16)&0xFF)}; |
|
|
|
|
|
|
|
if(effectVal==0)effectVal=(((background.GetAnimation()>>24)&0xFF)); |
|
|
|
|
|
|
|
distorter.effect=std::make_unique<DistortionEffect>(data,effectVal); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
std::u8string data; |
|
|
|
std::u8string data; |
|
|
|
inline static std::string reversedBytes; |
|
|
|
inline static std::string reversedBytes; |
|
|
|
std::vector<BattleBackground>backgrounds; |
|
|
|
std::vector<BattleBackground>backgrounds; |
|
|
|
std::vector<BackgroundPalette>palettes; |
|
|
|
std::vector<BackgroundPalette>palettes; |
|
|
|
std::vector<BackgroundGraphics>graphics; |
|
|
|
std::vector<BackgroundGraphics>graphics; |
|
|
|
BackgroundLayer layer1{nullptr,0U,backgrounds,palettes,graphics},layer2{nullptr,0U,backgrounds,palettes,graphics}; |
|
|
|
std::unique_ptr<BackgroundLayer>layer1,layer2; |
|
|
|
Rom(){ |
|
|
|
Rom(){ |
|
|
|
#pragma region Setup Reversed Bytes |
|
|
|
#pragma region Setup Reversed Bytes |
|
|
|
reversedBytes.resize(256); |
|
|
|
reversedBytes.resize(256); |
|
|
|
for(int i:std::views::iota(0U,reversedBytes.size())){ |
|
|
|
for(int i:std::views::iota(0U,reversedBytes.size())){ |
|
|
|
uint_fast8_t newNumb{}; |
|
|
|
uint_fast8_t newNumb{}; |
|
|
|
for(int digit=0;digit<8;digit++){ |
|
|
|
for(int digit=0;digit<8;digit++){ |
|
|
|
uint_fast8_t digitVal{1U<<digit}; |
|
|
|
uint_fast8_t digitVal{1U<<digit}; |
|
|
|
if(i&digitVal)newNumb|=1<<(7-digit); |
|
|
|
if(i&digitVal)newNumb|=1<<(7-digit); |
|
|
|
} |
|
|
|
|
|
|
|
reversedBytes[i]=newNumb; |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
reversedBytes[i]=newNumb; |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
#pragma endregion |
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
|
|
std::ifstream dataStream{"truncated_backgrounds.dat",std::ios_base::binary}; |
|
|
|
std::ifstream dataStream{"truncated_backgrounds.dat",std::ios_base::binary}; |
|
|
|
while(dataStream.good())data+=dataStream.get(); |
|
|
|
while(dataStream.good())data+=dataStream.get(); |
|
|
|
|
|
|
|
|
|
|
|
for(uint_fast16_t i:std::views::iota(0U,MAX_INDEX+1U)){ |
|
|
|
for(uint_fast16_t i:std::views::iota(0U,MAX_INDEX+1U)){ |
|
|
|
backgrounds.emplace_back(data,i); |
|
|
|
backgrounds.emplace_back(data,i); |
|
|
|
paletteBits[backgrounds.back().paletteInd]=backgrounds.back().bbp; |
|
|
|
paletteBits[backgrounds.back().paletteInd]=backgrounds.back().bbp; |
|
|
@ -351,6 +383,9 @@ struct Rom{ |
|
|
|
for(uint_fast16_t i:std::views::iota(0U,graphicsBits.size())){ |
|
|
|
for(uint_fast16_t i:std::views::iota(0U,graphicsBits.size())){ |
|
|
|
graphics.emplace_back(data,i,graphicsBits[i]); |
|
|
|
graphics.emplace_back(data,i,graphicsBits[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer1=std::make_unique<BackgroundLayer>(nullptr,0U,backgrounds,palettes,graphics,data); |
|
|
|
|
|
|
|
layer2=std::make_unique<BackgroundLayer>(nullptr,0U,backgrounds,palettes,graphics,data); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -432,7 +467,7 @@ public: |
|
|
|
{ |
|
|
|
{ |
|
|
|
//PaletteDisplayTest();
|
|
|
|
//PaletteDisplayTest();
|
|
|
|
//GraphicsDisplayTest();
|
|
|
|
//GraphicsDisplayTest();
|
|
|
|
BackgroundLayerDisplayTest(); |
|
|
|
//BackgroundLayerDisplayTest();
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|