First post, by superfury
I've been looking at the XGA documentation's 16-bit monitor ID documentation and tried to implement it's behaviour into my own emulation's bit reporting (really nibble-reporting, but the nibble in this case is precalculated (the A,B,C,D ones in the documentation).
Basically, I've used the following function to calculate the nibbles to send for each subsequent documented timestamp (the A, B, C, D nibbles):
void VGA_encodeDisplayIDpacket(VGA_Type *VGA, word data) //Encodes a display ID packet for use.{byte bit;word result;VGA->precalcs.hasExtendedIDbits = 1; //Has extended ID bits!//Now, go and encode the packet into the four chunks to report.result = 0; //Init the result!//bit 0 of the result comes from packet 0, bit 1 from packet 1 etc.//id0 delivers nibble 0, id1 delivers nibble 1 etc.for (bit=0;bit<0x10;++bit) //process all bits.{SETBITS(result, (((bit&3)<<2)|(bit>>2)), 1, GETBIT(data, bit));}VGA->precalcs.extendedIDbits = result; //Set the resulting packets!}
The SETBITS and getbits use almost the same syntax:
SETBITS(x,shift,mask,val)
GETBIT(x,bitnr)
shift in this case is the same as bitnr on the other function. mask is fixed to 1 to write 1-bit values into the resulting variable.
The basics of SETBITS is like x=(x&(~mask<<shift))|((val&mask)<<shift)
And getbit is the same way roughly ((x>>bitnr)&1) . It just assumes a bitmask of 1.
Is this behaviour correct to build the nibbles for the specified monitor ID? The order of the resulting nibbles is basically the same as A,B,C,D (literally indexed in that way, including the inversion (3-x) performed when the counter is applied to the current nybble number to obtain 3(D),2,1,0(A) from the lookup table's 0(A),1,2,3(D)). And the resulting bits (for example bitnumber modulo 0) is the ID pin to put it at (ID0,1,2,3).
Is this behaviour correct?
I've based this on the IBM XGA documenation page 3-215.
Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io