diff --git a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp index 322f23e..0eaaa9d 100644 --- a/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp +++ b/EarthboundBattleBackgrounds/EarthboundBattleBackgrounds/main.cpp @@ -1,6 +1,8 @@ #define OLC_PGE_APPLICATION #include "olcPixelGameEngine.h" +#define PI 3.14159f + #include using namespace olc; @@ -269,11 +271,45 @@ struct Rom{ arrayGraphicsData=arrayBlock.decompress(); } }; + + 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 PaletteCycle{ + std::vectororiginalCols; + std::vectorcurrentCols; + byte type,start1,end1,start2,end2,speed,cycleCountdown,cycleCount{}; + PaletteCycle(BattleBackground&background,BackgroundPalette&palette) + :type(background.paletteCycleType),start1(background.paletteCycle1StartInd),end1(background.paletteCycle1EndInd),start2(background.paletteCycle2StartInd),end2(background.paletteCycle2EndInd),speed(background.paletteCycleSpeed/2),cycleCountdown(speed),originalCols(palette.colors),currentCols(originalCols){ + for(int i:std::views::iota(0U,originalCols.size())){ + originalCols.emplace_back(originalCols[i]); + } + } + }; + + PixelGameEngine*pge; + Sprite*spr; + Distorter distorter; + PaletteCycle cycle; + BattleBackground&background; + BackgroundGraphics&graphics; + BackgroundLayer(PixelGameEngine*pge,uint8_t pgeLayer,uint16_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]){} + }; std::u8string data; inline static std::string reversedBytes; std::vectorbackgrounds; std::vectorpalettes; std::vectorgraphics; + BackgroundLayer layer1{nullptr,0U,0U,backgrounds},layer2{nullptr,1U,0U,backgrounds}; Rom(){ #pragma region Setup Reversed Bytes reversedBytes.resize(256); @@ -320,8 +356,6 @@ public: public: bool OnUserCreate() override { - CreateLayer(); - EnableLayer(1U,true); return true; } @@ -375,12 +409,17 @@ public: } } + void BackgroundLayerDisplayTest(){ + + } + int yOffset{0}; bool OnUserUpdate(float fElapsedTime) override { //PaletteDisplayTest(); - GraphicsDisplayTest(); + //GraphicsDisplayTest(); + BackgroundLayerDisplayTest(); return true; } };