Author Topic: The most efficient way to store and recall lots of text  (Read 4341 times)

0 Members and 1 Guest are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
The most efficient way to store and recall lots of text
« on: September 15, 2010, 09:06:46 pm »
Yeah... what the title says.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: The most efficient way to store and recall lots of text
« Reply #1 on: September 15, 2010, 09:11:29 pm »
I mostly use the following system to store any kind of data with variable lengths to an AppVar:
first byte: number of datablocks in the AppVar
foreach datablock: one word/ two bytes: offset, relative to the start of the AppVar
foreach datablock: variable amount of bytes: the data at the position pointed to by the offset word.

but i think the most efficient way to do it when you have left over enough room in your program, to store it in your program.
« Last Edit: September 15, 2010, 09:13:28 pm by LordConiupiter »
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: The most efficient way to store and recall lots of text
« Reply #2 on: September 15, 2010, 09:18:05 pm »
I'm trying to save all of the text in my game to one string.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: The most efficient way to store and recall lots of text
« Reply #3 on: September 15, 2010, 09:20:48 pm »
If you mean memory efficient, you might want to try some kind of compression by using a reduced character set.  26 uppercase, 26 lowercase, 10 numbers, a space, and a 'special character' is 64 possibilities (6 bits) which means you can store 4 characters in only 3 bytes.  'special character' (which is the binary combination 000000) would look at the next character which could be one of 64 special characters like a period, exclamation mark, parenthesis, question mark, apostrophe, and most importantly the end-of-line character.  That makes all your text data about 20% smaller.

Another strategy is to chose 255 of the most used words and have a list of these "common words" to form a sentence with the unused combination representing that you will spell out the word instead.  That can lead to reduction of over 50% for large text files.

Either way, you'll have to make a decoder/encoder to actually use them in your programs.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: The most efficient way to store and recall lots of text
« Reply #4 on: September 15, 2010, 09:22:53 pm »
well, you could do it the way KermM does it, like described here: http://ourl.ca/7036/117479.
i prefer the way I would do it, cuz else I wouldn't have invented it :)
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: The most efficient way to store and recall lots of text
« Reply #5 on: September 15, 2010, 09:24:18 pm »
Hmmm, well you could store it all in one string then have a certain token that is at the beginning and end of a phrase then when a phrase is triggered it stores the number of the beginning character to whatever then use inString( to find the second one and then use sub( output the result. I don't know if that helps or even makes a lot of sense.

Oh, this is Axe. My bad :P Didn't even think to check.
« Last Edit: September 15, 2010, 09:25:13 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)