BackgroundLayer implementation added.
This commit is contained in:
parent
41ab66d4c9
commit
99dde2e607
@ -250,7 +250,7 @@ struct Rom{
|
||||
int c{};
|
||||
for(int bp{};bp<bpp;bp++){
|
||||
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;
|
||||
}
|
||||
tiles[i][x][y]=c;
|
||||
@ -274,15 +274,6 @@ struct Rom{
|
||||
|
||||
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{
|
||||
enum{
|
||||
HORIZONTAL=1,
|
||||
@ -292,10 +283,47 @@ struct Rom{
|
||||
uint_fast16_t type(){
|
||||
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:
|
||||
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{
|
||||
std::vector<Pixel>originalCols;
|
||||
std::vector<Pixel>currentCols;
|
||||
@ -311,30 +339,34 @@ struct Rom{
|
||||
PixelGameEngine*pge;
|
||||
Sprite*spr;
|
||||
Distorter distorter;
|
||||
PaletteCycle cycle;
|
||||
BattleBackground&background;
|
||||
BackgroundGraphics&graphics;
|
||||
BackgroundLayer(PixelGameEngine*pge,uint_fast16_t backgroundInd,std::vector<BattleBackground>&backgrounds,std::vector<BackgroundPalette>&palettes,std::vector<BackgroundGraphics>&graphics)
|
||||
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){}
|
||||
PaletteCycle cycle;
|
||||
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;
|
||||
inline static std::string reversedBytes;
|
||||
std::vector<BattleBackground>backgrounds;
|
||||
std::vector<BackgroundPalette>palettes;
|
||||
std::vector<BackgroundGraphics>graphics;
|
||||
BackgroundLayer layer1{nullptr,0U,backgrounds,palettes,graphics},layer2{nullptr,0U,backgrounds,palettes,graphics};
|
||||
std::unique_ptr<BackgroundLayer>layer1,layer2;
|
||||
Rom(){
|
||||
#pragma region Setup Reversed Bytes
|
||||
reversedBytes.resize(256);
|
||||
for(int i:std::views::iota(0U,reversedBytes.size())){
|
||||
uint_fast8_t newNumb{};
|
||||
for(int digit=0;digit<8;digit++){
|
||||
uint_fast8_t digitVal{1U<<digit};
|
||||
if(i&digitVal)newNumb|=1<<(7-digit);
|
||||
}
|
||||
reversedBytes[i]=newNumb;
|
||||
i++;
|
||||
reversedBytes.resize(256);
|
||||
for(int i:std::views::iota(0U,reversedBytes.size())){
|
||||
uint_fast8_t newNumb{};
|
||||
for(int digit=0;digit<8;digit++){
|
||||
uint_fast8_t digitVal{1U<<digit};
|
||||
if(i&digitVal)newNumb|=1<<(7-digit);
|
||||
}
|
||||
reversedBytes[i]=newNumb;
|
||||
i++;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
std::ifstream dataStream{"truncated_backgrounds.dat",std::ios_base::binary};
|
||||
@ -351,6 +383,9 @@ struct Rom{
|
||||
for(uint_fast16_t i:std::views::iota(0U,graphicsBits.size())){
|
||||
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();
|
||||
//GraphicsDisplayTest();
|
||||
BackgroundLayerDisplayTest();
|
||||
//BackgroundLayerDisplayTest();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user