For Context I am working on an unfinished space invaders emulator and I want to draw to the screen but my double stacked for loop is sad and slow and I (currently) do not know how to convert a 256*2401d array to a 320*240 1d array so im basically wondering is there a way to speed up my for loops
the code in question
Code:
the code in question
Code:
for(int pxlx = 0; pxlx < 256; pxlx++)
for(int pxly = 0; pxly < 28; pxly++)
{
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00000001] == 0b00000001));
gfx_SetPixel(pxlx,pxly*8-7);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00000010] == 0b00000010));
gfx_SetPixel(pxlx,pxly*8-6);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00000100] == 0b00000100));
gfx_SetPixel(pxlx,pxly*8-5);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00001000] == 0b00001000));
gfx_SetPixel(pxlx,pxly*8-4);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00010000] == 0b00010000));
gfx_SetPixel(pxlx,pxly*8-3);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b00100000] == 0b00100000));
gfx_SetPixel(pxlx,pxly*8-2);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b01000000] == 0b01000000));
gfx_SetPixel(pxlx,pxly*8-1);
gfx_SetColor(255*(state->memory[0x2400+(256 * pxlx + pxly) & 0b10000000] == 0b10000000));