This commit is contained in:
libretroadmin 2023-02-27 17:56:04 +01:00
parent 02a85863f3
commit 64652b4724
6 changed files with 120 additions and 114 deletions

View File

@ -253,7 +253,7 @@ int WSwan_EEPROMStateAction(StateMem *sm, int load, int data_only)
};
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "EEPR", false))
return(0);
return 0;
return(1);
return 1;
}

View File

@ -14,17 +14,16 @@ static uint32 IVector_Cache;
static void RecalcInterrupt(void)
{
unsigned i;
IOn_Cache = false;
IOn_Which = 0;
IOn_Cache = false;
IOn_Which = 0;
IVector_Cache = 0;
for(i = 0; i < 8; i++)
{
if(IStatus & IEnable & (1 << i))
{
IOn_Cache = true;
IOn_Which = i;
IOn_Cache = true;
IOn_Which = i;
IVector_Cache = (IVectorBase + i) * 4;
break;
}
@ -44,10 +43,13 @@ void WSwan_InterruptWrite(uint32 A, uint8 V)
switch(A)
{
case 0xB0:
IVectorBase = V; RecalcInterrupt();
IVectorBase = V;
RecalcInterrupt();
break;
case 0xB2:
IEnable = V; IStatus &= IEnable; RecalcInterrupt();
IEnable = V;
IStatus &= IEnable;
RecalcInterrupt();
break;
case 0xB6:
IStatus &= ~V;
@ -96,10 +98,10 @@ int WSwan_InterruptStateAction(StateMem *sm, int load, int data_only)
};
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "INTR", false))
return(0);
return 0;
if(load)
RecalcInterrupt();
return(1);
return 1;
}

View File

@ -58,7 +58,7 @@ uint8 WSwan_RTCRead(uint32 A)
return Data | 0x80;
long_time = CurrentTime;
newtime = gmtime( &long_time );
newtime = gmtime( &long_time );
switch(wsCA15)
{
@ -94,9 +94,9 @@ void WSwan_RTCReset(void)
{
time_t happy_time = time(NULL);
CurrentTime = mktime(localtime(&happy_time));
CurrentTime = mktime(localtime(&happy_time));
ClockCycleCounter = 0;
wsCA15 = 0;
wsCA15 = 0;
}
void WSwan_RTCClock(uint32 cycles)
@ -122,7 +122,6 @@ int WSwan_RTCStateAction(StateMem *sm, int load, int data_only)
};
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "RTC", false))
return(0);
return(1);
return 0;
return 1;
}

View File

