Author Topic: Zeros(36)->{L1}  (Read 8712 times)

0 Members and 1 Guest are viewing this topic.

Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Zeros(36)->{L1}
« on: July 03, 2011, 11:11:33 am »
Hi!  :D

I've another problem: I store my data in L1
I tried to store zeros in it:
Code: [Select]
Zeros(36)->{L1}but it only stores zero in {L1+0}, but not in {L1+1}, {L1+2}, ... , {L1+36} :-\
My walkaround is:
Code: [Select]
For(X,0,36)
0->{L1+X}
End

Question: is there a better solution??

Thanks for your help!  ;)
« Last Edit: July 03, 2011, 01:47:37 pm by GreenFreak »

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Zeros(36)->{L1}
« Reply #1 on: July 03, 2011, 11:25:40 am »
Fill() should work. If I'm not mistaken, this would be the correct code:
Code: [Select]
Fill(0->{L1},36)


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Zeros(36)->{L1}
« Reply #2 on: July 03, 2011, 11:30:22 am »
Code: [Select]
0->{L1}
Fill(L1,35)
That should work.  It may be 36, though, I'm not to sure on that.  I'm pretty sure it's 35, though.

Zeros(36) stores 36 bytes of zero in the program and then whatever you store it to is a pointer to that.  So Zeros(36)->A would cause A to point to the first byte of that section of 36 zeros in your program.

Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Re: Zeros(36)->{L1}
« Reply #3 on: July 03, 2011, 11:39:09 am »
Aaaahh!
Thanks for the very fast answer ;)
Code: [Select]
0->{L1}
Fill(L1,35)
works fine ;)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Zeros(36)->{L1}
« Reply #4 on: July 03, 2011, 11:51:54 am »
I know I've been majorly ninja'd and you already have a working solution, but I'll post this anyways. I tried to go a lot more in depth of explaining how objects and data work in Axe, and how to properly manipulate them.



An important thing to remember about Axe is that the only data type it directly operates on is a 16-bit integer. In languages like TI-BASIC, something like :"HELLO" actually makes the last entry that string. However, in Axe, :"HELLO" will make the last entry a pointer to that string, which is stored inside of your program. This is because it cannot fit the whole string into its 16-bit data type, so it instead stores a 16-bit reference that tells where the real string is stored.


This means a few things. Most importantly for you, it means that Zeros(36)→{L₁} isn't actually storing the 36-byte object to {L₁}, it's storing a pointer to the object to {L₁}. And because there is no 2-byte r modifier after the closing brace, it's actually only storing the low byte (8 bits) of the pointer to {L₁}. But this is relatively unimportant, since either 8 or 16 bits of the pointer is not what you want.


Because using to store objects doesn't cut it, we want to use some commands specific to blocks of data. If you wanted to put a block of data at L₁, you would first need to define the data in your program. Then, you can move that data from your program to L₁ using the Copy() command. This is found under MATH ► CPX ► 1. Here is how you would create 36 bytes of zeros in your program and then move them to L₁:

Code: (Data copying method) [Select]
Zeros(36)→GDB0Z      .Add 36 bytes of zeros to the program and store a pointer to it in GDB0Z
Copy(GDB0Z,L₁,36)    .Copy 36 bytes of data starting at GDB0Z to L1


In most circumstances when you want to move data to an external location, the code above is the way to go. However, when you want to fill a location with one value, there's a slightly better way to go: the Fill() command. This is found under LIST ► OPS ► 4.You feed this a pointer and a size, and then it copies the byte pointed to ahead [size] times. Take note that because it copies the already existing byte [size] times, you'll be left with [size]+1 bytes. So as graphmastur posted, you would want to do this:

Code: (Data filling method) [Select]
0→{L₁}         .Give the fill a seed value of 0 to copy forwards
Fill(L₁,35)    .Copy the value pointed to by L₁ (which is 0) ahead for 35 bytes


Finally, the optimized code! :evillaugh: It uses some tricks that I've picked up from extensive experience with Axe and is 2 bytes smaller and a tiny bit faster. You don't need to know these tricks, but after enough practice with Axe you may pick up such tricks on your own.

