%TITLE          "XDIR - Atari XL/XE DIsk manageR - CHiPS bv 1997"
;**********************************************************************
;**                                                                  **
;**  Program   : XDIR v10.05.00                                      **
;**  Purpose   : Atari XL/XE Disk Manager                            **
;**                                                                  **
;**  Author    : B.F. Schreurs                                       **
;**              Computer High Performance Software (CHiPS) bv       **
;**  Date      : November 19th, 1997                                 **
;**                                                                  **
;**  Calls     : DC_DIRS  - Determine Current Directories            **
;**              DC_DRV   - Determine Current Drives                 **
;**              DC_FILES - Determine Current Files                  **
;**              FMSIO    - File Management System Handler           **
;**              HEX2DIGI - Convert Hex Data To Digits (Text)        **
;**              TO_UPPER - Convert a string to uppercase            **
;**              WSIO     - Screen Handler                           **
;**                                                                  **
;**  Language  : Turbo Assembler                                     **
;**                                                                  **
;**  CLI syntax: XDIR Indisk Outlib                                  **
;**              i.e.                                                **
;**              XDIR C:\XLDISKS\020.ATR C:\XLFILES\                 **
;**              i.e.                                                **
;**              Indisk  = C:\XLDISKS\020.ATR                        **
;**              Outlib  = C:\XLFILES\                               **
;**                                                                  **
;**********************************************************************
        IDEAL
        JUMPS

;----------------------------------------------------------------------
;--  Equates                                                         --
;----------------------------------------------------------------------
include ".\equ\attrib.equ"
include ".\equ\dos.equ"
include ".\equ\equipmnt.equ"
include ".\equ\fmsio.equ"
include ".\equ\keyboard.equ"
include ".\str\psp.str"
include ".\equ\sysdep.equ"
include ".\equ\video.equ"
include ".\equ\wsio.equ"

EXTRA_TABLE_FIELDS                      EQU     16
DIR_MAP_LENGTH                          EQU (MAX_DIRS_AND_FILES + EXTRA_TABLE_FIELDS) * DIR_ENTRY_LENGTH
COMMENT_ROW                             EQU    "#"
CONFIG_PARAMETERS                       EQU      7          ; Max 7 parameters
CLI_OFFSET_COMMAND_TAIL                 EQU    130

DISK_SIZE                               EQU     11

DISK_MEDIA_TYPE_UNKNOWN_DENSITY         EQU     "U"
DISK_MEDIA_TYPE_SINGLE_DENSITY          EQU     "S"
DISK_MEDIA_TYPE_MEDIUM_DENSITY          EQU     "M"
DISK_MEDIA_TYPE_ENHANCED_DENSITY        EQU     "E"
DISK_MEDIA_TYPE_DOUBLE_DENSITY          EQU     "D"
DISK_MEDIA_TYPE_QUAD_DENSITY            EQU     "Q"
DISK_MEDIA_TYPE_720KB_DENSITY           EQU     "7"
DISK_MEDIA_TYPE_1440KB_DENSITY          EQU     "1"
DISK_MEDIA_TYPE_MEGADISK_DENSITY        EQU     "G"
DISK_MEDIA_TYPE_HARDDISK_DENSITY        EQU     "H"

ATR_HEADER_SIZE                         EQU     16
ATR_HEADER_SIZE_COMPARE                 EQU      8

EIGHTBIT_VTOC_FILES_MAX                 EQU     64
EIGHTBIT_BOOT_SECTOR                    EQU      1
EIGHTBIT_VTOC_SECTOR                    EQU    361
EIGHTBIT_VTOC_SIZE                      EQU   1024

EIGHTBIT_FILE_ENTRY_SIZE                EQU     16
SPARTADOS_FILE_ENTRY_SIZE               EQU     23

EIGHTBIT_SECTOR_SIZE                    EQU    128
EIGHTBIT_SECTOR_SIZE_DOUBLE             EQU    256

EIGHTBIT_BOOT_SECTOR_SIZE               EQU    384
EIGHTBIT_BOOT_SECTORS                   EQU      3

PC_DATE_YEAR_OFFSET                     EQU     80      ; Year 1980 for Pc date

DISK_BLOCK_SIZE                         EQU   1024

SPARTADOS_VTOC_BUFFER_SIZE              EQU   2048
SPARTADOS_DIRECTORY                     EQU     32

; Sectors Free
XDISK_SECTORS_SINGLE                    EQU    707
XDISK_SECTORS_MEDIUM                    EQU   1010
XDISK_SECTORS_ENHANCED                  EQU   1120
XDISK_SECTORS_DOUBLE                    EQU   1437
XDISK_SECTORS_QUAD                      EQU   2877
XDISK_SECTORS_720KB                     EQU   2877
XDISK_SECTORS_1440KB                    EQU   5757
XDISK_SECTORS_MEGADISK                  EQU   8192
XDISK_SECTORS_HARDDISK                  EQU  65532

XFILE_SIZE_LENGTH                       EQU      4



;**********************************************************************
SEGMENT SSeg Para Stack 'STACK'
;**********************************************************************

        db        64 dup (0)                            ; Stack

ENDS    SSeg

;**********************************************************************
SEGMENT DSeg Word Public 'DATA'
;**********************************************************************

;----------------------------------------------------------------------
;--  Structures                                                      --
;----------------------------------------------------------------------
include ".\str\dta.str"
include ".\str\fmsio.str"
include ".\str\position.str"
include ".\str\wsio.str"

;----------------------------------------------------------------------
;--  SELECT and FD                                                   --
;----------------------------------------------------------------------
;
; Configuration File
;
CONFIG___File                   FMS_Area <>
CONFIG___Pathname               DB  "C:\XDIR.CFG"
                                DB  PATH_LENGTH - 11   dup (SPACE)
                                DB    1 dup (0)
CONFIG___Data_Buffer            DB  PATH_LENGTH + 2    dup (NULL)

;
; Atari Disk Image
;
ATARI____File                   FMS_Area <>
ATARI____Pathname               DB  PATH_LENGTH        dup (SPACE)
                                DB    1 dup (0)

;
; Extracted Atari Disk Image (pc) File
;
PC_ATARI_File                   FMS_Area <>
PC_ATARI_Pathname               DB  PATH_LENGTH        dup (SPACE)
                                DB    1 dup (0)

;----------------------------------------------------------------------
;--  Working Storage                                                 --
;----------------------------------------------------------------------
GLOBAL Return_Code:Byte:1

Return_Code                     DB    0
Allocation_Strategy_Old         DW    NULL
Allocation_Strategy_New         DW    NULL

;------------------------------
; Command Line Interface fields
;------------------------------
CLI_Used                        DB    LOGIC_NO          ; CLI interface not active
CLI_Command_Tail_Size           DW    0
CLI_Command_Tail                DB    PATH_LENGTH       dup (SPACE)
                                DB    NULL
CLI_Indisk                      DB    PATH_LENGTH       dup (SPACE)
                                DB    NULL
CLI_Outdir                      DB    PATH_LENGTH       dup (SPACE)
                                DB    NULL
CLI_Error                       DB    LOGIC_NO          ; 0=No Error
                                                        ; 1=Error Encountered

Requested_Format_Drives         DB   "1"        ; 1 = "ABCDEFGHIJKL    " etc.
                                                ; 2 = "A: [Floppy     ]"
                                                ;     "C: [HARD_DRIVE ]" etc.
Requested_Format_LibFil         DB   "1"        ; 1 = DIRENTRY format    etc.
                                                ; 2 = "..           <DIR>      "
                                                ;     "ATARI        <DIR>      "
Hex2digi_Requested_Format       DB  "2"         ; "1" = With thousand seperator
                                                ; "2" = No thousand seperator
Media_Id_Buffer                 DB   25 dup (NULL)
Available_Drives                DB  MAX_DRIVES     dup (SPACE)
                                DB  SPACE
Directories_File_Mask           DB   "*.*         "
Search_Files_Path               DB  PATH_LENGTH    dup (SPACE)
                                DB  NULL        ; To satisfy DOS find file
Search_Dirs_Path                DB  PATH_LENGTH    dup (SPACE)
Search_Filemask                 DB  FILE_NAME_LENGTH    dup (SPACE)

Buffer_Sense_Media_Type         DW    1 dup (NULL)
Save_cx                         DW    ?
XL_VTOC_File_Nr                 DB    0
Dir_Memo_Occur_Curr             DW  MAX_DIRS dup (NULL) ; Remember from which dir we came
Dir_Memo_Occur_W_Curr           DW  MAX_DIRS dup (NULL) ; Remember from which dir we came
Dir_Memo_Pointer                DB    0
Dir_Up                          DB    0         ; 0=Stay current
                                                ; 1=Go dir up
                                                ; 2=Go dir down
Disk_Present                    DB  LOGIC_NO
Mouse_Pressed                   DB  LOGIC_NO
SpartaDos_Disk                  DB  LOGIC_NO
SpartaDos_Last_Sector           DB  LOGIC_NO
SpartaDos_Filesize_Hi           DW    0
SpartaDos_Filesize_Lo           DW    0
SpartaDos_Next_Link_Sector      DW    0
SpartaDos_Link_Sector_Offset    DB    0
SpartaDos_Date_YY               DB    0
SpartaDos_Date_MM               DB    0
SpartaDos_Date_DD               DB    0
SpartaDos_Time_HH               DB    0
SpartaDos_Time_MM               DB    0
Attrib_Non_modifiable           DB  ATTRIB_GREEN_WHITE
Parm_Being_Processed            DB    0

Pc_Date_YY                      DB    0
Pc_Date_MM                      DB    0
Pc_Date_DD                      DB    0
Pc_Time_HH                      DB    0
Pc_Time_MM                      DB    0

Old_Dta_Seg                     DW    ?                 ; Old Dta Segment Address
Old_Dta_Ofs                     DW    ?                 ; Old Dta Segment Offset
Own_Dta                         Dta <>

Disk_VTOC_Buffer                DB  DISK_BLOCK_SIZE dup (0)
                                DB  DISK_BLOCK_SIZE dup (0)     ; SpartaDos overflow buffer
Disk_I_O_Buffer                 DB  EIGHTBIT_SECTOR_SIZE_DOUBLE dup (0)
Disk_Link_Sector_Buffer         DB  EIGHTBIT_SECTOR_SIZE_DOUBLE dup (0)
                                DB    0


;----------------------------------------------------------------------
;--                                                                  --
;--  C O N F I G U R A T I O N   F I L E   F O R   X D I R           --
;--                                                                  --
;----------------------------------------------------------------------
Default_Startup_Path            DB  "C:\"
                                DB  PATH_LENGTH - 3   dup (SPACE)
                                DB  NULL
Config_Startup_Path             DB   PATH_LENGTH  dup (SPACE)
                                DB   1            dup (0)
Config_Deleted_YN               DB   1            dup (LOGIC_YES)

;--------------
; Config Fields
;--------------
Config_Field_Drives             DB   "*                         "
                                DB   1            dup (0)
Config_Field_Filemask           DB   "*.ATR       "
                                DB   1            dup (0)
Config_Field_Startup_Path       DB   "\"
                                DB   PATH_LENGTH - 1  dup (SPACE)
                                DB   1            dup (0)
Config_Field_Extract_To_Path    DB   "C:\XIN\"
                                DB   PATH_LENGTH - 7  dup (SPACE)
                                DB   1            dup (0)
Config_Field_Deleted_Extract    DB   "Y"
                                DB   1            dup (0)
Config_Field_Deleted_Path       DB   "C:\XDEL\"
                                DB   PATH_LENGTH - 8  dup (SPACE)
                                DB   1            dup (0)
Config_Field_Add_Path           DB   PATH_LENGTH  dup (SPACE)
                                DB   1            dup (0)



;----------------------------------------------------------------------
;--                                                                  --
;--  A T A R I   8   B I T   D I S K   I N F O                       --
;--                                                                  --
;----------------------------------------------------------------------
Disk_Sector_Size                DW   0
Disk_Media_Type                 DB   DISK_MEDIA_TYPE_SINGLE_DENSITY
Disk_Image_Shown                DB   LOGIC_NO
Disk_Image_ATR                  DB   LOGIC_NO

Disk_XFD_Single                 DB   "     92,160"
Disk_XFD_Medium                 DB   "    133,120"
Disk_XFD_Enhanced               DB   "    143,360"
Disk_XFD_Double                 DB   "    183,936"
Disk_XFD_Quad                   DB   "    368,256"
Disk_XFD_720KB                  DB   "    736,896"
Disk_XFD_Megadisk               DB   "  1,048,576"
Disk_XFD_1440KB                 DB   "  1,474,176"
Disk_XFD_Harddisk               DB   " 16,776,576"

Disk_ATR_Single                 DB   "     92,176"
Disk_ATR_Medium                 DB   "    133,136"
Disk_ATR_Enhanced               DB   "    143,376"
Disk_ATR_Double                 DB   "    183,952"
Disk_ATR_Quad                   DB   "    368,272"
Disk_ATR_720KB                  DB   "    736,912"
Disk_ATR_Megadisk               DB   "  1,048,592"
Disk_ATR_1440KB                 DB   "  1,474,192"
Disk_ATR_Harddisk               DB   " 16,776,592"

Disk_ATR_Single_Header          DB   096h,002h,080h,016h,080h,000h,000h,000h
Disk_ATR_Medium_Header          DB   096h,002h,080h,020h,080h,000h,000h,000h
Disk_ATR_Enhanced_Header        DB   096h,002h,000h,023h,080h,000h,000h,000h
Disk_ATR_Double_Header          DB   096h,002h,0E8h,02Ch,000h,001h,000h,000h
Disk_ATR_Quad_Header            DB   096h,002h,0E8h,059h,000h,001h,000h,000h
Disk_ATR_720KB_Header           DB   096h,002h,000h,0B4h,000h,001h,000h,000h
Disk_ATR_Megadisk_Header        DB   096h,002h,000h,000h,080h,000h,001h,000h
Disk_ATR_1440KB_Header          DB   096h,002h,000h,068h,000h,001h,001h,000h
Disk_ATR_Harddisk_Header        DB   096h,002h,0F0h,0FFh,000h,001h,00Fh,000h

XFile_Size_Text                 DB  "000,000,000"
XFile_Deleted                   DB    1 dup (LOGIC_NO)
XFile_Locked                    DB    1 dup (LOGIC_NO)
XFile_Extended                  DB    1 dup (LOGIC_NO)
XFile_Inverse                   DB    1 dup (LOGIC_NO)
XDisk_Sectors_Free              DW  XDISK_SECTORS_SINGLE

XDisk_File_Info_1               DB   22 dup ("xxxxxxxx.xxx9999")
XDisk_File_Info_2               DB   22 dup ("xxxxxxxx.xxx9999")
XDisk_File_Info_3               DB   20 dup ("xxxxxxxx.xxx9999")
;                                    --
;                                    64 files
;
XDisk_Free_Sectors              DB  "0000"

XDisk_Attrib_Info_1             DB   22 dup (ATTRIB_CYAN_WHITE)
XDisk_Attrib_Info_2             DB   22 dup (ATTRIB_CYAN_WHITE)
XDisk_Attrib_Info_3             DB   20 dup (ATTRIB_CYAN_WHITE)

XDisk_Attrib_Size_1             DB   22 dup (ATTRIB_CYAN_WHITE)
XDisk_Attrib_Size_2             DB   22 dup (ATTRIB_CYAN_WHITE)
XDisk_Attrib_Size_3             DB   20 dup (ATTRIB_CYAN_WHITE)

XDisk_Progress_Cnt_Prev         DB    0
XDisk_Progress_Cnt_Max          DB   32

XDisk_Progress_Bar              DB   32 dup (0B0h)
XDisk_Progress_Bar_Attr         DB   ATTRIB_CYAN_WHITE
XDisk_Extract_File              DB   12 dup (SPACE)

XDisk_Next_Sector               DW      0

Sectors_To_Extract              DW      ?
Sectors_Extracted               DW      ?
Sectors_For_This_File           DW      ?

XDisk_Image_Is_Bootdisk         DB   "Bootdisk    "

;-------------------------------------------------------------------
; Directory/Folder structure for SpartaDos disks
; Assume a maximum of 64 displayable folders/directories on the disk
;-------------------------------------------------------------------
                                                          ; Sector hi byte
                                                          ; ³  Sector lo byte
                                                          ; ³  ³  Position in sector hi byte
                                                          ; ³  ³  ³  Position in sector lo byte
                                                          ; ³  ³  ³  ³
Folder_Pointer                  DB   256 dup (000000000h) ; 00 00 00 00
Folder_Counter                  DW     0
Folder_Indicator                DB   LOGIC_NO
Process_Files                   DB   LOGIC_NO

;-----------------------------------------------------
; When extracting the files (from within directories),
; we need the folder path (i.e. to create directories)
;-----------------------------------------------------
Folder_Path                     DB   PATH_LENGTH dup (SPACE)

;----------------------------------------------------------------------
;--                                                                  --
;--  S C R E E N S   S E C T I O N                                   --
;--                                                                  --
;----------------------------------------------------------------------
Filler                  DB   64 dup (" ")

;**********************************************************************
; B a c k G r o u n d                                                 *
;**********************************************************************
Ws_BG                   DB    WSIO_OPEN
                        DB    1                 ; Start of screen ROW
                        DB    1                 ; Start of screen COLUMN
                        DB   25                 ; End of screen ROW
                        DB   80                 ; End of screen COLUMN
                        DB    ATTRIB_BLUE_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Input attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_BG_Name              DB    "BG      "
Ws_BG_Keys              DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_BG_Text              DB    "ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
Ws_BG_Fields            DB    NULL

;**********************************************************************
; F r e e W a r e                                                     *
;**********************************************************************
Ws_FW                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB   28                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   79                 ; End of screen COLUMN
                        DB    ATTRIB_CYAN_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Input attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_FW_Name              DB    "FREEWARE"
Ws_FW_Keys              DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_FW_Text              DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "   XDIR - Atari XL/XE Directory Lister - v10.05.00  "
                        DB                               "                                                    "
                        DB                               "   by B.F. Schreurs, February 2nd, 1999, CHiPS bv   "
                        DB                               "   Computer High Performance Software - Freeware    "
                        DB                               "   Email: stack@xs4all.nl                           "
                        DB                               "   Homepage: http:\\www.xs4all.nl\~stack            "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB                               "                                                    "
                        DB    NULL
Ws_FW_Fields            DB    NULL

;**********************************************************************
; X L   d i s k   i m a g e   v t o c                                 *
;**********************************************************************
Ws_XL                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB   28                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   79                 ; End of screen COLUMN
                        DB    ATTRIB_CYAN_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Input attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_XL_Name              DB    "XLDISK  "
Ws_XL_Keys              DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_XL_Text              DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³                ³"
                        DB                               "³                ³                ³Free Sectors    ³"
                        DB    NULL
;
; VTOC Files Specification
;
Ws_XL_F_XL_File_1       DB    1                 ; Relative ROW, NULL=End
                        DB    2                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB   22                 ; Nr of occurrences
                        DW    4                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_XL_Size_1       DB    1                 ; Relative ROW, NULL=End
                        DB   14                 ; Relative COLUMN 
                        DB    4                 ; Field Size
                        DB   22                 ; Nr of occurrences
                        DW   12                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_XL_File_2       DB    1                 ; Relative ROW, NULL=End
                        DB   19                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB   22                 ; Nr of occurrences
                        DW    4                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_XL_Size_2       DB    1                 ; Relative ROW, NULL=End
                        DB   31                 ; Relative COLUMN 
                        DB    4                 ; Field Size
                        DB   22                 ; Nr of occurrences
                        DW   12                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_XL_File_3       DB    1                 ; Relative ROW, NULL=End
                        DB   36                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB   20                 ; Nr of occurrences
                        DW    4                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_XL_Size_3       DB    1                 ; Relative ROW, NULL=End
                        DB   48                 ; Relative COLUMN 
                        DB    4                 ; Field Size
                        DB   20                 ; Nr of occurrences
                        DW   12                 ; Offset to next field
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_F_Free_Sectors    DB   22                 ; Relative ROW, NULL=End
                        DB   48                 ; Relative COLUMN 
                        DB    4                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is a table, not part of a table
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    1                 ; Protected
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Hi>
                        DB    0                 ; <.... Lo>
                        DB    0                 ; <Backspace option>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XL_No_More_Fields    DB    NULL

;**********************************************************************
; e X t r a c t i n g   x l   d i s k   F i l e s                     *
;**********************************************************************
Ws_XF                   DB    WSIO_DISPLAY_ONLY
                        DB   11                 ; Start of screen ROW
                        DB   36                 ; Start of screen COLUMN
                        DB   16                 ; End of screen ROW
                        DB   71                 ; End of screen COLUMN
                        DB    ATTRIB_GREEN_WHITE ; Screen attribute
                        DB    ATTRIB_GREEN_WHITE ; Field attribute
                        DB    0                 ; Input attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; No cursor
                        DB    CURSOR_OFF_SCREEN ; to display
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_XF_Name              DB    "XFILES  "
Ws_XF_Keys              DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_XF_Text              DB                                       "ΙΝΝ[8 bit Disk Image Extraction]ΝΝΝ»"
                        DB                                       "Ί                                  Ί"
                        DB                                       "Ί xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB                                       "Ί                                  Ί"
                        DB                                       "Ί Extracting file: xxxxxxxxxxxx    Ί"
                        DB                                       "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; Progress bar
;
Ws_XF_F_Progress_Bar    DB    3                 ; Relative ROW, NULL=End
                        DB    3                 ; Relative COLUMN 
                        DB   32                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    0                 ; <Mouse Sensitive>
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

;
; Progress bar
;
Ws_XF_F_Extract_File    DB    5                 ; Relative ROW, NULL=End
                        DB   20                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    0                 ; <Mouse Sensitive>
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_XF_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
; See Beginning of program

;**********************************************************************
; P A t h                                                             *
;**********************************************************************
Ws_PA                   DB    WSIO_DISPLAY_ONLY
                        DB    2                 ; Start of screen ROW
                        DB    2                 ; Start of screen COLUMN
                        DB    2                 ; End of screen ROW
                        DB   79                 ; End of screen COLUMN
                        DB    ATTRIB_BLUE_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Input attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_PA_Name              DB    "PATH    "
Ws_PA_Keys              DB    KEY_ESC, KEY_ENTER, KEY_ARROW_LEFT, KEY_ARROW_RIGHT
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_PA_Text              DB    "Path:                                                                          "
                        DB    NULL
;------------
; F I E L D S
;------------
;
; Path Specification
;
Ws_PA_F_Path            DB    1                 ; Relative ROW, NULL=End
                        DB    7                 ; Relative COLUMN 
                        DB   72                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Protected
                        DB    0                 ; <Mouse Sensitive>
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_PA_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
; See Search Files Path

;**********************************************************************
; D R i v e   S e l e c t i o n                                       *
;**********************************************************************
Ws_DR                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB    2                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   27                 ; End of screen COLUMN
                        DB    ATTRIB_BLUE_WHITE ; Screen attribute
                        DB    ATTRIB_BLUE_WHITE ; Field attribute
                        DB    ATTRIB_GREEN_WHITE  ; Select attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    1                 ; Locate cursor at field
                        DB    1                 ; Locate cursor at occurrence
                        DB    1                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_DR_Name              DB    "DRIVES  "
Ws_DR_Keys              DB    KEY_ESC,      KEY_ENTER
                        DB    KEY_HELP,     KEY_F2,         KEY_F4
                        DB    KEY_ARROW_UP, KEY_ARROW_DOWN
                        DB    KEY_PAGE_UP,  KEY_PAGE_DOWN
                        DB    KEY_HOME,     KEY_END
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_DR_Text              DB    "ΙΝΝΝΝΝ[Select Drive]ΝΝΝΝΝ»"
                        DB    "Ί    A: [FLOPPYDRIVE]    Ί"
                        DB    "Ί    C: [MY_VOLUME  ]    Ί"
                        DB    "Ί    D: [MY_CDROM   ]    Ί"
                        DB    "Ί    E: [NET_DRIVE  ]    Ί"
                        DB    "Ί    Z: [RAM_DISK   ]    Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "ΊENTER=Select Esc=Cancel Ί"
                        DB    "ΊF1=Help F2=FilMsk F4=CfgΊ"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; Drive Table
