Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Paul Lynde to block..." -- a contestant on "Hollywood Squares"


computers / comp.sys.apple2 / Detecting sector order of .dsk images

SubjectAuthor
* Detecting sector order of .dsk imagesKent Dickey
+* Re: Detecting sector order of .dsk imagesfadden
|`- Re: Detecting sector order of .dsk imagesKent Dickey
`- Re: Detecting sector order of .dsk imagesmmphosis

1
Detecting sector order of .dsk images

<tlm5s8$f20m$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=4933&group=comp.sys.apple2#4933

  copy link   Newsgroups: comp.sys.apple2
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: keg...@provalid.com (Kent Dickey)
Newsgroups: comp.sys.apple2
Subject: Detecting sector order of .dsk images
Date: Wed, 23 Nov 2022 22:12:24 -0000 (UTC)
Organization: provalid.com
Lines: 99
Message-ID: <tlm5s8$f20m$1@dont-email.me>
Injection-Date: Wed, 23 Nov 2022 22:12:24 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="1874b491ff33fe50252babbb093714da";
logging-data="493590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Bj9vh6ev80IeKb02RDWns"
Cancel-Lock: sha1:+XEO2XBA3RneARFWsfqxEMDAO98=
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: kegs@provalid.com (Kent Dickey)
 by: Kent Dickey - Wed, 23 Nov 2022 22:12 UTC

There was a thread here about detecting the sector ordering of Apple II
5.25" .dsk images (unfortunately under Michael Mahon's FASTCIRC post).

I maintain that .dsk images should always be DOS 3.3 sector order, .do
images are always DOS3.3 sector order, and .po images are always ProDOS
order. All images > 140KB are ProDOS order, as well as any unknown extension
(so harddrive images and 3.5" 800KB images are always ProDOS order).

The ease of creation of ProDOS images with tools like Cadius now means
people are creating many new images on modern computers. If they name
their image files .dsk (which seems like the "right thing to do"), then
they've created new .dsk images in ProDOS order.

A description of sector order is at the end of this message, feel free to
skip it if you know this stuff, or don't care about the details.

As for detection, Applewin uses a simple easy-to-understand algorithm to
determine the sector order of .dsk images:

A .dsk defaults to DOS 3.3 sector order. However, if a DOS 3.3 catalog
track appears to exist on track $11 by looking at the first 2 bytes of
each sector, when assuming the disk is in ProDOS order, then it treats the
..dsk image as ProDOS order. Or, if a ProDOS volume directory appears to be
on blocks 2,3,4,5 on track $00 by looking at the first 4 bytes of each
block when treated as ProDOS order, then the .dsk is treated as ProDOS order.

I like this simple check, since it's looking for well-formed disk images
with normal catalog tracks. This makes sense if a main source of the
images in ProDOS order is modern tools creating these images. If an image
doesn't look like a normal DOS 3.3 disk or ProDOS (say, no OS at all, like
a game would do), then .dsk is always DOS 3.3 sector order.

But this detection seems to have a problem: if a user mounts a prodos1.dsk
created by Cadius in ProDOS order, it will work fine as long as the user
keeps using it as a normal disk. But what if the user then, under
emulation, plays a game which wants to format a save disk to save
progress on, and picks this prodos1.dsk? The resulting image probably
no longer has a valid catalog. Applewin will read and write the
prodos1.dsk image in ProDOS order since that's what it knows to do for
as long as the user runs the game in one session. But when stopped and
restarted later, the .dsk detection routine will now say the prodos1.dsk
image is DOS 3.3 order (since it cannot tell), and the saved game is
lost.

So my proposal: Emulators should support detecting .dsk images as ProDOS,
but should use a very simple check like Applewin's. And if a .dsk image
is determined to be ProDOS order, then the emulator should immediately
re-write the .dsk image file as DOS 3.3 order. If the image is write-
protected or not writeable, then do nothing. This solves the misdetection
problem of using .dsk images in ProDOS order--.dsk is always DOS 3.3 sector
order to the emulator

Kent

----

As background, Apple II 5.25" disks generally contain 16 sectors of 256-bytes
each on 35 tracks. On the physical disk, these sectors have a physical
sector number, counting from 0-15 in order on the disk. DOS 3.3 knew it
could not read adjacent sectors that fast, so it has a table of logical
sectors to physical sectors, to try to give it more time to process
adjacent logical sectors. All DOS 3.3 operations are on logical sectors.

