Page 1 of 1

STORE/RECALL for SEDORIC

Posted: Fri Apr 25, 2014 1:59 pm
by Hialmar
Hi,

For Maximus' game, I would need to find a solution to recode STORE and RECALL for SEDORIC.
I.e. I want to save an array (and only one array) on the disk and then reload it.

So basically I would need to find the start and end addresses of a Basic array.

Is there a way to do that ?

My first idea is to compute the size of each array and then find them in between ( #9E) and ( #A0) – 1.

However, this wouldn't work with string arrays.

Edit: I have looked at the ROM disassembly for both routines. I think I will do something similar and with this:
http://forum.defence-force.org/viewtopic.php?t=222
I should be able to save data on the sedoric disk.

Re: STORE/RECALL for SEDORIC

Posted: Fri Apr 25, 2014 3:01 pm
by Hialmar
Ah I think I found a better solution here:
http://www.defence-force.org/computing/ ... htm#chap_6

I'll try this.

Re: STORE/RECALL for SEDORIC

Posted: Fri Apr 25, 2014 3:32 pm
by Hialmar
Well there is something strange.

Here is my program:

Code: Select all

   1 PRINT "CRETAB"                     
   10 DIM A%(10,10)                     
   15 DIM B%(25)                        
   20 FOR I=0 TO 10                     
   25 FOR J=0 TO 10                     
   30 A%(I,J)=I*J                       
   40 NEXT J,I                          
   60 FOR I=0 TO 25                     
   70 B%(I)=16                          
   75 NEXT                              
   80 OPEN S,"DATA.DAT",0                
   90 PUT 0,10                          
   100 PUT 0,10                         
   110 FOR I=0 TO 10                    
   120 FOR J=0 TO 10                    
   130 PUT 0,A%(I,J)                    
   140 NEXT J,I                         
   150 CLOSE 0                          
I'm creating two numeric arrays, filling them with some data, then I open a file called data.dat, I write the two sizes of the matrix, write the matrix data and close the file.

Each time I run it I get a: ?FILE NOT OPEN ERROR IN 90

I have tried to execute the code interactively and I can save data correctly and load it without any problem.

Code: Select all

                              
  OPEN S,"DATA.TAB",0                   
                                        
  Ready                                                            
  PUT 0,10                              
                                        
  Ready                                 
  CLOSE                                 
                                        
  Ready                                 
  OPEN S,"DATA.TAB",0                   
                                        
  Ready                                 
  TAKE 0,A                              
                                        
  Ready                                 
  PRINT A                               
   10                                   
                                        
  Ready
It's the program that creates this error.

Re: STORE/RECALL for SEDORIC

Posted: Fri Apr 25, 2014 6:17 pm
by Dbug
I would help if I had any idea of how this whole thing work :)
Back in the days already I did not like STORE/RECALL on tapes!

Do you really need BASIC type arrays, can't you just use memory buffers and use PEEK/DEEK/POKE/DOKE to access data?

Re: STORE/RECALL for SEDORIC

Posted: Fri Apr 25, 2014 6:23 pm
by Hialmar
It would be the best solution indeed but we would need to rewrite the whole programs...

Anyway, Danymou on the CEO forum found out that we apparently need to open the file at the beginning of the program.

Edit: I changed the explanation. Zodiac said that this is because the Sedoric allocates a buffer for IO and this must be done before declarations of other variables.

Here are the modified programs (save and load) in case it's useful for someone else:

Code: Select all

   1 PRINT "CRETAB"                     
   5 OPEN S,"DATA.DAT",0                
   10 DIM A%(10,10)                     
   15 DIM B%(25)                        
   20 FOR I=0 TO 10                     
   25 FOR J=0 TO 10                     
   30 A%(I,J)=I*J                       
   40 NEXT J,I                          
   60 FOR I=0 TO 25                     
   70 B%(I)=16                          
   75 NEXT                              
   85 WAIT 100                          
   90 PUT 0,10                          
   100 PUT 0,10                         
   110 FOR I=0 TO 10                    
   120 FOR J=0 TO 10                    
   130 PUT 0,A%(I,J)                    
   140 NEXT J,I                         
   150 CLOSE 0                          

Code: Select all

                                   
   1 PRINT "LOATAB"                     
   5 OPEN S,"DATA.DAT",0                
   10 DIM A%(10,10)                     
   15 DIM B%(25)                        
   90 TAKE 0,A                          
   100 TAKE 0,B                         
   110 FOR I=0 TO A                     
   120 FOR J=0 TO B                     
   130 TAKE 0,A%(I,J)                   
   135 PRINT A%(I,J)                    
   140 NEXT J,I                         
   150 CLOSE 0