nanogui: Re: Herc in Microwin
Subject:
SV: Herc in Microwin
From:
Bjorn Eriksson ####@####.####
Date:
8 Sep 1999 17:52:04 -0000
Message-Id: <01BEFA32.89E13860@BJORN>
>: I looked at the code and at the moment it just uses a loop to draw the line
>: pixel by pixel. How does it need to be improved??
>:
> Are you familiar with the Herc memory/screen layout? Instead of
>looping for each bit, the C code needs to set up to 8 pixels at a time with a
>single MOV instruction. This entails pre-calculating the bits in the screen memory
>and writing it once.
Oh, wait a second. I've got some very, very old C-code somewhere on my very old 386SX 16MHz PC somewhere. Nah, I wouldn't bother considering it's ten years old and I was fairly new to C at the time... :-)
Well, if you're unfamiliar with the hercules screen-memory layout it might provide some guidance. Here's a bit of code for TurboC 2.0: (please don't comment the code-quality)
#define US unsigned
#define BYTE US char
#define HERCADDR(column,row) \
((BYTE far *) ( 0xB0000000L | (US long) (0x2000u*(row & 3u) + 90u*(row>>2u) + (column>>3u)) ))
void vert_line(US x1, US x2, US y, const BYTE color) {
BYTE far *addr1;
BYTE far *addr2;
BYTE byte1, byte2;
byte1 = 128u >> (x1 & 7u);
byte1 |= byte1-1;
byte2 = 128u >> (x2 & 7u);
byte2--;
byte2 ^= 0xFF;
addr1 = HERCADDR(x1, y);
addr2 = HERCADDR(x2, y);
if ( color ) {
if ( FP_OFF(addr2) == FP_OFF(addr1) ) {
*addr1 |= byte1 & byte2;
} else {
*addr1 |= byte1;
*addr2 |= byte2;
addr1++;
while ( addr1 < addr2 )
*addr1++ = 0xFF;
}
} else {
if ( FP_OFF(addr2) == FP_OFF(addr1) ) {
*addr1 &= (byte1 & byte2) ^ 0xFF;
} else {
*addr1 &= byte1 ^ 0xFF;
*addr2 &= byte2 ^ 0xFF;
addr1++;
while ( addr1 < addr2 )
*addr1++ = 0;
}
}
}
Hmmm. Wasn't hercules a four color graphics card? Maybe I decided a two color model was more "speed optimized".
//Björn.