Refactor slots & allow empty slots for s1(printer), s6(disk2)

. NB. can't empty s3(uthernet) yet
This commit is contained in:
tomcw 2019-09-15 20:37:20 +01:00
parent 94556b5eaf
commit 506a52f359
10 changed files with 97 additions and 78 deletions

View File

@ -109,10 +109,15 @@ CSuperSerialCard sg_SSC;
CMouseInterface sg_Mouse;
Disk2InterfaceCard sg_Disk2Card;
SS_CARDTYPE g_Slot0 = CT_LanguageCard; // Just for Apple II or II+ or similar clones
SS_CARDTYPE g_Slot2 = CT_SSC;
SS_CARDTYPE g_Slot4 = CT_Empty;
SS_CARDTYPE g_Slot5 = CT_Empty;
SS_CARDTYPE g_Slot[8] = {
/*0*/ CT_LanguageCard, // Just for Apple II or II+ or similar clones
/*1*/ CT_GenericPrinter,
/*2*/ CT_SSC,
/*3*/ CT_Uthernet,
/*4*/ CT_Empty,
/*5*/ CT_Empty,
/*6*/ CT_Disk2,
/*7*/ CT_Empty };
SS_CARDTYPE g_SlotAux = CT_Extended80Col; // For Apple //e and above
HANDLE g_hCustomRomF8 = INVALID_HANDLE_VALUE; // Cmd-line specified custom ROM at $F800..$FFFF
@ -635,10 +640,6 @@ void LoadConfiguration(void)
REGLOAD_DEFAULT(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk, 1);
sg_Disk2Card.SetEnhanceDisk(dwEnhanceDisk ? true : false);
DWORD dwTfeEnabled;
REGLOAD_DEFAULT(TEXT("Uthernet Active"), &dwTfeEnabled, 0);
tfe_enabled = dwTfeEnabled ? 1 : 0;
//
DWORD dwTmp = 0;
@ -696,9 +697,9 @@ void LoadConfiguration(void)
sg_PropertySheet.SetMouseRestrictToWindow(dwTmp);
if(REGLOAD(TEXT(REGVALUE_SLOT4), &dwTmp))
g_Slot4 = (SS_CARDTYPE) dwTmp;
g_Slot[4] = (SS_CARDTYPE) dwTmp;
if(REGLOAD(TEXT(REGVALUE_SLOT5), &dwTmp))
g_Slot5 = (SS_CARDTYPE) dwTmp;
g_Slot[5] = (SS_CARDTYPE) dwTmp;
//
@ -725,6 +726,15 @@ void LoadConfiguration(void)
//
DWORD dwTfeEnabled;
REGLOAD_DEFAULT(TEXT(REGVALUE_UTHERNET_ACTIVE), &dwTfeEnabled, 0);
tfe_enabled = dwTfeEnabled ? 1 : 0;
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, szFilename, MAX_PATH, TEXT(""));
update_tfe_interface(szFilename, NULL);
//
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_SAVESTATE_FILENAME), 1, szFilename, MAX_PATH, TEXT(""));
Snapshot_SetFilename(szFilename); // If not in Registry than default will be used (ie. g_sCurrentDir + default filename)
@ -734,9 +744,6 @@ void LoadConfiguration(void)
REGLOAD_DEFAULT(TEXT(REGVALUE_PRINTER_IDLE_LIMIT), &dwTmp, 10);
Printer_SetIdleLimit(dwTmp);
RegLoadString(TEXT(REG_CONFIG), TEXT("Uthernet Interface"), 1, szFilename, MAX_PATH, TEXT(""));
update_tfe_interface(szFilename, NULL);
if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp))
SetViewportScale(dwTmp);
@ -1194,8 +1201,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
bool bBoot = false;
bool bChangedDisplayResolution = false;
bool bSlot0LanguageCard = false;
bool bSlot2Empty = false;
bool bSlot7Empty = false;
bool bSlotEmpty[NUM_SLOTS] = {false,false,false,false,false,false,false,false};
UINT bestWidth = 0, bestHeight = 0;
LPSTR szImageName_drive[NUM_DRIVES] = {NULL,NULL};
LPSTR szImageName_harddisk[NUM_HARDDISKS] = {NULL,NULL};
@ -1245,19 +1251,13 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
lpNextArg = GetNextArg(lpNextArg);
szImageName_harddisk[HARDDISK_2] = lpCmdLine;
}
else if (strcmp(lpCmdLine, "-s2") == 0)
else if (lpCmdLine[0] == '-' && lpCmdLine[1] == 's' && lpCmdLine[2] >= '1' && lpCmdLine[2] <= '7' && lpCmdLine[3] == 0)
{
const UINT slot = lpCmdLine[2] - '0';
lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg);
if (strcmp(lpCmdLine, "empty") == 0)
bSlot2Empty = true;
}
else if (strcmp(lpCmdLine, "-s7") == 0)
{
lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg);
if (strcmp(lpCmdLine, "empty") == 0)
bSlot7Empty = true;
bSlotEmpty[slot] = true;
}
else if (strcmp(lpCmdLine, "-load-state") == 0)
{
@ -1629,8 +1629,15 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
FrameCreateWindow(); // g_hFrameWindow is now valid
LogFileOutput("Main: FrameCreateWindow() - post\n");
if (bSlot2Empty)
g_Slot2 = CT_Empty;
// Allow the 4 hardcoded slots to be configurated as empty
if (bSlotEmpty[1])
g_Slot[1] = CT_Empty;
if (bSlotEmpty[2])
g_Slot[2] = CT_Empty;
if (bSlotEmpty[3])
g_Slot[3] = CT_Empty;
if (bSlotEmpty[6])
g_Slot[6] = CT_Empty;
// Pre: may need g_hFrameWindow for MessageBox errors
// Post: may enable HDD, required for MemInitialize()->MemInitializeIO()
@ -1641,7 +1648,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
InsertHardDisks(szImageName_harddisk, bBoot);
szImageName_harddisk[HARDDISK_1] = szImageName_harddisk[HARDDISK_2] = NULL; // Don't insert on a restart
if (bSlot7Empty)
if (bSlotEmpty[7])
HD_SetEnabled(false);
}

