SAMview - SAM Coupé DiskImage Viewer

Version 1.0 - (C) 2006 by Klemens Czajka


INTRODUCTION

SAM Coupé DiskImage Viewer is a PC Windows application provided to view and inspect contents of disk images of diskettes used with SAM Coupé home computer.
Diskimage is a PC Windows file that reflects 2-sided, 80-track disk with 10 (or 9) 512-byte sectors per track. It can appear in few different formats:

.SAD - Aley Keprt's image with 22-byte prefix describing disk geometry. Sectors in the image are in the order:
side0.trk0.sector1,...,side0.trk0.sector10(or9),
side1.trk0.sector1,...,side1.trk0.sector10(or9),
side0.trk1.sector1,...,side0.trk1.sector10(or9),
side1.trk1.sector1,...,side1.trk1.sector10(or9), ... and so on.

.IMG - like .SAD format, but without 22-byte prefix

.DSK - (but not EDSK) SAM disk image compatible with the /dev/fd0u800 device under Linux. Sectors in the image are in the order:
side0.trk0.sector1,...,side0.trk0.sector10(or9),
side0.trk1.sector1,...,side0.trk1.sector10(or9), ... and so on side 0,
side1.trk0.sector1,...,side1.trk0.sector10(or9),
side1.trk1.sector1,...,side1.trk1.sector10(or9), ... and so on side 1.

.MGT - DISCiPLE/PlusD image format used with ZX Spectrum. Compatible with .DSK

Diskimage can contain files from SAMDOS, MasterDOS and B-DOS operating systems (generally the DISCiPLE/PlusD format used with ZX Spectrum), or files of Pro-DOS 1.9 (SAM version of CP/M 2.2) operating system. SAMview recognizes disks with 9 sectors per track as Pro-DOS disks, and disks with 10-sectors per track as disks of SAMDOS family. Generally disks should be 2-sided, 80-track, 10-sectors/track (9 for Pro-DOS), 512-byte sector, but SAMview reads also SAMDOS diskimages up to 85 tracks per side.
If a diskimage can't be read, contains no data, or has many errors, then try to BOOT it in SimCoupe emulator. It may be protected disk or specially written to increase its capacity.
It is assumed you have already transferred real SAM disks to diskimages on your PC. There are many utilities that can be used: SimCoupe emulator, Edwin Blink's Disk Image Manager, Aley Keprt's utilities, or you can find other proper tools in Internet:

http://www.simcoupe.org - SimCoupe Homepage
http://www.simcoupe.org/cpdtools.zip - CPDRead/CPDWrite for EDSK images and copy-protected disks
http://home.wanadoo.nl/edwin.blink/samcoupe - Blinky's SAM coupé page
http://www.keprt.cz/progs/samutils/readme.html - Aley's Sam Utils
http://www.worldofsam.org - World of Sam archive
ftp://ftp.nvg.ntnu.no/pub/sam-coupe - SAM Coupé FTP catalog


INSTALLATION

The installation package consists of the following files:

SAMview.exe  - execution file (you can create Windows shortcut to it, if you need)
SAMviewH.htm - general help file (used from menu "Help / General")
fontBLK0.gif - general help illustration
fontBLK1.gif - general help illustration
fontBLK2.gif - general help illustration
fontZXS.gif  - general help illustration

SAMBLK0.fon  - optional "SAMcoupe BLOCK 0" font ready to install in Windows
SAMBLK1.fon  - optional "SAMcoupe BLOCK 1" font ready to install in Windows (default)
SAMBLK2.fon  - optional "SAMcoupe BLOCK 2" font ready to install in Windows
SAMSPECT.fon - optional "SAMcoupe ZXSpectrum" font ready to install in Windows

SAM Coupé DiskImage Viewer is ready to run immediately after loading it into a folder, but you can do additional actions:


DE-INSTALLATION

To de-install SAMview you should:


USING

SAMview is a menu driven application. Almost all the functions available have appropriate menu items, which can be selected from keyboard with ALT plus underlined menu letters. In the main window SAMview displays the contents of the opened disk or the contents of a file on the disk.

The disk contents can be shown in the "flat directory mode" in which all files are visible regardless of containing subdirectory, or in the "current directory mode" in which only files from the current subdirectory are visible.

SAMview notes you with the view background what type of disk (SAMDOS or CP/M), or what type of file view (BASIC, SCREEN$, TEXT, etc) you are looking at.

