Fix lenient semicolon handling in parser

This commit is contained in:
drmortalwombat 2022-09-10 10:05:44 +02:00
parent 8287f03f49
commit e50f3f9814
38 changed files with 184 additions and 96 deletions

View File

@ -11,7 +11,7 @@ const struct A {
{ {
{4, 5, 6, 7, 8} {4, 5, 6, 7, 8}
} }
} };
const int * t[4] = { const int * t[4] = {
a.b + 1 + 1 a.b + 1 + 1

View File

@ -20,7 +20,7 @@ void qsort(Node * n, int s)
{ {
n[pi] = n[i]; n[pi] = n[i];
pi++; pi++;
n[i] = n[pi] n[i] = n[pi];
} }
} }
n[pi] = pn; n[pi] = pn;

View File

@ -11,6 +11,6 @@ int main(void)
assert(lsum == 32157742L); assert(lsum == 32157742L);
return 0 return 0;
} }

View File

@ -115,7 +115,7 @@ inline void rirq_delay(RIRQCode * ic, byte cycles);
inline void rirq_set(byte n, byte row, RIRQCode * write); inline void rirq_set(byte n, byte row, RIRQCode * write);
// Remove a raster IRQ from one of the 16 slots // 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 // Change the vertical position of the raster IRQ of one of the slots
inline void rirq_move(byte n, byte row); inline void rirq_move(byte n, byte row);

View File

@ -46,7 +46,7 @@ void vic_setmode(VicMode mode, char * text, char * font)
vic.ctrl2 = VIC_CTRL2_CSEL | VIC_CTRL2_MCM; vic.ctrl2 = VIC_CTRL2_CSEL | VIC_CTRL2_MCM;
break; break;
default: default:
__assume(false) __assume(false);
} }
cia2.pra = (cia2.pra & 0xfc) | (((unsigned)text >> 14) ^ 0x03); cia2.pra = (cia2.pra & 0xfc) | (((unsigned)text >> 14) ^ 0x03);

View File

@ -5,7 +5,7 @@
__native unsigned long lmul16u(unsigned x, unsigned y); __native unsigned long lmul16u(unsigned x, unsigned y);
// Multiply two signed 16bit numbers and return a signed 32bit result // 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 // Multiply two 12.4 fixpoint numbers and return a 12.4 fixpoint result
inline int lmul12f4s(int x, int y); 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); inline int lmul8f8s(int x, int y);
// Multiply two 4.12 fixpoint numbers and return a 12.4 fixpoint result // 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 // Square of a 4.12 sigend fixpoint number and return an 8.24 fixpoint result
inline unsigned long lsqr4f12s(int x); inline unsigned long lsqr4f12s(int x);
// Divide a 32bit unsigned number by a 16bit number and return a 16bit number // 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 // 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 // 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 // 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 // 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 // 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 // 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); __native unsigned lmuldiv16by8(unsigned a, char b, char c);

View File

@ -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 bm_usqrt(unsigned n)
{ {
unsigned p, q, r, h unsigned p, q, r, h;
p = 0; p = 0;
r = n; r = n;

View File

@ -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 // 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 // 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. // 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 // 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); 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);

View File

@ -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; int rx = (dx + w + 1) & ~1;
dx &= ~1; dx &= ~1;
sx &= ~1 sx &= ~1;
bmu_bitblit(dbm, dx, dy, sbm, sx, sy, rx - dx, h, nullptr, BLTOP_COPY); 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; int rx = (dx + w + 1) & ~1;
dx &= ~1; dx &= ~1;
sx &= ~1 sx &= ~1;
bm_bitblit(dbm, clip, dx, dy, sbm, sx, sy, rx - dx, h, nullptr, BLTOP_COPY); bm_bitblit(dbm, clip, dx, dy, sbm, sx, sy, rx - dx, h, nullptr, BLTOP_COPY);
} }

View File

@ -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 // 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 // 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. // 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 // 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); 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);

View File

