Skip to content

Commit 7d885a9

Browse files
committed
4.7.2 fix apple2 device id detection bug, fix apple2gs clock implementation
1 parent 52a2001 commit 7d885a9

File tree

5 files changed

+44
-21
lines changed

5 files changed

+44
-21
lines changed

Changelog.md

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

33
## [Unreleased]
44

5+
## [4.7.2] - 2024-09-22
6+
7+
- [apple2] fix finding device bug that was breaking network id and not setting correct device id
8+
- [clock apple2gs] fix clock implementation
9+
10+
I moved the apple2gs C code into the apple2 path, and tested apps against it.
11+
Adds 160 bytes to the application vs ASM version, but does produce runnable applications.
12+
This should now work with apple2gs.
13+
514
## [4.7.1] - 2024-09-21
615

716
- [clock] add apple2gs clock implementation (untested)

apple2/apple2-6502/bus/sp_find_device.s

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
.export device_type_id
44
.export device_count
55
.export _device_id_idx
6-
.export tmp_orig_type
76

87
.import _sp_cmdlist
98
.import _sp_init
@@ -35,20 +34,33 @@ sp_find_device:
3534
lda _sp_is_init
3635
bne have_init
3736

38-
; no, so do it now, we first have to save the current type we're searching for, as it gets overwritten searching for network device
37+
; no, so do it now, we first have to save some data about what we're currently searching for, as it gets overwritten searching for network device
3938
lda device_type_id
40-
sta tmp_orig_type
39+
pha
40+
lda id_loc1
41+
pha
42+
lda id_loc1 + 1
43+
pha
4144
jsr _sp_init
42-
bne restore_type
45+
sta tmp1 ; save the result
46+
47+
; restore the data we stashed
48+
pla
49+
sta id_loc1 + 1
50+
sta id_loc2 + 1
51+
pla
52+
sta id_loc1
53+
sta id_loc2
54+
pla
55+
sta device_type_id
56+
57+
lda tmp1 ; restore the result
58+
bne have_init
4359

4460
return_error:
4561
; not found, so return 0 as the network device, and is an error
4662
jmp return0
4763

48-
restore_type:
49-
lda tmp_orig_type
50-
sta device_type_id
51-
5264
have_init:
5365
lda #$00
5466
jsr pusha ; doesn't change A, so can be used to double up as both params
@@ -102,6 +114,8 @@ sp_find_device_type:
102114
sta device_type_id ; the type to search for
103115
stx id_loc1 ; the low location of the address to save the id at
104116
sty id_loc1 + 1 ; the high location of the address to save the id at
117+
stx id_loc2
118+
sty id_loc2 + 1
105119

106120
lda $ffff ; don't use 0000, compiler thinks you want ZP!
107121
id_loc1 = *-2
@@ -114,12 +128,8 @@ id_loc1 = *-2
114128
cmp #$00 ; force status bits for the return
115129
rts
116130

117-
; no ID set, so fetch it, write x/y to the location the id needs to be saved to
118-
: stx id_loc2
119-
sty id_loc2 + 1
120-
121-
jsr sp_find_device
122-
131+
; no ID set, so fetch it
132+
: jsr sp_find_device
123133
beq not_found
124134

125135
; found it from searching, so return the id after setting it
@@ -138,7 +148,9 @@ id_loc2 = *-2
138148
rts
139149

140150
.bss
151+
; the type of the device we are looking for
141152
device_type_id: .res 1
153+
154+
; temp variables
142155
device_count: .res 1
143-
_device_id_idx: .res 1
144-
tmp_orig_type: .res 1
156+
_device_id_idx: .res 1

apple2/apple2gs/fn_clock/clock_get_time.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ uint8_t clock_get_time(uint8_t* tz, TimeFormat format) {
1111
uint8_t result;
1212

1313
sp_get_clock_id();
14+
1415
if (sp_clock_id == 0) return FN_ERR_IO_ERROR;
16+
if (format >= 6) return FN_ERR_BAD_CMD;
1517

16-
result = sp_status(sp_clock_id, 'G');
17-
if (result == 0) return FN_ERR_IO_ERROR;
18+
result = sp_status(sp_clock_id, format_cmds[format]);
19+
if (result != 0) return FN_ERR_IO_ERROR;
1820

1921
memcpy(tz, sp_payload, sp_count);
2022
return FN_ERR_OK;

apple2/apple2gs/fn_clock/clock_get_tz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#include "fujinet-clock.h"
55
#include "fujinet-bus-apple2.h"
66

7-
uint8_t clock_get_tz(uint8_t *tz) {
7+
uint8_t clock_get_tz(char *tz) {
88
uint8_t result;
99

1010
sp_get_clock_id();
1111
if (sp_clock_id == 0) return FN_ERR_IO_ERROR;
1212

1313
result = sp_status(sp_clock_id, 'G');
14-
if (result == 0) return FN_ERR_IO_ERROR;
14+
if (result != 0) return FN_ERR_IO_ERROR;
1515

1616
memcpy(tz, sp_payload, sp_count);
1717
return FN_ERR_OK;

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.7.1
1+
4.7.2

0 commit comments

Comments
 (0)