Skip to content

Commit

Permalink
3.0.3 [apple2] fix bug in Y reg trashed by popax breaking apple2enh
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Apr 2, 2024
1 parent bf6858b commit c84920c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 32 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

## [3.0.3] - 2024-04-02

Bugfix release:

- [apple2] fix network_status on apple2enh by setting y specifically
- replaced BUILD_APPLE2 and BUILD_ATARI in favour of cc65 macros __APPLE2__ and __ATARI__

## [3.0.2] - 2024-03-24

This should be considered the BASE 3 release.
Expand Down
5 changes: 3 additions & 2 deletions apple2/src/fn_network/network_status.s
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,20 @@ have_network:
jsr _sp_status
pha ; save the error until we've dealt with the function args

ldy #$00

; process the device error
lda _sp_payload+3
ldy #$00
sta (ptr4), y ; *err = sp_payload[3]

; process the connection status param
popax ptr4
lda _sp_payload+2
ldy #$00 ; popax destroys y, so reset it
sta (ptr4), y ; *c = sp_payload[2]

; process the bytes waiting (bw) param
popax ptr4
ldy #$00
mway _sp_payload, {(ptr4), y}

; remove the devicespec parameter from stack, it isn't used
Expand Down
4 changes: 2 additions & 2 deletions common/src/network_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "../../fujinet-network.h"

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
#include "fujinet-bus-apple2.h"
#include "apple2/src/bus/inc/sp.h"
#endif
Expand All @@ -12,7 +12,7 @@ uint8_t network_init()
{
int8_t err = 0;

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
err = sp_init();
if (err == 0) {
return FN_ERR_NO_DEVICE;
Expand Down
24 changes: 12 additions & 12 deletions common/src/network_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include "fujinet-network.h"

#ifdef BUILD_ATARI
#ifdef __ATARI__
#include "fujinet-network-atari.h"
#include "fujinet-bus-atari.h"
#endif

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
#include "fujinet-network-apple2.h"
#include "fujinet-bus-apple2.h"
#include "apple2/src/bus/inc/sp.h"
Expand All @@ -27,20 +27,20 @@ int16_t network_read(char *devicespec, uint8_t *buf, uint16_t len)
uint16_t fetch_size = 0;
uint16_t amount_left = len;
uint16_t total_read = 0;
#ifdef BUILD_ATARI
#ifdef __ATARI__
uint8_t unit = 0;
#endif

if (len == 0 || buf == NULL) {
#ifdef BUILD_ATARI
#ifdef __ATARI__
return fn_error(132); // invalid command
#endif
#ifdef BUILD_APPLE2
#ifdef __APPLE2__
return fn_error(SP_ERR_BAD_CMD);
#endif
}

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
// check we have the SP network value
if (sp_network == 0) {
return fn_error(SP_ERR_BAD_UNIT);
Expand All @@ -50,18 +50,18 @@ int16_t network_read(char *devicespec, uint8_t *buf, uint16_t len)
fn_bytes_read = 0;
fn_device_error = 0;

#ifdef BUILD_ATARI
#ifdef __ATARI__
unit = network_unit(devicespec);
#endif

while (1) {
// exit condition
if (amount_left == 0) break;

#ifdef BUILD_ATARI
#ifdef __ATARI__
r = network_status_unit(unit, &fn_network_bw, &fn_network_conn, &fn_network_error);
#endif
#ifdef BUILD_APPLE2
#ifdef __APPLE2__
r = network_status_no_clr(devicespec, &fn_network_bw, &fn_network_conn, &fn_network_error);
#endif

Expand All @@ -79,16 +79,16 @@ int16_t network_read(char *devicespec, uint8_t *buf, uint16_t len)

fetch_size = MIN(amount_left, fn_network_bw);

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
// need to validate this is only required for apple
fetch_size = MIN(fetch_size, MAX_READ_SIZE);
#endif

#ifdef BUILD_ATARI
#ifdef __ATARI__
sio_read(unit, buf, fetch_size);
#endif

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
sp_read(sp_network, fetch_size);
memcpy(buf, sp_payload, fetch_size);
#endif
Expand Down
24 changes: 12 additions & 12 deletions common/src/network_read_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#include "fujinet-network.h"

#ifdef BUILD_ATARI
#ifdef __ATARI__
#include "fujinet-network-atari.h"
#include "fujinet-bus-atari.h"
#endif

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
#include "fujinet-network-apple2.h"
#include "fujinet-bus-apple2.h"
#include "apple2/src/bus/inc/sp.h"
Expand All @@ -26,20 +26,20 @@ int16_t network_read_nb(char *devicespec, uint8_t *buf, uint16_t len)
{
uint8_t r = 0;
uint16_t fetch_size = 0;
#ifdef BUILD_ATARI
#ifdef __ATARI__
uint8_t unit = 0;
#endif

if (len == 0 || buf == NULL) {
#ifdef BUILD_ATARI
#ifdef __ATARI__
return -fn_error(132); // invalid command
#endif
#ifdef BUILD_APPLE2
#ifdef __APPLE2__
return -fn_error(SP_ERR_BAD_CMD);
#endif
}

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
// check we have the SP network value
if (sp_network == 0) {
return -fn_error(SP_ERR_BAD_UNIT);
Expand All @@ -49,14 +49,14 @@ int16_t network_read_nb(char *devicespec, uint8_t *buf, uint16_t len)
fn_bytes_read = 0;
fn_device_error = 0;

#ifdef BUILD_ATARI
#ifdef __ATARI__
unit = network_unit(devicespec);
#endif

#ifdef BUILD_ATARI
#ifdef __ATARI__
r = network_status_unit(unit, &fn_network_bw, &fn_network_conn, &fn_network_error);
#endif
#ifdef BUILD_APPLE2
#ifdef __APPLE2__
r = network_status_no_clr(devicespec, &fn_network_bw, &fn_network_conn, &fn_network_error);
#endif
// check if the status failed
Expand All @@ -72,16 +72,16 @@ int16_t network_read_nb(char *devicespec, uint8_t *buf, uint16_t len)

fetch_size = MIN(len, fn_network_bw);

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
// need to validate this is only required for apple
fetch_size = MIN(fetch_size, MAX_READ_SIZE);
#endif

#ifdef BUILD_ATARI
#ifdef __ATARI__
sio_read(unit, buf, fetch_size);
#endif

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
sp_read(sp_network, fetch_size);
memcpy(buf, sp_payload, fetch_size);
#endif
Expand Down
6 changes: 3 additions & 3 deletions fujinet-fuji.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct {

// Disks have different structures / parameters

#ifdef BUILD_ATARI
#ifdef __ATARI__
typedef struct
{
uint16_t numSectors;
Expand All @@ -87,7 +87,7 @@ typedef struct
} NewDisk;
#endif

#ifdef BUILD_APPLE2
#ifdef __APPLE2__
typedef struct
{
uint8_t hostSlot;
Expand Down Expand Up @@ -328,7 +328,7 @@ bool fuji_set_device_filename(uint8_t mode, uint8_t hs, uint8_t ds, char *buffer
*/
bool fuji_set_directory_position(uint16_t pos);

#ifdef BUILD_ATARI
#ifdef __ATARI__
/*
* Fetch the current HSIO index value.
* @return success status of request
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2
3.0.3

0 comments on commit c84920c

Please # to comment.