;functions SENDIT, MRESET, HFILL, NATIVELINE ;(HFILL is internal) include BDSYM.EQU include EPDATA .request GCHR .comment ` int sdti; sendit() { if (!gpoint) {skdots++; return; } /* position printhead */ paperup(0); inover(); if (mx || fa) { if (mx) {PTESCCH('L');} else {PTESCCH('Y');} PTCH((gpoint>>1) % 256); PTCH((gpoint>>1)/256); for (sdti = 0; sdti < gpoint; sdti++) if (!(sdti % 2)) PTCH(gbuf[sdti] | gbuf[sdti+1]); } else if (val['H'-'@']['R'-'@']) { PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); for (sdti = 0; sdti < gpoint; sdti++) if (sdti % 2) PTCH(gbuf[sdti]); else PTCH('\0'); PTCH('\r'); inover(); PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); for (sdti = 0; sdti < gpoint; sdti++) if (sdti % 2) PTCH('\0'); else PTCH(gbuf[sdti]); } else { PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); for (sdti = 0; sdti < gpoint; sdti++) PTCH(gbuf[sdti]); } PTCH('\r'); skdots++; } inover() { /* over for indentation */ if (nc) hfill(lindent[ 1] + ad, FALSE); else hfill(lindent[cc] + ad, FALSE); } ` sendit:: push b ; if (!gpoint) {skdots++; return; } lhld gpoint mov a,h ora l jz .sdtx ; ; /* position printhead */ ; paperup(0); lxi h,0 push h call paperup## pop d ;if noprint, can skip rest lda noprint ora a jnz .sdtx ; ; inover(); ;;; call inover ; ; if (mx || fa) lda mx ora a mvi a,'L' jnz .sdt1 lda fa ora a jz .sdt3 ; { if (mx) {PTESCCH('L');} else {PTESCCH('Y');} mvi a,'Y' .sdt1: call presc1 ; PTCH((gpoint>>1) % 256); PTCH((gpoint>>1)/256); ;;; lhld _zlfill ;;; lxi d,1 ;;; call shlrbe ;;; push h ;;; push h lhld gpoint ;force to next even number inx h ;PLUS some mvi e,1 call shlrbe ;;; pop d ;;; dad d call prw ;PLUS some nuls ;;; pop h ;;; call lfillz ; for (sdti = 0; sdti < gpoint; sdti++) ; changed to ... sdti++,sdti++ call stgcnt .sdt2: ; if (!(sdti % 2)) PTCH(gbuf[sdti] | gbuf[sdti+1]); ; changed no 'if' mov a,m inx h ora m inx h call pr1 ; } dcx b mov a,b ora c jz .sdt6 dcx b mov a,b ora c jnz .sdt2 jmp .sdt6 ; else if (val['H'-'@']['R'-'@']) ; { .sdt3: lda val + 54*('H'-'@') + 2*('R'-'@') ;5dda ora a jz .sdt4 ; PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); mvi a,'Z' call presc1 call prgpw ; for (sdti = 0; sdti < gpoint; sdti++) ; if (sdti % 2) PTCH(gbuf[sdti]); else PTCH('\0'); mvi e,0 ;first pass out 0 if even call prevryother ; ; PTCH('\r'); mvi a,0dh call pr1 ; ; inover(); ;- call inover ; ; PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); mvi a,'Z' call presc1 call prgpw ; for (sdti = 0; sdti < gpoint; sdti++) ; if (sdti % 2) PTCH('\0'); else PTCH(gbuf[sdti]); mvi e,1 ;second pass out 0 if odd call prevryother jmp .sdt6 ; else ; { ; PTESCCH('Z'); PTCH(gpoint % 256); PTCH(gpoint/256); .sdt4: mvi a,'Z' call presc1 call prgpw ; for (sdti = 0; sdti < gpoint; sdti++) PTCH(gbuf[sdti]); call stgcnt .sdt5: mov a,m call pr1 inx h dcx b mov a,b ora c jnz .sdt5 ; } ; PTCH('\r'); .sdt6: mvi a,0dh call pr1 ; skdots++; ;} .sdtx: lhld skdots inx h shld skdots pop b ret prevryother: ; for (sdti = 0; sdti < gpoint; sdti++) call stgcnt .peo1: ; if (sdti % 2) PTCH(gbuf[sdti]); else PTCH('\0'); mov a,e ani 1 ;if even count, out 0 jz .peo2 ;if odd count, out real byte mov a,m .peo2: call pr1 inr e inx h dcx b mov a,b ora c jnz .peo1 ret stgcnt: lhld gpoint mov b,h mov c,l lxi h,gbuf ret ; ;inover() ;{ ; /* over for indentation */ ; if (nc) hfill(lindent[ 1] + ad, FALSE); ; else hfill(lindent[cc] + ad, FALSE); ;} ;(revise so just set the value, and call hfill only for nativeline) inover:: lhld lindent+2*1 xchg lda val + 54*('N'-'@') + 2*('C'-'@') ora a cz getlindent## lhld val + 54*('A'-'@') + 2*('D'-'@') dad d ;plus left-inside or left-outside xchg lhld val + 54*('L'-'@') + 2*('I'-'@') lda pn ani 1 jnz $+6 lhld val + 54*('L'-'@') + 2*('O'-'@') dad d ;check not negative mov a,h ora a rp lxi h,0 ret .comment ` /************************************************/ /* Tell Epson what kind of characters to print */ /************************************************/ mreset(m) { int dif; if (!(dif = emode ^ m)) return; if (dif & 61) if (mx) { dif &= 61; if (CMPRSSD & dif) if (CMPRSSD & m) PTCH(15); else PTCH(18);; if (EMPHSZD & dif) if (EMPHSZD & m) {PTESCCH('E');} else PTESCCH('F');; if (DBLSTRK & dif) if (DBLSTRK & m) {PTESCCH('G');} else PTESCCH('H');; if (EXPNDD & dif) { PTESCCH('W'); if (EXPNDD & m) PTCH(1); else PTCH(0); } } else { PTESCCH('!'); PTCH(m & 61); } if (UNDRLN & dif) { PTESCCH('-'); if (UNDRLN & m) PTCH(1); else PTCH(0); } if (PRPTNL & dif) { PTESCCH('p'); if (PRPTNL & m) PTCH(1); else PTCH(0); } if (SUPSCRPT & dif) { if (SUPSCRPT & m) {PTESCCH('S'); PTCH(1);} else {PTESCCH('T');} } if (SUBSCRPT & dif) { if (SUBSCRPT & m) {PTESCCH('S'); PTCH(0);} else {PTESCCH('T');} } emode = m; } ` mreset:: ;get list vector lhld 1 lxi d,4*3 dad d shld _biopr+1 pop d pop h push h push d push b ;arg m kept in HL ;local dif kept in BC ; if (!(dif = emode ^ m)) return; xchg lhld emode xchg mov a,h xra d ani 0f8h mov b,a mov a,l xra e ani not ITALIC mov c,a ora b jz .mrx ; ; if (dif & 61) mov a,c ani 61 jz .mr9 ; ; if (mx) lda mx ora a jz .mr8 ; { dif &= 61; ;why did I do this? -- doesn't seem right ; mov a,c ; ani 61 ; mov c,a ; if (CMPRSSD & dif) mvi a,CMPRSSD call .mrTEST jnc .mr2 ; if (CMPRSSD & m) PTCH(15); else PTCH(18);; mvi a,15 jnz .mr1 mvi a,18 .mr1: call pr1 ; if (EMPHSZD & dif) .mr2: mvi a,EMPHSZD call .mrTEST jnc .mr4 ; if (EMPHSZD & m) {PTESCCH('E');} else PTESCCH('F');; mvi a,'E' jnz .mr3 mvi a,'F' .mr3: call presc1 .mr4: ; if (DBLSTRK & dif) mvi a,DBLSTRK call .mrTEST jnc .mr6 ; if (DBLSTRK & m) {PTESCCH('G');} else PTESCCH('H');; mvi a,'G' jnz .mr5 mvi a,'H' .mr5: call presc1 .mr6: ; if (EXPNDD & dif) mvi a,EXPNDD call .mrTEST ; { PTESCCH('W'); mvi e,'W' cc .mrTURN ; if (EXPNDD & m) PTCH(1); else PTCH(0); ; } ; } jmp .mr9 ; ; else ; { PTESCCH('!'); .mr8: mvi a,'!' call presc1 ; PTCH(m & 61); mov a,l ani 61 call pr1 ; } ; ; ; if (UNDRLN & dif) .mr9: mvi a,UNDRLN call .mrTEST ; { PTESCCH('-'); mvi e,'-' cc .mrTURN ; if (UNDRLN & m) PTCH(1); else PTCH(0); ; } ; if (PRPTNL & dif) ;.mr11: mvi a,PRPTNL call .mrTEST ; { PTESCCH('p'); mvi e,'p' cc .mrTURN ; if (PRPTNL & m) PTCH(1); else PTCH(0); ; } ; if (SUPSCRPT & dif) ;.mr13: mov a,b ;-- ani supscrpt shr 8 ani suBscrpt shr 8 jz .mr15 ; { if (SUPSCRPT & m) {PTESCCH('S'); PTCH(1);} mov a,h ;---- ani supscrpt shr 8 ani suBscrpt shr 8 jz .mr14 mvi a,'S' call presc1 mvi a,1 call pr1 jmp .mr15 ; else {PTESCCH('T');} ; } .mr14: mvi a,'T' call presc1 ; if (SUBSCRPT & dif) .mr15: mov a,b ;---- ani subscrpt shr 8 ani suPscrpt shr 8 jz .mr17 ; { if (SUBSCRPT & m) {PTESCCH('S'); PTCH(0);} mov a,h ;--- ani subscrpt shr 8 ani suPscrpt shr 8 jz .mr16 mvi a,'S' call presc1 xra a call pr1 jmp .mr17 ; else {PTESCCH('T');} ; } .mr16: mvi a,'T' call presc1 ; ; emode = m; ;} .mr17: shld emode .mrx: pop b ret .mrTURN: mov d,a mov a,e call presc1 mov a,d jmp pr1 .mrTEST: mov e,a ana c rz mov a,e ana l mvi a,0 cmc rz mvi a,1 ret .comment ` /************************************************/ /* Move print head to right by 'n' dots, */ /* underlining if 'fch' is true */ /************************************************/ hfill(n, fch) int n; char fch; { int i, lensp; if (!n) return; if (!(lensp = modelen[emode & 63])) { lensp = pmlen[' ']; if (emode & EXPNDD) lensp <<= 1; } while (n >= lensp) {PTCH(' '); n -= lensp;} if (mx) { n >>= 1; if (n) { PTESCCH('L'); PTCH(n); PTCH(0); while (n--) PTCH(0); } } else if (n) /* fch is TRUE for underscoring Epson font */ { if (fch) {PTESCCH('J'); PTCH(3);} PTESCCH('Z'); PTCH(n); PTCH(0); while (n--) PTCH(fch & 1); if (fch) {PTESCCH('j'); PTCH(3);} } } ` ;made internal -- fch in A, n in HL hfill: sta fch mov a,h ora l rz push b mov b,h mov c,l ;BC = n ; if (!n) return; ;(cf. above) ; ; if (!(lensp = modelen[emode & 63])) lda emode ani 63 mov e,a mvi d,0 lxi h,modelen dad d mov l,m mvi h,0 shld lensp mov a,l ora a jnz .hf1 ; { lensp = pmlen[' ']; lda pmlen + ' ' ;64f1 sta lensp ; if (emode & EXPNDD) lensp <<= 1; ; } mov l,a mvi h,0 ; lhld lensp lda emode ani EXPNDD jz .hf1 dad h shld lensp ; ; while (n >= lensp) {PTCH(' '); n -= lensp;} .hf1: ;DE = -lensp (throughout following loop) call cmh xchg .hf2: ;HL = -lensp mov h,d mov l,e ;HL = n - lensp dad b ;done if HL < 0 mov a,h ora a jm .hf3 ;else n = HL = n - lensp mov b,h mov c,l ;out SP mvi a,' ' call pr1 push d mvi a,' ' call termput## pop d ;loop jmp .hf2 ; ; if (mx) .hf3: lda mx ora a jz .hf6 ; { n >>= 1; ;(carry is clear) mov a,b rar mov b,a mov a,c rar mov c,a ; if (n) mov a,c ora a jz .hf5 ; { PTESCCH('L'); mvi a,'L' call presc1 ; PTCH(n); PTCH(0); mov a,c call pr1 xra a call pr1 ; while (n--) PTCH(0); ; } ; } .hf4: xra a call pr1 dcr c jnz .hf4 .hf5: pop b ret ; ; else ; if (n) .hf6: mov a,b ora c jz .hfx ; /* fch is TRUE for underscoring Epson font */ ; { if (fch) {PTESCCH('J'); PTCH(3);} lda fch ani 1 ;E = fch & 1 for later mov e,a ora a jz .hf7 mvi a,'J' call presc1 mvi a,3 call pr1 ; PTESCCH('Z'); .hf7: mvi a,'Z' call presc1 ; PTCH(n); PTCH(0); mov a,c call pr1 xra a call pr1 ; while (n--) PTCH(fch & 1); .hf8: mov a,e call pr1 dcr c jnz .hf8 ; if (fch) {PTESCCH('j'); PTCH(3);} mov a,e ora a jz .hfx mvi a,'j' call presc1 mvi a,3 call pr1 ; } ;} .hfx: pop b ret fch: dw 0 lensp: dw 0 .comment ` /************************************************/ /* Do a line of Epson native characters */ /************************************************/ nativeline() { int cumfill; char c; if (!epsflag) {skdots++; return; } cumfill = 0; /* don't underline to left of margin */ mreset(emode & ~UNDRLN); paperup(0); inover(); /* hfill(lindent[cc]+ad, FALSE); */ for (gsti = 0; gsti < outpoint; gsti++) { /* if graphics font, just fill */ if (attrbuf[gsti] & 0x700) cumfill += widbuf[gsti]; /* Is it a variable space? */ else if ((c = outbuf[gsti]) == ' ') { if (attrbuf[gsti] & UNDRLN) { hfill(cumfill, FALSE); hfill(widbuf[gsti], TRUE); cumfill = 0; } else cumfill += widbuf[gsti]; } else if (c == SOFTHY || c >= 0x7F) continue; else /* real Epson character */ { hfill(cumfill, FALSE); mreset(attrbuf[gsti]); cumfill = 0; if (c == rb) c = ' '; if (!widbuf[gsti]) PTCH('\b'); PTCH( (attrbuf[gsti] & ITALIC) | c); } } PTCH('\r'); skdots++; } ` nativeline:: push b ; if (!epsflag) {skdots++; return; } lda epsflag ora a jz .ntskX ; ; cumfill = 0; i1a70: lxi h,0 shld cumfill ; ; /* don't underline to left of margin */ ; mreset(emode & ~UNDRLN); lhld emode lxi d,not UNDRLN ;ffbf mov a,h ana d mov h,a mov a,l ana e mov l,a push h call mreset pop d ; paperup(0); lxi h,0 push h call paperup## pop d ; inover(); call inover xra a call hfill ; ; for (gsti = 0; gsti < outpoint; gsti++) lxi b,0 .ntLOOP: mov d,b mov e,c lhld outpoint call albs jnc i1c45 ; { /* if graphics font, just fill */ ; if (attrbuf[gsti] & 0x700) lhld attrbuf dad b dad b inx h mov a,m ani 7 jz i1aea ; cumfill += widbuf[gsti]; lhld widbuf dad b dad b mov e,m inx h mov d,m lhld cumfill dad d shld cumfill jmp .ntNXT ; ; /* Is it a variable space? */ ; else if ((c = outbuf[gsti]) == ' ') i1aea: lhld outbuf dad b mov a,m sta _ntc cpi HSFLAG jz .nt2 cpi SPFLAG jz .nt2 cpi ' ' jnz .nt5 .nt2: ; { if (attrbuf[gsti] & UNDRLN) lhld attrbuf dad b dad b mov a,m ani undrln ; jz .nt3 jnz .nt2a ;reset the mode, in case we have a non-underlined space, following ; an underlined real character mov e,a inx h mov d,m push d call mreset pop d jmp .nt3 ; { hfill(cumfill, FALSE); .nt2a: xra a lhld cumfill call hfill ; hfill(widbuf[gsti], TRUE); lhld widbuf dad b dad b mov e,m inx h mov d,m xchg mvi a,1 call hfill ; cumfill = 0; ; } lxi h,0 shld cumfill jmp .ntNXT ; else cumfill += widbuf[gsti]; ; } .nt3: lhld widbuf dad b dad b mov e,m inx h mov d,m lhld cumfill dad d shld cumfill .nt4: jmp .ntNXT ; ; else if (c == SOFTHY || c >= 0x7F) continue; .nt5: lda _ntc cpi SOFTHY jz .ntNXT cpi 7fh jnc .ntNXT ; ; else /* real Epson character */ ; { hfill(cumfill, FALSE); .nt6: xra a lhld cumfill call hfill ; mreset(attrbuf[gsti]); lhld attrbuf dad b dad b mov e,m inx h mov d,m push d call mreset pop d ; cumfill = 0; lxi h,0 shld cumfill ; if (c == rb) c = ' '; lxi h,_ntc lda rb cmp m jnz .nt7 mvi m,' ' ; if (!widbuf[gsti]) PTCH('\b'); .nt7: lhld widbuf dad b dad b mov a,m inx h ora m mvi a,8 cz pr1 ; PTCH( (attrbuf[gsti] & ITALIC) | c); ; } ; } .nt8: lhld attrbuf dad b dad b mov a,m ani italic lxi h,_ntc ora m call pr1 lda _ntc call termput## .ntNXT: inx b jmp .ntLOOP ; PTCH('\r'); i1c45: mvi a,0dh call pr1 ; skdots++; .ntskX: lhld skdots inx h shld skdots ;} .ntX: pop b ret cumfill: dw 0 _ntc: db 0 .comment * List output * prgpw: lhld gpoint ;PLUS some for indent ;;; xchg ;;; lhld _zlfill ;;; push h ;;; dad d ;;; call prw ; THEN print the word ; Then print the extra nuls ;;; pop h ;;;lfillz: ;;; mov a,h ;;; ora l ;;; rz ;;; xra a ;;; call pr1 ;;; dcx h ;;; jmp lfillz ;;;_zlfill: dw 0 prw: mov a,l call pr1 mov a,h jmp pr1 presc1:: push psw mvi a,1bh call pr1 pop psw pr1:: push b push h push d mov c,a lda noprint ora a _biopr: cz 0 ;filled in by mreset pop d pop h pop b ret end