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.

record.src 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. .page 'record'
  2. ;*********************************
  3. ;* record: position relative *
  4. ;* pointers to given *
  5. ;* record number or to *
  6. ;* last record if out of *
  7. ;* range. *
  8. ;*********************************
  9. ;
  10. record
  11. jsr cmdset ; init tables, ptrs
  12. lda cmdbuf+1
  13. sta sa
  14. jsr fndrch
  15. bcc r20 ; got channel's lindex
  16. ;
  17. lda #nochnl ; no valid channel
  18. jsr cmderr
  19. r20
  20. lda #lrf+ovrflo
  21. jsr clrflg
  22. jsr typfil ; get file type
  23. beq r30 ; it is relative file
  24. ;
  25. lda #mistyp ; wrong type
  26. jsr cmderr
  27. r30
  28. lda filtyp,x
  29. and #1
  30. sta drvnum
  31. lda cmdbuf+2
  32. sta recl,x ; get record #
  33. lda cmdbuf+3
  34. sta rech,x
  35. ldx lindx ; clear chnrdy to rndrdy
  36. lda #rndrdy
  37. sta chnrdy,x
  38. ;
  39. lda cmdbuf+4 ; get offset
  40. beq r40
  41. sec
  42. sbc #1
  43. beq r40
  44. cmp rs,x
  45. bcc r35
  46. ;
  47. lda #recovf
  48. sta erword
  49. lda #0
  50. r35
  51. r40
  52. sta recptr ; set offset
  53. jsr fndrel ; calc ss stuff
  54. jsr sspos ; set ss ptrs
  55. bvc r50
  56. ;
  57. lda #lrf ; beyond the end
  58. jsr setflg ; set last rec flag
  59. jmp rd05
  60. r50
  61. jsr positn ; position to record
  62. lda #lrf
  63. jsr tstflg
  64. beq r60
  65. jmp rd05
  66. r60
  67. jmp endcmd ; that's all
  68. ;
  69. ;*********************************
  70. ;* positn: position relative *
  71. ;* data block into active*
  72. ;* buffer & next block *
  73. ;* into inactive buffer. *
  74. ;*********************************
  75. ;
  76. positn
  77. ; jsr restor ;restore buffer areas
  78. jsr posbuf ; position buffers
  79. lda relptr
  80. jsr setpnt ; set ptr from fndrel
  81. ;
  82. ldx lindx
  83. lda rs,x
  84. sec ; calc the offset
  85. sbc recptr
  86. bcs p2
  87. jmp break ; should not be needed
  88. p2
  89. clc
  90. adc relptr
  91. bcc p30
  92. adc #1
  93. sec
  94. p30
  95. jsr nxout ; set nr
  96. jmp rd15
  97. lda #recovf
  98. jsr cmderr
  99. ;* posbuf: position proper data *
  100. ;* blocks into buffers *
  101. ;*********************************
  102. ;
  103. posbuf
  104. lda dirbuf
  105. sta r3
  106. lda dirbuf+1
  107. sta r4
  108. jsr bhere ; is buffer in?
  109. bne p10 ; yes!
  110. rts
  111. p10
  112. jsr scrub ; clean buffer
  113. jsr getlnk
  114. lda track
  115. beq p80
  116. jsr bhere2
  117. bne p75
  118. jsr dblbuf
  119. jmp freiac
  120. p75
  121. jsr freiac
  122. ;
  123. p80
  124. ldy #0 ; get proper block
  125. lda (r3),y
  126. sta track
  127. iny
  128. lda (r3),y
  129. sta sector
  130. jmp strdbl ; get next block, too.
  131. ;rts
  132. ;
  133. bhere
  134. jsr gethdr ; get the header
  135. bhere2
  136. ldy #0
  137. lda (r3),y
  138. cmp track
  139. beq bh10 ; test sector, too.
  140. rts
  141. bh10
  142. iny
  143. lda (r3),y
  144. cmp sector ; set .z
  145. rts
  146. ;
  147. ; .end