Physical sector: 0 1 2 3 4 5 6 7 8 9 a b c d e f
Logical sector: 0 7 e 6 d 5 c 4 b 3 a 2 9 1 8 f

This arrangement is great for booting DOS 3.3, where it reads logical sector
'f', then 'e', 'd', etc. Once 'f' is found, 'e' is 3 sectors later, and
'd' is 2 sectors after that. That is about as fast as the DOS 3.3 RWTS can
read. It turns out, DOS 3.3's File Manager is so slow that between
reading sectors during LOAD or BLOAD, about half a track passes by while it
twiddles its thumbs between each sector. This is why there are enhanced
DOS's which are more efficient.

ProDOS has a logical 512-byte block. So it needs to map it's blocks to
sectors. Here's that mapping for 5.25" disks.

ProDOS block: 0 1 2 3 4 5 6 7
DOS 3.3 physical sector: 0,2 4,6 8,a c,e 1,3 5,7 9,b d,f
DOS 3.3 logical sector: 0,e d,c b,a 9,8 7,6 5,4 3,2 1,f

In DOS3.3 sector order, the .do image has DOS 3.3 logical sectors 0...f
in ascending order. This is what users would think is the natural order
for sectors since any sector editor would make the disk appear to be in
this order.

In ProDOS block order, a .po image has ProDOS blocks in ascending order 0...7,
which works out to DOS 3.3 logical sectors: 0,e,d,c,b,a,9,8,7,6,5,4,3,2,1,f.

Note the physical sector order does not matter at all for .dsk, .do, or
..po images.

In general, almost all "classic" .dsk images (created more than 20 years ago)
are in DOS 3.3 logical sector order since that's what tools of the time
generally did. But now there are various ways to quickly make ProDOS images
on modern computers--and if users name their files .dsk, then they are
creating .dsk's in ProDOS order.

Re: Detecting sector order of .dsk images

<3ec07805-8fec-4a40-8d0b-33418b755134n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=4934&group=comp.sys.apple2#4934

  copy link   Newsgroups: comp.sys.apple2
X-Received: by 2002:ac8:53da:0:b0:3a5:c1e:d8b with SMTP id c26-20020ac853da000000b003a50c1e0d8bmr30840679qtq.537.1669309470496;
Thu, 24 Nov 2022 09:04:30 -0800 (PST)
X-Received: by 2002:a37:58c7:0:b0:6fa:6fa6:fcb with SMTP id
m190-20020a3758c7000000b006fa6fa60fcbmr16032173qkb.468.1669309470300; Thu, 24
Nov 2022 09:04:30 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.sys.apple2
Date: Thu, 24 Nov 2022 09:04:30 -0800 (PST)
In-Reply-To: <tlm5s8$f20m$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=24.130.68.111; posting-account=UAtoeQoAAADrX7T-MHdWWRC4Fzf0dsLP
NNTP-Posting-Host: 24.130.68.111
References: <tlm5s8$f20m$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ec07805-8fec-4a40-8d0b-33418b755134n@googlegroups.com>
Subject: Re: Detecting sector order of .dsk images
From: thefad...@gmail.com (fadden)
Injection-Date: Thu, 24 Nov 2022 17:04:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1794
 by: fadden - Thu, 24 Nov 2022 17:04 UTC

On Wednesday, November 23, 2022 at 2:12:26 PM UTC-8, Kent Dickey wrote:
> [...]And if a .dsk image
> is determined to be ProDOS order, then the emulator should immediately
> re-write the .dsk image file as DOS 3.3 order. If the image is write-
> protected or not writeable, then do nothing.

That should probably be preceded by a dialog box with 3 options: (1) rewrite the disk; (2) rename the image file to have the correct extension; (3) leave the disk image alone and come what may. Rearranging the image order without asking permission seems... rude.

Or maybe just offer #2 and #3, since #1 seems like more work for a less-desirable outcome.

Re: Detecting sector order of .dsk images

