Programming the 1540 / 2031 Floppy

Basic and Machine Language

Moderator: Moderators

User avatar
MrSterlingBS
Vic 20 Afficionado
Posts: 304
Joined: Tue Jan 31, 2023 2:56 am

Re: Programming the 1540 / 2031 Floppy

Post by MrSterlingBS »

Hi,

i like to convert the drivecode example from CODEBASE64.ORG https://codebase64.org/doku.php?id=base:drivecode to the VIC.
My question is about the register $DD00 from the C64.
The C64 needs only the $DD00 register with ? And why are the bits 0 and 1 are set?
bit 7 serial in
bit 6 clock in
bit 5 serial out
bit 4 clock out
bit 3 atn out
bit 2 ???
bit 1 screen
bit 0 screen

and the VIC needs
$911F
bit 7 atn out
bit 6 -
bit 5 -
bit 4 -
bit 3 -
bit 2 -
bit 1 serial in
bit 0 clock in

$912C
bit 7 serial out
bit 6 serial out
bit 5 serial out
bit 4 -
bit 3 clock out
bit 2 clock out
bit 1 clock out
bit 0 -

Do all bits have to be set for serial and clock out or is one bit sufficient?

BR
Sven
User avatar
srowe
Vic 20 Scientist
Posts: 1471
Joined: Mon Jun 16, 2014 3:19 pm

Re: Programming the 1540 / 2031 Floppy

Post by srowe »

MrSterlingBS wrote: Mon Sep 16, 2024 9:34 am Do all bits have to be set for serial and clock out or is one bit sufficient?
You'll need to read and understand the 6522 datasheet. Register $C is the Peripheral Control Register (PCR). Those three bits act together to control what happens to CB2, whether is is an input or output etc. As it is connected to the serial DATA output you want to be able to toggle the line between 0 and 1. That means the two values to use are 110 and 111, but also note the line goes through a 7406 buffer which inverts the level seen by devices.
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Programming the 1540 / 2031 Floppy

Post by Mike »

srowe wrote:You'll need to read and understand the 6522 datasheet.
+1

... and the schematics of VIC-20 (or C64) and the drives, because of this: https://sleepingelephant.com/ipw-web/bu ... 7&start=51
User avatar
MrSterlingBS
Vic 20 Afficionado
Posts: 304
Joined: Tue Jan 31, 2023 2:56 am

Re: Programming the 1540 / 2031 Floppy

Post by MrSterlingBS »

Some people often only give cryptic or insulting answers to specific questions here in the forum. It's a real shame, even though we all have the same interests. So I won't be asking any more questions. Thank you very much and all the best!
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Programming the 1540 / 2031 Floppy

Post by Mike »

What you dismiss here as "cryptic" or "insulting" answers are answers that tell you to do your homework first.

To make things clear: drive code is notoriously difficult to debug. One single programming error, and the drive will simply stop responding, leaving no clue to the programmer what happened.

At the beginning of this thread's page, you ask why the VIC-20 employs two port registers whereas the C64 only uses one. The answer: that is simply how it happened! It is the responsibility of the OS (on the VIC-20 and C64, the KERNAL in particular) to 'shield' the user from these differences in hardware. If you decide not to use the provided bus protocol, but rather roll your own, for whatever reason, that is entirely your business. To succeed in that, you need innate knowledge about the chips themselves (via their data sheets), how they are used in computer and drive (via the schematics) and about the original bus protocol itself, so you have at least a chance to understand how the routines in the drive and computer implement the original bus protocol and derive an alternate bus protocol from that.

What you cannot expect is, that people hand over ready made bus protocol routines to you on a silver platter. Chances are they will not work as such in the context you want to use them, you will need to adapt them for your use, and without real understanding of the topic - any changes in those routines have a good chance to crash the drive and, as I wrote above, giving no clue why.

Not the answers you expected or wanted to read, true, but still no reason for a rage quit.
User avatar
MrSterlingBS
Vic 20 Afficionado
Posts: 304
Joined: Tue Jan 31, 2023 2:56 am

Re: Programming the 1540 / 2031 Floppy

Post by MrSterlingBS »

What you cannot expect is, that people hand over ready made bus protocol routines to you on a silver platter. Chances are they will not work as such in the context you want to use them, you will need to adapt them for your use, and without real understanding of the topic - any changes in those routines have a good chance to crash the drive and, as I wrote above, giving no clue why.
I only asked whether I had interpreted my assumption of the comparison of the VIC-20 and C64 registers correctly.
I did not ask for a complete code or a routine.

The POST can be closed!

THX
Sven
tlr
Vic 20 Nerd
Posts: 594
Joined: Mon Oct 04, 2004 10:53 am

Re: Programming the 1540 / 2031 Floppy

Post by tlr »

For an example of a working VIC-20 transfer routine you could examine JiffyDOS for the VIC-20. There are quite a few drive -> VIC-20 implementations (e.g turbo load) but not very many VIC-20 -> drive. JiffyDOS has both.

All in all doing a transfer routine is quite an interesting, and sometimes frustrating task.
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Programming the 1540 / 2031 Floppy

Post by Mike »

MrSterlingBS wrote:I did not ask for a complete code or a routine.
See your post from Jul 11, 2024:
MrSterlingBS wrote:Do you have a fast IEC transfer routine to share?
groepaz
Vic 20 Scientist
Posts: 1266
Joined: Wed Aug 25, 2010 5:30 pm

Re: Programming the 1540 / 2031 Floppy

Post by groepaz »

Make sure you are optimizing the right thing! I’d start with the multiplication, then rotation, and after that consider any multiprocessing.
And don't forget the drawing code - which often is the most time consuming part :) Doing stuff on the drive on the other hand almost never gives a significant advantage, its really only a good idea for doing if you need a lot of time for few calculations (textbook example: calculating mandelbrot)

That said, check out the "krill loader". It has a framework for running code on the drive, and there are fast transfer routines also. (i don't know if it supports vic20, but the basic idea is pretty much the same on the c64)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Post Reply