@ -60,25 +60,22 @@ static uint32 last_ts;
#define MK_SAMPLE_CACHE \
{ \
int sample; \
sample = (((wsRAM[((SampleRAMPos << 6) + (sample_pos[ch] >> 1) + (ch << 4)) ] >> ((sample_pos[ch] & 1) ? 4 : 0)) & 0x0F)); \
int sample = (((wsRAM[((SampleRAMPos << 6) + (sample_pos[ch] >> 1) + (ch << 4)) ] >> ((sample_pos[ch] & 1) ? 4 : 0)) & 0x0F)); \
sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
}
#define MK_SAMPLE_CACHE_NOISE \
{ \
int sample; \
sample = ((nreg & 1) ? 0xF : 0x0); \
int sample = ((nreg & 1) ? 0xF : 0x0); \
sample_cache[ch][0] = sample * ((volume[ch] >> 4) & 0x0F); \
sample_cache[ch][1] = sample * ((volume[ch] >> 0) & 0x0F); \
}
#define MK_SAMPLE_CACHE_VOICE \
{ \
int sample, half; \
sample = volume[ch]; \
half = sample >> 1; \
int sample = volume[ch]; \
int half = sample >> 1; \
sample_cache[ch][0] = (voice_volume & 4) ? sample : (voice_volume & 8) ? half : 0; \
sample_cache[ch][1] = (voice_volume & 1) ? sample : (voice_volume & 2) ? half : 0; \
}
@ -112,9 +109,9 @@ void WSwan_SoundUpdate(void)
}
else if(ch == 2 && (control & 0x40) && sweep_value) /* Sweep */
{
uint32 tmp_pt = 2048 - period[ch];
uint32 tmp_pt = 2048 - period[ch];
uint32 meow_timestamp = v30mz_timestamp - run_time;
uint32 tmp_run_time = run_time;
uint32 tmp_run_time = run_time;
while(tmp_run_time)
{
@ -235,9 +232,7 @@ void WSwan_SoundWrite(uint32 A, uint8 V)
period[ch] = (period[ch] & 0x0700) | ((V & 0xFF) << 0);
}
else if(A >= 0x88 && A <= 0x8B)
{
volume[A - 0x88] = V;
}
else if(A == 0x8C)
sweep_value = V;
else if(A == 0x8D)
@ -294,8 +289,7 @@ uint8 WSwan_SoundRead(uint32 A)
if(A & 1)
return(period[ch] >> 8);
else
return(period[ch]);
return(period[ch]);
}
else if(A >= 0x88 && A <= 0x8B)
return(volume[A - 0x88]);
@ -316,7 +310,7 @@ uint8 WSwan_SoundRead(uint32 A)
break;
}
return(0);
return 0;
}
int32 WSwan_SoundFlush(int16 **SoundBuf, int32 *SoundBufSize)
@ -404,49 +398,49 @@ bool WSwan_SetSoundRate(uint32 rate)
int WSwan_SoundStateAction(StateMem *sm, int load, int data_only)
{
SFORMAT StateRegs[] =
{
SFARRAY16(period, 4),
SFARRAY(volume, 4),
SFVAR(voice_volume),
SFVAR(sweep_step),
SFVAR(sweep_value),
SFVAR(noise_control),
SFVAR(control),
SFVAR(output_control),
SFVAR(HVoiceCtrl),
SFVAR(HVoiceChanCtrl),
SFORMAT StateRegs[] =
{
SFARRAY16(period, 4),
SFARRAY(volume, 4),
SFVAR(voice_volume),
SFVAR(sweep_step),
SFVAR(sweep_value),
SFVAR(noise_control),
SFVAR(control),
SFVAR(output_control),
SFVAR(HVoiceCtrl),
SFVAR(HVoiceChanCtrl),
SFVAR(sweep_8192_divider),
SFVAR(sweep_counter),
SFVAR(SampleRAMPos),
SFARRAY32(period_counter, 4),
SFARRAY(sample_pos, 4),
SFVAR(nreg),
SFEND
};
SFVAR(sweep_8192_divider),
SFVAR(sweep_counter),
SFVAR(SampleRAMPos),
SFARRAY32(period_counter, 4),
SFARRAY(sample_pos, 4),
SFVAR(nreg),
SFEND
};
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "PSG", false))
return(0);
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "PSG", false))
return 0;
if(load)
{
unsigned ch;
if(sweep_8192_divider < 1)
sweep_8192_divider = 1;
if(load)
{
unsigned ch;
if(sweep_8192_divider < 1)
sweep_8192_divider = 1;
for(ch = 0; ch < 4; ch++)
{
period[ch] &= 0x7FF;
for(ch = 0; ch < 4; ch++)
{
period[ch] &= 0x7FF;
if(period_counter[ch] < 1)
period_counter[ch] = 1;
if(period_counter[ch] < 1)
period_counter[ch] = 1;
sample_pos[ch] &= 0x1F;
}
}
sample_pos[ch] &= 0x1F;
}
}
return(1);
return 1;
}
void WSwan_SoundReset(void)

View File