@ -447,7 +447,7 @@ void mat3_rmmul(Matrix3 * md, const Matrix3 * ms)
void mat3_transpose(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[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[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]; t = ms->m[5]; md->m[5] = ms->m[7]; md->m[7] = t; md->m[8] = ms->m[8];

View File

@ -74,7 +74,7 @@ void mat2_invert(Matrix2 * md, const Matrix2 * ms);
struct Vector3 struct Vector3
{ {
float v[3]; float v[3];
} };
inline void vec3_set(Vector3 * vd, float x, float y, float z); 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 struct Matrix3
{ {
float m[9]; float m[9];
} };
void mat3_ident(Matrix3 * m); void mat3_ident(Matrix3 * m);
@ -160,7 +160,7 @@ void mat3_set_rotate(Matrix3 * m, const Vector3 * v, float a);
struct Vector4 struct Vector4
{ {
float v[4]; float v[4];
} };
inline void vec4_set(Vector4 * vd, float x, float y, float z, float w); 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 struct Matrix4
{ {
float m[16]; float m[16];
} };
void mat4_ident(Matrix4 * m); void mat4_ident(Matrix4 * m);

View File

@ -98,7 +98,7 @@ float atan2(float p, float q)
s *= g; s += F_ATAN_3; s *= g; s += F_ATAN_3;
s *= g; s += F_ATAN_2; s *= g; s += F_ATAN_2;
s *= g; s += F_ATAN_1; s *= g; s += F_ATAN_1;
s *= g; s += F_ATAN_0 s *= g; s += F_ATAN_0;
if (quad & 1) if (quad & 1)
s = 0.5 * PI - s; s = 0.5 * PI - s;
@ -138,7 +138,7 @@ float exp(float f)
s *= g; s += F_EXP_3; s *= g; s += F_EXP_3;
s *= g; s += F_EXP_2; s *= g; s += F_EXP_2;
s *= g; s += F_EXP_1; s *= g; s += F_EXP_1;
s *= g; s += F_EXP_0 s *= g; s += F_EXP_0;
return s * x.f; return s * x.f;
} }
@ -174,7 +174,7 @@ float log(float f)
s *= g; s += F_LOG_3; s *= g; s += F_LOG_3;
s *= g; s += F_LOG_2; s *= g; s += F_LOG_2;
s *= g; s += F_LOG_1; s *= g; s += F_LOG_1;
s *= g; s += F_LOG_0 s *= g; s += F_LOG_0;
return (fex + s) * 0.6931471806; return (fex + s) * 0.6931471806;
} }

View File

@ -82,7 +82,7 @@ const char * oscar_expand_rle(char * dp, const char * sp)
cmd = sp[0]; cmd = sp[0];
} while (cmd) } while (cmd);
return sp + 1; return sp + 1;
} }

View File

@ -719,7 +719,7 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
{ {
char fc, cs; char fc, cs;
int nv = 0; int nv = 0;
unsigned nch = 0 unsigned nch = 0;
cs = ffunc(fparam); cs = ffunc(fparam);
nch++; nch++;

View File

@ -62,6 +62,7 @@ enum ErrorID
ERRR_INSUFFICIENT_MEMORY, ERRR_INSUFFICIENT_MEMORY,
ERRR_INTERRUPT_TO_COMPLEX, ERRR_INTERRUPT_TO_COMPLEX,
ERRR_INVALID_STORAGE_TYPE, ERRR_INVALID_STORAGE_TYPE,
ERRR_SEMICOLON_EXPECTED,
EERR_INVALID_PREPROCESSOR, EERR_INVALID_PREPROCESSOR,
}; };

View File

