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.fmt2 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. .PAGE 'LCC.FMT2'
  2. ;
  3. ;
  4. ;
  5. DS08 LDA #$66 ; MIN BLOCK SIZE 282*5/4 -256=85
  6. ;
  7. STA DTRCK
  8. ;
  9. LDX SECTR ; TOTAL BYTES= MIN*#SECORS
  10. LDY #0
  11. TYA
  12. ;
  13. DS10 CLC ; MIN*#SECTORS
  14. ADC DTRCK
  15. BCC DS14
  16. ;
  17. INY ;
  18. ;
  19. DS14 INY
  20. DEX
  21. BNE DS10
  22. ;
  23. EOR #$FF ; GET 2S COMP
  24. SEC
  25. ADC #0
  26. ;
  27. CLC
  28. ADC TRAL+1
  29. BCS DS15
  30. ;
  31. DEC TRAL
  32. ;
  33. DS15 TAX
  34. TYA
  35. EOR #$FF
  36. SEC
  37. ADC #0
  38. CLC
  39. ADC TRAL
  40. ;
  41. BPL DS17
  42. ;
  43. LDA #TOBIG ; NOT ENOUGH SPACE
  44. JMP FMTERR
  45. ;
  46. DS17 TAY
  47. TXA
  48. LDX #0
  49. ;
  50. DS20 SEC
  51. SBC SECTR
  52. BCS DS22
  53. ;
  54. DEY
  55. BMI DS30
  56. ;
  57. DS22 INX
  58. BNE DS20
  59. ;
  60. DS30 STX DTRCK
  61. CPX #GAP2 ; TEST FOR MIN SIZE
  62. BCS DS32
  63. ;
  64. LDA #TOSMAL ; GAP2 TO SMALL
  65. JMP FMTERR
  66. ;
  67. DS32 CLC
  68. ADC SECTR
  69. STA REMDR ; GET REMAIDER SIZE
  70. ;
  71. ;
  72. ;
  73. ;
  74. ;
  75. ; CREATE HEADER IMAGES
  76. ;
  77. ;
  78. LDA #0
  79. STA SECT
  80. ;
  81. LDY #0
  82. LDX DRIVE
  83. ;
  84. MAK10 LDA HBID ; HBID CS S T ID ID 0F 0F
  85. STA BUFF0,Y
  86. INY
  87. ;
  88. INY ; SKIP CHECKSUM
  89. ;
  90. LDA SECT ; STORE SECTOR #
  91. STA BUFF0,Y
  92. INY
  93. ;
  94. LDA FTNUM ; STORE TRACK #
  95. STA BUFF0,Y
  96. INY
  97. ;
  98. LDA DSKID+1,X ; STORE ID LOW
  99. STA BUFF0,Y
  100. INY
  101. ;
  102. LDA DSKID,X ; STORE ID HI
  103. STA BUFF0,Y
  104. INY
  105. ;
  106. LDA #$0F ; STORE GAP1 BYTES
  107. STA BUFF0,Y
  108. INY
  109. STA BUFF0,Y
  110. INY
  111. ;
  112. LDA #0 ;CREATE CHECKSUM
  113. EOR BUFF0-6,Y
  114. EOR BUFF0-5,Y
  115. EOR BUFF0-4,Y
  116. EOR BUFF0-3,Y
  117. ;
  118. STA BUFF0-7,Y ; STORE CHECKSUM
  119. ;
  120. ;
  121. INC SECT ; GOTO NEXT SECTOR
  122. ;
  123. LDA SECT ; TEST IF DONE YET
  124. CMP SECTR
  125. BCC MAK10 ; MORE TO DO
  126. ;
  127. TYA ; SAVE BLOCK SIZE
  128. PHA
  129. ;
  130. ;
  131. ;
  132. ;
  133. ; CREATE DATA BLOCK OF ZERO
  134. ;
  135. INX ; .X=0
  136. TXA
  137. ;
  138. CRTDAT STA BUFF2,X
  139. INX
  140. BNE CRTDAT
  141. ;
  142. ;
  143. ; CONVERT HEADER BLOCK TO GCR
  144. ;
  145. LDA #>BUFF0
  146. STA BUFPNT+1 ; POINT AT BUFFER
  147. ;
  148. JSR FBTOG ; CONVERT TO GCR WITH NO BID CHAR
  149. ;
  150. PLA ; RESTORE BLOCK SIZE
  151. TAY ; MOVE BUFFER UP 79 BYTES
  152. DEY ; FOR I=N-1 TO 0:MEM[I+69]:=MEM[I]:NEXT
  153. JSR MOVUP ;MOVE BUF0 UP 69 BYTES
  154. ;
  155. JSR MOVOVR ; MOVE OVRBUF UP TO BUFFER
  156. ;
  157. ;
  158. ;
  159. ; CONVERT DATA BLOCK TO GCR
  160. ; WRITE IMAGE
  161. ;
  162. ; LEAVE IT IN OVRBUF AND BUFFER
  163. ;
  164. ;
  165. LDA #>BUFF2 ; POINT AT BUFFER
  166. STA BUFPNT+1
  167. ;
  168. ;
  169. JSR CHKBLK ; GET BLOCK CHECKSUM
  170. STA CHKSUM
  171. JSR BINGCR
  172. ;
  173. ;
  174. ;
  175. ; START THE FORMAT NOW
  176. ;
  177. ; WRITE OUT SYNC HEADER GAP1
  178. ; DATA BLOCK
  179. ;
  180. ;
  181. ;
  182. LDA #0 ; INIT COUNTER
  183. STA HDRPNT
  184. ;
  185. JSR CLEAR ; CLEAR DISK
  186. ;
  187. WRTSYN LDA #$FF ; WRITE SYNC
  188. STA DATA2
  189. ;
  190. LDX #NUMSYN ; WRITE 4 SYNC
  191. ;
  192. WRTS10 BVC *
  193. CLV
  194. ;
  195. DEX
  196. BNE WRTS10
  197. ;
  198. LDX #10 ; WRITE OUT HEADER
  199. LDY HDRPNT
  200. ;
  201. WRTS20 BVC *
  202. CLV
  203. ;
  204. LDA BUFF0,Y ; GET HEADER DATA
  205. STA DATA2
  206. ;
  207. INY
  208. DEX
  209. BNE WRTS20
  210. ;
  211. ;
  212. ; * WRITE OUT GAP1
  213. ;
  214. LDX #GAP1-2 ; WRITE GCR BYTES
  215. ;
  216. WRTS30 BVC *
  217. CLV
  218. ;
  219. LDA #$55
  220. STA DATA2
  221. ;
  222. DEX
  223. BNE WRTS30
  224. ;
  225. ;
  226. ;
  227. ; * WRITE OUT DATA BLOCK
  228. ;
  229. LDA #$FF ; WRITE DATA BLOCK SYNC
  230. ;
  231. LDX #NUMSYN
  232. ;
  233. DBSYNC BVC *
  234. CLV
  235. ;
  236. STA DATA2
  237. ;
  238. DEX
  239. BNE DBSYNC
  240. ;
  241. LDX #256-TOPWRT ; WRITE OUT OVRBUF
  242. ;
  243. WRTS40 BVC *
  244. CLV
  245. ;
  246. LDA OVRBUF,X
  247. STA DATA2
  248. ;
  249. INX
  250. BNE WRTS40
  251. ;
  252. ;
  253. LDY #0
  254. ;
  255. WRTS50 BVC *
  256. CLV
  257. ;
  258. LDA (BUFPNT),Y
  259. STA DATA2
  260. ;
  261. INY
  262. BNE WRTS50
  263. ;
  264. LDA #$55 ; WRITE GAP2(DTRCK)
  265. LDX DTRCK
  266. ;
  267. WGP2 BVC *
  268. CLV
  269. ;
  270. STA DATA2
  271. DEX
  272. BNE WGP2
  273. ;
  274. ; LDX #20 ; WRITE ERASE TRAIL GAP
  275. ;WGP3 BVC *
  276. ; CLV
  277. ; DEX
  278. ; BNE WGP3
  279. ;
  280. LDA HDRPNT ; ADVANCE HEADER POINTER
  281. CLC
  282. ADC #10
  283. STA HDRPNT
  284. ;
  285. ;
  286. ;
  287. ; DONE WRITING SECTOR
  288. ;
  289. DEC SECT ; GO TO NEXT ON
  290. BNE WRTSYN ; MORE TO DO
  291. ;
  292. BVC * ; WAIT FOR LAST ONE TO WRITE
  293. CLV
  294. ;
  295. BVC *
  296. CLV
  297. ;
  298. JSR KILL ; GOTO READ MODE
  299. ;
  300. ;
  301. ;
  302. .END