mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-20 06:40:01 +01:00
Refactor / dices : code format
* trailling spaces + indentation
This commit is contained in:
@@ -42,7 +42,8 @@ static uint8_t *g_dicemap=NULL;
|
|||||||
|
|
||||||
void dice_create_map(int w, int h);
|
void dice_create_map(int w, int h);
|
||||||
|
|
||||||
typedef enum _dice_dir {
|
typedef enum _dice_dir
|
||||||
|
{
|
||||||
Up = 0,
|
Up = 0,
|
||||||
Right = 1,
|
Right = 1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
@@ -71,7 +72,8 @@ vj_effect *dices_init(int width, int height)
|
|||||||
int next = pow(2, floor(log2(near)));
|
int next = pow(2, floor(log2(near)));
|
||||||
int limit = 1;
|
int limit = 1;
|
||||||
int iter = 1;
|
int iter = 1;
|
||||||
while(limit < next) {
|
while(limit < next)
|
||||||
|
{
|
||||||
limit = limit * 2;
|
limit = limit * 2;
|
||||||
iter ++;
|
iter ++;
|
||||||
}
|
}
|
||||||
@@ -85,11 +87,13 @@ int dices_malloc(int width, int height)
|
|||||||
{
|
{
|
||||||
g_dicemap = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height);
|
g_dicemap = (uint8_t *) vj_malloc(sizeof(uint8_t) * width * height);
|
||||||
if(!g_dicemap) return 0;
|
if(!g_dicemap) return 0;
|
||||||
|
|
||||||
dice_create_map(width, height);
|
dice_create_map(width, height);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dices_free() {
|
void dices_free()
|
||||||
|
{
|
||||||
if(g_dicemap)
|
if(g_dicemap)
|
||||||
free(g_dicemap);
|
free(g_dicemap);
|
||||||
g_dicemap = NULL;
|
g_dicemap = NULL;
|
||||||
@@ -103,9 +107,12 @@ void dice_create_map(int w, int h)
|
|||||||
g_map_width = w >> g_cube_bits;
|
g_map_width = w >> g_cube_bits;
|
||||||
g_cube_size = 1 << g_cube_bits;
|
g_cube_size = 1 << g_cube_bits;
|
||||||
maplen = maplen / (g_map_height * g_map_width);
|
maplen = maplen / (g_map_height * g_map_width);
|
||||||
for( k = 0; k < maplen;k++) {
|
for( k = 0; k < maplen;k++)
|
||||||
for (y = 0; y < g_map_height; y++) {
|
{
|
||||||
for (x = 0; x < g_map_width; x++) {
|
for (y = 0; y < g_map_height; y++)
|
||||||
|
{
|
||||||
|
for (x = 0; x < g_map_width; x++)
|
||||||
|
{
|
||||||
//g_dicemap[i] = j++;
|
//g_dicemap[i] = j++;
|
||||||
//if(j==3) j=0;
|
//if(j==3) j=0;
|
||||||
g_dicemap[i] = ((1 + (rand() * (i + y))) & 0x03);
|
g_dicemap[i] = ((1 + (rand() * (i + y))) & 0x03);
|
||||||
@@ -113,13 +120,14 @@ void dice_create_map(int w, int h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "created map of %d, %d did %d in dicemap, total is %d\n",
|
fprintf(stderr,
|
||||||
w,h,i,(w*h));
|
"created map of %d, %d did %d in dicemap, total is %d\n",
|
||||||
|
w,h,i,(w*h)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dices_apply( void* data, VJFrame *frame, int cube_bits)
|
void dices_apply( void* data, VJFrame *frame, int cube_bits)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = 0, map_x, map_y, map_i = 0, base, dx, dy, di=0;
|
int i = 0, map_x, map_y, map_i = 0, base, dx, dy, di=0;
|
||||||
int width, height;
|
int width, height;
|
||||||
frame->width = width; frame->height = height;
|
frame->width = width; frame->height = height;
|
||||||
@@ -127,19 +135,25 @@ void dices_apply( void* data, VJFrame *frame, int cube_bits)
|
|||||||
uint8_t *Cb = frame->data[1];
|
uint8_t *Cb = frame->data[1];
|
||||||
uint8_t *Cr = frame->data[2];
|
uint8_t *Cr = frame->data[2];
|
||||||
|
|
||||||
if (cube_bits != g_cube_bits) {
|
if (cube_bits != g_cube_bits)
|
||||||
|
{
|
||||||
g_cube_bits = cube_bits;
|
g_cube_bits = cube_bits;
|
||||||
dice_create_map(width, height);
|
dice_create_map(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (map_y = 0; map_y < g_map_height; map_y++) {
|
for (map_y = 0; map_y < g_map_height; map_y++)
|
||||||
for (map_x = 0; map_x < g_map_width; map_x++) {
|
{
|
||||||
|
for (map_x = 0; map_x < g_map_width; map_x++)
|
||||||
|
{
|
||||||
base = (map_y << g_cube_bits) * width + (map_x << g_cube_bits);
|
base = (map_y << g_cube_bits) * width + (map_x << g_cube_bits);
|
||||||
switch (g_dicemap[map_i]) {
|
switch (g_dicemap[map_i])
|
||||||
|
{
|
||||||
case Left:
|
case Left:
|
||||||
for (dy = 0; dy < g_cube_size; dy++) {
|
for (dy = 0; dy < g_cube_size; dy++)
|
||||||
|
{
|
||||||
i = base + dy * width;
|
i = base + dy * width;
|
||||||
for (dx = 0; dx < g_cube_size; dx++) {
|
for (dx = 0; dx < g_cube_size; dx++)
|
||||||
|
{
|
||||||
di = base + (dx * width) + (g_cube_size - dy - 1);
|
di = base + (dx * width) + (g_cube_size - dy - 1);
|
||||||
Y[di] = Y[i];
|
Y[di] = Y[i];
|
||||||
Cb[di] = Cb[i];
|
Cb[di] = Cb[i];
|
||||||
@@ -149,11 +163,12 @@ void dices_apply( void* data, VJFrame *frame, int cube_bits)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Down:
|
case Down:
|
||||||
for (dy = 0; dy < g_cube_size; dy++) {
|
for (dy = 0; dy < g_cube_size; dy++)
|
||||||
|
{
|
||||||
di = base + dy * width;
|
di = base + dy * width;
|
||||||
i = base + (g_cube_size - dy - 1) * width +
|
i = base + (g_cube_size - dy - 1) * width + g_cube_size;
|
||||||
g_cube_size;
|
for (dx = 0; dx < g_cube_size; dx++)
|
||||||
for (dx = 0; dx < g_cube_size; dx++) {
|
{
|
||||||
i--;
|
i--;
|
||||||
Y[di] = Y[i];
|
Y[di] = Y[i];
|
||||||
Cb[di] = Cb[i];
|
Cb[di] = Cb[i];
|
||||||
@@ -163,9 +178,11 @@ void dices_apply( void* data, VJFrame *frame, int cube_bits)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
for (dy = 0; dy < g_cube_size; dy++) {
|
for (dy = 0; dy < g_cube_size; dy++)
|
||||||
|
{
|
||||||
i = base + (dy * width);
|
i = base + (dy * width);
|
||||||
for (dx = 0; dx < g_cube_size; dx++) {
|
for (dx = 0; dx < g_cube_size; dx++)
|
||||||
|
{
|
||||||
di = base + dy + (g_cube_size - dx - 1) * width;
|
di = base + dy + (g_cube_size - dx - 1) * width;
|
||||||
Y[di] = Y[i];
|
Y[di] = Y[i];
|
||||||
Cb[di] = Cb[i];
|
Cb[di] = Cb[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user