diff options
-rw-r--r-- | source/clip.c | 90 | ||||
-rw-r--r-- | source/dsp1.c | 102 | ||||
-rw-r--r-- | source/dsp1emu.c | 74 | ||||
-rw-r--r-- | source/dsp2emu.c | 66 | ||||
-rw-r--r-- | source/dsp4emu.c | 36 | ||||
-rw-r--r-- | source/fxemu.c | 2 | ||||
-rw-r--r-- | source/fxinst.c | 2 | ||||
-rw-r--r-- | source/getset.h | 20 | ||||
-rw-r--r-- | source/globals.c | 12 |
9 files changed, 204 insertions, 200 deletions
diff --git a/source/clip.c b/source/clip.c index cc0f48b..db68e1e 100644 --- a/source/clip.c +++ b/source/clip.c @@ -56,7 +56,7 @@ void ComputeClipWindows() { if ((Memory.FillRAM [0x2130] & 0xc0) == 0xc0) { - // The whole of the main screen is switched off, completely clip everything. + /* The whole of the main screen is switched off, completely clip everything. */ for (i = 0; i < 6; i++) { IPPU.Clip [c].Count [i] = 1; @@ -68,9 +68,9 @@ void ComputeClipWindows() else if ((Memory.FillRAM [0x2130] & 0xc0) == 0x00) continue; } - else if ((Memory.FillRAM [0x2130] & 0x30) == 0x30) // .. colour window on the sub-screen. + else if ((Memory.FillRAM [0x2130] & 0x30) == 0x30) /* .. colour window on the sub-screen. */ { - // The sub-screen is switched off, completely clip everything. + /* The sub-screen is switched off, completely clip everything. */ int32_t i; for (i = 0; i < 6; i++) { @@ -121,8 +121,8 @@ void ComputeClipWindows() } else { - // 'outside' a window with no range - - // appears to be the whole screen. + /* 'outside' a window with no range - + * appears to be the whole screen. */ Win1[Window1Enabled].Left = 0; Win1[Window1Enabled++].Right = 256; } @@ -164,12 +164,12 @@ void ComputeClipWindows() } if (Window1Enabled && Window2Enabled) { - // Overlap logic - // - // Each window will be in one of three states: - // 1. <no range> (Left > Right. One band) - // 2. | ---------------- | (Left >= 0, Right <= 255, Left <= Right. One band) - // 3. |------------ ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands) + /* Overlap logic + * + * Each window will be in one of three states: + * 1. <no range> (Left > Right. One band) + * 2. | ---------------- | (Left >= 0, Right <= 255, Left <= Right. One band) + * 3. |------------ ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands) */ Band Bands [6]; int32_t B = 0; switch (PPU.ClipWindowOverlapLogic [w] ^ 1) @@ -180,7 +180,7 @@ void ComputeClipWindows() if (BAND_EMPTY(Win1[0])) { B = Window2Enabled; - // memmove converted: Different stack allocations [Neb] + /* memmove converted: Different stack allocations [Neb] */ memcpy(Bands, Win2, sizeof(Win2[0]) * Window2Enabled); } else @@ -232,17 +232,17 @@ void ComputeClipWindows() { if (BAND_EMPTY(Win2[0])) { - // Window 2 defines an empty range - just - // use window 1 as the clipping (which - // could also be empty). + /* Window 2 defines an empty range - just + * use window 1 as the clipping (which + * could also be empty). */ B = Window1Enabled; - // memmove converted: Different stack allocations [Neb] + /* memmove converted: Different stack allocations [Neb] */ memcpy(Bands, Win1, sizeof(Win1[0]) * Window1Enabled); } else { - // Window 1 has two bands and Window 2 has one. - // Neither is an empty region. + /* Window 1 has two bands and Window 2 has one. + * Neither is an empty region. */ if (BANDS_INTERSECT(Win2[0], Win1[0])) { OR_BANDS(Bands[0], Win2[0], Win1[0]) @@ -273,7 +273,7 @@ void ComputeClipWindows() } else { - // Both windows have two bands + /* Both windows have two bands */ OR_BANDS(Bands[0], Win1[0], Win2[0]); OR_BANDS(Bands[1], Win1[1], Win2[1]); B = 1; @@ -286,7 +286,7 @@ void ComputeClipWindows() case CLIP_AND: if (Window1Enabled == 1) { - // Window 1 has one band + /* Window 1 has one band */ if (BAND_EMPTY(Win1[0])) Bands [B++] = Win1[0]; else if (Window2Enabled == 1) @@ -312,7 +312,7 @@ void ComputeClipWindows() Bands[B++] = Win2[0]; else { - // Window 1 has two bands. + /* Window 1 has two bands. */ AND_BANDS(Bands[0], Win1[0], Win2[0]); AND_BANDS(Bands[1], Win1[1], Win2[0]); B = 2; @@ -320,7 +320,7 @@ void ComputeClipWindows() } else { - // Both windows have two bands. + /* Both windows have two bands. */ AND_BANDS(Bands[0], Win1[0], Win2[0]); AND_BANDS(Bands[1], Win1[1], Win2[1]); B = 2; @@ -338,18 +338,18 @@ void ComputeClipWindows() break; case CLIP_XNOR: invert = !invert; - // Fall... + /* Fall... */ case CLIP_XOR: if (Window1Enabled == 1 && BAND_EMPTY(Win1[0])) { B = Window2Enabled; - // memmove converted: Different stack allocations [Neb] + /* memmove converted: Different stack allocations [Neb] */ memcpy(Bands, Win2, sizeof(Win2[0]) * Window2Enabled); } else if (Window2Enabled == 1 && BAND_EMPTY(Win2[0])) { B = Window1Enabled; - // memmove converted: Different stack allocations [Neb] + /* memmove converted: Different stack allocations [Neb] */ memcpy(Bands, Win1, sizeof(Win1[0]) * Window1Enabled); } else @@ -359,7 +359,7 @@ void ComputeClipWindows() uint32_t i; invert = !invert; - // Build an array of points (window edges) + /* Build an array of points (window edges) */ points [p++] = 0; for (i = 0; i < Window1Enabled; i++) { @@ -372,7 +372,7 @@ void ComputeClipWindows() points [p++] = Win2[i].Right; } points [p++] = 256; - // Sort them + /* Sort them */ qsort((void*) points, p, sizeof(points [0]), IntCompare); for (i = 0; i < p; i += 2) { @@ -392,7 +392,7 @@ void ComputeClipWindows() int32_t j = 0; int32_t empty_band_count = 0; - // First remove all empty bands from the list. + /* First remove all empty bands from the list. */ for (b = 0; b < B; b++) { if (!BAND_EMPTY(Bands[b])) @@ -410,7 +410,7 @@ void ComputeClipWindows() if (j == 1) { j = 0; - // Easy case to deal with, so special case it. + /* Easy case to deal with, so special case it. */ if (Bands[0].Left > 0) { pClip->Left[j][w] = 0; @@ -429,11 +429,11 @@ void ComputeClipWindows() } else { - // Now sort the bands into order + /* Now sort the bands into order */ B = j; qsort((void*) Bands, B, sizeof(Bands [0]), BandCompare); - // Now invert the area the bands cover + /* Now invert the area the bands cover */ j = 0; for (b = 0; b < B; b++) { @@ -457,9 +457,9 @@ void ComputeClipWindows() } else { - // Inverting a window that consisted of only - // empty bands is the whole width of the screen. - // Needed for Mario Kart's rear-view mirror display. + /* Inverting a window that consisted of only + * empty bands is the whole width of the screen. + * Needed for Mario Kart's rear-view mirror display. */ if (empty_band_count) { pClip->Left[j][w] = 0; @@ -482,8 +482,8 @@ void ComputeClipWindows() } else { - // Only one window enabled so no need to perform - // complex overlap logic... + /* Only one window enabled so no need to perform + * complex overlap logic... */ if (Window1Enabled) { if (invert) @@ -587,9 +587,9 @@ void ComputeClipWindows() if (w != 5 && pClip->Count [5]) { - // Colour window enabled. Set the - // clip windows for all remaining backgrounds to be - // the same as the colour window. + /* Colour window enabled. Set the + * clip windows for all remaining backgrounds to be + * the same as the colour window. */ if (pClip->Count [w] == 0) { uint32_t i; @@ -602,8 +602,8 @@ void ComputeClipWindows() } else { - // Intersect the colour window with the bg's - // own clip window. + /* Intersect the colour window with the bg's + * own clip window. */ uint32_t i, j; for (i = 0; i < pClip->Count [w]; i++) { @@ -614,20 +614,20 @@ void ComputeClipWindows() (pClip->Left[j][5] >= pClip->Left[i][w] && pClip->Left[j][5] < pClip->Right[i][w])) { - // Found an intersection! + /* Found an intersection! */ pClip->Left[i][w] = MAX(pClip->Left[i][w], pClip->Left[j][5]); pClip->Right[i][w] = MIN(pClip->Right[i][w], pClip->Right[j][5]); goto Clip_ok; } } - // no intersection, nullify it + /* no intersection, nullify it */ pClip->Left[i][w] = 1; pClip->Right[i][w] = 0; Clip_ok:; } } } - } // if (w == 5 || pClip->Count [5] ... - } // for (w... + } /* if (w == 5 || pClip->Count [5] ... */ + } /* for (w... */ } /* for (c... */ } diff --git a/source/dsp1.c b/source/dsp1.c index e0ffa99..f8a0713 100644 --- a/source/dsp1.c +++ b/source/dsp1.c @@ -45,7 +45,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.in_index = 0; DSP1.waiting4command = false; DSP1.first_parameter = true; - switch (byte) // Mario Kart uses 0x00, 0x02, 0x06, 0x0c, 0x28, 0x0a + switch (byte) /* Mario Kart uses 0x00, 0x02, 0x06, 0x0c, 0x28, 0x0a */ { case 0x07: case 0x0a: @@ -162,7 +162,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) case 0x1f: DSP1.out_count = 2048; break; - case 0x00: // Multiple + case 0x00: /* Multiple */ Op00Multiplicand = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op00Multiplier = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); DSPOp00(); @@ -170,7 +170,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [0] = Op00Result & 0xFF; DSP1.output [1] = (Op00Result >> 8) & 0xFF; break; - case 0x20: // Multiple + case 0x20: /* Multiple */ Op20Multiplicand = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op20Multiplier = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); DSPOp20(); @@ -179,7 +179,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [1] = (Op20Result >> 8) & 0xFF; break; case 0x30: - case 0x10: // Inverse + case 0x10: /* Inverse */ Op10Coefficient = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op10Exponent = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); DSPOp10(); @@ -190,7 +190,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [3] = (uint8_t)((((int16_t) Op10ExponentR) >> 8) & 0xff); break; case 0x24: - case 0x04: // Sin and Cos of angle + case 0x04: /* Sin and Cos of angle */ Op04Angle = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op04Radius = (uint16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); DSPOp04(); @@ -200,7 +200,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [2] = (uint8_t)(Op04Cos & 0xFF); DSP1.output [3] = (uint8_t)((Op04Cos >> 8) & 0xFF); break; - case 0x08: // Radius + case 0x08: /* Radius */ Op08X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op08Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op08Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -211,7 +211,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [2] = (uint8_t)(((int16_t) Op08Lh) & 0xFF); DSP1.output [3] = (uint8_t)((((int16_t) Op08Lh) >> 8) & 0xFF); break; - case 0x18: // Range + case 0x18: /* Range */ Op18X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op18Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op18Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -221,7 +221,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [0] = (uint8_t)(Op18D & 0xFF); DSP1.output [1] = (uint8_t)((Op18D >> 8) & 0xFF); break; - case 0x38: // Range + case 0x38: /* Range */ Op38X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op38Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op38Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -231,7 +231,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [0] = (uint8_t)(Op38D & 0xFF); DSP1.output [1] = (uint8_t)((Op38D >> 8) & 0xFF); break; - case 0x28: // Distance (vector length) + case 0x28: /* Distance (vector length) */ Op28X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op28Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op28Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -241,7 +241,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [1] = (uint8_t)((Op28R >> 8) & 0xFF); break; case 0x2c: - case 0x0c: // Rotate (2D rotate) + case 0x0c: /* Rotate (2D rotate) */ Op0CA = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op0CX1 = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op0CY1 = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -253,7 +253,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [3] = (uint8_t)((Op0CY2 >> 8) & 0xFF); break; case 0x3c: - case 0x1c: // Polar (3D rotate) + case 0x1c: /* Polar (3D rotate) */ Op1CZ = (DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op1CY = (DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op1CX = (DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -272,7 +272,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) case 0x32: case 0x22: case 0x12: - case 0x02: // Parameter (Projection) + case 0x02: /* Parameter (Projection) */ Op02FX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op02FY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op02FZ = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -291,9 +291,9 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [6] = (uint8_t)(Op02CY & 0xFF); DSP1.output [7] = (uint8_t)((Op02CY >> 8) & 0xFF); break; - case 0x3a: //1a Mirror - case 0x2a: //1a Mirror - case 0x1a: // Raster mode 7 matrix data + case 0x3a: /* 1a Mirror */ + case 0x2a: /* 1a Mirror */ + case 0x1a: /* Raster mode 7 matrix data */ case 0x0a: Op0AVS = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); DSPOp0A(); @@ -311,7 +311,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) case 0x16: case 0x26: case 0x36: - case 0x06: // Project object + case 0x06: /* Project object */ Op06X = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op06Y = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op06Z = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -327,7 +327,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) case 0x1e: case 0x2e: case 0x3e: - case 0x0e: // Target + case 0x0e: /* Target */ Op0EH = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op0EV = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); DSPOp0E(); @@ -337,10 +337,10 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [2] = (uint8_t)(Op0EY & 0xFF); DSP1.output [3] = (uint8_t)((Op0EY >> 8) & 0xFF); break; - case 0x05: // Extra commands used by Pilot Wings + case 0x05: /* Extra commands used by Pilot Wings */ case 0x35: case 0x31: - case 0x01: // Set attitude matrix A + case 0x01: /* Set attitude matrix A */ Op01m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op01Zr = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op01Yr = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -348,7 +348,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSPOp01(); break; case 0x15: - case 0x11: // Set attitude matrix B + case 0x11: /* Set attitude matrix B */ Op11m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op11Zr = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op11Yr = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -356,7 +356,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSPOp11(); break; case 0x25: - case 0x21: // Set attitude matrix C + case 0x21: /* Set attitude matrix C */ Op21m = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op21Zr = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op21Yr = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -366,7 +366,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) case 0x09: case 0x39: case 0x3d: - case 0x0d: // Objective matrix A + case 0x0d: /* Objective matrix A */ Op0DX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op0DY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op0DZ = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -380,7 +380,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [5] = (uint8_t)((Op0DU >> 8) & 0xFF); break; case 0x19: - case 0x1d: // Objective matrix B + case 0x1d: /* Objective matrix B */ Op1DX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op1DY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op1DZ = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -394,7 +394,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [5] = (uint8_t)((Op1DU >> 8) & 0xFF); break; case 0x29: - case 0x2d: // Objective matrix C + case 0x2d: /* Objective matrix C */ Op2DX = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op2DY = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op2DZ = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -408,7 +408,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [5] = (uint8_t)((Op2DU >> 8) & 0xFF); break; case 0x33: - case 0x03: // Subjective matrix A + case 0x03: /* Subjective matrix A */ Op03F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op03L = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op03U = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -421,7 +421,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [4] = (uint8_t)(Op03Z & 0xFF); DSP1.output [5] = (uint8_t)((Op03Z >> 8) & 0xFF); break; - case 0x13: // Subjective matrix B + case 0x13: /* Subjective matrix B */ Op13F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op13L = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op13U = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -434,7 +434,7 @@ void DSP1SetByte(uint8_t byte, uint16_t address) DSP1.output [4] = (uint8_t)(Op13Z & 0xFF); DSP1.output [5] = (uint8_t)((Op13Z >> 8) & 0xFF); break; - case 0x23: // Subjective matrix C + case 0x23: /* Subjective matrix C */ Op23F = (int16_t)(DSP1.parameters [0] | (DSP1.parameters[1] << 8)); Op23L = (int16_t)(DSP1.parameters [2] | (DSP1.parameters[3] << 8)); Op23U = (int16_t)(DSP1.parameters [4] | (DSP1.parameters[5] << 8)); @@ -645,7 +645,7 @@ void DSP2SetByte(uint8_t byte, uint16_t address) DSP1.out_count = 32; DSP2_Op01(); break; - case 0x09: // Multiply - don't yet know if this is signed or unsigned + case 0x09: /* Multiply - don't yet know if this is signed or unsigned */ DSP2Op09Word1 = DSP1.parameters[0] | (DSP1.parameters[1] << 8); DSP2Op09Word2 = DSP1.parameters[2] | (DSP1.parameters[3] << 8); DSP1.out_count = 4; @@ -729,7 +729,7 @@ bool DSP4_init = false; void DSP4SetByte(uint8_t byte, uint16_t address) { - if (!DSP4_init) // bootup + if (!DSP4_init) /* bootup */ { DSP4.waiting4command = 1; DSP4_init = true; @@ -812,7 +812,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address) DSP4.in_index = 0; switch (DSP4.command) { - case 0x0000: // 16-bit multiplication + case 0x0000: /* 16-bit multiplication */ { int16_t multiplier, multiplicand; int32_t product; @@ -824,7 +824,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address) DSP4_WRITE_WORD(2, product >> 16); break; } - case 0x0011: // unknown: horizontal mapping command + case 0x0011: /* unknown: horizontal mapping command */ { int16_t a, b, c, d, m; a = DSP4_READ_WORD(6); @@ -836,44 +836,44 @@ void DSP4SetByte(uint8_t byte, uint16_t address) DSP4_WRITE_WORD(0, m); break; } - case 0x0001: // track projection + case 0x0001: /* track projection */ DSP4_Op01(); break; - case 0x0007: // track projection (pass 2) + case 0x0007: /* track projection (pass 2) */ DSP4_Op07(); break; - case 0x0008: // zone projections (fuel/repair/lap/teleport/...) + case 0x0008: /* zone projections (fuel/repair/lap/teleport/...) */ DSP4_Op08(); break; - case 0x0009: // sprite transformation + case 0x0009: /* sprite transformation */ DSP4_Op09(); break; - case 0x000D: // fast track projection + case 0x000D: /* fast track projection */ DSP4_Op0D(); break; - case 0x0003: // internal memory management (01) + case 0x0003: /* internal memory management (01) */ { - // reset op09 data + /* reset op09 data */ op09_mode = false; break; } - case 0x0005: // internal memory management (06) + case 0x0005: /* internal memory management (06) */ { int32_t lcv; - // clear OAM tables + /* clear OAM tables */ op06_index = 0; op06_offset = 0; for (lcv = 0; lcv < 32; lcv++) op06_OAM[lcv] = 0; break; } - case 0x000E: // internal memory management (0D) + case 0x000E: /* internal memory management (0D) */ { - // reset op09 data + /* reset op09 data */ op09_mode = true; break; } - case 0x0006: // sprite OAM post-table data + case 0x0006: /* sprite OAM post-table data */ { int32_t lcv; DSP4.out_count = 32; @@ -881,7 +881,7 @@ void DSP4SetByte(uint8_t byte, uint16_t address) DSP4.output[lcv] = op06_OAM[lcv]; break; } - case 0x000A: // unknown + case 0x000A: /* unknown */ { int16_t out1a, out2a; out1a = (int16_t)0xff40; @@ -893,29 +893,29 @@ void DSP4SetByte(uint8_t byte, uint16_t address) DSP4_WRITE_WORD(6, out2a); break; } - case 0x000B: // render player positions around track + case 0x000B: /* render player positions around track */ { int16_t sp_x = DSP4_READ_WORD(0); int16_t sp_y = DSP4_READ_WORD(2); int16_t oam = DSP4_READ_WORD(4); - if (!op09_mode) // Only allow 1p/1p-split to yield output (???) + if (!op09_mode) /* Only allow 1p/1p-split to yield output (???) */ { - // yield OAM output + /* yield OAM output */ DSP4.out_count = 6; DSP4_WRITE_WORD(0, 1); - // pack OAM data: x,y,name,attr + /* pack OAM data: x,y,name,attr */ DSP4.output[2] = sp_x & 0xff; DSP4.output[3] = sp_y & 0xff; DSP4_WRITE_WORD(4, oam); - // OAM: size,msb data + /* OAM: size,msb data */ DSP4_Op06(false, false); } - else // 4p mode + else /* 4p mode */ { - // no OAM available + /* no OAM available */ DSP4.out_count = 0; DSP4_WRITE_WORD(0, 0); } diff --git a/source/dsp1emu.c b/source/dsp1emu.c index 1a78e5f..e7c3f7d 100644 --- a/source/dsp1emu.c +++ b/source/dsp1emu.c @@ -168,7 +168,7 @@ int16_t Op10ExponentR; void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient, int16_t* iExponent) { - // Step One: Division by Zero + /* Step One: Division by Zero */ if (Coefficient == 0x0000) { *iCoefficient = 0x7fff; @@ -178,7 +178,7 @@ void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient, { int16_t Sign = 1; - // Step Two: Remove Sign + /* Step Two: Remove Sign */ if (Coefficient < 0) { if (Coefficient < -32767) @@ -187,14 +187,14 @@ void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient, Sign = -1; } - // Step Three: Normalize + /* Step Three: Normalize */ while (Coefficient < 0x4000) { Coefficient <<= 1; Exponent--; } - // Step Four: Special Case + /* Step Four: Special Case */ if (Coefficient == 0x4000) { if (Sign == 1) @@ -207,10 +207,10 @@ void DSP1_Inverse(int16_t Coefficient, int16_t Exponent, int16_t* iCoefficient, } else { - // Step Five: Initial Guess + /* Step Five: Initial Guess */ int16_t i = DSP1ROM[((Coefficient - 0x4000) >> 7) + 0x0065]; - // Step Six: Iterate "estimated" Newton's Method + /* Step Six: Iterate "estimated" Newton's Method */ i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1; @@ -467,13 +467,13 @@ int16_t VOffset; int16_t VPlane_C; int16_t VPlane_E; -// Azimuth and Zenith angles +/* Azimuth and Zenith angles */ int16_t SinAas; int16_t CosAas; int16_t SinAzs; int16_t CosAzs; -// Clipped Zenith angle +/* Clipped Zenith angle */ int16_t SinAZS; int16_t CosAZS; int16_t SecAZS_C1; @@ -498,10 +498,10 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les int16_t LesNx, LesNy, LesNz; int16_t CentreZ; - // Copy Zenith angle for clipping + /* Copy Zenith angle for clipping */ int16_t AZS = Azs; - // Store Sine and Cosine of Azimuth and Zenith angle + /* Store Sine and Cosine of Azimuth and Zenith angle */ SinAas = DSP1_Sin(Aas); CosAas = DSP1_Cos(Aas); SinAzs = DSP1_Sin(Azs); @@ -515,7 +515,7 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les LfeNy = Lfe * Ny >> 15; LfeNz = Lfe * Nz >> 15; - // Center of Projection + /* Center of Projection */ CentreX = Fx + LfeNx; CentreY = Fy + LfeNy; CentreZ = Fz + LfeNz; @@ -538,7 +538,7 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les VPlane_C = C; VPlane_E = E; - // Determine clip boundary and clip Zenith angle if necessary + /* Determine clip boundary and clip Zenith angle if necessary */ MaxAZS = MaxAZS_Exp[-E]; if (AZS < 0) @@ -550,7 +550,7 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les else if (AZS > MaxAZS) AZS = MaxAZS; - // Store Sine and Cosine of clipped Zenith angle + /* Store Sine and Cosine of clipped Zenith angle */ SinAZS = DSP1_Sin(AZS); CosAZS = DSP1_Cos(AZS); @@ -566,7 +566,7 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les *Cx = CentreX; *Cy = CentreY; - // Raster number of imaginary center and horizontal line + /* Raster number of imaginary center and horizontal line */ *Vof = 0; if ((Azs != AZS) || (Azs == MaxAZS)) @@ -601,7 +601,7 @@ void DSP1_Parameter(int16_t Fx, int16_t Fy, int16_t Fz, int16_t Lfe, int16_t Les *Vva = DSP1_Truncate(-C, E); - // Store Secant of clipped Zenith angle + /* Store Secant of clipped Zenith angle */ DSP1_Inverse(CosAZS, 0, &SecAZS_C2, &SecAZS_E2); } @@ -677,7 +677,7 @@ void DSP1_Project(int16_t X, int16_t Y, int16_t Z, int16_t *H, int16_t *V, int16 DSP1_NormalizeDouble((int32_t) Y - Gy, &Py, &E); DSP1_NormalizeDouble((int32_t) Z - Gz, &Pz, &E3); Px>>=1; - E4--; // to avoid overflows when calculating the scalar products + E4--; /* to avoid overflows when calculating the scalar products */ Py>>=1; E--; Pz>>=1; @@ -686,56 +686,56 @@ void DSP1_Project(int16_t X, int16_t Y, int16_t Z, int16_t *H, int16_t *V, int16 refE = MIN(E, E3); refE = MIN(refE, E4); - Px = DSP1_ShiftR(Px, E4 - refE); // normalize them to the same exponent + Px = DSP1_ShiftR(Px, E4 - refE); /* normalize them to the same exponent */ Py = DSP1_ShiftR(Py, E - refE); Pz = DSP1_ShiftR(Pz, E3 - refE); C11 = -(Px * Nx >> 15); C8 = -(Py * Ny >> 15); C9 = -(Pz * Nz >> 15); - C12 = C11 + C8 + C9; // this cannot overflow! + C12 = C11 + C8 + C9; /* this cannot overflow! */ - aux4 = C12; // de-normalization with 32-bit arithmetic - refE = 16 - refE; // refE can be up to 3 + aux4 = C12; /* de-normalization with 32-bit arithmetic */ + refE = 16 - refE; /* refE can be up to 3 */ if (refE >= 0) aux4 <<= refE; else aux4 >>= -refE; if (aux4 == -1) - aux4 = 0; // why? + aux4 = 0; /* why? */ aux4>>=1; - aux = ((int16_t) G_Les) + aux4; // Les - the scalar product of P with the normal vector of the screen + aux = ((int16_t) G_Les) + aux4; /* Les - the scalar product of P with the normal vector of the screen */ DSP1_NormalizeDouble(aux, &C10, &E2); E2 = 15 - E2; DSP1_Inverse(C10, 0, &C4, &E4); - C2 = C4 * C_Les >> 15; // scale factor + C2 = C4 * C_Les >> 15; /* scale factor */ - // H + /* H */ E7 = 0; C16 = (Px * (CosAas * 0x7fff >> 15) >> 15); C20 = (Py * (SinAas * 0x7fff >> 15) >> 15); - C17 = C16 + C20; // scalar product of P with the normalized horizontal vector of the screen... + C17 = C16 + C20; /* scalar product of P with the normalized horizontal vector of the screen... */ - C18 = C17 * C2 >> 15; // ... multiplied by the scale factor + C18 = C17 * C2 >> 15; /* ... multiplied by the scale factor */ DSP1_Normalize(C18, &C19, &E7); *H = DSP1_Truncate(C19, E_Les - E2 + refE + E7); - // V + /* V */ E6 = 0; C21 = Px * (CosAzs * -SinAas >> 15) >> 15; C22 = Py * (CosAzs * CosAas >> 15) >> 15; C23 = Pz * (-SinAzs * 0x7fff >> 15) >> 15; - C24 = C21 + C22 + C23; // scalar product of P with the normalized vertical vector of the screen... + C24 = C21 + C22 + C23; /* scalar product of P with the normalized vertical vector of the screen... */ - C26 = C24 * C2 >> 15; // ... multiplied by the scale factor + C26 = C24 * C2 >> 15; /* ... multiplied by the scale factor */ DSP1_Normalize(C26, &C25, &E6); *V = DSP1_Truncate(C25, E_Les - E2 + refE + E6); - // M + /* M */ DSP1_Normalize(C2, &C6, &E4); - *M = DSP1_Truncate(C6, E4 + E_Les - E2 - 7); // M is the scale factor divided by 2^7 + *M = DSP1_Truncate(C6, E4 + E_Les - E2 - 7); /* M is the scale factor divided by 2^7 */ } int16_t Op06X; @@ -935,7 +935,7 @@ void DSPOp14(void) DSP1_Inverse(DSP1_Cos(Op14Xr), 0, &CSec, &ESec); - // Rotation Around Z + /* Rotation Around Z */ DSP1_NormalizeDouble(Op14U * DSP1_Cos(Op14Yr) - Op14F * DSP1_Sin(Op14Yr), &C, &E); E = ESec - E; @@ -944,10 +944,10 @@ void DSPOp14(void) Op14Zrr = Op14Zr + DSP1_Truncate(C, E); - // Rotation Around X + /* Rotation Around X */ Op14Xrr = Op14Xr + (Op14U * DSP1_Sin(Op14Yr) >> 15) + (Op14F * DSP1_Cos(Op14Yr) >> 15); - // Rotation Around Y + /* Rotation Around Y */ DSP1_NormalizeDouble(Op14U * DSP1_Cos(Op14Yr) + Op14F * DSP1_Sin(Op14Yr), &C, &E); E = ESec - E; @@ -1091,19 +1091,19 @@ int16_t Op1CZ2; void DSPOp1C(void) { - // Rotate Around Op1CZ1 + /* Rotate Around Op1CZ1 */ Op1CX1 = (Op1CYBR * DSP1_Sin(Op1CZ) >> 15) + (Op1CXBR * DSP1_Cos(Op1CZ) >> 15); Op1CY1 = (Op1CYBR * DSP1_Cos(Op1CZ) >> 15) - (Op1CXBR * DSP1_Sin(Op1CZ) >> 15); Op1CXBR = Op1CX1; Op1CYBR = Op1CY1; - // Rotate Around Op1CY1 + /* Rotate Around Op1CY1 */ Op1CZ1 = (Op1CXBR * DSP1_Sin(Op1CY) >> 15) + (Op1CZBR * DSP1_Cos(Op1CY) >> 15); Op1CX1 = (Op1CXBR * DSP1_Cos(Op1CY) >> 15) - (Op1CZBR * DSP1_Sin(Op1CY) >> 15); Op1CXAR = Op1CX1; Op1CZBR = Op1CZ1; - // Rotate Around Op1CX1 + /* Rotate Around Op1CX1 */ Op1CY1 = (Op1CZBR * DSP1_Sin(Op1CX) >> 15) + (Op1CYBR * DSP1_Cos(Op1CX) >> 15); Op1CZ1 = (Op1CZBR * DSP1_Cos(Op1CX) >> 15) - (Op1CYBR * DSP1_Sin(Op1CX) >> 15); Op1CYAR = Op1CY1; diff --git a/source/dsp2emu.c b/source/dsp2emu.c index 4e22d54..48e06c2 100644 --- a/source/dsp2emu.c +++ b/source/dsp2emu.c @@ -11,30 +11,31 @@ uint8_t DSP2Op05Transparent = 0; void DSP2_Op05(void) { uint8_t color; - // Overlay bitmap with transparency. - // Input: - // - // Bitmap 1: i[0] <=> i[size-1] - // Bitmap 2: i[size] <=> i[2*size-1] - // - // Output: - // - // Bitmap 3: o[0] <=> o[size-1] - // - // Processing: - // - // Process all 4-bit pixels (nibbles) in the bitmap - // - // if ( BM2_pixel == transparent_color ) - // pixelout = BM1_pixel - // else - // pixelout = BM2_pixel + /* Overlay bitmap with transparency. + * Input: + * + * Bitmap 1: i[0] <=> i[size-1] + * Bitmap 2: i[size] <=> i[2*size-1] + * + * Output: + * + * Bitmap 3: o[0] <=> o[size-1] + * + * Processing: + * + * Process all 4-bit pixels (nibbles) in the bitmap + * + * if ( BM2_pixel == transparent_color ) + * pixelout = BM1_pixel + * else + * pixelout = BM2_pixel - // The max size bitmap is limited to 255 because the size parameter is a byte - // I think size=0 is an error. The behavior of the chip on size=0 is to - // return the last value written to DR if you read DR on Op05 with - // size = 0. I don't think it's worth implementing this quirk unless it's - // proven necessary. + * The max size bitmap is limited to 255 because the size parameter is a byte + * I think size=0 is an error. The behavior of the chip on size=0 is to + * return the last value written to DR if you read DR on Op05 with + * size = 0. I don't think it's worth implementing this quirk unless it's + * proven necessary. + */ int32_t n; uint8_t c1; @@ -55,15 +56,15 @@ void DSP2_Op05(void) void DSP2_Op01(void) { - // Op01 size is always 32 bytes input and output. - // The hardware does strange things if you vary the size. + /* Op01 size is always 32 bytes input and output. + * The hardware does strange things if you vary the size. */ int32_t j; uint8_t c0, c1, c2, c3; uint8_t* p1 = DSP1.parameters; uint8_t* p2a = DSP1.output; - uint8_t* p2b = &DSP1.output[16]; // halfway + uint8_t* p2b = &DSP1.output[16]; /* halfway */ - // Process 8 blocks of 4 bytes each + /* Process 8 blocks of 4 bytes each */ for (j = 0; j < 8; j++) { c0 = *p1++; @@ -79,9 +80,10 @@ void DSP2_Op01(void) void DSP2_Op06(void) { - // Input: - // size - // bitmap + /* Input: + * size + * bitmap + */ int32_t i, j; @@ -93,10 +95,10 @@ bool DSP2Op0DHasLen = false; int32_t DSP2Op0DOutLen = 0; int32_t DSP2Op0DInLen = 0; -// Scale bitmap based on input length out output length +/* Scale bitmap based on input length out output length */ void DSP2_Op0D(void) { - // (Modified) Overload's algorithm + /* (Modified) Overload's algorithm */ int32_t i; for(i = 0 ; i < DSP2Op0DOutLen ; i++) { diff --git a/source/dsp4emu.c b/source/dsp4emu.c index 921f896..6c492e9 100644 --- a/source/dsp4emu.c +++ b/source/dsp4emu.c @@ -9,7 +9,7 @@ #define DSP4_WRITE_WORD(x,d) \ WRITE_WORD(DSP4.output+x,d); -// used to wait for dsp i/o +/* used to wait for dsp i/o */ #define DSP4_WAIT(x) \ DSP4_Logic = x; \ return @@ -26,14 +26,14 @@ int16_t DSP4_UnknownOP11(int16_t A, int16_t B, int16_t C, int16_t D) void DSP4_Op06(bool size, bool msb) { - // save post-oam table data for future retrieval + /* save post-oam table data for future retrieval */ op06_OAM[op06_index] |= (msb << (op06_offset + 0)); op06_OAM[op06_index] |= (size << (op06_offset + 1)); op06_offset += 2; if (op06_offset == 8) { - // move to next byte in buffer + /* move to next byte in buffer */ op06_offset = 0; op06_index++; } @@ -48,7 +48,7 @@ void DSP4_Op01(void) uint16_t command; DSP4.waiting4command = false; - switch (DSP4_Logic) // op flow control + switch (DSP4_Logic) /* op flow control */ { case 1: goto resume1; @@ -58,10 +58,11 @@ void DSP4_Op01(void) break; } - //////////////////////////////////////////////////// - // process initial inputs + /* + * process initial inputs + */ - // sort inputs + /* sort inputs */ project_focaly = DSP4_READ_WORD(0x02); raster = DSP4_READ_WORD(0x04); viewport_top = DSP4_READ_WORD(0x06); @@ -78,36 +79,37 @@ void DSP4_Op01(void) far_plane = DSP4_READ_WORD(0x1e); project_y1low = DSP4_READ_WORD(0x22); - // pre-compute + /* pre-compute */ view_plane = PLANE_START; - // find starting projection points + /* find starting projection points */ project_x1 = project_focalx; project_y -= viewport_bottom; project_x = project_centerx + project_x1; - // multi-op storage + /* multi-op storage */ multi_index1 = 0; multi_index2 = 0; - //////////////////////////////////////////////////// - // command check + /* + * command check + */ do { - // scan next command + /* scan next command */ DSP4.in_count = 2; DSP4_WAIT(1); resume1: - // inspect input + /* inspect input */ command = DSP4_READ_WORD(0); - // check for termination + /* check for termination */ if(command == 0x8000) break; - // already have 2 bytes in queue + /* already have 2 bytes in queue */ DSP4.in_index = 2; DSP4.in_count = 8; DSP4_WAIT(2); @@ -1226,7 +1228,7 @@ resume7: { sprite_type = 2; - // shift bytes + /* shift bytes */ DSP4.parameters[2] = DSP4.parameters[0]; DSP4.parameters[3] = DSP4.parameters[1]; DSP4.parameters[0] = 0; diff --git a/source/fxemu.c b/source/fxemu.c index 1a6ca7b..dd798fd 100644 --- a/source/fxemu.c +++ b/source/fxemu.c @@ -22,7 +22,7 @@ void fx_flushCache(void) void fx_updateRamBank(uint8_t Byte) { - // Update BankReg and Bank pointer + /* Update BankReg and Bank pointer */ GSU.vRamBankReg = (uint32_t) Byte & (FX_RAM_BANKS - 1); GSU.pvRamBank = GSU.apvRamBank[Byte & 0x3]; } diff --git a/source/fxinst.c b/source/fxinst.c index d48631d..7b79cd5 100644 --- a/source/fxinst.c +++ b/source/fxinst.c @@ -851,7 +851,7 @@ static INLINE void fx_cmode(void) GSU.vPlotOptionReg = SREG; if (GSU.vPlotOptionReg & 0x10) - GSU.vScreenHeight = 256; // OBJ Mode (for drawing into sprites) + GSU.vScreenHeight = 256; /* OBJ Mode (for drawing into sprites) */ else GSU.vScreenHeight = GSU.vScreenRealHeight; diff --git a/source/getset.h b/source/getset.h index c7f4950..1435348 100644 --- a/source/getset.h +++ b/source/getset.h @@ -38,10 +38,10 @@ inline uint8_t S9xGetByte(uint32_t Address) return S9xGetDSP(Address & 0xffff); case MAP_SA1RAM: case MAP_LOROM_SRAM: - //Address & 0x7FFF - offset into bank - //Address & 0xFF0000 - bank - //bank >> 1 | offset = s-ram address, unbound - //unbound & SRAMMask = Sram offset + /*Address & 0x7FFF - offset into bank + *Address & 0xFF0000 - bank + *bank >> 1 | offset = s-ram address, unbound + *unbound & SRAMMask = Sram offset */ return Memory.SRAM[(((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) &Memory.SRAMMask]; case MAP_RONLY_SRAM: case MAP_HIROM_SRAM: @@ -99,10 +99,10 @@ inline uint16_t S9xGetWord(uint32_t Address) return S9xGetDSP(Address & 0xffff) | (S9xGetDSP((Address + 1) & 0xffff) << 8); case MAP_SA1RAM: case MAP_LOROM_SRAM: - //Address & 0x7FFF - offset into bank - //Address & 0xFF0000 - bank - //bank >> 1 | offset = s-ram address, unbound - //unbound & SRAMMask = Sram offset + /*Address & 0x7FFF - offset into bank + *Address & 0xFF0000 - bank + *bank >> 1 | offset = s-ram address, unbound + *unbound & SRAMMask = Sram offset */ /* BJ: no FAST_LSB_WORD_ACCESS here, since if Memory.SRAMMask=0x7ff * then the high byte doesn't follow the low byte. */ return *(Memory.SRAM + ((((Address & 0xFF0000) >> 1) | (Address & 0x7FFF)) & Memory.SRAMMask)) | ((*(Memory.SRAM + (((((Address + 1) & 0xFF0000) >> 1) | ((Address + 1) & 0x7FFF)) & Memory.SRAMMask))) << 8); @@ -320,8 +320,8 @@ inline uint8_t* GetBasePointer(uint32_t Address) return s7r.bank50; case MAP_SPC7110_ROM: return Get7110BasePtr(Address); - case MAP_PPU: //just a guess, but it looks like this should match the CPU as a source. - case MAP_CPU: //fixes Ogre Battle's green lines + case MAP_PPU: /*just a guess, but it looks like this should match the CPU as a source. */ + case MAP_CPU: /*fixes Ogre Battle's green lines */ case MAP_OBC_RAM: return Memory.FillRAM; case MAP_DSP: diff --git a/source/globals.c b/source/globals.c index 233ca42..14b8a64 100644 --- a/source/globals.c +++ b/source/globals.c @@ -94,12 +94,12 @@ uint8_t BitShifts[8][4] = { {2, 2, 2, 2}, /* 0 */ {4, 4, 2, 0}, /* 1 */ - {4, 4, 0, 0}, // 2 - {8, 4, 0, 0}, // 3 - {8, 2, 0, 0}, // 4 - {4, 2, 0, 0}, // 5 - {4, 0, 0, 0}, // 6 - {8, 0, 0, 0} // 7 + {4, 4, 0, 0}, /* 2 */ + {8, 4, 0, 0}, /* 3 */ + {8, 2, 0, 0}, /* 4 */ + {4, 2, 0, 0}, /* 5 */ + {4, 0, 0, 0}, /* 6 */ + {8, 0, 0, 0} /* 7 */ }; uint8_t TileShifts[8][4] = { |