
#include <Ninja.h>

Uint32 _alpha_;
Int _alpha_flag_ = 0;


void Blur(Int cnt, NJS_MATRIX *mat, void (*func)(void *), void *param)
{
    Int i;
    static Int mat_num = 0;

    _alpha_flag_ = 1;
    if(mat_num < cnt)
        njMemCopy4(&(mat[mat_num++]), _nj_current_matrix_ptr_, (Sint32)(sizeof(NJS_MATRIX)*.25f));
    else{
        for(i = 0; i < cnt-1; i++)
            njMemCopy4(&(mat[i]), &(mat[i+1]), (Sint32)(sizeof(NJS_MATRIX)*.25f));
        njMemCopy4(&(mat[cnt-1]), _nj_current_matrix_ptr_, (Sint32)(sizeof(NJS_MATRIX)*.25f));
    }

    for(i = 0; i < mat_num; i++){
        _alpha_ = (i < mat_num-1) ? (0x10|(((0x8)/cnt*i) << 4)) : 0xff;
        njPushMatrix(&(mat[i]));
        njTranslate(NULL, 0.f, 0.f, .25f*i);
        (*func)(param);
        njPopMatrix(1);
    }
    _alpha_flag_ = 0;
}
