Skip to content

Commit 11edc95

Browse files
shunkitamarkjfisher
authored andcommitted
support multiple smart port card
1 parent b030b8b commit 11edc95

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

apple2/src/bus/sp_init.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ uint8_t read_memory(uint16_t address) {
77
return *((volatile uint8_t *) address);
88
}
99

10+
1011
uint8_t sp_init() {
1112
const uint8_t sp_markers[] = {0x20, 0x00, 0x03, 0x00};
1213
uint16_t base;
1314
uint8_t i;
1415
bool match;
1516
uint8_t offset;
17+
uint8_t fn_device;
18+
uint16_t tmp_addr;
1619

1720
sp_network = 0;
1821

@@ -28,13 +31,20 @@ uint8_t sp_init() {
2831
if (match) {
2932
// If a match is found, calculate the dispatch function address
3033
offset = read_memory(base + 0xFF);
31-
base += offset + 3;
32-
sp_dispatch_fn[0] = base & 0xFF;
33-
sp_dispatch_fn[1] = (base >> 8) & 0xFF;
34+
tmp_addr = base + offset + 3;
35+
sp_dispatch_fn[0] = tmp_addr & 0xFF;
36+
sp_dispatch_fn[1] = (tmp_addr >> 8) & 0xFF;
3437

35-
// now find and return the network id, this will return 0 if not found.
38+
// now find and return the network id.
3639
sp_is_init = 1;
37-
return sp_get_network_id();
40+
41+
fn_device = sp_get_network_id();
42+
if (fn_device != 0) {
43+
return fn_device;
44+
}
45+
else {
46+
sp_is_init = 0;
47+
}
3848
}
3949
}
4050

@@ -43,4 +53,4 @@ uint8_t sp_init() {
4353
sp_dispatch_fn[0] = 0;
4454
sp_dispatch_fn[1] = 0;
4555
return 0;
46-
}
56+
}

0 commit comments

Comments
 (0)