Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: BlackCode on September 21, 2013, 11:04:27 pm

Title: Sprite Overwriting
Post by: BlackCode on September 21, 2013, 11:04:27 pm
Alright, I'm making a cursor for a menu, and need to figure out how to draw it.  It seems simple enough, but the problem arises when it overlaps with text.  Ideally it would just display over the text, however I cannot find a way to do this.  Pt-off will erase the text, and I'd rather not retext(?) the entire screen every iteration as it would be slow and ugly.  Pt-on has the side effect of not erasing the cursor, so I leave a trail of on pixels (which, while fun, is undesired).

Edit:  Simplest solution preferred-speed is not critical.
Title: Re: Sprite Overwriting
Post by: willrandship on September 21, 2013, 11:07:38 pm
You could do Pt-Change, which will cause it to invert the pixels it draws. This means you can simply do pt-change again to erase the cursor, leaving the underlying text.

Another option would be to use the 3-level greyscale. Then, you just use the grey buffer for the cursor and the black buffer for the text.
Title: Re: Sprite Overwriting
Post by: Runer112 on September 21, 2013, 11:15:24 pm
The OS solves this by reprinting the character that was under the cursor when it moves or blinks off. Is there a reason why this isn't feasible here? This can either be done the OS way by looking up what character was under the cursor and reprinting it, or you can use Axe's pt-Get() (http://axe.eeems.ca/Commands.html#spritesCommands) command to copy the 8*8 "sprite" under where the cursor is about to be drawn to memory, draw the cursor, and then redraw the copied sprite later to erase the cursor.
Title: Re: Sprite Overwriting
Post by: BlackCode on September 21, 2013, 11:23:04 pm
I don't quite understand how pt-change twice will erase the cursor?  Will it not just undo itself?  As for using the backbuffer, that's quite a good solution.  My only worry would be the cursor being even harder to see while moving.
Runner, I couldn't look it up and redraw (as far as I knew) because what is underneath is not another sprite, but text from the text() command.  Now that you mention the pt-get command though, I have solution.
Thanks for the quick replies, I'll try these and see what works best.

Edit:  Is there a reason text wouldn't display?  I've tested in other programs and it works fine, it even displays when I put it in the program loop.  But if it's just at the start it won't display...

Edit 2:  It's due to dispgraph.  Is there a solution to this?

Edit 3:  Ah.  Fix 5.  May I ask why this is necessary instead of just having it occur by default? 
Title: Re: Sprite Overwriting
Post by: Hayleia on September 22, 2013, 02:43:07 am
I don't quite understand how pt-change twice will erase the cursor?  Will it not just undo itself?
The goal is not to use it twice in a row. You do it once before the DispGraph to display the cursor, then once after the DispGraph to erase the cursor.
Title: Re: Sprite Overwriting
Post by: willrandship on September 22, 2013, 02:59:15 am
Text, by default, goes into a real-time text mode using the same functions used by TI-OS. Because of this, it's substantially smaller code, and it provides a separate buffer to use as well. There needs to be a default, so it might as well be the faster one.
Title: Re: Sprite Overwriting
Post by: BlackCode on September 22, 2013, 11:47:58 am
Alright, thanks guys.  I understand now.