You've narrowed the problem down really well! Without having tested it, it looks like it's pretty much as you said. When the NPC sprite displays a message from another level, it tricks the game into thinking the current level number is something else, but it never restores the proper level number after it's done, so it leaves the dragon coin patch thinking you're in another level.
Here's a quick fix that might work. After
print "INIT ",pc
, add these lines:
, add these:
Not sure how well this will work, especially when there are multiple NPCs on-screen at the same time, but it's worth a try.
(Also, thanks for reminding me that I've been meaning to remake those sprites sometime. The current ones are showing their age.)