From e81960a29578bdfff89aae74795a64b4adf9e6f5 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 28 May 2018 14:46:57 +1000 Subject: [PATCH 1/4] Added RAMBoard support = RAM at 0x8000 Changed Address decoding code to be clearer --- src/main.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f633446..e6be416 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -203,19 +203,40 @@ DWORD get_fattime() { return 0; } // If you have hardware RTC return a correct v u8 read6502(u16 address) { u8 value; - if (address & 0x8000) // address line 15 selects the ROM + if (address & 0x8000) { - value = roms.Read(address); + switch (address & 0xe000) // keep bits 15,14,13 + { + case 0x8000: // 0x8000-0x9fff + value = s_u8Memory[address]; // 74LS42 outputs low on pin 1 or pin 2 + break; + case 0xa000: // 0xa000-0xbfff + case 0xc000: // 0xc000-0xdfff + case 0xe000: // 0xe000-0xffff + value = roms.Read(address); + break; + } } else { // Address lines 15, 12, 11 and 10 are fed into a 74LS42 for decoding - u16 addressLines15_12_11_10 = (address & 0x1c00) >> 10; - addressLines15_12_11_10 |= (address & 0x8000) >> (15 - 3); - if (addressLines15_12_11_10 == 0 || addressLines15_12_11_10 == 1) value = s_u8Memory[address & 0x7ff]; // 74LS42 outputs low on pin 1 or pin 2 - else if (addressLines15_12_11_10 == 6) value = pi1541.VIA[0].Read(address); // 74LS42 outputs low on pin 7 - else if (addressLines15_12_11_10 == 7) value = pi1541.VIA[1].Read(address); // 74LS42 outputs low on pin 9 - else value = address >> 8; // Empty address bus + u16 addressLines12_11_10 = (address & 0x1c00) >> 10; + switch (addressLines12_11_10) + { + case 0: + case 1: + value = s_u8Memory[address & 0x7ff]; // 74LS42 outputs low on pin 1 or pin 2 + break; + case 6: + value = pi1541.VIA[0].Read(address); // 74LS42 outputs low on pin 7 + break; + case 7: + value = pi1541.VIA[1].Read(address); // 74LS42 outputs low on pin 9 + break; + default: + value = address >> 8; // Empty address bus + break; + } } return value; } @@ -258,12 +279,39 @@ u8 peek6502(u16 address) void write6502(u16 address, const u8 value) { - if (address & 0x8000) return; // address line 15 selects the ROM - u16 addressLines15_12_11_10 = (address & 0x1c00) >> 10; - addressLines15_12_11_10 |= (address & 0x8000) >> (15 - 3); - if (addressLines15_12_11_10 == 0 || addressLines15_12_11_10 == 1) s_u8Memory[address & 0x7ff] = value; // 74LS42 outputs low on pin 1 or pin 2 - else if (addressLines15_12_11_10 == 6) pi1541.VIA[0].Write(address, value); // 74LS42 outputs low on pin 7 - else if (addressLines15_12_11_10 == 7) pi1541.VIA[1].Write(address, value); // 74LS42 outputs low on pin 9 + if (address & 0x8000) + { + switch (address & 0xe000) // keep bits 15,14,13 + { + case 0x8000: // 0x8000-0x9fff + s_u8Memory[address] = value; // 74LS42 outputs low on pin 1 or pin 2 + break; + case 0xa000: // 0xa000-0xbfff + case 0xc000: // 0xc000-0xdfff + case 0xe000: // 0xe000-0xffff + return; + } + } + else + { + // Address lines 15, 12, 11 and 10 are fed into a 74LS42 for decoding + u16 addressLines12_11_10 = (address & 0x1c00) >> 10; + switch (addressLines12_11_10) + { + case 0: + case 1: + s_u8Memory[address & 0x7ff] = value; // 74LS42 outputs low on pin 1 or pin 2 + break; + case 6: + pi1541.VIA[0].Write(address, value); // 74LS42 outputs low on pin 7 + break; + case 7: + pi1541.VIA[1].Write(address, value); // 74LS42 outputs low on pin 9 + break; + default: + break; + } + } } void write6502ExtraRAM(u16 address, const u8 value) From 89ff0d4771337b23f58d3e8e5a32aa2393fb1013 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 28 May 2018 23:17:22 +1000 Subject: [PATCH 2/4] Added config option for RAMBOard = 0/1 Displays parsed options on startup --- src/main.cpp | 28 ++++++++++++++++++++++++---- src/options.cpp | 7 +++++++ src/options.h | 2 ++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e6be416..d3036ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,6 +90,7 @@ u8 deviceID = 8; IEC_Commands m_IEC_Commands; bool onResetChangeToStartingFolder = false; bool extraRAM = false; +bool enableRAMBOard = false; bool disableSD2IECCommands = false; bool supportUARTInput = false; bool graphIEC = false; @@ -202,7 +203,7 @@ DWORD get_fattime() { return 0; } // If you have hardware RTC return a correct v // 1c00 !cs2 on pin 7 u8 read6502(u16 address) { - u8 value; + u8 value = 0; if (address & 0x8000) { switch (address & 0xe000) // keep bits 15,14,13 @@ -1011,6 +1012,9 @@ static void CheckOptions() extraRAM = options.GetExtraRAM() != 0; DEBUG_LOG("extraRAM = %d\r\n", extraRAM); + enableRAMBOard = options.GetRAMBOard() != 0; + DEBUG_LOG("RAMBOard = %d\r\n", enableRAMBOard); + disableSD2IECCommands = options.GetDisableSD2IECCommands(); //supportUARTInput = options.GetSupportUARTInput() != 0; graphIEC = options.GraphIEC(); @@ -1026,6 +1030,20 @@ static void CheckOptions() invertIECInputs = false; ignoreReset = options.IgnoreReset(); + screen.Clear(COLOUR_BLACK); + int y_pos = 200; + snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", ignoreReset); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", enableRAMBOard); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", splitIECLines); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", invertIECInputs); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", invertIECOutputs); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + IEC_Bus::WaitMicroSeconds(3 * 1000000); + ROMName = options.GetRomFontName(); if (ROMName) { @@ -1125,12 +1143,14 @@ extern "C" write32(ARM_GPIO_GPCLR0, 0xFFFFFFFF); DisplayLogo(); + int y_pos = 184; snprintf(tempBuffer, tempBufferSize, "Copyright(C) 2018 Stephen White"); - screen.PrintText(false, 0, 200, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); snprintf(tempBuffer, tempBufferSize, "This program comes with ABSOLUTELY NO WARRANTY."); - screen.PrintText(false, 0, 216, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); snprintf(tempBuffer, tempBufferSize, "This is free software, and you are welcome to redistribute it."); - screen.PrintText(false, 0, 232, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + if (!quickBoot) IEC_Bus::WaitMicroSeconds(3 * 1000000); diff --git a/src/options.cpp b/src/options.cpp index 9fb1b82..ed16748 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -122,6 +122,7 @@ Options::Options(void) , deviceID(8) , onResetChangeToStartingFolder(0) , extraRAM(0) + , enableRAMBOard(0) , disableSD2IECCommands(0) , supportUARTInput(0) , graphIEC(0) @@ -174,6 +175,12 @@ void Options::Process(char* buffer) if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) extraRAM = nValue; } + else if (strcasecmp(pOption, "RAMBOard") == 0) + { + unsigned nValue = 0; + if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) + enableRAMBOard = nValue; + } else if (strcasecmp(pOption, "DisableSD2IECCommands") == 0) { unsigned nValue = 0; diff --git a/src/options.h b/src/options.h index 879b138..8d2266d 100644 --- a/src/options.h +++ b/src/options.h @@ -49,6 +49,7 @@ public: const char* GetRomFontName() const { return ROMFontName; } const char* GetRomName(int index) const; unsigned int GetExtraRAM() const { return extraRAM; } + unsigned int GetRAMBOard() const { return enableRAMBOard; } unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; } unsigned int GetSupportUARTInput() const { return supportUARTInput; } @@ -70,6 +71,7 @@ private: unsigned int deviceID; unsigned int onResetChangeToStartingFolder; unsigned int extraRAM; + unsigned int enableRAMBOard; unsigned int disableSD2IECCommands; unsigned int supportUARTInput; unsigned int graphIEC; From 05c9cae9cf586e87e3a1117323bd37fb5d24d372 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 29 May 2018 18:21:49 +1000 Subject: [PATCH 3/4] now actually obeys RAMBOard setting --- src/main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d3036ca..4590eaa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -209,8 +209,10 @@ u8 read6502(u16 address) switch (address & 0xe000) // keep bits 15,14,13 { case 0x8000: // 0x8000-0x9fff - value = s_u8Memory[address]; // 74LS42 outputs low on pin 1 or pin 2 - break; + if (enableRAMBOard) { + value = s_u8Memory[address]; // 74LS42 outputs low on pin 1 or pin 2 + break; + } case 0xa000: // 0xa000-0xbfff case 0xc000: // 0xc000-0xdfff case 0xe000: // 0xe000-0xffff @@ -285,8 +287,10 @@ void write6502(u16 address, const u8 value) switch (address & 0xe000) // keep bits 15,14,13 { case 0x8000: // 0x8000-0x9fff - s_u8Memory[address] = value; // 74LS42 outputs low on pin 1 or pin 2 - break; + if (enableRAMBOard) { + s_u8Memory[address] = value; // 74LS42 outputs low on pin 1 or pin 2 + break; + } case 0xa000: // 0xa000-0xbfff case 0xc000: // 0xc000-0xdfff case 0xe000: // 0xe000-0xffff @@ -1042,7 +1046,7 @@ static void CheckOptions() screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", invertIECOutputs); screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - IEC_Bus::WaitMicroSeconds(3 * 1000000); + IEC_Bus::WaitMicroSeconds(5 * 1000000); ROMName = options.GetRomFontName(); if (ROMName) From c7c3b0901c827afa8d20ed849e8594b3ec1cf2dd Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 29 May 2018 18:24:56 +1000 Subject: [PATCH 4/4] disable debug display options to screen --- src/main.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4590eaa..2eab71b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1034,19 +1034,22 @@ static void CheckOptions() invertIECInputs = false; ignoreReset = options.IgnoreReset(); - screen.Clear(COLOUR_BLACK); - int y_pos = 200; - snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", ignoreReset); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", enableRAMBOard); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", splitIECLines); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", invertIECInputs); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", invertIECOutputs); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - IEC_Bus::WaitMicroSeconds(5 * 1000000); + // print confirmation of parsed options + if (0) { + screen.Clear(COLOUR_BLACK); + int y_pos = 200; + snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", ignoreReset); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", enableRAMBOard); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", splitIECLines); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", invertIECInputs); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", invertIECOutputs); + screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + IEC_Bus::WaitMicroSeconds(5 * 1000000); + } ROMName = options.GetRomFontName(); if (ROMName)