Author Topic: Can I use the FreeRam pointers as static variables?  (Read 8401 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
Can I use the FreeRam pointers as static variables?
« on: July 29, 2010, 06:57:14 pm »
I initially designed Star Trek with one static variable storing every thing that needed to stored. Then I ran into one small problem...I ran out of static variables. With some functions left to be assigned a variable.

My question is simple. Can I store the same data to {L1}, then read from it and write to it while the program is running, in the same way as you would read from and write to a static variable?

And, also, what is the maximum 1 byte number? 2 byte? I was told before, but forgot.

Thanks.

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Can I use the FreeRam pointers as static variables?
« Reply #1 on: July 29, 2010, 07:22:37 pm »
The anwer to your question is: yes, you can, since it's just the same kind of memory the other static vars are stored in.
The difference is that the pointers L1-L6 are used for some other things, like the back buffer (L3) and the buffer (L6), the textShadow in L5 for example. This is all included in the Documentation.

a single byte can hold a value between 0 and 255 (2^8)
a double byte can hold a value between 0 and 65535 (2^16)
with the ^ symbol I mean the power symbol, not the modular symbol as in Axe

hope this helps
« Last Edit: July 29, 2010, 07:26:25 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 ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Can I use the FreeRam pointers as static variables?
« Reply #2 on: July 29, 2010, 08:06:13 pm »
thank you much. i am relieved to hear that i can indeed use {L1}.

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Can I use the FreeRam pointers as static variables?
« Reply #3 on: July 29, 2010, 08:51:27 pm »
yes, and whenever you want some more space, you could also create an Appvar and use it as a pointer like L1 to store data, like this:
Code: [Select]
.A
"appvPTR"->Str11
GetCalc(Str11,32)->{L1}r
[3C3C66C3C3663C3C]->Pic01
Copy(Pic01,{L1}r,8)
« Last Edit: August 06, 2010, 03:41:16 am 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 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: Can I use the FreeRam pointers as static variables?
« Reply #4 on: July 29, 2010, 08:53:06 pm »
In fact you should ONLY use free ram to hold your variables and arrays (unless you run out or need larger dimensions) since using static pointers are just a form of self-modifying code and therefore adds extra size to the program.  Your program wouldn't be compatible as an app either if it uses SMC.

EDIT: Also LordConiupiter, you need the r modifier there since you're holding a 2 byte number.
« Last Edit: July 29, 2010, 08:55:21 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Can I use the FreeRam pointers as static variables?
« Reply #5 on: August 06, 2010, 02:23:15 am »
I was just looking at the Axe Parser category and part of this topic's name caught my eye: "static variables" ;D

Hehehe *chuckling to self*
« Last Edit: August 06, 2010, 02:23:39 am by Runer112 »

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: Can I use the FreeRam pointers as static variables?
« Reply #6 on: August 06, 2010, 02:56:57 am »
They have that in C++ too since you can define variables as "const" and then you have a static variable ;)
___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: Can I use the FreeRam pointers as static variables?
« Reply #7 on: August 06, 2010, 03:40:36 am »
In fact you should ONLY use free ram to hold your variables and arrays (unless you run out or need larger dimensions) since using static pointers are just a form of self-modifying code and therefore adds extra size to the program.  Your program wouldn't be compatible as an app either if it uses SMC.

EDIT: Also LordConiupiter, you need the r modifier there since you're holding a 2 byte number.
o yes, forgot about that. fixed 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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Can I use the FreeRam pointers as static variables?
« Reply #8 on: August 08, 2010, 03:33:21 pm »
You can also use L2 through L6, but be advised that they can cause some issues. Example, for L2, you cannot use it if you also use Interrupts. I believe there were MirageOS interrupts issues as well, but I don,t remember if it was fixed. In L3 case, this contains the backbuffer content. Only use this if you don't need the backbuffer, otherwise when recalling it it will have garbage. Same for L6, but L6 is the main buffer, not the back buffer. As for L4 and L5, one of them prevents you from using Archive/Unarchive and the other one prevents you from using the Homescreen, if I recall correctly. Basically, think before using them, but if you can use them, they can be pretty handy.

L1 can also be used as a screen buffer, I believe, but it will miss some rows of pixels at the bottom since it's not 768 bytes.