Jump to content
IGNORED

How to use tiles & Maps


Lavalamp

Recommended Posts

Hi Peeps, having issues with getting tiling to work, the below results in a black screen...what have i missed? The Map has tiles set to emended and is XML, 8x16, and 20 x 12 in size. Thanks guys.

 set doublewide on
 set basepath gfx_morph
 set romsize 48k
 set tv pal
 displaymode 160A

 rem Color Palettes
 P0C1=$02: P0C2=$06: P0C3=$0F : rem grey, light grey & white

 rem Graphics Import
 incgraphic tileset_level_1.png
 incmapfile level_1.tmx

main_init
 clearscreen
 plotmap level_1 0 0 0 20 12
 savescreen
 drawscreen

main_loop
 BACKGRND=$00
 restorescreen
 drawscreen
 goto main_loop

Edited by Lavalamp
Link to comment
Share on other sites

If you're just using plotmap then unless you're redrawing the display over and over it shouldn't have much of a noticeable difference. If you're using plotmapfile then that's another story, because plotmapfile allows drawing tiles with different pallettes it has to manage a new object for each pallette change.

 

It's hard to say what the problem is without looking at the rest of the code but it shouldn't just be because you're using a tilemap.

Link to comment
Share on other sites

If you're just using plotmap then unless you're redrawing the display over and over it shouldn't have much of a noticeable difference. If you're using plotmapfile then that's another story, because plotmapfile allows drawing tiles with different pallettes it has to manage a new object for each pallette change.

 

It's hard to say what the problem is without looking at the rest of the code but it shouldn't just be because you're using a tilemap.

 

 

Thanks that's what I conlcuded, but its performing badly with the tile code removed so something I have introduced has done something. But its pretty clean early code so dunno. I got the map to appear so CHARACTERSET was the missing piece thanks! I didn't know that PLOTMAPFILES allowed the multi pallette support, nice!

Link to comment
Share on other sites

If you're just using plotmap then unless you're redrawing the display over and over it shouldn't have much of a noticeable difference. If you're using plotmapfile then that's another story, because plotmapfile allows drawing tiles with different pallettes it has to manage a new object for each pallette change.

 

It's hard to say what the problem is without looking at the rest of the code but it shouldn't just be because you're using a tilemap.

 

The DRAWSCREEN command below was the culprate, I thought this needed to be called after plotting sprites?

main_loop
 BACKGRND=$00
 restorescreen
 globalFrameCount = globalFrameCount + 1
 if globalFrameCount = 30 then globalFrameCount = 0
 if globalFrameCount = 15 then gosub moveplayer
 gosub drawplayer
 rem drawscreen
 goto main_loop
Link to comment
Share on other sites

You are correct in thinking that drawscreen should be called after you've finished plotting everything for the frame. It does a bit of setup and waits until the screen finishes drawing which is where your delay might be.

I think what might be actually happening is that the rest of your code takes slightly too long so that the 7800 is already drawing the next frame before drawscreen is called, so drawscreen would have to wait for the screen to finish, wait for vblank to finish, and then continue at the start of the NEXT frame.

 

A strategy to make the most of the time you have on each frame is to have all of your logic at the start of your loop, then restore the screen, then do all your plotting, then drawscreen. What you don't want to do is have anything graphics related near the start because 7800BASIC will wait for the screen to finish drawing before making changes to prevent the display being scrambled while it's being drawn, meaning all your code has to finish within the small amount of time that vblank takes.

For example, if your drawplayer routine does anything not directly related to drawing then that code can be run earlier in the loop during the visible screen time leaving just the plotting to be done between frames.

Edited by SmittyB
  • Like 2
Link to comment
Share on other sites

You are correct in thinking that drawscreen should be called after you've finished plotting everything for the frame. It does a bit of setup and waits until the screen finishes drawing which is where your delay might be.

I think what might be actually happening is that the rest of your code takes slightly too long so that the 7800 is already drawing the next frame before drawscreen is called, so drawscreen would have to wait for the screen to finish, wait for vblank to finish, and then continue at the start of the NEXT frame.

 

A strategy to make the most of the time you have on each frame is to have all of your logic at the start of your loop, then restore the screen, then do all your plotting, then drawscreen. What you don't want to do is have anything graphics related near the start because 7800BASIC will wait for the screen to finish drawing before making changes to prevent the display being scrambled while it's being drawn, meaning all your code has to finish within the small amount of time that vblank takes.

For example, if your drawplayer routine does anything not directly related to drawing then that code can be run earlier in the loop during the visible screen time leaving just the plotting to be done between frames.

 

 

Thanks I will re-engineer the code based on your recommendations, makes sense. I'll introduce you guys to my game Morph once I have the basics controls and collision detection working. Thinking about it I think my STOS Game Makers manual has a good example of this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...