/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    map3.c
    preparing stimuli on memory bitmaps
*/

#include <tscope.h>


// set the global bitmap pointers
map *fix, *mask, *prime, *target;


// allocate memory for all bitmaps
// draw the bitmaps that are the same on each trial 
// (== fixation and mask bitmap)
void makemaps()
{
    // allocate memory
    fix = ts_makebmp(50, 50);
    mask = ts_makebmp(50, 50);
    prime = ts_makebmp(50, 50);
    target = ts_makebmp(50, 50);

    // draw fixation bitmap
    ts_tobmp(fix);
    ts_line(20, 0, -20, 0);
    ts_line(0, 20, 0, -20);

    // draw mask bitmap
    ts_tobmp(mask);
    int i;
    for (i = -50; i < 50; i += 2)
        ts_line(i, 50, i, -50);
    for (i = -50; i < 50; i += 2)
        ts_line(50, i, -50, i);

    // set the screen as drawing destination
    ts_toscr();
}

// remove bitmaps from memory after use
void killmaps()
{
    // free memory
    ts_killbmp(fix);
    ts_killbmp(mask);
    ts_killbmp(prime);
    ts_killbmp(target);
}


// befor the trial starts, draw the stimuli 
// that change in between trials
// (== prime and target)
void trial()
{
    // draw prime on prime bitmap
    ts_tobmp(prime);
    ts_circle(0, 0, 30);

    // draw target on target bitmap
    ts_tobmp(target);
    ts_rect(30, 30, -30, -30);

    // set screen as drawing destination
    ts_toscr();
    __int64 junk;


    // fixation
    ts_vsync(&junk, &junk);
    ts_blit(fix, 0, 0);
    ts_wait(mtt(500));
    ts_clrscr();
    ts_wait(mtt(500));

    // premask
    ts_vsync(&junk, &junk);
    ts_blit(mask, 0, 0);

    // prime
    ts_vsyncs(&junk, &junk, 10);
    ts_blit(prime, 0, 0);

    // postmask
    ts_vsyncs(&junk, &junk, 10);
    ts_blit(mask, 0, 0);

    // target
    ts_vsyncs(&junk, &junk, 10);
    ts_blit(target, 0, 0);

    // blank
    ts_vsyncs(&junk, &junk, 10);
    ts_clrscr();

}

int main()
{
    // open Tscope
    ts_scrsize(SIZE1);
    ts_init();
    ts_bgcolor(WHITE);
    ts_fgcolor(BLACK);

    // make the maps
    makemaps();

    ts_printf_centre(0, 20, "bitmaps are ready in memory");
    ts_printf_centre(0, -20, "press next to blit them to the screen");
    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();

    trial();

    // destroy the maps after use
    killmaps();

    ts_button(XMAX - 20, -YMAX + 20);
    ts_clrscr();
    return 0;
}

END_OF_MAIN();


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