Non linear modes were pain but very common in old hardware. Maybe even for legitimate reasons, like it fit well in the design of the hardware at the time.
My setPixel function is like this
static void putPixel(int x, int y, uint8 c, uint8 far *vram)
{
uint8 shift = (6 - (uint8)((x<<1) & 7));
uint8 pixel = (c & 3) << shift;
uint8 mask = ~(3 << shift);
vram += vramY[y] + (x >> 2);
*vram = (*vram & mask) | pixel;
}
I precalculated vramY[200] array to avoid some stuff
for (int y=0; y<200; ++y) {
vramY[y] = (y & 1) * 8192 + (y >> 1) * 80;
}