home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / GENASM / NOSLTPOP.LBR / NOSLTPOP.ZZZ / NOSLTPOP.AZM
Text File  |  2000-06-30  |  9KB  |  312 lines

  1.  
  2. ;   NOSLTPOP.AZM     A sample program to demonstrate a pop-up clock 
  3. ;                    display for the SMT no-slot clock.
  4. ;                    Assemble with Z80MR.     R.Gaspari    11-20-87
  5.  
  6.                 
  7.     ORG     0100h           
  8.     CALL    SETUP        ; load overlay that traps ^A and ^B
  9. GET$CHAR:
  10.     LD    C,1        ; 
  11.     CALL    5        ; get a char from console
  12.     CP    3        ; if ^C then exit
  13.     JP    Z,0    
  14.     JP    GET$CHAR    ; otherwise go back for next char
  15.                 ; end of main program
  16.     
  17.  
  18. ; ************************************
  19. ;    PART I  -  HARDWARE EQUATES  
  20. ; ************************************
  21.  
  22. ROW    EQU    0        ; row and column where pop-up clock
  23. COL    EQU    50        ;    display will be seen on crt
  24.                 
  25. CA1    EQU    1BH        ; cursor addressing sequence
  26. CA2    EQU    '='        
  27. CA3    EQU    ROW+20H        
  28. CA4    EQU    COL+20H        
  29.                 
  30. CV1    EQU    18H        ; make cursor visible
  31. CV2    EQU    0        ;     (2 bytes avail)
  32. CI1    EQU    19H        ; make cursor invisible
  33. CI2    EQU    0        ;     (2 bytes avail)
  34.  
  35. CURPTR    EQU    0F400H+21EH    ; location in your bios where the pointer
  36.                 ; to current cursor location is stored
  37.  
  38. HKEY1    EQU    01H        ; hot-key 1 = single display of clock (^A)
  39. HKEY2    EQU    02H        ; hot-key 2 - continuous clk display (^B)
  40.                 
  41. M6    EQU    -6        ; a constant
  42. KBA    EQU    0D700H        ; base addr below which code below is loaded 
  43. KKS    EQU    300H        ; how far below kba the code will go
  44.  
  45. ; ******************************
  46. ;    PART II  -  SETUP
  47. ; ******************************
  48.  
  49.  
  50. SETUP:
  51.     LD    HL,(6)        ; get bdos vector DF06
  52.     LD    (KREM6),HL    ; store it for future use 
  53.     LD    DE,M6        ; get -6
  54.     ADD    HL,DE        ; HL now has DF00 (source)
  55.     LD    DE,KBA-KKS    ; DE now has D300 (destination)
  56.     LD    BC,9        ; move 9 bytes 
  57.     LDIR            
  58.                 
  59.     LD    HL,(1)        ; get warm boot vector ED03 (source)
  60.     LD    DE,KBA-KKS+9    ; DE now has D309 (destination)
  61.     LD    BC,12        ; move 12 bytes
  62.     LDIR            
  63.                 
  64.     LD    DE,KBA-KKS+21    ; DE has D315 (destination)
  65.     LD    HL,KKODE+21    ; HL points to code below
  66.     LD    BC,KSIZE    ; move bytes
  67.     LDIR            
  68.                 
  69.     LD    HL,KBDOS    ; get new bdos vector
  70.     LD    (6),HL        ; put it in place
  71.     LD    HL,(1)        ; point to actual table (dest)
  72.     EX    DE,HL        ;
  73.     LD    HL,KBOOT    ; point to replace table (source)
  74.     LD    BC,12        ; move the 12 replacement bytes 
  75.      LDIR            
  76.                 
  77.     RET            ; done with SETUP
  78.                 
  79.  
  80.          
  81. ; ***********************************************
  82. ;    PART III  -  CODE MOVED TO HIGH MEMORY
  83. ; ***********************************************
  84.  
  85. KKODE:                
  86. OK    EQU    (KBA-KKS)-KKODE        ; offset 
  87.                 
  88. KSER    EQU    $+OK        
  89.     DS    6        ; space for serial number
  90. KBDOS    EQU    $+OK        
  91.     DS    3        ; space for bdos jump
  92.  
  93. BBOOT    EQU    $+OK        
  94.     DS    3        ; orig warm boot jmp vector
  95. BSTAT    EQU    $+OK        
  96.     DS    3        ; orig console status
  97. BCONIN    EQU    $+OK        
  98.     DS    3        ; orig console input
  99. BCONOUT EQU    $+OK        
  100.     DS    3        ; orig console output
  101.                 
  102. KBOOT    EQU    $+OK        
  103.     JP    KBT        ; new warm boot vector
  104. KCSTAT    EQU    $+OK        
  105.     JP    KST        ; new console status
  106. KCONIN    EQU    $+OK        
  107.     JP    KIN        ; new console input
  108. KCONOUT    EQU    $+OK        
  109.     JP    BCONOUT        ; new console output
  110.                 
  111.  
  112. KBT    EQU    $+OK        ; NEW WARM BOOT ROUTINE 
  113.     LD    HL,(KREM6)    ; get orig bdos jmp vector
  114.     LD    (6),HL        ; put it back
  115.     LD    DE,(1)        ; point to ED03
  116.     LD    HL,BBOOT    ; get orig actual data
  117.     LD    BC,12        ; move 12 bytes
  118.     LDIR
  119.     JP    0        ; reboot to cpm ccp 
  120. KREM6    EQU    $+OK
  121.     DW    0        ; temp storage for orig bdos (DF06)
  122.  
  123.  
  124. KST    EQU    $+OK        ; NEW CONSOLE STATUS TEST FOR DATA READY
  125.     CALL    CLKPOP        ; if pop-up clk in effect, display it 
  126.     JP      BSTAT         ; then go to normal bios status
  127. CLKPOP    EQU    $+OK
  128.     LD    A,(CLKFLG)    ; see if pop-up flag is set 
  129.     OR    A        
  130.     RET    Z        ; if no, return to call clkpop
  131.     LD    A,(CLKCTR)    ; if yes, get the delay counter
  132.     INC    A        ; display clk only every 256 iterations
  133.     LD    (CLKCTR),A    ; update the counter
  134.     RET    NZ        ; if NZ, go back to call clkpop
  135.     JP    CDSP         ; otherwise, display clock 
  136. CLKFLG    EQU    $+OK
  137.     DB    0        ; set 0FFh for continuous pop-up display
  138. CLKCTR    EQU    $+OK
  139.     DB    0        ; temp storage for 256 state counter
  140.  
  141.  
  142.  
  143. KIN    EQU    $+OK        ; NEW CONSOLE INPUT ROUTINE
  144. KIN2:    CALL    KST        ; see if something is there to input
  145.     OR    A
  146.     JR    Z,KIN2        ; if not, go back and wait
  147.     CALL    BCONIN         ; if yes, get the byte using actual bios
  148.         CP    HKEY1        ; see if it's HOTKEY1    
  149.     JP    Z,CDSP       ;    (single pop-up clock request)
  150.     CP    HKEY2        ; see if it's HOTKEY2 
  151.     JR    Z,CLKREQ    ;    (continuous pop-up clk display)
  152.     CP    7FH        ; see if it's a "delete"
  153.     RET    NZ        ; if not, return with it
  154.     LD    A,08H        ; if yes, get the 7F replacement
  155.     RET            ; and return with it
  156.  
  157. CLKREQ: LD    A,(CLKFLG)    ; prepare to toggle the pop-up flag
  158.     CPL            ; complement the accumulator
  159.     LD    (CLKFLG),A    ; store it back again 
  160.     XOR    A        ; put 0 in accum before return
  161.     RET            ; retn from conin
  162.  
  163.  
  164.  
  165.  
  166. ; ****************************************
  167. ;    PART IIIb  -  CLOCK READ ROUTINE
  168. ; ****************************************
  169. ;    see NOSLT20.LBR for more info
  170.  
  171. TIME    EQU    $+OK        ; 1. - CLOCK ENABLE routine
  172.     CALL    TIXR         ; READ with addr bit A2 high
  173.     LD    HL,TIMREG    ; point to bit stream
  174.     LD    A,(HL)        ; get first byte
  175. TIBYT:  LD    B,A        ; b contains byte
  176.     LD    C,8        ; do this for 8 bits
  177. TIBIT:    SRL    B        ; 0->b7...b0->cy
  178.  
  179. TIWR:    DI
  180.     LD    A,084H        ; select PROM memory
  181.     OUT    0A0H,A        ; map it to 0000h to 4000h
  182.  
  183.     JR    NC,TIX1
  184.     LD    A,(00003H)    ; WRITE with bit A2 low & bit A0 high
  185.     JR    TIX2        
  186. TIX1:    LD    A,(00002H)    ; WRITE with bit A2 low & bit A0 low
  187. TIX2:    LD    A,0        ; select normal RAM memory
  188.     OUT    0A0H,A        ; map it onto 0000h to 4000h
  189.     EI            ; done with TIWR
  190.  
  191.         DEC    C
  192.     JR    NZ,TIBIT     ; do all 8 bits
  193.     INC    HL        ; point to next byte
  194.     LD    A,(HL)        ; get next byte
  195.     OR    A        ; set zero flag
  196.     JR    NZ,TIBYT     ; go do next byte
  197.                 ; code enable complete...
  198. TIREAD:                ; 2. - CLOCK READ routine
  199.     LD    HL,TIBUF    ; set up buffer
  200.     LD    E,8        ; do 8 bytes
  201. TIRBYT:    LD    D,8        ; do 8 bits
  202. TIRBIT:    CALL    TIXR
  203.     SRL    A        ; shift bit into cy
  204.     RR    (HL)        ; shift bit into (hl)
  205.     DEC    D        ; dec bit counter
  206.     JR    NZ,TIRBIT    ; read next bit
  207.     INC    HL        ; point to next buf location
  208.     DEC    E        ; dec byte counter
  209.     JR    NZ,TIRBYT    ; read next byte
  210.     LD    HL,TIBUF+1    ; point to data loc before RET
  211.       RET             ; and return from TIME
  212.  
  213. TIXR    EQU    $+OK
  214.     DI            ; subroutine to enable PROM
  215.      LD    A,084H        ; select PROM memory
  216.     OUT    0A0H,A        ; map it onto 0000h - 4000h
  217.  
  218.     LD    A,(00004H)    ; READ with bit A2 high 
  219.     LD    B,A        ; store in B for the return
  220.         
  221.     LD    A,0        ; select normal RAM memory
  222.     OUT    0A0H,A        ; map it onto 0000h - 4000h
  223.     LD    A,B
  224.     EI
  225.     RET            ; normal return from TIME 
  226.  
  227. TIMREG    EQU    $+OK
  228.     DB    0c5h,3ah,0a3h,5ch    ; comparison reg
  229.     DB    0c5h,3ah,0a3h,5ch,0    ; definition
  230.  
  231. TIBUF    EQU    $+OK        ; (example) Tues 10/20/87 5:15pm
  232.     DB    0,0        ; seconds    (0000)
  233.     DB    0        ; minutes    (15h)
  234.     DB    0        ; hour        (17h)
  235.     DB    0        ; day        (03h)
  236.     DB    0        ; date        (20h)
  237.     DB    0        ; month        (10h)
  238.     DB    0        ; year        (87h)
  239.  
  240. ; ****************************************
  241. ;    PART IIIc  -  POP-UP CLOCK DISPLAY 
  242. ; ****************************************
  243.  
  244. CDSP       EQU    $+OK        ; clock display code
  245.     LD    HL,(CURPTR)    ; get current cursor location
  246.     PUSH    HL        ; save it (@1)
  247.     CALL    TIME         ; call TIME & retn with pointer
  248.     LD    A,(TIBUF+7)    ; point to year 
  249.     LD    (TIBUF+4),A    ; overwrite year onto weekday
  250.  
  251.     LD    B,6        ; convert 6 binary bytes to ascii
  252.     LD    DE,CDABUF+23    ; point to end of ascii data buffer
  253. CDS2:    LD    A,(HL)        ; get the binary data
  254.     CALL    CDASC        ; convert it & store at HL & HL-1
  255.     INC    HL        ; point to next binary data
  256.     DEC    DE        ; point to next ascii buffer loc
  257.     DEC    B        ; countdown 6 binary bytes 
  258.     JR    NZ,CDS2        ;      
  259.             
  260.     LD    HL,CDABUF    ; point HL to start of cdabuf
  261.     LD    B,25        ; count 25 bytes to send out
  262. CDS4:    LD    C,(HL)        ; get the byte to send to console
  263.     CALL    BCONOUT       ; N* Adv bios conout
  264.     INC    HL        ; point to next loc
  265.     DEC    B        ; continue for all 25 bytes 
  266.     JR    NZ,CDS4
  267.  
  268.     POP    HL        ; get orig cursor location
  269.     LD    (CURPTR),HL    ; put cursor back in bios
  270.     LD    C,CV1        ; make the cursor visible again 
  271.     CALL    BCONOUT        ;      (use bios conout)
  272.     LD    C,CV2        ; byte 2 of cursor visible
  273.     CALL    BCONOUT        ;
  274.     XOR    A        ; load 0 into A before ret
  275.     RET             ; normal retn from CDSP 
  276.         
  277. CDABUF    EQU    $+OK
  278.     DB    CI1,CI2        ; make cursor display invisible
  279.     DB    CA1,CA2,CA3,CA4 ; move to location row & col
  280.     DB    ' '        
  281.     DB    0,0,'/'        ; month    ascii
  282.     DB    0,0,'/'        ; day    ascii
  283.     DB    0,0,' '        ; year    ascii
  284.     DB    0,0,':'        ; hour    ascii
  285.     DB    0,0,':'        ; min    ascii
  286.     DB    0,0,' '        ; sec    ascii
  287.  
  288. CDASC    EQU    $+OK
  289.     LD    C,A        ; binary to ascii conversion
  290.     AND    0FH        ; mask lower nibble
  291.     CALL    CDAS2        ;
  292.     LD    A,C        ; get byte back
  293.     AND    0F0H        ; mask upper nibble
  294.     RLCA             ; shift right 4 times
  295.     RLCA            ; (or left 4 times)
  296.     RLCA            ;
  297.     RLCA            ;
  298. CDAS2    EQU    $+OK
  299.     OR    30H        ; convert to ascii
  300.     LD    (DE),A        ; store it
  301.     DEC    DE        ; move to prev loc for upper nibble
  302.     RET            ; retn CDAS2 & retn CDASC
  303.  
  304.  
  305. KREF1    EQU    $        ; location of end of code (local)
  306. KREF2    EQU    $+OK        ; location of end (after it's moved)
  307. KSIZE   EQU     $-KKODE         ; the size of code to be moved
  308.  
  309.     end                ; nosltpop.azm   11-20-87
  310.  
  311.  
  312.