-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.7.0 add fn_clock interface and atari/apple2 cc65 implementations
- Loading branch information
1 parent
0cbbc3c
commit df98441
Showing
15 changed files
with
421 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.export _clock_get_time | ||
|
||
.import _sp_count | ||
.import _sp_get_clock_id | ||
.import _sp_payload | ||
.import _sp_status | ||
|
||
.import incsp2 | ||
.import popax | ||
.import pusha | ||
.import return0 | ||
.import return1 | ||
|
||
.include "macros.inc" | ||
.include "zp.inc" | ||
|
||
; uint8_t clock_get_time(uint8_t* time_data, TimeFormat format); | ||
|
||
_clock_get_time: | ||
sta time_format ; format, save it where we need it! saves a BSS byte | ||
|
||
; get the device id of the clock, this is stored in _sp_clock_id, but also returned so we can check if it failed (0 is error) | ||
jsr _sp_get_clock_id | ||
bne got_id | ||
|
||
; no clock found, return 1 as an error (FN_ERR_IO_ERROR) | ||
; but first adjust the stack to remove the data pointer | ||
error: | ||
jsr incsp2 | ||
jmp return1 | ||
|
||
got_id: | ||
; call sp_status(uint8_t dest, uint8_t statcode) | ||
sta tmp1 ; save the clock device id | ||
|
||
; convert the time format to the appropriate device specific code. | ||
; SIMPLE_BINARY (0) -> 'T' | ||
; PRODOS_BINARY (1) -> 'P' | ||
; APETIME_TZ_BINARY (2) -> 'A' | ||
; APETIME_BINARY (3) -> 'B' | ||
; TZ_ISO_STRING (4) -> 'S' | ||
; UTC_ISO_STRING (5) -> 'Z' | ||
|
||
ldx #$00 | ||
time_format = *-1 | ||
; ensure the value is valid | ||
cpx #$06 | ||
bcs error | ||
pusha tmp1 | ||
lda code_table, x | ||
|
||
jsr _sp_status | ||
bne error | ||
|
||
; results are in sp_payload, the clock data returned is small (4 to 26 bytes) | ||
; _sp_count holds the number of bytes to copy from sp_payload, will always contain at least 1 byte (null terminator) | ||
popax ptr1 ; read the time_data location into ptr1 | ||
ldy #$00 | ||
: lda _sp_payload, y | ||
sta (ptr1), y | ||
iny | ||
cpy _sp_count | ||
bne :- | ||
|
||
jmp return0 | ||
|
||
.data | ||
code_table: | ||
.byte 'T', 'P', 'A', 'B', 'S', 'Z' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.export _clock_get_tz | ||
|
||
.import _sp_count | ||
.import _sp_get_clock_id | ||
.import _sp_payload | ||
.import _sp_status | ||
|
||
.import pusha | ||
.import return0 | ||
.import return1 | ||
|
||
.include "macros.inc" | ||
.include "zp.inc" | ||
|
||
; uint8_t clock_get_tz(uint8_t* tz); | ||
|
||
_clock_get_tz: | ||
axinto tmp_tz_loc | ||
jsr _sp_get_clock_id | ||
bne got_id | ||
|
||
error: | ||
jmp return1 | ||
|
||
got_id: | ||
; sp_status(clock_id, 'G') | ||
jsr pusha | ||
lda #'G' | ||
jsr _sp_status | ||
bne error | ||
|
||
; copy sp_count bytes from payload into buffer, there's always at least 1 byte (null terminator) | ||
mwa tmp_tz_loc, ptr1 | ||
ldy #$00 | ||
: lda _sp_payload, y | ||
sta (ptr1), y | ||
iny | ||
cpy _sp_count | ||
bne :- | ||
|
||
jmp return0 | ||
|
||
|
||
.bss | ||
tmp_tz_loc: .res 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.export _clock_set_tz | ||
|
||
.import _fn_error | ||
.import _memcpy | ||
.import _sp_control | ||
.import _sp_get_clock_id | ||
.import _sp_payload | ||
.import _strlen | ||
|
||
.import incsp2 | ||
.import pusha | ||
.import pushax | ||
.import return1 | ||
|
||
.include "macros.inc" | ||
.include "zp.inc" | ||
|
||
; uint8_t clock_set_tz(char *tz); | ||
_clock_set_tz: | ||
axinto tmp_tz_ptr ; save the tz | ||
|
||
; get the device id of the clock, this is stored in _sp_clock_id, but also returned so we can check if it failed (0 is error) | ||
jsr _sp_get_clock_id | ||
bne got_id | ||
|
||
; no clock found, return 1 as an error (FN_ERR_IO_ERROR) | ||
jmp return1 | ||
|
||
got_id: | ||
jsr pusha ; store the destination device for call to sp_control | ||
|
||
; copy timezone string into sp_payload, including the null terminator | ||
pushax #(_sp_payload + 2) | ||
pushax tmp_tz_ptr | ||
jsr _strlen | ||
|
||
clc | ||
adc #$01 | ||
bcc :+ | ||
inx | ||
|
||
: sta _sp_payload + 0 | ||
stx _sp_payload + 1 | ||
jsr _memcpy | ||
|
||
; destination was stored on s/w stack already | ||
lda #'T' ; set 'T'imezone | ||
jsr _sp_control | ||
|
||
; convert to fujinet error | ||
jmp _fn_error | ||
|
||
|
||
.bss | ||
tmp_tz_ptr: .res 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.export _clock_get_time | ||
|
||
.import _bus | ||
.import _fuji_success | ||
|
||
.import popax | ||
.import return0 | ||
|
||
.include "device.inc" | ||
.include "fujinet-clock.inc" | ||
.include "macros.inc" | ||
.include "zp.inc" | ||
|
||
; uint8_t clock_get_time(uint8_t* time_data, TimeFormat format); | ||
_clock_get_time: | ||
tay | ||
cpy #$06 ; was the format value in range? | ||
bcc ok | ||
|
||
; return an error status | ||
jmp return0 | ||
|
||
ok: | ||
lda t_clock_get_time_cmd, y | ||
sta IO_DCB::dcomnd | ||
lda t_clock_get_time_len, y | ||
sta IO_DCB::dbytlo | ||
popax IO_DCB::dbuflo | ||
|
||
; the SIO clock device follows the APETIME device ID: | ||
; #define SIO_DEVICEID_APETIME 0x45 | ||
mva #SIO_CLOCK_DEVICE_ID, IO_DCB::ddevic | ||
mva #$40, IO_DCB::dstats | ||
ldx #$00 | ||
stx IO_DCB::dunuse | ||
stx IO_DCB::daux1 | ||
stx IO_DCB::daux2 | ||
stx IO_DCB::dbythi | ||
inx ; x = 1 | ||
stx IO_DCB::dunit | ||
inx ; x = 2 - as this is a FN non network call, we can keep this low | ||
stx IO_DCB::dtimlo | ||
jsr _bus | ||
jmp _fuji_success | ||
|
||
.rodata | ||
|
||
; tables for the commands that have to be sent for the different types of time command | ||
; see fuji_clock.h | ||
t_clock_get_time_cmd: | ||
.byte 'T', 'P', SIO_APETIMECMD_GETTZTIME, SIO_APETIMECMD_GETTIME, 'S', 'Z' | ||
|
||
t_clock_get_time_len: | ||
.byte 7, 4, 6, 6, 25, 25 |
Oops, something went wrong.