TPSRC6 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. MOV CX,#$0004 ;4 times
  2. erpblnk2 CALL ekbdstat ;get KBD stat
  3. JNZ erpbw2 ;:key pressed
  4. MOV BX,#$0064 ;wait 100 ms
  5. PUSH CX ;save cnt
  6. CALL delaybx ;Delay
  7. POP CX ;restore cnt
  8. LOOP erpblnk2 ;:another
  9. JMP erpblnk ;'blink again
  10. erpbw2 CALL keyget ;get char
  11. CALL etstint ;test interrupt
  12. CALL upcase ;UpCase
  13. CMP AL,#$59 ;Y ?
  14. JZ erpdoit ;:yes, do it
  15. CMP AL,#$19 ;^Y ?
  16. JNZ erpbk
  17. erpdoit MOV.B txchg,#$FF ;set flags: text changed
  18. MOV.B txcomp,#$00 ;code invalid
  19. MOV.B CL,srrepl1 ;length of replacement
  20. MOV CH,#$00
  21. POP BX ;restore pos
  22. PUSH BX
  23. PUSH CX ;save
  24. MOV AL,srword1 ;length of word found
  25. SUB.B AL,CL ;- length of replacement
  26. MOV.B CL,AL ;-> CL
  27. LAHF ;save flags
  28. PUSH AX
  29. JNB erp2 ;do sign extension
  30. DEC.B CH
  31. erp2 TEST.B sropt,#$10 ;backwards ?
  32. JNZ erpbw ;:yes
  33. MOV BX,srpos ;beg of that word
  34. erpbw POP AX ;flag
  35. SAHF
  36. PUSH BX
  37. JZ erpsame ;: no difference
  38. CALL echgsize ;change len
  39. erpsame POP DX ;restore
  40. POP CX
  41. MOV.B AL,CH ;length = 0 ?
  42. OR.B AL,CL
  43. JZ erpnil
  44. MOV BX,#srrepl2 ;move in replacement word
  45. CALL movebk
  46. erpnil CALL ekbdstat ;get KBD stat
  47. JZ erpok ;:nothing
  48. CALL eredall ;redisplay all
  49. JMP.b erpchg ;'
  50. erpok PUSH DX ;save pos
  51. CALL erstlin ;restore line
  52. CALL eredall ;flag: redisplay
  53. POP DX ;restore pos
  54. erpchg TEST.B sropt,#$10 ;backwards ?
  55. JNZ erpbk ;:yes
  56. POP BX ;remove
  57. XCHG DX,BX ;set to end of word
  58. RET ;'
  59. erpbk POP BX ;restore beg of word
  60. erpret RET ;"
  61. ekw CMP.B bkhide,#$FF ;^KW:Write block to disk
  62. JZ erpret ;block hidden: ret
  63. CALL eflush ;rewrite line
  64. CALL erstlin ;restore line
  65. MOV AX,bkbeg ;block begin > block end ?
  66. CMP AX,bkend
  67. JNB erpret ;yes: ret
  68. CALL etstblk ;test block
  69. CALL erstlin ;restore line
  70. ekwlp CALL eclrstat ;clr status line
  71. CALL ewrits ;write string
  72. B "Write block to file",$00
  73. CALL ekwfile ;get filename
  74. JZ erpret ;nothing entered: ret
  75. CALL kpasext ;default extension .PAS
  76. MOV AX,#$3D00 ;open file
  77. MOV DX,#scrpn ;name ptr
  78. PUSH DS ;DS -> ES
  79. POP ES
  80. CALL dos
  81. MOV BX,AX ;file handle
  82. JB ekwnew
  83. MOV AH,#$3E ;close file
  84. CALL dos
  85. CALL eclrs2 ;clr status line
  86. CALL ewrits
  87. B "Overwrite old ",$00
  88. MOV SI,#scrpn ;write filename
  89. CALL printpn
  90. CALL yorn ;Y or N ?
  91. JZ ekwlp ;no: get new filename
  92. ekwnew MOV AH,#$3C ;create file
  93. MOV DX,#scrpn ;name ptr
  94. XOR CX,CX ;no attribute
  95. PUSH DS ;DS -> ES
  96. POP ES
  97. CALL dos
  98. JNB ekwopen ;:ok
  99. CALL eclrs2 ;clr status line
  100. CALL ewriterr ;write message
  101. B "Unable to create ",$00
  102. MOV SI,#scrpn ;write filename
  103. CALL printpn
  104. CALL waitesc ;wait for ESC
  105. JMP ekwlp ;'get new filename
  106. ekwopen PUSH AX ;save file handle
  107. CALL eclrs2 ;clr status line
  108. POP BX ;restore
  109. MOV DX,bkbeg ;block begin
  110. MOV SI,bkend ;block end
  111. MOV.B AL,[SI] ;get char at block end
  112. PUSH AX ;save it
  113. PUSH SI ;save its addr
  114. MOV.B [SI],#$1A ;store a ^Z there
  115. MOV CX,SI ;count = block end - block beg
  116. SUB CX,DX
  117. CMP BX,#$04 ;write to device ?
  118. JBE ekwdev ;:yes
  119. INC CX ;file: write ^Z, too
  120. ekwdev MOV AH,#$40 ;write byte block
  121. CALL dos
  122. JB ekwfull ;:error
  123. SUB CX,AX ;length = expected ?
  124. JZ ekwdone ;:yes
  125. DEC CX ;1 byte difference ?
  126. JNZ ekwfull ;no: error
  127. ekwdone CALL ekwclose ;close file
  128. JNB ekwok ;:ok
  129. CALL ewriterr ;write message
  130. B "Error closing file",$00
  131. CALL waitesc ;wait for ESC
  132. ekwok POP SI ;restore char at block end
  133. POP AX
  134. MOV.B [SI],AL
  135. RET ;'
  136. ekwfull CALL ekwclose ;close file
  137. MOV AH,#$41 ;delete it
  138. MOV DX,#scrpn ;name ptr
  139. CALL dos
  140. CALL ewriterr ;write message
  141. B "Disk full",$00
  142. CALL waitesc ;wait for ESC
  143. JMP ekwok ;'restore block end
  144. ekwclose MOV AH,#$3E ;close file
  145. JMP dos ;"
  146. ekwfile MOV DX,#fnbuf ;get filename
  147. CALL edreadst ;read it
  148. MOV BX,#fnbuf2 ;first char
  149. CMP.B [BX],#$1A ;= ^Z ?
  150. ekrret RET ;"yes: nothing entered
  151. ekr CALL eclrstat ;^KR:Read block from disk
  152. CALL ewrits ;write string
  153. B "Read block from file",$00
  154. CALL ekwfile ;get file name
  155. JZ ekrret ;nothing entered: ret
  156. CALL kpasext ;default extension .PAS
  157. MOV AX,#$3D00 ;open file
  158. MOV DX,#scrpn ;name ptr
  159. PUSH DS ;DS -> ES
  160. POP ES
  161. CALL dos ;do it
  162. XCHG AX,BX ;file handle
  163. JNB ekrfound ;:ok
  164. CALL eclrs2 ;clr status line
  165. CALL ewriterr ;write message
  166. B "File ",$00
  167. MOV SI,#scrpn ;write filename
  168. CALL printpn
  169. CALL prints ;write string
  170. B " not found",$00
  171. CALL waitesc ;wait for ESC
  172. JMP ekr ;'get another filename
  173. ekrfound PUSH BX ;save file handle
  174. MOV.B bkhide,#$00 ;flag: block not hidden
  175. CALL etstblk ;test block
  176. MOV BX,txend ;text end
  177. MOV DX,txmemend ;text space end
  178. MOV CX,#$00FE ;+ some space free
  179. ADD BX,CX
  180. SUB BX,DX
  181. PUSH BX ;save free space
  182. MOV CX,BX
  183. MOV BX,nbkbeg ;new block beg
  184. STC
  185. CALL echgsize ;make space
  186. POP AX ;restore free space
  187. POP BX ;restore file handle
  188. MOV DX,nbkbeg ;new block beg
  189. MOV CX,DX ;-> offset
  190. SUB CX,AX
  191. MOV explen,CX ;save end free space
  192. MOV vfilbig,#ebigfil ;set error vec
  193. CALL kload2 ;load block
  194. INC BX ;end of block read
  195. MOV bkend,BX ;store as new block end
  196. XCHG DX,BX ;-> DX
  197. MOV BX,nbkbeg ;new block beg
  198. MOV bkbeg,BX ;-> block beg
  199. ekrremov MOV BX,explen ;end free space
  200. SUB BX,DX ;-block end
  201. MOV CX,BX ;-> count
  202. JMP.b ekvremov ;'remove unneeded space
  203. MOV DX,nbkbeg ;File too big:
  204. CALL ekrremov ;remove space made free
  205. JMP etsterr ;"error: out of space
  206. eblkmov CALL etstblk ;^KV:Move block - test block
  207. JNB ekvrest
  208. CALL ecopyblk ;copy it
  209. MOV BX,nbkbeg ;new block beg
  210. MOV DX,bkbeg ;-> block beg
  211. MOV bkbeg,BX
  212. ADD BX,CX ;+ count
  213. MOV bkend,BX ;-> block end
  214. ekvremov XCHG BX,DX ;old block beg -> BX
  215. CLC
  216. CALL echgsize ;remove old block
  217. MOV BX,bkbeg ;block begin
  218. CALL efsetpos ;set position
  219. JMP erewrall ;'rewrite all
  220. ekvrest JMP erstlin ;"restore line
  221. eblkcpy CALL etstblk ;^KC:Copy block - test block
  222. JNB ekvrest
  223. CALL ecopyblk ;do copy it
  224. MOV BX,nbkbeg ;new block beg
  225. MOV bkbeg,BX ;-> block beg
  226. ADD BX,CX ;+ count
  227. MOV bkend,BX ;-> block end
  228. CALL eseldisp ;selective redisplay
  229. CALL erstlin ;restore line
  230. JMP erewrall ;"rewrite all
  231. etstblk CMP.B bkhide,#$00 ;Test block
  232. JZ etb2 ;:block not hidden
  233. CLC
  234. RET ;'
  235. etb2 CALL esrcend ;search end of input line
  236. INC BX ;+1
  237. MOV DX,lnpos ;pos in input line
  238. PUSH DX ;save it
  239. CALL emin ;take smaller of them
  240. XCHG BX,DX ;-> BX
  241. CALL efl2 ;write back to memory
  242. POP BX ;restore pos in input line
  243. MOV DX,#line ;calc relative pos in input line
  244. SUB BX,DX
  245. MOV DX,edpos ;+pos of current line
  246. ADD BX,DX
  247. MOV nbkbeg,BX ;-> new block beg
  248. PUSH BX ;save
  249. MOV DX,bkbeg ;block beg+1
  250. INC DX
  251. CMP BX,DX ;destination inside block ?
  252. MOV DX,bkend ;block end
  253. JB etbbeg ;:no
  254. CMP BX,DX
  255. JNB etbbeg ;:no
  256. OR.B AL,AL ;dest is in old block...
  257. JMP.b etb3 ;'end it
  258. etbbeg MOV BX,bkbeg ;block beg
  259. SUB BX,DX ;-block end
  260. MOV nbk,BX ;-> - block len
  261. MOV CX,BX ;-> count
  262. etb3 POP BX ;restore destination
  263. RET ;"
  264. ecopyblk CALL echgsize ;Copy block: make space for it
  265. MOV CX,nbk ;get count
  266. NEG CX ;(is - block len)
  267. MOV DX,nbkbeg ;block destination
  268. MOV BX,bkbeg ;block source
  269. PUSH CX ;save count
  270. CALL movebk ;move it
  271. POP CX ;restore count
  272. RET ;"
  273. eblkdel CALL eflush ;^KY:Delete block - rewrite line
  274. CMP.B bkhide,#$00 ;block hidden ?
  275. JNZ ekyrest
  276. MOV BX,bkbeg ;block beg
  277. CALL esrcbeg ;search beg of line
  278. MOV edpos,BX ;-> current pos
  279. MOV BX,posfifo ;update pos FIFO
  280. MOV DX,bkbeg ;inside block ?
  281. INC DX
  282. CMP BX,DX
  283. JB ekynochg ;:no
  284. MOV DX,bkend
  285. CMP BX,DX
  286. JNB ekynochg ;:no
  287. MOV BX,edpos ;current pos
  288. MOV posfifo,BX ;-> FIFO
  289. ekynochg MOV BX,bkend ;block end-block beg
  290. MOV DX,bkbeg
  291. SUB BX,DX ;calc count
  292. JNB ekyblkok ;:ok
  293. ekyrest JMP erstlin ;'restore line
  294. ekyblkok MOV CX,BX ;-> count
  295. XCHG BX,DX ;swap addrs
  296. PUSH BX ;save them
  297. PUSH CX
  298. PUSHF
  299. CALL eseldisp ;do selective rewrite
  300. POPF
  301. POP CX ;restore
  302. POP BX
  303. CALL echgsize ;delete block
  304. MOV BX,edpos ;current pos
  305. MOV bkbeg,BX ;-> block beg
  306. MOV bkend,BX ;-> block end
  307. CALL erstlin ;restore line
  308. JMP.b erewrall ;"rewrite all
  309. NOP ;^KH:hide / unhide block
  310. ekh NOT.B bkhide ;toggle flag: block hidden
  311. JMP.b erewrall ;"rewrite all
  312. NOP ;Mark block end
  313. emarkend MOV BX,lnpos ;pos in line
  314. MOV bkendl,BX ;-> block end in buffer
  315. MOV BX,edpos ;line pos
  316. MOV bkend,BX ;-> block end
  317. TEST.B attflg,#$02 ;block marked in this line ?
  318. LAHF
  319. OR.B attflg,#$02 ;set that flag
  320. emrend2 CMP.B bkhide,#$FF ;block hidden ?
  321. MOV.B bkhide,#$00 ;make it visible
  322. JZ erewrall ;hidden: rewrite all
  323. SAHF
  324. JZ erewrall ;no block marked in line: all
  325. JMP.b erewrlin ;"rewrite line, only
  326. NOP ;Mark block beg
  327. emarkbeg MOV BX,lnpos ;get pos in line
  328. MOV bkbegl,BX ;-> block beg in line buffer
  329. MOV BX,edpos ;current pos
  330. MOV bkbeg,BX ;-> block beg
  331. TEST.B attflg,#$01 ;block beg in this line ?
  332. LAHF
  333. OR.B attflg,#$01 ;set flag
  334. JMP emrend2 ;"as above
  335. ejbkbeg CALL eflush ;^QB:to beginning of block
  336. MOV BX,bkbeg ;block beg
  337. JMP efsetpos ;"set new position
  338. ejbkend CALL eflush ;^QK:to end of block
  339. MOV BX,bkend ;block end
  340. JMP efsetpos ;"set new position
  341. erewrlin MOV BH,#$00 ;Rewrite line
  342. CALL eposrow ;pos cursor to beg of line
  343. MOV BX,#line ;pos of current line
  344. MOV.B attchg,#$FF ;critical line
  345. CALL edmalin ;display it
  346. MOV.B attchg,#$00 ;normal again
  347. RET ;"
  348. erewrall CALL erewrlin ;rewrite line
  349. JMP eredall ;"then rewrite all
  350. ejtxend CALL eflush ;^QC:to end of text
  351. MOV BX,txend ;text end
  352. JMP efsetpos ;"set new position
  353. ejlnbeg MOV BX,#line ;^QS:to beg of line
  354. MOV lnpos,BX ;buffer beg -> pos in line
  355. JMP erepos ;"reposition in line
  356. ejlnend CALL esrcend ;^QD:to end of line
  357. INC BX ;search end of line+1
  358. MOV DX,#lineend ;too much ?
  359. CMP BX,DX
  360. JB ele2 ;:no
  361. MOV BX,#lineend1 ;limit it
  362. ele2 MOV lnpos,BX ;set new pos in line
  363. JMP erepos ;"reposition in line
  364. etogovr MOV.B statobs,#$00 ;^V:insert mode on/off
  365. NOT.B overflg ;toggle flag
  366. RET ;"status line obsolete
  367. etogind MOV.B statobs,#$00 ;^QI:indent mode on/off
  368. NOT.B indntflg ;toggle flag
  369. ednrt RET ;"status line obsolete
  370. eposcur MOV.B BH,phcol ;put cursor to current pos
  371. eposrow MOV.B BL,phrow
  372. JMP esetcur ;"set cursor pos
  373. edn MOV BX,edpos ;^X:line down
  374. CALL elindn ;go down one line
  375. JB ednrt
  376. CALL eflush ;rewrite line
  377. MOV BX,edpos ;now really go down
  378. CALL elindn
  379. edn2 MOV edpos,BX ;store new pos
  380. MOV.B scrfl2,#$00 ;flag: short update
  381. MOV.B scrfl1,#$FF
  382. CALL eseldisp ;do selective redisplay
  383. MOV.B scrfl1,#$00 ;clear flag
  384. JMP erstlin ;"restore line
  385. eup MOV BX,edpos ;^E:line up
  386. CALL elinup ;go up one line
  387. JB ednrt
  388. PUSH BX ;save pos
  389. CALL eflush ;rewrite line
  390. POP BX ;now go there
  391. JMP edn2 ;"set it
  392. escrup MOV AX,disbeg ;^W:scroll up
  393. CMP AX,txbeg ;display beg = text beg ?
  394. JZ eptret ;yes: ret
  395. CALL eflush ;rewrite line
  396. XOR CX,CX ;count pos on screen
  397. MOV BX,edpos ;current pos
  398. esulp CMP BX,disbeg ;= display beg ?
  399. JZ esu2 ;yes: do it
  400. CALL elinup ;go up one line
  401. INC CX ;count it
  402. JMP esulp ;'
  403. esu2 XCHG BX,edpos ;current pos = top of screen
  404. CS:
  405. MOV AL,txwiny2 ;line count - 3
  406. SUB AL,#$03
  407. CMP.B CL,AL ;= count ?
  408. JNZ esu3 ;no: ok
  409. CALL elinup ;go up one line
  410. esu3 PUSH BX ;save current pos
  411. MOV BX,edpos ;display beg
  412. CALL elinup ;go up one line
  413. CALL edn2 ;display it
  414. POP BX ;restore current pos
  415. esu4 JMP edn2 ;"set new pos
  416. escrdn CALL eflush ;^Z:scroll down
  417. PUSH edpos ;save current pos
  418. MOV BX,disbeg ;start from display beg
  419. XOR CX,CX
  420. CS:
  421. MOV.B CL,txwiny2 ;line count-2 -> CX
  422. SUB.B CL,#$02
  423. esdlp CALL elindn ;go down one line
  424. LOOP esdlp ;do it again
  425. PUSHF
  426. CALL edn2 ;set new pos
  427. POPF
  428. POP BX ;restore old pos
  429. JB esu4 ;:set new pos
  430. CMP BX,disbeg ;>= display beg ?
  431. JNB esu4 ;:set new pos
  432. CALL elindn ;go down one line
  433. JMP esu4 ;'set new pos
  434. eptret RET ;"
  435. epagtop MOV BX,disbeg ;^QE:to page top
  436. CMP BX,edpos ;display beg = current line ?
  437. JZ eptret ;yes: done
  438. PUSH BX ;save this pos
  439. CALL eflush ;rewrite line
  440. POP BX ;display beg -> new pos
  441. JMP esu4 ;"set that pos
  442. epagbot CALL eflush ;^QX:to bottom of page
  443. MOV BX,disbeg ;display beg
  444. XOR CX,CX ;line count-3 -> CX
  445. CS:
  446. MOV.B CL,txwiny2
  447. SUB.B CL,#$03
  448. epblp CALL elindn ;go down one line
  449. LOOP epblp ;:again
  450. JMP esu4 ;"set new pos
  451. epagdn CALL eflush ;^C:page down - rewrite line
  452. CS:
  453. MOV AL,txwiny2 ;line count - 2
  454. SUB AL,#$02
  455. MOV.B CH,AL ;-> CL, CH
  456. MOV.B CL,AL
  457. MOV BX,disbeg ;display beg
  458. epdlp CALL elindn ;go down one line
  459. DEC.B CH
  460. JNZ epdlp ;:another one
  461. MOV disbeg,BX ;store new display beg
  462. MOV BX,edpos ;current pos
  463. epdl2 CALL elindn ;go down one line
  464. LOOP epdl2 ;:again
  465. epd2 MOV edpos,BX ;set new pos
  466. CALL eseldisp ;redisplay
  467. CALL eredall ;redisplay all
  468. JMP erstlin ;"restore line
  469. epagup CALL eflush ;^R:page up - rewrite line
  470. CS:
  471. MOV AL,txwiny2 ;line count - 2
  472. SUB AL,#$02
  473. MOV.B CH,AL ;-> CL, CH
  474. MOV.B CL,AL
  475. MOV BX,disbeg ;display beg
  476. epulp CALL elinup ;go up one line
  477. DEC.B CH
  478. JNZ epulp ;:another
  479. MOV disbeg,BX ;store new display beg
  480. MOV BX,edpos ;current pos
  481. epul2 CALL elinup ;go up one line
  482. LOOP epul2 ;:another
  483. JMP epd2 ;"set new pos, redisplay
  484. etxtbeg MOV BX,disbeg ;^QR:to beg of text
  485. MOV DX,txbeg ;text beg = display beg ?
  486. CMP BX,DX
  487. JZ etsb2 ;:yes
  488. CALL eredall ;no:redisplay all
  489. etsb2 CALL eflush ;rewrite line
  490. MOV BX,txbeg ;text beg
  491. MOV edpos,BX ;-> current pos
  492. MOV disbeg,BX ;-> display beg
  493. CALL eseldisp ;do selective redisplay
  494. CALL erstlin ;restore line
  495. MOV BX,#line ;go to beg of line
  496. MOV lnpos,BX ;pos in line
  497. JMP erepos ;"reposition in line
  498. ecr CMP.B overflg,#$00 ;CR:carriage return
  499. JNZ ecrins ;:insert mode
  500. CALL edn ;go down one line
  501. JMP ejlnbeg ;'go to beg of line
  502. ecrins MOV.B txchg,#$FF ;set flags: text changed
  503. MOV.B txcomp,#$00
  504. MOV BX,phrow ;current cursor pos
  505. INC.B BL
  506. CALL esetcur ;set cursor to beg of line
  507. CALL elinbrk ;insert line break
  508. MOV BX,edpos
  509. PUSH BX ;save current pos
  510. CALL erstlin ;restore line
  511. CALL eflush ;rewrite line
  512. POP BX ;restore current pos
  513. CALL elindn ;go down one line
  514. MOV edpos,BX ;-> current pos
  515. MOV BX,#line ;go to beg of line
  516. CALL eredisp ;redisplay
  517. CALL eposcur ;set new position
  518. CMP.B indntflg,#$00 ;indent ?
  519. JZ elftret ;:no
  520. CALL etabup ;up one line from curr pos
  521. JB elftret ;:no
  522. MOV SI,#esepspc ;separator: spaces only
  523. CALL etslp ;'go word right
  524. JNB elftret
  525. JMP etab ;"do tab
  526. eredisp MOV lnpos,BX ;store pos in buffer
  527. CALL erepos ;reposition in line
  528. CALL eseldisp ;selective redisplay
  529. JMP erstlin ;"restore line
  530. elinins CALL elinbrk ;^N:insert line - insert line break
  531. MOV.B BL,phrow ;row + 1
  532. INC.B BL
  533. XOR.B BH,BH ;col = 0
  534. CALL esetcur ;set cursor pos
  535. MOV BX,edpos ;current pos
  536. CALL elindn ;go down one line
  537. CALL edmalin ;display line
  538. JMP erstlin ;"restore line
  539. elinbrk CALL eflush ;Insert line break: rewrite line
  540. CALL xinsline ;InsLine
  541. CALL esrcend ;search end of line + 1
  542. INC BX
  543. MOV DX,lnpos ;pos in buffer
  544. CALL emin
  545. MOV DX,#line ;relative pos in line
  546. SUB BX,DX
  547. elb2 XCHG BX,DX ;-> DX
  548. MOV BX,edpos ;current pos
  549. ADD BX,DX ;+ relative pos
  550. PUSH BX ;save pos of line break
  551. STC ;insert two bytes
  552. MOV CX,#$FFFE
  553. CALL echgsize ;do it
  554. POP BX ;restore pos
  555. MOV [BX],#$0A0D ;store CR, LF there
  556. INC BX
  557. elftret RET ;"
  558. eleft MOV BX,lnpos ;^S, ^H:character left
  559. DEC BX ;pos in line - 1
  560. CMP BX,#line ;already at the beg ?
  561. JB elftret
  562. eleft2 MOV lnpos,BX ;set new pos
  563. JMP erepos ;"reposition in line
  564. eright MOV BX,lnpos ;^D:character right
  565. INC BX ;pos in line + 1
  566. CMP BX,#lineend0 ;= end of buffer ?
  567. JB eleft2 ;below: ok, set it
  568. RET ;"
  569. elstpos CALL eflush ;^QP:to last position
  570. MOV BX,qppos ;get pos from FIFO
  571. CALL esrcbeg ;search beg of line
  572. MOV edpos,BX ;-> current pos
  573. MOV BX,qppos1 ;get display beg from FIFO
  574. JMP eredisp ;"redisplay
  575. emrkwrd CALL ewrdrt ;^T:mark word - word right
  576. CALL ewrdlft ;word left
  577. MOV BX,lnpos ;pos in line buffer
  578. emwlp CALL etstsep ;char = separator ?
  579. JB emwend ;yes: word end found
  580. INC BX ;next char
  581. CMP BX,#lineend0 ;end of line ?
  582. JB emwlp ;:no, continue
  583. emwend MOV lnpos,BX ;-> current pos
  584. CALL emarkend ;mark block end
  585. CALL ewrdlft ;go left one word
  586. JMP emarkbeg ;"mark block beg
  587. ewlup MOV BX,edpos ;get current pos
  588. CALL elinup ;go up one line
  589. JB ewloldp
  590. PUSH BX ;save pos
  591. CALL eflush ;rewrite line
  592. POP BX
  593. MOV edpos,BX ;set new pos
  594. MOV.B scrfl2,#$00 ;set flag: short updating
  595. CALL eseldisp ;selective redisplay
  596. CALL erstlin ;restore line
  597. CALL esrcend ;search end of line
  598. JMP.b ewlle ;'store position
  599. ewrdlft MOV BX,lnpos ;^A:word left
  600. ewllp DEC BX ;pos in buffer-1:search char<>sep
  601. CMP BX,#line ;= line beg ?
  602. JB ewlup ;yes: go up one line
  603. CALL etstsep ;char = separator ?
  604. JB ewllp ;yes: continue searching
  605. ewll2 DEC BX ;go back: search separator
  606. CMP BX,#$046C ;= line beg ?
  607. JB ewlle ;yes: end it
  608. CALL etstsep ;char = separator ?
  609. JNB ewll2 ;:no
  610. ewlle INC BX ;go to left of word
  611. ewlpos MOV lnpos,BX ;store pos in line
  612. ewloldp MOV BX,lnpos ;get pos
  613. JMP erepos ;"reposition in line
  614. ewrdrt CALL esrcend ;^F:word right
  615. MOV AX,BX ;end of line -> AX
  616. MOV BX,lnpos ;pos in line
  617. SUB AX,BX ;calc count
  618. MOV AL,#$00
  619. JNB ewr1 ;:ok
  620. INC.B AL
  621. ewr1 MOV curpast,AL ;flag: cursor past end of line
  622. ewrlp DEC BX
  623. ewrl2 INC BX ;next char
  624. CMP BX,#lineend0 ;end of line ?
  625. JB ewrtst ;:no
  626. ewrl3 MOV BX,edpos ;current pos
  627. CALL elindn ;go down one line
  628. JB etabret
  629. CALL eflush ;rewrite line
  630. MOV BX,edpos ;current pos
  631. CALL elindn ;go down
  632. MOV edpos,BX ;new pos
  633. MOV.B scrfl2,#$00 ;short update
  634. CALL eseldisp ;redisplay
  635. CALL erstlin ;restore line
  636. MOV BX,#$046C ;go to beg of line
  637. MOV lnpos,BX
  638. CALL etstsep ;char = separator ?
  639. JB ewrlp ;:yes
  640. JMP erepos ;'set that pos
  641. ewrtst CALL etstsep ;char = separator ?
  642. JNB ewrl2 ;:no
  643. ewrlp2 INC BX ;next char
  644. CMP BX,#lineend0 ;end of line ?
  645. JB ewrtst2 ;:no
  646. CMP.B curpast,#$00 ;cursor past end of line ?
  647. JNZ ewrl3 ;:yes
  648. CALL esrcend ;search end of line + 1
  649. INC BX
  650. JMP ewlpos ;'set that pos
  651. ewrtst2 CALL etstsep ;char = separator ?
  652. JB ewrlp2 ;:yes
  653. JMP ewlpos ;"set that pos
  654. etabup MOV BX,edpos ;current pos
  655. CALL elinup ;go up one line
  656. etabret RET ;"
  657. etab CALL etabup ;^I:Tab - go up one line
  658. JB etabret
  659. MOV AL,phrow ;save phys row
  660. PUSH AX
  661. MOV BX,lnpos ;pos in line
  662. MOV lnupper,BX ;store pos of upper line
  663. MOV.B disflg,#$00 ;normal mode
  664. CALL eflush ;rewrite line
  665. MOV BX,edpos ;current pos
  666. PUSH BX ;save it
  667. CALL elinup ;go up one line
  668. MOV edpos,BX ;store pos
  669. CALL erstlin ;restore line
  670. PUSH sepptr ;save ptr
  671. MOV sepptr,#esepspc ;set sep ptr: spaces only
  672. CALL ewrdrt ;word right
  673. POP sepptr ;restore sep ptr
  674. POP edpos ;restore current pos
  675. POP AX
  676. MOV phrow,AL ;restore phys row
  677. CALL erstlin ;restore line
  678. MOV.B disflg,#$FF ;flag: short update
  679. CMP.B overflg,#$FF ;insert ?
  680. JZ etabins ;:yes
  681. JMP erewrlin ;'rewrite line
  682. etabins MOV BX,lnpos ;pos in line
  683. MOV DX,lnupper ;pos in upper line
  684. SBB BX,DX ;difference
  685. JBE etabret ;not found: ret
  686. XCHG BX,DX ;-> count
  687. etabinsl PUSH DX ;save count
  688. CALL einsch ;insert a char
  689. MOV.B [BX],#$20 ;space
  690. POP DX ;restore count
  691. DEC.B DL ;another ?
  692. JNZ etabinsl ;:yes
  693. JMP erewrlin ;"rewrite line
  694. edeleol MOV BX,lnpos ;^QY:delete to end of line
  695. PUSH BX ;save pos in line
  696. CALL etstbk ;test block markers in line
  697. POP BX ;restore pos
  698. PUSH BX
  699. MOV DX,#lineend1 ;end position
  700. edelp MOV.B [BX],#$20 ;fill up with spaces
  701. CMP BX,DX ;end reached ?
  702. JZ edeend ;:yes
  703. INC BX ;next char
  704. JMP edelp ;'
  705. edeend POP BX ;restore pos in line
  706. JMP eredlin ;"redisplay line
  707. edellin MOV BX,#line ;^Y:delete line
  708. MOV lnpos,BX ;to line beg
  709. CALL erepos ;reposition in line
  710. CALL edeleol ;delete to end of line
  711. CALL eflush ;rewrite line
  712. MOV BX,edpos ;current pos
  713. PUSH BX ;save it
  714. PUSH BX
  715. CALL elindn ;go down one line
  716. POP DX ;old pos
  717. JB edlend
  718. SUB BX,DX ;difference
  719. MOV CX,BX ;-> count
  720. POP BX ;restore current pos
  721. JNZ edb3 ;:erase the rest
  722. RET ;'
  723. edlend POP BX ;remove from stack
  724. JMP erstlin ;"restore line
  725. edlinbrk CALL efl2 ;del line break: rewrite to BX
  726. MOV BX,edpos ;current pos
  727. CALL elindn ;go down one line
  728. JNB edb2 ;:ok
  729. JMP erstlin ;'restore line
  730. edb2 DEC BX ;go back two bytes
  731. DEC BX
  732. MOV CX,#$0002 ;delete 2 bytes
  733. OR.B AL,AL ;clear carry
  734. edb3 CALL echgsize ;do it
  735. CALL xdelline ;DelLine
  736. CS:
  737. MOV AL,txwiny2 ;get line cnt - 1
  738. DEC.B AL
  739. CALL edsplin ;redisplay last line
  740. JMP erstlin ;"restore line
  741. edelwrd CALL esrcend ;^T:delete right word
  742. MOV DX,lnpos ;pos in buffer
  743. CMP BX,DX ;> end ?
  744. XCHG BX,DX
  745. JB edlinbrk ;:delete line break
  746. MOV.B AL,[BX] ;get char
  747. CMP AL,#$20 ;space ?
  748. JZ edelspc ;:delete spaces
  749. CALL etstsep ;separator ?
  750. JB edel2 ;:end it
  751. edwlp CALL edelch ;delete char
  752. CALL etstsep ;separator ?
  753. JB edrest ;:yes, end
  754. JMP edwlp ;"another char
  755. edwend MOV BX,edpos ;current pos
  756. CALL elinup ;up one line
  757. JB edwret
  758. CALL eup ;line up
  759. CALL ejlnend ;go to line end
  760. JMP edelwrd ;'delete word
  761. edwret RET ;'
  762. edelrt MOV BX,lnpos ;^G:delete right
  763. JMP.b edel2 ;'
  764. edellft MOV BX,lnpos ;DEL:delete left
  765. DEC BX ;go back one char
  766. CMP BX,#line ;beg of line ?
  767. JB edwend ;yes: go to line above
  768. MOV lnpos,BX ;store new pos
  769. edel2 CALL edelch ;delete char
  770. edrest CALL erepos ;reposition on line
  771. JMP eredlin ;"redisplay line
  772. edelspc CALL edelch ;Delete spaces
  773. MOV.B AL,[BX] ;get char
  774. CMP AL,#$20 ;space ?
  775. JZ edelspc ;:delete it
  776. JMP edrest ;"redisplay
  777. eredispl CALL eposcur ;Redisplay: set cursor pos
  778. CALL edisbdn ;go down from display beg
  779. edisp1 CALL ekbdstat ;get KBD stat
  780. JNZ edisp2
  781. CALL edsp2 ;redisplay
  782. JNB edisp1 ;:continue
  783. edisp2 JMP eposcur ;"set cursor pos
  784. edodispl CALL eposcur ;Redisplay: set cursor pos
  785. CALL edisbdn ;go down from display beg
  786. eddlp CALL edsp2 ;redisplay
  787. JNB eddlp ;:continue
  788. JMP eposcur ;"set cursor pos
  789. edisbdn MOV.B CL,dislin ;go down from display beg
  790. edisbdn2 XOR.B CH,CH ;count: first line to display
  791. MOV BX,disbeg ;display beg
  792. DEC CX ;count down
  793. JZ eddnil ;:end it
  794. eddn CALL elindn ;go down one line
  795. JB eddend
  796. LOOP eddn ;:another line
  797. eddnil RET ;'
  798. eddend MOV BX,txend ;go to text end
  799. RET ;"
  800. edodisp CALL elindn ;do redisplay: go down
  801. JNB edsp2 ;:ok
  802. MOV BX,txend ;go to text beg
  803. edsp2 MOV AL,dislin ;display from where ?
  804. CS:
  805. CMP.B AL,txwiny2 ;= line cnt ?
  806. JNB edspret
  807. INC.B dislin ;go down one more line
  808. CMP.B AL,phrow ;= phys row ?
  809. JZ edodisp ;yes: go down
  810. edsp3 MOV scrrow,AL ;current line
  811. CMP BX,txend ;text end reached ?
  812. JNB edsp4 ;:yes
  813. CALL edmalin ;display line
  814. CLC ;not yet end
  815. RET ;'
  816. edsp4 CALL esetnrm ;NormVideo
  817. CALL eclrlin ;clear line
  818. CLC ;not yet end
  819. RET ;'
  820. edspret STC ;end it
  821. RET ;"
  822. edsplin PUSH AX ;redisplay one line
  823. MOV.B CL,AL ;line number
  824. CALL edisbdn2 ;go down to this line
  825. POP AX ;restore
  826. JMP edsp3 ;"redisplay that line
  827. esrcbeg MOV AL,#$0A ;search beg of line: LF
  828. esblp DEC BX ;go back
  829. CMP BX,txbeg ;text beg ?
  830. JZ esbend ;yes: end it
  831. JB esb1 ;below: next char
  832. CMP.B AL,[BX] ;test char: LF ?
  833. JNZ esblp ;no: continue searching
  834. esb1 INC BX ;next char
  835. esbend RET ;"
  836. eskipcr CMP AL,#$0D ;Skip CR
  837. JNZ escret ;no: ret
  838. MOV.B AL,[BX] ;get char
  839. INC BX ;next char
  840. CMP BX,txend ;text end ?
  841. JB eskipcr ;no: continue
  842. escret RET ;"
  843. eclrlin CS: ;Clear line
  844. MOV.B CH,txwinx2 ;col count-1
  845. DEC.B CH
  846. JMP eclrln ;"clear line
  847. escrdma PUSH DS ;Prepare screen DMA
  848. POP ES ;DS -> ES
  849. MOV DI,#dmabuf ;ptr to DMA buffer
  850. CLD
  851. XOR.B AH,AH ;AL -> CX = pos in line
  852. MOV CX,AX
  853. MOV SI,AX ;AL*2 -> SI
  854. ADD SI,SI
  855. CS:
  856. MOV AL,txwinx2 ;column count * 2
  857. ADD AX,AX
  858. MOV BP,AX ;-> BP
  859. SUB BP,SI ;- horizontal offset
  860. MUL.B scrrow ;line length * current row
  861. ADD BP,AX ;+ row position
  862. RET ;"
  863. escrdma2 INC.B AL ;column + 1
  864. CALL escrdma ;prepare DMA
  865. DEC CX ;char cnt-1
  866. JMP.b edlcrit ;"do it
  867. edmalin CS: ;Display line
  868. MOV AL,txwinx2 ;column count
  869. CALL escrdma ;prepare screen DMA
  870. DEC CX ;count down
  871. MOV.B AH,horscr ;horizontal scroll
  872. OR.B AH,AH ;=0 ?
  873. JZ edlcrit
  874. edl1 CALL esetatt ;set attribute
  875. MOV.B AL,[BX] ;get char
  876. INC BX ;next char
  877. CMP BX,txend ;text end ?
  878. JNB edletx ;:yes
  879. CALL eskipcr ;skip CR
  880. CMP AL,#$0A ;LF ?
  881. JZ edletx ;:yes
  882. DEC.B AH ;another char ?
  883. JNZ edl1 ;:yes
  884. edlcrit CMP.B attchg,#$00 ;critical line
  885. JZ edlatt ;:no
  886. PUSH BX ;save pos
  887. CALL esrcend ;search end of line
  888. MOV AX,lnpos ;pos in line = end of line ?
  889. CMP AX,BX
  890. JBE edllim ;:ok
  891. MOV BX,AX ;limit it
  892. edllim INC BX
  893. MOV eolpos,BX ;pos: end of line
  894. POP BX ;restore pos
  895. CALL esetatt ;set attribute
  896. CMP BX,eolpos ;= pos EOL ?
  897. JNB edletx ;:yes
  898. edlatt CALL esetatt ;set attribute
  899. CMP BX,eolpos ;end of line ?
  900. JZ edletx ;yes: end
  901. MOV.B AL,[BX] ;get char
  902. INC BX ;next
  903. CMP BX,txend ;text end ?
  904. JA edletx ;yes: end
  905. CMP AL,#$0D ;CR ?
  906. JZ edllp ;yes: forget it
  907. CMP AL,#$20 ;control char ?
  908. JNB edlnrm ;:no, normal
  909. ADD AL,#$40 ;convert to normal
  910. PUSH AX ;save it
  911. CALL etogatt ;set attribute
  912. POP AX ;restore
  913. edlnrm MOV.B AH,attcur ;current attribute
  914. STOS ;store in buffer
  915. LOOP edlatt ;:another char
  916. edllp MOV.B AL,[BX] ;get char
  917. INC BX
  918. CMP BX,txend ;text end ?
  919. JA edletx ;:yes
  920. CMP AL,#$0A ;LF ?
  921. JNZ edllp ;:not yet
  922. edletx INC CX ;one more byte
  923. MOV AL,#$20 ;fill up with spaces
  924. MOV.B AH,attcur ;current attribute
  925. REPZ
  926. STOS
  927. CMP.B disflg,#$00 ;display it ?
  928. JZ edlret ;:no
  929. MOV CX,SI ;byte number / 2 -> words
  930. SHR CX,1
  931. MOV DI,BP ;destination ofs
  932. MOV ES,scrseg ;screen segment
  933. MOV SI,#dmabuf ;buffer addr
  934. CMP.B scrbad,#$FF
  935. JZ edlbad ;:yes
  936. REPZ ;just move it into screen memory
  937. MOVS
  938. edlret RET ;'
  939. edlbad MOV DX,#$03DA ;test port
  940. edlblp LODS ;get word
  941. MOV BP,AX ;save it
  942. edlbw1 IN AL,DX ;get status
  943. RCR.B AL,1
  944. JB edlbw1 ;:wait
  945. CLI ;no INT allowed
  946. edlbw2 IN AL,DX ;get status
  947. RCR.B AL,1
  948. JNB edlbw2 ;:wait
  949. XCHG AX,BP ;restore char
  950. STOS ;store it
  951. STI ;clear interrupt
  952. LOOP edlblp ;:another char
  953. edlbret RET ;"
  954. esetatt CMP.B bkhide,#$FF ;Set attribute
  955. JZ esetnrm ;:block hidden
  956. CMP.B attchg,#$FF ;block beg/end in this line ?
  957. JZ esetblk ;:no
  958. CMP BX,bkbeg ;block begin ?
  959. JB esetnrm ;:no, normal
  960. CMP BX,bkend ;block end ?
  961. JNB esetnrm ;above: normal
  962. JMP.b eset2 ;'in block !
  963. esetblk CMP BX,bkbegl ;= pos block beg in buffer ?
  964. JB esetnrm ;:no, normal
  965. CMP BX,bkendl ;> pos block end in buffer ?
  966. JNB esetnrm ;yes: normal
  967. eset2 CMP.B disflg,#$00 ;display it ?
  968. JZ edlbret ;:no
  969. JMP vidattr2 ;'Attribute #2
  970. esetnrm CMP.B disflg,#$00 ;display it ?
  971. JZ edlbret ;:no
  972. JMP knrmvid ;"NormVideo
  973. esetlow CMP.B disflg,#$00 ;display it ?
  974. JZ edlbret ;:no
  975. JMP klowvid ;"LowVideo
  976. etogatt CMP.B curatt,#$01 ;low set ?
  977. JZ esetnrm ;yes:NormVideo
  978. JMP esetlow ;"LowVideo
  979. eclrln CMP.B disflg,#$00 ;Clear line
  980. JZ edlbret
  981. PUSH AX ;save
  982. PUSH DX
  983. MOV.B AL,CH ;line number+1
  984. INC.B AL
  985. CALL escrdma ;prepare screen DMA
  986. DEC CX ;length-1
  987. CALL edletx ;erase to end of line
  988. POP DX ;restore
  989. POP AX
  990. RET ;"
  991. escrolup MOV BX,#$0001 ;Scroll up
  992. CALL esetcur ;set cursor pos: top line
  993. JMP xdelline ;"DelLine
  994. erstlin MOV BX,edpos ;^QL:restore line
  995. MOV DX,#$0000 ;clear block pos in buf:
  996. MOV bkbegl,DX ;block beg
  997. MOV bkendl,DX ;block end
  998. MOV CH,#$7F ;up to 127 chars
  999. MOV SI,#line ;dest: line buffer
  1000. MOV.B attflg,#$00 ;flag: no block beg / end
  1001. erllp MOV.B AL,[BX] ;get char
  1002. CMP BX,bkbeg ;block beg ?
  1003. JNZ erlnbeg ;:no
  1004. MOV bkbegl,SI ;pos block beg in line
  1005. OR.B attflg,#$01 ;block beg in this line
  1006. erlnbeg CMP BX,bkend ;block end ?
  1007. JNZ erlnend ;:no
  1008. MOV bkendl,SI ;pos block end in line
  1009. OR.B attflg,#$02 ;block end in this line
  1010. erlnend CMP AL,#$0D ;CR ?
  1011. JNZ erlnext ;no:next char
  1012. MOV.B [SI],#$20 ;store a space
  1013. INC SI ;next
  1014. DEC.B CH ;count down
  1015. JZ elonglin ;:line too long
  1016. INC BX ;next char
  1017. CMP BX,txend ;end of text ?
  1018. JNB erllp ;:no, continue
  1019. erlend CMP BX,bkend ;block active in this line ?
  1020. JNB erlbeg ;:no
  1021. PUSH BX ;save pos
  1022. MOV BX,#$FFFF ;flag: block ends after
  1023. MOV bkendl,BX ;this line
  1024. POP BX
  1025. erlbeg CMP BX,bkbeg ;block beg ?
  1026. JNB erllen
  1027. MOV BX,#$FFFF ;flag: block starts before this
  1028. MOV bkbegl,BX ;line
  1029. erllen MOV AL,#$7F ;test line length
  1030. SUB.B AL,CH
  1031. MOV oldlen,AL ;store old length
  1032. erlpad MOV.B [SI],#$20 ;fill up with spaces
  1033. INC SI
  1034. DEC.B CH
  1035. JNZ erlpad ;:again
  1036. MOV BX,lnpos ;pos in buffer
  1037. CALL erepos ;reposition in line
  1038. CMP.B scrfl2,#$00 ;small move only ?
  1039. MOV.B scrfl2,#$FF ;reset flag
  1040. JZ erldisp ;:yes
  1041. JMP erewrlin ;'redisplay line
  1042. erldisp MOV AL,dislin ;redisplay from ...
  1043. DEC.B AL
  1044. CMP.B AL,phrow ;= phys row ?
  1045. JNB eseret ;above: ret
  1046. JMP erewrlin ;'rewrite line
  1047. erlnext CMP AL,#$0A ;LF ?
  1048. JZ erlend ;yes: end it
  1049. MOV.B [SI],AL ;store char
  1050. INC SI ;go to next
  1051. DEC.B CH ;too much ?
  1052. JNZ erletx ;:no
  1053. JMP.b elonglin ;'error: long line
  1054. erletx INC BX ;end of text ?
  1055. CMP BX,txend
  1056. JNB erlend ;yes: end it
  1057. JMP erllp ;"continue
  1058. elonglin CALL eclrstat ;Insert line break - line too long
  1059. CALL ewriterr ;write message
  1060. B "Line too long - CR inserted",$00
  1061. CALL waitesc ;wait for ESC
  1062. MOV BX,#$007D ;offset
  1063. CALL elb2 ;insert line break
  1064. CALL erstlin ;restore line
  1065. JMP erewrall ;"rewrite all
  1066. eclrstat CALL edodispl ;Clear status line
  1067. eclrs2 MOV.B statobs,#$00 ;status line destroyes
  1068. MOV BX,#$0000 ;set cursor pos
  1069. CALL esetcur
  1070. CALL knrmvid ;NormVideo
  1071. CALL eclrlin ;clear line
  1072. MOV BX,#$0000 ;set cursor pos
  1073. CALL esetcur
  1074. JMP klowvid ;"LowVideo
  1075. esrcend MOV AL,#$20 ;Search end of input line
  1076. MOV BX,#lineend1 ;end pos
  1077. MOV DX,#line0 ;start pos
  1078. eselp CMP.B AL,[BX] ;space ?
  1079. JNZ eseret ;no: end found
  1080. DEC BX ;search backwards
  1081. CMP BX,DX ;beg reached ?
  1082. JNZ eselp ;no:continue
  1083. eseret RET ;"
  1084. elimpos MOV DX,#lineend ;BX>end of line ?
  1085. CMP BX,DX
  1086. JNB eseret ;:ret
  1087. MOV DX,CX
  1088. JMP emin ;"min(BX,DX)->BX
  1089. eflush CALL esrcend
  1090. INC BX ;search end of line + 1
  1091. efl2 MOV CX,BX ;end position
  1092. MOV BX,bkbegl ;pos block beg in buf
  1093. CALL elimpos ;limit to end position
  1094. MOV bkbegl,BX
  1095. MOV BX,bkendl ;pos block beg in buf
  1096. CALL elimpos ;limit to end position
  1097. MOV bkendl,BX
  1098. MOV BX,CX ;restore end position
  1099. INC BX ;+1
  1100. MOV DX,#line ;- beg position
  1101. SUB BX,DX
  1102. PUSH BX ;-> length
  1103. MOV AL,oldlen ;old length - new length
  1104. SUB.B AL,BL
  1105. MOV.B CL,AL ;-> count
  1106. MOV CH,#$00
  1107. JNB eflpos ;:ok
  1108. MOV CH,#$FF ;negative
  1109. eflpos MOV BX,edpos ;current pos
  1110. JZ eflsame ;:no size change
  1111. CALL echgsize ;expand / shrink text
  1112. eflsame POP CX ;restore length
  1113. MOV SI,edpos ;destination pos
  1114. MOV BX,#line ;buffer pos
  1115. MOV.B CH,CL ;count
  1116. OR.B CH,CH ;test it
  1117. JZ eflend ;0:nothing to do
  1118. efllp MOV.B AL,[BX] ;get char
  1119. CMP BX,bkbegl ;= block beg ?
  1120. JNZ eflnbeg ;:no
  1121. MOV bkbeg,SI ;set block beg
  1122. eflnbeg CMP BX,bkendl ;= block end ?
  1123. JNZ eflnend ;:no
  1124. MOV bkend,SI ;set block end
  1125. eflnend MOV.B [SI],AL ;store char
  1126. INC BX ;next char
  1127. INC SI
  1128. DEC.B CH ;another ?
  1129. JNZ efllp ;:yes
  1130. DEC SI ;go back one char
  1131. eflend MOV.B [SI],#$0D ;store CR at end
  1132. RET ;"
  1133. etstmem MOV BX,txmemend ;Test if memory full
  1134. SUB BX,DX ;end text space - new text end
  1135. JB etsterr ;:error
  1136. MOV CX,#$00FE ;254 bytes left ?
  1137. SUB BX,CX
  1138. JNB etstret ;or more: ret
  1139. ADD BX,CX ;restore
  1140. PUSH BX
  1141. CALL eclrs2 ;clear status line
  1142. POP BX ;number free bytes
  1143. MOV CH,#$00
  1144. CALL ewriterr ;write message
  1145. B "WARNING: ",$00
  1146. CALL edcvt ;display number
  1147. CALL ewriterr ;write message
  1148. B " byte(s) left",$00
  1149. CALL waitesc ;wait for ESC
  1150. etstret RET ;'
  1151. etsterr CALL eclrstat ;clear status line
  1152. CALL ewriterr ;write message
  1153. B "ERROR: Out of space",$00
  1154. CALL waitesc ;wait for ESC
  1155. JMP edmain ;"return to main loop
  1156. etstint CMP AL,#$15 ;Test for interrupt
  1157. JNZ etstret ;:not ^U - ret
  1158. CALL eclrstat ;clear status line
  1159. CALL ewriterr ;write message
  1160. B "*** INTERRUPTED",$00
  1161. CALL waitesc ;wait for ESC
  1162. JMP edmain ;"go to main loop
  1163. echgsize PUSH BX ;Shrink or expand text
  1164. PUSH CX ;save pos,cnt
  1165. JB edinsert ;:insert, negative count
  1166. JMP edshrink ;'delete, positive count
  1167. edinsert MOV DX,txend ;save text end
  1168. PUSH DX
  1169. PUSH DX
  1170. XCHG DX,BX ;text end - pos
  1171. SUB BX,DX
  1172. MOV BP,BX ;-> BP
  1173. POP BX ;text end
  1174. PUSH BP ;save (text end - pos)
  1175. SUB BX,CX ;text end - count
  1176. JNB etsterr ;:error - out of space
  1177. MOV DX,BX ;-> BX
  1178. PUSH DX ;save new text end
  1179. CALL etstmem ;test space free
  1180. POP DX ;restore new text end
  1181. POP CX ;restore count+1
  1182. INC CX
  1183. POP BX ;text end
  1184. MOV txend,DX ;set new text end
  1185. OR CX,CX ;test count
  1186. JZ edins2 ;0:no move to do
  1187. CALL movebkb ;move block backwards
  1188. edins2 POP CX ;restore difference
  1189. POP BX ;pos
  1190. XCHG BX,DX
  1191. MOV BX,bkbeg ;update pointers:
  1192. CALL edupdate ;block beg
  1193. MOV bkbeg,BX
  1194. MOV BX,bkend
  1195. CALL edupdate ;block end
  1196. MOV bkend,BX
  1197. MOV BX,disbeg
  1198. CALL edupdate ;display beg
  1199. MOV disbeg,BX
  1200. MOV BX,edpos
  1201. CALL edupdate ;pos current line
  1202. MOV edpos,BX
  1203. MOV BX,posfifo
  1204. CALL edupdate ;position FIFO
  1205. MOV posfifo,BX
  1206. MOV BX,qppos
  1207. CALL edupdate ;pos FIFO 2
  1208. MOV qppos,BX
  1209. MOV BX,srend
  1210. CALL edupdate ;search limit end
  1211. MOV srend,BX
  1212. MOV BX,srbeg
  1213. CALL edupdate ;search limit beg
  1214. MOV srbeg,BX
  1215. RET ;"
  1216. edupdate CMP BX,DX ;update pointer: >pos of change ?
  1217. JBE edupret ;below/equal: no change
  1218. SUB BX,CX ;change it
  1219. edupret RET ;"
  1220. edshrink PUSH BX ;Shrink text: save pos
  1221. ADD BX,CX ;+ count
  1222. PUSH BX ;save
  1223. MOV DX,txend ;text end+1
  1224. INC DX
  1225. XCHG DX,BX ;-pos-count
  1226. SUB BX,DX
  1227. MOV CX,BX ;-> move count
  1228. POP BX ;restore source
  1229. POP DX ;restore dest
  1230. OR CX,CX ;test counter
  1231. JZ edshnil ;:nothing to move
  1232. CALL movebk ;move it - delete
  1233. DEC DX ;end pos-1
  1234. edshnil MOV txend,DX ;set new end pos
  1235. JMP edins2 ;"update pointers
  1236. etstbk PUSH BX ;Test block markers in line buffer
  1237. MOV DX,bkbegl ;pos block beg in buffer
  1238. CALL emin ;min(BX,DX)->BX
  1239. TEST.B attflg,#$01 ;block beg in this line ?
  1240. JZ etbnbeg ;:no
  1241. MOV bkbegl,BX ;set it
  1242. etbnbeg POP BX ;restore
  1243. TEST.B attflg,#$02 ;block end in this line ?
  1244. JZ etbnend ;:no
  1245. MOV DX,bkendl ;update it
  1246. CALL emin
  1247. MOV bkendl,BX
  1248. etbnend RET ;"
  1249. erepos MOV DX,#line ;Reposition in current line
  1250. CS: ;ptr line beg
  1251. MOV AL,txwinx2 ;column count - 1 -> CL
  1252. DEC.B AL
  1253. MOV.B CL,AL
  1254. SUB BX,DX ;relative pos -> BX
  1255. MOV.B AL,BL
  1256. SUB.B AL,horscr ;pos < hor scroll ?
  1257. JB erephscr ;yes: underflow
  1258. CMP.B AL,CL ;outside displayed window ?
  1259. JB erepcol ;no: ok
  1260. SUB.B AL,CL ;calc diff+1 (overflow)
  1261. INC.B AL
  1262. ADD.B AL,horscr ;add to horizontal scroll
  1263. MOV horscr,AL
  1264. CS:
  1265. MOV AL,txwinx2 ;col cnt-2 -> phys col
  1266. DEC.B AL
  1267. DEC.B AL
  1268. MOV phcol,AL
  1269. JMP erewrall ;'redisplay all
  1270. erepcol MOV phcol,AL ;store phys col
  1271. erepret RET ;'
  1272. erephscr ADD.B AL,horscr ;add to horizontal scroll
  1273. MOV horscr,AL
  1274. MOV.B phcol,#$00 ;phys col 0
  1275. JMP erewrall ;"rewrite all
  1276. eseldisp CMP.B disflg,#$00 ;Do selective rewrite
  1277. JZ erepret
  1278. MOV BX,disbeg ;display beg
  1279. MOV AX,txbeg ;text beg
  1280. CMP AX,BX ;the same ?
  1281. JBE esd2 ;:yes
  1282. MOV disbeg,AX ;store to display beg
  1283. MOV BX,AX
  1284. esd2 MOV CX,#$0001 ;line cnt
  1285. MOV DX,edpos ;current pos
  1286. CMP BX,DX ;= display beg ?
  1287. JNZ esd3 ;:no
  1288. JMP esd9 ;'yes: done
  1289. esd3 JB esddn ;below: search down
  1290. esd4 MOV DX,edpos ;current pos
  1291. CMP BX,DX ;= ?
  1292. JZ esd5
  1293. CALL elinup ;go up one line
  1294. INC CX ;count it
  1295. JMP esd4 ;'
  1296. esd5 MOV disbeg,BX ;store display beg
  1297. MOV.B phrow,#$01 ;phys row
  1298. MOV.B scrfl2,#$FF ;set flag
  1299. XOR AX,AX
  1300. CS:
  1301. MOV AL,txwiny2 ;row cnt - 1
  1302. SUB AX,#$0001
  1303. CMP AX,CX ;= line ?
  1304. JB esdredsp ;below: ok
  1305. DEC CX ;go back one line
  1306. MOV BX,#$0001 ;set cursor pos:
  1307. CALL esetcur ;below status line
  1308. DEC CX ;test it
  1309. PUSHF
  1310. INC CX ;restore
  1311. esdinsl CALL xinsline ;InsLine
  1312. LOOP esdinsl ;:again
  1313. POPF ;one only ?
  1314. JNZ esdredsp ;no: do redisplay
  1315. RET ;'
  1316. esdredsp JMP eredall ;'redisplay all
  1317. esddn CMP BX,edpos ;>= current pos
  1318. JNB esd6 ;:not yet
  1319. CALL elindn ;go down one line
  1320. INC CX ;count
  1321. JMP esddn ;'
  1322. esd6 OR.B CH,CH ;clear count
  1323. JNZ esd10 ;:much
  1324. CS:
  1325. MOV AL,txwiny2 ;line count-1 -> DL
  1326. DEC.B AL
  1327. MOV.B DL,AL
  1328. MOV.B AL,CL ;counter-line cnt+1 -> DH
  1329. SUB.B AL,DL
  1330. MOV.B DH,AL
  1331. INC.B DH
  1332. JB esd9 ;:ok
  1333. DEC.B DH ;test it
  1334. JNZ esd7
  1335. CMP.B scrfl1,#$FF ;test flag
  1336. JNZ esd7 ;:normal
  1337. JMP.b esd11 ;'keep it short
  1338. NOP
  1339. esd7 INC.B DH
  1340. SUB.B AL,DL
  1341. JNB esd10
  1342. MOV AL,dislin ;redisplay from
  1343. SUB.B AL,DH
  1344. JBE esd10
  1345. MOV dislin,AL ;set it
  1346. MOV BX,disbeg ;display beg
  1347. MOV.B CH,DH
  1348. PUSH DX
  1349. esdscrl CALL elindn ;go down one line
  1350. PUSH BX ;save pos
  1351. CALL escrolup ;scroll up
  1352. POP BX ;restore
  1353. DEC.B CH ;count down
  1354. JNZ esdscrl ;:another
  1355. MOV disbeg,BX ;store display beg
  1356. POP DX
  1357. esd8 DEC.B DL
  1358. MOV.B phrow,DL ;phys row
  1359. RET ;'
  1360. esd9 MOV.B phrow,CL
  1361. RET ;'
  1362. esd10 MOV BX,disbeg
  1363. DEC CX
  1364. CS: ;line cnt - 3 -> DL
  1365. MOV AL,txwiny2
  1366. SUB AL,#$03
  1367. MOV.B DL,AL
  1368. MOV.B AL,CL
  1369. SUB.B AL,DL
  1370. MOV.B CL,AL
  1371. JNB esddn2
  1372. DEC.B CH
  1373. esddn2 CALL elindn ;go down one line
  1374. LOOP esddn2 ;:again
  1375. MOV disbeg,BX ;store display beg
  1376. CALL eredall ;redisplay all
  1377. MOV.B scrfl2,#$FF ;set flag: long update
  1378. JMP eseldisp ;'do it again
  1379. esd11 CALL esd8 ;set phys row
  1380. MOV AL,dislin ;redisplay from
  1381. CS:
  1382. CMP.B AL,txwiny2 ;= line cnt ?
  1383. JZ esd12 ;:yes
  1384. DEC.B AL
  1385. JZ esd12
  1386. MOV dislin,AL ;set: redisplay from
  1387. esd12 MOV BX,disbeg ;display beg
  1388. CALL elindn ;go down one line
  1389. MOV disbeg,BX ;-> new display beg
  1390. CALL escrolup ;scroll up
  1391. CS:
  1392. MOV AL,txwiny2 ;line cnt - 1
  1393. DEC.B AL
  1394. JMP edsplin ;"redisplay one line
  1395. etstsep MOV SI,sepptr ;Char = separator ?
  1396. etslp CS: ;get ptr to table
  1397. MOV.B AL,[SI] ;get char from table
  1398. OR.B AL,AL ;table end ?
  1399. JZ etsno ;:yes
  1400. CMP.B AL,[BX] ;= text char ?
  1401. JZ etsyes ;:yes
  1402. INC SI ;try next char
  1403. JMP etslp ;'
  1404. etsyes STC ;found it !
  1405. etsno MOV DX,SI ;DX=pos in table
  1406. RET ;"
  1407. LAHF ;redisplay current line
  1408. PUSH AX ;save
  1409. MOV AL,phrow ;phys row
  1410. CMP.B AL,dislin ;>= redisplay from ?
  1411. JNB erc2 ;:ok
  1412. MOV dislin,AL ;redisplay current line, too !
  1413. erc2 POP AX ;restore
  1414. SAHF
  1415. RET ;"
  1416. eredall MOV.B dislin,#$01 ;set flag: redisplay all
  1417. RET ;"
  1418. eblkupdt XCHG BX,DX ;Update blocks
  1419. TEST.B attflg,#$01 ;block beg in this line ?
  1420. JZ ebunobk ;:no
  1421. MOV BX,bkbegl ;pos block in buffer
  1422. CMP BX,DX ;< BX ?
  1423. JB ebunobk ;:ok
  1424. ADD BX,CX ;add count
  1425. MOV bkbegl,BX ;-> update
  1426. ebunobk TEST.B attflg,#$02 ;block end in this line ?
  1427. JZ ebunochg ;:no
  1428. MOV BX,bkendl ;pos block end in buffer
  1429. CMP BX,DX ;< BX ?
  1430. JB ebunochg ;:ok
  1431. ADD BX,CX ;add count
  1432. MOV bkendl,BX ;-> update
  1433. ebunochg XCHG BX,DX ;restore BX
  1434. RET ;"
  1435. edelch PUSH BX ;delete char: save pos
  1436. MOV CX,#$FFFF ;1 char back
  1437. CALL eblkupdt ;update blocks
  1438. XCHG BX,DX ;pos -> DX
  1439. MOV BX,#lineend1 ;buffer end
  1440. SUB BX,DX ;calculate count
  1441. JZ edelcnil ;:nothing to move
  1442. MOV CX,BX ;count -> CX
  1443. MOV BX,DX ;pos -> BX
  1444. INC BX ;source: +1
  1445. CALL movebk ;move it
  1446. edelcnil MOV BX,#lineend1 ;store a space at the end
  1447. MOV.B [BX],#$20
  1448. POP BX ;restore pos
  1449. RET ;"
  1450. emin CMP BX,DX ;min(BX,DX) -> BX
  1451. JB emin2 ;max(BX,DX) -> DX
  1452. XCHG BX,DX
  1453. emin2 RET ;"
  1454. eredlin CALL eposcur ;redisplay line: set cursor pos
  1455. CS:
  1456. MOV AL,txwinx2 ;col cnt - 1
  1457. DEC.B AL
  1458. SUB.B AL,phcol ;- phys col
  1459. MOV BX,lnpos ;pos in line buffer
  1460. MOV.B attchg,#$FF ;attribute change in this line
  1461. CALL escrdma2 ;redisplay this line
  1462. MOV.B attchg,#$00 ;clear attribute flag
  1463. RET ;"
  1464. elindn MOV BP,CX ;go down one line
  1465. MOV CX,txend ;text end
  1466. MOV DI,BX ;current pos
  1467. SUB CX,DI ;text end-pos -> count
  1468. JBE eld2 ;:too much
  1469. MOV AX,DS ;DS -> ES
  1470. MOV ES,AX
  1471. CLD ;search LF
  1472. MOV AL,#$0A
  1473. REPNZ
  1474. SCAS.B
  1475. JNZ eld2 ;:not found
  1476. MOV CX,BP ;restore CX
  1477. MOV BX,DI ;pos of line break
  1478. RET ;'
  1479. eld2 MOV CX,BP ;restore CX
  1480. STC ;flag: not done
  1481. RET ;"
  1482. elinup MOV BP,BX ;go up one line
  1483. MOV AL,#$0A ;search LF
  1484. MOV DI,txbeg ;text beg = limit
  1485. DEC BX ;go back one char
  1486. elulp DEC BX ;go back
  1487. CMP BX,DI ;= end ?
  1488. JBE eluend ;:yes
  1489. CMP.B [BX],AL ;LF ?
  1490. JNZ elulp ;:no, try again
  1491. INC BX ;go to beg of line
  1492. eluend JB eluerr ;:not found
  1493. RET ;'
  1494. eluerr MOV BX,BP ;restore pos
  1495. RET ;"
  1496. einsch PUSH BX ;insert char in line
  1497. MOV CX,#$0001 ;1 char
  1498. CALL eblkupdt ;update blocks
  1499. MOV DX,#lineend1 ;buffer end
  1500. XCHG BX,DX ;calc count
  1501. SUB BX,DX
  1502. DEC BX
  1503. MOV CX,BX
  1504. MOV DX,#lineend0 ;buffer end
  1505. MOV BX,DX
  1506. DEC BX
  1507. MOV.B AL,CL ;test length
  1508. OR.B AL,CH ;did they translate this automatically
  1509. JZ einscnil ;from Z80-code ??!!
  1510. PUSH DX ;save pos
  1511. CALL movebkb ;insert
  1512. POP BX ;restore pos
  1513. MOV.B [BX],#$20 ;store a space
  1514. einscnil POP BX ;restore pos
  1515. RET ;"
  1516. ewritpos CALL esetcur ;Write string + pos cursor
  1517. ewrits CALL klowvid ;LowVideo
  1518. JMP prints ;"write string
  1519. ewriterr CALL vidattr3 ;Attribute #3
  1520. JMP prints ;"write string: error message
  1521. ewritch CMP.B disflg,#$FF ;editing status
  1522. JNZ ewritret ;:ret
  1523. JMP conput ;"write it
  1524. ekbdstat PUSH AX ;Get KBD stat
  1525. PUSH BX
  1526. PUSH CX
  1527. PUSH DX
  1528. DEC SP
  1529. CALL [vkbdstat] ;do it
  1530. POP DX
  1531. POP CX
  1532. POP BX
  1533. POP AX
  1534. ewritret RET ;"
  1535. esetcur CMP.B disflg,#$00 ;set cursor pos
  1536. JZ escrt
  1537. MOV.B scrrow,BL ;line
  1538. XCHG BX,DX
  1539. CALL setcpos ;set it
  1540. XCHG BX,DX ;restore
  1541. escrt RET ;"
  1542. ;first command table (installed with TINST)
  1543. ecmd1 B $01,$0D,$02,$1B,$4B,$01,$FF,$02,$1B,$4D,$02,$1B,$73,$02
  1544. B $1B,$74,$02,$1B,$48,$02,$1B,$50,$01,$FF,$01,$FF,$02,$1B
  1545. B $49,$02,$1B,$51,$02,$1B,$47,$02,$1B,$4F,$02,$1B,$77,$02
  1546. B $1B,$75,$02,$1B,$84,$02,$1B,$76,$01,$FF,$01,$FF,$01,$FF
  1547. B $02,$1B,$52,$01,$FF,$01,$FF,$01,$FF,$01,$FF,$02,$1B,$53
  1548. B $01,$08,$01,$FF,$02,$1B,$41,$02,$1B,$42,$01,$FF,$01,$FF
  1549. B $01,$FF,$01,$FF,$01,$FF,$01,$FF,$01,$FF,$01,$FF,$01,$FF
  1550. B $01,$FF,$01,$FF,$01,$FF,$01,$FF,$01,$FF,$01,$FF,$00,$00
  1551. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1552. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1553. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1554. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1555. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1556. B $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
  1557. B $00,$00,$00,$00 ;"
  1558. ;second command line (preinstalled)
  1559. ecmd2 B $01,$0D,$01,$13,$01,$08,$01,$04,$01,$01,$01,$06,$01,$05
  1560. B $01,$18,$01,$17,$01,$1A,$01,$12,$01,$03,$02,$11,$13,$02
  1561. B $11,$04,$02,$11,$05,$02,$11,$18,$02,$11,$12,$02,$11,$03
  1562. B $02,$11,$02,$02,$11,$0B,$02,$11,$10,$01,$16,$01,$0E,$01
  1563. B $19,$02,$11,$19,$01,$14,$01,$07,$01,$7F,$01,$FF,$02,$0B
  1564. B $02,$02,$0B,$0B,$02,$0B,$14,$02,$0B,$08,$02,$0B,$03,$02
  1565. B $0B,$16,$02,$0B,$19,$02,$0B,$12,$02,$0B,$17,$02,$0B,$04
  1566. B $01,$09,$02,$11,$09,$02,$11,$0C,$02,$11,$06,$02,$11,$01
  1567. B $01,$0C,$01,$10,$00 ;"
  1568. eseptab B "<>,[].*+-/$:=(){}^#\'"
  1569. esepspc B " ",$00 ;"
  1570. ;Jump table for editor commands
  1571. ;Labels ending with 2 have the MSB set. On these commands
  1572. ;the text is marked as changed. The commands are in the order
  1573. ;given in the chapter "Editing Command Installation" of the
  1574. ;Turbo manual.
  1575. ejmptab W ecr,eleft,eleft,eright,ewrdlft,ewrdrt,eup,edn,escrup,escrdn
  1576. W epagup,epagdn,ejlnbeg,ejlnend,epagtop,epagbot,etxtbeg
  1577. W ejtxend,ejbkbeg,ejbkend,elstpos,etogovr,elinins2,edellin2
  1578. W edeleol2,edelwrd2,edelrt2,edellft2,edellft2,emarkbeg,emarkend
  1579. W emrkwrd,ekh,eblkcpy2,eblkmov2,eblkdel2,eblkrd2,ekw,ekd
  1580. W etab2,etogind,erstlin2,efind,ereplace,erepeat,eprefix2 ;"
  1581. ;*** Compiler ***
  1582. turbo MOV spsav,SP ;save stack pointer
  1583. CMP.B cpmode,#$02 ;to COM or CHN ?
  1584. JB turmem ;:no
  1585. CMP.B txcomp,#$00 ;is it already compiled ?
  1586. JZ turmem ;:no
  1587. CMP.B cdinval,#$00 ;is it invalid ?
  1588. JNZ turmem ;:yes
  1589. CALL opendest ;open dest file
  1590. CALL cvmemdsk ;change to disk code
  1591. JMP.b turret ;'no error
  1592. turmem CALL inittur ;init variables
  1593. CMP.B cpmode,#$00 ;to memory ?
  1594. JNZ turfil ;:no
  1595. CALL copyrt ;make space, copy run-time lib
  1596. JMP.b turmem2 ;'
  1597. turfil CMP.B cpmode,#$02 ;COM / CHN ?
  1598. JB turmem2 ;:no
  1599. CALL opendest ;open dest file
  1600. turmem2 CALL compile ;compile program