(SOLVED) help with 4.5.6 npc text issue

Deadbear

New member
so i have a bug that is in need of some serious ironing.
i am using the adventure module in 4.5.6
whenever i talk to an npc, and press the B button or any directional button while
text is being drawn, it either freezes or glitches out real bad.

I saw Joe say something about this in a post on the FB page, but I can't figure out how to do it.
he mentioned disabling player input while text is being drawn.
can someone please help walk me through this?
 
Last edited:

pigeonaut

Member
Hey Deadbear!

I think you're right and the easiest way to fix this bug is to disable player input while the text is drawing. Here are the steps that have helped me solve this issue:
1. We need to (A) determine the place BEFORE the textbox is drawn and (B) the place AFTER the text box (and all of the text inside) is drawn.

A is easy, just go inside the NPC text trigger script or auto tile script and find the line

Code:
DrawBox #BOX_1_ORIGIN_X, #BOX_1_ORIGIN_Y, #BOX_1_WIDTH , #BOX_1_HEIGHT, #TEXT_NPC, screenText

This line starts drawing the textbox.

B took me some time to find but I finally found where the text finishes in the script "doDrawText.asm" at around line 211 just under this piece of code:


Code:
    +notDrawingVariableNumber
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    
+continueRoutine        
        LDA temp
        CMP #$FF
        BNE notEndOfText
        endOfText:
        
    ;;;Right here!   
    PlaySound #sfx_powerup ;; this soundfx should go off as soon as the text has finished drawing!

I used sound effects to help me step through the code haha

But what if you had text that spawned multiple pages? (For when you add a ">" sign to your text boxes). Well that is finished somewhere else in the "doDrawText.asm" script at around line 293 under this piece of code:


Code:
    PLA
            TAY
            LDA #$00
            STA textHandler
            JMP endOfText
        notEndTrigger:
        CMP #_MORE
        BNE notMoreText
  ;;;Right here!   
    PlaySound #sfx_powerup ;; this soundfx should go off as soon as the text has finished drawing before the ">" place !


2. Using this information, you will need to figure out a way to stop player input between the line "drawBox" and where the text finished drawing in step B.
Here is what I did:
A. I created a new user variable and called it "is_drawing_box" and set it to 0. Then right before the "drawBox" line I set that variable to 1.
B. In the "doDrawText.asm" script at line ~211 I set the "is_drawing_box" back to 0
C. Then in ALL my player input scripts I added this check at the top:

Code:
LDA is_drawing_box ;; Check if box is still drawing
CMP #$00
BEQ +do_player_input ;;no longer drawing so we can do player input again!
    JMP skip_player_input ;; is_drawing_box is still a 1 so that must mean the text is still drawing. Better skip player input to avoid freezing the game!
+do_player_input
;; player input stuff

skip_player_input
RTS

This is what worked for me but I'm sure this can be more streamlined!

Please let me know if you have any questions and if any of this helped!
 

Deadbear

New member
hey thank you so much for the help! i am having a little trouble implementing it though. what code do i use to set the is_drawing_box variable?
 

pigeonaut

Member
Sure! After you have added that variable into project/project settings/user variables, you can set the variable like this:
Code:
LDA #$01 ;;this will load the number 1
STA is_drawing_box ;;this will set is_drawing_box to whatever has been loaded above this. (1)
 

pigeonaut

Member
ok thank you, thats what i thought, but i keep getting vectors.asm(1) out of range
Interesting.. I got that same error awhile back. I wonder if you are out of space in your $1F bank https://www.nesmakers.com/index.php...-more-custom-scripts-out-of-range-error.6434/

You can check the space by using the "nes space checker" tool: https://shiru.untergrund.net/software.shtml

Do you have a lot of custom scripts in your game right now?

If not can I see the script you are trying to change?
 

Deadbear

New member
ok so i removed some things, and i'm not getting that error now, i guess i'm going to have to start freeing up some space lol. thanks for the help.
 

Deadbear

New member
ok... so this is where i am now. i have it where it disables player input when text is being drawn, but it doesn't reset the variable back to 0 when i'm done.
 

Attachments

  • 2021-01-13_18-17-35.png
    2021-01-13_18-17-35.png
    24.2 KB · Views: 21
  • 2021-01-13_18-18-09.png
    2021-01-13_18-18-09.png
    18.8 KB · Views: 21

Deadbear

New member
well i got the right one edited, but it still doesn't set the variable back to 0.. i'm still tinkering, but do you have any ideas?
 

Deadbear

New member
just fact that after i talk to someone, i can't move up are use my projectile (those are the only inputs i have applied your code to so far)
 

pigeonaut

Member
Hmm that's a weird one. Based on the code you showed me it should be working.

Can you add a soundFX after the variable is set to 0 and confirm that the sound plays after the text is drawn?

Playsound #sfx_powerup

You will need to import the sound effects by right clicking sound on the left side and importing the famitracker.txt from the tutorial assets folder. Unless you have your own soundfx hooked up.
 
Top Bottom