DefineGlobalConstant('kROMPatch, ReadStreamFile(HOME&"ROMPatch.stream"));
SetPartFrameSlot('RegisterPatch, ReadStreamFile(HOME&"RegisterPatchOriginal.stream"));

SetPartFrameSlot('DoNotInstall,
func()
begin
	local who, themsgtext, sysInfo;
	who := kAppName;
	themsgtext := "This System Update cannot be installed into this Newton product. (";
	sysInfo := Gestalt(kGestalt_SystemInfo);
	if sysInfo.manufacturer <> kPatchManufacturer then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong Base ROM ManufacturerID)");
		return true;
	end;
	if sysInfo.machineType <> kMachineType then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong Machine Type) ");
		return true;
	end;
	if sysInfo.ROMVersion <> kBaseROMVersion then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong Base ROM Version) ");
		return true;
	end;
	if sysInfo.ROMStage <> kBaseROMStage then
	begin
		GetRoot():Notify(3, who, themsgtext && "Wrong Base ROM Stage) ");
		return true;
	end;
	return
end);

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

InstallScript := func (part, removeFrame)
begin
	if part:RegisterPatch(part.PatchData.code, kPatchVersion, Length(part.PatchData.code), 0) = 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
