From b39beacc4022c5399793635308f535ea4ce66c36 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 11 Jun 2022 08:16:16 +0200 Subject: [PATCH] RL02 for ESP32 --- ESP32/loaders.cpp | 1 + ESP32/loaders.h | 1 + ESP32/main.ino | 53 +++++++++++++++++++++++------------------------ 3 files changed, 28 insertions(+), 27 deletions(-) create mode 120000 ESP32/loaders.cpp create mode 120000 ESP32/loaders.h diff --git a/ESP32/loaders.cpp b/ESP32/loaders.cpp new file mode 120000 index 0000000..c8fc77d --- /dev/null +++ b/ESP32/loaders.cpp @@ -0,0 +1 @@ +../loaders.cpp \ No newline at end of file diff --git a/ESP32/loaders.h b/ESP32/loaders.h new file mode 120000 index 0000000..72369d4 --- /dev/null +++ b/ESP32/loaders.h @@ -0,0 +1 @@ +../loaders.h \ No newline at end of file diff --git a/ESP32/main.ino b/ESP32/main.ino index 629c576..0edbf03 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -15,6 +15,7 @@ #include "error.h" #include "esp32.h" #include "gen.h" +#include "loaders.h" #include "memory.h" #include "tty.h" #include "utils.h" @@ -39,29 +40,6 @@ bool trace_output { false }; // std::atomic_bool on_wifi { false }; -void setBootLoader(bus *const b) { - cpu *const c = b->getCpu(); - - const uint16_t offset = 01000; - - constexpr uint16_t bootrom[] = { - 0012700, - 0177406, - 0012710, - 0177400, - 0012740, - 0000005, - 0105710, - 0100376, - 0005007 - }; - - for(size_t i=0; iwriteWord(offset + i * 2, bootrom[i]); - - c->setRegister(7, offset); -} - void console_thread_wrapper_panel(void *const c) { console *const cnsl = reinterpret_cast(c); @@ -126,7 +104,8 @@ void setup_wifi_stations() #endif } -std::vector select_disk_files(console *const c) +// RK05, RL02 files +std::pair, std::vector > select_disk_files(console *const c) { c->debug("MISO: %d", int(MISO)); c->debug("MOSI: %d", int(MOSI)); @@ -145,6 +124,15 @@ std::vector select_disk_files(console *const c) std::string selected_file = c->read_line("Enter filename: "); + c->put_string("1. RK05, 2. RL02, 3. re-select file"); + + int ch = -1; + while(ch == -1 && ch != '1' && ch != '2' && ch != '3') + ch = c->wait_char(500); + + if (ch == '3') + continue; + c->put_string("Opening file: "); c->put_string_lf(selected_file.c_str()); @@ -153,7 +141,11 @@ std::vector select_disk_files(console *const c) if (fh.open(selected_file.c_str(), O_RDWR)) { fh.close(); - return { selected_file }; + if (ch == '1') + return { { selected_file }, { } }; + + if (ch == '2') + return { { }, { selected_file } }; } c->put_string_lf("open failed"); @@ -209,9 +201,16 @@ void setup() { Serial.println(F("Load RK05")); auto disk_files = select_disk_files(cnsl); - b->add_rk05(new rk05(disk_files, b, cnsl->get_disk_read_activity_flag(), cnsl->get_disk_write_activity_flag())); + if (disk_files.first.empty() == false) + b->add_rk05(new rk05(disk_files.first, b, cnsl->get_disk_read_activity_flag(), cnsl->get_disk_write_activity_flag())); - setBootLoader(b); + if (disk_files.second.empty() == false) + b->add_rl02(new rl02(disk_files.second, b, cnsl->get_disk_read_activity_flag(), cnsl->get_disk_write_activity_flag())); + + if (disk_files.first.empty() == false) + setBootLoader(b, BL_RK05); + else + setBootLoader(b, BL_RL02); Serial.print(F("Free RAM after init: ")); Serial.println(ESP.getFreeHeap());