Technical notes =============== You shouldn't need to know these internal details of HADFS, but occasionally low-level code may need to know about the internal strucures HADFS uses. Context ------- Early versions of HADFS read and wrote the filing system context with OSARGS &FD with handles of &08-&0A and &88-&8A. Obviously, these handles are not owned by HADFS and clash with other filing systems. Later versions of HADFS use its own handles of 25-29 to read and write the context with OSARGS &FE to read and OSARGS &FD to write. Code should use the correct handles of 25-29, but in the rare case that code must work with early versions of HADFS, OSARGS &FE must be used to read the context, and if it fails, the old handle should be read with OSARGS &FD. LDY #25:STY CSDhandle :\ Prepare to use new handle LDA #&FE:LDX #csd:JSR OSARGS :\ Read CSD TAX:BEQ CSDok :\ A=0, CSD was read LDY #&88:STY CSDhandle :\ Old handle to restore CSD LDA #&FD:LDY #&08:JSR OSARGS :\ Read CSD with old handle .CSDok \ continue... LDY CSDhandle:LDX #csd :\ Use previously saved handle LDA #&FD:JSR OSARGS :\ Restore CSD Workspace --------- Prior to version 5.50 HADFS used workspace at &1000. The OSWORD &7F code in DFS tramples over parts of the memory, and HADFS was carefully written to avoid those areas of memory that were corrupted during a disk access. However, when HADFS was updated to allow 24-bit disk addresses (disks and files larger than 16M), some of the open file blocks would no longer fit into the areas of memory that were untouched by DFS on the BBC model B+. Consequently, in order to work correctly on the B+ the workspace was moved to &0E00, with the loss of one open file buffer when running on the B/B+. If code needs to know where the HADFS workspace is OSARGS &FD,0 should be used to read the HADFS capability flags. Bit 9 is zero if &0E00 is being use and one if &1000 is being used. Usefully, looking at byte 1 of the returned data this is a value of 0 or 2, which can be added to the high byte of &0E00 to form the workspace address of &0E00 or &1000. LDA #&FD:LDX #zp:LDY #0:JSR OSARGS :\ Read HADFS flags LDA zp+1:AND #2:CLC:ADC #&0E :\ A=WS address high byte The channel information blocks are stored in the workspace in &0E00 or &1000. They can either be scattered in 32-byte blocks throughout the workspace, or compacted in 24-byte blocks in the top 128 bytes of the workspace. Bit 8 of the capability flags is 1 if the channel information blocks are at offset &4B, &8B, &AB, &CB, &EB, and is 0 if the blocks are at offset &88, &A0, &B8, &D0, &E8. The information blocks are in reverse order, the information for channel 25 is at offset &E8/&EB, channel 29 at &88/&4B. In the scattered blocks there is no channel information at offset &6B and this block should be avoided. Open file buffers ----------------- Located with HADFS capability flags. Number of open file buffers --------------------------- Commands such as *COPY can use the file buffers for their own buffering. You need to check the workspace open file blocks to check that they are not open (using OSARGS &FD,0 to find the workspace and to find the buffers) and must only use those buffers that exist (found with OSBYTE 90,6,255). If the channel information blocks are not scattered, then on the Master the buffers are in high workspace.