JamesNES
Well-known member
If you've seen the "Monster Bits" panel in the monster setup window you've probably wondered what to do with them or how to use them. They can work as another set of monster flags, but they're not included in your game by default. NES Maker exports them when you compile but you have to bring them into your game yourself.
Bringing them in is straightforward, then to use them you have two choices. You can either create an object variable for them, which will use up your object RAM, or you can just have them in a bank somewhere and look them up by object type every time, which won't take up RAM but then you won't be able to alter the bits, they'll be fixed to what object type they're for.
Importing them without using Object RAM
First you need to get the monster bits into your project by importing them. You can do this in two places, depending on how you want to use them. If you're not going to use object RAM, it's easiest to put them into the static bank so you don't need to switch in order to look them up. It's 90 bytes so it's not a huge cost.
At the bottom of LoadAllSubroutines add:
Now when you want to look at an object's monster bits, assuming the object ID is in x, you can just do:
And then check with AND and whatnot. All done for this method.
Importing them and using Object RAM
For this method, you need to add a monster bits variable in your object variable settings.
Since we only need to reference the imported data during object creation now, we can put these in bank 1C with the rest of the monster data.
So at the bottom of Bank1C.asm add:
Now to load it into RAM when an object is created. This is handled in doHandleObjects (filename is different between modules):
Around line 70ish you should see something like:
So during that bank switch we just need to add loading the bits in:
Now objects will have their monster bits loaded in as a variable so you can change them during gameplay using LDA Monster_bits,x and so forth.
Bringing them in is straightforward, then to use them you have two choices. You can either create an object variable for them, which will use up your object RAM, or you can just have them in a bank somewhere and look them up by object type every time, which won't take up RAM but then you won't be able to alter the bits, they'll be fixed to what object type they're for.
Importing them without using Object RAM
First you need to get the monster bits into your project by importing them. You can do this in two places, depending on how you want to use them. If you're not going to use object RAM, it's easiest to put them into the static bank so you don't need to switch in order to look them up. It's 90 bytes so it's not a huge cost.
At the bottom of LoadAllSubroutines add:
Code:
MonsterBits:
.include "ScreenData\ObjectData\MonsterBits.dat"
Now when you want to look at an object's monster bits, assuming the object ID is in x, you can just do:
Code:
LDY Object_type,x
LDA MonsterBits,y
And then check with AND and whatnot. All done for this method.
Importing them and using Object RAM
For this method, you need to add a monster bits variable in your object variable settings.
Since we only need to reference the imported data during object creation now, we can put these in bank 1C with the rest of the monster data.
So at the bottom of Bank1C.asm add:
Code:
MonsterBits:
.include "ScreenData\ObjectData\MonsterBits.dat"
Now to load it into RAM when an object is created. This is handled in doHandleObjects (filename is different between modules):
Around line 70ish you should see something like:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here, we create a new object. It will exist upon the next frame.
.include SCR_CREATE_STATE
JSR doHandleCreateState
SwitchBank #$1C
LDY Object_type,x
LDA ObjectFlags,y
STA Object_flags,x
ReturnBank
JMP doObjectIsInactive
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
So during that bank switch we just need to add loading the bits in:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here, we create a new object. It will exist upon the next frame.
.include SCR_CREATE_STATE
JSR doHandleCreateState
SwitchBank #$1C
LDY Object_type,x
LDA ObjectFlags,y
STA Object_flags,x
LDA MonsterBits,y
STA Monster_bits,x
ReturnBank
JMP doObjectIsInactive
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Now objects will have their monster bits loaded in as a variable so you can change them during gameplay using LDA Monster_bits,x and so forth.
Last edited: