Author Topic: copy to Pic0 - Pic9  (Read 7942 times)

0 Members and 1 Guest are viewing this topic.

Offline Rollum78

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +5/-0
  • Sodium
    • View Profile
copy to Pic0 - Pic9
« 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
« Last Edit: December 03, 2012, 05:10:36 pm by Rollum78 »
Sachs'e nix mehr, hm?

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #1 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
« Last Edit: December 03, 2012, 05:08:09 pm by annoyingcalc »
This used to contain a signature.

Offline Rollum78

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +5/-0
  • Sodium
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #2 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?
Sachs'e nix mehr, hm?

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #3 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
This used to contain a signature.

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: copy to Pic0 - Pic9
« Reply #4 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.

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #5 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
This used to contain a signature.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #6 on: December 03, 2012, 05:21:01 pm »
Annoyingcalc he wants to *store* to the picture variable not read from it

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #7 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
« Last Edit: December 03, 2012, 05:27:51 pm by Runer112 »

Offline Rollum78

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +5/-0
  • Sodium
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #8 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?

Sachs'e nix mehr, hm?

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: copy to Pic0 - Pic9
« Reply #9 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

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #10 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.
« Last Edit: December 03, 2012, 05:52:13 pm by Runer112 »

Offline Rollum78

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +5/-0
  • Sodium
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #11 on: December 04, 2012, 12:01:13 pm »
Thank you very much, this is exactly what was looking for :)
Sachs'e nix mehr, hm?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: copy to Pic0 - Pic9
« Reply #12 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...
I'm not a nerd but I pretend:

Offline Rollum78

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +5/-0
  • Sodium
    • View Profile
Re: copy to Pic0 - Pic9
« Reply #13 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
Sachs'e nix mehr, hm?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: copy to Pic0 - Pic9
« Reply #14 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.
I'm not a nerd but I pretend: