Author Topic: Axe Q&A  (Read 571155 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Q&A
« Reply #1965 on: July 03, 2022, 08:09:09 pm »
That's assuming you have 8 bytes per row, but i think you might be mixing things up.

If you want 5 bytes per row (that's 40 bits total per row), you'd do  "{L1+(5*Y)+X}" where the 5 is how many bytes per row.

That's the code if you want a 5-by-5 array of 8-bit numbers

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1966 on: July 03, 2022, 08:16:38 pm »
I think I’m starting to understand instead of having variables I have data spaces that space out and hold data in binary just hypothetical  when should sombody want to use more dangerous storage like l3

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Q&A
« Reply #1967 on: July 03, 2022, 08:25:57 pm »
L3 is safe as long as you aren't using grayscale (Axe uses it like a second "graph screen")


L2 uses the same memory as the OS's "statistics variables" so that'll clear that data, but that's usually fine since anybody who needs it can very easily regenerate the data.


L4 gets overwritten when you archive/unarchive.


L5 is overwritten when you draw text on the homescreen


L6 is overwritten when you draw to the graph screen


Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1968 on: July 03, 2022, 08:28:00 pm »
Ok how many bits can I fit in l1

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Q&A
« Reply #1969 on: July 03, 2022, 08:30:39 pm »
L1 is 768 bytes, so 768*8 = 6144 bits.

For reference, I'm using https://axe.eeems.ca/Commands.html to look things up. Eeems (an admin) hosts that Axe reference sheet and it's really handy

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1970 on: July 03, 2022, 08:32:11 pm »
Than you so much I think I got it figured out (kinda) D:

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: Axe Q&A
« Reply #1971 on: July 05, 2022, 12:15:56 am »
Does Axe not allow you to manipulate more than one appvar at a time? I'm getting some really strange bugs when I do. I have 2 appvars that I create in RAM. One is the appvar for the current generated floor in my game. The second appvar is supposed to be another map that I am going to use in my AI calculation that I call DistMap. I running across several strange bugs with Axe when I do this. If I create both appvars at the same time, I am no longer able to manipulate the DistMap appvar if I do anything with the Floor appvar. In this case all I am trying to do is fill it with some value for now. If I instead create the DistMap appvar whenever I press a button (down in this case), the tilemap gets corrupted somehow. Or rather, it seems as if the 2 pointers are getting mixed up somehow. Because when I try to move down a bunch of corrupted tiles are scrolled in instead. Any ideas?

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1972 on: July 05, 2022, 09:57:35 pm »
Does Axe not allow you to manipulate more than one appvar at a time? I'm getting some really strange bugs when I do. I have 2 appvars that I create in RAM. One is the appvar for the current generated floor in my game. The second appvar is supposed to be another map that I am going to use in my AI calculation that I call DistMap. I running across several strange bugs with Axe when I do this. If I create both appvars at the same time, I am no longer able to manipulate the DistMap appvar if I do anything with the Floor appvar. In this case all I am trying to do is fill it with some value for now. If I instead create the DistMap appvar whenever I press a button (down in this case), the tilemap gets corrupted somehow. Or rather, it seems as if the 2 pointers are getting mixed up somehow. Because when I try to move down a bunch of corrupted tiles are scrolled in instead. Any ideas?

Some code to see exactly what is going on would be helpful. Here is a summary of what GetCalc( does which may be helpful.

Everything in ram is stored between 0x9D95 and the VAT which is at the top couple hundred bytes of memory. The VAT (Variable Allocation Table I believe) holds information about everything in RAM that isn't locked down to a fixed address. It also holds information on where archived stuff is in flash is but that doesn't matter for your problem. When you use GetCalc() to open an existing program/appvar/other that is in ram, what it is actually doing is going to the VAT to look up where in memory the file is and returning that pointer. Since the file is in memory, ti-os may move the file whenever needed. Any time you create or destroy a file, you should assume any pointers you got from GetCalc() are outdated and that you need to get them again. There are rules as to what moves when, but unless you are really, really hurting for speed, just do it anyway. I don't think that existing files move when you make a new one but it doesn't hurt to make sure. Resizing almost always moves stuff around.
Since each file is nothing but a reserved space in memory, simply reading/writing to it is no different than manipulating a normal area in memory. From your description of the problem my guess would be that you are resizing or creating and deleting appvars which causes them to move in memory and throws off your pointers. If you are, remember that creation/deletion/resizing can be slow because it likely has to copy kilobytes of memory around. That shouldn't cause slowdowns if you do it once or twice a second, but I would avoid it in a loop. I would suggest using existing memory areas before resorting to appvars. There is a lot of built in memory if you look. Take a look at this if you want to to beyond what Axe's L1-L6 give you. It is pretty outdated in where it says Axe's variables are located so ignore those. For example 0x8000 gives you 256 bytes of memory and as long as you don't turn your calc off, it is perfectly free to use. (although it overlaps somewhat with the 756 byte buffer L4-512)

Here are some other fun facts that probably won't help you but may be interesting:
Appvars and programs are the same thing (as far as I know) and they only differ by one byte which tells what they are.
Pretty much any name is legal for a program/appvar as long as you don't intend on interacting with it through ti-os. You can make and edit programs with lower case names. Axe will even allow you to include and compile programs with lowercase names just like normal ones. Ti-os won't let you run a program with a lowercase name but as long as you compile to an uppercase program you will be fine. When transferring these programs to and from a computer, the ti-connect will irritatingly capitalize all the names.
"prgm#" and "prgm!" are special programs that hold recently entered stuff on the home screen. I don't remember exactly what each one does, but they exist. I'm not 100% sure on their names but I'm pretty sure those are it.
When you run a program, it gets moved to 0x9D95 (0x9D93 is the 2-byte size of the program) and then executed. So if you want to run a program from within an app, you can copy it there and just :Goto E9D95. Since there could be appvars there already, you should use some calls that aren't part of standard Axe to move anything that is there out of the way.
I'm still around... kind of.

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: Axe Q&A
« Reply #1973 on: July 06, 2022, 02:22:00 am »
I'm starting to think that this is just an Axe bug. I'm never resizing or deleting or recreating, just editing them. I "fixed" the problem by calling GetCalc again before I manipulate the appvar. I have another issue. It seems that signed comparison or signed operations don't seem to work.
I have a line of code that looks like this:
Code: [Select]
~8->{°MobOX+Mob}Later on I call a function that looks like this:
Code: [Select]
Lbl AnimateMob
For(I,0,Mobs-1)
°MobArray+(I*4)->Mob
If {°MobOX+Mob}>>0
{°MobOX+Mob}--
End
If {°MobOX+Mob}<<0
{°MobOX+Mob}+1->{°MobOX+Mob}
End
If {°MobOY+Mob}>>0
{°MobOY+Mob}--
End
If {°MobOY+Mob}<<0
{°MobOY+Mob}+1->{°MobOY+Mob}
End
End
Return
However, despite being a signed comparison, it still treats {°MobOX+Mob} as some large number and decrements it instead. I've used the sign{} command but that only breaks it further. How do I do this? It's starting to feel like I really have to fight the language to do simple things. I've hand calculated the offsets so nothing is off there when I draw. It is literally not working with negative numbers. I've subtracted 8 instead, I've changed the comparison from signed to unsigned. I'm really at a loss here. Please help!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Q&A
« Reply #1974 on: July 06, 2022, 07:13:13 am »
This
Code: [Select]
-8→{°MobOX+Mob}Is storing -8 as an 8-bit number.

At first, -8 is a 16-bit number stored as 65536-8 = 65528. That's works when your arithmetic is 16-bit. But when you store it as an 8-bit number, you lose the top 8 bits and it is stored as 256-8 = 248 instead.

Now when you read it, Axe has no idea that it used to be a signed 16-bit number, it's reading an 8-bit value that is 248 and in 16-bit, that's a positive number.

So what you need is to sign-extend the number where you copy the sign bit [top bit] of the 8-bit number into the top 8 bits of the 16-bit number. Luckily, Axe has a command for that: signed{<ptr>}

So whenever you are reading an 8-bit number and you want to tell Axe to interpret it as a signed number, you need to explicitly tell it.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Axe Q&A
« Reply #1975 on: July 06, 2022, 08:57:31 am »
Your issue with GetCalc isn't an Axe bug. I have worked with 6+ appvars at once and had no trouble. Since all Axe is doing with GetCalc is asking the os for a pointer, it would be a ti-os bug and I very much doubt that ti-os would have such a problem. If you post your code I may be able to find what the problem was.
I'm still around... kind of.

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1976 on: July 09, 2022, 02:06:01 pm »
This is probably the last question for a while. How can I make and used Latin named variables? Also why does it seem like everyone knows all about this stuff but I’m just behind?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Q&A
« Reply #1977 on: July 09, 2022, 07:55:30 pm »
I'm not sure what you mean, could you give an example of what you want to do?

As for Axe knowledge, I think I started using Axe around 11 years ago, so it's just experience. I've never been a heavy user of Axe since I was comfortable as an assembly programmer by the time I learned about it, but I know enough to make simple programs :) (Axe can get very convoluted in the hands of a pro.)

Offline ferbplatypult

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 15
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #1978 on: July 09, 2022, 08:13:26 pm »
I didnt mean Latin but custom, like EMNX for enemy x rather than j, I see people share code with long named variables and degrees symbols and was wondering what that was.
« Last Edit: July 09, 2022, 08:25:46 pm by ferbplatypult »

Offline Ki1o

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 119
  • Rating: +5/-2
  • Doing my best...
    • View Profile
Re: Axe Q&A
« Reply #1979 on: July 09, 2022, 08:45:39 pm »
Hey there! If you are talking about custom named variables, what you can do is take a memory location and give it a name using the degree symbol like so:
Code: [Select]
L1+00->->°MyVarThen you can use it as a variable in any way like so:
Code: [Select]
42->MyVarAny custom variable you create will always be 2 bytes in size.
If you use this for any other value that is not a memory location, it is basically a named constant that you can use in place of that number. It serves no purpose outside of improving readability, but it is helpful.
When using named constants you must include the degree symbol. This is not the case when using a custom variable.
There are a few additional rules for naming anything in Axe. They must begin with a capital letter and they cannot be more than 13 characters long. They must also only contain letters or numbers. Hope this helps.
« Last Edit: July 09, 2022, 08:49:19 pm by Ki1o »