MSX-DOS 1 / Disk BASIC 1 file write question

By zPasi

Champion (499)

zPasi의 아바타

28-11-2015, 21:08

I've learned, in MSX-DOS 1, there is FCB access only available. You just write n sectors of 128 bytes to a file. So the file size will be a multiple of 128 bytes, right?

But Disk BASIC and MSX-DOS themselves are able to set file sizes in one byte resolution. How do they do that?

Login or 등록 to post comments

By RetroTechie

Paragon (1563)

RetroTechie의 아바타

29-11-2015, 07:51

Those 128 bytes blocks (IIRC the correct term is "records" *) are a leftover from CP/M, to which MSX-DOS is partly compatible. If I'm not mistaken, a few of the lower level function calls actually read or write in 128 byte chunks.

Some programs originating from CP/M days (PMARC / PMEXT comes to mind) behave in the same way because they use those function calls.

However unlike CP/M, that's not a limitation of MSX-DOS (or Disk BASIC). You can read or write files in single byte increments just fine as long as you use the appropriate function calls. Files will be created with exact length then. And if you read/write a block of 10,000 'records' of 1 byte each but do it in one function call, MSX-DOS does have the brains to do the math and read/write that in one go.

* In some old disk formats used with CP/M, 128 byte "records" would actually correspond directly with disk sector size.

By hit9918

Prophet (2911)

hit9918의 아바타

29-11-2015, 10:31

in msx2 technical handbook, function 26h,
"When 0 records are to be written, the file lenght is calculated at the record size multiplied by the record number".
a dummy write of size 0 before closing the file.

By Bit Addict

Resident (34)

Bit Addict의 아바타

29-11-2015, 15:47

ld hl,1
ld [FCB + 0EH ],hl ; Change Record Size

ld de, FCB ; Pointer to opened FCB
ld hl, 27 ; Number of records to write
ld c, BWRITE ; Random Block Write (26h)
call BDOS ; Writes 27 blocks of 1 byte

By zPasi

Champion (499)

zPasi의 아바타

29-11-2015, 21:51

Ok, I got it!

But since these are random access modes (aren't they?) I'll better to set the record number also. Like in this Konamimans file dump example

	LD	HL,8
	LD	(FCB+14),HL	;record size := 8

	LD	HL,0
	LD	(FCB+33),HL
	LD	(FCB+35),HL	;random record := 0

Thanks, everyone!