Skip to content

Commit a46f9cd

Browse files
EricCarrGHmarkjfisher
authored andcommitted
Apple2 AppKeys
1 parent 3f15422 commit a46f9cd

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
#include <stdint.h>
2-
#include "fujinet-fuji.h"
2+
#include "../../../fujinet-fuji.h"
3+
#include "../../../fujinet-bus-apple2.h"
34

45
uint8_t fuji_appkey_open(AppKeyOpen *buffer)
56
{
6-
return 0;
7+
sp_error = sp_get_fuji_id();
8+
if (sp_error <= 0) {
9+
return false;
10+
}
11+
12+
sp_payload[0] = 5; // Packet size
13+
sp_payload[1] = 0;
14+
sp_payload[2] = buffer->creator & 0xFF;
15+
sp_payload[3] = (buffer->creator & 0xFF00) >> 8;
16+
sp_payload[4] = buffer->app;
17+
sp_payload[5] = buffer->key;
18+
sp_payload[6] = buffer->mode;
19+
20+
sp_error = sp_control(sp_fuji_id, 0xDC);
21+
return sp_error == 0;
722
}
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
#include <stdint.h>
2-
#include "fujinet-fuji.h"
2+
#include <string.h>
3+
#include "../../../fujinet-fuji.h"
4+
#include "../../../fujinet-bus-apple2.h"
35

46
uint8_t fuji_appkey_read(AppKeyRead *buffer)
57
{
6-
return 0;
8+
sp_error = sp_get_fuji_id();
9+
if (sp_error <= 0) {
10+
return false;
11+
}
12+
13+
sp_error = sp_status(sp_fuji_id, 0xDD);
14+
if (sp_error == 0) {
15+
buffer->length = 0;
16+
if (sp_count>0 && sp_count <= MAX_APPKEY_LEN) {
17+
memcpy(buffer->value, &sp_payload[0], sp_count);
18+
buffer->length = sp_count;
19+
}
20+
}
21+
return sp_error == 0;
722
}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
#include <stdint.h>
2-
#include "fujinet-fuji.h"
2+
#include "../../../fujinet-fuji.h"
3+
#include "../../../fujinet-bus-apple2.h"
4+
#include <string.h>
35

46
uint8_t fuji_appkey_write(uint16_t count, AppKeyWrite *buffer)
57
{
6-
return 0;
8+
sp_error = sp_get_fuji_id();
9+
10+
if (sp_error <= 0) {
11+
return false;
12+
}
13+
14+
sp_payload[0] = 64;
15+
sp_payload[1] = 0;
16+
17+
// Sticking with a 64 payload size. Can we use smaller?
18+
memset(&sp_payload[2], 0, 64);
19+
20+
if (count>MAX_APPKEY_LEN)
21+
count = MAX_APPKEY_LEN;
22+
23+
memcpy(&sp_payload[2], buffer, count);
24+
25+
sp_error = sp_control(sp_fuji_id, 0xDE);
26+
return sp_error == 0;
727
}

0 commit comments

Comments
 (0)