*
*  Simple Text File LIST utility
*
*  Copyright (C) 1979 by
*  Technical Systems Consultants, Inc.
*
*  Taken from FLEX manual
*
*  DOS equates
*
WARMS  equ $CD03   DOS WARM START entry
GETFIL equ $CD2D   GET FILE spec
PUTCHR equ $CD18   Put Character routine
PCRLF  equ $CD24   Print CR & LF
SETEXT equ $CD33   Set default name EXT
RPTERR equ $CD3F   Report Disk error

*  FMS equates

FMS    equ $D406
FMSCLS equ $D403

*  System Equates

FCB    equ $C840   System FCB

*  LIST utility starts here

        org     $c100

List    bra     list2                  get around temps

VN      fcb     1                      version number

list2   ldx     #FCB                   point to fcb
        jsr     GETFIL                 get file spec
        bcs     list9                  any errors?
        lda     #1                     set up code
        sta     0,x                    save for read open
        jsr     setext                 set TXT extension
        jsr     FMS                    call FMS - do OPEN
        bne     list9                  check for error
list4   ldx     #FCB                   point to FCB
        jsr     FMS                    call FMS - get char
        bne     list6                  errors?
        cmpa    #$D                    is char a CR?
        bne     list5
        jsr     PCRLF                  output CR and LF
        bra     list4                  repeat
list5   jsr     PUTCHR                 output the character
        bra     list4                  repeat sequence
list6   lda     1,x                    get error status
        cmpa    #8                     is it EOF error ?
        bne     list9
        lda     #4                     close file code
        sta     0,x                    store in FCB
        jsr     FMS                    call FMS - close file
        bne     list9                  errors ?
        jmp     WARMS                  return to FLEX

list9   jsr     RPTERR                 report error
        jsr     FMSCLS                 close all files
        jmp     WARMS                  return to FLEX

        end     LIST
