Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wonder if anyone remembers the alternate text plane that allowed Norton/Symantec, Central Point Software, and moused in FreeBSD simulate a "pixel-accurate" mouse cursor in a text mode display (often 720 x 480 addressable as 80x25 using 8x16 glyphs that were last bit extended to 9x16). There was a little-used secondary code plane function in VGA where 512 characters could be displayed by sacrificing half of the colors (foreground color intensity bit 16 colors -> 8 colors). The secondary code page would be used as a raster bitmap to overlay the regular code page glyphs with the mouse cursor shape. Ultimately, the mouse cursor was typically 1-4 magic characters. One could code a double-sized cursor to use 4-9 characters if they so chose. The extra unused characters could be used for pixel-granular thermometer, progress bars, extra drawing characters, and UI elements like radio buttons and check boxes.

    /* segment:offset -> linear = (segment << 4) + offset */  

    volatile void *text_base = (volatile void *)(0xb8000) /* B800:0000 to BFFF:000F is 32 KiB */ 

    /* In VGA, bg bit 3 is a blink bit by default depending on Attribute Mode Control Register bit 3 */
    /* In VGA, fg bit 3 is a secondary character code plane if font A and font B pointers are different */

    void put_char(int ch, int fg, int bg, int x /* 0..79 */, int y /* 0..24 */, int video_page /* 0..7 */ ) {
      size_t offset = video_page*4096 + (y*80 + x)*2;
      uint8_t* p = (uint8_t*)(text_base) + offset;
      /* Modern compilers should turn this into a 16-bit memory access without worrying about endianness. */
      *p++ = (uint8_t)(ch & 0xff);
      *p = (uint8_t)((bg & 0xf)*16 + (fg & 0xf)));
    }


Bisqwit made a great video on this (as usual): https://youtu.be/7nlNQcKsj74


I remember pixel-accurate mouse cursors in Norton/Symantec products around mid-90s, but at that time they were using 4 characters in the 128-255 range to render the cursor - you could actually observe that by displaying a file with all 256 characters on the screen and then moving the mouse around.


Yes, I was thinking to this when I've read the OP. I have source code I wrote in the 90's that was displaying text boxes with the border on the actual border of the characters, without any color bleeding. But I was just using the normal mode (256 characters, just redefining some in the upper 128 block). On VGA, by default only characters in a specific range can be used for horizontal line drawing, as these are the ones that get the 9th bit extended...

I've actually reused this code a few months ago for a prank (UEFI network booted Linux containing DosBox running fullscreen in the framebuffer, to display a fake OS installer).


I think you could also replace the font with its inverse so that foreground and background are swapped. Disable blinking and you lose high intensity background but keep high intensity foreground (more useful).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: