FAQ: Is it not possible to put more than 4 Enemies on Screen?

This is a repost of Mr. Granato's answer to someone asking "So is not possible to put more than 4 Enemies on Screen?", which I found on "NESmaker - Getting Started, Part 7"'s video https://youtu.be/9Xyomv-kHvU I thought it was a great answer, so why not let more people read it. Here it is:

The answer to that is a very long and complicated one. Let’s see if I can break it down.

1. For the nes, you’re working at the byte level. Each object needs certain bytes to determine placement, behavior, size, sprites, etc...all the things that make them up. The place that is reserved by default for monsters in ram is a block of 512 bytes. That is actually a huge chunk of memory devoted to this. Default NESmaker objects need about 32 bytes each to function - this gives them their versatility, which is important when making a wysiwyg that can be morphed to various genres.

2. If you do the math, 512 / 32 = 16. So technically, 16 objects can exist in the game per screen. However, these 16 include player, projectiles, effects, etc. ALL objects. So you shouldn’t put 16 objects on a screen, because the if you went to attack, let’s say, your sword could not be created...no more object slots left. You definitely need overflow.

3. Depending on the complexity of your engine and the routines its trying to squeeze into a single frame, once you get to around 10-12 objects on the screen you get that classic NES slowdown.

4. You also need to determine PLACEMENT data per screen. There is limited byte space for this as well. Because we have 4 states the screen can be in, you have to take the number of objects and multiply it by four, for placement details for day/night/triggered/night triggered, as they all can be different. This is where the 4 object limit truly comes from.

So what can you do knowing this info? I recommend watching the first video again...NESmaker is intended to be very modifiable by the user. You can sacrifice the night state, write a screen loading routine that uses both day and night placement of objects on a screen, doubling your object count to 8. You can have tiles that spawn objects on screen load and have up to 16 ( with the issues cited above). You can rewrite the byte handling for your specific purpose, get rid of the bytes your game doesn’t need per object, and fit more slots. You can write more efficient main loop code so your game takes more objects to get to slow down. You could build a class system where certain objects like projectiles had limited byte structure so you could get more of them on screen at one time...

And on and on. These are all advance uses, but that should be expected. The more advanced of a game you want to make, the more complex. The more you want to refine your engine to you very specific game requirements, the more you'll have to tweak the underlying code.

But by default for NESmaker screens, you have 4 object placements on a screen at a time. It’s the middle of the road solution that can be most easily expanded upon. If that seems like a small number, really think back to the nes catalogue of games. Picture, say, smb 3 and try to remember screens that had more than 4 non player or non gameplay created objects that spawned at one time. Good game design, and that stretches much farther than you’d realize!
 
Top Bottom