|
Post by mirkosoft on Feb 8, 2015 16:29:59 GMT
Hi!
I'm working with RTC and I'm able to set RTC in CIA, but I want to be able to set RTC also to Basic variable TI$... Looking at TI$, it's string variable with length 6 characters in format HHMMSS and is impossible to set it in other length, value of hour >23 sets TI$ to 0, minute >59 sets TI$ to 0, second can have values 00-99 but seconds >59 adds minute... only characters 0-9 are usable (in Basic it reports error, in assembler can be only checked if is correct).
So, mismatch makes it clear = "000000"
But how to access TI$? Where in RAM is its value?
Thank you for every help, reply or comments.
Miro
|
|
|
Post by buzbard on Feb 9, 2015 23:48:32 GMT
The values returned by TI and TI$ are calculated values of the system jiffy clock, located at addresses 160-162($A0-$A2). The TI$ variable isn't "stored" anywhere, it's calculated each time the variable is accessed.
162/$A2 is updated every 1/60 of a second.
161/$A1 is updated every 1/60 * 256 of a second or every 4.27 seconds.
160/$A0 is updated every 4.27 * 256 seconds or every 1092 seconds or every 18.2 minutes.
The Kernal SETTIM($F665) and RDTIM($F65E) routines can be used to set/read these locations.
There is a BASIC routine at 31096($7978) that evaluates the TI & TI$ variables, among others.
|
|
|
Post by mirkosoft on Feb 10, 2015 6:21:06 GMT
Thank you very much
|
|
|
Post by hydrophilic on Feb 10, 2015 7:16:50 GMT
Note the "TI" variable is only updated when interrupts are enabled... in other words, during Cassette/Serial-Bus(Disk/printer) access, it is disabled... not very accurate time!!
Also, for PAL systems, $a2 is updated 50 times per second (50Hz), but every 5th IRQ (interrupt) the variable $a2 is incremented again! So NTSC (60Hz) system will increment $a2 like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... very natural... BUT on a PAL system, $a2 will increment like this: 0, 1, 2, 3, 4, *6*, 7, 8, 9, 10, *12*...
In other words, best to use CIA registers $dc08~dc0b (or $dd08~dd0b)... most accurate time (immune to software interrupts!). Sadly, BASIC does not read/write either CIA when you reference TI$... mainly due to compatibility with older systems (VIC-20 / Plus4 / PET) which do not have real hardware clock...
Of course ultimate goal should be to initialize CIA registers with a "real-time-clock" from some other device...
|
|
|
Post by mirkosoft on Feb 10, 2015 19:56:19 GMT
Thank you Robert for correction. Really is for me variable TI$ not so important, only playing with RTC options is TI$ accessible... so I don't want to forget it.
Miro
|
|