Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Rollum78 on December 03, 2012, 05:03:43 pm

Title: copy to Pic0 - Pic9
Post by: Rollum78 on December 03, 2012, 05:03:43 pm
I want to copy the frontbuffer to a OS Pic-variable, like this:
Code: [Select]
: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
Title: Re: copy to Pic0 - Pic9
Post by: annoyingcalc on December 03, 2012, 05:06:15 pm
hm hang on I have the code somewhere let me find it
found it
use
Code: [Select]
[Pic1]->Pic1
instead of GetCalc
Title: Re: copy to Pic0 - Pic9
Post by: Rollum78 on December 03, 2012, 05:09:15 pm
hm hang on I have the code somewhere let me find it
found it

Code: [Select]
[Pic1]->Pic1
wouldn't that just "absorb" Pic1 into my program?
Title: Re: copy to Pic0 - Pic9
Post by: annoyingcalc on December 03, 2012, 05:10:40 pm
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
Title: Re: copy to Pic0 - Pic9
Post by: Xeda112358 on December 03, 2012, 05:15:24 pm
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:
Code: [Select]
<<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.
Title: Re: copy to Pic0 - Pic9
Post by: annoyingcalc on December 03, 2012, 05:19:02 pm
No, this code works with ones that you create outside axe ex: ones you use in ti-basic
Title: Re: copy to Pic0 - Pic9
Post by: Builderboy on December 03, 2012, 05:21:01 pm
Annoyingcalc he wants to *store* to the picture variable not read from it
Title: Re: copy to Pic0 - Pic9
Post by: Runer112 on December 03, 2012, 05:25:28 pm
If you're not compiling your code as an application, I would do it like this:

Code: [Select]
:.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:

Code: [Select]
:.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
Title: Re: copy to Pic0 - Pic9
Post by: Rollum78 on December 03, 2012, 05:36:48 pm
Sorry, but i didn't really get that... :)
What do these lines of code do?
Code: [Select]
:[0760]->°Pic
:[0000]->°PicN
And is "Pic" a token?

Title: Re: copy to Pic0 - Pic9
Post by: Xeda112358 on December 03, 2012, 05:42:17 pm
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:
Code: [Select]
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
Title: Re: copy to Pic0 - Pic9
Post by: Runer112 on December 03, 2012, 05:49:54 pm
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.
Title: Re: copy to Pic0 - Pic9
Post by: Rollum78 on December 04, 2012, 12:01:13 pm
Thank you very much, this is exactly what was looking for :)
Title: Re: copy to Pic0 - Pic9
Post by: aeTIos on December 06, 2012, 07:07:58 am
You could also use this code:
Code: [Select]
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...
Title: Re: copy to Pic0 - Pic9
Post by: Rollum78 on December 06, 2012, 11:00:09 am
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
Title: Re: copy to Pic0 - Pic9
Post by: aeTIos on December 06, 2012, 11:03:31 am
Oh I didn't know that :p In that case, never mind. Go with Runer's thing.
Title: Re: copy to Pic0 - Pic9
Post by: stevon8ter on December 07, 2012, 08:34:33 am
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
Title: Re: copy to Pic0 - Pic9
Post by: Hayleia on December 07, 2012, 09:22:24 am
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 ?
Title: Re: copy to Pic0 - Pic9
Post by: stevon8ter on December 07, 2012, 09:24:56 am
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
Title: Re: copy to Pic0 - Pic9
Post by: Hayleia on December 07, 2012, 09:26:57 am
And are they all right after each other ? I mean, like that:

[96 bytes for level1]→GDB1LVL1
[96 bytes for level2]→GDB1LVL2
etc
Title: Re: copy to Pic0 - Pic9
Post by: stevon8ter on December 07, 2012, 09:29:05 am
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 ;)
Title: Re: copy to Pic0 - Pic9
Post by: Hayleia on December 07, 2012, 09:31:19 am
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 ;)
Title: Re: copy to Pic0 - Pic9
Post by: stevon8ter on December 07, 2012, 09:32:26 am
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
Title: Re: copy to Pic0 - Pic9
Post by: Hayleia on December 07, 2012, 09:33:42 am
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
Title: Re: copy to Pic0 - Pic9
Post by: stevon8ter on December 07, 2012, 09:38:21 am
What misspell? xDDDDDDDD