;
Ws_DR_F_Drive           DB    2                 ; Relative ROW, NULL=End
                        DB    6                 ; Relative COLUMN 
                        DB   16                 ; Field Size
                        DB   17                 ; Nr of occurrences
                        DW    0                 ; This is a table, not part of a table
                        DB    0                 ; Protected
                        DB    KEY_ENTER         ; Mouse sensitive
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_DR_F_Key_Esc         DB   20                 ; Relative ROW, NULL=End
                        DB   15                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ESC           ; Emulate Key Esc
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_DR_F_Key_Help        DB   21                 ; Relative ROW, NULL=End
                        DB    2                 ; Relative COLUMN 
                        DB    7                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_HELP          ; Emulate Key F1
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_DR_F_Key_FilMsk      DB   21                 ; Relative ROW, NULL=End
                        DB   10                 ; Relative COLUMN 
                        DB    9                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_F2            ; Emulate Key F2
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_DR_F_Key_Cfg         DB   21                 ; Relative ROW, NULL=End
                        DB   20                 ; Relative COLUMN 
                        DB    6                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_F4            ; Emulate Key F4
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_DR_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
;
; Drive Table
;
Ws_DR_D_Drive           DB    MAX_DRIVES + EXTRA_TABLE_FIELDS dup ("                ")

;--------------------
; W O R K F I E L D S
;--------------------
Ws_DR_Occur_Curr        DW    ?
Ws_DR_Occur_Max         DW    ?                 ; Maximum nr of drives present
Ws_DR_Occur_W_Curr      DW    ?
WS_DR_OCCUR_W_CURR_MAX  DW   17                 ; Maximum occurrences per window

Ws_DR_D_Key_Esc         DB   "Esc=Cancel"
Ws_DR_D_Key_Help        DB   "F1=Help"
Ws_DR_D_Key_FilMsk      DB   "F2=FilMsk"
Ws_DR_D_Key_Cfg         DB   "F4=Cfg"

;**********************************************************************
; D r i v e   H e l p   S c r e e n                                   *
;**********************************************************************
Ws_DH                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB    2                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   27                 ; End of screen COLUMN
                        DB    ATTRIB_GREEN_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Select attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    NULL              ; Field Area  Address HIGH
                        DW    NULL              ; Field Area  Address LOW
Ws_DH_Name              DB    "DRIVEHLP"
Ws_DH_Keys              DB    KEY_ANY
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_DH_Text              DB    "ΙΝΝΝΝΝΝ[Drive Help]ΝΝΝΝΝΝ»"
                        DB    "Ί                        Ί"
                        DB    "ΊENTER = Select drive    Ί"
                        DB    "Ί", ARROW_UP, "     = Previous drive  Ί"
                        DB    "Ί", ARROW_DOWN, "     = Next drive      Ί"
                        DB    "ΊHome  = First drive     Ί"
                        DB    "ΊEnd   = Last drive      Ί"
                        DB    "ΊPg Up = Previous drives Ί"
                        DB    "ΊPg Dn = Next drives     Ί"
                        DB    "ΊF1    = This screen     Ί"
                        DB    "ΊF2    = Specify FileMaskΊ"
                        DB    "ΊF4    = Config setup    Ί"
                        DB    "ΊEsc   = Cancel          Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "ΊPress any key to exit   Ί"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL

;**********************************************************************
; L i b r a r y   F i l e   S e l e c t i o n                         *
;**********************************************************************
Ws_LF                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB    2                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   27                 ; End of screen COLUMN
                        DB    ATTRIB_BLUE_WHITE ; Screen attribute
                        DB    ATTRIB_BLUE_WHITE ; Field attribute
                        DB    ATTRIB_GREEN_WHITE  ; Select attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    1                 ; Locate cursor at field
                        DB    1                 ; Locate cursor at occurrence
                        DB    1                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_LF_Name              DB    "LIBFILES"
Ws_LF_Keys              DB    KEY_ESC,      KEY_ENTER
                        DB    KEY_HELP,     KEY_F2,         KEY_F3,     KEY_F4
                        DB    KEY_ARROW_UP, KEY_ARROW_DOWN
                        DB    KEY_PAGE_UP,  KEY_PAGE_DOWN
                        DB    KEY_HOME,     KEY_END
                        DB    KEY_CTL_A_Z
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_LF_Text              DB    "ΙΝΝΝ[Select Dir/Image]Ν", ARROW_UP, ARROW_DOWN, "»"
                        DB    "Ί..           <DIR>      Ί"
                        DB    "ΊASM          <DIR>      Ί"
                        DB    "ΊEQUAL        <DIR>      Ί"
                        DB    "ΊMYDIR        <DIR>      Ί"
                        DB    "ΊPROJECT .TOO <DIR>      Ί"
                        DB    "ΊATARI   .ATR 123,456,789Ί"
                        DB    "ΊMY      .ATR  12,345,678Ί"
                        DB    "ΊYOUR    .ATR   1,234,567Ί"
                        DB    "ΊZZZZZZZZ.ATR     123,456Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "ΊENTER=Select Esc=Cancel Ί"
                        DB    "ΊF1=Help F2=FilMsk F3=DrvΊ"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; Directories/Images Table
;
Ws_LF_F_Dir_Fil         DB    2                 ; Relative ROW, NULL=End
                        DB    2                 ; Relative COLUMN 
                        DB   24                 ; Field Size
                        DB   17                 ; Nr of occurrences
                        DW    0                 ; This is a table, not part of a table
                        DB    0                 ; Protected
                        DB    KEY_ENTER         ; Mouse sensitive
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Page_Up         DB    1                 ; Relative ROW, NULL=End
                        DB   24                 ; Relative COLUMN 
                        DB    1                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is a table, not part of a table
                        DB    0                 ; Protected
                        DB    KEY_PAGE_UP       ; Mouse sensitive
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    NULL              ; Source Hi
                        DW    NULL              ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Page_Down       DB    1                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB    1                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is a table, not part of a table
                        DB    0                 ; Protected
                        DB    KEY_PAGE_DOWN     ; Mouse sensitive
                        DB    0                 ; <Edit option>
                        DB    0                 ; <Blanks option>
                        DB    0                 ; <Uppercase/Lowercase option>
                        DB    0                 ; <Backspace option>
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    NULL              ; Source Hi
                        DW    NULL              ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Key_Esc         DB   20                 ; Relative ROW, NULL=End
                        DB   15                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ESC           ; Emulate Enter
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Key_Help        DB   21                 ; Relative ROW, NULL=End
                        DB    2                 ; Relative COLUMN 
                        DB    7                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_HELP          ; Emulate Key F1
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Key_FilMsk      DB   21                 ; Relative ROW, NULL=End
                        DB   10                 ; Relative COLUMN 
                        DB    9                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_F2            ; Emulate Key F2
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_F_Key_Drv         DB   21                 ; Relative ROW, NULL=End
                        DB   20                 ; Relative COLUMN 
                        DB    6                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_F3            ; Emulate Key F3
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_LF_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
;
; Dir / Fil Table
;
Dir_Map_ptr_es          DW    1 dup (NULL)      ; Segment 1
Dir_Map_ptr_di          DW    1 dup (NULL)

Ws_LF_D_Key_Esc         DB   "Esc=Cancel"
Ws_LF_D_Key_Help        DB   "F1=Help"
Ws_LF_D_Key_FilMsk      DB   "F2=FilMsk"
Ws_LF_D_Key_Drv         DB   "F3=Drv"

;--------------------
; W O R K F I E L D S
;--------------------
Ws_LF_Occur_Curr        DW    ?
Ws_LF_Occur_Max         DW    ?                 ; Maximum nr of entries present
Ws_LF_Occur_W_Curr      DW    ?
WS_LF_OCCUR_W_CURR_MAX  DW   17                 ; Maximum occurrences per window

;**********************************************************************
; L i b r a r y   F i l e   H e l p   S c r e e n                     *
;**********************************************************************
Ws_LH                   DB    WSIO_DISPLAY_ONLY
                        DB    3                 ; Start of screen ROW
                        DB    2                 ; Start of screen COLUMN
                        DB   24                 ; End of screen ROW
                        DB   27                 ; End of screen COLUMN
                        DB    ATTRIB_GREEN_WHITE ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Select attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    NULL              ; Field Area  Address HIGH
                        DW    NULL              ; Field Area  Address LOW
Ws_LH_Name              DB    "LIBHELP "
Ws_LH_Keys              DB    KEY_ANY
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_LH_Text              DB    "ΙΝΝΝΝ[Dir/Image Help]ΝΝΝΝ»"
                        DB    "Ί                        Ί"
                        DB    "ΊENTER = Select Dir/ImageΊ"
                        DB    "Ί", ARROW_UP, "     = Prev Dir/Image  Ί"
                        DB    "Ί", ARROW_DOWN, "     = Next Dir/Image  Ί"
                        DB    "ΊHome  = First Dir/Image Ί"
                        DB    "ΊEnd   = Last Dir/Image  Ί"
                        DB    "ΊPg Up = Prev Dirs/ImagesΊ"
                        DB    "ΊPg Dn = Next Dirs/ImagesΊ"
                        DB    "ΊF1    = This screen     Ί"
                        DB    "ΊF2    = Specify FileMaskΊ"
                        DB    "ΊF3    = Go to drive scrnΊ"
                        DB    "ΊF4    = Config setup    Ί"
                        DB    "ΊEsc   = Exit Program    Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "Ί                        Ί"
                        DB    "ΊPress any key to exit   Ί"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL

;**********************************************************************
; F i l e m a s k   s p e c i f i c a t i o n                         *
;**********************************************************************
Ws_FM                   DB    WSIO_DISPLAY_AND_READ
                        DB   10                 ; Start of screen ROW
                        DB   28                 ; Start of screen COLUMN
                        DB   15                 ; End of screen ROW
                        DB   53                 ; End of screen COLUMN
                        DB    ATTRIB_GREEN_WHITE ; Screen attribute
                        DB    ATTRIB_BLUE_WHITE ; Field attribute
                        DB    ATTRIB_BLUE_WHITE ; Input attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    0                 ; Go to first          
                        DB    0                 ; modifiable field
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_FM_Name              DB    "CONFIG  "
Ws_FM_Keys              DB    KEY_ESC, KEY_ENTER
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_FM_Text              DB    "ΙΝΝΝ[Specify Filemask]ΝΝΝ»"
                        DB    "Ί                        Ί"
                        DB    "Ί      xxxxxxxxxxxx      Ί"
                        DB    "Ί                        Ί"
                        DB    "ΊENTER=Specify Esc=CancelΊ"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; File Mask
;
Ws_FM_F_Filemask        DB    3                 ; Relative ROW, NULL=End
                        DB    8                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_FM_F_Key_Enter       DB   05                 ; Relative ROW, NULL=End
                        DB   02                 ; Relative COLUMN 
                        DB   13                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ENTER         ; Emulate Enter
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_FM_F_Key_Esc         DB   05                 ; Relative ROW, NULL=End
                        DB   16                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ESC           ; Emulate Escape
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_FM_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
Ws_FM_D_Key_Enter       DB   "Enter=Specify"
Ws_FM_D_Key_Esc         DB   "Esc=Cancel"

; And see Configuration File Fields

;**********************************************************************
; C o n f i g u r a t i o n   F I l e   S p e c i f i c a t i o n     *
;**********************************************************************
Ws_CF                   DB    WSIO_DISPLAY_AND_READ
                        DB    1                 ; Start of screen ROW
                        DB    1                 ; Start of screen COLUMN
                        DB   25                 ; End of screen ROW
                        DB   80                 ; End of screen COLUMN
                        DB    ATTRIB_CYAN_WHITE ; Screen attribute
                        DB    ATTRIB_BLUE_WHITE ; Field attribute
                        DB    ATTRIB_BLUE_WHITE ; Input attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    0                 ; Go to first          
                        DB    0                 ; modifiable field
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_CF_Name              DB    "CONFIG  "
Ws_CF_Keys_No_Config    DB    KEY_F2
                        DB    NULL
Ws_CF_Keys              DB    KEY_ESC, KEY_ENTER,   KEY_F2
                        DB    NULL
Ws_CF_Enter_Keys        DB    KEY_F2
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_CF_Text              DB    "ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ[Configuration Setup]ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»"
                        DB    "Ί                                                                              Ί"
                        DB    "ΊStartup Drives       : xxxxxxxxxxxxxxxxxxxxxxxxxx                             Ί"
                        DB    "Ί                       Use a '*' to scan all available drives,                Ί"
                        DB    "Ί                       or specify the drive letters to scan, i.e. 'CDE'.      Ί"
                        DB    "ΊCurrently Active     : xxxxxxxxxxxxxxxxxxxxxxxxxx                             Ί"
                        DB    "Ί                       Shows the drives who are currently available,          Ί"
                        DB    "Ί                       and is always a subset of the Startup Drives specified.Ί"
                        DB    "ΊSearch Filemask      : xxxxxxxxxxxx                                           Ί"
                        DB    "Ί                       Use only valid filemask characters (i.e. '*.ATR').     Ί"
                        DB    "ΊSource path          : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB    "Ί                       Use a '\' to use the current directory,                Ί"
                        DB    "Ί                       or specify the drive/directory, i.e. 'C:\MYDIR\'.      Ί"
                        DB    "ΊDestination path     : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB    "Ί                       Used to store extracted 8bit files from images.        Ί"
                        DB    "ΊExtract Deleted Files: Y                                                      Ί"
                        DB    "Ί                       Only specify 'Y'es or 'N'o here.                       Ί"
                        DB    "ΊDestination path del.: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB    "Ί                       Used to store extracted deleted 8bit files from images.Ί"
                        DB    "ΊAdding Files path    : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB    "Ί                       This option can be specified, but is not used yet.     Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "Ί                                                                              Ί"
                        DB    "ΊENTER=Save   F2=Update Configuration File C:\XDIR.CFG   Esc=Cancel            Ί"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; Startup Drives
;
Ws_CF_F_Drives          DB    3                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   26                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    0                 ; Edit External
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Actives Drives
;
Ws_CF_F_Active          DB    6                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   26                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Non-modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    3                 ; Edit Letters
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; File Mask
;
Ws_CF_F_Filemask        DB    9                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   12                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Source Path
;
Ws_CF_F_Startup_Path    DB   11                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   54                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Destination Path
;
Ws_CF_F_Extract_To_Path DB   14                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   54                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Extract Deleted Yes/No
;
Ws_CF_F_Deleted_Extract DB   16                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB    1                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    0                 ; Edit External
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Deleted Files Path
;
Ws_CF_F_Deleted_Path    DB   18                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   54                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Add Files Path
;
Ws_CF_F_Add_Path        DB   20                 ; Relative ROW, NULL=End
                        DB   25                 ; Relative COLUMN 
                        DB   54                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_CF_F_Key_Enter       DB   24                 ; Relative ROW, NULL=End
                        DB    2                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ENTER         ; Emulate Enter
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_CF_F_Key_Update      DB   24                 ; Relative ROW, NULL=End
                        DB   15                 ; Relative COLUMN 
                        DB   40                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_F2            ; Emulate Key F2
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_CF_F_Key_Esc         DB   24                 ; Relative ROW, NULL=End
                        DB   58                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ESC           ; Emulate Enter
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_CF_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
; See Configuration File Fields
Yes_No_Field            DB   "YN"
                        DB  NULL
Drives_Field            DB   "*ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                        DB  NULL

Ws_CF_D_Key_Enter       DB   "ENTER=Save"
Ws_CF_D_Key_Esc         DB   "Esc=Cancel"
Ws_CF_D_Key_Update      DB   "F2=Update Configuration File C:\XDIR.CFG"



;**********************************************************************
; S p a r t a D o s   F i l e s   L o c a t i o n   S p e c i f i e r *
;**********************************************************************
Ws_SD                   DB    WSIO_DISPLAY_AND_READ
                        DB    9                 ; Start of screen ROW
                        DB   29                 ; Start of screen COLUMN
                        DB   16                 ; End of screen ROW
                        DB   78                 ; End of screen COLUMN
                        DB    ATTRIB_GREEN_WHITE ; Screen attribute
                        DB    ATTRIB_BLUE_WHITE ; Field attribute
                        DB    ATTRIB_BLUE_WHITE ; Input attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    0                 ; Go to first          
                        DB    0                 ; modifiable field
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    ?                 ; Field Area  Address HIGH
                        DW    ?                 ; Field Area  Address LOW
Ws_SD_Name              DB    "SPARTADS"
Ws_SD_Keys              DB    KEY_ESC, KEY_ENTER
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_SD_Text              DB    "ΙΝΝΝΝΝ[Specify Location for SpartaDos Files]ΝΝΝΝΝ»"
                        DB    "Ί                                                Ί"
                        DB    "Ί Path: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Ί"
                        DB    "Ί                                                Ί"
                        DB    "Ί Use volume name xxxxxxxx as directory name     Ί"
                        DB    "Ί                                                Ί"
                        DB    "ΊENTER=Specify Esc=Cancel                        Ί"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL
;------------
; F I E L D S
;------------
;
; File Mask
;
Ws_SD_F_Extract_To_Path DB    3                 ; Relative ROW, NULL=End
                        DB    9                 ; Relative COLUMN 
                        DB   40                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>
;
; Volume Name
;
Ws_SD_F_Volume_Name     DB    5                 ; Relative ROW, NULL=End
                        DB   19                 ; Relative COLUMN 
                        DB    8                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    1                 ; Modifiable
                        DB    0                 ; Not mouse sensitive
                        DB    6                 ; Edit Filemask
                        DB    1                 ; Blanks Trailing
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Attrib Hi>
                        DW    NULL              ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_SD_F_Key_Enter       DB   07                 ; Relative ROW, NULL=End
                        DB   02                 ; Relative COLUMN 
                        DB   13                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ENTER         ; Emulate Enter
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_SD_F_Key_Esc         DB   07                 ; Relative ROW, NULL=End
                        DB   16                 ; Relative COLUMN 
                        DB   10                 ; Field Size
                        DB    1                 ; Nr of occurrences
                        DW    0                 ; This is not a table
                        DB    0                 ; Protected
                        DB    KEY_ESC           ; Emulate Escape
                        DB    0                 ; Edit External
                        DB    0                 ; Blanks Anywhere
                        DB    0                 ; Uppercase
                        DB    0                 ; Backspace destructive
                        DB    0                 ; <Digits before dot>
                        DB    0                 ; <Digits after dot>
                        DB    0                 ; <Negative number option>
                        DB    0                 ; <Decimal point character>
                        DB    0                 ; <Date Time Format>
                        DB    LOGIC_NO          ; Field changed indicator
                        DW    ?                 ; Source Hi
                        DW    ?                 ; ...... Lo
                        DW    NULL              ; <Object Hi>
                        DW    NULL              ; <...... Lo>
                        DW    ?                 ; <Attrib Hi>
                        DW    ?                 ; <...... Lo>
                        DW    NULL              ; <Keys Hi>
                        DW    NULL              ; <.... Lo>

Ws_SD_No_More_Fields    DB    NULL

;--------
; D A T A
;--------
Ws_SD_D_Key_Enter       DB   "Enter=Specify"
Ws_SD_D_Key_Esc         DB   "Esc=Cancel"
Ws_SD_D_Extract_To_Path DB   "C:\XIN\"
                        DB   PATH_LENGTH - 7  dup (SPACE)
                        DB   1            dup (0)
Ws_SD_D_Volume_Name     DB   "SPARTADS"



;**********************************************************************
; E R R O R - D R I V E   N O T   R E A D Y                           *
;**********************************************************************
Ws_E1                   DB    WSIO_DISPLAY_ONLY
                        DB   10                 ; Start of screen ROW
                        DB   28                 ; Start of screen COLUMN
                        DB   16                 ; End of screen ROW
                        DB   51                 ; End of screen COLUMN
                        DB    ATTRIB_RED_WHITE  ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Select attribute
                        DB    0                 ; Error attribute
                        DB    1                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    NULL              ; Field Area  Address HIGH
                        DW    NULL              ; Field Area  Address LOW
Ws_E1_Name              DB    "ERROR1  "
Ws_E1_Keys              DB    KEY_ANY
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_E1_Text              DB    "ΙΝΝ[Drive Not Ready]ΝΝΝ»"
                        DB    "Ί                      Ί"
                        DB    "Ί There is NO media in Ί"
                        DB    "Ί the requested drive! Ί"
                        DB    "Ί                      Ί"
                        DB    "ΊEsc or Any key=ConfirmΊ"
                        DB    "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL



;**********************************************************************
; E R R O R - N O   V A L I D   D R I V E   P R E S E N T             *
;**********************************************************************
Ws_E2                   DB    WSIO_DISPLAY_ONLY
                        DB   10                 ; Start of screen ROW
                        DB   41                 ; Start of screen COLUMN
                        DB   16                 ; End of screen ROW
                        DB   66                 ; End of screen COLUMN
                        DB    ATTRIB_RED_WHITE  ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Select attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    NULL              ; Field Area  Address HIGH
                        DW    NULL              ; Field Area  Address LOW
Ws_E2_Name              DB    "ERROR2  "
Ws_E2_Keys              DB    KEY_ANY
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_E2_Text              DB                                             "ΙΝΝΝ[Drive Not Present]ΝΝ»"
                        DB                                             "Ί                        Ί"
                        DB                                             "Ί  There is NO valid     Ί"
                        DB                                             "Ί  disk drive present!   Ί"
                        DB                                             "Ί                        Ί"
                        DB                                             "ΊPress any key to confirmΊ"
                        DB                                             "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL

;**********************************************************************
; E R R O R - C O M M A N D   L I N E   I N T E R F A C E   E R R O R *
;**********************************************************************
Ws_E3                   DB    WSIO_OPEN
                        DB    9                 ; Start of screen ROW
                        DB   18                 ; Start of screen COLUMN
                        DB   17                 ; End of screen ROW
                        DB   63                 ; End of screen COLUMN
                        DB    ATTRIB_RED_WHITE  ; Screen attribute
                        DB    0                 ; Field attribute
                        DB    0                 ; Select attribute
                        DB    0                 ; Error attribute
                        DB    0                 ; Mouse support
                        DB    0                 ; Locate cursor at field
                        DB    0                 ; Locate cursor at occurrence
                        DB    0                 ; Locate cursor at position
                        DB    LOGIC_NO          ; Screen not changed
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Row
                        DB    CURSOR_OFF_SCREEN ; Cursor Position Col
                        DW    ?                 ; Screen Name Address HIGH
                        DW    ?                 ; Screen Name Address LOW
                        DW    ?                 ; Text        Address HIGH
                        DW    ?                 ; Text        Address LOW
                        DW    NULL              ; Attribute   Address HIGH
                        DW    NULL              ; Attribute   Address LOW
                        DW    ?                 ; Valid Keys  Address HIGH
                        DW    ?                 ; Valid Keys  Address LOW
                        DW    ?                 ; Enter Keys  Address HIGH
                        DW    ?                 ; Enter Keys  Address LOW
                        DW    NULL              ; Field Area  Address HIGH
                        DW    NULL              ; Field Area  Address LOW
Ws_E3_Name              DB    "ERROR3  "
Ws_E3_Keys              DB    KEY_ANY
                        DB    NULL
;                                       1         2         3         4         5         6         7         8
;                              ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0
Ws_E3_Text              DB                     "ΙΝΝΝΝΝΝΝ[Command Line Interface Error]ΝΝΝΝΝΝΝ»"
                        DB                     "Ί                                            Ί"
                        DB                     "Ί  The number of specified CLI parameters is Ί"
                        DB                     "Ί  incorrect, or the parameters themselves   Ί"
                        DB                     "Ί  are incorrectly specified. Please refer   Ί"
                        DB                     "Ί  to the documentation file XDIR.TXT.       Ί"
                        DB                     "Ί                                            Ί"
                        DB                     "ΊPress any key to confirm                    Ί"
                        DB                     "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"
                        DB    NULL



