home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol141 / osbdumb.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  9.7 KB  |  344 lines

  1.     PAGE    60
  2. ;************************************************************************
  3. ;*                                    *
  4. ;*    This program is designed to allow the Osborne to act as a    *
  5. ;*    Dumb Terminal (e.g. to "talk" to other micro computers -     *
  6. ;*    Superbrain, Sorcerer, Osborne, etc. or to connect to a time    *
  7. ;*    sharing bureau - The "SOURCE", The Australian Beginning, etc.)    *
  8. ;*                                    *
  9. ;*    It has the ability to provide a hardcopy of the dialog,        *
  10. ;*    but the printer cannot be assigned to the serial interface    *
  11. ;*    of the Osborne-1 (actually this should be obvious cos u r     *
  12. ;*    using the serial interface to talk to the modem, other m/c etc)    *
  13. ;*                                    *
  14. ;*    This is a heavily modified version of a DUMB TERMINAL program    *
  15. ;*    written for a Superbrain Computer by Tony Lonsdale        *
  16. ;*    Current date = 28th March 1983                    *
  17. ;*                                                                      *
  18. ;************************************************************************
  19.     .Z80
  20. ;
  21. ;    EQUATES
  22. ;
  23. BDOS    EQU    5
  24. JUMP    EQU    0C3H        ;The op. code for JP(can't us opcodes as operands in Z80 mode)
  25. NOOP    EQU    00H        ;The op. code for NOP 
  26. RETURN    EQU    0C9H        ;The op. code for RET
  27. CTRLE    EQU    05H        ;Control/E used to indicate end of DUMB
  28. CTRLD    EQU    04H        ;Control/D used to switch duplex mode
  29. CTRLP    EQU    10H        ;Control/P used to toggle printing
  30. STRING    EQU    9        ;CP/M code to print a string on screen
  31. LIST    EQU    5        ;CP/M code for list output
  32. IOBYTE    EQU    7        ;CP/M code to get the iobyte
  33. CONWRT    EQU    2        ;CP/M code for console write
  34. CIN    EQU    1        ;CP/M code for console char input
  35. WBOOT    EQU    0        ;WARM BOOT ADDRESS
  36. ;
  37. INIT:    LD    (STACKS),SP
  38.     LD    SP,STACK    ;set our stack
  39.     LD    HL,ACIART    ;move the acia
  40.     LD    DE,ACIACN    ;routines to where
  41.     LD    BC,ACIAL    ;they should be
  42.     LDIR
  43.     LD    C,STRING
  44.     LD    DE,STMSG
  45.     CALL    BDOS        ;Ask operator if Half or Full Duplex
  46.     LD    C,CIN
  47.     CALL    BDOS
  48.     LD    DE,FULMSG
  49.     CP    'H'
  50.     JP    NZ,FULL
  51.     LD    A,1
  52.     LD    (DUPLEX),A    ;Put non-zero value into indicator
  53.     LD    DE,HAFMSG
  54. FULL:
  55.     LD    C,STRING
  56.     CALL    BDOS        ;Print msg acknowledging Duplex mode
  57.     LD    C,STRING
  58.     LD    DE,BAUDMSG
  59.     CALL    BDOS        ;Ask what speed 
  60.     LD    C,CIN
  61.     CALL    BDOS
  62.     CP    '2'
  63.     JR    Z,S1200
  64.     LD    A,56H        ;Data to set speed to 300 baud
  65.     JR    SETBAUD        ;and skip
  66. S1200:    LD    A,55H        ;Data to set speed to 1200 baud
  67. SETBAUD: LD    (BAUD),A    ;Save it
  68.     LD    A,57H        ;Reset ACIA
  69.     CALL    ACIACN        ;go do it
  70.     NOP            ;wait a while
  71.     NOP
  72.     NOP
  73.     NOP
  74.     LD    A,(BAUD)    ;pick up the baud rate
  75.     CALL    ACIACN        ;go do it
  76.     NOP            ;wait a while
  77.     NOP
  78.     NOP
  79.     NOP
  80.     LD    C,STRING
  81.     LD    DE,SPEED
  82.     CALL    BDOS        ; Let him know that speed set
  83.     LD    C,STRING
  84.     LD    A,(BAUD)
  85.     LD    DE,S1
  86.     CP    55H
  87.     JR    NZ,SKIP
  88.     LD    DE,S2
  89. SKIP:    CALL    BDOS
  90.     LD    C,IOBYTE    ;pick up the iobyte
  91.     CALL    BDOS        ;to check LST: assignment
  92.     BIT    6,A        ;if this bit on, need to check bit 7
  93.     JP    Z,IOOK        ;else it's alright
  94.     BIT    7,A        ;If bit 7 is also on, that's ok
  95.     JP    NZ,IOOK
  96.     LD    DE,BADLST
  97.     LD    C,STRING    ;tell the user
  98.     CALL    BDOS
  99.     LD    A,RETURN    ;get rid of the routine to add  
  100.     LD    (BUFFADD),A    ;to the printer buffer 
  101. IOOK:
  102.     LD    DE,FINMSG
  103.     LD    C,STRING
  104.     CALL    BDOS
  105.     LD    HL,(1)        ;Find BIOS Warm Boot entry point
  106.     LD    DE,3        ;BIOS JP instr's are 3 bytes long
  107.     ADD    HL,DE
  108.     LD    (CONST+1),HL    ;Address of BIOS Console Status routine
  109.     ADD    HL,DE
  110.     LD    (CONIN+1),HL    ;Address of BIOS Console Input routine
  111.     ADD    HL,DE
  112.     LD    (CONOUT+1),HL    ;Address of BIOS Console Output routine
  113.     ADD    HL,DE
  114.     ADD    HL,DE
  115.     LD    (PUNCH+1),HL    ;Address of BIOS PUNCH Output routine
  116.     ADD    HL,DE
  117.     LD    (RDR+1),HL    ;Address of BIOS READER Input routine
  118.     LD    DE,18H
  119.     ADD    HL,DE        ;Address of bios list status routine
  120.     LD    (LSTSTAT+1),HL
  121.     LD    DE,36H
  122.     ADD    HL,DE        ;Address of serial status routine
  123.     LD    (SERSTAT+1),HL
  124.     PAGE
  125. ;
  126. DUMB:
  127.     CALL    BUFPRT        ;print a char from circular buffer
  128.     CALL    SERSTAT        ;check if any char from modem
  129.     AND    01H        ;Mask of bits we don't want
  130.     CP    01H        ;Is the Receive Data Register full?
  131.     JP    NZ,KEYBD    ;No, check keyboard
  132.     CALL    RDR        ;Get that char
  133.     AND    7FH        ;Take the top bit off
  134.     CALL    VIDEO        ;We have a character from Main Port
  135. ;                ;so display it on the screen.
  136. KEYBD:    CALL    CONST        ;Check the kayboard status
  137.     JP    Z,DUMB        ;No key pressed, so go round again.
  138.     CALL    CONIN        ;Get the key that was typed
  139.     CP    CTRLE        ;Ctrl/E?
  140.     JP    Z,WBOOT     ;Yes, back to CP/M
  141.     CP    CTRLP        ;CTRL/P ?
  142.     JP    Z,FLIPP        ;Yes, flip-flop the list device    
  143.     CP    CTRLD        ;CTRL/D ?
  144.     JP    Z,FLIPD        ;Yes, flip-flop the duplex bit    
  145.     LD    E,A
  146.     LD    A,(DUPLEX)    ;Should we echo
  147.     OR    A    
  148.     JP    Z,NOECHO
  149.     CALL    VIDEOE        ;Yes, echo to screen
  150. NOECHO:    
  151.     LD    C,E
  152.     CALL    PUNCH        ;Send it out to the Main Port
  153.     JP    DUMB        ;Now go see if there are any more.
  154. ;
  155. ;  Routine to send a character to the screen.
  156. ;
  157. VIDEO:    
  158.     LD    E,A
  159. VIDEOE:
  160.     PUSH    DE
  161.     LD    C,CONWRT
  162.     CALL    BDOS        ;Display on screen
  163.     POP    DE
  164.     LD    A,(SWITCH)    ;Should we echo to the printer?
  165.     OR    A
  166.     RET    Z        ;Nope
  167.     PUSH    DE        ;Better hang on to it again
  168.     CALL    BUFFADD        ;add char to circular print buffer
  169.     POP    DE
  170.     RET
  171. ;
  172. ;  Routine to flip/flop the list device switch (controlled by ^P)
  173. ;
  174. FLIPP:    LD    A,(SWITCH)
  175.     XOR    1        ;Flip/flop the switch
  176.     LD    (SWITCH),A
  177.     JP    DUMB
  178.  
  179. FLIPD:    LD    A,(DUPLEX)
  180.     XOR    1        ;Flip/flop the switch
  181.     LD    (DUPLEX),A
  182.     JP    DUMB
  183. ;    Routine to add a characetr to the circular print buffer
  184. ;    This routine is necessary to allow time for the printer to 
  185. ;    print a line, and do a carriage return
  186. ;
  187. BUFFADD:
  188.     DB    NOOP        ;overwritten by a RET if iobyte is wrong
  189.     LD    A,E        ;char is given to us in E
  190.     LD    DE,(NXTAVAIL)    ;next available byte in buffer
  191.     LD    (DE),A        ;insert the character
  192.     INC    DE        ;increment 'nxtavail' pointer
  193.     LD    HL,BUFEND    ; find the end of buffer
  194.     OR    A        ;clear carry flag
  195.     SBC    HL,DE        ;is nxtavail past end of buffer
  196.     JR    NC,NOTYET
  197.     LD    DE,PBUFF    ;paast the end so go back to start
  198. NOTYET: LD    (NXTAVAIL),DE    ;save the pointer for next time
  199.     RET
  200. ;
  201. ;    This routine checks to see if the printer is ready to
  202. ;    receive another char, and if it is, it checks to see 
  203. ;    if there is a char to print from the circular print 
  204. ;    buffer, gets it from the buffer and sends it to the printer,
  205. ;    otherwise it just returns from whence it came
  206. BUFPRT:
  207.     LD    DE,(NXTPRINT)    ;where is printer up to?
  208.     LD    HL,(NXTAVAIL)    ;where is buffer up to?
  209.     SBC    HL,DE        ;is there anything to print
  210.     RET    Z        ;not yet!
  211. ;
  212.     CALL    PRTSTAT        ;is the printer ready for this?
  213.     RET    Z        ;not yet
  214. ;
  215.     EX    DE,HL        ;HL haa address of next character to print
  216.     LD    E,(HL)        ;get that character
  217.     LD    C,LIST
  218.     CALL    BDOS        ;go print it
  219.     LD    DE,(NXTPRINT)
  220.     INC    DE        ;incerment 'NXTPRINT' pointer
  221.     LD    HL,BUFEND    ;end of PBUFF
  222.     SBC    HL,DE        ;is NXTPRINT past end of buffer
  223.     JR    NC,NOTPAST
  224.     LD    DE,PBUFF    ;reset to start
  225. NOTPAST:LD    (NXTPRINT),DE
  226.     RET
  227. PRTSTAT: PUSH    BC
  228.     PUSH    DE
  229.     PUSH    HL
  230.     CALL    LSTSTAT
  231.     POP    HL
  232.     POP    DE
  233.     POP    BC
  234.     RET
  235. ;
  236. CONST:    DB    JUMP
  237.     DW    0
  238. CONIN:    DB    JUMP
  239.     DW    0
  240. CONOUT:    DB    JUMP
  241.     DW    0
  242. PUNCH:    DB    JUMP
  243.     DW    0
  244. RDR:    DB    JUMP
  245.     DW    0
  246. LSTSTAT: DB    JUMP
  247.     DW    0
  248. SERSTAT: DB    JUMP
  249.     DW    0
  250. ;
  251. STACKS:    DW    0    ;Stack save area
  252. SWITCH:    DB    0    ;Printer flip/flop (0 = no print, 1 = print)
  253. BAUD:    DB    0    ;Storage for selected baud rate 
  254. DUPLEX:    DB    0    ;0 = FULL DUPLEX
  255. NXTAVAIL: DW    PBUFF    ;address of next empty space in PBUFF
  256. NXTPRINT: DW    PBUFF    ;address of next chat to print in PBUFF
  257. STMSG:    DB    26,10,9,9,'DUMB for the OSBORNE-1 as at March 28,1983'
  258.     DB    13,10,10,'Would you like H-alf or F-ull duplex <F> $'
  259. FULMSG:    DB    13,10,10,9,9,'*** FULL DUPLEX ***',13,10,10
  260.     DB    'Expecting the other system to echo our keystrokes$'
  261. HAFMSG:    DB    13,10,10,9,9,'*** HALF DUPLEX ***',13,10,10
  262.     DB    'Not expecting an echo from the other system.',13,10
  263.     DB    'All keystrokes will be echoed on the screen before',10,13
  264.     DB    'transmission.$'
  265. BAUDMSG: DB    13,10,'Set the Communications speed'
  266.     DB    13,10,'Enter 1 for 300, or 2 for 1200 <1>$'
  267. SPEED:    DB    13,10,10,'Speed has been set to $'
  268. S1:    DB    '300 Baud$'
  269. S2:    DB    '1200 Baud$'
  270. FINMSG:    DB    13,10,10,'Enter Ctrl/E to exit.',13,10 
  271.     DB    'Enter Ctrl/P to echo to printer.',13,10
  272.     DB    'Enter Ctrl/D to switch between FULL and HALF Duplex.',10,13,'$'
  273. BADLST:    DB    13,10,'The IOBYTE is not set correctly,'
  274.     DB    13,10,'and  there will be NO hardcopy'
  275.     DB    13,10,'Either use STAT to set the LST: device to the Parallel'
  276.     DB    13,10,'port or the IEEE port, or accept NO HARDCOPY$'
  277.  
  278.     PAGE
  279. ACIART:
  280. ;
  281. ;********************************************************
  282. ;*                            *
  283. ;*    ACIA ROUTINES . TO BE RELOCATED AT 4000H TO     *
  284. ;*        ALLOW BANK SWITCHING            *
  285. ;*                            *
  286. ;********************************************************
  287.     .PHASE    4000H    ;locate these routines above 4000h 
  288. ;            ;to allow them to bank switch
  289. ;
  290. ;********************************************************
  291. ;*                            *
  292. ;*    ACIACN    SENDS THE CHAR IN A TO THE ACIA CONTROL *
  293. ;*                            *
  294. ;********************************************************
  295. ACIACN:    DI        ;cos its necessary
  296.     OUT    (0),A    ;Switch to bank 2
  297.     LD    (2A00H),A ;Thats where the control port is
  298.     OUT    (1),A    ; and back to bank 1
  299.     EI        ; seems a good idea
  300.     RET        ; and back from whence we came
  301. ;
  302. ;********************************************************
  303. ;*                            *
  304. ;*    ACIAST    GETS THE ACIA STATUS IN A        *
  305. ;*                            *
  306. ;********************************************************
  307. ACIAST:    DI        ;cos its necessary
  308.     OUT    (0),A    ;Switch to bank 2
  309.     LD    A,(2A00H) ;Thats where the control port is
  310.     OUT    (1),A    ; and back to bank 1
  311.     EI        ; seems a good idea
  312.     RET        ; and back from whence we came
  313. ;
  314. ;********************************************************
  315. ;*                            *
  316. ;*    ACIAOT    SENDS THE CHAR IN A TO THE ACIA DATA    *
  317. ;*                            *
  318. ;********************************************************
  319. ACIAOT:    DI        ;cos its necessary
  320.     OUT    (0),A    ;Switch to bank 2
  321.     LD    (2A01H),A ;Thats where the control port is
  322.     OUT    (1),A    ; and back to bank 1
  323.     EI        ; seems a good idea
  324.     RET        ; and back from whence we came
  325. ;
  326. ;********************************************************
  327. ;*                            *
  328. ;*    ACIAIN    GETS THE CHAR FROM THE DATA PORT IN A    *
  329. ;*                            *
  330. ;********************************************************
  331. ACIAIN:    DI        ;cos its necessary
  332.     OUT    (0),A    ;Switch to bank 2
  333.     LD    A,(2A01H) ;Thats where the data port is
  334.     OUT    (1),A    ; and back to bank 1
  335.     EI        ; seems a good idea
  336.     RET        ; and back from whence we came
  337. STACK    EQU    $+250    ;Last 250 bytes for the stack
  338.     .DEPHASE
  339. ACIAL    EQU    $-ACIART
  340. PBUFF    EQU    $
  341. BUFEND    EQU    03FFFH    ; may as well use all the vacant space
  342.     END
  343.