You can use SAMview to extract some files to PC Windows environment with "File / Extract file". You can also use file view of SAMview and copy displayed text or picture to the Windows clipboard.

SAMview makes intensive disk error checking. Despite of this there is a possibility of some surprise. Some data are not checked, but are displayed in a way discovering potential inconsistencies. You should take care and do not modify original disk, as there is a possibility of undefined or non-documented bits in it. Modifications can be done with "DiskImage / Change diskimage", "File / Change file ...", "File / Delete file" and "File / Implant file". Below is the list of recognized errors for Pro-DOS and then for SAMDOS disks:


"Disk size, Users (should be 0 (blank), or 1 to 15)"
Disk has not exactly 80 tracks per side, or Pro-DOS user area for a file is out of range 0 to 15.

"File entries validity (names, zeroed SYS fields, duplicates)"
File name is invalid, or there are duplicate file names in the Pro-DOS disk, or reserved bytes in directory entry are not zeroed.

"Extents (completeness and consistency of file extent chains)"
Duplicate or missing extents for file in Pro-DOS (One extent is one directory entry corresponding to maximum 16 KiB of data. Large files have more than one extent.)

"Records v Extents (consistency of records, blocks and extents)"
Incorrectly filled file extent entries, or file extent entry points to Data Allocation Blocks outside of disk data space. (Data Allocation Block is 2-KiB data space containing up to 16 logical 128-byte records.)

"Intersections (muddled, criss-crossing files, common blocks)"
Some Data Allocation Blocks are allocated to files more than once. All criss-crossing files are flagged with error icons.


"Disk size, Directory size, Directory end v last file entry"
Disk has not exactly 80 tracks per side, or MasterDOS disk directory has more than 39 tracks, or there is a file entry in the non-searched part of directory space. (SAMDOS assumes all directory slots after the first never used were also never used.)

"File entries validity (names, types, duplicates)"
File name is invalid, or file type is unknown, or erased file has assigned flags PROTECTED or HIDDEN, or there are duplicate file names in the same subdirectory. Note, file name may be valid in SAMDOS but not in MasterDOS. SAMview checking is more restrictive to not allow for example slashes used by MasterDOS in subdirectory paths.

"Paths consistency (does exist unique parent directory)"
Directory or subdirectory has an alias names, or there is no parent directory for a file or subdirectory, or a directory is the subdirectory of itself (may be indirectly).

"Allocation Map and Data Block Chains consistency, Far blocks"
Number of sectors in directory entry, number of bits in sector allocation map and number of sectors or sector numbers in file sector chain do not agree. The error is also for files having sectors out of 80-track data space, and for subdirectories that have data space assigned like normal files.

"Intersections (muddled, criss-crossing files, common blocks)"
Some sectors are allocated several times to files and disk directory. All criss-crossing files are flagged with error icons.


MENU

DiskImage

DiskImage / New diskimage
I suggest you use new blank diskimage for some critical operations (to implant external files for example).

DiskImage / Open diskimage
After opening a diskimage, the disk name is displayed at the beginning of a current path on the toolbar. In case the disk has no name, there is an asterisk with a name of the operating system used to format it. SAMview automatically recognizes type of disk and operating system.
If you associate appropriate diskimage formats to SAMview, you will be able to run SAMview with double-clicking on the diskimage.

DiskImage / Save diskimage
The option of in-place saving is inactive in this version of SAMview.

DiskImage / Save diskimage As ...
I recommend to not save over the original image. Saving a diskimage under the same or new name resets internal "changed" status.

DiskImage / General Information
You can find here a categorized information about recognized disk errors. Some errors, such as too many disk tracks or too large or small directory, relate to disk as a whole and not to any file. Other are propagated from file related errors. Erroneous files are indicated with error icons in a disk view.

DiskImage / Change diskimage
Changes to diskimage do not apply to Pro-DOS disks.
The option allows you in particular to decrease size of MasterDOS disk directory if possible.
Changes are disallowed when there are errors recognized on the disk or disk has abnormal geometry. You may be irritated for example with disk error status from a file name having characters illegal in MasterDOS; this is because SAMview checks more restrictive than SAMDOS, and allows mixture of files from SAMDOS, MasterDOS and B-DOS. Some changes, as disk format for example, can be disallowed because appropriate disk fields contain unknown non-zero bits.

DiskImage / Exit
Leaving the changed disk gives you the possibility to save or discard changes made to the diskimage before opening new image or exit the program.


File