ENDS    DSeg



;**********************************************************************
;               Extended Segments
;**********************************************************************
SEGMENT DSeg1 Word Public 'LIBFILES'
Dir_Map                 DB   DIR_MAP_LENGTH dup ("E")

ENDS    DSeg1

;**********************************************************************
SEGMENT CSeg Word Public 'CODE'
;**********************************************************************
;----------------------------------------------------------------------
;--  External Variables                                              --
;----------------------------------------------------------------------
        EXTRN   DC_DIRS:proc            ; Determine Current Directories
        EXTRN   DC_DRV:proc             ; Determine Current Drives
        EXTRN   DC_FILES:proc           ; Determine Current Files
        EXTRN   FMSIO:proc              ; File Management System Handler
        EXTRN   HEX2DIGI:proc           ; Convert Hex Data To Digits (Text)
        EXTRN   TO_UPPER:proc           ; Convert string to uppercase
        EXTRN   WSIO:proc               ; Screen Handler



;**********************************************************************
Main:   
;**********************************************************************
        ASSUME  cs:CSeg
        ASSUME  ds:DSeg
        mov     ax, DSeg                        ; Initialize DS to address
        mov     ds, ax                          ; of data segment

        call    Init_Program
        call    Init_Files
        call    Init_Screens
        call    CLI_Check
        cmp     [CLI_Error], LOGIC_YES                  ; Error encounterd?
        je      @@99                                    ; Yes
                                                        ; No, so
        call    Read_XDir_Config_File
        call    Parameter_Processing

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@30                                    ; Yes
                                                        ; No, so
        call    Read_VTOC_Drives
        cmp     [Ws_DR_Occur_Max], 0                    ; Any valid drive present?
        je      @@99                                    ; No
                                                        ; Yes, so
        call    Open_Ws_BG
        call    Display_Ws_BG                           ; Display background
        call    Display_Ws_FW                           ; Display freeware message

@@20:
        call    Display_and_Read_Ws_LF                  ; Let user select library
        call    Close_Ws_BG
        jmp     @@99

@@30:
        call    CLI_Processing

@@99:
        call    Exit_Program



;**********************************************************************
PROC    Init_Program
;**********************************************************************
        push    es                                      ; Save Psp

        xor     ax, ax
        mov	ah, DOS_SET_MEMORY_BLOCK_SIZE           ; resize the psp memory
        xor     bx, bx
        int	DOS_SERVICE

        pop     es                                      ; Restore Psp

        mov     di, CLI_OFFSET_COMMAND_TAIL
        xor     cx, cx                                  ; Reset cx
        mov     cl, [es:Psp.LengthByte]                 ; Check if command line is empty
        mov     [CLI_Command_Tail_Size], cx             ; Save size of command tail
        cmp     cx, NULL                                ; Parameter(s) specified?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Copy Command Line To File Specification Buffer
;
        push    ds si                                   ; Save program entry

        push    es di                                   ; Save cli data

        mov     si, offset CLI_Command_Tail
        push    ds si
        pop     di es

        pop     si ds                                   ; Restore cli data
        rep     movsb                                   ; Copy Command_Tail

        pop     si ds                                   ; Restore program entry

@@10:
;
; Segment Addressing
;
        ASSUME  ds:DSeg1
        mov     ax, DSeg1                               ; Initialize ds to address
        mov     ds, ax                                  ; of data segment
 
        mov     si, offset Dir_Map
        push    ds si
        pop     di es

        ASSUME  ds:DSeg
        mov     ax, DSeg                                ; Initialize ds to address
        mov     ds, ax                                  ; of data segment

        mov     [Dir_Map_ptr_es], es
        mov     [Dir_Map_ptr_di], di
 
@@99:
        ret

ENDP    Init_Program



;**********************************************************************
PROC    Init_Files
;**********************************************************************
        mov     si, offset CONFIG___File
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Pathname
        mov     [(FMS_Area ptr di).Path_Address_Hi], ds
        mov     [(FMS_Area ptr di).Path_Address_Lo], si

        mov     si, offset ATARI____File
        push    ds si
        pop     di es
        mov     si, offset ATARI____Pathname
        mov     [(FMS_Area ptr di).Path_Address_Hi], ds
        mov     [(FMS_Area ptr di).Path_Address_Lo], si
        mov     si, offset Disk_I_O_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si

        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es
        mov     si, offset PC_ATARI_Pathname
        mov     [(FMS_Area ptr di).Path_Address_Hi], ds
        mov     [(FMS_Area ptr di).Path_Address_Lo], si
        mov     si, offset Disk_I_O_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si

        ret

ENDP    Init_Files



;**********************************************************************
PROC    Init_Screens
;**********************************************************************
;
; Init screen BG=Background
;
        mov     si, offset Ws_BG
        push    ds si
        pop     di es

        mov     si, offset Ws_BG_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_BG_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_BG_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen FW=FreeWare
;
        mov     si, offset Ws_FW
        push    ds si
        pop     di es

        mov     si, offset Ws_FW_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_FW_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_FW_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen XL=Atari Disk Image VTOC
;
        mov     si, offset Ws_XL
        push    ds si
        pop     di es

        mov     si, offset Ws_XL_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_XL_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_XL_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

; Field 1 Filename
        mov     si, offset Ws_XL_F_XL_File_1
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_1
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Info_1
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 1 Size
        mov     si, offset Ws_XL_F_XL_Size_1
        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_1
        add     si, FILE_NAME_LENGTH
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Size_1
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 2 Filename
        mov     si, offset Ws_XL_F_XL_File_2
        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_2
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Info_2
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 2 Size
        mov     si, offset Ws_XL_F_XL_Size_2
        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_2
        add     si, FILE_NAME_LENGTH
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Size_2
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 3 Filename
        mov     si, offset Ws_XL_F_XL_File_3
        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_3
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Info_3
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 3 Size
        mov     si, offset Ws_XL_F_XL_Size_3
        push    ds si
        pop     di es

        mov     si, offset XDisk_File_Info_3
        add     si, FILE_NAME_LENGTH
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Attrib_Size_3
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 4
        mov     si, offset Ws_XL_F_Free_Sectors
        push    ds si
        pop     di es

        mov     si, offset XDisk_Free_Sectors
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen XF=Extracting Files From Atari Disk Image
;
        mov     si, offset Ws_XF
        push    ds si
        pop     di es

        mov     si, offset Ws_XF_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_XF_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_XF_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

; Field 1
        mov     si, offset Ws_XF_F_Progress_Bar
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset XDisk_Progress_Bar
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset XDisk_Progress_Bar_Attr
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

; Field 2
        mov     si, offset Ws_XF_F_Extract_File
        push    ds si
        pop     di es

        mov     si, offset XDisk_Extract_File
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen PA=Path
;
        mov     si, offset Ws_PA
        push    ds si
        pop     di es

        mov     si, offset Ws_PA_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_PA_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_PA_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_PA_F_Path
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset Search_Files_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen DR=Drives
;
        mov     si, offset Ws_DR
        push    ds si
        pop     di es

        mov     si, offset Ws_DR_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_DR_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_DR_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_DR_F_Drive
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset Ws_DR_D_Drive
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_DR_F_Key_Esc

        push    ds si
        pop     di es

        mov     si, offset Ws_DR_D_Key_Esc
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_DR_F_Key_Help

        push    ds si
        pop     di es

        mov     si, offset Ws_DR_D_Key_Help
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_DR_F_Key_FilMsk

        push    ds si
        pop     di es

        mov     si, offset Ws_DR_D_Key_FilMsk
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_DR_F_Key_Cfg

        push    ds si
        pop     di es

        mov     si, offset Ws_DR_D_Key_Cfg
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen DH=Drive Help Screen
;
        mov     si, offset Ws_DH
        push    ds si
        pop     di es

        mov     si, offset Ws_DH_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_DH_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_DH_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen LF=Directories/Images
;
        mov     si, offset Ws_LF
        push    ds si
        pop     di es

        mov     si, offset Ws_LF_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_LF_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_LF_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_LF_F_Dir_Fil
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        mov     si, offset Ws_LF_F_Dir_Fil
        push    ds si
        pop     di es

        mov     ax, [Dir_Map_ptr_es]
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ax
        mov     ax, [Dir_Map_ptr_di]
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], ax

        mov     si, offset Ws_LF_F_Key_Esc

        push    ds si
        pop     di es

        mov     si, offset Ws_LF_D_Key_Esc
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_LF_F_Key_Help

        push    ds si
        pop     di es

        mov     si, offset Ws_LF_D_Key_Help
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_LF_F_Key_FilMsk

        push    ds si
        pop     di es

        mov     si, offset Ws_LF_D_Key_FilMsk
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_LF_F_Key_Drv

        push    ds si
        pop     di es

        mov     si, offset Ws_LF_D_Key_Drv
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen LH=Directory/Image Help Screen
;
        mov     si, offset Ws_LH
        push    ds si
        pop     di es

        mov     si, offset Ws_LH_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_LH_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_LH_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen FM=FileMask
