visrealm / pico-56

The HBC-56 (65C02/TMS9918A/AY-3-8910 retro computer) fully emulated on a Raspberry Pi Pico
https://youtube.com/@TroySchrapel
MIT License
120 stars 10 forks source link

BGR vs RGB #9

Closed cbmeeks closed 3 months ago

cbmeeks commented 3 months ago

I am curious on how I can change the library to encode pixels as RGB instead of BGR.

I realize I could just swap the wires around (blue pins send to red, etc.) but that doesn't feel right. Also, when I look at the graphic you have the red pins starting on left.

Is there a way to change this in the code or do I just need to rewire things?

Thanks!

void scanline(uint16_t y, uint16_t pixels[VGA_VIRTUAL_WIDTH]) {
    uint16_t c = 0x0000;
    if (y == 0 || y == VGA_VIRTUAL_HEIGHT - 1) c = 0x0000;
    else if (y < 30) c = 0x000f;    // red
    else if (y < 60) c = 0x00f0;    // green
    else if (y < 90) c = 0x0f00;    // blue
    else if (y < 120) c = 0x0f0f;   // fuscia
    else if (y < 150) c = 0x0ff0;   // cyan
    else if (y < 180) c = 0x00ff;   // yellow
    else if (y < 210) c = 0x007f;   // orange
    else if (y < 240) c = 0x0707;   // purple
    for (int x = 1; x < VGA_VIRTUAL_WIDTH - 1; ++x) {
        pixels[x] = c;
    }
    pixels[0] = 0x0000;
    pixels[VGA_VIRTUAL_WIDTH - 1] = 0x0000;
}
visrealm commented 3 months ago

I don't think this can be changed in code. I thought perhaps sm_config_set_out_shift() which as a shift_right argument, but that doesn't appear to do what I had hoped it would. LSB seems to always be mapped to the lowest IO pin number in the group.

If you must use RGB, I think swapping the R and B pins on the VGA is your best bet.

cbmeeks commented 3 months ago

Thanks! I can do that.