Skip to content

Commit b834b9b

Browse files
committed
[atari] Fix return code for clock_get_time/tz
1 parent e8950c1 commit b834b9b

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
lines changed

atari/src/bus/fn_error.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
; and returns 0/false (by design FN_ERR_OK), or 1/true (by design FN_ERR_IO_ERROR)
1818
; which are inverted but correct. Most functions return the success status (0 = false = error), but we flip that into FN_ERR_OK/FN_ERR_IO_ERROR
1919

20+
; THIS RETURNS FN_ERR_* VALUES, NOT BOOLEANS (although it only returns FN_ERR_OK and FN_ERR_IO_ERROR at the moment)
2021
.proc _fn_error
2122
sta _fn_device_error
23+
; this is utilising the common code in fuji_error, which returns booleans which match our FN_ERR_OK or FN_ERR_IO_ERROR codes
24+
; because fuji_error returns the "is error" boolean, true meaning there was an error, and its value is 1
2225
jmp fuji_error_cmp
2326
.endproc

atari/src/fn_clock/clock_get_time.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ aux1_val = *-1
8686
stx IO_DCB::daux1
8787

8888
jsr _bus
89+
lda IO_DCB::dstats
8990
jmp _fn_error
9091

9192
.rodata

testing/unit/atari/fn_clock/clock_get_time/test_clock_get_time.s

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313
.export t5_end
1414
.export t6
1515
.export t6_end
16+
.export t7
17+
.export t7_end
1618
.export output_buffer
19+
.export dstats_called_with
20+
.export return_err
1721

1822
.export _bus
1923
.export _clock_set_alternate_tz
20-
.export _fn_error
24+
.export _fn_device_error
2125

26+
.import _fn_error
2227
.import _clock_get_time
2328

2429
.import pushax
@@ -30,6 +35,7 @@
3035
.code
3136
_main:
3237

38+
mva #$01, return_err
3339
mwa #clock0, clock_ptr
3440
pushax #output_buffer
3541
lda #0
@@ -77,6 +83,15 @@ t6:
7783
jsr _clock_get_time
7884
t6_end:
7985

86+
; emulate a bus error
87+
mva #$80, return_err
88+
lda #$00
89+
t7:
90+
jsr _clock_get_time
91+
t7_end:
92+
93+
94+
8095
rts
8196

8297
; mocks
@@ -85,6 +100,7 @@ _bus:
85100
; clock_ptr points to the correct return data
86101
mwa clock_ptr, ptr1
87102
mwa IO_DCB::dbuflo, ptr2
103+
mva IO_DCB::dstats, dstats_called_with
88104

89105
ldy #$00 ; size to copy, e.g. 6
90106
: mva {(ptr1), y}, {(ptr2), y}
@@ -95,18 +111,24 @@ _bus:
95111
; add a zero to finish the buffer off
96112
lda #$00
97113
sta (ptr2), y
98-
rts
99114

100-
_fn_error:
115+
; return the custom error via dstats
116+
mva return_err, IO_DCB::dstats
101117
rts
102118

103119
_clock_set_alternate_tz:
104120
rts
105121

106122
.bss
107123

108-
clock_ptr: .res 2
109-
output_buffer: .res 31
124+
clock_ptr: .res 2
125+
output_buffer: .res 31
126+
_fn_device_error: .res 1
127+
dstats_called_with: .res 1
128+
129+
.data
130+
; return value for fn_error
131+
return_err: .byte 0
110132

111133
.rodata
112134
clock0: .byte $00, $01, $02, $03, $04, $05, $06

testing/unit/atari/fn_clock/clock_get_time/test_clock_get_time.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,57 @@ run $_main while CP != $t0
99
registers set cycle_count = 0
1010
run while CP != $t0_end
1111
assert $output_buffer ~ 0x(00,01,02,03,04,05,06,00) $$t0: T format has 7 bytes$$
12-
assert #0x0300 ~ 0x(45,01,54,40) $$t0: IO_DCB matches first 4 bytes$$
12+
assert #0x0300 ~ 0x(45,01,54) $$t0: IO_DCB matches first 3 bytes$$
13+
assert $dstats_called_with = 0x40 $$t0: IO_DCB::dstats set to 0x40$$
1314
assert #0x0306 ~ 0x(02,00,07,00,00,00) $$t0: IO_DCB matches last 6 bytes$$
1415

