Пример #1
0
static void InitWaveScope() {
  WORD i, j;
  BitmapT *bm;

  for (i = 0; i < 4; i++) {
    memset(&wavescope.channel[i], 0, sizeof(WaveScopeChanT));
    wavescope.channel[i].bm = NewBitmap(64, 64, 1);
  }

  for (i = 0; i < 64; i++) {
    for (j = 0; j < 128; j++) {
      WORD index = (i << 8) | j;
      WORD x = (j * (i + 1)) >> 4;
      wavescope.multab[index] = x;
    }

    for (; j < 255; j++) {
      WORD index = (i << 8) | j;
      WORD x = ((255 - j) * (i + 1)) >> 4;
      wavescope.multab[index] = x;
    }
  }

  bm = NewBitmap(64, 32, 1);
  BlitterLineSetup(bm, 0, LINE_EOR, LINE_ONEDOT);
  BlitterLine(32, 0, 1, 31);
  BlitterLine(32, 0, 63, 31);
  BlitterFill(bm, 0);
  WaitBlitter();
  ((BYTE *)bm->planes[0])[4] = 0x80;
  wavescope.spans = bm;
}
Пример #2
0
static void Init() {
  WORD i;

  screen[0] = NewBitmap(WIDTH, HEIGHT, DEPTH);
  screen[1] = NewBitmap(WIDTH, HEIGHT, DEPTH);

  custom->dmacon = DMAF_SETCLR | DMAF_BLITTER;

  for (i = 0; i < 8; i++) {
    Area2D flare_area = { 0, i * SIZE, SIZE, SIZE };
    flare[i] = NewBitmap(SIZE, SIZE, DEPTH);
    BitmapCopyArea(flare[i], 0, 0, flares, &flare_area);
  }

  carry = NewBitmap(SIZE + 16, SIZE, 2);
  cp = NewCopList(50);

  for (i = 0; i < 2; i++)
    BitmapClear(screen[i]);

  CopInit(cp);
  CopSetupGfxSimple(cp, MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT);
  CopSetupBitplanes(cp, bplptr, screen[active], DEPTH);
  CopLoadPal(cp, flares->palette, 0);
  CopEnd(cp);
  CopListActivate(cp);
  custom->dmacon = DMAF_SETCLR | DMAF_RASTER;
}
Пример #3
0
static void Load() {
  screen[0] = NewBitmap(WIDTH * 2, HEIGHT * 2, DEPTH, FALSE);
  screen[1] = NewBitmap(WIDTH * 2, HEIGHT * 2, DEPTH, FALSE);

  texture = LoadTGA("data/texture-16-1.tga", PM_CMAP, MEMF_PUBLIC);
  uvmap = ReadFile("data/uvmap.bin", MEMF_PUBLIC);
}
Пример #4
0
static void Load() {
  WORD i;

  screen[0] = NewBitmap(WIDTH, HEIGHT, DEPTH);
  screen[1] = NewBitmap(WIDTH, HEIGHT, DEPTH);

  for (i = 0; i < PNUM; i++)
    greeting[i].bitmap = LoadILBMCustom(greeting[i].filename, BM_DISPLAYABLE);

  background = LoadILBMCustom("data/neons.ilbm", BM_DISPLAYABLE|BM_LOAD_PALETTE);
  palette[0] = background->palette;
  palette[1] = LoadPalette("data/greet_moods.ilbm");
  palette[2] = LoadPalette("data/greet_rno.ilbm");

  PositionGreetings();
}
Пример #5
0
void SavePixmap(Pixmap* px, char* name) {
	Bitmap* b =NewBitmap(px->width,px->height,px->bitsPerPixel); 
	b->data=(char*)px->data;
	SaveBitmap(b,name);
	b->data=NULL;
	DeleteBitmap(b);
}
Пример #6
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH);
  cp = NewCopList(100);
  CopInit(cp);
  CopSetupGfxSimple(cp, MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT);
  CopSetupBitplanes(cp, NULL, screen, DEPTH);
  CopSetRGB(cp, 0, 0x000);
  CopSetRGB(cp, 1, 0xfff);
  CopEnd(cp);
}
Пример #7
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH, FALSE);
  cp = NewCopList(100);
  CopInit(cp);
  CopMakePlayfield(cp, NULL, screen, DEPTH);
  CopMakeDispWin(cp, X(0), Y(0), WIDTH, HEIGHT);
  CopSetRGB(cp, 0, 0x000);
  CopSetRGB(cp, 1, 0xfff);
  CopEnd(cp);
}
Пример #8
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH + 1);
  palette = LoadPalette("boxes-pal.ilbm");
  anim = LoadFile("running.bin", MEMF_PUBLIC);

  Log("Animation has %ld frames %ld x %ld.\n", 
      (LONG)anim->count, (LONG)anim->width, (LONG)anim->height);

  {
    WORD i;

    for (i = 0; i < anim->count; i++)
      anim->frame[i] = (APTR)anim->frame[i] + (LONG)anim;
  }
}
Пример #9
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH, FALSE);
  cp = NewCopList(100);
  nullspr = NewSprite(0, FALSE);
  pointer = CloneSystemPointer();

  CopInit(cp);
  CopMakePlayfield(cp, NULL, screen, DEPTH);
  CopMakeDispWin(cp, X(0), Y(0), WIDTH, HEIGHT);
  CopMakeSprites(cp, sprptr, nullspr);
  CopEnd(cp);

  CopInsSet32(sprptr[0], pointer->data);
  UpdateSpritePos(pointer, X(0), Y(0));
}
Пример #10
0
static void Init() {
  scroll = NewBitmap(WIDTH, HEIGHT + 16, 1);

  custom->dmacon = DMAF_SETCLR | DMAF_BLITTER;
  BitmapClear(scroll);

  line_start = text;

  cp[0] = MakeCopperList(0);
  cp[1] = MakeCopperList(1);

  CopListActivate(cp[active]);

  custom->dmacon = DMAF_SETCLR | DMAF_RASTER;
}
Пример #11
0
static void Load() {
  screen = NewBitmap(WIDTH, HEIGHT, DEPTH);
  bitmap = LoadILBM("data/sprites4.ilbm");
  cp = NewCopList(100);

  CopInit(cp);
  CopSetupGfxSimple(cp, MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT);
  CopSetupBitplanes(cp, NULL, screen, DEPTH);
  CopLoadPal(cp, bitmap->palette, 16);
  CopSetupSprites(cp, sprptr);
  CopEnd(cp);

  sprite[0] = NewSpriteFromBitmap(19, bitmap, 0, 0);
  sprite[1] = NewSpriteFromBitmap(24, bitmap, 0, 19);
  sprite[2] = NewSpriteFromBitmap(42, bitmap, 0, 43);
  UpdateSprite(sprite[0], X(0), Y(113));
  UpdateSprite(sprite[1], X(0), Y(110));
  UpdateSprite(sprite[2], X(0), Y(101));
}
Пример #12
0
static void Load() {
  screen = NewBitmap(320, 256, 1, FALSE);
  bitmap = LoadILBM("data/sprites4.ilbm", TRUE);
  cp = NewCopList(100);

  CopInit(cp);
  CopMakePlayfield(cp, NULL, screen, screen->depth);
  CopMakeDispWin(cp, X(0), Y(0), screen->width, screen->height);
  CopLoadPal(cp, bitmap->palette, 16);
  CopMakeSprites(cp, sprptr, nullspr);
  CopEnd(cp);

  sprite[0] = NewSpriteFromBitmap(19, bitmap, 0, 0);
  sprite[1] = NewSpriteFromBitmap(24, bitmap, 0, 19);
  sprite[2] = NewSpriteFromBitmap(42, bitmap, 0, 43);
  UpdateSpritePos(sprite[0], X(0), Y(113));
  UpdateSpritePos(sprite[1], X(0), Y(110));
  UpdateSpritePos(sprite[2], X(0), Y(101));

  nullspr = NewSprite(0, FALSE);
}
Пример #13
0
static void Init() {
  {
    LONG lines = ReadLineCounter();
    pixmap = PixmapFromPNG(image, MEMF_PUBLIC);
    lines = ReadLineCounter() - lines;
    Log("Png decoding took %ld raster lines.\n", (LONG)lines);
  }

  bitmap = NewBitmap(pixmap->width, pixmap->height, 4);
  bitmap->palette = PaletteFromPNG(image);

  {
    LONG lines = ReadLineCounter();
    c2p_1x1_4(pixmap->pixels, bitmap->planes[0], 
              pixmap->width, pixmap->height, bitmap->bplSize);
    lines = ReadLineCounter() - lines;
    Log("Chunky to planar took %ld raster lines.\n", (LONG)lines);
  }

  cp = NewCopList(100);

  {
    WORD w = bitmap->width;
    WORD h = bitmap->height;
    WORD xs = X((320 - w) / 2);
    WORD ys = Y((256 - h) / 2);

    CopInit(cp);
    CopSetupGfxSimple(cp, MODE_LORES, bitmap->depth, xs, ys, w, h);
    CopSetupBitplanes(cp, NULL, bitmap, bitmap->depth);
    CopLoadPal(cp, bitmap->palette, 0);
    CopEnd(cp);

    CopListActivate(cp);
    EnableDMA(DMAF_RASTER);
  }
}
Пример #14
0
__regargs BitmapT *LoadILBM(const char *filename, BOOL interleaved) {
  BitmapT *bitmap = NULL;
  PaletteT *palette = NULL;
  IffFileT iff;

  if (OpenIff(&iff, filename)) {
    if (iff.header.type == ID_ILBM) {
      BOOL compression = FALSE;

      while (ParseChunk(&iff)) {
        BitmapHeaderT bmhd;

        switch (iff.chunk.type) {
          case ID_BMHD:
            ReadChunk(&iff, &bmhd);
            bitmap = NewBitmap(bmhd.w, bmhd.h, bmhd.nPlanes, interleaved);
            compression = bmhd.compression;
            break;

          case ID_CMAP:
            palette = NewPalette(iff.chunk.length / sizeof(ColorT));
            ReadChunk(&iff, palette->colors);
            break;
        
          case ID_BODY:
            {
              BYTE *data = MemAlloc(iff.chunk.length, MEMF_PUBLIC);
              LONG size = iff.chunk.length;

              ReadChunk(&iff, data);

              if (compression) {
                LONG newSize = bitmap->bplSize * bitmap->depth;
                BYTE *uncompressed = MemAlloc(newSize, MEMF_PUBLIC);

                UnRLE(data, size, uncompressed);
                MemFree(data, size);

                data = uncompressed;
                size = newSize;
              }

              if (!interleaved)
                Deinterleave(data, bitmap);
              else
                memcpy(bitmap->planes[0], data, bitmap->bplSize * bitmap->depth);

              MemFree(data, size);
            }
            break;

          default:
            SkipChunk(&iff);
            break;
        }
      }

      if (bitmap)
        bitmap->palette = palette;
    }

    CloseIff(&iff);
  } else {
    Log("File '%s' missing.\n", filename);
  }

  return bitmap;
}
Пример #15
0
void PBTabPanel::RecountNewPosition()
{
	if (GetLeft() >= 0 && GetTop() >= 0 && GetWidth() > 0 && GetHeight() > 0)
	{
		MarkAsChanged();
	}

	if (m_pActiveTab != NULL)
	{
		free(m_pActiveTab);
		m_pActiveTab = NULL;
	}
	if (m_pInactiveTab != NULL)
	{
		free(m_pInactiveTab);
		m_pInactiveTab = NULL;
	}

	m_pActiveTab = GetResource("tab_active", NULL);
	m_pInactiveTab = GetResource("tab_inactive", NULL);

	if (m_pActiveTab == NULL || m_pInactiveTab == NULL) {
		m_pActiveTab = NewBitmap(68, 26);
		m_pInactiveTab = NewBitmap(68, 26);
		memset(m_pActiveTab->data, 0xff, m_pActiveTab->height * m_pActiveTab->scanline);
		memset(m_pInactiveTab->data, 0xaa, m_pInactiveTab->height * m_pInactiveTab->scanline);
	}

	switch(m_Alignment)
	{
		case ALIGNMENT_BOTTOM:
			GetGraphics()->RotateBitmap(&m_pActiveTab, ROTATE0);
			GetGraphics()->RotateBitmap(&m_pInactiveTab, ROTATE0);

			SetWindowPos(0, m_pParent->GetHeight() - m_pActiveTab->height, m_pParent->GetWidth(), m_pActiveTab->height);
//			SetLeft(0);
//			SetTop(m_pParent->GetHeight() - m_pActiveTab->height);
//			SetWidth(m_pParent->GetWidth());
//			SetHeight(m_pActiveTab->height);

			m_Length = m_pParent->GetWidth();
			m_X = GetLeft() + HIDESPACE;
			m_Y = GetTop() - 2;
			m_ShiftX = m_pActiveTab->width - HIDESPACE;
			m_ShiftY = 0;
			break;

		case ALIGNMENT_LEFT:
			GetGraphics()->RotateBitmap(&m_pActiveTab, ROTATE90);
			GetGraphics()->RotateBitmap(&m_pInactiveTab, ROTATE90);

			SetWindowPos(0, 0, m_pActiveTab->width, m_pParent->GetHeight());
//			SetLeft(0);
//			SetTop(0);
//			SetWidth(m_pActiveTab->width);
//			SetHeight(m_pParent->GetHeight());

			m_Length = m_pParent->GetHeight();
			m_X = GetLeft() + 2;
			m_Y = GetTop() + HIDESPACE;
			m_ShiftX = 0;
			m_ShiftY = m_pActiveTab->height - HIDESPACE;
			break;

		case ALIGNMENT_RIGHT:
			GetGraphics()->RotateBitmap(&m_pActiveTab, ROTATE270);
			GetGraphics()->RotateBitmap(&m_pInactiveTab, ROTATE270);

			SetWindowPos(m_pParent->GetWidth() - m_pActiveTab->width, 0, m_pActiveTab->width, m_pParent->GetHeight());
//			SetLeft(m_pParent->GetWidth() - m_pActiveTab->width);
//			SetTop(0);
//			SetWidth(m_pActiveTab->width);
//			SetHeight(m_pParent->GetHeight());

			m_Length = m_pParent->GetHeight();
			m_X = GetLeft() - 2;
			m_Y = GetTop() + HIDESPACE;
			m_ShiftX = 0;
			m_ShiftY = m_pActiveTab->height - HIDESPACE;
			break;

		case ALIGNMENT_TOP:
			GetGraphics()->RotateBitmap(&m_pActiveTab, ROTATE180);
			GetGraphics()->RotateBitmap(&m_pInactiveTab, ROTATE180);

			SetWindowPos(0, 0, m_pParent->GetWidth(), m_pActiveTab->height);
//			SetLeft(0);
//			SetTop(0);
//			SetWidth(m_pParent->GetWidth());
//			SetHeight(m_pActiveTab->height);

			m_Length = m_pParent->GetWidth();
			m_X = GetLeft() + HIDESPACE;
			m_Y = GetTop() + 2;
			m_ShiftX = m_pActiveTab->width - HIDESPACE;
			m_ShiftY = 0;
			break;
	}

	RecountViewTabs();

	MarkAsChanged();

}
Пример #16
0
Bitmap* ReadPCXFile (const Collection* A)
/* Read a bitmap from a PCX file */
{
    PCXHeader* P;
    Bitmap* B;
    unsigned char* L;
    Pixel* Px;
    unsigned MaxIdx = 0;
    unsigned X, Y;


    /* Get the file name */
    const char* Name = NeedAttrVal (A, "name", "read pcx file");

    /* Open the file */
    FILE* F = fopen (Name, "rb");
    if (F == 0) {
        Error ("Cannot open PCX file `%s': %s", Name, strerror (errno));
    }

    /* Read the PCX header */
    P = ReadPCXHeader (F, Name);

    /* Dump the header if requested */
    if (Verbosity > 0) {
        DumpPCXHeader (P, Name);
    }

    /* Create the bitmap */
    B = NewBitmap (P->Width, P->Height);

    /* Copy the name */
    SB_CopyStr (&B->Name, Name);

    /* Allocate memory for the scan line */
    L = xmalloc (P->Width);

    /* Read the pixel data */
    Px = B->Data;
    if (P->Planes == 1) {

        /* This is either monochrome or indexed */
        if (P->BPP == 1) {
            /* Monochrome */
            for (Y = 0, Px = B->Data; Y < P->Height; ++Y) {

                unsigned I;
                unsigned char Mask;

                /* Read the plane */
                ReadPlane (F, P, L);

                /* Create pixels */
                for (X = 0, I = 0, Mask = 0x01; X < P->Width; ++Px) {
                    Px->Index = (L[I] & Mask) != 0;
                    if (Mask == 0x80) {
                        Mask = 0x01;
                        ++I;
                    } else {
                        Mask <<= 1;
                    }
                }

            }
        } else {
            /* One plane with 8bpp is indexed */
            for (Y = 0, Px = B->Data; Y < P->Height; ++Y) {

                /* Read the plane */
                ReadPlane (F, P, L);

                /* Create pixels */
                for (X = 0; X < P->Width; ++X, ++Px) {
                    if (L[X] > MaxIdx) {
                        MaxIdx = L[X];
                    }
                    Px->Index = L[X];
                }
            }
        }

        /* One plane means we have a palette which is either part of the header
        ** or follows.
        */
        if (P->PalInfo == 0) {

            /* Create the monochrome palette */
            B->Pal = NewMonochromePalette ();

        } else {

            unsigned      Count;
            unsigned      I;
            unsigned char Palette[256][3];
            unsigned long EndPos;

            /* Determine the current file position */
            unsigned long CurPos = FileGetPos (F);

            /* Seek to the end of the file */
            (void) fseek (F, 0, SEEK_END);

            /* Get this position */
            EndPos = FileGetPos (F);

            /* There's a palette if the old location is 769 bytes from the end */
            if (EndPos - CurPos == sizeof (Palette) + 1) {

                /* Seek back */
                FileSetPos (F, CurPos);

                /* Check for palette marker */
                if (Read8 (F) != 0x0C) {
                    Error ("Invalid palette marker in PCX file `%s'", Name);
                }

            } else if (EndPos == CurPos) {

                /* The palette is in the header */
                FileSetPos (F, 16);

                /* Check the maximum index for safety */
                if (MaxIdx > 15) {
                    Error ("PCX file `%s' contains more than 16 indexed colors "
                           "but no extra palette", Name);
                }

            } else {
                Error ("Error in PCX file `%s': %lu bytes at end of pixel data",
                       Name, EndPos - CurPos);
            }

            /* Read the palette. We will just read what we need. */
            Count = MaxIdx + 1;
            ReadData (F, Palette, Count * sizeof (Palette[0]));

            /* Create the palette from the data */
            B->Pal = NewPalette (Count);
            for (I = 0; I < Count; ++I) {
                B->Pal->Entries[I].R = Palette[I][0];
                B->Pal->Entries[I].G = Palette[I][1];
                B->Pal->Entries[I].B = Palette[I][2];
                B->Pal->Entries[I].A = 0;
            }

        }

    } else {

        /* 3 or 4 planes are RGB or RGBA (don't know if this exists) */
        for (Y = 0, Px = B->Data; Y < P->Height; ++Y) {

            /* Read the R plane and move the data */
            ReadPlane (F, P, L);
            for (X = 0; X < P->Width; ++X, ++Px) {
                Px->C.R = L[X];
            }

            /* Read the G plane and move the data */
            ReadPlane (F, P, L);
            for (X = 0; X < P->Width; ++X, ++Px) {
                Px->C.G = L[X];
            }

            /* Read the B plane and move the data */
            ReadPlane (F, P, L);
            for (X = 0; X < P->Width; ++X, ++Px) {
                Px->C.B = L[X];
            }

            /* Either read the A plane or clear it */
            if (P->Planes == 4) {
                ReadPlane (F, P, L);
                for (X = 0; X < P->Width; ++X, ++Px) {
                    Px->C.A = L[X];
                }
            } else {
                for (X = 0; X < P->Width; ++X, ++Px) {
                    Px->C.A = 0;
                }
            }
        }
    }

    /* Close the file */
    fclose (F);

    /* Free memory for the scan line */
    xfree (L);

    /* Free the PCX header */
    FreePCXHeader (P);

    /* Return the bitmap */
    return B;
}