Skip to content

Commit e008e0b

Browse files
committed
Add clock_get_time_tz, remove feature tests, add soft65c02 tests
1 parent 5fb49b9 commit e008e0b

File tree

217 files changed

+538
-8425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+538
-8425
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
you are an expert in 6502 assembly language, and C for the cc65 development 8 bit computer environment.
7+
you will follow existing layout of assembly files.
8+
you will prefer lowercase labels and instructions.
9+
the project uses cc65 to compile C and asm files.
10+
The C standard is c99, with all variables being defined at the top of block structures, rather than inline.
11+
The asm is compiled with ca65.
12+
This project is for 8 bit machines, where memory is limited.
13+
For any C files, you must try not to use expensive library functions such as printf, but stdlib and memory efficient functions like memmove and memcpy are prefered.
14+
The preferred convention for passing parameters to functions in asm files is the cc65 C conventions of passing values via the software stack.
15+
Your responses should be to the point. You will say when you do not know the answer rather than guessing, or at least indicate that you are postulating a solution, or need more information to formulate a better response.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ build/
77
.vscode/
88

99
Makefile.options
10+
11+
_temp

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- [atari] fix software stack leak in clock_get_time when timeformat value is not valid [Mark Fisher]
88
- [atari] add block reading for directories [Mark Fisher]
9+
- [atari] align apetime functionality with original intent with optional alternate TZ for some applications
910

1011
## [4.7.5] - 2025-04-18
1112

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TARGETS = adam atari c64 apple2 apple2enh apple2gs coco
88
# TARGETS = msdos
99
PROGRAM := fujinet.lib
1010

11-
SUB_TASKS := clean disk test release
11+
SUB_TASKS := clean disk test release unit-test
1212
.PHONY: all help $(SUB_TASKS)
1313

1414
all:
@@ -32,3 +32,4 @@ help:
3232
@echo "all - do all compilation tasks, create app in build directory"
3333
@echo "clean - remove all build artifacts"
3434
@echo "release - create a release of the executable in the dist/ dir"
35+
@echo "unit-test - run unit tests"

application.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# for application specific settings
2+
3+
-include makefiles/unit_tests.mk

atari/src/fn_clock/clock_get_time.s

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.export _clock_get_time
2+
.export _clock_get_time_tz
23

34
.import _bus
45
.import _fuji_success
6+
.import _clock_set_alternate_tz
57

68
.import incsp2
79
.import popax
@@ -12,17 +14,40 @@
1214
.include "macros.inc"
1315
.include "zp.inc"
1416

17+
18+
; either 2 or 4 bytes to increase sp4 by
19+
exit_bad_tz4:
20+
jsr incsp2
21+
22+
exit_bad_tz2:
23+
jsr incsp2
24+
jmp return0
25+
26+
27+
; uint8_t clock_get_time_tz(uint8_t* time_data, const char* tz, TimeFormat format);
28+
_clock_get_time_tz:
29+
cmp #$06 ; was the format value in range?
30+
bcs exit_bad_tz4 ; too large, exit and remove 2 pointers (4 bytes) from stack
31+
32+
; save it while we deal with the TZ string
33+
sta tmp_format
34+
; first read tz from string given, and set it as the alternate TZ in fujinet.
35+
jsr popax
36+
jsr _clock_set_alternate_tz
37+
38+
; an error, but we still have an arg on software stack
39+
bne exit_bad_tz2
40+
41+
ldy tmp_format
42+
bpl common_tz ; it's between 0 and 6 validated, so this will always branch
43+
1544
; uint8_t clock_get_time(uint8_t* time_data, TimeFormat format);
1645
_clock_get_time:
17-
tay
46+
tay ; time format enum
1847
cpy #$06 ; was the format value in range?
19-
bcc ok
48+
bcs exit_bad_tz2
2049

21-
; return an error status
22-
jsr incsp2 ; remove stack parameter
23-
jmp return0
24-
25-
ok:
50+
common_tz:
2651
lda t_clock_get_time_cmd, y
2752
sta IO_DCB::dcomnd
2853
lda t_clock_get_time_len, y
@@ -45,6 +70,9 @@ ok:
4570
jsr _bus
4671
jmp _fuji_success
4772

