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 / BYE5 / B5AB-1.IQS / B5AB-1.INS
Text File  |  2000-06-30  |  13KB  |  503 lines

  1. ; B5AB-1.INS - BYE5 inset for Apple // with ALS CP/M card - 03/14/86
  2. ;
  3. ;           6551 with internal baudrate generator
  4. ;
  5. ;
  6. ; This version is for Apple ][ computers using the Advanced Logic Sys-
  7. ; tems (ALS) CP/M Card and Apple Super Serial Card.  The ALS CP/M card
  8. ; runs CP/M v3.0.
  9. ;
  10. ; NOTE:  This is an insert, not an overlay.
  11. ;
  12. ;=======================================================================
  13. ;
  14. ; 03/14/86  Written for use with BYE5    - Jerry Levy
  15. ;
  16. ;=======================================================================
  17. ;
  18. ; CONNECTING MODEM TO SSC:
  19. ;
  20. ;    MODEM=DCE            Super Serial Card
  21. ;
  22. ;    TXD    2  -------->    2    RXD    received data
  23. ;    RXD    3  <--------    3    TXD    tranmitted data
  24. ;    SG    7  ---------    7    SG    signal ground
  25. ;    DCD    8  -------->    6    DSR    data set ready
  26. ;    DTR    20 <-------    20    DTR    data terminal ready
  27. ;                8-->20    DCD-->DSR (SSC side only)
  28. ;
  29. ; This cable configuration uses DSR signal at the SSC to check carrier.
  30. ; Also, Serial card DCD wired to DTR so that modem result codes are
  31. ; received when carrier is off.
  32. ;
  33. ; Set modem switches as defined in B5IM-1.DQC.
  34. ;
  35. ; THIS WORKS PROPERLY WITH BYE5 AND IS COMPATIBLE WITH IMP WITHOUT ANY
  36. ; CHANGES. ANY OTHER CONFIGURATION MIGHT REQUIRE RESETTING SOME MODEM
  37. ; SWITCHES WHEN GOING FROM BYE5 TO IMP, MDM7, MEX, ETC.
  38. ;
  39. ;-----------------------------------------------------------------------
  40. ;
  41. ;NOTES:
  42. ;  1.    Check that SLOT equate is OK.  This is the only change you
  43. ;    need to make in this insert.
  44. ;
  45. ;  2.    We do not need to identify a free area in common memory (for
  46. ;    relocation of bank-switching routines or as safe haven for a
  47. ;    replacement jump table) as has to be done for the Osborne and
  48. ;    Morrow machines.  We are spared this because ALS BIOS's allocate
  49. ;    enough common memory space that the code segments in question,
  50. ;    which are in the BYE5 RSX, sit there in memory space that is
  51. ;    common to all banks.
  52. ;
  53. ;    See the discussion by James Dunn in his B5LO-1.INS insert if
  54. ;    you want to learn more...
  55. ;
  56. ;-----------------------------------------------------------------------
  57. ;
  58. SLOT    EQU    2        ; Slot 2 is normal
  59. OFFS    EQU    16*SLOT        ; This is the slot offset
  60. ;
  61. ;
  62. ; Modem port addresses.  Apple addresses for direct access of SSC 6551
  63. ; ACIA registers
  64. ;
  65. PORT    EQU    0C088H+OFFS    ; SSC ACIA Data port
  66. STPORT    EQU    PORT+1        ; SSC ACIA Status port
  67. CPORT    EQU    PORT+2        ; SSC ACIA Command port
  68. BRPORT    EQU    PORT+3        ; SSC ACIA Control/Baudrate port
  69. ;
  70. ;-----------------------------------------------------------------------
  71. ;
  72. ; Initialize BIOS addresses and insert in PEEK, POKE and bank-switching
  73. ; routines.  Whichever of PEEK, POKE or MDPREP is called first funnels a
  74. ; call through ALS1, ALS2, or ALS3 to ALSINIT.    ALSINIT computes and
  75. ; stores the BIOS addresses, also overwrites the calls to ALS1-3 so it
  76. ; doesn't get called more than once.  This initialization saves having
  77. ; to wade through the BIOS for addresses and simplifies installation for
  78. ; the different BIOS's for the ALS CP/M Card.
  79. ;
  80. ; The APREAD and APWRITE stuff is specific to the Apple ][ with ALS CP/M
  81. ; Card, but the concept of more automated installation should be more
  82. ; broadly applicable.
  83. ;
  84. ALS1:    CALL    ALSINIT        ; Do the initialization, and then do the
  85. APRD1:    CALL    0000H        ; 'read' we thought we were going to do.
  86.     RET            ;  ALSINIT fills in the APREAD address
  87. ;
  88. ALS2:    CALL    ALSINIT        ; Similarly
  89. APWRT1:    CALL    0000H        ;   for APWRITE
  90.     RET
  91. ;
  92. ALS3:    CALL    ALSINIT        ; Initialize addresses in SWIN and SWOUT
  93.     RET
  94. ;.....
  95. ;
  96. ;
  97. ALSINIT:
  98.     PUSH    H        ; Save everything
  99.     PUSH    D
  100.     PUSH    B
  101.     PUSH    PSW
  102.     LHLD    0001H        ; Point to WBOOT jump in BIOS jump table
  103.     LXI    D,3*26        ; Offset to SELMEM jump
  104.     DAD    D        ; Add them
  105.     INX    H        ; Point to addr of SELMEM bIOS routine
  106.     PUSH    H        ; Save pointer
  107.     CALL    INTO$HL        ; Move addr into HL store in SWIN, SWOUT
  108.     SHLD    SLMEM1+1
  109.     SHLD    SLMEM2+1
  110.     INX    H        ; Move past STA opcode to point to addr
  111.     CALL    INTO$HL        ;   where current bank is stored, move
  112.     SHLD    CURBNK+1    ;   adfdress into HL and then into SWIN
  113.     POP    H        ; Recall pointer
  114.     LXI    D,3*6        ; Advance pointer 6 jumps to APREAD addr
  115.     DAD    D
  116.     PUSH    H
  117.     CALL    INTO$HL
  118.     SHLD    APRD+1        ; Store address of APREAD routine
  119.     SHLD    APRD1+1
  120.     POP    H
  121.     INX    H        ; Bump HL to point to APWRITE address
  122.     INX    H
  123.     INX    H
  124.     CALL    INTO$HL
  125.     SHLD    APWRT+1        ; Store address of APWRITE routine
  126.     SHLD    APWRT1+1
  127.     POP    PSW        ; Restore all
  128.     POP    B
  129.     POP    D
  130.     POP    H
  131.     LXI    H,RETNUL    ; Change CALL ALS3 in MDPREP to a call
  132.     SHLD    MDPREP+1    ;   to a harmless RET so if MDPRE is
  133.                 ;   called, it won't do this again.
  134. RETNUL:    RET
  135. ;.....
  136. ;
  137. ;
  138. ; Move into HL what is stored where HL points
  139. ;
  140. INTO$HL:MOV    E,M
  141.     INX    H
  142.     MOV    D,M
  143.     XCHG
  144.     RET
  145. ;.....
  146. ;
  147. ;
  148. ; The following two  routines are specific to the Apple // with ALS CP/M
  149. ; Card.  The routines respectively read from and write to modem hardware
  150. ; (Apple Super Serial Card ACIA registers) directly.  The calls to ALS1
  151. ; and ALS2 are overwritten with the APREAD or APWRITE BIOS address by
  152. ; the ALSINIT routine.
  153. ;.....
  154. ;
  155. ;
  156. ; Peek at 1 byte from Apple 6502 address space
  157. ;
  158. ;     ENTRY: HL = Address in Apple
  159. ;     EXIT:  A = Data
  160. ;
  161. PEEK:    PUSH    D    ; Preserve, then restore regs
  162.     PUSH    B
  163. ;
  164. APRD:    CALL    ALS1    ; ALSINIT, called by ALS1, overwrites ALS1 with
  165.     POP    B    ;   the addr of APREAD, a special BIOS function
  166.     POP    D    ;   added by ALS that reads Apple memory space
  167.     RET
  168. ;.....
  169. ;
  170. ;
  171. ; Poke 1 byte to Apple 6502 address space
  172. ;
  173. ;     ENTRY: HL = Address in Apple
  174. ;     EXIT:  A = Data
  175. ;
  176. POKE:    PUSH    D
  177.     PUSH    B
  178. ;
  179. APWRT:    CALL    ALS2        ; ALSINIT fills in addr of APWRITE, etc.
  180.     POP    B
  181.     POP    D
  182.     RET
  183. ;.....
  184. ;
  185. ;
  186. ; Read the baud rate port of the 6551
  187. ;
  188. RD$BRPORT:
  189.     PUSH    H
  190.     LXI    H,BRPORT
  191.     CALL    PEEK
  192.     POP    H
  193.     RET
  194. ;.....
  195. ;
  196. ;
  197. ; Read the command port of 6551
  198. ;
  199. RD$CPORT:
  200.     PUSH    H
  201.     LXI    H,CPORT
  202.     CALL    PEEK
  203.     POP    H
  204.     RET
  205. ;.....
  206. ;
  207. ;
  208. ; Read data port of 6551
  209. ;
  210. RD$PORT:
  211.     PUSH    H
  212.     LXI    H,PORT
  213.     CALL    PEEK
  214.     POP    H
  215.     RET
  216. ;.....
  217. ;
  218. ;
  219. ; Read the status port of the 6551
  220. ;
  221. RD$STPORT:
  222.     PUSH    H
  223.     LXI    H,STPORT
  224.     CALL    PEEK
  225.     POP    H
  226.     RET
  227. ;.....
  228. ;
  229. ;
  230. ; Write to the baud rate port of the 6551
  231. ;
  232. WR$BRPORT:
  233.     PUSH    H
  234.     LXI    H,BRPORT
  235.     CALL    POKE
  236.     POP    H
  237.     RET
  238. ;.....
  239. ;
  240. ;
  241. ; Write to the command port of 6551
  242. ;
  243. WR$CPORT:
  244.     PUSH    H
  245.     LXI    H,CPORT
  246.     CALL    POKE
  247.     POP    H
  248.     RET
  249. ;.....
  250. ;
  251. ;
  252. ; Write to the serial data port of the 6551
  253. ;
  254. WR$PORT:
  255.     PUSH    H
  256.     LXI    H,PORT
  257.     CALL    POKE
  258.     POP    H
  259.     RET
  260. ;.....
  261. ;
  262. ;
  263. ;----------------------------------------------------------------------
  264. ;
  265. ;
  266. ; Check for a carrier, if none, return with the zero flag set.
  267. ;
  268. MDCARCK:CALL    RD$STPORT    ; Get status
  269.     ANI    40H        ; Check DSR pin for DCD (see above)
  270.     XRI    40H        ; Reverse the zero flag (the 6551
  271.     RET            ; Has status 0 for DCD/DSR true)
  272. ;......
  273. ;
  274. ;
  275. ; This routine will turn off the serial card and hang up the phone.
  276. ;
  277. MDINIT:    MVI    A,41H        ; Turn off DTR
  278.     CALL    WR$CPORT
  279.     PUSH    B        ; Save register
  280.     MVI    B,20        ; Delay 2 sec to drop carrier
  281. ;
  282. OFFTI:    CALL    DELAY        ; 1 sec per loop
  283.     DCR    B
  284.     JNZ    OFFTI        ; Keep going until finished
  285.     POP    B        ; Restore register
  286.     MVI    A,4BH        ; Raise DTR
  287.     CALL    WR$CPORT
  288.     MVI    A,18H        ; Set 1200, 8 bits, 1 stop
  289.     CALL    WR$BRPORT
  290. ;
  291.       IF    IMODEM
  292.     CALL    IMINIT
  293.       ENDIF            ; IMODEM
  294. ;
  295.     RET
  296. ;......
  297. ;
  298. ;
  299. ; Super Serial Card status checks.  NOT READY indication if bit 3 of
  300. ; STPORT byte equals zero (for receive-readiness check), or bit 4
  301. ; equals zero (for transmit-readiness check).
  302. ;
  303. ; Check the status to see if a character is waiting to be received.
  304. ; Return with zero flag set, if not.  If yes, clear flag and return with
  305. ; 0FFH in A.
  306. ;
  307. MDINST:    CALL    RD$STPORT    ; Get modem status
  308.     ANI    08H        ; Is data available?
  309.     RZ            ; If not, return with zero flat set
  310.     ORI    0FFH        ; Otherwise insure flag is reset
  311.     RET
  312. ;.....
  313. ;
  314. ;
  315. ; Check if transmit register is empty.    If empty, ready to transmit
  316. ; another character and returns with zero flag clear.  If busy, returns
  317. ; with zero flag set.
  318. ;
  319. MDOUTST:
  320.     CALL    RD$STPORT    ; Get modem status
  321.     ANI    10H        ; Ready to transmit?
  322.     RET            ; If not, returns with zero flag set
  323. ;.......
  324. ;
  325. ;
  326. ; Input a character from the modem port.
  327. ;
  328. MDINP:    JMP    RD$PORT        ; Get character
  329. ;......
  330. ;
  331. ;
  332. ; Output one character in register A.
  333. ;
  334. MDOUTP:    JMP    WR$PORT        ; Send character
  335. ;.......
  336. ;
  337. ;
  338. ; Reinitialize the modem and hang up the phone by dropping DTR and
  339. ; leaving it inactive.
  340. ;
  341. MDQUIT:     IF    IMODEM        ; If using a smartmodem
  342.     CALL    IMQUIT        ; Tell it to shut down
  343.      ENDIF            ; IMODEM
  344. ;
  345. ;
  346. ; Called by the main program after caller types BYE
  347. ;
  348. MDSTOP:    MVI    A,41H        ; Drop DTR
  349.     JMP    WR$CPORT
  350. ;.....
  351. ;
  352. ;
  353. ; If you do not support a particular baud rate, put it here
  354. ; before SETINV:
  355. ;
  356. SETINV:    ORI    0FFH
  357.     RET
  358. ;.....
  359. ;
  360. ;
  361. SET300:    MVI    A,16H
  362.     JMP    WR$BRPORT    ; Go change the baud rate
  363. ;
  364. SET1200:
  365.     MVI    A,18H
  366.     JMP    WR$BRPORT
  367. ;
  368. SET2400:MVI    A,1AH
  369.     JMP    WR$BRPORT
  370. ;
  371. SET4800:MVI    A,1CH
  372.     JMP    WR$BRPORT
  373. ;
  374. SET9600:MVI    A,1EH
  375.     JMP    WR$BRPORT
  376. ;.....
  377. ;
  378. ;
  379. ;-----------------------------------------------------------------------
  380. ;
  381. ;            CP/M v3.0 stuff
  382. ;
  383. ;-----------------------------------------------------------------------
  384. ;
  385. ; Perform system or hardware dependent PRE-processing.
  386. ;
  387. ; The following code will be executed by the PATCH subroutine before the
  388. ; BIOS jump table is overwritten.  This will allow the BIOS intercept
  389. ; routines to operate as early as the initial signon message display.
  390. ; ALS3 calls ALSINIT, which initializes some addresses.
  391. ;
  392. MDPREP:    CALL    ALS3        ; ALSINIT (called by ALS3) initializes
  393.                 ;  BIOS addresses, then changes this
  394.                 ;  call to a call to a harmless RET so
  395.                 ;  we only do ALS3 once
  396. ;
  397. ; Replace the NEWJTBL BIOS routing table with our own
  398. ;
  399.     LXI    H,JTBLNEW    ; Get replacement table address
  400.     LXI    D,NEWJTBL    ; Get address to overwrite
  401.     LXI    B,JTBLEN    ; Get number of bytes to overwrite
  402.     DB    0EDH,0B0H    ; (LDIR - Z80 opcodes)
  403.     RET
  404. ;.....
  405. ;
  406. ;
  407. ; Perform system or hardware dependent POST-processing.  The following
  408. ; code will be executed by the EXCPM routine before returning control to
  409. ; CP/M Plus when the BYE5 program is terminated.
  410. ;
  411. MDPOSP:    RET            ; None required
  412. ;.....
  413. ;
  414. ;
  415. ; The following code is required for proper operation of the ALS CP/M
  416. ; Card.  As the CP/M Card operates in a banked environment, BIOS calls
  417. ; and parameter storage may be in any bank (currently 0 and 1).  It is
  418. ; therefore possible that the proper bank may not be in context at the
  419. ; time a BIOS call or search of banked memory is made.    As a result,
  420. ; steps must be taken to be sure that the BIOS jump table does not
  421. ; direct an operation or BIOS call into bank 1 unless that bank is
  422. ; selected.  Therefore, this code must be in common memory where it
  423. ; will be visible to all banks.
  424. ;
  425. ; For each of the intercepted BIOS calls, this code will:
  426. ;
  427. ;   - Save the caller's bank
  428. ;   - Switch to bank 1
  429. ;   - Execute the BYE interface routine, then the original BIOS routine
  430. ;     as necessary
  431. ;   - Reset the bank to that of the caller
  432. ;   - Return control to the caller
  433. ;.....
  434. ;
  435. ;
  436. WBCOMN:    CALL    SWIN        ; Warm boot
  437.     JMP    MBOOT
  438. ;.....
  439. ;
  440. ;
  441. CSCOMN:    CALL    SWIN        ; Console status
  442.     CALL    MSTAT
  443.     JMP    SWOUT
  444. ;.....
  445. ;
  446. ;
  447. CICOMN:    CALL    SWIN        ; Console input
  448.     CALL    MINPUT
  449.     JMP    SWOUT
  450. ;.....
  451. ;
  452. ;
  453. COCOMN:    CALL    SWIN        ; Console output
  454.     CALL    MOUTPUT
  455.     JMP    SWOUT
  456. ;.....
  457. ;
  458. ;
  459. SWIN:    PUSH    PSW        ; Bank switch-in destroys HL,A,flags
  460. ;
  461. CURBNK:    LDA    0000H        ; ALSINIT fills in addr of @CBNK, where
  462.                 ;   BIOS/BDOS store current bank
  463.     STA    CURBANK        ; Save bank for the return trip
  464.     MVI    A,1        ; Select bank 1
  465. ;
  466. SLMEM1:    CALL    0000H        ; Address of BIOS SELMEM routine filled
  467.     POP    PSW        ;   in by ALSINIT
  468.     RET
  469. ;.....
  470. ;
  471. ;
  472. SWOUT:    PUSH    PSW        ; Bank switch-out destroys HL,A,flags
  473.     MOV    H,A        ; Save A reg (for console input call)
  474.     LDA    CURBANK        ; Retrieve caller's bank
  475.     PUSH    H
  476. ;
  477. SLMEM2:    CALL    0000H        ; Address of BIOS SELMEM routine filled
  478.     POP    H        ;   in by ALSINIT
  479.     POP    PSW        ; Restore A,flags
  480.     MOV    A,H        ; Restore A reg (for console input call)
  481.     RET
  482. ;
  483. CURBANK:DS    1        ; For storage of bank
  484. ;.....
  485. ;
  486. ;
  487. JTBLNEW:JMP    MCBOOT        ; Cold boot
  488.     JMP    WBCOMN        ; Warm boot
  489.     JMP    CSCOMN        ; Modem status test
  490.     JMP    CICOMN        ; Modem input routine
  491.     JMP    COCOMN        ; Modem output routine
  492. ;
  493.      IF    (NOT HARDLOG) AND (NOT PRINTER)
  494.     JMP    COCOMN        ; Modem list device
  495.     JMP    COCOMN        ; Modem punch (auxout) device
  496.     JMP    CICOMN        ; Modem reader (auxin) device
  497.      ENDIF            ; (NOT HARDLOG) AND (NOT PRINTER)
  498. ;
  499. JTBLEN    EQU    $-JTBLNEW
  500. ;
  501. ;            end of insert
  502. ;-------------------------------------------------------------------
  503.