In some other screen modes, "planes" complicate things, but "screen 13" is simple.
offset = y * 320 + x
x = offset MOD 320
y = offset \ 320
The POKE line in the .bas file in the other post could be replaced with:
PSET ((p& + c) MOD 320, (p& + c) \ 320), sins(r + f) + sins(c + f) + sins(r + c) + rands(f2 * r + c)