First post, by superfury
How is the amount of installed VRAM detected on a EGA video card and up (including VGA, ET3000, ET4000 and possibly others)?
UniPCemu just fetches whatever is there, and gives 0xFF when reading non-existent VRAM.
But software seems to always detect 256K/512K/1MB, depending on the graphics card(1MB for Tseng ET4000(and it's W32 variant) cards, 512K for ET3000, 256K for EGA and VGA)?
Edit: Or does that mean ther's an issue with the way memory is mapped in UniPCemu or one other VRAM mapping related issues?
Edit: Hmmm... I do see it reading 3D4 index 37h before displaying that message (" 1MB" installed, before starting to boot the normal motherboard BIOS)...
Edit: Hmmm... c000:00000c1f seems to start to detect something by having read index 37h from the CRTC registers. It did read 0xFF from that register somehow, though? It starts to check bit 3?
Edit: Still reporting 1MB after specifying it's bit 3 correctly(it had flipped behaviour in UniPCemu). Bit 0 behaved correctly, though. Together, bits 0&4 determine the memory size and wrapping?
Edit: Hmmm... It looks like the BIOS always detects the maximum supported? W32P detects 2MB on the W32 chipset with any VRAM installed, while W32 always seems to detect 1MB?
Edit: Hmmm... Capping the settings in the CRTC register 37h based on the bits inputted(as the requested value) and installed memory(as the max value) and then always setting the lowest of the two in the register when written to causes the following:
ET4000/W32 BIOS: 512KB installed=512KB, 1024KB installed=1MB, 2048KB installed=1MB, 4MB installed=1MB
ET4000/W32p BIOS: 512KB installed=512KB, 1024KB installed=2MB, 2048KB installed=2MB, 4MB installed=2MB
So 512KB is detected correctly, but all others resolve to 1MB(W32) or 2MB(W32p BIOS)?
Anyone knows more about this?
Edit: Just found a little bug in at least the ET4000 and ET4000/W32 chips documentation vs FreeVGA: When the extended memory in the Sequencer Memory Mode Register is set to 0, the VGA (based on FreeVGA) disables memory past 64KB. But apparently, the Tseng chips don't do this (but like the VGA do actually disable the font select bits in the character attributes).
Edit: It just seems that the BIOSes for the W32 and W32p won't correctly detect memory chips that are larger than the 1MB(W32) or 2MB(W32p) BIOS seems to support, even though looking through the BIOS in a hex editor clearly shows support for it?
I currently implemented register 37h as updating a memory mask to apply to all VRAM accesses(depending on the data in the register). Then, if a size is set larger than installed VRAM or the lower 4 bits are written with all ones(done during detection during POST it seems), it will update the bits with the installed RAM's values(256KB or 1MB times 2(for 16-bit) or 4(for 32-bit) for the closest thing below/at the installed VRAM amount). And of course that value is loaded when the
'power' is applied to the emulated machine as well.
I did adjust one slight thing in UniPCemu now: the CRTC register 37h is unprotected for reads (still write-protected though) now. Somehow, the BIOS seems to be reading the register with the KEY not entered yet?
Edit: Of course, none of those extended past 1MB VRAM modes run in WhatVGA, due to the BIOS still thinking it doesn't have enough RAM somehow?
Edit: Made register 37h protected again, as per the Tseng documentation.