File / View file
This shows the formatted contents of the selected file. Available formats are: BASIC, COMET Assembler, TEXT, HEXADECIMAL, TEXT ARRAY, NUMERIC ARRAY, SCREEN and FONT.
Double-clicking a file name (which is an equivalent of "File / View file") shows the contents of the file in the default or assumed view format. For example, if you double-click file name "xxxxxxxx.s" or "xxxxxxxx.b" of type CODE, SAMview assumes this is a COMET Assembler source or backup file, and tries to view in a COMET format. If it recognizes some errors in such a file, then automatically reverts to the TEXT format (which is default for CODE files). Some other CODE file may be assumed to be SCREEN dump or FONT data.
Compressed files, i.e. files saved with SAVE MODE 2 or 3, are the exceptions - default and only available for them is the HEXADECIMAL format.
If you double-click on a subdirectory name, then SAMview automatically changes to "current directory mode" as "Directory / Current directory mode" makes, and shows the subdirectory contents.
You can exit from file view with "Directory / Up to parent directory".
In a file view you can copy selected part of the text or the picture to clipboard (CTRL+C) or save the picture as a .BMP file (CTRL+S). There is a right button context menu in the file view.

File / View ... as ... _
You have the possibilities to select other than assumed or default view format, however inapplicable formats are inactive in the menu.

File / General Information
Here you can also find categorized information about recognized file errors. Erroneous file in a disk view has error icons next to the:
- Size - if there are errors in assignment of blocks (sectors) or Pro-DOS extents to file,
- *128 / *512 - if file data block are muddled, criss-crossing or common with other files,
- # / User - if there are other errors regarding the file or subdirectory.

File / Change file
This option may be used to rename file or change file attributes. But sorry, invalid file name can't be changed as it may be some kind of disk protection. If needed, you can use SimCoupe emulator.
The option can also be used to move file to another subdirectory by simply writing or changing directory path before file name in the dialog box, in the way similar to MasterDOS: arrow-up or caret (^) at the beginning of the path points to upper directory, and slash (/) or backslash (\) at the beginning points to the root directory. In the flat directory mode the current directory is the root directory, so you must give a full path. In the current directory mode you can add path relative to the current directory (see the "Directory" menu).

File / Delete file
You can delete a file or an empty subdirectory. It is unable to restore deleted file with SAMview unless you do not save the diskimage.

File / Extract file
Copies SAMDOS or Pro-DOS file to PC Windows. Files of type with 9-byte prefix (BASIC, D.ARRAY, $.ARRAY, CODE and SCREEN$) are copied without it.

File / Implant file
Copies PC Windows file into SAM disk as a new file of type CODE. The file will be stored under original name in the current subdirectory, and will be given default 9-byte prefix. Thus implanted file name must conform MasterDOS naming rules. To change the 9-byte prefix you can use SimCoupe emulator to LOAD and SAVE the file under adequate operating system.


Directory

Directory / Up to parent directory
This option is impotent for directory view in the flat directory mode. For directory view in the current directory mode it shows the contents of the upper directory and points to the leaved subdirectory.
For a view of a file contents it exits from file view and returns to directory view.

Directory / Flat directory mode
Switches view in such a way that all disk files are visible regardless of the subdirectories. Previously selected file or current directory remains selected. The view is similar to SAMDOS view. It gives simple and easy orientation in the disk contents.

Directory / Current directory mode
Switches view in such a way that only contents of the current directory is visible. This is similar to MasterDOS directory view. Directory view is automatically switched to the "current directory mode" when you select to view (or double-click) a subdirectory item.


Options

Options / Set font for text view
This option is useful to adapt text view (BASIC, COMET, TEXT, HEXADECIMAL, TEXT/NUMERIC ARRAY DATA) to a SAM character set. You can choose from fixed pitch fonts installed in Windows. Font setting applies to text views of file and to disk:\path\filename information displayed on toolbar. SAMview fonts are described later.

Options / Wrap text view lines
Can be useful in reading long lines in text view (BASIC, COMET, TEXT, HEXADECIMAL, TEXT/NUMERIC ARRAY DATA).

Options / Indent BASIC program
Switches BASIC program source text formatting, like LIST FORMAT 0 and 2, to increase readability.

Options / Decode FUNCTIONS in SAM BASIC texts
Some bytes in character strings or REMs in SAM BASIC can be interpreted as either characters or BASIC functions. This options switches the interpretation for SAM BASIC files; for ZX BASIC files the function codes are always recognized. Switch this option off only if the code 0xFF is used as a normal character. When interpreted, function code is listed as function name in brackets.

