The textbox will always be behind the objects. Because it's made from Bg tiles.
Try to design your screen for always having the npc and the player on the bottom / under the textbox area.
Another solution would be to hide all the objects when a textbox is displayed: http://nesmakers.com/viewtopic.php?p=13559#p13559
For the DrawOrder... the function checks the top position of each object, if the top is lower, it will be rendered in front. if upper, it will be displayed behind.
If you are making a Platformer you could use the cycling to have the Player always in front of the other objects: http://nesmakers.com/viewtopic.php?f=40&t=2455
If you are making a Adventure Top Down game, a better code would be to check the bottom of the objects instead of the top: if the bottom is lower, the object should be in front of the others..
Here's the "UpdateDrawOrder" subroutine for that (to replace the one in the HandleUpdateObjects.asm script)
Code:
UpdateDrawOrder:
LDX #$1
OrderLoop:
LDY drawOrder,x
LDA Object_y_hi,y
CLC
ADC Object_bottom,y
STA temp
LDY drawOrder-1,x
LDA Object_y_hi,y
CLC
ADC Object_bottom,y
CMP temp
BCS doneWithSwapItem
LDA drawOrder,x
STA drawOrder-1,x
TYA
STA drawOrder,x
doneWithSwapItem:
INX
CPX #TOTAL_MAX_OBJECTS
BNE OrderLoop
RTS