/*  
    File:               vpw_trial.c
    Author:             michael stevens
    Experiment:         Viewing position effect (words)
                        Stevens & Grainger 2003
                        
        Trial definition

            Fixation:   1000ms          2 vertical bars above and below stimulus
            Blank:      0ms             (fixation mark disappears at onset stimulus)
            Stimulus:   50ms
            Mask:                       until response
            Instruction:                'enter the word' appears 250 ms after stimulus
            Maxrt:                      no limit
            Iti:        500ms
*/


// include functions from vpw_data.c
#define VPW_TRIAL_C
#include "vpw_data.c"

#include <ctype.h>              // declaration of toupper function

// timing intervals
#define FIXTM   mtt(1000)
#define BLTM    mtt(0)
#define STM     3
#define INSTM   mtt(250)
#define ITI     mtt(500)

// temporary timing data
struct {
    __int64 junk;
} rttmp;

// trial definition
void trial(int i)
{
    // determine font size
    int w = ts_textheight();
    int h = ts_textlength("A");

    // prepare mask
    char m[20];
    int mpos;
    if (data[i].wlen == 5) {
        if (data[i].mask == SMALL) {
            sprintf(m, "#######");
            mpos = data[i].sloc;
        } else {
            sprintf(m, "###########");
            mpos = 0;
        }
    } else {
        if (data[i].mask == SMALL) {
            sprintf(m, "#########");
            mpos = data[i].sloc;
        } else {
            sprintf(m, "###############");
            mpos = 0;
        }
    }

    // fixation
    ts_vsync(&rttmp.junk, &rttmp.junk);
    ts_printf_centre(0, h, "|");
    ts_printf_centre(0, -h, "|");
    ts_wait(FIXTM);

    // word
    ts_vsync(&rttmp.junk, &rttmp.junk);
    ts_clrscr();
    ts_printf_centre(data[i].sloc * w, 0, data[i].stim);

    // mask
    ts_vsyncs(&rttmp.junk, &rttmp.junk, STM);
    ts_clrscr();
    ts_printf_centre(mpos * w, 0, m);

    // response
    ts_wait(INSTM);
    ts_clrscr();
    int ipos = ts_printf(-ax(.9), -ay(.9), "Word: ");
    ts_scanf(-ax(.9) + ipos, -ay(.9), "%s", data[i].resp);

    // process response
    ts_clrscr();
    int j = 0;
    while (data[i].resp[j] != '\0') {
        data[i].resp[j] = toupper(data[i].resp[j]);
        j++;
    }

    if (strcmp(data[i].stim, data[i].resp))
        data[i].corr = E;
    else
        data[i].corr = C;

    // escape?
    int r = ts_resp(&rttmp.junk, &rttmp.junk, ITI);
    if (r) {
        writedata();
        ts_fatal("aborted by user");
    }
}


// test-function
#ifndef VPW_EXP_C
int main()
{
    // black text background
    ts_textmode(BLACK);

    // activate escape key
    ts_defkey(KEY_ESC);

    // prepare data
    readwords();
    randomize(0);

    int i;
    for (i = 0; i < NTRIALS; i++)
        trial(i);

    // write data
    writedata();
    return 0;
}

END_OF_MAIN();
#endif                          // VPW_EXP_C


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information