VOGONS


IBM EGA vert and horiz timing

Topic actions

Reply 20 of 21, by superfury

User metadata
Rank l33t++
Rank
l33t++

In the end, I just created the lookup table manually, using a simple loop from index 0 to 256(VGA DAC entries) to create RGB entries using the rgbRGB format, then modifying the VGA precalcs(also used by the EGA) to ignore any values in the DAC table(that's usually filled by VGA DAC writes using the VGA DAC ports) to instead use the precalculated DAC entries below:

void VGA_setupEGAPalette(VGA_Type *VGA)
{
word index;
DACEntry entry;
byte r,g,b;
byte strengthtable[4] = {0x00,0xAA,0x55,0xFF};
VGA->registers->DACMaskRegister = 0x3F; //Set a DAC mask register to apply!
for (index=0;index<0x100;++index) //
{
b = strengthtable[(((index&0x08)>>2)|(index&1))];
g = strengthtable[((((index&0x10)>>2)|(index&2))>>1)];
r = strengthtable[((((index&0x20)>>2)|(index&4))>>2)];
VGA->precalcs.DAC[index] = RGB(r,g,b); //Calculate the color to use!
}
VGA_calcprecalcs(VGA,WHEREUPDATED_DACMASKREGISTER); //Update the entire DAC with our loaded DAC values!
}

VGA_calcprecalcs updates the active entries as needed:
1. It generates the VGA->precalcs.DAC when not emulating EGA(to apply VGA/SVGA+ DAC entries mentioned above to generate a 256-entry RGBA lookup table, written to VGA->precalcs.DAC).
2. It refreshes the active video entries by either normal color values(direct copy of VGA->precalcs.DAC) or b/w values(depending on the setting in the settings menu, to generate a lookup table containing the grayscale, greenscale or amberscale).
This resulting table is then used to render all EGA+ colors on the screen(e.g. all modes on EGA, VGA and SVGA graphics cards).

The EGA BIOS does seem to completely clear the Misc Output Register for some reason, which normally shouldn't happen anywhere? So the CPU emulation itself is going wrong somewhere?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 21 of 21, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote:

The EGA BIOS does seem to completely clear the Misc Output Register for some reason, which normally shouldn't happen anywhere? So the CPU emulation itself is going wrong somewhere?

It should not clear it. I logged all writes to 3C2 register from the EGA BIOS and I am seeing the following during self check at boot time (notice no 0)

Misc reg 0x1
Misc reg 0xd
Misc reg 0x9
Misc reg 0x5
Misc reg 0x1
Misc reg 0x23
Misc reg 0xa7
Misc reg 0x23
Misc reg 0xa7
Misc reg 0x23

EDIT: Can you post the IP address that outputs 0 to 3C2? Ideally some instructions before and after would be good to better locate the code.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/