First of all, you might want to have some familiarity with the hexadecimal system, as we're going to rely pretty heavily on it. There are plenty of resources for you out there, including Joe's own video that covers the subject. You will also need a text editing program. You can use notepad, but I highly suggest picking up Notepad++. You also might try to familiarize yourself with the path system, and there are a few videos on Joe's channel that will walk you through how they work, but I'm going to briefly cover it here too.

You'll also want to keep in mind that this version changes the way ALL paths work, it's possible in the future that I'll come up with a way to have multiple path systems in one game, but for now this is what you're working with.

Also, this tutorial is for the NESmaker Pi Beta, so if you have a version that's later than that, it might not work (unless specified otherwise). It's probably best to backup your files if you're worried about messing it up.

With all that out of the way, let's start cracking.

-- Installing the code

The first thing you need to do is to insert the Pathfinder code into a some of the .asm files in your NESmaker project folder. Specifically you'll want to find "MainASM.asm" (it's in the GameEngineData folder) and insert the following code near the very bottom right after the line ".include "GameData\HUD_DEFINES.dat"":

Then you're going to need to find LoadMetaNametableWithPaths.asm in "GameEngineData\Routines\System\" and replace everything from "handlePath:" to right before "GetSingleMetaTileValues:" with the following code.

Make sure to save the text file after you're done, and you should be ready! Fire up NESmaker and import your favorite path tiles, then test them out on a screen to see.... that they look exactly the same as before...?
Yes, the pathfinder.txt code above instructs NESmaker to construct paths the same way it already does currently, but in the next post I'll show you how to customize it to behave the way YOU want it to.

Last edited by MistSonata on Sat Jul 21, 2018 3:12 am, edited 3 times in total.

Have you ever done one of those paint-by-numbers things? Well that's kind of how NESmaker draws the background, except all the painting areas are 16x16 pixel boxes in a grid. It reads the screen data top to bottom and left to right, looks up what tiles that hex value represents, and then places those tiles there.

But path tiles work a little differently than that, you can't just have it read "Path one is here, so just grab the 16x16 tile in that area of the PPU and slap it on the screen", you need to first be aware of the values of the boxes surrounding that path tile.

In the pathfinder code, what it does is it reads the 8 tiles surrounding it, and generates a 3 bit code to tell each 8x8 pixel quadrant of that tile (labelled NE, SE, SW, NW) what graphic it needs to pull from the PPU. This isn't REALLY necessary to fully understand in order to write your own pathfinder.txt, but it does help.

-- Making Your Own Pathfinder File

Now, before you start tinkering with the pathfinder.txt file, you'll want to make a copy of it just in case. In fact you might want to just make multiple copies for different path styles that you like so you can swap them in and out as you will (and maybe save them until I can figure out how make multiple path styles work).

Okay, so, all these hex values may seem daunting at first, but once you know what they represent, it'll probably be easier to comprehend.

You'll notice that each row represents one of the four quadrants in the path tile, starting with the northeast one. All the quadrants only pay attention to the neighboring tiles they're touching, and the columns show all the scenarios that each quadrant could experience (you'd think there'd be more than 8, but there's not, and that makes it very simple to manage). So the question you might be left with is... what do we put in these hex value places?

-- What Do We Put In These Hex Value Places??

Looking just at the NE quadrant, we can determine which situation we'll want to insert certain tiles into. Making the first tile of the path graphics your starting point (essentially $00) you can count up from there in hexidecimal, up to $0F.

Since we're only working on a 16 tile path, we can set the 1st and 3rd hex value to $04, that's really all there is to it. Do that for the rest of the values and you're good to go!

Now, you might be asking how we get from here to using 32 unique tiles. The offsets are basically telling the program "Hey, this path's starting point is at $80, so add the offset to that to get $84 and grab the tile that's in that slot", so if you want it to go further than the current 16 tile path and into the next path, you need to add $10 to the number. So if you want the 4th tile from the path below the current one, you'd write $14 instead.

And this doesn't only work for going down, you can go up by wrapping the first digit around to F, so if you want the 4th tile in the path above the one you're working with, you would write $F4.

By the way, you can use this to go further up and use tiles from other places in the PPU:

Here I modified the pathfinder file I made to use a tile from the manticore (which is part of the background graphics, I didn't pull this from the sprite PPU). Now, doing stuff like this for fun is cool, but if you want to use this method regularly, you're going to have to do a LOT of planning ahead, since all the other parts of the background PPU can change from screen to screen. You've got to be careful there, or you'll end up with a garbled mess.

Anyway, that should be it. Let me know if you guys have questions, or need clarification on something.

Pathfinder 2.0 Update: As long as you've followed the instructions and made the changes highlighted above, the new pathfinder should work for you. However, if you want to make the most of the new system and all of its 16 path types, and you don't mind a whole lot of tedium, scroll down to my next post in the thread!

Last edited by MistSonata on Fri Jul 20, 2018 6:07 am, edited 1 time in total.

Thanks for this explanation! starting to understand this system a bit more. i was curious if there was a call/command to flip a path tile, to double the available graphic tile space? (similar to the ability to flip game object and monster tiles)

Thanks for this explanation! starting to understand this system a bit more. i was curious if there was a call/command to flip a path tile, to double the available graphic tile space? (similar to the ability to flip game object and monster tiles)

Okay, so here's where it gets complicated. Right now this is kind of a backdoor hack to make path types work until there's an easier way to do it with NESmaker. When NESmaker draws paths, it's using the hex values $80, $90, $A0, and $B0 to represent them in the nametable data, but in order to define which path type we want a path to use, we will need to change the zeroes on these values into the path type number that we want to use. ($81 for path number 1 ($80) and path type 1 (Pathfinder01) etc)

There's just one problem with that, though. Even if you go into "GameEngineData\ScreenData\Nametables\" and edit the nametable file for the screen you want to define your path types on, as soon as you export and test your game in NESmaker, the tool will override your hard earned work.

What you'll have to do is find the nametable file for the screen you want to customize and copy it, then move that copy to a new folder (for example, I chose to put them in "GameEngineData\ScreenData\UserNametables\", to make it easier.

After you've done that, you'll need to go into your Bank00.asm file in "GameEngineData\BankData\", find the .include for the nametable you copied, and modify it to include the custom "UserNametable" file instead.

I'd highly recommend doing this after you're done editing the screen in NESmaker, and just want to define your path types. If you only have one path type in mind for each path, it shouldn't be too difficult at that point to perform a "find and replace" to make your life a little easier.