View File

@ -51,10 +51,7 @@ extern bool g_bDisableDirectSound; // Cmd line switch: don't init DS (s
extern bool g_bDisableDirectSoundMockingboard; // Cmd line switch: don't init MB support
extern int g_nMemoryClearType; // Cmd line switch: use specific MIP (Memory Initialization Pattern)
extern SS_CARDTYPE g_Slot0; // LC or Saturn in slot0
extern SS_CARDTYPE g_Slot2; // SSC in slot2
extern SS_CARDTYPE g_Slot4; // Mockingboard, Z80, Mouse in slot4
extern SS_CARDTYPE g_Slot5; // Mockingboard, Z80, in slot5
extern SS_CARDTYPE g_Slot[NUM_SLOTS];
extern SS_CARDTYPE g_SlotAux;
extern HANDLE g_hCustomRomF8; // NULL if no custom rom

View File

@ -105,6 +105,8 @@ enum AppMode_e
#define REGVALUE_CUSTOM_SPEED "Custom Speed"
#define REGVALUE_EMULATION_SPEED "Emulation Speed"
#define REGVALUE_WINDOW_SCALE "Window Scale"
#define REGVALUE_UTHERNET_ACTIVE "Uthernet Active"
#define REGVALUE_UTHERNET_INTERFACE "Uthernet Interface"
#define REGVALUE_SLOT0 "Slot 0"
#define REGVALUE_SLOT1 "Slot 1"
#define REGVALUE_SLOT2 "Slot 2"

View File

@ -19,8 +19,8 @@ public:
m_bEnableTheFreezesF8Rom = bEnableTheFreezesF8Rom;
memset(&m_Slot, 0, sizeof(m_Slot));
m_SlotAux = CT_Empty;
m_Slot[4] = g_Slot4;
m_Slot[5] = g_Slot5;
m_Slot[4] = g_Slot[4];
m_Slot[5] = g_Slot[5];
}
const CConfigNeedingRestart& operator= (const CConfigNeedingRestart& other)

