load/unload tape
This commit is contained in:
parent
95db008a68
commit
e643b2a0bb
5 changed files with 112 additions and 53 deletions
2
bus.h
2
bus.h
|
@ -49,6 +49,7 @@ class console;
|
||||||
class cpu;
|
class cpu;
|
||||||
class kw11_l;
|
class kw11_l;
|
||||||
class memory;
|
class memory;
|
||||||
|
class tm_11;
|
||||||
class tty;
|
class tty;
|
||||||
|
|
||||||
typedef enum { T_PROCEED, T_ABORT_4, T_TRAP_250 } trap_action_t;
|
typedef enum { T_PROCEED, T_ABORT_4, T_TRAP_250 } trap_action_t;
|
||||||
|
@ -121,6 +122,7 @@ public:
|
||||||
mmu *getMMU() { return mmu_; }
|
mmu *getMMU() { return mmu_; }
|
||||||
rk05 *getRK05() { return rk05_; }
|
rk05 *getRK05() { return rk05_; }
|
||||||
rl02 *getRL02() { return rl02_; }
|
rl02 *getRL02() { return rl02_; }
|
||||||
|
tm_11 *getTM11() { return tm11; }
|
||||||
|
|
||||||
uint16_t read (const uint16_t a, const word_mode_t word_mode, const rm_selection_t mode_selection, const bool peek_only=false, const d_i_space_t s = i_space);
|
uint16_t read (const uint16_t a, const word_mode_t word_mode, const rm_selection_t mode_selection, const bool peek_only=false, const d_i_space_t s = i_space);
|
||||||
uint16_t read_byte(const uint16_t a) { return read(a, wm_byte, rm_cur); }
|
uint16_t read_byte(const uint16_t a) { return read(a, wm_byte, rm_cur); }
|
||||||
|
|
107
debugger.cpp
107
debugger.cpp
|
@ -76,35 +76,8 @@ std::optional<disk_backend *> select_nbd_server(console *const cnsl)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// disk image files
|
std::optional<std::string> select_host_file(console *const c)
|
||||||
std::optional<disk_backend *> select_disk_file(console *const c)
|
|
||||||
{
|
{
|
||||||
#if IS_POSIX
|
|
||||||
c->put_string_lf("Files in current directory: ");
|
|
||||||
#else
|
|
||||||
c->put_string_lf(format("MISO: %d", int(MISO)));
|
|
||||||
c->put_string_lf(format("MOSI: %d", int(MOSI)));
|
|
||||||
c->put_string_lf(format("SCK : %d", int(SCK )));
|
|
||||||
c->put_string_lf(format("SS : %d", int(SS )));
|
|
||||||
|
|
||||||
c->put_string_lf("Files on SD-card:");
|
|
||||||
|
|
||||||
#if defined(SHA2017)
|
|
||||||
if (!SD.begin(21, SD_SCK_MHZ(10)))
|
|
||||||
SD.initErrorHalt();
|
|
||||||
#elif !defined(BUILD_FOR_RP2040)
|
|
||||||
if (!SD.begin(SS, SD_SCK_MHZ(15))) {
|
|
||||||
auto err = SD.sdErrorCode();
|
|
||||||
if (err)
|
|
||||||
c->put_string_lf(format("SDerror: 0x%x, data: 0x%x", err, SD.sdErrorData()));
|
|
||||||
else
|
|
||||||
c->put_string_lf("Failed to initialize SD card");
|
|
||||||
|
|
||||||
return { };
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
#if defined(linux)
|
#if defined(linux)
|
||||||
DIR *dir = opendir(".");
|
DIR *dir = opendir(".");
|
||||||
|
@ -164,16 +137,57 @@ std::optional<disk_backend *> select_disk_file(console *const c)
|
||||||
fh.close();
|
fh.close();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (can_open_file) {
|
if (can_open_file)
|
||||||
|
return selected_file;
|
||||||
|
|
||||||
|
c->put_string_lf("open failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// disk image files
|
||||||
|
std::optional<disk_backend *> select_disk_file(console *const c)
|
||||||
|
{
|
||||||
#if IS_POSIX
|
#if IS_POSIX
|
||||||
disk_backend *temp = new disk_backend_file(selected_file);
|
c->put_string_lf("Files in current directory: ");
|
||||||
#else
|
#else
|
||||||
disk_backend *temp = new disk_backend_esp32(selected_file);
|
c->put_string_lf(format("MISO: %d", int(MISO)));
|
||||||
|
c->put_string_lf(format("MOSI: %d", int(MOSI)));
|
||||||
|
c->put_string_lf(format("SCK : %d", int(SCK )));
|
||||||
|
c->put_string_lf(format("SS : %d", int(SS )));
|
||||||
|
|
||||||
|
c->put_string_lf("Files on SD-card:");
|
||||||
|
|
||||||
|
#if defined(SHA2017)
|
||||||
|
if (!SD.begin(21, SD_SCK_MHZ(10)))
|
||||||
|
SD.initErrorHalt();
|
||||||
|
#elif !defined(BUILD_FOR_RP2040)
|
||||||
|
if (!SD.begin(SS, SD_SCK_MHZ(15))) {
|
||||||
|
auto err = SD.sdErrorCode();
|
||||||
|
if (err)
|
||||||
|
c->put_string_lf(format("SDerror: 0x%x, data: 0x%x", err, SD.sdErrorData()));
|
||||||
|
else
|
||||||
|
c->put_string_lf("Failed to initialize SD card");
|
||||||
|
|
||||||
|
return { };
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
auto selected_file = select_host_file(c);
|
||||||
|
|
||||||
|
if (selected_file.has_value() == false)
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if IS_POSIX
|
||||||
|
disk_backend *temp = new disk_backend_file(selected_file.value());
|
||||||
|
#else
|
||||||
|
disk_backend *temp = new disk_backend_esp32(selected_file.value());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!temp->begin(false)) {
|
if (!temp->begin(false)) {
|
||||||
c->put_string("Cannot use: ");
|
c->put_string("Cannot use: ");
|
||||||
c->put_string_lf(selected_file.c_str());
|
c->put_string_lf(selected_file.value().c_str());
|
||||||
|
|
||||||
delete temp;
|
delete temp;
|
||||||
|
|
||||||
|
@ -183,9 +197,6 @@ std::optional<disk_backend *> select_disk_file(console *const c)
|
||||||
return { temp };
|
return { temp };
|
||||||
}
|
}
|
||||||
|
|
||||||
c->put_string_lf("open failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +246,6 @@ std::optional<disk_backend *> select_disk_backend(console *const cnsl)
|
||||||
|
|
||||||
void configure_disk(bus *const b, console *const cnsl)
|
void configure_disk(bus *const b, console *const cnsl)
|
||||||
{
|
{
|
||||||
// TODO tape
|
|
||||||
int type_ch = wait_for_key("1. RK05, 2. RL02, 9. abort", cnsl, { '1', '2', '3', '9' });
|
int type_ch = wait_for_key("1. RK05, 2. RL02, 9. abort", cnsl, { '1', '2', '3', '9' });
|
||||||
|
|
||||||
bootloader_t bl = BL_NONE;
|
bootloader_t bl = BL_NONE;
|
||||||
|
@ -590,6 +600,19 @@ void serialize_state(console *const cnsl, const bus *const b, const std::string
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void tm11_load_tape(console *const cnsl, bus *const b)
|
||||||
|
{
|
||||||
|
auto file = select_host_file(cnsl);
|
||||||
|
|
||||||
|
if (file.has_value())
|
||||||
|
b->getTM11()->load(file.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tm11_unload_tape(bus *const b)
|
||||||
|
{
|
||||||
|
b->getTM11()->unload();
|
||||||
|
}
|
||||||
|
|
||||||
void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing_in)
|
void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing_in)
|
||||||
{
|
{
|
||||||
int32_t trace_start_addr = -1;
|
int32_t trace_start_addr = -1;
|
||||||
|
@ -959,6 +982,16 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (cmd == "lt") {
|
||||||
|
tm11_load_tape(cnsl, b);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (cmd == "ult") {
|
||||||
|
tm11_unload_tape(b);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (cmd == "dp") {
|
else if (cmd == "dp") {
|
||||||
cnsl->stop_panel_thread();
|
cnsl->stop_panel_thread();
|
||||||
|
|
||||||
|
@ -1012,6 +1045,8 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
"setmem - set memory (a=) to value (v=), both in octal, one byte",
|
"setmem - set memory (a=) to value (v=), both in octal, one byte",
|
||||||
"toggle - set switch (s=, 0...15 (decimal)) of the front panel to state (t=, 0 or 1)",
|
"toggle - set switch (s=, 0...15 (decimal)) of the front panel to state (t=, 0 or 1)",
|
||||||
"cls - clear screen",
|
"cls - clear screen",
|
||||||
|
"lt - load tape (parameter is filename)",
|
||||||
|
"ult - unload tape",
|
||||||
"stats - show run statistics",
|
"stats - show run statistics",
|
||||||
"ramsize - set ram size (page count (8 kB))",
|
"ramsize - set ram size (page count (8 kB))",
|
||||||
"bl - set bootload (rl02 or rk05)",
|
"bl - set bootload (rl02 or rk05)",
|
||||||
|
|
3
main.cpp
3
main.cpp
|
@ -580,6 +580,9 @@ int main(int argc, char *argv[])
|
||||||
cnsl->set_bus(b);
|
cnsl->set_bus(b);
|
||||||
cnsl->begin();
|
cnsl->begin();
|
||||||
|
|
||||||
|
tm_11 *tm_11_ = new tm_11(b);
|
||||||
|
b->add_tm11(tm_11_);
|
||||||
|
|
||||||
running = cnsl->get_running_flag();
|
running = cnsl->get_running_flag();
|
||||||
|
|
||||||
std::atomic_bool interrupt_emulation { false };
|
std::atomic_bool interrupt_emulation { false };
|
||||||
|
|
21
tm-11.cpp
21
tm-11.cpp
|
@ -10,18 +10,35 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
tm_11::tm_11(const std::string & file, memory *const m): file(file), m(m)
|
tm_11::tm_11(bus *const b): m(b->getRAM())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
tm_11::~tm_11()
|
tm_11::~tm_11()
|
||||||
{
|
{
|
||||||
|
if (fh)
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tm_11::begin()
|
void tm_11::unload()
|
||||||
{
|
{
|
||||||
|
if (fh) {
|
||||||
|
fclose(fh);
|
||||||
|
fh = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
tape_file.clear();
|
||||||
|
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tm_11::load(const std::string & file)
|
||||||
|
{
|
||||||
|
if (fh)
|
||||||
|
fclose(fh);
|
||||||
|
|
||||||
fh = fopen(file.c_str(), "rb");
|
fh = fopen(file.c_str(), "rb");
|
||||||
|
tape_file = file;
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
8
tm-11.h
8
tm-11.h
|
@ -7,6 +7,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "bus.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
#define TM_11_MTS 0172520 // status register
|
#define TM_11_MTS 0172520 // status register
|
||||||
|
@ -24,18 +25,19 @@ class memory;
|
||||||
class tm_11 : public device
|
class tm_11 : public device
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string file;
|
|
||||||
memory *const m { nullptr };
|
memory *const m { nullptr };
|
||||||
uint16_t registers[6] { 0 };
|
uint16_t registers[6] { 0 };
|
||||||
uint8_t xfer_buffer[65536];
|
uint8_t xfer_buffer[65536];
|
||||||
int offset { 0 };
|
int offset { 0 };
|
||||||
FILE *fh { nullptr };
|
FILE *fh { nullptr };
|
||||||
|
std::string tape_file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
tm_11(const std::string & file, memory *const m);
|
tm_11(bus *const b);
|
||||||
virtual ~tm_11();
|
virtual ~tm_11();
|
||||||
|
|
||||||
void begin();
|
void load(const std::string & file);
|
||||||
|
void unload();
|
||||||
|
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue