Need coding help with autotext tile

Bucket Mouse

Active member
I've been trying to rig my autotext tile so that it doesn't display the text again when a screen trigger is tripped. I used the code they use for detecting triggered screens elsewhere:

Code:
;; CHANGE to a "0 - Walkable" special Tile "UnderSecret"

	LDA screenType
		;; divide by 32
		LSR
		LSR
		LSR 
		;LSR
		;LSR
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		STA temp
		LDA screenType
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		AND temp
		BNE finishedWithAutoText

	CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:
	;;RTS

I've run into a problem...turns out that code doesn't check to see if a trigger is active on the screen. It checks to see if a trigger has been assigned to that screen AT ALL, whether it's tripped or not. So if I've assigned a trigger number to the screen, the text won't appear.

I don't know how to adjust it because I'm unfamiliar with the math involved here. How do I get this stupid code to check if A TRIGGER IS ACTIVE, not IF A TRIGGER IS ASSIGNED?
 

dale_coop

Moderator
Staff member
And how is checking the collision data of your tile to check is already triggered, like that:
Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	JSR GetTileAtPosition
	LDA collisionTable,y		;<<-- check the current tile collision data
	BEQ finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:
 

Bucket Mouse

Active member
dale_coop said:
And how is checking the collision data of your tile to check is already triggered, like that:
Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	JSR GetTileAtPosition
	LDA collisionTable,y		;<<-- check the current tile collision data
	BEQ finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:

With this version, the tile generates text pre-trigger.....but then it also generates text post-trigger when I return to the screen. It didn't work. What else can I try?
 

chronosv2

New member
You could set the post-trigger version of the screen to not have the tile. I think that's what I did with my use of your original tile in Desolate Desert.
 

Bucket Mouse

Active member
chronosv2 said:
You could set the post-trigger version of the screen to not have the tile. I think that's what I did with my use of your original tile in Desolate Desert.

How do you do that, exactly? If I put a tile on a screen, or change the property of one by right-clicking, that change stays on both the "Normal" and "triggered" versions of the screen. Only the monsters change. Is there a setting I'm missing?
 

chronosv2

New member
I could have sworn that triggered had a different layout... I could be mistaken though.

Edit: Yeah, I guess the screen nametables aren't changed between versions. Just checked my Desolate Desert ROM and both versions of the screen are the same.
But I thought when I stepped on that tile a second time testing it that it didn't re-trigger...
I blame my memory being faulty.

But looking at your code again, it looks like your code for checking triggers is different than the Macro.
Code:
MACRO GetTrigger
	;; arg0 = screen to change, usually held in variable screenType <-- chronosv2 note -- I don't think this is meant to say "change". I think it's "check" because it's not saving the results of the check.
	TXA
	STA tempx
	TYA
	STA tempy
	
	lda screenType ;; this is the value of the screen to change.
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		STA temp
	lda screenType
	
		LSR
		LSR
		LSR 
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		AND temp
	LDX tempx
	LDY tempy
ENDM

So I think this might do the trick:
Code:
	CPX player1_object
	BNE finishedWithAutoText

	lda screenType ;; this is the value of the screen to change.
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		STA temp
	lda screenType
	
		LSR
		LSR
		LSR 
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		AND temp
		BNE finishedWithAutoText	

	JSR GetTileAtPosition
	LDA collisionTable,y		;<<-- check the current tile collision data
	BEQ finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:

Maybe this will work?
 

Bucket Mouse

Active member
chronosv2 said:
I could have sworn that triggered had a different layout... I could be mistaken though.

Edit: Yeah, I guess the screen nametables aren't changed between versions. Just checked my Desolate Desert ROM and both versions of the screen are the same.
But I thought when I stepped on that tile a second time testing it that it didn't re-trigger...
I blame my memory being faulty.

But looking at your code again, it looks like your code for checking triggers is different than the Macro.
Code:
MACRO GetTrigger
	;; arg0 = screen to change, usually held in variable screenType <-- chronosv2 note -- I don't think this is meant to say "change". I think it's "check" because it's not saving the results of the check.
	TXA
	STA tempx
	TYA
	STA tempy
	
	lda screenType ;; this is the value of the screen to change.
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		STA temp
	lda screenType
	
		LSR
		LSR
		LSR 
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		AND temp
	LDX tempx
	LDY tempy
ENDM

So I think this might do the trick:
Code:
	CPX player1_object
	BNE finishedWithAutoText

	lda screenType ;; this is the value of the screen to change.
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		STA temp
	lda screenType
	
		LSR
		LSR
		LSR 
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		AND temp
		BNE finishedWithAutoText	

	JSR GetTileAtPosition
	LDA collisionTable,y		;<<-- check the current tile collision data
	BEQ finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:

Maybe this will work?

Wow, I think you did it! A quick test during the Walking Dead commercials was successful. I'll repost later tonight if there are further problems.
 

chronosv2

New member
Glad to be of assistance!
I've been digging around in NESMaker's ASM code a lot lately. Once I discovered that my original idea about screens being able to have different tiles when triggered was seemingly incorrect, I decided I'd try to see what I could find out.
 
Top Bottom