<mmphosis-1669412342@macgui.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=4937&group=comp.sys.apple2#4937

  copy link   Newsgroups: comp.sys.apple2
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mmpho...@macgui.com (mmphosis)
Newsgroups: comp.sys.apple2
Subject: Re: Detecting sector order of .dsk images
Date: Fri, 25 Nov 2022 21:39:04 -0000 (UTC)
Organization: Mac GUI
Lines: 119
Message-ID: <mmphosis-1669412342@macgui.com>
References: <tlm5s8$f20m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 25 Nov 2022 21:39:04 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="8d8faa2449089bbe2aaf7112b15170db";
logging-data="1157740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CAAGzc9nA3noO8jbtwMmc"
User-Agent: Mac GUI Usenet
Cancel-Lock: sha1:9SOo5/0FlIl0DTthZP/O2uDqckw=
In-Reply-To: <tlm5s8$f20m$1@dont-email.me>
 by: mmphosis - Fri, 25 Nov 2022 21:39 UTC

Kent Dickey wrote:
> There was a thread here about detecting the sector ordering of Apple II
> 5.25" .dsk images (unfortunately under Michael Mahon's FASTCIRC post).
>
> I maintain that .dsk images should always be DOS 3.3 sector order, .do
> images are always DOS3.3 sector order, and .po images are always ProDOS
> order. All images > 140KB are ProDOS order, as well as any unknown
> extension
> (so harddrive images and 3.5" 800KB images are always ProDOS order).
>
> The ease of creation of ProDOS images with tools like Cadius now means
> people are creating many new images on modern computers. If they name
> their image files .dsk (which seems like the "right thing to do"), then
> they've created new .dsk images in ProDOS order.
>
> A description of sector order is at the end of this message, feel free to
> skip it if you know this stuff, or don't care about the details.
>
> As for detection, Applewin uses a simple easy-to-understand algorithm to
> determine the sector order of .dsk images:
>
> A .dsk defaults to DOS 3.3 sector order. However, if a DOS 3.3 catalog
> track appears to exist on track $11 by looking at the first 2 bytes of
> each sector, when assuming the disk is in ProDOS order, then it treats the
> .dsk image as ProDOS order. Or, if a ProDOS volume directory appears to
> be
> on blocks 2,3,4,5 on track $00 by looking at the first 4 bytes of each
> block when treated as ProDOS order, then the .dsk is treated as ProDOS
> order.
>
> I like this simple check, since it's looking for well-formed disk images
> with normal catalog tracks. This makes sense if a main source of the
> images in ProDOS order is modern tools creating these images. If an image
> doesn't look like a normal DOS 3.3 disk or ProDOS (say, no OS at all, like
> a game would do), then .dsk is always DOS 3.3 sector order.
>
> But this detection seems to have a problem: if a user mounts a prodos1.dsk
> created by Cadius in ProDOS order, it will work fine as long as the user
> keeps using it as a normal disk. But what if the user then, under
> emulation, plays a game which wants to format a save disk to save
> progress on, and picks this prodos1.dsk? The resulting image probably
> no longer has a valid catalog. Applewin will read and write the
> prodos1.dsk image in ProDOS order since that's what it knows to do for
> as long as the user runs the game in one session. But when stopped and
> restarted later, the .dsk detection routine will now say the prodos1.dsk
> image is DOS 3.3 order (since it cannot tell), and the saved game is
> lost.
>
> So my proposal: Emulators should support detecting .dsk images as ProDOS,
> but should use a very simple check like Applewin's. And if a .dsk image
> is determined to be ProDOS order, then the emulator should immediately
> re-write the .dsk image file as DOS 3.3 order. If the image is write-
> protected or not writeable, then do nothing. This solves the misdetection
> problem of using .dsk images in ProDOS order--.dsk is always DOS 3.3
> sector
> order to the emulator
>
> Kent
>
> ----
>
> As background, Apple II 5.25" disks generally contain 16 sectors of
> 256-bytes
> each on 35 tracks. On the physical disk, these sectors have a physical
> sector number, counting from 0-15 in order on the disk. DOS 3.3 knew it
> could not read adjacent sectors that fast, so it has a table of logical
> sectors to physical sectors, to try to give it more time to process
> adjacent logical sectors. All DOS 3.3 operations are on logical sectors.
>
> Physical sector: 0 1 2 3 4 5 6 7 8 9 a b c d e f
> Logical sector: 0 7 e 6 d 5 c 4 b 3 a 2 9 1 8 f
>
> This arrangement is great for booting DOS 3.3, where it reads logical
> sector
> 'f', then 'e', 'd', etc. Once 'f' is found, 'e' is 3 sectors later, and
> 'd' is 2 sectors after that. That is about as fast as the DOS 3.3 RWTS
> can
> read. It turns out, DOS 3.3's File Manager is so slow that between
> reading sectors during LOAD or BLOAD, about half a track passes by while
> it
> twiddles its thumbs between each sector. This is why there are enhanced
> DOS's which are more efficient.
>
> ProDOS has a logical 512-byte block. So it needs to map it's blocks to
> sectors. Here's that mapping for 5.25" disks.
>
> ProDOS block: 0 1 2 3 4 5 6 7
> DOS 3.3 physical sector: 0,2 4,6 8,a c,e 1,3 5,7 9,b d,f
> DOS 3.3 logical sector: 0,e d,c b,a 9,8 7,6 5,4 3,2 1,f
>
> In DOS3.3 sector order, the .do image has DOS 3.3 logical sectors 0...f
> in ascending order. This is what users would think is the natural order
> for sectors since any sector editor would make the disk appear to be in
> this order.
>
> In ProDOS block order, a .po image has ProDOS blocks in ascending order
> 0...7,
> which works out to DOS 3.3 logical sectors:
> 0,e,d,c,b,a,9,8,7,6,5,4,3,2,1,f.
>
> Note the physical sector order does not matter at all for .dsk, .do, or
> .po images.
>
> In general, almost all "classic" .dsk images (created more than 20 years
> ago)
> are in DOS 3.3 logical sector order since that's what tools of the time
> generally did. But now there are various ways to quickly make ProDOS
> images
> on modern computers--and if users name their files .dsk, then they are
> creating .dsk's in ProDOS order.
>

