Check for disk activity?

ページ 1/2
| 2

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

31-05-2023, 09:23

I'd want to check when the disk activity ended. Cannot find anything for that, BIOS or DiskROM.

ログイン/登録して投稿

By bore

Master (182)

bore さんの画像

31-05-2023, 10:29

I don't know how MSX handles the disk internally, but typically programs will perform multiple disk accesses fairly close to each other, so to prevent the disk motor from having to spin up between each access the driver will keep the drive spinning after each access and stop it on a timeout if no access has happened for a while.

So "disk activity" have probably already ended the moment your code is allowed to run again, but the timeout for stopping the disk motor has not happened.

There is a 401FH (DSKSTP) that might force this early if you don't want to wait.
Otherwise it's probably fairly safe to count the time since last disk access and assume that the disk have stopped after a certain time.

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

31-05-2023, 11:23

Those are the only ways I can find:
- Checking if 401FH (DSKSTP) of slot MASTER (F348H) <> 00H for it to be valid and call it. Or
- Set a 8-bit variable at 0 then inc at vblank and when Carry (overflow) we could assume it already stopped.

I'd prefer to use a system check for disk activity, but looks like BIOS ISFLIO does nothing, and cannot find any other thing.

By Manuel

Ascended (19691)

Manuel さんの画像

31-05-2023, 14:12

Can you explain the use case, i.e. why you want to check for disk activity?

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

31-05-2023, 14:43

Manuel wrote:

Can you explain the use case, i.e. why you want to check for disk activity?

I want to disable the Inter-slot call to the DiskROM once it has finished loading content.
Made some tests and it takes too much CPU.
So the idea is: load, disable DiskROM, on new load enable again.

If we disable it just after loading finished there is no spin-down.

By Manuel

Ascended (19691)

Manuel さんの画像

01-06-2023, 00:29

But isn't your own code actually using the diskdrive? So you know when loading is finished?

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

01-06-2023, 10:38

Yes but the drive spin takes some time to stop. If we disable just after loading some drives could not spin-down.

By bore

Master (182)

bore さんの画像

01-06-2023, 11:22

TBH I think your best bet is to just wait a fixed time, like 150 frames or something.
Maybe use the time to unpack the data.
If you show some loader graphics you can take the time to do a pretty transition.

By cjs

Master (143)

cjs さんの画像

01-06-2023, 12:57

Wouldn't it make more sense just to call into the Disk ROM to turn off the drive motor after your data is loaded but before you disable the inter-slot call to the Disk ROM? My guess is that the Disk ROM hooks the timer while the motor is on so that, after it's seen enough time elapse after the last access, it can turn off the drive motor, but disabling the Disk ROM inter-slot call while the motor is on is breaking this mechanism.

By bore

Master (182)

bore さんの画像

01-06-2023, 14:15

Yes, but Not all diskinterfaces support this entry. Only valid when 401FH <> 00H, so you still need to handle the case where you can't.

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

01-06-2023, 15:19

Well, implemented but seems to do nothing:

public _disk_stop
_disk_stop:
	; read DSKSTP
	ld a, (MASTER)
	ld hl, DSKSTP
	call RDSLT
	; if 0 then not supported, return
	or 0
	ret z
	; else call it
	ld ix, DSKSTP
	ld iy, (MASTER - 1)
	jp CALSLT

The RDSLT result is != 0, so it should be supported. Calling it just before disabling the DiskROM and the drive doesn't spin-down.

But, the main is the IDE one, and reading from FDD, so probably MASTER is not what I want, but the current used drive. Don't know how can get that.
Looking at the machine XML, the FDD controller is at slot 3-3, and then calling with:

	ld ix, DSKSTP
	ld iy, 0x8f00
	jp CALSLT

It stops the drive.

But reading about MTOFF:

引用:

Some HDD interfaces have wrongly implemented this as a HDD powerdown (HSH/MAK)

Seems better to wait a time. As probably the multiple controllers implementation is made by chaining them.

ページ 1/2
| 2