CGA (RGBI TTL) Signal generation

Inspired by this post (VSzA techblog - Arduino vs. CGA part 1 - flag PoC) I have been playing around with driving a Tandy RGB-11 CGA monitor with an Arduino (something far less people have been doing it seems, perhaps because these monitors are not as easily sourced as their VGA counterparts).

I connect R,G,B to digital 8, 9, 10 on the Arduino respectively and HSync and VSync to 11 and 12. I put a direct 5V on intensity, GND to GND.

It's easy enough to get the timings correct (4 CPU cycles to emit a pixel, this displays 200x200, 8 colors).

It's discouraging to try to implement any type of framebuffer in the available 2KB though. pgm_read_byte seems to be extraordinarily slow (immediately deemed unusable). So I guess I'll need to go full monochrome only or have a seriously reduced resolution and color depth...

Anyway, here is the current code (no special requirements):

All feedback or ideas welcome.