Tricking Mapper 30 to do 4-way Scrolling

User avatar
redantgames
Posts: 8
Joined: Wed Apr 04, 2018 4:56 pm
Location: Cold Lake, Alberta
Contact:

Tricking Mapper 30 to do 4-way Scrolling

Post by redantgames » Sat Apr 07, 2018 7:19 am

I know that Joe has stated over and over that the limitations of NES Maker will be directly tethered to mapper 30. Which I get and I can totally understand that a standard had to be drawn. That said I have a few projects I'd love to bring to the platform that require me to have greater than a 16x15 tile grid to portray on screen.

This limits me design-wise as I now have to work around a few technical limitations. ie. One of my games is a top-down arena-style shooter where I have a 19x19 tile grid and the same 4-8 or so enemies running around trying to find/fight the player. Besides how to handle my custom pathfinding (A*) and waypoint tracking AI and fog of war systems, which will have to involve some sneakiness, I'll have to figure out how to defeat the screen & scrolling limitations imposed by mapper 30.

I can do quite well at 16x16 sized tiles & character "sprites" but 8x8 makes them too small and will have colour palette issues. Here are my options however:

A) reduce to 8x8 sized sprites where detail makes the game hard to make nice sprites

B) find a way to scroll in 4 directions to make up the 19 x 19 sized tile grid that way

C) have 4 screens I can hop between as seamless as I can where the enemy AI can retain it's data and track the player off screen each other with a hud / mini-map

Option A is the best to match current gameplay with my existing design/concept, but the graphics would most likely be far too small.
Option C will maintain the ability to translate the graphics well enough for the platform, but possibly make the game feel far too unintuitive to be much fun.
Option B is best to maintain as much of the gameplay and graphics quality, but requires me to defeat the mapper 30 limitations not having 4 way scrolling.

Is there no way to trick mapper 30 into doing Option B at all or am I screwed until NES Maker supports a 4 way scrolling capable mapper?
Jason McMillen

Red Ant Retro -- Retro video games & hardware store
Red Ant Games -- Indie Game Development (Old website!)
User avatar
Kasumi
Posts: 99
Joined: Fri Mar 09, 2018 11:13 pm

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Kasumi » Sat Apr 07, 2018 10:03 am

Mapper makes no difference at all in regards to whether 4-way scrolling is possible. Even the same hardware Super Mario Bros./Donkey Kong used (no mapper) can do it. Mappers can make having a background (rather than a sprite) HUD easier in addition to the 4 way scrolling, but that's about it.

However, 4-way scrolling is a very difficult programming task. It's not the kind of thing one makes happen in a week (maybe not even in a month or two), one has to tread very carefully. Doubly so with destructible environments added.

It is becoming a bit more common in homebrew these days, though. My game, Indivisible, does it, Super Bat Puncher does it, and Legends of Owlia does it (on very similar hardware to mapper 30).

Edit: Actually, one more thing. I understand not wanting to go to 8x8 for characters because it's pretty small but you realize you can do any size in between that and 16x16, right? You can do 4x13 or 12x12 or whatever really, as far as characters. The NES "thinks" in 8x8 tiles, but you can use transparency with sprites so it's not like you absolutely have to fill all of them. But if your game is very, very grid based, you'll still have some work cut out for you background-wise, yes.

Edit 2: I'm not sure that wording was the most clear. Your characters can be 10 by 14 (or whatever, really) but the background will still be palette locked at 16x16 no matter what you do. In theory that's only graphical, though. Collision could be whatever. In practice, plan for tile based collision as well.
User avatar
redantgames
Posts: 8
Joined: Wed Apr 04, 2018 4:56 pm
Location: Cold Lake, Alberta
Contact:

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by redantgames » Sat Apr 07, 2018 4:45 pm

Ok so I am going to be able to make the game scroll (within reason) in NES Maker with some modification, most likely yes?

Now I'm not trying to make a StarCraft map here, just cover a 16x16 sized tile map that'll go up to 19x19 tile spaces. Is that a reasonable goal? Maybe if Joe has time later he might be able to advise...?
Jason McMillen

Red Ant Retro -- Retro video games & hardware store
Red Ant Games -- Indie Game Development (Old website!)
User avatar
redantgames
Posts: 8
Joined: Wed Apr 04, 2018 4:56 pm
Location: Cold Lake, Alberta
Contact:

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by redantgames » Sat Apr 07, 2018 4:52 pm

I should mention that I'm going to need a HUD as well. I guess that will make a huge difference considering how memory restrictive the system is.
Jason McMillen

Red Ant Retro -- Retro video games & hardware store
Red Ant Games -- Indie Game Development (Old website!)
User avatar
Kasumi
Posts: 99
Joined: Fri Mar 09, 2018 11:13 pm

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Kasumi » Sat Apr 07, 2018 7:20 pm

Even if you only wanted to go one 16x16 tile extra in both directions it gets hard because there isn't an offscreen buffer to draw to in one of the directions. Essentially you get two screens worth of "map" to draw to. The two can be aligned vertically or the two can be aligned horizontally.

Ice Climber has the two screens arranged vertically so it can draw new tiles to scroll up and down offscreen without worry.

Super Mario Bros. has the two screens arranged horizontally so it can draw new tiles to scroll left and right offscreen without worry.

