home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDLFILE / OPTIMIZE.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  28.7 KB  |  1,490 lines

  1. *************************************************************************
  2. *            Revision Control System
  3. * =======================================================================
  4. *  $Revision: 2.2 $    $Source: /u2/MRS/osrevisions/aes/optimize.s,v $
  5. * =======================================================================
  6. *  $Author: mui $    $Date: 89/04/26 18:29:34 $    $Locker:  $
  7. * =======================================================================
  8. *  $Log:    optimize.s,v $
  9. * Revision 2.2  89/04/26  18:29:34  mui
  10. * TT
  11. * Revision 2.1  89/02/22  05:31:30  kbad
  12. * *** TOS 1.4  FINAL RELEASE VERSION ***
  13. * Revision 1.1  88/06/02  12:36:01  lozben
  14. * Initial revision
  15. *************************************************************************
  16. * --
  17. *
  18. * optimize.s
  19. * 02/02/87    Totally rewritten from optimize.c    Mike Schmal
  20. *
  21. *        Grect - a block of four contiguous words representing a 
  22. *            graphics rectangle x,y,w,h
  23. *
  24. * NOTE    One day we should remove calls to inf_sget and use fs_sget since
  25. *    they are the same function.
  26. *
  27. * UPDATES:
  28. *    02/24/87 Bug in fmt_str now checks for null when skipping extension
  29. *         '.'.
  30. * Fix bug at unfmt_str    2/23/88        D.Mui
  31. * --
  32.  
  33. *
  34. OB_FLAGS    =    $8
  35. OB_STATE    =    $a
  36. OB_SPEC        =    $c
  37. OB_SIZE        =    $18
  38. *
  39. TEDTXTLEN    =    $18
  40. *
  41. PERCENT        =    $25
  42. CAP_L        =    $4c
  43. CAP_W        =    $57
  44. CAP_S        =    $53
  45. DOT        =    $2e
  46. SPACE        =    $20
  47. QUEST        =    $3f
  48. STAR        =    $2a
  49.  
  50. * --
  51. * external variables
  52. * --
  53.     .globl _gl_wchar
  54.     .globl _gl_hchar
  55.     .globl _r_get
  56.  
  57. * --
  58. * internal defined routines
  59. * --
  60.     .globl    _r_get
  61.     .globl    _r_set
  62.     .globl _rc_copy
  63.     .globl _rc_equal
  64.     .globl _rc_inter
  65.     .globl _rc_union
  66.     .globl _rc_const
  67.     .globl _movs
  68.     .globl _min
  69.     .globl _max
  70.     .globl _inside
  71.     .globl _strlen
  72.     .globl _strcmp
  73.     .globl _strcpy
  74.     .globl _strscn
  75.     .globl _strchk
  76.     .globl _toupper
  77.     .globl _fmt_str
  78.     .globl _unfmt_st
  79.     .globl _fs_sset
  80.     .globl _inf_sset
  81.     .globl _fs_sget
  82.     .globl _inf_sget
  83.     .globl _inf_fldset
  84.     .globl _inf_gind
  85.     .globl _inf_what
  86.     .globl _merge_st
  87.     .globl _strcat
  88.     .globl _bfill
  89.     .globl _wildcmp
  90.     .globl _scasb
  91.  
  92.     .text
  93. * --
  94. *
  95. * r_get        Routine to set the variables x,y,w,h to the values found
  96. *        in an x,y,w,h block (grect)
  97. *        C binding:    r_get(xywhptr,xptr,yprt,wptr,hptr);
  98. *                int    *xywhptr;
  99. *                int    *xptr,*yptr,*wptr,*hptr;
  100. * --
  101. _r_get:
  102.     movem.l    a3-a4,-(sp)    ; save a3,a4
  103.     movem.l    12(sp),a0-a4    ; a0 -> grect , a1->x, a2->y, a3->w, a4->h
  104.     move.w    (a0)+,(a1)    ; set x from grect
  105.     move.w     (a0)+,(a2)    ; set y
  106.     move.w    (a0)+,(a3)    ; set w
  107.     move.w    (a0)+,(a4)    ; set h
  108.     movem.l    (sp)+,a3-a4    ; restore
  109.     rts
  110.  
  111. * --
  112. *
  113. * _r_set    Routine to set a x,y,w,h block to the x,y,w,h values passed
  114. *        in.
  115. *        C binding:    r_set(xywhptr,x,y,w,h);
  116. *                int    *xywhptr;
  117. *                int    x,y,w,h;
  118. * --
  119. _r_set:
  120.     movem.l    4(sp),a0-a2    ; a0 -> grect, a1 = x and y, a2 = w and h
  121.     movem.l    a1-a2,(a0)    ; set x and y and w and h
  122.     rts
  123.  
  124.  
  125. * --
  126. *
  127. * rc_copy    Copy src xywh block to dest xywh block.
  128. *        C binding:    r_copy(srcxywh,dstxywh);
  129. *                GRECt    *srcxywh,*dstxywh;
  130. *
  131. * --
  132. _rc_copy:
  133.     movem.l    4(sp),a0-a1    ; a0 ->src, a1 ->dest
  134.     move.l    (a0)+,(a1)+    ; set x and y
  135.     move.l    (a0)+,(a1)+    ; set w and h
  136.     rts
  137.  
  138.  
  139. * --
  140. *
  141. * inside    Return true if the x,y position is within the grect
  142. *        C binding:    inside(x,y,ptr1);
  143. *                int    x,y;
  144. *                GRECT    *ptr1;
  145. * --
  146. _inside:
  147.     movem.w    4(sp),d0-d1    ; d0 = x, d1 = y
  148.     move.l    8(sp),a0    ; a0 -> grect
  149.     cmp.w    (a0),d0        ; if (x1 >= x)
  150.     blt    retfalse
  151.     cmp.w    2(a0),d1    ; && (y1 >= y)
  152.     blt    retfalse
  153.     move.w    (a0),d2        ; d2 = x1
  154.     add.w    4(a0),d2    ; d2 = x1 +w1
  155.     cmp.w    d2,d0        ; && ( x1+w1 <= x )
  156.     bge    retfalse
  157.     move.w    2(a0),d2    ; d2 = y1
  158.     add.w    6(a0),d2    ; d2 y2+h2
  159.     cmp.w    d2,d1        ; && ( y1+h1 <= y)
  160.     bge    retfalse
  161.     bra    rettrue
  162.  
  163.  
  164. * --
  165. *
  166. * rc_equal    Returns true if the two grects are equal.
  167. *        C binding:    rc_equal(ptr1,ptr2);
  168. *                int    *ptr1,ptr2*
  169. * --
  170. _rc_equal:
  171.     movem.l    4(sp),a0-a1    ; a0 -> grect 1, a1 -> grect 2
  172.     cmpm.l    (a0)+,(a1)+    ; are the x and y equal
  173.     bne    retfalse
  174.     cmpm.l    (a0)+,(a1)+    ; are the w and h equal
  175.     bne    retfalse
  176.     bra    rettrue
  177.  
  178. * --
  179. *
  180. * rc_intersect    Returns the intersection of two rectangles in ptr2.
  181. *        Returns true if there was an intersection where the width
  182. *        is greater than x and the height is greater than y.
  183. *        C binding:    rc_intersect(ptr1,ptr2);
  184. *                GRECT    *ptr1,*ptr2;
  185. *
  186. * --
  187. _rc_inter:
  188.     movem.l    4(sp),a0-a1    ; a0 = grect 1, a1 = grect 2
  189.     move.w    (a1),d0        ; d0 = x2
  190.     cmp.w    (a0),d0        ; If (x1 < x2)
  191.     bge    int1
  192.     move.w    (a0),d0        ; d0 = max(x1,x2)
  193. int1:
  194.     move.w    (a0),d1        ; d1 = x1
  195.     add.w    4(a0),d1    ; d1 = x1 + w1
  196.     move.w    (a1),d2        ; d2 = x2
  197.     add.w    4(a1),d2    ; d2 = x2 + w2
  198.     cmp.w    d1,d2        ; IF (x1+w1 > x2+w2)
  199.     ble    int2
  200.     move.w    d1,d2        ; d2 = min(x1+w1,x2+w2)
  201. int2:
  202.     move.w    d0,(a1)        ; x2 = max(x1,x2)
  203.     sub.w    d0,d2
  204.     move.w    sr,-(sp)    ; save status
  205.     move.w    d2,4(a1)    ; w2 = min(x1+w1,x2+w2) - max(x1,x2)
  206. *
  207.     move.w    2(a1),d0    ; d0 = y2
  208.     cmp.w    2(a0),d0    ; If (y1 < y2)
  209.     bge    int3
  210.     move.w    2(a0),d0    ; d0 = max(y1,y2)
  211. int3:
  212.     move.w    2(a0),d1    ; d1 = y1
  213.     add.w    6(a0),d1    ; d1 = y1 + h1
  214.     move.w    2(a1),d2    ; d2 = y2
  215.     add.w    6(a1),d2    ; d2 = y2 + h2
  216.     cmp.w    d1,d2        ; IF (y1+h1 > y2+h2)
  217.     ble    int4
  218.     move.w    d1,d2        ; d2 = min(y1+h1,y2+h2)
  219. int4:
  220.     move.w    d0,2(a1)    ; y2 = max(y1,y2)
  221.     sub.w    d0,d2
  222.     move.w    sr,d0        ; save status in d0 (ty > th)
  223.     move.w    d2,6(a1)    ; h2 = min(y1+h1,y2+h2) - max(y1,y2)
  224.     move.w    (sp)+,ccr    ; if (tw > tx)
  225.     ble    retfalse
  226.     move.w    d0,ccr        ; && (ty > th)
  227.     ble    retfalse
  228.     bra    rettrue
  229.  
  230. * --
  231. *
  232. * rc_union    Returns the union of two rectangles in ptr2.
  233. *        C binding:    rc_union(ptr1,ptr2);
  234. *                GRECT    *ptr1,*ptr2;
  235. *
  236. * --
  237. _rc_union:
  238.     movem.l    4(sp),a0-a1    ; a0 = ptr block 1, a1 = ptr block 2
  239.     move.w    (a1),d0        ; d0 = x2
  240.     cmp.w    (a0),d0        ; If (x1 < x2)
  241.     blt    uni1
  242.     move.w    (a0),d0        ; d0 = min(x1,x2)
  243. uni1:
  244.     move.w    (a0),d1        ; d1 = x1
  245.     add.w    4(a0),d1    ; d1 = x1 + w1
  246.     move.w    (a1),d2        ; d2 = x2
  247.     add.w    4(a1),d2    ; d2 = x2 + w2
  248.     cmp.w    d1,d2        ; IF (x1+w1 > x2+w2)
  249.     bgt    uni2
  250.     move.w    d1,d2        ; d2 = min(x1+w1,x2+w2)
  251. uni2:
  252.     sub.w    d0,d2
  253.     move.w    d0,(a1)        ; x2 = min(x1,x2)
  254.     move.w    d2,4(a1)    ; w2 = max(x1+w1,x2+w2) - min(x1,x2)
  255. *
  256.     move.w    2(a1),d0    ; d0 = y2
  257.     cmp.w    2(a0),d0    ; If (y1 < y2)
  258.     blt    uni3
  259.     move.w    2(a0),d0    ; d0 = min(y1,y2)
  260. uni3:
  261.     move.w    2(a0),d1    ; d1 = y1
  262.     add.w    6(a0),d1    ; d1 = y1 + h1
  263.     move.w    2(a1),d2    ; d2 = y2
  264.     add.w    6(a1),d2    ; d2 = y2 + h2
  265.     cmp.w    d1,d2        ; IF (y1+h1 > y2+h2)
  266.     bgt    uni4
  267.     move.w    d1,d2        ; d2 = max(y1+h1,y2+h2)
  268. uni4:
  269.     sub.w    d0,d2
  270.     move.w    d0,2(a1)    ; y2 = min(y1,y2)
  271.     move.w    d2,6(a1)    ; h2 = max(y1+h1,y2+h2) - min(y1,y2)
  272.     rts
  273.  
  274.  
  275. * --
  276. *
  277. * rc_constrain    Routine to constrain a box within another box.  This is done by
  278. *        seting the x,y of the inner box to remain within the
  279. *        constraining box.
  280. *        C binding:    r_constrain(const_ptr,xywhptr);
  281. *                GRECT    *const_ptr,*xywhptr;
  282. * --
  283. _rc_const:
  284.     movem.l    4(sp),a0-a1    ; a0 -> x of constrain rect, a1 -> grect
  285.     move.w    (a0),d0        ; d0 = const_x
  286.     cmp.w    (a1),d0        ; If ( x < const_x )
  287.     blt    clp_right
  288.     move.w    d0,(a1)        ; yes set x
  289. clp_right:
  290.     add.w    4(a0),d0    ; d0 = const_x+const_w
  291.     move.w    (a1),d1        ; d1 = x
  292.     add.w    4(a1),d1    ; d1 = x+w
  293.     cmp.w    d1,d0        ; If ( x+w < const_x+const_w )
  294.     bge    do_y
  295.     sub.w    4(a1),d0    ; d0 =     const_x+const_w-w
  296.     move.w    d0,(a1)        ; set x
  297. do_y:
  298.     move.w    2(a0),d0    ; d0 = const_y
  299.     cmp.w    2(a1),d0    ; If ( y < const_y )
  300.     blt    clp_bottom
  301.     move.w    d0,2(a1)    ; yes set y
  302. clp_bottom:
  303.     add.w    6(a0),d0    ; d0 = const_y+const_h
  304.     move.w    2(a1),d1    ; d1 = y
  305.     add.w    6(a1),d1    ; d1 = y+h
  306.     cmp.w    d1,d0        ; If ( y+h < const_y+const_h )
  307.     bge    rc_done
  308.     sub.w    6(a1),d0    ; d0 =     const_y+const_h-h
  309.     move.w    d0,2(a1)    ; set y
  310. rc_done:
  311.     rts
  312.  
  313. * --
  314. *
  315. * movs    move bytes from source to dest for a count of N
  316. *        C binding:    movs(count,src,dst);
  317. *                int    count;
  318. *                byte    *src,*dst;
  319. * --
  320. _movs:
  321.     move.w    4(sp),d0    ; count
  322.     movem.l    6(sp),a0-a1    ; a0 -> source, a1 -> dest
  323.     bra    stmovs
  324. movnxt:
  325.     move.b (a0)+,(a1)+
  326. stmovs:
  327.     dbra    d0,movnxt
  328.     rts
  329.  
  330. * --
  331. *
  332. * min    Returns minimum value of two words
  333. *        C binding:    min(a,b);
  334. *                int    a,b;
  335. * --
  336. _min:
  337.     move.w    4(sp),d0    ; d0 = a
  338.     cmp.w    6(sp),d0    ; if (a < b)
  339.     blt    genret
  340.     bra    minmax
  341.  
  342. * --
  343. *
  344. * max    Returns maximum value of two words
  345. *        C binding:    max(a,b);
  346. *                int    a,b;
  347. * --
  348. _max:
  349.     move.w    4(sp),d0    ; d0 = a
  350.     cmp.w    6(sp),d0    ; if (a > b)
  351.     bgt    genret
  352. minmax:
  353.     move.w    6(sp),d0
  354. genret:
  355.     rts            ; general rts
  356.  
  357. * --
  358. *
  359. * bfill        Copy the byte passed in to the dest pointer for a count of N
  360. *        C binding:    bfill(count,byte,dest);
  361. *                int    count;
  362. *                byte    byte;
  363. *                byte    *dest;
  364. * --
  365. _bfill:
  366.     move.w    4(sp),d0    ; d0 = count
  367.     move.b    7(sp),d1    ; d1 = byte
  368.     move.l    8(sp),a0    ; a0 = dest
  369.     bra    bfout
  370. bfnxt:
  371.     move.b    d1,(a0)+
  372. bfout:
  373.     dbra    d0,bfnxt
  374.     rts
  375.  
  376. * --
  377. *
  378. * toupper    Return upper case value
  379. *        C binding:    toupper(chr);
  380. *                byte    chr;
  381. * --
  382. _toupper:
  383.     move.b    5(sp),d0    ; d0 = chr
  384.     ext.w    d0        ; extend to word
  385.     cmp.w    #97,d0        ; if (chr >= 'a')
  386.     blt    toupout
  387.     cmp.w    #122,d0        ; if (chr <= 'z')
  388.     bgt    toupout
  389.     add.w     #-32,d0    ; upper it
  390. toupout:
  391.     rts
  392.  
  393.  
  394. * --
  395. *
  396. * strlen    Need I say more
  397. *        C binding:    word    strlen(ptr);
  398. *                    byte    *ptr;
  399. * --
  400. _strlen:
  401.     move.l    4(sp),a0    ; a0 -> string
  402.     clr.w    d0
  403. strnxt:
  404.     tst.b    (a0)+        ; if (end of string)
  405.     beq    genrts
  406.     addq.w    #1,d0        ; inc count
  407.     bra    strnxt
  408.  
  409. * --
  410. *
  411. * strcmp    dito
  412. *        C binding:    word    strcmp(ptr1,ptr2);
  413. *                    byte    *ptr1,*ptr2;
  414. * --
  415. _strcmp:
  416.     movem.l 4(sp),a0-a1    ; a0 ->string1, a1 ->string2
  417. cmpnxt:
  418.     tst.b    (a0)        ; if (we have char)
  419.     beq    cmp1
  420.     cmpm.b (a0)+,(a1)+    ; if (they match)
  421.     beq    cmpnxt
  422.     bra    retfalse
  423. cmp1:
  424.     tst.b    (a1)        ; if (no char)
  425.     bne    retfalse
  426.     bra    rettrue        ; else ret true
  427.  
  428. * --
  429. *
  430. * strcpy    dito dito
  431. *        C binding:    byte    *strcpy(src,dst);
  432. *                    byte    *src,*dst;
  433. * --
  434. _strcpy:
  435.     movem.l    4(sp),a0-a1    ; a0 -> src, a1 -> dst
  436. cpynxt:
  437.     move.b    (a0)+,(a1)+    ; dst = src
  438.     bne    cpynxt
  439.     bra    catscn
  440.  
  441. * --
  442. *
  443. * strscn    copy the src to destination untill we are out of characters
  444. *        or we get a char match.
  445. *        C binding:    byte    *strscn(src,dst,stopchar);
  446. *                    byte    *src,*dst,stopchar;
  447. *
  448. * --
  449. _strscn:
  450.     movem.l    4(sp),a0-a1    ; a0 -> src, a1 -> dst
  451.     move.b    13(sp),d0    ; d0 = char
  452. scnxt:
  453.     cmp.b    (a0),d0        ; if( (src) != char)
  454.     beq    catscn
  455.     tst.b    (a0)        ; && (we have source)
  456.     beq    catscn
  457.     move.b    (a0)+,(a1)+
  458.     bra    scnxt
  459.  
  460. * --
  461. *
  462. * strcat    dito dito dito
  463. *        C binding:    byte    *strcat(src,dst);
  464. * --
  465. _strcat:
  466.     movem.l    4(sp),a0-a1    ; a0 -> src, a1 -> dst
  467. catend:
  468.     tst.b    (a1)+        ; if (not at end of dst string)
  469.     bne    catend
  470.     sub.l    #1,a1        ; now at end of str
  471. ;
  472. catnxt:
  473.     move.b    (a0)+,(a1)+    ; dst = scr
  474.     bne    catnxt
  475. catscn:
  476.     move.l    a1,d0        ; return dest pointer
  477.     rts
  478.  
  479. * --
  480. *
  481. * scasb        Returns a byte pointer pointing to the matched byte or
  482. *        the end of the string.
  483. *        C binding:    byte    *scasb(ptr,byte);
  484. *                    byte    *ptr,byte;
  485. *
  486. * --
  487. _scasb:
  488.     move.l    4(sp),a1    ; a1 -> string
  489.     move.b    9(sp),d0    ; d0 = byte
  490. scanxt:
  491.     tst.b    (a1)        ; if (end of string)
  492.     beq    catscn
  493.     cmp.b    (a1),d0        ; if ((ptr) == byte)
  494.     beq    catscn
  495.     add.l    #1,a1        ; next char
  496.     bra    scanxt
  497.  
  498.  
  499. * --
  500. *
  501. * strchk    This is the true version of strcmp. Shall we remove the
  502. *        other -we shall see!!!
  503. *        Returns    - <0 if(str1<str2), 0 if(str1=str2), >0 if(str1>str2)
  504. *        C binding:    word    strchk(str1,str2);
  505. *                    byte    *str1,*str2;
  506. *
  507. * --
  508. _strchk:
  509.     movem.l    4(sp),a0-a1    ; a0 -> string 1, a1 -> string 2
  510.     clr.w    d0        ; init to strings equal
  511. chknxt:
  512.     move.b    (a0),d1        ; get str1 char
  513.     cmp.b    (a1)+,d1    ; if ( strings are not equal )
  514.     bne    chk1
  515.     tst.b    (a0)+        ; if ( end of string )
  516.     beq    chkout
  517.     bra    chknxt
  518. chk1:
  519.     move.b    (a0),d0
  520.     ext.w    d0
  521.     move.b    -1(a1),d1    ; a1 is ahead by 1 at this point
  522.     ext.w    d1
  523.     sub.w    d1,d0        ; return (byte1 - byte2)
  524. chkout:
  525.     rts
  526.  
  527. ; --
  528. ;
  529. ; fmt_str    Routine to strip out '.' from string and return raw
  530. ;        data. Pad with spaces ex. "this.p" to "this    p"
  531. ;        C binding:    fmt_str(src,dst);
  532. ;                    byte    ;src,*dst;
  533. ; --
  534. _fmt_str:
  535.     movem.l    4(sp),a0-a1    ; a0 -> src, a1 -> dst
  536.     move.w    #7,d0        ; init for filename
  537. fmtnxt:
  538.     tst.b    (a0)
  539.     beq    padit
  540.     cmp.b    #DOT,(a0)    ; char = '.'    
  541.     beq    padit
  542.     move.b (a0)+,(a1)+    ; copy char
  543.     dbra    d0,fmtnxt
  544.     bra    extens
  545. padit:
  546.     tst.b    (a0)
  547.     beq    unfout
  548. fmt1:
  549.     move.b #' ',(a1)+    ; pad with ' '
  550.     dbra    d0,fmt1
  551. extens:
  552.     tst.b    (a0)+        ; inc past '.'
  553.     beq    unfout        ; if(null) exit
  554. fmt2:
  555.     tst.b    (a0)
  556.     beq    unfout
  557.     move.b (a0)+,(a1)+    ; copy char
  558.     bra    fmt2
  559.  
  560. * --
  561. *
  562. * unfmt_str    Routine to convert a string of type "mike    xxx" to
  563. *        a dos string of "mike.xxx"
  564. *        C binding:    unfmt_str(src,dst);
  565. *                byte    *src,*dst;
  566. * --
  567. _unfmt_st:
  568.     movem.l    4(sp),a0-a1    ; a0 -> src, a1 -> dst
  569.     move.w    #7,d0        ; init for filename
  570. unfnxt:
  571.     move.b    (a0)+,d1    ; get char
  572.     tst.b    d1    
  573.     beq    unfout        ; no more character
  574.     cmp.b    #SPACE,d1    ; if (space)
  575.     beq    unfskip
  576.     move.b    d1,(a1)+    ; copy char
  577. unfskip:
  578.     dbra    d0,unfnxt
  579.     tst.b    (a0)        ; fix the dot
  580.     beq    unfout
  581.     move.b    #DOT,(a1)+    ; add '.'
  582. unfext:
  583.     tst.b    (a0)        ; If (extension)
  584.     beq    unfout
  585.     move.b    (a0)+,(a1)+
  586.     bra    unfext
  587. unfout:
  588.     clr.b    (a1)        ; null terminate dest
  589.     rts
  590.  
  591.  
  592. * --
  593. *
  594. * fs_sset    Copy the long in the ob_spec field to the callers variable
  595. *        ptext.  Next copy the string located at the ob_spec long to the
  596. *        callers pstr.  Finally copy the length of the tedinfo string
  597. *        to the callers ptxtlen.
  598. *        C binding:    fs_sset(tree,obj,pstr,ptext,ptxtlen);
  599. *                    long    tree,pstr,*ptext;
  600. *                    word    obj,*ptxtlen;
  601. * --
  602. _fs_sset:
  603.     move.l    14(sp),a1    ; a1 -> ptext
  604. ;
  605.     move.l    #OB_SPEC,a0    ; a0 = ob_spec offset
  606.     bsr    get_addr
  607.     move.l    (a0),a0        ; a0 -> tedinfo block
  608. ;
  609.     move.l    (a0),(a1)    ; set callers ptext to tedinfo data string
  610.     move.l    a0,-(sp)    ; save pointer to tedinfo block
  611. ;
  612.     move.l 14(sp),-(sp)    ; sp = pstr
  613.     move.l (a0),-(sp)    ; sp = tedinfo text data
  614.     addq.l #8,sp
  615.     move.l    (sp)+,a0    ; get pointer to tedinfo structure
  616. ;
  617.     move.l    18(sp),a1    ; ptxtlen
  618.     add.l    #TEDTXTLEN,a0    ; now points to tedinfo text length
  619.     move.w    (a0),(a1)    ; store it
  620.     rts
  621.  
  622. * --
  623. *
  624. * inf_sset
  625. *        C binding:    inf_sset(tree,obj,pstr,&text,&txtlen);
  626. *
  627. * --
  628. _inf_sset:
  629.     link    a6,#-8        ; room for temp variables
  630.     pea    $FFFA(a6)    ; addr of txtlen    (-6)
  631.     pea    $FFFC(a6)    ; addr of text        (-4)
  632.     move.l    14(a6),-(sp)    ; pstr
  633.     move.w    12(a6),-(sp)    ; obj
  634.     move.l    8(a6),-(sp)    ; tree
  635.     jsr    _fs_sset
  636.     adda.l    #18,sp
  637.     unlk    a6
  638.     rts
  639.  
  640. * --
  641. * inf_sget
  642. * fs_sget    This routine copies the tedinfo string to the dst pointer.
  643. *        The function inf_sget was the same as fs_sget.
  644. *        C binding:    inf_sget(tree,obj,dst);
  645. *        C binding:    fs_sget(tree,obj,dst);
  646. *                long    tree,dst;
  647. *                word    obj;
  648. * --
  649. _inf_sget:
  650. _fs_sget:
  651.     move.l    #OB_SPEC,a0    ; a0 = offset to ob_spec
  652.     bsr    get_addr
  653.     move.l    (a0),a0        ; a0 = ob_spec pointer
  654. ;
  655.     move.l    (a0),-(sp)    ; sp = addr of tedinfo str
  656.     move.l    14(sp),-(sp)    ; sp = destination
  657.     addq.l    #8,sp
  658.     rts
  659.  
  660.  
  661.  
  662. * --
  663. * f_fldset    This routine is used to set an objects flags based on 
  664. *        the outcome of a 'and' operation.  The word is set to
  665. *        the 'truestate' if the operation is true else set to
  666. *        'falsestate'
  667. *    C binding: inf_fldset(tree,obj,tstfld,tstbit,truestate,falsestate);
  668. *
  669. * --
  670. _inf_fldset:
  671.     move.l    #OB_STATE,a0    ; a0 = offset to ob_state
  672.     bsr    get_addr
  673. ;
  674.     clr    d0
  675.     move.w    10(sp),d0    ; d0 = tstfld
  676.     and.w    12(sp),d0    ; d0 = tstfld & tstbit
  677.     beq    false
  678.     move.w    14(sp),(a0)    ; set the word to the 'truestate'
  679.     bra    inf1
  680. false:
  681.     move.w    16(sp),(a0)    ; set the word to the 'falsestate'
  682. inf1:
  683.     rts
  684.  
  685.  
  686. * --
  687. *
  688. * inf_gindex    for each object from baseobj for N objects return the object
  689. *        that is selected or -1 if no objects are selected.
  690. *        C binding:    inf_gindex(tree,baseobj,n);
  691. *                    word    baseobj,n;
  692. *                    long    tree;
  693. * --
  694. _inf_gind:
  695.     move.l    #OB_STATE+1,a0    ; a0 = offset to byte to test
  696.     bsr    get_addr
  697. ;
  698.     move.w    10(sp),d0    ; d0 = n
  699.     subq.w    #1,d0        ; adjust for dbra
  700.     move.w    d0,d1        ; d1 = copy of count
  701. nxtstat:
  702.     btst.b    #0,(a0)        ; if( OB_STATE & SELECTED)
  703.     beq    gind1
  704.     sub.w    d1,d0        ; get object number
  705.     bra    gindout
  706. gind1:
  707.     adda.l    #OB_SIZE,a0    ; next object state to test
  708.     dbra    d1,nxtstat
  709.     move.w    d1,d0        ; d0 = -1
  710. gindout:
  711.     rts
  712.  
  713. * --
  714. *
  715. * inf_what    Return     0 is cancel was selected
  716. *             1 if ok was selected
  717. *            -1 if nothing is selected
  718. *        If an object was selected then deselect it.
  719. *        C binding:    inf_what(tree,ok,cancel);
  720. *                    word    ok,cancel;
  721. *                    long    tree;
  722. * --
  723. _inf_what:
  724.     move.w    #2,-(sp)    ; sp = 2
  725.     move.w    10(sp),-(sp)    ; sp = ok
  726.     move.l    8(sp),-(sp)    ; sp = tree
  727.     ;jsr    _inf_gin    
  728.     ; find selected object
  729.     addq.l    #8,sp
  730. ;
  731.     cmp.w    #-1,d0        ; if (ret == -1)
  732.     beq    genrts
  733. ;
  734.     move.w    d0,d1        ; save return value
  735. ;
  736.     add.w    d0,8(sp)    ; 8(sp) = object# + ret
  737.     move.l    #OB_STATE,a0    ; a0 = offset to ob_state
  738.     bsr    get_addr
  739. ;
  740.     clr.w    (a0)        ; set ob_state to NORMAL
  741.     tst.w    d1
  742.     beq    rettrue
  743. *
  744. * general return true/false exit point
  745. *
  746. retfalse:
  747.     clr.w    d0
  748.     bra    genrts
  749. rettrue:
  750.     move.w    #1,d0        ; return 1 if ok is selected
  751. genrts:
  752.     rts
  753.  
  754.  
  755.  
  756. * --
  757. * merge_str
  758. *        C binding:    merge_str(dest,src,parms);
  759. *                    byte    *dest,src;
  760. *                    uword    parms[];
  761. * --
  762.  
  763. PARMS    =    7*4
  764.  
  765. _merge_st:
  766.     movem.l    d3-d6/a3-a5,-(sp)    ; save d3,d4,d5,d6,a3,a4,a5
  767.     movem.l    PARMS+4(sp),a3-a5    ; a3 -> dest, a4 -> src, a5 -> parms
  768.     clr.w    d3            ; d3 = parms[] index
  769. ;
  770. mernxt:
  771.     tst.b    (a4)        ; if (char = 0) get out
  772.     beq    merout
  773. ;
  774.     cmp.b    #'%',(a4)    ; if(char == '%')
  775.     beq    do_per
  776.     move.b    (a4)+,(a3)+    ; dest = src
  777.     bra    mernxt
  778. ;
  779. do_per:
  780.     tst.b    (a4)+        ; inc past '%'
  781.     move.b    (a4)+,d0
  782.     cmp.b    #PERCENT,d0    ; if (char != '%')
  783.     bne    ltest
  784.     move.b    d0,(a3)+    ; dest = '%'
  785.     bra    mernxt
  786. ltest:
  787.     cmp.b    #CAP_L,d0    ; if (char != 'L')
  788.     bne    wtest
  789.     move.w    d3,a0        ; a0 = num
  790.     add.l    a5,a0        ; a0 = &parms[] + num (index)
  791.     move.l    (a0),d4        ; d4 = lvalue
  792.     addq.w    #4,d3        ; inc num
  793.     bra    dovalue
  794. wtest:
  795.     cmp.b    #CAP_W,d0    ; if (char != 'W')
  796.     bne    stest
  797.     clr.l    d4        ; d4 = 0
  798.     move.w    d3,a0        ; a0 = num
  799.     add.l    a5,a0        ; a0 = &parms[] + num (index)
  800.     move.w    (a0),d4        ; d4 = lvalue
  801.     addq.w    #4,d3        ; inc num
  802.     bra    dovalue
  803. stest:
  804.     cmp.b    #CAP_S,d0    ; if (char != 'S')
  805.     bne    mernxt        ; else do next character
  806.     move.w    d3,a0        ; a0 = num
  807.     add.l    a5,a0        ; a0 = &parms[] + num (index)
  808.     move.l    (a0),a0        ; a0 = src pointer
  809.     addq.w    #4,d3        ; inc num
  810. s1:
  811.     tst.b    (a0)        ; If (character)
  812.     beq    mernxt        ; do next character
  813.     move.b    (a0)+,(a3)+    ; dest = src
  814.     bra    s1
  815. ;
  816. dovalue:
  817.     clr.l    d5        ; d5 is index
  818.     sub.l    #16,sp        ; get room on stack
  819. ;
  820. nxtdigit:
  821.     tst.l    d4        ; more digits (lvalue)
  822.     beq    nomore
  823.     move.l    #$a,-(sp)
  824.     move.l    d4,-(sp)
  825.         ;jsr    ldiv
  826.     move.l    d0,d6        ; x = d6 = lvalue / 10
  827.     move.l    d0,(sp)
  828.     ;jsr    lmul
  829.     addq.l #8,sp        ; d0 = (x * 10)
  830.     move.l    d4,d2
  831.     sub.l    d0,d2        ; d2 = lvalue - (x * 10)
  832.     add    #$30,d2        ; d2 = ascii value
  833.     move.b    d2,(sp,d5.w)    ; save character
  834.     add.w    #1,d5        ; inc index
  835.     move.l    d6,d4        ; lvalue = x
  836.     bra    nxtdigit
  837. nomore:
  838.     subq.w    #1,d5        ; adjust for dbra
  839.     bge    ascdig
  840.     move.b    #'0',(a3)+    ; move digit
  841.     bra    stclean
  842. ascdig:
  843.     move.b    (sp,d5.w),(a3)+    ; copy digit
  844.     dbra    d5,ascdig
  845. stclean:
  846.     add.l    #16,sp        ; clean up stack
  847.     bra    mernxt
  848. merout:
  849.     clr.b    (a3)        ; null terminate string
  850.     movem.l    (sp)+,d3-d6/a3-a5 ; restore d3,d4,d5,d6,a3,a4,a5
  851.     rts
  852.  
  853. * --
  854. *
  855. * wildcmp
  856. *        C binding:    wildcmp(pwild,ptest);
  857. *                    byte    *pwild,*ptest;
  858. * --
  859.  
  860. _wildcmp:
  861.     movem.l 4(sp),a0-a1    ; a0-> pwild, a1 -> ptest
  862. wildnxt:
  863.     tst.b    (a0)        ; no pwild source
  864.     beq    wld5
  865.     tst.b    (a1)        ; no ptest source
  866.     beq    wld5
  867.     cmp.b    #QUEST,(a0)    ; if ( *pwild != '?' )
  868.     bne    wld1
  869.     add.l    #1,a0        ; pwild += 1
  870.     cmp.b    #DOT,(a1)    ; if ( *ptest != '.')
  871.     beq    wildnxt
  872. inctest:
  873.     add.l    #1,a1        ; ptest += 1
  874.     bra    wildnxt
  875. wld1:
  876.     cmp.b    #STAR,(a0)    ; if (*pwild != '*')
  877.     bne    wld2
  878.     cmp.b    #DOT,(a1)    ; if (*ptest != '.')
  879.     bne    inctest
  880.     add.l    #1,a0        ; pwild += 1
  881.     bra    wildnxt
  882. wld2:
  883.     move.b    (a0),d0
  884.     cmp.b    (a1),d0        ; if (*pwild == *ptest)
  885.     bne    wldfalse
  886.     add.l    #1,a0        ; pwild += 1
  887.     bra    inctest
  888. wld6:
  889.     add.l    #1,a0        ; pwild++
  890. wld5:
  891.     cmp.b    #STAR,(a0)    ; if (*pwild == '*')
  892.     beq    wld6
  893.     cmp.b    #QUEST,(a0)    ; || (*pwild == '?')
  894.     beq    wld6
  895.     cmp.b    #DOT,(a0)    ; || (*pwild == '.')
  896.     beq    wld6
  897. *
  898.     tst.b    (a0)        ; if (*pwild == char)
  899.     bne    wldfalse
  900.     tst.b    (a1)        ; || (*ptest == char)
  901.     bne    wldfalse
  902.     move.w    #1,d0        ; return true
  903.     bra    wldout
  904. wldfalse:
  905.     clr.w    d0        ; else return false
  906. wldout:
  907.     rts
  908.  
  909.  
  910. * --
  911. *
  912. * get_addr    Calculate the objects address given:
  913. *            a0 = object offset
  914. *            12(sp) = object
  915. *            8(sp)  = tree
  916. *--
  917. get_addr:
  918.     move.w    12(sp),d0    ; d0 = object
  919.     muls    #OB_SIZE,d0    ; d0 = object ; ob_size
  920.     add.l    8(sp),a0    ; a0 = tree + offset
  921.     add.l    d0,a0        ; a0 -> desired word or long
  922.     rts
  923.  
  924.  
  925. *    OPTIMIZE.C    1/25/84 - 01/27/85    Lee Jay Lorenzen    */
  926. *    reg op 68k    2/10/85 - 04/03/85    LKW            */
  927. *    remove mid,cmps 06/10/85        Mike Schmal        */
  928. *        bit_num    06/10/85        Mike Schmal        */
  929. *    Fix the bfill    4/3/86            Derek Mui        */
  930. *
  931. *
  932. *    -------------------------------------------------------------
  933. *    GEM Application Environment Services          Version 1.1
  934. *    Serial No.  XXXX-0000-654321          All Rights Reserved
  935. *    Copyright (C) 1985            Digital Research Inc.
  936. *    -------------------------------------------------------------
  937. **/
  938. *
  939. *#include <portab.h>
  940. *#include <machine.h>
  941. *#include <taddr.h>
  942. *#include <obdefs.h>
  943. *
  944. *
  945. *EXTERN WORD    gl_wchar;
  946. *EXTERN WORD    gl_hchar;
  947. *
  948. *
  949. *r_get(pxywh, px, py, pw, ph)
  950. *    REG WORD    *pxywh;
  951. *    WORD        *px, *py, *pw, *ph;
  952. *{
  953. *    *px = pxywh[0];
  954. *    *py = pxywh[1];
  955. *    *pw = pxywh[2];
  956. *    *ph = pxywh[3];
  957. *}
  958. *
  959. *
  960. *
  961. *r_set(pxywh, x, y, w, h)
  962. *    REG WORD    *pxywh;
  963. *    WORD        x, y, w, h;
  964. *{
  965. *    pxywh[0] = x;
  966. *    pxywh[1] = y;
  967. *    pxywh[2] = w;
  968. *    pxywh[3] = h;
  969. *}
  970. *
  971. *
  972. *rc_constrain(pc, pt)
  973. *    REG GRECT    *pc;
  974. *    REG GRECT    *pt;
  975. *{
  976. *      if (pt->g_x < pc->g_x)
  977. *        pt->g_x = pc->g_x;
  978. *      if (pt->g_y < pc->g_y)
  979. *        pt->g_y = pc->g_y;
  980. *      if ((pt->g_x + pt->g_w) > (pc->g_x + pc->g_w))
  981. *        pt->g_x = (pc->g_x + pc->g_w) - pt->g_w;
  982. *      if ((pt->g_y + pt->g_h) > (pc->g_y + pc->g_h))
  983. *        pt->g_y = (pc->g_y + pc->g_h) - pt->g_h;
  984. *}
  985. *
  986. *
  987. *rc_copy(psxywh, pdxywh)
  988. *    REG WORD    *psxywh;
  989. *    REG WORD    *pdxywh;
  990. *{
  991. *    *pdxywh++ = *psxywh++;
  992. *    *pdxywh++ = *psxywh++;
  993. *    *pdxywh++ = *psxywh++;
  994. *    *pdxywh++ = *psxywh++;
  995. *}
  996. *
  997. *
  998. *    VOID
  999. *rc_union(p1, p2)
  1000. *    REG GRECT    *p1, *p2;
  1001. *{
  1002. *    REG WORD    tx, ty, tw, th;
  1003. *
  1004. *    tw = max(p1->g_x + p1->g_w, p2->g_x + p2->g_w);
  1005. *    th = max(p1->g_y + p1->g_h, p2->g_y + p2->g_h);
  1006. *    tx = min(p1->g_x, p2->g_x);
  1007. *    ty = min(p1->g_y, p2->g_y);
  1008. *    p2->g_x = tx;
  1009. *    p2->g_y = ty;
  1010. *    p2->g_w = tw - tx;
  1011. *    p2->g_h = th - ty;
  1012. *}
  1013. *
  1014. *
  1015. *    WORD
  1016. *rc_intersect(p1, p2)
  1017. *    REG GRECT    *p1, *p2;
  1018. *{
  1019. *    REG WORD    tx, ty, tw, th;
  1020. *
  1021. *    tw = min(p2->g_x + p2->g_w, p1->g_x + p1->g_w);
  1022. *    th = min(p2->g_y + p2->g_h, p1->g_y + p1->g_h);
  1023. *    tx = max(p2->g_x, p1->g_x);
  1024. *    ty = max(p2->g_y, p1->g_y);
  1025. *    p2->g_x = tx;
  1026. *    p2->g_y = ty;
  1027. *    p2->g_w = tw - tx;
  1028. *    p2->g_h = th - ty;
  1029. *    return( (tw > tx) && (th > ty) );
  1030. *}
  1031. *
  1032. *
  1033. *    UWORD
  1034. *inside(x, y, pt)
  1035. *    REG WORD    x, y;
  1036. *    REG GRECT    *pt;
  1037. *{
  1038. *    if ( (x >= pt->g_x) && (y >= pt->g_y) &&
  1039. *         (x < pt->g_x + pt->g_w) && (y < pt->g_y + pt->g_h) )
  1040. *      return(TRUE);
  1041. *    else
  1042. *      return(FALSE);
  1043. *} /* inside */
  1044. *
  1045. *
  1046. *    WORD
  1047. *rc_equal(p1, p2)
  1048. *    REG WORD    *p1, *p2;
  1049. *{
  1050. *    REG WORD    i;
  1051. *
  1052. *    for(i=0; i<4; i++)
  1053. *    {
  1054. *      if (*p1++ != *p2++)
  1055. *        return(FALSE);
  1056. *    }
  1057. *    return(TRUE);
  1058. *}
  1059. *
  1060. *
  1061. *    VOID
  1062. *movs(num, ps, pd)
  1063. *    REG WORD    num;
  1064. *    REG BYTE    *ps, *pd;
  1065. *{
  1066. *    do
  1067. *      *pd++ = *ps++;
  1068. *    while (--num);
  1069. *}
  1070. *
  1071. *
  1072. *    WORD
  1073. *min(a, b)
  1074. *    WORD        a, b;
  1075. *{
  1076. *    return( (a < b) ? a : b );
  1077. *}
  1078. *
  1079. *
  1080. *    WORD
  1081. *max(a, b)
  1082. *    WORD        a, b;
  1083. *{
  1084. *    return( (a > b) ? a : b );
  1085. *}
  1086. *
  1087. *
  1088. *
  1089. *    VOID
  1090. *bfill(num, bval, addr)
  1091. *    REG WORD    num;
  1092. *    REG BYTE    bval;
  1093. *    REG BYTE    *addr;
  1094. *{
  1095. *    while(num)
  1096. *    {
  1097. *      *addr++ = bval;
  1098. *      num --;
  1099. *    }
  1100. *}
  1101. *
  1102. *
  1103. *    BYTE
  1104. *toupper(ch)
  1105. *    REG BYTE    ch;
  1106. *{
  1107. *    if ( (ch >= 'a') &&
  1108. *         (ch <= 'z') )
  1109. *      return(ch - 32);
  1110. *    else
  1111. *      return(ch);
  1112. *}
  1113. *
  1114. *    BYTE
  1115. **scasb(p, b)
  1116. *    REG BYTE        *p;
  1117. *    REG BYTE        b;
  1118. *{
  1119. *    for(; *p && *p != b; p++);
  1120. *    return (p);
  1121. *}
  1122. *
  1123. *    WORD
  1124. *strlen(p1)
  1125. *    REG BYTE    *p1;
  1126. *{
  1127. *    REG WORD    len;
  1128. *
  1129. *    len = 0;
  1130. *    while( *p1++ )
  1131. *      len++;
  1132. *
  1133. *    return(len);
  1134. *}
  1135. *
  1136. *
  1137. *    WORD
  1138. *strcmp(p1, p2)
  1139. *    REG BYTE    *p1, *p2;
  1140. *{
  1141. *    while(*p1)
  1142. *    {
  1143. *      if (*p1++ != *p2++)
  1144. *        return(FALSE);
  1145. *    }
  1146. *    if (*p2)
  1147. *      return(FALSE);
  1148. *    return(TRUE);
  1149. *}
  1150. *
  1151. *
  1152. */*
  1153. **    Return <0 if s<t, 0 if s==t, >0 if s>t
  1154. **/
  1155. *
  1156. *    WORD
  1157. *strchk(s, t)
  1158. *    REG BYTE    s[], t[];
  1159. *{
  1160. *    REG WORD    i;
  1161. *
  1162. *    i = 0;
  1163. *    while( s[i] == t[i] )
  1164. *      if (s[i++] == NULL)
  1165. *        return(0);
  1166. *    return(s[i] - t[i]);
  1167. *}
  1168. *
  1169. *
  1170. *    BYTE
  1171. **strcpy(ps, pd)
  1172. *    REG BYTE    *ps, *pd;
  1173. *{
  1174. *    while(*pd++ = *ps++)
  1175. *      ;
  1176. *    return(pd);
  1177. *}
  1178. *
  1179. *
  1180. *    BYTE
  1181. **strscn(ps, pd, stop)
  1182. *    REG BYTE    *ps, *pd, stop;
  1183. *{
  1184. *    while ( (*ps) &&
  1185. *        (*ps != stop) )
  1186. *      *pd++ = *ps++;
  1187. *    return(pd);
  1188. *}
  1189. *
  1190. *
  1191. *    BYTE
  1192. **strcat(ps, pd)
  1193. *    REG BYTE    *ps, *pd;
  1194. *{
  1195. *    while(*pd)
  1196. *      pd++;
  1197. *    while(*pd++ = *ps++)
  1198. *      ;
  1199. *    return(pd);
  1200. *}
  1201. *
  1202. *
  1203. */*
  1204. **    Strip out period and turn into raw data.
  1205. **/
  1206. *    VOID
  1207. *fmt_str(instr, outstr)
  1208. *    REG BYTE    *instr, *outstr;
  1209. *{
  1210. *    REG WORD    count;
  1211. *    REG BYTE    *pstr;
  1212. *
  1213. *    pstr = instr;
  1214. *    while( (*pstr) && (*pstr != '.') )
  1215. *      *outstr++ = *pstr++;
  1216. *    if (*pstr)
  1217. *    {
  1218. *      count = 8 - (pstr - instr);
  1219. *      while ( count-- )
  1220. *        *outstr++ = ' ';
  1221. *      pstr++;
  1222. *      while (*pstr)
  1223. *        *outstr++ = *pstr++;
  1224. *    }
  1225. *    *outstr = NULL;
  1226. *}
  1227. *
  1228. *
  1229. */*
  1230. **    Insert in period and make into true data.
  1231. **/
  1232. *    VOID
  1233. *unfmt_str(instr, outstr)
  1234. *    REG BYTE    *instr, *outstr;
  1235. *{
  1236. *    REG BYTE    *pstr, temp;
  1237. *
  1238. *    pstr = instr;
  1239. *    while( (*pstr) && ((pstr - instr) < 8) )
  1240. *    {
  1241. *      temp = *pstr++;
  1242. *      if (temp != ' ')
  1243. *        *outstr++ = temp;
  1244. *    }
  1245. *    if (*pstr)
  1246. *    {
  1247. *      *outstr++ = '.';
  1248. *      while (*pstr)
  1249. *        *outstr++ = *pstr++;
  1250. *    }
  1251. *    *outstr = NULL;
  1252. *}
  1253. *
  1254. *
  1255. *    VOID
  1256. *fs_sset(tree, obj, pstr, ptext, ptxtlen)
  1257. *    LONG        tree;
  1258. *    WORD        obj;
  1259. *    LONG        pstr;
  1260. *    REG LONG    *ptext;
  1261. *    WORD        *ptxtlen;
  1262. *{
  1263. *    REG LONG    spec;
  1264. *
  1265. *    *ptext = LLGET( spec = LLGET(OB_SPEC(obj)) );
  1266. *    LSTCPY(*ptext, pstr);
  1267. *    *ptxtlen = LWGET( spec + 24 );
  1268. *}
  1269. *
  1270. *
  1271. *    VOID
  1272. *inf_sset(tree, obj, pstr)
  1273. *    LONG        tree;
  1274. *    WORD        obj;
  1275. *    BYTE        *pstr;
  1276. *{
  1277. *    LONG        text;
  1278. *    WORD        txtlen;
  1279. *
  1280. *    fs_sset(tree, obj, ADDR(pstr), &text, &txtlen);
  1281. *}
  1282. *
  1283. *
  1284. *    VOID
  1285. *fs_sget(tree, obj, pstr)
  1286. *    LONG        tree;
  1287. *    WORD        obj;
  1288. *    LONG        pstr;
  1289. *{
  1290. *    LONG        ptext;
  1291. *
  1292. *    ptext = LLGET( LLGET(OB_SPEC(obj)) );
  1293. *    LSTCPY(pstr, ptext);
  1294. *}
  1295. *
  1296. *
  1297. *    VOID
  1298. *inf_sget(tree, obj, pstr)
  1299. *    LONG        tree;
  1300. *    WORD        obj;
  1301. *    BYTE        *pstr;
  1302. *{
  1303. *    fs_sget(tree, obj, ADDR(pstr));
  1304. *}
  1305. *
  1306. *
  1307. *    VOID
  1308. *inf_fldset(tree, obj, testfld, testbit, truestate, falsestate)
  1309. *    LONG        tree;
  1310. *    WORD        obj;
  1311. *    UWORD        testfld, testbit;
  1312. *    UWORD        truestate, falsestate;
  1313. *{
  1314. *    LWSET(OB_STATE(obj), (testfld & testbit) ? truestate : falsestate);
  1315. *}
  1316. *
  1317. *
  1318. *    WORD
  1319. *inf_gindex(tree, baseobj, numobj)
  1320. *    LONG        tree;
  1321. *    WORD        baseobj;
  1322. *    WORD        numobj;
  1323. *{
  1324. *    WORD        retobj;
  1325. *
  1326. *    for (retobj=0; retobj < numobj; retobj++)
  1327. *    {
  1328. *      if (LWGET(OB_STATE(baseobj+retobj)) & SELECTED)
  1329. *        return(retobj);
  1330. *    }
  1331. *    return(-1);
  1332. *}
  1333. *
  1334. *
  1335. */*
  1336. **    Return 0 if cancel was selected, 1 if okay was selected, -1 if
  1337. **    nothing was selected.
  1338. **/
  1339. *
  1340. *    WORD
  1341. *inf_what(tree, ok, cncl)
  1342. *    REG LONG        tree;
  1343. *    REG WORD        ok, cncl;
  1344. *{
  1345. *    REG WORD        field;
  1346. *
  1347. *    field = inf_gindex(tree, ok, 2);
  1348. *
  1349. *    if (field != -1)
  1350. *    {
  1351. *      LWSET(OB_STATE(ok + field), NORMAL);
  1352. *      field = (field == 0);
  1353. *    }
  1354. *    return(field);
  1355. *}
  1356. *
  1357. *
  1358. *    WORD
  1359. *merge_str(pdst, ptmp, parms)
  1360. *    REG BYTE    *pdst;
  1361. *    REG BYTE    *ptmp;
  1362. *    UWORD        parms[];    
  1363. *{
  1364. *    REG WORD        num;
  1365. *    WORD        do_value;
  1366. *    BYTE        lholder[12];
  1367. *    REG BYTE        *pnum;
  1368. *    BYTE        *psrc;
  1369. *    REG LONG        lvalue, divten;
  1370. *    WORD        digit;
  1371. *
  1372. *    num = 0;
  1373. *    while(*ptmp)
  1374. *    {
  1375. *      if (*ptmp != '%')
  1376. *        *pdst++ = *ptmp++;
  1377. *      else
  1378. *      {
  1379. *        ptmp++;
  1380. *        do_value = FALSE;
  1381. *        switch(*ptmp++)
  1382. *        {
  1383. *          case '%':
  1384. *        *pdst++ = '%';
  1385. *        break;
  1386. *          case 'L':
  1387. *        lvalue = *((LONG *) &parms[num]);
  1388. *        num += 2;
  1389. *        do_value = TRUE;
  1390. *        break;
  1391. *          case 'W':
  1392. *        lvalue = parms[num];
  1393. *#if MC68K
  1394. *        num += 2;
  1395. *#endif
  1396. *#if I8086
  1397. *        num++;
  1398. *#endif
  1399. *        do_value = TRUE;
  1400. *        break;
  1401. *          case 'S':
  1402. *        psrc = (BYTE *) parms[num]; 
  1403. *#if MC68K
  1404. *        num += 2;
  1405. *#endif
  1406. *#if I8086
  1407. *        num++;
  1408. *#endif
  1409. *        while(*psrc)
  1410. *          *pdst++ = *psrc++;
  1411. *        break;
  1412. *        }
  1413. *        if (do_value)
  1414. *        {
  1415. *          pnum = &lholder[0];
  1416. *          while(lvalue)
  1417. *          {
  1418. *        divten = lvalue / 10;
  1419. *        digit = (WORD) lvalue - (divten * 10);
  1420. *        *pnum++ = '0' + digit;
  1421. *        lvalue = divten;
  1422. *          }
  1423. *          if (pnum == &lholder[0])
  1424. *        *pdst++ = '0';
  1425. *          else
  1426. *          {
  1427. *        while(pnum != &lholder[0])
  1428. *          *pdst++ = *--pnum;
  1429. *          }
  1430. *        }
  1431. *      }
  1432. *    }
  1433. *    *pdst = NULL;
  1434. *}
  1435. *
  1436. *
  1437. *    WORD
  1438. *wildcmp(pwild, ptest)
  1439. *    REG BYTE        *pwild;
  1440. *    REG BYTE        *ptest;
  1441. *{
  1442. *    while( (*ptest) && 
  1443. *           (*pwild) )
  1444. *    {
  1445. *      if (*pwild == '?')
  1446. *      {
  1447. *         pwild++;
  1448. *         if (*ptest != '.')
  1449. *           ptest++;
  1450. *      }
  1451. *      else
  1452. *      {
  1453. *        if (*pwild == '*')
  1454. *        {
  1455. *          if (*ptest != '.')
  1456. *        ptest++;
  1457. *          else        
  1458. *        pwild++;
  1459. *        }
  1460. *        else
  1461. *        {
  1462. *          if (*ptest == *pwild)
  1463. *          {
  1464. *            pwild++;
  1465. *            ptest++;
  1466. *          }
  1467. *          else
  1468. *            return(FALSE);
  1469. *        }
  1470. *      }
  1471. *    }
  1472. *                        /* eat up remaining     */
  1473. *                        /*   wildcard chars    */
  1474. *    while( (*pwild == '*') ||
  1475. *           (*pwild == '?') ||
  1476. *           (*pwild == '.') )
  1477. *      pwild++;
  1478. *                        /* if any part of wild-    */
  1479. *                        /*   card or test is    */
  1480. *                        /*   left then no match    */
  1481. *    if ( (*pwild) ||
  1482. *         (*ptest) )
  1483. *      return(FALSE);
  1484. *    else
  1485. *      return(TRUE);
  1486. *}
  1487.