1516
run while CP != $t1
1617
registers set cycle_count = 0
1718
run while CP != $t1_end
1819
assert $output_buffer ~ 0x(10,11,12,13,00) $$t1: Prodos format has 4 bytes$$
19-
assert #0x0300 ~ 0x(45,01,50,40) $$t1: IO_DCB matches first 4 bytes$$
20+
assert #0x0300 ~ 0x(45,01,50) $$t1: IO_DCB matches first 3 bytes$$
21+
assert $dstats_called_with = 0x40 $$t1: IO_DCB::dstats set to 0x40$$
2022
assert #0x0306 ~ 0x(02,00,04,00,00,00) $$t1: IO_DCB matches last 6 bytes$$
2123

2224
// this will be deprecated
2325
run while CP != $t2
2426
registers set cycle_count = 0
2527
run while CP != $t2_end
2628
assert $output_buffer ~ 0x(20,21,22,23,24,25,00) $$t2: Apetime TZ 0x93$$
27-
assert #0x0300 ~ 0x(45,01,93,40) $$t2: IO_DCB matches first 4 bytes$$
29+
assert #0x0300 ~ 0x(45,01,93) $$t2: IO_DCB matches first 3 bytes$$
30+
assert $dstats_called_with = 0x40 $$t2: IO_DCB::dstats set to 0x40$$
2831
assert #0x0306 ~ 0x(02,00,06,00,00,00) $$t2: IO_DCB matches last 6 bytes$$
2932

3033
run while CP != $t3
3134
registers set cycle_count = 0
3235
run while CP != $t3_end
3336
assert $output_buffer ~ "YYYY-MM-DDTHH:MM:SS+HHMM\0"$$t3: ISO TZ 'I' (0x49)$$
34-
assert #0x0300 ~ 0x(45,01,49,40) $$t3: IO_DCB matches first 4 bytes$$
37+
assert #0x0300 ~ 0x(45,01,49) $$t3: IO_DCB matches first 3 bytes$$
38+
assert $dstats_called_with = 0x40 $$t3: IO_DCB::dstats set to 0x40$$
3539
assert #0x0306 ~ 0x(02,00,19,00,00,00) $$t3: IO_DCB matches last 6 bytes$$
3640

3741
run while CP != $t4
3842
registers set cycle_count = 0
3943
run while CP != $t4_end
4044
assert $output_buffer ~ "2025-06-11T20:19:00+0100\0"$$t4: ISO ZULU 'Z' (0x5A)$$
41-
assert #0x0300 ~ 0x(45,01,5A,40) $$t4: IO_DCB matches first 4 bytes$$
45+
assert #0x0300 ~ 0x(45,01,5A) $$t4: IO_DCB matches first 3 bytes$$
46+
assert $dstats_called_with = 0x40 $$t4: IO_DCB::dstats set to 0x40$$
4247
assert #0x0306 ~ 0x(02,00,19,00,00,00) $$t4: IO_DCB matches last 6 bytes$$
4348

4449
run while CP != $t5
4550
registers set cycle_count = 0
4651
run while CP != $t5_end
4752
assert $output_buffer ~ "YYYYMMDD0HHMMSS000\0" $$t5: APPLE 3 SOS 'S' (0x53)$$
48-
assert #0x0300 ~ 0x(45,01,53,40) $$t5: IO_DCB matches first 4 bytes$$
53+
assert #0x0300 ~ 0x(45,01,53) $$t5: IO_DCB matches first 3 bytes$$
54+
assert $dstats_called_with = 0x40 $$t5: IO_DCB::dstats set to 0x40$$
4955
assert #0x0306 ~ 0x(02,00,13,00,00,00) $$t5: IO_DCB matches last 6 bytes$$
5056

5157
run while CP != $t6
5258
registers set cycle_count = 0
5359
run while CP != $t6_end
5460
assert A = 2 $$t6: invalid format returns FN_ERR_BAD_CMD$$
5561

62+
run while CP != $t7
63+
registers set cycle_count = 0
64+
run while CP != $t7_end
65+
assert A = 1 $$t7: bus error returns FN_ERR_IO_ERROR (1)$$

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ configs:
44
- ${UNIT_TEST_DIR}/base_configs/base_test_atari.yaml
55

66
src_files:
7+
- ${WS_ROOT}/atari/src/fn_fuji/fuji_error.s
8+
- ${WS_ROOT}/atari/src/bus/fn_error.s
79
- ${WS_ROOT}/atari/src/fn_clock/clock_get_time.s
810
- test_clock_get_time.s
911

0 commit comments

Comments
 (0)