You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lcc.read 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. .PAGE 'LCC.READ'
  2. ;
  3. ;
  4. ;
  5. ;
  6. ;
  7. ; *READ
  8. ;
  9. ; READ IN TRACK,SECTOR SPECIFIED
  10. ; IN HEADER
  11. ;
  12. ;
  13. REED CMP #0 ; TEST IF READ JOB
  14. BEQ READ01 ; GO TEST IF WRITE
  15. JMP WRIGHT
  16. ;
  17. READ01 JSR DSTRT ; FIND HEADER AND START READING DATA
  18. ;
  19. READ11 BVC * ; WAIT FOR BYTE
  20. CLV
  21. ;
  22. LDA DATA2 ; STORE AWAY DATA
  23. STA (BUFPNT),Y ; IN DATA BUFFER
  24. INY
  25. BNE READ11
  26. ;
  27. LDY #255-TOPRD ; STORE REST IN OVERFLOW BUFFER
  28. ;
  29. READ20 BVC *
  30. CLV
  31. ;
  32. LDA DATA2
  33. STA OVRBUF,Y
  34. INY
  35. BNE READ20
  36. ;
  37. JSR GCRBIN ; CONVERT BUFFER TO BINARY
  38. ;
  39. LDA BID ; TEST IF ITS A DATA BLOCK
  40. CMP DBID
  41. BEQ READ28
  42. ;
  43. LDA #4 ; NOT A DATA BLOCK
  44. JMP ERRR
  45. ;
  46. READ28 JSR CHKBLK ; CALC CHECKSUM
  47. ;
  48. CMP CHKSUM
  49. BEQ READ40
  50. ;
  51. LDA #5 ; DATA BLOCK CHECKSUM ERROR
  52. .BYTE SKIP2
  53. ;
  54. READ40 LDA #1 ; READ DATA BLOCK OK
  55. JMP ERRR
  56. ;
  57. ;
  58. ;
  59. DSTRT JSR SRCH ; FIND HEADER
  60. JMP SYNC ; AND THEN DATA BLOCK SYNC
  61. ;
  62. ;
  63. SRCH LDA DRIVE ; CREATE HEADER IMAGE
  64. ASL A
  65. TAX
  66. ;
  67. LDA DSKID,X ; GET MASTER ID FOR THE DRIVE
  68. STA HEADER
  69. LDA DSKID+1,X
  70. STA HEADER+1
  71. ;
  72. LDY #0 ; GET TRACK,SECTOR
  73. LDA (HDRPNT),Y
  74. STA HEADER+2
  75. INY
  76. LDA (HDRPNT),Y
  77. STA HEADER+3
  78. ;
  79. LDA #0
  80. ;CREATE HEADER CHECKSUM
  81. EOR HEADER
  82. EOR HEADER+1
  83. EOR HEADER+2
  84. EOR HEADER+3
  85. ;
  86. STA HEADER+4 ; STORE THE CHECKSUM
  87. ;
  88. JSR CONHDR ; CONVERT HEADER TO GCR
  89. ;
  90. LDX #90 ; SEARCH 90 SYNC CHARS
  91. ;
  92. SRCH20 JSR SYNC ; FIND SYNC
  93. ;
  94. LDY #0 ; TEST 8 GCR BYTES
  95. ;
  96. SRCH25 BVC *
  97. CLV ; WAIT FOR BYTE
  98. ;
  99. LDA DATA2
  100. CMP STAB,Y ; TEST IF THE SAME
  101. BNE SRCH30 ; NOPE
  102. ;
  103. INY
  104. CPY #8
  105. BNE SRCH25
  106. ;
  107. RTS
  108. ;
  109. ;
  110. SRCH30 DEX ;TRY AGAIN
  111. BNE SRCH20
  112. ;
  113. LDA #2 ; CANT FIND THIS HEADER
  114. ERR JMP ERRR
  115. ;
  116. ;
  117. ;
  118. ;
  119. SYNC
  120. ;
  121. LDA #$80+80 ; WAIT 20 MS FOR SYNC MAX
  122. STA TIMER1
  123. ;
  124. LDA #3 ; ERROR CODE FOR NO SYNC
  125. ;
  126. SYNC10 BIT TIMER1 ; TEST FOR TIME OUT
  127. BPL ERR
  128. BIT DSKCNT ; TEST FOR SYNC
  129. BMI SYNC10
  130. ;
  131. ;
  132. LDA DATA2 ; RESET PA LATCH
  133. CLV
  134. LDY #0 ; CLEAR POINTER
  135. RTS
  136. ;
  137. ;
  138. ;
  139. .END