Minor cleanups to compiled CON bytecode interpreter

git-svn-id: https://svn.eduke32.com/eduke32@30 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-04-16 06:25:14 +00:00
parent b11595ad2e
commit 6a83968dd7
2 changed files with 53 additions and 142 deletions

View file

@ -1872,11 +1872,9 @@ void tics(void)
{ {
j=(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]); j=(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]);
Bsprintf(b,"%ld",j>0?j:0); Bsprintf(b,"%ld",j>0?j:0);
/* printext256(windowx1,windowy1,31,-21,b,1); */ minitext(320-strlen(b)*4,ud.screen_size!=0?(ud.multimode>1&&ud.multimode<5?9:(ud.multimode>4?17:1)):1,b,(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]) < 40?2:0,26);
minitext(320-strlen(b)*4,ud.multimode>1&&ud.multimode<5?9:ud.multimode>4?17:1,b,(TICRATE*AVERAGEFRAMES)/(i-frameval[framecnt]) < 40?2:0,26);
frameval[framecnt] = i; frameval[framecnt] = i;
} }
framecnt = ((framecnt+1)&(AVERAGEFRAMES-1)); framecnt = ((framecnt+1)&(AVERAGEFRAMES-1));
} }

View file

@ -3588,8 +3588,7 @@ char parse(void)
case CON_SOUNDONCE: case CON_SOUNDONCE:
insptr++; insptr++;
if(!isspritemakingsound(g_i,*insptr)) if(!isspritemakingsound(g_i,*insptr))
spritesound((short) *insptr,g_i); spritesound((short) *insptr++,g_i);
insptr++;
break; break;
case CON_IFSOUND: case CON_IFSOUND:
insptr++; insptr++;
@ -3599,14 +3598,12 @@ char parse(void)
case CON_STOPSOUND: case CON_STOPSOUND:
insptr++; insptr++;
if(isspritemakingsound(g_i,*insptr)) if(isspritemakingsound(g_i,*insptr))
stopspritesound((short)*insptr,g_i); stopspritesound((short)*insptr++,g_i);
insptr++;
break; break;
case CON_GLOBALSOUND: case CON_GLOBALSOUND:
insptr++; insptr++;
if(g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) if(g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND))
spritesound((short) *insptr,ps[screenpeek].i); spritesound((short) *insptr++,ps[screenpeek].i);
insptr++;
break; break;
case CON_SOUND: case CON_SOUND:
insptr++; insptr++;
@ -4248,23 +4245,6 @@ SKIPJIBS:
break; break;
} }
case CON_EQSPAWNVAR:
{
long lReturn;
long lIn;
lReturn=-1;
insptr++;
lIn=*insptr++;
lIn=GetGameVarID(lIn, g_i, g_p);
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i, lIn);
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
insertspriteq(lReturn);
break;
}
case CON_INITTIMER: case CON_INITTIMER:
{ {
short i; short i;
@ -4286,20 +4266,7 @@ SKIPJIBS:
} }
case CON_ESPAWNVAR: case CON_ESPAWNVAR:
{ case CON_EQSPAWNVAR:
long lIn, lReturn=-1;
insptr++;
lIn=*insptr++;
lIn=GetGameVarID(lIn, g_i, g_p);
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i, lIn);
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
break;
}
case CON_QSPAWNVAR: case CON_QSPAWNVAR:
{ {
long lIn, lReturn=-1; long lIn, lReturn=-1;
@ -4310,45 +4277,38 @@ SKIPJIBS:
lIn=GetGameVarID(lIn, g_i, g_p); lIn=GetGameVarID(lIn, g_i, g_p);
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i, lIn); lReturn = spawn(g_i, lIn);
switch(tw) {
insertspriteq(lReturn); case CON_EQSPAWNVAR:
insertspriteq(lReturn);
case CON_ESPAWNVAR:
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
break;
case CON_QSPAWNVAR:
insertspriteq(lReturn);
break;
}
break; break;
} }
case CON_ESPAWN: case CON_ESPAWN:
{
long lReturn=-1;
insptr++;
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i,*insptr);
insptr++;
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
break;
}
case CON_EQSPAWN: case CON_EQSPAWN:
{
long lReturn=-1;
insptr++;
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i,*insptr);
insptr++;
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
insertspriteq(lReturn);
break;
}
case CON_QSPAWN: case CON_QSPAWN:
{ {
long lReturn=-1; long lReturn=-1;
insptr++; insptr++;
if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i,*insptr); lReturn = spawn(g_i,*insptr++);
insptr++; switch(tw) {
insertspriteq(lReturn); case CON_EQSPAWN:
insertspriteq(lReturn);
case CON_ESPAWN:
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
break;
case CON_QSPAWN:
insertspriteq(lReturn);
break;
}
break; break;
} }
@ -5027,7 +4987,7 @@ SKIPJIBS:
case CON_GUTS: case CON_GUTS:
insptr += 2; insptr += 2;
guts(g_sp,*(insptr-1),*insptr,g_p); guts(g_sp,*(insptr-1),*insptr,g_p);
insptr++; insptr++;
break; break;
case CON_IFSPAWNEDBY: case CON_IFSPAWNEDBY:
insptr++; insptr++;
@ -5303,13 +5263,8 @@ good:
// that is of <type> into <getvar> // that is of <type> into <getvar>
// -1 for none found // -1 for none found
// <type> <maxdistvarid> <varid> // <type> <maxdistvarid> <varid>
long lType; long lType, lMaxDistVar, lMaxDist;
long lMaxDistVar; long lVarID, lTemp, lFound, lDist;
long lMaxDist;
long lVarID;
long lTemp;
long lFound;
long lDist;
short j, k; short j, k;
insptr++; insptr++;
@ -5380,16 +5335,8 @@ good:
// that is of <type> into <getvar> // that is of <type> into <getvar>
// -1 for none found // -1 for none found
// <type> <maxdistvarid> <varid> // <type> <maxdistvarid> <varid>
long lType; long lType, lMaxDistVar, lMaxZDistVar, lMaxDist, lMaxZDist;
long lMaxDistVar; long lVarID, lTemp, lTemp2, lFound, lDist;
long lMaxZDistVar;
long lMaxDist;
long lMaxZDist;
long lVarID;
long lTemp;
long lTemp2;
long lFound;
long lDist;
short j, k; short j, k;
insptr++; insptr++;
@ -5440,14 +5387,8 @@ good:
// that is of <type> into <getvar> // that is of <type> into <getvar>
// -1 for none found // -1 for none found
// <type> <maxdist> <varid> // <type> <maxdist> <varid>
long lType; long lType, lMaxDist, lMaxZDist, lVarID;
long lMaxDist; long lTemp, lTemp2, lFound, lDist;
long lMaxZDist;
long lVarID;
long lTemp;
long lTemp2;
long lFound;
long lDist;
short j, k; short j, k;
insptr++; insptr++;
@ -5907,12 +5848,10 @@ good:
{ {
int i; int i;
long l1; // l2; long l1; // l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
lResult=max_ammo_amount[l1]; SetGameVarID(*insptr++, max_ammo_amount[l1], g_i, g_p );
SetGameVarID(*insptr++, lResult , g_i, g_p );
break; break;
} }
@ -5920,7 +5859,6 @@ good:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
@ -5933,20 +5871,17 @@ good:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
l2=GetGameVarID(*insptr++, g_i, g_p); l2=GetGameVarID(*insptr++, g_i, g_p);
lResult=l1*l2; SetGameVarID(i, l1*l2, g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
break; break;
} }
case CON_DIVVARVAR: case CON_DIVVARVAR:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
@ -5955,68 +5890,55 @@ good:
{ {
gameexit("CON_DIVVARVAR: Divide by zero."); gameexit("CON_DIVVARVAR: Divide by zero.");
} }
lResult=l1/l2; SetGameVarID(i, l1/l2 , g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
break; break;
} }
case CON_MODVARVAR: case CON_MODVARVAR:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
l2=GetGameVarID(*insptr, g_i, g_p); l2=GetGameVarID(*insptr++, g_i, g_p);
if(l2==0) if(l2==0)
{ {
gameexit("CON_MODVARVAR: Mod by zero."); gameexit("CON_MODVARVAR: Mod by zero.");
} }
lResult=l1 % l2; SetGameVarID(i, l1 % l2, g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
insptr++;
break; break;
} }
case CON_ANDVARVAR: case CON_ANDVARVAR:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
l2=GetGameVarID(*insptr, g_i, g_p); l2=GetGameVarID(*insptr++, g_i, g_p);
lResult=l1 & l2; SetGameVarID(i, l1 & l2 , g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
insptr++;
break; break;
} }
case CON_XORVARVAR: case CON_XORVARVAR:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
l2=GetGameVarID(*insptr, g_i, g_p); l2=GetGameVarID(*insptr++, g_i, g_p);
lResult=l1 ^ l2; SetGameVarID(i, l1 ^ l2 , g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
insptr++;
break; break;
} }
case CON_ORVARVAR: case CON_ORVARVAR:
{ {
int i; int i;
long l1,l2; long l1,l2;
long lResult;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
l1=GetGameVarID(i, g_i, g_p); l1=GetGameVarID(i, g_i, g_p);
l2=GetGameVarID(*insptr, g_i, g_p); l2=GetGameVarID(*insptr++, g_i, g_p);
lResult=l1 | l2; SetGameVarID(i, l1 | l2 , g_i, g_p );
SetGameVarID(i, lResult , g_i, g_p );
insptr++;
break; break;
} }
case CON_SUBVAR: case CON_SUBVAR:
@ -6024,8 +5946,7 @@ good:
int i; int i;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr, g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr++, g_i, g_p );
insptr++;
break; break;
} }
case CON_SUBVARVAR: case CON_SUBVARVAR:
@ -6033,8 +5954,7 @@ good:
int i; int i;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr, g_i, g_p), g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p );
insptr++;
break; break;
} }
case CON_ADDVAR: case CON_ADDVAR:
@ -6044,8 +5964,7 @@ good:
i=*insptr++; // ID of def i=*insptr++; // ID of def
//Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p);
//AddLog(g_szBuf); //AddLog(g_szBuf);
SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr, g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr++, g_i, g_p );
insptr++;
break; break;
} }
case CON_SHIFTVARL: case CON_SHIFTVARL:
@ -6055,8 +5974,7 @@ good:
i=*insptr++; // ID of def i=*insptr++; // ID of def
//Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p);
//AddLog(g_szBuf); //AddLog(g_szBuf);
SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr, g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr++, g_i, g_p );
insptr++;
break; break;
} }
@ -6067,8 +5985,7 @@ good:
i=*insptr++; // ID of def i=*insptr++; // ID of def
//Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p); //Bsprintf(g_szBuf,"AddVar %d to Var ID=%d, g_i=%d, g_p=%d\n",*insptr, i, g_i, g_p);
//AddLog(g_szBuf); //AddLog(g_szBuf);
SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr, g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr++, g_i, g_p );
insptr++;
break; break;
} }
@ -6079,10 +5996,9 @@ good:
long lValue; long lValue;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
lValue=GetGameVarID(*insptr, g_i, g_p); lValue=GetGameVarID(*insptr++, g_i, g_p);
lValue=sintable[lValue&2047]; lValue=sintable[lValue&2047];
SetGameVarID(i, lValue , g_i, g_p ); SetGameVarID(i, lValue , g_i, g_p );
insptr++;
break; break;
} }
case CON_COS: case CON_COS:
@ -6091,12 +6007,11 @@ good:
long lValue; long lValue;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
lValue=GetGameVarID(*insptr, g_i, g_p); lValue=GetGameVarID(*insptr++, g_i, g_p);
// propiedad trigonometrica con el seno para hallar coseno: cos = sqrt(1-sen^2) // propiedad trigonometrica con el seno para hallar coseno: cos = sqrt(1-sen^2)
// I don't know anything about sin/cos, and I don't know anything about foreign languages, either. :( // I don't know anything about sin/cos, and I don't know anything about foreign languages, either. :(
lValue=sintable[(lValue+512)&2047]; lValue=sintable[(lValue+512)&2047];
SetGameVarID(i, lValue , g_i, g_p ); SetGameVarID(i, lValue , g_i, g_p );
insptr++;
break; break;
} }
case CON_ADDVARVAR: case CON_ADDVARVAR:
@ -6104,8 +6019,7 @@ good:
int i; int i;
insptr++; insptr++;
i=*insptr++; // ID of def i=*insptr++; // ID of def
SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr, g_i, g_p), g_i, g_p ); SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p );
insptr++;
break; break;
} }
case CON_SPGETLOTAG: case CON_SPGETLOTAG:
@ -6403,8 +6317,7 @@ good:
break; break;
case CON_QUOTE: case CON_QUOTE:
insptr++; insptr++;
FTA(*insptr,&ps[g_p]); FTA(*insptr++,&ps[g_p]);
insptr++;
break; break;
case CON_USERQUOTE: case CON_USERQUOTE:
insptr++; insptr++;