#include <tscope.h>
#define FIXTM mtt(500)
#define BLANKTM mtt(500)
#define MAXTM mtt(1500)
struct {
int rt;
int re;
int resp;
} data;
struct {
__int64 junk;
__int64 t1, e1;
__int64 t2, e2;
} tmp;
void trial()
{
ts_vsync(&tmp.junk, &tmp.junk);
ts_printf_centre(0, 0, "+");
ts_wait(FIXTM);
ts_vsync(&tmp.junk, &tmp.junk);
ts_clrscr();
ts_wait(BLANKTM);
ts_vsync(&tmp.t1, &tmp.e1);
ts_printf_centre(0, 0, "stimulus");
data.resp = ts_resp(&tmp.t2, &tmp.e2, MAXTM);
ts_clrscr();
data.rt = ttm(tmp.t2 - tmp.t1);
data.re = ttmu(tmp.e1 + tmp.e2);
}
int main()
{
ts_printf_centre(0, 20, "press one of the mouse buttons");
ts_printf_centre(0, 0, "within 1500ms after the appearance");
ts_printf_centre(0, -20, "of the stimulus");
ts_button(XMAX - 20, -YMAX + 20);
ts_clrscr();
ts_defkey(M1);
ts_defkey(M2);
trial();
ts_printf_centre(0, 50, "response: %d", data.resp);
ts_printf_centre(0, 0, "reaction time: %4d milliseconds", data.rt);
ts_printf_centre(0, -50, "timing error: %4d microseconds", data.re);
ts_button(XMAX - 20, -YMAX + 20);
return 0;
}
END_OF_MAIN();