Author Topic: Painting Sprites from File/RAM  (Read 5626 times)

0 Members and 1 Guest are viewing this topic.

Offline nabako

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Painting Sprites from File/RAM
« 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.
Still a learning Axe coder, but lots of experience with BASIC :)

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: Painting Sprites from File/RAM
« Reply #1 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.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Painting Sprites from File/RAM
« Reply #2 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.

Offline nabako

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Painting Sprites from File/RAM
« Reply #3 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.
Still a learning Axe coder, but lots of experience with BASIC :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Painting Sprites from File/RAM
« Reply #4 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.