Minor fix to Highly Theoretical that won't be used (yet?) anyway.
parent
540ca59b50
commit
d94bd9a183
|
@ -370,8 +370,10 @@ struct YAM_STATE {
|
||||||
uint32 odometer;
|
uint32 odometer;
|
||||||
uint8 dry_out_enabled;
|
uint8 dry_out_enabled;
|
||||||
uint8 dsp_emulation_enabled;
|
uint8 dsp_emulation_enabled;
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
uint8 dsp_dyna_enabled;
|
uint8 dsp_dyna_enabled;
|
||||||
uint8 dsp_dyna_valid;
|
uint8 dsp_dyna_valid;
|
||||||
|
#endif
|
||||||
uint32 randseed;
|
uint32 randseed;
|
||||||
uint32 mem_word_address_xor;
|
uint32 mem_word_address_xor;
|
||||||
uint32 mem_byte_address_xor;
|
uint32 mem_byte_address_xor;
|
||||||
|
@ -443,7 +445,9 @@ struct YAM_STATE {
|
||||||
//
|
//
|
||||||
// Buffer for dynarec code
|
// Buffer for dynarec code
|
||||||
//
|
//
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
uint8 dynacode[DYNACODE_MAX_SIZE];
|
uint8 dynacode[DYNACODE_MAX_SIZE];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -495,7 +499,9 @@ void EMU_CALL yam_clear_state(void *state, uint8 version) {
|
||||||
YAMSTATE->dsp_emulation_enabled = 1;
|
YAMSTATE->dsp_emulation_enabled = 1;
|
||||||
|
|
||||||
// Enable DSP dynarec
|
// Enable DSP dynarec
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
YAMSTATE->dsp_dyna_enabled = 1;
|
YAMSTATE->dsp_dyna_enabled = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -562,7 +568,9 @@ void EMU_CALL yam_setram(void *state, uint32 *ram, uint32 size, uint8 mbx, uint8
|
||||||
//
|
//
|
||||||
// Invalidate dynarec code
|
// Invalidate dynarec code
|
||||||
//
|
//
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
YAMSTATE->dsp_dyna_valid = 0;
|
YAMSTATE->dsp_dyna_valid = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -584,12 +592,16 @@ void EMU_CALL yam_enable_dry(void *state, uint8 enable) {
|
||||||
|
|
||||||
void EMU_CALL yam_enable_dsp(void *state, uint8 enable) {
|
void EMU_CALL yam_enable_dsp(void *state, uint8 enable) {
|
||||||
YAMSTATE->dsp_emulation_enabled = (enable != 0);
|
YAMSTATE->dsp_emulation_enabled = (enable != 0);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
if(enable == 0) { YAMSTATE->dsp_dyna_valid = 0; }
|
if(enable == 0) { YAMSTATE->dsp_dyna_valid = 0; }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EMU_CALL yam_enable_dsp_dynarec(void *state, uint8 enable) {
|
void EMU_CALL yam_enable_dsp_dynarec(void *state, uint8 enable) {
|
||||||
YAMSTATE->dsp_dyna_enabled = (enable != 0);
|
YAMSTATE->dsp_dyna_enabled = (enable != 0);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
if(enable == 0) { YAMSTATE->dsp_dyna_valid = 0; }
|
if(enable == 0) { YAMSTATE->dsp_dyna_valid = 0; }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1241,7 +1253,9 @@ static void coef_write(struct YAM_STATE *state, uint32 n, uint32 d, uint32 mask)
|
||||||
state->coef[n] &= ~mask;
|
state->coef[n] &= ~mask;
|
||||||
state->coef[n] |= d & mask;
|
state->coef[n] |= d & mask;
|
||||||
state->coef[n] = ((sint16)(state->coef[n])) >> 3;
|
state->coef[n] = ((sint16)(state->coef[n])) >> 3;
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
if(old != state->coef[n]) { state->dsp_dyna_valid = 0; }
|
if(old != state->coef[n]) { state->dsp_dyna_valid = 0; }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void madrs_write(struct YAM_STATE *state, uint32 n, uint32 d, uint32 mask) {
|
static void madrs_write(struct YAM_STATE *state, uint32 n, uint32 d, uint32 mask) {
|
||||||
|
@ -1250,7 +1264,9 @@ static void madrs_write(struct YAM_STATE *state, uint32 n, uint32 d, uint32 mask
|
||||||
n &= 0x3F;
|
n &= 0x3F;
|
||||||
state->madrs[n] &= ~mask;
|
state->madrs[n] &= ~mask;
|
||||||
state->madrs[n] |= d & mask;
|
state->madrs[n] |= d & mask;
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
if(old != state->madrs[n]) { state->dsp_dyna_valid = 0; }
|
if(old != state->madrs[n]) { state->dsp_dyna_valid = 0; }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 temp_read(struct YAM_STATE *state, uint32 n) {
|
static uint32 temp_read(struct YAM_STATE *state, uint32 n) {
|
||||||
|
@ -1363,7 +1379,9 @@ static void dsp_scsp_store_reg(
|
||||||
if(newvalue != oldvalue) {
|
if(newvalue != oldvalue) {
|
||||||
yam_flush(state);
|
yam_flush(state);
|
||||||
mpro_scsp_write(state->mpro + index64, newvalue);
|
mpro_scsp_write(state->mpro + index64, newvalue);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
state->dsp_dyna_valid = 0;
|
state->dsp_dyna_valid = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1414,7 +1432,9 @@ static void dsp_aica_store_reg(
|
||||||
if(newvalue != oldvalue) {
|
if(newvalue != oldvalue) {
|
||||||
yam_flush(state);
|
yam_flush(state);
|
||||||
mpro_aica_write(state->mpro + index64, newvalue);
|
mpro_aica_write(state->mpro + index64, newvalue);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
state->dsp_dyna_valid = 0;
|
state->dsp_dyna_valid = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1616,7 +1636,9 @@ void EMU_CALL yam_scsp_store_reg(void *state, uint32 a, uint32 d, uint32 mask, u
|
||||||
YAMSTATE->rbp = oldrbp;
|
YAMSTATE->rbp = oldrbp;
|
||||||
YAMSTATE->rbl = oldrbl;
|
YAMSTATE->rbl = oldrbl;
|
||||||
yam_flush(YAMSTATE);
|
yam_flush(YAMSTATE);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
YAMSTATE->dsp_dyna_valid = 0;
|
YAMSTATE->dsp_dyna_valid = 0;
|
||||||
|
#endif
|
||||||
YAMSTATE->rbp = newrbp;
|
YAMSTATE->rbp = newrbp;
|
||||||
YAMSTATE->rbl = newrbl;
|
YAMSTATE->rbl = newrbl;
|
||||||
}
|
}
|
||||||
|
@ -1799,7 +1821,9 @@ void EMU_CALL yam_aica_store_reg(void *state, uint32 a, uint32 d, uint32 mask, u
|
||||||
YAMSTATE->rbp = oldrbp;
|
YAMSTATE->rbp = oldrbp;
|
||||||
YAMSTATE->rbl = oldrbl;
|
YAMSTATE->rbl = oldrbl;
|
||||||
yam_flush(YAMSTATE);
|
yam_flush(YAMSTATE);
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
YAMSTATE->dsp_dyna_valid = 0;
|
YAMSTATE->dsp_dyna_valid = 0;
|
||||||
|
#endif
|
||||||
YAMSTATE->rbp = newrbp;
|
YAMSTATE->rbp = newrbp;
|
||||||
YAMSTATE->rbl = newrbl;
|
YAMSTATE->rbl = newrbl;
|
||||||
}
|
}
|
||||||
|
@ -2005,8 +2029,7 @@ static void readnextsample(
|
||||||
if(out < (-0x8000)) { out = (-0x8000); /* logf("<adpcmunderflow>"); */ }
|
if(out < (-0x8000)) { out = (-0x8000); /* logf("<adpcmunderflow>"); */ }
|
||||||
chan->adpcmstep = (chan->adpcmstep * adpcmscale[s & 7]) >> 8;
|
chan->adpcmstep = (chan->adpcmstep * adpcmscale[s & 7]) >> 8;
|
||||||
if(chan->adpcmstep > 0x6000) { chan->adpcmstep = 0x6000; }
|
if(chan->adpcmstep > 0x6000) { chan->adpcmstep = 0x6000; }
|
||||||
if(chan->adpcmstep < 0x007F) { chan->adpcmstep = 0x007F; }
|
if(chan->adpcmstep < 0x7F) { chan->adpcmstep = 0x7F; }
|
||||||
chan->adpcmprev = out;
|
|
||||||
s = out;
|
s = out;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2500,6 +2523,7 @@ static void __fastcall dsp_sample_interpret(struct YAM_STATE *state) {
|
||||||
#define STRUCTOFS(thetype,thefield) ((uint32)(&(((struct thetype*)0)->thefield)))
|
#define STRUCTOFS(thetype,thefield) ((uint32)(&(((struct thetype*)0)->thefield)))
|
||||||
#define STATEOFS(thefield) STRUCTOFS(YAM_STATE,thefield)
|
#define STATEOFS(thefield) STRUCTOFS(YAM_STATE,thefield)
|
||||||
|
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
static int instruction_uses_shifted(struct MPRO *mpro) {
|
static int instruction_uses_shifted(struct MPRO *mpro) {
|
||||||
// uses SHIFTED if:
|
// uses SHIFTED if:
|
||||||
// - ADRL and INTERP
|
// - ADRL and INTERP
|
||||||
|
@ -2517,12 +2541,14 @@ static int instruction_uses_shifted(struct MPRO *mpro) {
|
||||||
// otherwise not
|
// otherwise not
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compile x86 code out of the current DSP program/coef/address set
|
// Compile x86 code out of the current DSP program/coef/address set
|
||||||
// Also uses the current ringbuffer pointer and size, and ram pointer/mask/memwordxor
|
// Also uses the current ringbuffer pointer and size, and ram pointer/mask/memwordxor
|
||||||
// So if any of those change, the compiled dynacode must be invalidated
|
// So if any of those change, the compiled dynacode must be invalidated
|
||||||
//
|
//
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
static void dynacompile(struct YAM_STATE *state) {
|
static void dynacompile(struct YAM_STATE *state) {
|
||||||
// Pre-compute ringbuffer size mask
|
// Pre-compute ringbuffer size mask
|
||||||
uint32 rbmask = (1 << ((state->rbl)+13)) - 1;
|
uint32 rbmask = (1 << ((state->rbl)+13)) - 1;
|
||||||
|
@ -2663,7 +2689,7 @@ static void dynacompile(struct YAM_STATE *state) {
|
||||||
C(0x8D) C(0x14) C(0x36) // lea edx,[esi+esi]
|
C(0x8D) C(0x14) C(0x36) // lea edx,[esi+esi]
|
||||||
// 16 bytes max
|
// 16 bytes max
|
||||||
}
|
}
|
||||||
C(0x72) C(0x09) // jb +9bytes
|
C(0x74) C(0x09) // je +9bytes
|
||||||
C(0xC1) C(0xFA) C(0x1F) // sar edx,1Fh
|
C(0xC1) C(0xFA) C(0x1F) // sar edx,1Fh
|
||||||
C(0x81) C(0xF2) C32(0x007FFFFF) // xor edx,7FFFFFh
|
C(0x81) C(0xF2) C32(0x007FFFFF) // xor edx,7FFFFFh
|
||||||
// 27 bytes max
|
// 27 bytes max
|
||||||
|
@ -2812,6 +2838,7 @@ static void dynacompile(struct YAM_STATE *state) {
|
||||||
//{FILE*f=fopen("C:\\Corlett\\yamdyna.bin","wb");if(f){fwrite(state->dynacode,1,0x6000,f);fclose(f);}}
|
//{FILE*f=fopen("C:\\Corlett\\yamdyna.bin","wb");if(f){fwrite(state->dynacode,1,0x6000,f);fclose(f);}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -2834,11 +2861,15 @@ static void render_effects(
|
||||||
sint32 eflin_l[16];
|
sint32 eflin_l[16];
|
||||||
sint32 eflin_r[16];
|
sint32 eflin_r[16];
|
||||||
|
|
||||||
|
#ifdef ENABLE_DYNAREC
|
||||||
if(state->dsp_dyna_enabled) {
|
if(state->dsp_dyna_enabled) {
|
||||||
if(!(state->dsp_dyna_valid)) {
|
if(!(state->dsp_dyna_valid)) {
|
||||||
dynacompile(state);
|
dynacompile(state);
|
||||||
}
|
}
|
||||||
samplefunc = (dsp_sample_t)(((uint8*)(state->dynacode)) + DYNACODE_SLOP_SIZE);
|
samplefunc = (dsp_sample_t)(((uint8*)(state->dynacode)) + DYNACODE_SLOP_SIZE);
|
||||||
|
#else
|
||||||
|
if (0) {
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
samplefunc = dsp_sample_interpret;
|
samplefunc = dsp_sample_interpret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue