+Karl G Posted April 14, 2020 Share Posted April 14, 2020 Before I do work to make something like this myself, I just wanted to make sure there wasn't already a utility someone else has made to copy the contents of an AtariVox or SaveKey to another AtariVox or SaveKey? Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 14, 2020 Share Posted April 14, 2020 I only made the suggestion. And I don't know of anyone who did this. 1 Link to comment Share on other sites More sharing options...
+Karl G Posted April 14, 2020 Author Share Posted April 14, 2020 Right - I don't mind working on this, but I wanted to make sure I wasn't duplicating effort if I did so. Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 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 More sharing options...
Thomas Jentzsch Posted April 17, 2020 Share Posted April 17, 2020 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 More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 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 More sharing options...
Thomas Jentzsch Posted April 17, 2020 Share Posted April 17, 2020 That's one thing. Plus I2C_TXBIT which is optimized, so you have to change that one too. Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 What else needs to be changed in I2C_TXBIT if I2C_SCL_MASK has already been changed? Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 17, 2020 Share Posted April 17, 2020 If I am not wrong you have to >> 6 and then ASL 6x to get the carry at the correct bit. ; 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) 1 Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 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 More sharing options...
Thomas Jentzsch Posted April 17, 2020 Share Posted April 17, 2020 Just replace with the variables in the comments. Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 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 More sharing options...
Thomas Jentzsch Posted April 17, 2020 Share Posted April 17, 2020 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 1 Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 Excellent! Thanks again. Link to comment Share on other sites More sharing options...
+Karl G Posted April 17, 2020 Author Share Posted April 17, 2020 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 Link to comment Share on other sites More sharing options...
+Karl G Posted April 18, 2020 Author Share Posted April 18, 2020 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 More sharing options...
Thomas Jentzsch Posted April 19, 2020 Share Posted April 19, 2020 Sounds correct. Sorry, very busy today. Link to comment Share on other sites More sharing options...
+Karl G Posted April 19, 2020 Author Share Posted April 19, 2020 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 More sharing options...
+Karl G Posted April 20, 2020 Author Share Posted April 20, 2020 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. copyvox.zip Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 21, 2020 Share Posted April 21, 2020 (edited) 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 April 21, 2020 by Thomas Jentzsch Link to comment Share on other sites More sharing options...
+Karl G Posted April 21, 2020 Author Share Posted April 21, 2020 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 More sharing options...
Thomas Jentzsch Posted April 21, 2020 Share Posted April 21, 2020 See above. Meanwhile I don't think your code is doing it right. Link to comment Share on other sites More sharing options...
+Karl G Posted April 21, 2020 Author Share Posted April 21, 2020 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 More sharing options...
Thomas Jentzsch Posted April 21, 2020 Share Posted April 21, 2020 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 More sharing options...
+Karl G Posted April 21, 2020 Author Share Posted April 21, 2020 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 More sharing options...
Recommended Posts