Jump to content

Open Club  ·  88 members

AtariVox
IGNORED

Copy AtariVox / SaveKey utility


Karl G

Recommended Posts

Okay my first stumbling block is figuring out how to communicate with an AtariVox / SaveKey that is in the left joystick port. I'm thinking that the cleanest approach would be to include two different version of the i2c include file with appropriately-renamed labels so as not to clash.  What would I need to change in one of the copies to make it address the left port?  Would it be as simple as changing the I2C_SDA_MASK and I2C_SCL_MASK constants?

 

I was thinking to test in Stella I could set one port to be a SaveKey and the other to be an AtariVox, since they use different data files to store the contents. Based on my forum searching, it would appear that Stella doesn't have the ability to communicate with these devices in the left port even though you can set them in the GUI, probably because no one has needed this functionality before now. I'm not sure if that's something I can maybe add myself to Stella if I can figure out the first problem, though.

Link to comment
Share on other sites

The SaveKey and AtariVox work on both ports. However they read/write using the same file no matter which port is used. 

 

But the files for SaveKey and AtariVox are different. So if you select e.g. a SaveKey for the left port and an AtariVox for the right port, you can copy from one file into the other.

 

Link to comment
Share on other sites

Good to know that the Stella limitation is no longer an issue. 

 

What would need to change in the driver to get it to communicate with the left porti instead of the right? Can I just change the  I2C_SDA_MASK and I2C_SCL_MASK constants?

Link to comment
Share on other sites

Once I get the left driver ironed-out, I think I can take it from there to make the utility. I appended the letter L to all symbols, macros, and labels so I can include the modified driver along with the unmodified without conflicts. Anyway, just to confirm, are these mask values correct?

 

I2C_SDA_MASKL    equ     $40
I2C_SCL_MASKL    equ     $80

 

Right now the assembler is choking on these two lines due to byte overflow

 

    lda     #(I2C_SCL_MASKL|I2C_SDA_MASKL)*2

 ...

    lda     #I2C_SCL_MASKL*2

 

I'm attaching my modified version in case it helps.  I appreciate your help!

 

i2c_v2.3left.inc

Link to comment
Share on other sites

Okay, so for this macro:

 

  MAC     I2C_STARTL
; I2C_SCL_1L
    lda     #(I2C_SCL_MASKL|I2C_SDA_MASKL)*2  ; 2         I2C_SCL_MASKL
    sta     SWCHA                           ; 4
; I2C_SDA_OUTL
    lsr                                     ; 2         I2C_SCL_MASKL|I2C_SDA_MASKL
    sta     SWACNT                          ; 4
; total: 12 cycles
  ENDM

 

I would change the lda line to:

 

    lda     #I2C_SCL_MASKL  ; 2         I2C_SCL_MASKL

 

And for this macro:

 

  MAC     I2C_TXNACKL
; I2C_SCL_0L
    lda     #I2C_SCL_MASKL*2                 ; 2         $00
    sta     SWCHA                           ; 4
; I2C_SDA_INL
    lsr                                     ; 2         I2C_SCL_MASKL
    sta     SWACNT                          ; 4
; I2C_SCL_1L
    nop                                     ; 2         required for timing!
    sta     SWCHA                           ; 4         I2C_SCL_MASKL
; total: 18 cycles
  ENDM

 

I would change the lda to:

 

    lda     #0                 ; 2         $00

 

Is that correct?

Link to comment
Share on other sites

The code is heavily optimized for space, I know its hard to understand (even for me :)).

 

This should do:

  MAC     I2C_START
; I2C_SCL_1
    lda     #I2C_SCL_MASK                   ; 2         I2C_SCL_MASK
    sta     SWCHA                           ; 4
; I2C_SDA_OUT
    lda     #I2C_SCL_MASK|I2C_SDA_MASK      ; 2         I2C_SCL_MASK|I2C_SDA_MASK
    sta     SWACNT                          ; 4
; total: 12 cycles
  ENDM

  MAC     I2C_TXBIT
; I2C_SCL_0
    lda     #$0                             ; 2
    sta     SWCHA                           ; 4
; set bit
    adc     #I2C_SCL_MASK >> 6              ; 2         %10 / %11
    asl                                     ; 2
    asl                                     ; 2
    asl                                     ; 2
    asl                                     ; 2
    asl                                     ; 2
    asl                                     ; 2
    sta     SWACNT                          ; 4         SDA = !C (a = %10000000 / %11000000)
; I2C_SCL_1
    lda     #I2C_SCL_MASK                   ; 2
    sta     SWCHA                           ; 4
; total: 30 cycles
  ENDM

  MAC     I2C_TXNACK
