See all articles from Update April 1988
This routine allows you to find the number of free blocks with out displaying the catalog.
It will return the number of free blocks in the BC register, so it can be accessed from basic with PRINT USR FREEBL or LET x=USR FREEBL .
00010 FREEBL DI
00020 CALL 98 - turn on the Lkdos cartridge
00030 LD A,0
00040 LD (curtrk),A - move the disk drive to
00050 CALL TRACK - block 0 (side 0 track 0)
00060 CALL LOADBF - load disk to buffer
00070 LD C,0 - set counter to 0
00080 LD HL,data - set HL to start of track-map
00090 USED INC HL - first block always used anyway
00100 LD A,(HL)
00110 CP 255 - 255 marker means 'end of track-map
00120 JR Z,EXIT - if so then exit
00130 CP 245 - 245 marker means 'block used'
00140 JR Z,USED - if used then move on to next one
00150 INC C - must be a free block,update count
00160 JR USED - continue searching for free blocks
00170 EXIT LD B,0
00180 LD A,(98) - turn cartridge off
00190 EI
00200 RET
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.