Re: drive-side routine

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2005-10-03 19:53:39

Hello,

the following is not completely tested, but it might give you the right
direction.

* On Sun, Oct 02, 2005 at 11:26:21PM +0200 silverdr@inet.com.pl wrote:

> Hello floppy experts. I am looking for an explanation to the 1541  
> code snippet below.
> 
> [... entering with X=0]
> 
>     TXA         ; LDA #$00
>     LDY #$A2    ; 162 times? 324 GCR bytes probably...
> L75F:
>     BVC *
>     CLV
>     EOR $1801    ; get the byte from parallel port
>     STA $1C01    ; write to disk
> 
>     DEC $1800    ; acknowledge (DATA HI?)
>     LDA $1801
>     BVC *
>     CLV
>     EOR $1801    ; zero out??!
>     STA $1C01
> 
>     INC $1800    ; acknowledge (DATA LO?)
>     LDA $1801
>     DEY
>     BNE L75F
> 
> I am not sure if I am missing something very obvious but I just don't  
> understand WTH is the EOR $1801 for and how come does

The port A if the VIA ($1801) has a "handshaked mode", that is, if you
read $1801, it shows the last contents of it when a specific line (would
have to look it up) was set/reset, or that line was last read. For
details, you would need to look up a 6522 data sheet.

BTW: An unbuffered access to port A is available at $180F.


Now, the first EOR $1801 reads the last content AND clears the buffer
for the next value.

This way, the next LDA $1801 clears A, but performs the handshake for
the C64 side to input the next data. While the floppy perform the BVC *,
the C64 has enough time to put the next value into the port which is
read by the 1541 via the EOR $1801 again.

Of course, this can be used in another way, too. The C64 does not need
to specifically write 0 into the buffer. The important thing is that the
C64 has enough time between the LDA $1801 and the EOR $1801 to change
the value - and it will, depending on how the VIA is programmed (have a
look at the contents of $180C) - generate handshakes on CA2, which the
C64 can recognize.

> LDA $xxxx
> EOR $xxxx
> 
> not zero the A?? Please someone enlighten me on that...

Because there is some time in between the two commands, which leaves the
C64 enough time to alter the value.

To be more precise, you would have to show us the C64 side.

Regards,
   Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/
http://cbm4win.sf.net/

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.