Options / Decode KEYWORDS in SAM BASIC texts
Some bytes in character strings or REMs in SAM BASIC can be interpreted as either characters or BASIC statement keywords. This options switches the interpretation for SAM BASIC files; for ZX BASIC files the statement keyword codes are always recognized. Switch this option on if you can see some strange, unexpected characters in strings. When interpreted, keyword code is listed as keyword in brackets.

Options / Decode CTRL codes in BASIC texts
BASIC string constants or REM comments can contain some control codes, which can give some effects (color, blink, etc.) when printed or listed. With this option you can discover control codes contained in string constants and REMs, or hide them for better readability. Control codes not contained in string constants or REMs are controlled with the next option. Control codes appear as character symbols with appropriate arguments in brackets.
One of the control codes is the hidden value of a numeric constant. Character appearance of a numeric constant is used in listings, while hidden value in computations during BASIC program execution. SAMview compares hidden value of the constant with its character denotation. If they do not compare (i.e. the relative difference is greater than 0.000000001) then the hidden value is listed in braces just behind the constant, discovering this kind of protection. This checking can not be deactivated.

Options / Decode Highlights of BASIC statements
BASIC statements can contain some control codes, which can color the program or give other highlights. With this option you can discover control codes not contained in string constants or REMs, or hide them for better readability. Control codes contained in string constants or REMs are controlled with the previous option. Control codes appear as character symbols with appropriate arguments in brackets.

Options / Stretch screen pixels to 5:4
SAM screen pixels are not quite square, so the SCREEN view can look as on real SAM with this option.

Options / Associations of diskimages
With this option you can associate SAMview and icons to different formats of diskimages. Because associations write informations to Windows registry, you should follow the DE-INSTALLATION guidelines at the time of deinstallation of SAMview to not garbage the registry.


Help

Help / About
Displays information about the version of SAMview.

Help / General
Displays this description of SAMview in .HTM format.



TOOLBAR

Toolbar buttons are the equivalents of menu items:

There is also the current directory path and file name next to the buttons. Disk:\path\filename information is displayed with the font selected in "Options / Set font for text view".


DIRECTORY VIEW

If you open a diskimage then the contents of the disk, its directory, is displayed below the toolbar. The directory view uses default Windows font (even for file names) and not the font selected in "Options / Set font for text view". If there are disk errors associated with files, then error icons appear next to the file informations. You can sort the directory by clicking on the appropriate column header. Each click changes to sorted ascending, then to sorted descending, and again to unsorted. Below are some notes to directory view columns.

ColumnNotes
UserThe Pro-DOS user area the file is assigned to.
#The file number (directory slot number) that is used in SAMDOS in the LOAD command.
FilenameThe file name with the Windows system font. Selected file name is also displayed on the toolbar with font selected from menu "Options / Set font for text view".
*128The number of Pro-DOS 128-byte logical sectors.
*512The number of SAMDOS 512-byte sectors. Each sector contains 510 bytes of data, except the first one, which can have 9-byte file header.
SizeThe file length in bytes. For SAMDOS file, size is not simply a multiple of the number of sectors as it is for Pro-DOS. 9-byte prefix (for BASIC, D.ARRAY, $.ARRAY, CODE and SCREEN$ file) does not count into the size. The size is the length of decompressed file if it is the case.
TypeThe fundamental file attribute in SAMDOS, while only .COM and .BAT are meaningful in Pro-DOS.
ExecA line of BASIC program or an address for CODE program at which it autoruns at load time.
DetailsInformations specific to file type:
PD=123is MasterDOS parent directory internal identifier. Not displayed for files in the current directory.
ID=123is MasterDOS directory internal identifier for subdirectory.
A=123456is default address at which CODE file or ZX SCREEN file or ZX EXECUTE file will be LOADed.
B=123456is SAM BASIC or ZX BASIC program length without any variables.
+V=123456is SAM BASIC program length with numeric variables.
+G=123456is SAM BASIC program length with numeric variables and gap before strings and arrays. Full length with all variables is in "Size" column.
text$is the BASIC name of a string variable saved in a file.
chars$(12,12,...)is the BASIC name of a character array with the extents of all dimensions.
numbers(12,12,...)is the BASIC name of a numeric array with the extents of all dimensions.
Mode4/3/2/1is screen mode of SAM SCREEN file.
R=hexadecimal...is data loaded into Z80 registers (IY IX DE' BC' HL' AF' DE BC HL I SP) for ZX SNP48 and ZX SNP128 snapshots.
AttributesThe letter P for protected, H for hidden, and A for archive of Pro-DOS file attributes.
AttrFlagsThe letter P for protected and H for hidden of SAMDOS file attributes, and 2/3 for SAVE MODE compression, N for not stoppable, and T for TPROMPTS of SAMDOS file flags.
Date/Time stampThe date/time that can be less or more precise according to internal format.

