Skip to content

Commit

Permalink
[apple2] 3.0.1 release - Support for CONFIG fuji functions
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Mar 19, 2024
1 parent 7c34b3b commit 1d730cc
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 30 deletions.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions apple2/src/fn_fuji/fuji_close_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
14 changes: 12 additions & 2 deletions apple2/src/fn_fuji/fuji_disable_device.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#include <stdint.h>
#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;
}
14 changes: 12 additions & 2 deletions apple2/src/fn_fuji/fuji_enable_device.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#include <stdint.h>
#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;
}
24 changes: 3 additions & 21 deletions apple2/src/fn_fuji/fuji_get_device_enabled_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions apple2/src/fn_fuji/fuji_mount_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions apple2/src/fn_fuji/fuji_mount_disk_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions apple2/src/fn_fuji/fuji_mount_host_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 1 addition & 2 deletions apple2/src/fn_fuji/fuji_open_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion apple2/src/fn_fuji/fuji_read_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion apple2/src/fn_fuji/fuji_set_device_filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.1

0 comments on commit 1d730cc

Please sign in to comment.