Skip to content

Commit

Permalink
4.7.2 fix apple2 device id detection bug, fix apple2gs clock implemen…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
markjfisher committed Sep 22, 2024
1 parent 52a2001 commit 7d885a9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

## [4.7.2] - 2024-09-22

- [apple2] fix finding device bug that was breaking network id and not setting correct device id
- [clock apple2gs] fix clock implementation

I moved the apple2gs C code into the apple2 path, and tested apps against it.
Adds 160 bytes to the application vs ASM version, but does produce runnable applications.
This should now work with apple2gs.

## [4.7.1] - 2024-09-21

- [clock] add apple2gs clock implementation (untested)
Expand Down
44 changes: 28 additions & 16 deletions apple2/apple2-6502/bus/sp_find_device.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.export device_type_id
.export device_count
.export _device_id_idx
.export tmp_orig_type

.import _sp_cmdlist
.import _sp_init
Expand Down Expand Up @@ -35,20 +34,33 @@ sp_find_device:
lda _sp_is_init
bne have_init

; 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
; 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
lda device_type_id
sta tmp_orig_type
pha
lda id_loc1
pha
lda id_loc1 + 1
pha
jsr _sp_init
bne restore_type
sta tmp1 ; save the result

; restore the data we stashed
pla
sta id_loc1 + 1
sta id_loc2 + 1
pla
sta id_loc1
sta id_loc2
pla
sta device_type_id

lda tmp1 ; restore the result
bne have_init

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

restore_type:
lda tmp_orig_type
sta device_type_id

have_init:
lda #$00
jsr pusha ; doesn't change A, so can be used to double up as both params
Expand Down Expand Up @@ -102,6 +114,8 @@ sp_find_device_type:
sta device_type_id ; the type to search for
stx id_loc1 ; the low location of the address to save the id at
sty id_loc1 + 1 ; the high location of the address to save the id at
stx id_loc2
sty id_loc2 + 1

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

; no ID set, so fetch it, write x/y to the location the id needs to be saved to
: stx id_loc2
sty id_loc2 + 1

jsr sp_find_device

; no ID set, so fetch it
: jsr sp_find_device
beq not_found

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

.bss
; the type of the device we are looking for
device_type_id: .res 1

; temp variables
device_count: .res 1
_device_id_idx: .res 1
tmp_orig_type: .res 1
_device_id_idx: .res 1
6 changes: 4 additions & 2 deletions apple2/apple2gs/fn_clock/clock_get_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ uint8_t clock_get_time(uint8_t* tz, TimeFormat format) {
uint8_t result;

sp_get_clock_id();

if (sp_clock_id == 0) return FN_ERR_IO_ERROR;
if (format >= 6) return FN_ERR_BAD_CMD;

result = sp_status(sp_clock_id, 'G');
if (result == 0) return FN_ERR_IO_ERROR;
result = sp_status(sp_clock_id, format_cmds[format]);
if (result != 0) return FN_ERR_IO_ERROR;

memcpy(tz, sp_payload, sp_count);
return FN_ERR_OK;
Expand Down
4 changes: 2 additions & 2 deletions apple2/apple2gs/fn_clock/clock_get_tz.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "fujinet-clock.h"
#include "fujinet-bus-apple2.h"

uint8_t clock_get_tz(uint8_t *tz) {
uint8_t clock_get_tz(char *tz) {
uint8_t result;

sp_get_clock_id();
if (sp_clock_id == 0) return FN_ERR_IO_ERROR;

result = sp_status(sp_clock_id, 'G');
if (result == 0) return FN_ERR_IO_ERROR;
if (result != 0) return FN_ERR_IO_ERROR;

memcpy(tz, sp_payload, sp_count);
return FN_ERR_OK;
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.7.1
4.7.2

0 comments on commit 7d885a9

Please sign in to comment.