01 April 2016, 21:32 | #1 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Speedup Loading?
Any of you AMOS brainboxes any ideas how to speed this up please?
I tried using Line Input#1,AM$(INDEX) However there is a 1000 character limit for that command and some of my elements can be way larger. CODE:- Open In 1,FILE$ Rem *** Read in tilemap *** For I=0 To 239 A$=(Input$(1,1)) Poke Start(8)+I,Asc(A$) Next I Rem *** Null all elements of AM$ (not really needed) *** For I=0 To 16 AM$(I)="" Next I Rem *** NEED to speed up this bit cos it's slooooow! *** INDEX=0 Do A$=Input$(1,1) If A$=Chr$(13) A$=Input$(1,1) Inc INDEX If INDEX=17 : Goto OUT : End If AM$(INDEX)="" Else AM$(INDEX)=AM$(INDEX)+A$ End If Loop OUT: Close 1 TIA V1 |
02 April 2016, 10:35 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,213
|
Scanning for a sentinel character is always slow. If you know the length in advance, that's always faster.
|
02 April 2016, 17:24 | #3 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
I agree with Samurai Crow. If the lengths of the fields are known, you could add a byte (or word) value prior to each text field in the file specifying the length of the following string, thus speeding things up immensely as you can use this to jump to the next string length value in the file.
To avoid the Line Input# issue, why not load the file in as an AMOS data bank? |
02 April 2016, 20:28 | #4 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Unfortunately the length of each element is wildly variable from 0 to 1500+characters.
that is why I didn't go down the BLOAD route because the bank would have to be quite large "just in case" or re allocating could cause memory frag problems, but I'll look into it anyway. Thanks guys |
03 April 2016, 05:57 | #5 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,213
|
Don't forget you can check the length of a file with the Lof function and allocate the exact bank size needed even if you keep your existing file format.
|
08 April 2016, 22:39 | #6 | |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Quote:
Anyway, I've (kinda) worked around it with a "Loading" screen which I may add DOESN'T say "Please Wait" (I hate that LOL). So thanks for your ideas guys Next Question :- Is it possible to FORCE uppercase or lowercase in Amos inputs? Obviously you can use upper$ etc, but that doesn't solve the problem of how your input is echoed to the screen on input. |
|
09 April 2016, 10:38 | #7 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,213
|
You'll have to write a custom input routine to do that. I wrote one for 8 bit Apple back in high school. It is easy using the Inkey$ function in AmosPro.
|
09 April 2016, 11:20 | #8 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
An alternative to using Inkey$ would be Input$(1). Unlike with Inkey$, AMOS won't continue through the code until a key has been pressed to satisfy the Input$(1).
|
09 April 2016, 12:46 | #9 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,213
|
The reason I did the input routine for the Apple 2 was a custom cursor that needed refreshing.
|
09 April 2016, 17:05 | #10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,362
|
Why don't you implement your format like the IFF format, where each segment to be loaded is preceded by its size? That way you can set up your loading loop to work really fast.
|
09 April 2016, 22:43 | #11 | ||
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Quote:
Quote:
I'm a bit of a space saver if possible, and I don't think it REALLY matters in the age of mass storage, however the simplest routines are usually the most efficiant. Thanks guys |
||
09 April 2016, 22:50 | #12 | |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Quote:
Lazyness (again) on my part I guess, but it means re-writing 2 save & load routines in this particular case. I could have just loaded into banks & peek'd it out again, but I hate wasting space either in mem or on disk. |
|
23 April 2016, 21:08 | #13 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
OK
Finally got around to a small re-write, and the results of just peeking out the 2 byte length of each string element is astounding, cutting loading time by about 3/4 . Thanks for the help guys |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is there a way to Speedup Mouse ? | Nibbler | project.WHDLoad | 11 | 09 November 2021 00:57 |
A2091ToFast: Even more A2091/A590 speedup possible! | SpeedGeek | Coders. System | 8 | 24 July 2015 14:47 |
SuperBuster Zorro2 Speedup Mod | SpeedGeek | Hardware mods | 12 | 17 September 2011 03:05 |
VOB speedup-system adapter | Boot_WB | support.Hardware | 5 | 18 April 2006 10:53 |
|
|