; I2C_SCL_0
    lda     #0                              ; 2         $00
    sta     SWCHA                           ; 4
; I2C_SDA_IN
    lda     #I2C_SCL_MASK                   ; 2         I2C_SCL_MASK
    sta     SWACNT                          ; 4
; I2C_SCL_1
    nop                                     ; 2         required for timing!
    sta     SWCHA                           ; 4         I2C_SCL_MASK
; total: 18 cycles
  ENDM

 

  • Thanks 1
Link to comment
Share on other sites

Unfortunately, I'm having issues with the left port still, both under Stella and real hardware.  I've attached my program alone with both include files (the original driver and the one modified to work with the left port with different symbol names.  Any ideas as to what's going wrong?

 

copyvox.zip

 

copyvox_2.png.8686698d9e729fd2bc58f9172430d888.png

Link to comment
Share on other sites

I'm wondering if the issue is with i2c_rxbit:

 

i2c_rxbit:                                  ;           receive bit in C
    I2C_TXNACK                              ;18 = 18

    lda     SWCHA                           ; 4
    lsr                                     ; 2
    lsr                                     ; 2
    lsr                                     ; 2 = 10    C = SDA

    tya                                     ; 2
    rol                                     ; 2         rotate into Y
    bcc     i2c_rxbyteloop                  ; 2�=  6/7

If I'm looking at the left port, I assume the relevant bit would be in the high nybble instead of the low nybble, so should I be adding 4 more "lsr" ops?

 

Link to comment
Share on other sites

2 hours ago, Thomas Jentzsch said:

Sounds correct. Sorry, very busy today.

Thanks, and no problem at all! I'm proceeding with my coding, and I'll see for myself if the reading of values is working correctly now.

Link to comment
Share on other sites

Getting closer now, but my reading from the left port is still not quite correct. My program now reads one 64 byte block of values from the left port, then stops.  Looking in Stella, all of the read values are $FE when they should be $FF.  I have confirmed in a hex editor that the first 64 bytes of my my atarivox_eeprom.dat file are all $FF.  I'm assuming that it's a remaining issue with withthe modified left port driver.  Any ideas?

 

I have a zip with the utility source and ROM along with the drivers.

 

955745999_ScreenShot2020-04-20at5_22_27PM.thumb.png.22f6cb9f2748d370ae6ae172d100148b.png

 

copyvox.zip

Link to comment
Share on other sites

I just checked with different values in the file and the result is always $FE. So there is something fundamental wrong. Your code looks fine and the I2C L macros too. Maybe the bug is in Stella and the SaveKey emulation. I will have a look, but I am not very firm with that code.

 

Edit: Checked your code again. Are you sure you are initializing the read addresses correctly? I cannot find stopwrite and startwrite. Also you should strictly separate access to left and right ports, the IC2 macros will corrupt the other port.

 

Edited by Thomas Jentzsch
Link to comment
Share on other sites

Okay; thanks for taking a look at it.  if it might be a Stella bug, then I'll try to modify my code to be able to do a little testing on hardware in the meantime to see if I am pulling the correct values, after all.

Link to comment
Share on other sites

What am I missing from what you said above? If it might be the an issue with the Stella SaveKey code, then I can see if I am getting correct values from my actual AtariVox.

 

Also, I'm not sure if you are saying my code looks fine, or if there's something wrong with it now?

Link to comment
Share on other sites

Your code seems wrong. E.g.

  • Where do you set the start address when reading from the SaveKey for the very first time? The code seems to jump this part when it first executes DoCopy. 
  • And where are the calls to the i2c_stopwrite and i2c_startwrite routines after setting up the start addresses?
  • Also you are accessing left and right port in parallel. This won't work, both macros are writing to the same registers, interfering each other.
Link to comment
Share on other sites

The idea is that I read one block of 64 bytes into RAM from the left (source) device, then write them to the right (destination) device.  I do have the init code:

 

    ; Source SK
    clv
    lda CurrentAddressHigh
    jsr i2c_txbytel
    lda CurrentAddressLow
    jsr i2c_txbytel
    ; Dest SK
    clv
    lda CurrentAddressHigh
    jsr i2c_txbyte
    lda CurrentAddressLow
    jsr i2c_txbyte

 The CurrentAddressHigh and CurrentAddressLow variables start at 0, and I increment the low address by 64 bytes after each block, with the carry going into the high address variable.

 

Noted about not accessing both devices at once.  I'll change it to init just the source, and read in a block, then init the destination, and write a block.

 

You are correct about the missing i2c_stopwrite and i2c_startwrite routines - I'll fix that, and give it another try.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...