home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_17_1987_Transactor_Publishing.d64 / help!.pal (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  18KB  |  889 lines

  1. 10 open 1,8,15,"s0:t-help!": close 1
  2. 11 open 2,8,1,"0:t-help!"
  3. 12 sys 700
  4. 13 .opt o2
  5. 14 .bas
  6. 15 rem the transactor help utility
  7. 16 rem nick sullivan and chris zamara
  8. 17 rem october 1986
  9. 18 rem (c) 1986 the transactor
  10. 19 rem okay to copy, not to sell
  11. 20 :
  12. 21 rem do not alter the length of any
  13. 22 rem line after program is assembled
  14. 23 :
  15. 24 a=00000: rem 5 digit link base addr
  16. 25 sys"init",a: clr
  17. 26 goto 340
  18. 27 :
  19. 50 data "[199]etting [211]tarted          "
  20. 51 data "[208]rinting [217]our [212]ext       "
  21. 52 data "[193]voyding [211]pelling [197]rrors "
  22. 53 data "[199]etting [198]inished         "
  23. 54 data "                         "
  24. 55 data "  [212]he first four data    "
  25. 56 data "lines above are a sample "
  26. 57 data "menu that will be shown  "
  27. 58 data "when help is invoked.    "
  28. 59 data "  [213]p to 20 menu items may"
  29. 60 data "be used. [198]or each one,   "
  30. 61 data "there must be a matching "
  31. 62 data "file on disk, with a     "
  32. 63 data "filename of the form:    "
  33. 64 data "         help-?          "
  34. 65 data "where the '?' represents "
  35. 66 data "an alphabetic character. "
  36. 67 data "  [212]he above menu items   "
  37. 68 data "require filenames help-a "
  38. 69 data "through help-d.          "
  39. 70 :
  40. 100 sl=25+1: rem 25 chars per menu item
  41. 110 s=peek(45)+256*peek(46)-20*sl-1
  42. 120 read a$
  43. 130 if left$(a$,1)=chr$(32) goto 200
  44. 140 for i=1 to sl-1
  45. 150 poke s+i,asc(mid$(a$,i))
  46. 160 next i
  47. 170 poke s+i,0
  48. 180 n=n+1: s=s+sl: if n<20 goto 120
  49. 190 :
  50. 200 a=122: gosub 330: z=a
  51. 210 a=123: gosub 330: z=z+256*a+11
  52. 220 :
  53. 230 poke z+0, n
  54. 240 poke z+1,09 :rem border
  55. 250 poke z+2,09 :rem background
  56. 260 poke z+3,00 :rem cursor
  57. 270 print "done!": goto 340
  58. 280 :
  59. 290 rem subroutine calculates addr of
  60. 300 rem chrget ptr at colon in line 330
  61. 310 rem (no spaces allowed in 330)
  62. 320 :
  63. 330 a=peek(a):return
  64. 340 end
  65. 350 :
  66. 1000 chrout = $ffd2  ;kernal addresses
  67. 1010 chkin  = $ffc6
  68. 1020 getin  = $ffe4
  69. 1030 setlfs = $ffba
  70. 1040 setnam = $ffbd
  71. 1050 open   = $ffc0
  72. 1060 close  = $ffc3
  73. 1070 clrchn = $ffcc
  74. 1080 scnkey = $ff9f
  75. 1090 ;
  76. 1100 sub    = 256    ;temp subrtns base
  77. 1110 prog   = $da00  ;prg2 code start
  78. 1120 ;
  79. 1130 ;the next four bytes can be set
  80. 1140 ;from basic with run 100
  81. 1150 ;
  82. 1160 numtop .byte 4  ;# of help files
  83. 1170 bord   .byte 9  ;help bord colour
  84. 1180 back   .byte 9  ;help bgnd colour
  85. 1190 curs   .byte 0  ;help text colour
  86. 1200 ;
  87. 1210 ;
  88. 1220 escape rts
  89. 1230 ;
  90. 1240 init =*
  91. 1250 ;called from basic on run
  92. 1260 jsr $aefd       ;check comma
  93. 1270 jsr $ad8a       ;evaluate address
  94. 1280 jsr $b7f7       ;conv to integer
  95. 1290 ldx $0290       ;text keylog now
  96. 1300 cpx $e0         ; in rom
  97. 1310 bcc escape      ; no
  98. 1320 stx out1+2      ;save old keylog
  99. 1330 ldx $028f       ; vector
  100. 1340 stx out1+1
  101. 1350 tax             ;test var a = 0
  102. 1360 bne in2         ; no
  103. 1370 ;
  104. 1380 in1 sec         ;make room for top
  105. 1390 lda $37         ; of basic subrtns
  106. 1400 sbc #end-start
  107. 1410 sta $37
  108. 1420 tay
  109. 1430 lda $38
  110. 1440 sbc #0
  111. 1450 sta $38
  112. 1460 ;
  113. 1470 in2 sty newlog  ;install new
  114. 1480 sta newlog+1    ; keylog vector
  115. 1490 sty $22         ;set up to copy
  116. 1500 sta $23         ; link code
  117. 1510 tax             ;set up jump to
  118. 1520 tya             ; old keylog-link
  119. 1530 clc             ; keylog-link
  120. 1540 adc #out-start
  121. 1550 sta ojmp
  122. 1560 bcc in3
  123. 1570 inx
  124. 1580 ;
  125. 1590 in3 stx ojmp+1
  126. 1600 ldy #end-(start+1)
  127. 1610 ;
  128. 1620 in4 lda start,y ;copy link code to
  129. 1630 sta ($22),y     ; its new home
  130. 1640 dey
  131. 1650 bpl in4
  132. 1660 ldy #2
  133. 1670 ;
  134. 1680 in8 lda bord,y  ;set up video
  135. 1690 sta hlpvid+15,y ; preferences
  136. 1700 dey
  137. 1710 bpl in8
  138. 1720 lda numtop      ;save # of help
  139. 1730 sta ntsave      ; files available
  140. 1740 sei             ;config 100% ram
  141. 1750 lda #$34        ; (no i/o, roms)
  142. 1760 sta 1
  143. 1770 lda #<end       ;copy help code
  144. 1780 ldy #>end       ; to $da00 ram
  145. 1790 sta $22
  146. 1800 sty $23
  147. 1810 lda #<prog
  148. 1820 ldy #>prog
  149. 1830 sta $24
  150. 1840 sty $25
  151. 1850 ldy #0
  152. 1860 ldx #>$e0ff-prog;# pages to copy
  153. 1870 ;
  154. 1880 in9 lda ($22),y
  155. 1890 sta ($24),y
  156. 1900 iny
  157. 1910 bne in9
  158. 1920 inc $23
  159. 1930 inc $25
  160. 1940 dex
  161. 1950 bne in9
  162. 1960 jsr end         ;vecset in low ram
  163. 1970 lda #$37        ;config for basic
  164. 1980 sta 1
  165. 1990 cli
  166. 2000 lda $37         ;decrement top
  167. 2010 bne in10        ; of basic due to
  168. 2020 dec $38         ; basic val() bug
  169. 2030 ;
  170. 2040 in10 dec $37
  171. 2050 rts
  172. 2060 ;
  173. 2070 ;
  174. 2080 ;the next 2 routines are stored in
  175. 2090 ;'normal' ram, either at the top
  176. 2100 ;of basic, or at an address
  177. 2110 ;specified by the user
  178. 2120 ;
  179. 2130 ;
  180. 2140 start =*
  181. 2150 ;switch out rom, do new keyscan
  182. 2160 sei
  183. 2170 lda 1
  184. 2180 pha
  185. 2190 lda #$34
  186. 2200 sta 1
  187. 2210 jmp scan
  188. 2220 ;
  189. 2230 ;
  190. 2240 out =*
  191. 2250 ;restore roms, do rom keyscan
  192. 2260 pla
  193. 2270 sta 1
  194. 2280 out1 jmp $ffff
  195. 2290 ;
  196. 2300 end =*
  197. 2310 ;
  198. 2320 ;
  199. 2330 ;vecset and hlpvid are needed by
  200. 2340 ;both init code and help code
  201. 2350 ;
  202. 2360 ;
  203. 2370 vecset =*
  204. 2380 ;save old vector, install new one
  205. 2390 lda $028f
  206. 2400 ldy $0290
  207. 2410 sta prog+(oldlog-vecset)
  208. 2420 sty prog+(oldlog+1-vecset)
  209. 2430 lda prog+(newlog-vecset)
  210. 2440 ldy prog+(newlog+1-vecset)
  211. 2450 ;
  212. 2460 vcs1 sta $028f
  213. 2470 sty $0290
  214. 2480 rts
  215. 2490 ;
  216. 2500 ;
  217. 2510 ;the following table will be poked
  218. 2520 ;into video chip on entering help
  219. 2530 ;
  220. 2540 ;
  221. 2550 hlpvid =*
  222. 2560 .byte $1b,$0a,$aa,$65,$00,$c8
  223. 2570 .byte $00,$17,$79,$f0,$00,$00
  224. 2580 .byte $00,$00,$00,$f9,$f9
  225. 2590 ;
  226. 2600 ;
  227. 2610 ;the variables in the following
  228. 2620 ;table are defined below
  229. 2630 ;
  230. 2640 ;
  231. 2650 hcurs  .byte 0
  232. 2660 ;
  233. 2670 usrtxt .byte 0
  234. 2680 usrcol .byte 0
  235. 2690 usrscr .byte 0
  236. 2700 usrbnk .byte 0
  237. 2710 ;
  238. 2720 ntsave .byte 0
  239. 2730 ;
  240. 2740 ojmp   .word 0
  241. 2750 ;
  242. 2760 oldlog .word 0
  243. 2770 newlog .word 0
  244. 2780 ;
  245. 2790 *=*+2
  246. 2800 ;
  247. 2810 ;
  248. 2820 ;'scan' is the address of the
  249. 2830 ;actual program code in d-block
  250. 2840 ;ram, as calculated by assembler
  251. 2850 ;
  252. 2860 ;
  253. 2870 scan = prog+(*-vecset)
  254. 2880 ;
  255. 2890 ;end 1st assembly
  256. 2900 .end
  257. 2910 :
  258. 2920 :
  259. 2930 print: rem cosmetic newline
  260. 2940 :
  261. 2950 :
  262. 2960 rem the output from the second
  263. 2970 rem assembly is appended to that
  264. 2980 rem from the first
  265. 2990 :
  266. 3000 open 2,8,2,"0:t-help!,p,a"
  267. 3010 :
  268. 3020 sys 700
  269. 3030 *= $da00
  270. 3040 .opt o2
  271. 3050 ;
  272. 3060 chrout = $ffd2  ;kernal addresses
  273. 3070 chkin  = $ffc6
  274. 3080 getin  = $ffe4
  275. 3090 setlfs = $ffba
  276. 3100 setnam = $ffbd
  277. 3110 open   = $ffc0
  278. 3120 close  = $ffc3
  279. 3130 clrchn = $ffcc
  280. 3140 scnkey = $ff9f
  281. 3150 ;
  282. 3160 sub    = $100   ;temp subrtns base
  283. 3170 flash  = $140   ;screenflash addr
  284. 3180 deslen = 25+1   ;# bytes/desc
  285. 3190 ;
  286. 3200 ;most of the actual data for the
  287. 3210 ;following storage area is written
  288. 3220 ;here by the first part of the
  289. 3230 ;program. it is duplicated here
  290. 3240 ;because we need to tell pal about
  291. 3250 ;the various addresses
  292. 3260 ;
  293. 3270 vecset *=*+18   ;vector swap
  294. 3280 vcs1   *=*+7    ; routine
  295. 3290 hlpvid *=*+17   ;help video prefs
  296. 3300 hcurs  *=*+1    ;help crsr colour
  297. 3310 usrtxt *=*+1    ;text colour save
  298. 3320 usrcol *=*+1    ;colour under crsr
  299. 3330 usrscr *=*+1    ;screen page
  300. 3340 usrbnk *=*+1    ;16k video bank
  301. 3350 ntsave *=*+1    ;# of help files
  302. 3360 ojmp   *=*+2    ;exit routine addr
  303. 3370 oldlog *=*+2    ;old keylog addr
  304. 3380 newlog *=*+2    ;new keylog addr
  305. 3390 ;
  306. 3400 *=*+2           ;skip load address
  307. 3410 ;
  308. 3420 scan =*
  309. 3430 ;new keyscan routine
  310. 3440 lda $cb         ;test last key
  311. 3450 cmp #$39        ; was left arrow
  312. 3460 beq sca2        ; yes
  313. 3470 ;
  314. 3480 sca1 jmp (ojmp) ;old keylog link
  315. 3490 ;
  316. 3500 sca2 ldx $028d  ;test (shift)ctrl
  317. 3510 cpx #4
  318. 3520 bcc sca1        ; no
  319. 3530 cpx #6
  320. 3540 bcs sca1        ; no
  321. 3550 lda #$40        ;put 'no key' in
  322. 3560 sta $cb         ; last key pressed
  323. 3570 lda oldlog      ;restore vec so 2d
  324. 3580 ldy oldlog+1    ; press won't bomb
  325. 3590 jsr vcs1
  326. 3600 cpx #4          ;test unshifted
  327. 3610 beq sca3        ; yes
  328. 3620 ldx #$30        ;long flash count
  329. 3630 bne sca7        ;flash and exit
  330. 3640 ;
  331. 3650 sca3 ldx #$10   ;short flash count
  332. 3660 ;
  333. 3670 sca4 lda $98    ;test # open files
  334. 3680 beq sca5        ; zero - ok
  335. 3690 cmp #1
  336. 3700 bne sca6        ; > one - exit
  337. 3710 lda $0259       ;current lf #
  338. 3720 jsr hash        ;get unique lf #
  339. 3730 sta file
  340. 3740 lda $026d       ;current secadd
  341. 3750 jsr hash        ;get unique secadd
  342. 3760 sta secadd
  343. 3770 ;
  344. 3780 sca5 jmp help
  345. 3790 ;
  346. 3800 sca6 jsr vecset ;install new k'log
  347. 3810 ;
  348. 3820 sca7 ldy #endfla;copy flash rout'n
  349. 3830 ;
  350. 3840 sca8 lda fla,y
  351. 3850 sta flash,y
  352. 3860 dey
  353. 3870 bpl sca8
  354. 3880 jsr flash       ;do flash
  355. 3890 jmp sca1        ;exit help pgm
  356. 3900 ;
  357. 3910 ;
  358. 3920 hash =*
  359. 3930 ;select non-conflicting file or sa
  360. 3940 and #$7e        ;clear bits 0, 7
  361. 3950 ora #4          ;set bit 2
  362. 3960 eor #2          ;clear bit 1
  363. 3970 rts
  364. 3980 ;
  365. 3990 ;
  366. 4000 ;this routine is copied to the
  367. 4010 ;stack when needed, and run there
  368. 4020 ;
  369. 4030 ;
  370. 4040 fla =*
  371. 4050 ;flash screen
  372. 4060 lda #$37        ;switch in i/o etc
  373. 4070 sta 1
  374. 4080 ;
  375. 4090 fla1 cpx $d012  ;wait for raster
  376. 4100 bne fla1
  377. 4110 inc $d020       ;bump colours
  378. 4120 inc $d021
  379. 4130 dex             ;test finished
  380. 4140 bne fla1        ; no - reflash
  381. 4150 lda #$34        ; yes - exit
  382. 4160 sta 1
  383. 4170 rts
  384. 4180 ;
  385. 4190 endfla = *-(fla+1)
  386. 4200 ;
  387. 4210 ;
  388. 4220 ;the next subroutines are copied
  389. 4230 ;from d-block ram to $100 every
  390. 4240 ;time help is used
  391. 4250 ;
  392. 4260 ;
  393. 4270 subr =*
  394. 4280 ;copy byte from ram addr (subr+5)
  395. 4290 ;to d-block ram addr (subr+12)
  396. 4300 ldx #$37        ;roms in
  397. 4310 stx 1
  398. 4320 lda $ffff       ;addr set on call
  399. 4330 ldx #$34        ;roms out
  400. 4340 stx 1
  401. 4350 sta $ffff       ;addr set on call
  402. 4360 inc sub+5       ;bump fetch addr
  403. 4370 bne sb1
  404. 4380 inc sub+6
  405. 4390 ;
  406. 4400 sb1 inc sub+12  ;bump stash addr
  407. 4410 bne sb2
  408. 4420 inc sub+13
  409. 4430 ;
  410. 4440 sb2 rts
  411. 4450 ;
  412. 4460 ;
  413. 4470 zubr =*
  414. 4480 ;copy byte from d-block ram addr
  415. 4490 ;(zubr+1) to ram addr (zubr+8)
  416. 4500 lda $ffff       ;addr set on call
  417. 4510 ldx #$37        ;roms in
  418. 4520 stx 1
  419. 4530 sta $ffff       ;addr set on call
  420. 4540 ldx #$34        ;roms out
  421. 4550 stx 1
  422. 4560 inc zub+1       ;bump fetch addr
  423. 4570 bne zb1
  424. 4580 inc zub+2
  425. 4590 ;
  426. 4600 zb1 inc zub+8   ;bump stash addr
  427. 4610 bne zb2
  428. 4620 inc zub+9
  429. 4630 ;
  430. 4640 zb2 rts
  431. 4650 ;
  432. 4660 ;calc absolute address of zubr
  433. 4670 zub = sub+zubr-subr
  434. 4680 ;
  435. 4690 ;
  436. 4700 opn =*
  437. 4710 ;open a help file (help-a, etc)
  438. 4720 sta filnam+5    ;last filnam char
  439. 4730 lda file        ;open lf,8,sa...
  440. 4740 pha
  441. 4750 ldy secadd
  442. 4760 ldx #$37
  443. 4770 stx 1
  444. 4780 ldx #8
  445. 4790 jsr setlfs
  446. 4800 ldx #<filnam    ;..."help-?"
  447. 4810 ldy #>filnam
  448. 4820 lda #6
  449. 4830 jsr setnam
  450. 4840 jsr open
  451. 4850 pla
  452. 4860 tax             ;open input chan
  453. 4870 jsr chkin
  454. 4880 ;
  455. 4890 of1 sei         ;(rom did cli)
  456. 4900 ldx #$34        ;roms out
  457. 4910 stx 1
  458. 4920 rts
  459. 4930 ;
  460. 4940 ;calc absolute address of opn
  461. 4950 opnfil = sub+opn-subr
  462. 4960 ;
  463. 4970 ;
  464. 4980 ;help filename - last char varies
  465. 4990 fnam .asc "help-?"
  466. 5000 ;
  467. 5010 ;calc absolute address of fnam
  468. 5020 filnam = sub+fnam-subr
  469. 5030 ;
  470. 5040 ;
  471. 5050 get =*
  472. 5060 ;get byte from help file
  473. 5070 ldx #$37        ;roms in
  474. 5080 stx 1
  475. 5090 jsr getin       ;get the byte
  476. 5100 clc             ;relocatable jmp
  477. 5110 bcc of1
  478. 5120 ;
  479. 5130 ;calc absolute address of get
  480. 5140 getbyt = sub+get-subr
  481. 5150 ;
  482. 5160 ;
  483. 5170 cls =*
  484. 5180 ;close help file
  485. 5190 lda file
  486. 5200 pha
  487. 5210 ldx #$37        ;roms in
  488. 5220 stx 1
  489. 5230 jsr clrchn      ;close the file
  490. 5240 pla
  491. 5250 jsr close
  492. 5260 clc             ;relocatable jmp
  493. 5270 bcc of1
  494. 5280 ;
  495. 5290 ;calc absolute address of cls
  496. 5300 clsfil = sub+cls-subr
  497. 5310 ;
  498. 5320 ;
  499. 5330 key =*
  500. 5340 ;get ascii byte, return in .a
  501. 5350 ;return shift key register in .y
  502. 5360 lda #$37       ;roms in
  503. 5370 sta 1
  504. 5380 jsr scnkey     ;scan kybd matrix
  505. 5390 ldy $cb        ;get keycode
  506. 5400 lda $eb81,y    ;conv to ascii
  507. 5410 ldy $028d      ;shift key register
  508. 5420 ;
  509. 5430 ky1 clc        ;relocatable jmp
  510. 5440 bcc of1
  511. 5450 ;
  512. 5460 ;calc absolute address of key
  513. 5470 keychk = sub+key-subr
  514. 5480 ;
  515. 5490 ;
  516. 5500 put =*
  517. 5510 ;print a character to the screen
  518. 5520 ldx #$37
  519. 5530 stx 1
  520. 5540 jsr chrout
  521. 5550 clc             ;relocatable jmp
  522. 5560 bcc of1
  523. 5570 ;
  524. 5580 ;calc absolute address of put
  525. 5590 putbyt = sub+put-subr
  526. 5600 ;
  527. 5610 ;
  528. 5620 ;calc # of subroutine bytes
  529. 5630 subsiz = *-subr
  530. 5640 ;
  531. 5650 ;
  532. 5660 ;next comes the actual code that
  533. 5670 ;executes in d-block ram. the
  534. 5680 ;first section swaps out the user
  535. 5690 ;environment, & installs a new one
  536. 5700 ;
  537. 5710 ;
  538. 5720 help =*
  539. 5730 ;the help utility mainline
  540. 5740 lda #0          ;copy $0000-01ff
  541. 5750 ldy #$d0        ;  to $d000-d1ff
  542. 5760 ldx #2
  543. 5770 jsr copy
  544. 5780 lda #4          ;copy $0400-07ff
  545. 5790 ldy #$d2        ;  to $d200-d5ff
  546. 5800 tax
  547. 5810 jsr copy
  548. 5820 tsx             ;save user stk ptr
  549. 5830 stx stksav
  550. 5840 ldx #$ff        ;put our stk ptr
  551. 5850 txs             ; far from subrtns
  552. 5860 ldy #subsiz     ;copy subroutines
  553. 5870 ;                 into stack page
  554. 5880 he1 lda subr,y
  555. 5890 sta sub,y
  556. 5900 dey
  557. 5910 cpy #$ff
  558. 5920 bne he1
  559. 5930 iny             ;copy colour ram
  560. 5940 sty sub+5       ; ($d800-$dbff)
  561. 5950 sty sub+12      ; to ram beneath
  562. 5960 lda #4          ; ($d600-$d9ff)
  563. 5970 sta 2
  564. 5980 ldx #$d8
  565. 5990 stx sub+6
  566. 6000 ldx #$d6
  567. 6010 stx sub+13
  568. 6020 ;
  569. 6030 he2 jsr sub
  570. 6040 dey
  571. 6050 bne he2
  572. 6060 dec 2
  573. 6070 bne he2
  574. 6080 lda #<$d011     ;copy video regs
  575. 6090 ldy #>$d011     ; to a save buffer
  576. 6100 sta sub+5
  577. 6110 sty sub+6
  578. 6120 lda #<vidbuf
  579. 6130 ldy #>vidbuf
  580. 6140 sta sub+12
  581. 6150 sty sub+13
  582. 6160 ldy #16
  583. 6170 sty $cc
  584. 6180 ;
  585. 6190 he3 jsr sub
  586. 6200 dey
  587. 6210 bpl he3
  588. 6220 lda $0286       ;save colour of
  589. 6230 ldy $0287       ; text and of char
  590. 6240 ldx $0288       ; under cursor,
  591. 6250 sta usrtxt      ; and screen page
  592. 6260 sty usrcol
  593. 6270 stx usrscr
  594. 6280 lda #4
  595. 6290 sta $0288       ;screen at page 4
  596. 6300 lda #<$dd00     ;save user's video
  597. 6310 ldy #>$dd00     ; bank number
  598. 6320 sta sub+5       ; (the hard way)
  599. 6330 sty sub+6
  600. 6340 sta zub+8
  601. 6350 sty zub+9
  602. 6360 lda #<usrbnk
  603. 6370 ldy #>usrbnk
  604. 6380 sta sub+12
  605. 6390 sty sub+13
  606. 6400 jsr sub
  607. 6410 lda usrbnk
  608. 6420 ora #3
  609. 6430 jsr zub+3
  610. 6440 lda #<hlpvid    ;copy our video
  611. 6450 ldy #>hlpvid    ; preferences into
  612. 6460 sta zub+1       ; vic chip
  613. 6470 sty zub+2
  614. 6480 lda #<$d011
  615. 6490 ldy #>$d011
  616. 6500 sta zub+8
  617. 6510 sty zub+9
  618. 6520 ldy #16
  619. 6530 ;
  620. 6540 he4 jsr zub
  621. 6550 dey
  622. 6560 bpl he4
  623. 6570 lda hcurs       ;our text colour
  624. 6580 sta $0286
  625. 6590 ;
  626. 6600 he5 lda #<hlptxt;startup message
  627. 6610 ldy #>hlptxt
  628. 6620 jsr prstr
  629. 6630 lda #13         ;two returns
  630. 6640 jsr putbyt
  631. 6650 jsr putbyt
  632. 6660 lda #<names     ;address of help
  633. 6670 ldy #>names     ; topic strings
  634. 6680 sta 3
  635. 6690 sty 4
  636. 6700 lda #0          ;topic #
  637. 6710 sta 2
  638. 6720 ;
  639. 6730 he6 clc         ;conv topic # to
  640. 6740 adc #"a"        ; char and print
  641. 6750 jsr putbyt
  642. 6760 lda #$20        ;print space
  643. 6770 jsr putbyt
  644. 6780 lda 3           ;print topic str
  645. 6790 ldy 4
  646. 6800 jsr prstr
  647. 6810 clc
  648. 6820 lda 3           ;calc address of
  649. 6830 adc #deslen     ; next string
  650. 6840 sta 3
  651. 6850 bcc he7
  652. 6860 inc 4
  653. 6870 ;
  654. 6880 he7 lda #13     ;print return
  655. 6890 jsr putbyt
  656. 6900 inc 2
  657. 6910 lda 2
  658. 6920 cmp ntsave      ;test all printed
  659. 6930 bne he6         ; no
  660. 6940 ;
  661. 6950 he8 jsr keychk  ;get a character
  662. 6960 cpy #2          ;test logo pressed
  663. 6970 beq he9         ; yes
  664. 6980 tax             ;save character
  665. 6990 sec             ;conv keypress to
  666. 7000 sbc #"a"        ; help topic #
  667. 7010 bcc he8         ; invalid
  668. 7020 cmp ntsave
  669. 7030 bcs he8         ; invalid
  670. 7040 txa             ;retrieve char
  671. 7050 jsr prtfil      ;print the file
  672. 7060 jmp he5         ;reprint menu
  673. 7070 ;
  674. 7080 he9 lda #<vidbuf;restore user's
  675. 7090 ldy #>vidbuf    ; video
  676. 7100 sta zub+1
  677. 7110 sty zub+2
  678. 7120 lda #<$d011
  679. 7130 ldy #>$d011
  680. 7140 sta zub+8
  681. 7150 sty zub+9
  682. 7160 ldy #16
  683. 7170 ;
  684. 7180 he10 jsr zub
  685. 7190 dey
  686. 7200 bpl he10
  687. 7210 iny             ;copy from d-ram
  688. 7220 sty zub+1       ; ($d700-$daff)
  689. 7230 sty zub+8       ; to colour ram
  690. 7240 ldx #$d6        ; ($d800-$dbff)
  691. 7250 stx zub+2
  692. 7260 ldx #$d8
  693. 7270 stx zub+9
  694. 7280 lda #4
  695. 7290 sta 2
  696. 7300 ;
  697. 7310 he11 jsr zub
  698. 7320 dey
  699. 7330 bne he11
  700. 7340 dec 2
  701. 7350 bne he11
  702. 7360 lda usrtxt
  703. 7370 ldy usrcol
  704. 7380 ldx usrscr
  705. 7390 sta $0286
  706. 7400 sty $0287
  707. 7410 stx $0288
  708. 7420 lda #<usrbnk
  709. 7430 ldy #>usrbnk
  710. 7440 sta zub+1
  711. 7450 sty zub+2
  712. 7460 lda #<$dd00
  713. 7470 ldy #>$dd00
  714. 7480 sta zub+8
  715. 7490 sty zub+9
  716. 7500 jsr zub
  717. 7510 ldx stksav      ;restore stack ptr
  718. 7520 txs
  719. 7530 ldx #3          ;save 4 0-pg bytes
  720. 7540 ;
  721. 7550 he11a lda $d022,x
  722. 7560 sta $07f8,x
  723. 7570 dex
  724. 7580 bpl he11a
  725. 7590 lda #$d0        ;restore 3 pgs low
  726. 7600 sta $d023       ; ram from $d000
  727. 7610 ldy #0          ; (doubling vecs
  728. 7620 sty $d022       ;  $22 - $25 in
  729. 7630 sty $d024       ;  d-ram image)
  730. 7640 sty $d025
  731. 7650 ldx #2
  732. 7660 bne xcopy
  733. 7670 ;
  734. 7680 he12 ldx #3     ;put zp bytes back
  735. 7690 he14 lda $07f8,x
  736. 7700 sta $22,x
  737. 7710 dex
  738. 7720 bpl he14
  739. 7730 ldy #4          ;restore $400-$7ff
  740. 7740 lda #$d2        ; from $d200-$d5ff
  741. 7750 ldx #4
  742. 7760 jsr copy
  743. 7770 jsr vecset      ;set up our vector
  744. 7780 he15 jmp (ojmp) ;exit via rom
  745. 7790 ;
  746. 7800 ;
  747. 7810 ;the next routine copies pages of
  748. 7820 ;memory. enter with source page in
  749. 7830 ;.a, target page in .y, # of pages
  750. 7840 ;to copy in .x. 'copy' is the
  751. 7850 ;normal version; 'xcopy' is a
  752. 7860 ;kludge to avoid using the stack
  753. 7870 ;copying into page 1 of memory.
  754. 7880 ;
  755. 7890 ;
  756. 7900 xcopy =*
  757. 7910 ;copy memory, branch back to he12
  758. 7920 sec
  759. 7930 .byte $24       ;'bit' (skip clc)
  760. 7940 ;
  761. 7950 copy =*
  762. 7960 ;copy memory, return via rts
  763. 7970 clc
  764. 7980 sta $23         ;source hi
  765. 7990 sty $25         ;target hi
  766. 8000 ldy #0
  767. 8010 sty $22         ;source lo
  768. 8020 sty $24         ;target lo
  769. 8030 cp1 lda ($22),y
  770. 8040 sta ($24),y
  771. 8050 iny
  772. 8060 bne cp1
  773. 8070 inc $23
  774. 8080 inc $25
  775. 8090 dex             ;page counter
  776. 8100 bne cp1
  777. 8110 bcs he12        ;xcopy escape
  778. 8120 rts
  779. 8130 ;
  780. 8140 ;
  781. 8150 prtfil =*
  782. 8160 ;print a help file
  783. 8170 jsr opnfil      ;open the file
  784. 8180 ;
  785. 8190 prt1 lda #$93   ;clear screen
  786. 8200 jsr putbyt
  787. 8210 lda #23         ;init line count
  788. 8220 sta lincnt
  789. 8230 ;
  790. 8240 prt2 lda #40    ;init column count
  791. 8250 sta colcnt
  792. 8260 ;
  793. 8270 prt3 jsr getbyt ;get disk byte
  794. 8280 jsr putbyt      ;print it
  795. 8290 ldx $90         ;test status
  796. 8300 bne prt6        ; eof
  797. 8310 cmp #13         ;test cr
  798. 8320 beq prt4        ; yes
  799. 8330 dec colcnt      ;test end of line
  800. 8340 bne prt3        ; no
  801. 8350 ;
  802. 8360 prt4 dec lincnt ;test end of page
  803. 8370 bne prt2        ; no
  804. 8380 jsr spcstr      ;'spc to continue'
  805. 8390 lda #<ht1       ;'logo to exit'
  806. 8400 ldy #>ht1
  807. 8410 jsr prstr
  808. 8420 ;
  809. 8430 prt5 jsr keychk ;get a key
  810. 8440 cpy #2          ;test logo pressed
  811. 8450 beq prt8        ; yes
  812. 8460 cmp #$20        ;test spc pressed
  813. 8470 bne prt5        ; no
  814. 8480 beq prt1        ; yes
  815. 8490 ;
  816. 8500 prt6 jsr spcstr ;'spc to continue'
  817. 8510 ;
  818. 8520 prt7 jsr keychk ;get a key
  819. 8530 cmp #$20        ;test spc pressed
  820. 8540 bne prt7        ; no
  821. 8550 ;
  822. 8560 prt8 jmp clsfil ;close and exit
  823. 8570 ;
  824. 8580 ;
  825. 8590 spcstr =*
  826. 8600 ;print 'press space to continue'
  827. 8610 lda #<spctxt
  828. 8620 ldy #>spctxt
  829. 8630 ;
  830. 8640 prstr =*
  831. 8650 ;print string addressed in .a/.y
  832. 8660 sta $22
  833. 8670 sty $23
  834. 8680 ldy #0
  835. 8690 ;
  836. 8700 prs1 lda ($22),y
  837. 8710 beq prs2
  838. 8720 jsr putbyt      ;print character
  839. 8730 iny
  840. 8740 bne prs1
  841. 8750 ;
  842. 8760 prs2 rts
  843. 8770 ;
  844. 8780 ;
  845. 8790 ;messages - no room for
  846. 8800 ;anything too fancy here
  847. 8810 ;
  848. 8820 ;
  849. 8830 hlptxt =*
  850. 8840 .byte 13,8,147
  851. 8850 .asc  "[200]elp! [200]elp!"
  852. 8860 .byte 13,13,18
  853. 8870 .asc  "[211]elect a topic"
  854. 8880 ;
  855. 8890 ;next msg is part of hlptxt, but
  856. 8900 ;can also be addressed separately
  857. 8910 ;
  858. 8920 ht1 =*
  859. 8930 .byte 18
  860. 8940 .asc  " ([204][207][199][207] key to exit)"
  861. 8950 .byte 146,0
  862. 8960 ;
  863. 8970 spctxt =*
  864. 8980 .byte 13,18
  865. 8990 .asc  "[211][208][193][195][197] to continue"
  866. 9000 .byte 146,0
  867. 9010 ;
  868. 9020 ;
  869. 9030 ;uninitialized data area
  870. 9040 ;
  871. 9050 ;
  872. 9060 stksav .byte 0  ;old stack ptr
  873. 9070 lincnt .byte 0  ;lines per page
  874. 9080 colcnt .byte 0  ;chars per line
  875. 9090 file   .byte 2  ;logical file #
  876. 9100 secadd .byte 2  ;secondary address
  877. 9110 ;
  878. 9120 vidbuf *=*+17   ;video save area
  879. 9130 ;
  880. 9140 ;
  881. 9150 ;a whole bunch of empty bytes
  882. 9160 ;for the help topic strings
  883. 9170 ;
  884. 9180 ;
  885. 9190 names =*
  886. 9200 *= names+(20*deslen)-1
  887. 9210 .byte 0
  888. 9220 ;
  889.