
(procedure scrub
	(
	(if (exists (tackon "photogenics:" OLDKACK))
		(
		(delete (tackon "photogenics:" OLDKACK)
			(prompt ("\n\nDeleting redundant program code:\n\n%s\n\n" OLDKACK) )
			(help "\n\n\nRelease 1.2a of Photogenics makes this file redundant, so we're getting rid of it.")
			(confirm)
			)
		)
	)
	)
)

(procedure fresh
	(
	(copyfiles
		(prompt ("\n\nInstalling new release of file:\n\n%s\n\n" NEWSTUFF))
		(source (tackon "new" NEWSTUFF))
		(dest (tackon "photogenics:" PATH))
		(help @copyfiles-help)
		(confirm)
	)
	)
)

(procedure do_a_patch
	(if (exists ("%s%s" PATH FILE))
		(
		(working ("Patching: %s\n\n" FILE))

		(run ( ("c/spatch -o%s%s -p%s%s.diff %s%s" PATH FILE PATCH FILE ORIGINAL FILE)))
		)
	)
)

(message
	"\n\n\nThis interim 1.2a set of patches can only be applied to a"
	" previous installation of Photogenics 1.2 - it won't be compatible"
	" with versions 1.1a and below, or any of the Special Edition"
	" releases. If you're not using the full 1.2 version, please hit"
	" ABORT now."
)

(message
	"\n\nGood, you're still with us ;->\n\n"
	"The patch will only affect parts of Photogenics 1.2 which have"
	" been installed on your hard disk - unfortunately, due to the"
	" ever-growing size of the main code, the floppy distribution"
	" for 1.2a has been heavily reorganised, and a patch to the"
	" original floppies isn't easily possible <however Almathera"
	" can update your original disk set from 1.2 to 1.2a if you"
	" send in your disks, return postage and registration details>."
)

(message
	"\n\nIf you install extra parts of release 1.2 from your original"
	" disks *after* applying this patch, you'll need to re-apply it"
	" to patch the new stuff you install. <C'est la vie>\n\n"
	" You really need to have this archive unpacked to the RAM disk or"
	" a spare partition on your hard drive, as we patch against the"
	" original 1.2 disks and so there's gonna be some disk-swapping"
	" to do. <Hence you want to have this patch available at all times>"
)

(askdisk
	(prompt "Please insert Photogenics release 1.2 disk 1 in any drive")
	(dest "Photogenics_1")
	(help @askdisk-help)
)
                          ; loop for each one...

(set LOOP-FLAG -1)

(while (< LOOP-FLAG 93 )
	(

	(set LOOP-FLAG (+ 1 LOOP-FLAG ))

	(set FILE
		(select LOOP-FLAG

			"Photogenics"		; 0
			"pgs.library"		; 1

			"ACBM.gio"		; 2
			"AmigaScreen.gio"
			"Backdrop.gio"
			"BMP.gio"
			"CDXL.gio"
			"GIF.gio"
			"Ham6.gio"
			"Ham8.gio"
			"IFF-24.gio"
			"IFFDeep.gio"

			"ILBM.gio"		; 12
			"Img.gio"
			"JPEG.gio"
			"Noise.gio"
			"Pattern.gio"
			"PBM.gio"
			"PCX.gio"
			"Plasma.gio"
			"Ripples.gio"
			"ShowHam6.gio"

			"ShowHam8.gio"		; 22
			"Streaks.gio"
			"Targa.gio"
			"Text.gio"

			"AddNoise"		; 26
			"AlterHue"
			"Antique"
			"Balance"
			"BasRelief"
			"Blur"
			"BrightMap"
			"Brightness"
			"Cloner"
			"Colourise"

			"Contrast"		;36
			"CrossHatch"
			"Defocus"
			"Deinterlace"
			"DisplaceMap"
			"Dither"
			"Emboss"
			"FalseColour"
			"Flip"
			"Gamma"

			"GradientTint"		;46
			"Greyscale"
			"HueMap"
			"Jitter"
			"Limit"
			"LineArt"
			"MaskingPaint"
			"Matrix"
			"Median"
			"Mirage"

			"Mix"			; 56
			"Monochrome"
			"MotionBlur"
			"Negative"
			"Paint"
			"Pixelise"
			"Posterise"
			"Randomise"
			"Refract"
			"Roll"

			"RubEmboss"		; 66
			"RubMix"
			"RubTexture"
			"RubThru"
			"RubTint"
			"Saturation"
			"Sharpen"
			"ShiftHue"
			"ShiftRGB"
			"Solarize"

			"Split"			; 76
			"Stellate"
			"Tile"
			"TileBrick"
			"Tint"

			"EGS.gio"		; 81
			"Harlequin.gio"
			"Impulse.gio"
			"OpalVision.gio"
			"Picasso-II.gio"
			"QRT.gio"
			"QuadAnim.gio"
			"Raw.gio"
			"Retina.gio"
			"Sculpt.gio"

			"StudioII-Print.gio"	; 91
			"TIFF.gio"
			"VLab.gio"		; 93
		)
	)

           ; wind thru the list changing paths on the fly

	(if (= 1 LOOP-FLAG)
		(
		(set PATH "photogenics:data/libs/")
		(set ORIGINAL "Photogenics_1:data/libs/")
		(set PATCH "diffs/data/Libs/")
		)
	)

	(if (= 2 LOOP-FLAG)
		(
		(set PATH "photogenics:data/GIO/")
		(set ORIGINAL "Photogenics_1:data/GIO/")
		(set PATCH "diffs/data/GIO/")
		)
	)

	(if (= 26 LOOP-FLAG)
		(
		(set PATH "photogenics:data/PaintModes/")
		(set ORIGINAL "Photogenics_1:data/PaintModes/")
		(set PATCH "diffs/data/PaintModes/")
		)
	)

	(if (= 81 LOOP-FLAG)
		(
		(set PATH "photogenics:data/GIO/")
		(set ORIGINAL "Photogenics_3:ExtraGIOs/")
		(set PATCH "diffs/ExtraGIOs/")
		)
	)

	(if (= 0 LOOP-FLAG)
		(

		(working "Reuncompressing new main program code")
		(run ("c/Deplode new/Photogenics Photogenics:Photogenics")
			(prompt "Reuncompressing new main program code")
			(help "Reuncompressing new main program code")
			)
		)

		(
		(if (> LOOP-FLAG 80 )
			(askdisk
				(prompt "Please insert Photogenics release 1.2 disk 3 in any drive")
				(dest "Photogenics_3")
				(help @askdisk-help)
			)
		)
		(do_a_patch)
		)
	)
	)
)

