Calculator Community > Axe

Painting Sprites from File/RAM

(1/1)

nabako:
So I've been trying to save my Sprites in an Appvar. That means 8 Byte per Sprite in a dedicaded Texture section, which isn't a problem.
But how do I actually paint them from a File?
Let's say my Sprite is in Y0 to Y0+7.
I tried the simple way Pt-On(0,0,{Y0}) which seems to only use the first Byte and only make sime gibberish.

Xeda112358:
Try without the brackets. The way you are doing it is actually taking the data at Y0 as an address, but you want to use Y0 itself as an address.

Runer112:
This doesn't seem be documented anywhere, but reading from files requires special logic. The only commands that have variants implementing this special logic are {PTR}, {PTR}r, and Copy(PTR1,PTR2,SIZE).

In your case, you'd need to copy the sprite out of the file and into a buffer in RAM, and then display the sprite from that buffer. Note that this will add some major overhead if the file is in fact archived; it'll make displaying an 8*8 sprite take about twice as much time.

nabako:

--- Quote from: Xeda112358 on October 29, 2018, 10:58:21 am ---Try without the brackets. The way you are doing it is actually taking the data at Y0 as an address, but you want to use Y0 itself as an address.

--- End quote ---

Yes that seemed to be the problem. Does Pt-On() only take pointers? I seem to remember that
Pt-On(0,0,[FFFFFFFFFFFFFFFF]) also works.

Runer112:

--- Quote from: nabako on October 29, 2018, 12:36:18 pm ---Does Pt-On() only take pointers? I seem to remember that Pt-On(0,0,[FFFFFFFFFFFFFFFF]) also works.

--- End quote ---

[FFFFFFFFFFFFFFFF] is a pointer. It statically allocates data as well, but the "return" value is a pointer. You should be able to use it in any expression, although I think you may need to enclose it in parentheses in some cases to avoid confusing the compiler.

Navigation

[0] Message Index

Go to full version