Author Topic: A little help  (Read 25342 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: A little help
« Reply #45 on: April 08, 2010, 12:31:05 am »
First, @meishe91, I'm flattered that you cited me as a reference.
Second, a pointer is a value that points to an offset in memory.  For instance, a pointer with a value of 10 points to the 10th byte (actually, it points to the 11th byte because it is zero-indexed, but lets say that it points to the 10th byte for now).  If that place in memory contains code, you can use a pointer to say, "execute this code."  If that place contains data, then you can say, "look at this data."  Code and data look the same in memory, the only difference being that executing data may accidently in your RAM.
Third, here is how applys to Axe, for methods and code:
Code: (Axe Basic) [Select]
ClrHome
sub(SH
Return
Lbl SH
Disp "Hello World!"
When Axe compiles, it saves the location of Lbl SH in the first run.  By location, I mean that it saves offset from the beginning.  So, if SH comes 10 bytes from the beginning, it remembers that SH is 10 bytes from the beginning.
The, it hits the "sub(SH" line.  It says to itself, "hey, I know where that is!  It's 10 bytes from the beginning!"  So, it tells the output program to jump to 10 bytes from the beginning, and come back when it's finished.

With storing data, it works the same way.  If you have:
Code: (Axe Basic) [Select]
[0102030405060708->Pic1
Pt-On(0,0,Pic1
Axe remembers that Pic1 points somewhere, and then supplys that location to the Pt-On command.

Questions?

On that, no. I think I can do that. My difficulty arises when I want to say... take Pic1 (above) and place it in an AppVar for use by the program in subsequent run. What I'm essentially inquiring about is the conversion from appvar to pointer and back again, without screwing up the data.

And, do all values for pointers have to be in hex?

SirCmpwn

  • Guest
Re: A little help
« Reply #46 on: April 08, 2010, 12:42:33 am »
And, do all values for pointers have to be in hex?
No, but it really doesn't make sense to do it any other way, based on the layout and structure of the memory, among other things.

And for the pointer->AppVar thing, I haven't played with it too much, but I will do so and post instructions tomorrow.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: A little help
« Reply #47 on: April 08, 2010, 12:49:20 am »
ok. thanks. Your instructions just got my program completion from 2% to 35% within 10 minutes.

Now, I just want to double check something. Within the program, I will be using regular variables A through O, minus G, which I reserve for getKey stuff. So when I store those variables to an array, I can do

Code: [Select]
A->{LX}
B->{LX+1}
C->{LX+2}
...and so on

even if one or two of the variables max out at 1000, correct?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A little help
« Reply #48 on: April 08, 2010, 12:55:27 am »
And, do all values for pointers have to be in hex?
No, but it really doesn't make sense to do it any other way, based on the layout and structure of the memory, among other things.

it can be easier to read in some cases, right, tho?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

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: A little help
« Reply #49 on: April 08, 2010, 01:24:07 am »
No!  The single bytes max out at 255 (or 127 if you're storing as positive and negative numbers instead of just positive).  To store larger numbers, they will have to take up 2 bytes.  Doubles give you up to 65535.

It makes the data storage a little tricky though since you have to remember that offsets with 2 byte variables is an offset by 2 for each variable.  You tell the parser to store 2 bytes by adding a r after the brackets.

So lets say A,B,and D are 2 byte variables and C and E are 1 byte.  You can store them like this:
A->{L1}r
B->{L1+2}r      B has to be 2 bytes after A
C->{L1+4}       C has to be 2 bytes after B
D->{L1+5}r      D is only 1 byte after C
E->{L1+7}       etc.

Notice how you have to leave enough room for each variable.  Usually, this can get pretty confusing to index the array if you mix 1 and 2 byte variables.  In that case, its sometimes a good idea to just make them all 2 byte variables just for convenience.

Quote
Well ya, he is the one developing Axe but I don't think he has been working with it in programming nearly as much as some other guys have
This is so true!  I haven't really had a lot of time to actually fool around with the language myself since I'm constantly spending that time on new features.  I bet all those people you mentioned have used it more than I have hours wise.  I'll let you in on a secret though.  My ultimate goal is to make the game "Frog Flap" for the calculator complete with music, grayscale, and saving.  That will be my final project when the final version comes out.  It's another minigame from warioware btw.
« Last Edit: April 08, 2010, 01:25:02 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: A little help
« Reply #50 on: April 08, 2010, 01:36:38 am »
That's a bummer you don't get to mess around with it that much. I bet everyone would understand if you wanted to take a few day or a week off to mess around some :) But that's cool about the upcoming project you plan to get done, sounds interesting.
Spoiler For Spoiler:



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

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: A little help
« Reply #51 on: April 08, 2010, 01:44:31 am »
Thanks Quigbo. So essentially, I'm doing what I did in my old Microsoft Word Simulator to store cursor location in ten files:

List size 2
File to recall: Doc3

So I'm pointing to term 5 for cursor Y and term 6 for X, except that Y is the first byte and X is the second. ok

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: A little help
« Reply #52 on: April 08, 2010, 01:53:21 am »
By the way, there is also the copy command which is conj().  You can use it to copy large blocks of data.  You would especially use it to save and load from appvars.  Lets say you want to save the entire graph buffer to an appvar.  Obviously you wouldn't want to store one element at a time and even a for loop would be slow and cumbersome.

conj copies however many consecutive bytes you want from one location to another.  So to copy all 768 bytes of the graph buffer to the appvar (lets say the pointer for that is in A) then you would do this:

conj(L6,A,768)

Since L6 is the graph buffer.  First argument is source, second is destination, and third is how many bytes.  Also you can load a saved screen from the appvar back into the buffer the same way:

conj(A,L6,768)
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A little help
« Reply #53 on: April 08, 2010, 02:35:13 am »
I'll let you in on a secret though.  My ultimate goal is to make the game "Frog Flap" for the calculator complete with music, grayscale, and saving.  That will be my final project when the final version comes out.  It's another minigame from warioware btw.
:O nice ^^

But by final I hope you don't mean once Axe and Frog Flap are finished that you are quitting calc programming and the community completly? :O
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: A little help
« Reply #54 on: April 08, 2010, 02:36:07 am »
So its conj(LX,POKE,27) (LX is a 14 slot array, each slot carrying 2 bytes, for a total of 27) to save to the appvar and conj(POKE,LX,27) to load back.

*L  in LX is actually the 'list' token.


And, Axe is throwing me a Bad Symbol when compiling, but I'll deal with that tomorrow. I need sleep now.
« Last Edit: April 08, 2010, 02:36:57 am by ACagliano »

SirCmpwn

  • Guest
Re: A little help
« Reply #55 on: April 08, 2010, 08:48:38 am »
No, after looking at the documentation, it appears to be done a different way (I have not tested this myself).
First of all, I can tell you that "LX" will not work.  You can only use L1-L6, and all those are is places in the RAM.  You don't actually modify user lists.
Now, assuming that you have all of your data in L1, this is how you would save it to the AppVar POKE:
Code: [Select]
Select(POKE)    // Select the AppVar POKE
Unarchive POKE  // Unarchive it if it already exists
GetCalc(27)->A  // Create/Overwrite an AppVar 27 bytes in size
conj(L1,A,27)  // Copy L1 to the AppVar

And to read from it:
Code: [Select]
Select(POKE)  // Select it
Unarchive POKE  // Unarchive it if it exists
GetCalc()->A  // Get a pointer to it
!If A
// It doesn't exist
Else
conj(A,L1,27)  // Load the data to L1
End

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: A little help
« Reply #56 on: April 08, 2010, 09:15:16 am »
Ok. Now the parser is giving me Err: Duplicate in pass 2. What's going on? What does that mean?
« Last Edit: April 08, 2010, 01:57:31 pm by ACagliano »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: A little help
« Reply #57 on: April 08, 2010, 02:23:31 pm »
No, after looking at the documentation, it appears to be done a different way (I have not tested this myself).
First of all, I can tell you that "LX" will not work.  You can only use L1-L6, and all those are is places in the RAM.  You don't actually modify user lists.
Now, assuming that you have all of your data in L1, this is how you would save it to the AppVar POKE:
Code: [Select]
Select(POKE)    // Select the AppVar POKE
Unarchive POKE  // Unarchive it if it already exists
GetCalc(27)->A  // Create/Overwrite an AppVar 27 bytes in size
conj(L1,A,27)  // Copy L1 to the AppVar

And to read from it:
Code: [Select]
Select(POKE)  // Select it
Unarchive POKE  // Unarchive it if it exists
GetCalc()->A  // Get a pointer to it
!If A
// It doesn't exist
Else
conj(A,L1,27)  // Load the data to L1
End

That's not how you use the file commands. You will need to do this:
Code: [Select]
"POKE->Str1
Select(Str1)    // Select the AppVar POKE
If GetCalc(27)->A  // Create/Overwrite an AppVar 27 bytes in size
conj(L1,A,27)  // Copy L1 to the AppVar
Else
// Not enough memory
End
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A little help
« Reply #58 on: April 08, 2010, 05:42:15 pm »
mhmm thanks for posting this, it might be helpful for me. Keep in mind Quigibo said those command syntax will change, tho (the new ones, that is), but it still makes things more clear for me now. :)
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

SirCmpwn

  • Guest
Re: A little help
« Reply #59 on: April 08, 2010, 06:54:41 pm »
Thanks for clarifying, calc84maniac.
Also, you should be aware that you can use 8 digit mixed-case names for AppVars, so you *can* call your AppVar "Pokemon"