changeset 221:5a27279ccc08

Added new utils
author boisy
date Tue, 16 Jul 2002 00:59:54 +0000
parents 7fed7dcadaee
children 840af855c723
files 3rdparty/utils/smartwatch/defsfile 3rdparty/utils/smartwatch/makefile 3rdparty/utils/smartwatch/swread.asm 3rdparty/utils/smartwatch/swset.asm
diffstat 4 files changed, 715 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/3rdparty/utils/smartwatch/defsfile	Tue Jul 16 00:58:22 2002 +0000
+++ b/3rdparty/utils/smartwatch/defsfile	Tue Jul 16 00:59:54 2002 +0000
@@ -1,1 +1,3 @@
+Level   equ     2
 	use	os9defs
+        use     scfdefs
--- a/3rdparty/utils/smartwatch/makefile	Tue Jul 16 00:58:22 2002 +0000
+++ b/3rdparty/utils/smartwatch/makefile	Tue Jul 16 00:59:54 2002 +0000
@@ -2,7 +2,7 @@
 
 DEPENDS		= ./Makefile
 
-CMDS		= getclk
+CMDS		= getclk swread swset
 
 ALLOBJS		= $(CMDS)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/3rdparty/utils/smartwatch/swread.asm	Tue Jul 16 00:59:54 2002 +0000
