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.

editor.1 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. .PAG 'SCREEN EDITOR'
  2. MAXCHR=80
  3. NWRAP=2 ;MAX NUMBER OF PHYSICAL LINES PER LOGICAL LINE
  4. ;
  5. ;UNDEFINED FUNCTION ENTRY
  6. ;
  7. ; UNDEFD LDX #0
  8. ; UNDEF2 LDA UNMSG,X
  9. ; JSR PRT
  10. ; INX
  11. ; CPX #UNMSG2-UNMSG
  12. ; BNE UNDEF2
  13. ; SEC
  14. ; RTS
  15. ;
  16. ; UNMSG .BYT $D,'?ADVANCED FUNCTION NOT AVAILABLE',$D
  17. ; UNMSG2
  18. ;
  19. ;RETURN ADDRESS OF 6526
  20. ;
  21. IOBASE LDX #<D1PRA
  22. LDY #>D1PRA
  23. RTS
  24. ;
  25. ;RETURN MAX ROWS,COLS OF SCREEN
  26. ;
  27. SCRORG LDX #LLEN
  28. LDY #NLINES
  29. RTS
  30. ;
  31. ;READ/PLOT CURSOR POSITION
  32. ;
  33. PLOT BCS PLOT10
  34. STX TBLX
  35. STY PNTR
  36. JSR STUPT
  37. PLOT10 LDX TBLX
  38. LDY PNTR
  39. RTS
  40. .SKI 5
  41. ;INITIALIZE I/O
  42. ;
  43. CINT
  44. ;
  45. ; ESTABLISH SCREEN MEMORY
  46. ;
  47. JSR PANIC ;SET UP VIC
  48. ;
  49. LDA #0 ;MAKE SURE WE'RE IN PET MODE
  50. STA MODE
  51. STA BLNON ;WE DONT HAVE A GOOD CHAR FROM THE SCREEN YET
  52. .SKI
  53. LDA #<SHFLOG ;SET SHIFT LOGIC INDIRECTS
  54. STA KEYLOG
  55. LDA #>SHFLOG
  56. STA KEYLOG+1
  57. LDA #10
  58. STA XMAX ;MAXIMUM TYPE AHEAD BUFFER SIZE
  59. STA DELAY
  60. LDA #$E ;INIT COLOR TO LIGHT BLUE<<<<<<<<<<
  61. STA COLOR
  62. LDA #4
  63. STA KOUNT ;DELAY BETWEEN KEY REPEATS
  64. LDA #$C
  65. STA BLNCT
  66. STA BLNSW
  67. CLSR LDA HIBASE ;FILL HI BYTE PTR TABLE
  68. ORA #$80
  69. TAY
  70. LDA #0
  71. TAX
  72. LPS1 STY LDTB1,X
  73. CLC
  74. ADC #LLEN
  75. BCC LPS2
  76. INY ;CARRY BUMP HI BYTE
  77. LPS2 INX
  78. CPX #NLINES+1 ;DONE # OF LINES?
  79. BNE LPS1 ;NO...
  80. LDA #$FF ;TAG END OF LINE TABLE
  81. STA LDTB1,X
  82. LDX #NLINES-1 ;CLEAR FROM THE BOTTOM LINE UP
  83. CLEAR1 JSR CLRLN ;SEE SCROLL ROUTINES
  84. DEX
  85. BPL CLEAR1
  86. .SKI 5
  87. ;HOME FUNCTION
  88. ;
  89. NXTD LDY #0
  90. STY PNTR ;LEFT COLUMN
  91. STY TBLX ;TOP LINE
  92. ;
  93. ;MOVE CURSOR TO TBLX,PNTR
  94. ;
  95. STUPT
  96. LDX TBLX ;GET CURENT LINE INDEX
  97. LDA PNTR ;GET CHARACTER POINTER
  98. FNDSTR LDY LDTB1,X ;FIND BEGINING OF LINE
  99. BMI STOK ;BRANCH IF START FOUND
  100. CLC
  101. ADC #LLEN ;ADJUST POINTER
  102. STA PNTR
  103. DEX
  104. BPL FNDSTR
  105. ;
  106. STOK JSR SETPNT ;SET UP PNT INDIRECT 901227-03**********
  107. ;
  108. LDA #LLEN-1
  109. INX
  110. FNDEND LDY LDTB1,X
  111. BMI STDONE
  112. CLC
  113. ADC #LLEN
  114. INX
  115. BPL FNDEND
  116. STDONE
  117. STA LNMX
  118. JMP SCOLOR ;MAKE COLOR POINTER FOLLOW 901227-03**********
  119. .SKI 5
  120. ; THIS IS A PATCH FOR INPUT LOGIC 901227-03**********
  121. ; FIXES INPUT"XXXXXXX-40-XXXXX";A$ PROBLEM
  122. ;
  123. FINPUT CPX LSXP ;CHECK IF ON SAME LINE
  124. BEQ FINPUX ;YES..RETURN TO SEND
  125. JMP FINDST ;CHECK IF WE WRAPPED DOWN...
  126. FINPUX RTS
  127. NOP ;KEEP THE SPACE THE SAME...
  128. .SKI 5
  129. ;PANIC NMI ENTRY
  130. ;
  131. VPAN JSR PANIC ;FIX VIC SCREEN
  132. JMP NXTD ;HOME CURSOR
  133. .SKI 5
  134. PANIC LDA #3 ;RESET DEFAULT I/O
  135. STA DFLTO
  136. LDA #0
  137. STA DFLTN
  138. .SKI 5
  139. ;INIT VIC
  140. ;
  141. INITV LDX #47 ;LOAD ALL VIC REGS ***
  142. PX4 LDA TVIC-1,X
  143. STA VICREG-1,X
  144. DEX
  145. BNE PX4
  146. RTS
  147. .SKI 5
  148. ;
  149. ;REMOVE CHARACTER FROM QUEUE
  150. ;
  151. LP2 LDY KEYD
  152. LDX #0
  153. LP1 LDA KEYD+1,X
  154. STA KEYD,X
  155. INX
  156. CPX NDX
  157. BNE LP1
  158. DEC NDX
  159. TYA
  160. CLI
  161. CLC ;GOOD RETURN
  162. RTS
  163. ;
  164. LOOP4 JSR PRT
  165. LOOP3
  166. LDA NDX
  167. STA BLNSW
  168. STA AUTODN ;TURN ON AUTO SCROLL DOWN
  169. BEQ LOOP3
  170. SEI
  171. LDA BLNON
  172. BEQ LP21
  173. LDA GDBLN
  174. LDX GDCOL ;RESTORE ORIGINAL COLOR
  175. LDY #0
  176. STY BLNON
  177. JSR DSPP
  178. LP21 JSR LP2
  179. CMP #$83 ;RUN KEY?
  180. BNE LP22
  181. LDX #9
  182. SEI
  183. STX NDX
  184. LP23 LDA RUNTB-1,X
  185. STA KEYD-1,X
  186. DEX
  187. BNE LP23
  188. BEQ LOOP3
  189. LP22 CMP #$D
  190. BNE LOOP4
  191. LDY LNMX
  192. STY CRSW
  193. CLP5 LDA (PNT)Y
  194. CMP #'
  195. BNE CLP6
  196. DEY
  197. BNE CLP5
  198. CLP6 INY
  199. STY INDX
  200. LDY #0
  201. STY AUTODN ;TURN OFF AUTO SCROLL DOWN
  202. STY PNTR
  203. STY QTSW
  204. LDA LSXP
  205. BMI LOP5
  206. LDX TBLX
  207. JSR FINPUT ;CHECK FOR SAME LINE AS START 901227-03**********
  208. CPX LSXP
  209. BNE LOP5
  210. LDA LSTP
  211. STA PNTR
  212. CMP INDX
  213. BCC LOP5
  214. BCS CLP2
  215. .SKI 5
  216. ;INPUT A LINE UNTIL CARRIAGE RETURN
  217. ;
  218. LOOP5 TYA
  219. PHA
  220. TXA
  221. PHA
  222. LDA CRSW
  223. BEQ LOOP3
  224. LOP5 LDY PNTR
  225. LDA (PNT)Y
  226. NOTONE
  227. STA DATA
  228. LOP51 AND #$3F
  229. ASL DATA
  230. BIT DATA
  231. BPL LOP54
  232. ORA #$80
  233. LOP54 BCC LOP52
  234. LDX QTSW
  235. BNE LOP53
  236. LOP52 BVS LOP53
  237. ORA #$40
  238. LOP53 INC PNTR
  239. JSR QTSWC
  240. CPY INDX
  241. BNE CLP1
  242. CLP2 LDA #0
  243. STA CRSW
  244. LDA #$D
  245. LDX DFLTN ;FIX GETS FROM SCREEN
  246. CPX #3 ;IS IT THE SCREEN?
  247. BEQ CLP2A
  248. LDX DFLTO
  249. CPX #3
  250. BEQ CLP21
  251. CLP2A JSR PRT
  252. CLP21 LDA #$D
  253. CLP1 STA DATA
  254. PLA
  255. TAX
  256. PLA
  257. TAY
  258. LDA DATA
  259. CMP #$DE ;IS IT <PI> ?
  260. BNE CLP7
  261. LDA #$FF
  262. CLP7 CLC
  263. RTS
  264. .SKI 5
  265. QTSWC CMP #$22
  266. BNE QTSWL
  267. LDA QTSW
  268. EOR #$1
  269. STA QTSW
  270. LDA #$22
  271. QTSWL RTS
  272. .SKI 5
  273. NXT33 ORA #$40
  274. NXT3 LDX RVS
  275. BEQ NVS
  276. NC3 ORA #$80
  277. NVS LDX INSRT
  278. BEQ NVS1
  279. DEC INSRT
  280. NVS1 LDX COLOR PUT COLOR ON SCREEN
  281. JSR DSPP
  282. JSR WLOGIC ;CHECK FOR WRAPAROUND
  283. LOOP2 PLA
  284. TAY
  285. LDA INSRT
  286. BEQ LOP2
  287. LSR QTSW
  288. LOP2 PLA
  289. TAX
  290. PLA
  291. CLC ;GOOD RETURN
  292. CLI
  293. RTS
  294. .PAG
  295. WLOGIC
  296. JSR CHKDWN ;MAYBE WE SHOULD WE INCREMENT TBLX
  297. INC PNTR ;BUMP CHARCTER POINTER
  298. LDA LNMX ;
  299. CMP PNTR ;IF LNMX IS LESS THAN PNTR
  300. BCS WLGRTS ;BRANCH IF LNMX>=PNTR
  301. CMP #MAXCHR-1 ;PAST MAX CHARACTERS
  302. BEQ WLOG10 ;BRANCH IF SO
  303. LDA AUTODN ;SHOULD WE AUTO SCROLL DOWN?
  304. BEQ WLOG20 ;BRANCH IF NOT
  305. JMP BMT1 ;ELSE DECIDE WHICH WAY TO SCROLL
  306. .SKIP 3
  307. WLOG20
  308. LDX TBLX ;SEE IF WE SHOULD SCROLL DOWN
  309. CPX #NLINES
  310. BCC WLOG30 ;BRANCH IF NOT
  311. JSR SCROL ;ELSE DO THE SCROL UP
  312. DEC TBLX ;AND ADJUST CURENT LINE#
  313. LDX TBLX
  314. WLOG30 ASL LDTB1,X ;WRAP THE LINE
  315. LSR LDTB1,X
  316. INX ;INDEX TO NEXT LLINE
  317. LDA LDTB1,X ;GET HIGH ORDER BYTE OF ADDRESS
  318. ORA #$80 ;MAKE IT A NON-CONTINUATION LINE
  319. STA LDTB1,X ;AND PUT IT BACK
  320. DEX ;GET BACK TO CURRENT LINE
  321. LDA LNMX ;CONTINUE THE BYTES TAKEN OUT
  322. CLC
  323. ADC #LLEN
  324. STA LNMX
  325. FINDST
  326. LDA LDTB1,X ;IS THIS THE FIRST LINE?
  327. BMI FINX ;BRANCH IF SO
  328. DEX ;ELSE BACKUP 1
  329. BNE FINDST
  330. FINX
  331. JMP SETPNT ;MAKE SURE PNT IS RIGHT
  332. .SKI
  333. WLOG10 DEC TBLX
  334. JSR NXLN
  335. LDA #0
  336. STA PNTR ;POINT TO FIRST BYTE
  337. WLGRTS RTS
  338. .PAG
  339. BKLN LDX TBLX
  340. BNE BKLN1
  341. STX PNTR
  342. PLA
  343. PLA
  344. BNE LOOP2
  345. ;
  346. BKLN1 DEX
  347. STX TBLX
  348. JSR STUPT
  349. LDY LNMX
  350. STY PNTR
  351. RTS
  352. .SKI 5
  353. ;PRINT ROUTINE
  354. ;
  355. PRT PHA
  356. STA DATA
  357. TXA
  358. PHA
  359. TYA
  360. PHA
  361. LDA #0
  362. STA CRSW
  363. LDY PNTR
  364. LDA DATA
  365. BPL *+5
  366. JMP NXTX
  367. CMP #$D
  368. BNE NJT1
  369. JMP NXT1
  370. NJT1 CMP #'
  371. BCC NTCN
  372. CMP #$60 ;LOWER CASE?
  373. BCC NJT8 ;NO...
  374. AND #$DF ;YES...MAKE SCREEN LOWER
  375. BNE NJT9 ;ALWAYS
  376. NJT8 AND #$3F
  377. NJT9 JSR QTSWC
  378. JMP NXT3
  379. NTCN LDX INSRT
  380. BEQ CNC3X
  381. JMP NC3
  382. CNC3X CMP #$14
  383. BNE NTCN1
  384. TYA
  385. BNE BAK1UP
  386. JSR BKLN
  387. JMP BK2
  388. BAK1UP JSR CHKBAK ;SHOULD WE DEC TBLX
  389. DEY
  390. STY PNTR
  391. BK1 JSR SCOLOR ;FIX COLOR PTRS
  392. BK15 INY
  393. LDA (PNT)Y
  394. DEY
  395. STA (PNT)Y
  396. INY
  397. LDA (USER)Y
  398. DEY
  399. STA (USER)Y
  400. INY
  401. CPY LNMX
  402. BNE BK15
  403. BK2 LDA #'
  404. STA (PNT)Y
  405. LDA COLOR
  406. STA (USER)Y
  407. BPL JPL3
  408. NTCN1 LDX QTSW
  409. BEQ NC3W
  410. CNC3 JMP NC3
  411. NC3W CMP #$12
  412. BNE NC1
  413. STA RVS
  414. NC1 CMP #$13
  415. BNE NC2
  416. JSR NXTD
  417. NC2 CMP #$1D
  418. BNE NCX2
  419. INY
  420. JSR CHKDWN
  421. STY PNTR
  422. DEY
  423. CPY LNMX
  424. BCC NCZ2
  425. DEC TBLX
  426. JSR NXLN
  427. LDY #0
  428. JPL4 STY PNTR
  429. NCZ2 JMP LOOP2
  430. NCX2 CMP #$11
  431. BNE COLR1
  432. CLC
  433. TYA
  434. ADC #LLEN
  435. TAY
  436. INC TBLX
  437. CMP LNMX
  438. BCC JPL4
  439. BEQ JPL4
  440. DEC TBLX
  441. CURS10 SBC #LLEN
  442. BCC GOTDWN
  443. STA PNTR
  444. BNE CURS10
  445. GOTDWN JSR NXLN
  446. JPL3 JMP LOOP2
  447. COLR1 JSR CHKCOL ;CHECK FOR A COLOR
  448. JMP LOWER ;WAS JMP LOOP2
  449. .SKI 3
  450. ;CHECK COLOR
  451. ;
  452. .SKI 5
  453. ;SHIFTED KEYS
  454. ;
  455. NXTX
  456. KEEPIT
  457. AND #$7F
  458. CMP #$7F
  459. BNE NXTX1
  460. LDA #$5E
  461. NXTX1
  462. NXTXA
  463. CMP #$20 ;IS IT A FUNCTION KEY
  464. BCC UHUH
  465. JMP NXT33
  466. UHUH
  467. CMP #$D
  468. BNE UP5
  469. JMP NXT1
  470. UP5 LDX QTSW
  471. BNE UP6
  472. CMP #$14
  473. BNE UP9
  474. LDY LNMX
  475. LDA (PNT)Y
  476. CMP #'
  477. BNE INS3
  478. CPY PNTR
  479. BNE INS1
  480. INS3 CPY #MAXCHR-1
  481. BEQ INSEXT ;EXIT IF LINE TOO LONG
  482. JSR NEWLIN ;SCROLL DOWN 1
  483. INS1 LDY LNMX
  484. JSR SCOLOR
  485. INS2 DEY
  486. LDA (PNT)Y
  487. INY
  488. STA (PNT)Y
  489. DEY
  490. LDA (USER)Y
  491. INY
  492. STA (USER)Y
  493. DEY
  494. CPY PNTR
  495. BNE INS2
  496. LDA #$20
  497. STA (PNT)Y
  498. LDA COLOR
  499. STA (USER)Y
  500. INC INSRT
  501. INSEXT JMP LOOP2
  502. UP9 LDX INSRT
  503. BEQ UP2
  504. UP6 ORA #$40
  505. JMP NC3
  506. UP2 CMP #$11
  507. BNE NXT2
  508. LDX TBLX
  509. BEQ JPL2
  510. DEC TBLX
  511. LDA PNTR
  512. SEC
  513. SBC #LLEN
  514. BCC UPALIN
  515. STA PNTR
  516. BPL JPL2
  517. UPALIN JSR STUPT
  518. BNE JPL2
  519. NXT2 CMP #$12
  520. BNE NXT6
  521. LDA #0
  522. STA RVS
  523. NXT6 CMP #$1D
  524. BNE NXT61
  525. TYA
  526. BEQ BAKBAK
  527. JSR CHKBAK
  528. DEY
  529. STY PNTR
  530. JMP LOOP2
  531. BAKBAK JSR BKLN
  532. JMP LOOP2
  533. NXT61 CMP #$13
  534. BNE SCCL
  535. JSR CLSR
  536. JPL2 JMP LOOP2
  537. SCCL
  538. ORA #$80 ;MAKE IT UPPER CASE
  539. JSR CHKCOL ;TRY FOR COLOR
  540. JMP UPPER ;WAS JMP LOOP2
  541. ;
  542. NXLN LSR LSXP
  543. LDX TBLX
  544. NXLN2 INX
  545. CPX #NLINES ;OFF BOTTOM?
  546. BNE NXLN1 ;NO...
  547. JSR SCROL ;YES...SCROLL
  548. NXLN1 LDA LDTB1,X ;DOUBLE LINE?
  549. BPL NXLN2 ;YES...SCROLL AGAIN
  550. STX TBLX
  551. JMP STUPT
  552. NXT1
  553. LDX #0
  554. STX INSRT
  555. STX RVS
  556. STX QTSW
  557. STX PNTR
  558. JSR NXLN
  559. JPL5 JMP LOOP2
  560. ;
  561. ;
  562. ; CHECK FOR A DECREMENT TBLX
  563. ;
  564. CHKBAK LDX #NWRAP
  565. LDA #0
  566. CHKLUP CMP PNTR
  567. BEQ BACK
  568. CLC
  569. ADC #LLEN
  570. DEX
  571. BNE CHKLUP
  572. RTS
  573. ;
  574. BACK DEC TBLX
  575. RTS
  576. ;
  577. ; CHECK FOR INCREMENT TBLX
  578. ;
  579. CHKDWN LDX #NWRAP
  580. LDA #LLEN-1
  581. DWNCHK CMP PNTR
  582. BEQ DNLINE
  583. CLC
  584. ADC #LLEN
  585. DEX
  586. BNE DWNCHK
  587. RTS
  588. ;
  589. DNLINE LDX TBLX
  590. CPX #NLINES
  591. BEQ DWNBYE
  592. INC TBLX
  593. ;
  594. DWNBYE RTS
  595. .SKI2
  596. CHKCOL
  597. LDX #15 ;THERE'S 15 COLORS
  598. CHK1A CMP COLTAB,X
  599. BEQ CHK1B
  600. DEX
  601. BPL CHK1A
  602. RTS
  603. ;
  604. CHK1B
  605. STX COLOR ;CHANGE THE COLOR
  606. RTS
  607. .SKI1
  608. COLTAB
  609. ;BLK,WHT,RED,CYAN,MAGENTA,GRN,BLUE,YELLOW
  610. .BYT $90,$05,$1C,$9F,$9C,$1E,$1F,$9E
  611. .BYT $81,$95,$96,$97,$98,$99,$9A,$9B
  612. .END
  613. ; RSR MODIFY FOR VIC-40 SYSTEM
  614. ; RSR 12/31/81 ADD 8 MORE COLORS