@ -454,7 +454,8 @@ static struct {
{ \
if (ModRM >= 0xc0) \
I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
else { \
else \
{ \
(*GetEA[ModRM])(); \
WriteWord( EA ,val); \
} \
@ -631,12 +632,12 @@ static void nec_interrupt(unsigned int_num)
I.TF = I.IF = 0;
dest_off = ReadWord((int_num)*4);
dest_seg = ReadWord((int_num)*4+2);
dest_off = ReadWord((int_num)*4);
dest_seg = ReadWord((int_num)*4+2);
PUSH(I.sregs[PS]);
PUSH(I.pc);
I.pc = (uint16)dest_off;
I.pc = (uint16)dest_off;
I.sregs[PS] = (uint16)dest_seg;
}
@ -716,40 +717,57 @@ I.regs.w[IX] += -2 * I.DF + 1; CLK(6);
static INLINE void i_real_cmpsw(void)
{
uint32 src = GetMemW(DS1, I.regs.w[IY]); uint32 dst = GetMemW(DS0, I.regs.w[IX]); SUBW; I.regs.w[IY] += -4 * I.DF + 2;
I.regs.w[IX] += -4 * I.DF + 2; CLK(6);
uint32 src = GetMemW(DS1, I.regs.w[IY]);
uint32 dst = GetMemW(DS0, I.regs.w[IX]);
SUBW;
I.regs.w[IY] += -4 * I.DF + 2;
I.regs.w[IX] += -4 * I.DF + 2;
CLK(6);
}
static INLINE void i_real_stosb(void)
{
PutMemB(DS1,I.regs.w[IY],I.regs.b[AL]); I.regs.w[IY] += -2 * I.DF + 1; CLK(3);
PutMemB(DS1,I.regs.w[IY],I.regs.b[AL]);
I.regs.w[IY] += -2 * I.DF + 1;
CLK(3);
}
static INLINE void i_real_stosw(void)
{
PutMemW(DS1,I.regs.w[IY],I.regs.w[AW]); I.regs.w[IY] += -4 * I.DF + 2; CLK(3);
PutMemW(DS1,I.regs.w[IY],I.regs.w[AW]);
I.regs.w[IY] += -4 * I.DF + 2;
CLK(3);
}
static INLINE void i_real_lodsb(void)
{
I.regs.b[AL] = GetMemB(DS0,I.regs.w[IX]); I.regs.w[IX] += -2 * I.DF + 1; CLK(3);
I.regs.b[AL] = GetMemB(DS0,I.regs.w[IX]);
I.regs.w[IX] += -2 * I.DF + 1;
CLK(3);
}
static INLINE void i_real_lodsw(void)
{
I.regs.w[AW] = GetMemW(DS0,I.regs.w[IX]); I.regs.w[IX] += -4 * I.DF + 2; CLK(3);
I.regs.w[AW] = GetMemW(DS0,I.regs.w[IX]);
I.regs.w[IX] += -4 * I.DF + 2;
CLK(3);
}
static INLINE void i_real_scasb(void)
{
uint32 src = GetMemB(DS1, I.regs.w[IY]); uint32 dst = I.regs.b[AL]; SUBB;
I.regs.w[IY] += -2 * I.DF + 1; CLK(4);
uint32 src = GetMemB(DS1, I.regs.w[IY]);
uint32 dst = I.regs.b[AL]; SUBB;
I.regs.w[IY] += -2 * I.DF + 1;
CLK(4);
}
static INLINE void i_real_scasw(void)
{
uint32 src = GetMemW(DS1, I.regs.w[IY]); uint32 dst = I.regs.w[AW]; SUBW;
I.regs.w[IY] += -4 * I.DF + 2; CLK(4);
uint32 src = GetMemW(DS1, I.regs.w[IY]);
uint32 dst = I.regs.w[AW];
SUBW;
I.regs.w[IY] += -4 * I.DF + 2;
CLK(4);
}
static void DoOP(uint8 opcode)
@ -897,19 +915,14 @@ static void DoOP(uint8 opcode)
OP( 0x62, i_chkind )
{
uint32 low,high,tmp;
GetModRM;
low = GetRMWord(ModRM);
high = GetnextRMWord;
tmp = RegWord(ModRM);
uint32 low = GetRMWord(ModRM);
uint32 high = GetnextRMWord;
uint32 tmp = RegWord(ModRM);
CLK(13);
if (tmp<low || tmp>high)
{
nec_interrupt(5);
}
} OP_EPILOGUE;
OP( 0x68, i_push_d16 ) { uint32 tmp; FETCHuint16(tmp); PUSH(tmp); CLK(1); } OP_EPILOGUE;
@ -938,7 +951,7 @@ static void DoOP(uint8 opcode)
OP( 0x7e, i_jle ) { JMP((ZF)||(SF!=FLAG_O)); CLK(1); } OP_EPILOGUE;
OP( 0x7f, i_jnle ) { JMP((SF==FLAG_O)&&(!ZF)); CLK(1); } OP_EPILOGUE;
OP( 0x80, i_80pre ) { uint32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH;
OP( 0x80, i_80pre ) { GetModRM; uint32 dst = GetRMByte(ModRM); uint32 src = FETCH;
CLKM(3, 1);
switch (ModRM & 0x38) {
case 0x00: ADDB; PutbackRMByte(ModRM,dst); break;
@ -952,7 +965,7 @@ static void DoOP(uint8 opcode)
}
} OP_EPILOGUE;
OP( 0x81, i_81pre ) { uint32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH; src+= (FETCH << 8);
OP( 0x81, i_81pre ) { GetModRM; uint32 dst = GetRMWord(ModRM); uint32 src = FETCH; src+= (FETCH << 8);
CLKM(3, 1);
switch (ModRM & 0x38) {
case 0x00: ADDW; PutbackRMWord(ModRM,dst); break;
@ -966,11 +979,11 @@ static void DoOP(uint8 opcode)
}
} OP_EPILOGUE;
OP( 0x82, i_82pre ) { uint32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (uint8)((int8)FETCH);
OP( 0x82, i_82pre ) { GetModRM; uint32 dst = GetRMByte(ModRM); uint32 src = (uint8)((int8)FETCH);
CLKM(3,1);
switch (ModRM & 0x38) {
case 0x00: ADDB; PutbackRMByte(ModRM,dst); break;
case 0x08: ORB; PutbackRMByte(ModRM,dst); break;
case 0x08: ORB; PutbackRMByte(ModRM,dst); break;
case 0x10: src+=CF; ADDB; PutbackRMByte(ModRM,dst); break;
case 0x18: src+=CF; SUBB; PutbackRMByte(ModRM,dst); break;
case 0x20: ANDB; PutbackRMByte(ModRM,dst); break;
@ -980,11 +993,11 @@ static void DoOP(uint8 opcode)
}
} OP_EPILOGUE;
OP( 0x83, i_83pre ) { uint32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (uint16)((int16)((int8)FETCH));
OP( 0x83, i_83pre ) { GetModRM; uint32 dst = GetRMWord(ModRM); uint32 src = (uint16)((int16)((int8)FETCH));
CLKM(3,1);
switch (ModRM & 0x38) {
case 0x00: ADDW; PutbackRMWord(ModRM,dst); break;
case 0x08: ORW; PutbackRMWord(ModRM,dst); break;
case 0x08: ORW; PutbackRMWord(ModRM,dst); break;
case 0x10: src+=CF; ADDW; PutbackRMWord(ModRM,dst); break;
case 0x18: src+=CF; SUBW; PutbackRMWord(ModRM,dst); break;
case 0x20: ANDW; PutbackRMWord(ModRM,dst); break;
@ -999,13 +1012,13 @@ static void DoOP(uint8 opcode)
OP( 0x86, i_xchg_br8 ) { DEF_br8; RegByte(ModRM)=dst; PutbackRMByte(ModRM,src); CLKM(5,3); } OP_EPILOGUE;
OP( 0x87, i_xchg_wr16 ) { DEF_wr16; RegWord(ModRM)=dst; PutbackRMWord(ModRM,src); CLKM(5,3); } OP_EPILOGUE;
OP( 0x88, i_mov_br8 ) { uint8 src; GetModRM; src = RegByte(ModRM); PutRMByte(ModRM,src); CLK(1); } OP_EPILOGUE;
OP( 0x89, i_mov_wr16 ) { uint16 src; GetModRM; src = RegWord(ModRM); PutRMWord(ModRM,src); CLK(1); } OP_EPILOGUE;
OP( 0x8a, i_mov_r8b ) { uint8 src; GetModRM; src = GetRMByte(ModRM); RegByte(ModRM)=src; CLK(1); } OP_EPILOGUE;
OP( 0x8b, i_mov_r16w ) { uint16 src; GetModRM; src = GetRMWord(ModRM); RegWord(ModRM)=src; CLK(1); } OP_EPILOGUE;
OP( 0x88, i_mov_br8 ) { GetModRM; uint8 src = RegByte(ModRM); PutRMByte(ModRM,src); CLK(1); } OP_EPILOGUE;
OP( 0x89, i_mov_wr16 ) { GetModRM; uint16 src = RegWord(ModRM); PutRMWord(ModRM,src); CLK(1); } OP_EPILOGUE;
OP( 0x8a, i_mov_r8b ) { GetModRM; uint8 src = GetRMByte(ModRM); RegByte(ModRM)=src; CLK(1); } OP_EPILOGUE;
OP( 0x8b, i_mov_r16w ) { GetModRM; uint16 src = GetRMWord(ModRM); RegWord(ModRM)=src; CLK(1); } OP_EPILOGUE;
OP( 0x8c, i_mov_wsreg ) { GetModRM; PutRMWord(ModRM,I.sregs[(ModRM & 0x38) >> 3]); CLK(1); } OP_EPILOGUE;
OP( 0x8d, i_lea ) { uint16 ModRM = FETCH; if(ModRM >= 192) { } else { (void)(*GetEA[ModRM])(); } RegWord(ModRM)=EO; CLK(1); } OP_EPILOGUE;
OP( 0x8e, i_mov_sregw ) { uint16 src; GetModRM; src = GetRMWord(ModRM); CLKM(3,2);
OP( 0x8d, i_lea ) { uint16 ModRM = FETCH; if(ModRM < 192) { (void)(*GetEA[ModRM])(); } RegWord(ModRM)=EO; CLK(1); } OP_EPILOGUE;
OP( 0x8e, i_mov_sregw ) { GetModRM; uint16 src = GetRMWord(ModRM); CLKM(3,2);
switch (ModRM & 0x38) {
case 0x00: I.sregs[DS1] = src; break; /* mov ds1,ew */
case 0x08: I.sregs[PS] = src; break; /* mov cs,ew */
@ -1095,9 +1108,10 @@ static void DoOP(uint8 opcode)
} OP_EPILOGUE;
OP( 0xc1, i_rotshft_wd8 ) {
uint32 src, dst; uint8 c;
GetModRM; src = (unsigned)GetRMWord(ModRM); dst=src;
c=FETCH;
GetModRM;
uint32 src = (unsigned)GetRMWord(ModRM);
uint32 dst = src;
uint8 c = FETCH;
c&=0x1f;
CLKM(5,3);
if (c) switch (ModRM & 0x38) {
@ -1388,7 +1402,6 @@ static void DoOP(uint8 opcode)
/*****************************************************************************/
unsigned v30mz_get_reg(int regnum)
{
switch( regnum )
@ -1425,8 +1438,6 @@ unsigned v30mz_get_reg(int regnum)
return 0;
}
void nec_set_irq_line(int irqline, int state);
void v30mz_set_reg(int regnum, unsigned val)
{
switch( regnum )

View File

@ -332,15 +332,15 @@ void WSwan_MemoryInit(bool lang, bool IsWSC, uint32 ssize, bool SkipSaveLoad)
{
const uint16 byear = MDFN_GetSettingUI("wswan.byear");
const uint8 bmonth = MDFN_GetSettingUI("wswan.bmonth");
const uint8 bday = MDFN_GetSettingUI("wswan.bday");
const uint8 sex = MDFN_GetSettingI("wswan.sex");
const uint8 blood = MDFN_GetSettingI("wswan.blood");
const uint8 bday = MDFN_GetSettingUI("wswan.bday");
const uint8 sex = MDFN_GetSettingI("wswan.sex");
const uint8 blood = MDFN_GetSettingI("wswan.blood");
language = lang;
SkipSL = SkipSaveLoad;
language = lang;
SkipSL = SkipSaveLoad;
wsRAMSize = 65536;
sram_size = ssize;
wsRAMSize = 65536;
sram_size = ssize;
// WSwan_EEPROMInit() will also clear wsEEPROM
WSwan_EEPROMInit(MDFN_GetSettingS("wswan.name"), byear, bmonth, bday, sex, blood);