#include <tscope.h>
#define BLANKTM mtt(500)
#define MAXTM mtt(3500)
struct {
int rt, err;
int presstime;
int resp;
} data;
struct {
__int64 junk;
__int64 t1, e1;
__int64 t2, e2;
__int64 t3, e3;
} tmp;
void trial()
{
ts_vsync(&tmp.junk, &tmp.junk);
ts_printf_centre(0, 0, "+");
ts_wait(BLANKTM);
ts_vsync(&tmp.t1, &tmp.e1);
ts_clrscr();
ts_printf_centre(0, 0, "stimulus");
data.resp = ts_resp(&tmp.t2, &tmp.e2, MAXTM);
ts_release(&tmp.t3, &tmp.e3, mtt(0));
ts_clrscr();
data.rt = ttm(tmp.t2 - tmp.t1);
data.err = ttmu(tmp.e1 + tmp.e2 + tmp.e3);
data.presstime = ttm(tmp.t3 - tmp.t2);
}
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, 60, "response: %d", data.resp);
ts_printf_centre(0, 20, "rt: %4d ms", data.rt);
ts_printf_centre(0, -20, "presstime: %4d ms", data.presstime);
ts_printf_centre(0, -60, "error: %4d us", data.err);
ts_mousepos(0, 0);
ts_button(XMAX - 20, -YMAX + 20);
return 0;
}
END_OF_MAIN();