Very cool little explanation of sector ordering.

The physical disk is actually circular. Could you write a fast program to
draw an image of the disk using HGR graphics?

mmphosis

Re: Detecting sector order of .dsk images

<tmatpn$2rpt9$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=4953&group=comp.sys.apple2#4953

  copy link   Newsgroups: comp.sys.apple2
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: keg...@provalid.com (Kent Dickey)
Newsgroups: comp.sys.apple2
Subject: Re: Detecting sector order of .dsk images
Date: Thu, 1 Dec 2022 19:03:19 -0000 (UTC)
Organization: provalid.com
Lines: 27
Message-ID: <tmatpn$2rpt9$1@dont-email.me>
References: <tlm5s8$f20m$1@dont-email.me> <3ec07805-8fec-4a40-8d0b-33418b755134n@googlegroups.com>
Injection-Date: Thu, 1 Dec 2022 19:03:19 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="8a6b7875296928ff9d86eab18fb1e88e";
logging-data="3008425"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/21Io+6SJRYrIlnzbWdXIH"
Cancel-Lock: sha1:BwasCW8lfivrcTuQ2WJTqRqeca0=
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: kegs@provalid.com (Kent Dickey)
 by: Kent Dickey - Thu, 1 Dec 2022 19:03 UTC

In article <3ec07805-8fec-4a40-8d0b-33418b755134n@googlegroups.com>,
fadden <thefadden@gmail.com> wrote:
>On Wednesday, November 23, 2022 at 2:12:26 PM UTC-8, Kent Dickey wrote:
>> [...]And if a .dsk image
>> is determined to be ProDOS order, then the emulator should immediately
>> re-write the .dsk image file as DOS 3.3 order. If the image is write-
>> protected or not writeable, then do nothing.
>
>That should probably be preceded by a dialog box with 3 options: (1)
>rewrite the disk; (2) rename the image file to have the correct
>extension; (3) leave the disk image alone and come what may.
>Rearranging the image order without asking permission seems... rude.
>
>Or maybe just offer #2 and #3, since #1 seems like more work for a
>less-desirable outcome.

OK, I'll move to option 4):

When a .dsk image is mounted and is detect to be ProDOS-ordered, the
internal image will be swapped to be DOS-ordered, but not written back to
the host yet. When ANY write to the image occurs and would update the
host copy, the entire image will be written to the host in DOS-order.

If you never write to the disk image in any way, the host copy is untouched.
If you write to it in any way, the host copy becomes DOS-ordered.

Kent

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor