coopth: remove switching states that basically mirrored the thr ret value

Use COOPTHS_SWITCH state and switching functions instead.
coopth: simplify state switching logic

Any switch now happens via COOPTHS_SWITCH.
COOPTHS_RUNNING now means no switch - no more exceptions from that rule.
COOPTH_DETACH now works through 2 switches more explicitly.
coopth: coopth_asleep() should work through sleep handlers
coopth: finally replace "goto again" with the do-while loop
coopth: make state a struct

containing enum and switch func pointer.
coopth: remove no longer needed COOPTHS_STARTING state

It was introduced by commit 9a5d80bc to allow early cancellation.
But later (eg c3de9196) the proper cancellation was implemented.
coopth: clean up state switching a bit more

Had to change emu.h to avoid redefinition of WAIT
coopth: clean up thread deletion