Author Topic: Sprite Overwriting  (Read 3187 times)

0 Members and 1 Guest are viewing this topic.

Offline BlackCode

  • LV2 Member (Next: 40)
  • **
  • Posts: 28
  • Rating: +0/-0
    • View Profile
Sprite Overwriting
« 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.
« Last Edit: September 21, 2013, 11:06:00 pm by BlackCode »
-I post from my iPod, so please forgive any funky formatting.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Sprite Overwriting
« Reply #1 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.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Sprite Overwriting
« Reply #2 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() 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.
« Last Edit: September 21, 2013, 11:24:21 pm by Runer112 »

Offline BlackCode

  • LV2 Member (Next: 40)
  • **
  • Posts: 28
  • Rating: +0/-0
    • View Profile
Re: Sprite Overwriting
« Reply #3 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? 
« Last Edit: September 21, 2013, 11:54:05 pm by BlackCode »
-I post from my iPod, so please forgive any funky formatting.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Sprite Overwriting
« Reply #4 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Sprite Overwriting
« Reply #5 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.

Offline BlackCode

  • LV2 Member (Next: 40)
  • **
  • Posts: 28
  • Rating: +0/-0
    • View Profile
Re: Sprite Overwriting
« Reply #6 on: September 22, 2013, 11:47:58 am »
Alright, thanks guys.  I understand now.
-I post from my iPod, so please forgive any funky formatting.