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.

407 lines
7.9KB

  1. .PAG 'EDITOR.2'
  2. ;SCREEN SCROLL ROUTINE
  3. ;
  4. SCROL LDA SAL
  5. PHA
  6. LDA SAH
  7. PHA
  8. LDA EAL
  9. PHA
  10. LDA EAH
  11. PHA
  12. ;
  13. ; S C R O L L U P
  14. ;
  15. SCRO0 LDX #$FF
  16. DEC TBLX
  17. DEC LSXP
  18. DEC LINTMP
  19. SCR10 INX ;GOTO NEXT LINE
  20. JSR SETPNT ;POINT TO 'TO' LINE
  21. CPX #NLINES-1 ;DONE?
  22. BCS SCR41 ;BRANCH IF SO
  23. ;
  24. LDA LDTB2+1,X ;SETUP FROM PNTR
  25. STA SAL
  26. LDA LDTB1+1,X
  27. JSR SCRLIN ;SCROLL THIS LINE UP1
  28. BMI SCR10
  29. ;
  30. SCR41
  31. JSR CLRLN
  32. ;
  33. LDX #0 ;SCROLL HI BYTE POINTERS
  34. SCRL5 LDA LDTB1,X
  35. AND #$7F
  36. LDY LDTB1+1,X
  37. BPL SCRL3
  38. ORA #$80
  39. SCRL3 STA LDTB1,X
  40. INX
  41. CPX #NLINES-1
  42. BNE SCRL5
  43. ;
  44. LDA LDTB1+NLINES-1
  45. ORA #$80
  46. STA LDTB1+NLINES-1
  47. LDA LDTB1 ;DOUBLE LINE?
  48. BPL SCRO0 ;YES...SCROLL AGAIN
  49. ;
  50. INC TBLX
  51. INC LINTMP
  52. LDA #$7F ;CHECK FOR CONTROL KEY
  53. STA COLM ;DROP LINE 2 ON PORT B
  54. LDA ROWS
  55. CMP #$FB ;SLOW SCROLL KEY?(CONTROL)
  56. PHP ;SAVE STATUS. RESTORE PORT B
  57. LDA #$7F ;FOR STOP KEY CHECK
  58. STA COLM
  59. PLP
  60. BNE MLP42
  61. ;
  62. LDY #0
  63. MLP4 NOP ;DELAY
  64. DEX
  65. BNE MLP4
  66. DEY
  67. BNE MLP4
  68. STY NDX ;CLEAR KEY QUEUE BUFFER
  69. ;
  70. MLP42 LDX TBLX
  71. ;
  72. PULIND PLA ;RESTORE OLD INDIRECTS
  73. STA EAH
  74. PLA
  75. STA EAL
  76. PLA
  77. STA SAH
  78. PLA
  79. STA SAL
  80. RTS
  81. .PAGE
  82. NEWLIN
  83. LDX TBLX
  84. BMT1 INX
  85. ; CPX #NLINES ;EXCEDED THE NUMBER OF LINES ???
  86. ; BEQ BMT2 ;VIC-40 CODE
  87. LDA LDTB1,X ;FIND LAST DISPLAY LINE OF THIS LINE
  88. BPL BMT1 ;TABLE END MARK=>$FF WILL ABORT...ALSO
  89. BMT2 STX LINTMP ;FOUND IT
  90. ;GENERATE A NEW LINE
  91. CPX #NLINES-1 ;IS ONE LINE FROM BOTTOM?
  92. BEQ NEWLX ;YES...JUST CLEAR LAST
  93. BCC NEWLX ;<NLINES...INSERT LINE
  94. JSR SCROL ;SCROLL EVERYTHING
  95. LDX LINTMP
  96. DEX
  97. DEC TBLX
  98. JMP WLOG30
  99. NEWLX LDA SAL
  100. PHA
  101. LDA SAH
  102. PHA
  103. LDA EAL
  104. PHA
  105. LDA EAH
  106. PHA
  107. LDX #NLINES
  108. SCD10 DEX
  109. JSR SETPNT ;SET UP TO ADDR
  110. CPX LINTMP
  111. BCC SCR40
  112. BEQ SCR40 ;BRANCH IF FINISHED
  113. LDA LDTB2-1,X ;SET FROM ADDR
  114. STA SAL
  115. LDA LDTB1-1,X
  116. JSR SCRLIN ;SCROLL THIS LINE DOWN
  117. BMI SCD10
  118. SCR40
  119. JSR CLRLN
  120. LDX #NLINES-2
  121. SCRD21
  122. CPX LINTMP ;DONE?
  123. BCC SCRD22 ;BRANCH IF SO
  124. LDA LDTB1+1,X
  125. AND #$7F
  126. LDY LDTB1,X ;WAS IT CONTINUED
  127. BPL SCRD19 ;BRANCH IF SO
  128. ORA #$80
  129. SCRD19 STA LDTB1+1,X
  130. DEX
  131. BNE SCRD21
  132. SCRD22
  133. LDX LINTMP
  134. JSR WLOG30
  135. ;
  136. JMP PULIND ;GO PUL OLD INDIRECTS AND RETURN
  137. ;
  138. ; SCROLL LINE FROM SAL TO PNT
  139. ; AND COLORS FROM EAL TO USER
  140. ;
  141. SCRLIN
  142. AND #$03 ;CLEAR ANY GARBAGE STUFF
  143. ORA HIBASE ;PUT IN HIORDER BITS
  144. STA SAL+1
  145. JSR TOFROM ;COLOR TO & FROM ADDRS
  146. LDY #LLEN-1
  147. SCD20
  148. LDA (SAL)Y
  149. STA (PNT)Y
  150. LDA (EAL)Y
  151. STA (USER)Y
  152. DEY
  153. BPL SCD20
  154. RTS
  155. ;
  156. ; DO COLOR TO AND FROM ADDRESSES
  157. ; FROM CHARACTER TO AND FROM ADRS
  158. ;
  159. TOFROM
  160. JSR SCOLOR
  161. LDA SAL ;CHARACTER FROM
  162. STA EAL ;MAKE COLOR FROM
  163. LDA SAL+1
  164. AND #$03
  165. ORA #>VICCOL
  166. STA EAL+1
  167. RTS
  168. ;
  169. ; SET UP PNT AND Y
  170. ; FROM .X
  171. ;
  172. SETPNT LDA LDTB2,X
  173. STA PNT
  174. LDA LDTB1,X
  175. AND #$03
  176. ORA HIBASE
  177. STA PNT+1
  178. RTS
  179. ;
  180. ; CLEAR THE LINE POINTED TO BY .X
  181. ;
  182. CLRLN LDY #LLEN-1
  183. JSR SETPNT
  184. JSR SCOLOR
  185. CLR10 JSR CPATCH ;REVERSED ORDER FROM 901227-02
  186. LDA #$20 ;STORE A SPACE
  187. STA (PNT)Y ;TO DISPLAY
  188. DEY
  189. BPL CLR10
  190. RTS
  191. NOP
  192. .SKI 5
  193. ;
  194. ;PUT A CHAR ON THE SCREEN
  195. ;
  196. DSPP TAY ;SAVE CHAR
  197. LDA #2
  198. STA BLNCT ;BLINK CURSOR
  199. JSR SCOLOR ;SET COLOR PTR
  200. TYA ;RESTORE COLOR
  201. DSPP2 LDY PNTR ;GET COLUMN
  202. STA (PNT)Y ;CHAR TO SCREEN
  203. TXA
  204. STA (USER)Y ;COLOR TO SCREEN
  205. RTS
  206. .SKI 5
  207. SCOLOR LDA PNT ;GENERATE COLOR PTR
  208. STA USER
  209. LDA PNT+1
  210. AND #$03
  211. ORA #>VICCOL ;VIC COLOR RAM
  212. STA USER+1
  213. RTS
  214. .PAG
  215. KEY JSR $FFEA ;UPDATE JIFFY CLOCK
  216. LDA BLNSW ;BLINKING CRSR ?
  217. BNE KEY4 ;NO
  218. DEC BLNCT ;TIME TO BLINK ?
  219. BNE KEY4 ;NO
  220. LDA #20 ;RESET BLINK COUNTER
  221. REPDO STA BLNCT
  222. LDY PNTR ;CURSOR POSITION
  223. LSR BLNON ;CARRY SET IF ORIGINAL CHAR
  224. LDX GDCOL ;GET CHAR ORIGINAL COLOR
  225. LDA (PNT)Y ;GET CHARACTER
  226. BCS KEY5 ;BRANCH IF NOT NEEDED
  227. ;
  228. INC BLNON ;SET TO 1
  229. STA GDBLN ;SAVE ORIGINAL CHAR
  230. JSR SCOLOR
  231. LDA (USER)Y ;GET ORIGINAL COLOR
  232. STA GDCOL ;SAVE IT
  233. LDX COLOR ;BLINK IN THIS COLOR
  234. LDA GDBLN ;WITH ORIGINAL CHARACTER
  235. ;
  236. KEY5 EOR #$80 ;BLINK IT
  237. JSR DSPP2 ;DISPLAY IT
  238. ;
  239. KEY4 LDA R6510 ;GET CASSETTE SWITCHES
  240. AND #$10 ;IS SWITCH DOWN ?
  241. BEQ KEY3 ;BRANCH IF SO
  242. ;
  243. LDY #0
  244. STY CAS1 ;CASSETTE OFF SWITCH
  245. ;
  246. LDA R6510
  247. ORA #$20
  248. BNE KL24 ;BRANCH IF MOTOR IS OFF
  249. ;
  250. KEY3 LDA CAS1
  251. BNE KL2
  252. ;
  253. LDA R6510
  254. AND #%011111 ;TURN MOTOR ON
  255. ;
  256. KL24
  257. STA R6510
  258. ;
  259. KL2 JSR SCNKEY ;SCAN KEYBOARD
  260. ;
  261. KPREND LDA D1ICR ;CLEAR INTERUPT FLAGS
  262. PLA ;RESTORE REGISTERS
  263. TAY
  264. PLA
  265. TAX
  266. PLA
  267. RTI ;EXIT FROM IRQ ROUTINES
  268. .SKI 3
  269. ; ****** GENERAL KEYBOARD SCAN ******
  270. ;
  271. SCNKEY LDA #$00
  272. STA SHFLAG
  273. LDY #64 ;LAST KEY INDEX
  274. STY SFDX ;NULL KEY FOUND
  275. STA COLM ;RAISE ALL LINES
  276. LDX ROWS ;CHECK FOR A KEY DOWN
  277. CPX #$FF ;NO KEYS DOWN?
  278. BEQ SCNOUT ;BRANCH IF NONE
  279. TAY ;.A=0 LDY #0
  280. LDA #<MODE1
  281. STA KEYTAB
  282. LDA #>MODE1
  283. STA KEYTAB+1
  284. LDA #$FE ;START WITH 1ST COLUMN
  285. STA COLM
  286. SCN20 LDX #8 ;8 ROW KEYBOARD
  287. PHA ;SAVE COLUMN OUTPUT INFO
  288. SCN22 LDA ROWS
  289. CMP ROWS ;DEBOUNCE KEYBOARD
  290. BNE SCN22
  291. SCN30 LSR A ;LOOK FOR KEY DOWN
  292. BCS CKIT ;NONE
  293. PHA
  294. LDA (KEYTAB),Y ;GET CHAR CODE
  295. CMP #$05
  296. BCS SPCK2 ;IF NOT SPECIAL KEY GO ON
  297. CMP #$03 ;COULD IT BE A STOP KEY?
  298. BEQ SPCK2 ;BRANCH IF SO
  299. ORA SHFLAG
  300. STA SHFLAG ;PUT SHIFT BIT IN FLAG BYTE
  301. BPL CKUT
  302. SPCK2
  303. STY SFDX ;SAVE KEY NUMBER
  304. CKUT PLA
  305. CKIT INY
  306. CPY #65
  307. BCS CKIT1 ;BRANCH IF FINISHED
  308. DEX
  309. BNE SCN30
  310. SEC
  311. PLA ;RELOAD COLUMN INFO
  312. ROL A
  313. STA COLM ;NEXT COLUMN ON KEYBOARD
  314. BNE SCN20 ;ALWAYS BRANCH
  315. CKIT1 PLA ;DUMP COLUMN OUTPUT...ALL DONE
  316. JMP (KEYLOG) ;EVALUATE SHIFT FUNCTIONS
  317. REKEY LDY SFDX ;GET KEY INDEX
  318. LDA (KEYTAB)Y ;GET CHAR CODE
  319. TAX ;SAVE THE CHAR
  320. CPY LSTX ;SAME AS PREV CHAR INDEX?
  321. BEQ RPT10 ;YES
  322. LDY #$10 ;NO - RESET DELAY BEFORE REPEAT
  323. STY DELAY
  324. BNE CKIT2 ;ALWAYS
  325. RPT10 AND #$7F ;UNSHIFT IT
  326. BIT RPTFLG ;CHECK FOR REPEAT DISABLE
  327. BMI RPT20 ;YES
  328. BVS SCNRTS
  329. CMP #$7F ;NO KEYS ?
  330. SCNOUT BEQ CKIT2 ;YES - GET OUT
  331. CMP #$14 ;AN INST/DEL KEY ?
  332. BEQ RPT20 ;YES - REPEAT IT
  333. CMP #$20 ;A SPACE KEY ?
  334. BEQ RPT20 ;YES
  335. CMP #$1D ;A CRSR LEFT/RIGHT ?
  336. BEQ RPT20 ;YES
  337. CMP #$11 ;A CRSR UP/DWN ?
  338. BNE SCNRTS ;NO - EXIT
  339. RPT20 LDY DELAY ;TIME TO REPEAT ?
  340. BEQ RPT40 ;YES
  341. DEC DELAY
  342. BNE SCNRTS
  343. RPT40 DEC KOUNT ;TIME FOR NEXT REPEAT ?
  344. BNE SCNRTS ;NO
  345. LDY #4 ;YES - RESET CTR
  346. STY KOUNT
  347. LDY NDX ;NO REPEAT IF QUEUE FULL
  348. DEY
  349. BPL SCNRTS
  350. CKIT2
  351. LDY SFDX ;GET INDEX OF KEY
  352. STY LSTX ;SAVE THIS INDEX TO KEY FOUND
  353. LDY SHFLAG ;UPDATE SHIFT STATUS
  354. STY LSTSHF
  355. CKIT3 CPX #$FF ;A NULL KEY OR NO KEY ?
  356. BEQ SCNRTS ;BRANCH IF SO
  357. TXA ;NEED X AS INDEX SO...
  358. LDX NDX ;GET # OF CHARS IN KEY QUEUE
  359. CPX XMAX ;IRQ BUFFER FULL ?
  360. BCS SCNRTS ;YES - NO MORE INSERT
  361. PUTQUE
  362. STA KEYD,X ;PUT RAW DATA HERE
  363. INX
  364. STX NDX ;UPDATE KEY QUEUE COUNT
  365. SCNRTS LDA #$7F ;SETUP PB7 FOR STOP KEY SENSE
  366. STA COLM
  367. RTS
  368. .PAG
  369. ;
  370. ; SHIFT LOGIC
  371. ;
  372. SHFLOG
  373. LDA SHFLAG
  374. CMP #$03 ;COMMODORE SHIFT COMBINATION?
  375. BNE KEYLG2 ;BRANCH IF NOT
  376. CMP LSTSHF ;DID I DO THIS ALREADY
  377. BEQ SCNRTS ;BRANCH IF SO
  378. LDA MODE
  379. BMI SHFOUT ;DONT SHIFT IF ITS MINUS
  380. .SKI
  381. SWITCH LDA VICREG+24 ;**********************************:
  382. EOR #$02 ;TURN ON OTHER CASE
  383. STA VICREG+24 ;POINT THE VIC THERE
  384. JMP SHFOUT
  385. .SKI
  386. ;
  387. KEYLG2
  388. ASL A
  389. CMP #$08 ;WAS IT A CONTROL KEY
  390. BCC NCTRL ;BRANCH IF NOT
  391. LDA #6 ;ELSE USE TABLE #4
  392. ;
  393. NCTRL
  394. NOTKAT
  395. TAX
  396. LDA KEYCOD,X
  397. STA KEYTAB
  398. LDA KEYCOD+1,X
  399. STA KEYTAB+1
  400. SHFOUT
  401. JMP REKEY
  402. .END
  403. ; RSR 12/08/81 MODIFY FOR VIC-40
  404. ; RSR 2/18/82 MODIFY FOR 6526 INPUT PAD SENSE
  405. ; RSR 3/11/82 FIX KEYBOARD DEBOUNCE, REPAIR FILE
  406. ; RSR 3/11/82 MODIFY FOR COMMODORE 64