I'm trying because ... well that's it really, because ...
I'm not going to ask you for code on this one, but if some sole could tell me where I'm going wrong with the code - OR - why the code will not work I would be very grateful. I'm seeing spots now I've looked at it for so long.
Cheers
Steady ... ???
Code: Select all
' $DYNAMIC
DEFINT A-Z
' declaring the registers
TYPE RegTypeX
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
FLAGS AS INTEGER
Ds AS INTEGER
es AS INTEGER
END TYPE
CLS
DIM inregs AS RegTypeX, outregs AS RegTypeX
'Set up a buffer large enough to hold one disk sector (512bytes)
Sbuffer$ = STRING$(512, " ")
'Read from the floppy boot record, repeating the read 4 times
'to allow the floppy time to spin up to speed.
FOR Re = 1 TO 4
inregs.dx = 0 'DRIVE0(A:)
inregs.ax = 0 'function0
CALL INTERRUPTX(&H13, inregs, outregs)
'Interrupt 13, function 0 - reset disk system
inregs.es = VARSEG(Sbuffer$)
'Es and BX point to address of disk buffer
inregs.bx = SADD(Sbuffer$)
inregs.ax = &H201 'function 2, read 1 sector
inregs.cx = &H1 'sector #1, the boot record
CALL INTERRUPTX(&H13, inregs, outregs)
NEXT
PRINT "Boot Record acquired :-"
'Create a buffer large enough to hold 14 disk sectors
RootBuffer$ = STRING$(7168, 0)
'Get the root directory entries
FOR Re = 1 TO 4
inregs.dx = 0: inregs.ax = 0
CALL INTERRUPTX(&H13, inregs, outregs)
inregs.dx = &H100 'side 1,drive0
inregs.es = VARSEG(RootBuffer$)
inregs.bx = SADD(RootBuffer$)
inregs.ax = &H20E 'function 2 read, 14 sectors
inregs.cx = 2 'starting at sector #2
CALL INTERRUPTX(&H13, inregs, outregs)
NEXT
PRINT "Root directory entries acquired :- "
'lets give th floppy an "illegal" volume label.
'First give it a legal label using the DOS LABEL command.
'using that value to search the floppy's root directory entries.
LBL$ = "QWERTYUIOPA"
SHL$ = "LABEL A: " + LBL$
SHELL SHL$
PRINT "Legal name allocated :- "; LBL$
'set the volume label to spomething strange
NLabel$ = "Xxx-Xxxx?!?"
PRINT "New Floppy Label chosen is :- "; NLabel$
PRINT "Searching for :- "; LBL$
MID$(RootBuffer$, INSTR(UCASE$(RootBuffer$), LBL$), 11) = NLabel$
'Set the volume label in the boot sector, too
MID$(Sbuffer$, 44, 11) = NLabel$
a$ = MID$(Sbuffer$, 44, 11)
PRINT "New label to boot string is :- "; a$
PRINT "writing to boot record !"
'write the changes to the floppy boot record
FOR Re = 1 TO 4
inregs.dx = 0
inregs.ax = 0
CALL INTERRUPTX(&H13, inregs, outregs)
inregs.es = VARSEG(Sbuffer$)
inregs.bx = SADD(Sbuffer$)
inregs.ax = &H301 'function 3, write one sector
inregs.cx = &H1 'at sector #1
CALL INTERRUPTX(&H13, inregs, outregs)
NEXT
PRINT "New label written to boot record !"
PRINT "Writing to root directory !"
'Write the changes to the root directory
FOR Re = 1 TO 4
inregs.dx = 0: inregs.ax = 0
CALL INTERRUPTX(&H13, inregs, outregs)
inregs.dx = &H100 'side 1, drive 0
inregs.es = VARSEG(RootBuffer$)
inregs.bx = SADD(RootBuffer$)
inregs.ax = &H30E 'function 3, write 14 sectors
inregsCX = 2 'starting at sector #2
CALL INTERRUPTX(&H13, inregs, outregs)
NEXT
PRINT "New label written to root directory !"