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

  1.  
  2.  
  3.     INCLUDE BDSYM.EQU
  4. ;    INCLUDE EPSYM.EQU
  5.     INCLUDE EPDATA
  6.  
  7.  
  8. ;    FUNCTION    UNDRLN
  9.  
  10. ;/************************************************/
  11. ;/* Underline graphics characters by setting    */
  12. ;/*     bits under them            */
  13. ;/************************************************/
  14. ;    int uli, strtus, stopus;
  15.  
  16. ;underline()
  17. ;{    /* int uli, strtus, stopus;*/
  18.  
  19.  
  20. underline::
  21.  
  22.     push    b
  23.  
  24. ;    strtus = 0;
  25.  
  26.     lxi    h,0
  27.     shld    strtus
  28. ;    for (uli = 0; uli < outpoint;)
  29.  
  30.     lxi    h,0
  31.     shld    uli
  32.  
  33. ;BC = outpoint and DE = *attrbuf throughout routine
  34.     lhld    outpoint
  35.     MOV    B,H
  36.     MOV    C,L
  37.  
  38.     LHLD    ATTRBUF
  39.     XCHG
  40.  
  41. i2e85:
  42.     lhld    uli
  43.     CALL    CMPBC
  44.     JC    i2e93a
  45.     POP    B
  46.     RET
  47.  
  48. ;    {    /* look for underlined char */
  49. ;        while (uli < outpoint && !(attrbuf[uli] & UNDRLN))
  50.  
  51. i2e93:
  52. ;(HL = uli when loop)
  53. ;    lhld    uli
  54.     CALL    CMPBC
  55.     jnc    i2f02
  56. i2e93a:
  57.     LDAX    D
  58.     ANI    40H
  59.     jnz    i2f02
  60.  
  61. ;        {    if (outbuf[uli] == SOFTHY) uli++;
  62.  
  63.     PUSH    D
  64.  
  65.     LHLD    OUTBUF
  66.     XCHG
  67.  
  68.     lhld    uli
  69.     dad    d
  70.     MOV    A,M
  71.     cpi    1EH
  72.     JZ    i2eff
  73.  
  74. ;            else    strtus += widbuf[uli++];
  75. ;        }
  76.  
  77.     LHLD    WIDBUF
  78.     XCHG
  79.  
  80.     lhld    uli
  81.     dad    h
  82.     dad    d
  83.  
  84.     MOV    E,M
  85.     INX    H
  86.     MOV    D,M
  87.  
  88.     LHLD    STRTUS
  89.     dad    d
  90.     shld    strtus
  91. i2eff:
  92.     POP    D
  93.     lhld    uli
  94.     inx    h
  95.     shld    uli
  96.     INX    D
  97.     INX    D
  98.     jmp    i2e93
  99.  
  100.  
  101. ;        stopus = strtus;
  102.  
  103. i2f02:    lhld    strtus
  104.     shld    stopus
  105.  
  106. ;        /* look for non-underlined char */
  107. ;        while (uli < outpoint &&  (attrbuf[uli] & UNDRLN))
  108.  
  109.     lhld    uli
  110. i2f08:
  111. ;(HL = uli on loop)
  112.     CALL    CMPBC
  113.     jnc    i2f77
  114.  
  115. ;    dad    h
  116. ;    dad    d
  117. ;    mov    a,m
  118.     LDAX    D
  119.     ANI    40H
  120.     jz    i2f77
  121.  
  122. ;        {    if (outbuf[uli] == SOFTHY) uli++;
  123.  
  124.     PUSH    D
  125.     LHLD    OUTBUF
  126.     XCHG
  127.  
  128.     lhld    uli
  129.     dad    d
  130.     MOV    A,M
  131.     cpi    1EH
  132.     JZ    i2f74
  133.  
  134. ;            else    stopus += widbuf[uli++];
  135. ;        }
  136.  
  137. i2f54:
  138.  
  139.     LHLD    WIDBUF
  140.     XCHG
  141.  
  142.     lhld    uli
  143.     dad    h
  144.     dad    d
  145.  
  146.     MOV    E,M
  147.     INX    H
  148.     MOV    D,M
  149.  
  150.     LHLD    STOPUS
  151.     dad    d
  152.     shld    stopus
  153.  
  154. i2f74:
  155.     POP    D
  156.     lhld    uli
  157.     inx    h
  158.     shld    uli
  159.     INX    D
  160.     INX    D
  161.     jmp    i2f08
  162.  
  163. ;            /* uscore(strtus, stopus); */
  164. ;        uscore();
  165.  
  166. i2f77:
  167.     PUSH    D
  168.     call    uscore
  169.     POP    D
  170. ;        strtus = stopus;
  171. ;    }
  172.  
  173.     lhld    stopus
  174.     shld    strtus
  175.     jmp    i2e85
  176. ;}
  177.  
  178. ;i2f83:    pop    b
  179. ;    ret
  180.  
  181.  
  182.  
  183. ;
  184. ;/************************************************/
  185. ;/* set bits under a span of underlined        */
  186. ;/*     characters                */
  187. ;/************************************************/
  188. ;    int usi, sus, eus, loffs, roffs;
  189. ;
  190. ;uscore()
  191. ;    /* uscore(strtus, stopus) */
  192. ;    /* int strtus, stopus;    */
  193. ;{    /* int i, sus, eus, loffs, roffs; */
  194. ;
  195.  
  196.  
  197. uscore:
  198.     push    b
  199.  
  200.     LHLD    STOPUS
  201.     MOV    B,H
  202.     MOV    C,L
  203.  
  204. ;    sus = strtus;
  205.     lhld    strtus
  206.     shld    sus
  207.  
  208. ;    while (sus < stopus)
  209. ;    {
  210. i2f8c:    lhld    sus
  211.     CALL    CMPBC
  212. ;    jnc    i30a8
  213.     JC    i2f8ca
  214.     POP    B
  215.     RET
  216. i2f8ca:
  217. ;        /* look for white */
  218. ;        while (sus < stopus &&  (gbuf[sus] & 1)) sus++;
  219.  
  220.     PUSH    H
  221.     LXI    D,GBUF
  222.     DAD    D
  223.     XCHG
  224.     POP    H
  225. ;keep sus in HL and gbuf[sus] in DE for following loop
  226.  
  227. i2f9a:
  228.     CALL    CMPBC
  229.     jnc    i2fca
  230.  
  231.     LDAX    D
  232.     ANI    1
  233.     jz    i2fca
  234.  
  235.     INX    D
  236.     inx    h
  237.     jmp    i2f9a
  238.  
  239. ;        eus = sus;
  240. i2fca:
  241.     SHLD    SUS    ;result from previous loop
  242.  
  243. ;eus kept in HL and gbuf[eus] in DE, for following loop
  244.  
  245. ;        /* look for black */
  246. ;        while (eus < stopus && !(gbuf[eus] & 1)) eus++;
  247.  
  248. i2fd0:
  249.     CALL    CMPBC
  250.     jnc    i3000
  251.  
  252.     LDAX    D
  253.     ANI    1
  254.     jnz    i3000
  255.     INX    D
  256.     inx    h
  257.     jmp    i2fd0
  258. ;        /* 8 vs 6 is 2 dots more clearance on the left */
  259. ;        loffs = (sus == strtus) ? 0 : 8;
  260.  
  261. i3000:
  262.     SHLD    EUS    ;computed in previous loop
  263.  
  264.     lhld    sus
  265.     XCHG
  266.     lhld    strtus
  267.     call    eqwel
  268.     LXI    H,8
  269.     JNZ    i3017
  270.     lxi    h,0
  271. i3017:    shld    loffs
  272.  
  273. ;        /* 4 is a guess at the right side-bearing */
  274. ;        roffs = (eus == stopus) ? 4 : 6;
  275.  
  276.     lhld    eus
  277.     XCHG
  278.     lhld    stopus
  279.     call    eqwel
  280.     LXI    H,6
  281.     jnz    i3031
  282.     lxi    h,4
  283. i3031:    shld    roffs
  284.  
  285. ;        if (eus - sus - loffs - roffs > 3)
  286.  
  287.     LHLD    SUS
  288.     XCHG
  289.     LHLD    LOFFS
  290.     DAD    D
  291.     XCHG
  292.     LHLD    ROFFS
  293.     DAD    D
  294.     XCHG
  295.     CALL    CMD
  296.     LHLD    EUS
  297.     DAD    D
  298.     MOV    A,H
  299.     ORA    A
  300.     JM    I309Fa
  301.     MOV    A,L
  302.     CPI    4
  303.     jc    i309fa
  304.  
  305. ;        for (usi = sus + loffs; usi < eus - roffs; usi++)
  306.  
  307.     PUSH    B
  308. ;count of dots to set in BC (usi no longer used)
  309.     MOV    B,H
  310.     MOV    C,L
  311.  
  312.     lhld    sus
  313.     XCHG
  314.     lhld    loffs
  315.     dad    d
  316.     LXI    D,GBUF
  317.     DAD    D
  318. ;keep gbuf[usi] in HL
  319. i3067:
  320.     DCX    B
  321.     MOV    A,B
  322.     ORA    C
  323.     JZ    I309F
  324.  
  325. ;            gbuf[usi] |= 1;
  326.  
  327.     MOV    A,M
  328.     ORI    1
  329.     MOV    M,A
  330.     INX    H
  331.     jmp    i3067
  332.  
  333. ;        sus = eus;
  334. ;    }
  335. i309f:
  336.     POP    B
  337. i309fa:
  338.     lhld    eus
  339.     shld    sus
  340.     jmp    i2f8c
  341. ;}
  342. ;
  343. ;
  344. ;i30a8:    pop    b
  345. ;    ret
  346.  
  347. CMPBC:
  348.     MOV    A,H
  349.     CMP    B
  350.     RNZ
  351.     MOV    A,L
  352.     CMP    C
  353.     RET
  354.  
  355. ;underlin locals
  356. ;    int uli, strtus, stopus;
  357. uli:    dw    0
  358. strtus:    dw    0
  359. stopus:    dw    0
  360.  
  361. ;uscore locals
  362. ;    int usi, sus, eus, loffs, roffs;
  363. ;usi:    dw    0
  364. sus:    dw    0
  365. eus:    dw    0
  366. loffs:    dw    0
  367. roffs:    dw    0
  368.  
  369.     END
  370.  
  371.