home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff227.lzh / PickPacket / src / stbuf.c < prev    next >
C/C++ Source or Header  |  1989-06-25  |  5KB  |  162 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
  2. * |_o_o|\\ Copyright (c) 1989 The Software Distillery.                    *
  3. * |. o.| ||          All Rights Reserved                                  *
  4. * | .  | ||          Written by John Toebes and Doug Walker               *
  5. * | o  | ||          The Software Distillery                              *
  6. * |  . |//           235 Trillingham Lane                                 *
  7. * ======             Cary, NC 27513                                       *
  8. *                    BBS:(919)-471-6436                                   *
  9. \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  10. #include "pickpack.h"
  11. #include "struct.h"
  12. #include "bufgen.h"
  13.  
  14. static struct IntuiText IText =
  15. {
  16.     1,0,JAM2,   /* front and back text pens, drawmode and fill byte */
  17.     0,0,       /* XY origin relative to container TopLeft */
  18.     &TOPAZ80,   /* font pointer or NULL for default */
  19.     NULL,       /* pointer to text */
  20.     NULL        /* next IntuiText structure */
  21. };
  22.  
  23. static struct IntuiText NameText = {
  24.     3,0,JAM2,   /* front and back text pens, drawmode and fill byte */
  25.     98,13,      /* XY origin relative to container TopLeft */
  26.     &TOPAZ80,   /* font pointer or NULL for default */
  27.     NULL,       /* pointer to text */
  28.     NULL        /* next IntuiText structure */
  29. };
  30.  
  31.  
  32. void stbufnew(nw, it, stnode)
  33. struct NewWindow **nw;
  34. struct IntuiText **it;
  35. struct STNODE *stnode;
  36. {
  37.    *nw = &NewWindowStructure1;
  38.    stnode->d.bdata->Gadget1 = Gadget1;
  39.    stnode->d.bdata->Gadget3 = Gadget2;
  40.    stnode->d.bdata->Gadget3 = Gadget3;
  41.    stnode->d.bdata->Gadget1SInfo = Gadget1SInfo;
  42.  
  43.    stnode->d.bdata->Gadget2.NextGadget = &stnode->d.bdata->Gadget1;
  44.    stnode->d.bdata->Gadget3.NextGadget = &stnode->d.bdata->Gadget2;
  45.    stnode->d.bdata->Gadget1.SpecialInfo = (APTR)&stnode->d.bdata->Gadget1SInfo;
  46.    stnode->d.bdata->pos = 0;
  47.    NewWindowStructure1.FirstGadget = &stnode->d.bdata->Gadget1;
  48.    *it = &IText1;
  49.    return;
  50. }
  51.  
  52. #define HEXASC  44
  53.  
  54. /* Display the struct FileHandle */
  55. int stbufdisp(n)
  56. struct STNODE *n;
  57. {
  58. return(stbufmove(n, 0));
  59. }
  60.  
  61. /* Display the struct FileHandle */
  62. int stbufmove(n, adj)
  63. struct STNODE *n;
  64. int adj;
  65. {
  66.    char data[100];
  67.    char *dpos, *p;
  68.    int cyc, c;
  69.    int bytes;
  70.    int i, off;
  71.    int dlines, wlines;
  72.    int hpot, hbody;
  73.  
  74.    INITTEXT(13)
  75.  
  76.    BUG(1, ("stbufdisp: Entry, stnode 0x%08x window 0x%08x\n", n, n->w))
  77.  
  78.    wlines = (n->w->Height - 13)/9;
  79.    dlines = (n->d.bdata->size+15) >> 4;
  80.    if (wlines >= dlines)
  81.       {
  82.       off = 0;
  83.       hpot = 0;
  84.       hbody = -1;
  85.       bytes = n->d.bdata->size;
  86.       dpos = n->d.bdata->buf;
  87.       }
  88.    else
  89.       {
  90.       if (n->d.bdata->Gadget1SInfo.VertPot == 0xffff)
  91.          off = dlines-wlines+adj;
  92.       else
  93.          off = ((n->d.bdata->Gadget1SInfo.VertPot*(dlines-wlines)+32000) >> 16)+adj;
  94.       if (off >= dlines-wlines)
  95.          {
  96.          hpot = -1;
  97.          off = dlines-wlines;
  98.          }
  99.       else if (off <= 0)
  100.          {
  101.          off = 0;
  102.          hpot = 0;
  103.          }
  104.       else
  105.          hpot = (off<<16)/(dlines-wlines);
  106.       hbody = (wlines<<16)/dlines;
  107.       bytes = n->d.bdata->size-(off*16);
  108.       if (bytes > wlines*16)
  109.          bytes = wlines*16;
  110.       dpos = &n->d.bdata->buf[off*16];
  111.       }
  112.  
  113.    BUG(3,("bytes=%d hpot=%d hbody=%d dlines=%d wlines=%d\n",bytes,hpot,hbody,dlines,wlines))
  114.    ModifyProp(&n->d.bdata->Gadget1, n->w, NULL,
  115.               AUTOKNOB+FREEVERT, -1, hpot, -1, hbody);
  116.  
  117.    /* Now go through and display the data */
  118.    off <<= 4;
  119.    i = 0;
  120.    while(bytes--)
  121.       {
  122.       c = *dpos++ & 0xff;
  123.       cyc = off&15;
  124.       if (!cyc)
  125.          {
  126.          /* Time to init the output buffer */
  127.          sprintf(data, 
  128. /* 0000: 00000000 00000000 00000000 00000000  *................*  */
  129.   "%04x:                                      *                *", off);
  130.  
  131.          }
  132.       /* - - - - - - - - - - - - - - - - - - - - - - - - */
  133.       /* Now fill in the current character slot          */
  134.       /* - - - - - - - - - - - - - - - - - - - - - - - - */
  135.       p = data+6+(cyc<<1)+(cyc>>2);
  136.       *p++ = "0123456789ABCDEF"[c>>4];
  137.       *p++ = "0123456789ABCDEF"[c&15];
  138.  
  139.       /* - - - - - - - - - - - - - - - - - - - - - - - - */
  140.       /* Translate all non printing characters to a '.'  */
  141.       /* This includes the range 0-1F, 7F, 80-9F, FF     */
  142.       /* - - - - - - - - - - - - - - - - - - - - - - - - */
  143.       if (((c+1)&0x7f) <= ' ') c = '.';
  144.  
  145.       data[HEXASC+cyc] = c;
  146.       off++;
  147.  
  148.       if (bytes == 0 || cyc == 15)
  149.          {
  150.          /* Display it on the screen */
  151.          SHOWTEXT
  152.          }
  153.       }
  154.  
  155.    strcpy(data, "                                                             ");
  156.    while(i++ < wlines)
  157.       SHOWTEXT
  158.  
  159.    BUG(1, ("stbufdisp: Exit\n"))
  160.    return(RC_OK);
  161. }
  162.