Hello and welcome to Part 2 of the NESMaker plugin guide! By now you have probably started your first plugin to give a better user experience than telling them to go in and edit your asm files by hand. You also might have run into a problem getting info from the base NESMaker model. Fear not! As of version 4.1.1, you will have access to almost everything available from the Project Settings dialog. Let’s talk about how to get there.
When your plugin starts up, you will be passed in an INesMaker interface. If you would like to access the project settings part of the model, it is all done through the ProcessCommand() method. The first thing you should do is check the version of NESMaker that your user is running. To do this, create a class that implements the INESCommand interface, and set the Action property to “GET VERSION”. Version 4.1 will return a blank string and will not support any other calls. Version 4.1.1 and above WILL support additional calls. You should see “4.1.1” (or a higher version) returned in the Result property.
Next, you should call ProcessCommand() with the Action property set to “GET COMMAND_LIST”. This will let you know if the commands that your plugin needs are available and if any newer commands have been added.
Here is a list of all the “GET” commands that you can call as of version 4.1.1. They all return a JSON object in the Result property.
* "GET PROJECT_LABELS" * "GET PROJECT_TILESETS" "GET PROJECT_SCRIPTS" "GET PROJECT_USER_DEFINED_VARS" "GET PROJECT_USER_CONSTANTS" "GET PROJECT_ZERO_RAM" "GET PROJECT_OVERFLOW_RAM" "GET PROJECT_OBJECT_VARS"
Most of these commands do not require any additional information. There are 2 exceptions however! “GET PROJECT_LABELS” and “GET PROJECT_TILESETS” both require a JSON string to be set in the Target property of your request. To simplify a LOT of the JSON syntax stuff, I prefer to use the Newtonsoft.Json dll. You can install it from the visual studio Nuget reference manager.
Let’s discuss “GET PROJECT_TILESETS” first. NESMaker has 7 types of tilesets. They are Main, Screen, Path, Monster, specialTiles, objectTiles, and HudTiles. These are located in different graphic banks. To specify the tilesets that I want information on, I need to pass in the graphic bank and the type. An example is shown below:
The key takeaway here is that you specify the extra info that the call needs in the JSON object, then convert it to a string and set the Target property. It might sound confusing, but once you use it a couple times, it will be second nature to you. Your response will be in the Result property. It will be in the form of a JSON object as well, so the easiest way to read it is with a call like this:
JObject jsonTilesets = JObject.Parse(response.Result);
Getting project labels is very similar. It however requires a field named “LabelOffset” as an int in the JSON object. That offset specifies what type of label you are interested in. 0=Tile Types, 1=Change Tile Types, etc…
Besides getting information from the NESMaker model, you can also SET. The table below gives a list of all the SET commands and the JSON parameters that they expect.
CommandParam NameParam Type
SET PROJECT_LABEL | LabelOffset ValueOffset Label |
int int int |
SET PROJECT_TILESET | GraphicBank TilesetID TilesetType DisplayName BMPFile |
int int string string string |
SET PROJECT_SCRIPT | Name Define Script |
string string string |
SET PROJECT_USER_DEFINED_VAR | Name Enabled InitialValue Notes |
string bool int string |
SET PROJECT_USER_CONSTANT | Name Enabled InitialValue Notes |
string bool int string |
SET PROJECT_ZERO_RAM | Name Enabled Bytes Notes |
string bool int string |
SET PROJECT_OVERFLOW_RAM | Name Enabled Bytes Notes |
string bool int string |
SET PROJECT_OBJECT_VARS | Name Enabled TotalObjectCount Notes |
string bool int string |
I hope that this gives you a good start in working with the INesMaker.ProcessCommand() method. I plan on adding more functionality so that plugin writers will be able to add even greater functionality! Good luck making your games!
–Josh