Autotext Tile in 4.1

Bucket Mouse

Active member
This evening I did some heavy experimentation, trying to build an Autotext tile in NESMaker 4.1. Feel like I'm really close now. I got a text box to appear with just these three lines:

Code:
    LDA #%10000000
    STA textboxHandler
    JSR HandleTextBox

The first two lines are what replaced textBoxFlag in this version; this bit must be set to "On" before you subroutine to HandleTextBox. I'm not sure what's happening after that, though.

Here's the strange part: My character can actually move while the text box is drawing, and while it is displayed. But he can't move while the box is undrawing. Also, the character is automatically moving in one direction when I hit the tile, only now it's upwards. Moving the control pad in any direction stops it.

There is a macro called "DrawText," and I experimented with it first, but it demands two ARGuments to work, arg0 and arg1. I have no idea what, exactly, it wants there. I do know that I've tried a few things and none have generated a text box with DrawText. DrawText never subroutines to HandleTextBox so how is it supposed to know to even draw one? It simply doesn't.

Maybe these things are supposed to work in tandem? If so how? DrawText is not used in the existing code anywhere and HandleTextBox is just referenced once, in HandleBoxes. So they never work together anywhere in this.
 

dale_coop

Moderator
Staff member
Here's mine:

Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	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
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:
 

Bucket Mouse

Active member
Once again you are nine steps ahead of me. Bravo!

For some reason though the code doesn't function for me with the two "collisionTable" lines active; I dummied them out and the code worked. Why does the current tile collision data need to be checked? Everything seems to work without it.

You can still see the sprites. HideSprites takes care of that, but the effect doesn't reverse when the text box undraws. If I put ShowSprites at the end, the sprite never disappears to begin with. It seems to be reading the entire code sequence before it does anything. How do I put in a check to have it verify the text box is gone and then restore the sprite?
 

dale_coop

Moderator
Staff member
Another version would be (inspired by the collectable tile script, uses a "tileCollisionFlag" to know if the textbox has already been displayed):
Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+	
	LDA #$01
	STA tileCollisionFlag
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:


And for hiding the sprites, something I did is... Modify the HandleTextBox.asm (in the "Routines\Basic\System\" folder)...
Line 29, uncomment the line:
Code:
notAlreadyWritingToNT
	HideSprites	;;dale_coop, hides the sprites during text box
;; DO TEXT BOX STUFF.

Line 641, uncomment the line:
Code:
	ShowSprites	;;dale_coop, show back the sprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; check to see if there is behavior after a text box.
(I have so many modifications in my scripts... sometimes I don't remember if it was a line I wrote and had it commented out... or it it was already there and just uncommented it or... :p)
 

dale_coop

Moderator
Staff member
The + sign is like a label (but no required to be unique. So you can use many of them, in the same script)
Code:
	LDA myVar
	BEQ +	;; if null branch out to the next "+" label
	;; do anything if myVar is NOT null
	JMP ++	;; jump the  next "++" label
+
	;; do anything if myVar IS null
++
;; last things to do ...
 

JFranco

New member
Using this code:

CPX player1_object
BNE finishedWithAutoText

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

;; activate the text-box
LDA gameHandler
ORA #%00100000
STA gameHandler
LDA #%10000000
STA textboxHandler

;;TriggerScreen screenType

finishedWithAutoText:

...it displays the text string from Text 1 of the assigned Text Group. How would I get it to always reference the text string in Text 3 of the Text Group instead? is it a simple variable I'd need to swap? (I'm having trouble figuring this out....)
 

dale_coop

Moderator
Staff member
JFranco said:
...it displays the text string from Text 1 of the assigned Text Group. How would I get it to always reference the text string in Text 3 of the Text Group instead? is it a simple variable I'd need to swap? (I'm having trouble figuring this out....)

To use the Text 3, here the script (cf my comments, at the middle of the script):

Code:
	CPX player1_object
	BNE finishedWithAutoText

	LDA tileCollisionFlag
	BEQ +
	JMP finishedWithAutoText
	+ 
	LDA #$01
	STA tileCollisionFlag

	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret

	;;; !! HERE !!  you can set the text you want (Text 1="00" or Text 3="01" or Text 4="02" or Text 4="03" from the TextGroup assigned to your screen):
	LDA #$02  ;;<<-- it will use the "Text 3" of your screen
	STA textVar

	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler

	;TriggerScreen screenType

finishedWithAutoText:
 

Bucket Mouse

Active member
I bet I could string together all four boxes of the Text Group with textVar. it doesn't seem to work this way, though:

Code:
    ;;; !! HERE !!  you can set the text you want (Text 1="00" or Text 3="01" or Text 4="02" or Text 4="03" from the TextGroup assigned to your screen):
    LDA #$00  ;;<<-- it will use the "Text 3" of your screen
    STA textVar
    
    textLoop:

    ;; activate the text-box:
    LDA gameHandler
    ORA #%00100000
    STA gameHandler
    LDA #%10000000
    STA textboxHandler
    
    INC textVar
    CMP #$03
    BEQ finishedWithAutoText
    
    JMP textLoop

    ;TriggerScreen screenType
    
finishedWithAutoText:
This modification just freezes the game.
 
I can't seem to get this to work. One thing I don't understand is the "finishedWithAutoText". Doesn't this imply that there is some kind of autotext command or macro existing somewhere in the asm files? I don't see any reference to it in the text box asm. I feel like I am missing something and this is calling for something that hasn't been defined/created in my asm.
 

Bucket Mouse

Active member
BentPawGames said:
I can't seem to get this to work. One thing I don't understand is the "finishedWithAutoText". Doesn't this imply that there is some kind of autotext command or macro existing somewhere in the asm files? I don't see any reference to it in the text box asm. I feel like I am missing something and this is calling for something that hasn't been defined/created in my asm.

"Finished with AutoText" is not a macro or a variable, it's a marker. If you look at the end, it's listed there. The code says to skip to the line called "Finished with AutoText" whenever it's done.

There's an easy way to find these things out: open the folders in Windows where NESMaker is located and do some search commands for a specific name. All the ASM files where it comes up will be listed. You'll be able to see exactly what it does and how it's used throughout the game.

Someone please help me with my Countdown Timer problem; I'm still waiting for a response in the other topic.
 
I Figured it out guys! thanks so much this is going to send my adventure game to the next level.I feel a a Community tutorial for this would be admicably beneficial to the entire community as auto text is a very important aspect of story telling at the smalles level in games!!! keep it up you guys rock
 
dale_coop said:
Here's mine:

Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	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
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:

Hey Dale. A bit less experienced of a user here. How does one go about implementing this into their project? So far I've created the new file in the Module/TileScripts/Adventure, and I've imported it. What else needs to be done to get it to function?
 
Nevermind. Linked it up to TileCollision09 by exploring the Project Settings and using common sense. Dale, you're one hell of a guy. I'd give my good nut for half the skill you possess.
 

dale_coop

Moderator
Staff member
Inspired by the collectable tile type, you could try something like that:

Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	LDA tileCollisionFlag
	BEQ +
	JMP finishedWithAutoText
+
	LDA #$01
	STA tileCollisionFlag
	
	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
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:
 
For some reason Dale's original code still doesn't work for me:

Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	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
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:

But then his other version does:

Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+	
	LDA #$01
	STA tileCollisionFlag
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:


However, while the text box comes up, I can't make it advance or go away by pressing the B button like I normally would. Not sure what is going on there.
 
Top Bottom