Skip to content

Commit f6a2130

Browse files
committed
Add fn_default_timeout to allow custom timlo setting for atari network/fuji commands
1 parent 5a0e807 commit f6a2130

File tree

9 files changed

+152
-13
lines changed

9 files changed

+152
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ build/
99
Makefile.options
1010

1111
_temp
12+
*.err

Changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
## [Unreleased]
44

5-
## [4.8.0] - 2025-10-29
5+
## [4.8.0] - 2025-10-30
66

77
- [atari] Fix bug in return status being marked ok after extended error 144
8+
- [fuji] Add field for default timeout (fn_default_timeout), only currently useful for atari. sets timlo (which still defaults to $0F). set before doing any network of fuji device command
9+
- [tests] updated unit testing to create minimal setup tests, added tests for above changes
810

911
## [4.7.9] - 2025-09-23
1012

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# Set the TARGETS and PROGRAM values as required.
44
# See makefiles/build.mk for details on directory structure for src files and how to add custom extensions to the build.
55

6-
TARGETS = adam apple2 apple2enh atari c64 coco
7-
TARGETS += msdos
8-
# TARGETS += apple2gs
9-
# TARGETS += pmd85
6+
TARGETS = adam apple2 apple2enh atari c64 coco msdos
107
PROGRAM := fujinet.lib
118

129
SUB_TASKS := clean disk test release unit-test

atari/src/bus/copy_cmd_data.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.export _copy_network_cmd_data
22
.export _copy_fuji_cmd_data
33

4+
.import _fn_default_timeout
5+
46
.include "device.inc"
57
.include "macros.inc"
68
.include "zp.inc"
@@ -30,8 +32,7 @@ common:
3032
mva #$00, IO_DCB::dbuflo
3133
sta IO_DCB::dbufhi
3234

33-
; almost all devices use $0f
34-
mva #$0f, IO_DCB::dtimlo
35+
mva _fn_default_timeout, IO_DCB::dtimlo
3536

3637
; copy bytes of table into DCB
3738
ldy #5 ; 6 bytes to copy
@@ -43,7 +44,6 @@ l1:
4344

4445
rts
4546

46-
4747
.rodata
4848
; which DCB entries to write to, indexed from DDEVIC
4949
; DCOMND, DSTATS, DBYTLO, DBYTHI, DAUX1, DAUX2

common/src/fn_fuji/fn_data.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1+
#ifndef _CMOC_VERSION_
2+
#include <stdint.h>
3+
#else
4+
#include <cmoc.h>
5+
#include <coco.h>
6+
#endif
7+
18
/*
29
* device specific error value, e.g. SmartPort specific errors
310
*/
4-
unsigned char fn_device_error;
11+
uint8_t fn_device_error;
12+
13+
/*
14+
* default timeout for fuji/network commands where supported
15+
*/
16+
17+
uint8_t fn_default_timeout = 15;
518

619

720
// network status values, these come from FujiNet itself, not the host machine.
821

922
/*
1023
* general network error
1124
*/
12-
unsigned char fn_network_error;
25+
uint8_t fn_network_error;
1326

1427
/*
1528
* bytes waiting
1629
*/
17-
unsigned short fn_network_bw;
30+
uint16_t fn_network_bw;
1831

1932
/*
2033
* connection status
2134
*/
22-
unsigned char fn_network_conn;
35+
uint8_t fn_network_conn;
2336

2437
/*
2538
* count of bytes read in last network_read call, so applications can nul terminate as needed.
2639
*/
27-
unsigned short fn_bytes_read;
40+
uint16_t fn_bytes_read;

fujinet-fuji.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,4 +655,11 @@ bool fuji_hash_add(uint8_t *data, uint16_t length);
655655
*/
656656
bool fuji_hash_calculate(hash_alg_t hash_type, bool as_hex, bool discard_data, uint8_t *output);
657657