;
        mov     si, offset Ws_FM
        push    ds si
        pop     di es

        mov     si, offset Ws_FM_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_FM_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_FM_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_FM_F_Filemask
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset Search_Filemask
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_FM_F_Key_Enter

        push    ds si
        pop     di es

        mov     si, offset Ws_FM_D_Key_Enter
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_FM_F_Key_Esc

        push    ds si
        pop     di es

        mov     si, offset Ws_FM_D_Key_Esc
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen CF=Configuration File
;
        mov     si, offset Ws_CF
        push    ds si
        pop     di es

        mov     si, offset Ws_CF_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_CF_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_CF_Enter_Keys
        mov     [(Wsio_Area ptr di).Enter_Address_Hi], ds
        mov     [(WSio_Area ptr di).Enter_Address_Lo], si

        mov     si, offset Ws_CF_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_CF_F_Drives
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es
        mov     si, offset Config_Field_Drives
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si
        mov     si, offset Drives_Field
        mov     [(Wsio_Field ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Field ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_CF_F_Active
        push    ds si
        pop     di es
        mov     si, offset Available_Drives
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si
        mov     si, offset Attrib_Non_Modifiable
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

        mov     si, offset Ws_CF_F_Filemask
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Filemask
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Startup_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Startup_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Extract_To_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Extract_To_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Deleted_Extract
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Deleted_Extract
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si
        mov     si, offset Yes_No_Field
        mov     [(Wsio_Field ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Field ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_CF_F_Deleted_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Deleted_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Add_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Add_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Key_Enter

        push    ds si
        pop     di es

        mov     si, offset Ws_CF_D_Key_Enter
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Key_Update

        push    ds si
        pop     di es

        mov     si, offset Ws_CF_D_Key_Update
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_CF_F_Key_Esc

        push    ds si
        pop     di es

        mov     si, offset Ws_CF_D_Key_Esc
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen SD=SpartaDos
;
        mov     si, offset Ws_SD
        push    ds si
        pop     di es

        mov     si, offset Ws_SD_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_SD_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_SD_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

        mov     si, offset Ws_SD_F_Extract_To_Path
        mov     [(Wsio_Area ptr di).Field_Address_Hi], ds
        mov     [(WSio_Area ptr di).Field_Address_Lo], si

        push    ds si
        pop     di es

        mov     si, offset Ws_SD_D_Extract_To_Path
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si
        mov     si, offset Attrib_Non_Modifiable
        mov     [(Wsio_Field ptr di).Attrib_Address_Hi], ds
        mov     [(WSio_Field ptr di).Attrib_Address_Lo], si

        mov     si, offset Ws_SD_F_Volume_Name

        push    ds si
        pop     di es

        mov     si, offset Ws_SD_D_Volume_Name
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_SD_F_Key_Enter

        push    ds si
        pop     di es

        mov     si, offset Ws_SD_D_Key_Enter
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        mov     si, offset Ws_SD_F_Key_Esc

        push    ds si
        pop     di es

        mov     si, offset Ws_SD_D_Key_Esc
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

;
; Init screen E1=Error Screen - Drive Not Ready
;
        mov     si, offset Ws_E1
        push    ds si
        pop     di es

        mov     si, offset Ws_E1_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_E1_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_E1_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen E2=Error Screen - No valid drives present
;
        mov     si, offset Ws_E2
        push    ds si
        pop     di es

        mov     si, offset Ws_E2_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_E2_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_E2_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

;
; Init screen E3=Error Screen - Command Line Interface Error
;
        mov     si, offset Ws_E3
        push    ds si
        pop     di es

        mov     si, offset Ws_E3_Name
        mov     [(Wsio_Area ptr di).Name_Address_Hi], ds
        mov     [(WSio_Area ptr di).Name_Address_Lo], si

        mov     si, offset Ws_E3_Keys
        mov     [(Wsio_Area ptr di).Keys_Address_Hi], ds
        mov     [(WSio_Area ptr di).Keys_Address_Lo], si

        mov     si, offset Ws_E3_Text
        mov     [(Wsio_Area ptr di).Text_Address_Hi], ds
        mov     [(WSio_Area ptr di).Text_Address_Lo], si

@@99:
        ret

ENDP    Init_Screens



;**********************************************************************
PROC    CLI_Check
;**********************************************************************
        mov     [CLI_Used], LOGIC_NO                    ; Assume interactive usage

        mov     cx, [CLI_Command_Tail_Size]             ; Check if command line is empty
        cmp     cx, NULL                                ; Parameter(s) specified?
        je      @@99                                    ; No
                                                        ; Yes, so
;
; Use CLI interface
;
        mov     [CLI_Used], LOGIC_YES

        mov     si, offset CLI_Command_Tail
        push    ds si
        call    TO_UPPER                                ; Make it uppercase
        pop     si ds

        mov     si, offset CLI_Command_Tail
        push    ds si
        pop     di es
        xor     ax, ax                                  ; Reset ax
        mov     al, CR                                  ; Search for Carriage Return
        repne   scasb                                   ; Search equal CR, uses es:di
        dec     di                                      ; Adjust start position after scan
        mov     [byte es:di], SPACE                     ; Remove return character here
        mov     [byte es:di + 1], CR                    ; Place it here

@@10:
        mov     [CLI_Error], LOGIC_NO

;-----------------------------------------------------
; Split Command Tail into the different CLI parameters
;-----------------------------------------------------
        mov     cx, [CLI_Command_Tail_Size]
        inc     cx                                      ; Because of CR replacement by space
        mov     si, offset CLI_Command_Tail
        push    ds si
        pop     di es

        mov     si, offset CLI_Indisk                   ; CLI Indisk
        call    CLI_Process_Parameter

        mov     si, offset CLI_Outdir                   ; CLI Outdisk
        call    CLI_Process_Parameter

@@20:
        cmp     [CLI_Error], LOGIC_NO                   ; CLI specs ok?
        je      @@99                                    ; Yes
                                                        ; No, so
;-------------------------------------
; ERROR - COMMAND LINE INTERFACE ERROR
;-------------------------------------
        mov     si, offset Ws_E3
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E3
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E3
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

@@99:
        ret

ENDP    CLI_Check



;**********************************************************************
PROC    CLI_Process_Parameter
;**********************************************************************
        cmp     [CLI_Error], LOGIC_YES                  ; Already error encounterd?
        je      @@99                                    ; Yes
                                                        ; No, so
@@00:
        mov     al, [byte es:di]                        ; Get character
        cmp     al, SPACE                               ; End of parameter?
        je      @@90                                    ; Yes
                                                        ; No, so
        mov     [byte ds:si], al                        ; Move character
        inc     si
        inc     di
        dec     cx                                      ; Byte count of Command Tail
        jnz     @@00                                    ; Next character
        mov     [CLI_Error], LOGIC_YES
        jmp     @@99

@@90:
        cmp     [byte es:di], SPACE                     ; Still SPACE?
        jne     @@99                                    ; No
                                                        ; Yes, so
        inc     di
        dec     cx
        jnz     @@90                                    ; Next character
        mov     [CLI_Error], LOGIC_YES

@@99:
        ret

ENDP    CLI_Process_Parameter



;**********************************************************************
PROC    Read_XDir_Config_File
;**********************************************************************
        mov     si, offset CONFIG___File
        push    ds si
        pop     di es

        mov     si, offset CONFIG___Data_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Request], CMD_OPEN_INPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_GET

; Retrieve Drives to scan on startup
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Drives
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, MAX_DRIVES
        rep     movsb

; Retrieve File Mask
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Filemask
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

; Retrieve Startup Path
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Startup_Path
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, PATH_LENGTH
        rep     movsb

; Retrieve Destination Path (XIN)
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Extract_To_Path
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, PATH_LENGTH
        rep     movsb

; Retrieve Specification If Deleted Files Should Be Extracted
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Deleted_Extract
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, 1
        rep     movsb

        mov     [Config_Deleted_YN], LOGIC_NO

        mov     si, offset CONFIG___Data_Buffer
        cmp     [byte ds:si], "N"                       ; Check if No is specified
        je      @@10                                    ; No is specified
                                                        ; Extract Deleted Files too!
        mov     [Config_Deleted_YN], LOGIC_YES

@@10:
; Retrieve Destination Path Deleted Files (XDEL)
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Deleted_Path
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, PATH_LENGTH
        rep     movsb                                   ; Copy Passed Mask to File Mask

; Retrieve Add Path Files (XADD)
        call    Get_Parameter_From_Config_File

        mov     si, offset Config_Field_Add_Path
        push    ds si
        pop     di es
        mov     si, offset CONFIG___Data_Buffer
        mov     cx, PATH_LENGTH
        rep     movsb                                   ; Copy Passed Mask to File Mask

@@90:
; Close config file
        mov     si, offset CONFIG___File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE
        push    es di
        call    FMSIO
        pop     di es

@@99:
        ret

ENDP    Read_XDir_Config_File



;**********************************************************************
PROC    Get_Parameter_From_Config_File
;**********************************************************************
@@00:
; Clear parameter
        mov     si, offset CONFIG___Data_Buffer
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        xor     ax, ax                                  ; Reset ax
        mov     al, SPACE
        rep     stosb                                   ; Clear parameter

; Get line from config file
        mov     si, offset CONFIG___File
        push    ds si
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

        mov     si, offset CONFIG___Data_Buffer
        cmp     [byte ds:si], COMMENT_ROW               ; Comment "line"?
        je      @@00                                    ; Yes
                                                        ; No, so
        cmp     [byte ds:si], SPACE                     ; Empty "line"?
        je      @@00                                    ; Yes
                                                        ; No, so
        cmp     [byte ds:si], NULL                      ; "line" starts with space?
        je      @@00                                    ; Yes
                                                        ; No, so
@@99:
        ret

ENDP    Get_Parameter_From_Config_File



;**********************************************************************
PROC    Parameter_Processing
;**********************************************************************
;------------------------------------
; Copy startup path info to work field
;-------------------------------------
        mov     si, offset Config_Startup_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Startup_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;------------------------------------
; Check Startup Path from config file
;------------------------------------
;
; If not specified, we use the current directory
;
        mov     si, offset Config_Startup_Path
        cmp     [byte ds:si], SPACE                     ; Config Field specified?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Startup path specified, use current directory?
;
        cmp     [byte ds:si], BACKSLASH                 ; Use current directory
        je      @@10                                    ; Yes
                                                        ; No, so
;---------------------------
; Use specified startup path
;---------------------------
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH                         ; Search length
        dec     cx                                      ; Because of null terminator
        add     di, cx                                  ; Go to end of path
        std                                             ; Search direction is down
        xor     ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search

        jmp     @@20

;----------------------
; Use current directory
;----------------------
@@10:
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        xor     ax, ax                                  ; Reset ax
        mov     al, SPACE
        rep     stosb                                   ; Clear parameter

; Get default drive
        xor     ax, ax                                  ; Reset ax
        mov     ah, DOS_GET_DEFAULT_DRIVE               ; Get Default Drive
        int     DOS_SERVICE 
        add     al, 041h                                ; Because of 0-based stuff

; Process Drive
        mov     si, offset Config_Startup_Path
        mov     [byte ds:si], al                        ; Process Drive letter
        mov     [byte ds:si + 1], COLON
        mov     [byte ds:si + 2], BACKSLASH
        add     si, 3                                   ; Locating at directory stuff

; Get current directory
        xor     ax, ax                                  ; Reset ax
        mov     ah, DOS_GET_CURRENT_DIRECTORY
        xor     dx, dx                                  ; Reset dx
        mov     dl, DOS_DEFAULT_DRIVE
        int     DOS_SERVICE

; Terminate it with a backslash "\"
        mov     si, offset Config_Startup_Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        dec     cx                                      ; To go to the last character
        add     di, cx                                  ; Go to end of path
        std                                             ; Searh direction is down
        mov     ax, SPACE                               ; Search for non space
        repe    scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting

        mov     cl, BACKSLASH                           ; Assume adding a backslash
        cmp     [byte es:di], BACKSLASH                 ; Are we in the root?
        jne     @@15                                    ; No
                                                        ; Yes, so
        mov     cl, SPACE                               ; Replace 000h by SPACE

@@15:
        inc     di                                      ; Pointer adjustment after search
        mov     [byte es:di], cl

;---------------------------------
; Copy Startup path to search path
;---------------------------------
@@20:
        mov     si, offset Search_Dirs_Path
        push    ds si
        pop     di es

        mov     si, offset Config_Startup_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;----------------------------------------
; Copy Config Filemask to Search Filemask
;----------------------------------------
        mov     si, offset Search_Filemask
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Filemask
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

@@99:
        ret

ENDP    Parameter_Processing



;**********************************************************************
PROC    CLI_Processing
;**********************************************************************
        mov     [Ws_LF_Occur_Max], 1

;---------------------------------------------
; Get field size of Libraries/Files Table item
;---------------------------------------------
        mov     si, offset Ws_LF_F_Dir_Fil
        push    ds si
        pop     di es

        mov     ax, MAX_DIRS_AND_FILES + EXTRA_TABLE_FIELDS
        xor     bx, bx
        xor     cx, cx
        mov     cl, [byte (Wsio_Field ptr di).Size]
        xor     dx, dx
        mul     cx

;----------------------------
; Clear Libraries/Files Table
;----------------------------
        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]
        mov     cx, ax
        xor     ax, ax                                  ; Reset ax
        mov     al, NULL                                ; Fill character
        rep     stosb

;---------------------------
; Set up Search path - Files
;---------------------------
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        mov     si, offset CLI_Indisk
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Set up parameters for File search
;
        mov     [Requested_Format_LibFil], "2"          ; Format "..           <DIR>      "
                                                        ;        "ATARI        <DIR>      "
        mov     si, offset Requested_Format_LibFil      ; Parameter 1
        push    ds si

        mov     si, offset Search_Files_Path            ; Parameter 2
        push    ds si

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]                    ; Parameter 3
        push    es di
 
;-----------------------------------
; Now retrieve Directory Map - Files
;-----------------------------------
        call    DC_FILES

        pop     ax ax ax ax ax ax

;------------------------------------------------------
; After reading the VTOC we are at the first occurrence
;------------------------------------------------------
        mov     [Ws_LF_Occur_Curr], 1
        mov     [Ws_LF_Occur_W_Curr], 1

        call    Display_and_Read_Ws_LF                  ; Process disk

        ret

ENDP    CLI_Processing



;**********************************************************************
PROC    Read_VTOC_Drives
;**********************************************************************
;
; Get drives in format: ACDE etc.
;
        mov     si, offset Config_Field_Drives
        cmp     [byte ds:si], ASTERISK                  ; Use available drives?
        je      @@15                                    ; Yes
                                                        ; No, so
        mov     si, offset Available_Drives
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Drives
        mov     cx, MAX_DRIVES
        rep     movsb

        mov     si, offset Available_Drives
        mov     cx, MAX_DRIVES

;
; Check existence of specified drives
;
@@00:
        cmp     [byte ds:si], SPACE                     ; End of drive list?
        je      @@10                                    ; Yes
                                                        ; No, so
        cmp     [byte ds:si], "A"                       ; A drive?
        je      @@01                                    ; Yes
                                                        ; No, so
        cmp     [byte ds:si], "B"                       ; B drive?
        je      @@01                                    ; Yes
                                                        ; No, so
        jmp     @@04

@@01:
;
; Check available diskette drives A and B
;
        push    ds si cx
        int     EQUIPMENT_SERVICE                       ; Get equipment info
        mov     cx, ax
        and     cx, 00001h                              ; Check nr of floppy drives
        cmp     cl, 001h                                ; Floppy drives present?
        jne     @@06                                    ; No
                                                        ; Yes, so
        and     ax, 000C0h                              ; Check nr of floppy drives present
        cmp     al, 000h                                ; 1 floppy drive present?
        jne     @@08                                    ; No
                                                        ; Yes, so
;
; Just 1 floppy drive present
;
        push    es di
        mov     ax, 00050h
        mov     es, ax
        mov     di, 00004h
        mov     al, [byte es:di]                        ; 0050:0004 shows which drive is
                                                        ; emulated with 1 floppy drive
                                                        ; 000h = drive A   0001h = drive B
        pop     di es

;
; Determine which floppy drive is being emulated, assume drive A
;
        cmp     al, 000h                                ; Emulating drive A?
        je      @@02                                    ; Yes
                                                        ; No, so
                                                        ; Emulating drive B
        cmp     [byte ds:si], "B"                       ; B drive?
        je      @@08                                    ; Yes
                                                        ; No, so
        jmp     @@06

@@02:
        cmp     [byte ds:si], "A"                       ; A drive?
        je      @@08                                    ; Yes
                                                        ; No, so
        jmp     @@06

;
; Check drive presence
;
@@04:
        mov     bl, [ds:si]

        push    ds si cx

        mov     ax, DOS_SENSE_MEDIA_TYPE
        mov     cx, DOS_SENSE_MEDIA_TYPE_CX
        sub     bl, 64                              ; Turn drive into DOS drive
        mov     si, offset Buffer_Sense_Media_Type
        mov     dx, si
        int     DOS_SERVICE                         ; Check Drive Presence
        cmp     ax, DOS_DRIVE_NOT_AVAILABLE         ; Drive available?
        jne     @@08                                ; Yes
                                                    ; No, so
@@06:
        pop     cx si ds
        dec     si
        push    ds si cx

        inc     si
        push    ds si
        pop     di es

        inc     si
        rep     movsb
        
@@08:
        pop     cx si ds
        inc     si
        loop    @@00

@@10:
        mov     si, offset Ws_DR_D_Drive          ; Parameter 2
        push    ds si
        pop     di es

;
; Init Drives descriptions
;
        push    es di
        mov     cx,  ((MAX_DRIVES + EXTRA_TABLE_FIELDS) * 16)
        mov     ax, SPACE
        rep     stosb
        pop     di es

        mov     si, offset Available_Drives
        mov     cx, MAX_DRIVES
        rep     movsb

        mov     [Requested_Format_Drives], "3"          ; Format [A: Myvolume   ]
        mov     si, offset Requested_Format_Drives      ; Parameter 1
        push    ds si

        mov     si, offset Ws_DR_D_Drive                ; Parameter 2
        push    ds si
 
        call    DC_DRV

        pop     ax ax ax ax

        jmp     @@20

@@15:
        mov     [Requested_Format_Drives], "1"          ; Format ABCDE
        mov     si, offset Requested_Format_Drives      ; Parameter 1
        push    ds si

        mov     si, offset Available_Drives             ; Parameter 2
        push    ds si
 
        call    DC_DRV

        pop     ax ax ax ax

;
; Get drives in format: [A: Myvolume   ]
;                       [C: Yourvolume ] etc.
;
        mov     [Requested_Format_Drives], "2"          ; Format [A: Myvolume   ]
        mov     si, offset Requested_Format_Drives      ; Parameter 1
        push    ds si

        mov     si, offset Ws_DR_D_Drive          ; Parameter 2
        push    ds si
 
        call    DC_DRV

        pop     ax ax ax ax

@@20:
;-----------------------
; Specify start of table
;-----------------------
        mov     [Ws_DR_Occur_Curr], 0

@@30:
;-----------------------------------
; Determine which drive to highlight
;-----------------------------------
        mov     [Ws_DR_Occur_W_Curr], 0

        mov     si, offset Search_Dirs_Path
        mov     bl, [byte ds:si]                        ; Config path drive

;-------------------------------------------
; Determine maximum number of drives present
;-------------------------------------------
        mov     si, offset Ws_DR_F_Drive
        push    ds si
        pop     di es

        xor     ax, ax
        mov     al, [(Wsio_Field ptr di).Size]

        mov     cx, MAX_DRIVES

        mov     [Ws_DR_Occur_Max], 0
        mov     si, offset Ws_DR_D_Drive

@@50:
        cmp     [byte ds:si], SPACE
        je      @@80

        inc     [Ws_DR_Occur_Max]
        cmp     [byte ds:si], bl                        ; Selected drive found?
        jne     @@70                                    ; No
                                                        ; Yes, so
        mov     dx, [Ws_DR_Occur_Max]
        mov     [Ws_DR_Occur_Curr], dx

@@60:
        mov     [Ws_DR_Occur_W_Curr], dx
        cmp     dx, [WS_DR_OCCUR_W_CURR_MAX]            ; dx > Max occur of window?
        jle     @@70                                    ; No
                                                        ; Yes, so
        sub     dx, [WS_DR_OCCUR_W_CURR_MAX]            ; Move 1 window up
        jmp     @@60

@@70:
        add     si, ax
        loop    @@50

@@80:
        cmp     [Ws_DR_Occur_Max], 0                    ; Any valid drive present?
        je      @@95                                    ; No
                                                        ; Yes, so
        cmp     [Ws_DR_Occur_W_Curr], 0                 ; Invalid drive specified?
        jne     @@90                                    ; No
                                                        ; Yes, so
        mov     si, offset Config_Startup_Path
        push    ds si
        pop     di es
        mov     si, offset Default_Startup_Path
        mov     cx, PATH_LENGTH
        rep     movsb
        mov     si, offset Config_Startup_Path
        push    ds si
        pop     di es
        mov     si, offset Ws_DR_D_Drive
        mov     cx, 1
        rep     movsb

;---------------------------------
; Copy Startup path to search path
;---------------------------------
        mov     si, offset Search_Dirs_Path
        push    ds si
        pop     di es

        mov     si, offset Config_Startup_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;----------------------------------------
; Copy Config Filemask to Search Filemask
;----------------------------------------
        mov     si, offset Search_Filemask
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Filemask
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

;----------------------------------------
; Retrieve files from new drive/directory
;----------------------------------------
        mov     [Dir_Up], 0                             ; We stay in the current dir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files

        jmp     @@20

@@90:
;------------------------------------
; Pass offset address of drives table
;------------------------------------
        mov     si, offset Ws_DR_D_Drive
        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si
        jmp     @@99

@@95:
;---------------------------------------------------
; ERROR - NO DRIVE FROM SPECIFIED DRIVE LIST PRESENT
;---------------------------------------------------
        mov     si, offset Ws_E2
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E2
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E2
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

@@99:
        ret

ENDP    Read_VTOC_Drives



;**********************************************************************
PROC    Open_Ws_BG
;**********************************************************************
        mov     si, offset Ws_BG
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        cmp     ax, NULL                                ; Error?
        jz      @@99                                    ; No
                                                        ; Yes, so
;
; Error
;

@@99:        
        ret

ENDP    Open_Ws_BG



;**********************************************************************
PROC    Display_Ws_BG
;**********************************************************************
        mov     si, offset Ws_BG
        mov     [byte ds:si], WSIO_DISPLAY_ONLY
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_BG



;**********************************************************************
PROC    Display_Ws_FW
;**********************************************************************
        mov     si, offset Ws_FW

        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_FW



;**********************************************************************
PROC    Display_Ws_XL
;**********************************************************************
        mov     si, offset Ws_XL

        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_XL



;**********************************************************************
PROC    Display_Ws_PA
;**********************************************************************
        mov     si, offset Ws_PA
        mov     [byte ds:si], WSIO_DISPLAY_ONLY

        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_PA



;**********************************************************************
PROC    Display_and_Read_Ws_PA
;**********************************************************************
        mov     si, offset Ws_PA
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        JMP     @@15

@@10:
        mov     si, offset Ws_PA
        mov     [byte ds:si], WSIO_READ_ONLY

@@15:
        push    ds si
        call    WSIO
        pop     si ds

;--------------------------------
; Determine which key was pressed
;--------------------------------
        cmp     al, KEY_ARROW_LEFT
        je      @@20
        cmp     al, KEY_ARROW_RIGHT
        je      @@30
        cmp     al, KEY_ENTER
        je      @@60
;
; Assume the Esc(ape) key
;
        jmp     @@99

;---------------
; KEY ARROW LEFT
;---------------
@@20:
        jmp     @@10

;----------------
; KEY ARROW RIGHT
;----------------
@@30:
        jmp     @@10

;----------
; KEY ENTER
;----------
@@60:
        jmp     @@99

@@99:
        ret

ENDP    Display_and_Read_Ws_PA



;**********************************************************************
PROC    Display_Ws_DR
;**********************************************************************
        mov     si, offset Ws_DR
        mov     [byte ds:si], WSIO_DISPLAY_ONLY

        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_DR



;**********************************************************************
PROC    Display_and_Read_Ws_DR
;**********************************************************************
;----------
; Init Path
;----------
;
; Reset Search Dirs Path
;
        mov     si, offset Search_Dirs_Path             ; Clear path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        mov     ax, SPACE
        rep     stosb

        call    Display_Ws_DR
        jmp     @@10

;---------------------------------
; Show fields only of Drives Table
;---------------------------------
@@05:
        mov     si, offset Ws_DR
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY

        push    ds si
        call    WSIO
        pop     si ds

@@10:
;
; Make current occurrence Green/White
;
        mov     si, offset Ws_DR
        push    ds si
        pop     di es

        mov     cl, ATTRIB_GREEN_WHITE
        mov     [(Wsio_Area ptr di).Input_Select_Attrib], cl

        mov     [(Wsio_Area ptr di).Select_Field_Nr], 1
        mov     cx, [Ws_DR_Occur_W_Curr]
        mov     [(Wsio_Area ptr di).Select_Field_Occur_Nr], cl

        mov     [(Wsio_Area ptr di).Cursor_Position_Row], CURSOR_OFF_SCREEN
        mov     [(Wsio_Area ptr di).Cursor_Position_Col], CURSOR_OFF_SCREEN

;
; Display current occurrence
;
        mov     si, offset Ws_DR
        mov     [byte ds:si], WSIO_SELECT_DESELECT

        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_DR
        mov     [byte ds:si], WSIO_READ_ONLY

        push    ds si
        call    WSIO
        pop     si ds

;
; Save pressed key
;
        push    ax

;
; Reset current occurrence
;
        mov     si, offset Ws_DR
        push    ds si
        pop     di es

        mov     cl, [(Wsio_Area ptr di).Field_Attrib]
        mov     [(Wsio_Area ptr di).Input_Select_Attrib], cl

        mov     [(Wsio_Area ptr di).Select_Field_Nr], 1
        mov     cx, [Ws_DR_Occur_W_Curr]
        mov     [(Wsio_Area ptr di).Select_Field_Occur_Nr], cl

        mov     si, offset Ws_DR
        mov     [byte ds:si], WSIO_SELECT_DESELECT

        push    ds si
        call    WSIO
        pop     si ds

;
; Restore pressed key
;
        pop     ax

;--------------------------------
; Determine which key was pressed
;--------------------------------
        cmp     al, KEY_ARROW_UP
        je      @@20
        cmp     al, KEY_ARROW_DOWN
        je      @@25
        cmp     al, KEY_PAGE_UP
        je      @@30
        cmp     al, KEY_PAGE_DOWN
        je      @@35
        cmp     al, KEY_HOME
        je      @@40
        cmp     al, KEY_END
        je      @@45
        cmp     al, KEY_ENTER
        je      @@60
        cmp     al, KEY_F2                              ; Specify filemask
        je      @@70
        cmp     al, KEY_F4                              ; Configuration setup
        je      @@80
        cmp     al, KEY_HELP
        je      @@90
;
; Assume the Esc(ape) key
;
        jmp     @@99

;-------------
; KEY ARROW UP
;-------------
@@20:
        cmp     [Ws_DR_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Move "up" to previous occurrence
;
        dec     [Ws_DR_Occur_Curr]

;
; Are we still in the current "window"?
;
        cmp     [Ws_DR_Occur_W_Curr], 1
        je      @@21

        dec     [Ws_DR_Occur_W_Curr]
        jmp     @@10

@@21:
;
; Move occurrence down
;
        mov     cx, [Ws_DR_Occur_Curr]                  ; Get current occurrence
        jmp     @@50

;---------------
; KEY ARROW DOWN
;---------------
@@25:
        mov     dx, [Ws_DR_Occur_Max]                   ; Max nr of available occurrences
        cmp     dx, [Ws_DR_Occur_Curr]                  ; Current occurr = max?
        je      @@10                                    ; Yes
                                                        ; No, so
;
; Move "down" to next occurrence
;
        inc     [Ws_DR_Occur_Curr]

;
; Are we still in the current "window"?
;
        mov     dx, [WS_DR_OCCUR_W_CURR_MAX]            ; Max occurrence of window
        cmp     [Ws_DR_Occur_W_Curr], dx                ; Current occurr = max window?
        je      @@26                                    ; Yes
                                                        ; No, so
        inc     [Ws_DR_Occur_W_Curr]
        jmp     @@10

@@26:
;
; Move occurrences up
;
        mov     cx, [Ws_DR_Occur_Curr]                  ; Get current occurrence
        sub     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Calculate window size
        inc     cx
        jmp     @@50

;------------
; KEY PAGE UP
;------------
@@30:
        cmp     [Ws_DR_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Move up to previous window
;
        mov     cx, [Ws_DR_Occur_Curr]                  ; Current occurrence
        sub     cx, [Ws_DR_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        cmp     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Can we subtract 1 page?
        jl      @@31                                    ; No
                                                        ; Yes, so
        sub     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Subtract size of 1 page
        jmp     @@32

@@31:
        mov     cx, 1                                   ; Go to beginning of occur

@@32:
;
; Determine Window occurrence
;
        mov     dx, cx
        add     dx, [Ws_DR_Occur_W_Curr]
        dec     dx
        mov     [Ws_DR_Occur_Curr], dx
        jmp     @@50

;--------------
; KEY PAGE DOWN
;--------------
@@35:
        mov     cx, [Ws_DR_Occur_Curr]                  ; Current occurrence
        sub     cx, [Ws_DR_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        add     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Add size of 1 page
        cmp     cx, [Ws_DR_Occur_Max]                   ; Is there a next window?
        jnle    @@10                                    ; No
                                                        ; Yes, so
;
; Determine window occurrence
;
        mov     dx, cx
        add     dx, [Ws_DR_Occur_W_Curr]                ; Go to same window occurrence
        dec     dx                                      ; Which is done now
        cmp     dx, [Ws_DR_Occur_Max]                   ; Does it exist?
        jle     @@36                                    ; Yes
                                                        ; No, so
        mov     bx, dx                                  ; bx = dx
        sub     bx, [Ws_DR_Occur_Max]                   ; Determine difference
        sub     [Ws_DR_Occur_W_Curr], bx                ; Go to last occurrence
        mov     dx, [Ws_DR_Occur_Max]

@@36:
        mov     [Ws_DR_Occur_Curr], dx
        jmp     @@50

;---------
; KEY HOME
;---------
@@40:
        cmp     [Ws_DR_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
        mov     cx, [Ws_DR_Occur_Curr]                  ; Current occurrence
        sub     cx, [Ws_DR_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        cmp     cx, 1                                   ; Showing from 1st already?
        jne     @@41                                    ; No
                                                        ; Yes, so
        cmp     [Ws_DR_Occur_W_Curr], 1                 ; At top of window?
        je      @@10                                    ; Yes
                                                        ; No, so
@@41:
        mov     cx, 1                                   ; Go to beginning of screen
        mov     [Ws_DR_Occur_W_Curr], 1
        mov     [Ws_DR_Occur_Curr], 1
        jmp     @@50

;--------
; KEY END
;--------
@@45:
        mov     cx, [Ws_DR_Occur_Curr]                  ; Current occurrence
        cmp     cx, [Ws_DR_Occur_Max]                   ; Can we go "down" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
        mov     cx, [Ws_DR_Occur_Max]                   ; Go to last occurrence
        mov     [Ws_DR_Occur_Curr], cx                  ; Go to last occurrence in table
        cmp     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Does it all fit in 1 window?
        jnle    @@46                                    ; No
                                                        ; Yes, so
        mov     [Ws_DR_Occur_W_Curr], cx                ; Go  to  last entry in window
        jmp     @@50

@@46:
;
; Determine window occurrence
;
        sub     cx, [WS_DR_OCCUR_W_CURR_MAX]            ; Subtract 1 page
        inc     cx                                      ; We are at the last page now
        mov     dx, [WS_DR_OCCUR_W_CURR_MAX]            ; Get last window occurrence
        mov     [Ws_DR_Occur_W_Curr], dx                ; Move to last window occurrence
        jmp     @@50

;----------------------------------------
; Set up drive window data and attributes
;----------------------------------------
@@50:
        mov     si, offset Ws_DR_F_Drive
        push    ds si
        pop     di es

        xor     ax, ax
        mov     al, [(Wsio_Field ptr di).Size]

        mov     si, offset Ws_DR_D_Drive

        jmp     @@52

@@51:
        add     si, ax

@@52:
        loop    @@51

        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ds
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], si

        jmp     @@05

;----------
; KEY ENTER
;----------
@@60:
        mov     si, offset Ws_DR
        push    ds si
        pop     di es

        xor     bx, bx
        mov     bl, [(Wsio_Area ptr di).Select_Field_Occur_Nr]

        mov     [Mouse_Pressed], LOGIC_NO

        xor     cx, cx
        mov     cl, [(Wsio_Area ptr di).Cursor_Position_Row]
        cmp     cl, CURSOR_OFF_SCREEN                   ; Enter by mouse press?
        je      @@61                                    ; No
                                                        ; Yes, so
        mov     [Mouse_Pressed], LOGIC_YES

;
; Mouse pressed Enter, is it valid?
;
        cmp     cl, 4                                   ; Valid occurrence?
        jl      @@10                                    ; No
                                                        ; Maybe
        cmp     cl, 20                                  ; Valid occurrence?
        jnle    @@10                                    ; No
                                                        ; Maybe
        sub     cl, 3                                   ; Determine occurrence
        mov     dx, [Ws_DR_Occur_Curr]                  ; Current occurrence
        sub     dx, bx
        add     dx, cx
        cmp     dx, [Ws_DR_Occur_Max]                   ; Valid occurrence?
        jnle    @@10                                    ; No
                                                        ; Yes, so
        mov     [Ws_DR_Occur_Curr], dx                  ; Set occurrence
        mov     [Ws_DR_Occur_W_Curr], cx

@@61:
;
; Copy selected drive to path
;
        mov     si, offset Search_Dirs_Path             ; 73 chars for Path
        push    ds si
        pop     di es
        mov     si, offset Available_Drives
        add     si, [Ws_DR_Occur_Curr]
        dec     si
        movsb
        mov     [byte es:di], COLON
        mov     [byte es:di + 1], BACKSLASH

;
; Show new path to user
;
        mov     si, offset Ws_PA
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY

        push    ds si
        call    WSIO
        pop     si ds

        mov     [Dir_Memo_Pointer], 0                   ; Reset directory memo pointer
        jmp     @@99

;------------------
; KEY F2 - FileMask
;------------------
@@70:
        call    Display_and_Read_Ws_FM
        jmp     @@10

;----------------------
; KEY F4 - Config setup
;----------------------
@@80:
        call    Display_and_Read_Ws_CF
        jmp     @@05

;---------
; KEY HELP
;---------
@@90:
        call    Display_Ws_DH
        jmp     @@10

;-------
; Return
;-------
@@99:
        ret

ENDP    Display_and_Read_Ws_DR



;**********************************************************************
PROC    Display_Ws_DH
;**********************************************************************
        mov     si, offset Ws_DH
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_DH
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_DH
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_DH



;**********************************************************************
PROC    Read_VTOC_Directories_Files
;**********************************************************************
        cmp     [Dir_Up], 2                             ; Do we have to remember from which directory we came from?
        jne     @@05                                    ; No
                                                        ; Yes, so
        mov     cx, [Ws_LF_Occur_Curr]
        mov     dx, [Ws_LF_Occur_W_Curr]
        xor     ax, ax
        mov     al, [Dir_Memo_Pointer]                  ; Get current occurrence
        rol     ax, 1                                   ; Multiply by 2

        mov     si, offset Dir_Memo_Occur_Curr
        add     si, ax                                  ; Move to empty spot
        mov     [ds:si], cx
        mov     si, offset Dir_Memo_Occur_W_Curr
        add     si, ax                                  ; Move to empty spot
        mov     [ds:si], dx
        inc     [Dir_Memo_Pointer]

@@05:
        mov     [Ws_LF_Occur_Max], 0

;---------------------------------------------
; Get field size of Libraries/Files Table item
;---------------------------------------------
        mov     si, offset Ws_LF_F_Dir_Fil
        push    ds si
        pop     di es

        mov     ax, MAX_DIRS_AND_FILES + EXTRA_TABLE_FIELDS
        xor     bx, bx
        xor     cx, cx
        mov     cl, [byte (Wsio_Field ptr di).Size]
        xor     dx, dx
        mul     cx

;----------------------------
; Clear Libraries/Files Table
;----------------------------
        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]
        mov     cx, ax
        xor     ax, ax                                  ; Reset ax
        mov     al, NULL                                ; Fill character
        rep     stosb

;----------------------------------------------
; Check if drive we have to access drive A or B
;----------------------------------------------
        call    Verify_Disk_Presence_Drive_A_Or_B       ; If were reading drive A or B

        cmp     [Disk_Present], LOGIC_YES               ; Diskette present
        jne     @@99                                    ; No
                                                        ; Yes, so
@@20:        
;-------------------------------
; Set up Search path - Libraries
;-------------------------------
;
; Copy shown path to search path first
;
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        mov     si, offset Search_Dirs_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Find first non blank character in the Search path
;
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, SPACE                               ; Search the first space
        mov     cx, PATH_LENGTH
        repne   scasb                                   ; Search
        dec     di                                      ; Pointer correction after search

;
; Add "*.*" to the Search path
;
        mov     si, offset Directories_File_Mask
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

;
; Terminate it with a null
;
        mov     [byte es:di], NULL

;
; Set up parameters for Directory search
;
        mov     [Requested_Format_LibFil], "2"          ; Format "..           <DIR>      "
                                                        ;        "ATARI        <DIR>      "
        mov     si, offset Requested_Format_LibFil      ; Parameter 1
        push    ds si

        mov     si, offset Search_Files_Path            ; Parameter 2
        push    ds si

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]                    ; Parameter 3
        push    es di
 
;-----------------------------------------
; Now retrieve Directory Map - Directories
;-----------------------------------------
        call    DC_DIRS

        pop     ax ax ax ax ax ax

;---------------------------
; Set up Search path - Files
;---------------------------

;
; Copy shown path to search path first
;
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        mov     si, offset Search_Dirs_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Find first non blank character in the Search path
;
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, SPACE                               ; Search the first space
        mov     cx, PATH_LENGTH
        repne   scasb                                   ; Search
        dec     di                                      ; Pointer correction after search

;
; Add FileMask to the Search path
;
        mov     si, offset Search_Filemask
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

;
; Terminate it with a null
;
        mov     [byte es:di], NULL

;
; Set up parameters for Directory search
;
        mov     [Requested_Format_LibFil], "2"          ; Format "..           <DIR>      "
                                                        ;        "ATARI        <DIR>      "
        mov     si, offset Requested_Format_LibFil      ; Parameter 1
        push    ds si

        mov     si, offset Search_Files_Path            ; Parameter 2
        push    ds si

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]                    ; Parameter 3

;
; Search null terminator
;
        xor     ax, ax
        mov     al, NULL                                ; Search the first null
        mov     cx, DIR_MAP_LENGTH
        repne   scasb                                   ; Search
        dec     di                                      ; Pointer correction after search

        push    es di
 
;-----------------------------------
; Now retrieve Directory Map - Files
;-----------------------------------
        call    DC_FILES

        pop     ax ax ax ax ax ax

;------------------------------------------------------
; After reading the VTOC we are at the first occurrence
;------------------------------------------------------
        mov     cx, 1                                   ; To satisfy loop condition
        mov     [Ws_LF_Occur_Curr], 1
        mov     [Ws_LF_Occur_W_Curr], 1

        cmp     [Dir_Up], 1                             ; Did we go up a dir?
        jne     @@50                                    ; No
                                                        ; Yes, so
        cmp     [Dir_Memo_Pointer], 0                   ; Did we have save info of previous dirs?
        je      @@50                                    ; No
                                                        ; Yes, so
        dec     [Dir_Memo_Pointer]

        xor     ax, ax
        mov     al, [Dir_Memo_Pointer]                  ; Get current occurrence
        rol     ax, 1                                   ; Multiply by 2

        mov     si, offset Dir_Memo_Occur_Curr
        add     si, ax                                  ; Move to occupied spot
        mov     cx, [ds:si]
        mov     si, offset Dir_Memo_Occur_W_Curr
        add     si, ax                                  ; Move to occupied spot
        mov     dx, [ds:si]

        mov     [Ws_LF_Occur_Curr], cx
        mov     [Ws_LF_Occur_W_Curr], dx

        sub     cx, [Ws_LF_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now

@@50:
        mov     si, offset Ws_LF_F_Dir_Fil

        push    ds si
        pop     di es

        xor     ax, ax
        mov     al, [(Wsio_Field ptr di).Size]

        push    es di

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]

        jmp     @@52

@@51:
        add     di, ax

@@52:
        loop    @@51

        mov     ax, es
        mov     bx, di

        pop     di es

        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ax
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], bx

;------------------------------------
; Determine MAXimum nr of occurrences
;------------------------------------
        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]
        mov     cx, DIR_MAP_LENGTH                      ; Search length
        xor     ax, ax                                  ; Search for null character
        repne   scasb                                   ; Search uses es:di

        mov     ax, DIR_MAP_LENGTH
        sub     ax, cx                                  ; Nr of entries in size determined
        xor     dx, dx
        xor     cx, cx
        mov     bx, DIR_ENTRY_LENGTH                    ; Determine nr of occurs
        div     bx

        mov     [Ws_LF_Occur_Max], ax

@@99:
        call    Display_Ws_PA                           ; Display path

        ret

ENDP    Read_VTOC_Directories_Files



;**********************************************************************
PROC    Verify_Disk_Presence_Drive_A_Or_B
;**********************************************************************
        mov     [Disk_Present], LOGIC_YES

;----------------------------------------------
; Check if drive we have to access drive A or B
;----------------------------------------------
        mov     si, offset Search_Dirs_Path
        cmp     [byte ds:si], "A"                       ; Access drive A?
        je      @@10                                    ; Yes
                                                        ; No, so
        cmp     [byte ds:si], "B"                       ; Access drive B?
        jne     @@99                                    ; No
                                                        ; Yes, so
@@10:
        xor     bx, bx                                  ; Reset dx
        mov     bl, [byte ds:si]                        ; Copy selected drive to path
        sub     bl, 64                                  ; Turn drive into DOS drive
        mov     ax, DOS_SENSE_MEDIA_TYPE
        mov     al, 00Dh                                ; subfunction code
        mov     cx, DOS_GET_MEDIA_ID_CX
        mov     dx, offset Media_ID_Buffer
        int     DOS_SERVICE                             ; Check Drive Presence
        cmp     ax, DOS_DRIVE_NOT_READY                 ; Drive ready?
        jne     @@99                                    ; Yes
                                                        ; No, so
        mov     [Disk_Present], LOGIC_NO

;------------------------
; ERROR - DRIVE NOT READY
;------------------------
        mov     si, offset Ws_E1
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E1
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_E1
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

@@99:
        ret

ENDP    Verify_Disk_Presence_Drive_A_Or_B



;**********************************************************************
PROC    Display_and_Read_Ws_LF
;**********************************************************************
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@05                                    ; Yes
                                                        ; No, so
        jmp     @@62                                    ; Because of startup path

;------------------------------------------
; Show fields only of Libraries/Files Table
;------------------------------------------
@@00:
        mov     si, offset Ws_LF
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY

        push    ds si
        call    WSIO
        pop     si ds

@@05:
;----------------------------------------------------
; Are we dealing with an Atari 8 bit disk image here?
;----------------------------------------------------
;
; Determine selected directory/file
;
        mov     ax, [Ws_LF_Occur_Curr]
        dec     ax                                      ; Because of offset reasons
        xor     bx, bx
        mov     cx, DIR_ENTRY_LENGTH
        xor     dx, dx
        mul     cx

;
; Check contents of selected dir/file
;        
        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]
        add     di, ax

        add     di, FILE_NAME_LENGTH + 1                ; Go to file size

        mov     [Disk_Image_ATR], LOGIC_YES             ; Assume ATR disk image

