Skip to content

Commit 5a0e807

Browse files
committed
Fix _bus_status return code on 144 error. Refactor unit tests
1 parent 8c493d1 commit 5a0e807

32 files changed

+278
-37
lines changed

Changelog.md

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

33
## [Unreleased]
44

5+
## [4.8.0] - 2025-10-29
6+
7+
- [atari] Fix bug in return status being marked ok after extended error 144
8+
59
## [4.7.9] - 2025-09-23
610

711
- [coco] CoCo: Fix fuji_set_directory_position (#41) [Rich Stephens]

atari/src/bus/bus_status.s

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.include "macros.inc"
1515
.include "zp.inc"
1616

17-
; uint8_t io_status(uint8_t unit)
17+
; uint8_t bus_status(uint8_t unit)
1818
;
1919
; unit is only used when dstats is equal to DERROR (144) for extended information
2020
.proc _bus_status
@@ -24,12 +24,17 @@
2424
lda IO_DCB::dstats
2525
cmp #DERROR
2626
beq @extended
27+
@exit:
2728
jmp _fn_error
2829

2930
@extended:
3031
pusha tmp8 ; unit
3132
pushax #_fn_network_bw ; bytes waiting location
3233
pushax #_fn_network_conn ; connection status
3334
setax #_fn_network_error ; network error
34-
jmp _network_status_unit
35+
jsr _network_status_unit ; fill in the status bytes into memory locations given
36+
37+
; we must restore the ERROR code from the original call, not leave ourselves with the network_status result code, which is "OK" and makes an extended error look like it didn't fail
38+
lda #DERROR
39+
bne @exit ; always
3540
.endproc

network_http_set_channel_mode.err

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msdos/src/fn_network/network_http_set_channel_mode.c(8): Warning! W131: No prototype found for function 'int_f5'

network_read.err

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
common/src/fn_network/network_read.c(154): Warning! W102: Parameter 1: Type mismatch (warning)
2+
common/src/fn_network/network_read.c(154): Note! I2003: source conversion type is 'unsigned char'
3+
common/src/fn_network/network_read.c(154): Note! I2004: target conversion type is 'char const *'

testing/unit/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# running unit tests
22

3+
Unit tests are a work in progress and use the soft65c02 project with extensions.
4+
5+
The repo for installing the unit test framework is https://github.com/markjfisher/soft65c02/tree/soft65c02_unit
6+
7+
8+
39
## running individual tests
410

511
```bash
@@ -16,4 +22,5 @@ make unit-test
1622

1723
## creating unit tests
1824

19-
Unit tests go in `testing/unit/tests`
25+
Unit tests go in `testing/unit/<platform>/<device>/<function>/`
26+

testing/unit/apple2/fn_clock/clock_get_time/test_clock_get_time.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: test fn_clock clock_get_time
22

33
configs:
4-
- ${UNIT_TEST_DIR}/base_configs/base_test_apple2.yaml
4+
- ${UNIT_TEST_DIR}/base_configs/apple2/base.yaml
55

66
src_files:
77
- ${WS_ROOT}/apple2/apple2-6502/fn_clock/clock_get_time.s

testing/unit/apple2/fn_clock/clock_get_time_tz/test_clock_get_time_tz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: test fn_clock clock_get_time_tz
22

33
configs:
4-
- ${UNIT_TEST_DIR}/base_configs/base_test_apple2.yaml
4+
- ${UNIT_TEST_DIR}/base_configs/apple2/base.yaml
55

66
src_files:
77
- ${WS_ROOT}/apple2/apple2-6502/fn_clock/clock_get_time.s

testing/unit/apple2/fn_clock/clock_set_tz/test_clock_set_tz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: test fn_clock clock_set_tz
22

33
configs:
4-
- ${UNIT_TEST_DIR}/base_configs/base_test_apple2.yaml
4+
- ${UNIT_TEST_DIR}/base_configs/apple2/base.yaml
55

66
src_files:
77
- ${WS_ROOT}/apple2/apple2-6502/fn_clock/clock_set_tz.s
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/////////////////////////////////////////////////////////////////
2+
marker $$testing bus_status when DSTATS is 0$$
3+
/////////////////////////////////////////////////////////////////
4+
5+
memory load atari "${BINARY_PATH}"
6+
symbols load "${SYMBOLS_PATH}"
7+
8+
// initialise state
9+
memory write $nw_status_was_called 0x(0)
10+
// set DSTATS to 0
11+
memory write #0x0303 0x(0)
12+
13+
// setup the application
14+
run init until CP = $end_setup
15+
16+
// call the function under test
17+
registers set A = 1
18+
run $_bus_status until false
19+
20+
assert $nw_status_was_called = 0 $$validate network_status_unit was not called for DSTATS=0$$
21+
assert $_fn_device_error = 0 $$check fn_device_error matches DSTATS$$
22+
assert A = 1 $$return result is FN_ERR_IO_ERROR (1)$$
23+
24+
/////////////////////////////////////////////////////////////////
25+
marker $$testing bus_status when DSTATS is 1$$
26+
/////////////////////////////////////////////////////////////////
27+
28+
memory load atari "${BINARY_PATH}"
29+
symbols load "${SYMBOLS_PATH}"
30+
31+
// initialise state
32+
memory write $nw_status_was_called 0x(0)
33+
// set DSTATS to 1
34+
memory write #0x0303 0x(1)
35+
36+
// setup the application
37+
run init until CP = $end_setup
38+
39+
// call the function under test
40+
registers set A = 1
41+
run $_bus_status until false
42+
43+
assert $nw_status_was_called = 0 $$validate network_status_unit was not called for DSTATS=1$$
44+
assert $_fn_device_error = 1 $$check fn_device_error matches DSTATS$$
45+
assert A = 0 $$return result is FN_ERR_OK (0)$$
46+
47+
/////////////////////////////////////////////////////////////////
48+
marker $$testing bus_status when DSTATS is 144$$
49+
/////////////////////////////////////////////////////////////////
50+
51+
memory load atari "${BINARY_PATH}"
52+
symbols load "${SYMBOLS_PATH}"
53+
54+
// initialise state
55+
memory write $nw_status_was_called 0x(0)
56+
// set DSTATS to 144
57+
memory write #0x0303 0x(90)
58+
59+
// setup the application
60+
run init until CP = $end_setup
61+
62+
// call the function under test
63+
registers set A = 1
64+
run $_bus_status until false
65+
66+
assert $nw_status_was_called = 1 $$validate network_status_unit was called for DSTATS=144$$
67+
assert $_fn_device_error = 144 $$check fn_device_error matches DSTATS$$
68+
// this was the bug in _bus_status
69+
assert A = 1 $$return result is FN_ERR_IO_ERROR (1)$$
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: test bus bus_status
2+
3+
configs:
4+
- ${UNIT_TEST_DIR}/base_configs/min_sp/base.yaml
5+
6+
src_files:
7+
- ${WS_ROOT}/atari/src/bus/bus_status.s
8+
- ${WS_ROOT}/common/src/fn_fuji/fn_data.c
9+
- ${WS_ROOT}/atari/src/bus/fn_error.s
10+
- ${WS_ROOT}/atari/src/fn_fuji/fuji_error.s
11+
- ${UNIT_TEST_DIR}/atari/mocks/network_status_unit.s
12+
13+
test_script: test_bus_status.txt
14+
15+
asm_include_paths:
16+
- ${WS_ROOT}
17+
- ${WS_ROOT}/atari/src/include
18+
- ${WS_ROOT}/common/inc

0 commit comments

Comments
 (0)