Skip to content

Commit 1f2ed3b

Browse files
committed
4.1.0 appkey and apple2 changes
1 parent 2a85f1d commit 1f2ed3b

Some content is hidden

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

69 files changed

+610
-811
lines changed

Changelog.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@
22

33
## [Unreleased]
44

5-
## [4.1.0] - 2024-05-08
5+
## [4.1.0] - 2024-05-12
66

7-
### AppKey Redesign
7+
### AppKeys Changes
88

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.
9+
Appkeys have been redesigned for simpler usecases.
10+
Using appkeys now involves first calling `fuji_set_appkey_details` to define the creator, appid, and key size.
1111

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.
12+
Then you call either "fuji_appkey_read" and "fuji_appkey_write".
13+
The old "open" phase is done internally by the API and not exposed.
1414

15-
Clients must provide a buffer/pointer for the read/write data.
15+
Clients must provide a pointer for the read/write data buffer to read from and write to.
16+
All structs have been removed in preference of calling functions with parameters directly.
17+
18+
There is a paramter for the appkey size, which is a placeholder for future changes to support larger key sizes
19+
than just 64 bytes.
20+
21+
### [apple2] Asm to C
22+
23+
I've replaced most of the SmartPort asm bus code with C versions.
24+
25+
This makes it way easier to support. The ASM was getting quite tricky to follow, and I wrote the bloody thing.
26+
The only one that shouldn't change to C is sp_dispatch, as it uses self modifying code techniques.
1627

1728
## [4.0.0] - 2024-05-06
1829

apple2/src/bus/sp_close.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdint.h>
2+
#include <stdbool.h>
3+
#include "fujinet-fuji.h"
4+
#include "fujinet-bus-apple2.h"
5+
6+
int8_t sp_close(uint8_t dest) {
7+
sp_cmdlist[1] = dest;
8+
sp_cmdlist[0] = SP_CLOSE_PARAM_COUNT;
9+
return sp_dispatch(SP_CMD_CLOSE);
10+
}

apple2/src/bus/sp_close.s

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

apple2/src/bus/sp_control.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdint.h>
2+
#include "fujinet-fuji.h"
3+
#include "fujinet-bus-apple2.h"
4+
5+
int8_t sp_control(uint8_t dest, uint8_t ctrlcode) {
6+
uintptr_t payload_address;
7+
8+
sp_cmdlist[4] = ctrlcode;
9+
10+
sp_cmdlist[0] = SP_STATUS_PARAM_COUNT;
11+
sp_cmdlist[1] = dest;
12+
13+
payload_address = (uintptr_t)(&sp_payload[0]);
14+
sp_cmdlist[2] = payload_address & 0xFF;
15+
sp_cmdlist[3] = (payload_address >> 8) & 0xFF;
16+
17+
return sp_dispatch(SP_CMD_CONTROL);
18+
}

apple2/src/bus/sp_control.s

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

apple2/src/bus/sp_dispatch.s

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
.export _sp_dispatch
22

3+
.import _sp_count
4+
.import _sp_cmdlist
35
.import _sp_dispatch_fn
4-
.import popa
6+
.import _sp_error
57

6-
; int8_t sp_dispatch(uint8_t cmd, void *cmdlist)
8+
; KEEP THIS FILE AS ASM AS IT DOES TRICKS WITH DATA AND INDIRECT CALLS TO DISPATCH FUNCTION
9+
10+
; int8_t sp_dispatch(uint8_t cmd)
711
;
812
; returns any error code from the smart port _sp_dispatch function
913
.proc _sp_dispatch
10-
sta dispatch_data+1 ; cmdlist low
11-
stx dispatch_data+2 ; cmdlist high
12-
13-
jsr popa ; cmd
1414
sta dispatch_data
15-
15+
lda #<_sp_cmdlist
16+
sta dispatch_data+1
17+
lda #>_sp_cmdlist
18+
sta dispatch_data+2
19+
20+
; the SP dispatch alters the return address by 3 bytes to skip the data below.
21+
; it returs with any error codes
1622
jsr do_jmp
23+
1724
dispatch_data:
1825
.byte $00 ; command
1926
.byte $00 ; cmdlist low
2027
.byte $00 ; cmdlist high
2128

29+
; A is error code. X,Y are the count of bytes
30+
sta _sp_error
31+
stx _sp_count
32+
sty _sp_count+1
33+
34+
; convert to a return value
35+
ldx #$00
36+
lda _sp_error
2237
rts
2338

2439
do_jmp:

apple2/src/bus/sp_find_clock.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdint.h>
2+
#include <stdbool.h>
3+
#include "fujinet-fuji.h"
4+
#include "fujinet-bus-apple2.h"
5+
6+
uint8_t sp_clock_id = 0;
7+
8+
bool sp_find_clock() {
9+
int r = sp_find_device("FN_CLOCK");
10+
if (r <= 0) {
11+
sp_clock_id = 0;
12+
return false;
13+
}
14+
sp_clock_id = (uint8_t) (r & 0xFF);
15+
return true;
16+
}
17+
18+
uint8_t sp_get_clock_id()
19+
{
20+
if (sp_clock_id != 0) {
21+
return sp_clock_id;
22+
}
23+
24+
sp_find_clock();
25+
return sp_clock_id;
26+
}

apple2/src/bus/sp_find_clock.s

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

apple2/src/bus/sp_find_cpm.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdint.h>
2+
#include <stdbool.h>
3+
#include "fujinet-fuji.h"
4+
#include "fujinet-bus-apple2.h"
5+
6+
uint8_t sp_cpm_id = 0;
7+
8+
bool sp_find_cpm() {
9+
int r = sp_find_device("CPM");
10+
if (r <= 0) {
11+
sp_cpm_id = 0;
12+
return false;
13+
}
14+
sp_cpm_id = (uint8_t) (r & 0xFF);
15+
return true;
16+
}
17+
18+
uint8_t sp_get_cpm_id()
19+
{
20+
if (sp_cpm_id != 0) {
21+
return sp_cpm_id;
22+
}
23+
24+
sp_find_cpm();
25+
return sp_cpm_id;
26+
}

apple2/src/bus/sp_find_cpm.s

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

0 commit comments

Comments
 (0)