home *** CD-ROM | disk | FTP | other *** search
/ Loadstar - Compleat Programmer / comprog2.d81 / reader.ebud < prev    next >
Text File  |  2022-08-28  |  17KB  |  1,580 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. ;loadstar reader source
  8. ;4-26-922 by Jeff Jones
  9. ;"If you look, don't laugh."
  10.  
  11. open =$ffc0
  12. readst =$ffb7
  13. setlfs =$ffba
  14. setnam =$ffbd
  15. setmsg =$ff90
  16. load =$ffd5
  17. getin =$ffe4
  18. input'buffer =512
  19. clrchn =$ffcc
  20. close =$ffc3   ;a
  21. chrin =$ffcf
  22. chkout =$ffc9  ;x
  23. chkin =$ffc6   ;x
  24. plot =$fff0
  25. chrout =$ffd2
  26. color'pointer =243
  27. screen'line'pointer =209
  28. print'number =$bdcd ;x,a
  29. clear'line =59903
  30. background =53281
  31. border =53280
  32. strout = $ab1e; .A low .Y high
  33. unlisten =$ffae
  34. clall =$ffe7
  35. color1 =53282
  36. color2 =53283
  37. color3 =53284
  38. white =5
  39. crsr'down =17
  40. rvs'on =18
  41. home =19
  42. del =20
  43. red =28
  44. crsr'right =29
  45. green =30
  46. blue =31
  47. black =144
  48. lowercase =14
  49. uppercase =142
  50. crsr'up =145
  51. rvs'off =146
  52. clr =147
  53. insert =148
  54. brown =149
  55. light'red =150
  56. dark'grey =151
  57. medium'grey =152
  58. light'green =153
  59. light'blue =154
  60. light'grey =155
  61. purple =156
  62. crsr'left =157
  63. yellow =158
  64. cyan =159
  65. top'left =176
  66. top'right =174
  67. bottom'left =173
  68. bottom'right =189
  69.  
  70. .org $c000
  71. .obj "@0:reader c000"
  72. .mem
  73. jmp load'file;27
  74. jmp box'entry;;    3
  75. jmp linx;          12
  76. jmp print'at;15
  77. jmp center;18
  78. jmp read'existing;30
  79. jmp bload;51
  80. jmp frame'entry;54
  81. jmp get'scroll'up;57
  82. jmp get'scroll'down;60
  83. jmp clear'row;63
  84.  
  85.  
  86. ;sys,addr y,x1,x2,number items,text,highlight,esc
  87.  
  88. ;***sys addr,x,to x,y,to y,s-code,color
  89.  
  90. box'entry lda #5
  91. sta parm'count
  92. box'ii lda #0
  93. sta temp
  94. - jsr get'number
  95. tya
  96. ldy temp
  97. sta box'parameters,y
  98. inc temp
  99. cpy parm'count
  100. bne -
  101.  
  102. fill'box jsr linx
  103. lda 214
  104. pha
  105. lda 211
  106. pha
  107. box'start ldx box'parameters+2
  108. ldy #0
  109. clc
  110. jsr $fff0
  111. jsr old'rom'patch
  112. dec box'parameters
  113. ;inc box'parameters+3
  114.  
  115. - ldy box'parameters+1
  116. - lda box'parameters+4
  117. cmp #255
  118. beq +
  119. sta (209),y
  120. + lda box'parameters+5
  121. store'color sta (243),y
  122. dey
  123. cpy box'parameters
  124. bne -
  125. lda 214
  126. cmp box'parameters+3
  127. beq +
  128.  
  129. inc 214
  130. jsr 58732
  131. jsr old'rom'patch
  132. jmp --
  133. + lda #home
  134. jsr $ffd2
  135. pla
  136. sta 211
  137. pla
  138. sta 214
  139. jmp 58732
  140.  
  141. linx ldy #24
  142. - lda 217,y
  143. ora #128
  144. sta 217,y
  145. dey
  146. bpl -
  147. rts
  148.  
  149. ;**** get number from BASIC ****
  150.  
  151. get'number jsr $aefd
  152. jsr $ad8a
  153. jmp $b7f7
  154.  
  155. ;***** get string from BASIC ****
  156.  
  157. get'string jsr $aefd
  158. jsr $ad9e
  159. jsr $b6a3
  160.  
  161. ldx $22
  162. ldy $23
  163. rts
  164.  
  165. print'at jsr linx
  166. jsr get'number
  167. sty 211
  168. jsr get'number
  169. sty 214
  170. jsr 58732
  171. jsr get'string
  172. sta temp
  173.  
  174. print'string lda temp
  175. beq +
  176. ldy #0
  177. - lda ($22),y
  178. jsr chrout
  179. iny
  180. cpy temp
  181. bne -
  182. + rts
  183.  
  184. center jsr get'number
  185. tya
  186. tax
  187. ldy #0
  188. clc
  189. jsr plot
  190.  
  191. jsr get'string
  192. mcenter sta temp
  193.  
  194. lsr
  195. sta flag
  196. lda #20
  197. sec
  198. sbc flag
  199. sta 211
  200. jsr 58732
  201. jmp print'string
  202.  
  203. old'rom'patch lda 210
  204. sec
  205. sbc 648
  206. clc
  207. adc #$d8
  208. sta 244
  209. lda 209
  210. sta 243
  211. rts
  212.  
  213. bload jsr get'string
  214. jsr setnam
  215. jsr get'number
  216. tya
  217. tax
  218. lda #2
  219. ldy #0
  220. jsr setlfs
  221. jsr get'number
  222. sty base
  223. sta base+1
  224. ldx $14
  225. ldy $15
  226. lda #0
  227. jmp load
  228.  
  229. do'box stx 251
  230. sty 252
  231. ldy #5
  232. - lda (251),y
  233. sta box'parameters,y
  234. dey
  235. bpl -
  236. jmp fill'box
  237.  
  238. do'frame stx 251
  239. sty 252
  240. ldy #4
  241. - lda (251),y
  242. sta box'parameters,y
  243. dey
  244. bpl -
  245. jmp frame'up
  246.  
  247. frame'entry lda #4
  248. sta parm'count
  249. frame'ii lda #0
  250. sta temp
  251. - jsr get'number
  252. tya
  253. ldy temp
  254. sta box'parameters,y
  255. inc temp
  256. cpy parm'count
  257. bne -
  258.  
  259. frame'up jsr linx
  260. lda 214
  261. pha
  262. lda 211
  263. pha
  264. frame'start ldx box'parameters+2
  265. ldy #0
  266. clc
  267. jsr plot  
  268. jsr old'rom'patch
  269. ;dec box'parameters
  270.  
  271. ldy box'parameters+1
  272. lda box'parameters+4
  273. pha
  274. and #128
  275. ora #110
  276. sta (209),y
  277. pla 
  278. sta (243),y
  279. dey
  280.  
  281. - lda box'parameters+4
  282. pha
  283. and #128
  284. ora #64
  285. sta (209),y
  286. pla
  287. sta (243),y
  288. dey
  289. cpy box'parameters
  290. bne -
  291.  
  292. lda box'parameters+4
  293. pha
  294. and #128
  295. ora #112
  296. sta (209),y
  297. pla 
  298. sta (243),y
  299.  
  300. - lda #13
  301. jsr chrout
  302. jsr old'rom'patch
  303.  
  304. lda 214
  305. cmp box'parameters+3
  306. bcs do'bottom
  307.  
  308. lda box'parameters+4
  309. pha
  310. and #128
  311. ora #93
  312. ldy box'parameters
  313. sta (209),y
  314. ldy box'parameters+1
  315. sta (209),y
  316. pla
  317. sta (243),y
  318. ldy box'parameters
  319. sta (243),y
  320. jmp -
  321.  
  322. do'bottom ldy box'parameters+1
  323. lda box'parameters+4
  324. pha
  325. and #128
  326. ora #125
  327. sta (209),y
  328. pla 
  329. sta (243),y
  330. dey
  331.  
  332. - lda box'parameters+4
  333. pha
  334. and #128
  335. ora #64
  336. sta (209),y
  337. pla
  338. sta (243),y
  339. dey
  340. cpy box'parameters
  341. bne -
  342.  
  343. lda box'parameters+4
  344. pha
  345. and #128
  346. ora #109
  347. sta (209),y
  348. pla 
  349. sta (243),y
  350.  
  351. pla
  352. sta 211
  353. pla
  354. sta 214
  355. jsr 58732
  356. jmp linx
  357.  
  358. zero'stash ldy #9
  359. - lda 245,y
  360. sta zero'buf,y
  361. dey
  362. bpl -
  363. rts
  364.  
  365. zero'restore ldy #9
  366. - lda zero'buf,y
  367. sta 245,y
  368. dey
  369. bpl -
  370. rts
  371.  
  372. read'existing jsr get'number
  373. sty 174
  374. sta 175
  375. sty base
  376. sta base+1
  377. ldy #0
  378. sei
  379. lda #$74
  380. sta 1
  381. - lda (174),y
  382. bne +
  383. beq ++
  384. + inc 174
  385. bne -
  386. inc 175
  387. jmp -
  388. + lda 174
  389. sta eof
  390. lda 175
  391. sta eof+1
  392. lda #$77
  393. sta 1
  394. cli
  395. lda #0
  396. jmp +
  397.  
  398. load'file jsr bload
  399. stx eof
  400. sty eof+1
  401. + ldy #0
  402. sty setup'flag
  403. tya
  404. sta (174),y
  405. sta bottom'flag
  406. lda #147
  407. jsr chrout
  408. lda #32
  409. sta text'color-1
  410. jsr get'number
  411. sty text'color
  412. sty top'frame'color
  413. tya
  414. and #128
  415. ora text'color-1
  416. sta text'color-1
  417. jsr get'number
  418. sty frame'color
  419. sty top'box'color
  420. jsr count'lines
  421.  
  422. setup lda #0
  423. sta bottom'flag
  424. ldx <frame'parms
  425. ldy >frame'parms
  426. jsr do'frame
  427.  
  428. ldx <top'frame'parms
  429. ldy >top'frame'parms
  430. jsr do'frame
  431.  
  432. lda top'box'color
  433. sta 646
  434. and #128
  435. sta 199
  436. bit setup'flag
  437. bmi +
  438. lda top'box'parms+4
  439. ora 199
  440. sta top'box'parms+4
  441. ldx <top'box'parms
  442. ldy >top'box'parms
  443. jsr do'box
  444. ldx #2
  445. ldy #0
  446. clc
  447. jsr plot
  448. jsr get'string
  449. jsr mcenter
  450. + lda #255
  451. sta setup'flag
  452. ldx <text'parms
  453. ldy >text'parms
  454. jsr do'box
  455. ldx frame'parms+3
  456. inx
  457. jsr 59903
  458. ldx frame'parms+3
  459. inx
  460. ldy #5
  461. clc
  462. jsr plot
  463. lda frame'parms+4
  464. sta 646
  465.  
  466. lda <line'text
  467. ldy >line'text
  468. jsr strout
  469. ldx #18
  470. stx 211
  471. jsr 58732
  472.  
  473. lda text'parms+5
  474. sta 646
  475.  
  476. ldx line'count
  477. lda line'count+1
  478. jsr print'number
  479.  
  480. lda frame'parms+4
  481. sta 646
  482. inc 214
  483. lda #1
  484. sta 211
  485. jsr 58732
  486. lda <lil'menu
  487. ldy >lil'menu
  488. jsr strout
  489.  
  490. inc 214
  491. lda #8
  492. sta 211
  493. jsr 58732
  494. lda <lil'too
  495. ldy >lil'too
  496. jsr strout
  497. ldx 214
  498. dex
  499. ldy #1
  500. clc
  501. jsr plot
  502. jsr old'rom'patch
  503.  
  504. ldy #80
  505. - lda (209),y
  506. bpl +
  507. and #127
  508. sta (209),y
  509. lda text'parms+5
  510. sta (243),y
  511. + dey
  512. bpl -
  513.  
  514. lda base
  515. sta 251
  516. lda base+1
  517. sta 252
  518. lda #0
  519. sta text'loc
  520. sta text'loc+1
  521. sta cur'line
  522. sta cur'line+1
  523. inc cur'line
  524. lda cur'line
  525.  
  526. jsr page
  527. jsr print'line'no
  528.  
  529. get'text'key jsr getin
  530. beq get'text'key
  531. cmp #17
  532. bne +
  533. jsr text'down
  534. jsr print'line'no
  535. jmp get'text'key
  536. + cmp #145
  537. bne +
  538. jsr text'up
  539. jsr print'line'no
  540. jmp get'text'key
  541. + cmp #19
  542. bne +
  543. jmp setup
  544.  
  545. + cmp #crsr'right
  546. bne +
  547. jmp page'down
  548.  
  549. + cmp #crsr'left
  550. bne +
  551. jmp page'up
  552.  
  553. + cmp #147
  554. bne +
  555. jsr move'bottom
  556. jsr print'line'no
  557. jmp get'text'key
  558. + cmp "q"
  559. bne +
  560. rts
  561. + cmp "p"
  562. bne get'text'key
  563. jsr print'text
  564. jmp setup
  565.  
  566.  
  567. text'down lda bottom'flag
  568. beq +
  569. rts
  570. + jsr zero'stash
  571. ldx <text'parms
  572. ldy >text'parms
  573. jsr do'scroll'down
  574. inc cur'line
  575. bne +
  576. inc cur'line+1
  577.  
  578. + jmp zero'restore
  579.  
  580. do'scroll'down stx 251
  581. sty 252
  582. ldy #3
  583. - lda (251),y
  584. sta startingx,y
  585. dey
  586. bpl -
  587. jsr scroll'up
  588.  
  589. lda text'color-1
  590. sta char
  591. lda text'color
  592. sta color
  593. jsr clear'ii
  594.  
  595. print'new'bottom'line lda text'loc
  596. sta 251
  597. lda text'loc+1
  598. sta 252
  599. jsr page'loop
  600. jsr rom'out
  601. ldy #0
  602. lda box'top
  603. sta 251
  604. lda box'top+1
  605. sta 252
  606. lda text'color
  607. and 3128
  608. sta 199
  609. - lda (251),y
  610. cmp #13
  611. beq nbo
  612. inc 251
  613. bne +
  614. inc 252
  615. + jmp -
  616. nbo lda 251
  617. sta box'top
  618. lda 252
  619. sta box'top+1
  620. jmp rom'in
  621.  
  622.  
  623. page lda text'color
  624. sta 646
  625. and #128
  626. sta 199
  627.  
  628. ldy text'parms
  629. ldx text'parms+2
  630. clc
  631. jsr plot
  632.  
  633. page'loop ldy #0
  634. - jsr rom'out
  635. lda (251),y
  636. jsr bump'251
  637. cmp #0
  638. beq hit'bottom
  639. jsr rom'in
  640. jsr chrout
  641. lda 211
  642. bne -
  643.  
  644. lda text'color
  645. and #128
  646. sta 199
  647. lda #29
  648. jsr chrout
  649. lda 214
  650. cmp frame'parms+3
  651. bcs +
  652. jmp -
  653. / lda 251
  654. sta text'loc
  655. lda 252
  656. sta text'loc+1
  657. rts
  658.  
  659. hit'bottom jsr rom'in
  660. lda #1
  661. sta bottom'flag
  662. jmp -
  663.  
  664. page'down lda #14
  665. sta wordbuf
  666. - lda #0
  667. sta 199
  668. jsr text'down
  669. dec wordbuf
  670. bpl -
  671. jsr print'line'no
  672. jmp get'text'key
  673.  
  674. page'up lda #14
  675. sta wordbuf
  676. - jsr text'up
  677. lda cur'line+1
  678. bne +
  679. lda cur'line
  680. cmp #1
  681. beq ++
  682. + dec wordbuf
  683. bpl -
  684. + jsr print'line'no
  685. jmp get'text'key
  686.  
  687. rom'out pha
  688. sei
  689. lda #$74
  690. sta 1
  691. pla
  692. rts
  693.  
  694. rom'in pha
  695. lda #$77
  696. sta 1
  697. cli
  698. pla
  699. rts
  700.  
  701. bump'251 inc 251
  702. bne +
  703. inc 252
  704. + rts
  705.  
  706. get'scroll'up jsr get'scroll'parms
  707. jmp scroll'up
  708.  
  709. get'scroll'down jsr get'scroll'parms
  710. jmp scroll'down
  711.  
  712. get'scroll'parms lda #0
  713. sta temp
  714. - jsr get'number
  715. tya
  716. ldx temp
  717. sta startingx,x
  718. inc temp
  719. inx
  720. cpx #4
  721. bcc -
  722. rts
  723.  
  724. scroll'up ldy startingx
  725. ldx startingy
  726. stx line
  727. clc
  728. jsr plot
  729. jsr old'rom'patch
  730.  
  731. scroll'up'math clc
  732. lda 209
  733. adc <40
  734. sta 251
  735. lda 210
  736. adc >40
  737. sta 252
  738.  
  739. clc
  740. lda 243
  741. adc <40
  742. sta 253
  743. lda 244
  744. adc >40
  745. sta 254
  746.  
  747. ldy startingx
  748.  
  749. - lda (251),y
  750. sta (209),y
  751. lda (253),y
  752. sta (243),y
  753. iny
  754. cpy endingx
  755. beq -
  756. bcc -
  757.  
  758. inc line
  759. lda line
  760. cmp endingy
  761. bcs through'scrolling'up
  762.  
  763. clc
  764. lda 209
  765. adc <40
  766. sta 209
  767. lda 210
  768. adc >40
  769. sta 210
  770.  
  771. clc
  772. lda 243
  773. adc <40
  774. sta 243
  775. lda 244
  776. adc >40
  777. sta 244
  778. jmp scroll'up'math
  779.  
  780. thr