[4.5.9] Prevent button mashing during text boxes

dale_coop

Moderator
Staff member
When interacting with NPCs and initiating dialogue, repeatedly pressing the button quickly can lead to glitches in the text.

npctext.gif

To prevent this issue, at the beginning of your doDrawNPCText input text, I'd suggest to add this small piece of code:

Code:
;; checking if the text box is already displayed
LDA gameStatusByte
AND #%00000001
BEQ +continue:
    ;;; we also check if text box is about to be drawn / or currently drawing
    LDA textQueued
    AND #%00000011
    BEQ +skip
        JMP dontSkipNPCtext
    +skip:
        RTS
+continue:

Voilà. It's a small tweak, but it should help.
 

Bucket Mouse

Active member
It's also possible to glitch up the text data by mashing while the box is UN-drawing. In this case the next text entry you read will be the wrong one. This solution doesn't cover for that.
 

dale_coop

Moderator
Staff member
It's also possible to glitch up the text data by mashing while the box is UN-drawing. In this case the next text entry you read will be the wrong one. This solution doesn't cover for that.
Have you encountered any issues with my code? I couldn't reproduce any glitches during the 'UN-drawing' process, but I would be happy to investigate further if you have come across any.
 
When interacting with NPCs and initiating dialogue, repeatedly pressing the button quickly can lead to glitches in the text.

View attachment 7743

To prevent this issue, at the beginning of your doDrawNPCText input text, I'd suggest to add this small piece of code:

Code:
;; checking if the text box is already displayed
LDA gameStatusByte
AND #%00000001
BEQ +continue:
    ;;; we also check if text box is about to be drawn / or currently drawing
    LDA textQueued
    AND #%00000011
    BEQ +skip
        JMP dontSkipNPCtext
    +skip:
        RTS
+continue:

Voilà. It's a small tweak, but it should help.
Dale i cannot seem to find the script for doDrawNPXText can you tell me where its located?
 

dale_coop

Moderator
Staff member
It's also possible to glitch up the text data by mashing while the box is UN-drawing. In this case the next text entry you read will be the wrong one. This solution doesn't cover for that.
Try adding a :
Code:
LDA queueFlags
BNE +skip
before the "JMP dontSkipNPCtext" line.
 

dale_coop

Moderator
Staff member
Dale i cannot seem to find the script for doDrawNPXText can you tell me where its located?
(that script is not difficult to find... it's in the "InputScripts", or the "Mod_AdventureBase\InputScripts" folders)
Check the Adventure "intermediate" tutorial, it explains how to set up that script.
 

Bucket Mouse

Active member
Try adding a :
Code:
LDA queueFlags
BNE +skip
before the "JMP dontSkipNPCtext" line.
Tried it. It prevents the loading error for NPC's but not for tiles that I've coded to serve the same function as NPCs. The code for that looks like this:


Code:
    LDA npcTrigger
    ORA #%00000001
    STA npcTrigger

LDA gamepad
        AND #%00000001
        BNE +
            RTS
        +
            LDA textHandler
    BEQ +stupidlimit
JMP    ++
+stupidlimit:
    
        DrawBox #BOX_1_ORIGIN_X, #BOX_1_ORIGIN_Y, #BOX_1_WIDTH, #BOX_1_HEIGHT, #TEXT_NPC, screenText+1
        RTS
        
++

What would I modify there?
 

dale_coop

Moderator
Staff member
But what should I put in the tile script?
Hmm...
maybe just a
Code:
LDA gameStatusByte
AND #%00000001
BEQ +continue
  RTS
+continue:
to prevent the DrawBox to happen when there is already a textbox
the rest should be in the input script.
 
Top Bottom