diff --git a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp index 972c7ce..0338d48 100644 --- a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp +++ b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp @@ -250,7 +250,7 @@ struct Rom{ int c{}; for(int bp{};bp>7-x)<data[i]=block.readInt8(); + } + } private: std::arraydata; }; + 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_ptreffect; + Distorter(Sprite&bitmap) + :bitmap(bitmap){} + }; + struct PaletteCycle{ std::vectororiginalCols; std::vectorcurrentCols; @@ -311,35 +339,39 @@ struct Rom{ PixelGameEngine*pge; Sprite*spr; Distorter distorter; - PaletteCycle cycle; BattleBackground&background; BackgroundGraphics&graphics; - BackgroundLayer(PixelGameEngine*pge,uint_fast16_t backgroundInd,std::vector&backgrounds,std::vector&palettes,std::vector&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&backgrounds,std::vector&palettes,std::vector&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(data,effectVal); + } }; std::u8string data; inline static std::string reversedBytes; std::vectorbackgrounds; std::vectorpalettes; std::vectorgraphics; - BackgroundLayer layer1{nullptr,0U,backgrounds,palettes,graphics},layer2{nullptr,0U,backgrounds,palettes,graphics}; + std::unique_ptrlayer1,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<(nullptr,0U,backgrounds,palettes,graphics,data); + layer2=std::make_unique(nullptr,0U,backgrounds,palettes,graphics,data); } }; @@ -432,7 +467,7 @@ public: { //PaletteDisplayTest(); //GraphicsDisplayTest(); - BackgroundLayerDisplayTest(); + //BackgroundLayerDisplayTest(); return true; } }; diff --git a/EarthboundBattleBackgrounds/x64/Debug/EarthboundBattleBackgrounds.exe b/EarthboundBattleBackgrounds/x64/Debug/EarthboundBattleBackgrounds.exe index e1e9ff1..9bde18b 100644 Binary files a/EarthboundBattleBackgrounds/x64/Debug/EarthboundBattleBackgrounds.exe and b/EarthboundBattleBackgrounds/x64/Debug/EarthboundBattleBackgrounds.exe differ