Jump to content


Plotmap has a limit plotting out of screen?

5 replies to this topic

#1 asdronin OFFLINE  


    Space Invader

  • 26 posts

Posted Sat May 11, 2019 1:16 AM

Hi all,

As Im trying several ways to make scrolling background I wanted to try this with plotmap although i know its not the best option, just wanted to see how it goes, and after making a map thats around twice the screen height then at some point it makes the screen purple, Im sure this means its not good to do that, then I wonder what is the exact limit for plotmap when its plotting tiles out of screen? I know I cant do much like that but you know at least know the limits to avoid them. Thanks for any help regarding this I have been trying to figure out what was the exact limit and only think that maybe plotting a whole screen out of screen makes it crash.


Edit: I assume this exception is the same for plotmapfile, or even worse as I cant assign a value to its coordinate so it cant be moved really onlly plotted at a certain coordinate

Edited by asdronin, Sat May 11, 2019 1:24 AM.

#2 SmittyB OFFLINE  



  • 373 posts

Posted Sat May 11, 2019 5:22 AM

I don't believe plotmap / plotchars / any of those similar functions have safeguards against writing to memory beyond what's allocated to drawing the screen. It's good that they don't because having those checks would slow them down with little benefit.


If your map is larger than the screen, or placed so that it goes beyond the bottom of the screen what you want to do instead is set the height parameter on the plotmap function to only cover the visible screen, but then use the optional offset parameters to say which part of your map data to draw.


It's also important to remember that the y location and height values are all counted in zones and not lines.

Edited by SmittyB, Sat May 11, 2019 5:25 AM.

#3 Mord OFFLINE  


    River Patroller

  • 2,697 posts
  • Location:Canada

Posted Sat May 11, 2019 5:24 AM

Probably best to try to avoid actively plotting too much off the screen if it's not needed - you'll just be wasting time that could be used for other things since maria will attempt to plot off the screen in vain if ordered to do so.


If you're using plotmap, you can instead plot a portion of that larger map on the screen. That way there's little to no waste in cpu cycles.  Plotmapfile is is harder to work with for this since you can't specify a portion of a plotmapfile in the same way. Plotmapfiles are certainly better for static backgrounds.

#4 asdronin OFFLINE  


    Space Invader

  • Topic Starter
  • 26 posts

Posted Sat May 11, 2019 10:28 PM

Thanks a lot SmittyB, I will do as you said with the offset and the screen size as the plotting area, as these functions are not meant to have off screen positions, well to be honest I tested a bit and some of the plotting was done correctly off-screen but at some point screen turns purple and makes odd noises so I stopped trying that.


Thanks a lot Mord, I see what you mean, plotmap allows us to plot sections of a larger map but plotmapfile isnt allowing that so its only good for static background, but in any case we can save the background and later restore it so I think in that case its just a matter of what we deal better, the Tiled tool or using characters in the editor.


As I have tried this over and over I find an odd behaviour, Im sure there is an explanation for this, but could you tell why is this happening? I tested first a few values for the Y-offset of my map (its two times the screen height) so I tried 0 offset its normal no offset of course, I tried limit values like in my case its 12, so its logical value, but then I decided to use a variable to make it move constantly and see how it behaves, the fact is this time around I notice that when my variable is 0 it crashes, but its senseless as I already tried 0 value, that makes me think, is the plotmap doing its things in the end when we draw screen? or well I cant explain this in any case not even with that as it seems odd. Here is the code that makes it crash, just copied the section in question:

 if ycordmap<0 then ycordmap=12

 plotmap screen1map 4 0 0 20 12 0 ycordmap 20

ycordmap is declared before and starts as 0, so the first step in plotting the map should be 0 and then the next time it becomes -1 then it should be again 12 so all safe, but as said this makes it not work. If I change the "if" condition to "ycordmap<=0" it works (well it doesnt crash i cant tell yet if its perfectly matching the values i want and its seamless scroll) but of course in this change its never 0 so I assume it could make a little jump when background is repositioned (right now its too fast so I cant confirm that), then my question about this is, why is this behaving like that? when is the map plotted or when the plotmap is seeing the variable value because even if it evaluates that when drawing the screen it makes no sense that the variable cant be 0 when I already tested 0 offset and worked fine like when no offset is specified, sorry for the long explanation, I try to make it clear and maybe use too many words for that.


#5 RevEng OFFLINE  


    Bit Player

  • 5,213 posts
  • Location:bottom of the stack

Posted Sat May 11, 2019 11:00 PM

This line isn't working like you think it does, due to the way the 6502 handles "negative" numbers...
if ycordmap<0 then ycordmap=12

... check out this post for details.

#6 asdronin OFFLINE  


    Space Invader

  • Topic Starter
  • 26 posts

Posted Sun May 12, 2019 12:05 AM

Impressive, thanks a lot RevEng, I feel like Im in another world, I mean usual things that I was used to use in other languages work different in this environment like negative numbers and so comparison and other structures are different, migh take some time to build what I have in mind but hopefully will be worth trying =)

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users