+johnnywc Posted November 2, 2016 Share Posted November 2, 2016 Hello all, I'm adding high score support to a game I am finishing up and I'm experiencing some odd behavior with the AtariVox when saving/loading the high scores. In short, when I write/read the scores from the AtariVox, it makes random speech and soundFX noises. Oddly enough, the saves/writes are working without issue. Has anyone experienced this before? I tried this with a SaveKey test app I found somewhere on AA and it does the same thing, so I'm pretty sure it's not something specific I'm doing in my game. It is using v2.2 of i2c subroutines (optimized for space by Thomas J.). I've attached the test app source; any help is greatly appreciated! Thanks, John savekey_test.zip Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2016 Share Posted November 2, 2016 Did you test with the original i2c.inc file? Quote Link to comment Share on other sites More sharing options...
+johnnywc Posted November 2, 2016 Author Share Posted November 2, 2016 (edited) Did you test with the original i2c.inc file? I finally got around to testing it with the original i2c.inc and it does *not* make the weird noises. Unfortunately I could really use the 64 bytes saved with the 2.2 version. Here is an updated test program; set I2C_VERSION to 1 to use the original i2c.inc; any other value will use i2c_v2.2.inc. Thanks, John savekey_test.zip Edited November 2, 2016 by johnnywc Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2016 Share Posted November 2, 2016 My problem is, that I only own a SaveKey. So we have to collaborate to eliminate the problem. Maybe you can find out which part of code causes the problem? Quote Link to comment Share on other sites More sharing options...
gauauu Posted November 2, 2016 Share Posted November 2, 2016 Ah, I'm interested in this as well....I've been told my game Anguna (which uses Thomas' optimized routines) also makes weird noises occasionally from the AtariVox. (But I don't have one either, so I haven't really tested or confirmed it) Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2016 Share Posted November 2, 2016 I checked my mail with Alex from 10 years ago. Oh, hang on, I've just seen what you've done in I2C_TXBIT: lda #$00 sta SWCHA adc #%1011 sta SWACNT This is bad! When the carry flag is clear, %1011 will be written to SWACNT which will also set pins 1 and 2 to Output 0 (low). When the carry flag is set, %1100 is written to SWACNT, setting pins 1 and 2 to input mode (high). We really don't want to be putting that sort of noise on the SpeakJet's data line. This should probably be ok though: lda #%0011 sta SWCHA adc #%1000 sta SWACNT This should write the same values to SWACNT as your code, but it will also set the lower 2 bits of SWCHA. What this means is, when the carry flag is clear, pins 1 and 2 will get set to output 1 (high). When carry is set, pins 1 and 2 are set to input mode (high). So, the SpeakJet will not see any state changes on it's data line. Maybe this fix was not sufficient, so please try this: MAC I2C_TXBIT ; I2C_SCL_0 ; lda #%0011 ; 2 lda #$0 ; 2 sta SWCHA ; 4 ; set bit ; adc #%1000 ; 2 lda #I2C_SCL_MASK >> 3 ; 2 = 1 rol ; 2 asl ; 2 asl ; 2 sta SWACNT ; 4 SDA = !C (a = %1000 / %1100) ; I2C_SCL_1 lda #I2C_SCL_MASK ; 2 sta SWCHA ; 4 ; total: 18+6 cycles ENDM Finger crossed! Quote Link to comment Share on other sites More sharing options...
+johnnywc Posted November 2, 2016 Author Share Posted November 2, 2016 (edited) I checked my mail with Alex from 10 years ago. Maybe this fix was not sufficient, so please try this: MAC I2C_TXBIT ; I2C_SCL_0 ; lda #%0011 ; 2 lda #$0 ; 2 sta SWCHA ; 4 ; set bit ; adc #%1000 ; 2 lda #I2C_SCL_MASK >> 3 ; 2 = 1 rol ; 2 asl ; 2 asl ; 2 sta SWACNT ; 4 SDA = !C (a = %1000 / %1100) ; I2C_SCL_1 lda #I2C_SCL_MASK ; 2 sta SWCHA ; 4 ; total: 18+6 cycles ENDM Finger crossed! Hi TJ! First the good news: it does work and the random noise is no longer played when transmitting a bit to the SaveKey The bad news: The extra 6 cycles is causing screen rolls (most likely because I was originally trying to transfer up to 2 bytes per frame). I'll need to modify my code to transmit only 1 byte a frame which shouldn't be too difficult. Thanks! John Edited November 2, 2016 by johnnywc Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2016 Share Posted November 2, 2016 Good news! I think I can save 2 cycles: MAC I2C_TXBIT ; I2C_SCL_0 ; lda #%0011 ; 2 lda #$0 ; 2 sta SWCHA ; 4 ; set bit ;; adc #%1000 ; 2 ; lda #I2C_SCL_MASK >> 3 ; 2 ; rol ; 2 ; asl ; 2 ; asl ; 2 adc #I2C_SCL_MASK >> 2 ; 2 %10 / %11 asl ; 2 asl ; 2 sta SWACNT ; 4 SDA = !C (a = %1000 / %1100) ; I2C_SCL_1 lda #I2C_SCL_MASK ; 2 sta SWCHA ; 4 ; total: 18+4 cycles ENDM So only 4 extra cycles/bit instead of 6. Quote Link to comment Share on other sites More sharing options...
+johnnywc Posted November 2, 2016 Author Share Posted November 2, 2016 Good news! I think I can save 2 cycles: MAC I2C_TXBIT ; I2C_SCL_0 ; lda #%0011 ; 2 lda #$0 ; 2 sta SWCHA ; 4 ; set bit ;; adc #%1000 ; 2 ; lda #I2C_SCL_MASK >> 3 ; 2 ; rol ; 2 ; asl ; 2 ; asl ; 2 adc #I2C_SCL_MASK >> 2 ; 2 %10 / %11 asl ; 2 asl ; 2 sta SWACNT ; 4 SDA = !C (a = %1000 / %1100) ; I2C_SCL_1 lda #I2C_SCL_MASK ; 2 sta SWCHA ; 4 ; total: 18+4 cycles ENDM So only 4 extra cycles/bit instead of 6. Excellent! That was just enough to allow me to transfer 2 bytes per frame so now I don't have to refactor my code. Here is the updated i2c_v2.3.inc: i2c_v2.3.inc 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2016 Share Posted November 2, 2016 Same version, but I removed old code and updated cycle counts. i2c_v2.3.inc 2 Quote Link to comment Share on other sites More sharing options...
gauauu Posted November 4, 2016 Share Posted November 4, 2016 Oh man, the the 2 bytes pushed me over the rom limit for the bank. Time for another optimization pass! (Thanks for taking the time to fix this!) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.