658+
/**
659+
* @brief The default timeout for fuji commands. Platform dependent on if it does anything.
660+
* The value defaults to 0x0F. No setter. This isn't java.
661+
*/
662+
extern uint8_t fn_default_timeout;
663+
664+
658665
#endif /* FN_FUJI_H */
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/////////////////////////////////////////////////////////////////
2+
marker $$testing _copy_fuji_cmd_data uses default timlo of $0F and device $70$$
3+
/////////////////////////////////////////////////////////////////
4+
5+
memory load atari "${BINARY_PATH}"
6+
symbols load "${SYMBOLS_PATH}"
7+
8+
// clear IO_DCB
9+
memory fill #0x0300~#0x030C 0x00
10+
11+
// write our data to be copied
12+
symbols add cmd_table = 0x1F00
13+
memory write $cmd_table 0x(a0,a1,a2,a3,a4,a5)
14+
15+
// setup the application
16+
run init until CP = $end_setup
17+
18+
// call the function under test, takes parameter of our data table of 6 bytes
19+
registers set A = <$cmd_table
20+
registers set X = >$cmd_table
21+
run $_copy_fuji_cmd_data until false
22+
23+
// check data was written from table area to IO_DCB
24+
assert #0x0300 ~ 0x(70,01,a0,a1,00,00,0f,00,a2,a3,a4,a5,00) $$IO_DCB setup correctly$$
25+
26+
/////////////////////////////////////////////////////////////////
27+
marker $$testing _copy_fuji_cmd_data uses set timlo $69 and device 70$$
28+
/////////////////////////////////////////////////////////////////
29+
30+
memory load atari "${BINARY_PATH}"
31+
symbols load "${SYMBOLS_PATH}"
32+
33+
// clear IO_DCB
34+
memory fill #0x0300~#0x030C 0x00
35+
36+
// write our data to be copied
37+
symbols add cmd_table = 0x1F00
38+
memory write $cmd_table 0x(a0,a1,a2,a3,a4,a5)
39+
memory write $_fn_default_timeout 0x(69)
40+
41+
// setup the application
42+
run init until CP = $end_setup
43+
44+
// call the function under test, takes parameter of our data table of 6 bytes
45+
registers set A = <$cmd_table
46+
registers set X = >$cmd_table
47+
run $_copy_fuji_cmd_data until false
48+
49+
// check data was written from table area to IO_DCB
50+
assert #0x0300 ~ 0x(70,01,a0,a1,00,00,69,00,a2,a3,a4,a5,00) $$IO_DCB setup correctly$$
51+
52+
/////////////////////////////////////////////////////////////////
53+
marker $$testing _copy_network_cmd_data uses default timlo of $0F and device $71$$
54+
/////////////////////////////////////////////////////////////////
55+
56+
memory load atari "${BINARY_PATH}"
57+
symbols load "${SYMBOLS_PATH}"
58+
59+
// clear IO_DCB
60+
memory fill #0x0300~#0x030C 0x00
61+
62+
// write our data to be copied
63+
symbols add cmd_table = 0x1F00
64+
memory write $cmd_table 0x(a0,a1,a2,a3,a4,a5)
65+
66+
// setup the application
67+
run init until CP = $end_setup
68+
69+
// call the function under test, takes parameter of our data table of 6 bytes
70+
registers set A = <$cmd_table
71+
registers set X = >$cmd_table
72+
run $_copy_network_cmd_data until false
73+
74+
// check data was written from table area to IO_DCB
75+
assert #0x0300 ~ 0x(71,00,a0,a1,00,00,0f,00,a2,a3,a4,a5,00) $$IO_DCB setup correctly$$
76+
77+
/////////////////////////////////////////////////////////////////
78+
marker $$testing _copy_network_cmd_data uses set timlo $69 and device $71$$
79+
/////////////////////////////////////////////////////////////////
80+
81+
memory load atari "${BINARY_PATH}"
82+
symbols load "${SYMBOLS_PATH}"
83+
84+
// clear IO_DCB
85+
memory fill #0x0300~#0x030C 0x00
86+
87+
// write our data to be copied
88+
symbols add cmd_table = 0x1F00
89+
memory write $cmd_table 0x(a0,a1,a2,a3,a4,a5)
90+
memory write $_fn_default_timeout 0x(69)
91+
92+
// setup the application
93+
run init until CP = $end_setup
94+
95+
// call the function under test, takes parameter of our data table of 6 bytes
96+
registers set A = <$cmd_table
97+
registers set X = >$cmd_table
98+
run $_copy_network_cmd_data until false
99+
100+
// check data was written from table area to IO_DCB
101+
assert #0x0300 ~ 0x(71,00,a0,a1,00,00,69,00,a2,a3,a4,a5,00) $$IO_DCB setup correctly$$
102+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test bus copy_cmd_data
2+
3+
configs:
4+
- ${UNIT_TEST_DIR}/base_configs/min_sp/base.yaml
5+
6+
src_files:
7+
- ${WS_ROOT}/atari/src/bus/copy_cmd_data.s
8+
- ${WS_ROOT}/common/src/fn_fuji/fn_data.c
9+
10+
test_script: test_copy_cmd_data.txt
11+
12+
asm_include_paths:
13+
- ${WS_ROOT}
14+
- ${WS_ROOT}/atari/src/include
15+
- ${WS_ROOT}/common/inc

testing/unit/base_configs/min_sp/base.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ SEGMENTS {
2323
ZEROPAGE: load = ZP, type = zp;
2424
STARTUP: load = MAIN, type = ro, define = yes;
2525
CODE: load = MAIN, type = ro, define = yes;
26+
DATA: load = MAIN, type = ro, define = yes;
27+
RODATA: load = MAIN, type = ro, define = yes;
2628
BSS: load = MAIN, type = bss, define = yes;
2729
V_RESET: load = V_RST, type = ro, define = yes;
2830
}

0 commit comments

Comments
 (0)