DefineGlobalConstant('kRExPatch, ReadStreamFile(HOME&"RExPatch.stream"));
SetPartFrameSlot('RegisterPatch, ReadStreamFile(HOME&"RegisterPatchOriginal.stream"));

SetPartFrameSlot('DoNotInstall,
func()
begin
	local who, themsgtext, refInfo;
	who := kAppName;
	themsgtext := "This System Update cannot be installed into this Newton product. (";
	rexInfo := Gestalt(kGestalt_Base + 8);
	if rexInfo[0].manufacturer <> kPatchManufacturer then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong REx0 ROM ManufacturerID) ");
		return TRUE;
	end;
	if rexInfo[0].version <> kREx0Version then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong REx0 ROM Version) ");
		return TRUE;
	end;
	return
end);

SetPartFrameSlot('PatchData,
{
	code: kRExPatch,
	symFile: NIL,
});

InstallScript := func (part, removeFrame)
begin
	if part:RegisterPatch(part.PatchData.code, kPatchVersion, Length(part.PatchData.code), 1) = NIL then
	begin
	end;
	else
		GetRoot():Notify(3, kAppName, "An error has occured during loading; probably out of memory.\nThe System Update was not installed.");
	return
end
