diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index 21db3c4..011952b 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -2463,6 +2463,10 @@ bool Declaration::IsSame(const Declaration* dec) const return true; if (mType != dec->mType) return false; + + if (!(mFlags & dec->mFlags & DTF_DEFINED) && mType == DT_TYPE_STRUCT) + return mIdent == dec->mIdent; + if (mSize != dec->mSize) return false; if (mStripe != dec->mStripe) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 97a94d4..b3daf03 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -4554,8 +4554,10 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex { if (!ndec->mBase->IsSame(pdec->mBase)) { - if (ndec->mBase->mType == DT_TYPE_ARRAY && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase) && pdec->mBase->mSize == 0) - pdec->mBase->mSize = ndec->mBase->mSize; + if (ndec->mBase->mType == DT_TYPE_ARRAY && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase)) + { + pdec->mBase = ndec->mBase; + } else if (pdec->mBase->mType == DT_TYPE_POINTER && ndec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase)) { pdec->mBase = ndec->mBase; @@ -4563,6 +4565,8 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex else mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent); } + else + pdec->mBase = ndec->mBase; if (!(ndec->mFlags & DTF_EXTERN)) { diff --git a/samples/fractals/mbzoom.c b/samples/fractals/mbzoom.c index f807e38..9725389 100644 --- a/samples/fractals/mbzoom.c +++ b/samples/fractals/mbzoom.c @@ -8,6 +8,9 @@ // Lookup table for squares from 0..255 __striped unsigned sqb[256]; +// Shift byte right and left by 4 +char shlb4[256], shrb4[256]; + #pragma align(sqb, 256); // Square an unsigned int into an unsigned long @@ -103,6 +106,16 @@ static const char colors[32] = { VCOL_DARK_GREY, }; +inline int shr12(long l) +{ + char b3 = (l >> 24) & 0xff; + char b2 = (l >> 16) & 0xff; + char b1 = (l >> 8) & 0xff; + char a0 = shrb4[b1] | shlb4[b2]; + char a1 = shrb4[b2] | shlb4[b3]; + return a0 | (a1 << 8); +} + // Return color for a given coordinate in the complex plane using // 12.4bit fixed numbers using m'=m²+b @@ -119,15 +132,17 @@ inline char fcolor(int xz, int yz) // Build squares of real and imaginary component long xx = sq(x), yy = sq(y), xxyy = sq(x + y); - // Use squares to check for exit condition of sure - // to proress towards infinity - if (xx + yy >= 4L * 4096 * 4096) return colors[i]; + long xxpyy = xx + yy; - // Next iteration values using complex artithmetic + // Use squares to check for exit condition of sure + // to progress towards infinity + if (xxpyy >= 4L * 4096 * 4096) return colors[i]; + + // Next iteration values using complex arithmetic // Mx' = Mx² - My² + Bx // My' = 2 * Mx * My + By = (Mx + My)² - Mx² - My² + By - x = ((xx - yy + 2048) >> 12) + xz; - y = ((xxyy - xx - yy + 2048) >> 12) + yz; + x = shr12(xx - yy + 2048) + xz; + y = shr12(xxyy - xxpyy + 2048) + yz; } // More than maximum number of iterations, so assume progress @@ -225,7 +240,11 @@ int main(void) { // Initialize square table for(unsigned i=0; i<256; i++) + { sqb[i] = i * i; + shlb4[i] = i << 4; + shrb4[i] = i >> 4; + } // Clear screen memset(Screen, 160, 1024);