VGAPATCH: Support for VGA screen modes in GEM/1     John Elliott, 23 July 2005
==============================================================================

  GEM/1 was written before VGA, so the highest resolution it can manage on 
standard PC hardware is 640x350 using the EGA driver (or 720x348 mono if 
you've got a Hercules card). If you try to substitute a VGA driver from a 
later version (say VGA.SYS from GEM/2) then the menus start acting oddly; the 
top left-hand corner of the screen fills up with the desktop pattern or bits 
of menus.

  This behaviour is caused by a bug, and the purpose of VGAPATCH is to fix it. 
To use VGAPATCH, simply run it, enter the path to GEM.EXE (or browse to 
GEM.EXE using the Item Selector) and click OK. GEM will then be patched and 
you can use the VGA driver as normal.

Copying
-------

VGAPATCH is copyright 2005, John Elliott <jce@seasip.demon.co.uk>.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Technical details
-----------------

  VGAPATCH works by fixing an integer overflow in the gsx_mcalc() routine, 
which blows up on screens where a plane is more than 32768 bytes. It replaces 
the code sequence:


     mov     cl, 4           ;paragraphs
     mov     [bp+4], ax
     shl     ax, cl          ;16-bit left shift
     xor     bx, bx
     test    ax, ax          ;Sign-extend to 32-bit signed
     jns     4f              ;long integer.
     dec     bx
4:

with:

     mov     cx,4
     xor     bx,bx
4:
     shl     ax,1
     rcl     bx,1
     loop    4b
     nop
     nop
     nop
