home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / bit_blt / amiga / initiali.c < prev    next >
C/C++ Source or Header  |  1987-04-24  |  3KB  |  119 lines

  1. /*
  2.  *   Initialization module of the blitlab program.
  3.  */
  4. #include "structures.h"
  5. /*
  6.  *   These are the externals we reference.
  7.  */
  8. extern struct Window *mywindow ;
  9. extern struct GfxBase *GfxBase ;
  10. extern struct IntuitionBase *IntuitionBase ;
  11. extern struct RastPort *myrp ;
  12. /*
  13.  *   This is the humongous window we open on the standard
  14.  *   workbench screen.
  15.  */
  16. static struct NewWindow mynewwindow = {
  17.    HWINSTART, VWINSTART, HWINSIZE, VWINSIZE,
  18.    -1, -1,
  19.    MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN | GADGETUP | CLOSEWINDOW,
  20.    WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | SMART_REFRESH | REPORTMOUSE
  21.    | ACTIVATE,
  22.    NULL,
  23.    NULL,
  24.    (UBYTE *)BANNER,
  25.    NULL,
  26.    NULL,
  27.    0, 0, 0, 0,
  28.    WBENCHSCREEN } ;
  29. /*
  30.  *   This is the main initialize routine, which gets everything started
  31.  *   up.
  32.  */
  33. initialize() {
  34.    int i, j ;
  35. /*
  36.  *   First, we try and open libraries and windows.
  37.  */
  38.    if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary(
  39.       "intuition.library",0L))==NULL ||
  40.        (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L))
  41.       ==NULL)
  42.       error("! Couldn't open libraries") ;
  43.    if ((mywindow=OpenWindow(&mynewwindow))==NULL)
  44.       error("! Couldn't open window") ;
  45.    myrp = mywindow -> RPort ;
  46.    allocbitmem() ;
  47.    buildgadgets() ;
  48.    drawlabels() ;
  49.    parseall() ;
  50. /*
  51.  *   Here we draw the bits array, hopefully for easy reference.
  52.  */
  53.    color(BLACK) ;
  54.    fbox(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ;
  55.    color(WHITE) ;
  56.    box(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ;
  57.    color(ORANGE) ;
  58.    for (i=1; i<24; i++)
  59.       box(HBITSTART + i * 24 - 2, VBITSTART, 2, VBITSIZE) ;
  60.    for (i=1; i<96; i++)
  61.       for (j=1; j<32; j++)
  62.          line(HBITSTART + i * 6 - 2, VBITSTART + j * 3, HBITSTART + i * 6 - 2,
  63.               VBITSTART + j * 3) ;
  64.    color(BLUE) ;
  65.    box(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ;
  66.    for (i=1; i<7; i++)
  67.       box(HBITSTART + i * 96 - 2, VBITSTART, 2, VBITSIZE) ;
  68.    for (i=1; i<9; i++)
  69.       line(HBITSTART, VBITSTART + i * 12, HBITSTART + HBITSIZE - 1,
  70.            VBITSTART + i * 12) ;
  71.    updatebits() ;
  72. /*
  73.  *   Now we draw boxes around the blitter register values and user
  74.  *   settable values.
  75.  */
  76.    color(WHITE) ;
  77.    box(HRVSTART, VRVSTART, HRVSIZE, VRVSIZE) ;
  78.    line(HMVSTART, VRVSTART, HMVSTART, VRVSTART + VRVSIZE - 1) ;
  79. }
  80. /*
  81.  *   This routine cleans up for exit.
  82.  */
  83. cleanup() {
  84.    if (mywindow != NULL)
  85.       CloseWindow(mywindow) ;
  86.    if (GfxBase != NULL)
  87.       CloseLibrary(GfxBase) ;
  88.    if (IntuitionBase != NULL)
  89.       CloseLibrary(IntuitionBase) ;
  90.    freemem() ;
  91.    exit(0) ;
  92. }
  93. /*
  94.  *   drawlabels() draws several miscellaneous labels all over the
  95.  *   screen.
  96.  */
  97. drawlabels() {
  98.    drawtext(HLMGSTART+4, VLMG3-2, "Adrs:") ;
  99.    drawtext(HLMGSTART+4, VLMG3+6, " M+") ;
  100.    drawtext(HLMGSTART+4, VLMG4-2, "Shift:") ;
  101.    drawtext(HRVC1 + 12, VRVL6, "Blitter Register Values") ;
  102.    drawtext(HRVC7 + 4, VRVLL6, "DMA Channels") ;
  103.    drawtext(HRVC1, VRVL1, "CON0") ;
  104.    drawtext(HRVC1, VRVL2, "CON1") ;
  105.    drawtext(HRVC1, VRVL3, "SIZE") ;
  106.    drawtext(HRVC1, VRVL4, "AFWM") ;
  107.    drawtext(HRVC1, VRVL5, "ALWM") ;
  108.    drawtext(HRVC3, VRVL2, "A") ;
  109.    drawtext(HRVC3, VRVL3, "B") ;
  110.    drawtext(HRVC3, VRVL4, "C") ;
  111.    drawtext(HRVC3, VRVL5, "D") ;
  112.    drawtext(HRVC4 + 4, VRVL1, "PTH  PTL  MOD  DAT") ;
  113.    drawtext(HRVC7, VRVLL2, "A") ;
  114.    drawtext(HRVC7, VRVLL3, "B") ;
  115.    drawtext(HRVC7, VRVLL4, "C") ;
  116.    drawtext(HRVC7, VRVLL5, "D") ;
  117.    drawtext(HRVC8, VRVL1, "USE   PT     MOD          DAT          SH") ;
  118. }
  119.