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 / UTILS / A / BIOS-R62.LZH / CXIO.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  25KB  |  1,311 lines

  1. ; BIOS-R6
  2. ; 1/27/93
  3. ; Randy Winchester
  4. ;
  5. ; code in this module was modified to set the screen up for 80 col 
  6. ; automaticly, all 40 column code has been deleted.  the label NULL40 is
  7. ; still maintained in the device table as removing it would change
  8. ; the subsequent device numbers, affecting the use of RS-232 (it would
  9. ; require rewrites of all modem programs)
  10. ; code at the label ?rlccp has been added to reset the feel and repeat
  11. ; rate at every warm start, this corrects problems that arise after 
  12. ; terminating a modem program. 
  13. ;
  14. ; Code has been added to allow setting the cursor flash rate and shape,
  15. ; set the temporary drive, and the drive search chain.
  16. ; Code has been added to require a password to be entered before the
  17. ; system finishes initialization, 3 trys are allowed, the system locks
  18. ; up if you fail all three.
  19. ;
  20. ; A label has been added to allow the 6551 init code to install baud
  21. ; rates based on the value in DEVTBL.
  22. ;
  23. ; User assumes _ALL_ liability for the use of this module. Original 
  24. ; Copyright is still maintained by Commodore
  25. ;
  26. ; Code to set cursor and drive chain; Copyright April 26, 1987 by
  27. ;    James W. Waltrip IV
  28. ;------------------------------------------------------------------------
  29. ; *ADDITIONS BY Randy Winchester, 5/6/89
  30. ;
  31. ; Default printer is device 4.
  32. ;
  33. ; Set up for non-flashing block cursor
  34. ;
  35. ; Drive Search chain/temp drive default values:  
  36. ; A:,logged drive, temp drive = A:
  37. ;
  38. ; Drive F: is reserved for a Quick Brown Box battery powered RAM cartridge.
  39. ; The QBB is initialized with QD.COM from Herne Data Systems, Ltd.
  40. ;
  41. ; No password protection for booting the system.
  42. ;
  43. ; Colors set in sign-on message.  Background=light grey, character=blue
  44. ;
  45. ; Default system baud rate set for 75 baud.  This speeds up normal operation
  46. ; considerably.
  47. ;
  48. ; Printer names set to PRT-D4 and PRT-D5 (devices 4 and 5)
  49. ;
  50. ; 1/27/93
  51. ; Added code to reset default baud rate on reload of CCP.  See
  52. ; code at ?rlccp.
  53. ;
  54. ;-------------------------------------------------------------------------
  55. ;
  56.     title    'C128 BIOS, main I/O and sys functions     6 May   89'
  57.  
  58. ;
  59. ;    This module contains CXIO,CXINIT,CXMOVE and CXTIME.
  60. ;
  61.     maclib    cpm3
  62.  
  63.     maclib    z80
  64.  
  65.     maclib    cxequ
  66.  
  67.     maclib    modebaud
  68.  
  69. ;**********************************************************
  70.  
  71.     extrn    repeat            ; repeat rate
  72.  
  73. repeat$amt    equ    2
  74.  
  75.     extrn    delay            ; delay before repeat
  76.  
  77. delay$amt    equ    16
  78.  
  79.  
  80. printnum    equ    010h        ; printer device to init
  81.                     ; Device 4 = 010h (16 decimal)
  82.                     ; Device 5 = 08
  83.  
  84. pass        equ    false        ; set to 'false' if password
  85.                      ; protection not wanted
  86.  
  87. pass$word    macro
  88.  
  89.     db    'PASS'                ; password is defined here
  90. ;                                       ; if using lower case letters
  91. ;                    ; use the HEX values rather than
  92. ;                    ; the characters themselves
  93. ;                    ; ie.-> 061h  instead of 'a'
  94.         endm
  95.  
  96. ;*************************************************************
  97.     public    ?init,?ldccp,?rlccp
  98.  
  99.     public    ?user,?di$int
  100.  
  101.     extrn    ?sysint
  102.  
  103. bdos    equ    5    
  104.     
  105.     extrn    @civec,@covec,@aivec,@aovec,@lovec
  106.     extrn     ?bnksl
  107.  
  108.     public    ?cinit,?ci,?co,?cist,?cost
  109.     public    @ctbl
  110.     extrn    ?kyscn
  111.  
  112. ; Utility routines in standard BIOS
  113.     extrn    ?wboot        ; warm boot vector
  114.     extrn    ?pmsg        ; print message @<HL> up to 00
  115.                 ; saves <BC> & <DE>
  116.     extrn    ?pdec        ; print binary number in <A> from 0 to 99.
  117.     extrn    ?pderr        ; print BIOS disk error header
  118.     extrn    ?conin,?cono    ; con in and out
  119.     extrn    ?const        ; get console status
  120.  
  121.     extrn    @hour,@min,@sec,@date,?bnksl
  122.     public    ?time
  123.  
  124.     page
  125. ;
  126. ;    keyboard scanning routine 
  127. ;
  128.     extrn    ?get$key,?int$cia
  129.     extrn    Fx$V$tbl
  130. ;
  131. ;    links to 80 column display
  132. ;
  133.     extrn    ?out80,?int80
  134.  
  135.     extrn    ?pt$i$1101,?pt$o$1,?pt$o$2
  136.  
  137. ;
  138. ;    bios8502 function routines
  139. ;
  140.     public    ?fun65
  141.  
  142. ;
  143. ;
  144. ;
  145.     public    X6551$baud
  146.     extrn    ?int65,?in65,?ins65,?out65
  147.     extrn    @drcha,@drchb,@drchc,@drchd,@tpdrv
  148.  
  149.  
  150.     DSEG
  151. ?fun65:
  152.     sta    vic$cmd            ; save the command passed in A
  153.  
  154. fun$di$wait:
  155.     lda    RS232$status
  156.     ani    01000010b        ; transmitting or receiving ?
  157.     jrnz    fun$di$wait        ; yes, wait for int to clean up
  158.     di
  159.     lda    force$map        ; get current MMU configuration
  160.     push    psw            ; save it
  161.     sta    io$0            ; make I/O 0 current
  162.     
  163.     lxi    d,1            ; D=0,  E=1
  164.     lxi    b,page$1$h
  165.     outp    d
  166.     dcr    c
  167.     outp    e            ; page 1, 0-1
  168.     dcr    c
  169.     outp    d
  170.     dcr    c
  171.     outp    d            ; page 0, 0-0
  172.     call    enable$6502+6        ; go run the 8502
  173.     mvi    c,low(page$1$h)
  174.     outp    e
  175.     dcr    c
  176.     outp    e            ; page 1, 1-1
  177.     dcr    c
  178.     outp    e
  179.     dcr    c
  180.     outp    d            ; page 0, 1-0
  181.  
  182.     pop    psw            ; recover the MMU config.
  183.     sta    force$map        ; restore it
  184.     ei                ; turn interrupts back on
  185.     lda    vic$data        ; get command results
  186.     ora    a            ; set the zero flag if A=0
  187.     ret
  188.  
  189. ?di$int:
  190.     push    psw
  191. di$int$1:
  192.     lda    RS232$status
  193.     ani    01000010b        ; transmitting or receiving ?
  194.     jrnz    di$int$1        ; yes, wait for int to clean up
  195.     pop    psw
  196.     di
  197.     ret
  198.  
  199.     page
  200. ;
  201. ;    set up the MMU for CP/M Plus
  202. ;
  203.     DSEG            ; init done from banked memory
  204. ?init:
  205.     mvi    a,3eh            ; force MMU into I/O space
  206.     sta    force$map        ;
  207.     lxi    h,mmu$table+11-1    ; table of 11 values
  208.     lxi    b,mmu$start+11-1    ; to to MMU registers
  209.     mvi    d,11            ; move all 11 bytes to the MMU
  210.  
  211. init$mmu$loop:
  212.     mov    a,m
  213.     outp    a
  214.     dcx    h
  215.     dcx    b
  216.     dcr    d
  217.     jrnz    init$mmu$loop
  218.  
  219.     mvi    a,1            ; enable track and sector status
  220.     sta    stat$enable        ; on the status line
  221.  
  222. ;    mvi    a,1h            ; no parity, 8 bits, 1 stop bit    
  223.     sta    XxD$config
  224.  
  225.     lxi    h,Fx$V$tbl
  226.     shld    key$FX$function
  227. ;*********************************************************
  228. ;
  229. ; install I/O assignments
  230. ;
  231.     lxi    h,4000h            ; 80 and 40 column drivers
  232.     shld    @covec
  233.     mvi    h,80h
  234.     shld    @civec            ; assign console input to keys
  235.     mvi    h,printnum        ; device # 4
  236.     shld    @lovec            ; assign printer to LPT:
  237.     mvi    h,00h
  238.     shld    @aivec
  239.     shld    @aovec            ; assign rdr/pun port
  240.  
  241. ;
  242. ; init SCB
  243. ;
  244.     mvi    a,01h            ; The following instr. set up the
  245.     sta    @drcha            ; Drive Search Chain, and the Temp. 
  246.     sta    @tpdrv            ; Drive.  This replaces the command
  247.     mvi    a,0            ; SETDEF A:,* [TEMP=A:]
  248.     sta    @drchb            ; A: = 01h, B: = 02h, C: = 03h, etc.
  249.     mvi    a,0ffh            ; 0ffh = filler byte
  250.     sta    @drchc
  251.     mvi    a,0ffh            ;
  252.     sta    @drchd
  253. ;
  254. ; Where are the bytes for COM/SUB execution?
  255. ;
  256. ; 80 Col. screen cursor attributes
  257. ;
  258.     lxi    b,0D600h    ; 80 col cmd reg
  259.     mvi    a,010        ; reg 10 of 8563 (cursor type, start scan line)
  260.     outp    a        ; tell 8563 you want reg 10
  261. lx1:                
  262.     inp    a        ; get status
  263.     jp    lx1        ; loop until status good
  264.     lxi    b,0D601h    ; 80 col data reg
  265.     mvi    a,00000000b    ; solid cursor, top scan line
  266.     outp    a
  267. ;
  268.     lxi    b,0D600h
  269.     mvi    a,011        ; reg 11 of 8563 (cursor end scan line)
  270.     outp    a
  271. lx2:
  272.     inp    a
  273.     jp    lx2
  274.     lxi    b,0D601h
  275.     mvi    a,00000111b    ; Bottom scan line = 7
  276.     outp    a
  277. ;
  278.     lxi    b,0D011h    ; Vic controll reg 1
  279.     mvi    a,00001000b    ; turn off Vic
  280.     outp    a
  281. ;
  282.     page
  283. ;
  284. ; print sign on message
  285. ;
  286.     call    prt$msg            ; print signon message
  287.     db    'Z'-'@'            ; home and clear screen (to BG color)
  288.      db    esc,esc,esc,blue+020h    ; blue characters
  289.         db      esc,esc,esc,lt$grey+030h ; light grey background
  290. ;                    123456789012345678901234567890123456789
  291.     db    esc,'=',32+2,32+28,'ZPM3 CP/M+ Compatible OS'
  292.     db    esc,'=',32+3,32+33,'by Simeon Cran'
  293.     db    esc,'=',32+5,32+27,'C128 BIOS Rev 6, 27 Jan 93'
  294.     db    cr,lf,lf,0
  295. ;;*********************************************************
  296.     page
  297.  
  298. ;
  299. ;
  300.     mvi    a,-1            ; set block move to NORMAL mode
  301.     sta    source$bnk
  302. ;
  303. ;    install mode 2 page vectors
  304. ;
  305.     mvi    a,JMP
  306.     sta    INT$vector        ; install a JMP at vector location
  307.     lxi    h,?sysint
  308.     shld    INT$vector+1        ; install int$handler adr
  309. ;
  310. ; A software fix is  required for the lack of hardware to force the
  311. ; LSB of the INT vector to 0. If the bus floats INT VECT could be
  312. ; read as 0FFh; thus ADRh=I (I=0FCh) ADRl=FF for first read, and
  313. ; ADRh=I+1 ADRl=00 for second, to ensure that control is retained
  314. ; 0FD00h will also have FDh in it.
  315. ;
  316.     lxi    h,int$block        ; FC00h
  317.     lxi    d,int$block+1        ; FC01h
  318.     lxi    b,256-1+1        ; interrupt pointer block
  319.     mvi    m,INT$vector/256    ; high and low are equal (FD)
  320.     ldir
  321.     mvi    a,INT$block/256
  322.     stai                ; set interrupt page pointer
  323.     im2                ; enable mode 2 interrupts
  324.  
  325.     page
  326. ;
  327. ;
  328.     mvi    a,vicinit        ; null command just to setup BIOS8502
  329.     call    ?fun65
  330. ;
  331. ;
  332. ;
  333.     lda    sys$freq        ; 0=60Hz 0FFh=50Hz
  334.     ani    80h            ; 0=60Hz 080h=50Hz
  335.     mov    l,a            ; save in L
  336.     lxi    b,cia$1+0eh        ; point to CRA
  337.     inp    a            ; get old config
  338.     ani    7fh            ; clear freq bit
  339.     ora    l            ; add in new freq bit
  340.     outp    a            ; set new config
  341.  
  342.     mvi    c,8            ; start RTC
  343.     outp    a
  344.  
  345.     lxi    h,date$hex
  346.     shld    @date            ; set date to system data
  347.  
  348. ;
  349. ;    setup the sound variables
  350. ;
  351.     lhld    key$tbl
  352.     lxi    d,58*4
  353.     dad    d
  354.     mov    e,m
  355.     inx    h
  356.     mov    d,m
  357.     inx    h
  358.     xchg
  359.     shld    sound1            ; H=SID reg 24, L=SID reg 5
  360.     xchg
  361.     mov    e,m
  362.     inx    h
  363.     mov    d,m
  364.     xchg
  365.     shld    sound2            ; H=SID reg 6, L=SID reg 1
  366.     lxi    h,9
  367.     dad    d
  368.     mov    e,m
  369.     inx    h
  370.     mov    d,m
  371.     xchg
  372.     shld    sound3            ; H=SID reg 4 then L=SID reg 4 
  373. ;
  374. ;    set-up key click sound registers
  375. ;
  376.     lxi    b,sid+7
  377.     lxi    h,0040h
  378.     outp    l            ; (sid+7)=40h
  379.     inr    c
  380.     outp    l            ; (sid+8)=40h
  381.     mvi    c,low(sid+12)
  382.     outp    h            ; (sid+12)=0  Attack=2ms, Decay=6ms
  383.     inr    c
  384.     outp    h            ; (sid+13)=0  Sustain=0,  Release=6ms
  385.     mvi    a,6
  386.     sta    tick$vol        ; set keyclick volumn level
  387.  
  388. ;**********************************************
  389. ;  Password protection routine
  390. ;**********************************************
  391. ;
  392. if    pass
  393. ;
  394.     mvi    a,0
  395.     sta    count
  396. loop1:
  397.     lda    count
  398.     inr    a
  399.     sta    count
  400.     cpi    4
  401.     jnz    over
  402.     call    prt$msg
  403.     db    cr,lf,lf,esc,'G2','Password Error,  System Aborting....',0
  404. there:
  405.     jmp    there
  406. over:
  407.     lxi    h,cmp$string
  408.     push    h
  409.     call    prt$msg
  410.     db    cr,lf,'Password: ',0
  411. lz1:
  412.     call    key$board$in
  413.     pop    h
  414.     cmp    m
  415.     jnz    loop1
  416.     inx    h
  417.     push    h
  418.     mov    a,m
  419.     cpi    0
  420.     jnz    lz1
  421.     call    prt$msg
  422.     db    cr,lf,lf,0
  423. ;
  424. endif
  425. ;
  426.     ret
  427. ;
  428. if    pass
  429. ;
  430. cmp$string:
  431.     pass$word        ;password macro
  432.     db    0
  433. count:
  434.     ds    1
  435. ;
  436. endif
  437. ;
  438. ;***************************************************
  439. ;
  440.  
  441. mmu$table:
  442.     mmu$tbl$M
  443.  
  444.     page
  445. ;
  446. ;
  447. ;
  448.     CSEG
  449. prt$msg:
  450.     xthl
  451.     call    ?pmsg
  452.     xthl
  453.     ret
  454.  
  455.  
  456. ;
  457. ;    placed in common memory to keep IO from stepping on this code
  458. ;        always called from bank 0
  459. ;
  460.     CSEG
  461. read$d505:
  462.     sta    io$0            ; enable MMU (not RAM)
  463.     lxi    b,0d505h
  464.     inp    a            ; read 40/80 column screen
  465.     sta    bank$0            ; re-enable RAM
  466.     ret
  467.  
  468.     page
  469. ;
  470. ;
  471. ;
  472.     DSEG
  473. init$RS232:
  474.     di
  475.  
  476.     xra    a
  477.     sta    RS232$status
  478.     lxi    h,RxD$buf$count        ; clear the count
  479.     mvi    m,0
  480.     inr    l            ; point to RxD$buf$put
  481.     mvi    m,low(RxD$buffer)
  482.     inr    l            ; point to RxD$buf$get
  483.     mvi    m,low(RxD$buffer)
  484.     lxi    h,NTSC$baud$table
  485.  
  486. ;***************************************
  487. ; code to check for NTSC or PAL removed here, system now assumes 
  488. ; that you are using a north american 128 at 60 hz.
  489. ; ***************************************
  490.  
  491. use$NTSC:
  492.     lda    RS232$baud
  493.     cpi    baud$1200        ; baud rate less then 1200 baud
  494.     jrc    baud$ok            ; yes, go set it
  495.     mvi    a,baud$1200        ; no, 1200 baud is the max
  496.     sta    RS232$baud        ; (change to 1200 baud)
  497.  
  498. baud$ok:
  499.     mov    e,a
  500.     mvi    d,0
  501.     dad    d            ; +1X
  502.     dad    d            ; +1X
  503.     dad    d            ; +1X = +3X
  504.     mov    e,m
  505.     inx    h
  506.     mov    d,m
  507.     inx    h            ;
  508.     mov    a,m            ; get rate #
  509.     sta    int$rate        ;
  510.  
  511.     lxi    b,CIA1+timer$b$low    ;
  512.     outp    e            ;
  513.     inr    c            ; point to timer$b$high
  514.     outp    d            ;
  515.  
  516.     mvi    a,11h            ;
  517.     mvi    c,CIA$ctrl$b        ; turn on timer B
  518.     outp    a            ;
  519.  
  520.     lxi    b,CIA2+data$b        ; setup user port for RS232
  521.     inp    a            ; get old data
  522.     ori    6            ; set CTS and DTR
  523.     outp    a            ; update it
  524.     ei
  525.     ret
  526.  
  527.     page
  528. ;
  529. ;    NTSC rates (1.02273 MHz)
  530. ;
  531. NTSC$baud$table:
  532.     dw    6818            ; no baud rate     (6666.47)
  533.     db    1
  534.     dw    6818            ; 50    6666.7us (6666.47)
  535.     db    1
  536.     dw    4545            ; 75    4444.4us (4443.99)
  537.     db    1
  538.     dw    3099            ; 110    3030.3us (3030.13)
  539.     db    1
  540.     dw    2544            ; 134    2487.6us (2487.46)
  541.     db    1
  542.     dw    2273            ; 150    2222.2us (2222.48)
  543.     db    2
  544.     dw    1136            ; 300    1111.1us (1110.75)
  545.     db    3
  546.     dw    568            ; 600     555.6us ( 555.38)
  547.     db    6
  548.     dw    284            ; 1200     277.8us ( 277.69)
  549.     db    12
  550.  
  551. ;****************************************************
  552. ; PAL baud table removed from here (redundant, as it is not checked for
  553. ; or used)
  554. ;******************************************************
  555.  
  556.     page
  557. ;
  558. ;
  559. ;
  560. out$RS232:
  561.     lda    RS232$status
  562.     ani    80h
  563.     jrnz    out$RS232
  564.     mov    a,c
  565.     sta    xmit$data        ; get character to send in A
  566.     lxi    h,RS232$status
  567.     setb    7,m            ; set Xmit request bit
  568.     ret
  569.  
  570. ;
  571. ;
  572. ;
  573. out$st$RS232:
  574.     lda    RS232$status
  575.     ani    80h            ; bit 8 set if busy
  576.     xri    80h            ; A cleared if busy (=80h if not)
  577.     rz
  578.     ori    0ffh            ; A=ff if ready (not busy)
  579.     ret
  580.  
  581. ;
  582. ;
  583. ;
  584. in$RS232:
  585.     lda    RS232$status
  586.     ani    1
  587.     jrz    in$RS232
  588.     lda    recv$data
  589.     lxi    h,RS232$status
  590.     res    0,m
  591.     ret
  592.  
  593. ;
  594. ;
  595. ;
  596. in$st$RS232:
  597.     lda    RS232$status
  598.     ani    1
  599.     rz
  600.     ori    0ffh            ; set data ready (-1)
  601.     ret
  602.  
  603.     page
  604. ;
  605. ;    this routine is used to provide the user with a method
  606. ;    of interfacing with low level system functions
  607. ;
  608.     CSEG
  609. ;
  610. ;    input:
  611. ;        all registers except HL and A are passed to function
  612. ;
  613. ;    output:
  614. ;        all resisters from function are preserved
  615. ;
  616. ?user:
  617.     shld    user$hl$temp
  618.     xchg
  619.     shld    de$temp            ; save DE for called function
  620.  
  621.     mov    e,a            ; place function number in E
  622.     mvi    a,num$user$fun-1    ; last legal function number
  623.  
  624.     call    vector            ; function
  625. usr$tb:    dw    read$mem$0        ; 0
  626.     dw    write$mem$0        ; 1
  627.     dw    ?kyscn            ; 2
  628.     dw    do$rom$fun        ; 3  (L=function #)     
  629.     dw    do$6502$fun        ; 4  (L=function #)
  630.     dw    read$d505        ; 5  returns MMU reg in A
  631.     dw    code$error        ; not 0 to 5 ret version number in HL
  632.  
  633. num$user$fun    equ    ($-usr$tb)/2
  634.  
  635.     page
  636. ;
  637. ;    address in DE is read and returned in C
  638. ;    A=0 if no error
  639. ;
  640.     DSEG
  641. read$mem$0:
  642.     ldax    d            ; read location addressed by DE
  643.     mov    c,a            ; value returned in C
  644.     xra    a            ; clear error flag
  645.     ret
  646.  
  647. ;
  648. ;    address in DE is written to with value in C
  649. ;    A=0 if no errors
  650. ;
  651. write$mem$0:
  652.     mvi    a,-1            ; get error flag and 0ffh value
  653.     cmp    d            ; do not allow write from FF00 to FFFF
  654.                     ;   this is 8502 space, MMU direct reg.
  655.     rz
  656.     mov    a,d
  657.     cpi    10h            ; do not allow write from 0000 to 0FFF
  658.                     ;   this is ROM space
  659.     mvi    a,-1            ; get error flag
  660.     rc                ; return if 00h to 0fh
  661.     mov    a,c
  662.     stax    d
  663.     xra    a            ; clear error flag 
  664.     ret
  665.  
  666.     page
  667. ;
  668. ;    This is the function code entry point for direct execution
  669. ;    of driver functions. If the MSB of the function number is
  670. ;    set, the 40 column driver is used; else the 80 column drive 
  671. ;    is used.
  672. ;
  673. do$rom$fun:
  674.     lhld    user$hl$temp        ; get HL (L=fun #)
  675.  
  676.     mvi    a,7eh            ; only allow even functions
  677.     ana    l
  678.     cpi    79h
  679.     jrc    no$hl$req
  680.     lhld    @dma            ; HL will be passed in @dma by
  681.     push    h            ; ..the user
  682. no$hl$req:
  683.     mov    l,a
  684.     rst    5            ; call rom functon (RCALL) L=fun #    
  685.     ret
  686.  
  687. ;    mvi    a,7eh            ; only allow even functions
  688. ;    ana    l
  689. ;    sta    no$hl$req+1
  690. ;    cpi    79h
  691. ;    jrc    no$hl$req
  692. ;    lhld    @dma            ; HL will be passed in @dma by
  693. ;    push    h            ; ..the user
  694. ;no$hl$req:
  695. ;    will be changed to RCALL xx   RET for next release (ROM FN 7A, 7C
  696. ;        and 7E will not function with current code, they expect
  697. ;        a return address on the stack
  698. ;
  699. ;    RJMP    5Eh            ; unused function, real fun# installed
  700.                     ; ..above
  701.  
  702. do$6502$fun:
  703.     lhld    user$hl$temp
  704.     mov    a,l
  705.     jmp    ?fun65
  706. ;
  707. ;
  708. ;
  709. code$error:
  710.     lxi    h,date$hex
  711.     mvi    a,-1
  712.     ret
  713.  
  714.     page
  715. ;
  716. ;
  717. ;
  718.     CSEG
  719. ?rlccp:
  720. ;
  721. ;******************************************************************
  722.     mvi    a,01            ; sets feel, put here to set it
  723.     sta    0fd52h            ; on every warm start
  724.     mvi    a,repeat$amt        ; set at 3
  725.     sta    repeat
  726.     mvi    a,delay$amt        ; set at 24
  727.     sta    delay
  728. ;
  729.     mvi    a,baud$75        ; Default baud rate reset
  730.     sta    RS232$baud        ; on reload of CCP
  731. ;
  732. ;******************************************************************
  733.     lxi    h,ccp$buffer
  734.     lxi    b,0c80h
  735. ;
  736. load$ccp:
  737.     sta    bank$0
  738.     mov    a,m
  739.     sta    bank$1
  740.     lxi    d,-ccp$buffer+100h
  741.     dad    d
  742.     mov    m,a
  743.     lxi    d,ccp$buffer-100h+1
  744.     dad    d
  745.     dcx    b
  746.     mov    a,b
  747.     ora    c
  748.     jrnz    load$ccp
  749.     ret
  750.  
  751.     page
  752. ;
  753. ;
  754. ;
  755.     CSEG
  756. ?ldccp:
  757.     xra    a
  758.     sta    ccp$fcb+15    ; zero extent
  759.     lxi    h,0
  760.     shld    fcb$nr        ; start at beginning of file
  761.     lxi    d,ccp$fcb
  762.     call    open        ; open file containing CCP
  763.     inr    a
  764.     jrz    no$CCP        ; error if no file...
  765.     lxi    d,0100h
  766.     call    setdma        ; start of TPA
  767.     lxi    d,128
  768.     call    setmulti    ; allow up to 16K bytes
  769.     lxi    d,ccp$fcb
  770.     call    read
  771.  
  772.     lxi    h,0100h
  773.     lxi    b,0c80h
  774.     lda    force$map
  775.     push    psw
  776.  
  777. ;
  778. ;
  779. save$ccp:
  780.     sta    bank$1
  781.     mov    a,m
  782.     sta    bank$0
  783.     lxi    d,ccp$buffer-100h
  784.     dad    d
  785.     mov    m,a
  786.     lxi    d,-ccp$buffer+100h+1
  787.     dad    d
  788.     dcx    b
  789.     mov    a,b
  790.     ora    c
  791.     jrnz    save$ccp
  792.  
  793.     pop    psw
  794.     sta    force$map
  795.     ret
  796.  
  797.  
  798.  
  799.     page 
  800. ;
  801. ;
  802. ;
  803. no$CCP:                ; here if we couldn't find the file
  804.     call    prtmsg        ; report this...
  805.     db    cr,lf,'BIOS Err on A: No CCP.COM file',0
  806.     call    ?conin        ; get a response
  807.     jr    ?ldccp        ; and try again
  808.  
  809.  
  810. ;
  811. ; CP/M BDOS Function Interfaces
  812. ;
  813.     CSEG
  814. open:
  815.     mvi    c,15        ; open file control block
  816.  
  817.     db    21h        ; lxi h,(mvi c,26)
  818. setdma:
  819.     mvi    c,26        ; set data transfer address
  820.  
  821.     db    21h        ; lxi h,(mvi c,44)    
  822. setmulti:
  823.     mvi    c,44        ; set record count
  824.  
  825.     db    21h        ; lxi h,(mvi c,20)
  826. read:
  827.     mvi    c,20        ; read records
  828.     jmp    bdos
  829.  
  830. ;               12345678901
  831. ccp$fcb        db    1,'CCP     COM',0,0,0
  832. fcb$rc        db    0
  833.         ds    16
  834. fcb$nr        db    0,0,0
  835.  
  836.  
  837.     page
  838. ;
  839. ;    CXIO.ASM and CXEM.ASM
  840. ;
  841. ;==========================================================
  842. ;        ROUITINE TO VECTOR TO HANDLER
  843. ;==========================================================
  844. ;    CP/M IO routines    b=device : c=output char : a=input char
  845. ;
  846.     CSEG
  847. ;*********************************************************************
  848. ; code in the following vector tables has been altered to null the 40
  849. ; column screen
  850. ;--------------------------------------------------
  851.  
  852. ?cinit:                ; initialize usarts
  853.     mov    b,c
  854.     call    vector$io    ; jump with table adr on stack
  855. number$drivers:
  856.     dw    ?int$cia    ; keys
  857.     dw    ?int80        ; 80col
  858.     dw    rret          ; 40col
  859.     dw    ?pt$i$1101    ; prt1
  860.     dw    ?pt$i$1101    ; prt2
  861.     dw    ?int65        ; 6551
  862.     dw    init$RS232    ; software RS232
  863.     dw    rret        ;
  864. max$devices    equ    (($-number$drivers)/2)-1
  865.  
  866. ;
  867. ;
  868. ;
  869. ?ci:                ; character input
  870.     call    vector$io    ; jump with table adr on stack
  871.     dw    key$board$in    ; keys
  872.     dw    rret        ; 80col
  873.     dw    rret        ; 40col
  874.     dw    rret        ; ptr1
  875.     dw    rret        ; prt2
  876.     dw    ?in65        ; 6551
  877.     dw    in$RS232    ; software RS232
  878.     dw    null$input
  879.  
  880. ;
  881. ;
  882. ;
  883. ?cist:                ; character input status
  884.     call    vector$io    ; jump with table adr on stack
  885.     dw    key$board$stat    ; keys
  886.     dw    rret        ; 80col
  887.     dw    rret        ; 40col
  888.     dw    rret        ; prt1
  889.     dw    rret        ; prt2
  890.     dw    ?ins65        ; 6551
  891.     dw    in$st$RS232    ; software RS232
  892.     dw    rret
  893.  
  894. ;
  895. ;
  896. ;
  897. ?co:                ; character output
  898.     call    vector$io    ; jump with table adr on stack
  899.     dw    rret        ; keys
  900.     dw    ?out80        ; 80col
  901.     dw    rret        ; 40col
  902.     dw    ?pt$o$1        ; prt1
  903.     dw    ?pt$o$2        ; prt2
  904.     dw    ?out65        ; 6551
  905.     dw    out$RS232    ; software RS232
  906.     dw    rret
  907.  
  908. ;
  909. ;
  910. ;
  911. ?cost:                ; character output status
  912.     call    vector$io    ; jump with table adr on stack
  913.     dw    ret$true    ; keys
  914.     dw    ret$true    ; 80col
  915.     dw    ret$true    ; 40col
  916.     dw    ret$true    ; prt1    ?pt$s$1101
  917.     dw    ret$true    ; prt2
  918.     dw    ret$true    ; 6551
  919.     dw    out$st$RS232    ; software RS232
  920.     dw    ret$true
  921.  
  922. ;************************************************************
  923.  
  924.     page
  925. ;
  926. ;    This entry does not care about values of DE
  927. ;
  928. vector$io:
  929.     mvi    a,max$devices    ; check for device # to high
  930.     mov    e,b        ; get devive # in E
  931. ;
  932. ;
  933. ;    INPUT:
  934. ;        Vector # in E, Max device in A
  935. ;        passes value in DE$TEMP in DE
  936. ;        HL has routine's address in it on entering routine
  937. ;
  938. ;    OUTPUT:
  939. ;        ALL registers of returning routine are passed
  940. ;
  941. vector:
  942.     pop    h        ; get address vector list
  943.     mvi    d,0        ; zero out the MSB
  944.     cmp    e        ; is it too high?
  945.     jrnc    exist        ; no, go get the handler address
  946.  
  947.     mov    e,a        ; yes, set to max$dev$handler(last one) 
  948. exist:
  949.     dad    d        ; 
  950.     dad    d        ; point into table
  951.  
  952.      mov    a,m
  953.     inx    h
  954.     mov    h,m
  955.     mov    l,a        ; get routine adr in HL
  956.  
  957.     shld    hl$temp        ; save exec adr
  958.     lxi    h,0
  959.     dad    sp
  960.     lxi    sp,bios$stack
  961.     push    h        ; save old stack
  962.  
  963.     lhld    de$temp
  964.     xchg
  965.     lhld    hl$temp        ; recover exec adr
  966.  
  967.     lda    force$map    ; get current bank
  968.     push    psw        
  969.     sta    bank$0        ; set bank 0 as current
  970.  
  971.     call    ipchl
  972.  
  973.     sta    a$temp        ; save value to return
  974.     pop    psw
  975.     sta    force$map    ; set old bank back
  976.     lda    a$temp        ; recover value to return
  977.  
  978.     shld    hl$temp
  979.     pop    h        ; recover old stack
  980.     sphl            ; set new stack
  981.     lhld    hl$temp
  982.     ret
  983.  
  984. ipchl:
  985.     pchl            ; jmp to handler
  986.  
  987.     ds    30h
  988. bios$stack:
  989.  
  990.  
  991.     page
  992. ;==========================================================
  993. ;        CHARACTER INPUT ROUTINES
  994. ;==========================================================
  995.  
  996.     DSEG
  997. ;
  998. ;
  999. ;
  1000. key$board$in:
  1001.     call    key$board$stat    ; test if key is available
  1002.     jrz    key$board$in    
  1003.  
  1004.     lda    key$buf
  1005.     push    psw        ; save on stack
  1006.     xra    a        ; clear key 
  1007.     sta    key$buf
  1008.     pop    psw        ; recover current key
  1009. rret:
  1010.     ret
  1011.  
  1012. ;
  1013. ;
  1014. ;
  1015. null$input:        ; return a ctl-Z for no device
  1016.     mvi    a,1Ah
  1017.     ret
  1018.  
  1019.  
  1020.     page
  1021.  
  1022. ;==========================================================
  1023. ;    CHARACTER DEVICE INPUT STATUS
  1024. ;==========================================================
  1025.  
  1026.     DSEG
  1027. ;
  1028. ;
  1029. ;
  1030. key$board$stat:
  1031.     lda    key$buf
  1032.     ora    a
  1033.     jrnz    ret$true
  1034.  
  1035.     call    ?get$key
  1036.     ora    a        ; =0 if none
  1037.     rz            ; return character not advailable
  1038.  
  1039.     sta    key$buf        ; was one, save in key buffer
  1040.  
  1041. ret$true:
  1042.     ori    0ffh        ; and return true
  1043.     ret
  1044.  
  1045.     page
  1046.  
  1047.     cseg
  1048. @ctbl
  1049.     db    'KEYBRD'    ; device 0, internal keyboard
  1050.     db    mb$input
  1051.     db    baud$none
  1052.  
  1053.     db    '80-COL'    ; device 1, 80 column display
  1054.     db    mb$output
  1055.     db    baud$none
  1056.  
  1057.     db    'NULL40'    ; device 2, 40 column display
  1058.     db    mb$output
  1059.     db    baud$none
  1060.  
  1061.     db    'PRT-D4'    ; device 3, serial bus printer (device 4)
  1062.     db    mb$output
  1063.     db    baud$none
  1064.  
  1065.     db    'PRT-D5'    ; device 4, serial bus printer (device 5)
  1066.     db    mb$output
  1067.     db    baud$none
  1068.  
  1069.     db    '6551  '    ; device 5, EXT CRT
  1070.     db    mb$in$out+mb$serial+mb$softbaud+mb$xonxoff
  1071. X6551$baud:
  1072.     db    baud$9600
  1073.  
  1074.     db    'RS-232'    ; device 6, software RS232 device
  1075.     db    mb$in$out+mb$serial+mb$xonxoff+mb$softbaud
  1076. RS232$baud:
  1077.     db    baud$75
  1078.  
  1079.     db    0        ; mark end of table
  1080.  
  1081.     page
  1082. ;
  1083. ;    TIME.ASM
  1084. ;
  1085.     cseg
  1086. ;
  1087. ;    HL and DE must be presevered
  1088. ;
  1089. ?time:
  1090.     inr    c
  1091.     lxi    b,cia$hours
  1092.     jrz    set$time
  1093. ;
  1094. ;    update SCB time  (READ THE TIME)
  1095. ;
  1096.     inp    a            ; read HR (sets sign flag)
  1097.     jp    is$am            ; jmp if AM (positive)
  1098.     ani    7fh
  1099.     adi    12h            ; noon=24(PM), midnight=12(AM)
  1100.     daa
  1101.     cpi    24h            ; check for noon (12+12 PM)
  1102.     jrnz    set$hr
  1103.     mvi    a,12h
  1104.     jr    set$hr
  1105.  
  1106. is$am:
  1107.     cpi    12h            ; check for midnight (AM)
  1108.     jrnz    set$hr
  1109.     xra    a            ; becomes 00:00
  1110. set$hr:
  1111.     sta    @hour
  1112.     mov    b,a
  1113.     lda    old$hr
  1114.     mov    c,a
  1115.     mov    a,b
  1116.     sta    old$hr
  1117.     cmp    c            ; if @hour<old$hr
  1118.     jrnc    same$day
  1119.  
  1120.     push    h
  1121.     lhld    @date
  1122.     inx    h
  1123.     shld    @date
  1124.     pop    h
  1125.  
  1126. same$day:
  1127.     lxi    b,cia$hours-1
  1128.     inp    a            ; read MIN
  1129.     sta    @min
  1130.  
  1131.     dcr    c
  1132.     inp    a            ; read SEC
  1133.     sta    @sec
  1134.  
  1135.     dcr    c
  1136.     inp    a            ; read 1/10 of SEC (a must to free
  1137.     ret                ; the holding register)
  1138.  
  1139. old$hr:
  1140.     ds    1
  1141.     page
  1142. ;
  1143. ;
  1144. ;
  1145. set$time
  1146.     lda    @hour
  1147.     cpi    12h            ; test for noon
  1148.     jrz    set$as$is
  1149.     ana    a            ; test for 00:xx
  1150.     jrnz    not$zero$hundred
  1151.     mvi    a,80h+12h            ; set to midnight
  1152.     jr    set$as$is
  1153.  
  1154. not$zero$hundred:
  1155.      cpi    11h+1            ; test for 1 to 11 AM
  1156.     jrc    set$as$is
  1157.     sui    12h
  1158.     daa                ; decimal adjust
  1159. set$msb:
  1160.     ori    80h            ; set PM
  1161.  
  1162. set$as$is:
  1163.     outp    a
  1164.     dcr    c
  1165.     lda    @min
  1166.     outp    a
  1167.     dcr    c
  1168.     lda    @sec
  1169.     outp    a
  1170.     dcr    c
  1171.     xra    a
  1172.     outp    a
  1173.     ret
  1174.  
  1175.     page
  1176.  
  1177. ;
  1178.     page
  1179. ;
  1180. ; CXMOVE.ASM
  1181. ;
  1182.     public ?move,?xmove,?bank
  1183.  
  1184. ;
  1185. ;    Move a block of data from DE to HL
  1186. ;    count is in BC (within current bank)
  1187. ;
  1188. ;
  1189.     cseg            ; place code in common
  1190. ?move:
  1191.     xchg            ;*
  1192.     lda    source$bnk    ; =FFh if normal block move 
  1193.     inr    a        ; 
  1194.     jrnz    inter$bank$move
  1195.  
  1196.     LDIR            ;* do block move    
  1197.     xchg            ;*
  1198.     ret
  1199.  
  1200.  
  1201. ;
  1202. ;
  1203. ;
  1204. ?xmove:                ; can be in bank 0    
  1205.     mov    a,c
  1206.     sta    source$bnk
  1207.     mov    a,b
  1208.     sta    dest$bnk
  1209.     ret            ;*
  1210.  
  1211.     page
  1212. ;
  1213. ;
  1214. ;
  1215. inter$bank$move:
  1216.     shld    @buffer        ; save HL TEMP
  1217.     lxi    h,0
  1218.     dad    sp
  1219.     lxi    sp,bios$stack
  1220.     push    h        ; save old stack  ;**1
  1221.     lhld    @buffer
  1222.  
  1223.     mov    a,b        ; get msb of count
  1224.     ora    a
  1225.     jrz    count$less$than$256
  1226.  
  1227.     push    b        ; save the count  ;**2
  1228.     push    d        ; save the dest   ;**3
  1229.     lxi    d,@buffer    ; make buffer the dest
  1230.     lxi    b,256        ; move 256 bytes
  1231.     lda    source$bnk
  1232.     call    ?bank
  1233.     ldir            ; move source to buffer
  1234.  
  1235.     pop    d        ; recover dest    ;**2
  1236.     push    h        ; save updated source ;**3
  1237.     lxi    h,@buffer    ; make the buffer the source
  1238.     lxi    b,256        ; move 256 bytes
  1239.     lda    dest$bnk
  1240.     call    ?bank
  1241.     ldir            ; move buffer to dest
  1242.  
  1243.     pop    h        ; recover updated source ;**2
  1244.     pop    b        ; recover count          ;**1
  1245.     dcr    b        ; subtract 256 from count
  1246.     jr    inter$bank$move
  1247.  
  1248.     page
  1249. ;
  1250. ;
  1251. ;
  1252. count$less$than$256:
  1253.     ora    c        ; BC=0  [A (0) or'ed with C]
  1254.      jrz    exit$move
  1255.  
  1256.     push    d        ; save count for 2nd half  ;**2
  1257.     push    b        ; save dest adr            ;**3
  1258.     lxi    d,@buffer
  1259.     lda    source$bnk
  1260.     call    ?bank
  1261.     ldir            ; move source to buffer
  1262.  
  1263.     pop    b        ; recover count          ;**2
  1264.     pop    d        ; recover dest          ;**1
  1265.     push    h        ; save updated dest      ;**2
  1266.     lxi    h,@buffer
  1267.     lda    dest$bnk
  1268.     call    ?bank
  1269.     ldir            ; move buffer to dest
  1270.     pop    h                        ;**1
  1271.  
  1272. ;
  1273. ;
  1274. ;
  1275. exit$move:
  1276.     xchg
  1277.     mvi    a,-1
  1278.     sta    source$bnk    ; set MOVE back to normal
  1279.     lda    @cbnk
  1280.  
  1281.     shld    @buffer
  1282.     pop    h        ; recover old stack    ;**0
  1283.     sphl
  1284.     lhld    @buffer
  1285.  
  1286. ; call    ?bank        ; set current bank
  1287. ; ret
  1288.  
  1289.     page
  1290. ;
  1291. ;    switch bank to bank number in A
  1292. ;
  1293.     cseg            ; (must be in common)
  1294. ?bank:                
  1295.     ora    a        ; bank 0 ?
  1296.     jrnz    not$bank$0    ; go check for bank 1
  1297.  
  1298.     sta    bank$0        ; set bank 0
  1299.     ret
  1300.  
  1301. ;
  1302. ;
  1303. not$bank$0:
  1304.     dcr    a        ; bank 1 ?
  1305.     rnz            ; if not a valid bank just return
  1306.     sta    bank$1        ; set bank 1
  1307.     ret
  1308.  
  1309.     end
  1310.