Palette and graphics test rendering.
This commit is contained in:
parent
b1cde6a168
commit
ea0e2a0a46
@ -237,6 +237,7 @@ struct Rom{
|
|||||||
std::vector<uint16_t>arrayGraphicsData;
|
std::vector<uint16_t>arrayGraphicsData;
|
||||||
std::vector<Tile>tiles;
|
std::vector<Tile>tiles;
|
||||||
byte bpp;
|
byte bpp;
|
||||||
|
private:
|
||||||
void buildTiles(){
|
void buildTiles(){
|
||||||
int n{int(graphicsData.size())/(8*bpp)};
|
int n{int(graphicsData.size())/(8*bpp)};
|
||||||
for(int i{};i<n;i++){
|
for(int i{};i<n;i++){
|
||||||
@ -255,7 +256,7 @@ struct Rom{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
BackgroundGraphics(std::u8string_view data,uint16_t index,byte bpp)
|
BackgroundGraphics(std::u8string_view data,uint16_t index,byte bpp)
|
||||||
:bpp(bpp){
|
:bpp(bpp){
|
||||||
DataBlock graphicsPtr{data,0xD7A1U+index*4U};
|
DataBlock graphicsPtr{data,0xD7A1U+index*4U};
|
||||||
@ -337,15 +338,47 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDisplayTest(){
|
uint8_t selectedPalette{};
|
||||||
|
|
||||||
|
void GraphicsDisplayTest(){
|
||||||
|
if(GetMouseWheel()<0)yOffset-=32;
|
||||||
|
if(GetMouseWheel()>0)yOffset+=32;
|
||||||
|
|
||||||
|
Clear(BLACK);
|
||||||
|
|
||||||
|
DrawStringDecal({},std::format("Selected Palette: {}",selectedPalette));
|
||||||
|
|
||||||
|
if(GetKey(PGUP).bPressed)selectedPalette=std::clamp(int(selectedPalette)-1,0,int(rom.palettes.size()-1));
|
||||||
|
if(GetKey(PGDN).bPressed)selectedPalette=std::clamp(int(selectedPalette)+1,0,int(rom.palettes.size()-1));;
|
||||||
|
|
||||||
|
Rom::BackgroundPalette&palette{rom.palettes[selectedPalette]};
|
||||||
|
for(uint8_t index=0;Pixel&col:palette.colors){
|
||||||
|
FillRectDecal(vf2d{index*8.f,8.f+yOffset+9},{8,8},col);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t row=0;Rom::BackgroundGraphics&graphics:rom.graphics){
|
||||||
|
for(uint8_t col=0;Rom::Tile&tile:graphics.tiles){
|
||||||
|
for(int x{};x<tile.size();x++){
|
||||||
|
for(int y{};y<tile[x].size();y++){
|
||||||
|
int paletteInd{tile[x][y]};
|
||||||
|
Pixel color{MAGENTA};
|
||||||
|
const bool ColorInRange{paletteInd<palette.colors.size()};
|
||||||
|
if(ColorInRange)color=palette.colors[paletteInd];
|
||||||
|
Draw(vi2d{col*8,row*8+yOffset+20}+vi2d{x,y},color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int yOffset{0};
|
int yOffset{0};
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
{
|
{
|
||||||
PaletteDisplayTest();
|
//PaletteDisplayTest();
|
||||||
GraphicsDisplayTest();
|
GraphicsDisplayTest();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user