home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / latrobe / b / biodif.arc / RX50DRVP.DIF < prev    next >
Text File  |  1987-06-20  |  26KB  |  1,053 lines

  1.  
  2. ----------rx50drvp.old
  3.     TITLE    'Z80 IF AND PRIM ROUTINES  --  PRIVATE VERSION'
  4. ;
  5.  
  6. ----------rx50drvp.azm
  7.     TITLE    'Z80 INTERFACE AND PRIMITIVE RTNS  --  PRIVATE VERS'
  8. ;
  9.  
  10. -----------------------------------------------
  11.  
  12. ----------rx50drvp.old
  13. ;*                                    *
  14. ;************************************************************************
  15.  
  16. ----------rx50drvp.azm
  17. ;*        By Richard Thomsen                    *
  18. ;*                                    *
  19. ;*    Updated on 13 September 1986 to use double-sided disks.        *
  20. ;*        By Richard Thomsen                    *
  21. ;*                                    *
  22. ;************************************************************************
  23.  
  24. -----------------------------------------------
  25.  
  26. ----------rx50drvp.old
  27. TEAC    EQU    FALSE        ;Teac single/double sided half heights
  28. ;
  29.  
  30. ----------rx50drvp.azm
  31. ;DSIDE    EQU    FALSE        ;Single/double sided half heights
  32. DSIDE    EQU    TRUE        ;Single/double sided half heights
  33. ;
  34.  
  35. -----------------------------------------------
  36.  
  37. ----------rx50drvp.old
  38. Rains        equ    0    ;Rainbow (single sided) media 96 tpi
  39. Robin        equ    2    ;Robin media
  40. IBM9        equ    4    ;IBM 9 sector media
  41. Raind        equ    6    ;Rainbow (double sided) media 96 tpi
  42. IBM8        equ    8    ;IBM 8 sector media
  43. Mongrel        equ    0AH    ;Some media other than what we are used to
  44. Unknown        equ    0FFH    ;Unknown media
  45.  
  46. ----------rx50drvp.azm
  47. Rainb        equ    0    ;Rainbow media 96 tpi
  48. Robin        equ    2    ;Robin media
  49. IBM9        equ    4    ;IBM 9 sector media
  50. IBM8        equ    8    ;IBM 8 sector media
  51. Mongrel        equ    0AH    ;Some media other than what we are used to
  52. DBSIDE        equ    10H    ;Double sided media flag
  53. Unknown        equ    0FFH    ;Unknown media
  54.  
  55. -----------------------------------------------
  56.  
  57. ----------rx50drvp.old
  58. Tg43        equ    2    ;Track greater than 43 bit
  59.  
  60. ----------rx50drvp.azm
  61. DRV_BITS_MASK    EQU    3    ;Drive bit mask
  62. Tg43        equ    2    ;Track greater than 43 bit
  63.  
  64. -----------------------------------------------
  65.  
  66. ----------rx50drvp.old
  67. ;
  68. STORE    macro    #reg        ;Load ?address+e reg with value in ?reg
  69.     push    hl        ;Save reg HL
  70.     push    de        ;Save reg DE
  71.     push    iy
  72.     pop    hl
  73.     push    af
  74.     ld    a,l
  75.     sub    12        ;Point to track table
  76.     ld    l,a
  77. ;
  78.    if .not.teac
  79.     ld    a,e        ;Move into accumulator
  80.     and    2        ;Mask so a = 0 or 2
  81.     ld    e,a        ;Return status
  82.    endif
  83. ;
  84.     pop    af
  85.     ld    d,0
  86.     add    hl,de        ;Point to offset in memory
  87.     pop    de
  88.     ld    (hl),#reg    ;Load contents of reg HL with contents
  89.                 ;of ?reg
  90.     pop    hl
  91.     endm            ;End of macro
  92. ;
  93. LOAD    macro    #reg        ;Load reg with value in ?reg
  94.                 ;offset oof iy (-12 an -11)
  95.     push    hl
  96.     push    de
  97.     push    iy
  98.     pop    hl
  99.     push    af
  100.     ld    a,l
  101.     sub    12        ;Point to track table
  102.     ld    l,a
  103. ;
  104.    if .not.teac
  105.     ld    a,e        ;Move into accumulator
  106.     and    2        ;Mask so reg A = 0 or 2
  107.     ld    e,a        ;Return status
  108.    endif
  109. ;
  110.     pop    af
  111.     ld    d,0        ;Clear reg D
  112.     add    hl,de        ;Point to offset in memory
  113.     pop    de
  114.     ld    #reg,(hl)    ;Load contents of reg HL with contents
  115.                 ;of ?reg
  116.     pop    hl
  117.     endm            ;End of macro
  118. ;
  119.  
  120. ----------rx50drvp.azm
  121. ;
  122.  
  123. -----------------------------------------------
  124.  
  125. ----------rx50drvp.old
  126. ;
  127. ;************************************************************************
  128. ;
  129. ;   NAME:    PKTPRO
  130. ;
  131. ;   FUNCTION:    This routine is passed a packet address in Z80PKT.  It uses
  132. ;        that to get the function number which it uses to jump
  133. ;        to the specific function handler routine.
  134. ;
  135. ;        This routine is entered with an interrupt from the 8088 at
  136. ;        RST 6 - therefore, interrupts are off
  137. ;
  138. ;        For all functions except Z80START and serial support from
  139. ;        8088, we will interrupt the 8088 to indicate we have finished
  140. ;        the function.
  141. ;
  142. ;   ENTRY:    Z80PKT = packet address
  143. ;
  144. ;   EXIT:    IX = packet address
  145. ;
  146. PKTPRO:
  147.   IF SHARE
  148.     PUSH    IX        ;Save
  149.     PUSH    AF
  150.     PUSH    IY        ;Save remaining registers
  151.     PUSH    HL
  152.     LD    IY,INTFPTR
  153.    ENDIF
  154.     LD    L,(IY)        ;Get address of packet
  155.     LD    H,(IY+1)
  156.     PUSH    HL        ;Move address of packet into IX
  157.     POP    IX
  158.     XOR    A
  159.     LD    (IY),A        ;Sero address of packet to indicate to
  160.     LD    (IY+1),A    ;8088 that function has started
  161. ;    LD    (IY),0        ;Zero address of packet to indicate to
  162. ;    LD    (IY+1),0    ;8088 that function has started
  163. ;
  164.     IN    A,(I88INT)    ;Clear 8088 interrup flag
  165. ;
  166. ;    PUSH    IX        ;Check for Zero address
  167. ;    POP    HL        ;Move IX into H
  168.     LD    A,H        ;Put in accumulator
  169.     OR    L        ;Or in lower byte
  170.     JR    Z,HIFXIT
  171. ;    JP    Z,HIFXIT    ;Go away if zero
  172. ;
  173.    IF SHARE
  174.     PUSH    DE
  175.     PUSH    BC
  176.    ENDIF
  177. ;
  178.     LD    BC,PKTRET    ;Push return address onto stack
  179.     PUSH    BC
  180. ;
  181.     EI            ;Re-enable interrupts
  182. ;
  183.     LD    A,(IX+Function)    ;Get function code
  184. ;
  185.     CP    _Read_sector    ;Read function 13
  186.     JP    Z,_R$ead_function
  187. ;
  188.     CP    _Right_sector    ;Write function 14
  189.     JP    Z,_W$rite_function
  190. ;
  191.     CP    _Media_check    ;Media check function 15
  192.     JP    Z,_M$edia_check_function
  193. ;
  194.     CP    _Verify_write    ;Write with verify function 16
  195.     JP    Z,_W$rite_function
  196. ;
  197.     CP    _Z80_begin    ;Allow Z80 TPA exection
  198. ;    JP    Z,_Z$start_function    ;function code 21
  199.     JR    Z,_Z$start_function    ;function code 21
  200. ;
  201.     CP    _Z80_move    ;Move Z80 memory
  202. ;    JP    Z,_Z$move_function    ;function code 22
  203.     JR    Z,_Z$move_function    ;function code 22
  204. ;
  205.     CP    _Disk_verify    ;Verify entire media
  206.     JP    Z,_V$erify_function    ;function code 23
  207. ;
  208.    IF PRIVATE
  209.     CP    _Format_disk    ;Format 96 tpi media
  210.     JP    Z,_V$erify_function    ;function code 24
  211. ;
  212.     CP    _Move_packet    ;Move packet pointer
  213. ;    JP    Z,_Move_function    ;function code 25
  214.     JP    Z,_Mv_function        ;function code 25
  215.    ENDIF
  216. ;
  217.     CP    _User_function    ;BIOS 42 - 4F, BDOS 90
  218.     JR    NC,HIFNC    ; Yes
  219. ;
  220. Bad_function_code:
  221. ;
  222.     POP    BC        ;Empty stack of return address
  223.     LD    A,illegal_function    ;Illegal function code asked for
  224.     LD    (IX+status),A
  225. ;
  226. PKTRET:
  227.     EI            ;Re-enable interrupts in case
  228.                 ;they were off (Disk I/O)
  229. ;
  230.     PUSH    IX        ;Move address of packet to reg HL
  231.     POP    HL
  232.     LD    (IY),L        ;Put packet address in packet pointer
  233.     LD    (IY+1),H
  234.     OUT    (I88INT),A    ;And interrupt 8088 to pass back the packet
  235. ;
  236.  
  237. ----------rx50drvp.azm
  238. ;
  239.  
  240. -----------------------------------------------
  241.  
  242. ----------rx50drvp.old
  243.    IF 0        ;TEMP*****TEMP Change 0 to private if desired
  244.  
  245. ----------rx50drvp.azm
  246. ;************************************************************************
  247. ;
  248. ;   NAME:    PKTPRO
  249. ;
  250. ;   FUNCTION:    This routine is passed a packet address in Z80PKT.  It uses
  251. ;        that to get the function number which it uses to jump
  252. ;        to the specific function handler routine.
  253. ;
  254. ;        This routine is entered with an interrupt from the 8088 at
  255. ;        RST 6 - therefore, interrupts are off
  256. ;
  257. ;        For all functions except Z80START and serial support from
  258. ;        8088, we will interrupt the 8088 to indicate we have finished
  259. ;        the function.
  260. ;
  261. ;   ENTRY:    Z80PKT = packet address
  262. ;
  263. ;   EXIT:    IX = packet address
  264. ;
  265. PKTPRO:
  266.   IF SHARE
  267.     PUSH    IX        ;Save
  268.     PUSH    AF
  269.     PUSH    IY        ;Save remaining registers
  270.     PUSH    HL
  271.     LD    IY,INTFPTR
  272.    ENDIF
  273.     LD    L,(IY)        ;Get address of packet
  274.     LD    H,(IY+1)
  275.     PUSH    HL        ;Move address of packet into IX
  276.     POP    IX
  277.     XOR    A
  278.     LD    (IY),A        ;Sero address of packet to indicate to
  279.     LD    (IY+1),A    ;8088 that function has started
  280. ;    LD    (IY),0        ;Zero address of packet to indicate to
  281. ;    LD    (IY+1),0    ;8088 that function has started
  282. ;
  283.     IN    A,(I88INT)    ;Clear 8088 interrup flag
  284. ;
  285. ;    PUSH    IX        ;Check for Zero address
  286. ;    POP    HL        ;Move IX into H
  287.     LD    A,H        ;Put in accumulator
  288.     OR    L        ;Or in lower byte
  289.     JR    Z,HIFXIT
  290. ;    JP    Z,HIFXIT    ;Go away if zero
  291. ;
  292.    IF SHARE
  293.     PUSH    DE
  294.     PUSH    BC
  295.    ENDIF
  296. ;
  297.     LD    BC,PKTRET    ;Push return address onto stack
  298.     PUSH    BC
  299. ;
  300.     EI            ;Re-enable interrupts
  301. ;
  302.     LD    A,(IX+Function)    ;Get function code
  303. ;
  304.     CP    _Read_sector    ;Read function 13
  305.     JP    Z,_R$ead_function
  306. ;
  307.     CP    _Right_sector    ;Write function 14
  308.     JP    Z,_W$rite_function
  309. ;
  310.     CP    _Media_check    ;Media check function 15
  311.     JP    Z,_M$edia_check_function
  312. ;
  313.     CP    _Verify_write    ;Write with verify function 16
  314.     JP    Z,_W$rite_function
  315. ;
  316.     CP    _Z80_begin    ;Allow Z80 TPA exection
  317. ;    JP    Z,_Z$start_function    ;function code 21
  318.     JR    Z,_Z$start_function    ;function code 21
  319. ;
  320.     CP    _Z80_move    ;Move Z80 memory
  321. ;    JP    Z,_Z$move_function    ;function code 22
  322.     JR    Z,_Z$move_function    ;function code 22
  323. ;
  324.     CP    _Disk_verify    ;Verify entire media
  325.     JP    Z,_V$erify_function    ;function code 23
  326. ;
  327.    IF PRIVATE
  328.     CP    _Format_disk    ;Format 96 tpi media
  329.     JP    Z,_V$erify_function    ;function code 24
  330. ;
  331.     CP    _Move_packet    ;Move packet pointer
  332. ;    JP    Z,_Move_function    ;function code 25
  333.     JP    Z,_Mv_function        ;function code 25
  334.    ENDIF
  335. ;
  336.     CP    _User_function    ;BIOS 42 - 4F, BDOS 90
  337.     JR    NC,HIFNC    ; Yes
  338. ;
  339. Bad_function_code:
  340. ;
  341.     POP    BC        ;Empty stack of return address
  342.     LD    A,illegal_function    ;Illegal function code asked for
  343.     LD    (IX+status),A
  344. ;
  345. PKTRET:
  346.     EI            ;Re-enable interrupts in case
  347.                 ;they were off (Disk I/O)
  348. ;
  349.     PUSH    IX        ;Move address of packet to reg HL
  350.     POP    HL
  351.     LD    (IY),L        ;Put packet address in packet pointer
  352.     LD    (IY+1),H
  353.     OUT    (I88INT),A    ;And interrupt 8088 to pass back the packet
  354. ;
  355. *EJECT
  356. ;
  357.    IF 0        ;TEMP*****TEMP Change 0 to private if desired
  358.  
  359. -----------------------------------------------
  360.  
  361. ----------rx50drvp.old
  362. ;        b)    If 9, then checks for IBM
  363. ;        c)    If 8, then IBM
  364. ;
  365.  
  366. ----------rx50drvp.azm
  367. ;        b)    If 9, then checks for IBM or ROBIN
  368. ;        c)    If 8, then IBM
  369. ;    7)    Reads sector 1 of second side and sets double-sided flag bit
  370. ;
  371.  
  372. -----------------------------------------------
  373.  
  374. ----------rx50drvp.old
  375. ;   Drive ready check
  376.  
  377. ----------rx50drvp.azm
  378. ;   Wait for the disk to become ready
  379. ;
  380. _RESD10:                                    ;RGT
  381. ;10$:                                    ;RGT
  382.     IN    A,(Fstatr)    ;Get disk status            ;RGT
  383.     BIT    BUSY,A        ;See if busy                ;RGT
  384. ;    JR    NZ,10$        ;If still busy, wait for it        ;RGT
  385.     JR    NZ,_RESD10    ;If still busy, wait for it        ;RGT
  386.     CALL    WAITREADY    ;Wait for disk to become ready        ;RGT
  387. ;
  388. ;   Drive ready check
  389.  
  390. -----------------------------------------------
  391.  
  392. ----------rx50drvp.old
  393. ;    JR    NC,20$        ;Test if carry set
  394.     JR    NC,_RD20    ;Test if carry set
  395.     CCF            ;If set, unset it
  396. _RD20:
  397.  
  398. ----------rx50drvp.azm
  399.     XOR    A        ;Clear carry bit
  400. _RD20:
  401.  
  402. -----------------------------------------------
  403.  
  404. ----------rx50drvp.old
  405.     JR    Z,Double_sided    ;If zero, check if double sided media
  406.     CP    9        ;Check if 48 tpi, 9 sector
  407.     JR    Z,Ibm9_check    ;If zero, 9 sector, find out if IBM
  408.     LD    A,Ibm8        ;Otherwise, check for 8 sector
  409.     CP    8        ;Check if 48 tpi, 8 sector
  410.     JR    Z,Finish_media_check    ;End of routine
  411.     LD    A,Mongrel    ;Some kind of media, don't know what kind
  412.     JR    Finish_media_check    ;End of routine
  413. ;
  414. ;   Coundn't read address  --  try again
  415.  
  416. ----------rx50drvp.azm
  417.     JR    NZ,IBM_CHECK    ;If not zero, check if IBM
  418.     LD    A,Rainb        ;Otherwise, set to Rainbow media
  419.     JR    DOUBLE_SIDED    ;And check for double sided media
  420. ;
  421. ;   Not a Rainbow media disk  --  check for IBM or ROBIN media
  422. ;
  423. IBM_CHECK:
  424.     CP    9        ;Check if 48 tpi, 9 sector
  425.     JR    Z,Ibm9_check    ;If zero, 9 sector, find out if IBM
  426.     CP    8        ;Check if 48 tpi, 8 sector
  427.     JR    Z,Ibm8_media    ;If zero, then 8-sector IBM media
  428.     LD    A,Mongrel    ;Some kind of media, don't know what kind
  429.     JR    DOUBLE_SIDED    ;And check for double sided media
  430. ;
  431. ;   This is an 8-sector IBM disk media
  432. ;
  433. Ibm8_media:
  434.     LD    A,Ibm8        ;Otherwise, check for 8 sector
  435.     JR    DOUBLE_SIDED    ;And check for double sided
  436. ;
  437. ;   IBM 9 sector check.  Do not know if ROBIN or IBM 9-sector media.
  438. ;    Return ROBIN media and let higher levels figure it out.
  439. ;
  440. Ibm9_check:
  441.     LD    A,Robin        ;Select:    Robin media
  442.     JR    DOUBLE_SIDED    ;And check for double sided media
  443. ;
  444. ;   Coundn't read address  --  try again
  445.  
  446. -----------------------------------------------
  447.  
  448. ----------rx50drvp.old
  449. ;   Double sided Rainbow check
  450. ;
  451. Double_sided:
  452.    IF TEAC
  453. ;
  454.     LD    HL,063DBH    ;Load 'IN A,(63H)' instruction
  455.     LD    (Inorout),HL    ;Move into read routine
  456.     LD    D,0        ;Initialize retry count
  457.     LD    A,E        ;Get desired drive number
  458.     OR    Side_select    ;Select:    Side 1
  459.     OUT    (Gfcontr),A
  460.     LD    A,Sec_10    ;Select:    Sector 10
  461.     OUT    (Fsr),A        ;Load sector register
  462. DSR10:
  463. ;10$:
  464.     LD    A,Sec_read    ;Select:    Read sector command
  465.     CALL    _Write_read    ;Read desired sector
  466.     LD    B,Raind        ;Select:    Rainbow double sided
  467. ;    JR    Z,20$        ;If no errors, double sided media
  468.  
  469. ----------rx50drvp.azm
  470. ;   Double sided media check.
  471. ;    Try to read sector 1 of side 1.  If success, then double sided.
  472. ;
  473. Double_sided:
  474.    IF DSIDE
  475. ;
  476.     PUSH    AF        ;Save disk type in reg A
  477.     LD    D,0        ;Initialize retry count
  478.     LD    A,E        ;Get desired drive number
  479.     SET    Sid_sel,A    ;Select:    Side 1
  480.     OUT    (Gfcontr),A
  481. DSR10:
  482. ;10$:
  483.     LD    HL,Buffer    ;Load buffer address
  484.     LD    A,Read_address    ;Select:    Read address
  485.     CALL    _Write_read    ;Read desired sector
  486.     LD    B,DBSIDE    ;Select:    Double sided
  487. ;    JR    Z,20$        ;If no errors, double sided media
  488.  
  489. -----------------------------------------------
  490.  
  491. ----------rx50drvp.old
  492.     CMP    D,Retry_fail    ;Check if too many retries
  493. ;    JR    NZ,10$        ;If retry finished, flag status
  494.     JR    NZ,DSR10    ;If retry finished, flag status
  495.     LD    B,Rains        ;Select:    Rainbow single sided
  496. DSR20:
  497.  
  498. ----------rx50drvp.azm
  499.     CMP    D,2        ;Try only twice
  500. ;    JR    NZ,10$        ;If retry finished, flag status
  501.     JR    NZ,DSR10    ;If retry finished, flag status
  502.     LD    B,0        ;Select:    Single sided
  503. ;
  504. ;   Register B is set with the double-sided media flag.
  505. ;    OR it into the media type code.
  506. ;
  507. DSR20:
  508.  
  509. -----------------------------------------------
  510.  
  511. ----------rx50drvp.old
  512.     LD    A,B        ;Get media type
  513.     JR    Finish_media_check    ;Media check ended
  514. ;
  515.    ELSE
  516. ;
  517.     LD    A,Rains        ;Select:    Rainbow single sided
  518.     JR    Finish_media_check    ;Media check ended
  519.    ENDIF
  520. ;
  521. ;   IBM 9 sector check
  522. ;
  523. Ibm9_check:
  524.     LD    A,Robin        ;Select:    Robin media
  525. ;
  526. ;   Media check finished
  527.  
  528. ----------rx50drvp.azm
  529.     POP    AF        ;Restore disk type from stack
  530.     OR    B        ;OR in the double sided bit
  531.    ENDIF
  532. ;
  533. ;   Media check finished
  534.  
  535. -----------------------------------------------
  536.  
  537. ----------rx50drvp.old
  538.    IF TEAC
  539.     CALL    Des_side    ;Get desired side value
  540.  
  541. ----------rx50drvp.azm
  542.    IF DSIDE
  543.     CALL    Des_side    ;Get desired side value
  544.  
  545. -----------------------------------------------
  546.  
  547. ----------rx50drvp.old
  548.    IF 0
  549.     LD    C,0        ;Initiate side select value
  550.     CALL    Des_side    ;Get desired side value
  551.     LD    (Cur_side),A    ;Save for later use
  552.     CP    0        ;Check if first side desired
  553. ;    JR    Z,15$        ;If Zero, then leave side alone
  554.     JR    Z,VF15        ;If Zero, then leave side alone
  555.     SET    5,C        ;Otherwise, set side select bit
  556.     LD    A,E        ;Get drive number
  557.     OR    C        ;Set side select value
  558.     OUT    (Gfcontr),A
  559.     LD    (Complete_drive),A    ;Save for later use
  560.    ENDIF
  561.  
  562. ----------rx50drvp.azm
  563.     IF dside
  564.     LD    C,0        ;Initiate side select value
  565.     CALL    Set_side    ;Set desired side value
  566.    ENDIF
  567.  
  568. -----------------------------------------------
  569.  
  570. ----------rx50drvp.old
  571.     CP    0EH        ;Check if value over 10
  572. ;    JR    C,60$        ;If carry, <13
  573.     JR    C,RAS60        ;If carry, <13
  574.     LD    A,4
  575. ;    JR    75$
  576.     JR    RAS75
  577. RAS60:
  578. ;60$:
  579.     CP    0DH        ;Check if value over 10
  580. ;    JR    C,65$        ;If carry, <12
  581.     JR    C,RAS65        ;If carry, <12
  582.     LD    A,3
  583. ;    JR    75$
  584.     JR    RAS75
  585. RAS65:
  586. ;65$:
  587.     CP    0CH        ;Check if value over 10
  588. ;    JR    C,70$        ;If carry, <11
  589.     JR    C,RAS70        ;If carry, <11
  590.     LD    A,2
  591. ;    JR    75$
  592.     JR    RAS75
  593. RAS70:
  594. ;70$:
  595.     CP    0BH        ;Check if value over 10
  596. ;    JR    C,75$        ;If not, then continue
  597.     JR    C,RAS75        ;If not, then continue
  598.     LD    A,1        ;Otherwise, set to sector 1
  599. RAS75:
  600.  
  601. ----------rx50drvp.azm
  602.     CP    0BH        ;Check if value over 10
  603. ;    JR    C,75$        ;If carry, <10
  604.     JR    C,RAS75        ;If carry, <10
  605.     SUB    10        ;Otherwise, make it less than 10
  606. RAS75:
  607.  
  608. -----------------------------------------------
  609.  
  610. ----------rx50drvp.old
  611.     LD    HL,(04AH)    ;Save contents of location
  612.     PUSH    HL        ;to be replaced at end of formatter
  613.     LD    HL,013H        ;Load 'INC DE' instruction
  614.     LD    (048H),HL
  615.     LD    HL,0F518H    ;Load 'JR xx' instruction
  616.     LD    (049H),HL
  617.     LD    E,1        ;Select:    E = track number
  618.  
  619. ----------rx50drvp.azm
  620.     LD    HL,(Inorout+4)    ;Save contents of location
  621.     PUSH    HL        ;to be replaced at end of formatter
  622.     LD    HL,013H        ;Load 'INC DE' instruction
  623.     LD    (Inorout+2),HL
  624.     LD    HL,0F518H    ;Load 'JR xx' instruction
  625.     LD    (Inorout+3),HL
  626.     LD    E,1        ;Select:    E = track number
  627.  
  628. -----------------------------------------------
  629.  
  630. ----------rx50drvp.old
  631.     LD    (04AH),HL
  632.     LD    HL,0F618H    ;Load 'JR' instruction
  633.     LD    (048H),HL
  634.     PUSH    BC        ;Replace return address
  635.  
  636. ----------rx50drvp.azm
  637.     LD    (Inorout+4),HL
  638.     LD    HL,0F618H    ;Load 'JR' instruction
  639.     LD    (Inorout+2),HL
  640.     PUSH    BC        ;Replace return address
  641.  
  642. -----------------------------------------------
  643.  
  644. ----------rx50drvp.old
  645.     ADD    A,A        ;Check if interrupt bit set
  646.     JP    P,_Com_com    ;If positive, no interrupt
  647.     IN    A,(Fstatr)    ;Get status
  648.  
  649. ----------rx50drvp.azm
  650.     BIT    Int_rq,A    ;Check if interrupt bit set
  651.     JR    Z,_Com_com    ;If not set, no interrupt
  652.     IN    A,(Fstatr)    ;Get status
  653.  
  654. -----------------------------------------------
  655.  
  656. ----------rx50drvp.old
  657.     LD    E,A        ;Store for later use
  658.     RET
  659.  
  660. ----------rx50drvp.azm
  661.     LD    E,A        ;Store disk drive number for later use
  662.     RET
  663.  
  664. -----------------------------------------------
  665.  
  666. ----------rx50drvp.old
  667. Des_sector:
  668.  
  669. ----------rx50drvp.azm
  670. Set_side:                                ;RGT
  671. ;                                    ;RGT
  672. ;   Sets up the desired side by setting the side bit and storing    ;RGT
  673. ;    the complete drive number.                    ;RGT
  674. ;                                    ;RGT
  675. ;   INPUT:    IX = Packet address                    ;RGT
  676. ;        Reg C    --  Precomp bit.                ;RGT
  677. ;                                    ;RGT
  678. ;   OUTPUT:    None                            ;RGT
  679. ;                                    ;RGT
  680.    IF DSIDE                                ;RGT
  681.     CALL    Des_side    ;Get desired side            ;RGT
  682.     LD    (CUR_SIDE),A    ;Store desired side            ;RGT
  683.     CP    1        ;See if side 1 is desired        ;RGT
  684. ;    JR    NZ,10$        ;If not, use precomp as is        ;RGT
  685.     JR    NZ,SETS10    ;If not, use precomp as is        ;RGT
  686.     SET    Sid_sel,C    ;Otherwise, set side select bit        ;RGT
  687.    ENDIF                                ;RGT
  688. ;10$:                                    ;RGT
  689. SETS10:                                    ;RGT
  690.     LD    A,(CUR_DRIVE)    ;Get current drive number        ;RGT
  691.     OR    C        ;OR in side and precomp bits        ;RGT
  692.     OUT    (Gfcontr),A    ;Send complete drive info to disk ctrl    ;RGT
  693.     LD    (COMPLETE_DRIVE),A    ;And store it in memory        ;RGT
  694.     RET            ;Return to caller            ;RGT
  695. ;
  696. ;
  697. Des_sector:
  698.  
  699. -----------------------------------------------
  700.  
  701. ----------rx50drvp.old
  702.    IF .NOT.TEAC        ;If RX50's, add extra precomp for > 61
  703.     CP    03DH        ;Check if > track 61
  704.  
  705. ----------rx50drvp.azm
  706.     CP    03DH        ;Check if > track 61
  707.  
  708. -----------------------------------------------
  709.  
  710. ----------rx50drvp.old
  711.    ENDIF
  712. ;
  713.  
  714. ----------rx50drvp.azm
  715. ;
  716.  
  717. -----------------------------------------------
  718.  
  719. ----------rx50drvp.old
  720.     AND    099H        ;Mask error bits
  721.  
  722. ----------rx50drvp.azm
  723. ;
  724. ;   For the SHUGART drives, must make sure disk is ready before exit.
  725. ;    It starts the disk turning, then becomes ready.  The standard code
  726. ;    tests for ready too soon and fails.
  727. ;
  728. STWR6:                                    ;RGT
  729. ;6$:                                    ;RGT
  730.     IN    A,(Fstatr)    ;Get disk status            ;RGT
  731.     BIT    BUSY,A        ;See if busy                ;RGT
  732. ;    JR    NZ,6$        ;If still busy, wait for it        ;RGT
  733.     JR    NZ,STWR6    ;If still busy, wait for it        ;RGT
  734.     CALL    WAITREADY    ;Wait for disk to become ready        ;RGT
  735.     AND    099H        ;Mask error bits
  736.  
  737. -----------------------------------------------
  738.  
  739. ----------rx50drvp.old
  740. ;
  741.  
  742. ----------rx50drvp.azm
  743. ;                                    ;RGT
  744. ;   Function:    WAITREADY                        ;RGT
  745. ;                                    ;RGT
  746. ;   Abstract:                                ;RGT
  747. ;                                    ;RGT
  748. ;    Wait until disk ready bit is clear.  If not clear within timeout,;RGT
  749. ;    then return anyway.                        ;RGT
  750. ;                                    ;RGT
  751. ;   Entry Parameters:                            ;RGT
  752. ;                                    ;RGT
  753. ;    None                                ;RGT
  754. ;                                    ;RGT
  755. ;   Exit Parameters:                            ;RGT
  756. ;                                    ;RGT
  757. ;    Reg A    --  status of the disk controller            ;RGT
  758. ;                                    ;RGT
  759. ;   Registers Changed:    A                        ;RGT
  760. ;                                    ;RGT
  761. ;   Side Effects:                            ;RGT
  762. ;                                    ;RGT
  763. ;    None                                ;RGT
  764. ;                                    ;RGT
  765. ;                                    ;RGT
  766. ;   Start of code  --  seek disk to desired track            ;RGT
  767. ;                                    ;RGT
  768. WAITREADY:                                ;RGT
  769.     PUSH    BC        ;Save counter registers            ;RGT
  770.     LD    C,5        ;Set outer count to 5            ;RGT
  771. WRD010:                                    ;RGT
  772.     LD    B,0        ;Set count to 256            ;RGT
  773. WRD030:                                    ;RGT
  774.     IN    A,(FSTATR)    ;Read the disk controller status    ;RGT
  775.     BIT    READY,A        ;Test ready bit                ;RGT
  776.     JR    Z,WRD110    ;If clear, then just return        ;RGT
  777. ;                                    ;RGT
  778. ;   Disk is not ready  --  wait for a while and try again        ;RGT
  779. ;                                    ;RGT
  780.     XOR    A        ;Set count to 256            ;RGT
  781. WRD050:                                    ;RGT
  782.     DEC    A            ;Decrement count        ;RGT
  783.     JR    NZ,WRD050        ;If not done, wait some more    ;RGT
  784.     DEC    B            ;Decrement middle count        ;RGT
  785.     JR    NZ,WRD030        ;If not done, wait again    ;RGT
  786.     DEC    C            ;Decrement outer count        ;RGT
  787.     JR    NZ,WRD010        ;If not done, wait again    ;RGT
  788. ;                                    ;RGT
  789. ;   Disk is either ready, or it has failed timeout.  Return to caller    ;RGT
  790. ;                                    ;RGT
  791. WRD110:                                    ;RGT
  792.     POP    BC        ;Restore registers            ;RGT
  793.     IN    A,(FSTATR)    ;Read the disk controller status    ;RGT
  794.     RET            ;Return to caller            ;RGT
  795. ;                                    ;RGT
  796. ;                                     ;RGT
  797. *EJECT
  798. ;
  799.  
  800. -----------------------------------------------
  801.  
  802. ----------rx50drvp.old
  803. RSU5:
  804. ;5$:
  805.     LOAD    A        ;Get head location of drive
  806.     CP    .LOW.-1        ;Check if ever accessed
  807.  
  808. ----------rx50drvp.azm
  809. ;
  810. ;   Get the track location for this particular drive.
  811. ;    Since the track location tables are shared with the 8088 code,
  812. ;    the 8088 code can set it to -1 at initialization and whenever
  813. ;    the 8088 decides that the media has been changed.
  814. ;
  815. RSU5:
  816. ;5$:
  817. ;
  818. ;    The drive number is assumed to be in reg E, and the track location
  819. ;    is stored into the track table just in front of the packet
  820. ;    pointer address.  It is in shared memory, and is defined in the
  821. ;    8088 code.
  822. ;
  823.     PUSH    IY
  824.     POP    HL
  825.     LD    A,L
  826.     SUB    12        ;Point to track table
  827.                 ;This is set up in the 8088 code as 4 bytes
  828.                 ;in front of the 8-byte media type table
  829.     LD    L,A
  830. ;
  831. ;   This appears to be used to set the RX50 disk drives to the same,
  832. ;    no matter which of the two disks is in use.
  833. ;    Since I now have two seperate drives, this is commented out.
  834. ;
  835. ;   if .not.dside
  836. ;    ld    a,e        ;Move into accumulator
  837. ;    and    2        ;Mask so reg A = 0 or 2
  838. ;    ld    e,a        ;Return status
  839. ;   endif
  840. ;
  841.     LD    D,0        ;Clear reg D
  842.     ADD    HL,DE        ;Point to offset in memory
  843.     LD    A,(HL)        ;Load contents of reg HL into reg A
  844.     CP    .LOW.-1        ;Check if ever accessed
  845.  
  846. -----------------------------------------------
  847.  
  848. ----------rx50drvp.old
  849.    IF TEAC
  850.     CALL    Des_side    ;Get desired side value
  851.     LD    (Cur_side),A    ;Save for later use
  852.     CP    1        ;Check if side 1
  853. ;    JR    NZ,20$        ;If not side 1, do not set bit
  854.     JR    NZ,MC9620    ;If not side 1, do not set bit
  855.     SET    5,C        ;Otherwise, set side select bit
  856.    ENDIF
  857. ;
  858. MC9620:
  859. ;20$:
  860.     LD    A,(Cur_drive)    ;Load drive value
  861.     OR    C        ;Add pre-comp and side select
  862.     OUT    (Gfcontr),A
  863.     LD    (Complete_drive),A    ;Save the precomp and side select
  864.                     ;as selected
  865. ;
  866. ;   Seek the desired track if drive not ready or
  867.  
  868. ----------rx50drvp.azm
  869.     CALL    Set_side    ;Set desired side value
  870. ;
  871. ;   Seek the desired track if drive not ready or
  872.  
  873. -----------------------------------------------
  874.  
  875. ----------rx50drvp.old
  876.     LD    A,(Cur_drive)    ;Load drive value
  877.     OR    C        ;Add pre-comp and side select
  878.     OUT    (Gfcontr),A
  879.     LD    (Complete_drive),A    ;Save the precomp value
  880. ;
  881. ;   Set side select location
  882. ;
  883.    IF TEAC
  884.     CALL    Des_side    ;Get side value for the book keeping
  885.     LD    (Cur_side),A    ;Save for guess sector
  886.    ENDIF
  887. ;
  888. _48_seek_track:
  889.  
  890. ----------rx50drvp.azm
  891. ;
  892. ;   Get desired side
  893. ;
  894.     CALL    Set_side    ;Set desired side value
  895. ;
  896. _48_seek_track:
  897.  
  898. -----------------------------------------------
  899.  
  900. ----------rx50drvp.old
  901. ;    pointed to by the HL register
  902. ;
  903.  
  904. ----------rx50drvp.azm
  905. ;    pointed to by the HL register.
  906. ;    This media type array is shared between this code and the 8088
  907. ;    code, so the 8088 can tell what type of media is in the drive.
  908. ;
  909.  
  910. -----------------------------------------------
  911.  
  912. ----------rx50drvp.old
  913.     LD    L,A
  914.  
  915. ----------rx50drvp.azm
  916.                 ;This is set up in the 8088 code as 8 bytes
  917.     LD    L,A
  918.  
  919. -----------------------------------------------
  920.  
  921. ----------rx50drvp.old
  922. ;
  923.  
  924. ----------rx50drvp.azm
  925. ;    This media type array is shared between this code and the 8088
  926. ;    code, so the 8088 can tell what type of media is in the drive.
  927. ;
  928.  
  929. -----------------------------------------------
  930.  
  931. ----------rx50drvp.old
  932.     LD    L,A
  933.  
  934. ----------rx50drvp.azm
  935.                 ;This is set up in the 8088 code as 8 bytes
  936.     LD    L,A
  937.  
  938. -----------------------------------------------
  939.  
  940. ----------rx50drvp.old
  941.     CP    Rains        ;Check for Rainbow single sided
  942. ;
  943.    IF TEAC
  944. ;    JR    Z,10$
  945.     JR    Z,MEDT10
  946.     CP    Raind        ;Check for Rainbow double sided
  947.    ENDIF
  948. ;
  949. MEDT10:
  950. ;10$:
  951.     RET            ;The Z flag is set for 96 tpi
  952.  
  953. ----------rx50drvp.azm
  954.     AND    .LOW.(.NOT.DBSIDE)    ;Clear double sided bit, if set
  955.     CP    Rainb        ;Check for Rainbow media
  956.     RET            ;The Z flag is set for 96 tpi
  957.  
  958. -----------------------------------------------
  959.  
  960. ----------rx50drvp.old
  961.     CP    Unknown        ;Check if media type unknown
  962.  
  963. ----------rx50drvp.azm
  964.     AND    .LOW.(.NOT.DBSIDE)    ;Clear double sided bit, if set
  965.     CP    Unknown        ;Check if media type unknown
  966.  
  967. -----------------------------------------------
  968.  
  969. ----------rx50drvp.old
  970.     CP    Rains        ;Check if 96 tpi single sided
  971. ;
  972.    IF TEAC
  973. ;    JR    Z,10$
  974.     JR    Z,E1R10
  975.     CP    Raind        ;Check if 96 tpi double sided
  976.    ENDIF
  977. ;
  978.  
  979. ----------rx50drvp.azm
  980.     CP    Rainb        ;Check for Rainbow media
  981. ;
  982.  
  983. -----------------------------------------------
  984.  
  985. ----------rx50drvp.old
  986.     STORE    D        ;Set head location for drive
  987. ;
  988. End5_routine:
  989.  
  990. ----------rx50drvp.azm
  991. ;
  992. ;   Store the track number for the specified drive.
  993. ;    The drive number is assumed to be in reg E,
  994. ;    and is stored into the track table just in front of the packet
  995. ;    pointer address.  It is in shared memory, and is defined in the
  996. ;    8088 code.
  997. ;
  998.     PUSH    IY
  999.     POP    HL
  1000.     PUSH    DE        ;Save head location
  1001.     PUSH    AF        ;Save reg A
  1002.     LD    A,L
  1003.     SUB    12        ;Point to track table
  1004.                 ;This is set up in the 8088 code as 4 bytes
  1005.                 ;in front of the 8-byte media type table
  1006.     LD    L,A
  1007. ;
  1008. ;   This appears to be used to set the RX50 disk drives to the same,
  1009. ;    no matter which of the two disks is in use.
  1010. ;    Since I now have two seperate drives, this is commented out.
  1011. ;
  1012. ;   if .not.dside
  1013. ;    ld    a,e        ;Move into accumulator
  1014. ;    and    2        ;Mask so a = 0 or 2
  1015. ;    ld    e,a        ;Return status
  1016. ;   endif
  1017. ;
  1018.     POP    AF
  1019.     LD    D,0
  1020.     ADD    HL,DE        ;Point to offset in memory
  1021.     POP    DE        ;Restore reg D
  1022.     LD    (HL),D        ;Load contents of reg HL with head location
  1023. ;
  1024. End5_routine:
  1025.  
  1026. -----------------------------------------------
  1027.  
  1028. ----------rx50drvp.old
  1029. **** Private version too large ****
  1030.  
  1031. ----------rx50drvp.azm
  1032.     Private version too large
  1033. **** Private version too large ****
  1034.  
  1035. -----------------------------------------------
  1036.  
  1037. ----------rx50drvp.old
  1038. ***** Shared version too large *****
  1039.  
  1040. ----------rx50drvp.azm
  1041.     Shared Version too large
  1042. ***** Shared version too large *****
  1043.  
  1044. -----------------------------------------------
  1045.  
  1046. ----------rx50drvp.old
  1047. 
  1048. ;
  1049.     DEFSTC    Sect_count,1    ;Multi-sector command counter
  1050.  
  1051. ----------rx50drvp.azm
  1052. 
  1053.