73+
.bss
74+
tmp_format: .res 1
75+
4876
.rodata
4977

5078
; tables for the commands that have to be sent for the different types of time command

atari/src/fn_clock/clock_set_tz.s

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.export _clock_set_apetime_tz
12
.export _clock_set_tz
23

34
.import _bus
@@ -11,8 +12,21 @@
1112
.include "macros.inc"
1213
.include "zp.inc"
1314

15+
16+
; uint8_t clock_set_alternate_tz(char *tz);
17+
_clock_set_alternate_tz:
18+
; for backwards compatibility, this is the same as the old "APETIME" settz
19+
ldy #SIO_APETIMECMD_SETTZ
20+
sty IO_DCB::dcomnd
21+
bne _clock_set_tz_common
22+
1423
; uint8_t clock_set_tz(char *tz);
1524
_clock_set_tz:
25+
ldy #'t'
26+
sty IO_DCB::dcomnd
27+
; ... fallthrough
28+
29+
_clock_set_tz_common:
1630
axinto IO_DCB::dbuflo ; the TZ string to send, will be null terminated
1731
jsr _strlen
1832

@@ -24,9 +38,6 @@ _clock_set_tz:
2438
: axinto IO_DCB::dbytlo
2539
axinto IO_DCB::daux1
2640

27-
lda #SIO_APETIMECMD_SETTZ
28-
sta IO_DCB::dcomnd
29-
3041
; the SIO clock device follows the APETIME device ID:
3142
; #define SIO_DEVICEID_APETIME 0x45
3243

fujinet-clock.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,23 @@ uint8_t clock_set_tz(const char *tz);
4343
uint8_t clock_get_tz(char *tz);
4444

4545
/**
46-
* @brief Get the current time in the format specified.
46+
* @brief Get the current time in the format specified using the FN timezone.
4747
* @param time_data pointer to buffer for the response. This is uint8_t, but for STRING formats, will be null terminated and can be treated as a string.
4848
* @param format a TimeFormat value to specify how the data should be returned.
4949
* @return fujinet-clock status/error code (See FN_ERR_* values)
5050
*/
5151
uint8_t clock_get_time(uint8_t* time_data, TimeFormat format);
5252

53+
/**
54+
* @brief Get the current time in the format specified for the given timezone without affecting the system timezone
55+
* @param time_data pointer to buffer for the response. This is uint8_t, but for STRING formats, will be null terminated and can be treated as a string.
56+
* @param tz pointer to the receiving timezone buffer.
57+
* @param format a TimeFormat value to specify how the data should be returned.
58+
* @return fujinet-clock status/error code (See FN_ERR_* values)
59+
*/
60+
uint8_t clock_get_time_tz(uint8_t* time_data, const char* tz, TimeFormat format);
61+
62+
// for C implementations, these shouldn't be used by consumer
5363
#define SIO_APETIMECMD_GETTIME 0x93
5464
#define SIO_APETIMECMD_SETTZ 0x99
5565
#define SIO_APETIMECMD_GETTZTIME 0x9A

makefiles/unit_tests.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Find all test_*.yaml files under testing/unit
2+
UNIT_TEST_FILES := $(shell find testing/unit/$(CURRENT_TARGET) -name "test_*.yaml")
3+
4+
# Create temp directory if it doesn't exist
5+
/tmp/fujinet-lib-unit:
6+
@mkdir -p /tmp/fujinet-lib-unit
7+
8+
# Run all unit tests
9+
.PHONY: unit-test
10+
unit-test: /tmp/fujinet-lib-unit
11+
@echo "Running unit tests..."
12+
@failed=0; \
13+
for test in $(UNIT_TEST_FILES); do \
14+
echo "Running $$test..."; \
15+
if ! WS_ROOT=$(CURDIR) UNIT_TEST_DIR=$(CURDIR)/testing/unit soft65c02_unit -b /tmp/fujinet-lib-unit -i $$test; then \
16+
echo "FAILED: $$test"; \
17+
failed=1; \
18+
fi; \
19+
done; \
20+
if [ $$failed -eq 1 ]; then \
21+
echo "One or more tests failed"; \
22+
exit 1; \
23+
fi
24+
@echo "All unit tests passed"

testing/bdd-testing/.gitignore

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)