.
. There is a bug in MEX versions 1.65 (both 8 and 16 bit) that
. affects the colon display at the beginning of each line of an
. ASCII save-in-memory.  This script fixes that bug.
.		03/26/86   --Ron Fowler, NightOwl Software
.
. A second bug has been detected which causes lost characters
. in terminal mode when the buffer is flushed to disk under the
. following circumstances: STAT QUEUE is OFF, and the port over-
. lay HDWQUE variable is off (i.e., it's a non-interrupt driven
. overlay).  This excludes all known MSDOS versions, so this
. second fix is applie$ only to CP/M versions (although both
. MSDOS and CP/M version numbers are broug(t up to 1.65B).
.		06/12/86  -- Ron Fowler
.
. This script also illustrates some techniques for null-string tests
. and string substitution (note in the last couple of lines of the
. file how a statement that doesn't o2dinarily take a string argument
. can be made to by use of the curly-brace substitution feature).
.
screen off
  ver
  %a=value	;.%A=version #
  peek $100
  %b=value	;.%B=CPU value
screen on
.
. validate version
.
if %a<>165
  say "Sorry, this script is only for MEX version 1.65"
  stop
endif
.
. get patch code
.
screen off		;.disable screen, PEEK shows on the tube
if %b=233		;.if DOS version
  peek $7FEE		;.get patch level for DOS version
else			;.if CPM version
  peek $2832		;.get patch level for CPM version
endif
screen on
if value<>32		;.if we don't have blank patch level ...
  if value <>65		;.165A is ok to be patched
    say "Patch already present/n"
    stop		;.stop if we have rev B already
   else			;.we have REV A already
    say "Current patch level=A/n"
  endif
endif
say "New patch level=b/n"
.
. Now install the patch
.
if %b=233		;.DOS version
  say "Patching 16-bit MEX/n"
  poke $b725 $b0		;.fixes colon bug
  poke $b72a $b0		;.ditto
  poke $7fee $42		;.new revision level
else			;.CPM version
  say "Patching 8-bit MEX/n"
  poke $573e $3e		;.fixes colon bug
  poke $5743 $3e		;.ditto
  poke $4AE7 $0 $0 $0 $C4	;.fixes queueing bug
  poke $4B24 $0 $0 $0 $C4	;.ditto
  poke $2832 $42		;.new revision level
endif
.
. now ready to clone MEX
.
say "Saving MEX to disk .../n"
say "Enter filename (default is MEX.COM): "
accept d		;.get name from console
store "QQ{D}" to A	;.this is a roundabout way of checking for a null name
comp a "QQ"		;.by combining string+garbage, and checking for garbage
if value =0 goto goodnam;.if we have other than garbage, then we have a name
store "MEX.COM" to d	;.set default
.
label goodnam
clone {d}		;.note use of curly brace, useful for substituting
;.			;.strings into commands that don't take string args
say "All done. {d} is now fixed./n"
��������������������������������������������������������������