Jump to content

Photo

How to use tiles & Maps

7800 BASIC Tile Map 7800Basic

8 replies to this topic

#1 Lavalamp OFFLINE  

Lavalamp

    Chopper Commander

  • 119 posts
  • Location:Wellington, New Zealand.

Posted Sun Sep 23, 2018 1:36 PM

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, Sun Sep 23, 2018 1:37 PM.


#2 SmittyB OFFLINE  

SmittyB

    Moonsweeper

  • 287 posts

Posted Sun Sep 23, 2018 2:36 PM

It took me a lot of staring but I think I know the issue. You need to call 'characterset tileset_level_1' so that when the screen is drawn it's loading the graphics from the right place. At the moment it's probably picking an arbitrary point in ROM that happens to be empty.



#3 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,992 posts
  • Bitnik
  • Location:bottom of the stack

Posted Sun Sep 23, 2018 2:44 PM

[edit] I believe SmittyB has it. :thumbsup:

#4 Lavalamp OFFLINE  

Lavalamp

    Chopper Commander

  • Topic Starter
  • 119 posts
  • Location:Wellington, New Zealand.

Posted Sun Sep 23, 2018 4:13 PM

Awesome thanks guys. Also can I expect a huge performance drop when using a tiled background? I only mention this because I had the global frame counter drop from 60 to 10 to get the speed up again :/ might be my code though.



#5 SmittyB OFFLINE  

SmittyB

    Moonsweeper

  • 287 posts

Posted Mon Sep 24, 2018 12:43 AM

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.

#6 Lavalamp OFFLINE  

Lavalamp

    Chopper Commander

  • Topic Starter
  • 119 posts
  • Location:Wellington, New Zealand.

Posted Mon Sep 24, 2018 1:31 PM

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!



#7 Lavalamp OFFLINE  

Lavalamp

    Chopper Commander

  • Topic Starter
  • 119 posts
  • Location:Wellington, New Zealand.

Posted Mon Sep 24, 2018 2:30 PM

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


#8 SmittyB OFFLINE  

SmittyB

    Moonsweeper

  • 287 posts

Posted Mon Sep 24, 2018 2:48 PM

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, Mon Sep 24, 2018 2:48 PM.


#9 Lavalamp OFFLINE  

Lavalamp

    Chopper Commander

  • Topic Starter
  • 119 posts
  • Location:Wellington, New Zealand.

Posted Tue Sep 25, 2018 1:31 PM

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.







Also tagged with one or more of these keywords: 7800, BASIC, Tile, Map, 7800Basic

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users