Commit 07c77d0e authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Miscellaneous fixes and improvements

Detail:
  Resources/UK/Desc - Changed handling of icon 17 (SCSI drive number) so that it gets restored properly when saved choices are reloaded
  Resources/UK/Templates,fec - Added scroll bars, resize icon, etc. to main window to make it usable on low-res displays
  Resources/UK/!Help - Add linebreaks to wrap text to 80 columns. Required for it to display properly in FrontEnd's help viewer. Updated changelog.
  bas/SDCreate:
  - Tidied up formatting a bit and added LOCAL's to procedures/functions to make it clearer which vars are local and which are global.
  - PROCdismount now dismounts the drive under both Fat32Fs and SCSIFS instead of just SCSIFS.
  - Added PROCCheckDisc to handle warning the user about potential data loss when writing an image to card/disc, and to provide an additional warning if the target disc holds !Boot or is the configured boot drive.
Admin:
  Tested in a few situations to ensure Fat32Fs dismounting and !Boot drive/boot drive detection works OK


Version 1.25. Tagged as 'SDCreate-1_25'
parent 65516205
This diff is collapsed.
......@@ -40,7 +40,7 @@ dbox_start
icn 14 maps_to "";
icn 15 maps_to "";
icn 16 on maps_to "disc " followed_by icn 17 produces_no_output;
icn 17 on maps_to "";
icn 17 maps_to string;
icn 18 decreases icn 17 min 0;
icn 19 increases icn 17 max 7;
......
/* (1.24)
/* (1.25)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.24
#define Module_MajorVersion_CMHG 1.25
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Mar 2012
#define Module_Date_CMHG 21 May 2012
#define Module_MajorVersion "1.24"
#define Module_Version 124
#define Module_MajorVersion "1.25"
#define Module_Version 125
#define Module_MinorVersion ""
#define Module_Date "25 Mar 2012"
#define Module_Date "21 May 2012"
#define Module_ApplicationDate "25-Mar-12"
#define Module_ApplicationDate "21-May-12"
#define Module_ComponentName "SDCreate"
#define Module_ComponentPath "bsd/RiscOS/Sources/Utilities/SDCreate"
#define Module_FullVersion "1.24"
#define Module_HelpVersion "1.24 (25 Mar 2012)"
#define Module_LibraryVersionInfo "1:24"
#define Module_FullVersion "1.25"
#define Module_HelpVersion "1.25 (21 May 2012)"
#define Module_LibraryVersionInfo "1:25"
......@@ -26,17 +26,23 @@ REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
REM POSSIBILITY OF SUCH DAMAGE.
REM
ON ERROR PRINT REPORT$;" at ";ERL : END
REM Create blank CMOS file
DIM cmos% 2052
FOR a%=0 TO 2044 STEP 4 : cmos%!a%=0 : NEXT a%
cmos%!2048 = 510 : REM Current Boot$OSVersion, just in case something cares about it in the future
loadedcmos%=FALSE
REM Grab command line from DDEUtils
SYS "DDEUtils_GetCLSize" TO clsize%
DIM cl% clsize%
SYS "DDEUtils_GetCl",cl%
clpos%=0
REM Find output type, name
type$=FNgetarg
IF type$="CMOS" THEN loadedcmos%=TRUE : PROCloadCMOS(FNgetarg) : type$=FNgetarg
IF type$="disc" THEN disc%=TRUE ELSE IF type$="file" THEN disc%=FALSE ELSE PRINT "Unknown output type '"+type$+"'"
......@@ -44,11 +50,14 @@ IF disc%=TRUE THEN
discno%=VAL(FNgetarg)
IF discno%<0 OR discno%>7 THEN PRINT "Bad SCSI drive number"
sdimage$="SCSI::"+STR$(discno%)+".$"
PROCCheckDisc
ELSE
sdimage$=FNgetarg
IF sdimage$="" THEN PRINT "No output filename given"
ENDIF
REM Validate the other command line args
pos%=clpos%
outfile$=FNgetarg
IF outfile$="image" THEN
......@@ -64,7 +73,9 @@ WHILE outfile$<>""
PROCCheckFile(outfile$,infile$)
outfile$=FNgetarg
ENDWHILE
REM Now do it for real
REM Now do it for real
clpos%=pos%
PROCdecompress("<SDCreate$Dir>.blank")
REM Process other command line args
......@@ -100,26 +111,28 @@ PRINT "Done"
END
DEF FNgetarg
arg$=""
WHILE clpos%<clsize% AND cl%?clpos%=32
clpos%+=1
ENDWHILE
WHILE clpos%<clsize% AND cl%?clpos%>32
arg$=arg$+CHR$(cl%?clpos%)
clpos%+=1
ENDWHILE
LOCAL arg$
arg$=""
WHILE clpos%<clsize% AND cl%?clpos%=32
clpos%+=1
ENDWHILE
WHILE clpos%<clsize% AND cl%?clpos%>32
arg$=arg$+CHR$(cl%?clpos%)
clpos%+=1
ENDWHILE
=arg$
DEF PROCdecompress(infile$)
LOCAL F%,size%,sqsh%,buf%,worksize%,work%,flags%,in%,in_remain%,discaddr%,O%,stat%,out_end%,unwritten%
F%=OPENIN(infile$)
size%=EXT#F%
DIM sqsh% size%
DIM sqsh% LOCAL size%
SYS "OS_GBPB",4,F%,sqsh%,size%
CLOSE#F%
IF sqsh%!0<>&48535153 THEN PRINT "Compressed file corrupt?" : END
DIM buf% 128*1024
DIM buf% LOCAL 128*1024
SYS "Squash_Decompress",8,-1 TO worksize%
DIM work% worksize%
DIM work% LOCAL worksize%
REM Decompress to temp buffer & write out
flags%=0
......@@ -147,6 +160,7 @@ DEF PROCdecompress(infile$)
ENDPROC
DEF PROCCheckFile(outfile$,infile$)
LOCAL F%,L%
IF infile$="" THEN PRINT "Bad command line parameters" : END
F%=OPENIN(infile$)
IF F%=0 THEN PRINT "File '"+infile$+"' not found" : END
......@@ -163,10 +177,11 @@ DEF PROCCheckFile(outfile$,infile$)
ENDPROC
DEF PROCwrite(infile$)
LOCAL F%,size%,discaddr%,read%,buf%,unread%
PROCdismount
F%=OPENIN(infile$)
size%=EXT#F%
DIM buf% 128*1024
DIM buf% LOCAL 128*1024
discaddr%=0
PRINT "Writing image...";
REPEAT
......@@ -184,6 +199,7 @@ DEF PROCwrite(infile$)
ENDPROC
DEF PROCloadCMOS(infile$)
LOCAL F%,L%,pos%
IF infile$="" THEN PRINT "Bad command line parameters" : END
F%=OPENIN(infile$)
IF F%=0 THEN PRINT "File '"+infile$+"' not found" : END
......@@ -206,8 +222,53 @@ DEF PROCwriteCMOS
ENDPROC
DEF PROCdismount
LOCAL A$
IF disc%=FALSE THEN ENDPROC
REM Fat32Fs may be loaded, make sure that dismounts the drive as well
A$="-Fat32Fs-%dismount :"+STR$ discno%
SYS "XOS_CLI",A$
SYS "XOS_CLI",A$
REM Dismount twice to ensure FileCore forgets the disc
OSCLI("-SCSI-%dismount :"+STR$ discno%)
OSCLI("-SCSI-%dismount :"+STR$ discno%)
A$="-SCSI-%dismount :"+STR$ discno%
OSCLI(A$)
OSCLI(A$)
ENDPROC
DEF PROCCheckDisc
LOCAL buf1%,buf2%,flags%,pos%,bad%,fs%,default%,result%
bad%=FALSE
DIM buf1% LOCAL 4096
DIM buf2% LOCAL 4096
REM Pop up a generic confirmation message
buf1%!0 = 0
$(buf1%+4) = "All existing data on drive "+sdimage$+" will be lost. Proceed?"+CHR$(0)
SYS "Wimp_ReportError",buf1%,&517,"SDCreate","!sdcreate" TO ,result%
IF result%<>1 THEN PRINT "User cancelled operation" : END
REM Check that the selected disc (discno%, sdimage$) is safe to write to
REM i.e. doesn't look like the boot drive!
SYS "XOS_FSControl",37,"<Boot$Dir>",buf1%,,,4096 TO ;flags%
IF (flags% AND 1) = 0 THEN
SYS "XOS_FSControl",37,sdimage$,buf2%,,,4096 TO ;flags%
IF (flags% AND 1) = 0 THEN
pos%=0
WHILE (buf1%?pos% = buf2%?pos%) AND (buf2%?pos%<>ASC("$"))
pos%=pos%+1
ENDWHILE
IF (buf1%?pos%=ASC("$")) AND (buf2%?pos%=ASC("$")) THEN bad%=TRUE
ENDIF
ENDIF
REM Also check configured boot drive?
IF bad%=FALSE THEN
SYS "OS_Byte",161,5 TO ,,fs%
IF fs%=26 THEN
SYS "SCSIFS_Drives" TO default%
IF default%=discno% THEN bad%=TRUE
ENDIF
ENDIF
IF bad%=TRUE THEN
buf1%!0 = 0
$(buf1%+4) = sdimage$+" appears to be the boot drive. Are you sure you want to proceed? All existing data will be lost"+CHR$(0)
SYS "Wimp_ReportError",buf1%,&517,"SDCreate","!sdcreate" TO ,result%
IF result%<>1 THEN PRINT "User cancelled operation" : END
ENDIF
ENDPROC
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment