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.fmt1 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. .PAGE 'LCC.FMT1'
  2. ;
  3. FMTVAR =$620 ; PUT FORMAT VARS IN JUMP BUFFER
  4. CNT = FMTVAR
  5. NUM = FMTVAR+1
  6. TRYS = FMTVAR+3
  7. TRAL = FMTVAR+4
  8. DTRCK= FMTVAR+6
  9. REMDR= FMTVAR+7
  10. SECT = FMTVAR+8
  11. ;
  12. ;
  13. ;
  14. ;* FORMAT ROUTINE FOR LCC
  15. ;*
  16. ;*
  17. ;*
  18. ;
  19. ;
  20. ;
  21. CODE
  22. FORMT LDA FTNUM ; TEST IF FORMATTING BEGUN
  23. BPL L213 ; YES
  24. ;
  25. LDX DRIVE ; NO,START UP BY BUMPING
  26. LDA #$60 ; STATUS=STEPPING
  27. STA DRVST,X
  28. ;
  29. LDA #1 ; DRIVE TRACK =1
  30. STA DRVTRK,X
  31. STA FTNUM ; START ON TRACK 1
  32. ;
  33. LDA #256-92 ; BUMP BACK 45 STEPS
  34. STA STEPS
  35. ;
  36. LDA DSKCNT ;SET PHASE A
  37. AND #$FF-$03
  38. STA DSKCNT
  39. ;
  40. ;
  41. LDA #10 ; 10 ERRORS ALLOWED
  42. STA CNT
  43. ;
  44. LDA #<4000 ; FIRST GUESS AT TRACK SIZE
  45. STA NUM
  46. LDA #>4000
  47. STA NUM+1
  48. ;
  49. JMP END ; BACK TO CONTROLLER
  50. ;
  51. ;
  52. ;
  53. L213 LDY #0 ; TEST IF ON RIGHT TRACK NUMBER
  54. CMP (HDRPNT),Y
  55. BEQ L214
  56. ;
  57. STA (HDRPNT),Y ; GOTO RIGHT TRACK
  58. JMP END
  59. ;
  60. ;
  61. L214 LDA DSKCNT ; TEST FOR WRITE PROTECT
  62. AND #$10
  63. BNE TOPP ; ITS OK
  64. ;
  65. LDA #8 ; WRITE PROTECT ERROR
  66. JMP FMTERR
  67. ;
  68. TOPP JSR SYNCLR ; ERASE TRACK WITH SYNC
  69. ;
  70. JSR WRTNUM ; WRITE OUT NUM SYNCS
  71. ;
  72. LDA #$55 ; WRITE OUT NUM NON SYNC
  73. STA DATA2
  74. ;
  75. JSR WRTNUM
  76. ;
  77. JSR KILL ; KILL WRITE
  78. ;
  79. JSR SYNC ; FIND SYNC
  80. ;
  81. LDA #$40 ; SET TIMER MODE
  82. ORA ACR1
  83. STA ACR1
  84. ;
  85. LDA #100-2 ; SET UP 100US TIMER
  86. STA T1LL1 ; CONT MODE TIMER
  87. LDA #0
  88. STA T1HL1 ; HI LATCH
  89. STA T1HC1 ; GET ATTENTION OF '22
  90. ;
  91. ;
  92. ;
  93. LDY #0 ; TIME THE SYNC AND NONSYNC SEGMENTS
  94. LDX #0
  95. ;
  96. FWAIT BIT DSKCNT ; WAIT FOR SYNC
  97. BMI FWAIT
  98. ;
  99. FWAIT2 BIT DSKCNT ; WAIT FOR NO SYNC
  100. BPL FWAIT2
  101. ;
  102. F000 LDA T1LC1 ; RESET IFR
  103. ;
  104. F001 BIT DSKCNT ; TIME NONSYNC AREA
  105. BPL F005 ; TIME UNTIL SYNC FOUND
  106. ;
  107. LDA IFR1 ; TEST FOR TIME OUT
  108. ASL A
  109. BPL F001 ; NOT YET
  110. ;
  111. INX ; .X IS LSB
  112. BNE F000
  113. INY ; .Y IS MSB
  114. BNE F000
  115. ;
  116. LDA #TOLONG ; CANT FIND SYNC
  117. JMP FMTERR
  118. ;
  119. F005 STX T2 ; SAVE TIME
  120. STY T2+1
  121. ;
  122. LDX #0 ; TIME SYNC AREA
  123. LDY #0
  124. ;
  125. F006 LDA T1LC1 ; RESET IFR
  126. ;
  127. F007 BIT DSKCNT ; TEST FOR NO SYNC
  128. BMI F009
  129. ;
  130. LDA IFR1 ; TEST FOR TIME OUT
  131. ASL A
  132. BPL F007
  133. ;
  134. INX ; COUNT UP ANOTHER 100US
  135. BNE F006
  136. INY ; MSB
  137. BNE F006
  138. ;
  139. LDA #TOLONG ; CANT BE THIS LONG
  140. JMP FMTERR
  141. ;
  142. ;
  143. ;* NOW CALC THE DIFFERENCE BETWEEN
  144. ;* SYNC AND NONSYNC AND ADJUST
  145. ;* NUM ACCORDINGLY
  146. ;
  147. F009 SEC ; T1-T2
  148. TXA
  149. SBC T2
  150. TAX
  151. STA T1
  152. ;
  153. TYA
  154. SBC T2+1
  155. TAY
  156. STA T1+1
  157. ;
  158. BPL F013 ; GET ABS(T1-T2)
  159. ;
  160. EOR #$FF ; MAKE +
  161. TAY
  162. TXA
  163. EOR #$FF
  164. TAX
  165. INX
  166. BNE F013
  167. INY
  168. ;
  169. F013 TYA ; TEST IF ABS(T1-T2)<4, THAT IS CLOSE ENOUGH
  170. BNE F014 ; MSB MUST BE 0
  171. ;
  172. CPX #4 ; TEST LSB < 4
  173. BCC COUNT ; ITS THERE
  174. ;
  175. F014 ASL T1 ; NUM=NUM+(DIFF/2)
  176. ROL T1+1
  177. ;
  178. CLC
  179. LDA T1
  180. ADC NUM
  181. STA NUM
  182. ;
  183. LDA T1+1
  184. ADC NUM+1
  185. STA NUM+1
  186. ;
  187. JMP TOPP ; TRY AGAIN SAM
  188. ;
  189. ;
  190. COUNT LDX #0 ; NOW COUNT #BYTES IN DATA SEGMENT
  191. LDY #0
  192. CLV
  193. ;
  194. CNT10 LDA DSKCNT ; TEST FOR SYNC
  195. BPL CNT20 ; FOUND SYNC
  196. BVC CNT10 ; TEST IF BYTE TIME
  197. ;
  198. CLV ; YES, COUNT IT
  199. INX
  200. BNE CNT10 ; KEEP COUNTING
  201. INY
  202. BNE CNT10 ; TO MANY ?
  203. ;
  204. LDA #TOMANY ; TOMANY COUNTS
  205. JMP FMTERR
  206. ;
  207. CNT20 TXA ; #BYTES=COUNT*2
  208. ASL A
  209. STA TRAL+1
  210. ;
  211. TYA
  212. ROL A
  213. STA TRAL
  214. ;
  215. LDA #$FF-$40 ; CLEAR CONT MODE
  216. AND ACR1
  217. STA ACR1
  218. ;
  219. ;
  220. .END