; Check ATR single
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_SINGLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_SINGLE
        push    es di
        mov     si, offset Disk_ATR_Single
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR single?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR medium
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEDIUM_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_MEDIUM
        push    es di
        mov     si, offset Disk_ATR_Medium
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR medium?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR enhanced
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_ENHANCED_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_ENHANCED
        push    es di
        mov     si, offset Disk_ATR_Enhanced
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR enhanced?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR double
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_DOUBLE
        push    es di
        mov     si, offset Disk_ATR_Double
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR quad
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_QUAD
        push    es di
        mov     si, offset Disk_ATR_Quad
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR 720KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_720KB_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_720KB
        push    es di
        mov     si, offset Disk_ATR_720KB
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR megadisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEGADISK_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_MEGADISK
        push    es di
        mov     si, offset Disk_ATR_Megadisk
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR 1440KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_1440KB_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_1440KB
        push    es di
        mov     si, offset Disk_ATR_1440KB
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check ATR harddisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_HARDDISK_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_HARDDISK
        push    es di
        mov     si, offset Disk_ATR_Harddisk
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = ATR double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; No ATR disk image
        mov     [Disk_Image_ATR], LOGIC_NO              ; Assume no ATR disk image

; Check XFD single
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_SINGLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_SINGLE
        push    es di
        mov     si, offset Disk_XFD_Single
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD single?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD medium
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEDIUM_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_MEDIUM
        push    es di
        mov     si, offset Disk_XFD_Medium
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD medium?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD enhanced
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_ENHANCED_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_ENHANCED
        push    es di
        mov     si, offset Disk_XFD_Enhanced
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD enhanced?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD double
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_DOUBLE
        push    es di
        mov     si, offset Disk_XFD_Double
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD quad
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_QUAD
        push    es di
        mov     si, offset Disk_XFD_Quad
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD 720KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_720KB_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_720KB
        push    es di
        mov     si, offset Disk_XFD_720KB
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD megadisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEGADISK_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_MEGADISK
        push    es di
        mov     si, offset Disk_XFD_Megadisk
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD 1440KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_1440KB_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_1440KB
        push    es di
        mov     si, offset Disk_XFD_1440KB
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

; Check XFD Harddisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_HARDDISK_DENSITY

        mov     [word XDisk_Sectors_Free], XDISK_SECTORS_HARDDISK
        push    es di
        mov     si, offset Disk_XFD_Harddisk
        mov     cx, DISK_SIZE                           ; Compare Size (file size)
        rep     cmpsb                                   ; File size = XFD double?
        je      @@06                                    ; Yes,
                                                        ; No, so
        pop     di es

        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_UNKNOWN_DENSITY

        jmp     @@07

