Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: nabako on October 29, 2018, 10:49:01 am

Title: Painting Sprites from File/RAM
Post by: nabako on October 29, 2018, 10:49:01 am
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.
Title: Re: Painting Sprites from File/RAM
Post by: 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.
Title: Re: Painting Sprites from File/RAM
Post by: Runer112 on October 29, 2018, 11:52:00 am
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.
Title: Re: Painting Sprites from File/RAM
Post by: nabako on October 29, 2018, 12:36:18 pm
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.

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.
Title: Re: Painting Sprites from File/RAM
Post by: Runer112 on October 29, 2018, 12:40:31 pm
Does Pt-On() only take pointers? I seem to remember that Pt-On(0,0,[FFFFFFFFFFFFFFFF]) also works.

[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.