home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / kaypro / kp10bios.mac < prev    next >
Text File  |  1994-07-13  |  18KB  |  714 lines

  1. title KAYPRO CBIOS for CP/M 2.2
  2. ;###############################################################
  3. ;##      KAYPRO 10      CBIOS for CP/M 2.2                    ##
  4. ;##      Copyright (C) 1982 By Non-Linear Systems, Inc.       ##
  5. ;##      No warranty is made, expressed or implied.           ##
  6. ;###############################################################
  7. ;##    Last Update: 10/20/83          [01]              ##
  8. ;###############################################################
  9. ;
  10. ;History:
  11. ;    Add secondary xlate table and build in ability to have
  12. ;    function keys.
  13. ;                Steven R. Fabian    
  14. ;    Initialization of modem port on a cold boot.
  15. ;                Steven R. Fabian
  16. ;    Add Parallel port driver using a time delay.
  17. ;                Steven R. Fabian
  18. ;
  19. true    equ     0ffh
  20. false    equ    0
  21. ;
  22. ;****************************************************************
  23. ;*                                *
  24. ;*  This BIOS can support versions D, F and G versions of the    *
  25. ;*  Kaypro 10 CP/M system, if the proper equates are set.  Set    *
  26. ;*  one and only one of the following three equates to true;    *
  27. ;*  be sure the other two are false.                *
  28. ;*                                *
  29. versd    equ    false    ; for version 2.2D            *
  30. versf    equ    false    ; for version 2.2F            *
  31. versg    equ    true    ; for version 2.2G            *
  32. ;*                                *
  33. ;****************************************************************
  34. ;
  35. ;
  36. ;****************************************************************
  37. ;*                                *
  38. ;*  Set the following equate to false if a standard CP/M BIOS    *
  39. ;*  is desired.  Set it to true for ZCPR3 buffer initialization *
  40. ;*                                *
  41. zcpr3    equ    true    ;                    *
  42. ;*                                *
  43. ;****************************************************************
  44. ;
  45. ;    Version 3.0
  46. ;    Initial version customized for ZCPR3.
  47. ;    John C. Smith        July 23, 1984
  48. ;
  49. ;    Version 3.1
  50. ;    Added code to support ZCPR3 from floppy.  Requires
  51. ;    LDR SYS.RCP,SYS.ENV,SYS.FCP,NAMES.NDR be executed
  52. ;    from the boot floppy.  Path is changed to B$,B0
  53. ;    when booted from floppy to be consistent with
  54. ;    hard disk path of A$,A0.  Also, added code and
  55. ;    conditional equates to support CP/M versions 2.2D
  56. ;    and 2.2G.
  57. ;    John C. Smith        August 5, 1984
  58. ;
  59. zvers    equ    31        ; ZCPR version number
  60. ;
  61. ;
  62.     .Z80            ; Z80 CPU
  63. hdisk    equ    -1        ; -1 for hard disk, 0 for floppy
  64.  
  65.     if    zcpr3
  66. msize    equ    58        ; system memory size in k (ZCPR3)
  67.     else
  68. msize    equ    60        ; system memory size in k (CP/M)
  69.     endif
  70.  
  71. vers    equ    22        ; CP/M version number
  72. bias    equ    (msize-20)*1024    ; bias for systems larger than 20k
  73. ccp    equ    3400H+bias    ; start of CCP
  74. bdos    equ    ccp+806H    ; start of BDOS (The resident portion of CP/M)
  75. bios    equ    ccp+1600H    ; start of Basic I/O Subsystem (BIOS)
  76. cpml    equ    bios-ccp    ; length of CP/M system in bytes (less BIOS)
  77. nsects    equ    cpml/128    ; length of CP/M system in sectors (less BIOS)
  78.     if    hdisk
  79. trksec    equ    68        ; sectors/track
  80.     else
  81. trksec    equ    40
  82.     endif
  83. ;
  84. ;    ZCPR3 BUFFERS
  85. ;
  86. WHEEL    EQU    3EH        ; LOCATION OF WHEEL BYTE
  87. EXTPATH EQU    40H        ; START OF EXTERNAL PATH
  88. GRAF    EQU    4FH        ; LOCATION OF GRAPHICS BYTE
  89. MCMD    EQU    0F600H        ; MUTLI-COMMAND BUFFER
  90. ;
  91. ;
  92. ;
  93. bitport    equ    14H        ; status/control bit maped port
  94. baudA    equ    0        ; baud rate port (modem)
  95. baudB    equ    8        ; baud rate port (printer)
  96. baud30    equ    05H        ; 300 baud rate
  97. iobyte    equ    3        ; logical to physical map
  98. rom    equ    00000H        ; base of rom
  99. time    equ    8000H        ; time out rate
  100. fox    equ    0        ; set to 0
  101. siokb0    equ    07H        ; keyboard channel command/status
  102. siosp0    equ    0EH        ; serial printer command/status channel
  103. siom0    equ    06H        ; modem channel command/status 
  104. reset    equ    18H        ; channel reset 
  105. wr1    equ    01H        ; interrupt enable and wait/ready modes
  106. tid    equ    00H        ; transmitter interrupt disable
  107. rid    equ    00H        ; recieve interrupt disable
  108. wr3    equ    03H        ; receiver logic control parameters
  109. re    equ    01H        ; receiver enable
  110. autoe    equ    20H        ; auto enable (use dcd and cts to enable recv 
  111.                 ; and xmt 
  112. rbits8    equ    0C0H        ; 8 bits/character
  113. wr4    equ    04H        ; control bits that affect both xmt and recv
  114. sbits1    equ    04H        ; 1 stop bit
  115. cr16    equ    40H        ; x16
  116. wr5    equ    05H        ; control bits that affect xmt
  117. te    equ    08H        ; transmit enable
  118. tbits8    equ    60H        ; 8 bits/character
  119. dtr    equ    80H        ; DTR output
  120. pfdat    equ    24        ; cent out data port (8 bit latch)
  121. pstrob    equ    3               ; bit in bit port 
  122. ;    aseg
  123. ;    org    bios
  124.     .phase  bios
  125.  
  126.     jp    boot        ; arrive here from cold start
  127.     jp    wboot        ; arrive here for warm start
  128.     jp    const        ; console status return in A FF=ready, 00=not
  129.     jp    conin        ; console char in
  130.     jp    conout        ; console char out
  131.     jp    list        ; listing char out
  132.     jp    punch        ; punch char out
  133.     jp    reader        ; reader char in
  134.     jp    home        ; move to track 0 on selected disk drive
  135.     jp    seldsk        ; select disk drive
  136.     jp    settrk        ; set track #
  137.     jp    setsec        ; set sector #
  138.     jp    setdma        ; set DMA address
  139.     jp    read        ; read selected sector
  140.     jp    write        ; write selected sector
  141.     jp    listst        ; list status (Ready to print a char)
  142.     jp    sectran        ; sector translate
  143. ioconfig: defb    10000001B    ; initial value for i/o byte (may be patched)
  144. wrtsafe: defb    0        ; write safe flage 0=false
  145. vtab:    defb    11, 10, 8, 12    ; vector pad xlate table ^k ^j ^h ^l
  146.     defb    '0', '1', '2', '3'
  147.     defb    '4', '5', '6', '7'
  148.     defb    '8', '9',  0 ,  0
  149.     defb    0DH, '.'
  150. baudrt:    defb    baud30        ; baud rate (modem)
  151.     defb    baud30        ; baud rate (printer)
  152.  
  153.     defb    (sndtab-vtab)
  154.  
  155. sioint:                ;i/o device initialization table
  156.                 ;first byte is number of bytes to send
  157.                 ;second byte is port to send out to
  158.                 ;third byte is data
  159.     ;init sio channel for serial printer
  160.     defb    09H
  161.     defb    siosp0
  162.     defb    reset            ;reset sio channel
  163.     defb    wr4    
  164.     defb    sbits1 or cr16        ;one stop bit 16x clock
  165.     defb    wr3
  166.     defb    re or rbits8 or autoe    ;recv enable, 8bits/char
  167.     defb    wr5
  168.     defb    te or tbits8 or dtr     ;xmt enable, 8bits/char,assert dtr
  169.     defb    wr1
  170.     defb    tid or rid        ;xmt & recv interrupts disabled
  171.  
  172.     ;init sio channel for modem
  173.     defb    09H
  174.         defb    siom0
  175.     defb    reset            ;reset sio channel
  176.     defb    wr4    
  177.     defb    sbits1 or cr16        ;one stop bit 16x clock
  178.     defb    wr3
  179.     defb    re or rbits8 or autoe    ;recv enable, 8bits/char
  180.     defb    wr5
  181.     defb    te or tbits8 or dtr     ;xmt enable, 8bits/char,assert dtr
  182.     defb    wr1 
  183.     defb    tid or rid        ;xmt & recv interrupts disabled
  184.  
  185. siotbnd:defb    0            ;end of table
  186.  
  187. sndtab:    defb    0,0,0,0        ; up arrow key
  188.     defb    0,0,0,0        ; down arrow key
  189.     defb    0,0,0,0        ; left arrow key
  190.     defb    0,0,0,0        ; right arrow key
  191.     defb    0,0,0,0        ; 0 key on numeric pad
  192.     defb    0,0,0,0        ; 1 key on numeric pad
  193.     defb    0,0,0,0        ; 2 key on numeric pad
  194.     defb    0,0,0,0        ; 3 key on numeric pad
  195.     defb    0,0,0,0        ; 4 key on numeric pad
  196.     defb    0,0,0,0        ; 5 key on numeric pad
  197.     defb    0,0,0,0        ; 6 key on numeric pad
  198.     defb    0,0,0,0        ; 7 key on numeric pad
  199.     defb    0,0,0,0        ; 8 key on numeric pad
  200.     defb    0,0,0,0        ; 9 key on numeric pad
  201.     defb    'dir',0DH    ; - key on numeric pad
  202.     defb    'swp',0DH    ; , key on numeric pad 
  203.     defb    0,0,0,0        ; <cr>    "    "    
  204.     defb    0,0,0,0        ; . key on numeric pad
  205.  
  206.     if    versg
  207. mdmflg:    defb    0ffh        ;Internal modem flag 0=none present
  208.     endif
  209.  
  210. subttl Cold and Warm boot entry points    defb
  211. page
  212. ; Cold boot entry point, set up system pointers and pass control to the CCP
  213. boot:    call    diskint
  214.     xor    a        ; clear system disk number
  215.     ld    (4),a
  216.  
  217.     if    zcpr3
  218.     LD    (GRAF),A    ; reset graphics byte
  219.     CPL
  220.     LD    (WHEEL),A    ; set wheel byte
  221.     LD    HL,PATH        ; initialize path
  222.     LD    DE,EXTPATH
  223.     LD    BC,7
  224.     LDIR
  225.     LD    HL,CMD        ; initialize multi-command line buffer
  226.     LD    DE,MCMD
  227.     LD    BC,0CH
  228.     LDIR
  229.     LD    HL,0E600H    ; initialize ZCPR3 RCP buffer by
  230.     LD    A,8        ; filling memory with 0
  231.     CALL    ZLOOP
  232.     endif
  233.  
  234.     if    zcpr3 and not hdisk    ; if boot from floppy, initialize
  235.     LD    HL,0F100H    ; all other buffer spaces since
  236.     LD    a,5        ; there will be no load from the
  237.     CALL    ZLOOP        ; "putovl" track.
  238.     endif
  239.  
  240.     ld    a,(ioconfig)    ; init value for i/o byte
  241.     ld    (iobyte),a
  242.     ld    hl,sioint    ; initialize i/o devices
  243. iolp:    ld    b,(hl)        ; number of bytes to send
  244.     inc    hl
  245.     ld    c,(hl)        ; port to send
  246.     inc    hl        ; address of byte being sent
  247.     otir
  248.     ld    a,(hl)        ; get this byte
  249.     or    a        ; clean test
  250.     jr    nz,iolp        ; if more tables then do 
  251.  
  252.     if    versd and hdisk
  253.     IN    A,(BITPORT)    ;2.2D PATCH
  254.     OR    4        ;2.2D PATCH
  255.     OUT    (BITPORT),A    ;2.2D PATCH
  256.     endif
  257.  
  258.     ld    a,(baudrt)    ; set baud rates
  259.     out    (baudA),a
  260.     ld    a,(baudrt+1)
  261.     out    (baudB),a
  262.     call    print
  263.     defb    1AH, 0DH, 0AH
  264.     defb    'KAYPRO 10 '
  265.     defb    msize/10+'0', msize mod 10+'0'
  266.     defb    'K CP/M Version '
  267.     defb    vers/10+'0', '.', vers mod 10+'0'
  268.  
  269.     if    versd
  270.     defb    'D'
  271.     endif
  272.     if    versf
  273.     defb    'F'
  274.     endif
  275.     if    versg
  276.     defb    'G'
  277.     endif
  278.  
  279.     if    zcpr3
  280.     defb    ' & ZCPR Version ' 
  281.     defb    zvers/10+'0', '.', zvers mod 10+'0'
  282.     defb    ' JCS'
  283.     endif
  284.  
  285.     defb    0DH, 0AH, 00H
  286.  
  287. goccp:    ld    hl,time        ; reset disk time out
  288.     ld    (count),hl
  289.  
  290.     ld    a,0C3H        ; set up CP/M jumps to bdos and wboot
  291.  
  292.     ld    hl,bios+3    ; wboot entry point
  293.     ld    (0),a
  294.     ld    (1),hl
  295.  
  296.     ld    hl,bdos        ; entry point to bdos
  297.     ld    (5),a
  298.     ld    (6),hl
  299.  
  300.     ld    a,(4)        ; last logical disk unit used
  301.     ld    c,a
  302.     and    0FH        ; valid disk?
  303.     cp    3
  304.     jp    c,ccp
  305.     ld    a,c        ; no, so go to drive 0
  306.     and    0F0H
  307.     ld    c,a        ; pass to ccp to select
  308.     jp    ccp        ; pass control to ccp
  309.  
  310. ; Warm boot entry point, re-load the CCP and BDOS
  311. wboot:    
  312.     if    versg
  313.     ld    a,(mdmflg)
  314.     cp    0
  315.     call    nz,mdmnit
  316.     endif
  317.  
  318.     ld    c,0        ; select drive A:
  319.     call    seldsk
  320.     call    home
  321.     call    diskint
  322.     call    print
  323.     defb    0DH, 0AH, 'Warm Boot', 0DH, 0AH, 00H
  324. wb0:    ld    sp,100H        ; re-set stack
  325.     ld    bc,0        ; set track
  326.     call    settrk
  327.     ld    bc,ccp        ; first memory location to load
  328.     ld    (dmaadr),bc
  329.     call    setdma
  330.     ld    bc,nsects*256+1
  331. wb1:    push    bc        ; save sector count and current sector
  332.     call    setsec        ; select sector
  333.     call    read
  334.     pop    bc
  335.     or    a
  336.     jr    nz,wb0        ; oops, error on warm boot
  337.     push    bc
  338.     ld    hl,(dmaadr)    ; update dma address for next sector
  339.     ld    de,128        ; new dma address
  340.     add    hl,de
  341.     ld    b,h
  342.     ld    c,l
  343.     ld    (dmaadr),hl
  344.     call    setdma
  345.     pop    bc
  346.  
  347.     if    not zcpr3
  348.     xor    a
  349.     ld    (ccp+7),a
  350.     endif
  351.  
  352.     dec    b
  353.     jp    z,goccp        ; done loading
  354.     inc    c        ; bump sector count
  355.     if    not hdisk
  356.     ld    a,trksec    ; next track?
  357.     cp    c
  358.     jr    nz,wb1
  359.     ld    c,16        ; next sector to read
  360.     push    bc
  361.     ld    c,1
  362.     call    settrk        ; set track number
  363.     pop    bc
  364.     endif
  365.     jr    wb1
  366.  
  367. subttl logical to physical devices CON:, PUN:, RDR:, and LST:
  368. page
  369. ; logical devices are con: rdr: pun: and lst:
  370. ; physical devices are:
  371. ;    crt:    video and kbd
  372. ;    tty:    serial
  373. ;    lpt:    centronics
  374. ;    ul1:    serial with cts as busy
  375. ;    pun:    same as ul1
  376. ;
  377. ;con:    tty, crt
  378. ;rdr:    tty
  379. ;pun:    tty, pun
  380. ;lst:    tty, crt, lpt, ul1
  381.  
  382. const:    ld    hl,(count)    ; time out motors?
  383.     dec    hl
  384.     ld    (count),hl
  385.     ld    a,h
  386.     or    l
  387.     call    z,diskoff
  388.     ld    a,(cnt)        ;load function counter
  389.     or    a        ;clean test
  390.     jr    nz,loadup    ;set to do function if not 0
  391.     ld    a,(iobyte)    ; get i/o byte
  392.     and    03H        ; strip to con bits
  393.     ld    l,rom+33H    ; serial status
  394.     jp    z,callrom
  395.     ld    l,rom+2AH    ; assume CRT
  396.     jp    callrom
  397.  
  398. loadup:    ld    a,0ffh        ;set for get character
  399.     or    a        ;clean test
  400.     ret
  401.  
  402. conin:    call    const        ; key press?
  403.     or    a
  404.     jr    z,conin
  405.     ld    a,(cnt)        ;get counter value
  406.     or    a        ;clean test
  407.     jr    nz,frjp        ;do function if not 0
  408.     ld    a,(iobyte)    ; go get character
  409.     and    03H        ; check i/o byte
  410.     ld    l,rom+36H    ; serial input
  411.     jp    z,callrom
  412.     ld    l,rom+2DH    ; assume input from kbd
  413.     call    callrom        ; go get char
  414.     or    a
  415.     ret    p        ; msb not set
  416.     and    01FH        ; form table index to vtab
  417.     ld    hl,vtab
  418.     ld    c,a
  419.     ld    b,0
  420.     add    hl,bc
  421.     ld    a,(hl)        ; pick up xlated character
  422.     or    a        ; clean test
  423.     ret    nz        ; if valid character value return
  424.  
  425. sectab:    ld    hl,sndtab    ;set to new table value
  426.     ld    a,c        ;get character position
  427.     sla    a        ;shift left to
  428.     sla    a        ;mult by 2, again
  429.     ld    c,a        ;get new character position
  430.     add    hl,bc        ;set hl to character position
  431.     ld    (pntr),hl    ;store position in pointer
  432.     ld    a,4        ;set to this value
  433.     ld    (cnt),a        ;initialize counter to 4
  434.                 ;continue process of function
  435.  
  436. frjp:    ld    hl,(pntr)    ;get pointer value
  437.     ld    c,(hl)        ;load character into c reg
  438.     inc    hl        ;increment pointer
  439.     ld    (pntr),hl    ;save this value off
  440.     ld    a,(cnt)        ;retrieve current counter value
  441.     dec     a        ;decrement this value
  442.     ld    (cnt),a        ;save this value off
  443.     ld    a,c        ;move character into a
  444.     ret    z        ;return if zero
  445.     ld    a,(hl)        ;get next byte value
  446.     cp    fox        ;compare to 0
  447.     ld    a,c        ;move value in c to a
  448.     ret    nz        ;return if not zero
  449.     xor    a        ;clear accumulator
  450.     ld    (cnt),a        ;clear counter value
  451.     ld    a,c        ;move value in c to a
  452.     ret
  453.  
  454. diskoff:ld    l,rom+27H
  455.     jp    callrom
  456.  
  457. conout: 
  458.     if    zcpr3
  459.     LD    A,(GRAF)    ; check graphics byte
  460.     OR    A        ; is it set?
  461.     JR    NZ,R1        ; allow eighth bit if it is
  462.     LD    A,C        ; otherwise, mask it out
  463.     AND    7FH
  464.     LD    C,A
  465. R1:    
  466.     endif
  467.     
  468.     ld    a,(iobyte)    ; check i/o byte
  469.     and    03H
  470.     ld    l,rom+39H    ; serial output
  471.     jp    z,callrom
  472.     ld    l,rom+45H    ; assume video
  473.     jp    callrom
  474.  
  475. reader:    ld    l, rom+36H    ; serial input
  476.     jp    callrom
  477.  
  478. ;punch:    ld    a,(iobyte)    ; check i/o byte
  479. ;    and    30H
  480. ;    ld    l,rom+39H    ; serial punch
  481. ;    jp    z,callrom
  482. ;    ld    l, rom+42H    ; serial with cts as busy
  483. ;    jp    callrom
  484. punch:
  485.     ld    l,rom+39h    ;serial punch
  486.     jp    callrom
  487. ;
  488.  
  489. list:    ld    a,(iobyte)
  490.     and    0C0H        ; check i/o byte
  491.     ld    l,rom+39H    ; serial
  492.     jp    z,callrom
  493.     cp    80H        ; centronics
  494.     jp    z,lstdev    ; time delay routine for output
  495.     ld    l,rom+45H    ; video
  496.     cp    40H
  497.     jp    z,callrom
  498. ;    ld    l, rom+42H    ; assume serial with cts as busy
  499.     ld    l, rom+39h    ;ul1: default to serial
  500.     jp    callrom
  501.  
  502. listst:    ld    a,(iobyte)    ; check i/o byte
  503.     and    0C0H
  504.     ld    l,rom+42H    ; serial
  505.     jp    z,callrom
  506.     ld    l,rom+3CH    ; centronics
  507.     cp    80H
  508.     jp    z,callrom
  509.     xor    a        ; 0=ready
  510.     ret
  511.  
  512. lstdev:    call    listst        ; is printer busy
  513.     jr    nz,lstdev    ; if not return
  514.     ld    a,c        ; move character into a
  515.     out    (pfdat),a    ; output character to printer
  516.     in    a,(bitport)    ; strb. printer
  517.     res    pstrob,a
  518.     out    (bitport),a
  519.     set    pstrob,a
  520.     out    (bitport),a
  521.     ret
  522.  
  523.     if    versg
  524. mdmnit:    ld    a,0fh        ; set up pio
  525.     out    (23h),a
  526.     ld    a,87h        ; and interrupt vector
  527.     out    (23h),a
  528.     ld    a,4ah        ; set modem on-hook
  529.     out    (21h),a
  530.     endif
  531.  
  532. subttl Disk I/O and ROM dispatch
  533. page
  534. diskint:ld    l,rom+03H    ; re-set disk software sub-system
  535.     jr    callrom
  536.  
  537. home:    ld    l,rom+0CH    ; home disk drive rom routine
  538.     jr    callrom
  539.  
  540. seldsk:    ld    l,rom+0FH    ; select disk drive
  541.     jr    callrom
  542.  
  543. settrk:    ld    l,rom+12H    ; seek track
  544.     jr    callrom
  545.  
  546. setsec:    ld    l,rom+15H    ; set sector number
  547.     jr    callrom
  548.  
  549. setdma:    ld    l,rom+18H    ; set dma address
  550.     jr    callrom
  551.  
  552. read:    ld    hl,time        ; reset time out
  553.     ld    (count),hl
  554.     ld    l,rom+1BH    ; read a logical sector
  555.     jr    callrom
  556.  
  557. write:    ld    hl,time        ; reset time out
  558.     ld    (count),hl
  559.     ld    l,rom+1EH    ; write a logical sector
  560.     ld    a,(wrtsafe)    ; write safe flag
  561.     or    a        ; true or false
  562.     jr    z,callrom    ; normal operation
  563.     ld    c,1        ; directory write code (forces write op)
  564.     jr    callrom
  565.  
  566. sectran:ld    l,rom+21H    ; xlate logical to physical sector
  567.     jr    callrom
  568.  
  569. callrom:exx            ; save cp/m arguments
  570.     in    a,(bitport)    ; turn rom on
  571.     set    7,a
  572.     out    (bitport),a    
  573.     ld    (savsp),sp    ; save current stack (may be under rom)
  574.     ld    sp,stack    ; set a local stack
  575.     ld    de,biosret    ; rom to "RET" here
  576.     push    de
  577.     exx            ; restore cp/m arguments and call loc
  578.     ld    h,0
  579.     jp    (hl)        ; to rom routine specified in hl
  580. biosret:ex    af,af'        ; save reg A
  581.     ld    sp,(savsp)    ; restore stack
  582.     in    a,(bitport)    ; off the rom
  583.     res    7,a
  584.     out    (bitport),a
  585.     ex    af,af'        ; restore reg A
  586.     ret            ; done with rom routine
  587.  
  588. print:
  589.     ex    (sp),hl    ; pop return address, points to text to print
  590.     ld    a,(hl)    ; get a byte of text, stop on zero byte
  591.     inc    hl
  592.     ex    (sp),hl    ; save new return address
  593.     or    a    ; is it a zero byte?
  594.     ret    z
  595.     ld    c,a    ; no, so print it
  596.     call    conout
  597.     jr    print
  598.  
  599.     if    zcpr3
  600. ZLOOP:    LD    B,0FFH
  601. ZERO:    LD    (HL),0
  602.     INC    HL
  603.     DJNZ    ZERO
  604.     DEC    A
  605.     JR    NZ,ZLOOP
  606.     RET
  607.     endif
  608.  
  609.     if    hdisk and zcpr3
  610. PATH:    DEFB    1,'$',1,0,0,0,0,0,0,0,0        ; search path
  611.     else
  612. PATH:    DEFB    2,'$',2,0,0,0,0,0,0,0,0
  613.     endif
  614.  
  615.     if    zcpr3
  616. CMD:    DEFB    4,0F6H,0C8H,0,'STARTUP',0    ; mcl buffer
  617. pntr:    defw    0    ; pointer for function key routine
  618. cnt:    defb    0    ; character counter for function routine
  619. count:    defs    2    ; disk time out counter
  620. savsp:    defs    2    ; current spact pointer during rom call
  621. dmaadr:    defs    2    ; dma address for warm boot
  622.     db    'END'    ; end of BIOS marker
  623. stack    equ    $+64    ; a local stack
  624.  
  625.     else
  626.  
  627. ; Patch CCP to display user # and search user 0 for a COM file.
  628.  
  629. openf    equ    15        ; open disk function
  630. bdosent    equ    5        ; entry point to bdos
  631. ccperr    equ    ccp+7EEH
  632. ccpfcb    equ    ccp+7CDH
  633. ccpco    equ    ccp+8CH
  634. ccpread    equ    ccp+0F9H
  635. ccpp1    equ    ccp+0392H
  636. ccpp2    equ    ccp+00D7H
  637. ccpp3    equ    ccp+06E9H
  638.  
  639. getusr    macro    x
  640.     .xlist
  641.     ld    e,-1
  642.     ld    c,32
  643.     call    bdosent
  644.     ld    (x),a
  645.     .list
  646.     endm
  647.  
  648. setusr    macro    x
  649.     .xlist
  650.     ld    a,(x)
  651.     ld    e,a
  652.     ld    c,32
  653.     call    bdosent
  654.     .list
  655.     endm
  656.  
  657. p1:    ld    c,32        ; show user#, get current one
  658.     ld    e,-1        ; e=255 is get user code
  659.     call    bdosent
  660.     cp    10        ; if a>10 then print first digit
  661.     jr    c,pmt0
  662.     sub    10
  663.     push    af        ; save second digit
  664.     ld    a,'1'
  665.     call    ccpco
  666.     pop    af
  667. pmt0:    add    a,'0'        ; for ascii digit
  668.     call    ccpco
  669.     ld    a,'>'
  670. pmt2:    jp    ccpco
  671.  
  672. p2:    getusr    curuser
  673.     ld    (fcbuser),a
  674.     ld    de,ccpfcb
  675.     ld    c,openf        ; open a file (check user 0 if not found)
  676.     call    bdosent
  677.     ld    (ccperr),a
  678.     inc    a
  679.     ret    nz        ; nz=file opened
  680.     ld    a,(curuser)    ; get current user #
  681.     or    a
  682.     jr    z,nogd        ; in user 0, file open no good
  683.     xor    a
  684.     ld    (fcbuser),a    ; try user 0
  685.     setusr    fcbuser
  686.     ld    de,ccpfcb    ; try to open file
  687.     ld    c,openf
  688.     call    bdosent
  689.     ld    (ccperr),a    ; ccp error return
  690.     setusr    curuser        ; restore user #
  691. nogd:    ld    a,(ccperr)    ; was open ok?
  692.     inc    a
  693.     ret            ; back to ccp
  694.  
  695. p3:    setusr    fcbuser        ; read a sector
  696.     ld    de,ccpfcb
  697.     call    ccpread
  698.     push    af
  699.     setusr    curuser
  700.     pop    af
  701.     ret
  702. pntr:    defw    0    ; pointer for function key routine
  703. cnt:    defb    0    ; character counter for function routine
  704. curuser:defs    1    ; current user
  705. fcbuser:defs    1    ; user # of load file
  706. count:    defs    2    ; disk time out counter
  707. savsp:    defs    2    ; current spact pointer during rom call
  708. dmaadr:    defs    2    ; dma address for warm boot
  709. stack    equ    $+64    ; a local stack
  710.     endif
  711.  
  712.     end
  713.  
  714.