Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion adam/src/fn_fuji/fuji_get_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
#include <stdbool.h>
#include <stdint.h>
#include "fujinet-fuji.h"
#include <eos.h>
#include <string.h>

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));
Copy link
Contributor

@markjfisher markjfisher Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't required anymore, the values are immediately set

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;
}
17 changes: 16 additions & 1 deletion adam/src/fn_fuji/fuji_set_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#include <stdbool.h>
#include <stdint.h>
#include "fujinet-fuji.h"
#include <eos.h>
#include <string.h>

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 = FUJICMD_SET_HOST_PREFIX;
shp.hs = hs;
strcpy(shp.prefix,prefix);

eos_write_character_device(0x0f,&shp,sizeof(shp));

return true;
}
16 changes: 14 additions & 2 deletions apple2/src/fn_fuji/fuji_get_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#include <stdint.h>
#include <string.h>
#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)
{
// Not implemented in A2
return false;
uint8_t stat = hs + 0xA8;

if (sp_get_fuji_id() == 0) {
return false;
}

sp_error = sp_status(sp_fuji_id, stat);
if (sp_error == 0) {
memcpy(prefix, &sp_payload[0], 256);
}
return sp_error == 0;
}
25 changes: 23 additions & 2 deletions apple2/src/fn_fuji/fuji_set_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#include <stdint.h>
#include <string.h>
#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
Copy link
Contributor

@markjfisher markjfisher Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment

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;
}
22 changes: 20 additions & 2 deletions coco/src/fn_fuji/fuji_get_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
#include <cmoc.h>
#include <coco.h>
#include <dw.h>
#include <fujinet-fuji-coco.h>
#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);
}
21 changes: 19 additions & 2 deletions coco/src/fn_fuji/fuji_set_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
#include <cmoc.h>
#include <coco.h>
#include "fujinet-fuji.h"
#include <dw.h>
#include <fujinet-fuji-coco.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();
}
20 changes: 18 additions & 2 deletions commodore/src/fn_fuji/fuji_get_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#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);
Copy link
Contributor

@markjfisher markjfisher Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've avoided using malloc in library. it pulls a huge chunk of cc65 into the application and is much better just using a static array.

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;
}
23 changes: 21 additions & 2 deletions commodore/src/fn_fuji/fuji_set_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#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);
Copy link
Contributor

@markjfisher markjfisher Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto (just trying to tag them all)

if (pl == NULL) {
status_error(ERROR_MALLOC_FAILED, FUJICMD_SET_HOST_PREFIX);
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;
}
2 changes: 2 additions & 0 deletions fujinet-fuji.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions pmd85/src/fn_fuji/fuji_get_host_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
22 changes: 20 additions & 2 deletions pmd85/src/fn_fuji/fuji_set_host_prefix.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#include <dw.h>
#include <fujinet-fuji-pmd85.h>
#include <string.h>
#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();
}