I want to use a pointer to a two dimensional array like it was an array name. This code works and I am okay with that but it uses pure pointer arithmetic, however, for readability I want to use the pointer like array notation instead.
Code: Select all
unsigned char *mvsQ[] = { &mvsNW[0][0], &mvsNE[0][0], &mvsSW[0][0], &mvsSE[0][0],
&mvsNN[0][0], &mvsEE[0][0], &mvsSS[0][0], &mvsSW[0][0] };
Code: Select all
void WSBBG(threadS *t, u08 id, u08 fs, u08 *inv, u64 *bb) {
u08 i;
u64 ray;
do {
i = FirstBit32(*inv);
*inv ^= (1 << i);
switch (i) {
...
case NN:
ray = (rayNN[fs] & belowInc[FirstBit64(rayNN[fs] & t->aPieces)] & ~t->wPieces);
*bb &= andNN[fs];
*bb |= ray; mvsNN[fs][0] = (u08)__popcnt64(ray);
break;
...
mvs = mvsQ[i];
while (ray) {
n++;
ts = FirstBit64(ray);
ray ^= one << ts;
*(mvs + (((fs << 3) + n))) = ts; // I want to do something like, mvs[fs][n] = ts;
}
*(mvs + (fs << 3)) = n;
t->inv[t->brd[fs]][t->top[t->brd[fs]]] = 0;
} while (*inv);
}