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.src 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. .page 'frets'
  2. ; mark a track,sector as free in bam
  3. wfree
  4. jsr fixbam
  5. ;
  6. frets
  7. jsr freuse ; calc index into bam
  8. frets2
  9. sec ; flag for no action
  10. bne frerts ; free already
  11. lda (bmpnt),y ; not free, free it
  12. ora bmask,x
  13. sta (bmpnt),y
  14. jsr dtybam ; set dirty flag
  15. ldy temp
  16. clc
  17. lda (bmpnt),y ; add one
  18. adc #1
  19. sta (bmpnt),y
  20. lda track
  21. cmp dirtrk
  22. beq use10
  23. ;
  24. inc ndbl,x
  25. bne fre10
  26. inc ndbh,x
  27. fre10
  28. frerts rts
  29. ;
  30. dtybam
  31. ldx drvnum
  32. lda #1
  33. sta mdirty,x ; set dirty flag
  34. rts
  35. ;
  36. ; mark track,sector,(bmpnt) as used
  37. ;
  38. wused
  39. jsr fixbam
  40. ;
  41. usedts ; calc in dex into bam
  42. jsr freuse ; calc in dex into bam
  43. beq userts ; used, no action
  44. lda (bmpnt),y ; get bits
  45. eor bmask,x ; mark sec used
  46. sta (bmpnt),y
  47. jsr dtybam
  48. ldy temp
  49. lda (bmpnt),y ; get count
  50. sec
  51. sbc #1 ; dec one (c=0)
  52. sta (bmpnt),y ; save it
  53. lda track
  54. cmp dirtrk
  55. beq use20
  56. ;
  57. lda ndbl,x
  58. bne use10
  59. dec ndbh,x
  60. use10
  61. dec ndbl,x
  62. use20
  63. lda ndbh,x
  64. bne userts
  65. lda ndbl,x
  66. ;##### GCB 11/20/86 disk full bug ######################################
  67. jmp ptch28
  68. nop
  69. ; cmp #3
  70. ; bcs userts
  71. ;#######################################################################
  72. ;
  73. lda #dskful
  74. jsr errmsg
  75. userts rts
  76. ;
  77. ; calculates index into bam
  78. ; for frets and usedts
  79. ;
  80. freuse
  81. jsr setbam
  82. tya
  83. freus2
  84. sta temp ; save index
  85. freus3
  86. lda sector ; a=sector/8
  87. lsr a
  88. lsr a
  89. lsr a ; for which of three bytes
  90. sec
  91. adc temp ; calc index
  92. tay
  93. lda sector ; bit in that byte
  94. and #7
  95. tax
  96. lda (bmpnt),y ; get the byte
  97. and bmask,x ; test it
  98. rts ; z=1=used,z=0=free
  99. ;
  100. ;
  101. bmask .byte 1,2,4,8,16,32,64,128
  102. ;
  103. fixbam ; write the bam according to wbam flag
  104. lda #$ff
  105. bit wbam
  106. beq fbam10 ; test flags
  107. bpl fbam10
  108. bvs fbam10
  109. ;
  110. lda #0
  111. sta wbam ; clear flag
  112. jmp dowrit
  113. ;
  114. fbam10
  115. rts
  116. ;
  117. ;
  118. ; clear the bam area
  119. ;
  120. clrbam
  121. jsr setbpt
  122. ldy #0
  123. tya
  124. clb1
  125. sta (bmpnt),y
  126. iny
  127. bne clb1
  128. rts
  129. ;
  130. setbam ; set bam image in memory
  131. lda t0 ; save temps
  132. pha
  133. lda t1
  134. pha
  135. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  136. jmp ptch18 ; *rom ds 09/03/85* *GCB 11/20/86 SAVE @ bug *
  137. nop ; fill
  138. ; ldx drvnum
  139. ; lda nodrv,x
  140. rtch18
  141. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  142. beq sbm10
  143. ;
  144. lda #nodriv ; no drive
  145. jsr cmder3
  146. sbm10
  147. jsr bam2a
  148. sta t0 ; t0:= index into buf0
  149. txa
  150. asl a
  151. sta t1 ; t1:= 2*drvnum
  152. tax
  153. lda track
  154. cmp tbam,x ; check bam table for track
  155. beq sbm30 ; it's in
  156. ;
  157. inx
  158. stx t1 ; check next entry
  159. cmp tbam,x
  160. beq sbm30 ; it's in
  161. ;
  162. jsr swap ; swap track bam in table
  163. sbm30
  164. lda t1
  165. ldx drvnum
  166. sta ubam,x ; set last used ptr
  167. asl a
  168. asl a
  169. clc
  170. adc #<bam ; set actual ptr
  171. sta bmpnt
  172. lda #>bam
  173. adc #0
  174. sta bmpnt+1
  175. ldy #0
  176. pla
  177. sta t1
  178. pla
  179. sta t0
  180. rts
  181. ;
  182. ;
  183. swap ; swap images of bam
  184. ldx t0
  185. jsr redbam ; read bam if not in
  186. lda drvnum
  187. tax
  188. asl a
  189. ora ubam,x ; swap out least used image
  190. eor #1
  191. and #3
  192. sta t1
  193. jsr putbam ; put to bam
  194. lda jobnum
  195. asl a
  196. tax
  197. lda track
  198. asl a
  199. asl a
  200. sta buftab,x ; set ptr
  201. lda t1
  202. asl a
  203. asl a
  204. tay
  205. swap3 ; transfer bam to mem image
  206. lda (buftab,x)
  207. sta bam,y
  208. lda #0
  209. sta (buftab,x) ; clear bam
  210. inc buftab,x
  211. iny
  212. tya
  213. and #3
  214. bne swap3
  215. ;
  216. ldx t1
  217. lda track
  218. sta tbam,x ; set track # for image
  219. ;
  220. lda wbam
  221. bne swap4 ; don't write now
  222. jmp dowrit
  223. swap4
  224. ora #$80 ; set pending write flag
  225. sta wbam
  226. rts
  227. ;
  228. putbam ; put mem image to bam
  229. tay
  230. lda tbam,y
  231. beq swap2 ; no image here
  232. ;
  233. pha ; save track #
  234. lda #0
  235. sta tbam,y ; clear track flag
  236. lda jobnum
  237. asl a
  238. tax
  239. pla
  240. asl a
  241. asl a
  242. sta buftab,x ; set ptr in bam
  243. tya
  244. asl a
  245. asl a
  246. tay
  247. swap1 ; transfer image to bam
  248. lda bam,y
  249. sta (buftab,x)
  250. lda #0
  251. sta bam,y ; clear image
  252. inc buftab,x
  253. iny
  254. tya
  255. and #3
  256. bne swap1
  257. swap2
  258. rts
  259. ;
  260. ;
  261. clnbam ; clean track # for images
  262. lda drvnum
  263. asl a
  264. tax
  265. lda #0
  266. sta tbam,x
  267. inx
  268. sta tbam,x
  269. rts
  270. ;
  271. ;
  272. ;
  273. redbam ; read in bam if not present
  274. lda buf0,x
  275. cmp #$ff
  276. bne rbm20 ; it is in memory
  277. txa
  278. pha ; save channel ptr
  279. jsr getbuf ; go find a buffer
  280. tax
  281. bpl rbm10
  282. ;
  283. lda #nochnl ; no buffers around
  284. jsr cmderr
  285. rbm10
  286. stx jobnum ; save jobnum assigned
  287. pla
  288. tay
  289. txa
  290. ora #$80
  291. sta buf0,y ; set as inactive for stealing
  292. ;read in bam
  293. asl a
  294. tax
  295. lda dirtrk
  296. sta hdrs,x
  297. lda #0
  298. sta hdrs+1,x
  299. jmp doread
  300. rbm20
  301. and #$f ; set bam's jobnum
  302. sta jobnum
  303. rts
  304. ;
  305. ;set bam pointer in buf0/1 tables
  306. ;
  307. bam2a ; leave in .a
  308. lda #blindx
  309. ldx drvnum
  310. bne b2x10
  311. ;
  312. clc
  313. adc #mxchns+1
  314. b2x10
  315. rts
  316. ;
  317. bam2x ; leave in .x
  318. jsr bam2a
  319. tax
  320. rts
  321. ;
  322. ;
  323. ; .end