Skip to content

Commit 2a85f1d

Browse files
committed
appkeys signature changes
1 parent 8eefe43 commit 2a85f1d

File tree

80 files changed

+357
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+357
-342
lines changed

Changelog.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
## [Unreleased]
44

5-
## [4.0.0] - 2024-05-06
5+
## [4.1.0] - 2024-05-08
6+
7+
### AppKey Redesign
8+
9+
Appkeys have been redesigned for simpler usecases. There is now only "fuji_appkey_read" and "fuji_appkey_write"
10+
with no need to call open first, this is done for you.
611

7-
Breaking Changes
12+
The mode value has been removed, now a read request specifies in its data structure the key size it wants, the default
13+
being 64 bytes as normal, but now a keysize of 256 is also supported.
14+
15+
Clients must provide a buffer/pointer for the read/write data.
16+
17+
## [4.0.0] - 2024-05-06
818

919
- [appkey] Update signature of appkey functions to return bool instead of uint8_t
1020
- [appkey] Change return values of appkey to indicate SUCCESS status to be consistent with other functions

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,12 @@ LIBS += $(wildcard $(TARGETLIST)/$(SRCDIR)/*.lib)
7878

7979
ASFLAGS += \
8080
--asm-include-dir common/inc \
81-
--asm-include-dir $(TARGETLIST)/$(SRCDIR)/fn_network/inc \
82-
--asm-include-dir $(TARGETLIST)/$(SRCDIR)/fn_fuji/inc \
83-
--asm-include-dir $(TARGETLIST)/$(SRCDIR)/bus/inc \
81+
--asm-include-dir $(TARGETLIST)/$(SRCDIR)/include \
8482
--asm-include-dir .
8583

8684
CFLAGS += \
8785
--include-dir common/inc \
88-
--include-dir $(TARGETLIST)/$(SRCDIR)/fn_network/inc \
89-
--include-dir $(TARGETLIST)/$(SRCDIR)/fn_fuji/inc \
90-
--include-dir $(TARGETLIST)/$(SRCDIR)/bus/inc \
86+
--include-dir $(TARGETLIST)/$(SRCDIR)/include \
9187
--include-dir .
9288

9389
# Add -DBUILD_(TARGET) to all args for the current name. This allows some level of cross platform code

apple2/src/fn_fuji/fuji_appkey_open.c

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include <string.h>
4+
#include "fujinet-fuji.h"
5+
#include "fujinet-bus-apple2.h"
6+
7+
bool fuji_read_appkey(uint16_t creator_id, uint8_t app_id, uint8_t key_id, uint16_t *count, uint8_t *data, enum AppKeySize keysize)
8+
{
9+
uint8_t mode = 0;
10+
uint16_t buffer_size = 64;
11+
12+
sp_error = sp_get_fuji_id();
13+
if (sp_error <= 0) {
14+
return false;
15+
}
16+
17+
if (keysize == SIZE_256) {
18+
mode = 3;
19+
buffer_size = 256;
20+
}
21+
22+
sp_payload[0] = 6;
23+
sp_payload[1] = 0;
24+
sp_payload[2] = creator_id & 0xFF;
25+
sp_payload[3] = (creator_id >> 8) & 0xFF;
26+
sp_payload[4] = app_id;
27+
sp_payload[5] = key_id;
28+
sp_payload[6] = mode;
29+
sp_payload[7] = 0; // reserved
30+
31+
sp_error = sp_control(sp_fuji_id, 0xDC);
32+
if (sp_error != 0) return false;
33+
34+
sp_error = sp_status(sp_fuji_id, 0xDD);
35+
if (sp_error == 0) {
36+
memset(data, 0, buffer_size);
37+
*count = sp_count;
38+
if (sp_count > 0 && sp_count <= buffer_size) {
39+
memcpy(data, &sp_payload[0], sp_count);
40+
}
41+
}
42+
return sp_error == 0;
43+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <stdint.h>
2+
#include <string.h>
3+
#include "fujinet-fuji.h"
4+
#include "fujinet-bus-apple2.h"
5+
6+
bool fuji_write_appkey(uint16_t creator_id, uint8_t app_id, uint8_t key_id, uint16_t count, uint8_t *data)
7+
{
8+
sp_error = sp_get_fuji_id();
9+
if (sp_error != 0) {
10+
return false;
11+
}
12+
13+
sp_payload[0] = 6;
14+
sp_payload[1] = 0;
15+
sp_payload[2] = creator_id & 0xFF;
16+
sp_payload[3] = (creator_id >> 8) & 0xFF;
17+
sp_payload[4] = app_id;
18+
sp_payload[5] = key_id;
19+
sp_payload[6] = 1; // WRITE mode
20+
sp_payload[7] = 0; // reserved
21+
22+
sp_error = sp_control(sp_fuji_id, 0xDC);
23+
if (sp_error != 0) {
24+
return false;
25+
}
26+
27+
sp_payload[0] = count & 0xFF;
28+
sp_payload[1] = (count << 8) & 0xFF;
29+
30+
memcpy(&sp_payload[2], data, count);
31+
32+
sp_error = sp_control(sp_fuji_id, 0xDE);
33+
return sp_error == 0;
34+
}

apple2/src/fn_fuji/fuji_appkey_read.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

apple2/src/fn_fuji/fuji_appkey_write.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

apple2/src/fn_fuji/fuji_copy_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bool fuji_copy_file(uint8_t src_slot, uint8_t dst_slot, char *copy_spec)
1616

1717
sp_payload[2] = src_slot;
1818
sp_payload[3] = dst_slot;
19-
strcpy(&sp_payload[4], copy_spec);
19+
strcpy((char *) &sp_payload[4], copy_spec);
2020

2121
sp_error = sp_control(sp_fuji_id, 0xD8);
2222
return sp_error == 0;
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)