Pulse wave formula I am developing a Game Boy emulator and I need to get a formula for generating pulse waves, like this:

(picture from this Wikipedia page)
I know that it is possible to generate a square wave with this formula: 
$$f(x) = A (-1)^{\lfloor 2 (x - x0) / T \rfloor}$$
What formula could I use to get a pulse wave?

You can generate your picture using:
$$\frac{x}{T} - \left\lfloor\frac{x}{T}\right\rfloor < \frac{\tau}{T}$$ where $<$ is a two-argument function that gives $1$ when true and $0$ when false, as is common in programming languages like C.  The left hand side is the phase in $[0..1)$.
(Note when implementing on a computer it's best to accumulate the phase with wrapping, to avoid floating point precision issues that will be noticeable after a few minutes with 32bit float.)
