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 / ENTERPRS / CPM / TERMS / QTPATCH.ARC / QT-JOYCE.ASM < prev    next >
Assembly Source File  |  1989-09-08  |  4KB  |  179 lines

  1. ; This is a patch for QTERM and the Joyce/PCW8256 with serial
  2. ; interface CPS8256.  It is developed out of other patches and by digging
  3. ; into the OS routines, since I don't have the proper documentation. As
  4. ; far as I know this information isn't available at bookstores etc.
  5. ; I even had to guess the right SIO and timer type...
  6. ; It seems to work fine, altough I can't promise it will work on every
  7. ; Joyce with every configuration. The only problem is that the the
  8. ; program and/or the computer are a bit too slow for speeds above 1200
  9. ; baud. After a clear-screen the emulator misses some characters, and
  10. ; sometimes after a return it misses one character.  On Unix systems this
  11. ; is no problem, since pading can be properly specified. But on a lot of
  12. ; systems padding is unknown, so if someone knows the answer to this
  13. ; problems I'd like to hear. Also if there are bugs, missing features
  14. ; or other terrible shortcommings please contact me.
  15. ;
  16. ; Greetings, Otto Moerbeek
  17.  
  18. TRUE    equ 0ffh
  19. FALSE    equ 0
  20. ESC    equ '['-40h
  21. scrout    equ 109h    ; Address of routine to put a char on screen
  22. siod    equ 0e0h    ; Data port
  23. sioc    equ port+1    ; Control port
  24. siobs    equ 0e4h    ; Send baudrate port
  25. siobr    equ siobs+1    ; Receive baudrate port
  26. siot    equ 0e7h    ; Timer port
  27.  
  28. modist    org 110h    ; Check input status
  29.     in sioc
  30.     ani 1        ; Bit 0 is 'char available' bit
  31.     ret
  32. modin    org 120h    ; Get char
  33.     in siod
  34.     ret
  35. modost    org 130h    ; Check output status
  36.     in sioc
  37.     ani 4        ; Bit 2 is 'ready to send' bit
  38.     ret
  39. modout    org 140h    ; Put char
  40.     out siod
  41.     ret
  42. sbreak    org 150h    ; Set break bit
  43.     mvi a,5        ; Break bit is controlled by register 5
  44.     out sioc
  45.     lda r5        ; Get old value
  46.     ori 10h        ; Set bit 4
  47.     out sioc
  48.     ret
  49. ebreak    org 160h    ; Restore old situation
  50.     mvi a,5
  51.     out sioc
  52.     lda r5
  53.     out sioc
  54.     ret
  55. dtroff    org 170h    ; Drop DTR
  56.     mvi a,5
  57.     out sioc
  58.     lda r5        ; Get old value
  59.     ani 7fh        ; Clear bit 7
  60.     out sioc
  61.     ret
  62. dtron    org 180h
  63.     jmp ebreak
  64. setbd    org 190h    ; Set baudrate
  65.     call compbaud    ; First get right value in bc
  66.     mov a,b        ; Low byte to send-baudrate port
  67.     out siobs
  68.     mov a,c        ; And high byte
  69.     out siobs
  70.     mov a,b        ; Same for receive-baudrate port
  71.     out siobr
  72.     mov a,c
  73.     out siobr
  74.     ret
  75.             
  76. brtab    org 1a0h     ; offsets into table
  77.     db 0,FALSE,0,FALSE,0,TRUE,2,TRUE,4,TRUE,6,TRUE,8,TRUE,10,TRUE
  78. setmod    org 1b0h
  79.     jmp domod
  80. r5      db 0aah        ; Save value for reg 5
  81. modtab    org 1c0h
  82.     db 00h,0c0h,08h,0c8h,03h,0c3h,0bh,0cbh,01h,0c1h,09h,0c9h
  83. xfersz    org 1cdh
  84.     db 8
  85. speed    org 1ceh
  86.     db 4
  87. escape    org 1cfh
  88.     db '\'-40h
  89. signon    org 1d0h
  90.     db 'Joyce',0
  91.  
  92. clrscr    org 1f0h
  93.     db ESC,'H',ESC,'E',0
  94. moveto    org 200h
  95.     push h
  96.     mvi c,ESC
  97.     call scrout
  98.     mvi c,'Y'
  99.     call scrout
  100.     pop h
  101.     push h
  102.     mov a,h
  103.     call poff
  104.     pop h
  105.     mov a,l
  106. poff    adi ' '
  107.     mov c,a
  108.     jmp scrout
  109. baudtab    dw 13,26,52,104,208,416 ; Here some space remained for
  110.                 ; baudrate table
  111.  
  112. tcbits    org 22fh
  113.     db 0dfh        ; We miss insert char
  114. brites    org 230h    ; Various string for screen
  115.     db ESC,'q',0
  116. dims    org 238h
  117.     db ESC,'p',0
  118. dlstr    org 240h
  119.     db ESC,'M',0
  120. ilstr    org 248h
  121.     db ESC,'L',0
  122. dcstr    org 250h
  123.     db ESC,'N',0
  124. icstr    org 258h
  125.     db 0
  126. ceol    org 260h
  127.     db ESC,'K',0
  128. ceos    org 268h
  129.     db ESC,'J',0
  130.  
  131. entry    org 270h
  132.     jmp init
  133. exit    org 273h
  134.     ret
  135. patch    org 276h
  136. init    mvi a,0        ; Reset SIO
  137.     out sioc
  138.     mvi a,18h
  139.     out sioc
  140.     mvi a,0c0h    ; Init on 8 bits, no parity and 1 stop bit
  141.     call domod
  142.     mvi a,6        ; 1200 baud
  143.     call setbd
  144.     ret
  145. compbaud        ; Compute offset into baudrate table
  146.     mov e,a
  147.     mvi a,36h    ; But first init timer
  148.     out siot
  149.     lxi h,baudtab
  150.     mvi d,0
  151.     dad d
  152.     mov b,m        ; Move offset to bc
  153.     inx h
  154.     mov c,m
  155.     ret
  156.  
  157. domod    mov c,a        ; Do mode change, save code in c
  158.     mvi a,3        ; Firts reg 3
  159.     out sioc
  160.     mov a,c        ; Retrieve code
  161.     ani 80h        ; Only bit for receive bits/char
  162.     ori 41h        ; Rest stays 41h
  163.     out sioc
  164.     mvi a,4        ; Now reg 4
  165.     out sioc
  166.     mov a,c        ; Retrieve code
  167.     ani 0bh        ; We only wants bits 0,1 and 3 to be
  168.     ori 44h        ; changed, rest stays 44h
  169.     out sioc
  170.     mvi a,5        ; Reg 5
  171.     out sioc
  172.     mov a,c        ; Restrieve code
  173.     ani 40h        ; Only send bits/char
  174.     ori 0aah    ; Rest of bits stay 0aah
  175.     sta r5        ; Store value for break and DTR routines
  176.     out sioc
  177.     ret
  178.