view level1/modules/clock2_dw3.asm @ 2730:6bd6e348665d

Working on cloned default branch, pulled 2012/11/03 user: gheskett@wdtv.com branch 'default' changed ChangeLog changed ReadMe changed defs/rbf.d changed defs/rbsuper.d changed defs/scsi.d changed level1/atari/cmds/fuji.asm changed level1/coco/modules/makefile changed level1/modules/boot_scsi.asm changed level1/modules/superdesc.asm changed level2/coco3/bootfiles/makefile changed level2/coco3/modules/makefile changed level2/coco3_6309/bootfiles/makefile changed level2/modules/joydrv_6551L.asm changed rules.mak
author gheskett@wdtv.com
date Sat, 10 Nov 2012 11:55:48 -0500
parents 2ebf5e737ceb
children 8399491c0821
line wrap: on
line source

********************************************************************
* Clock2 - DriveWire 3 RTC Driver
*
* $Id$
*
* Edt/Rev  YYYY/MM/DD  Modified by
* Comment
* ------------------------------------------------------------------
*   1      2004/08/18  Boisy G. Pitre
* Separated clock2 modules for source clarity.
*
*   2      2010/01/02  Boisy G. Pitre
* Saved some bytes by optimizing

          nam       Clock2
          ttl       DriveWire 3 RTC Driver

          ifp1            
          use       defsfile  
          use       drivewire.d  
          endc            

tylg      set       Sbrtn+Objct
atrv      set       ReEnt+rev
rev       set       $00
edition   set       2


RTC.Base  equ       $0000     

          mod       eom,name,tylg,atrv,JmpTable,RTC.Base

name      fcs       "Clock2"  
          fcb       edition

subname   fcs       "dw3"

* Three Entry Points:
*   - Init
*   - GetTime
*   - SetTIme
JmpTable                 
          bra       Init
          nop
          bra       GetTime   	RTC Get Time
          nop

SetTime   pshs      u,y,x,d
          IFNE      atari
          tst       D.ATARIFLAGS
          bmi       UpdLeave
          ENDC
          IFGT      Level-1
          ldu       <D.DWSubAddr
          ELSE
          ldu       >D.DWSubAddr
          ENDC
          beq       UpdLeave      in case we failed to link it, just exit
          lda       #OP_SETTIME
          pshs      a
          ldy       #$0001
          leax      ,s
          jsr       DW$Write,u
          puls      a
          ldx       #D.Year
          ldy       #$0006
          jsr       DW$Write,u
          bra       UpdLeave

GetTime 
          lda       #OP_TIME        Time packet
          pshs      u,y,x,d
          IFNE      atari
          tst       D.ATARIFLAGS
          bmi       UpdLeave
          ENDC
          IFGT      Level-1
          ldu       <D.DWSubAddr
          ELSE
          ldu       >D.DWSubAddr
          ENDC
          beq       UpdLeave      in case we failed to link it, just exit
          leax      ,s
          ldy       #$0001
          jsr       DW$Write,u
          ldx       #D.Year
          ldy       #$0006
          jsr       DW$Read,u
UpdLeave  puls      d,x,y,u,pc


Init     
* Check if subroutine already linked
          IFGT      Level-1
          ldx       <D.DWSubAddr
          ELSE
          ldx       >D.DWSubAddr
          ENDC
          bne       leave
          IFGT      Level-1
          ldx       <D.Proc
          pshs      x
          ldx       <D.SysPrc
          stx       <D.Proc
          ENDC
          leax      subname,pcr
          clra
          os9       F$Link
          IFGT      Level-1
          puls      x
          stx       <D.Proc
          bcs       leave
          sty       <D.DWSubAddr
          ELSE
          bcs       leave
          sty       >D.DWSubAddr
          ENDC
          jmp       ,y			call initialization routine
leave     rts

          emod          
eom       equ   *         
          end