make time zone work
This commit is contained in:
@@ -128,12 +128,15 @@ extern struct _timezone {
|
|||||||
char dstname[5]; /* Name when daylight true, e.g. CEST */
|
char dstname[5]; /* Name when daylight true, e.g. CEST */
|
||||||
} _tz;
|
} _tz;
|
||||||
|
|
||||||
|
/* Set _tz for a specific time, if supported by target */
|
||||||
|
void __fastcall__ tzset_time (time_t* t);
|
||||||
|
|
||||||
#define CLK_TCK CLOCKS_PER_SEC
|
#define CLK_TCK CLOCKS_PER_SEC
|
||||||
|
|
||||||
/* POSIX function prototypes */
|
/* POSIX function prototypes */
|
||||||
int __fastcall__ clock_getres (clockid_t clock_id, struct timespec *res);
|
int __fastcall__ clock_getres (clockid_t clock_id, struct timespec* res);
|
||||||
int __fastcall__ clock_gettime (clockid_t clock_id, struct timespec *tp);
|
int __fastcall__ clock_gettime (clockid_t clock_id, struct timespec* tp);
|
||||||
int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec *tp);
|
int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec* tp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,27 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export _localtime
|
.export _localtime
|
||||||
.import __time_t_to_tm, __tz
|
.import __time_t_to_tm, __tz, _tzset_time
|
||||||
.import ldeaxi, tosaddeax, pusheax
|
.import ldeaxi, tosaddeax, pusheax
|
||||||
.importzp sreg
|
.importzp sreg, ptr1
|
||||||
|
|
||||||
_localtime:
|
_localtime:
|
||||||
cpx #$00 ; Check for null pointer
|
.if .cap(CPU_HAS_PUSHXY)
|
||||||
bne :+
|
pha
|
||||||
cmp #$00
|
phx
|
||||||
beq no_pointer
|
jsr _tzset_time
|
||||||
: jsr ldeaxi ; Load value
|
plx
|
||||||
|
pla
|
||||||
|
.else
|
||||||
|
pha
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
jsr _tzset_time
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
pla
|
||||||
|
.endif
|
||||||
|
jsr ldeaxi ; Load value
|
||||||
jsr pusheax ; Push it
|
jsr pusheax ; Push it
|
||||||
lda __tz+1+3
|
lda __tz+1+3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
@@ -23,7 +34,12 @@ _localtime:
|
|||||||
ldx __tz+1+1
|
ldx __tz+1+1
|
||||||
lda __tz+1
|
lda __tz+1
|
||||||
jsr tosaddeax ; Add _tz.timezone
|
jsr tosaddeax ; Add _tz.timezone
|
||||||
jmp __time_t_to_tm ; Convert to struct tm
|
jsr __time_t_to_tm ; Convert to struct tm
|
||||||
|
sta ptr1 ; Save returned tm pointer
|
||||||
no_pointer:
|
stx ptr1+1
|
||||||
|
ldy #16
|
||||||
|
lda __tz+0 ; Load _tz.daylight
|
||||||
|
sta (ptr1),y ; Store to tm.tm_isdst
|
||||||
|
lda ptr1 ; Restore returned tm pointer
|
||||||
|
ldx ptr1+1
|
||||||
rts ; A/X already set
|
rts ; A/X already set
|
||||||
|
|||||||
16
libsrc/common/tzset_time.s
Normal file
16
libsrc/common/tzset_time.s
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
; tzset_time.s
|
||||||
|
;
|
||||||
|
; This file is part of
|
||||||
|
; cc65 - a freeware C compiler for 6502 based systems
|
||||||
|
;
|
||||||
|
; https://cc65.github.io
|
||||||
|
;
|
||||||
|
; See "LICENSE" file for legal information.
|
||||||
|
;
|
||||||
|
; void __fastcall__ tzset_time (time_t* time);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _tzset_time
|
||||||
|
|
||||||
|
_tzset_time:
|
||||||
|
rts
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include <rp6502.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
int clock_gettimezone (time_t time, clockid_t clock_id, struct _timezone* tz);
|
|
||||||
|
|
||||||
void ria_tzset (unsigned long time)
|
|
||||||
{
|
|
||||||
clock_gettimezone (time, CLOCK_REALTIME, &_tz);
|
|
||||||
}
|
|
||||||
29
libsrc/rp6502/tzset_time.s
Normal file
29
libsrc/rp6502/tzset_time.s
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
; tzset_time.s
|
||||||
|
;
|
||||||
|
; This file is part of
|
||||||
|
; cc65 - a freeware C compiler for 6502 based systems
|
||||||
|
;
|
||||||
|
; https://cc65.github.io
|
||||||
|
;
|
||||||
|
; See "LICENSE" file for legal information.
|
||||||
|
;
|
||||||
|
; void __fastcall__ tzset_time (time_t* time);
|
||||||
|
;
|
||||||
|
|
||||||
|
.export _tzset_time
|
||||||
|
.import _clock_gettimezone, __tz
|
||||||
|
.import pushax, ldax0sp, ldeaxi, pusheax, pusha, incsp2
|
||||||
|
.include "time.inc"
|
||||||
|
|
||||||
|
|
||||||
|
_tzset_time:
|
||||||
|
jsr pushax
|
||||||
|
jsr ldax0sp
|
||||||
|
jsr ldeaxi
|
||||||
|
jsr pusheax
|
||||||
|
lda #CLOCK_REALTIME
|
||||||
|
jsr pusha
|
||||||
|
lda #<(__tz)
|
||||||
|
ldx #>(__tz)
|
||||||
|
jsr _clock_gettimezone
|
||||||
|
jmp incsp2
|
||||||
Reference in New Issue
Block a user