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 / BDOS / DOSPLSOR.ARK / SYSGEN.MAC < prev    next >
Text File  |  1987-05-08  |  6KB  |  337 lines

  1. ; This creates a SYSGEN for the Kaypro 2/4 floppy disks.
  2. ; If no SYSGEN is supplied with your system try modifying this.
  3. ; Be sure to change the identification sign-on at the end.
  4. ;
  5. ; If modifying for hard disks, note 1 byte used for trk/sector sets.
  6. ;
  7. ; 87/05/02 slaved bad drive message to maxdv. cbf
  8. ;
  9. boot    equ    0
  10. @bios    equ    boot+1
  11. @cin    equ    1
  12. @cout    equ    2
  13. cpm    equ    5
  14. lf    equ    0Ah
  15. cr    equ    0Dh
  16. yes    equ    -1
  17. no    equ    not yes
  18.  
  19. @fopn    equ    15
  20. @rdsq    equ    20
  21. @stdma    equ    26
  22.  
  23. tfcb    equ    5Ch
  24. tfcbn    equ    5Dh
  25. tfcbr    equ    7Ch
  26. defdma    equ    080h
  27. ;
  28. ;    -------
  29. ; Modify the following equates for other systems.
  30. ;
  31. bootsz    equ    1;        number of boot loader sectors
  32. ;                (0 for Osborne I ? )
  33. image    equ    0980h - 128 * bootsz;    start of memory image
  34. ;
  35. ; Applies to all except last system track used.
  36. tk0bgn    equ    0;        1st sector to use on trk 0
  37. spertk    equ    40;        sectors / physical trk, use on trk 0
  38. ;
  39. ; Kaypro special.  Puts rest of system in allocated, unused
  40. ;  bk 1 (dsdd), or bks 2,3 (ssdd).  Most others use tk0bgn/spertk here
  41. ; NOTE not for hard disks, floppies only!!.  
  42. ltkbgn    equ    16;        1st sector to use on last trk
  43. ltksiz    equ    16;        # sectors to use on last trk
  44.  
  45. systks    equ    2;        Kaypro uses 0 and part of 1
  46. maxdv    equ    3;        allowed for put/get system 1=A etc.
  47. ;    -------
  48.  
  49. begin:    lxi    sp,stktop
  50.     lxi    h,signon
  51.     call    tstr
  52.     lda    tfcbn
  53.     cpi    ' '
  54.     jz    getsor;        no file specified
  55.     lxi    d,tfcb
  56.     call    fopen
  57.     inr    a
  58.     lxi    h,nosorf
  59.     jz    exitm;        not found
  60. ;    "    "
  61. fload:    xra    a;        Load from a file
  62.     sta    tfcbr;        start at record 0
  63.     mvi    b,(image - 100h) / 128;    skip 1st 2k
  64. fload1:    push    b
  65.     lxi    d,tfcb
  66.     lxi    h,defdma
  67.     call    frdseq;        into default dma & discard
  68.     pop    b
  69.     ora    a
  70.     lxi    h,short
  71.     jnz    exitm;        can't skip
  72.     dcr    b
  73.     jnz    fload1
  74.     lxi    h,image-128;    file pos'nd
  75. fload2:    ora    h;        a was zero
  76.     jm    putsys;        big input, over 32k!! Truncate
  77.     lxi    d,128
  78.     dad    d
  79.     lxi    d,tfcb
  80.     call    frdseq
  81.     ora    a
  82.     jz    fload2;        not eof
  83.     mov    a,h
  84.     lxi    h,short
  85.     cpi    (image + 1700h) shr 8
  86.     jc    exitm;        must have at least 128 bytes of bios
  87.     jmp    putsys
  88.  
  89. notsor:    call    badrv;        message and try again
  90. ;    "    "
  91. getsor:    lxi    h,sormsg;    Optionally get sys tracks
  92.     call    tstrc
  93.     call    cinup
  94.     cpi    cr
  95.     jz    putsys;        cr skips get
  96.     sta    sordrv
  97.     sui    'A'
  98.     cpi    maxdv
  99.     jnc    notsor;        invalid drive
  100.     call    bsetdv
  101.     call    crlf
  102.     lxi    h,sormnt
  103.     call    tstr
  104.     call    cinup
  105.     cpi    cr
  106.     jnz    abort;        non-cr aborts everything
  107.     xra    a
  108. ;    "    "
  109. ; read if a = 0, else write
  110. rwsys:    sta    wrtflg
  111.     call    crlf
  112.     call    sysio
  113.     lxi    h,dunmsg
  114.     call    tstr
  115.     jmp    putsys
  116.  
  117. notdst:    call    badrv;        message and try again
  118. ;    "    "
  119. putsys:    lxi    h,dstmsg;    Optionally put sys tracks
  120.     call    tstrc
  121.     call    cinup
  122.     cpi    cr
  123.     jz    exit;        cr aborts, leaves any image
  124.     sta    dstdrv
  125.     sui    'A'
  126.     cpi    maxdv
  127.     jnc    notdst;        invalid drive
  128.     call    bsetdv
  129.     lxi    h,dstmnt
  130.     call    tstrc
  131.     call    cinup
  132.     cpi    cr
  133.     jnz    abort;        non-cr aborts everything
  134.     mvi    a,1
  135.     jmp    rwsys
  136.  
  137. abort:    lxi    h,abortm
  138. ;    "    "
  139. exitm:    call    tstrc
  140. ;    "    "
  141. exit:    mvi    a,0
  142.     call    bsetdv;        select drive a on bios
  143.     jmp    boot
  144.  
  145. ; Subroutines
  146.  
  147. ; console in and upshift
  148. ; a,f
  149. cinup:    mvi    a,@cin
  150.     call    dos
  151.     cpi    'a'
  152.     rc;            not lower case
  153.     cpi    'z'+1
  154.     rnc;            not lower case
  155.     ani    5fh;        upshift
  156.     ret
  157.  
  158. ; cr/lf to console
  159. ; a,f,e
  160. crlf:    mvi    a,cr
  161.     call    couta
  162.     mvi    a,lf
  163. ;    "    "
  164. ; (a) a to console
  165. ; a,f,e
  166. couta:    mov    e,a
  167.     mvi    a,@cout
  168.     jmp    dos
  169.  
  170. badrv:    lxi    h,baddrv;    message
  171. ;    "    "
  172. ; crlf then string hl^
  173. ; a,f,e,h,l
  174. tstrc:    call    crlf
  175. ;    "    "
  176. ; string hl^ to console
  177. ; a,f,e,h,l
  178. tstr:    mov    a,m;        0 terminated message
  179.     ora    a
  180.     rz
  181.     call    couta
  182.     inx    h
  183.     jmp    tstr
  184.  
  185. ; Bios calls.  All regs modified
  186. ; set drive a
  187. bsetdv:    mov    c,a
  188.     mvi    e,18h
  189. ;    "    "
  190. xbios:    mvi    d,0;        call entry #e/3
  191.     lhld    @bios
  192.     dad    d
  193.     pchl
  194.  
  195. bsetrk:    mvi    e,1bh
  196.     jmp    xbios
  197.  
  198. bstsec:    mvi    e,1eh
  199.     jmp    xbios
  200.  
  201. bstdma:    mvi    e,21h
  202.     jmp    xbios
  203.  
  204. bread:    mvi    e,24h
  205.     jmp    xbios
  206.  
  207. bwrite:    mvi    e,27h
  208.     jmp    xbios
  209.  
  210. ; CPM DOS calls
  211. ;
  212. ; read next record file de^ into hl^
  213. ; a,f
  214. frdseq:    xchg
  215.     mvi    a,@stdma
  216.     call    dos
  217.     xchg
  218.     mvi    a,@rdsq
  219. ;    "    "
  220. ; dos call (a), saving regs
  221. ; a,f
  222. dos:    push    h
  223.     push    d
  224.     push    b
  225.     mov    c,a
  226.     call    cpm
  227.     pop    b
  228.     pop    d
  229.     pop    h
  230.     ret
  231.  
  232. ; open file de^
  233. ; a,f
  234. fopen:    mvi    a,@fopn
  235.     jmp    dos
  236.  
  237. ; The actual work - get/put system
  238. ; a,f,b,c,d,e,h,l
  239. sysio:    lxi    h,image
  240.     shld    xfradr
  241.     mvi    a,0;        1st system track always 0
  242.     sta    track
  243. ;    "    "
  244. ; Repeat this code for each full track except the last.
  245.     rept    systks - 1
  246.      mvi    a,tk0bgn
  247.      sta    sector
  248.      mvi    a,spertk
  249.      sta    nsects
  250.      call    trkio;        do first track
  251.     endm
  252. ;    "    "
  253. ; following used for LAST system track.
  254.     if    systks GT 1
  255.      mvi    a,systks-1
  256.      sta    track
  257.      mvi    a,ltkbgn;    Magic for Kaypro
  258.      sta    sector;        setup for last track
  259.      mvi    a,ltksiz;    "    "
  260.      sta    nsects;        now do last track
  261.      call    trkio
  262.     endif
  263.     ret
  264. ;
  265. trkio:    lda    track;        rd/write 1 track area
  266.     mov    c,a
  267.     inr    a
  268.     sta    track;        advance for next time
  269.     call    bsetrk
  270. trkio1:    lda    sector
  271.     mov    c,a
  272.     inr    a
  273.     sta    sector
  274.     call    bstsec
  275.     lhld    xfradr
  276.     push    h
  277.     lxi    d,128
  278.     dad    d
  279.     shld    xfradr
  280.     pop    b
  281.     call    bstdma;        input value
  282.     xra    a
  283.     sta    errors
  284. trkio2:    lda    errors
  285.     cpi    1
  286.     jc    trkio3
  287.     lxi    h,ioerr
  288.     call    tstr
  289.     call    cinup
  290.     cpi    cr
  291.     jnz    exit
  292.     call    crlf
  293.     jmp    trkio6
  294.  
  295. trkio3:    inr    a
  296.     sta    errors
  297.     lda    wrtflg
  298.     ora    a
  299.     jz    trkio4
  300.     call    bwrite
  301.     jmp    trkio5
  302.  
  303. trkio4:    call    bread
  304. trkio5:    ora    a
  305.     jnz    trkio2
  306. trkio6:    lxi    h,nsects
  307.     dcr    m
  308.     jnz    trkio1
  309.     ret
  310.  
  311. signon:    db    'SYSGEN [fn.ft]  (for Kaypro only)',0
  312. sormsg:    db    'Source drive ( <ret> to skip) :',0
  313. sormnt:    db    'Source on '
  314. sordrv:    db    0,', then type return ',0
  315. dstmsg:    db    'Destination drive ( <ret> reboots) :',0
  316. dstmnt:    db    'Destination on '
  317. dstdrv:    db    0,', then type return ',0
  318. ioerr:    db    'PERMANENT ERROR, <ret> to ignore',0
  319. dunmsg:    db    'Function complete',0
  320. baddrv:    db    'Invalid drive (A thru '
  321.     db    maxdv+'@'
  322.     db    ')',0
  323. nosorf:    db    'Source file not found',0
  324. short:    db    'Source file too short',0
  325. abortm:    db    'Aborted',0
  326.  
  327. track:    ds    1
  328. sector:    ds    1
  329. nsects:    ds    1;    To read
  330. wrtflg:    ds    1;    zero to read, else write
  331. xfradr:    ds    2
  332. errors:    ds    1
  333.     ds    64
  334. stktop:    
  335.     end
  336. ┌8