Think of the game Snake when you hit the edge of the screen.

I'm trying to figure out what would be the best way to know if I am drawing a single pixel at the edge of the LCD. I am draw using 8bpp mode.

I was thinking about taking my current drawing address subtracted from $D40000 and then performing a division by lcdWidth. The remainder would tell me if I was on the edge of the LCD or not.

Am I going about it the wrong way, should this instead be put into a lookup table, or is there another way of doing this?
Store the X and Y position of the head in memory. Then read it when necessary to see if the Y position is less than 240.
[quote="Brando"]Store the X and Y position of the head in memory. Then read it when necessary to see if the Y position is less than 240.[/quote]

Yeah that would tell me if I hit the top of the screen. The part I'm more concerned about are the left and right edges. I could also just check if the memory address is between vRam && vRam + lcdWidth - 1 to know if the top was hit.
And you can't just check if X or Y is greater than 319 or 239 respectively because?...
[quote="MateoConLechuga"]And you can't just check if X or Y is greater than 319 or 239 respectively because?...[/quote]

I haven't tried storing the result as a point in 2D space, was hoping I could do that just holding onto the current address. I'm just moving a 1x1 particle right now and seeing how it turns out.
So you are just incrementing a pointer in vRam to move right? Sure you could do that, but why?

It would be a lot easier and more efficient to preserve an X and Y value and add that to the vRam address, rather than adding displacement to a pointer.

EDIT: multiplying is a lot faster on the eZ80 than division
Yeah I'm starting to see that, I'll try it that way.

Thanks.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement