Subject: Re: WANTED: ][gs clock info.
From: [email-masked] (George Powell)
Date: Thu, 07 Jul 94 03:31:06 GMT
Newsgroups: comp.sys.apple2.programmer

> source...

well..since you insist...

THe code is from 'shell' youll noitice im using the direct read from the 
clock
only for the time. The date/setting are not critical code, so speed in 
that
part is no problem. Text follows...

clk_data is in the format..

 *-----------------------------
* Mod: June 29, 1994_5:24 am
*-----------------------------
* Clock Driver for the GS internal clock
** Reads the clock and sets the values of the shell global
* with the correct values
**------------------
 lst off
 dsk /hd3/sh3/ob/Driver/Sh.clk.0003
 use /hd3/sh3/src/sh.header
 typ 6
  ORG $9c00
*------------------
CLOCKDATA      equ $C033
CLOCKCTL       equ $C034
*------------------
 bra clk_init_ex             ; ($9c00) init the clock driver
 bra clk_close_ex            ; ($9c02) shut down the clock driver
 bra clk_read_time_ex        ; ($9c04) read the time
 bra clk_read_date_ex        ; ($9c06) read the date
 bra clk_read_day_ex         ; ($9c08) read the day
 bra clk_set_ex              ; ($9c0a) set clock from global page
*------------------
clk_data_ex    ds 7
*------------------
clk_init_ex
 jsr clk_read_time_ex        ; read time
 jsr clk_set_ex              ; set the time
 jsr clk_read_date_ex        ; read date
 jsr clk_read_day_ex         ; read day of week
*------------------
clk_close_ex
 rts
*------------------
clk_read_day_ex              ; compute day of week
 jsr clk_read_date_ex        ; read date
 jmp Time_findday2           ; compute day of week
*------------------
clk_set_ex                   ; set clock from global page
 php
 lda clk_data_ex+2
 dec
 pha
 lda clk_data_ex+3
 dec
 pha
 lda clk_data_ex+1
 pha
 lda clk_data_ex+4
 pha
 lda clk_data_ex+5
 pha
 lda clk_data_ex+6
 pha
  clc
 xce
 rep #$30
  ldx #$0e03                  ; set time hex toolbox call
 jsl $e10000
  sep #$30
 sec
 xce
 plp
 rts
 *------------------
clk_read_date_ex
 JSR $BF00                   ; prodos Time call
 db $82
 da $0000
  LDA $BF91
 CLC
 ROR
 STA clk_data_ex+1
  LDA $BF90
 ROR
 LSR
 LSR
 LSR
 LSR
 STA clk_data_ex+2
  LDA $BF90
 AND #%00011111
 STA clk_data_ex+3
  rts
*------------------
clk_read_time_ex
 php
 ldx #0
 ldy #125
 clk_read_1
 iny
 iny
 iny
 iny
 sty   CLOCKDATA
  lda   CLOCKCTL
 and   #$1F
 ora   #$A0
 sta   CLOCKCTL
 clk_read_2
 lda   CLOCKCTL
 bmi   clk_read_2
  lda   CLOCKCTL
 and   #$1F
 ora   #$E0
 sta   CLOCKCTL
 clk_read_3
 lda   CLOCKCTL
 bmi   clk_read_3
  lda   CLOCKCTL
 and   #$DF
 sta   CLOCKCTL
  lda   CLOCKDATA
 sta   clk_read_data,x
  inx
 cpx   #4
 bcc   clk_read_1
*------------------
 plp
  stz   clk_data_ex+6
 stz   clk_data_ex+5
 stz   clk_data_ex+4
 ldx   #32
 clk_read_4
 asl   clk_read_data+0
 rol   clk_read_data+1
 rol   clk_read_data+2
 rol   clk_read_data+3
*------------------
 rol   clk_data_ex+6
  sec
 lda   clk_data_ex+6
 sbc   #60
 bcc   clk_read_5
  sta   clk_data_ex+6
*------------------
clk_read_5
 rol   clk_data_ex+5
  sec
 lda   clk_data_ex+5
 sbc   #60
 bcc   clk_read_6
  sta   clk_data_ex+5
*------------------
clk_read_6
 rol   clk_data_ex+4
  lda   clk_data_ex+4
 sec
 sbc   #24
 bcc   clk_read_7
  sta   clk_data_ex+4
*------------------
clk_read_7
 dex
 bne   clk_read_4
 rts
*------------------
clk_read_data
 db 0
 db 0
 db 0
 db 0
 db 1
 db 0
 db 0
*------------------
 *------------------
 ds \
 err *-$9d00
*------------------
Page:
 -----------------------------------------------------------------------
Clock Drivers
-----------------------------------------------------------------------
 $9c00 clk_init       Init the clock driver
$9c02 clk_close      Close down clock driver
$9c04 clk_read_time  Read the time & date into global page
$9c06 clk_read_date  Read the current year/month/date
$9c08 clk_read_day   Return the day of the week.
                      Exit: x=Day of week 1-7
 $9c0a clk_set        Set clock from global page data

Gp

 * Via Monalisa Gateway. Id: MLUSA00007
Path: blue.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!usc!cs.utexas.edu!swrinde!ihnp4.ucsd.edu!dog.ee.lbl.gov!agate!news.ossi.com!news.fai.com!amdahl!netcomsv!skysys!gate.skysys.org
From: [email-masked] (George Powell)
Date: Thu, 07 Jul 94 03:31:07 GMT
Newsgroups: comp.sys.apple2.programmer
Subject: more clock info
Message-ID: <[email-masked]>
Lines: 50

arg.acos=4k editor..here's the rest..

-----------------------------------------------------------------------
Clock Drivers
-----------------------------------------------------------------------
 $9c00 clk_init       Init the clock driver
$9c02 clk_close      Close down clock driver
$9c04 clk_read_time  Read the time & date into global page
$9c06 clk_read_date  Read the current year/month/date
$9c08 clk_read_day   Return the day of the week.
                      Exit: x=Day of week 1-7
 $9c0a clk_set        Set clock from global page data
                     NOT all drivers support this call
 $9c0c Clk_data       Global clock data values
 Offset:
 0 - Day of week
    0 = Sunday
    1 = Monday
    2 = Tuesday
    3 = Wendsday
    4 = Thursday
    5 = Friday
    6 = Saturday
 1 - Year      (0-99)
2 - Month     (1-12)
3 - Day       (1-31)
4 - Hour      (0-23)
5 - Minute    (0-59)
6 - Second    (0-60)
 $9c0c Clk_data       Global clock data values
 Offset:
 0 - Day of week
    0 = Sunday
    1 = Monday
    2 = Tuesday
    3 = Wendsday
    4 = Thursday
    5 = Friday
    6 = Saturday
 1 - Year      (0-99)
2 - Month     (1-12)
3 - Day       (1-31)
4 - Hour      (0-23)
5 - Minute    (0-59)
6 - Second    (0-60)
  
 Gp

 * Via Monalisa Gateway. Id: MLUSA00007