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.

frets 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. .PAGE 'FRETS'
  2. .SKIP
  3. ; MARK A TRACK,SECTOR AS FREE IN BAM
  4. WFREE
  5. JSR FIXBAM
  6. ;
  7. FRETS
  8. JSR FREUSE ;CALC INDEX INTO BAM
  9. FRETS2
  10. SEC ;FLAG FOR NO ACTION
  11. BNE FRERTS ;FREE ALREADY
  12. LDA (BMPNT),Y ;NOT FREE, FREE IT
  13. ORA BMASK,X
  14. STA (BMPNT),Y
  15. JSR DTYBAM ;SET DIRTY FLAG
  16. LDY TEMP
  17. CLC
  18. LDA (BMPNT),Y ;ADD ONE
  19. ADC #1
  20. STA (BMPNT),Y
  21. LDA TRACK
  22. CMP DIRTRK
  23. BEQ USE10
  24. ;
  25. INC NDBL,X
  26. BNE FRE10
  27. INC NDBH,X
  28. FRE10
  29. FRERTS RTS
  30. ;
  31. DTYBAM
  32. LDX DRVNUM
  33. LDA #1
  34. STA MDIRTY,X ;SET DIRTY FLAG
  35. RTS
  36. ;
  37. ; MARK TRACK,SECTOR,(BMPNT) AS USED
  38. ;
  39. WUSED
  40. JSR FIXBAM
  41. ;
  42. USEDTS ;CALC IN DEX INTO BAM
  43. JSR FREUSE ;CALC IN DEX INTO BAM
  44. BEQ USERTS ;USED, NO ACTION
  45. LDA (BMPNT),Y ;GET BITS
  46. EOR BMASK,X ;MARK SEC USED
  47. STA (BMPNT),Y
  48. JSR DTYBAM
  49. LDY TEMP
  50. LDA (BMPNT),Y ;GET COUNT
  51. SEC
  52. SBC #1 ; DEC ONE (C=0)
  53. STA (BMPNT),Y ;SAVE IT
  54. LDA TRACK
  55. CMP DIRTRK
  56. BEQ USE20
  57. ;
  58. LDA NDBL,X
  59. BNE USE10
  60. DEC NDBH,X
  61. USE10
  62. DEC NDBL,X
  63. USE20
  64. LDA NDBH,X
  65. BNE USERTS
  66. LDA NDBL,X
  67. CMP #3
  68. BCS USERTS
  69. ;
  70. LDA #DSKFUL
  71. JSR ERRMSG
  72. USERTS RTS
  73. ;
  74. ; CALCULATES INDEX INTO BAM
  75. ; FOR FRETS AND USEDTS
  76. ;
  77. FREUSE
  78. JSR SETBAM
  79. TYA
  80. FREUS2
  81. STA TEMP ;SAVE INDEX
  82. FREUS3
  83. LDA SECTOR ;A=SECTOR/8
  84. LSR A
  85. LSR A
  86. LSR A ;FOR WHICH OF THREE BYTES
  87. SEC
  88. ADC TEMP ;CALC INDEX
  89. TAY
  90. LDA SECTOR ;BIT IN THAT BYTE
  91. AND #7
  92. TAX
  93. LDA (BMPNT),Y ;GET THE BYTE
  94. AND BMASK,X ;TEST IT
  95. RTS ;Z=1=USED,Z=0=FREE
  96. ;
  97. ;
  98. BMASK .BYTE 1,2,4,8,16,32,64,128
  99. ;
  100. FIXBAM ;WRITE THE BAM ACCORDING TO WBAM FLAG
  101. LDA #$FF
  102. BIT WBAM
  103. BEQ FBAM10 ;TEST FLAGS
  104. BPL FBAM10
  105. BVS FBAM10
  106. ;
  107. LDA #0
  108. STA WBAM ;CLEAR FLAG
  109. JMP DOWRIT
  110. ;
  111. FBAM10
  112. RTS
  113. ;
  114. ;
  115. ; CLEAR THE BAM AREA
  116. ;
  117. CLRBAM
  118. JSR SETBPT
  119. LDY #0
  120. TYA
  121. CLB1
  122. STA (BMPNT)Y
  123. INY
  124. BNE CLB1
  125. RTS
  126. ;
  127. SETBAM ;SET BAM IMAGE IN MEMORY
  128. LDA T0 ;SAVE TEMPS
  129. PHA
  130. LDA T1
  131. PHA
  132. LDX DRVNUM
  133. LDA NODRV,X
  134. BEQ SBM10
  135. ;
  136. LDA #NODRIV ;NO DRIVE
  137. JSR CMDER3
  138. SBM10
  139. JSR BAM2A
  140. STA T0 ;T0:= INDEX INTO BUF0
  141. TXA
  142. ASL A
  143. STA T1 ;T1:= 2*DRVNUM
  144. TAX
  145. LDA TRACK
  146. CMP TBAM,X ;CHECK BAM TABLE FOR TRACK
  147. BEQ SBM30 ;IT'S IN
  148. ;
  149. INX
  150. STX T1 ;CHECK NEXT ENTRY
  151. CMP TBAM,X
  152. BEQ SBM30 ;IT'S IN
  153. ;
  154. JSR SWAP ;SWAP TRACK BAM IN TABLE
  155. SBM30
  156. LDA T1
  157. LDX DRVNUM
  158. STA UBAM,X ;SET LAST USED PTR
  159. ASL A
  160. ASL A
  161. CLC
  162. ADC #<BAM ;SET ACTUAL PTR
  163. STA BMPNT
  164. LDA #>BAM
  165. ADC #0
  166. STA BMPNT+1
  167. LDY #0
  168. PLA
  169. STA T1
  170. PLA
  171. STA T0
  172. RTS
  173. ;
  174. ;
  175. SWAP ;SWAP IMAGES OF BAM
  176. LDX T0
  177. JSR REDBAM ;READ BAM IF NOT IN
  178. LDA DRVNUM
  179. TAX
  180. ASL A
  181. ORA UBAM,X ;SWAP OUT LEAST USED IMAGE
  182. EOR #1
  183. AND #3
  184. STA T1
  185. JSR PUTBAM ;PUT TO BAM
  186. LDA JOBNUM
  187. ASL A
  188. TAX
  189. LDA TRACK
  190. ASL A
  191. ASL A
  192. STA BUFTAB,X ;SET PTR
  193. LDA T1
  194. ASL A
  195. ASL A
  196. TAY
  197. SWAP3 ;TRANSFER BAM TO MEM IMAGE
  198. LDA (BUFTAB,X)
  199. STA BAM,Y
  200. LDA #0
  201. STA (BUFTAB,X) ;CLEAR BAM
  202. INC BUFTAB,X
  203. INY
  204. TYA
  205. AND #3
  206. BNE SWAP3
  207. ;
  208. LDX T1
  209. LDA TRACK
  210. STA TBAM,X ;SET TRACK # FOR IMAGE
  211. ;
  212. LDA WBAM
  213. BNE SWAP4 ;DON'T WRITE NOW
  214. JMP DOWRIT
  215. SWAP4
  216. ORA #$80 ;SET PENDING WRITE FLAG
  217. STA WBAM
  218. RTS
  219. ;
  220. PUTBAM ;PUT MEM IMAGE TO BAM
  221. TAY
  222. LDA TBAM,Y
  223. BEQ SWAP2 ;NO IMAGE HERE
  224. ;
  225. PHA ;SAVE TRACK #
  226. LDA #0
  227. STA TBAM,Y ;CLEAR TRACK FLAG
  228. LDA JOBNUM
  229. ASL A
  230. TAX
  231. PLA
  232. ASL A
  233. ASL A
  234. STA BUFTAB,X ;SET PTR IN BAM
  235. TYA
  236. ASL A
  237. ASL A
  238. TAY
  239. SWAP1 ;TRANSFER IMAGE TO BAM
  240. LDA BAM,Y
  241. STA (BUFTAB,X)
  242. LDA #0
  243. STA BAM,Y ;CLEAR IMAGE
  244. INC BUFTAB,X
  245. INY
  246. TYA
  247. AND #3
  248. BNE SWAP1
  249. SWAP2
  250. RTS
  251. ;
  252. ;
  253. CLNBAM ;CLEAN TRACK # FOR IMAGES
  254. LDA DRVNUM
  255. ASL A
  256. TAX
  257. LDA #0
  258. STA TBAM,X
  259. INX
  260. STA TBAM,X
  261. RTS
  262. ;
  263. ;
  264. ;
  265. REDBAM ;READ IN BAM IF NOT PRESENT
  266. LDA BUF0,X
  267. CMP #$FF
  268. BNE RBM20 ;IT IS IN MEMORY
  269. TXA
  270. PHA ;SAVE CHANNEL PTR
  271. JSR GETBUF ;GO FIND A BUFFER
  272. TAX
  273. BPL RBM10
  274. ;
  275. LDA #NOCHNL ;NO BUFFERS AROUND
  276. JSR CMDERR
  277. RBM10
  278. STX JOBNUM ;SAVE JOBNUM ASSIGNED
  279. PLA
  280. TAY
  281. TXA
  282. ORA #$80
  283. STA BUF0,Y ;SET AS INACTIVE FOR STEALING
  284. ;READ IN BAM
  285. ASL A
  286. TAX
  287. LDA DIRTRK
  288. STA HDRS,X
  289. LDA #0
  290. STA HDRS+1,X
  291. JMP DOREAD
  292. RBM20
  293. AND #$F ;SET BAM'S JOBNUM
  294. STA JOBNUM
  295. RTS
  296. ;
  297. ;SET BAM POINTER IN BUF0/1 TABLES
  298. ;
  299. BAM2A ;LEAVE IN .A
  300. LDA #BLINDX
  301. LDX DRVNUM
  302. BNE B2X10
  303. ;
  304. CLC
  305. ADC #MXCHNS+1
  306. B2X10
  307. RTS
  308. ;
  309. BAM2X ;LEAVE IN .X
  310. JSR BAM2A
  311. TAX
  312. RTS
  313. ;
  314. ;
  315. .END