Replace invalid characters with HTML entities
— with — ’ with ’ + with + × with x ç with ç “ with “ ” with ” ‘ with ‘ • with • – with - µ with µ † with † Fix C++ θ with θ Yen symbol instead of times Fix broken apos Bullet again E-circumflex
This commit is contained in:
parent
9e52de9586
commit
500e7f5654
353 changed files with 5091 additions and 5091 deletions
46
46-02.html
46
46-02.html
|
|
@ -41,7 +41,7 @@
|
|||
<PRE>
|
||||
/* Sample simple dirty-rectangle animation program, partially optimized and
|
||||
featuring internal animation, masked images (sprites), and nonoverlapping dirty
|
||||
rectangle copying. Tested with Borland C++ in the small model. */
|
||||
rectangle copying. Tested with Borland C++ in the small model. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
|
|
@ -81,7 +81,7 @@ DirtyRectangle DirtyHead;
|
|||
/* If set to 1, ignore dirty rectangle list and copy the whole screen. */
|
||||
int DrawWholeScreen = 0;
|
||||
/* pixels and masks for the two internally animated versions of the image
|
||||
we’ll animate */
|
||||
we’ll animate */
|
||||
#define IMAGE-WIDTH 13
|
||||
#define IMAGE-HEIGHT 11
|
||||
char ImagePixels0[] = {
|
||||
|
|
@ -143,7 +143,7 @@ char * ImageMaskArray[] = {ImageMask0, ImageMask1};
|
|||
/* Animated entities */
|
||||
#define NUM-ENTITIES 15
|
||||
Entity Entities[NUM-ENTITIES];
|
||||
/* pointer to system buffer into which we’ll draw */
|
||||
/* pointer to system buffer into which we’ll draw */
|
||||
char far *SystemBufferPtr;
|
||||
/* pointer to screen */
|
||||
char far *ScreenPtr;
|
||||
|
|
@ -161,22 +161,22 @@ void main()
|
|||
unsigned int TempCount;
|
||||
char far *TempPtr;
|
||||
union REGS regs;
|
||||
/* Allocate memory for the system buffer into which we’ll draw */
|
||||
/* Allocate memory for the system buffer into which we’ll draw */
|
||||
if (!(SystemBufferPtr = farmalloc((unsigned int)SCREEN-WIDTH*
|
||||
SCREEN-HEIGHT))) {
|
||||
printf(”Couldn’t get memory\n”);
|
||||
printf(”Couldn’t get memory\n”);
|
||||
exit(1);
|
||||
}
|
||||
/* Clear the system buffer */
|
||||
TempPtr = SystemBufferPtr;
|
||||
for (TempCount = ((unsigned)SCREEN-WIDTH*SCREEN-HEIGHT); TempCount--; ) {
|
||||
*TempPtr++ = 0;
|
||||
*TempPtr++ = 0;
|
||||
}
|
||||
/* Point to the screen */
|
||||
ScreenPtr = MK-FP(SCREEN-SEGMENT, 0);
|
||||
/* Set up the entities we’ll animate, at random locations */
|
||||
/* Set up the entities we’ll animate, at random locations */
|
||||
randomize();
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
Entities[i].X = random(SCREEN-WIDTH - IMAGE-WIDTH);
|
||||
Entities[i].Y = random(SCREEN-HEIGHT - IMAGE-HEIGHT);
|
||||
Entities[i].XDirection = 1;
|
||||
|
|
@ -210,7 +210,7 @@ void main()
|
|||
updating the dirty rectangle list */
|
||||
EraseEntities();
|
||||
/* Move the entities, bouncing off the edges of the screen */
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
XTemp = Entities[i].X + Entities[i].XDirection;
|
||||
YTemp = Entities[i].Y + Entities[i].YDirection;
|
||||
if ((XTemp < 0) || ((XTemp + IMAGE-WIDTH) > SCREEN-WIDTH)) {
|
||||
|
|
@ -240,14 +240,14 @@ void DrawEntities()
|
|||
char *TempPtrMask;
|
||||
Entity *EntityPtr;
|
||||
|
||||
for (= 0, EntityPtr = Entities; < NUM-ENTITIES; i++, EntityPtr++) {
|
||||
for (= 0, EntityPtr = Entities; < NUM-ENTITIES; i++, EntityPtr++) {
|
||||
/* Remember the dirty rectangle info for this entity */
|
||||
AddDirtyRect(EntityPtr, IMAGE-HEIGHT, IMAGE-WIDTH);
|
||||
/* Point to the destination in the system buffer */
|
||||
RowPtrBuffer = SystemBufferPtr + (EntityPtr->Y * SCREEN-WIDTH) +
|
||||
EntityPtr->X;
|
||||
/* Advance the image animation pointer */
|
||||
if (++EntityPtr->InternalAnimateCount >=
|
||||
if (++EntityPtr->InternalAnimateCount >=
|
||||
EntityPtr->InternalAnimateMax) {
|
||||
EntityPtr->InternalAnimateCount = 0;
|
||||
}
|
||||
|
|
@ -272,9 +272,9 @@ void CopyDirtyRectanglesToScreen()
|
|||
SCREEN-WIDTH, SCREEN-WIDTH);
|
||||
} else {
|
||||
/* Copy only the dirty rectangles, in the YX-sorted order in which
|
||||
they’re linked */
|
||||
they’re linked */
|
||||
DirtyPtr = DirtyHead.Next;
|
||||
for (= 0; < NumDirtyRectangles; i++) {
|
||||
for (= 0; < NumDirtyRectangles; i++) {
|
||||
/* Offset in both system buffer and screen of image */
|
||||
Offset = (unsigned int) (DirtyPtr->Top * SCREEN-WIDTH) +
|
||||
DirtyPtr->Left;
|
||||
|
|
@ -296,7 +296,7 @@ void EraseEntities()
|
|||
int i;
|
||||
char far *RowPtr;
|
||||
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
for (= 0; < NUM-ENTITIES; i++) {
|
||||
/* Remember the dirty rectangle info for this entity */
|
||||
AddDirtyRect(&Entities[i], IMAGE-HEIGHT, IMAGE-WIDTH);
|
||||
/* Point to the destination in the system buffer */
|
||||
|
|
@ -332,18 +332,18 @@ void EraseEntities()
|
|||
#ifdef CHECK-OVERLAP
|
||||
/* Check for overlap with existing rectangles */
|
||||
TempPtr = DirtyHead.Next;
|
||||
for (= 0; < NumDirtyRectangles; i++, TempPtr = TempPtr->Next) {
|
||||
for (= 0; < NumDirtyRectangles; i++, TempPtr = TempPtr->Next) {
|
||||
if ((TempPtr->Left < (pEntity->X + ImageWidth)) &&
|
||||
(TempPtr->Right > pEntity->X) &&
|
||||
(TempPtr->Top < (pEntity->Y + ImageHeight)) &&
|
||||
(TempPtr->Bottom > pEntity->Y)) {
|
||||
|
||||
/* We’ve found an overlapping rectangle. Calculate the
|
||||
/* We’ve found an overlapping rectangle. Calculate the
|
||||
rectangles, if any, remaining after subtracting out the
|
||||
overlapped areas, and add them to the dirty list */
|
||||
/* Check for a nonoverlapped left portion */
|
||||
if (TempPtr->Left > pEntity->X) {
|
||||
/* There’s definitely a nonoverlapped portion at the left; add
|
||||
/* There’s definitely a nonoverlapped portion at the left; add
|
||||
it, but only to at most the top and bottom of the overlapping
|
||||
rect; top and bottom strips are taken care of below */
|
||||
TempEntity.X = pEntity->X;
|
||||
|
|
@ -355,7 +355,7 @@ void EraseEntities()
|
|||
}
|
||||
/* Check for a nonoverlapped right portion */
|
||||
if (TempPtr->Right < (pEntity->X + ImageWidth)) {
|
||||
/* There’s definitely a nonoverlapped portion at the right; add
|
||||
/* There’s definitely a nonoverlapped portion at the right; add
|
||||
it, but only to at most the top and bottom of the overlapping
|
||||
rect; top and bottom strips are taken care of below */
|
||||
TempEntity.X = TempPtr->Right;
|
||||
|
|
@ -367,25 +367,25 @@ void EraseEntities()
|
|||
}
|
||||
/* Check for a nonoverlapped top portion */
|
||||
if (TempPtr->Top > pEntity->Y) {
|
||||
/* There’s a top portion that’s not overlapped */
|
||||
/* There’s a top portion that’s not overlapped */
|
||||
TempEntity.X = pEntity->X;
|
||||
TempEntity.Y = pEntity->Y;
|
||||
AddDirtyRect(&TempEntity, TempPtr->Top - pEntity->Y, ImageWidth);
|
||||
}
|
||||
/* Check for a nonoverlapped bottom portion */
|
||||
if (TempPtr->Bottom < (pEntity->Y + ImageHeight)) {
|
||||
/* There’s a bottom portion that’s not overlapped */
|
||||
/* There’s a bottom portion that’s not overlapped */
|
||||
TempEntity.X = pEntity->X;
|
||||
TempEntity.Y = TempPtr->Bottom;
|
||||
AddDirtyRect(&TempEntity,
|
||||
(pEntity->Y + ImageHeight) - TempPtr->Bottom, ImageWidth);
|
||||
}
|
||||
/* We’ve added all non-overlapped portions to the dirty list */
|
||||
/* We’ve added all non-overlapped portions to the dirty list */
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* CHECK-OVERLAP */
|
||||
/* There’s no overlap with any existing rectangle, so we can just
|
||||
/* There’s no overlap with any existing rectangle, so we can just
|
||||
add this rectangle as-is */
|
||||
/* Find the YX-sorted insertion point. Searches will always terminate,
|
||||
because the head/tail rectangle is set to the maximum values */
|
||||
|
|
@ -398,7 +398,7 @@ void EraseEntities()
|
|||
TempPtr = TempPtr->Next;
|
||||
}
|
||||
/* Set the rectangle and actually add it to the dirty list */
|
||||
DirtyPtr = &DirtyRectangles[NumDirtyRectangles++];
|
||||
DirtyPtr = &DirtyRectangles[NumDirtyRectangles++];
|
||||
DirtyPtr->Left = pEntity->X;
|
||||
DirtyPtr->Top = pEntity->Y;
|
||||
DirtyPtr->Right = pEntity->X + ImageWidth;
|
||||
|
|
|
|||
Loading…
Reference in a new issue