!lm12
!rm75
A Text File Display Command for DOS........Bob Sander-Cederlof

How many times have you wished that you could see what was in a TEXT file?  You end up loading a word processor (if you are lucky enough to have one that can read normal DOS TEXT files), or EXECing it into the S-C Macro Assembler, or writing a special Applesoft program....  Why not a DOS command for this very common need?

The June 1982 issue of Call A.P.P.L.E. has an article by Lee Reynolds describing the addition of a FILEDUMP command to DOS.  Lee gives a 20-byte program which fits nicely in an unused space in DOS.  He replaced the MAXFILES command with "FILEDUMP".   In case you want to try it, here are the patches for Lee's method.
!lm17

]CALL -151
*BCDF:20
*BCE0:8E FD 20 A3 A2 20 8C A6 F0 05 20 F0 FD D0 F6 20
*BCF0:FC A2 60
*A8E7:46 49 4C 45 44 55 4D D0
*9D48:DE BC
*A933:20 30
*3D0G
]
!lm12

$BCDF-BCF2 is the FILEDUMP command processor.  $A8E7-$A8EE is the string "FILEDUMP", the command name.  The two bytes at $9D48,9D49 are the address (minus 1) of the command processor.  The two bytes at $A933,A934 are flags indicating that the FILEDUMP command requires a filename, and can optionally have S and D parameters.

My first reaction to the program, being a programmer, was to try to modify it.  The first change I made saved one byte.  The last two instructions are a JSR and an RTS.  By ending with a JMP to the final subroutine, the RTS at BCF2 is not needed.  Then I tried modifying the order of the loop, and saved another three bytes.  Here is my revised listing:



<listing here>



After playing with the new command a little, I thought of several more changes.  I wanted to be able to stop the file listing, to restart it, and to abort it.  The first article I ever wrote about Apples described just such an addition, at that time for Integer BASIC.  (See MICRO, June/July, 1978.)  With this addition, the program would not fit in the unused space at $BCDF, so I decided to put it in the place of the INIT command instead.  I changed the name to "SHOW".
!np
Not all of the code would fit in the spot where the INIT command processor is, at $A54F.  Therefore I broke out the routine to check for the pause/abort keys as a separate subroutine, and placed in over the top of some of the INIT code inside the File Manager of DOS.  If you install this patch, you could call on the PAUSE.CHECK subroutine from your own programs.


<listing here>


After assembling the program above, the various pieces are in memory in page 8 and 9, instead of inside DOS.  I did it this way because DOS is protected during assembly.  You can install the patches by hex input commands, or by some memory moves.  I did it this way:

!lm17
:$A54F<84F.863M
:$AE8E<88E.8A4M
:$A884:53 48 4F D7
:$A909:20 30
!lm12

Then try typing "SHOW filename", where "filename" is a text file, and see the action.

You may want to put some POKEs in your HELLO file on some disks to install the SHOW command.  If so, this is what they might look like:

!lm17
100 DATA 21,42319,32,163,162,169,141,32,240,253,32,142,
         174,240,5,32,140,166,208,243,76,252,162
110 DATA 23,44686,173,0,192,16,17,141,16,192,201,141,
         240,10,173,0,192,16,251,141,16,192,201,141,96
120 DATA 4,43140,83,72,79,215
130 DATA 2,43273,32,48
140 DATA 0
150 READ N : IF N THEN READ A : FOR I = 1 TO N : READ D
    : POKE A+I-1,D : NEXT : GO TO 150
!lm12

I tried several other versions, with features like clearing the screen, filling it up, and waiting; a stand-alone program, rather than a DOS command; and so on.  You will probably want to try your own experiments.