View File

@ -282,16 +282,16 @@ void CPageConfigTfe::save_tfe_dialog(HWND hwnd)
// RGJ - Added check for NULL interface so we don't set it active without a valid interface selected
if (strlen(buffer) > 0)
{
RegSaveString(TEXT("Configuration"), TEXT("Uthernet Interface"), 1, buffer);
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, buffer);
active_value = SendMessage(GetDlgItem(hwnd, IDC_TFE_SETTINGS_ENABLE), CB_GETCURSEL, 0, 0);
tfe_enabled = active_value >= 1 ? 1 : 0;
REGSAVE(TEXT("Uthernet Active") ,tfe_enabled);
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE) ,tfe_enabled);
}
else
{
REGSAVE(TEXT("Uthernet Active") ,0);
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE) ,0);
}
}

View File

@ -116,7 +116,7 @@ BOOL CPageSound::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETTICFREQ,10,0);
SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETPOS,1,MB_GetVolume());
if (g_Slot5 == CT_SAM)
if (g_Slot[5] == CT_SAM)
m_NewCardType = CT_SAM;
else
m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE)

View File

@ -120,14 +120,14 @@ void CPropertySheetHelper::SaveCpuType(eCpuType NewCpuType)
void CPropertySheetHelper::SetSlot4(SS_CARDTYPE NewCardType)
{
g_Slot4 = NewCardType;
REGSAVE(TEXT(REGVALUE_SLOT4),(DWORD)g_Slot4);
g_Slot[4] = NewCardType;
REGSAVE(TEXT(REGVALUE_SLOT4), (DWORD)g_Slot[4]);
}
void CPropertySheetHelper::SetSlot5(SS_CARDTYPE NewCardType)
{
g_Slot5 = NewCardType;
REGSAVE(TEXT(REGVALUE_SLOT5),(DWORD)g_Slot5);
g_Slot[5] = NewCardType;
REGSAVE(TEXT(REGVALUE_SLOT5), (DWORD)g_Slot[5]);
}
// Looks like a (bad) C&P from SaveStateSelectImage()
@ -423,8 +423,8 @@ void CPropertySheetHelper::SaveCurrentConfig(void)
// NB. clone-type is encoded in g_Apple2Type
m_ConfigOld.m_Apple2Type = GetApple2Type();
m_ConfigOld.m_CpuType = GetMainCpu();
m_ConfigOld.m_Slot[4] = g_Slot4;
m_ConfigOld.m_Slot[5] = g_Slot5;
m_ConfigOld.m_Slot[4] = g_Slot[4];
m_ConfigOld.m_Slot[5] = g_Slot[5];
m_ConfigOld.m_bEnableHDD = HD_CardIsEnabled();
m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom();
m_ConfigOld.m_videoRefreshRate = GetVideoRefreshRate();
@ -442,8 +442,8 @@ void CPropertySheetHelper::RestoreCurrentConfig(void)
// NB. clone-type is encoded in g_Apple2Type
SetApple2Type(m_ConfigOld.m_Apple2Type);
SetMainCpu(m_ConfigOld.m_CpuType);
g_Slot4 = m_ConfigOld.m_Slot[4];
g_Slot5 = m_ConfigOld.m_Slot[5];
g_Slot[4] = m_ConfigOld.m_Slot[4];
g_Slot[5] = m_ConfigOld.m_Slot[5];
HD_SetEnabled(m_ConfigOld.m_bEnableHDD);
sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom);
SetVideoRefreshRate(m_ConfigOld.m_videoRefreshRate);

View File

