/* * Copyright (C) 2007 Michael Lewis * Author: Mike Lewis * * This work is provide AS IS, and has no warranty. * The author is NOT responsible for anything that happens * due to use of this code, either using it or running it on * your system */ #ifdef __SSE2__ #include #include #endif #include #include #include "types.h" #include "helpers.h" //The get and set ops are scalar and slow. __m128i set_bit( __m128i A, int col ) { char* bytes = (char*)&A; int byte = col % 16; int shift = col / 16; bytes[byte] |= 0x01 << shift; return A; } char get_bit( __m128i A, int col ) { char* bytes = (char*)&A; int byte = col % 16; int shift = col / 16; return ( bytes[byte] >> shift ) & 0x01; } void print_packed_row( __m128i A ) { int i, j; for( i = 0; i < 8; i++ ) { __m128i fin = unpack( A, i ); unsigned char *f = (unsigned char*)&fin; for( j = 0; j < 16; j++ ) { printf( *f ? "@" : "." ); f++; } printf( " " ); } } void print_life_block( life_block *block ) { int i; for( i = 0; i < 128; i++ ) { printf( "%3.d ", i ); print_packed_row( (*block->current)[i] ); printf( "\n" ); } fflush( stdout ); } void set_bit_in_block( life_block *block, int row, int column ) { (*block->current)[row] = set_bit( (*block->current)[row], column ); }