(if (> (exists "photogenics:data/GIO/FramestoreDisplay.gio") 0)
	(
	(run "Photogenics_3:c/lhex -qfw=diffs/ x Photogenics_3:Toaster.lha")
	(set PATH "photogenics:data/GIO/")
	(set ORIGINAL "diffs/")
	(set PATCH "diffs/Toaster/")
	(set FILE "FramestoreDisplay.gio")
	(do_a_patch)
	(set FILE "FramestoreFile.gio")
	(do_a_patch)
	(set FILE "FramestoreGrab.gio")
	(do_a_patch)
	)
)

(set OLDKACK "Data/Paintmodes/Maximum")
(scrub)

(set OLDKACK "Data/Paintmodes/Minimum")
(scrub)

(set OLDKACK "Data/Paintmodes/Highlights")
(scrub)

(set OLDKACK "Data/Paintmodes/Lowlights")
(scrub)

(set OLDKACK "Data/GIO/Ascii-Art.gio")
(scrub)

(set OLDKACK "Data/GIO/CyBERgraphics.gio")
(scrub)

(set OLDKACK "Data/GIO/PCD.gio")
(scrub)

(set OLDKACK "Data/GIO/PrefsPrinter.gio")
(scrub)

; okay, nuked from orbit, let's do the new stuff...

(set NEWSTUFF "data/PaintModes/Hi&LowLights")
(set PATH "data/PaintModes")
(fresh)

(set NEWSTUFF "data/GIO/Ascii-Art.gio")
(set PATH "data/GIO")
(fresh)

(set NEWSTUFF "data/GIO/CyberGraphX.gio")
(fresh)

(set NEWSTUFF "data/GIO/PCD.gio")
(fresh)

(set NEWSTUFF "data/GIO/PrefsPrinter.gio")
(fresh)


(run "c/Avail >nil: <nil: FLUSH") ; now wash your hands....

(set #PGX-ENV "Creating Photogenics directory in ENV:...")

(set #PREFS-MOVE
	(cat "\nNow copying your Photogenics preferences into %s\n"
	     "(Photogenics v1.2a uses environmental variables"
	     " instead of the Photogenics file tree)")
)

(if ( < (exists "envarc:Photogenics" (noreq) ) 2)
	(
	(makedir "envarc:Photogenics"
		(prompt "Creating Photogenics directory in ENVARC:...")
		(help @makedir-help)
		)

	(makedir "env:Photogenics"
		(prompt "Creating Photogenics directory in ENVARC:...")
		(help @makedir-help)
		)
	)
)

(if (exists "photogenics:data/Preferences" (noreq))
	(
	(copyfiles
		(prompt (#PREFS-MOVE "ENVARC:"))
		(source "photogenics:Data/Preferences")
		(dest "ENVARC:Photogenics/")
		(help @copyfiles-help)
		(newname "preferences")
		(confirm)
	)

	(copyfiles
		(prompt (#PREFS-MOVE "ENV:"))
		(source "photogenics:Data/Preferences")
		(dest "ENV:Photogenics/")
		(help @copyfiles-help)
		(newname "preferences")
		(confirm)
	)

	(delete "photogenics:Data/Preferences"
		(prompt "\n\n\n\nYour preferences have been copied into ENV: and ENVARC, so can now be deleted from the Photogenics file tree.")
		(help "\n\n\n\n\n\n Installing v1.2a requires you to delete this file.")
		(confirm)
	)

	)
)

(copyfiles
	(prompt "Updating READ.ME")
	(source "new/READ.ME")
	(dest "photogenics:")
	(help @copyfiles-help)
	(confirm)
)

(message
	"\n\nPhotogenics 1.2a has now been patched into your existing"
	" installation. Please remember to repatch should you"
	" install extra data from your 1.2 release disks <or"
	" simply have your 1.2 set updated to 1.2a>, and in"
	" the meantime, enjoy the new update to the package"
	" once you've read the new READ.ME file."
)

(run "run photogenics_3:c/More photogenics:READ.ME")

(exit (quiet))

