You didn't say but you could try inserting the loop I told you before writing various things to the screen.
- LDA $4210
BPL -
If you do, it *should* wait until you are in the safe time to write to the PPU. Maybe you really are just running out of time. Actually thinking right now, how are you throttling your loop? Do you have a loop similar to what I posted? Or does it run without any throttling? If it runs without any throttling it is no wonder you have it so "sometimes" it works but most of the time it doesn't. If it is that way, the time at which you write to the screen is totally random. You must only write during vblank or force blank. If you write at any other time writes are either ignored or will corrupt VRAM.
Try adding this right here:
$00/F085 C2 20 REP #$20
Add before this:
- LDA $4210
BPL -
- LDA $4210
BPL -
This will wait for the VLANK flag to be set, twice, just incase it catches VBLANK late. This will give the best case scenario on time to write to the PPU through this code segment you posted. This could fix all your issues.
If this doesn't fix your issues, you can add this loop before other writes to the PPU to again make sure you write at the safe time, but I don't think you'll need it anywhere but the beginning of your writing/update.