home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / list / ep-src.ark / GCHR.MAC < prev    next >
Text File  |  1988-05-21  |  26KB  |  2,049 lines

  1.  
  2.     INCLUDE BDSYM.EQU
  3. ;    INCLUDE    EPSYM.EQU
  4.     INCLUDE    EPDATA
  5.  
  6.  
  7. ;    FUNCTION    GCHR
  8.     EXT        EPERROR,LOADFT
  9.  
  10.  
  11.  
  12.  
  13. ;/************************************************/
  14. ;/* Set the bits for 1/3 of one graphics char    */
  15. ;/************************************************/
  16. ;gchr(ix,pass)
  17. ;int ix, pass;
  18. ;{    int    len,    +00
  19. ;        i,    +02
  20. ;        j,    +04
  21. ;        cbase,    +06
  22. ;        gindex; +08
  23. ;    char    c,    +0AH
  24. ;        c0,    +0BH
  25. ;        c1,    +0CH
  26. ;        c2,    +0DH
  27. ;        charft,    +0EH
  28. ;        *ptft,    +0FH
  29. ;        ftn;    +11H
  30. ;(locals: 6 ints + 6 bytes = 18 bytes)
  31. ;        (bc)    +12H
  32. ;        (ret)    +14H
  33. ;        ix    +16H
  34. ;        pass    +18H
  35. gchr::
  36.  
  37.     pop    d
  38.     pop    h
  39.     shld    ix
  40.     mov    a,l
  41.     ora    h
  42.     jnz    gc0
  43.     shld    lstlen
  44. gc0:    pop    h
  45.     mov    a,l
  46.     sta    pass
  47.     add    a
  48.     add    a
  49.     add    a
  50.     sta    pix    ;for use by dotset
  51.     push    h
  52.     push    h
  53.     push    d
  54.  
  55.     push    b
  56.  
  57.     LHLD    WIDBUF
  58.     XCHG
  59.  
  60.     lhld    ix
  61.     dad    h
  62.     dad    d
  63.  
  64.     mov    a,m
  65.     inx    h
  66.     mov    h,m
  67.     mov    l,a
  68.     shld    widix    ;for later
  69. ;
  70. ;    /* get char out of buffer        */
  71. ;    c = outbuf[ix];
  72.     LHLD    OUTBUF
  73.     XCHG
  74.  
  75.     lhld    ix
  76.     dad    d    ;= (outbuf) + (ix)
  77.     mov    a,m
  78.     sta    ch    
  79.  
  80. ;
  81. ;    /* skip soft hyphen & flag chars    */
  82. ;    if (c == SOFTHY || c >= 0x7F) return;
  83.  
  84. ;(ch still in acc)
  85.     cpi    SOFTHY    ;1EH
  86.     jz    gchrret
  87.  
  88.     cpi    SPFLAG
  89.     jnz    g1
  90.     mvi    a,' '
  91.     sta    ch
  92. g1:    cpi    HSFLAG
  93.     jz    g2
  94.     cpi    7FH
  95.     jnc    gchrret
  96.  
  97.  
  98. g2:
  99.     cpi    newlin
  100.     jz    g2.1
  101.     mov    e,a
  102.     lda    tabottom
  103.     ora    a
  104.     jz    g2.1
  105.     lda    pass
  106.     dcr    a
  107.     jnz    g2.1
  108.     mov    a,e
  109.     cpi    ' '
  110.     jnz    g2.0
  111.     lhld    widix
  112. g2.sp:    push    h
  113.     mvi    a,' '
  114.     call    termput##
  115.     pop    h
  116.     lxi    d,-PICA
  117.     dad    d
  118.     mov    a,h
  119.     ora    a
  120.     jp    g2.sp
  121.     jmp    g2.1
  122. g2.0:    call    termput##
  123. g2.1:
  124. ;
  125. ;    /* what font?                */
  126. ;    charft = 7 & (attrbuf[ix] >> 8);
  127.  
  128.     LHLD    ATTRBUF
  129.     XCHG
  130.  
  131.     lhld    ix
  132.     dad    h
  133. ;ix word
  134.     dad    d
  135.     mov    e,m
  136.     inx    h
  137.     mov    d,m
  138. ;attrbuf[ix]
  139. ;+    for later
  140.     mov    b,d
  141.     mov    c,e
  142. ;    shld    attrix
  143.     mov    a,d
  144. ;    lxi    d,8
  145. ;    call    SHLRBE
  146. ;>> 8
  147. ;+
  148.     ani    7
  149. ;& 7
  150.     sta    charft
  151. ;charft =
  152. ;
  153.  
  154. ;    /* if not in font, or native Epson font,
  155. ;       or required blank, make it a space    */
  156. ;    if (!charft || c < ' ' || c == rb) c = ' ';
  157. ;/*(change to allow c < SP) */
  158.  
  159.     ora    a
  160. ;$$    jz    i31f0
  161.     jz    i322.sp
  162.     dcr    a    ;for later
  163.     sta    ftn
  164. ;!charft
  165.     lda    ch
  166. ;new June '84
  167.     cpi    HSFLAG
  168. ;$$    jz    i31f0
  169.     jz    i322.sp
  170.  
  171. ;    cpi    ' '
  172. ;    jc    i31f0
  173. ;c < ' '
  174.     lhld    rb    ;rb
  175.     cmp    l
  176.     jz    i322.sp
  177. ;$$    jnz    i31f6
  178. ;== rb
  179. ;$$i31f0:
  180. ;$$    mvi    a,' '
  181. ;$$    sta    ch
  182. ; c = ' '
  183.  
  184. ;
  185. ;    /* if 1st 3 of passes and not tall char, just space    */
  186. ;    if (!tabottom && !(attrbuf[ix] & TALL))  c = ' ';
  187. ;
  188. i31f6:
  189. ;also if 1st big duplex pass & not duplex
  190.     lda    tduplex
  191.     cpi    2
  192.     jnz    i31f6a
  193.     mov    a,c
  194.     ani    PRPTNL
  195.     jz    i322.sp
  196.  
  197. i31f6a:
  198.     lda    tabottom
  199.     ora    a
  200.     jnz    i3229
  201.  
  202. ;!tabottom
  203. ;    lhld    attrix
  204.     mov    a,b
  205.     ani    40H
  206. ;    attrix & 4000H
  207. ;TALL
  208.     jnz    i3229
  209.  
  210. ;... and add: also sp if cheight > 16p 
  211.  
  212. ;if alignment requested, keep non-tall char
  213.     LDA    ALIGN
  214.     ORA    A
  215.     JNZ    i3229
  216.  
  217.  
  218. i322.sp:
  219.     mvi    a,' '
  220.     sta    ch
  221. ;c = ' '
  222.  
  223.  
  224. ;    /* if it's a space, just move pointer over    */
  225. ;    if (c == ' ')
  226. ;    {    gpoint += widbuf[ix];
  227. ;        return;
  228. ;    }
  229.  
  230. i3229:
  231. ;also treat all as space if noprint
  232.     lda    noprint
  233.     ora    a
  234.     jnz    i3229a
  235.  
  236.     lda    ch
  237.     cpi    ' '
  238.     jnz    i3257
  239. ;c = ' ' ??
  240. i3229a:
  241.     lhld    gpoint
  242.     xchg
  243.     lhld    widix
  244.     shld    lstlen
  245.     dad    d
  246.     shld    gpoint
  247.     jmp    gchrret
  248.  
  249. i3257:
  250.  
  251. ;
  252. ;    /* which font to use? number of graphics font is 0-7,
  253. ;        corresponding to 'fo' value of 1-8    */
  254. ;    ftn = charft - 1;
  255.  
  256. ;    lda    charft
  257. ;    dcr    a
  258. ;done    sta    ftn
  259.  
  260. ;    /* ... and where is the font?            */
  261. ;    if (!ftp[ftn]) /* reload if necessary */
  262.  
  263.     lda    ftn
  264.     mov    l,a
  265.     mvi    h,0
  266.     dad    h
  267. ;ftn word
  268.     lxi    d,ftp
  269.     dad    d
  270.     push    h
  271.     mov    e,m
  272.     inx    h
  273.     mov    d,m
  274.  
  275.     pop    h
  276.     xchg    
  277.     mov    a,h
  278. ;ftp[ftn]
  279.     ora    l
  280.     jnz    i329c
  281.  
  282. ;     if (loadft(ftn) == ERROR) eperror(120+ftn);
  283.  
  284.     push    d    ;save addr. font location
  285.     lda    ftn
  286.     mov    l,a
  287.     mvi    h,0
  288.     push    h
  289.     call    loadft
  290.     pop    d
  291.     inx    h
  292.     mov    a,h
  293.     ora    l
  294.     pop    h
  295.     jnz    i329c0
  296. ;== ERROR
  297.     lda    ftn
  298.     adi    120
  299.     mov    l,a
  300.     mvi    h,0
  301. ;+120
  302.     push    h
  303.     call    eperror    ;never returns
  304. ;;    pop    d
  305.  
  306.  
  307. shftdup:
  308. ;check for duplex font
  309. ;(change here, since stowc will now leave mode prptnl for duplex)
  310.  
  311. ;;    lda    ftn
  312. ;;    mov    h,a
  313. ;;    mvi    l,0
  314. ;;    lxi    d,fix
  315. ;;    dad    d
  316. ;;    mvi    a,PRPTNL
  317. ;;    ana    m
  318.     mov    a,c
  319.     ani    PRPTNL
  320.     rz
  321.  
  322. ;***
  323.     lda    tduplex
  324.     ora    a
  325.     jz    .sdup3
  326. ;if tduplex=2, treat as though tabottom=0,
  327. ;if tduplex=1, treat as though tabottom=1.
  328.     ani    1
  329.     mov    l,a
  330.     jmp    .sdup4
  331.  
  332.  
  333. .sdup3:
  334. ;***
  335.  
  336.     mov    a,b        ;pretend not tall
  337.     ani    not (TALL shr 8)    ;0BFH
  338.     mov    b,a
  339.     lhld    tabottom    ;L = tabottom, for later test
  340. .sdup4:
  341.     lda    ch
  342.     mov    h,a
  343.     cpi    5FH    ;should change to a sp if not tabottom
  344.     rz
  345. ;if ch < 20H and top, shift up
  346.     cpi    20H
  347.     rz
  348.     jnc    dup1
  349.     mov    a,l
  350.     ora    a
  351.     rnz
  352. dup4:    mov    a,h
  353.     adi    20H
  354.     jmp    dup
  355. ;if ch >= 60H and top, shift down
  356. dup1:    cpi    60H
  357.     jc    dup2
  358.     mov    a,l
  359.     ora    a
  360.     rnz
  361. dup3:    mov    a,h
  362.     sui    20H
  363. ;;    jmp    dup
  364. dup:    sta    ch
  365.     ret
  366. ;if 21H <= ch <= 5F and top, no shift, 
  367. dup2:    mov    a,l
  368.     ora    a
  369.     rz
  370. ;otherwise when bottom, shift up if >= 40H, or shift down if less
  371.     mov    a,h
  372.     cpi    40H
  373.     jc    dup3
  374.     jmp    dup4
  375.  
  376.  
  377.  
  378.  
  379.  
  380. ;    ptft = ftp[ftn];
  381. ;
  382. i329c0:
  383.     mov    e,m    ;reload ptr after
  384.     inx    h    ;loadft call
  385.     mov    d,m
  386.     xchg
  387.  
  388. i329c:
  389. ;ftp[ftn]
  390.     shld    ptft
  391.  
  392.     call    shftdup
  393.  
  394. ndup:
  395.  
  396.  
  397. ;ptft =
  398.  
  399. ;    /* where to start laying in the black        */
  400. ;    gindex = gpoint;
  401.  
  402.     lhld    gpoint
  403.     shld    gindex
  404.  
  405. ;    /* update for next dots after these        */
  406. ;    gpoint += widbuf[ix];
  407. ;
  408.  
  409. ;    lhld    gpoint
  410.     xchg
  411.     lhld    widix
  412.     dad    d
  413. ;check not > 1920 = 780H
  414.     mov    a,h
  415.     cpi    GBUFSIZ shr 8    ;was 7
  416.     jc    twok
  417.     jnz    gchrret
  418.     mov    a,l
  419.     cpi    GBUFSIZ and 0FFH    ;was 80H
  420.     jnc    gchrret
  421. twok:    shld    gpoint
  422.  
  423. ;    /* what width?                    */
  424. ;    len = ftlen[ftn][c];
  425. ;
  426. ;or:
  427.     lda    ftn
  428.     ora    a
  429.     rar
  430.     mov    h,a
  431.     mvi    a,0
  432.     rar
  433.     mov    l,a
  434.  
  435. ;-    lda    ftn
  436. ;-    mov    l,a
  437. ;-    mvi    h,0
  438. ;ftn
  439. ;-    lxi    d,80H
  440. ;-    call    USMUL
  441.     lxi    d,ftlen
  442.     dad    d
  443.     xchg
  444.     lda    ch
  445.     mov    l,a
  446.     mvi    h,0
  447. ;c
  448.     dad    d
  449.     mov    a,m
  450.     sta    len
  451. ;len =
  452.  
  453. ;    /* if width is 0, overprint            */
  454. ;    if (!widbuf[ix]) gindex -= widbuf[ix-1];
  455.  
  456.     lhld    widix
  457.     mov    a,h
  458.     ora    l
  459.     jnz    i334d
  460. ;!widbuf[ix] ??
  461. ;gindex
  462.     LHLD    WIDBUF
  463.     XCHG
  464.  
  465.     lhld    ix
  466.     dcx    h
  467. ;check not neg
  468.     mov    a,h
  469.     ora    a
  470.     jm    i334d
  471. ;ix-1
  472.     dad    h
  473.     dad    d
  474.     MOV    E,M
  475.     INX    H
  476.     MOV    D,M
  477.     call    cmd
  478.     lhld    gindex
  479.     dad    d
  480.     push    h
  481.  
  482.     lhld    lstlen
  483.     xchg
  484.     lhld    len
  485.     mvi    h,0
  486.     call    cmh
  487.     dad    d
  488.     lxi    d,2
  489.     xchg
  490.     call    sdiv
  491.     xchg
  492.     pop    h
  493.     dad    d
  494.     shld    gindex
  495. ;gpoint =
  496.     jmp    i33b2
  497.  
  498. ;    /* if non-proportional, center in char field    */
  499. ;    else if (cw) gindex += (j = (widbuf[ix] - len) / 2) > 0 ? j : 0;
  500. ;        /* bad way to test - can be sync problem */
  501. ;
  502. ;
  503.  
  504. i334d:
  505. ;store st and sw in temporary locations
  506.     lhld    st
  507.     shld    _st
  508.     lhld    sh
  509.     shld    _sh
  510.  
  511. ;no fixed cw if graphic
  512.     lda    len
  513.     inr    a
  514.     jz    i33b2
  515.  
  516.     lhld    cw
  517.     mov    a,h
  518.     ora    l
  519.     jz    i33b2
  520. ;here fixed cw request
  521.  
  522. ;desired new ink width is recorded width - character-spacing
  523. ;(here we neglect shrink or stretch of cs itself)
  524.  
  525.     lhld    widix
  526.     xchg
  527.     lhld    cs
  528.     call    cmh
  529.     dad    d
  530. ;check for cs > cw
  531.     mov    a,h
  532.     ora    a
  533.     jm    i33b2
  534.  
  535. ;;Tried calling wadjust -- Worse than before
  536. ;;;new -- if high is > 1, use max stretch
  537. ;;;(try to prevent overflow in rest of calc.)
  538. ;;    dcr    a
  539. ;;    dcr    a
  540. ;;    jm    .gcw1
  541. ;;    mvi    a,200
  542. ;;    jmp    .gcw5
  543. ;;.gcw1:
  544.  
  545. ;;;new vers -- ready to take percent change
  546. ;;    lxi    d,100
  547. ;;    call    usmul
  548.  
  549. ;old ink width is in len -- take difference
  550.     lda    len
  551.     mov    e,a
  552.     mvi    d,0
  553. ;;;new - round and get percent change
  554. ;;    dcx    d
  555. ;;    dad    d
  556. ;;    inx    d
  557. ;;    xchg
  558. ;;    call    usdiv
  559. ;;;now wadjust calculates desired st and sh
  560. ;;    mov    a,l
  561. ;;.gcw5:
  562. ;;    call    wadjust##
  563. ;;    shld    _st
  564. ;;    xchg
  565. ;;    shld    _sh
  566.  
  567.     push    d    ;save len for a moment
  568.  
  569.     call    cmd
  570.     dad    d
  571.  
  572. ;if positive, we want to stretch
  573.     mov    a,h
  574.     ora    a
  575.     pop    d    ;get len back
  576. ;remember sign
  577.     push    psw
  578.     jm    .gcw6
  579. ;if positive and diff. > len, max stretch will be insufficient,
  580. ; and we should center it (if diff = len, center vacuously)
  581.     call     albu
  582.     jnc    .gcw7
  583.     call    cmd
  584.     dad    d
  585. ;HL = diff - len, which is amount that cannot be done by stretching
  586.     mvi    e,1
  587.     call    shlrbe
  588.     xchg
  589.     lhld    gindex
  590.     dad    d
  591.     shld    gindex
  592. ;now it's centered -- go stretch by maximum
  593.     lxi    h,1
  594.     jmp    .gcw8
  595.  
  596. .gcw6:
  597. ;get absolute value
  598.     call    cmh
  599. .gcw7:
  600. ;st or sh = old-ink / |new-ink - old-ink|
  601.     push    h
  602.     xchg
  603.     lhld    widix
  604. ;round up
  605.     dcx    d
  606.     dad    d
  607.     xchg
  608.     pop    h
  609.     call    usdiv
  610. .gcw8:
  611. ;other value will be 0
  612.     lxi    d,0
  613.     pop    psw
  614.     jp    $+4
  615.     xchg
  616.  
  617. ;(if stretching, shouldn't allow stretch 0 -- can we get that here?)
  618.  
  619.     shld    _st
  620.     xchg
  621. ;don't allow shrink 1
  622.     mov    a,l
  623.     dcr    a
  624.     jnz    $+4
  625.     inx    h
  626.     shld    _sh
  627.  
  628.  
  629.  
  630.  
  631.     .comment    `
  632. Real old code for cw ...
  633. (it would still be nice to do a little centering) <-- now done
  634.     lhld    widix
  635.     xchg
  636.     lda    len
  637.     mov    l,a
  638.     mvi    h,0
  639. ;len
  640.     call    CMH
  641.     dad    d
  642. ;widbuf[ix] - len
  643.     mov    a,h
  644.     ora    a
  645.     jm    i33b2
  646.     rar
  647.     mov    h,a
  648.     mov    a,l
  649.     rar
  650.     mov    l,a
  651.  
  652.     xchg
  653.     lhld    gindex
  654.     dad    d
  655.     shld    gindex
  656.         `
  657.  
  658. i33b2:
  659.     lda    len
  660.     sta    lstlen
  661.  
  662. ;    /* where do the bits start in the font?        */
  663. ;    cbase = fix[ftn][c] + pass*len;
  664. ;
  665.     lda    ftn
  666.  
  667.     mov    h,a
  668.     mvi    l,0
  669.     lxi    d,fix
  670.     dad    d
  671.  
  672.     xchg
  673.     lda    ch
  674.     mov    l,a
  675.     mvi    h,0
  676.     dad    h
  677.     dad    d
  678.  
  679.     mov    e,m
  680.     inx    h
  681.     mov    d,m
  682. ;fix[ftn][c]
  683.     lhld    ptft
  684.     dad    d
  685.     shld    ptft0
  686.  
  687.     lda    len
  688. ;graph char only 1 pass
  689.     cpi    0ffh
  690.     jnz    $+4
  691.     xra    a
  692.     mov    e,a
  693.     mvi    d,0
  694.     dad    d
  695.     shld    ptft1
  696.     dad    d
  697.  
  698. ;exchange 1st and 3rd pass data if bent and upside down or gothic
  699.     mov    a,b
  700.     ani    BENT shr 8
  701.     jz    i33b.nb
  702.     lda    be+1
  703.     ani    30H
  704.     jz    i33b.nb
  705.     xchg
  706.     lhld    ptft0
  707.     xchg
  708.     shld    ptft0
  709.     xchg
  710. i33b.nb:
  711.     shld    ptft2
  712.  
  713. ;and another little change for graph char
  714.     xra    a
  715.     sta    len+1
  716.     lxi    h,450
  717.     lda    len
  718.     cpi    0ffh
  719.     jnz    $+6
  720.     shld    len
  721.  
  722. ;    /* move the dots into the output graphics buffer    */
  723. ;    for (i = cbase; i < cbase + len; i++)
  724.  
  725. ;**-> for ( ; len; len--)
  726. ;i < cbase + len ff.
  727. i3400:
  728.     lhld    len
  729.     mov    a,h
  730.     ora    l
  731.     jz    gchrret
  732.     dcx    h
  733.     shld    len
  734.  
  735. ;    {    c = ptft[i];
  736. ;
  737. ;**-> c = ptft0 if pass 0, = ptft1 if pass 1, = ptft2 if pass 2
  738.  
  739.     lhld    ptft0
  740.     mov    a,m
  741.     sta    c0
  742.     sta    ch
  743.     lhld    ptft1
  744.     mov    a,m
  745.     sta    c1
  746.     lhld    ptft2
  747.     mov    a,m
  748.     sta    c2
  749.  
  750. ;For tall and cheight > 8 points but not 16-<24p,
  751. ;  stretch up as per char. height
  752.     mov    a,b
  753.     ani    40H
  754.     jz    i33nt
  755.     lda    cheight
  756.     cpi    3*8+1
  757.     jc    i33nt
  758.     cpi    3*16
  759.     jc    i33ts
  760.     cpi    3*24
  761.     jc    i33nt
  762. i33ts:    push    b
  763.     call    canon
  764.     call    hidots
  765.     call    decanon
  766.     pop    b
  767.     lda    c0
  768.     sta    ch
  769. i33nt:
  770.     lda    pass
  771.     ora    a
  772.     jz    i3400c
  773.     dcr    a
  774.     jz    i3400a
  775.     lda    c2
  776.     jmp    i3400b
  777. i3400a:    lda    c1
  778. i3400b:    sta    ch
  779. i3400c:
  780.  
  781. ;c =
  782. ;        /* modify vertical format of char        */
  783. ;        if
  784. ;        (    fa
  785. ;            || attrbuf[ix]
  786. ;               & (    SUPSCRPT | SUBSCRPT | DBLSTRK | TALL)
  787. ;        )
  788. ;
  789. ;(should fix tall super- and subscripts)
  790.     lda    fa    ;fa
  791.     ora    a
  792.     jnz    i3468
  793. ;fa ??
  794. ;    lhld    attrix
  795. ;    lxi    d,5810H    ;0101100000010000
  796.  
  797.     mov    a,b
  798.     ani    58H
  799.     mov    h,a
  800.     mov    a,c
  801.     ani    10H
  802.     ora    h
  803.     jz    i37cb
  804.  
  805. ;        {    j = i - pass*len;
  806. i3468:
  807. ;*-> nothing, work done already
  808. ;done            c0 = ptft[j];
  809. ;done            c1 = ptft[j + len];
  810. ;done            c2 = ptft[j + len + len];
  811. ;            if (attrbuf[ix] & DBLSTRK)
  812.  
  813. ;    lhld    attrix
  814. ;    lda    attrix
  815.     mov    a,c
  816.     ani    10H
  817.     jz    i35be
  818. ;disable double striking for tall char?
  819. ;    MOV    A,B
  820. ;    ANI    40H
  821. ;    JNZ    i35be
  822. ;            {    c = c1;
  823.     lxi    h,c1
  824.     mov    a,m
  825.     sta    ch
  826. ;                c1 |= c0;
  827. ;    lxi    h,c1
  828.     lda    c0
  829.     ora    m
  830.     mov    m,a
  831.  
  832. ;                c0 |= c2 >> 1;
  833.     lxi    h,c0
  834.     lda    c2
  835.     ora    a
  836.     rar
  837.     ora    m
  838.     mov    m,a
  839.  
  840. ;                c2 |= c;
  841.     lxi    h,c2
  842.     lda    ch
  843.     ora    m
  844.     mov    m,a
  845.  
  846. ;                if (!pass) c = c0;
  847.     lda    pass
  848.     ora    a
  849.     jnz    i3597
  850.  
  851.     lda    c0
  852. ;    sta    ch
  853.  
  854.     jmp    i35b3x
  855.  
  856.  
  857. ;                else if (pass == 1) c = c1; else c = c2;
  858. ;            }
  859. i3597:
  860.     dcr    a
  861.     ora    a
  862.     jnz    i35b3
  863. ;pass == 1 ??
  864.     lda    c1
  865. ;    sta    ch
  866. ;c = c1
  867.     jmp    i35b3x
  868.  
  869. i35b3:
  870.     lda    c2
  871. i35b3x:    sta    ch
  872. ;c = c2
  873.  
  874. ;            if (attrbuf[ix] & (SUPSCRPT | SUBSCRPT))
  875.  
  876. i35be:
  877.  
  878. ;    lda    attrix+1
  879.     mov    a,b
  880.     ani    18H
  881. ;    lxi    d,1800H...
  882.     jz    i3743
  883. ;if TALL superscript, no shrinking ...
  884.     mov    a,b
  885.     ani    40H
  886.     jz    i35ss
  887.     mov    a,b
  888.     ani    10H
  889.     jz    i35ss
  890.     lda    tabottom
  891.     ora    a
  892.     jz    i37cb
  893.     xra    a
  894.     sta    ch
  895.     jmp    i37cb
  896.  
  897. i35ss:
  898. ;            {    if (!pass) c2 = 0;
  899.  
  900.     lda    pass
  901.     ora    a
  902.     jnz    i35f9
  903.     sta    c2
  904.     jmp    i3649
  905. ;                else if (pass == 1)
  906. ;                    {c1 = 0; c0 <<= 1;}
  907. i35f9:
  908. ;    lda    pass
  909.     dcr    a
  910.     jnz    i361c
  911. ;pass == 1 ??
  912.     sta    c1
  913. ;c1 = 0
  914.     lda    c0
  915.     add    a
  916.     sta    c0
  917. ;c0 <<= 1
  918.     jmp    i3649
  919. ;                else if (pass == 2)
  920. ;                -> else
  921. i361c:
  922. ;    dcr    a
  923. ;    jnz    i3649
  924. ;                    {c0 = 0; c1 <<= 1; c2 <<= 1;}
  925.     xra    a
  926.     sta    c0
  927. ;c0 = 0
  928.     lda    c1
  929.     add    a
  930.     sta    c1
  931. ;c1 <<= 1
  932.     lda    c2
  933.     add    a
  934.     sta    c2
  935. ;c2 <<= 1
  936. ;                c = c0 | c1 | c2;
  937. i3649:
  938.     lda    c0
  939.     lxi    h,c1
  940.     ora    m
  941.     lxi    h,c2
  942.     ora    m
  943. ;    sta    ch
  944. ;                c = (c & 128) |
  945.     mov    h,a
  946.     ani    80H
  947.     mov    l,a
  948. ;                    ((c << 1) & 64) |
  949.     mov    a,h
  950.     add    a
  951.     mov    h,a
  952.     ani    40H
  953.     ora    l
  954.     mov    l,a
  955. ;                    ((c << 2) & 32) |
  956.     mov    a,h
  957.     add    a
  958.     mov    h,a
  959.     ani    20H
  960.     ora    l
  961.     mov    l,a
  962. ;                    ((c << 3) & 16);
  963.     mov    a,h
  964.     add    a
  965.     ani    10H
  966.     ora    l
  967.  
  968.     sta    ch
  969. ;c =
  970. ;                if (attrbuf[ix] & SUBSCRPT) c >>= 2;
  971. ;    lda    attrix+1
  972.     mov    a,b
  973.     ani    10H    ;attrix & 1000H
  974.     jz    i370d
  975.  
  976.     lda    ch
  977.     rar
  978.     rar
  979.     ani    3FH
  980.     sta    ch
  981. ;                if (!(attrbuf[ix] & SUPSCRPT)) c >>= 2;
  982. ;            }
  983. i370d:
  984. ;    lda    attrix+1
  985.     mov    a,b
  986.     ani    8    ;attrix & 0800H
  987.     jnz    i3743
  988.  
  989.     lda    ch
  990.     rar
  991.     rar
  992.     ani    3FH
  993.     sta    ch
  994. ;            if (attrbuf[ix] & TALL)
  995. i3743:
  996. ;    lda    attrix+1
  997.     mov    a,b
  998.     ani    40H    ;attrix & 4000H
  999.     jz    i3799
  1000. ;double height for 0..8points or 16..<24 points
  1001.     lda    cheight
  1002.     cpi    3*24
  1003.     jnc    i3799
  1004.     cpi    3*8+1
  1005.     jc    i37tt
  1006.     cpi    3*16
  1007.     jc    i3799
  1008. i37tt:
  1009. ;             c = maketall(pass,c0,c1,c2);
  1010. ;maketall references now global
  1011.     call    maketall
  1012.     jmp    i37cb
  1013.  
  1014. ;            else if (fa) c = c0 | c1 | c2;
  1015. ;        }
  1016. i3799:
  1017.     lhld    fa    ;fa
  1018.     mov    a,h
  1019.     ora    l
  1020.     jz    i37cb
  1021.  
  1022.     lda    c0
  1023.     lxi    h,c1
  1024.     ora    m
  1025.     lxi    h,c2
  1026.     ora    m
  1027.     sta    ch
  1028.  
  1029. ;
  1030. ;        dotset(attrbuf[ix], gindex++, pass << 3, c);
  1031. i37cb:
  1032. ;2nd parm now passed in HL, others global
  1033.     lhld    gindex
  1034.  
  1035. ;if no dots, skip down to gindex adjustments
  1036.     LDA    CH
  1037.     ORA    A
  1038.     JNZ    i37tg
  1039.     INX    H
  1040.     SHLD    GINDEX
  1041.     JMP    i38c4
  1042.  
  1043. i37tg:
  1044. ;align non-tall characters in tall lines
  1045.     mov    a,b
  1046.     ani    40H
  1047.     jnz    i37dt    ;not if tall
  1048.     mov    a,c
  1049.     ani    PRPTNL
  1050.     jnz    i37dt    ;not if duplex
  1051.  
  1052.     lda    tallflag
  1053.     ora    a
  1054.     jz    i37dt    ;not if line not tall
  1055.     lda    align
  1056.     ora    a
  1057.     jz    i37dt    ;not if no alignment request
  1058.     mov    e,a
  1059.     lhld    ch
  1060.     mvi    h,0
  1061.     call    shllbe
  1062.     lda    tabottom
  1063.     ora    a
  1064.     jnz    alg1
  1065.     mov    l,h
  1066. alg1:    mov    a,l
  1067.     sta    ch
  1068.     lhld    gindex
  1069. i37dt:
  1070.     push    h
  1071.     call    dotset
  1072.     pop    h
  1073.     inx    h
  1074.     shld    gindex
  1075. ;
  1076. ;        if (attrbuf[ix] & EMPHSZD)
  1077.  
  1078. ;    lda    attrix
  1079.     mov    a,c
  1080.     ani    8
  1081.     jz    i38c4
  1082. ;        {    j = (bo << 1) -1;
  1083. ;            if (j < 0) j = 1;
  1084.     LDA    BO
  1085.     ora    a
  1086.     JNZ    I3853
  1087.     INR    A
  1088.  
  1089. ;            for ( ; j > 0; j--,j--)
  1090. i3853:
  1091.     MVI    L,1
  1092.     MOV    H,A
  1093. i385l:
  1094.     PUSH    H
  1095.     MVI    H,0
  1096.  
  1097.  
  1098.     .comment    `
  1099. May as well give up on this.
  1100.     lda    callig
  1101.     ora    a
  1102.     jz    i385m
  1103.  
  1104.     push    h
  1105. ;index + 1 pass for each level of emphasis
  1106.     lda    pass
  1107.     mov    e,a
  1108.     mvi    d,0
  1109.     dad    d
  1110.     push    h
  1111.     xchg
  1112.     lxi    h,3
  1113.     call    usmod
  1114.     xchg
  1115.     lxi    h,c0
  1116.     dad    d
  1117.     mov    l,m
  1118.     mvi    h,0
  1119. ;shift left 1 every 3rd level of emphasis
  1120.     pop    d
  1121.     push    h
  1122.     lxi    h,3
  1123.     call    usdiv
  1124.     xchg
  1125.     pop    h
  1126.     call    shllbe
  1127.     mov    a,l
  1128.  
  1129.     sta    ch
  1130.     pop    h
  1131. ;;    JMP    I385N
  1132.     jmp    $+4
  1133.             `
  1134.  
  1135.  
  1136.  
  1137. i385m:    DAD    H
  1138.     DCX    H
  1139. i385n:
  1140. ;            dotset(attrbuf[ix], gindex + j, pass << 3, c);
  1141. ;        }
  1142.     xchg
  1143.     lhld    gindex
  1144.     dad    d
  1145.  
  1146.     call    dotset
  1147. ;((... j--,j--
  1148.  
  1149.     POP    H
  1150.     INR    L
  1151.     DCR    H
  1152.     JNZ    I385L
  1153.  
  1154.  
  1155. ;        if (attrbuf[ix] & EXPNDD) gindex++;
  1156. i38c4:
  1157.     lhld    gindex
  1158.     push    h
  1159.  
  1160. ;    lda    attrix
  1161.     mov    a,c
  1162.     ani    20H    ;& 0020H
  1163.     jz    i38f4
  1164.     pop    h
  1165.     inx    h
  1166.     push    h
  1167. ;        if (attrbuf[ix] & CMPRSSD && i % 4 == 1) gindex--;
  1168. i38f4:
  1169.  
  1170. ;    lda    attrix
  1171.     mov    a,c
  1172.     ani    4
  1173.     jz    i3939
  1174.  
  1175.     lda    ptft0    ;no longer use i
  1176.     ani    3
  1177.     dcr    a
  1178.     jnz    i3939
  1179.  
  1180.     pop    h
  1181.     dcx    h
  1182.     push    h
  1183.  
  1184. ;        if (attrbuf[ix] & ELITE   && i % 5 == 3) gindex--;
  1185. i3939:
  1186. ;    lda    attrix
  1187.     mov    a,c
  1188.     ani    1
  1189.     jz    i3980
  1190.     lhld    ptft0
  1191.     lxi    d,5
  1192.     xchg
  1193.     call    USMOD
  1194.     dcx    h
  1195.     dcx    h
  1196.     dcx    h
  1197.     mov    a,h
  1198.     ora    l
  1199.     jnz    i3980
  1200.  
  1201.     pop    h
  1202.     dcx    h
  1203.     push    h
  1204. ;        if (sh && !(i % sh)) gindex--;
  1205. i3980:
  1206.     lhld    _sh
  1207.     mov    a,h
  1208.     ora    l
  1209.     jz    i39a8
  1210.     xchg
  1211.     lhld    ptft0
  1212.     xchg
  1213.     call    USMOD
  1214.     mov    a,h
  1215.     ora    l
  1216.     jnz    i39a8
  1217.  
  1218.     pop    h
  1219.     dcx    h
  1220.     push    h
  1221. ;        if (st && !(i % st)) gindex++;
  1222. i39a8:
  1223.     lhld    _st
  1224.     mov    a,h
  1225.     ora    l
  1226.     jz    i39d0
  1227.  
  1228.     xchg
  1229.     lhld    ptft0
  1230.     xchg
  1231.     call    USMOD
  1232.     mov    a,h
  1233.     ora    l
  1234.     jnz    i39d0
  1235.  
  1236.     pop    h
  1237.     inx    h
  1238.     push    h
  1239. ;    }
  1240. ;}
  1241. ;
  1242.  
  1243. i39d0:
  1244.     pop    h
  1245.     shld    gindex
  1246.  
  1247.     lhld    ptft0
  1248.     inx    h
  1249.     shld    ptft0
  1250.     lhld    ptft1
  1251.     inx    h
  1252.     shld    ptft1
  1253.     lhld    ptft2
  1254.     inx    h
  1255.     shld    ptft2
  1256.  
  1257.     jmp    i3400
  1258.  
  1259. gchrret:
  1260.     pop    b
  1261.     ret
  1262.  
  1263.  
  1264. ;
  1265. ;dotset(kind, gindex, pix, c)
  1266. ;int        kind,    +08 === attrbuf[ix]
  1267. ;        gindex,    +0A === gindex or gindex + j
  1268. ;        pix;    +0C === pass << 3
  1269. ;char        c;    +0E === c
  1270. ;{    int    bx,    +00
  1271. ;        power;    +02
  1272. ;
  1273.  
  1274. dotset:
  1275.     shld    dtgindex
  1276.  
  1277. ;    if (kind & BENT)
  1278.     mov    a,b
  1279. ;    lda    attrix+1
  1280.     ani    20H    ;& 2000H
  1281.     jz    i3b17
  1282. ;;    LDA    BE
  1283. ;;    ORA    A
  1284. ;;    JZ    I3B17
  1285.  
  1286. ;Now mode is bent and bend > 0
  1287. ;    for (bx = 0, power = 1; bx < 8; bx++, power <<= 1)
  1288.  
  1289.     xra    a
  1290.     sta    bx
  1291.     inr    a
  1292.     sta    power
  1293. ;bx = 0
  1294. ;power = 1
  1295.  
  1296.  
  1297. ;start of loop for bent chars
  1298.  
  1299. i3a14:
  1300. ;(test now at end)
  1301. ;    {    if (kind & ITALIC)
  1302. ;        gbuf[gindex + bx + bending[be-1][pix + bx]] |= power & c;
  1303.  
  1304.     lhld    dtgindex
  1305.  
  1306.     .comment    `
  1307. ;here A = power
  1308.     mov    e,a
  1309.     lda    be+1
  1310.     ani    80h
  1311.     jz    i3a14.1
  1312.     push    h
  1313.     mov    a,e
  1314.     lxi    d,gbuf-1
  1315.     dad    d
  1316.     ana    m
  1317.     pop    h
  1318.     jz    i3af9
  1319. if really want to do this, just jmp so not bent next time
  1320. i3a14.1:
  1321.             `
  1322.  
  1323. ;(if italic add bx)
  1324.     mov    a,c
  1325.     ani    80H
  1326.     jz    i3a14a
  1327.     lda    bx
  1328.     mov    e,a
  1329.  
  1330. ;top of italicized tall or duplex character over by 8
  1331.     mov    a,c
  1332.     ani    PRPTNL
  1333.     jnz    $+9
  1334.  
  1335.     MOV    A,B
  1336.     ANI    40H
  1337.     JZ    i3nt1
  1338.     LDA    TABOTTOM
  1339.     ORA    A
  1340.     JNZ    i3nt1
  1341.     MOV    A,E
  1342.     ADI    8
  1343.     MOV    E,A
  1344. i3nt1:
  1345.     mvi    d,0
  1346.     dad    d
  1347. i3a14a:
  1348.     push    h
  1349.  
  1350.  
  1351.  
  1352. ;;    lhld    be    ;be
  1353.     lda    be+1
  1354.     ani    7
  1355.     mov    h,a
  1356.     dcr    a
  1357.     jm    .bnt1
  1358.     mov    l,a
  1359.     add    a    ;*2
  1360.     add    l    ;*3
  1361.     mov    l,a
  1362.     mvi    h,0
  1363.     dad    h    ;*6
  1364.     dad    h    ;*12
  1365.     dad    h    ;*24
  1366.  
  1367. ;;    dcx    h
  1368. ;be - 1
  1369. ;;    lxi    d,24
  1370. ;;    call    USMUL
  1371.  
  1372.     lxi    d,bending
  1373.     dad    d
  1374. .bnt1:
  1375.     xchg
  1376.  
  1377.     lda    pix
  1378.     mov    l,a
  1379.     lda    bx
  1380.  
  1381. ;for tall, index every other
  1382.     MOV    H,A
  1383.     MOV    A,B
  1384.     ANI    40H
  1385.     JZ    i3nt2
  1386.     MOV    A,H
  1387.     RAR
  1388.     MOV    H,A
  1389.     LDA    TABOTTOM
  1390.     ORA    A
  1391.     JNZ    i3nt2
  1392.     MOV    A,H
  1393.     ADI    4
  1394.     MOV    H,A
  1395. i3nt2:
  1396.     MOV    A,H
  1397.     push    psw
  1398.  
  1399.     add    l
  1400.     mov    l,a
  1401. ;L = row (0-23) to index
  1402.     mvi    h,0
  1403.  
  1404. ;high of DE is 0 if no table value sought
  1405.     mov    a,d
  1406.     ora    a
  1407.     jz    .bnt2
  1408. ;DE is still bending[...]
  1409.     dad    d
  1410.  
  1411.     mov    d,m
  1412. .bnt2:
  1413.     mov    l,d
  1414. ;L = right displacement for this row of dots
  1415.     mvi    h,0
  1416.  
  1417.     lda    pass
  1418.     mov    d,a
  1419. ;get back adjusted bx
  1420.     pop    psw    ;is 0..7
  1421.     inr    a    ;is 1..8
  1422.     mov    e,a
  1423.     add    a
  1424.     add    e    ;*3 -- is 3..24
  1425.  
  1426.     dcr    a    ;is 2..23
  1427.     sub    d    ;is 0..23
  1428.  
  1429.     add    a    ;is 0..46
  1430.     mov    e,a
  1431.     mov    d,h
  1432.  
  1433.  
  1434. ;any slant?
  1435.     lda    be
  1436.     push    psw
  1437. ;add in foreslant or backslant according to row in E
  1438.  
  1439. ;low nib is foreslant
  1440.     call    ..slant
  1441. ;invert row for backslant in high nib
  1442.     mvi    a,46
  1443.     sub    e
  1444.     mov    e,a
  1445.  
  1446.     pop    psw
  1447.     rar
  1448.     rar
  1449.     rar
  1450.     rar
  1451.     call    ..slant
  1452.  
  1453. ;bending[be-1][pix + bx]
  1454.  
  1455.     pop    d    ;dtgindex + bx
  1456.     dad    d
  1457.  
  1458.     lxi    d,gbuf
  1459.     dad    d
  1460.     push    h
  1461.     mov    e,m
  1462.  
  1463. ;;    lda    power
  1464. ;;    mov    l,a
  1465. ;;    lda    ch
  1466.     call    updwnch
  1467.     lda    power
  1468.  
  1469.     ana    l
  1470.         ;gbuf[...]
  1471.     ora    e
  1472.  
  1473.     pop    h    ;@gbuf[...]
  1474.     mov    m,a
  1475. ;    jmp    i3af9
  1476. ;        else gbuf[gindex + bending[be-1][pix + bx]] |= power & c;
  1477. ;    }
  1478.  
  1479. ;("else" included in preceding loop now)
  1480. ;
  1481. ;((    for (...;...; bx++, power <<= 1)
  1482. ;
  1483. i3af9:
  1484.     lda    bx
  1485.     inr    a
  1486.     sta    bx
  1487.  
  1488.     lda    power
  1489.     add    a
  1490.     sta    power
  1491.  
  1492.     rc
  1493.     jmp    i3a14
  1494. ;
  1495. ;i3b14:    jmp    dsetret
  1496.  
  1497.  
  1498. ;add to displ. in HL slant in Acc according to row # in DE
  1499. ..slant:
  1500.     ani    0fh
  1501.     rz
  1502.     push    d
  1503.     push    h
  1504.     cma
  1505.     ani    0fh
  1506.     jz    ..slax
  1507.     inr    a
  1508.     mov    l,a
  1509.     mvi    h,0
  1510.     call    usdiv
  1511.     pop    d
  1512.     dad    d
  1513.     pop    d
  1514.     ret
  1515. ..slax:    pop    h
  1516.     dad    d
  1517.     pop    d
  1518.     ret
  1519.  
  1520.  
  1521. updwnch:
  1522.     lda    be+1
  1523.     ani    20h
  1524.     lda    ch
  1525.     mov    l,a
  1526.     rz
  1527.     mvi    d,8
  1528. .upd1:    mov    a,l
  1529.     rar
  1530.     mov    l,a
  1531.     mov    a,h
  1532.     ral
  1533.     mov    h,a
  1534.     dcr    d
  1535.     jnz    .upd1
  1536.     mov    l,h
  1537.     ret
  1538.  
  1539.  
  1540.  
  1541.  
  1542. ;    else if (kind & ITALIC)
  1543. i3b17:
  1544. ;    lda    attrix
  1545.     mov    a,c
  1546.     ani    80H
  1547.     jz    i3ba0
  1548. ;    for (bx = 0, power = 1; bx < 8; bx++, power <<= 1)
  1549.  
  1550. ;;    push    b
  1551. ;;    mvi    c,1
  1552.     lhld    dtgindex
  1553.     lxi    d,gbuf
  1554. ;over 8 more for top of tall or duplex character
  1555.     mov    a,c
  1556.     ani    PRPTNL
  1557.     push    b
  1558.     mvi    c,1
  1559.     jnz    $+9
  1560.     MOV    A,B
  1561.     ANI    40H
  1562.     JZ    i3nt3
  1563.     LDA    TABOTTOM
  1564.     ORA    A
  1565.     JNZ    i3nt3
  1566.     LXI    D,GBUF+8
  1567. i3nt3:
  1568.  
  1569.     dad    d
  1570.     lda    ch
  1571.     mov    d,a
  1572. ;bx = 0
  1573. ;power = 1
  1574. i3b3c:
  1575. ;        gbuf[gindex++] |= power & c;
  1576.     mov    e,m
  1577.     mov    a,d
  1578.     ana    c
  1579.     ora    e
  1580.     mov    m,a
  1581.     inx    h
  1582.     mov    a,c
  1583.     add    a
  1584.     mov    c,a
  1585.  
  1586.     jnc    i3b3c
  1587. ;    jmp    i3b3c
  1588.  
  1589. i3b9d:    pop    b
  1590. ;    jmp    dsetret
  1591.     ret
  1592. ;    else gbuf[gindex] |= c;
  1593.  
  1594. i3ba0:
  1595.     lhld    dtgindex
  1596.     lxi    d,gbuf
  1597.     dad    d
  1598.     mov    e,m
  1599.     lda    ch
  1600.     ora    e
  1601.     mov    m,a
  1602.  
  1603. ;}
  1604. ;
  1605.  
  1606. ;dsetret:
  1607. ;    pop    b
  1608.     ret
  1609.  
  1610.  
  1611. ;
  1612. ;maketall(pass,c0,c1,c2)
  1613. ;char        pass,    05
  1614. ;        c0,    07
  1615. ;        c1,    09
  1616. ;        c2;    0B
  1617. ;{    char    c;    00    (returned)
  1618. maketall:
  1619.     push    b
  1620. ;
  1621. ;    if (tabottom)
  1622.     lhld    tabottom
  1623.     mov    a,l
  1624.     ora    a
  1625.     jz    i3c07
  1626. ;    {    c0 <<= 4;
  1627.     lda    c0
  1628.     add    a
  1629.     add    a
  1630.     add    a
  1631.     add    a
  1632.     sta    c0
  1633. ;        c1 <<= 4;
  1634.     lda    c1
  1635.     add    a
  1636.     add    a
  1637.     add    a
  1638.     add    a
  1639.     sta    c1
  1640. ;        c2 <<= 4;
  1641. ;    }
  1642.     lda    c2
  1643.     add    a
  1644.     add    a
  1645.     add    a
  1646.     add    a
  1647.     sta    c2
  1648. ;
  1649. ;    switch (pass)
  1650.  
  1651. i3c07:
  1652.     lda    pass
  1653.  
  1654. ;    cpi    0
  1655. ;    jz    i3c1f
  1656.     cpi    1
  1657.     jz    i3c4c
  1658.     cpi    2
  1659.     jz    i3c79
  1660. ;    jmp    i3ca6
  1661. ;    {    case 0:    c = tallfu(c0) | tallfu(c1) >> 1; break;
  1662. ;i3c1f:
  1663.     lda    c0
  1664.     call    tallfu
  1665.     push    psw
  1666.     lda    c1
  1667.     jmp    i3c79b
  1668.  
  1669. ;    jmp    i3ca6
  1670. ;        case 1:    c = tallfu(c0) | tallfu(c2) >> 1; break;
  1671. i3c4c:
  1672.     lda    c0
  1673.     jmp    i3c79a
  1674.  
  1675. ;    jmp    i3ca6
  1676. ;        case 2:    c = tallfu(c1) | tallfu(c2) >> 1; break;
  1677. i3c79:
  1678.     lda    c1
  1679. i3c79a:    call    tallfu
  1680.     push    psw
  1681.     lda    c2
  1682. i3c79b:    call    tallfu
  1683.     ora    a
  1684.     rar
  1685.     mov    l,a
  1686.     pop    psw
  1687.     ora    l
  1688.  
  1689. ;    }
  1690. ;
  1691. ;    return(c);
  1692. ;}
  1693. i3ca6:
  1694.     sta    ch
  1695.     pop    b
  1696.     ret
  1697.  
  1698.  
  1699. ;
  1700. ;tallfu(c)
  1701. ;char c;
  1702. ;{
  1703.  
  1704. tallfu:
  1705.     push    b
  1706.     mov    b,a
  1707. ;    return
  1708. ;    (       c       & 128
  1709.     ani    80H
  1710.     mov    c,a
  1711. ;        | (c >> 1) &  32
  1712.     mov    a,b
  1713.     rar
  1714.     ani    20H
  1715.     ora    c
  1716.     mov    c,a
  1717. ;        | (c >> 2) &   8
  1718.     mov    a,b
  1719.     rar
  1720.     rar
  1721.     ani    8
  1722.     ora    c
  1723.     mov    c,a    
  1724. ;        | (c >> 3) &   2
  1725.     mov    a,b
  1726.     rar
  1727.     rar
  1728.     rar
  1729.     ani    2
  1730.     ora    c
  1731.  
  1732. ;    );
  1733. ;}
  1734. ;
  1735.     pop    b
  1736.     ret
  1737.  
  1738. ;$pass:    db    0
  1739. ;$ch:    db    0
  1740. ;$c0:    db    0
  1741. ;$c1:    db    0
  1742. ;$c2:    db    0
  1743. ;$bx:    db    0
  1744. ;$ftn:    db    0
  1745. ;$charft:    db    0
  1746. ;$len:    dw    0
  1747. ;$lstlen:    dw    0
  1748. ;$pix:    db    0
  1749.  
  1750. ;$power:    db    0
  1751. ;$gindex:    dw    0
  1752. ;$dtgindex:    dw    0
  1753. ;$ix:        dw    0
  1754. ;(kept in BC)
  1755. ;attrix:    dw    0
  1756. ;$widix:    dw    0
  1757. ;$ptft:    dw    0
  1758. ;$ptft0:    dw    0
  1759. ;$ptft1:    dw    0
  1760. ;$ptft2:    dw    0
  1761. ;$gcj:    dw    0
  1762.  
  1763. ;$cx48:    db    0,0,0,0,0,0
  1764.  
  1765. ;$_st:    dw    0
  1766. ;$_sh:    dw    0
  1767.  
  1768. ;For a tall=1 character:
  1769. ; canon, hidots, decanon
  1770. ;(Ref. to cheight required)
  1771.  
  1772.  
  1773. ;canonicalize C0,C1,C2 with result in CX48
  1774. canon:
  1775.     lxi    h,0
  1776.     shld    cx48
  1777.     shld    cx48+2
  1778.     lda    c0
  1779.     mov    h,a
  1780.     lda    c1
  1781.     mov    l,a
  1782.     lda    c2
  1783.     mov    e,a
  1784.     mvi    b,8
  1785.     call    shft
  1786.     sta    cx48+3
  1787.     mvi    b,8
  1788.     call    shft2
  1789.     sta    cx48+4
  1790.     mvi    b,8
  1791.     call    shft3
  1792.     sta    cx48+5
  1793.     ret
  1794.  
  1795. ;decanonicalize CX48 with result in C0,C1,C2
  1796. ; Distribute the 24 bits of the first 3 bytes (for
  1797. ; the top part of a tall char.) or the last 3 (for
  1798. ; the bottom part) among c0,c1,c2
  1799. decanon:
  1800.     lxi    h,cx48
  1801.     lda    tabottom
  1802.     ora    a
  1803.     jz    dcnn0
  1804.     lxi    h,cx48+3
  1805. dcnn0:    mov    d,m
  1806.     inx    h
  1807.     mov    e,m
  1808.     inx    h
  1809.     mov    l,m
  1810.     xchg
  1811.     lda    cheight
  1812.     cpi    3*24
  1813.     jc    dcnn1
  1814.     mov    a,h
  1815.     sta    c0
  1816.     mov    a,l
  1817.     sta    c1
  1818.     mov    a,e
  1819.     sta    c2
  1820.     ret
  1821. dcnn1:    mvi    b,8
  1822. dcnn2:    call    dshft
  1823.     mov    a,c
  1824.     ral
  1825.     mov    c,a
  1826.     call    dshft
  1827.     mov    a,d
  1828.     ral
  1829.     mov    d,a
  1830.     call    dshft
  1831.     lda    c2
  1832.     ral
  1833.     sta    c2
  1834.     dcr    b
  1835.     jnz    dcnn2
  1836.     mov    a,d
  1837.     sta    c1
  1838.     mov    a,c
  1839.     sta    c0
  1840.     ret
  1841.  
  1842. ;collect bits in C from 24 bits in H-L-E
  1843. shft:
  1844.     mov    a,h
  1845.     ral
  1846.     mov    h,a
  1847.     mov    a,c
  1848.     ral
  1849.     mov    c,a
  1850.     dcr    b
  1851.     rz
  1852. shft3:    mov    a,l
  1853.     ral
  1854.     mov    l,a
  1855.     mov    a,c
  1856.     ral
  1857.     mov    c,a
  1858.     dcr    b
  1859.     rz
  1860. shft2:    mov    a,e
  1861.     ral
  1862.     mov    e,a
  1863.     mov    a,c
  1864.     ral
  1865.     mov    c,a
  1866.     dcr    b
  1867.     rz
  1868.     jmp    shft
  1869.  
  1870. ;rotate left 24 bits in H-L-E, returning
  1871. ; with high bit in carry
  1872. dshft:
  1873.     mov    a,e
  1874.     ral
  1875.     mov    e,a
  1876.     mov    a,l
  1877.     ral
  1878.     mov    l,a
  1879.     mov    a,h
  1880.     ral
  1881.     mov    h,a
  1882.     ret
  1883.  
  1884. ;if character height > 8 points, stretch pattern accordingly
  1885. hidots:
  1886.     lda    cheight
  1887.     cpi    3*24
  1888.     jc    hdts0
  1889.     rz
  1890. ;for >= 24 points, use points instead of dots
  1891.     mov    l,a
  1892.     mvi    h,0
  1893.     lxi    d,3
  1894.     xchg
  1895.     call    USDIV
  1896.     mov    a,l
  1897. hdts0:
  1898.     sui    3*8
  1899.     rm
  1900.     cpi    3*8+1
  1901.     rnc
  1902.  
  1903.     mov    e,a
  1904.     lxi    h,sttab
  1905.     lda    ta
  1906.     dcr    a
  1907.     jnz    hidots2
  1908.     inr    e
  1909. hidots1:
  1910.     dcr    e
  1911.     rz
  1912.     mov    c,m    ;load byte offset and bit mask
  1913.     inx    h
  1914.     mov    b,m
  1915.     inx    h
  1916.     push    d
  1917.     push    h
  1918.     call    stret
  1919.     pop    h
  1920.     pop    d
  1921.     jmp    hidots1
  1922.  
  1923. hidots2:
  1924.     dcr    a
  1925.     mov    a,e
  1926.     jz    $+9
  1927. ;here tall was >= 3
  1928.     lxi    b,041FH    ;row 35
  1929.     jmp    hirowb
  1930.  
  1931. ;;    mov    a,e
  1932.     ora    a
  1933.     rar
  1934.     ora    a
  1935.     jnz    hdts2a
  1936.     inr    a
  1937. hdts2a:
  1938. ;(new version)
  1939.     push    psw
  1940.     lxi    b,037FH
  1941.     call    hirowb
  1942.     pop    psw
  1943.     lxi    b,0503H
  1944.  
  1945. ;;    mov    e,a
  1946. ;;    mov    d,a
  1947. ;;hidots3:
  1948. ;;    lxi    b,037FH    ;25th row
  1949. ;;    push    d
  1950. ;;    call    stret
  1951. ;;    pop    d
  1952. ;;    dcr    e
  1953. ;;    jnz    hidots3
  1954. ;;hidots4:
  1955. ;;    lxi    b,0503H    ;46th row
  1956. ;;    push    d
  1957. ;;    call    stret
  1958. ;;    pop    d
  1959. ;;    dcr    d
  1960. ;;    jnz    hidots4
  1961. ;;    ret
  1962.  
  1963. hirowb:
  1964.     push    psw
  1965.     push    b
  1966.     call    stret
  1967.     pop    b
  1968.     pop    psw
  1969.     dcr    a
  1970.     jnz    hirowb
  1971.     ret
  1972.  
  1973. ;stretch out pattern in cx48 by doubling one bit
  1974. ; the bit is in the byte at offset B, and a mask
  1975. ; for the lesser bits to remain unaffected is in C
  1976. stret:
  1977.     lxi    h,cx48
  1978.     mov    e,b
  1979.     mvi    d,0
  1980.     dad    d    ;HL-> highest byte to change
  1981.     mov    a,m
  1982.     mov    e,a    ;E = original
  1983.     ana    c    ;use mask
  1984.     mov    d,a    ;D = bits to save
  1985.     mov    a,c    ;invert mask for bits to change
  1986.     xri    0FFH
  1987.     mov    c,a
  1988.     mov    a,e
  1989.     ral
  1990.     ana    c    ;A = new rotated bits
  1991.     ora    d    ;restore old saved bits
  1992.     mov    m,a    ;now lowest order byte is ready
  1993.             ; and e still has original (for b7)
  1994. stret1:
  1995.     dcr b
  1996.     rm        ;if just did lowest byte, done
  1997.     dcx    h    ;-> next lower byte
  1998.     mov    a,e    ;get b7 of last in carry
  1999.     ral
  2000.     mov    a,m    ;get the original
  2001.     mov    e,a    ;save for sake of b7
  2002.     ral
  2003.     mov    m,a    ;change it
  2004.     jmp    stret1
  2005.  
  2006. ;Table contains list of bits to double, in
  2007. ; increasing order of priority
  2008. ; First byte of each 2 byte entry is a mask
  2009. ; for the low order bits to remain unaffected
  2010. ; (which will include the doubled bit),
  2011. ; and high byte is offset = 0,1,2,3,4,5 of the
  2012. ; byte in cx48 where the doubled bit is to be found
  2013. ;Present table values just to test
  2014. sttab:
  2015.     db    0FFH shr (27 mod 8), 27 / 8
  2016.     db    0FFH shr (35 mod 8), 35 / 8
  2017.     db    0FFH shr (45 mod 8), 45 / 8
  2018. ; 9 points
  2019.     db    0FFH shr (36 mod 8), 36 / 8
  2020.     db    0FFH shr (21 mod 8), 21 / 8
  2021.     db    0FFH shr (30 mod 8), 30 / 8
  2022. ;10 points
  2023.     db    0FFH shr (42 mod 8), 42 / 8
  2024.     db    0FFH shr (37 mod 8), 37 / 8
  2025.     db    0FFH shr (23 mod 8), 23 / 8
  2026. ;11 points
  2027.     db    0FFH shr (25 mod 8), 25 / 8
  2028.     db    0FFH shr (47 mod 8), 47 / 8
  2029.     db    0FFH shr (38 mod 8), 38 / 8
  2030. ;12 points
  2031.     db    0FFH shr (15 mod 8), 15 / 8
  2032.     db    0FFH shr (30 mod 8), 30 / 8
  2033.     db    0FFH shr (42 mod 8), 42 / 8
  2034. ;13 points
  2035.     db    0FFH shr (25 mod 8), 25 / 8
  2036.     db    0FFH shr (15 mod 8), 15 / 8
  2037.     db    0FFH shr (32 mod 8), 32 / 8
  2038. ;14 points
  2039.     db    0FFH shr (38 mod 8), 38 / 8
  2040.     db    0FFH shr (19 mod 8), 19 / 8
  2041.     db    0FFH shr ( 4 mod 8),  4 / 8
  2042. ;15 points
  2043.     db    0FFH shr (34 mod 8), 34 / 8
  2044.     db    0FFH shr (45 mod 8), 45 / 8
  2045.     db    0FFH shr (13 mod 8), 13 / 8
  2046. ;16 points
  2047.  
  2048.     END
  2049.