home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <dos.h>
- #include <conio.h>
- #include <string.h>
- #include <graphics.h>
-
- #define Bit(x) (1 << x)
-
- void Sprite( int x, int y, unsigned char *bitmap, int byteswide, int rows )
- {
- char far *ptr;
- register int i, j;
- unsigned char XOR;
- unsigned char SAVE;
- int Shift;
- unsigned char ANDVAL = 0;
- int YStart;
- int SaveShift;
-
- Shift = x % 8;
- for (i=0; i<Shift; ++i)
- ANDVAL += Bit(i);
- SaveShift = 8 - Shift;
-
- YStart = y * 80 + x / 8;
-
- for (j=0; j<rows; ++j) {
- ptr = MK_FP( 0xA000U, YStart );
- YStart += 80;
- SAVE = 0;
- for (i=0; i<byteswide; ++i) {
- XOR = (*bitmap >> Shift) + SAVE;
- SAVE = ( (*bitmap & ANDVAL) << SaveShift );
- *ptr++ ^= XOR;
- bitmap++;
- }
- *ptr ^= SAVE;
- }
- }
-
-
- unsigned char LetterA[145] = {
- 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x01, 0xc0, 0x00, 0x00,
- 0x00, 0x01, 0xc0, 0x00, 0x00,
- 0x00, 0x01, 0xe0, 0x00, 0x00,
- 0x00, 0x03, 0xe0, 0x00, 0x00,
- 0x00, 0x03, 0xf0, 0x00, 0x00,
- 0x00, 0x06, 0xf0, 0x00, 0x00,
- 0x00, 0x06, 0xf8, 0x00, 0x00,
- 0x00, 0x0c, 0xf8, 0x00, 0x00,
- 0x00, 0x0c, 0x7c, 0x00, 0x00,
- 0x00, 0x18, 0x7c, 0x00, 0x00,
- 0x00, 0x18, 0x3e, 0x00, 0x00,
- 0x00, 0x30, 0x3e, 0x00, 0x00,
- 0x00, 0x30, 0x1f, 0x00, 0x00,
- 0x00, 0x60, 0x1f, 0x00, 0x00,
- 0x00, 0x60, 0x0f, 0x00, 0x00,
- 0x00, 0xc0, 0x0f, 0x80, 0x00,
- 0x00, 0xc0, 0x0f, 0x80, 0x00,
- 0x01, 0xff, 0xff, 0xc0, 0x00,
- 0x01, 0xff, 0xff, 0xc0, 0x00,
- 0x03, 0x80, 0x03, 0xe0, 0x00,
- 0x03, 0x00, 0x03, 0xe0, 0x00,
- 0x07, 0x00, 0x01, 0xf0, 0x00,
- 0x06, 0x00, 0x01, 0xf0, 0x00,
- 0x0e, 0x00, 0x00, 0xf8, 0x00,
- 0x0c, 0x00, 0x00, 0xf8, 0x00,
- 0x1c, 0x00, 0x00, 0xfc, 0x00,
- 0x3e, 0x00, 0x00, 0xfe, 0x00,
- 0xff, 0xc0, 0x07, 0xff, 0x80
- };
-
- void main()
- {
- int graphdriver=VGA, graphmode=VGAHI;
- register int i;
- int x=8, y=8;
-
- initgraph(&graphdriver,&graphmode,"");
- for (i=0; i<200; i++) {
- Sprite( x, y, LetterA, 5, 29 );
- x += 41;
- if ( x > 610 ) {
- x = 8;
- y += 33;
- }
- }
- getch();
- closegraph();
- }
-