From 6ef5b5aa8ab544ab4f677aa3bdafa9091fd72909 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Tue, 1 Jul 2025 19:13:29 -0500 Subject: [PATCH 01/13] [adam][fn_fuji] implement fuji_get_host_prefix and fuji_set_host_prefix. --- adam/src/fn_fuji/fuji_get_host_prefix.c | 24 +++++++++++++++++++++++- adam/src/fn_fuji/fuji_set_host_prefix.c | 17 ++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/adam/src/fn_fuji/fuji_get_host_prefix.c b/adam/src/fn_fuji/fuji_get_host_prefix.c index 671e701..4301dc5 100644 --- a/adam/src/fn_fuji/fuji_get_host_prefix.c +++ b/adam/src/fn_fuji/fuji_get_host_prefix.c @@ -1,8 +1,30 @@ #include #include #include "fujinet-fuji.h" +#include +#include + +extern unsigned char response[1024]; bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - return true; + struct _ghp + { + unsigned char cmd; + unsigned char hs; + } ghp; + + memset(response,0,sizeof(response)); + ghp.cmd = 0xE0; + ghp.hs = hs; + + if (eos_write_character_device(0x0f,ghp,sizeof(ghp)) != 0x80) + return false; + + if (eos_read_character_device(0x0f,response,sizeof(response)) != 0x80) + return false; + + strcpy(prefix,response); + + return true; } diff --git a/adam/src/fn_fuji/fuji_set_host_prefix.c b/adam/src/fn_fuji/fuji_set_host_prefix.c index c9edf98..48be6f0 100644 --- a/adam/src/fn_fuji/fuji_set_host_prefix.c +++ b/adam/src/fn_fuji/fuji_set_host_prefix.c @@ -1,8 +1,23 @@ #include #include #include "fujinet-fuji.h" +#include +#include bool fuji_set_host_prefix(uint8_t hs, char *prefix) { - return true; + struct _shp + { + unsigned char cmd; + unsigned char hs; + unsigned char prefix[256]; + } shp; + + shp.cmd = 0xE2; + shp.hs = hs; + strcpy(shp.prefix,prefix); + + eos_write_character_device(0x0f,&shp,sizeof(shp)); + + return true; } From b63ec91c9fb96b65e2e682792ea654347fe124d4 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Tue, 1 Jul 2025 19:28:46 -0500 Subject: [PATCH 02/13] [fujinet-fuji] add FUJICMD_GET_HOST_PREFIX and FUJICMD_SET_HOST_PREFIX. --- fujinet-fuji.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fujinet-fuji.h b/fujinet-fuji.h index 14437d3..1733c92 100644 --- a/fujinet-fuji.h +++ b/fujinet-fuji.h @@ -67,6 +67,8 @@ #define FUJICMD_GET_DIRECTORY_POSITION 0xE5 #define FUJICMD_SET_DIRECTORY_POSITION 0xE4 #define FUJICMD_SET_DEVICE_FULLPATH 0xE2 +#define FUJICMD_SET_HOST_PREFIX 0xE1 +#define FUJICMD_GET_HOST_PREFIX 0xE0 #define FUJICMD_WRITE_APPKEY 0xDE #define FUJICMD_READ_APPKEY 0xDD #define FUJICMD_OPEN_APPKEY 0xDC From b4363fec9fca3bfc3396fbbf1afd0c8c028b4e0e Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Tue, 1 Jul 2025 19:30:39 -0500 Subject: [PATCH 03/13] [apple2][fn_fuji] implement fuji_set_host_prefix.c --- apple2/src/fn_fuji/fuji_set_host_prefix.c | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apple2/src/fn_fuji/fuji_set_host_prefix.c b/apple2/src/fn_fuji/fuji_set_host_prefix.c index d7fe97b..5abb1b7 100644 --- a/apple2/src/fn_fuji/fuji_set_host_prefix.c +++ b/apple2/src/fn_fuji/fuji_set_host_prefix.c @@ -1,8 +1,29 @@ #include +#include #include "fujinet-fuji.h" +#include "fujinet-bus-apple2.h" bool fuji_set_host_prefix(uint8_t hs, char *prefix) { - // Not implemented in A2 - return false; + // Not implemented in A2 + size_t filename_len = strlen(prefix); + if (filename_len >= 254) + { + return false; + } + + sp_error = sp_get_fuji_id(); + if (sp_error <= 0) + { + return false; + } + + sp_payload[0] = (filename_len + 1) & 0xFF; + sp_payload[1] = 0; + sp_payload[2] = hs; + strcpy((char *) &sp_payload[3], prefix); + + sp_error = sp_control(sp_fuji_id, FUJICMD_SET_HOST_PREFIX); + + return sp_error == 0; } From 2dbdbe6e54ede03ca567d0e4230334ab31994dd5 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Tue, 1 Jul 2025 19:32:01 -0500 Subject: [PATCH 04/13] [adam][fn_fuji] change to use constant. --- adam/src/fn_fuji/fuji_set_host_prefix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adam/src/fn_fuji/fuji_set_host_prefix.c b/adam/src/fn_fuji/fuji_set_host_prefix.c index 48be6f0..9a0adad 100644 --- a/adam/src/fn_fuji/fuji_set_host_prefix.c +++ b/adam/src/fn_fuji/fuji_set_host_prefix.c @@ -13,7 +13,7 @@ bool fuji_set_host_prefix(uint8_t hs, char *prefix) unsigned char prefix[256]; } shp; - shp.cmd = 0xE2; + shp.cmd = FUJICMD_SET_HOST_PREFIX; shp.hs = hs; strcpy(shp.prefix,prefix); From 5153a30896acd9cff981eb28c685aaa7da4c6db4 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 13:41:31 -0500 Subject: [PATCH 05/13] [apple2][fn_fuji] implement get_host_prefix, TODO: Implement in firmware. --- apple2/src/fn_fuji/fuji_get_host_prefix.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apple2/src/fn_fuji/fuji_get_host_prefix.c b/apple2/src/fn_fuji/fuji_get_host_prefix.c index 53d9b39..f165f1e 100644 --- a/apple2/src/fn_fuji/fuji_get_host_prefix.c +++ b/apple2/src/fn_fuji/fuji_get_host_prefix.c @@ -1,8 +1,18 @@ #include #include "fujinet-fuji.h" +// A8 to AF are now being allocated as get host prefix for slots 0 to 7. bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - // Not implemented in A2 - return false; + uint8_t stat = ds + 0xA8; + + if (sp_get_fuji_id() == 0) { + return false; + } + + sp_error = sp_status(sp_fuji_id, stat); + if (sp_error == 0) { + memcpy(buffer, &sp_payload[0], 256); + } + return sp_error == 0; } From 213c51f8cb093b5be153cacfa744dbdf6efd613e Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 13:44:46 -0500 Subject: [PATCH 06/13] [apple2][fn_fuji] implement missing includes. --- apple2/src/fn_fuji/fuji_get_host_prefix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apple2/src/fn_fuji/fuji_get_host_prefix.c b/apple2/src/fn_fuji/fuji_get_host_prefix.c index f165f1e..6ed76c0 100644 --- a/apple2/src/fn_fuji/fuji_get_host_prefix.c +++ b/apple2/src/fn_fuji/fuji_get_host_prefix.c @@ -1,5 +1,7 @@ #include +#include #include "fujinet-fuji.h" +#include "fujinet-bus-apple2.h" // A8 to AF are now being allocated as get host prefix for slots 0 to 7. bool fuji_get_host_prefix(uint8_t hs, char *prefix) From a49f6d69b758dd45e15a94c5762f43194c2a5c37 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 13:48:07 -0500 Subject: [PATCH 07/13] [fn_fuji][apple2] i really am dumb. --- apple2/src/fn_fuji/fuji_get_host_prefix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apple2/src/fn_fuji/fuji_get_host_prefix.c b/apple2/src/fn_fuji/fuji_get_host_prefix.c index 6ed76c0..75d3b00 100644 --- a/apple2/src/fn_fuji/fuji_get_host_prefix.c +++ b/apple2/src/fn_fuji/fuji_get_host_prefix.c @@ -6,7 +6,7 @@ // A8 to AF are now being allocated as get host prefix for slots 0 to 7. bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - uint8_t stat = ds + 0xA8; + uint8_t stat = hs + 0xA8; if (sp_get_fuji_id() == 0) { return false; @@ -14,7 +14,7 @@ bool fuji_get_host_prefix(uint8_t hs, char *prefix) sp_error = sp_status(sp_fuji_id, stat); if (sp_error == 0) { - memcpy(buffer, &sp_payload[0], 256); + memcpy(prefix, &sp_payload[0], 256); } return sp_error == 0; } From 0cb6177ce4fcb4244ba8590f07233aae4eb1eb1d Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:04:50 -0500 Subject: [PATCH 08/13] [coco][fn_fuji] implement fuji_set_host_prefix() --- coco/src/fn_fuji/fuji_set_host_prefix.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/coco/src/fn_fuji/fuji_set_host_prefix.c b/coco/src/fn_fuji/fuji_set_host_prefix.c index 22848dc..98f5092 100644 --- a/coco/src/fn_fuji/fuji_set_host_prefix.c +++ b/coco/src/fn_fuji/fuji_set_host_prefix.c @@ -1,9 +1,26 @@ #include #include #include "fujinet-fuji.h" +#include +#include bool fuji_set_host_prefix(uint8_t hs, char *prefix) { - // Not implemented anywhere yet. - return true; + struct _shp + { + uint8_t opcode; + uint8_t cmd; + uint8_t hs; + char filename[256]; + } shp; + + shp.opcode = OP_FUJI; + shp.cmd = FUJICMD_SET_HOST_PREFIX; + shp.hs = hs; + strcpy(shp.filename,prefix); + + bus_ready(); + dwwrite((uint8_t *)&shp, sizeof(shp)); + + return !fuji_get_error(); } From 380a1706993f0dab60f7430fed85eb01d1168274 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:05:16 -0500 Subject: [PATCH 09/13] [coco][fn_fuji] implement fuji_get_host_prefix() --- coco/src/fn_fuji/fuji_get_host_prefix.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/coco/src/fn_fuji/fuji_get_host_prefix.c b/coco/src/fn_fuji/fuji_get_host_prefix.c index 8169430..b5d3b98 100644 --- a/coco/src/fn_fuji/fuji_get_host_prefix.c +++ b/coco/src/fn_fuji/fuji_get_host_prefix.c @@ -1,9 +1,27 @@ #include #include +#include +#include #include "fujinet-fuji.h" bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - // TODO: not implemented in firmware. - return true; + struct _ghp + { + uint8_t opcode; + uint8_t cmd; + uint8_t hs; + } ghp; + + ghp.opcode = OP_FUJI; + ghp.cmd = FUJICMD_GET_HOST_PREFIX; + ghp.hs = hs; + + bus_ready(); + + dwwrite((uint8_t *)&ghp, sizeof(ghp)); + if (fuji_get_error()) + return false; + + return fuji_get_response((uint8_t *)prefix, 256); } From e2362ff71d74291b980148ada1868985ead8f592 Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:14:29 -0500 Subject: [PATCH 10/13] [commodore][fn_fuji] implement fuji_set_host_prefix. --- commodore/src/fn_fuji/fuji_set_host_prefix.c | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/commodore/src/fn_fuji/fuji_set_host_prefix.c b/commodore/src/fn_fuji/fuji_set_host_prefix.c index a31980f..43474f1 100644 --- a/commodore/src/fn_fuji/fuji_set_host_prefix.c +++ b/commodore/src/fn_fuji/fuji_set_host_prefix.c @@ -1,10 +1,29 @@ #include #include +#include +#include #include "fujinet-fuji.h" #include "fujinet-fuji-cbm.h" bool fuji_set_host_prefix(uint8_t hs, char *prefix) { - // Not implemented in IEM fuji firmware - return false; + uint8_t *pl; + uint16_t pl_len; + bool ret; + + pl_len = strlen(prefix) + 3 + 1; // add 1 for the null string terminator, although technically not required as we go by lengths + + pl = malloc(pl_len); + if (pl == NULL) { + status_error(ERROR_MALLOC_FAILED, FUJICMD_SET_DEVICE_FULLPATH); + return false; + } + + pl[0] = hs; + strcpy((char *) &pl[1], prefix); + pl[pl_len - 1] = '\0'; + + ret = open_close_data(FUJICMD_SET_HOST_PREFIX, true, pl_len, pl); + free(pl); + return ret; } From a6c36953b3798f8b894387ebc3341c593ae8cb7f Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:15:36 -0500 Subject: [PATCH 11/13] [commodore][fn_fuji] fuji_set_host_prefix, fix malloc error warning to be correct. --- commodore/src/fn_fuji/fuji_set_host_prefix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commodore/src/fn_fuji/fuji_set_host_prefix.c b/commodore/src/fn_fuji/fuji_set_host_prefix.c index 43474f1..72acec4 100644 --- a/commodore/src/fn_fuji/fuji_set_host_prefix.c +++ b/commodore/src/fn_fuji/fuji_set_host_prefix.c @@ -15,7 +15,7 @@ bool fuji_set_host_prefix(uint8_t hs, char *prefix) pl = malloc(pl_len); if (pl == NULL) { - status_error(ERROR_MALLOC_FAILED, FUJICMD_SET_DEVICE_FULLPATH); + status_error(ERROR_MALLOC_FAILED, FUJICMD_SET_HOST_PREFIX); return false; } From 80934313844ec025d1f5e04a924a75de0e9703bc Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:22:31 -0500 Subject: [PATCH 12/13] [commodore][fn_fuji] implement fuji_get_host_prefix() --- commodore/src/fn_fuji/fuji_get_host_prefix.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/commodore/src/fn_fuji/fuji_get_host_prefix.c b/commodore/src/fn_fuji/fuji_get_host_prefix.c index 2ce31c5..b22af90 100644 --- a/commodore/src/fn_fuji/fuji_get_host_prefix.c +++ b/commodore/src/fn_fuji/fuji_get_host_prefix.c @@ -1,10 +1,26 @@ #include #include +#include +#include #include "fujinet-fuji.h" #include "fujinet-fuji-cbm.h" bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - // not implemented on CBM - return false; + uint8_t *filename; + bool is_success; + int bytes_read; + + filename = malloc(256); + if (filename == NULL) { + return false; + } + memset(filename, 0, 256); + + is_success = open_read_close_data_1(FUJICMD_GET_HOST_PREFIX, &bytes_read, hs, 256, (uint8_t *) filename); + if (is_success) { + strcpy(prefix, (char *)filename); + } + free(filename); + return is_success; } From 10126199aa46469621629c69eaefacf0609d7a1b Mon Sep 17 00:00:00 2001 From: Thomas Cherryhomes Date: Fri, 4 Jul 2025 14:29:54 -0500 Subject: [PATCH 13/13] [pmd85][fn_fuji] implement fuji_get_host_prefix and fuji_set_host_prefix --- pmd85/src/fn_fuji/fuji_get_host_prefix.c | 20 ++++++++++++++++++-- pmd85/src/fn_fuji/fuji_set_host_prefix.c | 22 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/pmd85/src/fn_fuji/fuji_get_host_prefix.c b/pmd85/src/fn_fuji/fuji_get_host_prefix.c index 034e42d..71ec9c9 100644 --- a/pmd85/src/fn_fuji/fuji_get_host_prefix.c +++ b/pmd85/src/fn_fuji/fuji_get_host_prefix.c @@ -2,6 +2,22 @@ bool fuji_get_host_prefix(uint8_t hs, char *prefix) { - // TODO: not implemented in firmware. - return true; + struct _ghp + { + uint8_t opcode; + uint8_t cmd; + uint8_t hs; + } ghp; + + ghp.opcode = OP_FUJI; + ghp.cmd = FUJICMD_GET_HOST_PREFIX; + ghp.hs = hs; + + bus_ready(); + + dwwrite((uint8_t *)&ghp, sizeof(ghp)); + if (fuji_get_error()) + return false; + + return fuji_get_response((uint8_t *)prefix, 256); } diff --git a/pmd85/src/fn_fuji/fuji_set_host_prefix.c b/pmd85/src/fn_fuji/fuji_set_host_prefix.c index 8de7f96..edaa38f 100644 --- a/pmd85/src/fn_fuji/fuji_set_host_prefix.c +++ b/pmd85/src/fn_fuji/fuji_set_host_prefix.c @@ -1,7 +1,25 @@ +#include +#include +#include #include "fujinet-fuji.h" bool fuji_set_host_prefix(uint8_t hs, char *prefix) { - // Not implemented anywhere yet. - return true; + struct _shp + { + uint8_t opcode; + uint8_t cmd; + uint8_t hs; + char filename[256]; + } shp; + + shp.opcode = OP_FUJI; + shp.cmd = FUJICMD_SET_HOST_PREFIX; + shp.hs = hs; + strcpy(shp.filename,prefix); + + bus_ready(); + dwwrite((uint8_t *)&shp, sizeof(shp)); + + return !fuji_get_error(); }