Advertisement
Guest User

Forth demo

a guest
Sep 12th, 2024
50
0
91 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.57 KB | Source Code | 0 0
  1.  
  2. This is the source to the DX-Forth installer program.
  3.  
  4. INSTALL customises the DX-Forth compiler and turnkey
  5. applications for a variety of video terminals. Also,
  6. the CPU speed, terminal delay times, arrow key codes
  7. and no-warmboot option may be adjusted.
  8.  
  9. empty forth definitions decimal
  10. application
  11.  
  12. : TITLE ( -- ) ." DX-INSTALL 2.2" cr ;
  13.  
  14. cr ." loading " title 2 #screens 1- thru
  15.  
  16. cr ." Save to disk? " y/n [if]
  17. turnkey install INSTALL
  18. [then]
  19.  
  20. 1 fload ZINS.SCR
  21.  
  22. : CLS ( -- ) 25 0 do cr loop ; \ simple clear screen
  23.  
  24. : EMITS ( n char -- ) swap 0 ?do dup emit loop drop ;
  25.  
  26. : +PLACE ( a u a2 -- ) count +string swap 1- c! ;
  27.  
  28. : ?PLACE ( a u a2 -- ) over if place end drop 2drop ;
  29.  
  30. : CHANGE? ( -- f ) ." Change? " y/n ;
  31.  
  32. : .HB ( u -- ) 2 (h.n) [char] $ hold #> type space ;
  33.  
  34. : .ONOFF ( flag -- ) if ." ON " end ." OFF " ;
  35.  
  36. integer cf ( -- a ) \ current file handle
  37.  
  38. -? : HANDLE create max-path 1+ cell+ allot does> to cf ;
  39.  
  40. : !FNAME ( a n -- ) max-path min cf cell+ place ;
  41. : @FNAME ( -- a n ) cf cell+ count ;
  42.  
  43. \ File handles
  44. handle IN-FILE handle DTA-FILE
  45.  
  46. \ Show help and exit
  47. : HELP ( -- )
  48. cr ." Installer for DX-Forth and applications" cr
  49. cr ." Use: INSTALL filename[.com] [termfile[.dta]]" abort ;
  50.  
  51. \ Encountered file error, display msg, filename then quit
  52. : FERR ( ? ior a u -- ? ) rot 0= if 2drop end
  53. cr ." File error: " type ." - " @fname type abort ;
  54.  
  55. : FOPEN ( a n fam -- ) open-file s" open" ferr cf ! ;
  56. : FCREAT ( a n fam -- ) create-file s" create" ferr cf ! ;
  57. : FREAD ( a n -- n' ) cf @ read-file s" read" ferr ;
  58. : FWRITE ( a n -- ) cf @ write-file s" write" ferr ;
  59. : FSEEK ( ud -- ) cf @ reposition-file s" position" ferr ;
  60. : FCLOSE ( -- ) cf @ close-file s" close" ferr ;
  61.  
  62. \ Parse the CP/M command line for the n'th blank delimited
  63. \ parameter. Return the address and length and a true flag if
  64. \ found, otherwise return false.
  65. : ARG ( n -- adr len -1 | 0 )
  66. >r 0 0 cmdtail r> 0 ?do
  67. 2nip
  68. bl skip 2dup bl scan
  69. rot over - -rot
  70. loop 2drop
  71. dup if -1 end and ;
  72.  
  73. integer #TERMS \ number of terminals in DTA file
  74. integer TERM \ working terminal#
  75. $95 constant TLEN \ length of each term definition
  76. $100 constant CHUNK \ in-file chunk to get
  77. 20 constant ISIZ \ size input buffer / terminal name
  78. 200 constant TMAX \ max #terminals
  79.  
  80. \ Storage areas allocated at run-time
  81. integer IN-BASE ( -- a ) \ in-file
  82. integer DTA-BASE ( -- a ) \ dta-file
  83. integer TBUF ( -- a ) \ temp terminal buffer
  84. integer SBUF ( -- a ) \ swap/work buffer
  85. integer IBUF ( -- a ) \ console input
  86. integer XBUF ( -- a ) \ terminal index
  87.  
  88. \ Convert logical adr to target adr
  89. : >TARGET ( a -- a' ) $100 - in-base + ;
  90.  
  91. \ Get input from console
  92. : ENTER ( -- adr len ) ibuf dup isiz accept -blanks ;
  93.  
  94. \ First terminal in DTA
  95. : 0TERM ( -- a ) dta-base 2 cells + ;
  96.  
  97. \ DTA end + 1
  98. : DTA-END ( -- a ) 0term #terms tlen * + ;
  99.  
  100. \ Get adr of terminal n
  101. : >DTA ( n -- a ) cells xbuf + @ ;
  102.  
  103. \ Get adr of selected terminal
  104. : DBUF ( -- a ) term >dta ;
  105.  
  106. \ Get name of terminal n
  107. : NAME ( n -- adr len ) >dta count ;
  108.  
  109. \ Install terminal data at offs to target at adr
  110. : SET.S ( a ofs -- ) dbuf + count rot >target place ;
  111. : SET.W ( a ofs -- ) dbuf + @ swap >target ! ;
  112. : SET.B ( a ofs -- ) dbuf + c@ swap >target c! ;
  113.  
  114. hex
  115. 110 constant 'WBT \ warm boot
  116. 124 constant 'SPD \ cpu speed
  117. 14E constant 'BKSP \ backspace
  118. 14F constant 'UP \ cursor keys
  119. 150 constant 'DN \
  120. 151 constant 'RT \
  121. 152 constant 'LFT \
  122. 153 constant 'TNAME \ terminal name
  123. 1A0 constant 'TDCM \ terminal delays
  124. 1BA constant 'TDCLS \
  125. 1CE constant 'TDEOL \
  126. decimal
  127.  
  128. hex
  129. : TNAME ( -- ) 'tname 0 set.s ; \ terminal name
  130. : TINIT ( -- ) 16B 16 set.s ; \ term init
  131. : TEXIT ( -- ) 17B 26 set.s ; \ term exit
  132. : TCM ( -- ) 18B 36 set.s ; \ cursor motion template
  133. : TBIN ( -- ) 19B 46 set.b ; \ binary mode
  134. : TPOS ( -- ) 19E 47 set.w ; \ col row pos
  135. : TOFFS ( -- ) 19C 49 set.w ; \ col row offset
  136. : TDCM ( -- ) 'tdcm 4B set.w ; \ cm delay
  137. : TCLS ( -- ) 1A2 4D set.s ; \ clear screen
  138. : THOM ( -- ) 1A8 53 set.s ; \ home cursor
  139. : TDCLS ( -- ) 'tdcls 59 set.w ; \ cls delay
  140. decimal
  141.  
  142. hex
  143. : THIL ( -- ) 1C2 5B set.s ; \ hilight video
  144. : TNOR ( -- ) 1C8 61 set.s ; \ normal video
  145. : TDEOL ( -- ) 'tdeol 67 set.w ; \ eol delay
  146. : TEOL ( -- ) 1BC 69 set.s ; \ clear to end-of-line
  147. : TINS ( -- ) 1AE 6F set.s ; \ insert line
  148. : TDEL ( -- ) 1B4 75 set.s ; \ delete line
  149. : TCR ( -- ) 168 7B set.w ; \ # cols rows
  150. decimal
  151.  
  152. \ Initialize target with terminal data
  153. : !TDATA ( -- )
  154. tname tinit texit tcm tbin tpos toffs tdcm tcls thom
  155. tdcls thil tnor tdeol teol tins tdel tcr ;
  156.  
  157. \ ZINS install area excluding speed
  158. 'up $100 chunk + over - 2constant ZDATA ( -- a u )
  159.  
  160. : SWAP-OUT ( -- )
  161. sbuf 'spd @ over ! cell+ zdata rot swap cmove ;
  162.  
  163. : SWAP-IN ( -- )
  164. sbuf dup @ 'spd ! cell+ zdata cmove ;
  165.  
  166. : ZINSTALL ( -- )
  167. swap-out \ save existing
  168. zins \ install from Termcap
  169. 'spd dup @ swap >target ! \ move speed
  170. zdata over >target swap cmove \ move zdata
  171. swap-in ; \ restore existing
  172.  
  173. \ Read first chunk of target file into memory
  174. : OPEN-TARGET ( -- )
  175. in-file \ select filehandle
  176. 1 arg 0= if help then \ get first filename
  177. s" COM" +ext !fname \ append filetype
  178. @fname r/w fopen \ open target file
  179. chunk reserve to in-base \ allot buffer
  180. in-base chunk fread ( u) \ read target file
  181. chunk - \ check size
  182. $111 >target @ $4683 - or \ check DX-Forth id.
  183. s" not a DX-Forth application" ferr ;
  184.  
  185. \ Read DTA file into memory
  186. : READ-DTA ( -- )
  187. dta-file \ select filehandle
  188. 2 arg \ if second filename
  189. if s" DTA" +ext \ append filetype
  190. else s" INSTALL.DTA" then !fname \ else use default
  191. @fname r/w fopen \ open DTA file
  192. pad 256 + to dta-base \ assign buffer
  193. dta-base unused fread drop \ read DTA file
  194. fclose \ close
  195. dta-base dup @ to #terms \ get #terminals
  196. cell+ @ tlen - \ check DTA id.
  197. s" not a TPascal terminal file" ferr ;
  198.  
  199. : CLOSE-TARGET ( -- ) in-file fclose ;
  200.  
  201. : SAVE-TARGET ( -- ) \ update target file
  202. in-file 0. fseek in-base chunk fwrite ;
  203.  
  204. variable ALTERED \ DTA changed
  205.  
  206. : SAVE-DTA ( -- ) \ overwrite DTA file
  207. altered @ if
  208. dta-file @fname r/w fcreat
  209. dta-base 2 cells fwrite ( hdr)
  210. xbuf #terms 0 ?do dup @ tlen fwrite cell+ loop drop
  211. fclose
  212. then ;
  213.  
  214. \ Bubblesort addr/cells
  215. defer PRECEDES ( x1 x2 -- f ) \ comparison
  216.  
  217. : SORT ( adr siz -- )
  218. begin dup while 1-
  219. 2dup cells bounds ?do
  220. i 2@ precedes if i 2@ swap i 2! altered on then
  221. 1 cells +loop
  222. repeat 2drop ;
  223.  
  224. \ Compare counted strings
  225. : $COMP ( a1 a2 -- f )
  226. >r count r> count caps compare 0< ;
  227.  
  228. ' $comp is precedes
  229.  
  230. \ Sort terminals by name
  231. : SORT-TERMS ( -- ) xbuf #terms sort ;
  232.  
  233. \ Create list of pointers to each terminal definition
  234. : IDX ( -- )
  235. xbuf dta-end 0term ?do i over ! cell+ tlen +loop drop ;
  236.  
  237. \ Index & sort terminals
  238. : CATALOG ( -- )
  239. #terms tmax > if cr ." Too many terminals" abort then
  240. idx sort-terms ;
  241.  
  242. \ Select number in range n1 to n2. Return n3 true | false
  243. : #SELECT ( n1 n2 adr len -- n3 -1 | 0 )
  244. cr ." Enter" type ." : " enter cr
  245. number? if
  246. d>s dup 2swap between dup if end
  247. then 2drop 0 ;
  248.  
  249. : SELECT ( n1 n2 -- n3 -1 | 0 ) s" " #select ;
  250.  
  251. : ANYKEY ( -- ) cr ." Press any key to continue " key drop ;
  252.  
  253. : INVALID ( -- ) cr ." Invalid or nothing entered" cr ;
  254.  
  255. \ Edit CPU speed
  256. : CPU-SPEED ( -- )
  257. cls ." CPU speed is "
  258. 'spd >target dup @ u. ." MHz " change? if
  259. 1 8191 s" (1-8191)" #select if
  260. over !
  261. else invalid then anykey
  262. then drop ;
  263.  
  264. \ Change delay specified by adr & string
  265. : CHG-DELAY ( a adr len -- )
  266. cr cr type ." delay "
  267. >target dup c@ . ." mS " change? if
  268. 0 255 s" (0-255)" #select if
  269. over c!
  270. else invalid then anykey
  271. then drop ;
  272.  
  273. \ Change delay times
  274. : DELAY-TIMES ( -- ) cls
  275. 'tdcm s" Cursor Motion" chg-delay
  276. 'tdcls s" Clear Screen" chg-delay
  277. 'tdeol s" Clear to End-of-Line" chg-delay ;
  278.  
  279. \ Convert offset to adr in terminal buffer
  280. : >BUF ( n -- a ) tbuf + ;
  281.  
  282. : @STR ( ofs -- a u ) >buf count ;
  283. : !STR ( a u ofs -- ) >buf place ;
  284. : @BYT ( ofs -- c ) >buf c@ ;
  285. : !BYT ( c ofs -- ) >buf c! ;
  286.  
  287. : CMT ( -- a ) $36 >buf ; \ cursor motion template
  288. : #CMT ( -- ofs ) $36 @byt ; \ current size/offset
  289. : BIN? ( -- f ) $46 @byt ; \ binary?
  290. : COL? ( -- f ) $92 @byt ; \ column first?
  291. : #ASC ( -- n ) $93 @byt ; \ ASCII digits for row/col
  292.  
  293. : RC$ ( -- a n ) \ row/col string
  294. bin? if s" \00" end s" 000" drop #asc ;
  295.  
  296. : !RCOFS ( cofs rofs -- ) \ store template offsets
  297. col? if swap then $47 !byt $48 !byt ;
  298.  
  299. : !CMT ( -- ) \ init cursor motion template
  300. $80 @str cmt place \ lead-in
  301. rc$ cmt +place #cmt \ col, offs
  302. $86 @str cmt +place \ between
  303. rc$ cmt +place #cmt \ row, offs
  304. $8C @str cmt +place \ after
  305. !rcofs ; \ row/col offsets
  306.  
  307. 8 constant <BS> 13 constant <CR>
  308.  
  309. : VISIBLE? ( c -- flag ) bl 127 within ;
  310.  
  311. : .CHR ( c -- )
  312. 10 of ." <LF> " end <cr> of ." <CR> " end
  313. 27 of ." <ESC> " end bl of ." <SP> " end
  314. 127 of ." <DEL> " end
  315. dup bl < if ." Ctrl-" [char] @ + emit space end
  316. dup visible? if emit space end
  317. .hb ;
  318.  
  319. : .DEC ( adr len -- )
  320. ." (" begin dup while over c@ 0 .r 1 /string
  321. dup while space repeat then 2drop ." ) " ;
  322.  
  323. : .STR ( offs -- )
  324. @str dup if
  325. 2dup bounds ?do i c@ .chr loop .dec
  326. end 2drop ." <none> " ;
  327.  
  328. variable #DIGIT \ #digits entered
  329.  
  330. : /FIELD ( n -- 0 )
  331. drop #digit @ begin dup while
  332. <bs> emit space <bs> emit 1-
  333. repeat decimal #digit off ;
  334.  
  335. : .VIS ( c -- )
  336. dup visible? if emit 1 #digit +! end drop ;
  337.  
  338. : ?$ ( n c -- n' c' )
  339. [char] $ of /field hex [char] $ .vis key then ;
  340.  
  341. : +DIGIT ( u c -- u' err )
  342. base @ >digit if swap base @ * + dup 255 u> end
  343. drop true ;
  344.  
  345. : BUILD# ( c -- n c2 ) \ CR or BL exits
  346. decimal #digit off 0 swap begin
  347. dup bl <> over <cr> <> and while
  348. ?$ upcase dup .vis +digit if beep /field then key
  349. repeat decimal ;
  350.  
  351. : GET# ( -- n ) key build# drop ;
  352.  
  353. variable LEN integer MAXCHR
  354.  
  355. : ROOM? ( -- f ) len @ maxchr < ;
  356.  
  357. : +CHR ( c -- ) ibuf len @ + c! 1 len +! ;
  358.  
  359. : DO-NUM ( c -- ) \ CR or BL BL exits
  360. begin room? while
  361. build# swap #digit @ if +chr else drop then
  362. <cr> = if end space key bl of <cr> then
  363. repeat drop ;
  364.  
  365. : DO-ASC ( c -- )
  366. begin dup <cr> - room? and while
  367. dup .chr +chr key
  368. repeat drop ;
  369.  
  370. : DIGIT? ( c -- f )
  371. dup [char] $ = swap [char] 0 [char] 9 between or ;
  372.  
  373. : GET$ ( maxlen -- adr len )
  374. to maxchr len off
  375. key dup digit? if do-num else do-asc then
  376. ibuf len @ ;
  377.  
  378. : SET$ ( ofs size -- )
  379. over .str change?
  380. if cr ." : " get$ rot !str end 2drop ;
  381.  
  382. : SET# ( ofs -- )
  383. dup @byt . change? if ." : " get# swap !byt end drop ;
  384.  
  385. : SETF ( ofs -- 0|1 )
  386. dup @byt dup .yn change? if 0= 1 and then dup rot !byt ;
  387.  
  388. \ Set offset2 flag according to string offset1
  389. : !FLAG ( ofs1 ofs2 -- ) >r @byt 0<> 1 and r> !byt ;
  390.  
  391. : ?NAME ( -- )
  392. 0 0 begin
  393. 2drop
  394. cr ." Terminal type: " 0 @str type space
  395. isiz dup [char] _ emits <bs> emits
  396. enter dup 0 @byt or
  397. until tbuf ?place ;
  398.  
  399. : ?INIT ( -- )
  400. cr ." Term INIT string: " $16 dup 15 set$ $7D !flag ;
  401.  
  402. : ?RESET ( -- )
  403. cr ." Term RESET string: " $26 dup 15 set$ $7E !flag ;
  404.  
  405. : ?LEADIN ( -- )
  406. cr ." CURSOR LEAD-IN command: " $80 5 set$ ;
  407.  
  408. : ?BETWEEN ( -- )
  409. cr ." CURSOR command BETWEEN row/col: " $86 5 set$ ;
  410.  
  411. : ?AFTER ( -- )
  412. cr ." CURSOR command AFTER row/col: " $8C 5 set$ ;
  413.  
  414. : ?COLFIRST ( -- )
  415. cr ." Column first? " $92 setf drop ;
  416.  
  417. : ?ROFS ( -- ) cr ." OFFSET to add to ROW: " $4A set# ;
  418.  
  419. : ?COFS ( -- ) cr ." OFFSET to add to COL: " $49 set# ;
  420.  
  421. : ?DIGITS ( -- n )
  422. cr ." ASCII digits (2 or 3): "
  423. #asc dup . change? 0= if end ." : "
  424. begin drop key [char] 0 - dup 2 3 between not
  425. while beep repeat dup . ;
  426.  
  427. : ?BINARY ( -- )
  428. cr ." Binary address? " $46 setf
  429. 0 of ?digits then $93 !byt ;
  430.  
  431. : ?CLS ( -- ) cr ." CLEAR SCREEN command: " $4D 5 set$ ;
  432.  
  433. : ?HOM ( -- )
  434. cr ." Does CLEAR SCREEN also HOME cursor? "
  435. $53 dup @byt dup not .yn change? over 0<> xor if
  436. drop cr ." HOME command: " 5 set$
  437. end if 0 over !byt then drop ;
  438.  
  439. : ?DEL ( -- ) cr ." DELETE LINE command: " $75 5 set$ ;
  440.  
  441. : ?INS ( -- ) cr ." INSERT LINE command: " $6F 5 set$ ;
  442.  
  443. : ?EOL ( -- ) cr ." ERASE TO EOL command: " $69 5 set$ ;
  444.  
  445. : ?BOLD ( -- ) cr ." BOLD VIDEO command: " $5B 5 set$ ;
  446.  
  447. : ?NORM ( -- ) cr ." NORMAL VIDEO command: " $61 5 set$ ;
  448.  
  449. : ?ROWS ( -- ) cr ." Number of screen rows: " $7C set# ;
  450.  
  451. : ?COLS ( -- ) cr ." Number of screen cols: " $7B set# ;
  452.  
  453. : ?DCUR ( -- )
  454. cr ." Delay after CURSOR ADDRESS: " $4B set# ;
  455.  
  456. : ?DCLS ( -- )
  457. cr ." Delay after CLEAR, DELETE, INSERT: " $59 set# ;
  458.  
  459. : ?DEOL ( -- )
  460. cr ." Delay after ERASE-EOL, BOLD, NORMAL: " $67 set# ;
  461.  
  462. \ Modify terminal definition in temp buffer
  463. : MODIFY ( -- ) cls
  464. ?name ?init ?reset ?leadin ?between ?after ?colfirst
  465. ?rofs ?cofs ?binary ?cls ?hom ?del ?ins ?eol
  466. ?bold ?norm ?rows ?cols ?dcur ?dcls ?deol
  467. !cmt
  468. 0 $94 !byt ; \ TINST always clears?
  469.  
  470. \ Bump #terms & update DTA header
  471. : +TERM ( n -- )
  472. #terms + dup to #terms dta-base !
  473. catalog altered on ;
  474.  
  475. : GET-TERM ( -- ) \ copy term in DTA to buffer
  476. dbuf tbuf tlen cmove ;
  477.  
  478. : INS-TERM ( -- ) \ insert a terminal
  479. tbuf dta-end tlen cmove 1 +term ;
  480.  
  481. : DEL-TERM ( -- ) \ delete selected terminal
  482. dbuf tlen + dta-end over - dbuf swap cmove -1 +term ;
  483.  
  484. : SAVE-MOD? ( -- f )
  485. cr ." Save modifications? " y/n ;
  486.  
  487. : INIT-TERM ( -- ) \ defaults
  488. tbuf tlen erase
  489. 1 $46 !byt 1 $92 !byt \ binary, column first
  490. 24 $7C !byt 80 $7B !byt ; \ #rows, #columns
  491.  
  492. : COPY-TERM ( -- )
  493. 1 #terms s" terminal # to copy" #select if
  494. 1- dup to term name cr type
  495. ." Are you sure? " y/n if get-term then cr
  496. end invalid anykey ;
  497.  
  498. : ?NEW-TERM ( -- )
  499. cr ." New definition? " y/n 0= if end
  500. init-term copy-term modify save-mod? if ins-term then ;
  501.  
  502. : ?DELETE ( -- )
  503. #terms 0= if cr ." Nothing to delete" cr end
  504. 1 #terms s" terminal # to delete" #select if
  505. 1- dup to term name cr type
  506. ." Are you sure? " y/n if del-term then cr
  507. end invalid anykey ;
  508.  
  509. \ Modify selected terminal
  510. : ?MODIFY ( -- )
  511. cr ." Modify definition? " y/n 0= if end
  512. get-term modify save-mod? if del-term ins-term then ;
  513.  
  514. \ Install selected terminal
  515. : !TERM ( -- )
  516. cr ." Terminal selected: " term name type cr
  517. ?modify !tdata cpu-speed ;
  518.  
  519. \ Install from Z-System TCAP
  520. : !ZTCAP ( -- ) zenv if zinstall cpu-speed end
  521. cr ." Z-System not present" cr anykey unnest unnest ;
  522.  
  523. : DO-TERM ( -- )
  524. term
  525. #terms of !ztcap end
  526. #terms 1+ of ?new-term end
  527. #terms 2+ of ?delete end
  528. drop !term ;
  529.  
  530. 10 constant #LINES \ lines to display
  531.  
  532. : VALID? ( n -- n f ) dup #terms 1+ < ;
  533.  
  534. : ?SPACES ( -- ) out @ ?dup if 25 swap - spaces then ;
  535.  
  536. : .LINE ( n adr len -- ) ?spaces rot 1+ 3 .r space type ;
  537.  
  538. : .TERM ( n -- )
  539. dup #terms < if dup name .line end
  540. dup #terms = if s" Z-System Termcap" .line end
  541. drop ;
  542.  
  543. : .TERMS ( n -- ) \ one page of terminals
  544. cr #lines 0 do
  545. valid? if cr then
  546. dup .term dup #lines + .term 1+
  547. loop drop cr ;
  548.  
  549. : .OPTIONS ( -- ) cr
  550. #terms 1+ s" None of the above" .line
  551. #terms 2+ s" Delete a definition" .line cr ;
  552.  
  553. \ Display terminals and select
  554. : SEL-TERM ( -- )
  555. 0 begin cls
  556. dup .terms .options
  557. 1 #terms 3 + select if ( exec)
  558. 1- to term do-term cr #lines 2* - true
  559. else
  560. invalid cr ." ESC to exit, other key for more "
  561. key 27 ( Esc) -
  562. then
  563. while
  564. #lines 2* + valid? and \ looping
  565. repeat drop ;
  566.  
  567. : CHANGE-TERM ( -- )
  568. cls ." Terminal is: "
  569. 'tname >target count type
  570. cr anykey sel-term ;
  571.  
  572. \ Change key specified by adr & string
  573. : CHG-KEY ( a adr len -- )
  574. cr cr type ." code "
  575. >target dup c@ .hb change? if
  576. cr ." Enter new value in hex"
  577. 0 $FF s" (00-FF)" hex #select decimal if
  578. over c!
  579. else invalid then anykey
  580. then drop ;
  581.  
  582. \ Change key codes
  583. : KEY-CODES ( -- )
  584. cls ." Use default backspace & arrow keys? " y/n if
  585. $08 'bksp >target c!
  586. $18051304. 'up >target 2!
  587. end
  588. 'bksp s" BACKSPACE" chg-key
  589. 'up s" UP arrow" chg-key
  590. 'dn s" DOWN arrow" chg-key
  591. 'rt s" RIGHT arrow" chg-key
  592. 'lft s" LEFT arrow" chg-key
  593. ;
  594.  
  595. \ Change the warmboot option
  596. : NOBOOT ( -- )
  597. cls ." NO WARMBOOT is "
  598. 'wbt >target ( a) dup c@
  599. dup .onoff ?dup if ." (" 0 .r ." pages)" then
  600. change? if
  601. 0 32 s" CCP pages (0-32)" #select if
  602. over c!
  603. else invalid then anykey
  604. then drop ;
  605.  
  606. \ Save to disk and exit
  607. : SAVE-SETUP ( -- )
  608. beep cr ." Save current setup to disk? " y/n if
  609. save-target save-dta unnest ( exit menu loop)
  610. then ;
  611.  
  612. \ Display main menu
  613. : .MENU ( -- )
  614. cr ." 1. Terminal selection"
  615. cr ." 2. CPU speed"
  616. cr ." 3. Time delays"
  617. cr ." 4. Key codes"
  618. cr ." 5. No Warmboot"
  619. cr ." 6. Save changes and exit" ;
  620.  
  621. \ Main menu loop. Exit if invalid option or nothing entered.
  622. : MENU ( -- )
  623. begin .menu cr 1 6 select while
  624. cond 1 of change-term else
  625. 2 of cpu-speed else
  626. 3 of delay-times else
  627. 4 of key-codes else
  628. 5 of noboot else
  629. 6 of save-setup else
  630. drop
  631. cont cls
  632. repeat ;
  633.  
  634. : INIT ( -- )
  635. altered off \ clear
  636. isiz reserve to ibuf \ console input
  637. tlen reserve to tbuf \ temp terminal buffer
  638. chunk reserve to sbuf \ swap/work buffer
  639. tmax cells reserve to xbuf \ terminal index
  640. ;
  641.  
  642. \ Main
  643. : INSTALL ( -- )
  644. cls title init
  645. open-target read-dta catalog
  646. menu
  647. close-target
  648. ;
  649.  
  650.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement