/* * EffecTV - Realtime Digital Video Effector * Copyright (C) 2001-2003 FUKUCHI Kentaro * * LifeTV - Play John Horton Conway's `Life' game with video input. * Copyright (C) 2001-2002 FUKUCHI Kentaro * * This idea is stolen from Nobuyuki Matsushita's installation program of * ``HoloWall''. (See http://www.csl.sony.co.jp/person/matsu/index.html) */ #include #include #include "EffecTV.h" #include "utils.h" static int start(void); static int stop(void); static int draw(RGB32 *src, RGB32 *dest); static int event(); static char *effectname = "LifeTV"; static int stat; static unsigned char *field, *field1, *field2; static void clear_field() { memset(field1, 0, video_area); } effect *lifeRegister() { effect *entry; sharedbuffer_reset(); field = (unsigned char *)sharedbuffer_alloc(video_area*2); if(field == NULL) { return NULL; } entry = (effect *)malloc(sizeof(effect)); if(entry == NULL) { return NULL; } entry->name = effectname; entry->start = start; entry->stop = stop; entry->draw = draw; entry->event = event; return entry; } static int start() { image_set_threshold_y(40); field1 = field; field2 = field + video_area; clear_field(); stat = 1; return 0; } static int stop() { stat = 0; return 0; } static int draw(RGB32 *src, RGB32 *dest) { int x, y; unsigned char *p, *q, v; unsigned char sum, sum1, sum2, sum3; int width; RGB32 pix; width = video_width; p = image_diff_filter(image_bgsubtract_update_y(src)); for(x=0; x> 8; *dest++ = pix | *src++; sum1 = sum2; sum2 = sum3; p++; } p += 2; q += 2; src += 2; dest += 2; } p = field1; field1 = field2; field2 = p; return 0; } static int event(SDL_Event *event) { if(event->type == SDL_KEYDOWN) { switch(event->key.keysym.sym) { case SDLK_SPACE: clear_field(); break; default: break; } } return 0; }