Songbird Posted March 25, 2020 Share Posted March 25, 2020 (edited) I'm looking for an assembly version of the EEPROM library for the 93c46 serial EEPROM chip. I found some really old code from @42bs called eeprom.m65 which supports basic read, write, and erase functions. Is this the best/simplest one to use? Any issues or caveats I should know about? Edited March 25, 2020 by Songbird Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/ Share on other sites More sharing options...
42bs Posted March 25, 2020 Share Posted March 25, 2020 There are two versions of the eeproms: 16 or 8 bit wide. I am not sure which version eeproms.m65 supports Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4490729 Share on other sites More sharing options...
Songbird Posted March 25, 2020 Author Share Posted March 25, 2020 Here is the code... seems like it is accessing 16-bit words. Is this the same code used on T-tris and SIMIS? Because I believe that matches what is on the PCB design by @karri. At least, I have been able to demonstrate that SIMIS saves data on this cart the same as modern games like Biniax. eeprom.m65 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4490739 Share on other sites More sharing options...
+karri Posted March 26, 2020 Share Posted March 26, 2020 So far I have only used 16 bits mode on everything. And yes, even the cc65 version is identical to this old file. lynxeeprom.s 1 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4491150 Share on other sites More sharing options...
42bs Posted March 26, 2020 Share Posted March 26, 2020 10 hours ago, Songbird said: Here is the code... seems like it is accessing 16-bit words. Is this the same code used on T-tris and SIMIS Yes, SIMIS/T-Tris use 16bit mode. 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4491172 Share on other sites More sharing options...
Songbird Posted March 26, 2020 Author Share Posted March 26, 2020 Awesome, thanks for the confirmation! Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4491267 Share on other sites More sharing options...
sage Posted March 29, 2020 Share Posted March 29, 2020 somewhere i still have the source files to access 8 and 16 bit for different kind of eeproms for cc65. if you need it i might dig them out. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4494272 Share on other sites More sharing options...
+karri Posted March 29, 2020 Share Posted March 29, 2020 @sage if you mean eeprom46.s eeprom66.s eeprom86.s They are in cc65 already. 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4494329 Share on other sites More sharing options...
sage Posted March 30, 2020 Share Posted March 30, 2020 but it looks like Carl is using the old compiler ? Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4495171 Share on other sites More sharing options...
+karri Posted March 30, 2020 Share Posted March 30, 2020 Well, MegaPak I was using the old compiler. But that compiler already has support for the 46 eeprom. So there is no need for fancy new eeprom chips at the moment. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4495199 Share on other sites More sharing options...
Songbird Posted March 30, 2020 Author Share Posted March 30, 2020 Actually I'm not using a compiler at all... raw assembly power for this project! Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4495949 Share on other sites More sharing options...
Nop90 Posted March 31, 2020 Share Posted March 31, 2020 6 hours ago, Songbird said: Actually I'm not using a compiler at all... raw assembly power for this project! Let me guess. Are you trying to add a save feature to one of the titles of yours? 2 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4496272 Share on other sites More sharing options...
Songbird Posted April 14, 2020 Author Share Posted April 14, 2020 So I've got my ROM patched with the EEPROM code, but having trouble making it work. Testing this on a real cartridge is painful. Is there a Windows executable of Handy somewhere with full 93c46 EEPROM support? Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4510064 Share on other sites More sharing options...
+karri Posted April 15, 2020 Share Posted April 15, 2020 Carl, there is something that I don't fully understand. You cannot call the eeprom routine as a first thing in startup. What I have done is to call it once the first frames have been displayed. It could be something related to the eeprom needing time to power up or something related to the signals during setup of registers that is different at startup. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4510280 Share on other sites More sharing options...
LordKraken Posted April 15, 2020 Share Posted April 15, 2020 (edited) Carl, "patched handy 0.95" from sage's handy-fork repo emulates 93c46 eeprom. I can provide you a compiled version later today if you want. Also check the lynxdir topic I created yesterday, i posted a compiled version of latest lynxdir to create a rom that will enable eeprom support for Handy. Edited April 15, 2020 by LordKraken Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4510311 Share on other sites More sharing options...
Songbird Posted April 15, 2020 Author Share Posted April 15, 2020 Sure, please send the compiled version. Karri, have you observed that issue even when the boot screen is displayed before game code is loaded? This is an old ROM using the Atari format, so the first ROM directory points to the boot screen, then the game code loads after 2-3 seconds. Should be plenty of power up time. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4510448 Share on other sites More sharing options...
LordKraken Posted April 15, 2020 Share Posted April 15, 2020 Check on the main atari lynx forum, handy 0.98 alt win32 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4510458 Share on other sites More sharing options...
Songbird Posted April 16, 2020 Author Share Posted April 16, 2020 Well, I think I have it working now... but strangely, on power up I have to do a dummy read of one word before trying to read any real data. If I do that first, then the rest of the reads seem to work correctly. The sequence I was doing was this: Read the first EEPROM word looking for a unique game ID pattern If bytes don't match, write the game ID, set all saved data to default values If bytes do match, read some saved data instead of defaults Boot the game The problem I was seeing is that the values in A and X after the first read were always $FF and $3F, respectively. If I immediately perform another read of the same word, then I get the proper values back and other reads work after first try. So it's just the very first EEPROM read that seems to have a problem. I tried moving this first read to various spots in the code, sometimes before the title menu is displayed, other times much later after several screens have been displayed. Even stranger, I see the same behavior in the new Handy 0.98 executable with EEPROM support. Is this expected? Is there some kind of init command or "always do a dummy read first" sequence that gets the EEPROM into a good state? Otherwise I wonder if there is a bug / race condition in lynx_eeprom_read which causes it to misbehave only on the first read... Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511230 Share on other sites More sharing options...
42bs Posted April 16, 2020 Share Posted April 16, 2020 (edited) I guess it is related to the IODAT/AUDIN setup. BLL sets IODIR = $1a, IODAT = $0b. Maybe cc65 init code does it differently. Try writing $b to $FD8B and before the first read. Edited April 16, 2020 by 42bs 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511309 Share on other sites More sharing options...
Nop90 Posted April 16, 2020 Share Posted April 16, 2020 I had the same behavior in my game version of Karri's template (that supports both EEPROM and SD saves) after there was the update to the SD code with the request of always call the SD init code. As @42bs pointed out it's related to the state of IODIR and IODAT because both the EEPROM and SD code use (and init) them. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511317 Share on other sites More sharing options...
+karri Posted April 16, 2020 Share Posted April 16, 2020 The problem seems to be in by bootloader. ; ; 4. set AUDIN to output ; A9 1A lda #$1a ; audin = out, rest = out, ; ; noexp = in, cart addr = out, ext pwd = in ; 8D 8A FD sta IODIR ; ; ; 5. set AUDIN to LOW ; A9 08 lda #$08 ; Set AUDIN low ; ; Set cart addr low for pwr to cart rom ; 85 1A sta $1a ; Save local copy to ZP ; 8D 8B FD sta IODAT FD8B = lODAT.Mikey Parallel Data(sort of a R/W) 8 bits of general purpose I/O data B7 = NC B6 = NC B5 = NC B4 = audin input B3 = rest output B2 = noexp input B1 = Cart Address Data output (0 turns cart power on) B0 = External Power input (note, R0M sets it to output, you must set it to input) The LSB B0 should not matter. It is an input. Why should B1 be set to turn the cart off? Plus the comment is wrong. I seem to set AUDIN HIGH at startup - not low. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511350 Share on other sites More sharing options...
42bs Posted April 16, 2020 Share Posted April 16, 2020 (edited) The problem is the block counter: IODAT.B1 is connected to 74HC164-B which must be high to enable output of the block address. But, why it affects the EEPROM is not clear to me yet as it uses A7 for CS and A1 for CLK. BTW: No one ever did wonder why A1 and not A0. Simply because A0 did not work back in time and I did not have the stamina to search why ? Edited April 16, 2020 by 42bs 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511384 Share on other sites More sharing options...
+karri Posted April 16, 2020 Share Posted April 16, 2020 29 minutes ago, 42bs said: The problem is the block counter: IODAT.B1 is connected to 74HC164-B which must be high to enable output of the block address. But, why it affects the EEPROM is not clear to me yet as it uses A7 for CS and A1 for CLK. BTW: No one ever did wonder why A1 and not A0. Simply because A0 did not work back in time and I did not have the stamina to search why ? Thanks! It is amazing that the code you wrote in "created : 11.05.95" still is in active use 25 years later I will change my bootloader to set the IODAT to $0B. This should not have any bad effects. Just take away problems. 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511396 Share on other sites More sharing options...
Songbird Posted April 16, 2020 Author Share Posted April 16, 2020 It is even more amazing the code from 25 years ago is still in use and we have such quick technical feedback from the author... I tried writing $b to IODAT before the first read, however it is the same behavior where the first read is bad. I can also see now in lynx_eeprom_read that IODAT is being used without being set, so in theory this should have cleaned things up. But since the dummy read seems to work reliably, I at least have that as a work-around. For reference, here is the source to lynx_eeprom_read I am using. My code must set "cell" prior to calling it, so the code knows which EEPROM word to read. But if, on the first EEPROM read, I simply perform two reads back-to-back, then I always get the correct result. lynx_eeprom_read: lda cell and #$3f ora #EE_C_READ jsr EE_Send9Bit lda #$a sta IODIR ; set AUDIN to Input clc stz ptr1 stz ptr1+1 ; Clear result ldy #15 ; Initialize bit counter @L1: ; CLK = 1 stz RCART0 stz RCART0 ; CLK = 0 stz RCART0 stz RCART0 lda IODAT and #$10 ; mask bit adc #$f0 ; C=1 if A=$10 rol ptr1 rol ptr1+1 ; shifts 0 to Carry dey bpl @L1 ldx #$1a stx IODIR ; set AUDIN for output ;EE_SET_CS_LOW ldx #3 stx SYSCTL1 dex stx SYSCTL1 lda ptr1 ldx ptr1+1 ; Load result rts 1 Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511482 Share on other sites More sharing options...
42bs Posted April 16, 2020 Share Posted April 16, 2020 2 hours ago, Songbird said: For reference, here is the source to lynx_eeprom_read I am using Like mine. I do nothing special in SIMIS/T-Tris. Quote Link to comment https://forums.atariage.com/topic/304345-eeprom-library/#findComment-4511596 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.