Date : Mon, 18 May 2009 01:43:57 +0100
From : jgh@... (Jonathan Graham Harston)
Subject: IMG Disk Format
"Mark Haysman" wrote:
> I'm trying to add software support to a program for .SSD, .DSD and .IMG.
I updated BeebArc to recognise a greater mixture of images, at
<http://mdfs.net/Apps/FileUtils> using the following code.
On entry, I%=handle of open image file
On exit, dsd%=FALSE, sequential, dsd%=TRUE, interleaved
fsid%=0=dfs31, 1=dfs62, 2=adfs, 3=hadfs
DEFPROCidentifyimage(I%) :REM Make an educated guess at
the image type
LOCAL a$
dsd%=FALSE:dbl%=FALSE:fsid%=0 :REM DFS31 sequential
IF EXT#I%>&4700 THEN
a$="":PTR#I%=&4610:FOR A%=0 TO 7:a$=a$+CHR$BGET#I%:NEXT
IF a$=CHR$0+"(C)JGH"+CHR$0:fsid%=3:dsd%=FALSE :REM HADFS sequential
ENDIF
IF EXT#I%>&8D00 AND fsid%=0 THEN
a$="":PTR#I%=&8C10:FOR A%=0 TO 7:a$=a$+CHR$BGET#I%:NEXT
IF a$=CHR$0+"(C)JGH"+CHR$0:fsid%=3:dsd%=TRUE :REM HADFS interleaved
ENDIF
IF EXT#I%>&400 AND fsid%=0 THEN
a$="":PTR#I%=&200:FOR A%=0 TO 7:a$=a$+CHR$BGET#I%:NEXT
IF a$=STRING$(8,CHR$&AA):fsid%=1:dsd%=FALSE :REM DFS62 sequential
ENDIF
IF EXT#I%>&D00 AND fsid%<2 THEN
a$="":PTR#I%=&C00:FOR A%=0 TO 7:a$=a$+CHR$BGET#I%:NEXT
IF a$=STRING$(8,CHR$&AA):fsid%=1:dsd%=TRUE :REM DFS62 sequential
ENDIF
IF EXT#I%>&700 AND fsid%=0 THEN
a$="":PTR#I%=&201:FOR A%=0 TO 3:a$=a$+CHR$BGET#I%:NEXT
IF a$="Nick" OR a$="Hugo":fsid%=2:PROCcheckadfs:ENDPROC :REM ADFS sequential
ENDIF
IF fsid%=0 THEN
PTR#I%=&106:L%=(BGET#I% AND 15)<<16 OR BGET#I%<<8
IF L%<EXT#I% THEN dsd%=TRUE :REM DFS interleaved
:REM ** or sequential
<side0><side1> **
ENDIF
ENDPROC
DEFPROCcheckadfs
LOCAL p%,z%,b%
dsd%=FALSE
p%=&205:REPEAT
PTR#I%=p%:z%=BGET#I%
IF z% THEN
PTR#I%=p%+3:b%=BGET#I%
IF (b%AND128) THEN
PTR#I%=p%+&16:b%=BGET#I%+256*BGET#I%+65536*BGET#I%
IF b%<&32000 THEN
b%=(b%AND15)+(b%DIV16)*32
PTR#I%=b%*256+1:a$="":FOR A%=0 TO 3:a$=a$+CHR$BGET#I%:NEXT
IF a$="Nick" OR a$="Hugo":dsd%=TRUE
ENDIF
ENDIF
ENDIF
p%=p%+26
UNTIL dsd% OR z%=0 OR p%>=&6CB
ENDPROC
--
J.G.Harston - jgh@... - mdfs.net/User/JGH
The most perfect world is an imperfect world as the imperfections
give people a reason to strive to change it.