Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Rollum78 on December 03, 2012, 05:03:43 pm
-
I want to copy the frontbuffer to a OS Pic-variable, like this:
:If GetCalc("Pic1",768)->P
:Copy(L6,P,768)
:Else
:random stuff
:End
But let's say i have a variable V (from 0 - 9) and want to get a pointer to "PicV"...
How would i do that?
Edit: So that for example the user can pick the picture to copy the frontbuffer to
-
hm hang on I have the code somewhere let me find it
found it
use
[Pic1]->Pic1
instead of GetCalc
-
hm hang on I have the code somewhere let me find it
found it
[Pic1]->Pic1
wouldn't that just "absorb" Pic1 into my program?
-
do you mean display it on the screen?
no this will copy the calculators Pic1 into the Pic1 that axe uses ex: for a sprite
-
I think he means an arbitrary picture, not a specific one. I am not sure if there is Axe code for that, but this should work:
<<shtuff>>
V
Asm(652E60227984AF327B84D7EB2323
→P
That should store a pointer to the picture data. That code assumes that the picture exists and is in RAM, by the way.
-
No, this code works with ones that you create outside axe ex: ones you use in ti-basic
-
Annoyingcalc he wants to *store* to the picture variable not read from it
-
If you're not compiling your code as an application, I would do it like this:
:.Put this near the top of the program, and then just use PicN as the variable to hold the picture number in your program
:[0760]->°Pic
:[0000]->°PicN
:
:.The actual code
:If GetCalc(°Pic,768)->P
:Copy(L6,P,768)
:Else
:.Random stuff
:End
If you are compiling your code as an application, it's slightly trickier because you cannot modify internal data, which is what the PicN variable was. So we have to move the name of the picture outside of our code and into static RAM somewhere. We can do this by changing how our name buffer is defined, like this:
:.Put this near the top of the program, and then just use PicN as the variable to hold the picture number in your program
:.You can replace L2 with any free static RAM location for 4 bytes of storage
:L2->°Pic+2->°PicN
:ᴇ6007->Pic
-
Sorry, but i didn't really get that... :)
What do these lines of code do?
:[0760]->°Pic
:[0000]->°PicN
And is "Pic" a token?
-
Hmm, isn't there an easy-ish way to do that in Axe? This code will automatically create the appvar or unarchive it if it doesn't exist or is archived:
V
Asm(652E60227984AF327B84D73005EF3343180778B72803EFD84FEB2323
Note that this will create any of the 246 hacked pics as well and V=0 creates Pic1, V=1 creates Pic2, ... V=9 creates Pic0. It also creates the pics with 756 bytes (not 768). If you specifically want 768 you can do that, but the OS normally only does 756 (the first 63 rows of pixels make 756 bytes).
EDIT: Super ninja'd while I was testing code XD
-
Oh, perhaps I should explain a bit more. :P
Firstly, °Pic and °PicN are user-defined constants, so they're not tokens, just some letters put together. You could call them whatever you wanted, but those names seemed logical to me. The square brackets contain hexadecimal data that is added to the program; [0760] followed by [0000] is really the same data as "Pic1" as you might use in a GetCalc() statement, so °Pic is our pointer to the picture name. The reason I broke the more readable "Pic1" into two parts, however, is because the 3rd byte in the name of a picture variable determines which picture number it is. So °PicN is a pointer to this byte in the picture name, and simply storing to the PicN variable will change it, like 1->PicN.
One thing I forgot to mention, though, is that picture variables in the OS are ordered a little strangely. Internally, pictures 1-9 are really represented as 0-8, and picture 0 is really represented as 9. Thankfully this conversion is fairly easy. Depending upon which direction you're going, it's the value plus or minus 1, mod 10.
-
Thank you very much, this is exactly what was looking for :)
-
You could also use this code:
getCalc("Pic1",756)->A (or any other pointer, Pic1 is the token)
copy(L6,A,756)
Afaik that works too. Though it overwrites whatever is in Pic1.
Correct me if I'm wrong...
-
Yes, that should work... But i would only get a pointer to Pic1 and not based on a variable, for example the user's input
-
Oh I didn't know that :p In that case, never mind. Go with Runer's thing.
-
Runer, (i didn't want to post a new topic cause it's a little bit the same) , so i want to do this: in my prog i copy GDBXXXXX (or GDBX , GDBXX , GDBXXX , GDBXXXX) to L1, where the X's are the level's name, so how could i do this? so in example: the var X = 1 (level 1) then it copys GDB1 to L1, if the level = 2 , it copys GDB2 to L1
-
Runer, (i didn't want to post a new topic cause it's a little bit the same) , so i want to do this: in my prog i copy GDBXXXXX (or GDBX , GDBXX , GDBXXX , GDBXXXX) to L1, where the X's are the level's name, so how could i do this? so in example: the var X = 1 (level 1) then it copys GDB1 to L1, if the level = 2 , it copys GDB2 to L1
What are the sizes of your levels data (the data located in GDBXXX) ? Are they all the same size ?
-
Runer, (i didn't want to post a new topic cause it's a little bit the same) , so i want to do this: in my prog i copy GDBXXXXX (or GDBX , GDBXX , GDBXXX , GDBXXXX) to L1, where the X's are the level's name, so how could i do this? so in example: the var X = 1 (level 1) then it copys GDB1 to L1, if the level = 2 , it copys GDB2 to L1
What are the sizes of your levels data (the data located in GDBXXX) ? Are they all the same size ?
Yes they are, all levels are 8*12
-
And are they all right after each other ? I mean, like that:
[96 bytes for level1]→GDB1LVL1
[96 bytes for level2]→GDB1LVL2
etc
-
Yes
Oooooh wait i know where it's getting to, i would have to do: {X*96 + GDB1LVL1}
ok, didn't think of that, thx ;)
-
Yes
Oooooh wait i know where it's getting to, i would have to do: {X*96 + GDB1LVL1}
ok, didn't think of that, thx ;)
Wait, you said {X*96+GDB1LVL1} so I guess you are going to make a for loop like that:
For(r1,0,95)
{X*96+r1+GDB1LVL1}→{r1+L1}
End
Just to tell you that Copy(X*96+GDB1LVL1,L1,96) is more optimized ;)
-
Hayleia, that's what i meant but i just was to lazy to post the copy and L1, i'll be less lazy next time xD
-
Hayleya, that's what i meant but i just was to lazy to post the copy and L1, i'll be less lazy next time xD
Ok, but try not to misspell my name next time :P
-
What misspell? xDDDDDDDD