;-------------------------------------
; Show Atari 8 bit disk image contents
;-------------------------------------
@@06:
        pop     di es

        call    Retrieve_Disk_Image_VTOC

        cmp     [Disk_Present], LOGIC_NO                ; Diskette present (if we're reading drive A or B)
        je      @@10                                    ; No
                                                        ; Yes, so
;------------------------------------------
; Show Freeware Text or Disk Image contents
;------------------------------------------
@@07:
        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_UNKNOWN_DENSITY
                                                        ; Is it an Atari 8 bit image?
        jne     @@08                                    ; Yes
                                                        ; No, so
        cmp     [Disk_Image_Shown], LOGIC_YES           ; Is there still an image showing?
        jne     @@10                                    ; No
                                                        ; Yes, so
        mov     [Disk_Image_Shown], LOGIC_NO
        call    Display_Ws_FW                           ; Show Freeware Text
        jmp     @@10                                    ; Continue

@@08:
        mov     [Disk_Image_Shown], LOGIC_YES
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@67                                    ; Yes
                                                        ; No, so
        call    Display_Ws_XL

;------------------------------------
; Make current occurrence Green/White
;------------------------------------
@@10:
        mov     si, offset Ws_LF
        push    ds si
        pop     di es

        mov     cl, ATTRIB_GREEN_WHITE
        mov     [(Wsio_Area ptr di).Input_Select_Attrib], cl

        mov     [(Wsio_Area ptr di).Select_Field_Nr], 1
        mov     cx, [Ws_LF_Occur_W_Curr]
        mov     [(Wsio_Area ptr di).Select_Field_Occur_Nr], cl

        mov     [(Wsio_Area ptr di).Cursor_Position_Row], CURSOR_OFF_SCREEN
        mov     [(Wsio_Area ptr di).Cursor_Position_Col], CURSOR_OFF_SCREEN

;
; Display current occurrence
;
        mov     si, offset Ws_LF
        mov     [byte ds:si], WSIO_SELECT_DESELECT

        push    ds si
        call    WSIO
        pop     si ds

;----------
; Get input
;----------
        mov     si, offset Ws_LF
        mov     [byte ds:si], WSIO_READ_ONLY

        push    ds si
        call    WSIO
        pop     si ds

;
; Save pressed key
;
        push    ax

;
; Reset current occurrence
;
        mov     si, offset Ws_LF
        push    ds si
        pop     di es

        mov     cl, [(Wsio_Area ptr di).Field_Attrib]
        mov     [(Wsio_Area ptr di).Input_Select_Attrib], cl

        mov     [(Wsio_Area ptr di).Select_Field_Nr], 1
        mov     cx, [Ws_LF_Occur_W_Curr]
        mov     [(Wsio_Area ptr di).Select_Field_Occur_Nr], cl

        mov     si, offset Ws_LF
        mov     [byte ds:si], WSIO_SELECT_DESELECT

        push    ds si
        call    WSIO
        pop     si ds

;
; Restore pressed key
;
        pop     ax

;--------------------------------
; Determine which key was pressed
;--------------------------------
        cmp     al, KEY_ARROW_UP
        je      @@15
        cmp     al, KEY_ARROW_DOWN
        je      @@20
        cmp     al, KEY_PAGE_UP
        je      @@25
        cmp     al, KEY_PAGE_DOWN
        je      @@30
        cmp     al, KEY_HOME
        je      @@35
        cmp     al, KEY_END
        je      @@40
        cmp     al, KEY_ENTER
        je      @@50
        cmp     al, KEY_F2                              ; Specify filemask
        je      @@55
        cmp     al, KEY_F3                              ; Back to drives
        je      @@60
        cmp     al, KEY_F4                              ; Configuration setup
        je      @@80

;
; Check for control key + drive letter
;
        mov     cx, MAX_DRIVES                          ; Drive A thru Z
        mov     bx, 1                                   ; Start at drive A

@@11:
        cmp     al, bl
        je      @@70
        inc     bx                                      ; Try next drive
        loop    @@11


        cmp     al, KEY_HELP
        je      @@90

;
; Assume the Esc(ape) key
;
        jmp     @@99

;-------------
; KEY ARROW UP
;-------------
@@15:
        cmp     [Ws_LF_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Move "up" to previous occurrence
;
        dec     [Ws_LF_Occur_Curr]

;
; Are we still in the current "window"?
;
        cmp     [Ws_LF_Occur_W_Curr], 1
        je      @@16

        dec     [Ws_LF_Occur_W_Curr]
        jmp     @@05

@@16:
;
; Move occurrence down
;
        mov     cx, [Ws_LF_Occur_Curr]                  ; Get current occurrence
        jmp     @@45

;---------------
; KEY ARROW DOWN
;---------------
@@20:
        mov     dx, [Ws_LF_Occur_Max]                   ; Max nr of available occurrences
        cmp     dx, [Ws_LF_Occur_Curr]                  ; Current occurr = max?
        je      @@10                                    ; Yes
                                                        ; No, so
;
; Move "down" to next occurrence
;
        inc     [Ws_LF_Occur_Curr]

;
; Are we still in the current "window"?
;
        mov     dx, [WS_LF_OCCUR_W_CURR_MAX]            ; Max occurrence of window
        cmp     [Ws_LF_Occur_W_Curr], dx                ; Current occurr = max window?
        je      @@21                                    ; Yes
                                                        ; No, so
        inc     [Ws_LF_Occur_W_Curr]
        jmp     @@05

@@21:
;
; Move occurrences up
;
        mov     cx, [Ws_LF_Occur_Curr]                  ; Get current occurrence
        sub     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Calculate window size
        inc     cx
        jmp     @@45

;------------
; KEY PAGE UP
;------------
@@25:
        cmp     [Ws_LF_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Move up to previous window
;
        mov     cx, [Ws_LF_Occur_Curr]                  ; Current occurrence
        sub     cx, [Ws_LF_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        cmp     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Can we subtract 1 page?
        jl      @@26                                    ; No
                                                        ; Yes, so
        sub     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Subtract size of 1 page
        jmp     @@27

@@26:
        mov     cx, 1                                   ; Go to beginning of occur

@@27:
;
; Determine Window occurrence
;
        mov     dx, cx
        add     dx, [Ws_LF_Occur_W_Curr]
        dec     dx
        mov     [Ws_LF_Occur_Curr], dx
        jmp     @@45

;--------------
; KEY PAGE DOWN
;--------------
@@30:
        mov     cx, [Ws_LF_Occur_Curr]                  ; Can we go "down" anyhow?
        sub     cx, [Ws_LF_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        add     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Add size of 1 page
        cmp     cx, [Ws_LF_Occur_Max]                   ; Is there a next window?
        jnle    @@10                                    ; No
                                                        ; Yes, so
;
; Determine window occurrence
;
        mov     dx, cx
        add     dx, [Ws_LF_Occur_W_Curr]                ; Go to same window occurrence
        dec     dx                                      ; Which is done now
        cmp     dx, [Ws_LF_Occur_Max]                   ; Does it exist?
        jle     @@31                                    ; Yes
                                                        ; No, so
        mov     bx, dx                                  ; bx = dx
        sub     bx, [Ws_LF_Occur_Max]                   ; Determine difference
        sub     [Ws_LF_Occur_W_Curr], bx                ; Go to last occurrence
        mov     dx, [Ws_LF_Occur_Max]

@@31:
        mov     [Ws_LF_Occur_Curr], dx
        jmp     @@45

;---------
; KEY HOME
;---------
@@35:
        cmp     [Ws_LF_Occur_Curr], 1                   ; Can we go "up" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
        mov     cx, [Ws_LF_Occur_Curr]                  ; Current occurrence
        sub     cx, [Ws_LF_Occur_W_Curr]                ; Determine begin of window
        inc     cx                                      ; Which is done now
        cmp     cx, 1                                   ; Showing from 1st already?
        jne     @@36                                    ; No
                                                        ; Yes, so
        cmp     [Ws_LF_Occur_W_Curr], 1                 ; At top of window?
        je      @@10                                    ; Yes
                                                        ; No, so
@@36:
        mov     cx, 1                                   ; Go to beginning of screen
        mov     [Ws_LF_Occur_W_Curr], 1
        mov     [Ws_LF_Occur_Curr], 1
        jmp     @@45

;--------
; KEY END
;--------
@@40:
        mov     cx, [Ws_LF_Occur_Curr]                  ; Current occurrence
        cmp     cx, [Ws_LF_Occur_Max]                   ; Can we go "down" anyhow?
        je      @@10                                    ; No
                                                        ; Yes, so
        mov     cx, [Ws_LF_Occur_Max]                   ; Go to last occurrence
        mov     [Ws_LF_Occur_Curr], cx                  ; Go to last occurrence in table
        cmp     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Does it all fit in 1 window?
        jnle    @@41                                    ; No
                                                        ; Yes, so
        mov     [Ws_LF_Occur_W_Curr], cx                ; Go  to  last entry in window
        mov     cx, 1                                   ; Start from first occurrence
        jmp     @@45

@@41:
;
; Determine window occurrence
;
        sub     cx, [WS_LF_OCCUR_W_CURR_MAX]            ; Subtract 1 page
        inc     cx                                      ; We are at the last page now
        mov     dx, [WS_LF_OCCUR_W_CURR_MAX]            ; Get last window occurrence
        mov     [Ws_LF_Occur_W_Curr], dx                ; Move to last window occurrence
        jmp     @@45

;--------------------------------------------
; Set up dir/image window data and attributes
;--------------------------------------------
@@45:
        mov     si, offset Ws_LF_F_Dir_Fil

        push    ds si
        pop     di es

        xor     ax, ax
        mov     al, [(Wsio_Field ptr di).Size]

        push    es di

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]

        jmp     @@47

@@46:
        add     di, ax

@@47:
        loop    @@46

        mov     ax, es
        mov     bx, di

        pop     di es

        mov     [(Wsio_Field ptr di).Data_Address_Src_Hi], ax
        mov     [(WSio_Field ptr di).Data_Address_Src_Lo], bx

        jmp     @@00

;----------
; KEY ENTER
;----------
@@50:
        mov     si, offset Ws_LF
        push    ds si
        pop     di es

        xor     bx, bx
        mov     bl, [(Wsio_Area ptr di).Select_Field_Occur_Nr]

        mov     [Mouse_Pressed], LOGIC_NO

        xor     cx, cx
        mov     cl, [(Wsio_Area ptr di).Cursor_Position_Row]
        cmp     cl, CURSOR_OFF_SCREEN                   ; Enter by mouse press?
        je      @@51                                    ; No
                                                        ; Yes, so
        mov     [Mouse_Pressed], LOGIC_YES

;
; Mouse pressed Enter, is it valid?
;
        cmp     cl, 4                                   ; Valid occurrence?
        jl      @@10                                    ; No
                                                        ; Maybe
        cmp     cl, 20                                  ; Valid occurrence?
        jnle    @@10                                    ; No
                                                        ; Maybe
        sub     cl, 3                                   ; Determine occurrence
        mov     dx, [Ws_LF_Occur_Curr]                  ; Current occurrence
        sub     dx, bx
        add     dx, cx
        cmp     dx, [Ws_LF_Occur_Max]                   ; Valid occurrence?
        jnle    @@10                                    ; No
                                                        ; Yes, so
        mov     [Ws_LF_Occur_Curr], dx                  ; Set occurrence
        mov     [Ws_LF_Occur_W_Curr], cx

@@51:
        push    ds si

;
; Go to end of path
;
        mov     si, offset Search_Dirs_Path             ; 73 chars for Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        dec     cx                                      ; To go to the last character
        add     di, cx                                  ; Go to end of path
        std                                             ; Searh direction is down
        mov     ax, BACKSLASH                           ; Search for "\"
        repne   scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; To postion after the "\"

;
; Determine selected directory/file
;
        mov     ax, [Ws_LF_Occur_Curr]
        dec     ax                                      ; Because of offset reasons
        xor     bx, bx
        mov     cx, DIR_ENTRY_LENGTH
        xor     dx, dx
        mul     cx

;
; Go to drive selection or dirs?
;        
        push    es di

        mov     es, [Dir_Map_ptr_es]
        mov     di, [Dir_Map_ptr_di]
        add     di, ax
        cmp     [byte es:di], DOT                       ; Go to drive selection/dirs?
        jne     @@64                                    ; No
                                                        ; Yes, so
        pop     di es                                   ; Check path
        pop     si ds
        cmp     [byte es:di - 2], COLON                 ; Go to drive selection?
        jne     @@63                                    ; No
                                                        ; Yes, so
        jmp     @@60

;------------------
; KEY F2 - FileMask
;------------------
@@55:
        call    Display_and_Read_Ws_FM

        mov     si, offset Ws_FM_F_Filemask
        push    ds si
        pop     di es

        cmp     [(Wsio_Field ptr di).Field_Changed], LOGIC_NO   ; Field changed?
        je      @@10                                    ; No
                                                        ; Yes, so
        mov     [Dir_Up], 0                             ; We stay in the current dir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files
        cmp     [Ws_LF_Occur_Max], 0                    ; Drive ready?
        je      @@60                                    ; No
                                                        ; Yes, so
        jmp     @@00

;------------------------------
; KEY F3 - Select another drive
;------------------------------
@@60:
;
; Select another drive
;
        cmp     [Disk_Image_Shown], LOGIC_YES           ; Is there still an image showing?
        jne     @@61                                    ; No
                                                        ; Yes, so
        mov     [Disk_Image_Shown], LOGIC_NO
        call    Display_Ws_FW                           ; Show Freeware Text

@@61:
;
; Reset Search Files Path
;
        mov     si, offset Search_Files_Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        mov     ax, SPACE
        rep     stosb                                   ; Clear path

        call    Display_Ws_PA                           ; Display path
        call    Display_and_Read_Ws_DR                  ; Let user select drive

        cmp     al, KEY_ESC                             ; Cancel pressed?
        je      @@99                                    ; Yes
                                                        ; No, so
@@62:
        mov     [Dir_Up], 0                             ; We stay in the current dir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files

        cmp     [Ws_LF_Occur_Max], 0                    ; Drive ready?
        je      @@60                                    ; No
                                                        ; Yes, so
        mov     si, offset Ws_LF
        mov     [byte ds:si], WSIO_DISPLAY_ONLY

        push    ds si
        call    WSIO
        pop     si ds

        jmp     @@05

@@63:
;
; Go to previous dir
;
        dec     di                                      ; Position on the "\"
        dec     di                                      ; Position before the "\"
        std                                             ; Searh direction is down
        mov     cx, DIR_NAME_LENGTH + 1
        mov     ax, BACKSLASH                           ; Search for "\"
        repne   scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; To postion after the "\"

        mov     cx, DIR_NAME_LENGTH + 1                 ; Because of "\"
        add     cx, FILE_NAME_LENGTH                    ; Because of *.ATR
        mov     ax, SPACE
        rep     stosb

        mov     [Dir_Up], 1                             ; We go to previous dir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files
        cmp     [Ws_LF_Occur_Max], 0                    ; Drive ready?
        je      @@60                                    ; No
                                                        ; Yes, so
        jmp     @@00

@@64:
;
; Go to subdir OR extract files from image OR do nothing
;
        push    es di
        add     di, FILE_NAME_LENGTH + 1                ; Go to file size
        cmp     [byte es:di], "<"                       ; Directory indicator
        pop     si ds                                   ; From -> Dir/File table

        pop     di es                                   ; To   -> Path
        jne     @@65                                    ; It's a file!
                                                        ; It's a directory, so
        mov     cx, DIR_NAME_LENGTH
        rep     movsb

        pop     si ds

        std                                             ; Search direction is down
        mov     cx, DIR_NAME_LENGTH + 1
        mov     ax, SPACE                               ; Search for not equal " "
        repe    scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; To position after the " "

        mov     [byte es:di], BACKSLASH

        mov     [Dir_Up], 2                             ; We go to a subdir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files

        cmp     [Ws_LF_Occur_Max], 0                    ; Drive ready?
        je      @@60                                    ; No
                                                        ; Yes, so
        jmp     @@00

@@65:
        pop     si ds

        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_UNKNOWN_DENSITY
                                                        ; Is this a XL disk image?
        jne     @@66                                    ; Yes
                                                        ; No, so
        cmp     [Mouse_Pressed], LOGIC_YES              ; Mouse pressed Enter?
        je      @@05                                    ; Yes
        jmp     @@10                                    ; No, so

@@66:
        cmp     [Mouse_Pressed], LOGIC_YES              ; Mouse pressed Enter?
        je      @@05                                    ; Yes
                                                        ; No, so
@@67:
        cmp     [Sectors_To_Extract], 0                 ; Something to extract?
        je      @@10                                    ; No
                                                        ; Yes, so
        cmp     [SpartaDos_Disk], LOGIC_YES             ; SpartaDos Disk format?
        jne     @@69                                    ; No
                                                        ; Yes, so
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@68                                    ; Yes
                                                        ; No, so
        call    Display_and_Read_Ws_SD                  ; Retrieve SpartaDos extract path

        cmp     al, KEY_ESC                             ; Cancel pressed?
        je      @@10                                    ; Yes
                                                        ; No, so
@@68:
        call    Extract_Disk_Image_Files_SpartaDos
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@99                                    ; Yes
                                                        ; No, so
        jmp     @@10

@@69:
        call    Extract_Disk_Image_Files
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@99                                    ; Yes
                                                        ; No, so
        jmp     @@10

;---------------------------
; Control Key + Drive Letter
;---------------------------
@@70:
        add     ax, 040h                                ; Turn drive into letter
        mov     cx, MAX_DRIVES                          ; Drives A thru Z
        mov     si, offset Available_Drives             ; Available drives

@@71:
        cmp     al, [byte ds:si]                        ; Selected drive present in table?
        je      @@72                                    ; Yes
                                                        ; No, so
        inc     si                                      ; Next drive from table
        loop    @@71                                    ; Check next drive
        jmp     @@60                                    ; Invalid drive, let user choose correct one

@@72:
        push    ax                                      ; Save drive letter

        mov     si, offset Search_Files_Path            ; Reset Search Files Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH
        mov     ax, SPACE
        rep     stosb

        mov     si, offset Search_Dirs_Path             ; Reset Search Dirs Path
        push    ds si
        pop     di es
        inc     di
        mov     cx, PATH_LENGTH - 1
        mov     ax, SPACE
        rep     stosb

        mov     si, offset Search_Dirs_Path             ; Copy selected drive to path
        push    ds si
        pop     di es

        pop     ax                                      ; Restore drive letter

        mov     [byte es:di], al
        mov     [byte es:di + 1], COLON
        mov     [byte es:di + 2], BACKSLASH

        jmp     @@62                                    ; Retrieve directories/files of selected drive

;----------------------
; KEY F4 - Config setup
;----------------------
@@80:
        call    Display_and_Read_Ws_CF

        cmp     al, KEY_ESC                             ; Cancel pressed?
        je      @@00                                    ; Yes
                                                        ; No, so
        mov     si, offset Ws_CF_F_Drives
        push    ds si
        pop     di es

        cmp     [(Wsio_Field ptr di).Field_Changed], LOGIC_YES  ; Field changed?
        je      @@00                                    ; Yes
                                                        ; No, so
        mov     si, offset Ws_CF_F_Filemask
        push    ds si
        pop     di es

        cmp     [(Wsio_Field ptr di).Field_Changed], LOGIC_YES  ; Field changed?
        jne     @@10                                    ; No
                                                        ; Yes, so
        mov     [Dir_Up], 0                             ; We stay in the current dir
        call    Read_VTOC_Directories_Files             ; Retrieve directories/files
        cmp     [Ws_LF_Occur_Max], 0                    ; Drive ready?
        je      @@60                                    ; No
                                                        ; Yes, so
        jmp     @@00

;---------
; KEY HELP
;---------
@@90:
        call    Display_Ws_LH
        jmp     @@05

;-------
; Return
;-------
@@99:
        ret

ENDP    Display_and_Read_Ws_LF



;**********************************************************************
PROC    Display_Ws_LH
;**********************************************************************
        mov     si, offset Ws_LH
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_LH
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_LH
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_Ws_LH



;**********************************************************************
PROC    Display_and_Read_Ws_FM
;**********************************************************************
        mov     si, offset Ws_FM
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_FM
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        mov     si, offset Ws_FM
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_and_Read_Ws_FM



;**********************************************************************
PROC    Display_and_Read_Ws_CF
;**********************************************************************
        mov     si, offset Ws_CF
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

@@00:
        mov     si, offset Ws_CF
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        cmp     al, KEY_ESC                             ; Cancel pressed?
        je      @@99                                    ; Yes
                                                        ; No, so
;
; Filemask
;
        mov     si, offset Search_Filemask
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Filemask
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

;
; Extract Deleted 8bit files?
;
        mov     [Config_Deleted_YN], LOGIC_NO

        mov     si, offset Config_Field_Deleted_Extract
        cmp     [byte ds:si], "N"                       ; Check if No is specified
        je      @@02                                    ; No is specified
                                                        ; Extract Deleted Files too!
        mov     [Config_Deleted_YN], LOGIC_YES

@@02:
;
; Get "new" list of drives
;
        push    ax                                      ; Save pressed key

        call    Read_VTOC_Drives

        pop     ax                                      ; Restore pressed key
        cmp     [Ws_DR_Occur_Max], 0                    ; Any valid drive present?
        je      @@00                                    ; No
                                                        ; Yes, so
;
; Check for update of configuration file
;
        cmp     al, KEY_F2                              ; Update config file
        jne     @@99                                    ; No
                                                        ; Yes, so
;
; Update XDIR.CFG configuration file
;
@@05:
;
; Allocate 10K to store old configuration file information
;
        mov     ax, DOS_GET_ALLOCATION_STRATEGY
        int     DOS_SERVICE

        mov     [Allocation_Strategy_Old], ax
        mov     [Allocation_Strategy_New], ax

        mov     bx, [Allocation_Strategy_New]
        or      bx, DOS_STRATEGY_MEM_UMB_CONV
        or      bx, DOS_STRATEGY_MEM_BEST_FIT
        mov     [Allocation_Strategy_New], bx

        mov     ax, DOS_SET_ALLOCATION_STRATEGY
        mov     bx, [Allocation_Strategy_New]
        int     DOS_SERVICE                             ; Set new strategy
        jnc     @@10                                    ; Failed?
                                                        ; Yes, so
        mov     ax, DOS_SET_ALLOCATION_STRATEGY
        mov     bx, [Allocation_Strategy_Old]
        int     DOS_SERVICE                             ; Reset to old strategy

@@10:
;
; Allocate Memory now
;
        xor     ax, ax                                  ; Reset ax
        mov     ah, DOS_ALLOCATE_MEMORY
        mov     bx, 640                                 ; Reserve 10K
        int     DOS_SERVICE                             ; Allocate Memory in paragraphs
        mov     cx, ax
        jnc     @@15

;
; Error, Memory Allocation
;
        mov     ax, DOS_SET_ALLOCATION_STRATEGY
        mov     bx, [Allocation_Strategy_Old]
        int     DOS_SERVICE                             ; Reset to old strategy

        jmp     @@99

@@15:
        mov     ax, DOS_SET_ALLOCATION_STRATEGY
        mov     bx, [Allocation_Strategy_Old]
        int     DOS_SERVICE                             ; Reset to old strategy

        push    cx                                      ; Determine address of allocated memory block
        pop     es
        xor     di, di
        push    es di                                   ; Save address of memory block

;
; Clear memory block
;
        mov     cx, 10240
        xor     ax, ax
        mov     al, SPACE                               ; Fill character
        rep     stosb                                   ; Initialize

        pop     di es
        push    es di

        mov     cx, CONFIG_PARAMETERS + 1

@@16:
        mov     [byte es:di], NULL                      ; When there is no config file
        add     di, 256
        loop    @@16

;
; Read Xdir.cfg configuration file
;
        pop     bx ax
        push    ax bx

        mov     si, offset CONFIG___File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Data_Address_Hi], ax
        mov     [(FMS_Area ptr di).Data_Address_Lo], bx
        mov     [(FMS_Area ptr di).Request], CMD_OPEN_INPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@40                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_GET

;
; Read Xdir.cfg file into allocated memory block
;

@@20:
;
; Get line from config file
;
        mov     si, offset CONFIG___File
        push    ds si
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@30                                    ; No
                                                        ; Yes, so
        add     [(FMS_Area ptr di).Data_Address_Lo], 256
        jnc     @@20
        inc     [(FMS_Area ptr di).Data_Address_Hi]
        jmp     @@20

@@30:
;
; Indicate input termination in memory file
;
        cmp     [(FMS_Area ptr di).Record_Size], 0      ; EOF found at end of line?
        je      @@35                                    ; No
                                                        ; Yes, so

        add     [(FMS_Area ptr di).Data_Address_Lo], 256
        jnc     @@35
        inc     [(FMS_Area ptr di).Data_Address_Hi]

@@35:
        push    es di

        mov     ax, [(FMS_Area ptr di).Data_Address_Hi]
        mov     di, [(FMS_Area ptr di).Data_Address_Lo]
        mov     es, ax
        mov     [byte es:di], NULL

        pop     di es

;
; Close configuration file
;
        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE
        push    es di
        call    FMSIO
        pop     di es

;
; Create Xdir.cfg configuration file
;
@@40:
        pop     bx ax
        push    ax bx

        mov     [(FMS_Area ptr di).Data_Address_Hi], ax
        mov     [(FMS_Area ptr di).Data_Address_Lo], bx
        mov     [(FMS_Area ptr di).Request], CMD_OPEN_OUTPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_PUT

        mov     [Parm_Being_Processed], 0

@@50:
;
; Prepare config "line" to be written
;
        push    es di
        mov     [(FMS_Area ptr di).Record_Size], PATH_LENGTH
        mov     ax, [(FMS_Area ptr di).Data_Address_Hi]
        mov     di, [(FMS_Area ptr di).Data_Address_Lo]
        mov     es, ax
        mov     al, [byte es:di]
        pop     di es

        cmp     al, NULL                                ; Last line processed
        je      @@70                                    ; Yes
                                                        ; No, so
        cmp     al, COMMENT_ROW                         ; Comment "line"?
        je      @@60                                    ; Yes
                                                        ; No, so
        cmp     al, SPACE                               ; Empty "line"?
        jne     @@70                                    ; No
                                                        ; Yes, so
@@60:
;
; Write config "line" (comment, etc.)
;
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@80                                    ; Error!

        add     [(FMS_Area ptr di).Data_Address_Lo], 256
        jnc     @@50
        inc     [(FMS_Area ptr di).Data_Address_Hi]
        jmp     @@50

@@70:
;
; Write config "line" (parameter)
;
        push    es di
        mov     bx, [(FMS_Area ptr di).Data_Address_Hi]
        mov     di, [(FMS_Area ptr di).Data_Address_Lo]
        mov     es, bx
        inc     [Parm_Being_Processed]

;
; Which parameter to process?
;
        mov     bx, MAX_DRIVES                          ; Field Size
        mov     si, offset Config_Field_Drives
        cmp     [Parm_Being_Processed], 1               ; Parm Drives?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, FILE_NAME_LENGTH                    ; Field Size
        mov     si, offset Config_Field_Filemask
        cmp     [Parm_Being_Processed], 2               ; Parm Filemask?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, PATH_LENGTH                         ; Field Size
        mov     si, offset Config_Field_Startup_Path
        cmp     [Parm_Being_Processed], 3               ; Parm Extract From?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, PATH_LENGTH                         ; Field Size
        mov     si, offset Config_Field_Extract_To_Path
        cmp     [Parm_Being_Processed], 4               ; Parm Write To?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, 1                                   ; Field Size
        mov     si, offset Config_Field_Deleted_Extract
        cmp     [Parm_Being_Processed], 5               ; Parm Extract Deleted Files?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, PATH_LENGTH                         ; Field Size
        mov     si, offset Config_Field_Deleted_Path
        cmp     [Parm_Being_Processed], 6               ; Parm Deleted Files Path?
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     bx, PATH_LENGTH                         ; Field Size
        mov     si, offset Config_Field_Add_Path
        cmp     [Parm_Being_Processed], 7               ; Parm Add Files From Path
        je      @@75                                    ; Yes
                                                        ; No, so
        pop     di es

        cmp     al, NULL                                ; Last line processed
        jne     @@50                                    ; No
                                                        ; Yes, so
        jmp     @@80

@@75:
        mov     cx, PATH_LENGTH
        rep     movsb

        pop     di es
        mov     [(FMS_Area ptr di).Record_Size], bx
        jmp     @@60

@@80:
;
; Close config file
;
        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE
        push    es di
        call    FMSIO
        pop     di es

@@90:
;
; Release Allocated Memory
;
        pop     di es
        xor     ax, ax
        mov     ah, DOS_FREE_ALLOCATED_MEMORY
        int     DOS_SERVICE                         ; Release Allocated Memory

@@99:
        mov     si, offset Ws_CF
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Display_and_Read_Ws_CF



;**********************************************************************
PROC    Display_and_Read_Ws_SD
;**********************************************************************
;
; Copy extract path from configuration file
;
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es
        mov     si, offset Config_Field_Extract_To_Path
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Display and Read SpartaDos extraction path
;
        mov     si, offset Ws_SD
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

@@10:
        mov     si, offset Ws_SD
        mov     [byte ds:si], WSIO_DISPLAY_AND_READ
        push    ds si
        call    WSIO
        pop     si ds

        cmp     al, KEY_ESC                             ; Cancel pressed?
        je      @@90                                    ; Yes
                                                        ; No, so
;
; Volume Name entered?
;
        mov     si, offset Ws_SD_D_Volume_Name
        cmp     [byte ds:si], SPACE                     ; Something entered?
        je      @@10                                    ; No
                                                        ; Yes, so
;
; Copy extract path from configuration file
;
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es

;
; Search backslash at end
;
        mov     cx, PATH_LENGTH                         ; Search length
        dec     cx                                      ; Because of null terminator
        add     di, cx                                  ; Go to end of string
        std                                             ; Search direction is down
        xor     ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; Pointer adjustment after search

;
; And add volume name
;
        mov     si, offset Ws_SD_D_Volume_Name
        mov     cx, 8                                   ; Volume Name Size
        rep     movsb

@@90:
        push    ax

        mov     si, offset Ws_SD
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        pop     ax

@@99:
        ret

ENDP    Display_and_Read_Ws_SD



;**********************************************************************
PROC    Retrieve_Disk_Image_VTOC
;**********************************************************************
        mov     [SpartaDos_Disk], LOGIC_NO

; Determine filename to open
        sub     di, FILE_NAME_LENGTH + 1                ; Go to filename

        push    ds si es di

        mov     si, offset ATARI____Pathname

        push    ds si
        pop     di es
        mov     si, offset Search_Dirs_Path
        mov     cx, PATH_LENGTH
        rep     movsb

; Search for last "\"
        mov     cx, PATH_LENGTH                         ; Search length
        std                                             ; Search direction is down
        or      ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search equal "\" uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; Move next to the "\"

; Append Filename from entry
        pop     si ds
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

        pop     si ds

;----------------------------------------------
; Check if drive we have to access drive A or B
;----------------------------------------------
        call    Verify_Disk_Presence_Drive_A_Or_B       ; If were reading drive A or B

        cmp     [Disk_Present], LOGIC_YES               ; Diskette present
        jne     @@99                                    ; No
                                                        ; Yes, so
;
; Open ATARI disk image file
;
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_INPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READNEXT
        mov     [(FMS_Area ptr di).Offset], EIGHTBIT_BOOT_SECTOR_SIZE

        cmp     [Disk_Image_ATR], LOGIC_YES             ; ATR Disk Image?
        jne     @@10                                    ; No
                                                        ; Yes, so
        add     [(FMS_Area ptr di).Offset], ATR_HEADER_SIZE

;
; Read file header
;
        mov     [(FMS_Area ptr di).Record_Size], ATR_HEADER_SIZE
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

        mov     si, offset Disk_I_O_Buffer
        mov     cx, ATR_HEADER_SIZE_COMPARE
        push    cx ds si                                ; Save compare info

; Check file header single
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_SINGLE_DENSITY

        mov     si, offset Disk_ATR_Single_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Single?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header medium
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEDIUM_DENSITY

        mov     si, offset Disk_ATR_Medium_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Medium?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header enhanced
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_ENHANCED_DENSITY

        mov     si, offset Disk_ATR_Enhanced_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Enhanced?
        je      @@05                                    ; Yes,
                                                        ; No, so
; Check file header double
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     si, offset Disk_ATR_Double_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Double?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header quad
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY

        mov     si, offset Disk_ATR_Quad_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Quad?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header 720KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_720KB_DENSITY

        mov     si, offset Disk_ATR_720KB_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR 720KB?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header megadisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_MEGADISK_DENSITY

        mov     si, offset Disk_ATR_Megadisk_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Megadisk?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header 1440KB
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_1440KB_DENSITY

        mov     si, offset Disk_ATR_1440KB_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR 1440KB?
        je      @@05                                    ; Yes
                                                        ; No, so
; Check file header harddisk
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_HARDDISK_DENSITY

        mov     si, offset Disk_ATR_Harddisk_Header
        push    ds si
        pop     di es

        pop     si ds cx
        push    cx ds si
        rep     cmpsb                                   ; Header is .ATR Harddisk?
        je      @@05                                    ; Yes
                                                        ; No, so
        pop     si ds cx
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_UNKNOWN_DENSITY
        jmp     @@90

@@05:
        pop     si ds cx

;---------------------------------------------------------------
; From now on, the disk image can be treated as a XFD disk image
;---------------------------------------------------------------
@@10:
;----------------------------------------------
; Get field size of 8 bit VTOC files table item
;----------------------------------------------
        mov     si, offset Ws_XL_F_XL_File_1
        push    ds si
        pop     di es

        mov     ax, EIGHTBIT_VTOC_FILES_MAX
        xor     bx, bx
        xor     cx, cx
        mov     cl, [byte (Wsio_Field ptr di).Size]

        mov     si, offset Ws_XL_F_XL_Size_1
        push    ds si
        pop     di es

        add     cl, [byte (Wsio_Field ptr di).Size]

        mov     [Save_cx], cx
        xor     dx, dx
        mul     cx

;-----------------------------
; Clear 8 bit VTOC files Table
;-----------------------------
        mov     si, offset XDisk_File_Info_1
        push    ds si

        push    ds si
        pop     di es

        mov     cx, ax
        xor     ax, ax                                  ; Reset ax
        mov     al, SPACE                               ; Fill character
        rep     stosb

;----------------
; Assume bootdisk
;----------------
        pop     di es
        mov     si, offset XDisk_Image_Is_Bootdisk
        mov     cx, FILE_NAME_LENGTH
        rep     movsb

;----------------------------
; Reset attributes - Filename
;----------------------------
        mov     si, offset XDisk_Attrib_Info_1
        push    ds si
        pop     di es
        mov     cx, EIGHTBIT_VTOC_FILES_MAX
        mov     al, ATTRIB_CYAN_WHITE
        rep     stosb                                   ; Initialize to Cyan White

;----------------------------
; Reset attributes - Filesize
;----------------------------
        mov     si, offset XDisk_Attrib_Size_1
        push    ds si
        pop     di es
        mov     cx, EIGHTBIT_VTOC_FILES_MAX
        mov     al, ATTRIB_CYAN_WHITE
        rep     stosb                                   ; Initialize to Cyan White

;
; Read Bootcode sector
;
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Record_Size], EIGHTBIT_SECTOR_SIZE
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!


        mov     [Disk_Sector_Size], EIGHTBIT_SECTOR_SIZE

        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY
        jne     @@11

        mov     [Disk_Sector_Size], EIGHTBIT_SECTOR_SIZE_DOUBLE

;----------------------------
; Check SpartaDos disk format
;----------------------------
@@11:
        mov     si, offset Disk_I_O_Buffer
        cmp     [byte ds:si], 000h                      ; 1e byte 00 hex?
        jne     @@15                                    ; No
                                                        ; Yes, so
        cmp     [byte ds:si + 1], 003h                  ; 1e byte 03 hex?
        jne     @@15                                    ; No
                                                        ; Yes, so
        cmp     [byte ds:si + 2], 000h                  ; 1e byte 00 hex?
        jne     @@15                                    ; No
                                                        ; Yes, so
        cmp     [byte ds:si + 7], 080h                  ; 8e byte 80 hex?
        jne     @@15                                    ; No
                                                        ; Yes, so
        cmp     [byte ds:si + 31], 000h                 ; 32e byte 00 hex?
        jne     @@12                                    ; No
                                                        ; Yes, so
        mov     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY
        mov     [Disk_Sector_Size], EIGHTBIT_SECTOR_SIZE_DOUBLE

@@12:
        call    Retrieve_Disk_Image_VTOC_SpartaDos
        jmp     @@90

@@15:
;------------------------------------------------------------------
; Read Atari Disk Image VTOC (sector/recordnr 361)
; Single   Density = offset 0B400h (0B410h for ATR)
; Medium   Density = offset 0B400h (0B410h for ATR)
; Enhanced Density = offset 0B400h (0B410h for ATR)
; Double   Density = offset 16680h (16690h for ATR)
; Megadisk Density = offset 0B400h (0B410h for ATR)
; VTOC is 8 sectors wide
;------------------------------------------------------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

;
; Jump to VTOC area
;
        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_START
        mov     si, offset Disk_VTOC_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_VTOC_SECTOR
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS
        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

;
; Read VTOC area
;
        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READNEXT
        mov     [(FMS_Area ptr di).Record_Size], EIGHTBIT_VTOC_SIZE

        push    es di
        call    FMSIO
        pop     di es

        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

;-----------------------------------
; Move 8bit vtoc files to field area
;-----------------------------------
        mov     cx, EIGHTBIT_VTOC_FILES_MAX             ; Maximum nr of 8bit vtoc files
        mov     si, offset XDisk_File_Info_1

        push    ds si
        pop     di es

        mov     [Sectors_To_Extract], 0
        mov     si, offset Disk_VTOC_Buffer

        xor     ax, ax                                  ; Reset ax
        mov     ah, [byte ds:si + 2]                    ; Load File Size high byte
        cmp     ah, 05                                  ; Filesize > 05FFh don't exist
        jnle    @@90                                    ; We have a "boot disk"
                                                        ; No, so regular vtoc
        mov     [XL_VTOC_File_Nr], 0                    ; Reset number of entries

@@30:
        xor     ax, ax
        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, 08Fh                                ; Entry present
        jnle    @@32                                    ; No
                                                        ; Maybe
        cmp     ax, 001h                                ; Entry present?
        jle     @@32                                    ; No
                                                        ; Maybe
        mov     al, [byte ds:si + 15]                   ; Get last byte of filename
        cmp     ax, NULL                                ; Filename exist?
        jne     @@34                                    ; Yes
                                                        ; No
@@32:
        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY
        jne     @@90                                    ; No
                                                        ; Yes, so
        add     si, EIGHTBIT_SECTOR_SIZE                ; Skip 1 sector of 128 bytes

        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, 08Fh                                ; Entry present
        jnle    @@90                                    ; No
                                                        ; Maybe
        cmp     ax, 001h                                ; Entry present?
        jle     @@90                                    ; No
                                                        ; Maybe
        mov     al, [byte ds:si + 15]                   ; Get last byte of filename
        cmp     ax, NULL                                ; Filename exist?
        je      @@90                                    ; Yes
                                                        ; Yes, so
@@34:
        inc     [XL_VTOC_File_Nr]

        mov     [XFile_Deleted], LOGIC_NO
        mov     [XFile_Locked], LOGIC_NO
        mov     [XFile_Extended], LOGIC_NO
        mov     [XFile_Inverse], LOGIC_NO

        push    ds si es di cx

; Check File Status
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 080h                                ; Check Delete Status
        cmp     al, 080h                                ; File Deleted?
        jne     @@40                                    ; No
                                                        ; Yes, so
        mov     [XFile_Deleted], LOGIC_YES

@@40:
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 020h                                ; Check Lock Status
        cmp     al, 020h                                ; File Locked?
        jne     @@42                                    ; No
                                                        ; Yes, so
        mov     [XFile_Locked], LOGIC_YES

@@42:
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 001h                                ; Check Extended Status
        cmp     al, 001h                                ; File Extended?
        jne     @@44                                    ; No
                                                        ; Yes, so
        mov     [XFile_Extended], LOGIC_YES

@@44:
        cmp     [Folder_Indicator], LOGIC_YES           ; Is this a subdirectory?
        je      @@56                                    ; Yes
                                                        ; No, so
        cmp     [XFile_Deleted], LOGIC_YES              ; Deleted file?
        je      @@50                                    ; Yes
                                                        ; No, so
        mov     ah, [byte ds:si + 2]                    ; Filesize
        mov     al, [byte ds:si + 1]

        sub     [XDisk_Sectors_Free], ax
        jmp     @@52

@@50:
        cmp     [Config_Deleted_YN], LOGIC_NO           ; Extract deleted?
        je      @@54                                    ; No
                                                        ; Yes, so
@@52:
;
; Number of sectors to extract if we are ordered to extract the files
;
        add     [Sectors_To_Extract], ax

;
; XFile size
;
@@54:
        mov     si, offset Hex2digi_Requested_Format
        push    ds si                                   ; Parameter 1

        mov     si, offset XFile_Size_Text
        mov     [byte ds:si], NULL
        mov     [byte ds:si + 1], NULL
        mov     [byte ds:si + 2], ah
        mov     [byte ds:si + 3], al

        push    ds si
        call    HEX2DIGI
        pop     ax ax ax ax

        mov     si, offset XFile_Size_Text
        cmp     [byte ds:si + 10], SPACE                ; File size present?
        jne     @@60                                    ; Yes
                                                        ; No, so
@@56:
        mov     [XFile_Inverse], LOGIC_YES              ; We have a "comment" entry

;---------------------------
; Move xl file info to table
;---------------------------
@@60:
        pop     cx di es si ds
        push    ds si es di cx

;------------------------------------------------------------------------
; Check Filename for special "comment" editing, and strip high bits if so
;------------------------------------------------------------------------
        push    ds si
        mov     cx, FILE_NAME_LENGTH - 1
        add     si, 5                                   ; Begin of filename, i.e. MYFILE  TXT

@@62:
        mov     al, [byte ds:si]                        ; load character
        and     al, 080h                                ; Check high bit
        cmp     al, NULL                                ; High bit set?
        je      @@64                                    ; No
                                                        ; Yes, so
        and     [byte ds:si], 07Fh                      ; Reset high bit
        
@@64:
        inc     si
        loop    @@62

        pop     si ds

; Move XFilename
        add     si, 5                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

; Move XSize
        mov     si, offset XFile_Size_Text
        add     si, 7                                   ; To skip 7 spaces
        mov     cx, 4
        rep     movsb                                   ; Move "  43" File Size part

;---------------------------------------------
; Check if we have to change screen attributes
;--------------------------------------------
        mov     ah, ATTRIB_RED_WHITE                    ; Assume deleted file
        cmp     [XFile_Deleted], LOGIC_YES
        je      @@70                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_GREEN_WHITE                  ; Assume locked file
        cmp     [XFile_Locked], LOGIC_YES
        je      @@70                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_MAGENTA_WHITE                ; Assume Comment
        cmp     [XFile_Inverse], LOGIC_YES
        je      @@70                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_CYAN_WHITE                   ; Assume default

@@70:
;
; Move attribute to tables (filename + filesize)
;
        mov     si, offset XDisk_Attrib_Info_1
        xor     bx, bx
        mov     bl, [XL_VTOC_File_Nr]
        dec     bx
        add     si, bx
        mov     [byte ds:si], ah

        mov     si, offset XDisk_Attrib_Size_1
        add     si, bx
        mov     [byte ds:si], ah

;
; If file extended, mark it accordingly
;
        cmp     [XFile_Extended], LOGIC_YES
        jne     @@85                                    ; No
                                                        ; Yes, so
        mov     ah, ATTRIB_RED_BLUE                     ; Assume deleted file
        cmp     [XFile_Deleted], LOGIC_YES
        je      @@80                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_GREEN_BLUE                   ; Assume locked file
        cmp     [XFile_Locked], LOGIC_YES
        je      @@80                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_CYAN_BLUE                    ; Assume default

@@80:
; Move attribute to table (filesize only)
        mov     si, offset XDisk_Attrib_Size_1
        mov     bx, EIGHTBIT_VTOC_FILES_MAX
        sub     bx, cx
        add     si, bx
        mov     [byte ds:si], ah

@@85:
        pop     cx di es si ds

        add     di, [Save_cx]                           ; Move to next file entry
        add     si, EIGHTBIT_FILE_ENTRY_SIZE            ; Move to next xl vtoc entry
        loop    @@30

;-----------------
; Close Disk image
;-----------------
@@90:
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE
        mov     si, offset Disk_I_O_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si

        push    es di
        call    FMSIO
        pop     di es

;--------------------------------------
; Show number of free sectors remaining
;--------------------------------------
@@95:
        mov     si, offset Hex2digi_Requested_Format
        push    ds si                                   ; Parameter 1

        mov     ax, [XDisk_Sectors_Free]

        mov     si, offset XFile_Size_Text
        mov     [byte ds:si], NULL
        mov     [byte ds:si + 1], NULL
        mov     [byte ds:si + 2], ah
        mov     [byte ds:si + 3], al

        push    ds si
        call    HEX2DIGI
        pop     ax ax ax ax

; Move Free sectors
        mov     si, offset Xdisk_Free_Sectors
        push    ds si
        pop     di es
        mov     si, offset XFile_Size_Text
        add     si, 7                                   ; To skip 7 spaces
        mov     cx, 4
        rep     movsb                                   ; Move "  43" File Size part

@@99:
        ret

ENDP    Retrieve_Disk_Image_VTOC



;**********************************************************************
PROC    Retrieve_Disk_Image_VTOC_SpartaDos
;**********************************************************************
        mov     [SpartaDos_Disk], LOGIC_YES

;---------------------
; Retrieve volume name
;---------------------
        mov     si, offset Ws_SD_D_Volume_Name
        push    ds si
        pop     di es
        mov     si, offset Disk_I_O_Buffer
        add     si, 22                                  ; Point to volume name
        mov     cx, 8                                   ; Volume name size
        rep     movsb

;---------------------------------------------------------------
; We want to show all (sub)folders on the SpartaDos disk
; that's why we keep track of where we are in the VTOC structure
; Of course there's a maximum of 64 showable items on the screen
;---------------------------------------------------------------
        mov     [Folder_Counter], 0

;-------------------------------------------------------------------------
; Read SpartaDos Disk Image VTOC (sector/recordnr specified in boot block)
; VTOC is unknown is size
;-------------------------------------------------------------------------
        mov     si, offset Disk_I_O_Buffer
        mov     ax, [ds:si + 9]                         ; Vtoc sector offset

;
; Remember start sector
;
        mov     si, offset Folder_Pointer
        mov     [ds:si], ax                             ; Sector

        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

;-----------------------------------
; Move 8bit vtoc files to field area
;-----------------------------------
        mov     cx, EIGHTBIT_VTOC_FILES_MAX             ; Maximum nr of 8bit vtoc files
        mov     si, offset XDisk_File_Info_1

        push    ds si
        pop     di es

        mov     [Sectors_To_Extract], 0
        mov     [XL_VTOC_File_Nr], 0                    ; Reset number of entries

        mov     si, offset Disk_VTOC_Buffer + SPARTADOS_FILE_ENTRY_SIZE ; Start of files
        mov     [Process_Files], LOGIC_YES

@@10:
;-------------------------
; First only process files
;-------------------------
        cmp     [Process_Files], LOGIC_YES
        jne     @@12                                    ; No
                                                        ; Yes, so
        xor     ax, ax
        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, NULL                                ; Last entry processed?
        je      @@11                                    ; Yes
                                                        ; No, so
        and     ax, SPARTADOS_DIRECTORY
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        jne     @@15                                    ; No
                                                        ; Yes, so
        jmp     @@95                                    ; Next entry

@@11:
;------------------------------
; Then only process directories
;------------------------------
        mov     [Process_Files], LOGIC_NO
        mov     si, offset Disk_VTOC_Buffer + SPARTADOS_FILE_ENTRY_SIZE ; Start of files
        jmp     @@10

@@12:
;-------------------------
; Process directories only
;-------------------------
        xor     ax, ax
        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, NULL                                ; Last entry processed?
        je      @@14                                    ; Yes
                                                        ; No, so
        and     ax, SPARTADOS_DIRECTORY
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        je      @@15                                    ; Yes
                                                        ; No, so
        jmp     @@95                                    ; Next entry

@@14:
        cmp     [Folder_Counter], 0                     ; Are we at the root?
        je      @@99                                    ; Yes
                                                        ; No, so
;-------------------------
; Go to previous directory
;-------------------------
        push    es di

        dec     [Folder_Counter]

        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]

        mov     ax, [ds:si]                             ; Sector number where this directory started

        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

        pop     di es

        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        mov     bx, [ds:si + 2]                         ; Offset within directory

        mov     si, offset Disk_VTOC_Buffer             ; Sector
        push    bx
        pop     si
        jmp     @@10                                    ; Check again

@@15:
;-----------------------------
; Process SpartaDos VTOC entry
;-----------------------------
        mov     [Folder_Indicator], LOGIC_NO            ; Assume no folder
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        jne     @@20                                    ; No
                                                        ; Yes, so
;----------------------------------------------
; SpartaDos directory encountered, deal with it
;----------------------------------------------
        mov     [Folder_Indicator], LOGIC_YES

@@20:
;----------------------------------------------
; Process file or directory name and properties
;----------------------------------------------
        mov     cl, EIGHTBIT_VTOC_FILES_MAX             ; Maximum nr of files we can show
        sub     cl, [XL_VTOC_File_Nr]                   ; Nr of Screen VTOC entries
        cmp     cl, NULL                                ; Are we at the maximum yet?
        jz      @@86                                    ; Yes
                                                        ; No, so
        inc     [XL_VTOC_File_Nr]

@@22:
        mov     [XFile_Deleted], LOGIC_NO
        mov     [XFile_Locked], LOGIC_NO
        mov     [XFile_Extended], LOGIC_NO
        mov     [XFile_Inverse], LOGIC_NO

; Check File Status
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 010h                                ; Check Delete Status
        cmp     al, 010h                                ; File Deleted?
        jne     @@25                                    ; No
                                                        ; Yes, so
        mov     [XFile_Deleted], LOGIC_YES
        cmp     [Folder_Indicator], LOGIC_YES           ; Deleted directory?
        je      @@95                                    ; Yes
                                                        ; No, so
@@25:
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 001h                                ; Check Lock Status
        cmp     al, 001h                                ; File Locked?
        jne     @@30                                    ; No
                                                        ; Yes, so
        mov     [XFile_Locked], LOGIC_YES

@@30:
        push    ds si es di

;---------------------------------------------------------------------
; When we are in a (sub)directory, we don't do something with the size
;---------------------------------------------------------------------
        cmp     [Folder_Indicator], LOGIC_YES           ; Is this file a folder name?
        je      @@45                                    ; Yes
                                                        ; No, so
        xor     dh, dh                                  ; Filesize
        mov     dl, [byte ds:si + 5]
        mov     ah, [byte ds:si + 4]
        mov     al, [byte ds:si + 3]

        mov     bx, [Disk_Sector_Size]                  ; Record size in bx
        xor     cx, cx

        div     bx                                      ; Determine nr of sectors

        cmp     dx, 0                                   ; Remainder?
        je      @@35                                    ; No
                                                        ; Yes, so
        inc     ax                                      ; We need another sector

@@35:
        sub     [XDisk_Sectors_Free], ax

        cmp     [XFile_Deleted], LOGIC_YES              ; Deleted file?
        jne     @@40                                    ; No
                                                        ; Yes, so
        cmp     [Config_Deleted_YN], LOGIC_NO           ; Extract deleted?
        je      @@50                                    ; No
                                                        ; Yes, so
;
; Number of sectors to extract if we are ordered to extract the files
;
@@40:
        add     [Sectors_To_Extract], ax
        jmp     @@50

@@45:
        mov     [XFile_Inverse], LOGIC_YES              ; We have a "comment" entry

        mov     cl, [XL_VTOC_File_Nr]                   ; Nr of Screen VTOC entries
        cmp     cl, EIGHTBIT_VTOC_FILES_MAX             ; Are we at the maximum yet?
        jnle    @@85                                    ; Yes
                                                        ; No, so
;---------------------------
; Move xl file info to table
;---------------------------
@@50:
        pop     di es si ds
        push    ds si es di

;------------------------------------------------------------------------
; When we are in a (sub)directory, the folder and files within the folder
; will be moved to the right "folder counter" - 1 times
;------------------------------------------------------------------------
        add     di, [Folder_Counter]
        cmp     [Folder_Indicator], LOGIC_YES           ; Folder?
        je      @@60                                    ; Yes
                                                        ; No, so
        cmp     [Folder_Counter], 0                     ; Are we at the root?
        je      @@60                                    ; Yes
                                                        ; No, so
        dec     di

@@60:
;------------------------------------------------------------------------
; Check Filename for special "comment" editing, and strip high bits if so
;------------------------------------------------------------------------
        push    ds si
        mov     cx, FILE_NAME_LENGTH - 1
        add     si, 6                                   ; Begin of filename, i.e. MYFILE  TXT

@@65:
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; load character
        and     al, 080h                                ; Check high bit
        cmp     al, NULL                                ; High bit set?
        je      @@70                                    ; No
                                                        ; Yes, so
        and     [byte ds:si], 07Fh                      ; Reset high bit
        
@@70:
        inc     si
        loop    @@65

        pop     si ds

; Move XFilename
        add     si, 6                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

;---------------------------------------------
; Check if we have to change screen attributes
;--------------------------------------------
        mov     ah, ATTRIB_RED_WHITE                    ; Assume deleted file
        cmp     [XFile_Deleted], LOGIC_YES
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_GREEN_WHITE                  ; Assume locked file
        cmp     [XFile_Locked], LOGIC_YES
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_MAGENTA_WHITE                ; Assume Comment
        cmp     [XFile_Inverse], LOGIC_YES
        je      @@75                                    ; Yes
                                                        ; No, so
        mov     ah, ATTRIB_CYAN_WHITE                   ; Assume default

@@75:
;
; Move attribute to tables (filename + filesize)
;
        mov     si, offset XDisk_Attrib_Info_1
        xor     dx, dx
        mov     dl, [XL_VTOC_File_Nr]
        dec     dx
        add     si, dx
        mov     [byte ds:si], ah

        mov     si, offset XDisk_Attrib_Size_1
        add     si, dx
        mov     [byte ds:si], ah

@@85:
        pop     di es si ds

@@86:
        add     di, [Save_cx]                           ; Move to next file entry
        cmp     [Folder_Indicator], LOGIC_YES           ; Are we processing a folder
        jne     @@95                                    ; No
                                                        ; Yes, so
        push    es di

;---------------------------
; Proces SpartaDos directory
;---------------------------
        mov     al, [byte ds:si + 1]                    ; Vtoc sector offset
        mov     ah, [byte ds:si + 2]

        push    si
        pop     bx
        add     bx, SPARTADOS_FILE_ENTRY_SIZE           ; Move to next xl vtoc entry

        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]

        mov     [ds:si + 2], bx                         ; Offset

        inc     [Folder_Counter]

        mov     [ds:si + 4], ax                         ; Remember offset