@ -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)) if (mIns[i].mLive & (LIVE_CPU_REG_A | LIVE_CPU_REG_C | LIVE_CPU_REG_Z))
return false; return false;
int live = 0; int live = mIns[i].mLive;
if (i > 0)
live |= mIns[i - 1].mLive;
for (int j = i; j < at; j++) for (int j = i; j < at; j++)
mIns[j].mLive |= mIns[end - 1].mLive; mIns[j].mLive |= mIns[end - 1].mLive;
@ -14345,6 +14343,72 @@ bool NativeCodeBasicBlock::CanForwardZPMove(int saddr, int daddr, int & index) c
return false; 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 bool NativeCodeBasicBlock::CanChangeTailZPStoreToX(int addr, const NativeCodeBasicBlock* nblock, const NativeCodeBasicBlock* fblock) const
{ {
if (mExitRequiredRegs[CPU_REG_X]) if (mExitRequiredRegs[CPU_REG_X])
@ -28922,6 +28986,16 @@ void NativeCodeProcedure::Optimize(void)
changed = true; changed = true;
} }
#endif #endif
#if 1
if (step == 3)
{
ResetVisited();
if (mEntryBlock->ShortcutPointerAddForward())
changed = true;
}
#endif
#if 1 #if 1
if (step > 0) if (step > 0)
{ {

View File

@ -412,6 +412,9 @@ public:
bool Is16BitAddSubImmediate(int at, int& sreg, int &dreg, int& offset) const; bool Is16BitAddSubImmediate(int at, int& sreg, int &dreg, int& offset) const;
bool CanForward16BitAddSubImmediate(int sreg, int dreg, int offset, int & index) 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 CheckPatchFail(const NativeCodeBasicBlock* block, int reg);
bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int at, int yval); bool CheckGlobalAddressSumYPointer(const NativeCodeBasicBlock * block, int reg, int at, int yval);

View File

@ -70,7 +70,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
Declaration* mlast = nullptr; Declaration* mlast = nullptr;
for (;;) for (;;)
{ {
Declaration* mdec = ParseDeclaration(false); Declaration* mdec = ParseDeclaration(false, false);
int offset = dec->mSize; int offset = dec->mSize;
if (dt == DT_TYPE_UNION) if (dt == DT_TYPE_UNION)
@ -957,7 +957,7 @@ Expression* Parser::ParseInitExpression(Declaration* dtype)
return exp; return exp;
} }
Declaration* Parser::ParseDeclaration(bool variable) Declaration* Parser::ParseDeclaration(bool variable, bool expression)
{ {
bool definingType = false; bool definingType = false;
uint64 storageFlags = 0, typeFlags = 0; uint64 storageFlags = 0, typeFlags = 0;
@ -1226,7 +1226,12 @@ Declaration* Parser::ParseDeclaration(bool variable)
return rdec; return rdec;
} }
else else
{
if (!expression && mScanner->mToken != TK_SEMICOLON)
mErrors->Error(mScanner->mLocation, ERRR_SEMICOLON_EXPECTED, "Semicolon expected");
return rdec; return rdec;
}
} }
return rdec; return rdec;
@ -1237,7 +1242,7 @@ Expression* Parser::ParseDeclarationExpression(void)
Declaration* dec; Declaration* dec;
Expression* exp = nullptr, * rexp = nullptr; Expression* exp = nullptr, * rexp = nullptr;
dec = ParseDeclaration(true); dec = ParseDeclaration(true, true);
if (dec->mType == DT_ANON && dec->mNext == 0) if (dec->mType == DT_ANON && dec->mNext == 0)
{ {
exp = new Expression(dec->mLocation, EX_TYPE); exp = new Expression(dec->mLocation, EX_TYPE);
@ -2112,6 +2117,7 @@ Expression* Parser::ParseStatement(void)
{ {
mScanner->NextToken(); mScanner->NextToken();
exp->mLeft = ParseParenthesisExpression(); exp->mLeft = ParseParenthesisExpression();
ConsumeToken(TK_SEMICOLON);
} }
else else
mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "'while' expected"); mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "'while' expected");
@ -2326,17 +2332,21 @@ Expression* Parser::ParseStatement(void)
exp = new Expression(mScanner->mLocation, EX_RETURN); exp = new Expression(mScanner->mLocation, EX_RETURN);
if (mScanner->mToken != TK_SEMICOLON) if (mScanner->mToken != TK_SEMICOLON)
exp->mLeft = ParseRExpression(); exp->mLeft = ParseRExpression();
ConsumeToken(TK_SEMICOLON);
break; break;
case TK_BREAK: case TK_BREAK:
mScanner->NextToken(); mScanner->NextToken();
exp = new Expression(mScanner->mLocation, EX_BREAK); exp = new Expression(mScanner->mLocation, EX_BREAK);
ConsumeToken(TK_SEMICOLON);
break; break;
case TK_CONTINUE: case TK_CONTINUE:
mScanner->NextToken(); mScanner->NextToken();
exp = new Expression(mScanner->mLocation, EX_CONTINUE); exp = new Expression(mScanner->mLocation, EX_CONTINUE);
ConsumeToken(TK_SEMICOLON);
break; break;
case TK_SEMICOLON: case TK_SEMICOLON:
exp = new Expression(mScanner->mLocation, EX_VOID); exp = new Expression(mScanner->mLocation, EX_VOID);
mScanner->NextToken();
break; break;
case TK_ASM: case TK_ASM:
mScanner->NextToken(); mScanner->NextToken();
@ -2359,14 +2369,13 @@ Expression* Parser::ParseStatement(void)
mScanner->NextToken(); mScanner->NextToken();
exp = new Expression(mScanner->mLocation, EX_ASSUME); exp = new Expression(mScanner->mLocation, EX_ASSUME);
exp->mLeft = ParseParenthesisExpression(); exp->mLeft = ParseParenthesisExpression();
ConsumeToken(TK_SEMICOLON);
break; break;
default: default:
exp = ParseExpression(); exp = ParseExpression();
ConsumeToken(TK_SEMICOLON);
} }
if (mScanner->mToken == TK_SEMICOLON)
mScanner->NextToken();
} }
assert(exp); assert(exp);
@ -3472,12 +3481,14 @@ void Parser::ParsePragma(void)
LinkerRegion* rgn = mCompilationUnits->mLinker->FindRegion(regionIdent); LinkerRegion* rgn = mCompilationUnits->mLinker->FindRegion(regionIdent);
if (!rgn) if (!rgn)
{
rgn = mCompilationUnits->mLinker->AddRegion(regionIdent, start, end); 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"); mErrors->Error(mScanner->mLocation, EERR_PRAGMA_PARAMETER, "Conflicting linker region definition");
rgn->mFlags = flags;
rgn->mCartridgeBanks = bank;
ConsumeToken(TK_COMMA); ConsumeToken(TK_COMMA);
ConsumeToken(TK_OPEN_BRACE); ConsumeToken(TK_OPEN_BRACE);
@ -3489,7 +3500,8 @@ void Parser::ParsePragma(void)
LinkerSection* lsec = mCompilationUnits->mLinker->FindSection(mScanner->mTokenIdent); LinkerSection* lsec = mCompilationUnits->mLinker->FindSection(mScanner->mTokenIdent);
if (lsec) if (lsec)
{ {
rgn->mSections.Push(lsec); if (!rgn->mSections.Contains(lsec))
rgn->mSections.Push(lsec);
} }
else else
mErrors->Error(mScanner->mLocation, EERR_PRAGMA_PARAMETER, "Section name not defined"); 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) else if (mScanner->mToken == TK_SEMICOLON)
mScanner->NextToken(); mScanner->NextToken();
else else
ParseDeclaration(true); ParseDeclaration(true, false);
} }
} }

