home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / gpl25 < prev    next >
Encoding:
Text File  |  2006-10-19  |  6.0 KB  |  308 lines

  1. * GPL Routine >25 - Access Direct Output File
  2. *
  3. * This procedure writes information to the disk
  4. * from the caller's buffer.
  5. *
  6. * Inputs:
  7. *    >834C - SCSI device number and buffer bit
  8. *    >834D - Access code
  9. *    >834E - Pointer to file name
  10. *    >8350 - Additional info
  11. *
  12. * Outputs:
  13. *    >8350 - Error code
  14. *              0 = success
  15. *              non 0 = error
  16. *
  17. GPL25
  18.        ANDI R12,>FF00
  19.        AI   R12,24
  20.  
  21.        BL   @MAKEFN
  22.  
  23. * First check the access code to see if we're transfering
  24. * data or file parameters.
  25. *
  26.        MOVB @>834D,R1
  27.        JNE  GPL25B
  28.  
  29. * We're just transferring file parameters.  We will store
  30. * the information and then call MKFDR to put the FDR on disk.
  31. *
  32.  
  33.        MOVB @>8350,R2        Get pointer to additional info
  34.        SRL  R2,8
  35.        AI   R2,>8300+2
  36.        LDCR @B02,4
  37.        MOVB *R2+,@MKFSZ   # of sectors
  38.        MOVB *R2+,@MKFSZ+1
  39.        MOVB *R2+,@MKFLAG  File flags
  40.        MOVB *R2+,@MKFRPS  # of rec/sec
  41.        MOVB *R2+,@MKFEOF  EOF offset
  42.        MOVB *R2+,@MKFRL   Logical record size
  43.        MOVB *R2+,@MKFL3   # of level 3 records
  44.        MOVB *R2+,@MKFL3+1
  45.  
  46.        BL   @SAVPAD
  47.        BL   @MKFDR
  48.        BL   @RESPAD
  49.        MOVB @B01,@>8350
  50.        CI   R1,0
  51.        JNE  GPL25A
  52.  
  53.        MOVB @ZERO,@>8350     Set success code
  54. GPL25A B    @DSRRT
  55.  
  56. * Here we have to store actual data to the file from
  57. * the buffer
  58. *
  59.  
  60. GPL25B
  61.        BL   @SAVPAD      Save contents of scratch pad RAM
  62.        BL   @GETFDR
  63.        CI   R5,0             See if file exists
  64.        JEQ  G25ERR
  65.  
  66. * Let's start off by copying the FDR to a buffer in another bank
  67. *
  68.        LI   R4,DFDR
  69.        LI   R0,256
  70. GPL25C LDCR @ZERO,4
  71.        MOV  *R5+,R3
  72.        LDCR @B02,4
  73.        MOV  R3,*R4+
  74.        DECT R0
  75.        JNE  GPL25C
  76.  
  77.        BL   @RESPAD
  78.  
  79. * Register Usage throughout the rest of the subprogram
  80. *
  81. * R1 - # of sectors left to be write
  82. * R4 - Current AU within file
  83. * R5 - Current sector within AU
  84. * R6 - SCSI ID
  85. * R7, R8 - SCSI sector number to read
  86. * R10 - Pointer to buffer (if CPU RAM)
  87.  
  88.        MOVB @>834D,R1
  89.        SRL  R1,8
  90.        MOVB @>834C,R6
  91.        ANDI R6,>0F00
  92.        AI   R6,->0100
  93.  
  94.        MOVB @>8350,R2        Get pointer to additional info
  95.        SRL  R2,8
  96.        AI   R2,>8300
  97.  
  98. * If the buffer is in VDP RAM, set the VDP read address now
  99. *
  100.  
  101.        MOV  *R2,R10
  102.        MOVB @>834C,R3
  103.        ANDI R3,>8000
  104.        JNE  GPL250
  105.        SWPB R10
  106.        MOVB R10,@VDPWA
  107.        SWPB R10
  108.        MOVB R10,@VDPWA
  109. GPL250
  110.  
  111.        CLR  R4
  112.        MOV  @2(R2),R5        Get sector number
  113.        JEQ  GPL251           Save a divide instruction maybe
  114.  
  115.        MOV  R6,R3
  116.        SRL  R3,8
  117.        SLA  R3,1
  118.        LDCR @B04,4
  119.        DIV  @SAUTBL(R3),R4
  120. GPL251
  121. * Now search through the FDR for actual AU on disk.
  122. *
  123.        LDCR @B02,4
  124.        LI   R3,DFDR+40
  125.  
  126. GPL25D MOV  *R3+,R2
  127.        CI   R4,0
  128.        JEQ  GPL25F
  129. G25DD  C    R2,*R3
  130.        JNE  GPL25E
  131.        INCT R3
  132.        DEC  R4
  133.        JMP  GPL25D
  134.  
  135. G25ERR
  136.        MOVB @B01,@>8350      Set an error code
  137.        B    @DSRRT
  138.  
  139. GPL25E INC  R2
  140.        DEC  R4
  141.        JNE  G25DD
  142.  
  143. GPL25F MOV  R2,R4            R4 now has actual AU
  144.  
  145. * Now lets write data to the disk
  146. *
  147. GPL25Z LI   R2,SECBUF
  148.        MOV  R4,R7
  149.        LDCR @B04,4
  150.        MOV  R6,R3
  151.        SRL  R3,8
  152.        SLA  R3,1
  153.        MPY  @SAUTBL(R3),R7
  154.  
  155.        A    R5,R8
  156.        JNC  GPL25G
  157.        INC  R7
  158. GPL25G
  159.        SRL  R8,1
  160.        JNC  GPL25H
  161.        AI   R2,>100
  162. GPL25H SRL  R7,1
  163.        JNC  GPL25I
  164.        AI   R8,>8000
  165. GPL25I
  166.  
  167. * Let's see if we can write out a 512 byte block and
  168. * save ourselves an extra read and write.
  169.  
  170.        CI   R1,1             See if we have only 1 sector left
  171.        JEQ  G25I1
  172.        CI   R2,SECBUF        Are we starting in the middle?
  173.        JNE  G25I1
  174.        MOV  R5,R0
  175.        INC  R0
  176.        C    R0,@SAUTBL(R3)
  177.        JNE  GPL25P
  178. G25I1
  179. * Save the contents of scratch pad RAM before
  180. * SCSIRD trashes it
  181.  
  182.        BL   @SAVPAD
  183.  
  184.        BLWP @BANKIT
  185.        DATA SCSIRD
  186.        JNE  G25ERR
  187.  
  188.        BL   @RESPAD
  189.  
  190. * Now overlay data into the sector buffer.
  191. * VDP RAM or CPU RAM.
  192.  
  193.        LI   R0,256
  194. G25I2
  195.        MOVB @>834C,R3
  196.        ANDI R3,>8000
  197.        JNE  GPL25K
  198.  
  199. * The buffer is in VDP RAM
  200.  
  201. GPL25J MOVB @VDPRD,*R2+
  202.        DEC  R0
  203.        JNE  GPL25J
  204.        AI   R10,256
  205.        JMP  GPL25L
  206.  
  207. GPL25K MOVB *R10+,*R2+
  208.        DEC  R0
  209.        JNE  GPL25K
  210.  
  211. GPL25L
  212.  
  213. * Now write it back out to disk
  214.  
  215.        BL   @SAVPAD
  216.        BLWP @BANKIT
  217.        DATA SCSIWT
  218.        JNE  G25ERR
  219.        BL   @RESPAD          Restore it again
  220.  
  221.        DEC  R1
  222.        JEQ  G25RT
  223.  
  224.        INC  R5
  225. GPL25N LDCR @B04,4
  226.        MOV  R6,R3
  227.        SRL  R3,8
  228.        SLA  R3,1
  229.        C    R5,@SAUTBL(R3)
  230.        JNE  GPL25Z
  231.  
  232.        CLR  R5
  233.  
  234. * We now loop through the FDR to see if we go to next AU
  235.  
  236.        LDCR @B02,4
  237.        LI   R3,DFDR+42
  238. GPL25M C    *R3,R4
  239.        JEQ  GPL25O
  240.        AI   R3,4
  241.        CI   R3,DFDR+>100
  242.        JL   GPL25M
  243.  
  244.        INC  R4
  245.        JMP  GPL25Z
  246.  
  247. G25RT
  248.        CLR  R1
  249.        MOVB R1,@>834D        I don't know if this is right
  250.        MOVB @ZERO,@>8350     Set success code
  251.        B    @DSRRT
  252.  
  253. GPL25O MOV  @2(R3),R4
  254.        JMP  GPL25Z
  255.  
  256. **
  257. *
  258. * Here we are writing a full 512 byte block.
  259. *
  260. **
  261.  
  262. GPL25P
  263.        CLR  R0
  264.        MOVB R6,R0            SCSI ID
  265.        MOVB @>834C,R3        Get CPU or VDP memory flag
  266.        ANDI R3,>8000
  267.        SOC  R3,R0
  268.        ORI  R0,>4000         Select absolute sector size
  269.        MOV  R0,@>834C
  270.        MOV  R10,@>834E       Set buffer address
  271.        MOV  R8,@>8350
  272.        MOV  R7,@>8352
  273.  
  274.        BL   @SAVPAD
  275.        BLWP @BANKIT
  276.        DATA SCSI20
  277.        BL   @RESPAD
  278.  
  279.        AI   R10,512
  280.        DECT R1
  281.        JEQ  G25RT
  282.  
  283.        INCT R5
  284.        JMP  GPL25N
  285.  
  286. * SAVPAD - Save the contents of scratch pad RAM to
  287. * a buffer in bank 2
  288.  
  289. SAVPAD LDCR @B02,4
  290.        MOV  R10,@POSIAU       Save R10 for now
  291.        LI   R9,>8300
  292.        LI   R10,G24BUF
  293. SAVPD1 LI   R0,>70
  294. SAVPD2 MOV  *R9+,*R10+
  295.        DECT R0
  296.        JNE  SAVPD2
  297.        MOV  @POSIAU,R10       Restore R10
  298.        LDCR @ZERO,4
  299.        RT
  300.  
  301. * RESPAD - Restore the contents of scratch pad RAM
  302.  
  303. RESPAD LDCR @B02,4
  304.        MOV  R10,@POSIAU       Save R10
  305.        LI   R10,>8300
  306.        LI   R9,G24BUF
  307.        JMP  SAVPD1
  308.