;--------------------
; Jump to Folder area
;--------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

        pop     di es
        mov     si, offset Disk_VTOC_Buffer             ; Start of files
        mov     [Process_Files], LOGIC_YES
        jmp     @@95

@@90:
        pop     di es
        jmp     @@99

@@95:
        add     si, SPARTADOS_FILE_ENTRY_SIZE           ; Move to next xl vtoc entry
        jmp     @@10

@@99:
        ret

ENDP    Retrieve_Disk_Image_VTOC_SpartaDos



;**********************************************************************
PROC    Extract_Disk_Image_Files
;**********************************************************************
;----------------------------------------------
; Check if drive we have to access drive A or B
;----------------------------------------------
        call    Verify_Disk_Presence_Drive_A_Or_B       ; If were reading drive A or B

        cmp     [Disk_Present], LOGIC_YES               ; Diskette present
        jne     @@99                                    ; No
                                                        ; Yes, so
;---------------------
; Open disk image file
;---------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_INPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@95                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READ

;---------------------------------
; Reset progress bar to Cyan White
;---------------------------------
        mov     si, offset XDisk_Progress_Bar
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, 0B0h
        xor     cx, cx
        mov     cl, [XDisk_Progress_Cnt_Max]
        rep     stosb

        mov     [XDisk_Progress_Cnt_Prev], 0
        mov     [Sectors_Extracted], 0

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@05                                    ; Yes
                                                        ; No, so
;--------------------
; Open extract window
;--------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

;----------------------------------------
; Show that we are going to extract stuff
;----------------------------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_ONLY
        push    ds si
        call    WSIO
        pop     si ds

@@05:
;------------------
; Process 8bit VTOC
;------------------
        mov     cx, EIGHTBIT_VTOC_FILES_MAX             ; Maximum nr of 8bit vtoc files
        mov     si, offset Disk_VTOC_Buffer

@@10:
        push    ds si cx

        mov     [XFile_Deleted], LOGIC_NO

        cmp     [byte ds:si + 15], NULL                 ; Entry present?
        jne     @@15                                    ; Yes
                                                        ; No
        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY
        jne     @@80                                    ; No
                                                        ; Yes, so
        pop     cx si ds
        add     si, EIGHTBIT_SECTOR_SIZE                ; Skip 1 sector of 128 bytes
        push    ds si cx
        
        cmp     [byte ds:si + 15], NULL                 ; Entry present?
        je      @@80                                    ; No
                                                        ; Yes, so
@@15:
;
; Check for File or Comment
;
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 083h                                ; Check File Status
        cmp     al, 000h                                ; Comment?
        je      @@80                                    ; Yes
                                                        ; No , so
;
; Check File Status
;
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 080h                                ; Check Delete Status
        cmp     al, 080h                                ; File Deleted?
        jne     @@20                                    ; No
                                                        ; Yes , so
        mov     [XFile_Deleted], LOGIC_YES
        cmp     [Config_Deleted_YN], LOGIC_NO           ; Extract deleted?
        je      @@80                                    ; No
                                                        ; Yes, so
;--------------------
; Set up pc file path
;--------------------
@@20:
;
; Set Up Path - Volume and Directories
;
        push    ds si                                   ; Save pointer into VTOC

        mov     si, offset PC_ATARI_Pathname
        push    ds si                                   ; Save file path

        push    ds si
        pop     di es

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        jne     @@21                                    ; No
                                                        ; Yes, so
        mov     si, offset CLI_Outdir
        jmp     @@25

@@21:
        mov     si, offset Config_Field_Extract_To_Path

        cmp     [XFile_Deleted], LOGIC_YES              ; File Deleted?
        jne     @@25                                    ; No
                                                        ; Yes, so
        mov     si, offset Config_Field_Deleted_Path

@@25:
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Search for last "\"
;
        pop     di es                                   ; Restore file path

        mov     cx, PATH_LENGTH                         ; Search length
        add     di, cx                                  ; Go to end of Path
        std                                             ; Search direction is down
        or      ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search equal "\" uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; Move next to the "\"

        pop     si ds                                   ; Restore pointer into VTOC

;
; Set Up Path - Append 8 bit Filename
;
        push    ds si                                   ; Save pointer into VTOC again

        mov     cl, [byte ds:si + 3]                    ; Low portion of Start Sector
        mov     ch, [byte ds:si + 4]                    ; High portion of Start Sector
        mov     [XDisk_Next_Sector], cx
        add     si, 5                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

;------------------------------
; Set up file we are extracting
;------------------------------
        mov     si, offset XDisk_Extract_File
        push    ds si
        pop     di es

        pop     si ds                                   ; Restore pointer into VTOC again

        mov     ah, [byte ds:si + 2]                    ; Nr of sectors according to VTOC
        mov     al, [byte ds:si + 1]
        mov     [Sectors_For_This_File], ax

        add     si, 5                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@30                                    ; Yes
                                                        ; No, so
;----------------------------------
; Show which file we are extracting
;----------------------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY
        push    ds si
        call    WSIO
        pop     si ds

@@30:
;----------------------------
; Create 8 bit file on the pc
;----------------------------
        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_OUTPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@80                                    ; Error!

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_WRITENEXT

;----------------------------------------
; Position to "Next" Sector in File Chain
;----------------------------------------
@@40:
        mov     ax, [XDisk_Next_Sector]
        cmp     ax, NULL                                ; More sectors to read?
        je      @@70                                    ; No
                                                        ; Yes, so
;
; Read (next) sector
;
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Record_Nr], ax
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        dec     [Sectors_For_This_File]

;---------------------------------------------
; Determine Next Sector from sector link chain
; Determine current byte count for this sector
;---------------------------------------------
        mov     si, offset Disk_I_O_Buffer
        mov     ah, [byte ds:si + 125]                  ; Low portion of Start Sector
        mov     al, [byte ds:si + 126]                  ; High portion of Start Sector
        xor     cx, cx                                  ; Reset cx
        mov     cl, [byte ds:si + 127]                  ; Byte Count

        cmp     [Disk_Media_Type], DISK_MEDIA_TYPE_DOUBLE_DENSITY
        jne     @@50                                    ; No
                                                        ; Yes, so
        mov     ah, [byte ds:si + 253]                  ; Low portion of Start Sector
        mov     al, [byte ds:si + 254]                  ; High portion of Start Sector
        mov     cl, [byte ds:si + 255]                  ; Byte Count

@@50:
        and     ax, 003FFh                              ; Reset 6 left bits
        mov     [XDisk_Next_Sector], ax

;-------------------------------------------------------------
; Write sector (without sector link chain info) to the pc file
;-------------------------------------------------------------
        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Record_Size], cx

@@60:
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        inc     [Sectors_Extracted]                     ; Another sector accounted for

;------------------------------------------------------
; Calculate progress bar size, and show it if necessary
;------------------------------------------------------
        mov     ax, [Sectors_Extracted]
        xor     bx, bx
        xor     cx, cx
        mov     cl, [XDisk_Progress_Cnt_Max]
        xor     dx, dx
        mul     cx

        xor     cx, cx
        mov     bx, [Sectors_To_Extract]
        div     bx

        cmp     al, [XDisk_Progress_Cnt_Prev]
        je      @@40

;---------------------------------
; Update progress bar, and show it
;---------------------------------
        mov     [Xdisk_Progress_Cnt_Prev], al
        mov     cx, ax

        mov     si, offset XDisk_Progress_Bar
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, 0DBh
        rep     stosb

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@40                                    ; Yes
                                                        ; No, so
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY
        push    ds si
        call    WSIO
        pop     si ds

        jmp     @@40

;--------------
; Close pc file
;--------------
@@70:
        mov     cx, [Sectors_For_This_File]             ; In case a deleted file was extracted
        add     [Sectors_Extracted], cx                 ; and not all sectors were acoounted for

        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE

        push    es di
        call    FMSIO
        pop     di es

;-------------------------------
; Select next xl file vtoc entry
;-------------------------------
@@80:
        pop     cx si ds

        add     si, EIGHTBIT_FILE_ENTRY_SIZE            ; Move to next vtoc entry
        loop    @@10                                    ; Complete VTOC scanned?

;----------------------------
; Close Atari disk image file
;----------------------------
@@90:
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE

        push    es di
        call    FMSIO
        pop     di es

;----------------------------------
; Close progress bar message screen
;----------------------------------
@@95:
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@99                                    ; Yes
                                                        ; No, so
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

@@99:
        ret

ENDP    Extract_Disk_Image_Files



