Author Topic: Buff() Command Help  (Read 3359 times)

0 Members and 1 Guest are viewing this topic.

Offline Pixilized

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 5
  • Rating: +0/-0
  • Dividing zero by zero…
    • View Profile
    • My Site
Buff() Command Help
« on: September 30, 2023, 08:26:24 pm »
In Axe, there is a Buff() command to make a custom buffer. It takes an input of a size, and an optional fill with constant, and returns a pointer to the new buffer.

However, when I run programs using the command, the size I choose doesn’t seem to affect how it runs, even when I choose a buffer size of one byte.

Why does the buffer size matter if it doesn’t affect the program? Or does it affect the program and I’m just to dense to notice it?

In addition, is the constant it can be filled with a hexadecimal code of an entire screen? Because I think that’s how it works, from what I’ve seen in the source code of Cookie Clicker Axe.

Thanks in advance!

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Buff() Command Help
« Reply #1 on: October 01, 2023, 08:16:56 pm »
Axe's documentation uses 'buffer' to mean 'a pointer to some data'. Any command that takes a buffer is really asking for a pointer. As long as the data you are pointing to is big enough for whatever operation the command is doing, it is happy.

Buff() makes a buffer by adding bytes to your program. If you make one with a size of 1000, it adds 1000 bytes to your program's size. The lines :Data(0, 0, 0, 0, 0)->X and Buff(5, 0)->X both do the same thing. Buff() is just a convenience if you want a lot of space.
It is a way to get more scratch memory if you run out of space in L1-L6 and don't want to use GetCalc() to create a temporary file to store data in. For example, if you want to store a screenshot (which is 768 bytes) and you are using L3 and L6 for something else, you could use Buff(768)->oScreenshotStorage to have a place to store your data. Since DispGraph can take a pointer, DispGraph(oScreenshotStorage) would display the contents of the buffer. (Of course you would probably want to put something there first)

I can give more detailed help or suggestions if you tell me what you are trying to do.
I'm still around... kind of.

Offline Pixilized

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 5
  • Rating: +0/-0
  • Dividing zero by zero…
    • View Profile
    • My Site
Re: Buff() Command Help
« Reply #2 on: October 01, 2023, 08:34:44 pm »
Okay, thank you, that information was very helpful.

As for what I wanted to do with it, I’m planning on making a game that has a striped background, and I wanted to put it on a separate buffer to save space so I can use the main and back buffers for more important objects. (I have no code to show, as I haven’t started the project yet).

And if it just returns normal data, does that mean that the following hexadecimal, when stored to a pointer, can be drawn as a buffer with a line on the left side of the screen?

[800000000000000000000000 (repeat shown hexadecimal for 63 additional rows, total of 64 rows)…]

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Buff() Command Help
« Reply #3 on: October 02, 2023, 08:41:44 am »
And if it just returns normal data, does that mean that the following hexadecimal, when stored to a pointer, can be drawn as a buffer with a line on the left side of the screen?

[800000000000000000000000 (repeat shown hexadecimal for 63 additional rows, total of 64 rows)…]
Yes. DispGraph(ptr to that data) would display a blank screen with a line on the left side.

In general, unless you are really hurting for speed, you can get away with redrawing everything each frame. Axe's drawing routines (except for text) are very fast.
I'm still around... kind of.

Offline Pixilized

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 5
  • Rating: +0/-0
  • Dividing zero by zero…
    • View Profile
    • My Site
Re: Buff() Command Help
« Reply #4 on: October 02, 2023, 04:35:50 pm »
Okay, thanks! I really appreciate your help and it has given me a a better understanding of Axe.