@@ -0,0 +1,352 @@
+********************************************************************
+* SWRead - Read SmartWatch clock
+*
+* $Id$
+*
+* Copyright May, 1990 by Robert Gault
+
+* SWREAD will read smartwatch compensating for 12hr mode if active
+* time will be sent to OS-9 in 24hr mode for compatability
+*
+* The routine does grab a large uninterruptible block of time from
+* the system, but no other way seems possible.
+*
+* syntax  swread [n&]      n=1-60 minutes
+* D.Daywk stored for possible use
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 1      Created                                        RG  91/03/01
+* 1      Changed irq handling; MPI handling;            RG  91/10/29
+*        error handling
+* 1      Removed relocation routine. Removal could be   RG  92/12/26
+*        dangerous if OS-9 did not grab block from the
+*        low addresses first. Code must not be in a
+*        RAM/ROM block when ROMs activated.
+* 2      Relocated part of clock read routine to        RG  94/12/19
+*        shorten the time spent with irqs off.
+
+         nam   SWRead
+         ttl   Read SmartWatch clock
+
+         ifp1  
+         use   defsfile
+         endc  
+
+cartI    equ   $FF22      cartridge IRQ report
+multipac equ   $FF7F
+rom      equ   $FFDE
+ram      equ   $FFDF
+IEN      equ   %00100000
+FEN      equ   %00010000
+SCS      equ   %00000100
+ROM1     equ   %00000010
+ROM0     equ   %00000001
+*D.Cntury	set	$6A century byte
+
+type     set   prgrm+objct
+revs     set   reent+1
+edition  set   2
+
+         mod   pgrmend,name,type,revs,start,size
+
+name     fcs   /SWRead/
+         fcb   edition
+
+locblk0  rmb   2          pointer to block 0
+locblk3E rmb   2          pointer to block $3E ie. disk ROM
+dpsave   rmb   1
+sleep    rmb   1          sleep interval time in minutes
+byte1    rmb   1          temp storage of clock read data; if never changes - no clock
+clkflag  rmb   1          set when clock is found
+mpiimage rmb   1
+sleepflg rmb   1          indicates multiple reads requested
+timer    rmb   1          count down for sleep interval; per minute
+century  rmb   1          century flag
+rawdata  rmb   8          direct readout from clock chip
+
+stack    rmb   200
+size     equ   .
+
+message1 fcc   /no clock found/
+         fcb   $0D
+setime   fcc   /setime/   forced chain to setime routine
+         fcb   $0D
+
+errmes   fcb   $0a
+         fcc   /Swread syntax:/
+         fdb   $a0a
+         fcc   /swread [n&]/
+         fcb   $0a
+         fcc   /           The parameter string is optional; n = 1 to 60 min/
+         fcb   $0a
+         fcc   /           permitting the watch to be poled in background every/
+         fcb   $0a
+         fcc   /           n minutes. Use decimal time values./
+         fcb   $0d
+allert   fcb   $C5,$3A,$A3,$5C,$C5,$3A,$A3,$5C,0
+
+start    clr   <sleepflg
+         cmpd  #2
+         blo   noparams
+         ldd   ,x
+         cmpa  #'?
+         lbeq  syntax
+         cmpa  #'-
+         lbeq  syntax
+
+         cmpb  #'0        if second byte is CR then only one number
+         blo   onebyte
+         subd  #$3030     convert from ascii to bcd
+
+         cmpd  #$600      one hour skip is max
+         lbhi  syntax
+         cmpb  #9         must be a number from 0-9
+         lbhi  syntax
+
+         pshs  b          convert reg.D to hexidecimal
+         ldb   #10
+         mul   
+         addb  ,s+
+         bra   storeit
+
+onebyte  suba  #'0
+         cmpa  #9
+         lbhi  syntax
+
+storeit  stb   <timer
+         stb   <sleep     used to reset timer on count down
+         com   <sleepflg
+
+noparams equ   *
+         lda   multipac
+         anda  #3         retain IRQ settings
+         ora   #$30       start at slot 4; ROM setting
+         sta   <mpiimage
+
+doit     pshs  u
+         ldb   #1         single block
+         ldx   #$3E       disk rom; $07C000-$07DFFF
+         os9   f$mapblk   map into user space clock ROM
+         bcs   exit2
+         stu   locblk3E   save pointer
+         ldx   #0         system direct page
+         os9   f$mapblk   system direct page
+         bcs   exit2
+         leax  ,u         faster but = to TFR; get pointer for system DP
+         stu   locblk0    save pointer
+         tfr   dp,b       get our own DP
+         stb   dpsave
+
+         bsr   readclk
+
+         ldb   #1         unmap blocks from user space
+         ldu   locblk3E   get pointer
+         os9   f$clrblk
+         ldb   #1
+         ldu   locblk0    get pointer
+         os9   f$clrblk
+         puls  u
+
+         tst   <clkflag   was clock found?
+         beq   error2
+         tst   <sleepflg  are we in repeat mode?
+         beq   exit
+
+snooze   ldx   #3540      = one minute of ticks minus one second for overhead
+         os9   f$sleep
+         cmpx  #0
+         bne   exit       received signal so quit
+
+         dec   timer
+         bne   snooze
+
+         lda   sleep      reset timer
+         sta   timer
+         bra   doit       go and read the clock
+
+exit2    leas  2,s        puls u
+         coma             set cc
+         os9   F$exit
+error    ldb   #e$illarg
+         os9   F$exit
+
+error2   lda   #2         error path
+         leax  message1,pcr
+         ldy   #40
+         os9   I$WritLn
+* force a normal Setime as SmartWatch was not detected
+         lda   #$11       modul type
+         ldb   #2         size of data area
+         leax  setime,pcr
+         ldy   #0         parameter size
+         leas  stack,u
+         leau  size,u
+         os9   F$Chain
+exit     clrb  
+         os9   F$exit
+
+* this is the heart of the clock reading routine
+* regX regU point to system direct page
+readclk  pshs  cc
+         lda   d.hinit,x  get $FF90 image
+         ldb   multipac   get current setting
+         pshs  d          save them
+         anda  #^(IEN+FEN+ROM1+ROM0) no GIME IRQ/FIRQ; external access
+         orcc  #$50       stop interrupts
+         sta   $FF90
+         sta   rom        go to ROM mode
+         ldx   <locblk3E  point to clock ROM
+         ldb   <mpiimage  get new value for MPI
+         clr   <clkflag   start with clock not found
+         lda   locblk3E
+         tfr   a,dp       point to clock
+
+findclk  stb   multipac   set new slot
+         leay  allert,pcr point to clock wakeup code
+         lda   <4         clear clock at $C004
+         clrb  
+         bita  #1         1bit serial I/O port; if no clock, all bits should be 0 or 1
+         beq   low
+         comb  
+low      stb   >byte1     save as flag for found clock
+
+nxtbyte  ldb   #8         bits/byte
+         lda   ,y+
+         beq   gettime
+nxtbit   lsra             do a serial generation
+         bcs   high
+         cmpa  <0         talk to clock at $C000; cmp faster than tst
+         bra   high2
+high     cmpa  <1         talk to clock at $C001
+high2    decb  
+         bne   nxtbit
+         bra   nxtbyte
+
+gettime  lda   #8         8 bytes to read from clock
+         pshs  a
+         ldy   #rawdata
+* read serial bit stream from clock
+timebyte lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         lsr   <4
+         rora  
+         sta   ,y+        store in raw data	
+         cmpa  >byte1     if reg.A never changes then no clock
+         beq   maybe      always possible that a clock byte might look like ROM
+         inc   >clkflag   indicate a found clock
+maybe    dec   ,s
+         bne   timebyte
+         leas  1,s        yank counter
+         tst   >clkflag   did we find the clock?
+         bne   found
+         ldb   >mpiimage  try another MPI slot
+         bitb  #$30       did we get to slot 0?
+         beq   found
+         subb  #$10       next slot
+         stb   >mpiimage  save image so that we don't hunt the next time.
+         bra   findclk
+
+found    lda   >dpsave
+         tfr   a,dp       back to program DP
+         sta   ram        go back to RAM mode
+         puls  d
+         stb   multipac   restore to original setting
+         tst   cartI      clear CART flag incase autostart ROM pack was present in MPI
+         sta   $FF90      restore GIME mode
+         puls  cc         restore IRQs
+         tst   <clkflag
+         beq   noclk
+         ldx   #rawdata
+         leay  D.Slice,u
+         ldb   #8
+         pshs  b
+trans    lda   ,x+        translate serial data into OS-9 format
+         ldb   ,s
+         cmpb  #1         year
+         bne   notyr
+         cmpa  #$80       binary coded decimal number
+         bhi   nintn
+*	ldb	#20
+*	stb	D.Cntury,u
+         sta   <century
+         bra   notyr
+nintn          
+*	ldb	#19
+*	stb	D.Cntury,u
+         clr   <century
+*notyr	ldb	,s
+notyr    cmpb  #4         day of the week
+         bne   notdywk
+         anda  #7
+         sta   D.Daywk,u
+         bra   nxtdata
+notdywk  cmpb  #5         special 12/24, AM/PM indicator
+         bne   cnvrt      convert any number
+         bita  #%10000000 12/24 hour bit
+         beq   cnvrt      24 hour time
+         bita  #%00100000 AM/PM bit since 12 hour time, check AM/PM
+         pshs  cc
+         anda  #%00011111 keep only time
+         puls  cc
+         bne   PMhr
+         cmpa  #$12       bcd value
+         bne   cnvrt
+         clra             12 AM = 0 hrs 24hr time
+         bra   cnvrt
+Pmhr     cmpa  #$12       bcd value
+         beq   cnvrt      12PM = 1200 24 hr time
+         adda  #$12       all other times (1-11) add 12; ie. 1300-2300
+cnvrt    tfr   a,b        return result in reg.B
+         anda  #%11110000 get MSN
+         lsra  
+         lsra  
+         sta   ,-s        save #4a
+         lsra  
+         sta   ,-s        save #2a
+         subb  ,s+        16a+b-4a
+         subb  ,s+        12a+b-2a=10a+b
+         stb   ,-y        decrease pointer and then store
+nxtdata  dec   ,s
+         bne   trans
+         tst   <century
+         beq   not20
+         lda   #100
+         adda  1,y
+         sta   1,y
+not20    puls  b,pc
+
+noclk    clr   D.Daywk,u  clear garbage as new date routine reads D.Daywk
+         leay  D.Time,u
+         ldd   #7
+noclklp  sta   ,y+        clear clock packet; faster than a clr ,y+
+         decb  
+         bne   noclklp
+*	clr	D.Cntury,u
+         clr   <century
+         clr   <clkflag
+         rts   
+
+syntax   lda   #2
+         leax  errmes,pcr
+         ldy   #300
+         os9   I$Writln
+         clrb  
+         os9   F$Exit
+
+         emod  
+pgrmend  equ   *
+         end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/3rdparty/utils/smartwatch/swset.asm	Tue Jul 16 00:59:54 2002 +0000
@@ -0,0 +1,360 @@
+********************************************************************
+* SWSet - Set time in SmartWatch
+*
+* $Id$
+*
+* Copyright May, 1990 by Robert Gault
+*
+* SWSET will set the smartwatch in either 12hr or 24hr mode
+* time will be sent to OS-9 in 24hr mode for compatability
+* see new DATE which presents time in 12hr. mode with day of week
+* and SWREAD which sends data from clock to OS-9
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 1      Revised: clock disable; no relocation          RG  95/07/04
+
+         nam   SWSet
+         ttl   Set time in SmartWatch
+
+         ifp1  
+         use   defsfile
+         endc  
+
+type     set   prgrm+objct
+revs     set   reent+1
+edition  set   1
+
+         mod   pgrmend,name,type,revs,start,size
+
+          
+locblk0  rmb   2          pointer to block 0
+locblk3E rmb   2          pointer to block $3E ie. disk ROM
+temp1    rmb   1
+temp2    rmb   1
+clkbyte  rmb   1
+clkflag  rmb   1
+mpiimage rmb   1
+alrtimag rmb   8          storage for the allert code with following:
+csec     rmb   1
+sec      rmb   1
+min      rmb   1
+hour     rmb   1
+daywk    rmb   1
+daymn    rmb   1
+month    rmb   1
+year     rmb   1
+stopbyte rmb   1
+rawdata  rmb   18
+stack    rmb   200
+size     equ   .
+
+rom      equ   $FFDE
+ram      equ   $FFDF
+multipac equ   $FF7F
+cartI    equ   $FF22
+skp1     equ   $21
+skp2     equ   $8C        code for cmpx #nn
+
+name     fcs   /SWSet/
+         fcb   edition
+
+clknfnd  fcb   C$LF
+         fcc   /no clock found/
+         fcb   C$LF
+         fcc   /I'm running Setime/
+         fcb   C$CR
+setime   fcc   /setime/
+         fcb   C$CR
+swread   fcc   /swread/
+         fcb   C$CR
+
+query    lda   #1
+         os9   I$Writln
+         clra             path 0
+         leax  temp1,u    storage
+         ldy   #1
+         os9   I$Read
+         lda   temp1      get key
+         rts   
+
+start    leax  alrtimag,u point to image of allert code
+         ldb   #8
+         leay  allert,pcr
+s1loop   lda   ,y+        transfer to data
+         sta   ,x+
+         decb  
+         bne   s1loop
+         ldb   #8
+s2loop   clr   ,x+        clear out the time date data
+         decb  
+         bne   s2loop
+         dec   ,x         mark stop byte
+         lda   multipac
+         anda  #3         keep IRQ
+         ora   #$30       start with slot 4
+         sta   mpiimage   save setting
+         lda   #1
+         leax  crmesage,pcr copyright message
+         ldy   #mesage1-crmesage
+         os9   I$WritLn
+getfunc  leax  mesage1,pcr select	time or disable clock
+         ldy   #mesage2-mesage1
+         bsr   query
+         anda  #$DF
+         cmpa  #'D        disable
+         lbeq  killit
+         cmpa  #'T        timer
+         lbeq  doit
+         cmpa  #'C        clock
+         bne   getfunc
+getday   leax  mesage2,pcr
+         ldy   #mesage3-mesage2 get day of week
+         bsr   query
+         suba  #'0
+         blo   getday
+         cmpa  #7
+         bhi   getday
+         sta   daywk      convert from ascii to number
+tmode    leax  mesage3,pcr 12	or 24 hour time
+         ldy   #mesage4-mesage3
+         bsr   query
+         cmpa  #'1        error trap
+         blo   tmode
+         cmpa  #'2
+         bhi   tmode
+         beq   date
+         lda   #%10000000 12 hr bit
+         sta   hour
+getAMPM  leax  mesage4,pcr
+         ldy   #mesage5-mesage4
+         lbsr  query
+         clrb  
+         anda  #$df
+         cmpa  #'A
+         beq   AMPMcode
+         cmpa  #'P
+         bne   getAMPM
+         ldb   #%100000   PM bit
+AMPMcode orb   hour
+         stb   hour
+date     leax  mesage5,pcr get date and time
+         lda   #1
+         ldy   #endmes-mesage5
+         os9   I$Writln
+         clra  
+         leax  rawdata,u
+         ldy   #18
+         os9   I$ReadLn
+         leax  rawdata,u
+         clr   temp1
+         bsr   ascbcd
+         stb   year
+         bsr   ascbcd
+         stb   month
+         bsr   ascbcd
+         stb   daymn
+         bsr   ascbcd
+         tst   hour
+         beq   sthour
+         cmpb  #$12       max in 12 hour mode
+         bhi   date
+         orb   hour
+sthour   stb   hour
+         bsr   ascbcd
+         stb   min
+         bsr   ascbcd
+         stb   sec
+         bra   doit
+
+ascbcd   clr   temp2
+         bsr   data1
+         bne   noinfo
+         com   temp2
+         tfr   a,b
+         bsr   data1
+         bne   endasc
+         lslb  
+         lslb  
+         lslb  
+         lslb  
+         pshs  a
+         addb  ,s+
+         inca  
+endasc   rts   
+noinfo   leas  2,s
+         bra   doit
+
+data1    lda   ,x+
+         beq   nomore
+         cmpa  #C$CR
+         beq   nomore
+         cmpa  #C$SPAC
+         beq   data2
+         cmpa  #'/
+         beq   data2
+         cmpa  #':
+         beq   data2
+         suba  #'0
+         bcs   error
+         cmpa  #9
+         bhi   error
+         orcc  #4
+         rts   
+data2    tst   temp2
+         beq   data1
+         rts   
+nomore   com   temp1
+         rts   
+error    leas  4,s
+         lbra  date
+
+doit     pshs  u
+         ldb   #1
+         ldx   #$3E       disk rom
+         os9   f$mapblk
+         bcs   exit2
+         stu   locblk3E
+         ldx   #0
+         os9   f$mapblk
+         bcs   exit2
+         leax  ,u
+         stx   locblk0
+         ldu   ,s
+         bsr   reloc
+         ldb   #1
+         ldu   locblk3E
+         os9   f$clrblk
+         ldb   #1
+         ldu   locblk0
+         os9   f$clrblk
+         puls  u
+         tst   clkflag
+         bne   exit
+         lda   #2
+         leax  clknfnd,pcr
+         ldy   #40
+         os9   I$Writln
+         lda   #$11
+         ldb   #2
+         leax  setime,pcr
+         ldy   #0
+         leas  stack,u
+         leau  size,u
+         os9   F$Chain
+exit     lda   #$11
+         ldb   #2
+         leax  swread,pcr
+         ldy   #0
+         leas  stack,u
+         leau  size,u
+         os9   F$Chain
+exit2    leas  2,s
+         coma  
+         os9   F$Exit
+
+killit   lda   #C$SPAC
+         sta   daywk
+         bra   doit
+
+reloc    pshs  cc
+         lda   d.hinit,x  get $FF90 image
+         ldb   multipac
+         pshs  d
+         anda  #$CC       external disk rom access
+         orcc  #$50
+         sta   $FF90      set for external ROM
+         sta   rom
+         ldx   locblk3E
+         ldb   mpiimage   get new value
+         clr   clkflag
+
+findclk  stb   multipac   set new slot
+         leay  allert,pcr
+         lda   4,x        clear clock
+         clrb  
+         bita  #1
+         beq   low
+         comb  
+low      stb   clkbyte
+         bsr   nxtbyte
+         bsr   gettime
+         tst   clkflag
+         bne   found
+         ldb   mpiimage
+         bitb  #$30       test for last try
+         beq   found
+         subb  #$10       next slot
+         stb   mpiimage
+         lbra  findclk
+
+nxtbyte  ldb   #8         bits/byte
+         lda   ,y+
+         cmpa  #-1
+         bne   nxtbit
+         rts   
+nxtbit   lsra  
+         bcs   high
+         cmpa  ,x         talk to clock; faster than tst
+         fcb   skp2
+high     cmpa  1,x
+         decb  
+         bne   nxtbit
+         bra   nxtbyte
+
+gettime  lda   #8         bytes to read
+         pshs  a
+timebyte ldb   #8
+timebit  lsr   4,x        read clock
+         rora  
+         decb  
+         bne   timebit
+         cmpa  clkbyte
+         beq   maybe
+         inc   clkflag
+maybe    dec   ,s
+         bne   timebyte
+         leas  1,s
+         rts   
+
+found    tst   clkflag
+         beq   noclk1
+         leay  alrtimag,u
+         lda   4,x
+         bsr   nxtbyte
+noclk1   sta   ram
+         puls  d
+         stb   multipac
+         tst   cartI
+         sta   $ff90
+         puls  cc,pc
+
+allert   fcb   $C5,$3A,$A3,$5C,$C5,$3A,$A3,$5C,$ff
+crmesage fcb   C$LF
+         fcc   /Set Smartwatch/
+         fcb   C$LF
+         fcc   /(c) May, 1990 by Robert Gault/
+         fcb   C$LF
+         fcb   C$CR
+mesage1  fcc   /Select clock, timer, or disable/
+         fcb   C$LF
+         fcc   /<C>lock; <T>imer; <D>isable ->/
+mesage2  fcb   C$LF
+         fcc   /Enter the day 0-7; Mon=1 Sun=7/
+         fcb   C$LF
+         fcc   /day = ->?	/
+mesage3  fcb   C$LF
+         fcc   /Select 12 or 24 hour clock/
+         fcb   C$LF
+         fcc   /<1> = 12; <2> = 24  ->/
+mesage4  fcb   C$LF
+         fcc   /Select <A>M or <P>M ->/
+mesage5  fcb   C$LF
+         fcc   /Enter as much of the date & time as desired/
+         fcb   C$LF
+         fcc   !yy/mm/dd hh:mm:ss!
+         fcb   C$LF
+         fcc   /->/
+endmes   equ   *
+         emod  
+pgrmend  equ   *