Can you see why your code doesn't work? It's worth spending a little time walking through it yourself instruction by instruction to see exactly what it's doing, and think about how that differs from what you expected.
Spoilers below:
I assume you have a 32x32 display, with each pixel being represented by one byte in the range $0200 - $05FF. To clear it, you want to write to every byte in this range. You're counting down to 0, which is an idiomatic thing to do on the 6502 as many instructions automatically set the Z flag. So you want the first bytes to be written at $02FF, $03FF, $04FF, and $05FF.
Your code loads X with $FF, which you'd think would be right. But the first thing it does is decrement it, so the first time through the loop it's actually writing to $02FE, $03FE, $04FE, and $05FE. What you want is for X to be $FF
after that first decrement. Loading it with $00 will do that.
I said before that many 6502 instructions automatically set the Z flag. DEX is one of them, so you don't need the CPX #$00 after it. It's not wrong to leave it in, but idiomatic 6502 code will omit it. It's worth noting that STA doesn't change the flags, so although separating the branch from the instruction that sets the flag makes me nervous, there's nothing wrong with it.
This code should work:
Code:
ldx #$ff
lda #$00 ; changed $ff to $00 so the first writes are to $xxff
drawPixel:
dex
; removed cpx #$00 as it is redundant
sta $0200,x
sta $0300,x
sta $0400,x
sta $0500,x
bne drawPixel
brk