Skip to content

Commit 0dffbd3

Browse files
committed
4.1.1 [apple2] Fix critical bug in sp_read causing it to do open instead
1 parent e3a37c9 commit 0dffbd3

File tree

7 files changed

+51
-92
lines changed

7 files changed

+51
-92
lines changed

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
## [Unreleased]
44

5+
## [4.1.1] - 2024-05-14
6+
57
- Enhance build to produce target specific versions of the library, e.g. apple2enh from apple2 src.
68
The appkey application was failing in apple2enh without the specific version of the library.
79

10+
- [apple2] convert network_open src from asm to c
11+
12+
Bugfix:
13+
14+
- [apple] sp_read was incorrectly calling sp_open :scream:
15+
816
## [4.1.0] - 2024-05-12
917

1018
### AppKeys Changes

apple2/src/bus/sp_read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ int8_t sp_read(uint8_t dest, uint16_t len) {
1515
sp_cmdlist[2] = payload_address & 0xFF;
1616
sp_cmdlist[3] = (payload_address >> 8) & 0xFF;
1717

18-
return sp_dispatch(SP_CMD_OPEN);
18+
return sp_dispatch(SP_CMD_READ);
1919
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <stdint.h>
2+
#include <string.h>
3+
#include "fujinet-network.h"
4+
#include "fujinet-bus-apple2.h"
5+
6+
uint8_t network_open(char* devicespec, uint8_t mode, uint8_t trans) {
7+
uint8_t nw_device;
8+
uint16_t slen;
9+
uint16_t payload_len;
10+
11+
// clear any errors
12+
fn_error(0);
13+
14+
if (sp_is_init == 0) {
15+
nw_device = sp_init();
16+
if (nw_device == 0) {
17+
return fn_error(SP_ERR_IO_ERROR);
18+
}
19+
}
20+
21+
if (sp_open(sp_network) != 0) {
22+
return fn_error(SP_ERR_IO_ERROR);
23+
}
24+
25+
sp_clr_payload();
26+
slen = strlen(devicespec);
27+
payload_len = slen + 3; // 2 for extra control bytes, 1 for NUL string terminator
28+
sp_payload[0] = payload_len & 0xFF;
29+
sp_payload[1] = (payload_len >> 8) & 0xFF;
30+
sp_payload[2] = mode;
31+
sp_payload[3] = trans;
32+
33+
strncpy(&sp_payload[4], devicespec, slen);
34+
return sp_control(sp_network, 'O');
35+
}

apple2/src/fn_network/network_open.s

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

apple2/src/include/fujinet-bus-apple2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void sp_clr_payload();
8282
int8_t sp_status(uint8_t dest, uint8_t statcode);
8383
int8_t sp_control(uint8_t dest, uint8_t ctrlcode);
8484
int8_t sp_read(uint8_t dest, uint16_t len);
85+
int8_t sp_open(uint8_t dest);
8586

8687
// initilises the dispatch funciton and returns the network device id if found, else returns 0.
8788
uint8_t sp_init();

fujinet-network.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ extern uint16_t fn_bytes_read;
3333
*/
3434
extern uint8_t fn_device_error;
3535

36+
/**
37+
* Convert device specific error in code to FujiNet Network library error, agnostic of device.
38+
* Library code calls this when it encounters an error to return value applications should use.
39+
*/
3640
uint8_t fn_error(uint8_t code);
41+
3742
/*
3843
* Network status values. These are set during network_read. You can capture your own using network_status.
3944
* bw : bytes waiting

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.0
1+
4.1.1

0 commit comments

Comments
 (0)