home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / compress / nulu152.lbr / NULU152.IZF / NULU152.INF
Text File  |  1990-11-03  |  22KB  |  503 lines

  1.               Additional Information for NULU version 1.52
  2.                             15 July 1987
  3.                                 by
  4.                             Mick Waters
  5.  
  6. Thi≤á documen⌠á detail≤ addition≤ anΣ change≤ t∩ NUL╒ version≤á 1.╡á anΣ ì
  7. 1.5▒á t∩á makσá versioε 1.52¼á particularl∙ t∩ use≥ modificatioεá anΣá ß ì
  8. history of the changes.
  9.  
  10. NUL╒ i≤ copyrigh⌠ (c⌐ 1984¼ 198╡ anΣ 198╖ b∙ Martiε Murray«  Thσ author≤ ì
  11. origina∞á copyright≤ remaiε intac⌠ despitσ thesσ change≤ oµ minσ anΣ hi≤ ì
  12. terms of use still apply.
  13.  
  14. History since 1985
  15. ------------------
  16.  
  17. NUL╒ versioε 1.╡ wa≤ releaseΣ iε 198╡ anΣ wa≤ haileΣ a≤ onσ oµ thσá mos⌠ ì
  18. usefu∞á utilit∙á program≤ oµ it≤ time¼á faste≥ thaε thσ origina∞ L╒á anΣ ì
  19. added filesweep facilities comparable to Dave Rands NSWP.
  20.  
  21. Somσá timσ afte≥ release¼á user≤ noticeΣ problem≤ wheεá extractinτá datß ì
  22. froφá ß librar∙ oε onσ drivσ t∩ file≤ oε another«á Thi≤ wa≤ founΣ t∩á bσ ì
  23. duσá t∩ ß buτ iε thσ CP/═ 2.▓ BDO╙ associateΣ (i⌠ wa≤ thought⌐ witΦ BDO╙ ì
  24. functioεá 3╖á (Rese⌠ Drive)«á ┴ temporar∙ fi° wa≤ issueΣ b∙á Martiεá (a≤ ì
  25. versioεá 1.51⌐ whicΦ effectivel∙ preventinτ user≤ froφ extractinτá file≤ ì
  26. t∩ drive≤ othe≥ thaε thσ default«á  Note¼ howeve≥ tha⌠ thi≤ probleφ doe≤ ì
  27. no⌠ occu≥ wheε runninτ unde≥ CP/═ Plus« Subsequently¼ ╔ discovereΣ ß buτ ì
  28. iε thσ KruncΦ routinσ whicΦ ╔ though⌠ a⌠ thσ timσ would¼á unde≥á certaiε ì
  29. circumstances¼á causσ ß gooΣ librar∙ t∩ bσ corrupted« Sincσ NUL╒ wa≤ to∩ ì
  30. gooΣ t∩ thro≈ awa∙ and¼ sincσ ß ne≈ releasσ haΣ no⌠ appeareΣ t∩ overcomσ ì
  31. thσ BDO╙ functioε 3╖ bug¼ ╔ voweΣ t∩ makσ thσ necessar∙ changes.
  32.  
  33. Now¼á somσ tw∩ o≥ threσ month≤ later¼á afte≥ disassemblinτ NUL╒á versioε ì
  34. 1.╡á anΣ missinτ ou⌠ oε severa∞ night≤ sleep¼á ╔ offe≥ versioε 1.5▓á in-ì
  35. lie⌡ oµ an∙ officia∞ upgradσ b∙ Martin.
  36.  
  37. Problems encountered
  38. --------------------
  39.  
  40. A≤ promiseΣ iε m∙ origina∞ buτ report¼á ╔ includσ ß (deliberatel∙ vague⌐ ì
  41. lis⌠á oµ thσ problem≤ founΣ anΣ thσ change≤ made«á Iε tha⌠ repor⌠ ╔ als∩ ì
  42. promiseΣá t∩ adΣ aε uncrunchinτ routinσ - I'φ afraiΣ thi≤ wil∞á havσá t∩ ì
  43. wait until I get time.
  44.  
  45. Thσá KruncΦá problem¼á a≤ i⌠ turneΣ out¼á wasn'⌠ a≤ seriou≤ a≤á ╔á firs⌠ ì
  46. predicted« Oncσ ╔ go⌠ int∩ Martin≤ code¼ ╔ discovereΣ tha⌠ althougΦ NUL╒ ì
  47. would¼á unde≥á thσ circumstance≤ ╔ described¼á fai∞ t∩ KruncΦ ßá librar∙ ì
  48. correctly¼á i⌠á woulΣá discove≥ thσ erro≥ (a≤ ß CR├ error⌐ anΣá n∩á harφ ì
  49. would be done.
  50.  
  51. Iε wha⌠ follows¼ m∙ reference≤ t∩ interna∞ NUL╒ routine≤ arσ necessaril∙ ì
  52. vaguσá sincσ withou⌠ thσ origina∞ source¼á ╔ canno⌠ refe≥ t∩á meaningfu∞ ì
  53. labe∞ names« M∙ disassembler¼ oµ course¼ gavσ labe∞ name≤ likσ L012│ anΣ ì
  54. J123┤á - prett∙ meaningles≤ t∩ Martiε ╔ imagine«á However¼á armeΣ witΦ ß ì
  55. disassebler, he should be able to see the changes that I have made.è
  56. Thσá fi°á fo≥ thσ KruncΦ buτ relate≤ t∩ thσ callinτ oµ ßá routinσá whicΦ ì
  57. read≤á ß disδ filσ witΦ CR├ calculatioε (origina∞ addres≤á 1BBAH)«á Thi≤ ì
  58. routinσá i≤á calleΣ witΦ A=▒ iµ aε initia∞ seeδ i≤ requireΣ t∩ finΣá thσ ì
  59. star⌠á oµ thσ wanteΣ membe≥ file«á Thσ changσ involveΣ savinτ thi≤ a≤á ß ì
  60. flaτ and¼ iµ 1BBA╚ returneΣ aε erro≥ tha⌠ involveΣ ß subsequen⌠ writσ t∩ ì
  61. disδ (buffe≥ ful∞ condition)¼á thσ flaτ wa≤ rese⌠ t∩ it≤ origina∞á statσ ì
  62. (▒ o≥ 0⌐ a≤ appropriate« Iµ an∙ datß wa≤ read¼ thσ flaτ shoulΣ bσ se⌠ t∩ ì
  63. zer∩ t∩ avoiΣ multiplσ seeks«á ┴ sectioε oµ thσ codσ follows¼á thσ labe∞ ì
  64. names used are my own but, I expect that Martin will recognise it:
  65.  
  66.     LD A,1                ; Set flag for an initial seek
  67.     LD (SEEKF),A       Added
  68. J1438:    CALL SWPFCB            ; Swap over the FCBs
  69. ;       PUSH AF            Removed
  70.     LD A,0                ; Saved user number for current library
  71. L143D    EQU $-1
  72.     CALL SUSRIR            ; Set user if not already there
  73. ;       POP AF             Removed
  74.     LD A,0             Added    ; Restore the seek flag
  75. SEEKF    EQU $-1            Added
  76.     CALL RDFCRC            ; Read file with CRC
  77.     CALL SWPFCB            ; Swap over the FCBs
  78.     JP Z,J1460            ; Jump if any errors
  79.     LD A,L                ; Test records still to read
  80.     OR H
  81.     LD HL,(L1425)            ; Get current record count
  82.     ADD HL,DE            ; Add on records just read
  83.     LD (L1425),HL            ; Save latest position in library
  84.     LD HL,(L146A)            ; Get records to write
  85.     ADD HL,DE            ; Add on records just read
  86.     LD (L146A),HL            ; Save new number of records to write
  87.     JP Z,J13A6            ; Jump if nothing left to read
  88.     SUB A              Added
  89.     LD (SEEKF),A       Added    ; Clear seek flag for next read
  90.     LD A,77                ; Error 77: Insufficient memory -
  91.                     ;  Interpret as meaning buffer full
  92. J1460:    OR A
  93.     JP Z,J13A6            ; Jump if end of member file reached
  94.     CP 77
  95.     JP NZ,J1495            ; Jump if not an out of memory error
  96.  
  97. ;
  98. ; The input buffer is now full, we
  99. ; need to write it out to 'WORK-LBR.$$$'.
  100. ;
  101.     LD DE,0                ; Get number of records to write out
  102. L146A    EQU $-2
  103.     LD HL,(DIRLEN)            ; Length of library directory in bytes
  104.     LD B,H                ; Offset from start of buffer to BC
  105.     LD C,L
  106.     LD HL,0                ; Get output random record position
  107. L1472    EQU $-2
  108.     PUSH HL                ; Save it
  109.     ADD HL,DE            ; Produce next random record positionè    LD (L1472),HL            ; Save updated random record position
  110.     POP HL                ; Get back current random record
  111.     LD A,(CFUSER)            ; Get current file user number
  112.     CALL SUSRIR            ; Set user if not already there
  113.     LD A,1                ; Set seek switch
  114.     CALL WRDECF            ; Write DE records to the library
  115.     JP Z,J1495            ; Jump if any errors
  116.     LD HL,(DIRLEN)            ; Length of library directory in bytes
  117.     LD (FDBFOF),HL            ; Offset to first file in buffer
  118.     CALL J1549            ; Clear records to write
  119.     LD A,(SEEKF)       Added    ; Set if an initial seek required
  120.     OR A               Added
  121.     JP Z,J1438         Added    ; Jump if no initial seek required
  122.     CALL GMBINF       Added    ; Get current member parameters
  123.     PUSH HL            Added
  124.     LD HL,(FDBFOF)       Added    ; New buffer offset to BC
  125.     LD B,H             Added
  126.     LD C,L             Added
  127.     POP HL             Added
  128. ;       SUB A              Removed
  129.     JP J1438            ; Read the file with initial seek
  130.  
  131.  
  132.                      -----------------------------
  133.  
  134.  
  135. Thσá othe≥á probleφá - tha⌠á oµá overcominτá thσá BDO╙á erro≥á i≤áá morσ ì
  136. complicated«á Thσá simples⌠á wa∙á woulΣ bσ t∩ fi° thσ BDO╙á anΣá ╔á havσ ì
  137. includeΣ ß patcΦ t∩ thσ Digita∞ ResearcΦ BDO╙ fo≥ thosσ wh∩ wisΦ t∩ makσ ì
  138. thσ change« Therσ arσ danger≤ inheren⌠ witΦ fixinτ thσ BDO╙ however¼ anΣ ì
  139. ╔ woulΣ strongl∙ recommenΣ leavinτ thing≤ thσ wa∙ the∙ are«á M∙ argumen⌠ ì
  140. for leaving things is as follows:
  141.  
  142. Thσá CP/═ 2.▓ BDO╙ i≤ ß stablσ produc⌠ anΣ caε bσ guaranteeΣ t∩á perforφ ì
  143. iε exactl∙ thσ samσ wa∙ fo≥ ever∙ user«á Knowinτ it≤ limitations¼á i⌠ i≤ ì
  144. possiblσ t∩ overcomσ thσ problem≤ causeΣ b∙ thσ bug(s)«á Iµ al∞ user≤ oµ ì
  145. NUL╒ werσ t∩ patcΦ thei≥ BDOSes¼á the∙ ma∙ onσ da∙ comσ acros≤ ß prograφ ì
  146. whicΦá work≤á BECAUS┼á oµá thσ buτ anΣ hencσ woulΣá no⌠á worδá oεá thei≥ ì
  147. systems«á Similarly¼á an∙ softwarσ developeΣ oε ß 'fixedº BDO╙ canno⌠ bσ ì
  148. guaranteeΣ t∩ worδ oε aε unfixeΣ BDOS«á However¼ ╔ includσ thσ patcΦ anΣ ì
  149. leave it up the users to decide. Freedom of choice is everyones right.
  150.  
  151. Thσá BDO╙ buτ althougΦ relateΣ t∩ functioε 3╖ i≤ not¼á iε fact¼á iε tha⌠ ì
  152. functioεá bu⌠ iε thσ Selec⌠ Disδ functioε (functioε 14)«á Problem≤á wil∞ ì
  153. only be caused under the following circumstances:
  154.  
  155. 1. The default drive has been reset, AND
  156.  
  157. 2. Data has been written to the default drive since the disk reset, AND
  158.  
  159. 3. Some sort of disk activity is requested on a different drive.
  160.  
  161. Thσá BDO╙á keep≤á ß 1╢ bi⌠ variablσ (thσ login vector⌐ whicΦá show≤á thσ ì
  162. login statσ fo≥ eacΦ oµ drive≤ A-P«á Iε thσ vector¼á eacΦ bi⌠ represent≤ ì
  163. onσ drivσ anΣ i≤ se⌠ iµ thσ drivσ i≤ loggeΣ in«á A≤ record≤ arσá writteε ìèt∩ disk¼á thσ allocatioε vecto≥ iε thσ BIO╙ i≤ useΣ t∩ maintaiε ß recorΣ ì
  164. oµá thosσá disδ block≤ allocateΣ t∩ thσ file«á Thσ allocatioε vecto≥á i≤ ì
  165. updateΣá a≤ block≤ arσ writteε t∩ disδ bu⌠ i≤ initiall∙ se⌠ u≡ froφá thσ ì
  166. disδá director∙á wheε thσ drivσ i≤ firs⌠ loggeΣá in«á BDO╙á functioεá 3╖ ì
  167. simpl∙á reset≤á thσ appropriatσ bit(s⌐ iε thσ login vecto≥ whicΦá shoulΣ ì
  168. cause the drive to be relogged on the next access.
  169.  
  170. Unfortunately¼á Digita∞á ResearcΦá maintaiεá aεá interna∞á variablσá fo≥ ì
  171. holdinτá thσ las⌠ drivσ accesseΣ anΣ checδ i⌠ beforσ logginτ iε ßá disk« ì
  172. Iµá thσ requesteΣ drivσ i≤ thσ samσ a≤ thσ last¼á theε thσ BDO╙á assume≤ ì
  173. tha⌠á i⌠á i≤ alread∙ loggeΣ iε anΣ i⌠ doesn'⌠ checδ thσ logiε vecto≥á a⌠ ì
  174. all«á Iµá wσ havσ rese⌠ thσ defaul⌠ drive¼á thσ interna∞á variablσá wil∞ ì
  175. stil∞á sa∙ tha⌠ i≤ i≤ loggeΣ in¼á eveε thougΦ thσ logiε vecto≥ bi⌠á wil∞ ì
  176. havσá beeεá reset«á Disδ write≤ ma∙ stil∞ bσ madσ t∩ thi≤ drivσ anΣá thσ ì
  177. allocatioε vecto≥ wil∞ stil∞ bσ updated«
  178.  
  179. Iµ wσ werσ no≈ t∩ temporaril∙ switcΦ drive≤ t∩ d∩ ß read¼á fo≥á example« ì
  180. Thσá interna∞á variablσá wil∞ reflec⌠ thi≤ anΣ NEX╘ timσ wσá acces≤á thσ ì
  181. defaul⌠ drive¼á thσ BDOS'≤ checδ wil∞ no≈ sa∙ "Ah¼á ß differen⌠ drivσá - ì
  182. checδ thσ logiε vector"«á Wheε thi≤ happens¼ oµ course¼ i⌠ wil∞ finΣ thσ ì
  183. bi⌠á fo≥á thi≤á drivσ i≤ rese⌠ anΣ wil∞ re-reaΣ thσá disδá director∙á t∩ ì
  184. updatσ thσ allocatioε vector.
  185.  
  186. Thσá disδá director∙ i≤ onl∙ updateΣ wheε eithe≥ aε exten⌠á boundar∙á i≤ ì
  187. passeΣ (ever∙ 16k⌐ o≥ wheε thσ filσ i≤ closed«á Consequently¼á unles≤ wσ ì
  188. arσ lucky¼á thσ disδ director∙ wil∞ no⌠ sho≈ thσ las⌠ fe≈ disδ write≤ wσ ì
  189. havσá madσ anΣ thosσ bit≤ wil∞ bσ rese⌠ iε thσ allocatioεá vector«á Thi≤ ì
  190. mean≤á tha⌠ a≤ fa≥ a≤ thσ BDO╙ i≤ concerned¼á thosσ block≤ arσ freσá fo≥ ì
  191. usσá anΣá i⌠ wil∞ usσ theφ agaiε - eveε iµ i⌠ mean≤ allocatinτ thσá samσ ì
  192. block(s) twice to the same file.
  193.  
  194. Iε contex⌠ oµ NULU¼á assumσ tha⌠ ß library¼ residen⌠ oε drivσ A¼ i≤ opeε ì
  195. anΣá tha⌠á wσá arσ currentl∙ loggeΣ int∩ drivσ ┬ (ie║á drivσá ┬á i≤á thσ ì
  196. defaul⌠á drive)«á Assumσá tha⌠ wσ wisΦ t∩ extrac⌠ ß 100δ membe≥ filσá t∩ ì
  197. drivσá B«á NUL╒á create≤ ß buffe≥ wheε thσ librar∙ i≤ openeΣá anΣá ßá 2δ ì
  198. buffe≥ fo≥ thσ filσ t∩ bσ extracted«á Thσ buffe≥ fo≥ thσ librar∙ wil∞ bσ ì
  199. ßá largσ percentagσ oµ thσ remaininτ TP┴ sizσ bu⌠ sufficσ t∩ sa∙ tha⌠ i⌠ ì
  200. wil∞á bσ smalle≥ thaε ou≥ membe≥ file«á Wσ theε fil∞ thσ librar∙á buffe≥ ì
  201. witΦá thσá firs⌠ par⌠ oµ thσ membe≥ filσ anΣ rese⌠ drivσ ┬ iεá casσá thσ ì
  202. disδá ha≤á beeε changeΣ - conditioε ▒ i≤ theε satisfied«á Wσá no≈á star⌠ ì
  203. writinτá ou⌠ thσ membe≥ filσ (conditioε 2⌐ unti∞ thσ librar∙á buffe≥á i≤ ì
  204. exhausted«á Wσá theεá neeΣá t∩ reaΣ morσ oµ thσ librar∙ froφ drivσá ┴á - ì
  205. condition 3.
  206.  
  207. Thσápossibles answe≥s to this problem are:
  208.  
  209. 1«á T∩á eithe≥ makσ al∞ disδ write≤ iε multiple≤ oµ 16δ (no⌠ necessaril∙ ì
  210.     convenient), OR
  211.  
  212. 2«á T∩á notσ  wheε thσ defaul⌠ drivσ ha≤ beeε rese⌠ anΣ als∩ iµá i⌠á ha≤ ì
  213. beeεá writteεá t∩ sincσ thσ reset«á Iµ an∙ BDO╙ cal∞ i≤ theε madσá whicΦ ì
  214. wil∞á causσá disδá activit∙á oε anothe≥ drivσá (drivσá ┴á iεá thσá abovσ ì
  215. example)¼ al∞ file≤ oε thσ defaul⌠ drivσ shoulΣ bσ closeΣ (t∩ updatσ thσ ì
  216. disδá directory⌐á anΣá theε reopened«á Fortunately¼á Martiε ha≤á ßá nicσ ì
  217. routinσ t∩ d∩ this.è
  218. Thi≤ seconΣ examplσ i≤ mess∙ bu⌠ wil∞ worδ witΦ al∞ permutation≤ oµ disδ ì
  219. reads and writes and was chosen by me for use within NULU.
  220.  
  221. Thσá fi° fo≥ thi≤ probleφ involve≤ thσ origina∞ routinσ (addres≤á 2B46H⌐ ì
  222. iε NUL╒ whicΦ update≤ ß disδ prio≥ t∩ ß possiblσ changσ b∙ closinτá theε ì
  223. reopeninτ al∞ oµ thσ file≤ oε thσ affecteΣ drive«á Thσ firs⌠ thinτ t∩ d∩ ì
  224. i≤ t∩ removσ thσ fina∞ jum≡ t∩ thσ 'rese⌠ driveº routinσ (addres≤ 32B9H⌐ ì
  225. anΣ changσ al∞ call≤ t∩ 2B46╚ t∩ adΣ ß cal∞ t∩ thσ 'rese⌠ driveº routinσ ì
  226. afterwards« ie:
  227.  
  228.         CAL╠áDSKUP─á                    ╗ Updatσ thσ disδ prio≥ t∩á ß change
  229.         CALL RESDSK                     ; Reset the drive
  230.  
  231. Oε anothe≥ subjec⌠ altogether¼á thσ addition≤ oµ codσ t∩ savσ anΣ resorσ ì
  232. thσ S▓ bytσ arσ t∩ d∩ witΦ file≤ large≥ thaε 512k« I⌠ ma∙ bσ oµ interes⌠ ì
  233. t∩á notσ tha⌠ Digita∞ ResearcΦ 'forgotº t∩ documen⌠ tha⌠ thσ S▓ bytσá i≤ ì
  234. aε overflo≈ exten⌠ byte«á Anyonσ wh∩ ha≤ trieΣ t∩ edi⌠ ß tex⌠ filσ unde≥ ì
  235. Wordsta≥á wil∞á probabl∙ havσ founΣ tha⌠ i⌠ goe≤ banana≤ wheεá thσá filσ ì
  236. sizσá exceed≤á 512k«á Wordsta≥ i≤ no⌠ alonσ iε this¼á therσ arσá severa∞ ì
  237. othe≥á commercia∞á anΣ P─ program≤ tha⌠ suffe≥ badl∙ wheεá dealinτá witΦ ì
  238. files greater than 512k.
  239.  
  240. Digita∞á ResearcΦá sa∙ tha⌠ CP/═ 2.▓ caε handlσ file≤ oµ u≡ t∩á 8MΓá anΣ ì
  241. CP/═á Plu≤ caε handlσ file≤ u≡ t∩ 32Mb«á The∙ als∩ sa∙ tha⌠á thσá exten⌠ ì
  242. bytσá (unde≥ 2.▓ anΣ Plus⌐ caε var∙ betweeε ░ anΣ 3▒ iε usσ - unde≥ CP/═ ì
  243. 1.┤á thi≤ wa≤ ░ t∩ 15«á No≈ 3▓ time≤ 16δ i≤ nowherσ nea≥ 8MΓá le⌠á alonσ ì
  244. 32Mb¼á iε fac⌠ i⌠ come≤ t∩ tha⌠ magiπ figurσ oµ 512δ - thi≤ i≤ wherσ thσ ì
  245. S▓á bytσá come≤ in«á Thσ S▓ bytσ count≤ thσ multiple≤ oµ 512δ useΣ iεá ß ì
  246. filσá anΣ ma∙ rangσ froφ ░ t∩ 1╡ unde≥ CP/═ 2.▓ (bit≤ 0-3⌐ anΣ ░á t∩á 6│ ì
  247. unde≥ CP/═ Plu≤ (bit≤ 0-6)«á Bi⌠ ╖ oµ thσ S▓ bytσ i≤ useΣ b∙ thσ BDO╙ a≤ ì
  248. aε interna∞ 'archiveº bit«á Wheε ß filσ i≤ opened¼ aε examinatioε oµ thσ ì
  249. S▓ bytσ wil∞ sho≈ ß valuσ oµ 80H«á Iµ an∙ writσ i≤ performeΣ t∩ thσ filσ ì
  250. iε question¼á thi≤ bi⌠ wil∞ bσ cleared«á Wheε thσ closσ filσ functioε i≤ ì
  251. called¼á iµá thσ bi⌠ i≤ se⌠ theε n∩ actioε i≤ required«á Iµ i⌠ i≤ clear¼ ì
  252. thσá disδá director∙ i≤ updated«á No≈ yo⌡ seσ thσ reasoε fo≥á thσá addeΣ ì
  253. code.
  254.  
  255. Example≤á oµ thσ change≤ madσ follow«á Again¼á thσ label≤ useΣ arσ mine« ì
  256. Thσá addresse≤á giveε arσ thσ thosσ froφ thσá origina∞á unmodifieΣá NUL╒ ì
  257. versioε 1.5.
  258.  
  259. ;
  260. ; This routine prepares for a disk change
  261. ; by making sure that all file activity
  262. ; up to now is accurately recorded on disk.
  263. ; This achieved by closing the files and
  264. ; reopening them. Original address is 2B46H.
  265. ;
  266. DSKUPD:    CALL SAVALL
  267.     CALL GETUSR            ; Get current user number
  268.     PUSH AF
  269.     LD A,(FTBIDX)            ; Current file table index
  270.     PUSH AF
  271.     LD A,(DE)            ; Get drive to be resetè    LD (L2B76),A
  272.     SUB A           Added        ; Clear flags to prevent infinite loop
  273.     LD (RESFLG),A       Added    ; Clear default drive reset flag
  274.     LD (WRTFLG),A       Added    ; Clear default drive written flag
  275.  
  276. ;
  277. ; Go through file table flushing
  278. ; the file buffers by closing the
  279. ; files (on the affected drive) and
  280. ; reopening them.
  281. ;
  282.     LD C,0                ; Start with the first file
  283. J2B57:    INC C
  284.     LD A,(MAXFIL)            ; Max no of files that may be open
  285.     CP C                ; All files flushed
  286.     JP NC,J2B6A            ; Continue if not
  287.     POP AF                ; Restore file table index
  288.     CALL SNEWCF            ; Select new current file
  289.     POP AF                ; Restore current user
  290. ;       CALL SUSRIR        Removed
  291. ;       JP RESDSK          Removed
  292.     JP SUSRIR            ; Set user if not already there
  293.  
  294. J2B6A:    LD A,C                ; Get file table index
  295.     CALL SNEWCF            ; Select new current file
  296.     JP Z,J2B57            ; Jump if no file entry for this index
  297.     LD HL,(FFCBPT)            ; Point to the current file FCB
  298.     LD A,(HL)            ; Get drive
  299.     CP 0                ; Same drive?
  300. L2B76    EQU $-1
  301.     JP NZ,J2B57            ; Jump if not
  302.     EX DE,HL
  303.     LD HL,12            ; Point to extent
  304.     ADD HL,DE
  305.     LD A,(HL)            ; Get extent
  306.     PUSH AF
  307.     PUSH HL
  308.     INC HL                ; Point to the S2 byte
  309.     INC HL
  310.     LD A,(HL)       Added    ; Get the S2 byte
  311.     PUSH AF            Added
  312.     PUSH HL            Added
  313.     INC HL                          ; Point to the record count
  314.     LD A,(HL)            ; Get record count
  315.     PUSH AF
  316.     PUSH HL
  317.     CALL CLOSEF            ; Close the file (forces disk update)
  318.     CALL OPENF            ; ...and reopen it
  319.     POP HL
  320.     POP AF
  321.     LD (HL),A            ; Renew record count
  322.     POP HL             Added
  323.     POP AF             Added
  324.     OR 80H           Added    ; Flag no file update (yet!)
  325.     LD (HL),A       Added    ; Renew the S2 byteè    POP HL
  326.     POP AF
  327.     LD (HL),A            ; Renew extent
  328.     JP J2B57
  329.  
  330.  
  331. Next¼ adΣ codσ t∩ thσ 'writσ B├ record≤ t∩ fileº routinσ (addres≤ 2CB8H⌐ ì
  332. whicΦá check≤á thσ firs⌠ bytσ oµ thσ FC┬ agains⌠ thσ defaul⌠á drivσá anΣ ì
  333. set≤ ß flaτ iµ i⌠ i≤ thσ same«á Oncσ thi≤ flaτ ha≤ beeε set¼á thi≤ checδ ì
  334. neeΣ no⌠ bσ repeated«
  335.  
  336. ;
  337. ; Write BC records to disk
  338. ; DMA address is passed in HL
  339. ; Original address 2CB8H
  340. ;
  341. WRFILE:    CALL SETDMA            ; Set initial DMA address
  342.     LD HL,WRTFLG       Added    ; Point at the default drive write flag
  343.     LD A,(HL)          Added
  344.     OR A               Added
  345.     JP NZ,WRF1       Added    ; Skip if flag already set
  346.     CALL GETDSK       Added    ; Get default drive
  347.     EX DE,HL       Added    ; FCB address to HL
  348.     CP (HL)           Added    ; Compare with wanted drive
  349.     EX DE,HL           Added
  350.     JP NZ,WRF1       Added    ; Jump if not writing to default drive
  351.     LD (HL),A       Added    ; Set the flag accordingly
  352. WRF1:    LD HL,0        Label Added    ; Initialise count of records written
  353.     CALL RSUBEX            ; Set up multiple calls to WRSEQ etc.
  354.  
  355.     DEFW RTRUE            ; Return true status when done
  356. ;
  357. ; The following code is executed BC times
  358. ;
  359.     CALL WRSEQ            ; Write one record to disk
  360.     JP Z,INC6SP            ; Throw away stack if any errors
  361.     INC HL                ; Bump number if records written
  362.     PUSH HL
  363.     CALL UPDDMA            ; Add 128 to current DMA address
  364.     POP HL
  365.     RET
  366.  
  367.  
  368. AdΣ codσ int∩ thσ 'rese⌠ driveº routinσ whicΦ set≤ ß flaτ iµ thσ defaul⌠ ì
  369. drivσá i≤ reset«á ╔ diΣ thi≤ b∙ placinτ thσ defaul⌠ drivσ numbe≥ iεá thσ ì
  370. flag¼á iµ required¼á otherwisσ leavinτ i⌠ clear«
  371.  
  372. ;
  373. ; Reset indicated drive
  374. ; Original address 32B9H
  375. ;
  376. RESDSK:    CALL SAVALL
  377.     CALL GETUSR
  378.     PUSH AF                ; Save current user
  379.     CALL GETDSK       Added    ; Get the current driveè    EX DE,HL           Added
  380.     CP (HL)           Added    ; Resetting default drive?
  381.     EX DE,HL           Added
  382.     JP NZ,RSD1       Added    ; Jump if not
  383.     LD (RESFLG),A       Added    ; Set flag if default drive is reset
  384. RSD1:    LD A,(DE)    Label added    ; Get drive to be reset
  385.     LD DE,L0001            ; Assume drive A initially
  386.     DEC A                ; Make range 0-15 for drives A-P
  387.     CALL NZ,SLDEXA            ; Convert drive code to bit position
  388.     LD C,25H
  389.     CALL GOCPM            ; Reset the drive
  390.     SUB A              Added
  391.     LD (WRTFLG),A       Added    ; Reset written since reset flag
  392.     POP AF                ; Restore current user
  393.     JP SETUSR
  394.  
  395.  
  396. Al∞á routine≤á whicΦá arσ likel∙ t∩ causσ disδ activit∙ shoulΣá theεá bσ ì
  397. redirecteΣ froφ thei≥ existinτ cal∞ t∩ CP/═ t∩ ß ne≈ routinσ whicΦá wil∞ ì
  398. checδ thσ flag≤ anΣ ac⌠ accordingly« Thσ entr∙ poin⌠ fo≥ norma∞ routine≤ ì
  399. tha⌠á pas≤á ß FC┬ addres≤ iε D┼ i≤ t∩ BUGCH╦ whilσá thσá SELDS╦á routinσ ì
  400. whicΦá passe≤á ß drivσ codσ iε ┼ call≤ BUGTST«á Example≤ oµ routine≤á t∩ ì
  401. patcΦ arσ 'Opeε file'¼á 'Closσ file'¼á 'ReaΣ Sequential/Random'¼á 'Writσ ì
  402. Sequential/Random/Randoφá witΦ Zer∩á Fill'¼á 'Se⌠á attributes'¼á 'SearcΦ ì
  403. First/Next'¼á 'Renamσá file'¼á 'Deletσá file'¼á 'Makσ fileº anΣá 'Selec⌠ ì
  404. disk'.
  405.  
  406. ;
  407. ; Select disk for use
  408. ; Original address 32D1H
  409. ;
  410. SELDSK:    CALL SAVXAF
  411.     LD E,A
  412.     LD A,(MAXDSK)            ; Maximum permitted drive number
  413.     CP E
  414.     LD A,14                ; Error 14: Bad drive
  415.     JP C,RFALSE
  416.     DEC E
  417.     LD C,0EH
  418. ;       CALL GOCPM         Removed
  419.     CALL BUGTST       Added    ; Call BDOS via the bug check routine
  420.     INC A
  421.     LD C,14                ; Error 14: Bad drive
  422.     JP Z,CPMERR            ; Handle the returned BDOS error code
  423.     RET
  424.  
  425. ;
  426. ; This routine has no equivalent in NULU 1.5
  427. ;
  428. ; This routine overcomes the problems
  429. ; introduced by the bug in BDOS function
  430. ; 14. It does this by closing and reopening
  431. ; all files on the default drive IF the drive
  432. ; has been reset via function 37 AND the drive
  433. ; has been written to since it was reset ANDè; this BDOS access is for a different drive.
  434. ;
  435. BUGCHK:    LD A,(CPMVER)            ; Get CP/M version number
  436.     CP 30H                ; Test whether CP/M Plus
  437.     JP NC,GOCPM            ; CP/M Plus doesn't have the bug
  438.     CALL GETDSK            ; Return current disk
  439.     EX DE,HL            ; Point to the wanted drive
  440.     CP (HL)                ; Same drive?
  441.     EX DE,HL
  442.     JP Z,GOCPM            ; No action if same drive
  443. BCHK:    LD A,(RESFLG)            ; Set if default drive was reset
  444.     OR A
  445.     JP Z,GOCPM            ; No action if not
  446.     LD A,(WRTFLG)            ; Set if default drive has been written
  447.                     ;  to since the reset
  448.     OR A
  449.     JP Z,GOCPM            ; No action if not
  450.     PUSH DE                ; Save FCB address
  451.     LD DE,RESFLG            ; Point to the drive to be updated
  452.     CALL DSKUPD            ; Ensure disk directory is up to date
  453.     POP DE                ; Restore FCB address
  454.     JP GOCPM            ; Process the BDOS call normally
  455.  
  456. ;
  457. ; This entry point is for the select
  458. ; disk function since its parameters
  459. ; are not passed in an FCB.
  460. ;
  461. BUGTST:    LD A,(CPMVER)            ; Get CP/M version number
  462.     CP 30H                ; Is it CP/M Plus
  463.     JP NC,GOCPM            ; No action if so (bug not in CP/M+)
  464.     CALL GETDSK
  465.     DEC A
  466.     CP E                ; Same drive?
  467.     JP Z,GOCPM            ; No action if same drive
  468.     JP BCHK
  469.  
  470.  
  471. Therσ shoulΣ bσ enougΦ informatioε herσ t∩ allo≈ Martiε t∩ recreatσ wha⌠ ì
  472. ╔ havσ donσ (iµ hσ wishes)«á Fo≥ thosσ user≤ wh∩ wisΦ t∩ patcΦ thei≥ DR╔ ì
  473. BDO╙á t∩ removσ thσ bug¼á proceeΣ a≤ follow≤ bu⌠ bσ warneΣ tha⌠ yo⌡á ma∙ ì
  474. stop software from running.
  475.  
  476. The DRI BDOS fix
  477. ----------------
  478.  
  479. Zer∩á ou⌠ thσ followinτ location≤ iε thσ DR╔ BDOS¼á notσ tha⌠á thσá BDO╙ ì
  480. start≤á ╢á byte≤ beforσ thσ addres≤ a⌠ locatioε 0006╚ anΣ tha⌠á ZSID/DD╘ ì
  481. etc«á wil∞ no⌠ givσ thσ truσ address« Usσ somethinτ likσ Z3LO├ o≥ STATU╙ ì
  482. t∩á determinσ you≥ BDO╙ address«á Thσ byte≤ a⌠ thosσ location≤ anΣá wha⌠ ì
  483. they do are given so that you can patch away with confidence.
  484.  
  485. Location to patch       Byte at that location (Hex)
  486.                      (xx = depends upon BDOS address)
  487. èBDO╙á½ 0C45╚                    3┴         LD┴ xxD6╚á    ╗áGe⌠áwanteΣ drive
  488. BDOS + 0C46H                    D6
  489. BDOS + 0C47H                    xx
  490. BDO╙á½á0C48╚                    2▒         LX╔ H,xx42╚á  ╗áGe⌠álas⌠ drive
  491. BDOS + 0C49H                    42
  492. BDOS + 0C4AH                    xx
  493. BDOS + 0C4BH                    BE         CMP M         ; Same drive?
  494. BDO╙ ½ 0C4C╚                    C╕         R┌            ╗áReturε iµ i⌠ is
  495.  
  496.  
  497. Thi≤ patcΦ prevent≤ thσ BDO╙ froφ usinτ it≤ interna∞ saveΣ recorΣ oµ thσ ì
  498. las⌠á drivσá accesseΣá anΣ force≤ i⌠ t∩ checδ thσ logiε vecto≥á bit≤á t∩ ì
  499. determine whether or not to relog a drive.
  500.  
  501. The patch above works but on your own head be it!
  502.  
  503.