Streamlined clock rate handling.
* Docs say that CLK_TCK is an obsolete alias of CLOCKS_PER_SEC so there's no point in individual definitions. * All targets determining the clock rate at runtime can use a common handling.
This commit is contained in:
parent
07cc6a3d20
commit
f723147f04
4 changed files with 24 additions and 45 deletions
|
@ -83,46 +83,31 @@ extern struct _timezone {
|
|||
|
||||
|
||||
|
||||
#if defined(__ATARI__)
|
||||
/* The clock depends on the video standard, so read it at runtime */
|
||||
unsigned _clocks_per_sec (void);
|
||||
# define CLK_TCK _clocks_per_sec()
|
||||
# define CLOCKS_PER_SEC _clocks_per_sec()
|
||||
#elif defined(__ATARI5200__)
|
||||
# define CLK_TCK 60 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 60 /* ANSI */
|
||||
#if defined(__ATARI5200__)
|
||||
# define CLOCKS_PER_SEC 60
|
||||
#elif defined(__ATMOS__)
|
||||
# define CLK_TCK 100 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 100 /* ANSI */
|
||||
# define CLOCKS_PER_SEC 100
|
||||
#elif defined(__CBM__)
|
||||
# if defined(__CBM510__) || defined(__CBM610__)
|
||||
/* The 510/610 gets its clock from the AC current */
|
||||
# define CLK_TCK 50 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 50 /* ANSI */
|
||||
# define CLOCKS_PER_SEC 50
|
||||
# else
|
||||
# define CLK_TCK 60 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 60 /* ANSI */
|
||||
# define CLOCKS_PER_SEC 60
|
||||
# endif
|
||||
#elif defined(__NES__)
|
||||
# define CLK_TCK 50 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 50 /* ANSI */
|
||||
# define CLOCKS_PER_SEC 50
|
||||
#elif defined(__PCE__)
|
||||
# define CLK_TCK 60 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 60 /* ANSI */
|
||||
# define CLOCKS_PER_SEC 60
|
||||
#elif defined(__GAMATE__)
|
||||
# define CLK_TCK 135 /* POSIX */ /* FIXME */
|
||||
# define CLOCKS_PER_SEC 135 /* ANSI */ /* FIXME */
|
||||
# define CLOCKS_PER_SEC 135 /* FIXME */
|
||||
#elif defined(__GEOS__)
|
||||
# define CLK_TCK 1 /* POSIX */
|
||||
# define CLOCKS_PER_SEC 1 /* ANSI */
|
||||
#elif defined(__LYNX__)
|
||||
/* The clock-rate depends on the video scan-rate;
|
||||
** so, read it at run-time.
|
||||
*/
|
||||
extern clock_t _clk_tck (void);
|
||||
# define CLK_TCK _clk_tck()
|
||||
# define CLOCKS_PER_SEC _clk_tck()
|
||||
# define CLOCKS_PER_SEC 1
|
||||
#else
|
||||
/* Read the clock rate at runtime */
|
||||
clock_t _clocks_per_sec (void);
|
||||
# define CLOCKS_PER_SEC _clocks_per_sec()
|
||||
#endif
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
#define CLOCK_REALTIME 0
|
||||
|
||||
|
||||
|
@ -149,6 +134,3 @@ int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec *tp);
|
|||
/* End of time.h */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
; originally by Ullrich von Bassewitz and Sidney Cadot
|
||||
;
|
||||
; clock_t clock (void);
|
||||
; unsigned _clocks_per_sec (void);
|
||||
; clock_t _clocks_per_sec (void);
|
||||
;
|
||||
|
||||
.export _clock, __clocks_per_sec
|
||||
|
@ -30,8 +30,10 @@
|
|||
|
||||
.proc __clocks_per_sec
|
||||
|
||||
ldx #$00 ; Clear high byte of return value
|
||||
lda PAL ; use hw register, PALNTS is only supported on XL/XE ROM
|
||||
ldx #$00 ; Clear byte 1 of return value
|
||||
stx sreg ; Clear byte 2 of return value
|
||||
stx sreg+1 ; Clear byte 3 of return value
|
||||
lda PAL ; Use hw register, PALNTS is only supported on XL/XE ROM
|
||||
and #$0e
|
||||
bne @NTSC
|
||||
lda #50
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
; from Atari computer version by Christian Groessler, 2014
|
||||
;
|
||||
; clock_t clock (void);
|
||||
; unsigned _clocks_per_sec (void);
|
||||
;
|
||||
|
||||
.export _clock
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
; 2003-04-13, Ullrich von Bassewitz
|
||||
; 2012-02-06, Greg King
|
||||
;
|
||||
; #include <time.h>
|
||||
; clock_t clock (void);
|
||||
; clock_t _clocks_per_sec (void);
|
||||
;
|
||||
; typedef unsigned long int clock_t;
|
||||
; clock_t _clk_tck(void);
|
||||
; #define CLOCKS_PER_SEC _clk_tck()
|
||||
; clock_t clock(void);
|
||||
;
|
||||
; clk_tck()'s test-values are based on the numbers in "set_tv.s".
|
||||
; clocks_per_sec()'s test-values are based on the numbers in "set_tv.s".
|
||||
; If you change the numbers there, then change them here, too.
|
||||
;
|
||||
|
||||
.export _clock, __clk_tck, clock_count
|
||||
.export _clock, __clocks_per_sec, clock_count
|
||||
.interruptor update_clock, 2 ; (low priority)
|
||||
.constructor init_clock
|
||||
|
||||
|
@ -42,7 +38,7 @@
|
|||
;-----------------------------------------------------------------------------
|
||||
; Return the number of clock ticks in one second.
|
||||
;
|
||||
__clk_tck:
|
||||
__clocks_per_sec:
|
||||
ldx #$00 ; >50, >60, >75
|
||||
ldy PBKUP
|
||||
lda #<75
|
||||
|
|
Loading…
Add table
Reference in a new issue