View File

@ -32,7 +32,7 @@ protected:
void ParsePragma(void); void ParsePragma(void);
Declaration* ParseBaseTypeDeclaration(uint64 flags); Declaration* ParseBaseTypeDeclaration(uint64 flags);
Declaration* ParseDeclaration(bool variable); Declaration* ParseDeclaration(bool variable, bool expression);
Declaration* ParseStructDeclaration(uint64 flags, DecType dt); Declaration* ParseStructDeclaration(uint64 flags, DecType dt);
Declaration* CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp); Declaration* CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp);

View File

@ -81,7 +81,7 @@ float iter(float xz, float yz)
if (i == 32) if (i == 32)
return 32; return 32;
else 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 // Calculate light with given new and old heights

View File

@ -208,7 +208,7 @@ void brick_animate(void)
char * sp = Screen + 40 * (y - 1) + (x - 1); 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) if (sp[ 0] >= 128)
sp[41] = ch | 4; sp[41] = ch | 4;
else else
@ -256,7 +256,7 @@ struct Ball
char index; char index;
bool active; bool active;
int sx, sy, vx, vy; int sx, sy, vx, vy;
} };
// using 10.6 bit fixed point math // 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)) if (paddlex < BALL_COORD(-4, 0) || paddlex > BALL_COORD(320 - 48 + 4, 0))
{ {
paddlevx = -paddlevx; paddlevx = -paddlevx;
paddlex += paddlevx paddlex += paddlevx;
} }
} }
@ -551,9 +551,9 @@ void game_state(GameState state)
break; break;
case GS_BALL_LOCKED: 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 + 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 + 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 + 2, 2, paddlex + BALL_COORD(22, 0), BALL_COORD(184, 0), BALL_COORD(0, 0), BALL_COORD(0, 0));
break; break;
case GS_PLAYING: case GS_PLAYING:

View File

