Optimize PETSCII conversion in charwin
This commit is contained in:
parent
25ba5ca789
commit
3507b09207
|
@ -181,17 +181,19 @@ bool cwin_cursor_backward(CharWin * win)
|
|||
return false;
|
||||
}
|
||||
|
||||
static char p2smap[] = {0x00, 0x20, 0x00, 0x40, 0x00, 0x60, 0x40, 0x60};
|
||||
static char s2pmap[] = {0x40, 0x20, 0x60, 0xb0, 0x40, 0x20, 0x60, 0xb0};
|
||||
//static char p2smap[] = {0x00, 0x20, 0x00, 0x40, 0x00, 0x60, 0x40, 0x60};
|
||||
static char p2smap[] = {0x00, 0x00, 0x40, 0x20, 0x80, 0xc0, 0x80, 0x80};
|
||||
//static char s2pmap[] = {0x40, 0x20, 0x60, 0xa0, 0x40, 0x20, 0x60, 0xa0};
|
||||
static char s2pmap[] = {0x40, 0x00, 0x20, 0xc0, 0xc0, 0x80, 0xa0, 0x40};
|
||||
|
||||
static inline char p2s(char ch)
|
||||
{
|
||||
return (ch & 0x1f) | p2smap[ch >> 5];
|
||||
return ch ^ p2smap[ch >> 5];
|
||||
}
|
||||
|
||||
static inline char s2p(char ch)
|
||||
{
|
||||
return (ch & 0x1f) | s2pmap[ch >> 5];
|
||||
return ch ^ s2pmap[ch >> 5];
|
||||
}
|
||||
|
||||
void cwin_read_string(CharWin * win, char * buffer)
|
||||
|
|
|
@ -226,7 +226,7 @@ Expression* Expression::ConstantFold(Errors * errors)
|
|||
return ex;
|
||||
}
|
||||
}
|
||||
else if (mLeft->mDecType->mType == DT_CONST_INTEGER)
|
||||
else if (mLeft->mDecType->mType == DT_TYPE_INTEGER)
|
||||
{
|
||||
if (mRight->mDecValue->mType == DT_CONST_FLOAT)
|
||||
{
|
||||
|
@ -238,8 +238,27 @@ Expression* Expression::ConstantFold(Errors * errors)
|
|||
ex->mDecType = mLeft->mDecType;
|
||||
return ex;
|
||||
}
|
||||
else if (mRight->mDecValue->mType == DT_CONST_INTEGER)
|
||||
{
|
||||
int64 sval = 1ULL << (8 * mLeft->mDecType->mSize);
|
||||
int64 v = mRight->mDecValue->mInteger & (sval - 1);
|
||||
|
||||
if (mLeft->mDecType->mFlags & DTF_SIGNED)
|
||||
{
|
||||
if (v & (sval >> 1))
|
||||
v -= sval;
|
||||
}
|
||||
|
||||
Expression* ex = new Expression(mLocation, EX_CONSTANT);
|
||||
Declaration* dec = new Declaration(mLocation, DT_CONST_INTEGER);
|
||||
dec->mBase = mLeft->mDecType;
|
||||
dec->mInteger = v;
|
||||
ex->mDecValue = dec;
|
||||
ex->mDecType = mLeft->mDecType;
|
||||
return ex;
|
||||
}
|
||||
}
|
||||
else if (mLeft->mDecType->mType == DT_CONST_FLOAT)
|
||||
else if (mLeft->mDecType->mType == DT_TYPE_FLOAT)
|
||||
{
|
||||
if (mRight->mDecValue->mType == DT_CONST_INTEGER)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue