!lm12
!rm75
Secret RWTS Caller Inside DOS....................Bill Parker

I found a portion of code tucked away in DOS that will perform a RWTS for you, doing away with the necessity of finding a place to put a controlling subroutine, an IOB, etc.

As you know, RWTS (Read/Write Track and Sector) gives the programmer the ability to read a sector from any specified track and put it in a buffer in RAM.  It also allows the programmer to manipulate the buffer and write it back out to any specified track and sector on the disk.

In this 48K DOS routine, which happens to be the same for 3.3 as well as 3.2, all the programmer has to do is to plug in the track and sector desired and whether he wants to read it from disk to the buffer, or write it from the buffer to the disk.  (The buffer is a fixed 256-byte location beginning at $B4BB (46267).)  A simple CALL 45111 or a JSR $B037 will then perform the transfer.  (You must remember to restore the original Read/Write code back to "2" when you are finished, so that the system can write to the directory when it needs to).

Here is a disassembled and commented version of the routine, which (for lack of a better term) I have named "WRTDIR".  This should aid in the development of programs that need to examine or alter the contents of a disk.

This routine, which normally writes a directory sector to the disk from the buffer at $B4BB.B5BA (46267-46522), can be used as a general RWTS utility by plugging in:

!lm17
      Value         Name  $Loc    Loc
Read/Write (1/2)     RW   $B041  45121
Track No. ($0-$22)   TK   $B397  45975
Sector No. ($0-$F)   SC   $B398  45976
!lm12

Then call 45111 or JSR $B037 and set RW to 2 when done.