You can select a file with one click on the file name. Some menu operations can be done only on the selected file.
Double-clicking on a file name enters into file view, as "File / View file" makes.


FILE VIEW

File view in assumed or default format is entered with double-clicking on a file name or from menu "File / View file" for selected file. If you need another view format, you can select it from menu. File view replaces the directory view in the program window. You can exit from a file view with "Directory / Up to parent directory" menu or button.

In a file view you can copy selected part of the text or the picture to Windows clipboard (CTRL+C) and then paste it in the Notepad or Paint for example. You can also save the picture as a .BMP file (CTRL+S). There is a mouse right button context menu in the file view.

You can also change the "Options" to customize the view to your needs.


STATUS INFORMATION

Status line at the bottom of program window gives basic disk informations:
Disk formatOperating system used to format the disk: Pro-DOS, SAMDOS, MasterDOS, B-DOS
Error indicatorIndication OK if the disk has no error recognized, or ERROR if there are some errors found on the disk (whole the status line is displayed on red background in this case).
Number of filesNumber of files on the disk (in the flat directory mode), or number of files in the current subdirectory and on the whole disk (in the current directory mode).
Number of directory slotsNumber of free and all slots in the disk directory.
Disk data spaceSize of free and all the disk data space in KiBytes, i.e. excluding directory and system reserved space.


SAM CHARACTER SET

You can select appropriate fixed pitch font to adapt file view and disk:\path\filename information to your SAM environment. There are four fonts prepared to use with SAMview, which you can further adapt to your needs. They are based on IBM Code Page 437 and differ only in the yellow and orange fields. Point the cursor on the chosen character in the below character tables to see additional information:

"SAMcoupe BLOCK 1" font (default)
SAM character set possible after BLOCK 1 command Control codes Comma Tabulation control code Edit key code Cursor Left control code Cursor Right control code Cursor Down control code Cursor Up control code Delete Left control code Return (Carriage Return) control code Delete Right control code Key Pad Toggle control code PEN[i] or INK[i] control code PAPER[p] control code FLASH[f] control code BRIGHT[b] control code INVERSE[v] control code OVER[o] control code AT[r,c] control code TAB[tt] control code Cursor Word Left control code Cursor Word Right control code Control codes ASCII characters ASCII Caret instead of SAM Arrow SAM Pound instead of ASCII Grave Accent SAM Copyright instead of ASCII Delete BLOCK 1 block shapes UDG characters;
 Polish characters' assignments used by me HUDG characters (IBM Code Page 437) HUDG character or
 SAM BASIC function indicator

"SAMcoupe BLOCK 0" font
SAM character set possible after BLOCK 0 command Control codes and ASCII characters UDG character defined in SAM ROM:
 Lower-Case cursor UDG character defined in SAM ROM:
 Upper-Case cursor UDG character defined in SAM ROM:
 'é' in the name 'SAM Coupé' UDG characters;
 Polish character set Mazovia (known as CP620) HUDG characters (IBM Code Page 437)

"SAMcoupe BLOCK 2" font
SAM character set possible after BLOCK 2 command in MasterBASIC Control codes and ASCII characters UDG characters defined in MasterBASIC:
 (IBM Code Page 437) UDG character:
Euro instead of IBM CP437 Pound defined in MasterBASIC HUDG character defined in MasterBASIC:
 Lower-Case cursor HUDG character defined in MasterBASIC:
 Upper-Case cursor HUDG characters (IBM Code Page 437)

"SAMcoupe ZXSpectrum" font
ZX Spectrum character set with possible UDG graphics Control codes and ASCII characters Block shapes UDG graphics in ZX Spectrum IBM Code Page 437 characters


DISCLAIMER

THIS PROGRAM AND DOCUMENTATION ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. BY USING THE PROGRAM, YOU AGREE TO BEAR ALL RISKS AND LIABILITIES ARISING FROM THE USE OF THE PROGRAM AND DOCUMENTATION AND THE INFORMATION PROVIDED BY THE PROGRAM AND THE DOCUMENTATION.