CMOS (RE: Lara Croft 1.5)
ZXNet echo conference «real.speccy»
From Aleksandr Majorov → To All 14 August 1998
Hi, Tim!
[ ]
TK> Give the *MAS* standard to the echo or to me, pls. And here the guy
did a good thing,
TK> can be supplemented. But the thing has nothing to do with this echo.
I’ll just throw it out, but in fact, an external driver is better...
For example, I keep my clock in BIN, it’s more convenient for all
kinds of automation, and you seem to be in BCD-schnik...
And there are also clocks in SMAK...
;-)))
In general, here’s the document for “my” clock:
...addresses CMOS clock ports will be located
in the TR-DOS area.
Select register #D8
Read from register #58
Write to register #58
============================================================
!!! although it's better
Selecting register #F9
Reading from register #79
Writing to register #79
I'm using these right now, just in case; p/n
TR-DOS:
#3FF0 - OUT (C),A
RET
#3FF3 - IN A,(C)
RET
On computers that do not have such commands in the TR-DOS ROM
the following program is recommended:
;writing data to register
;in:
;[C] - register number CMOS clock
;[B] - value to be written
WRREG LD A,C
CALL SETREG
LDA,B
LD C,#58
JR OUTPAR
;reading data from the register
;in
;[C] - CMOS clock register number
;out:
;[A] - value read from the register
RDREG LD A,C
CALL SETREG
LD A,#D8
LD C,#1F
CALL OUTPAR
LD C,#58
LD IX,#3EF3
CALL JPTR
LD A,H
RET
SETREG LD C,#D8
OUTPAR LD IX,#2A53
JPTR PUSH IX
JP #3D2F
-------------------------------------------------
But for Scorpio with with gusto
89h (R8time) - reading/writing time from CMOS.
Called like this: set the registers, and then
RST 8
DB #89
after which you work further...
In the D register, the bits are set:
7 - (1) write the time/date value
(0) read the time/date value.
6 - (1) read into the buffer (only if bit 7=0. (see bit 5).
5 - (1) direct reading (6 bytes of data from CMOS).
(0) reading in ASCII format.
0 - (1) working with date
(0) working with time.
In addition, in HL - the buffer address (if reading occurs
into a buffer), in banks 5 and 2 of the CPU. Register E contains
reading format: lower 5 bits - delimiter character (+32!!!)
(VS: for example, for the symbol ":" there should be 26), bits 7,6 and 5
permit output of hours, minutes and seconds, respectively, or
for date output:
bit 7 - output dayweeks
bit 6 - put "0" before the number
bit 5 - display the month as a word and add "19" before the year.
The function returns data either to a buffer (as an ASCII string
or 6 bytes: seconds, minutes, hours, day, month, year),
or in registers:
C - seconds/day
B - minutes/month
E - hours/year
L - day of the week
Values for changing
time/date are set in the same registers.
out: CY=error (there is no CMOS chip).
VS: MOA succinctly noted that data can be returned
to a buffer (in ASCII format.) But if you do this, then
you will notice that the same
values are returned to you all the time! In fact, the time in ASCII is stored somewhere in the 8th bank, from where it is returned to you. And it is updated only
when Reset or Magic is initialized!!! I learned how to get around this feature
in this way: first, the time is called in the registers
(at this moment the data in the buffer is also updated), after which
I return the time to the buffer. And this time it's the true time.
(This is how I poll the time in BBS 3.20).
So calling the time occurs through 2 passes:
first to the registers (via RST 8), then directly to the buffer
(again via RST 8). MOA should also be hit over the head for this ;)
-------------------------------------------------------
But something that climbs directly to Smakov’s CMOS,
I’ll say right away - Iсам пока это не проверял, как получил так
и на полочку положил ;-)))
; *** proc
; parm : ---
; value : cf==busy
; nc==read, hl=&bf[6]
; modify: af bc de hl
_rtc_try_read
ld de, #3FF3 ;in
ld bc, #3FF0 ;out
ld (rtc_tryrd_sp+1), sp
ld hl, rtc_tryrd_fin
push hl
push de
push bc
ld hl, rtc_tryrd_inc
push hl
push de
push bc
push hl
push de
push bc
push hl
push de
push bc
ld hl, rtc_tryrd_add2
push hl
push de
push bc
push hl
push de
push bc
push hl
push de
push bc
ld hl, rtc_tryrd_tst
push hl
push de
push bc
ld a, #0A
ld hl, rtc_tryrd_bf
ld e, 0
ld bc, #DFBA
di
jp #3D30
rtc_tryrd_bf ds 7
rtc_tryrd_tst
add a, a
ld a, e
jp nc, #3D30
ei
rtc_tryrd_sp ld sp, 0
ret
rtc_tryrd_fin ei
ld (hl), a
ret
rtc_tryrd_add2 ld (hl), a
inc hl
ld a, 2
add a, e
ld e, a
jp #3D30
rtc_tryrd_inc ld (hl), a
inc hl
inc e
ld a, e
jp #3D30
; *** end proc
-----------------------------------------
Hу вот и все
*MAS* с кувалдой