ChatGPT translation Stumbled upon the following DirectX 5 example
http://archive.gamedev.net/archive/reference/articles/article589.htmlIt does some obscure shit. In particular, it inits palette to random colors
// clear all the palette entries to RGB 0,0,0
memset(color_palette,0,256*sizeof(PALETTEENTRY));
// set all of the flags to the correct value
for (index=0; index<256; index++)
{
// create the GRAY/RED/GREEN/BLUE palette, 64 shades of each
if ((index / 64)==0)
{
color_palette[index].peRed = index*4;
color_palette[index].peGreen = index*4;
color_palette[index].peBlue = index*4;
} // end if
else
if ((index / 64)==1)
color_palette[index].peRed = (index%64)*4;
else
if ((index / 64)==2)
color_palette[index].peGreen = (index%64)*4;
else
if ((index / 64)==3)
color_palette[index].peBlue = (index%64)*4;
// set the no collapse flag
color_palette[index].peFlags = PC_NOCOLLAPSE;
} // end for index
So I asked ChatGPT to convert it to SDL2.
And it decided to be smart....
for (int i = 0; i < MAX_COLORS; i++)
{
Set_Pal_Entry(i, (i % 64) * 4, ((i / 64) % 4) * 64, ((i / 64) % 4) * 64);
}
That was in fact the single broken part of it.
Outside of the need to "#define SDL_MAIN_HANDLED" to suppress SDL from doing `#define main SDL_main /*happy debugging retards!*/`
Anyway, the code is basically Etch A Sketch
Current Mood: amused