home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OS9_6X09 / SYSMODS / RTC_Disto_RGB_Utils.lzh / setclk.a < prev    next >
Text File  |  1989-03-13  |  4KB  |  157 lines

  1.  nam SetClk
  2.  ttl RGB Computer Systems Clock Set Program
  3. * Sets RGB or DISTO Real Time Clock Chip
  4. * Copyright (C) 1989 by RGB Computer Systems
  5.  ifp1
  6.  use /dd/DEFS/DefsFile
  7.  endc
  8. ClkType equ 0 0=RGB, 1=DISTO <--Change this for your clock type
  9.  ifeq ClkType
  10. * RGB RTClock register equates
  11. RtcWrite equ $ff75 write clock data
  12. RtcRead equ $ff76 read clock data
  13. RtcCtrl equ $ff77 write register select
  14.  else
  15. * DISTO RTClock register equates
  16. RtcWrite equ $ff50 write clock data
  17. RtcRead equ $ff50 read clock data
  18. RtcCtrl equ $ff51 write register select
  19.  endc
  20.  Mod Size,Name,Prgrm+Objct,ReEnt+1,Entry,Stack
  21. InBuf rmb 20 Line input buffer
  22. OutBuf rmb 16 Clock set buffer
  23.  rmb 200+240 stack & parameter space
  24. Stack equ .
  25. Name fcs /SetClk/
  26.  fcb 1 edition byte
  27. Entry lda ,x+ get a possible parameter
  28.  cmpa #13 end of line?
  29.  beq Setup yes, go set clock
  30.  cmpa #'- optional dash?
  31.  beq Entry yes, allow it
  32.  cmpa #'? help needed?
  33.  bne Setup no, ignore & continue
  34.  lda #2 error path
  35.  leax HelpMsg,pcr help message
  36.  ldy #HelpSize byte count
  37.  OS9 I$Write send out data
  38.  lbcs Exit exit if error
  39.  lbra OK no error
  40. Setup leax P1,pcr point to prompt
  41.  ldd #('C*256)+'R comparison bytes
  42.  cmpa ,x+ was it hacked?
  43.  lbne Error yes, exit
  44.  leax P2,pcr point to prompt
  45.  cmpb ,x+ was it hacked?
  46.  lbne Error yes, exit
  47.  lda #1 std out
  48.  leax Prompt,pcr point to prompt
  49.  ldy #PSize size of text
  50.  OS9 I$Write write it out
  51.  bcs Exit exit if error
  52. * Erase the existing buffer
  53.  ldb #16 erasing 16 bytes
  54.  leax OutBuf,u point to buffer
  55. ClrBuf clr ,x+ erase it
  56.  decb count down
  57.  bne ClrBuf go again
  58. * Now we get operator input
  59.  clra std input
  60.  leax InBuf,u input buffer
  61.  ldy #20 allow 20 characters max
  62.  OS9 I$ReadLn get input line
  63.  bcs Exit exit if error
  64.  leay -1,y no entry?
  65.  beq Exit nope, just leave
  66. * Setup control register defaults first
  67.  ldb #3 setting up last 3
  68.  leax DefData,pcr point to default register data
  69.  leay OutBuf,u point to output buffer
  70. SetDef lda ,x+ get a byte
  71.  sta ,y+ put a byte into output buffer
  72.  decb count down
  73.  bne SetDef go again
  74. * Now parse info from line input buffer
  75.  ldb #13 going to move 13 bytes
  76.  leax InBuf,u point to input buffer
  77. Loop lda ,x+ get a byte
  78.  cmpa #13 c/r?
  79.  beq Done yes, write out info
  80.  cmpa #32 space?
  81.  beq Loop yes, skip it
  82.  cmpa #': colon used?
  83.  beq Loop yes, skip it
  84.  cmpa #'/ slash used?
  85.  beq Loop yes, skip it
  86.  cmpa #'. dot used?
  87.  beq Loop yes, skip it
  88.  cmpa #', comma used?
  89.  beq Loop yes, skip it
  90.  cmpa #'0 legal?
  91.  blo Error no
  92.  cmpa #'9 legal?
  93.  bhi Error no
  94.  sta ,y+ put parsed character in buffer
  95.  decb count down
  96.  bne Loop go again
  97. Done ldb #$0f last register number
  98.  leax OutBuf,u point to data
  99. Loop2 stb RtcCtrl select register
  100.  lda ,x+ get RTC info
  101.  anda #$0f convert to BCD
  102.  sta RtcWrite set clock
  103.  decb count down
  104.  bpl Loop2 go if more
  105. * "Rest" bit is set, now select 24 hr. mode
  106.  lda #$0f last register
  107.  sta RtcCtrl select control register
  108.  lda #%00000101 24 hr. plus rest
  109.  sta RtcWrite write it in
  110.  anda #%00000100 mask off "rest" bit
  111.  sta RtcWrite write it in (locks clock mode)
  112. OK clrb no errors
  113. Exit OS9 F$Exit leave
  114. Error comb set carry
  115.  ldb #E$IllArg illegal argument error
  116.  bra Exit exit with error
  117. Prompt fcb $0a,$0d
  118. P1 fcc "Copyright (c) 1989"
  119.  fcb $0a,$0d
  120. P2 fcc "RGB Computer Systems"
  121.  fcb $0a,$0d,$0a,$0d
  122.  fcc "       w yy/mm/dd hh:mm:ss"
  123.  fcb $0a,$0d
  124.  fcc "Time ? "
  125. PSize equ *-Prompt
  126. HelpMsg fcb $07,$0a,$0d
  127.  fcc /Syntax: SETCLK [-?]/
  128.  fcb $0a,$0d
  129.  ifeq ClkType
  130.  fcc /Usage : Use to set the RGB Real Time Clock/
  131.  else
  132.  fcc /Usage : Use to set the DISTO Real Time Clock/
  133.  endc
  134.  fcb $0a,$0d,$0a,$0d
  135.  fcc / Please enter data in the following format:/
  136.  fcb $0a,$0d,$0a,$0d
  137.  fcc /          W = Day of the Week (Sunday=0)/
  138.  fcb $0a,$0d
  139.  fcc /         YY = Year, last 2 digits/
  140.  fcb $0a,$0d
  141.  fcc /         MM = Month (January=01)/
  142.  fcb $0a,$0d
  143.  fcc /         DD = Day (First day=01)/
  144.  fcb $0a,$0d
  145.  fcc /         HH = Hour (Midnight=00)/
  146.  fcb $0a,$0d
  147.  fcc /         MM = Minutes (First=00)/
  148.  fcb $0a,$0d
  149.  fcc /         SS = Seconds (First=00)/
  150.  fcb $0a,$0d
  151. HelpSize equ *-HelpMsg
  152. DefData fcb %00000001 set "rest" bit (reg $0f)
  153.  fcb %00000100 1 second period (reg $0e)
  154.  fcb %00000000 no hold or irq (reg $0d)
  155.  emod
  156. Size equ *
  157.  end