Code: (Optimized data filling method) [Select]
and 0→{L₁}ʳ    .Give the fill a seed value of 0 to copy forwards
Fill(L₁,35)    .Copy the value pointed to by L₁ (which is 0) ahead for 35 bytes
« Last Edit: July 03, 2011, 11:55:53 am by Runer112 »

Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Re: Zeros(36)->{L1}
« Reply #5 on: July 03, 2011, 12:27:33 pm »
wow...
thats a text  :D
Thanks a lot for the explanation! ;)

Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Re: Zeros(36)->{L1}
« Reply #6 on: July 03, 2011, 12:36:51 pm »
Can I store 8-bit data and 16-bit data both in {L1}?
My sprite x/y coordinates are stored as 8-bit numbers (because 16-bit aren't necessary for that^^) and I what to store the score in {L1+37}, but as a 16-bit number... ( {L1+37^r} )
is that possible?
I would say yes, or isn't that possible?

Ashbad

  • Guest
Re: Zeros(36)->{L1}
« Reply #7 on: July 03, 2011, 12:40:27 pm »
Can I store 8-bit data and 16-bit data both in {L1}?
My sprite x/y coordinates are stored as 8-bit numbers (because 16-bit aren't necessary for that^^) and I what to store the score in {L1+37}, but as a 16-bit number... ( {L1+37^r} )
is that possible?
I would say yes, or isn't that possible?

Yes, you store 8 bit data by doing 0->{L1}, 16 bit little endian by doing 0->{L1}r.

Also, please don't double post, just edit your first post to include the contents of your last post.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Zeros(36)->{L1}
« Reply #8 on: July 03, 2011, 12:40:48 pm »
I can't help but wonder why storing to two bytes is smaller than storing to one byte (as in, 0→{L1}r being smaller than 0→{L1} ).  Is it because it doesn't have to limit or something?
Vy'o'us pleorsdti thl'e gjaemue

Ashbad

  • Guest
Re: Zeros(36)->{L1}
« Reply #9 on: July 03, 2011, 12:43:45 pm »
Well, I think it is due to having to only parse the expression that determines the place in memory to be pointed to, and then do a ld (place),hl since hl is the primary expression register for axe; I bet that for 8 bit storing it has to add an extra ld a,l and then do a ld (place),a.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Zeros(36)->{L1}
« Reply #10 on: July 03, 2011, 12:46:32 pm »
Code: (Optimized data filling method) [Select]
and 0→{L₁}ʳ    .Give the fill a seed value of 0 to copy forwards
Fill(L₁,35)    .Copy the value pointed to by L₁ (which is 0) ahead for 35 bytes

What's and for? O.O

EDIT: Whoa, loading 0 to L ... brilliant.

Can I store 8-bit data and 16-bit data both in {L1}?
My sprite x/y coordinates are stored as 8-bit numbers (because 16-bit aren't necessary for that^^) and I what to store the score in {L1+37}, but as a 16-bit number... ( {L1+37^r} )
is that possible?
I would say yes, or isn't that possible?

Of course, data is what you make of it. Even when you store something in {L₁+37}ʳ as 16 bits you can take it out the lower eight bits with {L₁+37}. If the value is less than 256, {L₁+37}ʳ and {L₁+37} are the same thing (just slightly more optimized to do it the first way).

But if you have the room, you don't need to keep x- and y-values as 8 bits. If you're dealing with constant pointers (something like {L₁+2} as opposed to {B+L₁}), it's faster and smaller to just use the full 16-bits. That's because when Axe gets an 8-bit value it extends it to 16 bits anyway, because all math operations are done in 16 bits.

EDIT2: Ninja'd.

I can't help but wonder why storing to two bytes is smaller than storing to one byte (as in, 0→{L1}r being smaller than 0→{L1} ).  Is it because it doesn't have to limit or something?

It's because when you load an 8-bit value from a constant pointer, Axe actually loads 16 bits, then masks off the higher eight. It's the most optimized way to load eight bits, but slower and more bloated than just loading the full sixteen bits.

Note that this doesn't apply to non-constant pointers. At all.
« Last Edit: July 03, 2011, 12:49:39 pm by Deep Thought »




Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Re: Zeros(36)->{L1}
« Reply #11 on: July 03, 2011, 12:48:09 pm »
What does that mean?

EDIT: ok! thanks everyone! ;)

EDIT2: sorry... one last question :D should I store everything as 16-bit, because it's faster?
« Last Edit: July 03, 2011, 12:53:06 pm by GreenFreak »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Zeros(36)->{L1}
« Reply #12 on: July 03, 2011, 12:49:03 pm »
What does that mean?

Which (at whose explanation)?




Offline GreenFreak

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 191
  • Rating: +16/-1
    • View Profile
Re: Zeros(36)->{L1}
« Reply #13 on: July 03, 2011, 01:31:00 pm »
I added in my game everywhere the ^r..
but I did a mistake and I don't know where..

My problem is, that I don't want to publish the code  :-X
Is there something, that I could have done wrong? (except forgetting one ^r)

I need your help :P again ;D
« Last Edit: July 03, 2011, 01:46:49 pm by GreenFreak »

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Zeros(36)->{L1}
« Reply #14 on: July 03, 2011, 02:11:56 pm »
Could we have a screenie so we can better tell what's going wrong with this?
Does it freeze, does something display at the wrong place, etc.
« Last Edit: July 03, 2011, 02:12:09 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue