diff --git a/data/webui/device_specific/BUILD_COCO/autorun.dsk b/data/webui/device_specific/BUILD_COCO/autorun.dsk index 6f999c9d7..9492c8435 100644 Binary files a/data/webui/device_specific/BUILD_COCO/autorun.dsk and b/data/webui/device_specific/BUILD_COCO/autorun.dsk differ diff --git a/lib/FileSystem/fnFsTNFS.cpp b/lib/FileSystem/fnFsTNFS.cpp index 614757984..b427aec8a 100644 --- a/lib/FileSystem/fnFsTNFS.cpp +++ b/lib/FileSystem/fnFsTNFS.cpp @@ -135,6 +135,11 @@ bool FileSystemTNFS::start(const char *host, uint16_t port, const char * mountpa return true; } +bool FileSystemTNFS::is_started() +{ + return _started; +} + bool FileSystemTNFS::exists(const char* path) { tnfsStat tstat; diff --git a/lib/FileSystem/fnFsTNFS.h b/lib/FileSystem/fnFsTNFS.h index 6dd593e4b..273aa13d6 100644 --- a/lib/FileSystem/fnFsTNFS.h +++ b/lib/FileSystem/fnFsTNFS.h @@ -33,6 +33,7 @@ class FileSystemTNFS : public FileSystem FileHandler * filehandler_open(const char* path, const char* mode = FILE_READ) override; #endif + bool is_started(); bool exists(const char* path) override; bool remove(const char* path) override; diff --git a/lib/device/drivewire/fuji.cpp b/lib/device/drivewire/fuji.cpp index 90f2169d6..424af8db6 100644 --- a/lib/device/drivewire/fuji.cpp +++ b/lib/device/drivewire/fuji.cpp @@ -16,6 +16,7 @@ #include "fnSystem.h" #include "fnConfig.h" #include "fsFlash.h" +#include "fnFsTNFS.h" #include "fnWiFi.h" #include "led.h" @@ -1355,6 +1356,7 @@ void drivewireFuji::insert_boot_device(uint8_t d) bIsDragon = (fnSystem.digital_read(PIN_EPROM_A14) == DIGI_HIGH && fnSystem.digital_read(PIN_EPROM_A15) == DIGI_HIGH); #endif /* ESP_PLATFORM */ + const char *boot_img = nullptr; fnFile *fBoot = NULL; size_t sz = 0; @@ -1365,16 +1367,38 @@ void drivewireFuji::insert_boot_device(uint8_t d) case 0: if (bIsDragon) { - fBoot = fsFlash.fnfile_open(config_atr_dragon); + boot_img = config_atr_dragon; } else { - fBoot = fsFlash.fnfile_open(config_atr_coco); + boot_img = config_atr_coco; } + fBoot = fsFlash.fnfile_open(boot_img); break; case 1: - fBoot = fsFlash.fnfile_open(mount_and_boot_atr); + boot_img = mount_and_boot_atr; + fBoot = fsFlash.fnfile_open(boot_img); break; + case 2: + Debug_printf("Mounting lobby server\n"); + if (!fnTNFS.is_started()) + { + Debug_printf("Starting TNFS connection\n"); + if (!fnTNFS.start("tnfs.fujinet.online")) + { + Debug_printf("TNFS failed to start.\n"); + fBoot = NULL; + return; + } + } + + Debug_printf("Opening lobby.\n"); + boot_img = "/COCO/lobby.dsk"; + fBoot = fnTNFS.fnfile_open(boot_img); + break; + default: + Debug_printf("Invalid boot mode: %d\n", d); + return; } if (fBoot) @@ -1382,7 +1406,7 @@ void drivewireFuji::insert_boot_device(uint8_t d) fnio::fseek(fBoot, 0, SEEK_END); sz = fnio::ftell(fBoot); fnio::fseek(fBoot, 0, SEEK_SET); - _bootDisk.mount(fBoot, bIsDragon ? config_atr_dragon : config_atr_coco, sz); + _bootDisk.mount(fBoot, boot_img, sz); _bootDisk.is_config_device = true; _bootDisk.device_active = true; diff --git a/lib/device/iwm/fuji.cpp b/lib/device/iwm/fuji.cpp index 5456524a9..93d4c5f26 100644 --- a/lib/device/iwm/fuji.cpp +++ b/lib/device/iwm/fuji.cpp @@ -1282,12 +1282,19 @@ void iwmFuji::insert_boot_device(uint8_t d) break; case 2: Debug_printf("Mounting lobby server\n"); - if (fnTNFS.start("tnfs.fujinet.online")) + if (!fnTNFS.is_started()) { - Debug_printf("opening lobby.\n"); - boot_img = "/APPLE2/_lobby.po"; - fBoot = fnTNFS.fnfile_open(boot_img); + Debug_printf("Starting TNFS connection\n"); + if (!fnTNFS.start("tnfs.fujinet.online")) + { + Debug_printf("TNFS failed to start.\n"); + return; + } } + + Debug_printf("opening lobby.\n"); + boot_img = "/APPLE2/_lobby.po"; + fBoot = fnTNFS.fnfile_open(boot_img); break; default: Debug_printf("Invalid boot mode: %d\n", d); diff --git a/lib/device/sio/fuji.cpp b/lib/device/sio/fuji.cpp index 0e71e521d..31a86abd7 100644 --- a/lib/device/sio/fuji.cpp +++ b/lib/device/sio/fuji.cpp @@ -2051,12 +2051,19 @@ void sioFuji::insert_boot_device(uint8_t d) break; case 2: Debug_printf("Mounting lobby server\n"); - if (fnTNFS.start("tnfs.fujinet.online")) + if (!fnTNFS.is_started()) { - Debug_printf("opening lobby.\n"); - fBoot = fnTNFS.fnfile_open("/ATARI/_lobby.xex"); - _bootDisk.mount(fBoot, "/ATARI/_lobby.xex", 0); + Debug_printf("Starting TNFS connection\n"); + if (!fnTNFS.start("tnfs.fujinet.online")) + { + Debug_printf("TNFS failed to start.\n"); + return; + } } + + Debug_printf("opening lobby.\n"); + fBoot = fnTNFS.fnfile_open("/ATARI/_lobby.xex"); + _bootDisk.mount(fBoot, "/ATARI/_lobby.xex", 0); break; } #else