@ -291,7 +291,7 @@ void SetExpansionMemType(const SS_CARDTYPE type)
newSlotAuxCard = type;
}
g_Slot0 = newSlot0Card;
g_Slot[0] = newSlot0Card;
g_SlotAux = newSlotAuxCard;
}
@ -302,9 +302,9 @@ void CreateLanguageCard(void)
if (IsApple2PlusOrClone(GetApple2Type()))
{
if (g_Slot0 == CT_Saturn128K)
if (g_Slot[0] == CT_Saturn128K)
g_pLanguageCard = new Saturn128K(g_uSaturnBanksFromCmdLine);
else if (g_Slot0 == CT_LanguageCard)
else if (g_Slot[0] == CT_LanguageCard)
g_pLanguageCard = new LanguageCardSlot0;
else
g_pLanguageCard = NULL;
@ -318,7 +318,7 @@ void CreateLanguageCard(void)
SS_CARDTYPE GetCurrentExpansionMemType(void)
{
if (IsApple2PlusOrClone(GetApple2Type()))
return g_Slot0;
return g_Slot[0];
else
return g_SlotAux;
}
@ -1048,7 +1048,7 @@ static void ResetPaging(BOOL initialize)
{
SetLastRamWrite(0);
if (IsApple2PlusOrClone(GetApple2Type()) && g_Slot0 == CT_Empty)
if (IsApple2PlusOrClone(GetApple2Type()) && g_Slot[0] == CT_Empty)
SetMemMode(0);
else
SetMemMode(LanguageCardUnit::kMemModeInitialState);
@ -1572,7 +1572,7 @@ void MemInitializeCustomF8ROM(void)
const UINT F8RomSize = 0x800;
const UINT F8RomOffset = Apple2RomSize-F8RomSize;
if (IsApple2Original(GetApple2Type()) && g_Slot0 == CT_LanguageCard)
if (IsApple2Original(GetApple2Type()) && g_Slot[0] == CT_LanguageCard)
{
try
{
@ -1654,47 +1654,54 @@ void MemInitializeIO(void)
else
RegisterIoHandler(LanguageCardUnit::kSlot0, IO_Null, IO_Null, NULL, NULL, NULL, NULL);
// TODO: Cleanup peripheral setup!!!
PrintLoadRom(pCxRomPeripheral, 1); // $C100 : Parallel printer f/w
if (g_Slot[1] == CT_GenericPrinter)
PrintLoadRom(pCxRomPeripheral, 1); // $C100 : Parallel printer f/w
if (g_Slot2 == CT_SSC)
if (g_Slot[2] == CT_SSC)
sg_SSC.CommInitialize(pCxRomPeripheral, 2); // $C200 : SSC
// Slot 3 contains the Uthernet card (which can coexist with an 80-col+Ram card in AUX slot)
// . Uthernet card has no ROM and only IO mapped at $C0Bx
if (g_Slot[3] == CT_Uthernet)
{
// Slot 3 contains the Uthernet card (which can coexist with an 80-col+Ram card in AUX slot)
// . Uthernet card has no ROM and only IO mapped at $C0Bx
// NB. I/O handlers setup via tfe_init() & update_tfe_interface()
}
// Apple//e: Auxilary slot contains Extended 80 Column card or RamWorksIII card
if (g_Slot4 == CT_MouseInterface)
if (g_Slot[4] == CT_MouseInterface)
{
sg_Mouse.Initialize(pCxRomPeripheral, 4); // $C400 : Mouse f/w
}
else if (g_Slot4 == CT_MockingboardC || g_Slot4 == CT_Phasor)
else if (g_Slot[4] == CT_MockingboardC || g_Slot[4] == CT_Phasor)
{
const UINT uSlot4 = 4;
const UINT uSlot5 = 5;
MB_InitializeIO(pCxRomPeripheral, uSlot4, uSlot5);
}
else if (g_Slot4 == CT_Z80)
else if (g_Slot[4] == CT_Z80)
{
ConfigureSoftcard(pCxRomPeripheral, 4); // $C400 : Z80 card
}
// else if (g_Slot4 == CT_GenericClock)
// else if (g_Slot[4] == CT_GenericClock)
// {
// LoadRom_Clock_Generic(pCxRomPeripheral, 4);
// }
if (g_Slot5 == CT_Z80)
if (g_Slot[5] == CT_Z80)
{
ConfigureSoftcard(pCxRomPeripheral, 5); // $C500 : Z80 card
}
else if (g_Slot5 == CT_SAM)
else if (g_Slot[5] == CT_SAM)
{
ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card
}
sg_Disk2Card.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w
if (g_Slot[6] == CT_Disk2)
sg_Disk2Card.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card
if (g_Slot[7] == CT_GenericHDD)
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w
//
@ -2346,7 +2353,7 @@ static void MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::
yamlLoadHelper.PopMap();
}
g_Slot0 = CT_Empty;
g_Slot[0] = CT_Empty;
g_SlotAux = type;
memaux = RWpages[g_uActiveBank];

View File

@ -1685,21 +1685,21 @@ void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5)
// Phasor : Slot 4
// <other> : Slot 4 & 5
if (g_Slot4 != CT_MockingboardC && g_Slot4 != CT_Phasor)
if (g_Slot[4] != CT_MockingboardC && g_Slot[4] != CT_Phasor)
{
MB_SetSoundcardType(CT_Empty);
return;
}
if (g_Slot4 == CT_MockingboardC)
if (g_Slot[4] == CT_MockingboardC)
RegisterIoHandler(uSlot4, IO_Null, IO_Null, MB_Read, MB_Write, NULL, NULL);
else // Phasor
RegisterIoHandler(uSlot4, PhasorIO, PhasorIO, MB_Read, MB_Write, NULL, NULL);
if (g_Slot5 == CT_MockingboardC)
if (g_Slot[5] == CT_MockingboardC)
RegisterIoHandler(uSlot5, IO_Null, IO_Null, MB_Read, MB_Write, NULL, NULL);
MB_SetSoundcardType(g_Slot4);
MB_SetSoundcardType(g_Slot[4]);
// Sound buffer may have been stopped by MB_InitializeForLoadingSnapshot().
// NB. DSZeroVoiceBuffer() also zeros the sound buffer, so it's better than directly calling IDirectSoundBuffer::Play():

View File

@ -497,31 +497,37 @@ void Snapshot_SaveState(void)
yamlSaveHelper.UnitHdr(GetSnapshotUnitSlotsName(), UNIT_SLOTS_VER);
YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE);
if (g_Slot0 != CT_Empty && IsApple2PlusOrClone(GetApple2Type()))
if (g_Slot[0] != CT_Empty && IsApple2PlusOrClone(GetApple2Type()))
GetLanguageCard()->SaveSnapshot(yamlSaveHelper); // Language Card or Saturn 128K
Printer_SaveSnapshot(yamlSaveHelper);
if (g_Slot[1] == CT_GenericPrinter)
Printer_SaveSnapshot(yamlSaveHelper);
sg_SSC.SaveSnapshot(yamlSaveHelper);
if (g_Slot[2] == CT_SSC)
sg_SSC.SaveSnapshot(yamlSaveHelper);
// if (g_Slot[3] == CT_Uthernet)
// sg_Uthernet.SaveSnapshot(yamlSaveHelper);
sg_Mouse.SaveSnapshot(yamlSaveHelper);
if (g_Slot4 == CT_Z80)
if (g_Slot[4] == CT_Z80)
Z80_SaveSnapshot(yamlSaveHelper, 4);
if (g_Slot5 == CT_Z80)
if (g_Slot[5] == CT_Z80)
Z80_SaveSnapshot(yamlSaveHelper, 5);
if (g_Slot4 == CT_MockingboardC)
if (g_Slot[4] == CT_MockingboardC)
MB_SaveSnapshot(yamlSaveHelper, 4);
if (g_Slot5 == CT_MockingboardC)
if (g_Slot[5] == CT_MockingboardC)
MB_SaveSnapshot(yamlSaveHelper, 5);
if (g_Slot4 == CT_Phasor)
if (g_Slot[4] == CT_Phasor)
Phasor_SaveSnapshot(yamlSaveHelper, 4);
sg_Disk2Card.SaveSnapshot(yamlSaveHelper);
if (g_Slot[6] == CT_Disk2)
sg_Disk2Card.SaveSnapshot(yamlSaveHelper);
HD_SaveSnapshot(yamlSaveHelper);
}