[GEM Development] GEM/1 and VGA

John Elliott jce at seasip.demon.co.uk
Thu Jul 21 23:50:03 PDT 2005


  As you know (or may not know) GEM/1 doesn't have a VGA driver, and doesn't
work properly if you substitute the VGA driver from later versions (such as 
VGA.SYS from GEM/2).

  I did a few experiments today and worked out why. I started by taking the
standard EGA driver and modifying it to select mode 18 rather than mode 16.
No problems so far. I then increased the drawable area until it went wrong,
which it did at 640x409. 
  
  Now, 640x409 is the point where the size of a plane goes above 32768. So
the problem is obviously a signed integer overflow, and after a bit more
calculation I narrowed it down to gsx_mcalc(), which works out how big the
buffer is. The GEM/2 version uses 32-bit arithmetic, whereas the GEM/1
version uses 16-bit signed. 

  Fortunately there are two simple patches that can be done without
rewriting the whole function to use 32-bit arithmetic. The first makes
GEM/1 use a 16-bit unsigned shift instead, allowing up to 64k planes. This
is a one-byte fix; look in GEM.EXE for the sequence 

B1 04 89 46 04 D3 E0 33 DB 85 C0 79 01 4B

(in GEM 1.2, it's at offset 0A8CFh) and change the last byte to 90h. 
  The second uses 16-bit arithmetic but has a 32-bit shift at the end. Look
for the same sequence as before but replace it entirely with

B9 04 00 31 DB D1 E0 D1 D3 E2 FA 90 90 90

  The second patch allows planes up to 512k. 

  I'll be updating my website with full details and downloads in the next
few days, but for now there's a screenshot of GEM/1 working correctly in VGA 
mode at the bottom of <http://www.seasip.info/Gem/History/gem1.html>.

-- 
------------- http://www.seasip.demon.co.uk/index.html --------------------
John Elliott           |BLOODNOK: "But why have you got such a long face?"
                       |SEAGOON: "Heavy dentures, Sir!"    - The Goon Show 
:-------------------------------------------------------------------------)


More information about the gem-dev mailing list