from what you have described so far, it may be easier than it seems to implement this..... maybe.
1, you have to use timer interrupt at 50micro seconds..... the highest common value for both times
2, you implement a while/wend loop with block of code for main X....hi/low and total run ... and block of code for Y .... with values you calculated
3, using counters in blocks to toggle pins and exit while when pulses/count are reached
4, outside of while blocks to get/calculate new Y's.... do other stuff then startup a new round of pulses
5, the constraint is all the code inside blocks have to be less than 50micro seconds..... at 20 MHZ should able to do about 100 to 200 instructions in 50micro seconds