home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / sampler0 / freecopy.asm < prev    next >
Assembly Source File  |  1985-06-06  |  94KB  |  2,855 lines

  1. Page    55,132
  2. Title    FREECOPY Version 1.13 (C)Copyright 1984
  3. ;***********************  F R E E C O P Y  ******************************
  4. ;*                                    *
  5. ;*    Program: FREECOPY                        *
  6. ;*                                    *
  7. ;*    Author: Donald L. Buresh, C.D.P.                *
  8. ;*        Squire Buresh Associates, Inc.                *
  9. ;*        Post Office Box 112                    *
  10. ;*        Millbury, MA  01527                    *
  11. ;*        (617) 865-3435                        *
  12. ;*                                    *
  13. ;*    !!!!!!!!!!!!!!!!!!!!!!   N O T I C E   !!!!!!!!!!!!!!!!!!!!!!     *
  14. ;*                                    *
  15. ;*    A limited license is granted to all users of this program to    *
  16. ;*    make copies of this source code and to distribute them to    *
  17. ;*    other users under the following conditions:            *
  18. ;*                                    *
  19. ;*    1. The notice contained in the variable MES00_Copy_Notice    *
  20. ;*       is not to be altered, bypassed or removed.            *
  21. ;*                                    *
  22. ;*    2. The program is not to be distributed to others in        *
  23. ;*       modified form.                        *
  24. ;*                                    *
  25. ;*    3. If you think that this program has helped you, we request    *
  26. ;*       a $25.00 contribution.                    *
  27. ;*                                    *
  28. ;*    4. No other fee is to be charged or any consideration received    *
  29. ;*       for copying or distributing the program without the        *
  30. ;*       expressed written permission of Squire Buresh Assoc, Inc.    *
  31. ;*                                    *
  32. ;*                                    *
  33. ;*  (C) Copyright  1984        Squire Buresh Associates, Inc.        *
  34. ;*                                    *
  35. ;************************************************************************
  36. Page
  37. ;************************************************************************
  38. ;*                                    *
  39. ;*    REVISION HISTORY                        *
  40. ;*                                    *
  41. ;*    Version                                *
  42. ;*    Number    Date        Comments                *
  43. ;*                                    *
  44. ;*    1.00    16-SEP-84    This is the first version of FREECOPY    *
  45. ;*                                    *
  46. ;*    1.01    13-OCT-84    Corrected a problem when copying    *
  47. ;*                diskettes on 512K systems. Reversed    *
  48. ;*                the order of testing the ES:BX table    *
  49. ;*                counter and the read/write track    *
  50. ;*                counter. Fix was near C2005, C2006,    *
  51. ;*                C2105 and C2106.            *
  52. ;*                                    *
  53. ;*    1.02    13-OCT-84    Flushed the standard input keyboard    *
  54. ;*                buffer before accepting a character.    *
  55. ;*                Fix was near U1101 and U1102.        *
  56. ;*                                    *
  57. ;*    1.03    21-OCT-84    Added parsing a tab character on the    *
  58. ;*                command line.  Fix was below C1215.    *
  59. ;*                                    *
  60. ;*    1.04 - 1.09        These versions never really existed in    *
  61. ;*                any decent form.  They are incorporated    *
  62. ;*                into fixing the memory allocation    *
  63. ;*                problems stemming from the original    *
  64. ;*                version of FREECOPY.            *
  65. ;*                                    *
  66. ;*    1.10    02-FEB-85    Allocated and freed memory when running    *
  67. ;*                FREECOPY under PC-DOS versions 2.00    *
  68. ;*                and greater.  The fix involved finding    *
  69. ;*                out the version of the operating system,*
  70. ;*                allocating the memory, establishing    *
  71. ;*                the ES:BX table entries and freeing    *
  72. ;*                memory before returning control to    *
  73. ;*                PC-DOS.                    *
  74. ;*                                    *
  75. ;*    1.11    06-JUN-85    Modified the sequence of turning inter- *
  76. ;*                rupts on and off in the S1000 and S1100 *
  77. ;*                modules.                *
  78. ;*                                    *
  79. ;*    1.12    06-JUN-85    Allowed users to write more than one    *
  80. ;*                target diskette, by setting FLG17 to    *
  81. ;*                True and jumping to B1105A after ini-    *
  82. ;*                tializing the appropriate variables.    *
  83. ;*                                    *
  84. ;*    1.13    07-JUN-85    Fixed a stack imbalance that appeared    *
  85. ;*                only when running PC-DOS 3.00 on a PC    *
  86. ;*                rather than on an XT or AT        *
  87. ;*                                    *
  88. ;************************************************************************
  89. Page
  90. ;************************************************************************
  91. ;*                                    *
  92. ;*    EQUATES                                *
  93. ;*                                    *
  94. ;*    The constants defined below are used to to specify:        *
  95. ;*                                    *
  96. ;*            o Disk commands,                *
  97. ;*                                    *
  98. ;*            o Keyboard commands,                *
  99. ;*                                    *
  100. ;*            o Video commands                *
  101. ;*                                    *
  102. ;*            o Miscellaneous parameters,            *
  103. ;*                                    *
  104. ;*            o Various ASCII characters.            *
  105. ;*                                    *
  106. ;************************************************************************
  107. ;
  108. Disk_Parameter_Addr    Equ    001EH*4    ; Address of Disk Parameter Table
  109. ;
  110. Reset_Command        Equ    0000D    ; Diskette reset command
  111. Status_Command        Equ    0001D    ; Diskette status command
  112. Read_Command        Equ    0002D    ; Diskette read command
  113. Write_Command        Equ    0003D    ; Diskette write command
  114. Verify_Command        Equ    0004D    ; Diskette verify command
  115. Format_Command         Equ    0005D    ; Diskette format command
  116. ;
  117. Time_Out_Error        Equ    0080H    ; Diskette error codes
  118. Seek_Error        Equ    0040H    ; .
  119. Controller_Error    Equ    0020H    ; .
  120. CRC_Error        Equ    0010H    ; .
  121. DMA_Boundary_Error    Equ    0009H    ; .
  122. DMA_Error        Equ    0008H    ; .
  123. Sector_Error        Equ    0004H    ; .
  124. Write_Protect_Error    Equ    0003H    ; .
  125. Address_Mark_Error    Equ    0002H    ; .
  126. Command_Error        Equ    0001H    ; ..End
  127. ;
  128. Video_Address        Equ    0A000H    ; Starting segment addr of Video RAM
  129. ;
  130. Set_Mode_Command    Equ    0000D    ; Set the video mode
  131. Set_CType_Command    Equ    0001D    ; Set the cursor type
  132. Set_CPos_Command    Equ    0002D    ; Set the cursor position
  133. Read_Cursor_Command    Equ    0003D    ; Get cursor position and attributes
  134. Read_LPen_Command    Equ    0004D    ; Get the light pen position
  135. Set_ADPage_Command    Equ    0005D    ; Set the active display page
  136. Scroll_Up_Command    Equ    0006D    ; Scrool up or blank a portion of
  137.                     ; . the video display
  138. ;
  139. Page
  140. ;************************************************************************
  141. ;*                                    *
  142. ;*    EQUATES        Page 2                        *
  143. ;*                                    *
  144. ;************************************************************************
  145. ;
  146. Scroll_Down_Command    Equ    0007D    ; Scroll down or blank a portion
  147.                     ; . of the video display
  148. Read_AChar_Command    Equ    0008D    ; Read the attribute and character
  149. Write_AChar_command    Equ    0009D    ; Write the attribute and character
  150. Write_Char_Command    Equ    0010D    ; Write the character only
  151. Set_Color_Command    Equ    0011D    ; Set the color pallette
  152. Write_Dot_Command    Equ    0012D    ; Write a pixel to a graphics screen
  153. Read_Dot_Command    Equ    0013D    ; Read a pixel from a graphics screen
  154. Write_TTY_Command    Equ    0014D    ; Write a character with automatic
  155.                     ; . processing for LF, CR, Bell & BS
  156. Video_State_Command    Equ    0015D    ; Get the current video state
  157. ;
  158. Read_Keyboard_Command    Equ    0007D    ; Reads character from the keyboard
  159. Flush_Keyboard_Command    Equ    0012D    ; Clears the standard keyboard buffer
  160. Get_DOS_Version_Number    Equ    0030H    ; Gets the current version of PC-DOS
  161. Allocate_Memory        Equ    0048H    ; Allocate a block of memory
  162. Free_Memory        Equ    0049H    ; Free a block of memory
  163. Modify_Memory_Block    Equ    004AH    ; Modify the size of memory block
  164. ;
  165. Default_Drive_Command    Equ    0025D    ; Get PC DOS default drive number
  166. ;
  167. Video_Interrupt        Equ    0010H    ; Interrupt 10H for video calls
  168. Equipment_Interrupt    Equ    0011H    ; Interrupt 11H for equipment
  169. Disk_Interrupt        Equ    0013H    ; Interrupt 13H for disk calls
  170. PC_DOS_Interrupt    Equ    0021H    ; Interrupt 21H for PC DOS calls
  171. ;
  172. Parallel_Ports_Mask    Equ    0C000H    ; Equipment masks
  173. Game_Adapters_Mask    Equ    00100H    ; .
  174. RS232_Ports_Mask    Equ    00E00H    ; .
  175. Disk_Drives_Mask    Equ    000C0H    ; .
  176. Init_Video_Mask        Equ    00030H    ; .
  177. Planar_RAM_Mask        Equ    0000CH    ; .
  178. IPL_Diskette_Mask    Equ    00001H    ; ..End
  179. ;
  180. Page
  181. ;************************************************************************
  182. ;*                                    *
  183. ;*    EQUATES        Page 3                        *
  184. ;*                                    *
  185. ;************************************************************************
  186. ;
  187. Command_Com_Size    Equ    0410D    ; Size of various tables and programs
  188. CHRN_Table_Size        Equ    0180D    ; in 16 byte paragraphs
  189.                     ; .
  190.                     ; .
  191. ESBX_Table_Size        Equ    0020D    ; .
  192.                     ; .
  193.                     ; .
  194. FAT_Sector_Size        Equ    0032D    ; ..End
  195. ;
  196. DMA_Boundary_Mask    Equ    0FFFH    ; Mask to isolate the high nibble of
  197.                     ; . the ES segment address
  198. ;
  199. Invalid_Drive        Equ    0255D    ; Invalid drive parameter
  200. Maximum_Drives        Equ    0003D    ; Maximum number of floppy drives 
  201. Minimum_Drives        Equ    0000D    ; Minimum number of floppy drives
  202. ;
  203. Sector_Size        Equ    0512D    ; Number of bytes per sector
  204. Paragraph_Size        Equ    0016D    ; Number of bytes per paragraph
  205. Number_of_Retries    Equ    0005D    ; Number of attempts to copy 
  206.                     ; . a track before admitting failure
  207. Final_Track        Equ    0039D    ; The last track on a PC DOS diskette
  208. ;
  209. One_Side_Eight_Sectors    Equ    00FEH    ; First entry in the File Allocation
  210. Two_Sides_Eight_Sectors    Equ    00FFH    ; Table (FAT)
  211. One_Side_Nine_Sectors    Equ    00FCH    ; .
  212. Two_Sides_Nine_Sectors    Equ    00FDH    ; .
  213. Fixed_Disk        Equ    00F8H    ; ..End
  214. ;
  215. Keyboard_Buffer_Size    Equ    0080D    ; Maximum number of characters in
  216.                     ; . the keyboard buffer
  217. ;
  218. Minimum_Memory_Size    Equ    0288D    ; Minimum memory size in 16 byte
  219.                     ; . paragraphs to hold a nine
  220.                     ; . sectored track
  221. ;
  222. Blank_Cursor        Equ    0F0FH    ; Blank cursor value
  223. Underline_Cursor    Equ    0D0DH    ; Underline cursor value
  224. ;
  225. False            Equ    0000D    ; Incorrect processing occured
  226. True            Equ Not False    ; Correct processing occured
  227. High_Values        Equ    0FFFFH    ; High values
  228. ;
  229. Page
  230. ;************************************************************************
  231. ;*                                    *
  232. ;*    EQUATES        Page 4                        *
  233. ;*                                    *
  234. ;************************************************************************
  235. ;
  236. NUL            Equ    0000D    ; Null character
  237. SOH            Equ    0001D    ; SOH character
  238. STX            Equ    0002D    ; STX character
  239. ETX            Equ    0003D    ; Control Break character
  240. Bell            Equ    0007D    ; Bell character
  241. BS            Equ    0008D    ; Backspace character
  242. HT            Equ    0009D    ; Horizontal tab character
  243. LF            Equ    0010D    ; Line feed character
  244. CR            Equ    0013D    ; Carriage return character
  245. Space            Equ    0032D    ; Space or blank character
  246. Slash            Equ    0047D    ; Slash character
  247. Zero_Digit        Equ    0048D    ; Digit Zero
  248. One_Digit        Equ    0049D    ; Digit One
  249. Capital_Letter_A    Equ    0065D    ; Capital letter A
  250. Capital_Letter_N    Equ    0078D    ; Capital letter N
  251. Capital_Letter_Y    Equ    0089D    ; Capital letter Y
  252. Small_Letter_n        Equ    0110D    ; Small letter n
  253. Small_Letter_y        Equ    0121D    ; Small letter y
  254. EOT            Equ    0255D    ; End of text character
  255. ;
  256. Minus_One        Equ      -1D    ; Numbers used in FREECOPY
  257. Zero            Equ    0000D    ; .
  258. One            Equ    0001D    ; .
  259. Two            Equ    0002D    ; .
  260. Three            Equ    0003D    ; .
  261. Four            Equ    0004D    ; .
  262. Six            Equ    0006D    ; .
  263. Eight            Equ    0008D    ; .
  264. Nine            Equ    0009D    ; .
  265. Ten            Equ    0010D    ; .
  266. Eleven            Equ    0011D    ; .
  267. Twelve            Equ    0012D    ; .
  268. Fourteen        Equ    0014D    ;.
  269. Fifteen            Equ    0015D    ; .
  270. Twenty_Four        Equ    0024D    ; .
  271. Twenty_Five        Equ    0025D    ; .
  272. Thirty_Four        Equ    0034D    ; .
  273. Thirty_Six        Equ    0036D    ; .
  274. Thirty_Nine        Equ    0039D    ; .
  275. Seventy_Nine        Equ    0079D    ; ..End
  276. ;
  277. Page
  278. ;************************************************************************
  279. ;*                                    *
  280. ;*    CSEG Segment                            *
  281. ;*                                    *
  282. ;*    This segment contains all of the code of the program.  It is    *
  283. ;*    named CSEG because this name conforms with ASM-86.        *
  284. ;*                                    *
  285. ;************************************************************************
  286. ;
  287. CSEG    Segment Para Public 'CSEG'
  288.     Assume CS:CSEG,DS:CSEG,ES:CSEG,SS:Nothing
  289. ;
  290. Page
  291. ;************************************************************************
  292. ;*                                    *
  293. ;*    PROGRAM SEGMENT PREFIX                        *
  294. ;*                                    *
  295. ;*    The first 256 bytes of every program executed under PC DOS    *
  296. ;*    contains a Program Segment Prefix control block.  The data    *
  297. ;*    stored in this block of memory is used by FREECOPY to process    *
  298. ;*    the parameters when invoking the program.            *
  299. ;*                                    *
  300. ;************************************************************************
  301. ;
  302.     Org    05CH
  303. Source_Drive        Label Byte    ; Source diskette drive number
  304.     Org    05DH
  305. Source_Filename        Label Byte    ; Source diskette filename
  306.     Org    068H
  307. Source_Filler_Area    Label Byte
  308.     Org    06CH
  309. Target_Drive        Label Byte    ; Target diskette drive number
  310.     Org    06DH
  311. Target_Filename        Label Byte    ; Target diskette filename
  312.     Org    078H
  313. Target_Filler_Area    Label Byte
  314.     Org    080H
  315. Parameter_Count        Label Byte    ; Number of parameters
  316.     Org    081H
  317. Parameter_String    Label Byte    ; String entered by the user
  318. ;
  319. Page
  320. ;************************************************************************
  321. ;*                                    *
  322. ;*    A1000_MAIN_MODULE                        *
  323. ;*                                    *
  324. ;*    This is the top level of FREECOPY and it controls the flow of    *
  325. ;*    the program.  The first sequence of commands in the routine    *
  326. ;*    preserve the state of the machine.  Next, there is a set of    *
  327. ;*    three (3) calls to sub-modules that control the initial        *
  328. ;*    processing, detail processing and final processing.  Finally,    *
  329. ;*    FREECOPY restores the state of the machine an returns to     *
  330. ;*    PC DOS via INT 20H.                        *
  331. ;*                                    *
  332. ;************************************************************************
  333. ;
  334.     Org    0100H
  335. ;
  336. Public    A1000_Main_Module
  337. ;
  338. A1000_Main_Module Proc Far
  339. ;
  340. A1001:
  341.     Cli                ; Set up the top of the stack
  342.     Mov    SP,Offset MEM04_Top_of_the_Stack
  343.     Sti                ; ..End
  344.     Push    BP            ; Save the state of the machine
  345.     Push    DS            ; .
  346.     Push    ES            ; .
  347.     Push    SS            ; .
  348.     Push    AX            ; .
  349.     Push    BX            ; .
  350.     Push    CX            ; .
  351.     Push    DX            ; .
  352.     Push    SI            ; .
  353.     Push    DI            ; .
  354.     Pushf                ; ..End
  355. ;
  356.     Cli                ; Save the current stack pointer
  357.     Mov    Word Ptr SYS15_Stack_Pointer,SP
  358.     Add    Word Ptr SYS15_Stack_Pointer,Two            ; .
  359.     Sti                ; ..End
  360. ;
  361.     Call    B1000_Initial_Process    ; Main flow of control
  362.     Cmp    Byte Ptr FLG01_Good_Command,False
  363.     Je    A1002            ; .
  364.     Cmp    Byte Ptr FLG03_Default_Drive,False
  365.     Je    A1002            ; .
  366.     Call    B1100_Detail_Process    ; .
  367. A1002:                    ; .
  368.     Call    B1200_Final_Process    ; ..End
  369. A1090:
  370.     Popf                ; Restore the state of the machine
  371.     Pop    DI            ; .
  372.     Pop    SI            ; .
  373.     Pop    DX            ; .
  374.     Pop    CX            ; .
  375.     Pop    BX            ; .
  376.     Pop    AX            ; .
  377.     Pop    SS            ; .
  378.     Pop    ES            ; .
  379.     Pop    DS            ; .
  380.     Pop    BP            ; ..End
  381. A1099:
  382.     Int    20H            ; Return to PC DOS
  383. ;
  384. A1000_Main_Module Endp
  385. ;
  386. Page
  387. ;************************************************************************
  388. ;*                                    *
  389. ;*    B1000_INITIAL_PROCESS                        *
  390. ;*                                    *
  391. ;*    This module performs the following functions after control    *
  392. ;*    passess to FREECOPY:                        *
  393. ;*                                    *
  394. ;*     1. Sets up the Disk Parameter Table.                *
  395. ;*                                    *
  396. ;*     2. Gets the current PC-DOS version number.            *
  397. ;*                                    *
  398. ;*     3. Initializes various parameters.                *
  399. ;*                                    *
  400. ;*     4. Gets and sets the video mode.                *
  401. ;*                                    *
  402. ;*     5. Displays the intiial message.                *
  403. ;*                                    *
  404. ;*     6. Parses the command line entered by a user.            *
  405. ;*                                    *
  406. ;*     7. Determines the amount of equipment on the machine.        *
  407. ;*                                    *
  408. ;*     8. Validates the number of disk drives on the system.        *
  409. ;*                                    *
  410. ;*     9. Displays the appropriate disk copying message.        *
  411. ;*                                    *
  412. ;*    10. Gets the amount of available memory.            *
  413. ;*                                    *
  414. ;*    11. Calculates the number and position of the entries in the    *
  415. ;*        ES:BX buffer address table.                    *
  416. ;*                                    *
  417. ;************************************************************************
  418. ;
  419. Page
  420. ;
  421. Public    B1000_Initial_Process
  422. ;
  423. B1000_Initial_Process Proc Near
  424. ;
  425. B1001:
  426.     Call    S1000_Setup_Disk_Param_Table
  427.     Call    S1200_Get_Version_Number
  428. ;
  429.     Mov    Byte Ptr FLG01_Good_Command,True
  430.     Mov    Byte Ptr FLG02_Double_Side,True
  431.     Mov    Byte Ptr FLG03_Default_Drive,True
  432.     Mov    Byte Ptr FLG04_Single_Drive,True
  433.     Mov    Byte Ptr FLG07_First_Time,True
  434.     Mov    Byte Ptr FLG16_Free_Memory,True
  435.     Mov    Byte Ptr FLG17_Copy_More_Disks,False
  436. B1002:
  437.     Call    C1000_Get_And_Set_Video    ; Get and set current video state
  438.     Call    C1100_Display_Intro    ; Display the intial screen
  439.     Call    C1200_Parse_Commands    ; Parse the command line entered
  440.                     ; . by the user
  441.     Cmp    Byte Ptr FLG01_Good_Command,False
  442.     Je    B1099            ; If false, go to end of the module
  443.     Call    C1300_Get_Equipment    ; Find out the equipment on the PC
  444.     Call    C1400_Validate_Drives    ; Validate the drive numbers
  445.     Cmp    Byte Ptr FLG03_Default_Drive,False
  446.     Je    B1099            ; If false, go to end of the module
  447.     Call    C1500_Diskette_Messages    ; Display the appropriate messages
  448. ;
  449.     Cmp    Byte Ptr SYS19_Major_Vers_Number,Zero
  450.     Jne    B1003            ; Get available memory in paragraphs
  451.     Call    C1600A_Get_Free_Memory    ; . and create the ES:BX table
  452.     Jmp    B1004            ; .
  453. B1003:                    ; .
  454.     Call    C1600B_Get_Free_Memory    ; .
  455. B1004:                    ; .
  456.     Cmp    Byte Ptr FLG01_Good_Command,False
  457.     Je    B1099            ; .
  458.     Call    C1700_Create_ESBX_Table; ..End
  459. B1099:
  460.     Ret
  461. ;
  462. B1000_Initial_Process Endp
  463. ;
  464. Page
  465. ;************************************************************************
  466. ;*                                    *
  467. ;*    B1100_DETAIL_PROCESS                        *
  468. ;*                                    *
  469. ;*    This module performs the following functions when copying one    *
  470. ;*    or more diskettes:                        *
  471. ;*                                    *
  472. ;*    1. Initializes various parameters.                *
  473. ;*                                    *
  474. ;*    2. Validates the contents of the source diskette.        *
  475. ;*                                    *
  476. ;*    3. Creates all of the entries of the CHRN table used in        *
  477. ;*       formatting the target diskette.                *
  478. ;*                                    *
  479. ;*    4. Reads the tracks of the source diskette.            *
  480. ;*                                    *
  481. ;*    5. If the diskette is being copied on only one drive, the    *
  482. ;*       routines asks the user to enter the target diskette.        *
  483. ;*                                    *
  484. ;*    6. Writes the tracks on the target diskette.            *
  485. ;*                                    *
  486. ;*    7. If FREECOPY is finished copying the source diskette, the    *
  487. ;*       program asks whether to write another target diskette,    *
  488. ;*       provided the source diskette fits completely in memory;    *
  489. ;*       otherwise, the program asks whether to copy a new diskette.    *
  490. ;*       If not, the module returns to A1000_Main_Module.  If so,    *
  491. ;*       control transfers to 1.                    *
  492. ;*                                    *
  493. ;*    8. If FREECOPY is not completed copying the source diskette,    *
  494. ;*       control transfers to 4.                    *
  495. ;*                                    *
  496. ;************************************************************************
  497. ;
  498. Page
  499. ;
  500. Public    B1100_Detail_Process
  501. ;
  502. B1100_Detail_Process Proc Near
  503. ;
  504. B1101:
  505.     Mov    Byte Ptr WRK20_Current_Source_Head,Zero
  506.     Mov    Byte Ptr WRK21_Current_Source_Track,Zero
  507.     Mov    Byte Ptr WRK22_Current_Target_Head,Zero
  508.     Mov    Byte Ptr WRK23_Current_Target_Track,Zero
  509.     Mov    Word Ptr WRK33_CHRN_Table_Address,Offset MEM02_CHRN_Table
  510.     Mov    Byte Ptr FLG13_First_Read_Write,True
  511.     Mov    Byte Ptr FLG14_Copy_Complete,False
  512.     Mov    Byte Ptr FLG15_IO_Error,Three
  513. B1102:
  514.     Call    C1800_Validate_Source_Disk
  515.     Cmp    Byte Ptr FLG08_Good_Read,True
  516.     Je    B1103            ; If it is a valid source, continue
  517.     Mov    SI,Offset MES07_Correct_And_Press_Key
  518.     Call    U1000_Display_Message    ; Display the message on the screen
  519.     Mov    Byte Ptr FLG05_Store_Buffer,False
  520.     Call    U1100_Get_Response    ; Get the user's response
  521.     Jmp    B1101            ; Go back and try again
  522. B1103:
  523.     Call    C1900_Create_CHRN_Table
  524. B1104:
  525.     Call    C2000_Read_Source_Disk
  526.     Cmp    Byte Ptr FLG08_Good_Read,True
  527.     Je    B1105            ; If read disk correctly, continue
  528.     Mov    SI,Offset MES07_Correct_And_Press_Key
  529.     Call    U1000_Display_Message    ; Display the message on the screen
  530.     Mov    Byte Ptr FLG05_Store_Buffer,False
  531.     Call    U1100_Get_Response    ; Get the user's response
  532.     Jmp    B1101            ; Go back and try again
  533. B1105:
  534.     Cmp    Byte Ptr FLG04_Single_Drive,False
  535.     Je    B1106            ; If a single drive copy, continue
  536. B1105A:
  537.     Mov    SI,Offset MES10_Insert_Target
  538.     Mov    AL,Byte Ptr WRK02_Target_Drive
  539.     Add    AL,Capital_Letter_A    ; Put drive letter into AL
  540.     Mov    [SI+Thirty_Four],AL    ; Put the drive letter into the
  541.                     ; . correct position in the message
  542.     Call    U1000_Display_Message    ; Display the message on the screen
  543.     Mov    SI,Offset MES16_Press_Any_Key
  544.     Call    U1000_Display_Message    ; Display the message on the screen
  545.     Mov    Byte Ptr FLG05_Store_Buffer,False
  546.     Call    U1100_Get_Response    ; Get the user's response
  547. B1106:
  548.     Call    C2100_Write_Format_Target_Disk
  549.     Cmp    Byte Ptr FLG09_Good_Write,False
  550.     Je    B1110            ; If bad write, go to bottom of loop
  551.     Cmp    Byte Ptr FLG11_Good_Format,False
  552.     Je    B1110            ; If bad format, go to bottom of loop
  553. B1107:
  554.     Cmp    Byte Ptr FLG14_Copy_Complete,True
  555.     Je    B1109            ; If copy done, go to bottom of loop
  556.     Cmp    Byte Ptr FLG04_Single_Drive,False
  557.     Je    B1108            ; If double drive copy, continue
  558.     Mov    SI,Offset MES09_Insert_Source
  559.     Mov    AL,Byte Ptr WRK01_Source_Drive
  560.     Add    AL,Capital_Letter_A    ; Put the drive letter into AL
  561.     Mov    [SI+Thirty_Four],AL    ; Put the drive letter into the
  562.                     ; . correct position in the message
  563.     Call    U1000_Display_Message    ; Display the message on the screen
  564.     Mov    SI,Offset MES16_Press_Any_Key
  565.     Call    U1000_Display_Message    ; Display the message on the screen
  566.     Mov    Byte Ptr FLG05_Store_Buffer,False
  567.     Call    U1100_Get_Response    ; Get the user's response
  568. B1108:
  569.     Call    C2200_Check_File_Alloc_Table
  570.     Cmp    Byte Ptr FLG12_Good_FAT,False
  571.     Je    B1110            ; If bad FAT, go to bottom of loop
  572.     Mov    Byte Ptr FLG13_First_Read_Write,False
  573.     Jmp    B1104            ; Go back and read some more
  574. B1109:
  575.     Mov    Byte Ptr FLG07_First_Time,False
  576.     Mov    SI,Offset MES02_Copy_Complete
  577.     Call    U1000_Display_Message
  578. B1110:
  579.     Cmp    Byte Ptr FLG17_Copy_More_Disks,False
  580.     Je    B1111
  581.     Mov    SI,Offset MES01A_Write_Another_Diskette
  582.     Call    U1000_Display_Message
  583.     Call    U1200_Get_Yes_or_No
  584.     Cmp    Byte Ptr FLG06_Yes_or_No,False
  585.     Je    B1111            ; Continue
  586.     Mov    Byte Ptr WRK22_Current_Target_Head,Zero
  587.     Mov    Byte Ptr WRK23_Current_Target_Track,Zero
  588.     Mov    Word Ptr WRK33_CHRN_Table_Address,Offset MEM02_CHRN_Table
  589.     Mov    Byte Ptr FLG13_First_Read_Write,True
  590.     Mov    Byte Ptr FLG14_Copy_Complete,False
  591.     Mov    Byte Ptr FLG15_IO_Error,Three
  592.     Jmp    B1105A            ; Start writing a diskette again
  593. B1111:
  594.     Mov    SI,Offset MES01B_Copy_Another_Diskette
  595.     Call    U1000_Display_Message
  596.     Call    U1200_Get_Yes_or_No
  597.     Cmp    Byte Ptr FLG06_Yes_or_No,False
  598.     Je    B1199            ; Go to the end of the module
  599.     Call    C1500_Diskette_Messages    ; Print out the messages on screen
  600.     Jmp    B1101            ; Start copying a diskette again
  601. B1199:
  602.     Ret
  603. ;
  604. B1100_Detail_Process Endp
  605. ;
  606. Page
  607. ;************************************************************************
  608. ;*                                    *
  609. ;*    B1200_FINAL_PROCESS                        *
  610. ;*                                    *
  611. ;*    This module performs the following functions before returning     *
  612. ;*    control to PC DOS:                        *
  613. ;*                                    *
  614. ;*    1. Restores the value of the stack pointer.            *
  615. ;*                                    *
  616. ;*    2. Displays the final message of the program.            *
  617. ;*                                    *
  618. ;*    3. Restores the underline cursor.                *
  619. ;*                                    *
  620. ;*    4. Restores the settings in the Disk Parameter Table.        *
  621. ;*                                    *
  622. ;*    5. Returns control to A1000_Main_Module.            *
  623. ;*                                    *
  624. ;************************************************************************
  625. ;
  626. Page
  627. ;
  628. Public    B1200_Final_Process
  629. ;
  630. B1200_Final_Process Proc Near
  631. ;
  632. B1201:
  633.     Cli                ; Establish the stack pointer
  634.     Mov    SP,Word Ptr SYS15_Stack_Pointer
  635.     Sti                ; ..End
  636. ;
  637.     Call    C2300_Free_Memory    ; Free allocated memory  if necessary
  638. ;
  639.     Mov    SI,Offset MES100_Freecopy_Finished
  640.     Call    U1000_Display_Message    ; Display the message on the screen
  641. ;
  642.     Mov    AH,Set_CType_Command    ; Restore the underline cursor
  643.     Mov    CX,Underline_Cursor    ; .
  644.     Int    Video_Interrupt        ; ..End
  645. ;
  646.     Call    S1100_Restore_Disk_Param_Table
  647. ;
  648.     Mov    AX,Offset A1090        ; Setup to return to the main module
  649.     Push    CS            ; .
  650.     Push    AX            ; ..End
  651. B1299:
  652.     Ret
  653. ;
  654. B1200_Final_Process Endp
  655. ;
  656. Page
  657. ;************************************************************************
  658. ;*                                    *
  659. ;*    C1000_GET_AND_SET_VIDEO                        *
  660. ;*                                    *
  661. ;*    This module gets the current video state and saves this        *
  662. ;*    information in the various SYStem variables.            *
  663. ;*                                    *
  664. ;************************************************************************
  665. ;
  666. Public    C1000_Get_And_Set_Video
  667. ;
  668. C1000_Get_And_Set_Video Proc Near
  669. ;
  670. C1001:
  671.     Push    AX            ; Save the registers
  672.     Push    BX            ; .
  673.     Push    CX            ; ..End
  674. C1002:
  675.     Mov    AH,Video_State_Command    ; Get the current video state
  676.     Int    Video_Interrupt        ; ..End
  677.     Mov    Byte Ptr SYS01_Number_Columns,AH
  678.     Mov    Byte Ptr SYS02_Current_Mode,AL
  679.     Mov    Byte Ptr SYS03_Active_Page,BH
  680. C1003:
  681.     Mov    AH,Set_CType_Command    ; Set the cursor to blanks
  682.     Mov    CX,Blank_Cursor        ; .
  683.     Int    Video_Interrupt        ; ..End
  684. C1090:
  685.     Pop    CX            ; Restore the registers
  686.     Pop    BX            ; .
  687.     Pop    AX            ; ..End
  688. C1099:
  689.     Ret
  690. ;
  691. C1000_Get_And_Set_Video Endp
  692. ;
  693. Page
  694. ;************************************************************************
  695. ;*                                    *
  696. ;*    C1100_DISPLAY_INTRO                        *
  697. ;*                                    *
  698. ;*    This module displays the introductory message to FREECOPY.    *
  699. ;*    Please do not disable this message, since it states the        *
  700. ;*    conditions under which a person may copy this program.        *
  701. ;*                                    *
  702. ;************************************************************************
  703. ;
  704. Public    C1100_Display_Intro
  705. ;
  706. C1100_Display_Intro Proc Near
  707. ;
  708. C1101:
  709.     Mov    SI,Offset MES00_Copy_Notice    ; Display the copy notice
  710.     Call    U1000_Display_Message        ; ..End
  711. C1199:
  712.     Ret
  713. C1100_Display_Intro Endp
  714. ;
  715. Page
  716. ;************************************************************************
  717. ;*                                    *
  718. ;*    C1200_PARSE_COMMANDS                        *
  719. ;*                                    *
  720. ;*    This module parses the command line entered by the user        *
  721. ;*    by checking the following conditions:                *
  722. ;*                                    *
  723. ;*    1. The source and/or the target drives do not exist.        *
  724. ;*                                    *
  725. ;*    2. The command line contains any characters other than two    *
  726. ;*       drive letters (e.g., a filename).                *
  727. ;*                                    *
  728. ;*    3. The /1 (single side) parameter is on the command line.    *
  729. ;*                                    *
  730. ;************************************************************************
  731. ;
  732. Public    C1200_Parse_Commands
  733. ;
  734. C1200_Parse_Commands Proc Near
  735. ;
  736. C1201:
  737.     Cmp    AH,Invalid_Drive    ; Compare for invalid drive parms
  738.     Jne    C1202            ; .
  739.     Mov    Byte Ptr FLG01_Good_Command,False
  740.     Mov    SI,Offset MES14_Invalid_Drive
  741.     Call    U1000_Display_Message
  742.     Jmp    C1299            ; .
  743. C1202:                    ; .
  744.     Cmp    AL,Invalid_Drive    ; .
  745.     Jne    C1203            ; .
  746.     Mov    Byte Ptr FLG01_Good_Command,False
  747.     Mov    SI,Offset MES14_Invalid_Drive
  748.     Call    U1000_Display_Message
  749.     Jmp    C1299            ; ..End
  750. C1203:
  751.     Mov    AL,Byte Ptr Source_Drive
  752.     Mov    Byte Ptr WRK01_Source_Drive,AL
  753.     Mov    AL,Byte Ptr Target_Drive
  754.     Mov    Byte Ptr WRK02_Target_Drive,AL
  755. C1204:
  756.     Mov    SI,Offset Source_Filename
  757.     Mov    DI,Offset WRK03_Valid_Filename
  758.     Mov    CX,Eleven        ; Set CX to compare 11 characters 
  759. C1205:
  760.     Mov    AL,[SI]            ; Compare for valid source diskette
  761.     Mov    AH,[DI]            ; filename in the FCB at 05DH
  762.     Cmp    AH,AL            ; .
  763.     Je    C1206            ; .
  764.     Mov    Byte Ptr FLG01_Good_Command,False
  765.     Mov    SI,Offset MES12_Invalid_Parameter
  766.     Call    U1000_Display_Message
  767.     Jmp    C1299            ; .
  768. C1206:                    ; .
  769.     Inc    SI            ; .
  770.     Inc    DI            ; .
  771.     Loop    C1205            ; ..End
  772. C1207:
  773.     Mov    SI,Offset Target_Filename
  774.     Mov    DI,Offset WRK03_Valid_Filename
  775.     Mov    CX,Eleven        ; Set CX to comapre 11 characters
  776. C1208:
  777.     Mov    AL,[SI]            ; Compare for valid target diskette
  778.     Mov    AH,[DI]            ; . filename in the FCB at 06DH
  779.     Cmp    AH,AL            ; .
  780.     Je    C1209            ; .
  781.     Mov    Byte Ptr FLG01_Good_Command,False
  782.     Mov    SI,Offset MES12_Invalid_Parameter
  783.     Call    U1000_Display_Message
  784.     Jmp    C1299            ; .
  785. C1209:                    ; .
  786.     Inc    SI            ; .
  787.     Inc    DI            ; .
  788.     Loop    C1208            ; ..End
  789. C1210:
  790.     Mov    AL,Byte Ptr Parameter_Count
  791.     Mov    Byte Ptr WRK04_Parameter_Count,AL
  792.     Mov    SI,Offset Parameter_String
  793.     Inc    Byte Ptr WRK04_Parameter_Count
  794. C1211:
  795.     Dec    Byte Ptr WRK04_Parameter_Count
  796.     Jz    C1299            ; Go to the end of the module
  797.     Mov    AL,[SI]            ; Put the character into AL
  798.     Cmp    AL,Slash        ; Compare character with a slash
  799.     Je    C1212            ; If so, then continue processing
  800.     Inc    SI            ; Increment the command string addr
  801.     Jmp    C1211            ; Go back and try again
  802. C1212:
  803.     Inc    SI            ; Increment the command string addr
  804.     Mov    AL,[SI]            ; Get the next char after the slash
  805.     Cmp    AL,One_Digit        ; Compare with the char 1
  806.     Je    C1214            ; Set double side flag to false
  807. C1213:
  808.     Mov    Byte Ptr FLG01_Good_Command,False
  809.     Mov    SI,Offset MES12_Invalid_Parameter
  810.     Call    U1000_Display_Message
  811.     Jmp    C1299            ; Go to the end of the module
  812. C1214:
  813.     Mov    Byte Ptr FLG02_Double_Side,False
  814.     Dec    Byte Ptr WRK04_Parameter_Count
  815.     Jz    C1299            ; Go to the end of the module
  816. C1215:
  817.     Dec    Byte Ptr WRK04_Parameter_Count
  818.     Jz    C1299            ; Go to the end of the module
  819.     Inc    SI            ; Increment the command string addr
  820.     Mov    AL,[SI]            ; Get the next char in command line
  821.     Cmp    AL,HT            ; Check for tabs and spaces
  822.     Je    C1215            ; .
  823.     Cmp    AL,Space        ; .
  824.     Je    C1215            ; ..End
  825. C1216:
  826.     Mov    Byte Ptr FLG01_Good_Command,False
  827.     Mov    SI,Offset MES12_Invalid_Parameter
  828.     Call    U1000_Display_Message
  829. C1299:
  830.     Ret
  831. ;
  832. C1200_Parse_Commands Endp
  833. ;
  834. Page
  835. ;************************************************************************
  836. ;*                                    *
  837. ;*    C1300_GET_EQUIPMENT                        *
  838. ;*                                    *
  839. ;*    This module determines the peripheral devices on the machine.    *
  840. ;*    It invokes the equipment status interrupt and places the    *
  841. ;*    information into the appropriate SYStem parameters.        *
  842. ;*                                    *
  843. ;************************************************************************
  844. ;
  845. Public    C1300_Get_Equipment
  846.  
  847.  
  848. C1300_Get_Equipment Proc Near
  849. ;
  850. C1301:
  851.     Int    Equipment_Interrupt    ; Get the equipment on machine
  852.     Mov    BX,AX            ; Save the result for future use
  853. ;
  854.     And    AX,Parallel_Ports_Mask    ; Get the number of parallel ports
  855.     Mov    CL,Fourteen        ; .
  856.     Shr    AX,CL            ; .
  857.     Mov    Byte Ptr SYS07_No_Parallel_Ports,AL
  858. ;
  859.     Mov    AX,BX            ; Get the game adapter attachments
  860.     And    AX,Game_Adapters_Mask    ; .
  861.     Mov    CL,Twelve        ; .
  862.     Shr    AX,CL            ; .
  863.     Mov    Byte Ptr SYS08_Game_Adapters,AL
  864. ;
  865.     Mov    AX,BX            ; Get the number of RS-232 ports
  866.     And    AX,RS232_Ports_Mask    ; .
  867.     Mov    CL,Nine            ; .
  868.     Shr    AX,CL            ; .
  869.     Mov    Byte Ptr SYS09_No_RS232_Ports,AL
  870. ;
  871.     Mov    AX,BX            ; Get the number of diskette drives
  872.     And    AX,Disk_Drives_Mask    ; .
  873.     Mov    CL,Six            ; .
  874.     Shr    AX,CL            ; .
  875.     Mov    Byte Ptr SYS10_No_Disk_Drives,AL
  876. ;
  877.     Mov    AX,BX            ; Get the initial video mode
  878.     And    AX,Init_Video_Mask    ; .
  879.     Mov    CL,Four            ; .
  880.     Shr    AX,CL            ; .
  881.     Mov    Byte Ptr SYS11_Init_Video_Mode,AL
  882. ;
  883.     Mov    AX,BX            ; Get planar RAM size
  884.     And    AX,Planar_RAM_Mask    ; .
  885.     Mov    CL,Two            ; .
  886.     Shr    AX,CL            ; .
  887.     Mov    Byte Ptr SYS12_Planar_RAM_Size,AL
  888. ;
  889.     Mov    AX,BX            ; Get IPL from diskette flag
  890.     And    AX,IPL_Diskette_Mask    ; .
  891.     Mov    Byte Ptr SYS13_IPL_From_Diskette,AL
  892. ;
  893. C1399:
  894.     Ret
  895. ;
  896. C1300_Get_Equipment Endp
  897. Page
  898. ;************************************************************************
  899. ;*                                    *
  900. ;*    C1400_VALIDATE_DRIVES                        *
  901. ;*                                    *
  902. ;*    This module determines if the drives specified in the        *
  903. ;*    command line are floppy disk drives or RAM disk drives.        *
  904. ;*    It also checks if copying the source diskette takes place    *
  905. ;*    on a single drive.                        *
  906. ;*                                    *
  907. ;************************************************************************
  908. ;
  909. Public    C1400_Validate_Drives
  910. ;
  911. C1400_Validate_Drives Proc Near
  912. ;
  913. C1401:
  914.     Mov    AH,Default_Drive_Command; Get the PC DOS default drive
  915.     Int    PC_DOS_Interrupt    ; .
  916.     Mov    Byte Ptr SYS14_Default_Drive,AL
  917. C1402:
  918.     Cmp    Byte Ptr SYS10_No_Disk_Drives,Minimum_Drives
  919.     Ja    C1403            ; If not single drive copy, set
  920.                     ; . FLG04 to false
  921.     Mov    Byte Ptr SYS14_Default_Drive,Minimum_Drives
  922.     Mov    Byte Ptr WRK01_Source_Drive,Minimum_Drives
  923.     Mov    Byte Ptr WRK02_Target_Drive,Minimum_Drives
  924.     Jmp    C1499            ; Go to the end of the module
  925. C1403:
  926.     Mov    Byte Ptr FLG04_Single_Drive,False
  927. C1404:
  928.     Cmp    Byte Ptr SYS14_Default_Drive,Maximum_Drives
  929.     Jbe    C1405            ; If below maximum, continue
  930.     Mov    Byte Ptr FLG03_Default_Drive,False
  931.     Mov    SI,Offset MES13_Invalid_Default
  932.     Call    U1000_Display_Message
  933.     Jmp    C1499            ; Go to the end of the module
  934. C1405:
  935.     Dec    Byte Ptr WRK01_Source_Drive
  936.     Cmp    Byte Ptr WRK01_Source_Drive,Minus_One
  937.     Jne    C1406
  938.     Mov    AL,Byte Ptr SYS14_Default_Drive
  939.     Mov    Byte Ptr WRK01_Source_Drive,AL
  940. C1406:
  941.     Dec    Byte Ptr WRK02_Target_Drive
  942.     Cmp    Byte Ptr WRK02_Target_Drive,Minus_One
  943.     Jne    C1407
  944.     Mov    AL,Byte Ptr SYS14_Default_Drive
  945.     Mov    Byte Ptr WRK02_Target_Drive,AL
  946. C1407:
  947.     Mov    AL,Byte Ptr WRK01_Source_Drive
  948.     Mov    AH,Byte Ptr WRK02_Target_Drive
  949.     Cmp    AH,AL            ; Check source drive = target drive
  950.     Jne    C1499            ; If so, then continue
  951.     Mov    Byte Ptr FLG04_Single_Drive,True
  952. C1499:
  953.     Ret
  954. ;
  955. C1400_Validate_Drives Endp
  956. ;
  957. Page
  958. ;************************************************************************
  959. ;*                                    *
  960. ;*    C1500_DISKETTE_MESSAGES                        *
  961. ;*                                    *
  962. ;*    This module displays the appropriate source and target        *
  963. ;*    insertion diskette messages on the screen.            *
  964. ;*                                    *
  965. ;************************************************************************
  966. ;
  967. Public    C1500_Diskette_Messages
  968. ;
  969. C1500_Diskette_Messages Proc Near
  970. ;
  971. C1501:
  972.     Cmp    Byte Ptr FLG07_First_Time,False
  973.     Je    C1502            ; If not first time, continue
  974.     Cmp    Byte Ptr FLG04_Single_Drive,False
  975.     Je    C1502            ; If false, then continue
  976.     Mov    SI,Offset MES15_Single_Drive_Copy
  977.     Call    U1000_Display_Message
  978. C1502:
  979.     Mov    SI,Offset MES09_Insert_Source
  980.     Mov    AL,Byte Ptr WRK01_Source_Drive
  981.     Add    AL,Capital_Letter_A    ; Put the drive letter into AL
  982.     Mov    [SI+Thirty_Four],AL    ; Put the drive letter into the
  983.                     ; . correct position in the message
  984.     Call    U1000_Display_Message    ; Display the message on the screen
  985. C1503:
  986.     Cmp    Byte Ptr FLG04_Single_Drive,True
  987.     Je    C1505            ; If true, go to the message to press
  988.                     ; . any key to continue
  989. C1504:
  990.     Mov    SI,Offset MES10_Insert_Target
  991.     Mov    AL,Byte Ptr WRK02_Target_Drive
  992.     Add    AL,Capital_Letter_A    ; Put the drive letter into AL
  993.     Mov    [SI+Thirty_Four],AL    ; Put the drive letter into the
  994.                     ; . correct position in the message
  995.     Call    U1000_Display_Message    ; Display the message on the screen
  996. C1505:
  997.     Mov    SI,Offset MES16_Press_Any_Key
  998.     Call    U1000_Display_Message
  999.     Mov    Byte Ptr FLG05_Store_Buffer,False
  1000.     Call    U1100_Get_Response
  1001. C1599:
  1002.     Ret
  1003. ;
  1004. C1500_Diskette_Messages Endp
  1005. ;
  1006. Page
  1007. ;************************************************************************
  1008. ;*                                    *
  1009. ;*    C1600A_GET_FREE_MEMORY                        *
  1010. ;*                                    *
  1011. ;*    This module calculates the amount of free 16 byte paragraphs    *
  1012. ;*    available on the machine. The segment address of the beginning    *
  1013. ;*    of free memory is obtained by setting DX to:            *
  1014. ;*                                    *
  1015. ;*        1. The contents of the stack segment SS plus        *
  1016. ;*                                    *
  1017. ;*        2. 256 bytes for the Program Segment Prefix plus    *
  1018. ;*                                    *
  1019. ;*        3. 128 bytes for the stack.                *
  1020. ;*                                    *
  1021. ;*    After saving the ES segment register on the stack and        *
  1022. ;*    initializing both the offset register BX and the 16 byte    *
  1023. ;*    counter register CX to zero, the routine begins the looping    *
  1024. ;*    through memory 16 bytes at a time (incrementing the segment    *
  1025. ;*    register ES by one) until either the module encounters one    *
  1026. ;*    of the two (2) conditions:                    *
  1027. ;*                                    *
  1028. ;*        1. The beginning of Video RAM at the segment address    *
  1029. ;*           specified in Video_Address.                *
  1030. ;*                                    *
  1031. ;*        2. The memory pattern defined by the machine that    *
  1032. ;*           indicates no more memory.                *
  1033. ;*                                    *
  1034. ;*    When either of these two (2) conditions occur, CX contains    *
  1035. ;*    the  number of 16 bytes paragraphs of free memory.        *
  1036. ;*                                    *
  1037. ;*    Since we do not know the size of the transient portion of    *
  1038. ;*    COMMAND.COM, FREECOPY makes the worst case assumption that    *
  1039. ;*    all of the bytes in COMMAND.COM reside in high memory.        *
  1040. ;*                                    *
  1041. ;*    This module also allocates space for the ES:BX table, the    *
  1042. ;*    CHRN table, the File Allocation Table (FAT) of the source    *
  1043. ;*    diskette and at least one track (4608 bytes).            *
  1044. ;*                                    *
  1045. ;*    This module executes only when running PC-DOS 1.0 and 1.1!!!    *
  1046. ;*                                    *
  1047. ;************************************************************************
  1048. ;
  1049. Page
  1050. ;
  1051. Public    C1600A_Get_Free_Memory
  1052. ;
  1053. C1600A_Get_Free_Memory Proc Near
  1054. ;
  1055. C1601A:
  1056.     Mov    DX,SS            ; Calculate the segment address for
  1057.                     ; . the beginning of free memory
  1058.     Add    DX,Offset MEM04_Top_of_the_Stack
  1059. ;
  1060.     Push    ES            ; Save ES on the stack for a moment
  1061.     Mov    BX,NUL            ; Initialize BX and CX registers
  1062.     Mov    CX,NUL            ; ..End
  1063. C1602A:
  1064.     Mov    ES,DX            ; Set ES to the appropriate value
  1065.     Cli                ; Turn off interrupts for a moment
  1066.     Mov    AX,ES:[BX]        ; Read a word from memory into AX
  1067.     Mov    Word Ptr ES:[BX],SOH    ; Put the test pattern into memory
  1068.     Cmp    Word Ptr ES:[BX],SOH    ; Compare memory with test pattern
  1069.     Mov    ES:[BX],AX        ; Restore the contents of memory
  1070.     Sti                ; Turn on the interrupts
  1071.     Jne    C1603A            ; If not equal, stop looping
  1072.     Inc    DX            ; Increment DX segment register
  1073.     Cmp    DX,Video_Address    ; Compare for start of Video RAM
  1074.     Jae    C1603A            ; If so, stop looping
  1075.     Inc    CX            ; Increment 16 byte counter CX
  1076.     Jmp    C1602A            ; Go back and try again
  1077. C1603A:
  1078.     Pop    ES            ; Restore the ES register
  1079.     Cmp    CX,Command_Com_Size    ; Compare the paragraph size of
  1080.                     ; . free memory with the paragraph
  1081.                     ; . size of COMMAND.COM.
  1082.     Ja    C1604A            ; If greater, continue
  1083. ;
  1084.     Mov    Byte Ptr FLG01_Good_Command,False
  1085.     Mov    SI,Offset MES11_Insufficient_Memory
  1086.     Call    U1000_Display_Message    ; Display the message on the screen
  1087.     Jmp    C1699A            ; Go to the end of the module
  1088. C1604A:
  1089.     Sub    CX,Command_Com_Size    ; Subtract the size of COMMAND.COM
  1090.     Cmp    CX,ESBX_Table_Size    ; Compare the paragraph size of the
  1091.                     ; . free memory with the paragraph
  1092.                     ; . size of the ES:BX table
  1093.     Ja    C1605A            ; If greater, continue
  1094.     Mov    Byte Ptr FLG01_Good_Command,False
  1095.     Mov    SI,Offset MES11_Insufficient_Memory
  1096.     Call    U1000_Display_Message    ; Display the message on the screen
  1097.     Jmp    C1699A            ; Go to the end of the module
  1098. C1605A:
  1099.     Sub    CX,ESBX_Table_Size    ; Subtract the size of ES:BX table
  1100.     Cmp    CX,CHRN_Table_Size    ; Compare the paragraph size of the
  1101.                     ; . free memory with the paragraph
  1102.                     ; . size of the CHRN table
  1103.     Ja    C1606A            ; If greater, continue
  1104. ;
  1105.     Mov    Byte Ptr FLG01_Good_Command,False
  1106.     Mov    SI,Offset MES11_Insufficient_Memory
  1107.     Call    U1000_Display_Message    ; Display the message on the screen
  1108.     Jmp    C1699A            ; Go to the end of the module
  1109. C1606A:
  1110.     Sub    CX,CHRN_Table_Size    ; Subtract the size of CHRN Table
  1111.     Cmp    CX,FAT_Sector_Size    ; Determine if there is enough memory
  1112.     Jae    C1607A            ; to read the File Allocation Table
  1113.     Mov    Byte Ptr FLG01_Good_Command,False
  1114.     Mov    SI,Offset MES11_Insufficient_Memory
  1115.     Call    U1000_Display_Message    ; Display the message on the screen
  1116.     Jmp    C1699A            ; Go to the end of the module
  1117. C1607A:
  1118.     Sub    CX,FAT_Sector_Size    ; Subtract the size of the source FAT
  1119.     Cmp    CX,Minimum_Memory_Size    ; Determine if the amount of memory
  1120.     Jae    C1608A            ; can hold a nine sectored track
  1121. ;
  1122.     Mov    Byte Ptr FLG01_Good_Command,False
  1123.     Mov    SI,Offset MES11_Insufficient_Memory
  1124.     Call    U1000_Display_Message    ; Display the message on the screen
  1125.     Jmp    C1699A            ; Go to the end of the module
  1126. C1608A:
  1127.     Mov    Word Ptr SYS05_Para_RAM_Size,CX
  1128. C1699A:
  1129.     Ret
  1130. ;
  1131. C1600A_Get_Free_Memory Endp
  1132. ;
  1133. Page
  1134. ;************************************************************************
  1135. ;*                                    *
  1136. ;*    C1600B_GET_FREE_MEMORY                        *
  1137. ;*                                    *
  1138. ;*    This module calcules the amount of available memory.  It    *
  1139. ;*    executes when running PC-DOS versions 2.0 and above.        *
  1140. ;*                                    *
  1141. ;************************************************************************
  1142. ;
  1143. Public    C1600B_Get_Free_Memory
  1144. ;
  1145. C1600B_Get_Free_Memory Proc Near
  1146. ;
  1147. C1601B:
  1148.     Mov    AH,Modify_Memory_Block    ; Allocate enough space for the
  1149.     Mov    BX,Offset MEM00_Bottom_Free_Memory
  1150.     Mov    CL,Four            ; . program and all tables
  1151.     Shr    BX,CL            ; .
  1152.     Inc    BX            ; .
  1153.     Int    PC_DOS_Interrupt    ; .
  1154.     Jnc    C1603B            ; ..End
  1155. C1602B:
  1156.     Mov    Byte Ptr FLG01_Good_Command,False
  1157.     Mov    SI,Offset MES11_Insufficient_Memory
  1158.     Call    U1000_Display_Message    ; Display the message on the screen
  1159.     Jmp    C1699B            ; Go to the end of the module
  1160. C1603B:
  1161.     Mov    AH,Allocate_Memory    ; Get the amount of available memory
  1162.     Mov    BX,High_Values        ; .
  1163.     Int    PC_DOS_Interrupt    ; .
  1164.     Mov    Word Ptr SYS21_Alloc_Segment,AX
  1165.     Mov    Word Ptr SYS05_Para_RAM_Size,BX
  1166.     Jnc    C1699B            ; .
  1167.     Cmp    AL,Eight        ; .
  1168.     Je    C1605B            ; .
  1169. C1604B:
  1170.     Mov    SI,Offset MES97_Return_Linefeed
  1171.     Call    U1000_Display_Message    ; Issue a carriage return/linefeed
  1172.     Mov    SI,Offset MES99_Memory_Block_Destroyed
  1173.     Call    U1000_Display_Message    ; Display the message on the screen
  1174.     Jmp    C1699B            ; Go to the end of the module
  1175. C1605B:
  1176.     Mov    AH,Allocate_Memory    ; .
  1177.     Int    PC_DOS_Interrupt    ; ..End
  1178.     Mov    Word Ptr SYS21_Alloc_Segment,AX
  1179.     Mov    Word Ptr SYS05_Para_RAM_Size,BX
  1180.     Jnc    C1606B            ; Set the allocation flag
  1181.     Jmp    C1604B            ; Go to the error condition
  1182. C1606B:
  1183.     Mov    Byte Ptr FLG16_Free_Memory,False
  1184. C1699B:
  1185.     Ret
  1186. ;
  1187. C1600B_Get_Free_Memory Endp
  1188. ;
  1189. Page
  1190. ;************************************************************************
  1191. ;*                                    *
  1192. ;*    C1700_CREATE_ESBX_TABLE                        *
  1193. ;*                                    *
  1194. ;*    This module creates the correct ES:BX addresses that are    *
  1195. ;*    used when storing tracks read from the source diskette.        *
  1196. ;*    The routine allocates at most 80 entries in the table for    *
  1197. ;*    double sided diskettes.                        *
  1198. ;*                                    *
  1199. ;************************************************************************
  1200. ;
  1201. Public    C1700_Create_ESBX_Table
  1202. ;
  1203. C1700_Create_ESBX_Table Proc Near
  1204. ;
  1205. C1701:
  1206.     Mov    Word Ptr WRK34_DMA_OverFlow_Counter,ZERO
  1207. ;
  1208.     Mov    Word Ptr WRK18_Counter_ESBX_Entries,Zero
  1209.     Mov    AX,Nine            ; Calculate DI = the number of bytes
  1210.     Mov    BX,Sector_Size        ; per track and BX = the number of
  1211.     Mul    BX            ; paragraphs per track
  1212.     Mov    DI,AX            ; .
  1213.     Mov    BX,Paragraph_Size    ; .
  1214.     Mov    DX,Zero            ; .
  1215.     Div    BX            ; .
  1216.     Mov    BX,AX            ; ..End
  1217. ;
  1218.     Cmp    Byte Ptr SYS19_Major_Vers_Number,Zero
  1219.     Je    C1702            ; Compare for PC DOS 1.0 and 1.1
  1220.     Mov    AX,Word Ptr SYS21_Alloc_Segment
  1221.     Jmp    C1703            ; Continue
  1222. C1702:
  1223.     Mov    AX,CS            ; Calculate the address of the 1st
  1224.     Mov    CL,Four            ; that will be copied into memory
  1225.     Shl    AX,CL            ; .
  1226.     Add    AX,Offset MEM00_Bottom_Free_Memory
  1227.     Shr    AX,CL            ; .
  1228.     Inc    AX            ; ..End
  1229. C1703:
  1230.     Mov    SI,Offset MEM03_ESBX_Table
  1231.     Mov    Word Ptr [SI],Zero    ; Put the 1st entry into the table
  1232.     Mov    Word Ptr [SI+Two],AX    ; ..End
  1233. C1704:
  1234.     Cmp    Word Ptr WRK18_Counter_ESBX_Entries,Seventy_Nine
  1235.     Jae    C1707            ; Calculate the ES:BX valid entries
  1236.     Add    SI,Four            ; Get the next ES:BX table address
  1237. ;
  1238.     Mov    AX,[SI-Two]        ; Check for DMA overflow error
  1239.     And    AX,DMA_Boundary_Mask    ; .
  1240.     Shl    AX,CL            ; .
  1241.     Add    AX,DI            ; .
  1242.     Jnc    C1705            ; ..End
  1243. ;
  1244.     Mov    AX,[SI-Two]        ; Correction for DMA overflow
  1245.     Add    AX,BX            ; .
  1246.     Mov    [SI-Two],AX        ; ..End
  1247.     Inc    Word Ptr WRK34_DMA_Overflow_Counter
  1248. C1705:
  1249.     Mov    AX,[SI-Two]        ; Increment the ES segment address
  1250.     Add    AX,BX            ; ..End
  1251. C1706:
  1252.     Mov    Word Ptr [SI],Zero    ; Put the address into the table
  1253.     Mov    Word Ptr [SI+Two],AX    ; ..End
  1254.     Inc    Word Ptr WRK18_Counter_ESBX_Entries
  1255.     Jmp    C1704            ; Go back and find another entry
  1256. C1707:
  1257.     Mov    AX,Word Ptr SYS05_Para_RAM_Size
  1258.     Mov    DX,Zero            ; Divide by the number of paragraphs
  1259.     Div    BX            ; . per track
  1260.     Mov    Word Ptr WRK19_Number_ESBX_Entries,AX
  1261.     Mov    AX,Word Ptr WRK34_DMA_Overflow_Counter
  1262.     Sub    Word Ptr WRK19_Number_ESBX_Entries,AX
  1263.     Cmp    Word Ptr WRK19_Number_ESBX_Entries,Seventy_Nine
  1264.     Jb    C1799            ; If less than 79, continue
  1265.     Mov    Word Ptr WRK19_Number_ESBX_Entries,Seventy_Nine
  1266.     Mov    Byte Ptr FLG17_Copy_More_Disks,True
  1267. C1799:
  1268.     Ret
  1269. ;
  1270. C1700_Create_ESBX_Table Endp
  1271. ;
  1272. Page
  1273. ;************************************************************************
  1274. ;*                                    *
  1275. ;*    C1800_VALIDATE_SOURCE_DISK                    *
  1276. ;*                                    *
  1277. ;*    This module determines if the source diskette is readable    *
  1278. ;*    and whether it was formatted under PC DOS 1.0, 1.1, 2.0 or    *
  1279. ;*    2.1.  The routine also reads the first copy of the File        *
  1280. ;*    Allocation Table (FAT) storing it for future comparisons    *
  1281. ;*    as well as analyzing it first entry.                *
  1282. ;*                                    *
  1283. ;*    A series of comparisons for the number of sectors per track    *
  1284. ;*    is done for the following reasons.  All diskettes formatted    *
  1285. ;*    under PC DOS 2.0 and 2.1 really have nine sectors.  In order    *
  1286. ;*    to obtain an eight sectored diskette, the operating system    *
  1287. ;*    sets the first byte of the File Allocation Table (FAT)        *
  1288. ;*    accordingly.  In contrast, PC DOS 1.0 and 1.1 formats a track    *
  1289. ;*    to have exactly eight sectors.                    *
  1290. ;*                                    *
  1291. ;************************************************************************
  1292. ;
  1293. Public    C1800_Validate_Source_Disk
  1294. ;
  1295. C1800_Validate_Source_Disk Proc Near
  1296. ;
  1297. C1801:
  1298.     Mov    Byte Ptr FLG08_Good_Read,True
  1299. ;
  1300.     Mov    AL,Byte Ptr WRK01_Source_Drive
  1301.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1302.     Mov    Byte Ptr WRK07_Head_Number,Zero
  1303.     Mov    Byte Ptr WRK08_Track_Number,Zero
  1304.     Mov    Byte Ptr WRK09_Sector_Number,Nine
  1305.     Mov    Byte Ptr WRK10_Number_of_Sectors,One
  1306.     Push    CS            ; Establish the address ES:BX
  1307.     Pop    ES            ; ..End
  1308.     Mov    BX,Offset MEM01_File_Allocation_Table
  1309. ;
  1310.     Call    D1000_Read_Diskette
  1311. ;
  1312.     Cli                ; Set the number of sectors to nine
  1313.     Mov    Byte Ptr SYS18_Disk_Parameter_Table[Four],Nine
  1314.     Sti                ; .
  1315.     Mov    Byte Ptr WRK17_Maximum_Sectors,Nine
  1316. ;                
  1317.     Cmp    Byte Ptr FLG08_Good_Read,True
  1318.     Je    C1803            ; Check for good read of sector nine
  1319.     Cmp    Byte Ptr WRK14_Status_Operation,Sector_Error
  1320.     Je    C1802            ; If so, continue
  1321.     Mov    Byte Ptr FLG15_IO_Error,One
  1322.     Call    D1200_Disk_IO_Error    ; Process the error
  1323.     Jmp    C1899            ; ..End
  1324. C1802:
  1325.     Cli                ; Set the number of sectors to eight
  1326.     Mov    Byte Ptr SYS18_Disk_Parameter_Table[Four],Eight
  1327.     Sti                ; .
  1328.     Mov    Byte Ptr WRK17_Maximum_Sectors,Eight
  1329. C1803:                    ; .
  1330.     Mov    Byte Ptr FLG08_Good_Read,True
  1331. ;
  1332.     Mov    AL,Byte Ptr WRK01_Source_Drive
  1333.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1334.     Mov    Byte Ptr WRK07_Head_Number,Zero
  1335.     Mov    Byte Ptr WRK08_Track_Number,Zero
  1336.     Mov    Byte Ptr WRK09_Sector_Number,Two
  1337.     Mov    Byte Ptr WRK10_Number_of_Sectors,One
  1338.     Push    CS            ; Establish the address ES:BX
  1339.     Pop    ES            ; ..End
  1340.     Mov    BX,Offset MEM01_File_Allocation_Table
  1341. ;
  1342.     Call    D1000_Read_Diskette
  1343. ;
  1344.     Cmp    Byte Ptr FLG08_Good_Read,True
  1345.     Je    C1804            ; If the read operation was
  1346.                     ; . successful, continue
  1347.     Mov    Byte Ptr FLG15_IO_Error,One
  1348.     Call    D1200_Disk_IO_Error    ; Display appropriate error message
  1349.     Jmp    C1899            ; Go to the end of the module
  1350. C1804:
  1351.     Mov    AL,Byte Ptr MEM01_File_Allocation_Table[Zero]
  1352. ;
  1353.     Cmp    AL,One_Side_Eight_Sectors
  1354.     Jne    C1805            ; If not, continue
  1355.     Mov    Byte Ptr WRK15_Maximum_Heads,Zero
  1356.     Mov    Byte Ptr WRK16_Maximum_Tracks,Thirty_Nine
  1357.     Mov    SI,Offset MES03_Copy81_Sectors
  1358.     Jmp    C1809            ; Continue the processing
  1359. C1805:
  1360.     Cmp    AL,Two_Sides_Eight_Sectors
  1361.     Jne    C1806            ; If not, continue
  1362.     Mov    Byte Ptr WRK15_Maximum_Heads,One
  1363.     Mov    Byte Ptr WRK16_Maximum_Tracks,Seventy_Nine
  1364.     Mov    SI,Offset MES04_Copy82_Sectors
  1365.     Jmp    C1809            ; Continue the processing
  1366. C1806:
  1367.     Cmp    AL,One_Side_Nine_Sectors
  1368.     Jne    C1807            ; If not, continue
  1369.     Mov    Byte Ptr WRK15_Maximum_Heads,Zero
  1370.     Mov    Byte Ptr WRK16_Maximum_Tracks,Thirty_Nine
  1371.     Mov    SI,Offset MES05_Copy91_Sectors
  1372.     Jmp    C1809            ; Continue the processing
  1373. C1807:
  1374.     Cmp    AL,Two_Sides_Nine_Sectors
  1375.     Jne    C1808            ; If not, continue
  1376.     Mov    Byte Ptr WRK15_Maximum_Heads,One
  1377.     Mov    Byte Ptr WRK16_Maximum_Tracks,Seventy_Nine
  1378.     Mov    SI,Offset MES06_Copy92_Sectors
  1379.     Jmp    C1809            ; Continue the processing
  1380. C1808:
  1381.     Mov    Byte Ptr FLG08_Good_Read,False
  1382.     Mov    SI,Offset MES19_Unrecoverable_Read
  1383.     Call    U1000_Display_Message    ; Display the message on the screen
  1384.     Mov    SI,Offset MES90_Unknown_FAT_Error
  1385.     Call    U1000_Display_Message    ; Display the message on the screen
  1386.     Jmp    C1899            ; Go to display the message
  1387. C1809:
  1388.     Cmp    Byte Ptr WRK15_Maximum_Heads,Zero
  1389.     Je    C1810            ; If the diskette is single sided,
  1390.                     ; . display the diskette message
  1391.     Cmp    Byte Ptr FLG02_Double_Side,True
  1392.     Je    C1810            ; If the flag indicates to copy 
  1393.                     ; . both sides of the diskette,
  1394.                     ; . then continue
  1395.     Mov    Byte Ptr WRK15_Maximum_Heads,Zero
  1396.     Mov    Byte Ptr WRK16_Maximum_Tracks,Thirty_Nine
  1397. C1810:
  1398.     Mov    AL,Byte Ptr WRK01_Source_Drive
  1399.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1400.     Mov    Byte Ptr WRK07_Head_Number,One
  1401.     Mov    Byte Ptr WRK08_Track_Number,Zero
  1402.     Mov    Byte Ptr WRK09_Sector_Number,One
  1403.     Mov    Byte Ptr WRK10_Number_of_Sectors,One
  1404.     Push    CS            ; Establish the ES segment register
  1405.     Pop    ES            ; .
  1406.     Push    ES            ; ..End
  1407.     Mov    BX,Offset MEM00_Bottom_Free_Memory
  1408.     Cmp    SYS19_Major_Vers_Number,Zero
  1409.     Je    C1811            ; If PC DOS 1.0 or 1.1, continue;
  1410.                     ; . otherwise, setup ES:BX a little
  1411.     Mov    ES,Word Ptr SYS21_Alloc_Segment
  1412.     Mov    BX,Zero            ; . differently
  1413. C1811:
  1414.     Call    D1000_Read_Diskette
  1415.     Pop    ES            ; Restore ES in any case
  1416. ;
  1417.     Cmp    Byte Ptr FLG08_Good_Read,True
  1418.     Je    C1813        ; Go to display the message
  1419.     Cmp    Byte Ptr WRK15_Maximum_Heads,One
  1420.     Je    C1812        ; If double sided diskette, error!!!
  1421.     Mov    Byte Ptr FLG08_Good_Read,True
  1422.     Mov    Byte Ptr FLG02_Double_Side,False
  1423.     Jmp    C1813        ; Display the appropriate message
  1424. C1812:
  1425.     Mov    SI,Offset MES19_Unrecoverable_Read
  1426.     Call    U1000_Display_Message    ; Display the message on the screen
  1427.     Mov    SI,Offset MES91_Single_Side_Error
  1428.     Call    U1000_Display_Message    ; Display the message on the screen
  1429.     Jmp    C1899            ; Go to the end of the module
  1430. C1813:
  1431.     Call    U1000_Display_Message    ; Display the message on the screen
  1432. C1899:
  1433.     Ret
  1434. ;
  1435. C1800_Validate_Source_Disk Endp
  1436. ;
  1437. Page
  1438. ;************************************************************************
  1439. ;*                                    *
  1440. ;*    C1900_CREATE_CHRN_TABLE                        *
  1441. ;*                                    *
  1442. ;*    This module creates the CHRN table to be used in case the    *
  1443. ;*    target diskette needs to be formatted.    The abbreviation    *
  1444. ;*    stands for C = track number, H = head number, R = sector    *
  1445. ;*    number and N = a code for the number of bytes per sector.    *
  1446. ;*                                    *
  1447. ;************************************************************************
  1448. ;
  1449. Public    C1900_Create_CHRN_Table
  1450. ;
  1451. C1900_Create_CHRN_Table Proc Near
  1452. ;
  1453. C1901:
  1454.     Mov    BH,Byte Ptr WRK15_Maximum_Heads
  1455.     Mov    BL,Byte Ptr WRK16_Maximum_Tracks
  1456.     Mov    AL,Nine
  1457. ;
  1458.     Mov    CL,BH            ; Establish correct track number
  1459.     Shr    BL,CL            ; ..End
  1460. ;
  1461.     Mov    DL,Two            ; . DL = number of sectors
  1462.     Mov    DH,Zero            ; . DH = head number
  1463.     Mov    CH,Zero            ; . CH = track number
  1464.     Mov    CL,One            ; . CL = sector number
  1465.     Mov    SI,Offset MEM02_CHRN_Table; Set up initial registers
  1466. C1902:
  1467.     Mov    [SI],CH            ; Establish an entry in the CHRN
  1468.     Mov    [SI+One],DH        ; . table
  1469.     Mov    [SI+Two],CL        ; .
  1470.     Mov    [SI+Three],DL        ; ..End
  1471. ;
  1472.     Add    SI,Four            ; Get the addr of next CHRN entry
  1473.     Inc    CL            ; Increment the sector number
  1474.     Cmp    CL,AL            ; Compare for maximum sectors
  1475.     Jbe    C1902            ; If not, go back and try again
  1476. ;
  1477.     Mov    CL,One            ; Initialize sector number
  1478.     Inc    DH            ; Increment the head number
  1479.     Cmp    DH,BH            ; Compare for maximum heads
  1480.     Jbe    C1902            ; If not, go back and try again
  1481. ;
  1482.     Mov    CL,One            ; Initialize sector number
  1483.     Mov    DH,Zero            ; Initialize head number
  1484.     Inc    CH            ; Increment the track number
  1485.     Cmp    CH,BL            ; Compare for maximum tracks
  1486.     Jbe    C1902            ; If not, go back and try again
  1487. C1999:
  1488.     Ret
  1489. ;
  1490. C1900_Create_CHRN_Table Endp
  1491. ;
  1492. Page
  1493. ;************************************************************************
  1494. ;*                                    *
  1495. ;*    C2000_READ_SOURCE_DISK                        *
  1496. ;*                                    *
  1497. ;*    This module reads a diskette track by track until it fills    *
  1498. ;*    all of available memory specified by the ES:BX table.  The    *
  1499. ;*    processing sequence is:                        *
  1500. ;*                                    *
  1501. ;*    1. Initializes the SI resgister to point to the correct entry    *
  1502. ;*       in the ES:BX table.                        *
  1503. ;*                                    *
  1504. ;*    2. Prints the initial read message on the screen.        *
  1505. ;*                                    *
  1506. ;*    3. Compares for the end of the ES:BX table and/or the number    *
  1507. ;*       of tracks on the diskette.  If not, continue.  If so,    *
  1508. ;*       return to B1100_Detail_Processing.                *
  1509. ;*                                    *
  1510. ;*    4. Reads a track from the source diskette.            *
  1511. ;*                                    *
  1512. ;*    5. Displays the track and head numbers on the screen.        *
  1513. ;*                                    *
  1514. ;*    6. Transfers control to 3.                    *
  1515. ;*                                    *
  1516. ;************************************************************************
  1517. ;
  1518. Page
  1519. ;
  1520. Public    C2000_Read_Source_Disk
  1521. ;
  1522. C2000_Read_Source_Disk Proc Near
  1523. ;
  1524. C2001:
  1525.     Mov    Byte Ptr FLG08_Good_Read,True
  1526. ;
  1527.     Mov    SI,Offset MEM03_ESBX_Table
  1528.     Mov    Word Ptr WRK18_Counter_ESBX_Entries,Zero
  1529. ;
  1530.     Cmp    Byte Ptr FLG13_First_Read_Write,False
  1531.     Je    C2002            ; If not first time, continue
  1532.     Mov    Byte Ptr WRK31_Track_Read_Counter,Zero
  1533.     Jmp    C2003            ; Go to display the message
  1534. C2002:
  1535.     Cmp    Byte Ptr FLG04_Single_Drive,False
  1536.     Je    C2004            ; If double drive copy, continue
  1537. C2003:
  1538.     Push    SI            ; Save SI = Addr of ES:BX table
  1539.     Mov    SI,Offset MES97_Return_Linefeed
  1540.     Call    U1000_Display_Message    ; Display a return and linefeed
  1541.     Mov    SI,Offset MES17_Reading_Track
  1542.     Mov    AL,Byte Ptr WRK21_Current_Source_Track
  1543.     Call    U1300_Convert_Binary_to_ASCII
  1544.     Mov    [SI+Fifteen],AX        ; Put the track number into message
  1545.     Mov    AL,Byte Ptr WRK20_Current_Source_Head
  1546.     Call    U1300_Convert_Binary_to_ASCII
  1547.     Mov    [SI+Twenty_Five],AL    ; Put the head number into message
  1548.     Call    U1000_Display_Message    ; Display the message on the screeen
  1549. ;
  1550.     Mov    AH,Read_Cursor_Command    ; Get the current cursor position
  1551.     Mov    BH,Byte Ptr SYS03_Active_Page
  1552.     Int    Video_Interrupt        ; ..End
  1553. ;
  1554.     Dec    DH            ; Save the row of the read track and
  1555.     Mov    Byte Ptr WRK24_Read_Message_Row,DH; . head message
  1556. ;
  1557.     Pop    SI            ; Restore SI = Addr of ES:BX table
  1558. C2004:
  1559.     Mov    AL,Byte Ptr WRK31_Track_Read_Counter
  1560.     Cmp    AL,Byte Ptr WRK16_Maximum_Tracks
  1561.     Jbe    C2005            ; If more tracks, then continue
  1562.     Jmp    C2099            ; Go to the end of the module
  1563. C2005:
  1564.     Mov    AX,Word Ptr WRK18_Counter_ESBX_Entries
  1565.     Cmp    AX,Word Ptr WRK19_Number_ESBX_Entries
  1566.     Jbe    C2006            ; If more memory exists, continue
  1567.     Jmp    C2099            ; Go to the end of the module
  1568. C2006:
  1569. ;                    ; Display the current track and head
  1570.     Mov    AL,Byte Ptr WRK24_Read_Message_Row
  1571.     Mov    Byte Ptr WRK28_Current_Message_Row,AL
  1572.     Mov    AL,Byte Ptr WRK20_Current_Source_Head
  1573.     Mov    Byte Ptr WRK29_Current_Head,AL
  1574.     Mov    AL,Byte Ptr WRK21_Current_Source_Track
  1575.     Mov    Byte Ptr WRK30_Current_Track,AL
  1576. ;
  1577.     Call    U1400_Display_Head_and_Track
  1578. ;
  1579.                     ; Establish the disk parameters
  1580.     Mov    AL,Byte Ptr WRK01_Source_Drive
  1581.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1582.     Mov    AL,Byte Ptr WRK20_Current_Source_Head
  1583.     Mov    Byte Ptr WRK07_Head_Number,AL
  1584.     Mov    AL,Byte Ptr WRK21_Current_Source_Track
  1585.     Mov    Byte Ptr WRK08_Track_Number,AL
  1586.     Mov    Byte Ptr WRK09_Sector_Number,One
  1587.     Mov    AL,Byte Ptr WRK17_Maximum_Sectors
  1588.     Mov    Byte Ptr WRK10_Number_of_Sectors,AL
  1589.     Mov    AX,DS:[SI]        ; .
  1590.     Mov    BX,AX            ; .
  1591.     Mov    AX,DS:[SI+Two]        ; .
  1592.     Mov    ES,AX            ; ..End
  1593. ;
  1594.     Call    D1000_Read_Diskette    ; Read the source diskette
  1595. C2007:
  1596.     Cmp    Byte Ptr FLG08_Good_Read,True
  1597.     Je    C2008            ; If the read operation was 
  1598.                     ; . successful, then continue
  1599.     Mov    Byte Ptr FLG15_IO_Error,One
  1600.     Call    D1200_Disk_IO_Error    ; Display appropriate error message
  1601.     Jmp    C2099            ; Go to the end of the module
  1602. C2008:
  1603.     Inc    Byte Ptr WRK31_Track_Read_Counter
  1604.     Inc    Word Ptr WRK18_Counter_ESBX_Entries
  1605.     Add    SI,Four            ; Increment addr of the ES:BX table
  1606.     Cmp    Byte Ptr FLG02_Double_Side,False
  1607.     Je    C2009            ; If single sided, then continue
  1608.     Inc    Byte Ptr WRK20_Current_Source_Head
  1609.     Cmp    Byte Ptr WRK20_Current_Source_Head,One
  1610.     Jbe    C2010            ; If the head number is less than or
  1611.                     ; . equal to one, then continue
  1612.     Mov    Byte Ptr WRK20_Current_Source_Head,Zero
  1613. C2009:
  1614.     Inc    Byte Ptr WRK21_Current_Source_Track
  1615. C2010:
  1616.     Jmp    C2004            ; Go back and read another track
  1617. C2099:
  1618.     Ret
  1619. ;
  1620. C2000_Read_Source_Disk Endp
  1621. ;
  1622. Page
  1623. ;************************************************************************
  1624. ;*                                    *
  1625. ;*    C2100_WRITE_FORMAT_TARGET_DISK                    *
  1626. ;*                                    *
  1627. ;*    This module formats and writes  a diskette track by track    *
  1628. ;*    until it fills all of available memory specified by the        *
  1629. ;*    ES:BX table.  The processing sequence is:            *
  1630. ;*                                    *
  1631. ;*    1. Initializes the SI resgister to point to the correct entry    *
  1632. ;*       in the ES:BX table.                        *
  1633. ;*                                    *
  1634. ;*    2. Prints the initial write message on the screen.        *
  1635. ;*                                    *
  1636. ;*    3. Compares for the end of the ES:BX table and/or the number    *
  1637. ;*       of tracks on the diskette.  If not, continue.  If so,    *
  1638. ;*       return to B1100_Detail_Processing.                *
  1639. ;*                                    *
  1640. ;*    4. Writes a track from the source diskette.            *
  1641. ;*                                    *
  1642. ;*    5. Displays the track and head numbers on the screen.        *
  1643. ;*                                    *
  1644. ;*    6. Transfers control to 3.                    *
  1645. ;*                                    *
  1646. ;************************************************************************
  1647. ;
  1648. Public    C2100_Write_Format_Target_Disk
  1649. ;
  1650. C2100_Write_Format_Target_Disk Proc Near
  1651. ;
  1652. C2101:
  1653.     Mov    Byte Ptr FLG09_Good_Write,True
  1654.     Mov    Byte Ptr FLG11_Good_Format,True
  1655. ;
  1656.     Mov    Byte Ptr WRK13_Retry_Counter,Number_of_Retries
  1657. ;
  1658.     Mov    SI,Offset MEM03_ESBX_Table
  1659.     Mov    Word Ptr WRK18_Counter_ESBX_Entries,Zero
  1660. ;
  1661.     Cmp    Byte Ptr FLG13_First_Read_Write,False
  1662.     Je    C2102            ; If not first time, continue
  1663.     Mov    Byte Ptr WRK32_Track_Write_Counter,Zero
  1664.     Jmp    C2103            ; Go to display the message
  1665. C2102:
  1666.     Cmp    Byte Ptr FLG04_Single_Drive,False
  1667.     Je    C2104            ; If double drive copy, continue
  1668. C2103:
  1669.     Push    SI            ; Save SI = Addr of ES:BX table
  1670. ;
  1671.     Mov    SI,Offset MES97_Return_Linefeed
  1672.     Call    U1000_Display_Message    ; Display return and line feed
  1673.     Mov    SI,Offset MES23_Writing_Track
  1674.     Call    U1000_Display_Message    ; Display write track message
  1675. ;
  1676.     Mov    AH,Read_Cursor_Command    ; Get the current cursor position
  1677.     Mov    BH,Byte Ptr SYS03_Active_Page
  1678.     Int    Video_Interrupt        ; ..End
  1679. ;
  1680.     Dec    DH            ; Save the row of the I/O track and
  1681.     Mov    Byte Ptr WRK27_Write_Message_Row,DH; . head information
  1682.     Sub    DH,Two            ; .
  1683.     Mov    Byte Ptr WRK24_Read_Message_Row,DH
  1684. ;
  1685.     Pop    SI            ; Restore SI = Addr of ES:BX table
  1686. C2104:
  1687.     Mov    AL,Byte Ptr WRK32_Track_Write_Counter
  1688.     Cmp    AL,Byte Ptr WRK16_Maximum_Tracks
  1689.     Jbe    C2105            ; If more tracks, then continue
  1690.     Mov    Byte Ptr FLG14_Copy_Complete,True
  1691.     Jmp    C2199            ; Go to the end of the module
  1692. C2105:
  1693.     Mov    AX,Word Ptr WRK18_Counter_ESBX_Entries
  1694.     Cmp    AX,Word Ptr WRK19_Number_ESBX_Entries
  1695.     Jbe    C2106            ; If more memory exists, continue
  1696.     Jmp    C2199            ; Go to the end of the module
  1697. C2106:
  1698. ;                    ; Establish the disk parameters
  1699.     Mov    AL,Byte Ptr WRK02_Target_Drive
  1700.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1701.     Mov    AL,Byte Ptr WRK22_Current_Target_Head
  1702.     Mov    Byte Ptr WRK07_Head_Number,AL
  1703.     Mov    AL,Byte Ptr WRK23_Current_Target_Track
  1704.     Mov    Byte Ptr WRK08_Track_Number,AL
  1705.     Mov    Byte Ptr WRK09_Sector_Number,One
  1706.     Mov    AL,Byte Ptr WRK17_Maximum_Sectors
  1707.     Mov    Byte Ptr WRK10_Number_of_Sectors,AL
  1708.     Mov    AX,DS:[SI+Two]        ; .
  1709.     Mov    Word Ptr WRK11_Segment_Address,AX
  1710.     Mov    AX,DS:[SI]        ; .
  1711.     Mov    Word Ptr WRK12_Offset_Address,AX
  1712. ;
  1713.     Call    D1100_Write_Format_Diskette
  1714. ;
  1715.     Cmp    Byte Ptr FLG11_Good_Format,True
  1716.     Je    C2107            ; If a good format, continue
  1717.     Cmp    Byte Ptr FLG09_Good_Write,True
  1718.     Je    C2107            ; If a good write, continue
  1719.     Call    D1200_Disk_IO_Error    ; Display appropriate error message
  1720.     Jmp    C2199            ; Go to the end of the module
  1721. C2107:
  1722.     Inc    Byte Ptr WRK32_Track_Write_Counter
  1723.     Inc    Word Ptr WRK18_Counter_ESBX_Entries
  1724.     Add    SI,Four            ; Increment addr of the ES:BX table
  1725.     Cmp    Byte Ptr FLG02_Double_Side,False
  1726.     Je    C2108            ; If single sided, then continue
  1727.     Inc    Byte Ptr WRK22_Current_Target_Head
  1728.     Cmp    Byte Ptr WRK22_Current_Target_Head,One
  1729.     Jbe    C2109            ; If the head number is less than or
  1730.                     ; . equal to one, then continue
  1731.     Mov    Byte Ptr WRK22_Current_Target_Head,Zero
  1732. C2108:
  1733.     Inc    Byte Ptr WRK23_Current_Target_Track
  1734. C2109:
  1735.     Jmp    C2104            ; Go back and write another track
  1736. C2199:
  1737.     Ret
  1738. ;
  1739. C2100_Write_Format_Target_Disk Endp
  1740. ;
  1741. Page
  1742. ;************************************************************************
  1743. ;*                                    *
  1744. ;*    C2200_CHECK_FILE_ALLOC_TABLE                    *
  1745. ;*                                    *
  1746. ;*    This module checks the File Allocation Table (FAT) of the    *
  1747. ;*    diskette in the source drive and compares it with the File    *
  1748. ;*    Allocation Table (FAT) of the original source diskette.  If    *
  1749. ;*    there are any differences, the program sets the flag        *
  1750. ;*    FLG12_Good_FAT to False; otherwise, the flag is True.        *
  1751. ;*                                    *
  1752. ;************************************************************************
  1753. ;
  1754. Public    C2200_Check_File_Alloc_Table
  1755. ;
  1756. C2200_Check_File_Alloc_Table Proc Near
  1757. ;
  1758. C2201:
  1759.     Mov    Byte Ptr FLG12_Good_FAT,True
  1760. ;
  1761.     Mov    AL,Byte Ptr WRK01_Source_Drive
  1762.     Mov    Byte Ptr WRK06_Drive_Number,AL
  1763.     Mov    Byte Ptr WRK07_Head_Number,Zero
  1764.     Mov    Byte Ptr WRK08_Track_Number,Zero
  1765.     Mov    Byte Ptr WRK09_Sector_Number,Two
  1766.     Mov    Byte Ptr WRK10_Number_of_Sectors,One
  1767.     Push    CS            ; Establish the ES segment register
  1768.     Pop    ES            ; .
  1769.     Push    ES            ; ..End
  1770.     Mov    BX,Offset MEM00_Bottom_Free_Memory
  1771.     Cmp    SYS19_Major_Vers_Number,Zero
  1772.     Je    C2202            ; If PC DOS 1.0 or 1.1, continue;
  1773.                     ; . otherwise, set up ES:BX a little
  1774.     Mov    ES,Word Ptr SYS21_Alloc_Segment
  1775.     Mov    BX,Zero            ; . differently
  1776. C2202:
  1777.     Call    D1000_Read_Diskette    ; Read the File Allocation Table
  1778.     Pop    ES            ; Restore ES in any case
  1779. ;
  1780.     Cmp    Byte Ptr FLG08_Good_Read,True
  1781.     Je    C2203            ; If the read operation was
  1782.                     ; . successful, continue
  1783.     Mov    Byte Ptr FLG15_IO_Error,One
  1784.     Call    D1200_Disk_IO_Error    ; Display appropriate error message
  1785.     Jmp    C2299            ; Go to the end of the module
  1786. C2203:
  1787.     Mov    SI,Offset MEM01_File_Allocation_Table
  1788.     Mov    DI,Offset MEM00_Bottom_Free_Memory
  1789.     Push    ES            ; Save ES for a moment
  1790.     Cmp    Byte Ptr SYS19_Major_Vers_Number,Zero
  1791.     Je    C2204            ; If PC DOS 1.0 or 1.1, continue
  1792.     Mov    ES,Word Ptr SYS21_Alloc_Segment
  1793.     Mov    DI,Zero            ; Set up ES:DI for PC DOS 2.0+
  1794. C2204:
  1795.     Mov    CX,Sector_Size        ; Set counter CX to compare the
  1796.                     ; . sector size in words
  1797.     Shr    CX,1            ; ..End
  1798.     Cld                ; Clear the direction flag
  1799.     Rep    Cmpsw            ; Compare all of the 512 bytes
  1800.     Jne    C2205            ; If there is a discrepancy, go to
  1801.                     ; . the error message routine
  1802.     Jmp    C2206            ; Go to the end of the module
  1803. C2205:
  1804.     Pop    ES            ; Restore the ES register
  1805.     Mov    Byte Ptr FLG12_Good_FAT,False
  1806.     Mov    SI,Offset MES19_Unrecoverable_Read
  1807.     Call    U1000_Display_Message    ; Display the message on the screen
  1808.     Mov    SI,Offset MES90_Unknown_FAT_Error
  1809.     Call    U1000_Display_Message    ; Display the message on the screen
  1810.     Jmp    C2299            ; Go to the end of the module
  1811. C2206:
  1812.     Pop    ES            ; Restore the ES register
  1813. C2299:
  1814.     Ret
  1815. ;
  1816. C2200_Check_File_Alloc_Table Endp
  1817. ;
  1818. Page
  1819. ;************************************************************************
  1820. ;*                                    *
  1821. ;*    C2300_FREE_MEMORY                        *
  1822. ;*                                    *
  1823. ;*    This module free up allocated memory, provided that a user    *
  1824. ;*    is running PC DOS 2.0 or greater; otherwise, it does nothing.    *
  1825. ;*                                    *
  1826. ;************************************************************************
  1827. ;
  1828. Public    C2300_Free_Memory
  1829. ;
  1830. C2300_Free_Memory Proc Near
  1831. ;
  1832. C2301:
  1833.     Cmp    Byte Ptr SYS19_Major_Vers_Number,Zero
  1834.     Je    C2399            ; If PC DOS 1.0 or 1.1, go to the
  1835.                     ; . end of the module
  1836.     Cmp    Byte Ptr FLG16_Free_Memory,True
  1837.     Je    C2399            ; If memory was not allocated, go
  1838.                     ; . to the end of the module
  1839. ;
  1840.     Mov    AH,Free_Memory        ; Free allocated memory
  1841.     Push    ES            ; .
  1842.     Mov    ES,Word Ptr SYS21_Alloc_Segment
  1843.     Int    PC_DOS_Interrupt    ; .
  1844.     Pop    ES            ; .
  1845.     Jnc    C2399            ; ..End
  1846. ;
  1847.     Mov    SI,Offset MES97_Return_Linefeed
  1848.     Call    U1000_Display_Message    ; Issue a carriage return/linefeed
  1849.     Mov    SI,Offset MES99_Memory_Block_Destroyed
  1850.     Call    U1000_Display_Message    ; Display the message on the screen
  1851. C2399:
  1852.     Ret
  1853. ;
  1854. C2300_Free_Memory Endp
  1855. ;
  1856. Page
  1857. ;************************************************************************
  1858. ;*                                    *
  1859. ;*    D1000_READ_DISKETTE                        *
  1860. ;*                                    *
  1861. ;*    This module reads a track at a time from a diskette. If it    *
  1862. ;*    fails to read the diskette it tries Number_of_Retries = 5    *
  1863. ;*    times.                                *
  1864. ;*                                    *
  1865. ;************************************************************************
  1866. ;
  1867. Public    D1000_Read_Diskette
  1868. ;
  1869. D1000_Read_Diskette Proc Near
  1870. ;
  1871. D1001:
  1872.     Mov    Byte Ptr WRK13_Retry_Counter,Number_of_Retries
  1873. D1002:
  1874.     Clc                ; Clear the carry flag
  1875.     Mov    AH,Read_Command        ; Read the data on the diskette
  1876.     Mov    DL,Byte Ptr WRK06_Drive_Number
  1877.     Mov    DH,Byte Ptr WRK07_Head_Number
  1878.     Mov    CH,Byte Ptr WRK08_Track_Number
  1879.     Mov    CL,Byte Ptr WRK09_Sector_Number
  1880.     Mov    AL,Byte Ptr WRK10_Number_of_Sectors
  1881.     Int    Disk_Interrupt        ; ..End
  1882. ;
  1883.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1884.     Jnc    D1099            ; Go to the end of the module
  1885. D1003:
  1886.     Dec    Byte Ptr WRK13_Retry_Counter
  1887.     Jz    D1004            ; Could not read the diskette
  1888.     Clc                ; Clear the carry flag
  1889.     Mov    AH,Reset_Command    ; Initialize the disk controller
  1890.     Int    Disk_Interrupt        ; .
  1891.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1892.     Jnc    D1002            ; .
  1893.     Jmp    D1003            ; ..End
  1894. D1004:
  1895.     Mov    Byte Ptr FLG08_Good_Read,False
  1896. D1099:
  1897.     Ret
  1898. ;
  1899. D1000_Read_Diskette Endp
  1900. ;
  1901. Page
  1902. ;************************************************************************
  1903. ;*                                    *
  1904. ;*    D1100_WRITE_FORMAT_DISKETTE                    *
  1905. ;*                                    *
  1906. ;*    This module formats and writes a track at a time to a         *
  1907. ;*    diskette.  If it fails to format or a write a track, it tries    *
  1908. ;*    Number_of_Retries = 5 times.                    *
  1909. ;*                                    *
  1910. ;************************************************************************
  1911. ;
  1912. Public    D1100_Write_Format_Diskette
  1913. ;
  1914. D1100_Write_Format_Diskette Proc Near
  1915. ;
  1916. D1101:
  1917.     Mov    Byte Ptr WRK13_Retry_Counter,Number_of_Retries
  1918. D1102:
  1919.     Clc                ; Clear the carry flag
  1920.     Mov    AH,Format_Command    ; Format the diskette
  1921.     Mov    DL,Byte Ptr WRK06_Drive_Number
  1922.     Mov    DH,Byte Ptr WRK07_Head_Number
  1923.     Mov    CH,Byte Ptr WRK08_Track_Number
  1924.     Mov    CL,Byte Ptr WRK09_Sector_Number
  1925.     Mov    AL,Byte Ptr WRK10_Number_of_Sectors
  1926.     Push    CS            ; .
  1927.     Pop    ES            ; .
  1928.     Mov    BX,Word Ptr WRK33_CHRN_Table_Address
  1929.     Int    Disk_Interrupt        ; ..End
  1930.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1931.     Jnc    D1105            ; Formatted the diskette
  1932. D1103:
  1933.     Dec    Byte Ptr WRK13_Retry_Counter
  1934.     Jz    D1104            ; Go to format error processing
  1935.     Clc                ; Clear the carry flag
  1936.     Mov    AH,Reset_Command    ; Initialize the disk controller
  1937.     Int    Disk_Interrupt        ; .
  1938.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1939.     Jnc    D1102            ; Try to format the disk again
  1940.     Jmp    D1103            ; Try to initialize the disk again
  1941. D1104:
  1942.     Mov    Byte Ptr FLG15_IO_Error,Zero
  1943.     Mov    Byte Ptr FLG11_Good_Format,False
  1944.     Jmp    D1199            ; Go to the end of the module
  1945. D1105:
  1946.     Mov    Byte Ptr WRK13_Retry_Counter,Number_of_Retries
  1947. D1106:
  1948.     Clc                ; Clear the carry flag
  1949.     Mov    AH,Write_Command    ; Write the diskette
  1950.     Mov    ES,Word Ptr WRK11_Segment_Address
  1951.     Mov    BX,Word Ptr WRK12_Offset_Address
  1952.     Mov    AL,Byte Ptr WRK10_Number_of_Sectors
  1953.     Int    Disk_Interrupt        ; .
  1954.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1955.     Jnc    D1109            ; ..End
  1956. D1107:
  1957.     Dec    Byte Ptr WRK13_Retry_Counter
  1958.     Jz    D1108            ; Go to write error processing
  1959.     Clc                ; Clear the carry flag
  1960.     Mov    AH,Reset_Command    ; Initialize the disk controller
  1961.     Int    Disk_Interrupt        ; .
  1962.     Mov    Byte Ptr WRK14_Status_Operation,AH
  1963.     Jnc    D1106            ; .
  1964.     Jmp    D1107            ; ..End
  1965. D1108:
  1966.     Mov    Byte Ptr FLG15_IO_Error,Two
  1967.     Mov    Byte Ptr FLG09_Good_Write,False
  1968.     Jmp    D1199            ; Go to the end of the module
  1969. D1109:
  1970.     Add    Word Ptr WRK33_CHRN_Table_Address,Thirty_Six
  1971. ;
  1972.     Mov    AL,Byte Ptr WRK27_Write_Message_Row
  1973.     Mov    Byte Ptr WRK28_Current_Message_Row,AL
  1974.     Mov    AL,Byte Ptr WRK22_Current_Target_Head
  1975.     Mov    Byte Ptr WRK29_Current_Head,AL
  1976.     Mov    AL,Byte Ptr WRK23_Current_Target_Track
  1977.     Mov    Byte Ptr WRK30_Current_Track,AL
  1978.     Call    U1400_Display_Head_and_Track
  1979. D1199:
  1980.     Ret
  1981. ;
  1982. D1100_Write_Format_Diskette Endp
  1983. ;
  1984. Page
  1985. ;************************************************************************
  1986. ;*                                    *
  1987. ;*    D1200_DISK_IO_ERROR                        *
  1988. ;*                                    *
  1989. ;*    This module fans out a disk error.  It tells a user if it    *
  1990. ;*    occured on a read, format or write operation.  If it cannot    *
  1991. ;*    determine the nature of the error, the routine displays an    *
  1992. ;*    unknown disk error message.                    *
  1993. ;*                                    *
  1994. ;************************************************************************
  1995. ;
  1996. Public    D1200_Disk_IO_Error
  1997. ;
  1998. D1200_Disk_IO_Error Proc Near
  1999. ;
  2000. D1201:
  2001.     Cmp    Byte Ptr WRK14_Status_Operation,Time_Out_Error
  2002.     Jne    D1202            ; If not time out error, continue
  2003.     Mov    SI,Offset MES08_Drive_Not_Ready
  2004.     Mov    AL,Byte Ptr WRK06_Drive_Number
  2005.     Add    AL,Capital_Letter_A    ; Convert drive number to a letter
  2006.     Mov    [SI+Twenty_Four],AL    ; Put the drive letter into position
  2007.     Call    U1000_Display_Message
  2008.     Jmp    D1299            ; Go to the end of the module
  2009. D1202:
  2010.     Cmp    Byte Ptr FLG15_IO_Error,Zero
  2011.     Jne    D1203            ; If not a format error, continue
  2012.     Mov    SI,Offset MES18_Unrecoverable_Format
  2013.     Jmp    D1206            ; Continue processing
  2014. D1203:
  2015.     Cmp    Byte Ptr FLG15_IO_Error,One
  2016.     Jne    D1204            ; If not a read error, continue
  2017.     Mov    SI,Offset MES19_Unrecoverable_Read
  2018.     Jmp    D1206            ; Continue processing
  2019. D1204:
  2020.     Cmp    Byte Ptr FLG15_IO_Error,Two
  2021.     Jne    D1205            ; If not a write error, continue
  2022.     Mov    SI,Offset MES21_Unrecoverable_Write
  2023.     Jmp    D1206            ; Continue processing
  2024. D1205:
  2025.     Mov    SI,Offset MES22_Unrecoverable_IO
  2026. D1206:
  2027.     Call    U1000_Display_Message    ; Display the message on the screen
  2028. D1207:
  2029.     Cmp    Byte Ptr WRK14_Status_Operation,Seek_Error
  2030.     Jne    D1208            ; If not a seek error, continue
  2031.     Mov    SI,Offset MES80_Seek_Error
  2032.     Jmp    D1217            ; Continue processing
  2033. D1208:
  2034.     Cmp    Byte Ptr WRK14_Status_Operation,Controller_Error
  2035.     Jne    D1209            ; If not a controller error, continue
  2036.     Mov    SI,Offset MES81_Controller_Error
  2037.     Jmp    D1217            ; Continue processing
  2038. D1209:
  2039.     Cmp    Byte Ptr WRK14_Status_Operation,CRC_Error
  2040.     Jne    D1210            ; If not a CRC error, continue
  2041.     Mov    SI,Offset MES82_CRC_Error
  2042.     Jmp    D1217            ; Continue processing
  2043. D1210:
  2044.     Cmp    Byte Ptr WRK14_Status_Operation,DMA_Boundary_Error
  2045.     Jne    D1211            ; If not DMA boundary error, continue
  2046.     Mov    SI,Offset MES83_DMA_Boundary_Error
  2047.     Jmp    D1217            ; Continue processing
  2048. D1211:
  2049.     Cmp    Byte Ptr WRK14_Status_Operation,DMA_Error
  2050.     Jne    D1212            ; If not a DMA error, continue
  2051.     Mov    SI,Offset MES84_DMA_Error
  2052.     Jmp    D1217            ; Continue processing
  2053. D1212:
  2054.     Cmp    Byte Ptr WRK14_Status_Operation,Sector_Error
  2055.     Jne    D1213            ; If not a sector error, continue
  2056.     Mov    SI,Offset MES85_Sector_Error
  2057.     Jmp    D1217            ; Continue processing
  2058. D1213:
  2059.     Cmp    Byte Ptr WRK14_Status_Operation,Write_Protect_Error
  2060.     Jne    D1214            ; If not write protected, continue
  2061.     Mov    SI,Offset MES86_Write_Protect_Error
  2062.     Jmp    D1217            ; Continue processing
  2063. D1214:
  2064.     Cmp    Byte Ptr WRK14_Status_Operation,Address_Mark_Error
  2065.     Jne    D1215            ; If not addr mark error, continue
  2066.     Mov    SI,Offset MES87_Address_Mark_Error
  2067.     Jmp    D1217            ; Continue processing
  2068. D1215:
  2069.     Cmp    Byte Ptr WRK14_Status_Operation,Command_Error
  2070.     Jne    D1216            ; If not a command error, continue
  2071.     Mov    SI,Offset MES88_Command_Error
  2072.     Jmp    D1217            ; Continue processing
  2073. D1216:
  2074.     Mov    SI,Offset MES89_Unknown_Error
  2075. D1217:
  2076.     Call    U1000_Display_Message    ; Display the message on the screen
  2077. D1299:
  2078.     Ret
  2079. ;
  2080. D1200_Disk_IO_Error Endp
  2081. ;
  2082. Page
  2083. ;************************************************************************
  2084. ;*                                    *
  2085. ;*    S1000_SETUP_DISK_PARAM_TABLE                    *
  2086. ;*                                    *
  2087. ;*    This module sets up the Disk Parameter Table (Int 1EH) so that    *
  2088. ;*    it points to the disk parameters for PC DOS 2.1 contained in    *
  2089. ;*    this program.                            *
  2090. ;*                                    *
  2091. ;************************************************************************
  2092. ;
  2093. Public    S1000_Setup_Disk_Param_Table
  2094. ;
  2095. S1000_Setup_Disk_Param_Table Proc Near
  2096. ;
  2097. S1001:
  2098.     Push    AX            ; Save the registers
  2099.     Push    BX            ; .
  2100.     Push    DS            ; ..End
  2101. ;
  2102.     Cli                ; Turn off the interrupts
  2103.  
  2104. ;
  2105.     Sub    AX,AX            ; Initialize DS to Absolute Zero
  2106.     Mov    DS,AX            ; ..End
  2107. ;
  2108.     Mov    BX,Disk_Parameter_Addr    ; Save and redirect the address
  2109.     Mov    AX,[BX]            ; .
  2110.     Mov    Word Ptr CS:SYS16_Save_DPT_Offset,AX
  2111.     Mov    AX,[BX+Two]        ; .
  2112.     Mov    Word Ptr CS:SYS17_Save_DPT_Segment,AX
  2113.                     ; .
  2114.     Mov    AX,Offset SYS18_Disk_Parameter_Table
  2115.     Mov    [BX],AX            ; .
  2116.     Mov    AX,CS            ; .
  2117.     Mov    [BX+Two],AX        ; ..End
  2118. ;
  2119.     Sti                ; Turn on interrupts
  2120. ;
  2121.     Pop    DS            ; Restore the registers
  2122.     Pop    BX            ; .
  2123.     Pop    AX            ; ..End
  2124. S1099:
  2125.     Ret
  2126. ;
  2127. S1000_Setup_Disk_Param_Table Endp
  2128. ;
  2129. Page
  2130. ;************************************************************************
  2131. ;*                                    *
  2132. ;*    S1100_RESTORE_DISK_PARAM_TABLE                    *
  2133. ;*                                    *
  2134. ;*    This module restores the Disk Parameter Table to its original    *
  2135. ;*    address in PC DOS.                        *
  2136. ;*                                    *
  2137. ;************************************************************************
  2138. ;
  2139. Public    S1100_Restore_Disk_Param_Table
  2140. ;
  2141. S1100_Restore_Disk_Param_Table Proc Near
  2142. ;
  2143. S1101:
  2144.     Push    AX            ; Save the registers
  2145.     Push    BX            ; .
  2146.     Push    DS            ; ..End
  2147. ;
  2148.     Cli                ; Turn off the interrupts
  2149. ;
  2150.     Sub    AX,AX            ; Initialize DS to Absolute Zero
  2151.     Mov    DS,AX            ; ..End
  2152. ;
  2153.     Mov    BX,Disk_Parameter_Addr    ; Restore Disk Parameter Address
  2154.     Mov    AX,Word Ptr CS:SYS16_Save_DPT_Offset
  2155.     Mov    [BX],AX            ; .
  2156.     Mov    AX,Word Ptr CS:SYS17_Save_DPT_Segment
  2157.     Mov    [BX+Two],AX        ; ..End
  2158. ;
  2159.     Sti                ; Turn on the interrupts
  2160. ;
  2161.     Pop    DS            ; Restore the registers
  2162.     Pop    BX            ; .
  2163.     Pop    AX            ; ..End
  2164. S1199:
  2165.     Ret
  2166. ;
  2167. S1100_Restore_Disk_Param_Table Endp
  2168. ;
  2169. Page
  2170. ;************************************************************************
  2171. ;*                                    *
  2172. ;*    S1200_GET_VERSION_NUMBER                    *
  2173. ;*                                    *
  2174. ;*    This module gets the current version number of PC DOS and    *
  2175. ;*    stores the information in determining whether to allocate    *
  2176. ;*    memory using the PC DOS 2.0 function calls.            *
  2177. ;*                                    *
  2178. ;************************************************************************
  2179. ;
  2180. Public    S1200_Get_Version_Number
  2181. ;
  2182. S1200_Get_Version_Number Proc Near
  2183. ;
  2184. S1201:
  2185.     Push    AX            ; Save the registers and flags
  2186.     Pushf                ; ..End
  2187. ;
  2188.     Mov    AH,Get_DOS_Version_Number
  2189.     Int    PC_DOS_Interrupt
  2190.     Mov    Byte Ptr SYS19_Major_Vers_Number,AL
  2191.     Mov    Byte Ptr SYS20_Minor_Vers_Number,AH
  2192. ;
  2193.     Popf                ; Restore the registers and flags
  2194.     Pop    AX            ; ..End
  2195. S1299:
  2196.     Ret
  2197. ;
  2198. S1200_Get_Version_Number Endp
  2199. ;
  2200. Page
  2201. ;************************************************************************
  2202. ;*                                    *
  2203. ;*    U1000_DISPLAY_MESSAGE                        *
  2204. ;*                                    *
  2205. ;*    This module displays a message on the screen. Before calling    *
  2206. ;*    this module, the offset of the message should be in SI         *
  2207. ;*    relative to the DS register.  This routine preserves the    *
  2208. ;*    registers and the flags.                    *
  2209. ;*                                    *
  2210. ;************************************************************************
  2211. ;
  2212. Public    U1000_Display_Message
  2213. ;
  2214. U1000_Display_Message Proc Near
  2215. ;
  2216. U1001:
  2217.     Push    AX            ; Save the registers and flags
  2218.     Push    BX            ; .
  2219.     Push    SI            ; .
  2220.     Pushf                ; ..End
  2221. U1002:
  2222.     Mov    AL,[SI]            ; Put the character into AL
  2223.     Cmp    AL,EOT            ; Compare for the end of the string
  2224.     Je    U1090            ; If so, go to end of the module
  2225.     Mov    AH,Write_TTY_Command    ; Write the Character
  2226.     Mov    BH,Byte Ptr SYS03_Active_Page
  2227.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2228.     Int    Video_Interrupt        ; ..End
  2229.     Inc    SI            ; Increment the SI counter
  2230.     Jmp    U1002            ; Go back and try again
  2231. U1090:
  2232.     Popf                ; Restore the registers and flags
  2233.     Pop    SI            ; .
  2234.     Pop    BX            ; .
  2235.     Pop    AX            ; ..End
  2236. U1099:
  2237.     Ret
  2238. ;
  2239. U1000_Display_Message Endp
  2240. ;
  2241. Page
  2242. ;************************************************************************
  2243. ;*                                    *
  2244. ;*    U1100_GET_RESPONSE                        *
  2245. ;*                                    *
  2246. ;*    This module gets the response from the keyboard and displays    *
  2247. ;*    the information on the video display unit.  The keyboard    *
  2248. ;*    buffer is WRK05_Keyboard_Buffer.  The first byte of this    *
  2249. ;*    buffer contains the length of the buffer and must be less    *
  2250. ;*    than or equal to 80 characters.  The next 80 characters are    *
  2251. ;*    the acutal buffer. The character EOT denotes the end of the    *
  2252. ;*    buffer and can occur in any one of the 80 characters.        *
  2253. ;*                                    *
  2254. ;************************************************************************
  2255. ;
  2256. Public    U1100_Get_Response
  2257. ;
  2258. U1100_Get_Response Proc Near
  2259. ;
  2260. U1101:
  2261.     Push    AX            ; Save the registers and flags
  2262.     Push    BX            ; .
  2263.     Push    CX            ; .
  2264.     Push    SI            ; .
  2265.     Pushf                ; ..End
  2266. U1102:
  2267.     Mov    SI,Offset WRK05_Keyboard_Buffer+1
  2268.     Mov    CX,NUL            ; Initialize the CX counter register
  2269. U1103:
  2270.     Mov    AH,Flush_Keyboard_Command; Read the character from keyboard
  2271.     Mov    AL,Read_Keyboard_Command; .
  2272.     Int    PC_DOS_Interrupt    ; ..End
  2273.     Cmp    AL,ETX            ; Compare for a control break
  2274.     Jne    U1104            ; If not, then continue
  2275.     Mov    SI,Offset MES98_Control_Break
  2276.     Call    U1000_Display_Message    ; Display the message on the screen
  2277.     Jmp    A1002            ; Go to B1200_Final_Process
  2278. U1104:
  2279.     Cmp    Byte Ptr FLG05_Store_Buffer,True
  2280.     Je    U1105            ; If store keyboard entries, continue
  2281.     Jmp    U1190            ; If not, go to end of the module
  2282. U1105:
  2283.     Cmp    AL,BS            ; Is AL a backspace character???
  2284.     Jne    U1106            ; If not, continue processing AL
  2285.     Cmp    CX,NUL            ; Is the cursor at column zero????
  2286.     Je    U1103            ; Yes, so get another character
  2287.     Dec    CX            ; Decrement CX to point to the
  2288.                     ; . previous cursor location
  2289.     Dec    SI            ; Decrement SI to go back to the
  2290.                     ; . previos buffer location
  2291. ;
  2292.     Mov    AH,Write_TTY_Command    ; Write a backspace to the screen
  2293.     Mov    AL,BS            ; .
  2294.     Mov    BH,Byte Ptr SYS03_Active_Page
  2295.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2296.     Int    Video_Interrupt        ; ..End
  2297. ;
  2298.     Mov    AH,Write_TTY_Command    ; Write a space to the screen
  2299.     Mov    AL,Space        ; .
  2300.     Mov    BH,Byte Ptr SYS03_Active_Page
  2301.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2302.     Int    Video_Interrupt        ; ..End
  2303. ;
  2304.     Mov    AH,Write_TTY_Command    ; Write a backspace to the screen
  2305.     Mov    AL,BS            ; .
  2306.     Mov    BH,Byte Ptr SYS03_Active_Page
  2307.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2308.     Int    Video_Interrupt        ; ..End
  2309. ;
  2310.     Jmp    U1103            ; Go back and get another character
  2311. U1106:
  2312.     Cmp    AL,CR            ; Compare char for a carriage return
  2313.     Je    U1108            ; If so, insert an EOT into buffer
  2314.     Cmp    CX,Keyboard_Buffer_Size    ; Check for keyboard buffer full
  2315.     Jae    U1107            ; If so, sound bell and get new char
  2316.     Mov    [SI],AL            ; Put the character into the buffer
  2317.     Inc    SI            ; Increment the keyboard address
  2318.     Inc    CX            ; Increment the CX character counter
  2319.     Jmp    U1103            ; Go back and get another character
  2320. U1107:
  2321.     Mov    AH,Write_TTY_Command    ; Sound the beep from the screen
  2322.     Mov    AL,Bell            ; .
  2323.     Mov    BH,Byte Ptr SYS03_Active_Page
  2324.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2325.     Int    Video_Interrupt        ; ..End
  2326.     Jmp    U1103            ; Go back and get another character
  2327. U1108:
  2328.     Mov    AL,EOT            ; Put an EOT into the buffer
  2329.     Mov    [SI],AL            ; ..End
  2330. ;
  2331.     Mov    AH,Write_TTY_Command    ; Write a carriage return to the
  2332.     Mov    AL,CR            ; . screen
  2333.     Mov    BH,Byte Ptr SYS03_Active_Page
  2334.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2335.     Int    Video_Interrupt        ; ..End
  2336. ;
  2337.     Mov    AH,Write_TTY_Command    ; Write a line feed to the screen
  2338.     Mov    AL,LF            ; .
  2339.     Mov    BH,Byte Ptr SYS03_Active_Page
  2340.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2341.     Int    Video_Interrupt        ; ..End
  2342. ;
  2343.     Mov    WRK05_Keyboard_Buffer[0],CL; Set the length accrodingly
  2344. U1190:
  2345.     Popf                ; Restore the registers and flags
  2346.     Pop    SI            ; .
  2347.     Pop    CX            ; .
  2348.     Pop    BX            ; .
  2349.     Pop    AX            ; ..End
  2350. U1199:
  2351.     Ret
  2352. U1100_Get_Response Endp
  2353. ;
  2354. Page
  2355. ;************************************************************************
  2356. ;*                                    *
  2357. ;*    U1200_GET_YES_OR_NO                        *
  2358. ;*                                    *
  2359. ;*    This module asks for a [Yy]es or [Nn]o answer from a user.  The    *
  2360. ;*    routine accepts only a [Yy] or [Nn] and exists with the flag    *
  2361. ;*    FLG06_Yes_or_No set to True for YES and False for NO.        *
  2362. ;*                                    *
  2363. ;************************************************************************
  2364. ;
  2365. Public    U1200_Get_Yes_or_No
  2366. ;
  2367. U1200_Get_Yes_or_No Proc Near
  2368. ;
  2369. U1201:
  2370.     Push    AX            ; Save the registers and flags
  2371.     Push    SI            ; .
  2372.     Pushf                ; ..End
  2373. U1202:
  2374.     Mov    AH,Flush_Keyboard_Command; Read the character from keyboard
  2375.     Mov    AL,Read_Keyboard_Command; .
  2376.     Int    PC_DOS_Interrupt    ; ..End
  2377.     Cmp    AL,ETX            ; Compare for control break
  2378.     Jne    U1203            ; If not, then continue
  2379.     Mov    SI,Offset MES98_Control_Break
  2380.     Call    U1000_Display_Message    ; Display the message on the screen
  2381.     Jmp    A1002            ; Go to B1200_Final_Process
  2382. U1203:
  2383.     Cmp    AL,Capital_Letter_Y    ; Check for capital letter Y
  2384.     Jne    U1204            ; ..End
  2385.     Mov    Byte Ptr FLG06_Yes_or_No,True
  2386.     Mov    SI,Offset MES24_Yes    ; Display YES on the screen
  2387.     Call    U1000_Display_Message    ; ..End
  2388.     Jmp    U1290            ; Go to the end of the module
  2389. U1204:
  2390.     Cmp    AL,Small_Letter_y    ; Check for small letter y
  2391.     Jne    U1205            ; ..End
  2392.     Mov    Byte Ptr FLG06_Yes_or_No,True
  2393.     Mov    SI,Offset MES24_Yes    ; Display YES on the screen
  2394.     Call    U1000_Display_Message    ; ..End
  2395.     Jmp    U1290            ; Go to the end of the module
  2396. U1205:
  2397.     Cmp    AL,Capital_Letter_N    ; Check for capital letter N
  2398.     Jne    U1206            ; ..End
  2399.     Mov    Byte Ptr FLG06_Yes_or_No,False
  2400.     Mov    SI,Offset MES25_No    ; Display NO on the screen
  2401.     Call    U1000_Display_Message    ; ..End
  2402.     Jmp    U1290            ; Go to the end of the module
  2403. U1206:
  2404.     Cmp    AL,Small_Letter_n    ; Check for small letter n
  2405.     Jne    U1207            ; ..End
  2406.     Mov    Byte Ptr FLG06_Yes_or_No,False
  2407.     Mov    SI,Offset MES25_No    ; Display NO on the screen
  2408.     Call    U1000_Display_Message    ; ..End
  2409.     Jmp    U1290            ; Go to the end of the module
  2410. U1207:
  2411.     Jmp    U1202            ; Go back and get another character
  2412. U1290:
  2413.     Popf                ; Restore the registers and flags
  2414.     Pop    SI            ; .
  2415.     Pop    AX            ; ..End
  2416. U1299:
  2417.     Ret
  2418. ;
  2419. U1200_Get_Yes_or_No Endp
  2420. ;
  2421. Page
  2422. ;************************************************************************
  2423. ;*                                    *
  2424. ;*    U1300_CONVERT_BINARY_TO_ASCII                    *
  2425. ;*                                    *
  2426. ;*    This module BCD contained in the AL register into an ASCII    *
  2427. ;*    character.  The output is returned in the AX register.        *
  2428. ;*                                    *
  2429. ;************************************************************************
  2430. ;
  2431. Public    U1300_Convert_Binary_to_ASCII
  2432. ;
  2433. U1300_Convert_Binary_to_ASCII Proc Near
  2434. ;
  2435. U1301:
  2436.     Push    DX            ; Save the registers
  2437.     Pushf                ; ..End
  2438. ;
  2439.     Cbw                ; Perform sign extension for division
  2440.     Mov    DL,Ten            ; Set DL disvisor to 10D
  2441.     Div    DL            ; Divide AL by 10D remainder in AH
  2442.     Add    AL,Zero_Digit        ; Setup the characters in AL & AH
  2443.     Add    AH,Zero_Digit        ; ..End
  2444. ;
  2445.     Popf                ; Restore the registers
  2446.     Pop    DX            ; ..End
  2447. U1399:
  2448.     Ret
  2449. ;
  2450. U1300_Convert_Binary_to_ASCII Endp
  2451. ;
  2452. Page
  2453. ;************************************************************************
  2454. ;*                                    *
  2455. ;*    U1400_DISPLAY_HEAD_AND_TRACK                    *
  2456. ;*                                    *
  2457. ;*    This module displays the current track and head number that    *
  2458. ;*    is being read from the source diskette or written to the     *
  2459. ;*    target diskette.                        *
  2460. ;*                                    *
  2461. ;************************************************************************
  2462. ;
  2463. Public    U1400_Display_Head_and_Track
  2464. ;
  2465. U1400_Display_Head_and_Track Proc Near
  2466. ;
  2467. U1401:
  2468.     Push    AX            ; Save the registers
  2469.     Push    BX            ; .
  2470.     Push    DX            ; .
  2471.     Pushf                ; ..End
  2472. ;
  2473.     Mov    AH,Set_CPos_Command    ; Set cursor to track position
  2474.     Mov    BH,Byte Ptr SYS03_Active_Page
  2475.     Mov    DH,Byte Ptr WRK28_Current_Message_Row
  2476.     Mov    DL,Fifteen        ; .
  2477.     Int    Video_Interrupt        ; ..End
  2478. ;
  2479.                     ; Write the current track number
  2480.     Mov    AL,Byte Ptr WRK30_Current_Track
  2481.     Call    U1300_Convert_Binary_to_ASCII
  2482.     Push    AX            ; .
  2483.     Mov    AH,Write_TTY_Command    ; .
  2484.     Mov    BH,Byte Ptr SYS03_Active_Page
  2485.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2486.     Int    Video_Interrupt        ; .
  2487.     Pop    AX            ; .
  2488.     Mov    AL,AH            ; .
  2489.     Mov    AH,Write_TTY_Command    ; .
  2490.     Mov    BH,Byte Ptr SYS03_Active_Page
  2491.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2492.     Int    Video_Interrupt        ; ..End
  2493. ;
  2494.     Mov    AH,Set_CPos_Command    ; Set cursor to head position
  2495.     Mov    BH,Byte Ptr SYS03_Active_Page
  2496.     Mov    DH,Byte Ptr WRK28_Current_Message_Row
  2497.     Mov    DL,Twenty_Five        ; .
  2498.     Int    Video_Interrupt        ; ..End
  2499. ;                    ; Write the current head number
  2500.     Mov    AL,Byte Ptr WRK29_Current_Head
  2501.     Call    U1300_Convert_Binary_to_ASCII
  2502.     Mov    AL,AH            ;.
  2503.     Mov    AH,Write_TTY_Command    ;.
  2504.     Mov    BH,Byte Ptr SYS03_Active_Page
  2505.     Mov    BL,Byte Ptr SYS04_Foreground_Color
  2506.     Int    Video_Interrupt        ; ..End
  2507. ;
  2508.     Mov    AH,Set_CPos_Command    ; Set cursor to the next line
  2509.     Mov    BH,Byte Ptr SYS03_Active_Page
  2510.     Mov    DH,Byte Ptr WRK28_Current_Message_Row
  2511.     Inc    DH            ; .
  2512.     Mov    DL,Zero            ; .
  2513.     Int    Video_Interrupt        ; ..End
  2514. U1490:
  2515.     Popf                ; Restore the registers
  2516.     Pop    DX            ; 
  2517.     Pop    BX            ; .
  2518.     Pop    AX            ; ..End
  2519. U1499:
  2520.     Ret
  2521. ;
  2522. U1400_Display_Head_and_Track Endp
  2523. ;
  2524. Page
  2525. ;************************************************************************
  2526. ;*                                    *
  2527. ;*    FLAGS                                *
  2528. ;*                                    *
  2529. ;*    This portion of FREECOPY contains the definitions of all of    *
  2530. ;*    flags defined in the program.                    *
  2531. ;*                                    *
  2532. ;************************************************************************
  2533. ;
  2534. FLG01_Good_Command    DB (?)        ; Establishes any errors in the
  2535.                     ; . command line entered by a user
  2536. FLG02_Double_Side    DB (?)        ; Points out whether the user wants
  2537.                     ; . to copy only the top side of a
  2538.                     ; . floppy diskette
  2539. FLG03_Default_Drive    DB (?)        ; Shows if the default drive is a
  2540.                     ; . valid floppy disk drive
  2541. FLG04_Single_Drive    DB (?)        ; Determines if the machine is a
  2542.                     ; . single drive system
  2543. FLG05_Store_Buffer    DB (?)        ; Establishes whether to put the
  2544.                     ; . characters entered from the
  2545.                     ; . keyboard into the buffer
  2546. FLG06_Yes_or_No        DB (?)        ; Points out the user's response
  2547.                     ; . NO = False   YES = True
  2548. FLG07_First_Time    DB (?)        ; Shows the number of times the user
  2549.                     ; . copies a diskette
  2550.                     ; . ONCE = True  MORE = False
  2551. FLG08_Good_Read        DB (?)        ; Flags establish whether the
  2552. FLG09_Good_Write    DB (?)        ; . operation was performed correctly
  2553. FLG10_Good_Verify      DB (?)        ; . YES = True    NO = False
  2554. FLG11_Good_Format    DB (?)        ; ..End
  2555. FLG12_Good_FAT        DB (?)        ; Establishes a good FAT when reading
  2556.                     ; . source diskette more than once
  2557. FLG13_First_Read_Write    DB (?)        ; Shows if a diskette is being read
  2558.                     ; . or written for the first time
  2559.                     ; . YES = True    NO  = False
  2560. FLG14_Copy_Complete    DB (?)        ; Points out if a diskette has been
  2561.                     ; . copied completely
  2562.                     ; . YES = True    NO = False
  2563. FLG15_IO_Error        DB (?)        ; Establishes the type of IO error
  2564.                     ; . Zero = Format error
  2565.                     ; . One  = Read error
  2566.                     ; . Two  = Write error
  2567.                     ; ..End
  2568. FLG16_Free_Memory    DB (?)        ; Determines whether memory should
  2569.                     ; . using the PC DOS function calls
  2570. FLG17_Copy_More_Disks    DB (?)        ; Indicates whether to ask a user to
  2571.                     ; . write the same disk over again
  2572. ;
  2573. Page
  2574. ;************************************************************************
  2575. ;*                                    *
  2576. ;*    MESSAGES                            *
  2577. ;*                                    *
  2578. ;*    This portion of FREECOPY contains the definitions of all of    *
  2579. ;*    messages defined in the program.                *
  2580. ;*                                    *
  2581. ;************************************************************************
  2582. ;
  2583. MES00_Copy_Notice        Label Byte
  2584.     DB    CR,LF
  2585.     DB    'FREECOPY Disk Utility',CR,LF
  2586.     DB    'IBM Personal Computer/Jr.',CR,LF
  2587.     DB    'Version 1.13 (C)Copyright 1984, 1985',CR,LF
  2588.     DB    CR,LF
  2589.     DB    'Squire Buresh Assoc., Inc.',CR,LF
  2590.     DB    'Post Office Box 112',CR,LF
  2591.     DB    'Millbury, MA 01527',CR,LF
  2592.     DB    CR,LF
  2593.     DB    '$25.00 requested contribution.',CR,LF,EOT
  2594. MES01A_Write_Another_Diskette    Label Byte
  2595.     DB    CR,LF
  2596.     DB    'Write source diskette again (Y/N)? ',EOT
  2597. MES01B_Copy_Another_diskette    Label Byte
  2598.     DB    CR,LF
  2599.     DB    'Copy another diskette (Y/N)? ',EOT
  2600. MES02_Copy_Complete        Label Byte
  2601.     DB    CR,LF
  2602.     DB    'Copy complete.',CR,LF,EOT
  2603. MES03_Copy81_Sectors        Label Byte
  2604.     DB    CR,LF
  2605.     DB    'Copying 8 sectors per track, 1 side.',CR,LF,EOT
  2606. MES04_Copy82_Sectors        Label Byte
  2607.     DB    CR,LF
  2608.     DB    'Copying 8 sectors per track, 2 sides.',CR,LF,EOT
  2609. MES05_Copy91_Sectors        Label Byte
  2610.     DB    CR,LF
  2611.     DB    'Copying 9 sectors per track, 1 side.',CR,LF,EOT
  2612. MES06_Copy92_Sectors        Label Byte
  2613.     DB    CR,LF
  2614.     DB    'Copying 9 sectors per track, 2 sides.',CR,LF,EOT
  2615. MES07_Correct_And_Press_Key    Label Byte
  2616.     DB    CR,LF
  2617.     DB    'Correct, and press any key to continue',CR,LF,EOT
  2618. MES08_Drive_Not_Ready        Label Byte
  2619.     DB    CR,LF
  2620.     DB    'Diskette not in drive  :.',CR,LF,EOT
  2621. MES09_Insert_Source        Label Byte
  2622.     DB    CR,LF
  2623.     DB    'Insert source diskette in drive  :.',CR,LF,EOT
  2624. MES10_Insert_Target        Label Byte
  2625.     DB    CR,LF
  2626.     DB    'Insert target diskette in drive  :.',CR,LF,EOT
  2627. MES11_Insufficient_Memory    Label Byte
  2628.     DB    CR,LF
  2629.     DB    'Insufficient memory.',Bell,CR,LF,EOT
  2630. MES12_Invalid_Parameter        Label Byte
  2631.     DB    CR,LF
  2632.     DB    'Invalid parameter(s) specified.',CR,LF,EOT
  2633. MES13_Invalid_Default        Label Byte
  2634.     DB    CR,LF
  2635.     DB    'Invalid default floppy disk drive',CR,LF,EOT
  2636. MES14_Invalid_Drive        Label Byte
  2637.     DB    CR,LF
  2638.     DB    'Invalid drive specification.',CR,LF,EOT
  2639. MES15_Single_Drive_Copy        Label Byte
  2640.     DB    CR,LF
  2641.     DB    'NOTE: Copying diskette on single drive.',Bell,CR,LF,EOT
  2642. MES16_Press_Any_Key        Label Byte
  2643.     DB    CR,LF
  2644.     DB    'Press any key when ready.',CR,LF,EOT
  2645. MES17_Reading_Track        Label Byte
  2646.     DB    'Reading track (  ) head ( ).',CR,LF,EOT
  2647. MES18_Unrecoverable_Format    Label Byte
  2648.     DB    CR,LF
  2649.     DB    'Unrecoverable format error on target.',CR,LF,EOT
  2650. MES19_Unrecoverable_Read    Label Byte
  2651.     DB    CR,LF
  2652.     DB    'Unrecoverable read error on source.',CR,LF,EOT
  2653. MES20_Unrecoverable_Verify    Label Byte
  2654.     DB    CR,LF
  2655.     DB    'Unrecoverable verify error on target.',CR,LF,EOT
  2656. MES21_Unrecoverable_Write    Label Byte
  2657.     DB    CR,LF
  2658.     DB    'Unrecoverable write error on target.',CR,LF,EOT
  2659. MES22_Unrecoverable_IO        Label Byte
  2660.     DB    CR,LF
  2661.     DB    'Unrecoverable IO error.',CR,LF,EOT
  2662. MES23_Writing_Track        Label Byte
  2663.     DB    'Writing track (  ) head ( ).',CR,LF,EOT
  2664. MES24_Yes            Label Byte
  2665.     DB    'YES',CR,LF,EOT
  2666. MES25_No            Label Byte
  2667.     DB    'NO',CR,LF,EOT
  2668. MES80_Seek_Error        Label Byte
  2669.     DB    'Seek operation has failed.',CR,LF,EOT
  2670. MES81_Controller_Error        Label Byte
  2671.     DB    'Disk controller has failed.',CR,LF,EOT
  2672. MES82_CRC_Error            Label Byte
  2673.     DB    'Cyclic redundancy check (CRC) error.',CR,LF,EOT
  2674. MES83_DMA_Boundary_Error    Label Byte
  2675.     DB    'Attempted to DMA across a 64K boundary.',CR,LF,EOT
  2676. MES84_DMA_Error            Label Byte
  2677.     DB    'DMA overrun on I/O operation.',CR,LF,EOT
  2678. MES85_Sector_Error        Label Byte
  2679.     DB    'Requested sector not found.',CR,LF,EOT
  2680. MES86_Write_Protect_Error    Label Byte
  2681.     DB    'Output diskette is write protected.',CR,LF,EOT
  2682. MES87_Address_Mark_Error    Label Byte
  2683.     DB    'Address mark was not found.',CR,LF,EOT
  2684. MES88_Command_Error        Label Byte
  2685.     DB    'Bad command passed to the disk interrupt 13H.',CR,LF,EOT
  2686. MES89_Unknown_Error        Label Byte
  2687.     DB    'Unknown diskette error encountered.',CR,LF,EOT
  2688. MES90_Unknown_FAT_Error        Label Byte
  2689.     DB    'First byte of the FAT does not',CR,LF
  2690.     DB    'match any known diskette type.',CR,LF,EOT
  2691. MES91_Single_Side_Error        Label byte
  2692.     DB    'Double sided diskette in a',CR,LF
  2693.     DB    'single sided disk drive.',CR,LF,EOT
  2694. MES97_Return_Linefeed        Label Byte
  2695.     DB    CR,LF,EOT
  2696. MES98_Control_Break        Label Byte
  2697.     DB    '^C',CR,LF,EOT
  2698. MES99_Memory_Block_Destroyed    Label Byte
  2699.     DB    'Memory control block destroyed.',CR,LF,EOT
  2700. MES100_Freecopy_Finished    Label Byte
  2701.     DB    CR,LF
  2702.     DB    'Returning to PC DOS.',CR,LF,EOT
  2703. ;
  2704. Page
  2705. ;************************************************************************
  2706. ;*                                    *
  2707. ;*    WORK VARIABLES                            *
  2708. ;*                                    *
  2709. ;*    This portion of FREECOPY contains the definitions of the work    *
  2710. ;*    variables that are used by the program.                *
  2711. ;*                                    *
  2712. ;************************************************************************
  2713. ;
  2714. WRK01_Source_Drive        DB (?)    ; Source diskette drive number
  2715. WRK02_Target_Drive        DB (?)    ; Target diskette drive number
  2716. WRK03_Valid_Filename        DB 11 Dup (32D); Valid diskette file name
  2717. WRK04_Parameter_Count        DB (?)    ; Valid diskette filler area
  2718. ;
  2719. WRK05_Keyboard_Buffer        Label Byte
  2720.                 DB 80D    ; Length of the keyboard buffer
  2721.                 DB 80 Dup (?); Actual keyboard buffer
  2722.                 DB EOT    ; Last char denotes the end of text
  2723. ;
  2724. WRK06_Drive_Number        DB (?)    ; Drive number of a disk drive
  2725. WRK07_Head_Number        DB (?)    ; Head number of a disk drive
  2726. WRK08_Track_Number        DB (?)    ; Track number of a diskette
  2727. WRK09_Sector_Number        DB (?)    ; Sector number of a diskette
  2728. WRK10_Number_of_Sectors        DB (?)    ; Number of sectors on a track
  2729. WRK11_Segment_Address        DW (?)    ; ES segment address
  2730. WRK12_Offset_Address        DW (?)    ; BX offset address
  2731. WRK13_Retry_Counter        DB (?)    ; Number of retrys to make
  2732. WRK14_Status_Operation        DB (?)    ; Result of the operation
  2733. ;
  2734. WRK15_Maximum_Heads        DB (?)    ; Maximum heads, tracks and sectors
  2735. WRK16_Maximum_Tracks        DB (?)    ; .
  2736. WRK17_Maximum_Sectors        DB (?)    ; ..End
  2737. ;
  2738. WRK18_Counter_ESBX_Entries    DW (?)    ; Counter to calculate ES:BX entries
  2739. WRK19_Number_ESBX_Entries    DW (?)    ; Maximum ES:BX table entires
  2740. ;
  2741. Page
  2742. ;************************************************************************
  2743. ;*                                    *
  2744. ;*    WORK VARIABLES    Page 2                        *
  2745. ;*                                    *
  2746. ;************************************************************************
  2747. ;
  2748. WRK20_Current_Source_Head    DB (?)    ; Current source head & track number
  2749. WRK21_Current_Source_Track    DB (?)    ; ..End
  2750. WRK22_Current_Target_Head    DB (?)    ; Current target head & track number
  2751. WRK23_Current_Target_Track    DB (?)    ; . End
  2752. ;
  2753. WRK24_Read_Message_Row        DB (?)    ; Cursor row of read, verify, format
  2754. WRK25_Verify_Message_Row    DB (?)    ; and write message
  2755. WRK26_Format_Message_Row    DB (?)    ; .
  2756. WRK27_Write_Message_Row        DB (?)    ; .
  2757. WRK28_Current_Message_Row    DB (?)    ; ..End
  2758. ;
  2759. WRK29_Current_Head        DB (?)    ; Current head and track to display
  2760. WRK30_Current_Track        DB (?)    ; . on the screen
  2761. ;
  2762. WRK31_Track_Read_Counter        DB (?)    ; Counter of tracks processed
  2763. WRK32_Track_Write_Counter       DB (?)  ; ..End
  2764. ;
  2765. WRK33_CHRN_Table_Address    DW (?)    ; Current address of the CHRN table
  2766. ;
  2767. WRK34_DMA_Overflow_Counter    DW (?)    ; Counts how many times FREECOPY
  2768.                     ; . adjusted for DMA overflow
  2769. ;
  2770. Page
  2771. ;************************************************************************
  2772. ;*                                    *
  2773. ;*    SYSTEM VARIABLES                        *
  2774. ;*                                    *
  2775. ;*    This portion of FREECOPY contains the definitions of all of    *
  2776. ;*    the system variables used by the program.            *
  2777. ;*                                    *
  2778. ;************************************************************************
  2779. ;
  2780. SYS01_Number_Columns    DB (?)        ; Number of columns in current mode
  2781. SYS02_Current_Mode    DB (?)        ; Current video mode
  2782. SYS03_Active_Page    DB (?)        ; Active display page
  2783. SYS04_Foreground_Color    DB (?)        ; Foreground color number
  2784. SYS05_Para_RAM_Size    DW (?)        ; Number of free 16 byte paragraphs
  2785. SYS06_Monitor_Flag    DB (?)        ; 0 = monochrome  1 = graphics
  2786. SYS07_No_Parallel_Ports    DB (?)        ; Number of parallel ports
  2787. SYS08_Game_Adapters    DB (?)        ; Number of RS-232 ports
  2788. SYS09_No_RS232_Ports    DB (?)        ; 0 = no adapter  1 = has adapter
  2789. SYS10_No_Disk_Drives    DB (?)        ; Number of floppy disk drives
  2790. SYS11_Init_Video_Mode    DB (?)        ; Initial video mode when powering
  2791.                     ; up the machine
  2792. SYS12_Planar_RAM_Size    DB (?)        ; Planar RAM size
  2793. SYS13_IPL_From_Diskette    DB (?)        ; Location of initial program load
  2794. SYS14_Default_Drive    DB (?)        ; Default disk drive
  2795. ;
  2796. SYS15_Stack_Pointer    DW (?)        ; Stack pointer value when entering
  2797.                     ; . FREECOPY from PC DOS
  2798. SYS16_Save_DPT_Offset    DW (?)        ; Address of Disk Parameter Table
  2799. SYS17_Save_DPT_Segment    DW (?)        ; ..End
  2800. ;
  2801. SYS18_Disk_Parameter_Table    Label Byte
  2802.             DB 11011111B    ; SRT = 0D & Head Unload = 0FH
  2803.             DB 002H        ; Head Load = 1 Mode = DMA
  2804.             DB 025H        ; Wait to turn the motor off
  2805.             DB 002H        ; 512 bytes per sector
  2806.             DB 009H        ; 9 sectors per track
  2807.             DB 02AH        ; PC DOS gap length for I/O
  2808.             DB 0FFH        ; Data length parameter
  2809.             DB 050H        ; PC DOS gap length for format
  2810.             DB 0F6H        ; Fille byte for format
  2811.             DB 00FH        ; Head Settle time in milliseconds
  2812.             DB 002H        ; Motor start-up time (1/8 sec.)
  2813. ;
  2814. SYS19_Major_Vers_Number DB (?)        ; Major and minor version number
  2815. SYS20_Minor_Vers_Number DB (?)        ; . of the operating system
  2816. ;
  2817. SYS21_Alloc_Segment    DW (?)        ; Beginning segment address of
  2818.                     ; . free memory
  2819. ;
  2820. Page
  2821. ;************************************************************************
  2822. ;*                                    *
  2823. ;*    SETUP STACK POINTER AND MEMORY                    *
  2824. ;*                                    *
  2825. ;*    This portion of FREECOPY is contains the stack and the label    *
  2826. ;*    that indicates the beginning of available memory.        *
  2827. ;*                                    *
  2828. ;************************************************************************
  2829. ;
  2830. MEM05_Bottom_of_the_Stack    Label Word
  2831.             DW 64 Dup (?)
  2832. MEM04_Top_of_the_Stack        Label Word
  2833. ;
  2834. MEM03_ESBX_Table        Equ MEM04_Top_of_the_Stack+2
  2835. ;
  2836. MEM02_CHRN_Table        Equ MEM03_ESBX_Table+320
  2837. ;
  2838. MEM01_File_Allocation_Table    Equ MEM02_CHRN_Table+2880
  2839. ;
  2840. MEM00_Bottom_Free_Memory    Equ MEM01_File_Allocation_Table+512
  2841. ;
  2842. Page
  2843. ;************************************************************************
  2844. ;*                                    *
  2845. ;*    END OF THE PROGRAM                        *
  2846. ;*                                    *
  2847. ;************************************************************************
  2848. ;
  2849. CSEG    Ends
  2850.     End   A1000_Main_Module
  2851.  
  2852.  
  2853.