If you've ever played Metroid, you'll notice it can scroll left and right, and scroll up and down. But it can't scroll say... down+left or up+right. The game switches which axis it can scroll on when you go through a door. (It's why the game is long corridors and tall shafts.) The door transition ensures the camera is axis aligned, and then it switches the way the screens are arranged.

Super Mario Bros. 3's method would probably work for your plan. It sort of sidesteps the common issues by primarily updating columns. Instead of drawing a new 240 pixel column of the level when the camera moves, it updates a new 432 pixel column of the level. (The remaining 48 pixels are for the HUD) This gets you a level that can be up to 27 16x16 tiles tall somewhat simply. (Without the HUD you could do up to 30.) The horizontal size of the level can be basically unlimited without issue.

That method would only fall apart if a level height+HUD height were needed that was taller than two screens. Whether or not this method is reasonable in NES Maker, I do not know.

As far as pixel smooth scrolling in both directions with a level that's taller than two screens in both directions like Indivisible... I'll put it like this. I've been programming the console for a decade, and I'd dread programming 4-way scrolling again.
Bucket Mouse
Posts: 88
Joined: Wed Mar 07, 2018 2:25 am

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Bucket Mouse » Sat Apr 07, 2018 7:22 pm

Maybe you can just copy-paste some screen-rendering engine code from Super Mario 3.....

....okay, not really. I tried looking at the ASM of some popular games with FCEUX to see how their tricks were done....I still don't know how they were done. There appear to be over 100 ASM commands for every single frame of action. There's a button to run the game one command at a time, where pretty much nothing changes, and a button that runs the game 128 commands at a time, which gives you a new frame every two pushes. I can't learn anything from the code of other games because there's just....so much of it.
User avatar
Kasumi
Posts: 99
Joined: Fri Mar 09, 2018 11:13 pm

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Kasumi » Sat Apr 07, 2018 8:12 pm

It's more like 8,000 instructions in a frame. There are about 29780 "cycles" in a frame, each instruction takes 3 or 4 cycles to complete on average. 128 lines doesn't mean 128 instructions. It means 128 rows of pixels. (While the screen is being rendered by the Picture Processing Unit, the 6502 CPU is running the logic for the game. Each row of pixels takes about 113 CPU cycles to render, or 30ish instructions. So 128 lines is really about 3840 instructions.)

You probably won't learn very much by stepping through undocumented code. You can try a (not fully) commented disassembly: https://github.com/captainsouthbird/smb ... prg031.asm (It starts at IntReset)

But even then it's not easy to follow unless you have a LOT of 6502 and NES knowledge already. Starting small (like making your own program that just gets some sprites on screen) is a good plan. As you learn more, it will start to come together how the old games work without any specific effort put toward it.
Bucket Mouse
Posts: 88
Joined: Wed Mar 07, 2018 2:25 am

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Bucket Mouse » Sat Apr 07, 2018 9:41 pm

This is due to all my programming experience being based in BASIC and HTML and other languages where, if you want to know how something works, you just find the specific bit of code and reverse-engineer it. When I see something on a webpage that I want to know how to do, I just right-click "Inspect Element" in Firefox and it shows me the line of instruction that did it. Usually that's transferable into my own projects.

But I guess that's not how NES works. I have a feeling I'm going to be relying on this "Code" sub-board a lot.
User avatar
Kasumi
Posts: 99
Joined: Fri Mar 09, 2018 11:13 pm

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by Kasumi » Sat Apr 07, 2018 10:32 pm

HTML has names and comments to help understand the flow of it. (Unless it has been purposefully obfuscated.)
Code you look at in FCEUX has nothing to help you understand its intent.
So it's not that it's not how NES works, it's that you're looking at a version of the code that is in a form that's no longer meant to be human readable.
Image
Same code. The left gives you context through name. Like instead of $E020 you see waitvblank, and instead of $E1BF you see joypad. $5C becomes frametimer. This isn't prepared example code, but it still gives way more context to what it's doing just from the names.

I'm not saying you can't learn from reading code at all, just
1. In FCEUX debugged code you're staring at an abyss of numbers when you don't need to.
2. Even if it is somewhat commented, rather than looking at 32 giant .asm files in that SMB3 disassembly you could read much smaller things to get the picture before the larger ones.
User avatar
redantgames
Posts: 8
Joined: Wed Apr 04, 2018 4:56 pm
Location: Cold Lake, Alberta
Contact:

Re: Tricking Mapper 30 to do 4-way Scrolling

Post by redantgames » Sat Apr 07, 2018 11:36 pm

I think at the ASM level you need to heavily comment all your code or it turns into unknown chaotic stuff unless it's something VERY common and it's something you code really often.

That said, I'm glad that it is possible. And to be honest it's one of those restrictions that are just out of reach with NES Maker out of the box. But as long as it'll let me modify it enough to scroll in one direction at a time for a few tiles I can make my game projects work in the engine. I can design to the 27-ish tile limits. At least for these existing projects. I will need a hub, but that'll be just 2-3 tile rows high worth of space to place the mini-map, weapon/ammo & key card info. (think of Doom's inventory, but smaller)

I do have an adventure puzzle project that I can make use of the extra size, doesn't need a HUD, but it's still best if I can scroll within a single level than splitting it into separate "rooms."

Here is to hoping I can tweak the engine a tad within each set of project files.
Jason McMillen

Red Ant Retro -- Retro video games & hardware store
Red Ant Games -- Indie Game Development (Old website!)
Post Reply