Nibble Histogram: the seeds of a disk-o-scope

What is the distribution of raw nibble values of the bitstream a Disk ][ controller would read from an ordinary DOS diskette?

What values would arise from a copy-protected game disk?  Or from a .DSK emulation of a diskette?

This little routine captures incoming nibbles and computes a moving-window histogram of their distribution.  The data usually stablizes after about 8 calls because it applies a base-2 logarithmic decay to the values after each iteration.

 

It turned out to be really tedious to call the routine (repeatedly) from the monitor...and then manually print the results on the screen.  And I couldn't type elaborate monitor commands while exercising the routine because the capture routine uses half of the keyboard buffer to store its samples.

So, this second routine prints all the nibble-counts on the screen...and distinguishes rising values from falling values by switching between INVERSE and NORMAL mode.

 

The print routine made it easy to throw together this BASIC program that collects samples (via CALL 768) and prints a running count of the moving average (via CALL 768+32).

 

The program samples whatever disk happens to be in the drive, counts instances of each nibble, and prints a running total in a table.  The hexadecimal totals are organized in a hexadecimal table.  That is to say, if you want to know how many instances there were of the $96 nibble, look at the hexadecimal value in row 90 column 06.  It's not a true histogram, but the table contains the raw values you might feed into a proper histogram.

Here's track 17, the directory track, of a DOS 3.3 data disk:

 

Here's track 17, the directory track, of a FloppyEmu DSK image

 

Nibble counts of an RWTS18 track.  (From side A of Prince of Persia)

 

It's not very pretty so far, but it's surprisingly interesting.

Dynamically switching beween NORMAL vs INVERSE really doesn't help.  The totals flicker distractingly between NORMAL and INVERSE without communicating any helpful information. 

Next time I will try using NORMAL vs INVERSE to distinguish "normal nibble values" from so-called illegal ones.