' Sets icon to 3 bitplanes so system won't crash in 16-color WB
' (Yes folks I could program this in C or assembly but what the heck...it works.)
DEFLNG a-z
DECLARE FUNCTION PutDiskObject LIBRARY
DECLARE FUNCTION GetDiskObject LIBRARY
LIBRARY "icon.library"
INPUT "Enter icon name (no .info) > ",f$:f$=f$+CHR$(0)
obj=GetDiskObject(SADD(f$))
IF obj<>0 THEN
img1=PEEKL(obj+22):img2=PEEKL(obj+26)
'GOSUB show 'unREM this if you want to see all of icon's struct. values
a=PEEKW(img1+8)
PRINT "Icon has";a;"bitplanes and ";
IF img2=0 THEN
PRINT "no alt image."
PRINT :PRINT "Since 4-color icons with no alt image work fine"
PRINT "in the 16-color WB do you still wish to force it to 3 bitplanes";
INPUT a$:IF UCASE$(a$)<>"Y" THEN cleanup
ELSE
PRINT "has an alt. image."
END IF
IF PEEKW(obj+16)=5 THEN PRINT :PRINT "Cannot fix backfill icons due to system incompatability.":PRINT "(Backfill only works in 4-color WB on 1.2)":GOTO cleanup
IF a<3 THEN 'check depth to see if fix is needed
PRINT "Fixing...";
POKEW img1+8,3 'set depth
POKE img1+14,3 'set planepick
IF img2<>0 THEN POKEW img2+8,3:POKE img2+14,3 'do same for alt image if exists
e=PutDiskObject(SADD(f$),obj)
IF e=0 THEN PRINT " Error writing icon!" ELSE PRINT "Done."
ELSE
PRINT "No need to fix...enough bitplanes already."