/* All Rights Reserved - 2000 */

/*--------------------------------------------------------------------------*/

#include <assert.h>
#include "ccd.h"
#include "ccdpp.h"

/*--------------------------------------------------------------------------*/

#define SZ_ROW      64
#define SZ_COL      128

/*--------------------------------------------------------------------------*/

static char buffer[SZ_ROW][SZ_COL];
static unsigned rowIndex;
static unsigned colIndex;

/*--------------------------------------------------------------------------*/

void CcdppInitialize() {
    
    rowIndex = -1;
    colIndex = -1;
}

/*--------------------------------------------------------------------------*/

void CcdppCapture(void) {
    
    char bias;
    
    CcdCapture();
    for(rowIndex=0; rowIndex<SZ_ROW; rowIndex++) {
        
        for(colIndex=0; colIndex<SZ_COL; colIndex++) {
            
            buffer[rowIndex][colIndex] = CcdPopPixel();
        }
        
        bias = (CcdPopPixel() + CcdPopPixel()) / 2;     
        for(colIndex=0; colIndex<SZ_COL; colIndex++) {
            
            buffer[rowIndex][colIndex] -= bias;
        }
    }
    rowIndex = 0;
    colIndex = 0;
}

/*--------------------------------------------------------------------------*/

char CcdppPopPixel(void) {
    
    char pixel;
    
    assert( rowIndex != -1 );
    assert( colIndex != -1 );
    
    pixel = buffer[rowIndex][colIndex];
    
    if( ++colIndex == SZ_COL ) {
        
        colIndex = 0;
        if( ++rowIndex == SZ_ROW ) {
            
            colIndex = -1;
            rowIndex = -1;
        }
    }
    return pixel;
}
<div align="center"><br /><script type="text/javascript"><!--
google_ad_client = "pub-7293844627074885";
//468x60, Created at 07. 11. 25
google_ad_slot = "8619794253";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />&nbsp;</div>