private void renderScanline(int line) {

        if ((mask & R_MASK_BG_ON) != 0) {
            renderBackground(line);
            address = (address & ~0x41F) | (latch & 0x41F);
        } else {
            int color = nesColors[bgPalette[0] & 0x3F];
            for (int i = 0; i < WIDTH; i++) {
                framebuffer[line * WIDTH + i] = color;
            }
        }
    }