include BDSYM.EQU include EPDATA .request STOWC .request CSEQ .request GOTOCOL .request GSTR .comment ` /************************************************/ /* Process one input line of text. */ /************************************************/ processline() { /* char pendc, hycorrect;*/ bsflag = FALSE; hycorrect = 0; pendc = inbuf[inpoint]; /* Special actions at beginning of input line */ /* some might like run-off style */ if (pendc == val['D'-'@']['C'-'@']) inbuf[inpoint] = pendc = ec; /* if ignoring, prevent beg. line action */ if (mode & IGNORE) pendc = '\0'; /* subsequent white space at beginning of line causes a break */ if (pendc == ' ' || pendc == '\t' || pendc == '\n') { brkflag = TRUE; prtsbuf(); /* empty input line? then leave blank output line */ if (pendc == '\n') { inbuf[inpoint] = 0; gstr(); } else while (pendc == ' '/* || pendc == SOFTSP*/) { /* if (pendc == ' ') */ lindent[cc] += PICA; scrncol++; pendc = inbuf[++inpoint]; } } else if (!co || nc) prtsbuf(); /* indent in multiple column mode */ if (cc > 1 && lindent[cc]) gotocol(lindent[cc]); /* Now the loop */ while (pendc = inbuf[inpoint++]) { scrncol++; /* maybe time to start a new line? */ /* pendc <= ' ' is experimental */ if (pendc <= ' ' && glen+lindent[cc]+hycorrect > llength) prtsbuf(); if (pendc == SOFTHY || pendc == SOFTHYA) putchar('&'); else putchar(pendc); /* if ignoring, look only at braces */ if ((mode & IGNORE) && pendc != '{' && pendc != '}') continue; /* Escape character */ if (pendc == ec) { if (pendc = cseq()) stowc(pendc); continue; } switch (pendc) { /* When concatenating, newline treated like a space - otherwise, start a new line */ case '\n': if (glen) if (co && !nc) { if (outbuf[outpoint-1] > ' ') stowc(' '); } /* else gstr();*/ scrncol = 0; hycorrect = 0; break; /* Tab */ case '\t': dotab(); hycorrect = 0; break; /* Soft hyphen -- correct for early line break */ case SOFTHY: case SOFTHYA: stowc(SOFTHY); hycorrect = widbuf[outpoint-1]; break; /* watch braces */ case '}': if (brccount || !modepop()) stowc(pendc); if (brccount) brccount--; break; case '{': if (allmode) { brcstk[cc][brcpt[cc]++] = mode; mode = allmode; } else { brccount++; stowc(pendc); } break; /* Space -- reset hyphen correction */ case ' ': hycorrect = 0; /* Not special -- put it in buffer */ default: stowc(pendc); } /* end switch */ } /* end while */ } ` processline:: push b ;pendc in C ;so can use ret's instead of jump's lxi h,.pLOOP push h ; bsflag = FALSE; ; hycorrect = 0; xra a sta bsflag sta hycorrect ; pendc = inbuf[inpoint]; call inbch## mov c,a ; ;/* Special actions at beginning of input line */ ; ; /* some might like run-off style */ ; if (pendc == val['D'-'@']['C'-'@']) inbuf[inpoint] = pendc = ec; ;check for 'cm' char lda val + 54*('C'-'@') + 2*('M'-'@') cmp c jz .p31 lda val + 54*('D'-'@') + 2*('C'-'@') cmp c jnz .p1 lda ec mov c,a ; lhld inpoint ; lxi d,inbuf ; dad d ;HL was set by inbch ; ;(in a $h or $f string, ec will replace dc permanently) mov m,c ; ; /* if ignoring, prevent beg. line action */ ; if (mode & IGNORE) pendc = '\0'; .p1: lda mode+1 ani IGNORE shr 8 jz .p2 mvi c,0 ; ; /* subsequent white space at beginning of line causes a break */ ; if (pendc == ' ' || pendc == '\t' || pendc == '\n') .p2: mov a,c cpi ' ' jz .p3 cpi 9 jz .p3 cpi 0AH jnz .p6 ; { brkflag = TRUE; ; prtsbuf(); .p3: mvi a,1 sta brkflag call prtsbuf## ; /* empty input line? then leave blank output line */ ; if (pendc == '\n') mov a,c cpi 0AH jnz .p4 ; { inbuf[inpoint] = 0; ; gstr(); ; } ; lhld inpoint ; lxi d,inbuf ; dad d ;I guess this is ok, since 0ah should never get into strings call inbch## mvi m,0 ;; call gstr## jmp gstr## ;; jmp .p8 ; else ; while (pendc == ' ') .p4: mov a,c cpi ' ' ;; jnz .p8 rnz ; { lindent[cc] += PICA; ; scrncol++; ; pendc = inbuf[++inpoint]; ; } ; } call getlindent## push h lhld cw mov a,l ora a jnz $+6 lxi h,PICA dad d xchg pop h mov m,d dcx h mov m,e call nxspnt## call inbch## mov c,a jmp .p4 ; else if (!co || nc) prtsbuf(); .p6: lda co ora a ;; jz .p7 jz prtsbuf## lda nc ora a ;; jz .p8 rz ;;.p7: call prtsbuf## jmp prtsbuf## ; ; /* indent in multiple column mode */ ; if (cc > 1 && lindent[cc]) gotocol(lindent[cc]); ;(changed to subr. so can use \br to separate columns) .p8: lda cc cpi 1+1 rc ;(make sure only once per column) lhld outpoint mov a,h ora l rnz call getlindent## mov a,d ora e rz push d call gotocol## pop d ret ; ;/* Now the loop */ ; ; while (pendc = inbuf[inpoint++]) .pLOOP: ;first push back self as ret lxi h,.pLOOP push h call inbch## mov c,a ;moved this up from below -- not clear that this is right ; (might make a difference for a 2nd ref. to =$$ in macro) ora a jz .p31 call nxspnt## ; ; { scrncol++; ;(done in nxspnt) ; ; /* maybe time to start a new line? */ ; if (pendc <= ' ' && glen+lindent[cc]+hycorrect > llength) ; prtsbuf(); ;(according to this, can break at a space or any control character -- ; a little too general; should be SP, LF, SOFTHY, SOFTHYA, and ; perhaps '-' as an option) mov a,c cpi ' '+1 jnc .p13 call chkbchar ;if not a real char, and not a break char, pass it to cseq jnz .p10 ;back to here to reconsider a break when cseq returns a blank or softhy .pLENCHK: call getlindent## lhld glen dad d lda hycorrect mov e,a mvi d,0 dad d lxi d,8 lda italcorrect ora a jz $+4 dad d xchg lhld llength call agbu cc prtsbuf## ; .p10: ; ; /* if ignoring, look only at braces */ ; if ((mode & IGNORE) && pendc != '{' && pendc != '}') continue; .p13: lda mode+1 ani IGNORE shr 8 jz .p14 mov a,c cpi '{' jz .p14 cpi '}' rnz ;.pLOOP ; ; ; /* Escape character */ ; if (pendc == ec) .p14: lda ec cmp c jnz .p16 mvi a,'\' ; { if (pendc = cseq()) stowc(pendc); ; continue; ; } .p14.0: call cseq## mov a,l mov c,l cpi ' ' jz .pLENCHK cpi SOFTHY jz .pLENCHK ora a rz ;.pLOOP ;0ffh returned by cseq for comment inr a jz .psTERM .p14a: jmp .lstow chkbchar: cpi ' ' rz cpi newlin rz cpi SOFTHY rz cpi SOFTHYA ret ; ; ; switch (pendc) { .p16: lda tc cmp c jnz .p16a lxi h,$tbcmd jmp sdirect## $tbcmd: db '\tb\.',0 .p16a: mov a,c cpi 0AH jz .p17 cpi 9 jz .p19 cpi SOFTHY jz .p20 cpi SOFTHYA jz .p20 cpi '}' jz .p21 cpi '{' jz .p25 cpi ' ' jz .p28 jc .p14.0 jmp .p29 ; ; ; /* When concatenating, newline treated like ; a space - otherwise, start a new line */ ; case '\n': ; if (glen) ; if (co && !nc) ; { if (outbuf[outpoint-1] > ' ') stowc(' '); ; } ; /* else gstr();*/ ; scrncol = 0; ; hycorrect = 0; ; break; .p17: lxi h,.p18 push h lhld glen mov a,h ora l rz lda co ora a rz lda nc ora a rnz lhld outbuf xchg lhld outpoint ;add check for outpoint = 0 (though maybe not possible) mov a,h ora l rz dcx h dad d mov a,m ;now printable control characters are allowed, so this ; has to be different ; cpi ' '+1 ; jc .p18 ;rather, check only for SP and BS (add SPFLAG and HSFLAG?) cpi ' ' rz cpi 8 rz pop h ;discard .p18 ret ;; lxi h,' ' ;; push h ;; call stowc## ;; pop d mvi l,' ' call .lstow .p18: xra a sta scrncol sta hycorrect sta italcorrect ret ; ; /* Tab */ ; case '\t': ; dotab(); ; hycorrect = 0; ; break; ; .p19: call dotab## xra a sta hycorrect ret ; ; /* Soft hyphen -- correct for early line break */ ; case SOFTHY: ; case SOFTHYA: ; stowc(SOFTHY); ; hycorrect = widbuf[outpoint-1]; ; break; .p20: mvi l,SOFTHY call .lstow lhld widbuf xchg lhld outpoint dcx h dad h dad d mov a,m sta hycorrect ret ; ; /* watch braces */ ; case '}': ; if (brccount || !modepop()) stowc(pendc); ; if (brccount) brccount--; ; break; .p21: lhld brccount mov a,h ora l jnz .p22 call modepop## mov a,h ora l jnz .p23 .p22: call .cstow .p23: lhld brccount mov a,h ora l rz ;.pLOOP dcx h shld brccount ret ; ; case '{': ; if (allmode) ; { brcstk[cc][brcpt[cc]++] = mode; ; mode = allmode; ; } ; else ; { brccount++; ; stowc(pendc); ; } ; break; .p25: lhld allmode mov a,h ora l jz .p26 call pshbrc## lhld allmode shld mode ret .p26: lhld brccount inx h shld brccount jmp .cstow ; ; /* Space -- reset hyphen correction */ ; case ' ': ; hycorrect = 0; .p28: mvi a,0 sta hycorrect ; /* Not special -- put it in buffer */ ; default: ; stowc(pendc); ; ; } /* end switch */ ; ; } /* end while */ ; .cstow: .p29: ;possibly do indentation in mc mode call .p8 mov l,c .lstow: mvi h,0 push h call stowc## pop d ;; lda mode ;; ani ITALIC ;; sta italcorrect lhld mode call endcorr## mov a,e sta italcorrect ret ;.pLOOP ;} .psTERM: ;terminate processing of string, if any call sddown## ;then exit (to get next line or to finish heading/footing) .p31: lxi h,val + 54*('R'-'@') + 2*('L'-'@') mov a,m ora a jz .p31ns dcr m jz .p31ns lhld rlpoint shld inpoint ret .p31ns: pop h ;discard ret to .pLOOP pop b ret italcorrect: db 0 end