home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / apple / thunder.azm / THUNDER.ASM
Assembly Source File  |  1988-01-02  |  4KB  |  93 lines

  1. * Program Generated 1 August 1982 
  2. * Author            Michael W. Foley
  3. * With assist from  Jim Moore using a program originaly written for the
  4. *                   Promethious multifunction card, for the Apple ][.
  5. *
  6. *
  7. * This program will allow you to use a Thunderclock from Apple CP/M.
  8. * The only equate that needs to be changed for your Apple is the location
  9. * of the Slot of the Thunderclock.
  10. * This is set into two of the equates both A$CKW for a write to the clock
  11. * and A$CKR for a read from the clock, as CNxx, where N is your slot #.
  12. *
  13. * The program at the bottom of the assembler routines is an example of a
  14. * clock data read program to use if you are going to use a MBASIC program
  15. * to obtain the clock data from the GETLN Buffer area of the Apple.  It
  16. * can be implimented as a subroutine in your program.
  17. *
  18.                 ;**** Equates ****
  19.                 ;
  20. FALSE    EQU    00H    ; define true and false for conditional assembly
  21. TRUE    EQU    NOT FALSE    ; true = FFFFH
  22. BASIC    EQU    FALSE    ; set to true if using this as a asm subroutine
  23.             ; called from a Mbasic program.
  24.                 ;
  25. BDOS    EQU    05H    ; CP/M Bdos call address
  26. Z$CPU    EQU    0F3DEH    ; Address of Softcard found here
  27. A$VEC    EQU    0F3D0H    ; 6502 subroutine address goes here
  28. A$ACC    EQU    0F045H    ; 6502 accumulator pass area for data
  29.                     ;
  30.                     ;
  31. A$CKW    EQU    0C50BH    ; Clock dependent call address for write
  32.                     ;
  33.                     ;
  34. A$CKR    EQU    0C508H     ; Clock dependent call address for read 
  35.                     ;
  36. Z$TMB    EQU    0F201H    ; start of the GETLN BUFFER
  37.                     ;
  38.                     ; Character string length from Thunderclock
  39. Z$FML    EQU    019H    ; 25 characters total length
  40.                      ;
  41.                      ; Format character to write to the clock
  42. Z$FMT    EQU    '>'    ; AP/PM format.
  43.                      ;
  44.                     ;
  45.      ORG    0100H    ; Put this where you want it, here for TPA
  46.            MVI    A,Z$FMT    ; get the format character in accumulator
  47.          STA    A$ACC    ; pass it to the 6502 Accumulator at $45
  48.          LXI    H,A$CKW    ; Set up for clock write to set format
  49.          SHLD    A$VEC    ; Tell the 6502 where the subroutine is
  50.          LHLD    Z$CPU    ; get the Softcard address
  51.           MOV    M,A    ; call the 6502 subroutine
  52.                     ; 6502 returns here after setting the proper format 
  53.             ; on the clock
  54.         LXI    H,A$CKR    ; Set up for clock read
  55.         SHLD    A$VEC    ; Tell the 6502 where the subroutine is
  56.         LHLD    Z$CPU    ; get the Softcard return address
  57.           MOV    M,A    ; call the 6502 subroutine for clock read
  58.                     ; conditional assembly depending on if you want to 
  59.             ; allow the asm subroutine
  60.                     ; to print the time string to the console or use a 
  61.             ; Mbasic routine to strip
  62.                     ; the characters out of memory via peeks and string 
  63.             ; concat routines.
  64.            IF    BASIC    ; if you are going to use a Mbasic routine set
  65.                    ; the BASIC equate to TRUE.
  66.            RET        ; Return to basic caller
  67.            ENDIF        ; Basic is being used to obtain characters
  68.                     ;
  69.         IF NOT BASIC    ; don't assemble if not needed
  70.         MVI    A,'$'    ; prepare to concat this onto the end of the string
  71.                    ; due to Bdos expecting it as an end of string marker.
  72.         STA    Z$TMB+Z$FML+1    ; concat to the end of the string
  73.         MVI    C,09H    ; Set up to call Bdos string printing routine
  74.          LXI    D,Z$TMB    ; point to the beginning of the GETLN buffer
  75.                    ; begin the read at this point.
  76.         CALL    BDOS    ; write the GETLN buffer to the console device for
  77.                    ; the length of characters output by the clock.
  78.            RET        ; back to the caller
  79.            ENDIF        ; not basic caller
  80.            END        ; of this program for the Thunderclock + for the
  81. *
  82. * MBASIC ROUTINES TO READ THE THUNDERCLOCK DATE TIME STRING FROM MEMORY
  83. *    10    FML = &H19 'Length of clock character string
  84. *    20    DG$ = " "  'Character to clear the time
  85. *    30    FOR X = &H201 th &H201+FML  'Loop to get characters
  86. *    40    DG$ = DG$ + CHR$(PEEK(X))  'One charater at a time
  87. *    50    NEXT I
  88. *    60    ' Now DG$ holds the time form the Thunderclock
  89. *
  90. *    Now you can use the MBASIC MID$ function to get the data you
  91. *    want from the Thunderclocks time string.
  92.