Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Ki1o on October 03, 2012, 08:39:31 pm

Title: Displaying greyscale sprites
Post by: Ki1o on October 03, 2012, 08:39:31 pm
I'm trying to see if I can display a sprite that has greyscale in it but I keep coming across a weird bug.  This is the code I have
.header
[Hex data] -> Pic1
[Hex data]
pt-on(15,20,Pic1)
repeat getkey(15)
Disphgraphr
end

The first hex is for the top buffer while the second is for the bottom.
When I run it, the sprite is displayed in monochrome while there is some greyscale "junk" along the top of the screen.
what am I doing wrong exactly?
Sorry for the bad post I am on my phone.
Title: Re: Displaying greyscale sprites
Post by: shmibs on October 03, 2012, 09:26:48 pm
you are doing several things "wrong"
firstly, you didn't clear the buffers before drawing to them. the front and back buffers are free ram areas that other things can and do use, so you need to clear them yourself with ClearDraw and ClearDraw^^r before drawing anything there or you will end up with the "junk" you mentioned.
secondly, all you are doing with that pt-on command is drawing to the front buffer. axe doesn't have a "draw to both front and back" command yet, although people have poked runer about it, so it may be added soon-ish. as of right now, you have to draw them separately, so that would mean drawing the first 8 bytes to the front buffer with pt-on(15,20,Pic1) and then the second 8 bytes in a sprite to the back buffer with pt-on(15,20,Pic1+8)^^r
Title: Re: Displaying greyscale sprites
Post by: Ki1o on October 03, 2012, 09:58:48 pm
I love you! That did the trick! Thanks you so much!  ;D :love:
Title: Re: Displaying greyscale sprites
Post by: shmibs on October 03, 2012, 10:06:03 pm
hehe, it wasn't anything big :P
any time you have questions don't hesitate to ask! axe can be a little tricky to work with at first.
Title: Re: Displaying greyscale sprites
Post by: Ki1o on October 03, 2012, 10:38:52 pm
Ok now how would I go about doing animation? Would it be *8 instead of plus or would I have to store the next frame to a different pointer?
Title: Re: Displaying greyscale sprites
Post by: shmibs on October 03, 2012, 10:49:08 pm
yeah, *8 is the best way to go about it.
if you wanted to loop through a list of 4 sprites, updating the buffer after displaying each one, then, you could do something like this:
for(L,0,3
pt-off(x,y,L*8+Pic1
DispGraph
End
Title: Re: Displaying greyscale sprites
Post by: leafy on October 04, 2012, 05:40:20 pm
^Small correction, if he/she wants to do greyscale sprites, *16 should be used instead of *8.
Title: Re: Displaying greyscale sprites
Post by: shmibs on October 04, 2012, 07:49:23 pm
not necessarily, as the front buffer and back buffer sprites could be stored in different places, or just stored with all the front buffer sprites together followed by all the back buffer sprites./me was just giving a general case as well.
Title: Re: Displaying greyscale sprites
Post by: Ki1o on October 05, 2012, 03:31:54 pm
Ok what if its like an RPG sprite with two frames for each side would I place the for loop before or after the display command.
Title: Re: Displaying greyscale sprites
Post by: leafy on October 05, 2012, 04:46:45 pm
Generally you should put the loop before the display command, although it really doesn't matter if it's in a while loop. Make sure you keep track of your order logic, however.