home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug097.arc / CACHE.MAC < prev    next >
Text File  |  1979-12-31  |  4KB  |  244 lines

  1. ;
  2. ;
  3. ;    512k operating system support program.
  4. ;    Disk cache control program.
  5. ;
  6. ;
  7.  
  8. bdos        equ    5
  9. cr        equ    13
  10. lf        equ    10
  11. tab        equ    9
  12. bell        equ    7
  13. command_line    equ    80h
  14.  
  15. bios_start    equ    0E700h
  16. id        equ    218h
  17. id_val        equ    0AA55h
  18. cache_pages    equ    226h
  19. restore_cache    equ    28Fh
  20. cache_table    equ    158h
  21. num_drives    equ    12Bh
  22. md_pages    equ    225h
  23. mem_page    equ    292h
  24. normal_map    equ    4
  25. bios_map    equ    0Ch
  26. map_port    equ    50h
  27. rst_00h        equ    0C7h
  28.  
  29.  
  30.     aseg
  31.  
  32.     org    100h
  33.  
  34.     ld    de,start_mesg
  35.     ld    c,9
  36.     call    bdos
  37.  
  38.     ld    hl,(bios_start+id)
  39.     ld    de,id_val
  40.     or    a
  41.     sbc    hl,de
  42.     jp    nz,get_lost
  43.  
  44.     ld    hl,command_line
  45.     ld    a,(hl)
  46.     or    a
  47.     jr    z,show_use
  48.     ld    b,a
  49.  
  50.     ld    de,cache_off_mesg
  51.     ld    a,(bios_start+restore_cache)
  52.     or    a
  53.     jp    z,prt_ret
  54.  
  55. parse:
  56.     inc    hl
  57.     ld    a,(hl)
  58.     cp    '?'
  59.     jr    z,show_size
  60.     or    'a'-'A'
  61.     cp    'e'
  62.     jr    z,enable
  63.     cp    'd'
  64.     jr    z,disable
  65.     cp    ' '
  66.     jr    nz,show_use
  67.     djnz    parse
  68. show_use:
  69.     ld    de,use_mesg
  70.     ld    c,9
  71.     call    bdos
  72.     jr    show_size
  73.  
  74. enable:
  75.     ld    c,0        ; Enabled flag
  76.     call    load_map_c
  77.     jr    purge_drives
  78.  
  79. disable:
  80.     ld    c,0FFh
  81.     call    load_map_c
  82.  
  83. purge_drives:
  84.     ld    b,4
  85.     ld    c,0
  86. pd_1:
  87.     push    bc
  88.     ld    a,6        ; XBIOS purge disk (C)
  89.     rst    28h
  90.     pop    bc
  91.     inc    c
  92.     djnz    pd_1
  93.  
  94. force_boot:
  95. ;    ld    a,rst_00h
  96. ;    ld    (ret_instr),a
  97.  
  98. show_size:
  99. ; Replace 'D:' in message with 'L:' if less than 4 drives
  100.     ld    a,(bios_start+num_drives)
  101.     cp    4
  102.     jr    nc,ss_3
  103.     ld    a,'L'
  104.     ld    (cache_drives_mesg+1),a
  105. ss_3:
  106. ; Loop to find which drives enabled
  107.     ld    hl,bios_start+cache_table+4
  108.     ld    ix,cache_drives_mesg
  109.     ld    bc,4*256+0
  110. ;    ld    c,0    ; Number found disabled
  111. ss_2:
  112.     dec    hl
  113.     ld    a,(hl)
  114.     sub    0FFh
  115.     jr    nz,ss_enabled
  116.     inc    c
  117.     ld    (ix),a
  118.     ld    (ix+1),a
  119.     ld    (ix+2),a
  120. ss_enabled:
  121.     dec    ix
  122.     dec    ix
  123.     dec    ix
  124.     djnz    ss_2
  125. ; Are none enabled ?
  126.     ld    de,cache_temp_off_mesg
  127.     ld    a,c
  128.     cp    4
  129.     jr    z,ss_1
  130. ; Are all enabled
  131.     ld    de,cache_on_mesg
  132.     or    a
  133.     jr    z,ss_1
  134. ; 1..3 enabled
  135.     ld    de,cache_some_mesg
  136. ; is just 1 enabled
  137.     sub    3
  138.     jr    nz,ss_1
  139.     ld    (cache_pl_mesg),a
  140. ss_1:
  141.     ld    c,9
  142.     call    bdos
  143.     ld    a,(bios_start+restore_cache)
  144.     dec    a
  145.     ld    b,a
  146.     add    a,b
  147.     add    a,b
  148.     ld    e,a
  149.     ld    d,0
  150.     ld    hl,cache_sizes
  151.     add    hl,de
  152.     ld    de,cache_size_loc
  153.     ld    bc,3
  154.     ldir
  155.     ld    de,cache_size_mesg
  156.     jr    prt_ret
  157.  
  158. get_lost:
  159.     ld    de,wb_mesg
  160. prt_ret:
  161.     ld    c,9
  162.     call    bdos
  163. ret_instr:
  164.     ret
  165.  
  166. ; Load flag in C into cache available map
  167. load_map_c:
  168.     ld    ix,bios_start+cache_table
  169.     dec    b
  170.     jr    z,en_3
  171. ; Allow/disallow buffering on selected drives ( flag them 0/0FFh )
  172. en_sel_drives:
  173.     inc    hl
  174.     ld    a,(hl)
  175.     or    'a'-'A'
  176.     sub    'a'
  177.     jr    c,en_2
  178.     cp    'L'-'A'
  179.     jr    nz,en_4
  180.     sub    'L'-'D'
  181. en_4:
  182.     cp    'D'-'A'+1
  183.     jr    nc,en_2
  184.     ld    (ix_offs_1),a
  185. ix_offs_1    equ    $+2
  186.     ld    (ix+0),c        ; flag
  187. en_2:
  188.     djnz    en_sel_drives
  189.     ret
  190. ; Enable/disable all
  191. en_3:
  192.     ld    b,4
  193. en_all:
  194.     ld    (ix),c
  195.     inc    ix
  196.     djnz    en_all
  197.     ret
  198.  
  199.  
  200. start_mesg:
  201.     db    cr,lf,'Microbee 512k Enhanced Operating System v2.2,'
  202.     db    ' (c) 1987 Peter Broughton.',cr,lf
  203.     db    'CACHE : disk cache control program.',cr,lf,lf,'$'
  204.  
  205. wb_mesg:
  206.     db    bell,'Wrong operating system !!',cr,lf,lf,'$'
  207.  
  208. use_mesg:
  209.     db    'Use : CACHE E/D/? [A:/B:/C:/D:/L:].',cr,lf
  210.     db    tab,'E - Enable cache on all or selected drives,',cr,lf
  211.     db    tab,'D - Disable cache on all or selected drives,',cr,lf
  212.     db    tab,'? - Query status.',cr,lf,lf,'$'
  213.  
  214. cache_off_mesg:
  215.     db    'Cache disabled (no memory allocated).'
  216.     db    cr,lf,lf,'$'
  217.  
  218. cache_size_mesg:
  219.     db    'Memory available to cache : '
  220. cache_size_loc:
  221.     db    '000k.',cr,lf,lf,'$'
  222.  
  223. cache_sizes:
  224.     db    0,'32',0,'64',0,'96128'
  225.  
  226. cache_on_mesg:
  227.     db    'Cache enabled for all drives.',cr,lf,'$'
  228.  
  229. cache_some_mesg:
  230.     db    'Cache enabled for drive'
  231. cache_pl_mesg:
  232.     db    's A: B: C:'
  233. cache_drives_mesg:
  234.     db    ' D:.',cr,lf,'$'
  235.  
  236. cache_temp_off_mesg:
  237.     db    'Cache disabled for all drives.',cr,lf,'$'
  238.  
  239.     if    ($ and 7Fh) ne 0
  240.      ds    80h-($ and 7Fh)
  241.     endif
  242.  
  243.     end
  244.