From e50f3f9814f7e040d022e7593b1cb0602c2447b2 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 10 Sep 2022 10:05:44 +0200 Subject: [PATCH] Fix lenient semicolon handling in parser --- autotest/ptrinittest.c | 2 +- autotest/qsorttest.c | 2 +- autotest/randsumtest.c | 2 +- include/c64/rasterirq.h | 2 +- include/c64/vic.c | 2 +- include/fixmath.h | 18 ++++---- include/gfx/bitmap.c | 2 +- include/gfx/bitmap.h | 2 +- include/gfx/mcbitmap.c | 4 +- include/gfx/mcbitmap.h | 2 +- include/gfx/vector3d.c | 2 +- include/gfx/vector3d.h | 8 ++-- include/math.c | 6 +-- include/oscar.c | 2 +- include/stdio.c | 2 +- oscar64/Errors.h | 1 + oscar64/NativeCodeGenerator.cpp | 80 +++++++++++++++++++++++++++++++-- oscar64/NativeCodeGenerator.h | 3 ++ oscar64/Parser.cpp | 34 +++++++++----- oscar64/Parser.h | 2 +- samples/fractals/mbmulti3d.c | 2 +- samples/games/breakout.c | 12 ++--- samples/games/lander.c | 12 ++--- samples/games/maze3d.c | 10 ++--- samples/games/missile.c | 2 +- samples/hires/func3d.c | 4 +- samples/hiresmc/func3d.c | 6 +-- samples/kernalio/charread.c | 2 +- samples/memmap/charsetcopy.c | 8 ++-- samples/memmap/charsetexpand.c | 6 +-- samples/memmap/charsethi.c | 4 +- samples/memmap/charsetlo.c | 4 +- samples/memmap/charsetload.c | 4 +- samples/memmap/easyflashreloc.c | 12 ++--- samples/memmap/largemem.c | 4 +- samples/scrolling/bigfont.c | 2 +- samples/scrolling/cgrid8way.c | 6 +-- samples/sprites/creditroll.c | 2 +- 38 files changed, 184 insertions(+), 96 deletions(-) diff --git a/autotest/ptrinittest.c b/autotest/ptrinittest.c index 7937b6a..f0ffa0a 100644 --- a/autotest/ptrinittest.c +++ b/autotest/ptrinittest.c @@ -11,7 +11,7 @@ const struct A { { {4, 5, 6, 7, 8} } -} +}; const int * t[4] = { a.b + 1 + 1 diff --git a/autotest/qsorttest.c b/autotest/qsorttest.c index f3ddeeb..c764773 100644 --- a/autotest/qsorttest.c +++ b/autotest/qsorttest.c @@ -20,7 +20,7 @@ void qsort(Node * n, int s) { n[pi] = n[i]; pi++; - n[i] = n[pi] + n[i] = n[pi]; } } n[pi] = pn; diff --git a/autotest/randsumtest.c b/autotest/randsumtest.c index cbb9aa0..eb48121 100644 --- a/autotest/randsumtest.c +++ b/autotest/randsumtest.c @@ -11,6 +11,6 @@ int main(void) assert(lsum == 32157742L); - return 0 + return 0; } diff --git a/include/c64/rasterirq.h b/include/c64/rasterirq.h index ff56309..2480a83 100644 --- a/include/c64/rasterirq.h +++ b/include/c64/rasterirq.h @@ -115,7 +115,7 @@ inline void rirq_delay(RIRQCode * ic, byte cycles); inline void rirq_set(byte n, byte row, RIRQCode * write); // Remove a raster IRQ from one of the 16 slots -inline void rirq_clear(byte n) +inline void rirq_clear(byte n); // Change the vertical position of the raster IRQ of one of the slots inline void rirq_move(byte n, byte row); diff --git a/include/c64/vic.c b/include/c64/vic.c index 26fc964..28d6827 100644 --- a/include/c64/vic.c +++ b/include/c64/vic.c @@ -46,7 +46,7 @@ void vic_setmode(VicMode mode, char * text, char * font) vic.ctrl2 = VIC_CTRL2_CSEL | VIC_CTRL2_MCM; break; default: - __assume(false) + __assume(false); } cia2.pra = (cia2.pra & 0xfc) | (((unsigned)text >> 14) ^ 0x03); diff --git a/include/fixmath.h b/include/fixmath.h index 190f311..2a7a983 100644 --- a/include/fixmath.h +++ b/include/fixmath.h @@ -5,7 +5,7 @@ __native unsigned long lmul16u(unsigned x, unsigned y); // Multiply two signed 16bit numbers and return a signed 32bit result -__native long lmul16s(int x, int y) +__native long lmul16s(int x, int y); // Multiply two 12.4 fixpoint numbers and return a 12.4 fixpoint result inline int lmul12f4s(int x, int y); @@ -15,31 +15,31 @@ inline int lmul12f4s(int x, int y); inline int lmul8f8s(int x, int y); // Multiply two 4.12 fixpoint numbers and return a 12.4 fixpoint result -__native int lmul4f12s(int x, int y) +__native int lmul4f12s(int x, int y); // Square of a 4.12 sigend fixpoint number and return an 8.24 fixpoint result inline unsigned long lsqr4f12s(int x); // Divide a 32bit unsigned number by a 16bit number and return a 16bit number -__native unsigned ldiv16u(unsigned long x, unsigned y) +__native unsigned ldiv16u(unsigned long x, unsigned y); // Divide a signed 32bit number by a signed 16bit number and return a signed 16bit number -__native int ldiv16s(long x, int y) +__native int ldiv16s(long x, int y); // Divide a 12.4 fixed point number by a 12.4 fixpoint number -inline int ldiv12f4s(int x, int y) +inline int ldiv12f4s(int x, int y); // Divide a 8.8 fixed point number by an 8.8 fixpoint number -inline int ldiv8f8s(int x, int y) +inline int ldiv8f8s(int x, int y); // Divide a 4.12 fixed point number by a 4.12 fixpoint number -inline int ldiv4f12s(int x, int y) +inline int ldiv4f12s(int x, int y); // Multiply two unsigned 16bit numbers and divide the result by another 16bit number a * b / c -__native unsigned lmuldiv16u(unsigned a, unsigned b, unsigned c) +__native unsigned lmuldiv16u(unsigned a, unsigned b, unsigned c); // Multiply two signed 16bit numbers and divide the result by another signed 16bit number a * b / c -__native int lmuldiv16s(int a, int b, int c) +__native int lmuldiv16s(int a, int b, int c); __native unsigned lmuldiv16by8(unsigned a, char b, char c); diff --git a/include/gfx/bitmap.c b/include/gfx/bitmap.c index dffa565..fe0a600 100644 --- a/include/gfx/bitmap.c +++ b/include/gfx/bitmap.c @@ -129,7 +129,7 @@ void bm_scan_fill(int left, int right, char * lp, int x0, int x1, char pat) unsigned bm_usqrt(unsigned n) { - unsigned p, q, r, h + unsigned p, q, r, h; p = 0; r = n; diff --git a/include/gfx/bitmap.h b/include/gfx/bitmap.h index 287178a..78184d1 100644 --- a/include/gfx/bitmap.h +++ b/include/gfx/bitmap.h @@ -82,7 +82,7 @@ void bm_circle_fill(const Bitmap * bm, const ClipRect * clip, int x, int y, char // Fill a trapezoid with horizontal top and bottom, top left is in x0, top right in x1 // dx0 and dx1 are the horizontal delta for each line. Coordinates are in 16.16 fixed point // numbers. y0 and y1 are vertical coordinates in pixel. -void bm_trapezoid_fill(const Bitmap * bm, const ClipRect * clip, long x0, long x1, long dx0, long dx1, int y0, int y1, const char * pat) +void bm_trapezoid_fill(const Bitmap * bm, const ClipRect * clip, long x0, long x1, long dx0, long dx1, int y0, int y1, const char * pat); // Fill a triangle with a pattern, coordinate pairs x0/y0, x1/y1 and x2/y2 are in pixel void bm_triangle_fill(const Bitmap * bm, const ClipRect * clip, int x0, int y0, int x1, int y1, int x2, int y2, const char * pat); diff --git a/include/gfx/mcbitmap.c b/include/gfx/mcbitmap.c index b114c6e..55383ce 100644 --- a/include/gfx/mcbitmap.c +++ b/include/gfx/mcbitmap.c @@ -772,7 +772,7 @@ void bmmcu_rect_copy(const Bitmap * dbm, int dx, int dy, const Bitmap * sbm, int { int rx = (dx + w + 1) & ~1; dx &= ~1; - sx &= ~1 + sx &= ~1; bmu_bitblit(dbm, dx, dy, sbm, sx, sy, rx - dx, h, nullptr, BLTOP_COPY); } @@ -798,7 +798,7 @@ void bmmc_rect_copy(const Bitmap * dbm, const ClipRect * clip, int dx, int dy, c { int rx = (dx + w + 1) & ~1; dx &= ~1; - sx &= ~1 + sx &= ~1; bm_bitblit(dbm, clip, dx, dy, sbm, sx, sy, rx - dx, h, nullptr, BLTOP_COPY); } diff --git a/include/gfx/mcbitmap.h b/include/gfx/mcbitmap.h index 804e665..7ae8831 100644 --- a/include/gfx/mcbitmap.h +++ b/include/gfx/mcbitmap.h @@ -34,7 +34,7 @@ void bmmc_circle_fill(const Bitmap * bm, const ClipRect * clip, int x, int y, ch // Fill a trapezoid with horizontal top and bottom, top left is in x0, top right in x1 // dx0 and dx1 are the horizontal delta for each line. Coordinates are in 16.16 fixed point // numbers. y0 and y1 are vertical coordinates in pixel. -void bmmc_trapezoid_fill(const Bitmap * bm, const ClipRect * clip, long x0, long x1, long dx0, long dx1, int y0, int y1, const char * pat) +void bmmc_trapezoid_fill(const Bitmap * bm, const ClipRect * clip, long x0, long x1, long dx0, long dx1, int y0, int y1, const char * pat); // Fill a triangle with a pattern, coordinate pairs x0/y0, x1/y1 and x2/y2 are in pixel void bmmc_triangle_fill(const Bitmap * bm, const ClipRect * clip, int x0, int y0, int x1, int y1, int x2, int y2, const char * pat); diff --git a/include/gfx/vector3d.c b/include/gfx/vector3d.c index 96088a5..0bf29ec 100644 --- a/include/gfx/vector3d.c +++ b/include/gfx/vector3d.c @@ -447,7 +447,7 @@ void mat3_rmmul(Matrix3 * md, const Matrix3 * ms) void mat3_transpose(Matrix3 * md, const Matrix3 * ms) { - float t + float t; t = ms->m[1]; md->m[1] = ms->m[3]; md->m[3] = t; md->m[0] = ms->m[0]; t = ms->m[2]; md->m[2] = ms->m[6]; md->m[6] = t; md->m[4] = ms->m[4]; t = ms->m[5]; md->m[5] = ms->m[7]; md->m[7] = t; md->m[8] = ms->m[8]; diff --git a/include/gfx/vector3d.h b/include/gfx/vector3d.h index 3c79b3e..b31acbc 100644 --- a/include/gfx/vector3d.h +++ b/include/gfx/vector3d.h @@ -74,7 +74,7 @@ void mat2_invert(Matrix2 * md, const Matrix2 * ms); struct Vector3 { float v[3]; -} +}; inline void vec3_set(Vector3 * vd, float x, float y, float z); @@ -127,7 +127,7 @@ void vec3_bend(Vector3 * vd, const Vector3 * vs, float chi1, float chi2); struct Matrix3 { float m[9]; -} +}; void mat3_ident(Matrix3 * m); @@ -160,7 +160,7 @@ void mat3_set_rotate(Matrix3 * m, const Vector3 * v, float a); struct Vector4 { float v[4]; -} +}; inline void vec4_set(Vector4 * vd, float x, float y, float z, float w); @@ -212,7 +212,7 @@ void vec4_bend(Vector4 * vd, const Vector4 * vs, float chi1, float chi2); struct Matrix4 { float m[16]; -} +}; void mat4_ident(Matrix4 * m); diff --git a/include/math.c b/include/math.c index f493791..3550da9 100644 --- a/include/math.c +++ b/include/math.c @@ -98,7 +98,7 @@ float atan2(float p, float q) s *= g; s += F_ATAN_3; s *= g; s += F_ATAN_2; s *= g; s += F_ATAN_1; - s *= g; s += F_ATAN_0 + s *= g; s += F_ATAN_0; if (quad & 1) s = 0.5 * PI - s; @@ -138,7 +138,7 @@ float exp(float f) s *= g; s += F_EXP_3; s *= g; s += F_EXP_2; s *= g; s += F_EXP_1; - s *= g; s += F_EXP_0 + s *= g; s += F_EXP_0; return s * x.f; } @@ -174,7 +174,7 @@ float log(float f) s *= g; s += F_LOG_3; s *= g; s += F_LOG_2; s *= g; s += F_LOG_1; - s *= g; s += F_LOG_0 + s *= g; s += F_LOG_0; return (fex + s) * 0.6931471806; } diff --git a/include/oscar.c b/include/oscar.c index ea3acba..5704091 100644 --- a/include/oscar.c +++ b/include/oscar.c @@ -82,7 +82,7 @@ const char * oscar_expand_rle(char * dp, const char * sp) cmd = sp[0]; - } while (cmd) + } while (cmd); return sp + 1; } diff --git a/include/stdio.c b/include/stdio.c index cbb660d..65d9b49 100644 --- a/include/stdio.c +++ b/include/stdio.c @@ -719,7 +719,7 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa { char fc, cs; int nv = 0; - unsigned nch = 0 + unsigned nch = 0; cs = ffunc(fparam); nch++; diff --git a/oscar64/Errors.h b/oscar64/Errors.h index 60d8517..0037c70 100644 --- a/oscar64/Errors.h +++ b/oscar64/Errors.h @@ -62,6 +62,7 @@ enum ErrorID ERRR_INSUFFICIENT_MEMORY, ERRR_INTERRUPT_TO_COMPLEX, ERRR_INVALID_STORAGE_TYPE, + ERRR_SEMICOLON_EXPECTED, EERR_INVALID_PREPROCESSOR, }; diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 7bc2f1d..e50cc46 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -12206,9 +12206,7 @@ bool NativeCodeBasicBlock::MoveAccuTrainUp(int at, int end) if (mIns[i].mLive & (LIVE_CPU_REG_A | LIVE_CPU_REG_C | LIVE_CPU_REG_Z)) return false; - int live = 0; - if (i > 0) - live |= mIns[i - 1].mLive; + int live = mIns[i].mLive; for (int j = i; j < at; j++) mIns[j].mLive |= mIns[end - 1].mLive; @@ -14345,6 +14343,72 @@ bool NativeCodeBasicBlock::CanForwardZPMove(int saddr, int daddr, int & index) c return false; } +bool NativeCodeBasicBlock::CheckShortcutPointerAddForward(int at) +{ + int i = at + 6; + + while (i < mIns.Size()) + { + if (mIns[i].mMode == ASMIM_INDIRECT_Y && mIns[i].mAddress == mIns[at + 1].mAddress) + { + if (!(mIns[i].mLive & LIVE_MEM)) + { + mIns[at + 0].mType = ASMIT_NOP; mIns[at + 0].mMode = ASMIM_IMPLIED; + mIns[at + 1].mType = ASMIT_NOP; mIns[at + 1].mMode = ASMIM_IMPLIED; + mIns[at + 5].mAddress = mIns[at + 4].mAddress; mIns[at + 4].mLive |= LIVE_MEM; + + for (int j = at + 6; j <= i; j++) + { + if (mIns[j].mMode == ASMIM_INDIRECT_Y && mIns[j].mAddress == mIns[at + 1].mAddress) + mIns[j].mAddress = mIns[at + 0].mAddress; + } + + return true; + } + } + else if (mIns[i].ChangesZeroPage(mIns[at + 0].mAddress) || + mIns[i].ReferencesZeroPage(mIns[at + 1].mAddress) || + mIns[i].ReferencesZeroPage(mIns[at + 4].mAddress) || + mIns[i].ReferencesZeroPage(mIns[at + 5].mAddress)) + return false; + + i++; + } + + return false; +} + +bool NativeCodeBasicBlock::ShortcutPointerAddForward(void) +{ + bool changed = false; + + if (!mVisited) + { + mVisited = true; + + for (int i = 0; i + 6 < mIns.Size(); i++) + { + if (mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && + mIns[i + 1].mType == ASMIT_STA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && + mIns[i + 2].mType == ASMIT_CLC && + mIns[i + 3].mType == ASMIT_LDA && mIns[i + 3].mMode == ASMIM_IMMEDIATE_ADDRESS && + mIns[i + 4].mType == ASMIT_ADC && mIns[i + 4].mMode == ASMIM_ZERO_PAGE && mIns[i + 4].mAddress == mIns[i + 0].mAddress + 1 && !(mIns[i + 4].mLive & LIVE_MEM) && + mIns[i + 5].mType == ASMIT_STA && mIns[i + 5].mMode == ASMIM_ZERO_PAGE && mIns[i + 5].mAddress == mIns[i + 1].mAddress + 1) + { + if (CheckShortcutPointerAddForward(i)) + changed = true; + } + } + + if (mTrueJump && mTrueJump->ShortcutPointerAddForward()) + changed = true; + if (mFalseJump && mFalseJump->ShortcutPointerAddForward()) + changed = true; + } + + return changed; +} + bool NativeCodeBasicBlock::CanChangeTailZPStoreToX(int addr, const NativeCodeBasicBlock* nblock, const NativeCodeBasicBlock* fblock) const { if (mExitRequiredRegs[CPU_REG_X]) @@ -28922,6 +28986,16 @@ void NativeCodeProcedure::Optimize(void) changed = true; } #endif + +#if 1 + if (step == 3) + { + ResetVisited(); + if (mEntryBlock->ShortcutPointerAddForward()) + changed = true; + } +#endif + #if 1 if (step > 0) { diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index 8e6a23b..55085bc 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -412,6 +412,9 @@ public: bool Is16BitAddSubImmediate(int at, int& sreg, int &dreg, int& offset) const; bool CanForward16BitAddSubImmediate(int sreg, int dreg, int offset, int & index) const; + bool CheckShortcutPointerAddForward(int at); + bool ShortcutPointerAddForward(void); + bool CheckPatchFail(const NativeCodeBasicBlock* block, int reg); bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int at, int yval); diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index d6390a8..b64bfea 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -70,7 +70,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt) Declaration* mlast = nullptr; for (;;) { - Declaration* mdec = ParseDeclaration(false); + Declaration* mdec = ParseDeclaration(false, false); int offset = dec->mSize; if (dt == DT_TYPE_UNION) @@ -957,7 +957,7 @@ Expression* Parser::ParseInitExpression(Declaration* dtype) return exp; } -Declaration* Parser::ParseDeclaration(bool variable) +Declaration* Parser::ParseDeclaration(bool variable, bool expression) { bool definingType = false; uint64 storageFlags = 0, typeFlags = 0; @@ -1226,7 +1226,12 @@ Declaration* Parser::ParseDeclaration(bool variable) return rdec; } else + { + if (!expression && mScanner->mToken != TK_SEMICOLON) + mErrors->Error(mScanner->mLocation, ERRR_SEMICOLON_EXPECTED, "Semicolon expected"); + return rdec; + } } return rdec; @@ -1237,7 +1242,7 @@ Expression* Parser::ParseDeclarationExpression(void) Declaration* dec; Expression* exp = nullptr, * rexp = nullptr; - dec = ParseDeclaration(true); + dec = ParseDeclaration(true, true); if (dec->mType == DT_ANON && dec->mNext == 0) { exp = new Expression(dec->mLocation, EX_TYPE); @@ -2112,6 +2117,7 @@ Expression* Parser::ParseStatement(void) { mScanner->NextToken(); exp->mLeft = ParseParenthesisExpression(); + ConsumeToken(TK_SEMICOLON); } else mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "'while' expected"); @@ -2326,17 +2332,21 @@ Expression* Parser::ParseStatement(void) exp = new Expression(mScanner->mLocation, EX_RETURN); if (mScanner->mToken != TK_SEMICOLON) exp->mLeft = ParseRExpression(); + ConsumeToken(TK_SEMICOLON); break; case TK_BREAK: mScanner->NextToken(); exp = new Expression(mScanner->mLocation, EX_BREAK); + ConsumeToken(TK_SEMICOLON); break; case TK_CONTINUE: mScanner->NextToken(); exp = new Expression(mScanner->mLocation, EX_CONTINUE); + ConsumeToken(TK_SEMICOLON); break; case TK_SEMICOLON: exp = new Expression(mScanner->mLocation, EX_VOID); + mScanner->NextToken(); break; case TK_ASM: mScanner->NextToken(); @@ -2359,14 +2369,13 @@ Expression* Parser::ParseStatement(void) mScanner->NextToken(); exp = new Expression(mScanner->mLocation, EX_ASSUME); exp->mLeft = ParseParenthesisExpression(); + ConsumeToken(TK_SEMICOLON); break; - default: exp = ParseExpression(); + ConsumeToken(TK_SEMICOLON); } - if (mScanner->mToken == TK_SEMICOLON) - mScanner->NextToken(); } assert(exp); @@ -3472,12 +3481,14 @@ void Parser::ParsePragma(void) LinkerRegion* rgn = mCompilationUnits->mLinker->FindRegion(regionIdent); if (!rgn) + { rgn = mCompilationUnits->mLinker->AddRegion(regionIdent, start, end); - else if (rgn->mStart != start || rgn->mEnd != end) + rgn->mFlags = flags; + rgn->mCartridgeBanks = bank; + } + else if (rgn->mStart != start || rgn->mEnd != end || rgn->mFlags != flags || rgn->mCartridgeBanks != bank) mErrors->Error(mScanner->mLocation, EERR_PRAGMA_PARAMETER, "Conflicting linker region definition"); - rgn->mFlags = flags; - rgn->mCartridgeBanks = bank; ConsumeToken(TK_COMMA); ConsumeToken(TK_OPEN_BRACE); @@ -3489,7 +3500,8 @@ void Parser::ParsePragma(void) LinkerSection* lsec = mCompilationUnits->mLinker->FindSection(mScanner->mTokenIdent); if (lsec) { - rgn->mSections.Push(lsec); + if (!rgn->mSections.Contains(lsec)) + rgn->mSections.Push(lsec); } else mErrors->Error(mScanner->mLocation, EERR_PRAGMA_PARAMETER, "Section name not defined"); @@ -3831,6 +3843,6 @@ void Parser::Parse(void) else if (mScanner->mToken == TK_SEMICOLON) mScanner->NextToken(); else - ParseDeclaration(true); + ParseDeclaration(true, false); } } diff --git a/oscar64/Parser.h b/oscar64/Parser.h index bcdc4a0..397fc6f 100644 --- a/oscar64/Parser.h +++ b/oscar64/Parser.h @@ -32,7 +32,7 @@ protected: void ParsePragma(void); Declaration* ParseBaseTypeDeclaration(uint64 flags); - Declaration* ParseDeclaration(bool variable); + Declaration* ParseDeclaration(bool variable, bool expression); Declaration* ParseStructDeclaration(uint64 flags, DecType dt); Declaration* CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp); diff --git a/samples/fractals/mbmulti3d.c b/samples/fractals/mbmulti3d.c index 78ccb6b..7cb3b6b 100644 --- a/samples/fractals/mbmulti3d.c +++ b/samples/fractals/mbmulti3d.c @@ -81,7 +81,7 @@ float iter(float xz, float yz) if (i == 32) return 32; else - return i - log(log(r)/log(64.0))/log(2.0) + return i - log(log(r)/log(64.0))/log(2.0); } // Calculate light with given new and old heights diff --git a/samples/games/breakout.c b/samples/games/breakout.c index 8f88aba..ace2326 100644 --- a/samples/games/breakout.c +++ b/samples/games/breakout.c @@ -208,7 +208,7 @@ void brick_animate(void) char * sp = Screen + 40 * (y - 1) + (x - 1); - char ch = 96 + (x & 1) + 2 * (y & 1) + char ch = 96 + (x & 1) + 2 * (y & 1); if (sp[ 0] >= 128) sp[41] = ch | 4; else @@ -256,7 +256,7 @@ struct Ball char index; bool active; int sx, sy, vx, vy; -} +}; // using 10.6 bit fixed point math @@ -527,7 +527,7 @@ void paddle_control(void) if (paddlex < BALL_COORD(-4, 0) || paddlex > BALL_COORD(320 - 48 + 4, 0)) { paddlevx = -paddlevx; - paddlex += paddlevx + paddlex += paddlevx; } } @@ -551,9 +551,9 @@ void game_state(GameState state) break; case GS_BALL_LOCKED: - ball_init(TheGame.balls + 0, 0, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)) - ball_init(TheGame.balls + 1, 1, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)) - ball_init(TheGame.balls + 2, 2, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)) + ball_init(TheGame.balls + 0, 0, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)); + ball_init(TheGame.balls + 1, 1, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)); + ball_init(TheGame.balls + 2, 2, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0)); break; case GS_PLAYING: diff --git a/samples/games/lander.c b/samples/games/lander.c index 856440e..c94970e 100644 --- a/samples/games/lander.c +++ b/samples/games/lander.c @@ -58,7 +58,7 @@ void screen_init(void) memset(Screen, ' ', 1000); for(char i=0; i<100; i++) - screen_put(rand() % 40, rand() % 25, '.', VCOL_WHITE) + screen_put(rand() % 40, rand() % 25, '.', VCOL_WHITE); sbyte height[41]; for(char i=0; i<41; i+=8) @@ -78,7 +78,7 @@ void screen_init(void) char yp = height[xp]; for(char i=1; i<4; i++) if (height[xp + i] < yp) - yp = height[xp + i] + yp = height[xp + i]; for(char i=0; i<4; i++) height[xp + i] = yp; @@ -87,14 +87,14 @@ void screen_init(void) { char h = height[x]; for(char y=0; y 200) - sx = 296 + sx = 296; // Fire missile missile_start(sx, 184, CrossX, CrossY); diff --git a/samples/hires/func3d.c b/samples/hires/func3d.c index 243e763..605c385 100644 --- a/samples/hires/func3d.c +++ b/samples/hires/func3d.c @@ -20,7 +20,7 @@ Bitmap Screen = { ClipRect SRect = { 0, 0, 320, 200 -} +}; char chk[] = {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}; char white[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -87,7 +87,7 @@ void qsort(Surf * n, int s) { n[pi] = n[i]; pi++; - n[i] = n[pi] + n[i] = n[pi]; } } n[pi] = pn; diff --git a/samples/hiresmc/func3d.c b/samples/hiresmc/func3d.c index 4d0af57..0c94f07 100644 --- a/samples/hiresmc/func3d.c +++ b/samples/hiresmc/func3d.c @@ -21,7 +21,7 @@ Bitmap Screen = { ClipRect SRect = { 0, 0, 320, 200 -} +}; Matrix4 wmat, pmat, tmat, rmat; @@ -85,7 +85,7 @@ void qsort(Surf * n, int s) { n[pi] = n[i]; pi++; - n[i] = n[pi] + n[i] = n[pi]; } } n[pi] = pn; @@ -105,8 +105,6 @@ int main(void) mat4_ident(&wmat); mat4_make_perspective(&pmat, 0.5 * PI, 1.0, 0.0, 200.0); - bm_put - for(int ix=0; ix= 0) { // Print the value of the byte - printf("%d : %d\n", k, ch) + printf("%d : %d\n", k, ch); k++; // Exit the loop if this was the last byte of the file diff --git a/samples/memmap/charsetcopy.c b/samples/memmap/charsetcopy.c index 0a1dfa0..0606869 100644 --- a/samples/memmap/charsetcopy.c +++ b/samples/memmap/charsetcopy.c @@ -21,7 +21,7 @@ char charset[2048] = { #embed "../resources/charset.bin" -} +}; // back to normal @@ -41,14 +41,14 @@ int main(void) mmap_set(MMAP_RAM); // copy the font - memcpy(Charset, charset, 2048) + memcpy(Charset, charset, 2048); // make lower part of RAM visible to CPU mmap_set(MMAP_NO_BASIC); // map the vic to the new charset - vic_setmode(VICM_TEXT, Screen, Charset) + vic_setmode(VICM_TEXT, Screen, Charset); for(int i=0; i<1000; i++) Screen[i] = (char)i; @@ -59,7 +59,7 @@ int main(void) // restore VIC - vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) + vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000); // restore basic ROM mmap_set(MMAP_ROM); diff --git a/samples/memmap/charsetexpand.c b/samples/memmap/charsetexpand.c index ee1a7a0..ce8293f 100644 --- a/samples/memmap/charsetexpand.c +++ b/samples/memmap/charsetexpand.c @@ -23,7 +23,7 @@ // lz compressed data char charset[] = { #embed 2048 0 lzo "../resources/charset.bin" -} +}; // back to normal @@ -50,7 +50,7 @@ int main(void) // map the vic to the new charset - vic_setmode(VICM_TEXT, Screen, Charset) + vic_setmode(VICM_TEXT, Screen, Charset); for(int i=0; i<1000; i++) Screen[i] = (char)i; @@ -61,7 +61,7 @@ int main(void) // restore VIC - vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) + vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000); // restore basic ROM mmap_set(MMAP_ROM); diff --git a/samples/memmap/charsethi.c b/samples/memmap/charsethi.c index b315b3d..ff931af 100644 --- a/samples/memmap/charsethi.c +++ b/samples/memmap/charsethi.c @@ -13,7 +13,7 @@ char charset[2048] = { #embed "../resources/charset.bin" -} +}; #pragma data(data) @@ -24,7 +24,7 @@ int main(void) { // map the vic to the new charset - vic_setmode(VICM_TEXT, Screen, charset) + vic_setmode(VICM_TEXT, Screen, charset); for(int i=0; i<1000; i++) Screen[i] = (char)i; diff --git a/samples/memmap/charsetlo.c b/samples/memmap/charsetlo.c index 7e41ce6..63e22d9 100644 --- a/samples/memmap/charsetlo.c +++ b/samples/memmap/charsetlo.c @@ -21,7 +21,7 @@ char charset[2048] = { #embed "../resources/charset.bin" -} +}; #pragma data(data) @@ -29,7 +29,7 @@ int main(void) { // map the vic to the new charset - vic_setmode(VICM_TEXT, (char *)0x0400, charset) + vic_setmode(VICM_TEXT, (char *)0x0400, charset); for(int i=0; i<10; i++) printf(p"%D Hello World\n", i); diff --git a/samples/memmap/charsetload.c b/samples/memmap/charsetload.c index 650d8ab..1bcf914 100644 --- a/samples/memmap/charsetload.c +++ b/samples/memmap/charsetload.c @@ -22,7 +22,7 @@ int main(void) // Change display address to new screen and charset - vic_setmode(VICM_TEXT, Screen, Charset) + vic_setmode(VICM_TEXT, Screen, Charset); for(int i=0; i<1000; i++) Screen[i] = (char)i; @@ -33,7 +33,7 @@ int main(void) // restore VIC - vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) + vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000); // restore basic ROM mmap_set(MMAP_ROM); diff --git a/samples/memmap/easyflashreloc.c b/samples/memmap/easyflashreloc.c index 4f78144..2738955 100644 --- a/samples/memmap/easyflashreloc.c +++ b/samples/memmap/easyflashreloc.c @@ -70,7 +70,7 @@ void done1(void) const EntryTable entry1 = { .fhello = &print1, .fdone = &done1 -} +}; // make sure the function is referenced #pragma reference(entry1) @@ -93,7 +93,7 @@ void done2(void) const EntryTable entry2 = { .fhello = &print2, .fdone = &done2 -} +}; // make sure the function is referenced #pragma reference(entry2) @@ -114,7 +114,7 @@ void done3(void) const EntryTable entry3 = { .fhello = &print3, .fdone = &done3 -} +}; #pragma reference(entry3) @@ -134,7 +134,7 @@ void done4(void) const EntryTable entry4 = { .fhello = &print4, .fdone = &done4 -} +}; #pragma reference(entry4) @@ -154,7 +154,7 @@ void done5(void) const EntryTable entry5 = { .fhello = &print5, .fdone = &done5 -} +}; #pragma reference(entry5) @@ -174,7 +174,7 @@ void done6(void) const EntryTable entry6 = { .fhello = &print6, .fdone = &done6 -} +}; #pragma reference(entry6) diff --git a/samples/memmap/largemem.c b/samples/memmap/largemem.c index dbc6ecf..bd396ce 100644 --- a/samples/memmap/largemem.c +++ b/samples/memmap/largemem.c @@ -10,7 +10,7 @@ int main(void) { // Hide the basic ROM, must be first instruction - mmap_set(MMAP_NO_BASIC) + mmap_set(MMAP_NO_BASIC); // Allocate all memory @@ -29,7 +29,7 @@ int main(void) // Return basic ROM to normal state - mmap_set(MMAP_ROM) + mmap_set(MMAP_ROM); return 0; } diff --git a/samples/scrolling/bigfont.c b/samples/scrolling/bigfont.c index 2160469..d3221ab 100644 --- a/samples/scrolling/bigfont.c +++ b/samples/scrolling/bigfont.c @@ -61,7 +61,7 @@ const char * text = s"dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit " s"amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor " s"invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam " - s"et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." + s"et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."; int main(void) diff --git a/samples/scrolling/cgrid8way.c b/samples/scrolling/cgrid8way.c index 2873284..27c64b0 100644 --- a/samples/scrolling/cgrid8way.c +++ b/samples/scrolling/cgrid8way.c @@ -157,7 +157,7 @@ void scroll_left(void) vic_waitBottom(); // Now back to 4, 4 - vic.ctrl2 = 0x04 + vic.ctrl2 = 0x04; } @@ -209,7 +209,7 @@ void scroll_right(void) #until ty == 25 vic_waitBottom(); - vic.ctrl2 = 0x02 + vic.ctrl2 = 0x02; vic_waitTop(); vic_waitBottom(); @@ -383,7 +383,7 @@ int main(void) // setup initial scroll offset vic.ctrl1 = 0x04 | VIC_CTRL1_DEN; - vic.ctrl2 = 0x04 + vic.ctrl2 = 0x04; for(;;) { diff --git a/samples/sprites/creditroll.c b/samples/sprites/creditroll.c index 4afa82a..b358c24 100644 --- a/samples/sprites/creditroll.c +++ b/samples/sprites/creditroll.c @@ -31,7 +31,7 @@ char spriteset[64 * 48] = {0}; char charset[32 * 8] = { #embed "../resources/scifiglyph.bin" -} +}; const char * scrolltext[] = {