256 different End Of Text Actions! WOW! (4.5.6)

Bucket Mouse

Active member
I noticed on the text entry screen in NESMaker, the "NPC Is Trigger" option in the End Of Text Action bar has a number selector underneath it. This is meant to trigger the screen when the text disappears -- and the previous versions of NESMaker had this, but you couldn't choose which trigger to use, it had to be the one assigned to the screen already.

As soon as I saw that number selector I thought "oh boy, I can have some fun with this." You were limited to five options when a text box displayed in NESMaker 4.1: Nothing, Open Shop, Win Game, NPC Gives Item, and NPC Is Trigger. We can now add hundreds of things to that list.

Let's take a look at what we're talking about. This is the native code that powers NPC Is Trigger, found in the middle of doDrawText.asm....

Code:
		CMP #_ENDTRIGGER
		BNE notEndTrigger
			LDA textPointer
			CLC
			ADC #$01
			STA textPointer
			LDA textPointer+1
			ADC #$00
			STA textPointer+1
			;;; NOW, get the modifier 
			TYA
			PHA
				LDY #$00
				LDA (textPointer),y
				;;; accumulators now contains the trigger type
				STA temp <<<<<<<<<<<<<
			TriggerScreen temp <<<<<<<<<<<<<<<<
				PLA
			TAY
			LDA #$00
			STA textHandler
			JMP endOfText

I've drawn arrows to the two lines that use the number to trigger the screen. We're going to dummy them out. Then we can use the space to make anything we want happen.

Say you want to change a condition, or change a tile somewhere, or alter anything after someone says something, but only at that moment. You would have to waste one of your five End Of Text Actions in the old NESMaker. Not anymore!

Keep in mind those two lines are the ONLY ONES we can change. Everything we want to do must go in between the lines LDA (textPointer),y and PLA. We don't want to mess with the math here or things will go wrong.

By comparing what's loaded into A at this point (the number you selected for that text box) to the number you want to trigger something to happen, you can command NPC text boxes to do pretty much anything.

Code:
				LDA (textPointer),y
				CMP #$01
				BNE notnumberone
				
	;					STICK YOUR CUSTOM CODE HERE
				
				notnumberone:
								CMP #$02
				BNE notnumbertwo
				
	;					STICK A DIFFERENT CUSTOM CODE HERE
				
				notnumbertwo:
				;;; accumulators now contains the trigger type
;				STA temp ;;;dummied out
;				TriggerScreen temp ;;;;dummied out
			PLA

You get the idea. The script cascades like that based on how many diferent things you want. Up to 256! Imagine the possibilities...
 

dale_coop

Moderator
Staff member
Oh nice script.


And just for information, that screen trigger selector is not new, it was already in the previous version (NESmaker 4.1):

 
Top Bottom