mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-23 00:30:17 +00:00
Phasor: support discrete LATCH & READ PSG functions (#1192)
. Recode 'MB_SUBUNIT::state' as a 2-element array
This commit is contained in:
parent
3b53c882ab
commit
d8e30e56be
@ -250,7 +250,7 @@ void MockingboardCard::AY8910_Write(BYTE subunit, BYTE ay, BYTE value)
|
||||
int nBC1 = value & 1;
|
||||
|
||||
MockingboardUnitState_e nAYFunc = (MockingboardUnitState_e) ((nBDIR<<2) | (nBC2<<1) | nBC1);
|
||||
MockingboardUnitState_e& state = (ay == AY8913_DEVICE_A) ? pMB->state : pMB->stateB; // GH#659
|
||||
MockingboardUnitState_e& state = pMB->state[ay]; // GH#659
|
||||
|
||||
#if _DEBUG
|
||||
if (!m_phasorEnable || m_phasorMode == PH_Mockingboard)
|
||||
@ -267,7 +267,10 @@ void MockingboardCard::AY8910_Write(BYTE subunit, BYTE ay, BYTE value)
|
||||
break;
|
||||
|
||||
case AY_READ: // 5: READ FROM PSG (need to set DDRA to input)
|
||||
r6522.SetRegORA( AYReadReg(subunit, ay, pMB->nAYCurrentRegister[ay]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff) );
|
||||
if (pMB->isChipSelected[ay] && pMB->isAYLatchedAddressValid[ay])
|
||||
r6522.SetRegORA(AYReadReg(subunit, ay, pMB->nAYCurrentRegister[ay]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff));
|
||||
else
|
||||
r6522.SetRegORA(r6522.GetReg(SY6522::rDDRA) ^ 0xff);
|
||||
break;
|
||||
|
||||
case AY_WRITE: // 6: WRITE TO PSG
|
||||
@ -1126,7 +1129,7 @@ void MockingboardCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||
AY8910_SaveSnapshot(yamlSaveHelper, subunit, AY8913_DEVICE_A, std::string(""));
|
||||
pMB->ssi263.SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state);
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state[0]);
|
||||
yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister[0]); // save all 8 bits (even though top 4 bits should be 0)
|
||||
}
|
||||
}
|
||||
@ -1183,10 +1186,10 @@ bool MockingboardCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version
|
||||
yamlLoadHelper.LoadBool(SS_YAML_KEY_SPEECH_IRQ); // Consume redundant data
|
||||
}
|
||||
|
||||
pMB->state = AY_INACTIVE;
|
||||
pMB->stateB = AY_INACTIVE;
|
||||
pMB->state[0] = AY_INACTIVE;
|
||||
pMB->state[1] = AY_INACTIVE;
|
||||
if (version >= 3)
|
||||
pMB->state = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE) & 7);
|
||||
pMB->state[0] = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE) & 7);
|
||||
|
||||
yamlLoadHelper.PopMap();
|
||||
}
|
||||
@ -1218,8 +1221,8 @@ void MockingboardCard::Phasor_SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||
AY8910_SaveSnapshot(yamlSaveHelper, subunit, AY8913_DEVICE_B, std::string("-B"));
|
||||
pMB->ssi263.SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state);
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE_B, pMB->stateB);
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state[0]);
|
||||
yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE_B, pMB->state[1]);
|
||||
yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister[0]); // save all 8 bits (even though top 4 bits should be 0)
|
||||
yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_AY_CURR_REG_B, pMB->nAYCurrentRegister[1]); // save all 8 bits (even though top 4 bits should be 0)
|
||||
|
||||
@ -1306,12 +1309,12 @@ bool MockingboardCard::Phasor_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT
|
||||
yamlLoadHelper.LoadBool(SS_YAML_KEY_SPEECH_IRQ); // Consume redundant data
|
||||
}
|
||||
|
||||
pMB->state = AY_INACTIVE;
|
||||
pMB->stateB = AY_INACTIVE;
|
||||
pMB->state[0] = AY_INACTIVE;
|
||||
pMB->state[1] = AY_INACTIVE;
|
||||
if (version >= 3)
|
||||
pMB->state = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE) & 7);
|
||||
pMB->state[0] = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE) & 7);
|
||||
if (version >= 5)
|
||||
pMB->stateB = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE_B) & 7);
|
||||
pMB->state[1] = (MockingboardUnitState_e) (yamlLoadHelper.LoadUint(SS_YAML_KEY_MB_UNIT_STATE_B) & 7);
|
||||
|
||||
if (version >= 10)
|
||||
{
|
||||
|
@ -64,8 +64,7 @@ private:
|
||||
SSI263 ssi263;
|
||||
BYTE nAY8910Number;
|
||||
BYTE nAYCurrentRegister[2];
|
||||
MockingboardUnitState_e state; // Where a unit is a 6522+AY8910 pair
|
||||
MockingboardUnitState_e stateB; // Phasor: 6522 & 2nd AY8910
|
||||
MockingboardUnitState_e state[2]; // AY's PSG function
|
||||
bool isAYLatchedAddressValid[2];
|
||||
bool isChipSelected[2];
|
||||
|
||||
@ -78,8 +77,7 @@ private:
|
||||
void Reset(void)
|
||||
{
|
||||
nAYCurrentRegister[0] = nAYCurrentRegister[1] = 0; // not valid
|
||||
state = AY_INACTIVE;
|
||||
stateB = AY_INACTIVE;
|
||||
state[0] = state[1] = AY_INACTIVE;
|
||||
isAYLatchedAddressValid[0] = isAYLatchedAddressValid[1] = false; // after AY reset
|
||||
isChipSelected[0] = isChipSelected[1] = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user