controlling the disk drive LED?

Basic and Machine Language

Moderator: Moderators

Post Reply
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

controlling the disk drive LED?

Post by Boray »

Is there an easy and more "accurate" way of turning the LED on and off instead of something like:

open1,8,0,"$"
(wait a moment)
close1

?

I've seen demos even dim the led so it must be possible. The question is how? And if it's easy enough.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: controlling the diks drive LED?

Post by Boray »

And would it work on an SD2IEC as well?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
TNT
Vic 20 Hobbyist
Posts: 121
Joined: Wed Apr 29, 2009 5:46 am

Re: controlling the disk drive LED?

Post by TNT »

Do M-W to $1c00 to control the LED, bit 3 IIRC. No, it won't work without proper 6502/6522 emulation unless there is specific code for it in the firmware.

ETA: Better to read the old value first to not change other bits :)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: controlling the disk drive LED?

Post by Boray »

Thanks! And that would be $1c00 in the 1541's memory I reckon? I have no idea how to change memory inside of the disk drive.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Mike
Herr VC
Posts: 4834
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: controlling the disk drive LED?

Post by Mike »

You'd use the M-R and M-W commands on the, duh, command channel of the drive to read and write drive memory. With M-E, you can execute code on the drive. The VIA chips of the 1541 are located at $1800 and $1C00 in the address room of the drive CPU. Bit 3 (value 8) of $1C00 controls the drive LED.

- Even with cautious use of AND/OR masking with M-R, M-W, you wouldn't have complete control over the drive LED, as the DOS still does its own business,

- It doesn't work with the 1581, as the I/O chips are located at another address,

- It doesn't work with SD2IEC devices neither, as those don't emulate the CPU nor the VIA chips, and their drive LED is controlled by the Atmel firmware. The M-R and M-W commands are only there to 'trick' fastloaders into doing their job, giving the sd2iec firmware a way to check whether certain fastloaders are being deployed into the drive - and then replicate their protocol within the firmware.

In short, your first two posts made conflicting requirements, and TNT's answer didn't anything to resolve them.
I've seen demos even dim the led so it must be possible. The question is how?
This is done with PWM (pulse width modulation), by code executed in the drive.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: controlling the disk drive LED?

Post by Boray »

Ah, thanks.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
TNT
Vic 20 Hobbyist
Posts: 121
Joined: Wed Apr 29, 2009 5:46 am

Re: controlling the disk drive LED?

Post by TNT »

Oh yeah, busy loop's stupid tendency to force LED state based on whether there's job in queue or not... However, you can use that feature to blink the LED yourself ;)

Code: Select all

10 open15,8,15:print#15,"m-w"chr$(0)chr$(3)chr$(1)chr$(96)
20 print#15,"m-w"chr$(0)chr$(0)chr$(1)chr$(208)
30 print#15,"m-w"chr$(0)chr$(0)chr$(1)chr$(1)
40 goto20
If I was you, I would allocate buffer 0 ($0300-$03ff) before overwriting it...
Post Reply