From 1d730cc3ec64ab3861ae56feb29371f878b71ca0 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 18 Mar 2024 15:34:06 +0000 Subject: [PATCH] [apple2] 3.0.1 release - Support for CONFIG fuji functions --- Changelog.md | 10 ++++++++ apple2/src/fn_fuji/fuji_close_directory.c | 3 +++ apple2/src/fn_fuji/fuji_disable_device.c | 14 +++++++++-- apple2/src/fn_fuji/fuji_enable_device.c | 14 +++++++++-- .../fn_fuji/fuji_get_device_enabled_status.c | 24 +++---------------- apple2/src/fn_fuji/fuji_mount_all.c | 3 +++ apple2/src/fn_fuji/fuji_mount_disk_image.c | 5 ++++ apple2/src/fn_fuji/fuji_mount_host_slot.c | 4 ++++ apple2/src/fn_fuji/fuji_open_directory.c | 3 +-- apple2/src/fn_fuji/fuji_read_directory.c | 2 +- apple2/src/fn_fuji/fuji_set_device_filename.c | 2 +- version.txt | 2 +- 12 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Changelog.md b/Changelog.md index 14f2040..54b11f4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,16 @@ ## [Unreleased] +## [3.0.1] - 2024-03-19 + +Complete Apple2 fuji device support for CONFIG. + +- [apple2] fixes for mount_host_slot and mount_disk_image +- [apple2] don't call FN for get_device_enabled_status, as it's broken +- [apple2] add fuji_disable_device and fuji_enable_device implementations +- [apple2] fix control commands that were not setting the payload parameters +- [apple2] fix fuji_set_device_filename payload length + ## [3.0.0] - 2024-03-18 - The great rename fn_io_ to fuji_ to reflect device in FN being used, version bump to 3.0.0 to reflect huge name changes diff --git a/apple2/src/fn_fuji/fuji_close_directory.c b/apple2/src/fn_fuji/fuji_close_directory.c index f5ca917..6e6b492 100644 --- a/apple2/src/fn_fuji/fuji_close_directory.c +++ b/apple2/src/fn_fuji/fuji_close_directory.c @@ -9,6 +9,9 @@ bool fuji_close_directory(void) return false; } + sp_payload[0] = 0x00; + sp_payload[1] = 0x00; + sp_error = sp_control(sp_fuji_id, 0xF5); return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_disable_device.c b/apple2/src/fn_fuji/fuji_disable_device.c index 2c2d7af..7eb4a0f 100644 --- a/apple2/src/fn_fuji/fuji_disable_device.c +++ b/apple2/src/fn_fuji/fuji_disable_device.c @@ -1,8 +1,18 @@ #include #include "fujinet-fuji.h" +#include "fujinet-bus-apple2.h" bool fuji_disable_device(uint8_t d) { - // not supported on apple2 - return false; + sp_error = sp_get_fuji_id(); + if (sp_error <= 0) { + return false; + } + + sp_payload[0] = 1; + sp_payload[1] = 0; + sp_payload[2] = d; + + sp_error = sp_control(sp_fuji_id, 0xD4); + return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_enable_device.c b/apple2/src/fn_fuji/fuji_enable_device.c index 932f3ca..80173d3 100644 --- a/apple2/src/fn_fuji/fuji_enable_device.c +++ b/apple2/src/fn_fuji/fuji_enable_device.c @@ -1,8 +1,18 @@ #include #include "fujinet-fuji.h" +#include "fujinet-bus-apple2.h" bool fuji_enable_device(uint8_t d) { - // not supported on apple2 - return false; + sp_error = sp_get_fuji_id(); + if (sp_error <= 0) { + return false; + } + + sp_payload[0] = 1; + sp_payload[1] = 0; + sp_payload[2] = d; + + sp_error = sp_control(sp_fuji_id, 0xD5); + return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_get_device_enabled_status.c b/apple2/src/fn_fuji/fuji_get_device_enabled_status.c index d804bb1..b07e958 100644 --- a/apple2/src/fn_fuji/fuji_get_device_enabled_status.c +++ b/apple2/src/fn_fuji/fuji_get_device_enabled_status.c @@ -2,27 +2,9 @@ #include "fujinet-fuji.h" #include "fujinet-bus-apple2.h" -// Stupidly complex, the FN ALWAYS returns "1" for IWM, and ignores the device id. -// However, if it is implemented on FN, this will not need changing. +// TODO: sort this out! To get status, we need a code for +// every different device as there's no payload to specify which device. bool fuji_get_device_enabled_status(uint8_t d) { - int8_t err = 0; - err = sp_get_fuji_id(); - if (err <= 0) { - return false; - } - - // Number of bytes in payload - sp_payload[0] = 1; - sp_payload[1] = 0; - - // Actual payload - sp_payload[2] = d; - - // Call FN - sp_error = sp_control(sp_fuji_id, 0xD1); - if (sp_error == 0) { - return sp_payload[0] != 0; - } - return false; + return true; } diff --git a/apple2/src/fn_fuji/fuji_mount_all.c b/apple2/src/fn_fuji/fuji_mount_all.c index 08a5a5f..b07b1b4 100644 --- a/apple2/src/fn_fuji/fuji_mount_all.c +++ b/apple2/src/fn_fuji/fuji_mount_all.c @@ -9,6 +9,9 @@ bool fuji_mount_all(void) return false; } + sp_payload[0] = 0x00; + sp_payload[1] = 0x00; + sp_error = sp_control(sp_fuji_id, 0xD7); return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_mount_disk_image.c b/apple2/src/fn_fuji/fuji_mount_disk_image.c index 32f777e..3734dd6 100644 --- a/apple2/src/fn_fuji/fuji_mount_disk_image.c +++ b/apple2/src/fn_fuji/fuji_mount_disk_image.c @@ -9,6 +9,11 @@ bool fuji_mount_disk_image(uint8_t ds, uint8_t mode) return false; } + sp_payload[0] = 2; + sp_payload[1] = 0; + sp_payload[2] = ds; + sp_payload[3] = mode; + sp_error = sp_control(sp_fuji_id, 0xF8); return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_mount_host_slot.c b/apple2/src/fn_fuji/fuji_mount_host_slot.c index 9b10e12..72e3f7c 100644 --- a/apple2/src/fn_fuji/fuji_mount_host_slot.c +++ b/apple2/src/fn_fuji/fuji_mount_host_slot.c @@ -9,6 +9,10 @@ bool fuji_mount_host_slot(uint8_t hs) return false; } + sp_payload[0] = 1; + sp_payload[1] = 0; + sp_payload[2] = hs; + sp_error = sp_control(sp_fuji_id, 0xF9); return sp_error == 0; } diff --git a/apple2/src/fn_fuji/fuji_open_directory.c b/apple2/src/fn_fuji/fuji_open_directory.c index d641075..bc69650 100644 --- a/apple2/src/fn_fuji/fuji_open_directory.c +++ b/apple2/src/fn_fuji/fuji_open_directory.c @@ -10,13 +10,12 @@ bool fuji_open_directory(uint8_t hs, char *path_filter) return false; } - // Number of bytes in payload // we don't care about the length of the path/filter, it's max is 255 (256 - 1 for hs) // The FN will split the string on null bytes anyway, so no need to worry about // it on the host side too much. sp_payload[0] = 0; sp_payload[1] = 1; - // Actual payload + sp_payload[2] = hs; memcpy(&sp_payload[3], path_filter, 255); diff --git a/apple2/src/fn_fuji/fuji_read_directory.c b/apple2/src/fn_fuji/fuji_read_directory.c index af8eff5..bfcafc8 100644 --- a/apple2/src/fn_fuji/fuji_read_directory.c +++ b/apple2/src/fn_fuji/fuji_read_directory.c @@ -22,7 +22,7 @@ bool fuji_read_directory(uint8_t maxlen, uint8_t aux2, char *buffer) sp_error = sp_status(sp_fuji_id, 0xF6); if (sp_error == 0) { - strcpy(buffer, sp_payload); + memcpy(buffer, &sp_payload[0], maxlen); } return sp_error == 0; diff --git a/apple2/src/fn_fuji/fuji_set_device_filename.c b/apple2/src/fn_fuji/fuji_set_device_filename.c index 1e5a85a..055423a 100644 --- a/apple2/src/fn_fuji/fuji_set_device_filename.c +++ b/apple2/src/fn_fuji/fuji_set_device_filename.c @@ -15,7 +15,7 @@ bool fuji_set_device_filename(uint8_t mode, uint8_t hs, uint8_t ds, char *buffer return false; } - sp_payload[0] = (filename_len + 2) & 0xFF; + sp_payload[0] = (filename_len + 4) & 0xFF; // 3 params, plus file length + 1 for nul sp_payload[1] = 0; sp_payload[2] = ds; sp_payload[3] = hs; diff --git a/version.txt b/version.txt index 56fea8a..13d683c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.0.0 \ No newline at end of file +3.0.1 \ No newline at end of file