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.

lccread.src 2.8KB

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