home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 6 / q06.d81 / quicktext.pal < prev    next >
Text File  |  2022-08-28  |  3KB  |  135 lines

  1. .org $1300
  2. ;
  3. r0 = $fa       ; 16-bit pseudo-reg #0
  4. r1 = r0+2      ; 16-bit pseudo-reg #1
  5. eol = $ae      ;
  6. topbase = $35  ; BASIC 7.0's string pointers
  7. beneath = $37  ; 
  8. cr = 13        ; carriage-return
  9.                ;
  10.                ;
  11. .obj "textfile2array.o"
  12.                ;
  13.                ;
  14. sta base       ; save pointer to string
  15. stx base+1     ;
  16.                ;
  17. ldy #0         ; NULL-terminate
  18. tya            ;  the text file
  19. sta (eol),y    ;
  20.                ;
  21. sta r0         ; Pointer to BASE of
  22. lda #$15       ;  BLOADed data 
  23. sta r0+1       ;
  24.                ;
  25. .byte $24      ; Skip over RTS instruction
  26.                ;
  27. steely = *
  28.                ;
  29. rts            ;
  30.                ;
  31.                ;------------------------
  32.                ;
  33. main = *
  34.                ;
  35. ldy #0         ; Init index register
  36.                ;
  37. traffic = *
  38.                ;
  39. lda (r0),y     ; Fetch a character
  40. beq steely     ;  exit if EOF
  41.                ;
  42. iny            ;
  43. cmp #cr        ; Is it a carriage return?
  44. beq kix        ;  branch if so
  45.                ;
  46. sta buffer-1,y ; Else store char
  47. bne traffic    ;  local buffer
  48.                ;
  49. kix = *
  50.                ;
  51. cpy #1         ;
  52. bne loco       ;
  53.                ;
  54. lda #$20       ; If the only char on that line
  55. sta buffer     ;  was a c/r, then substitute a SPACE
  56. clc            ;
  57. .byte $2c      ; skip next TWO instr's
  58.                ;
  59. loco = *
  60.                ;
  61. sec            ;
  62. dey            ;
  63.                ;
  64. sty length     ; Save length of current line
  65. tya            ; Update SOURCE pointer
  66. adc r0         ;
  67. sta r0         ;
  68. bcc cars       ;
  69. inc r0+1       ;
  70.                ;
  71. cars = *
  72.                ; Adjust 'TOPBASE'
  73.                ;
  74. sec            ; TOPBASE = 
  75. lda beneath    ;  BENEATH-LENGTH
  76. sbc length     ;
  77. sta topbase    ;
  78. lda beneath+1  ;
  79. sbc #0         ;
  80. sta topbase+1  ;
  81.                ;
  82. ldy #0         ;
  83.                ;
  84. legs = *
  85.                ;
  86. lda buffer,y   ; Copy the buffer to
  87. sta (topbase),y ; the destination
  88. iny            ;
  89. cpy length     ;
  90. bne legs       ;
  91.                ; Copy POINTER to
  92. lda base       ;  End of String
  93. sta (topbase),y ;
  94. sta r1         ;
  95. iny            ;
  96. lda base+1     ;
  97. sta (topbase),y ;
  98. sta r1+1       ;
  99.                ;
  100. ldy #0         ; MoveW LENGTH,(BASE)
  101. lda length     ;
  102. sta (r1),y     ;
  103. iny            ;
  104. lda topbase    ; MoveW [old TOPBASE],(BASE)
  105. sta (r1),y     ;
  106. iny            ;
  107. lda topbase+1  ;
  108. sta (r1),y     ;
  109.                ;
  110. sec            ; BENEATH = TOPBASE - 2
  111. lda topbase    ;
  112. sbc #2         ;
  113. sta beneath    ;
  114. lda topbase+1  ;
  115. sbc #0         ;
  116. sta beneath+1  ;
  117.                ;
  118. sec            ; BASE = BASE + 3
  119. tya            ;
  120. adc base       ;
  121. sta base       ;
  122. bcc dan        ;
  123. inc base+1     ;
  124.                ;
  125. dan = *
  126.                ;
  127. jmp main       ;
  128.                ;
  129.                ;
  130.                ;
  131. length .buf 1  ;
  132. base .buf 2    ;
  133. temp .buf 2    ;
  134. buffer .buf 1  ;
  135.