@ -58,7 +58,7 @@ void screen_init(void)
memset(Screen, ' ', 1000); memset(Screen, ' ', 1000);
for(char i=0; i<100; i++) 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]; sbyte height[41];
for(char i=0; i<41; i+=8) for(char i=0; i<41; i+=8)
@ -78,7 +78,7 @@ void screen_init(void)
char yp = height[xp]; char yp = height[xp];
for(char i=1; i<4; i++) for(char i=1; i<4; i++)
if (height[xp + i] < yp) if (height[xp + i] < yp)
yp = height[xp + i] yp = height[xp + i];
for(char i=0; i<4; i++) for(char i=0; i<4; i++)
height[xp + i] = yp; height[xp + i] = yp;
@ -87,14 +87,14 @@ void screen_init(void)
{ {
char h = height[x]; char h = height[x];
for(char y=0; y<h; y++) for(char y=0; y<h; y++)
screen_put(x, 24 - y, 160, VCOL_YELLOW) screen_put(x, 24 - y, 160, VCOL_YELLOW);
} }
for(char i=0; i<4; i++) for(char i=0; i<4; i++)
{ {
screen_put(xp + i, 24 - yp, 128 + 86, VCOL_MED_GREY) screen_put(xp + i, 24 - yp, 128 + 86, VCOL_MED_GREY);
screen_put(xp + i, 23 - yp, 100, VCOL_WHITE) screen_put(xp + i, 23 - yp, 100, VCOL_WHITE);
} }
} }
@ -189,7 +189,7 @@ void game_state(GameState state)
{ {
case GS_READY: case GS_READY:
// Clear the screen // Clear the screen
lander_init(&TheGame.lander) lander_init(&TheGame.lander);
screen_init(); screen_init();
TheGame.count = 32; TheGame.count = 32;
break; break;

View File

@ -41,7 +41,7 @@ static const char * maze[16] =
// Character set including some ramps for the upper edge // Character set including some ramps for the upper edge
char charset[2048] = { char charset[2048] = {
#embed "../resources/maze3dchars.bin" #embed "../resources/maze3dchars.bin"
} };
// Current target screen // Current target screen
char * DrawScreen; char * DrawScreen;
@ -302,7 +302,7 @@ void maze_draw(const char * zxdist)
for(char cx=sx; cx<40-sx; cx++) for(char cx=sx; cx<40-sx; cx++)
{ {
color_column(cx, cfront); color_column(cx, cfront);
screen_column(cx, sx, 96 + (sx & 3), 96, 96) screen_column(cx, sx, 96 + (sx & 3), 96, 96);
} }
// And be done // And be done
@ -320,7 +320,7 @@ void maze_draw(const char * zxdist)
sbyte by = 25 - cx; sbyte by = 25 - cx;
color_column(cx, cleft); color_column(cx, cleft);
screen_column(cx, cx, 100 + (cx & 3), 96, 124) screen_column(cx, cx, 100 + (cx & 3), 96, 124);
} }
} }
else else
@ -333,7 +333,7 @@ void maze_draw(const char * zxdist)
for(char cx=sx; cx<tx; cx++) for(char cx=sx; cx<tx; cx++)
{ {
color_column(cx, cfront); color_column(cx, cfront);
screen_column(cx, tx, 96 + (tx & 3), 96, 96) screen_column(cx, tx, 96 + (tx & 3), 96, 96);
} }
} }
@ -345,7 +345,7 @@ void maze_draw(const char * zxdist)
sbyte ty = cx / 4; sbyte ty = cx / 4;
sbyte by = 25 - cx; sbyte by = 25 - cx;
color_column(39 - cx, cright); color_column(39 - cx, cright);
screen_column(39 - cx, cx, 107 - (cx & 3), 96, 125) screen_column(39 - cx, cx, 107 - (cx & 3), 96, 125);
} }
} }
else else

View File

@ -700,7 +700,7 @@ void game_play(void)
if (CrossX < 120) if (CrossX < 120)
sx = 24; sx = 24;
else if (CrossX > 200) else if (CrossX > 200)
sx = 296 sx = 296;
// Fire missile // Fire missile
missile_start(sx, 184, CrossX, CrossY); missile_start(sx, 184, CrossX, CrossY);

View File

