mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 16:41:09 +00:00
Add VM opcodes NOP, LANG, and SANG
- To simplify code generation genericizing, add three new opcodes * NOP: No-Operation * LANG: Load Angle - load a BAM angle into a float reg as degrees * SANG: Save Angle - store a float reg into a BEM angle, converting from degrees
This commit is contained in:
parent
a69089ffd7
commit
3ea0d1b444
3 changed files with 32 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
#include "vm.h"
|
||||
#include "c_console.h"
|
||||
|
||||
#define NOP MODE_AUNUSED | MODE_BUNUSED | MODE_CUNUSED
|
||||
|
||||
#define LI MODE_AI | MODE_BCJOINT | MODE_BCIMMS
|
||||
#define LKI MODE_AI | MODE_BCJOINT | MODE_BCKI
|
||||
#define LKF MODE_AF | MODE_BCJOINT | MODE_BCKF
|
||||
|
|
|
@ -220,6 +220,16 @@ begin:
|
|||
GETADDR(PB,RC,X_READ_NIL);
|
||||
reg.f[a] = *(VM_SWORD *)ptr / 65536.0;
|
||||
NEXTOP;
|
||||
OP(LANG):
|
||||
ASSERTF(a); ASSERTA(B); ASSERTKD(C);
|
||||
GETADDR(PB,KC,X_READ_NIL);
|
||||
reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000); // BAM -> deg
|
||||
NEXTOP;
|
||||
OP(LANG_R):
|
||||
ASSERTF(a); ASSERTA(B); ASSERTD(C);
|
||||
GETADDR(PB,RC,X_READ_NIL);
|
||||
reg.f[a] = (*(VM_UWORD *)ptr >> 1) * (180.0 / 0x40000000);
|
||||
NEXTOP;
|
||||
OP(LBIT):
|
||||
ASSERTD(a); ASSERTA(B);
|
||||
GETADDR(PB,0,X_READ_NIL);
|
||||
|
@ -326,6 +336,17 @@ begin:
|
|||
GETADDR(PA,RC,X_WRITE_NIL);
|
||||
*(VM_SWORD *)ptr = (VM_SWORD)(reg.f[B] * 65536.0);
|
||||
NEXTOP;
|
||||
OP(SANG):
|
||||
ASSERTA(a); ASSERTF(B); ASSERTKD(C);
|
||||
GETADDR(PA,KC,X_WRITE_NIL);
|
||||
*(VM_UWORD *)ptr = (VM_UWORD)(reg.f[B] * ((1<<30) / 180.0)) << 1; // deg -> BAM
|
||||
NEXTOP;
|
||||
OP(SANG_R):
|
||||
ASSERTA(a); ASSERTF(B); ASSERTD(C);
|
||||
GETADDR(PA,RC,X_WRITE_NIL);
|
||||
*(VM_UWORD *)ptr = (VM_UWORD)(reg.f[B] * ((1<<30) / 180.0)) << 1;
|
||||
NEXTOP;
|
||||
|
||||
OP(SBIT):
|
||||
ASSERTA(a); ASSERTD(B);
|
||||
GETADDR(PA,0,X_WRITE_NIL);
|
||||
|
@ -1301,6 +1322,9 @@ begin:
|
|||
ASSERTA(B); ASSERTKA(C);
|
||||
CMPJMP(reg.a[B] == konsta[C].v);
|
||||
NEXTOP;
|
||||
|
||||
OP(NOP):
|
||||
NEXTOP;
|
||||
}
|
||||
}
|
||||
catch(VMException *exception)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define xx(op, name, mode) OP_##op
|
||||
#endif
|
||||
|
||||
xx(NOP, nop, NOP), // no operation
|
||||
|
||||
// Load constants.
|
||||
xx(LI, li, LI), // load immediate signed 16-bit constant
|
||||
xx(LK, lk, LKI), // load integer constant
|
||||
|
@ -35,6 +37,8 @@ xx(LV, lv, RVRPKI), // load vector
|
|||
xx(LV_R, lv, RVRPRI),
|
||||
xx(LX, lx, RFRPKI), // load fixed point
|
||||
xx(LX_R, lx, RFRPRI),
|
||||
xx(LANG, lang, RFRPKI), // load angle
|
||||
xx(LANG_R, lang, RFRPRI),
|
||||
|
||||
xx(LBIT, lbit, RIRPI8), // rA = !!(*rB & C) -- *rB is a byte
|
||||
|
||||
|
@ -57,6 +61,8 @@ xx(SV, sv, RPRVKI), // store vector
|
|||
xx(SV_R, sv, RPRVRI),
|
||||
xx(SX, sx, RPRFKI), // store fixed point
|
||||
xx(SX_R, sx, RPRFRI),
|
||||
xx(SANG, sang, RPRFKI), // store angle
|
||||
xx(SANG_R, sang, RPRFRI),
|
||||
|
||||
xx(SBIT, sbit, RPRII8), // *rA |= C if rB is true, *rA &= ~C otherwise
|
||||
|
||||
|
|
Loading…
Reference in a new issue