;**********************************************************************
PROC    Extract_Disk_Image_Files_SpartaDos
;**********************************************************************
        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        jne     @@01                                    ; No
                                                        ; Yes, so
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es
        mov     si, offset CLI_Outdir
        mov     cx, PATH_LENGTH
        rep     movsb

@@01:
;-------------------------------------------------
; Check if drive we have to access is drive A or B
;-------------------------------------------------
        call    Verify_Disk_Presence_Drive_A_Or_B       ; If were reading drive A or B

        cmp     [Disk_Present], LOGIC_YES               ; Diskette present
        jne     @@99                                    ; No
                                                        ; Yes, so
;---------------------
; Open disk image file
;---------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_INPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

;---------------------------------
; Reset progress bar to Cyan White
;---------------------------------
        mov     si, offset XDisk_Progress_Bar
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, 0B0h
        xor     cx, cx
        mov     cl, [XDisk_Progress_Cnt_Max]
        rep     stosb

        mov     [XDisk_Progress_Cnt_Prev], 0
        mov     [Sectors_Extracted], 0

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@02                                    ; Yes
                                                        ; No, so
;--------------------
; Open extract window
;--------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_OPEN
        push    ds si
        call    WSIO
        pop     si ds

;----------------------------------------
; Show that we are going to extract stuff
;----------------------------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_ONLY
        push    ds si
        call    WSIO
        pop     si ds

;----------------------------------------------------------
; Create Volume Name Directory within Extract To Path first
;----------------------------------------------------------
        call    Create_Dir_From_SpartaDos_Disk

@@02:
;-----------------------------------------------------------------
; We want to extract all (sub)folders on the SpartaDos disk
; that's why we keep track of where we are in the VTOC structure
; We assume a maximum of 256 directories total on a SpartaDos disk
;-----------------------------------------------------------------
        mov     [Folder_Counter], 0

;-------------------------------------------------------------------------
; Read SpartaDos Disk Image VTOC (sector/recordnr specified in boot block)
; VTOC is unknown is size
;-------------------------------------------------------------------------
        mov     si, offset Disk_I_O_Buffer
        mov     ax, [ds:si + 9]                         ; Vtoc sector offset

;
; Remember start sector
;
        mov     si, offset Folder_Pointer
        mov     [ds:si], ax                             ; Sector

        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

@@04:
        mov     si, offset Disk_VTOC_Buffer + SPARTADOS_FILE_ENTRY_SIZE ; Start of files
        mov     [Process_Files], LOGIC_YES

@@05:
;-------------------------
; First only process files
;-------------------------
        cmp     [Process_Files], LOGIC_YES
        jne     @@07                                    ; No
                                                        ; Yes, so
        xor     ax, ax
        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, NULL                                ; Last entry processed?
        je      @@06                                    ; Yes
                                                        ; No, so
        and     ax, SPARTADOS_DIRECTORY
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        jne     @@15                                    ; No
                                                        ; Yes, so
        jmp     @@80                                    ; Next entry

@@06:
;------------------------------
; Then only process directories
;------------------------------
        mov     [Process_Files], LOGIC_NO
        mov     si, offset Disk_VTOC_Buffer + SPARTADOS_FILE_ENTRY_SIZE ; Start of files
        jmp     @@05

@@07:
;-------------------------
; Process directories only
;-------------------------
        xor     ax, ax
        mov     al, [byte ds:si]                        ; Get file status
        cmp     ax, NULL                                ; Last entry processed?
        je      @@08                                    ; Yes
                                                        ; No, so
        and     ax, SPARTADOS_DIRECTORY
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        je      @@15                                    ; Yes
                                                        ; No, so
        jmp     @@80                                    ; Next entry

@@08:
        cmp     [Folder_Counter], 0                     ; Are we at the root?
        je      @@90                                    ; Yes
                                                        ; No, so
;-------------------------
; Go to previous directory
;-------------------------
        dec     [Folder_Counter]

        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]

        mov     ax, [ds:si]                             ; Sector number where this directory started

        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

;------------------
; Do some cd.. here
;------------------
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH                         ; Search length
        dec     cx                                      ; Because of null terminator
        add     di, cx                                  ; Go to end of path
        std                                             ; Search direction is down
        xor     ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer correction

@@09:
        mov     [byte es:di], SPACE                     ; Erase
        dec     di
        cmp     [byte es:di], BACKSLASH                 ; Are we at the previous "\"?
        jne     @@09                                    ; No
                                                        ; Yes, so
;
; Get offset into directory
;
        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        mov     bx, [ds:si + 2]                         ; Offset within directory

        mov     si, offset Disk_VTOC_Buffer             ; Sector
        push    bx
        pop     si                                      ; Offset

        jmp     @@05                                    ; Check again

@@15:
;--------------------------
; Process File or Directory
;--------------------------
        mov     [Folder_Indicator], LOGIC_NO            ; Assume no folder
        cmp     ax, SPARTADOS_DIRECTORY                 ; Directory entry?
        jne     @@20                                    ; No
                                                        ; Yes, so
;-----------------------------------------------
; SpartaDos directory encountered, indicate this
;-----------------------------------------------
        mov     [Folder_Indicator], LOGIC_YES

@@20:
;-------------------------------------------
; Process file/directory name and properties
;-------------------------------------------
        mov     [XFile_Deleted], LOGIC_NO

;-------------------------------------
; Check File Status
; We don't extract deleted directories
;-------------------------------------
        xor     ax, ax                                  ; Reset ax
        mov     al, [byte ds:si]                        ; Load File Status
        and     al, 010h                                ; Check Delete Status
        cmp     al, 010h                                ; File/Directory Deleted?
        jne     @@25                                    ; No
                                                        ; Yes, so
        mov     [XFile_Deleted], LOGIC_YES
        cmp     [Folder_Indicator], LOGIC_YES           ; Is it a deleted Directory?
        je      @@80                                    ; Yes
                                                        ; No, so
@@25:
;-------------------
; Determine filesize
;-------------------
        mov     ah, [byte ds:si + 4]
        mov     al, [byte ds:si + 3]
        xor     bh, bh
        mov     bl, [byte ds:si + 5]

        mov     [SpartaDos_Filesize_Lo], ax
        mov     [SpartaDos_Filesize_Hi], bx

;-------------------------------
; Determine File's Date and Time
;-------------------------------
        mov     cl, [byte ds:si + 17]
        mov     [SpartaDos_Date_DD], cl
        mov     cl, [byte ds:si + 18]
        mov     [SpartaDos_Date_MM], cl
        mov     cl, [byte ds:si + 19]
        mov     [SpartaDos_Date_YY], cl
        mov     cl, [byte ds:si + 20]
        mov     [SpartaDos_Time_HH], cl
        mov     cl, [byte ds:si + 21]
        mov     [SpartaDos_Time_MM], cl

;-------------------------------
; Determine start of link sector
;-------------------------------
        mov     ch, [byte ds:si + 2]
        mov     cl, [byte ds:si + 1]

        mov     [SpartaDos_Next_Link_Sector], cx

;-----------------------
; Extract deleted files?
;-----------------------
        cmp     [XFile_Deleted], LOGIC_YES
        jne     @@30                                    ; No
                                                        ; Yes, so
        cmp     [Config_Deleted_YN], LOGIC_NO           ; Extract deleted?
        je      @@80                                    ; No
                                                        ; Yes, so
@@30:
;--------------------------
; Setup File/Directory path
;--------------------------
        push    ds si                                   ; Save pointer into VTOC

        mov     si, offset PC_ATARI_Pathname
        push    ds si

        push    ds si
        pop     di es

        mov     si, offset Ws_SD_D_Extract_To_Path

        cmp     [XFile_Deleted], LOGIC_YES              ; File Deleted?
        jne     @@35                                    ; No
                                                        ; Yes, so
        mov     si, offset Config_Field_Deleted_Path

@@35:
        mov     cx, PATH_LENGTH
        rep     movsb

;
; Search for last "\"
;
        pop     di es                                   ; Restore file path

        mov     cx, PATH_LENGTH                         ; Search length
        add     di, cx                                  ; Go to end of Path
        std                                             ; Search direction is down
        or      ax, ax                                  ; Reset ax
        mov     al, BACKSLASH                           ; Search for the "\" character
        repne   scasb                                   ; Search equal "\" uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        inc     di                                      ; Move next to the "\"

        pop     si ds                                   ; Restore pointer into VTOC
        push    ds si                                   ; Save pointer into VTOC

        add     si, 6                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

;--------------------------
; Create a (sub) directory?
;--------------------------
        cmp     [Folder_Indicator], LOGIC_YES           ; Is it a (sub)directory?
        jne     @@40                                    ; No
                                                        ; Yes, so
        pop     si ds                                   ; Restore pointer into VTOC
        push    ds si                                   ; Save pointer into VTOC

        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es

        mov     si, offset PC_ATARI_Pathname
        mov     cx, PATH_LENGTH
        rep     movsb

        call    Create_Dir_From_SpartaDos_Disk

        pop     si ds                                   ; Restore pointer into VTOC

        jmp     @@75

@@40:
;------------------------------
; Set up file we are extracting
;------------------------------
        mov     si, offset XDisk_Extract_File
        push    ds si
        pop     di es

        pop     si ds                                   ; Restore pointer into VTOC
        push    ds si                                   ; Save pointer into VTOC

        add     si, 6                                   ; Begin of filename, i.e. MYFILE  TXT
        mov     cx, 8                                   ; Size of filename
        rep     movsb                                   ; Move "MYFILE" part
        mov     [byte es:di], DOT                       ; Insert a "."
        inc     di                                      ; Move to extender part
        mov     cx, 3                                   ; Size of extender
        rep     movsb                                   ; Move "TXT" part

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@41                                    ; Yes
                                                        ; No, so
;----------------------------------
; Show which file we are extracting
;----------------------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY
        push    ds si
        call    WSIO
        pop     si ds

@@41:
;----------------------------
; Create 8 bit file on the pc
;----------------------------
        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_OUTPUT
        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        je      @@45                                    ; Yes
                                                        ; No, so
;
; Error!
;
        pop     si ds                                   ; Restore pointer into VTOC
        jmp     @@99

@@45:
        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_WRITENEXT
        mov     [SpartaDos_Last_Sector], LOGIC_NO

@@46:
        mov     cx, [SpartaDos_Next_Link_Sector]        ; Start of Link Sector Info

        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READ
        mov     si, offset Disk_Link_Sector_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Record_Nr], cx
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS
        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        mov     [SpartaDos_Link_Sector_Offset], 4

@@50:
        cmp     [SpartaDos_Link_Sector_Offset], NULL    ; All sectors in sector link sector processed?
        jne     @@51                                    ; No
                                                        ; Yes, so
        mov     si, offset Disk_Link_Sector_buffer      ; Move to next sector link sector
        mov     ch, [byte ds:si + 1]
        mov     cl, [byte ds:si]
        mov     [SpartaDos_Next_Link_Sector], cx
        jmp     @@46

@@51:
        mov     si, offset Disk_Link_Sector_buffer
        xor     cx, cx                                  ; Reset cx
        mov     cl, [SpartaDos_Link_Sector_Offset]
        add     si, cx
        mov     ch, [byte ds:si + 1]
        mov     cl, [byte ds:si]

;
; Read (next) data sector
;
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READ
        mov     si, offset Disk_I_O_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Record_Nr], cx
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS
        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        mov     ax, [SpartaDos_Filesize_Lo]
        mov     bx, [SpartaDos_Filesize_Hi]

        clc                                             ; Clear carry
        mov     dx, [Disk_Sector_Size]
        sub     ax, dx
        jnc     @@60                                    ; Nr of bytes remaining >to write?
        cmp     bx, 0                                   ; Still more bytes?
        je      @@55                                    ; No
                                                        ; Yes, so
        dec     bx
        jmp     @@60

@@55:
        mov     [SpartaDos_Last_Sector], LOGIC_YES
        mov     dx, [SpartaDos_Filesize_Lo]
        mov     ax, dx
        cmp     dx, 0                                   ; Still something to write?
        je      @@70                                    ; No
                                                        ; Yes, so
@@60:
        mov     [SpartaDos_Filesize_Lo], ax
        mov     [SpartaDos_Filesize_Hi], bx

;----------------------------
; Write sector to the pc file
;----------------------------
        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Record_Size], dx

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@70                                    ; Error!

        inc     [Sectors_Extracted]                     ; Another sector accounted for

        add     [SpartaDos_Link_Sector_Offset], 2
        cmp     [Disk_Sector_Size], EIGHTBIT_SECTOR_SIZE_DOUBLE ; 256 bytes/sector?
        jne     @@61                                            ; No
                                                                ; Yes, so
        cmp     [byte SpartaDos_Link_Sector_Offset], NULL       ; Next sector link?
        jne     @@64                                            ; No
                                                                ; Yes, so
        jmp     @@62

@@61:
        cmp     [byte SpartaDos_Link_Sector_Offset], 080h       ; Next sector link?
        jne     @@64                                            ; No
                                                                ; Yes, so
@@62:
        mov     [SpartaDos_Link_Sector_Offset], NULL

@@64:
;------------------------------------------------------
; Calculate progress bar size, and show it if necessary
;------------------------------------------------------
        mov     ax, [Sectors_Extracted]
        xor     bx, bx
        xor     cx, cx
        mov     cl, [XDisk_Progress_Cnt_Max]
        xor     dx, dx
        mul     cx

        xor     cx, cx
        mov     bx, [Sectors_To_Extract]
        div     bx

        cmp     al, [XDisk_Progress_Cnt_Prev]
        je      @@65

;---------------------------------
; Update progress bar, and show it
;---------------------------------
        mov     [Xdisk_Progress_Cnt_Prev], al
        mov     cx, ax

        mov     si, offset XDisk_Progress_Bar
        push    ds si
        pop     di es
        xor     ax, ax
        mov     al, 0DBh
        rep     stosb

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@65                                    ; Yes
                                                        ; No, so
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_DISPLAY_FIELDS_ONLY
        push    ds si
        call    WSIO
        pop     si ds

@@65:
        cmp     [SpartaDos_Last_Sector], LOGIC_YES      ; More sectors to read?
        jne     @@50                                    ; Yes
                                                        ; No, so
;--------------
; Close pc file
;--------------
@@70:
        mov     cx, [Sectors_For_This_File]             ; In case a deleted file was extracted
        add     [Sectors_Extracted], cx                 ; and not all sectors were acoounted for

        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     bx, [(FMS_Area ptr di).Disk_Handler]
        call    Set_Pc_File_Date_And_Time

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE

        push    es di
        call    FMSIO
        pop     di es

        pop     si ds                                   ; Restore pointer into VTOC
        jmp     @@80                                    ; Next entry

@@75:
;---------------------------
; Proces SpartaDos directory
;---------------------------
        mov     al, [byte ds:si + 1]                    ; Vtoc sector offset
        mov     ah, [byte ds:si + 2]

        push    si
        pop     bx
        add     bx, SPARTADOS_FILE_ENTRY_SIZE           ; Move to next xl vtoc entry

        mov     si, offset Folder_Pointer
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]
        add     si, [Folder_Counter]

        mov     [ds:si + 2], bx                         ; Offset

        inc     [Folder_Counter]

        mov     [ds:si + 4], ax                         ; Remember offset

;--------------------
; Jump to Folder area
;--------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        push    es di
        call    Extract_VTOC_SpartaDos
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@90                                    ; Error!

        jmp     @@04                                    ; Process directory

@@80:
        add     si, SPARTADOS_FILE_ENTRY_SIZE           ; Move to next xl vtoc entry
        jmp     @@05

@@90:
;--------------------
; Re-read boot sector
;--------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_START
        mov     si, offset Disk_I_O_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Record_Nr], 1
        sub     [(FMS_Area ptr di).Offset], EIGHTBIT_BOOT_SECTOR_SIZE
        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        push    es di
        call    FMSIO
        pop     di es

        add     [(FMS_Area ptr di).Offset], EIGHTBIT_BOOT_SECTOR_SIZE

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@95                                    ; Error!

;------------------------
; Re-read boot sector now
;------------------------
        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READNEXT

        push    es di
        call    FMSIO
        pop     di es

@@95:
;----------------------------
; Close Atari disk image file
;----------------------------
        mov     si, offset ATARI____File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE

        push    es di
        call    FMSIO
        pop     di es

        cmp     [CLI_Used], LOGIC_YES                   ; Command Line Interface used?
        je      @@99                                    ; Yes
                                                        ; No, so
;----------------------------------
; Close progress bar message screen
;----------------------------------
        mov     si, offset Ws_XF
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

@@99:
        ret

ENDP    Extract_Disk_Image_Files_SpartaDos



;**********************************************************************
PROC    Extract_VTOC_SpartaDos
;**********************************************************************
;------------------
; Clear VTOC buffer
;------------------
        push    ax es di

        mov     si, offset Disk_VTOC_Buffer
        push    ds si
        pop     di es
        mov     cx, SPARTADOS_VTOC_BUFFER_SIZE
        mov     ax, NULL
        rep     stosb

        pop     di es ax

;---------------------------
; Read VTOC Sector Link area
;---------------------------
        mov     [(FMS_Area ptr di).Request], CMD_ACCESS_READ
        mov     si, offset Disk_Link_Sector_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     [(FMS_Area ptr di).Record_Nr], ax
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS
        mov     ax, [Disk_Sector_Size]
        mov     [(FMS_Area ptr di).Record_Size], ax

        push    es di
        call    FMSIO
        pop     di es

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

        mov     si, offset Disk_VTOC_Buffer
        mov     [(FMS_Area ptr di).Data_Address_Hi], ds
        mov     [(FMS_Area ptr di).Data_Address_Lo], si
        mov     cx, 4                                   ; Link sectors for VTOC start here

@@10:
;-------------------------------------------
; Get sector to read from Sector Link sector
;-------------------------------------------
        mov     si, offset Disk_Link_Sector_Buffer
        add     si, cx
        mov     ax, [ds:si]
        cmp     ax, NULL                                ; VTOC completely read?
        je      @@99                                    ; Yes
                                                        ; No, so
;-------------------------------------------------------------------------
; Read SpartaDos Disk Image VTOC (sector/recordnr specified in Sector Link
;-------------------------------------------------------------------------
        mov     [(FMS_Area ptr di).Record_Nr], ax
        sub     [(FMS_Area ptr di).Record_Nr], EIGHTBIT_BOOT_SECTORS

        push    cx es di
        call    FMSIO
        pop     di es cx

        cmp     [(FMS_Area ptr di).Status], STATUS_OK
        jne     @@99                                    ; Error!

;----------------------------------------------
; Move to next VTOC "sector" within VTOC buffer
;----------------------------------------------
        clc                                             ; Clear carry
        mov     ax, [(FMS_Area ptr di).Data_Address_Hi]
        mov     bx, [(FMS_Area ptr di).Data_Address_Lo]
        add     bx, [Disk_Sector_Size]
        jnc     @@20
        inc     ax

@@20:
        mov     [(FMS_Area ptr di).Data_Address_Hi], ax
        mov     [(FMS_Area ptr di).Data_Address_Lo], bx
        inc     cx                                      ; Next VTOC sector
        inc     cx                                      ; according to Sector Link sector
        jmp     @@10

@@99:
        ret

ENDP    Extract_VTOC_SpartaDos



;**********************************************************************
PROC    Create_Dir_From_SpartaDos_Disk
;**********************************************************************
;-----------------
; Create directory
;-----------------
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    si
        pop     dx                                      ; File handle
        xor     ax, ax
        mov     ah, DOS_CREATE_DIRECTORY                ; Directory with volume name created
        int     DOS_SERVICE

        jmp     @@05

;---------------------------------------------------------------------------
; Set date/time of Pc directory according to SpartaDos directory's date/time
;---------------------------------------------------------------------------
        mov     si, offset PC_ATARI_Pathname
        push    ds si
        pop     di es
        mov     si, offset Ws_SD_D_Extract_To_Path
        mov     cx, PATH_LENGTH
        rep     movsb

        mov     si, offset PC_ATARI_File
        push    ds si
        pop     di es

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_EXTEND

        push    es di
        call    FMSIO
        pop     di es

        mov     bx, [(FMS_Area ptr di).Disk_Handler]
        call    Set_Pc_File_Date_And_Time

        mov     [(FMS_Area ptr di).Request], CMD_OPEN_CLOSE

        push    es di
        call    FMSIO
        pop     di es

@@05:
;-------------------------------------------
; Add a "\" to the end of the Pc file's path
;-------------------------------------------
        mov     si, offset Ws_SD_D_Extract_To_Path
        push    ds si
        pop     di es
        mov     cx, PATH_LENGTH                         ; Search length
        dec     cx                                      ; Because of null terminator
        add     di, cx                                  ; Go to end of path
        std                                             ; Search direction is down
        xor     ax, ax                                  ; Reset ax
        mov     al, SPACE                               ; Search for the non SPACE character
        repe    scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search
        cmp     [byte es:di], DOT                       ; Is this a "."?
        jne     @@10                                    ; No
                                                        ; Yes, so
        mov     [byte es:di], SPACE                     ; Replace with " "
        dec     di
        std                                             ; Search direction is down
        xor     ax, ax                                  ; Reset ax
        mov     al, SPACE                               ; Search for the non SPACE character
        repe    scasb                                   ; Search uses es:di
        cld                                             ; Cancel the std setting
        inc     di                                      ; Pointer adjustment after search

@@10:
        inc     di                                      ; Pointer adjustment after search
        mov     [byte es:di], BACKSLASH                 ; Add "\" the end of the string

        ret

ENDP    Create_Dir_From_SpartaDos_Disk



;**********************************************************************
PROC    Set_Pc_File_Date_And_Time
;**********************************************************************
;---------------------------------------------------------
; Convert date from SpartaDos format to Pc Dir/File format
;---------------------------------------------------------
;
; Year
;
        xor     dx, dx                                  ; Reset dx
        mov     dh, [SpartaDos_Date_YY]                 ; Hex 62 = 98       (=1998)
        sub     dh, PC_DATE_YEAR_OFFSET                 ; Minus hex 50 = 80 (=1980)
        rol     dh, 1                                   ; Year is placed in 7 left bits

;
; Day
;
        mov     dl, [SpartaDos_Date_DD]                 ; Hex 18 = 24

;
; Month
;
        xor     ax, ax                                  ; Reset ax
        mov     al, [SpartaDos_Date_MM]                 ; Hex 06 = June
        rol     ax, 5                                   ; Move 5 positions to the right for Pc Date
        xor     dx, ax                                  ; Insert month in date

;---------------------------------------------------------
; Convert time from SpartaDos format to Pc Dir/File format
;---------------------------------------------------------
;
; Hours
;
        xor     cx, cx                                  ; Reset cx
        mov     ch, [SpartaDos_Time_HH]                 ; Hex 0E = 14 (= 2:__p)
        rol     ch, 3                                   ; Hours is placed in 5 left bits

;
; Minutes
;
        xor     ax, ax                                  ; Reset ax
        mov     al, [SpartaDos_Time_MM]                 ; Hex 38 = 56 (=__:56)
        rol     ax, 5                                   ; Minutes is placed in 6 bits 5 bits from the right
        xor     cx, ax                                  ; Insert minutes in time

;
; Set Pc Dir/File Date/Time format
;
        mov     ax, DOS_SET_FILE_DATE_AND_TIME          ; Update date/time
        int     DOS_SERVICE

        ret

ENDP    Set_Pc_File_Date_And_Time



;**********************************************************************
PROC    Close_Ws_BG
;**********************************************************************
        mov     si, offset Ws_BG
        mov     [byte ds:si], WSIO_CLOSE
        push    ds si
        call    WSIO
        pop     si ds

        ret

ENDP    Close_Ws_BG



;**********************************************************************
PROC    Exit_Program
;**********************************************************************
        mov     ah, DOS_TERMINATE_EXE
        mov     al, [Return_Code]                   ; Return code value
        int     DOS_SERVICE

ENDP    Exit_Program



ENDS    CSeg                                        ; End of Code segment

END     Main