@ -20,7 +20,7 @@ Bitmap Screen = {
ClipRect SRect = { ClipRect SRect = {
0, 0, 320, 200 0, 0, 320, 200
} };
char chk[] = {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}; char chk[] = {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55};
char white[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; char white[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@ -87,7 +87,7 @@ void qsort(Surf * n, int s)
{ {
n[pi] = n[i]; n[pi] = n[i];
pi++; pi++;
n[i] = n[pi] n[i] = n[pi];
} }
} }
n[pi] = pn; n[pi] = pn;

View File

@ -21,7 +21,7 @@ Bitmap Screen = {
ClipRect SRect = { ClipRect SRect = {
0, 0, 320, 200 0, 0, 320, 200
} };
Matrix4 wmat, pmat, tmat, rmat; Matrix4 wmat, pmat, tmat, rmat;
@ -85,7 +85,7 @@ void qsort(Surf * n, int s)
{ {
n[pi] = n[i]; n[pi] = n[i];
pi++; pi++;
n[i] = n[pi] n[i] = n[pi];
} }
} }
n[pi] = pn; n[pi] = pn;
@ -105,8 +105,6 @@ int main(void)
mat4_ident(&wmat); mat4_ident(&wmat);
mat4_make_perspective(&pmat, 0.5 * PI, 1.0, 0.0, 200.0); mat4_make_perspective(&pmat, 0.5 * PI, 1.0, 0.0, 200.0);
bm_put
for(int ix=0; ix<SIZE; ix++) for(int ix=0; ix<SIZE; ix++)
{ {
for(int iy=0; iy<SIZE; iy++) for(int iy=0; iy<SIZE; iy++)

View File

@ -12,7 +12,7 @@ int main(void)
while ((ch = krnio_getch(2)) >= 0) while ((ch = krnio_getch(2)) >= 0)
{ {
// Print the value of the byte // Print the value of the byte
printf("%d : %d\n", k, ch) printf("%d : %d\n", k, ch);
k++; k++;
// Exit the loop if this was the last byte of the file // Exit the loop if this was the last byte of the file

View File

@ -21,7 +21,7 @@
char charset[2048] = { char charset[2048] = {
#embed "../resources/charset.bin" #embed "../resources/charset.bin"
} };
// back to normal // back to normal
@ -41,14 +41,14 @@ int main(void)
mmap_set(MMAP_RAM); mmap_set(MMAP_RAM);
// copy the font // copy the font
memcpy(Charset, charset, 2048) memcpy(Charset, charset, 2048);
// make lower part of RAM visible to CPU // make lower part of RAM visible to CPU
mmap_set(MMAP_NO_BASIC); mmap_set(MMAP_NO_BASIC);
// map the vic to the new charset // 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++) for(int i=0; i<1000; i++)
Screen[i] = (char)i; Screen[i] = (char)i;
@ -59,7 +59,7 @@ int main(void)
// restore VIC // restore VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
// restore basic ROM // restore basic ROM
mmap_set(MMAP_ROM); mmap_set(MMAP_ROM);

View File

@ -23,7 +23,7 @@
// lz compressed data // lz compressed data
char charset[] = { char charset[] = {
#embed 2048 0 lzo "../resources/charset.bin" #embed 2048 0 lzo "../resources/charset.bin"
} };
// back to normal // back to normal
@ -50,7 +50,7 @@ int main(void)
// map the vic to the new charset // 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++) for(int i=0; i<1000; i++)
Screen[i] = (char)i; Screen[i] = (char)i;
@ -61,7 +61,7 @@ int main(void)
// restore VIC // restore VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
// restore basic ROM // restore basic ROM
mmap_set(MMAP_ROM); mmap_set(MMAP_ROM);

View File

@ -13,7 +13,7 @@
char charset[2048] = { char charset[2048] = {
#embed "../resources/charset.bin" #embed "../resources/charset.bin"
} };
#pragma data(data) #pragma data(data)
@ -24,7 +24,7 @@ int main(void)
{ {
// map the vic to the new charset // 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++) for(int i=0; i<1000; i++)
Screen[i] = (char)i; Screen[i] = (char)i;

View File

@ -21,7 +21,7 @@
char charset[2048] = { char charset[2048] = {
#embed "../resources/charset.bin" #embed "../resources/charset.bin"
} };
#pragma data(data) #pragma data(data)
@ -29,7 +29,7 @@ int main(void)
{ {
// map the vic to the new charset // 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++) for(int i=0; i<10; i++)
printf(p"%D Hello World\n", i); printf(p"%D Hello World\n", i);

View File

@ -22,7 +22,7 @@ int main(void)
// Change display address to new screen and charset // 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++) for(int i=0; i<1000; i++)
Screen[i] = (char)i; Screen[i] = (char)i;
@ -33,7 +33,7 @@ int main(void)
// restore VIC // restore VIC
vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000) vic_setmode(VICM_TEXT, (char *)0x0400, (char *)0x1000);
// restore basic ROM // restore basic ROM
mmap_set(MMAP_ROM); mmap_set(MMAP_ROM);

View File

@ -70,7 +70,7 @@ void done1(void)
const EntryTable entry1 = { const EntryTable entry1 = {
.fhello = &print1, .fhello = &print1,
.fdone = &done1 .fdone = &done1
} };
// make sure the function is referenced // make sure the function is referenced
#pragma reference(entry1) #pragma reference(entry1)
@ -93,7 +93,7 @@ void done2(void)
const EntryTable entry2 = { const EntryTable entry2 = {
.fhello = &print2, .fhello = &print2,
.fdone = &done2 .fdone = &done2
} };
// make sure the function is referenced // make sure the function is referenced
#pragma reference(entry2) #pragma reference(entry2)
@ -114,7 +114,7 @@ void done3(void)
const EntryTable entry3 = { const EntryTable entry3 = {
.fhello = &print3, .fhello = &print3,
.fdone = &done3 .fdone = &done3
} };
#pragma reference(entry3) #pragma reference(entry3)
@ -134,7 +134,7 @@ void done4(void)
const EntryTable entry4 = { const EntryTable entry4 = {
.fhello = &print4, .fhello = &print4,
.fdone = &done4 .fdone = &done4
} };
#pragma reference(entry4) #pragma reference(entry4)
@ -154,7 +154,7 @@ void done5(void)
const EntryTable entry5 = { const EntryTable entry5 = {
.fhello = &print5, .fhello = &print5,
.fdone = &done5 .fdone = &done5
} };
#pragma reference(entry5) #pragma reference(entry5)
@ -174,7 +174,7 @@ void done6(void)
const EntryTable entry6 = { const EntryTable entry6 = {
.fhello = &print6, .fhello = &print6,
.fdone = &done6 .fdone = &done6
} };
#pragma reference(entry6) #pragma reference(entry6)

View File

@ -10,7 +10,7 @@ int main(void)
{ {
// Hide the basic ROM, must be first instruction // Hide the basic ROM, must be first instruction
mmap_set(MMAP_NO_BASIC) mmap_set(MMAP_NO_BASIC);
// Allocate all memory // Allocate all memory
@ -29,7 +29,7 @@ int main(void)
// Return basic ROM to normal state // Return basic ROM to normal state
mmap_set(MMAP_ROM) mmap_set(MMAP_ROM);
return 0; return 0;
} }

View File

@ -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"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"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"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) int main(void)

View File

@ -157,7 +157,7 @@ void scroll_left(void)
vic_waitBottom(); vic_waitBottom();
// Now back to 4, 4 // Now back to 4, 4
vic.ctrl2 = 0x04 vic.ctrl2 = 0x04;
} }
@ -209,7 +209,7 @@ void scroll_right(void)
#until ty == 25 #until ty == 25
vic_waitBottom(); vic_waitBottom();
vic.ctrl2 = 0x02 vic.ctrl2 = 0x02;
vic_waitTop(); vic_waitTop();
vic_waitBottom(); vic_waitBottom();
@ -383,7 +383,7 @@ int main(void)
// setup initial scroll offset // setup initial scroll offset
vic.ctrl1 = 0x04 | VIC_CTRL1_DEN; vic.ctrl1 = 0x04 | VIC_CTRL1_DEN;
vic.ctrl2 = 0x04 vic.ctrl2 = 0x04;
for(;;) for(;;)
{ {

View File

@ -31,7 +31,7 @@ char spriteset[64 * 48] = {0};
char charset[32 * 8] = { char charset[32 * 8] = {
#embed "../resources/scifiglyph.bin" #embed "../resources/scifiglyph.bin"
} };
const char * scrolltext[] = { const char * scrolltext[] = {