Change HTML4 entities to HTML5
< to < > to > & to &
This commit is contained in:
parent
56a4baa60e
commit
b8e7ce7165
105 changed files with 1117 additions and 1117 deletions
140
46-02.html
140
46-02.html
|
|
@ -43,11 +43,11 @@
|
|||
featuring internal animation, masked images (sprites), and nonoverlapping dirty
|
||||
rectangle copying. Tested with Borland C++ in the small model. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <alloc.h>
|
||||
#include <memory.h>
|
||||
#include <dos.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <alloc.h>
|
||||
#include <memory.h>
|
||||
#include <dos.h>
|
||||
|
||||
/* Comment out to disable overlap elimination in the dirty rectangle list. */
|
||||
#define CHECK-OVERLAP 1
|
||||
|
|
@ -176,25 +176,25 @@ void main()
|
|||
ScreenPtr = MK-FP(SCREEN-SEGMENT, 0);
|
||||
/* 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;
|
||||
Entities[i].YDirection = -1;
|
||||
Entities[i].InternalAnimateCount = & 1;
|
||||
Entities[i].InternalAnimateCount = & 1;
|
||||
Entities[i].InternalAnimateMax = 2;
|
||||
}
|
||||
/* Set the dirty rectangle list to empty, and set up the head/tail node
|
||||
as a sentinel */
|
||||
NumDirtyRectangles = 0;
|
||||
DirtyHead.Next = &DirtyHead;
|
||||
DirtyHead.Next = &DirtyHead;
|
||||
DirtyHead.Top = 0x7FFF;
|
||||
DirtyHead.Left= 0x7FFF;
|
||||
DirtyHead.Bottom = 0x7FFF;
|
||||
DirtyHead.Right = 0x7FFF;
|
||||
/* Set 320x200 256-color graphics mode */
|
||||
regs.x.ax = 0x0013;
|
||||
int86(0x10, &regs, &regs);
|
||||
int86(0x10, &regs, &regs);
|
||||
/* Loop and draw until a key is pressed */
|
||||
do {
|
||||
/* Draw the entities to the system buffer at their current locations,
|
||||
|
|
@ -205,19 +205,19 @@ void main()
|
|||
CopyDirtyRectanglesToScreen();
|
||||
/* Reset the dirty rectangle list to empty */
|
||||
NumDirtyRectangles = 0;
|
||||
DirtyHead.Next = &DirtyHead;
|
||||
DirtyHead.Next = &DirtyHead;
|
||||
/* Erase the entities in the system buffer at their old locations,
|
||||
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)) {
|
||||
if ((XTemp < 0) || ((XTemp + IMAGE-WIDTH) > SCREEN-WIDTH)) {
|
||||
Entities[i].XDirection = -Entities[i].XDirection;
|
||||
XTemp = Entities[i].X + Entities[i].XDirection;
|
||||
}
|
||||
if ((YTemp < 0) || ((YTemp + IMAGE-HEIGHT) > SCREEN-HEIGHT)) {
|
||||
if ((YTemp < 0) || ((YTemp + IMAGE-HEIGHT) > SCREEN-HEIGHT)) {
|
||||
Entities[i].YDirection = -Entities[i].YDirection;
|
||||
YTemp = Entities[i].Y + Entities[i].YDirection;
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ void main()
|
|||
|
||||
/* Return back to text mode */
|
||||
regs.x.ax = 0x0003;
|
||||
int86(0x10, &regs, &regs);
|
||||
int86(0x10, &regs, &regs);
|
||||
}
|
||||
/* Draw entities at their current locations, updating dirty rectangle list. */
|
||||
void DrawEntities()
|
||||
|
|
@ -240,20 +240,20 @@ 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;
|
||||
RowPtrBuffer = SystemBufferPtr + (EntityPtr->Y * SCREEN-WIDTH) +
|
||||
EntityPtr->X;
|
||||
/* Advance the image animation pointer */
|
||||
if (++EntityPtr->InternalAnimateCount >=
|
||||
EntityPtr->InternalAnimateMax) {
|
||||
EntityPtr->InternalAnimateCount = 0;
|
||||
if (++EntityPtr->InternalAnimateCount >=
|
||||
EntityPtr->InternalAnimateMax) {
|
||||
EntityPtr->InternalAnimateCount = 0;
|
||||
}
|
||||
/* Point to the image and mask to draw */
|
||||
TempPtrImage = ImagePixelArray[EntityPtr->InternalAnimateCount];
|
||||
TempPtrMask = ImageMaskArray[EntityPtr->InternalAnimateCount];
|
||||
TempPtrImage = ImagePixelArray[EntityPtr->InternalAnimateCount];
|
||||
TempPtrMask = ImageMaskArray[EntityPtr->InternalAnimateCount];
|
||||
DrawMasked(RowPtrBuffer, TempPtrImage, TempPtrMask, IMAGE-HEIGHT,
|
||||
IMAGE-WIDTH, SCREEN-WIDTH);
|
||||
}
|
||||
|
|
@ -274,18 +274,18 @@ void CopyDirtyRectanglesToScreen()
|
|||
/* Copy only the dirty rectangles, in the YX-sorted order in which
|
||||
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;
|
||||
Offset = (unsigned int) (DirtyPtr->Top * SCREEN-WIDTH) +
|
||||
DirtyPtr->Left;
|
||||
/* Dimensions of dirty rectangle */
|
||||
RectWidth = DirtyPtr->Right - DirtyPtr->Left;
|
||||
RectHeight = DirtyPtr->Bottom - DirtyPtr->Top;
|
||||
RectWidth = DirtyPtr->Right - DirtyPtr->Left;
|
||||
RectHeight = DirtyPtr->Bottom - DirtyPtr->Top;
|
||||
/* Copy a dirty rectangle */
|
||||
CopyRect(ScreenPtr + Offset, SystemBufferPtr + Offset,
|
||||
RectHeight, RectWidth, SCREEN-WIDTH, SCREEN-WIDTH);
|
||||
/* Point to the next dirty rectangle */
|
||||
DirtyPtr = DirtyPtr->Next;
|
||||
DirtyPtr = DirtyPtr->Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -296,9 +296,9 @@ 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);
|
||||
AddDirtyRect(&Entities[i], IMAGE-HEIGHT, IMAGE-WIDTH);
|
||||
/* Point to the destination in the system buffer */
|
||||
RowPtr = SystemBufferPtr + (Entities[i].Y * SCREEN-WIDTH) +
|
||||
Entities[i].X;
|
||||
|
|
@ -321,7 +321,7 @@ void EraseEntities()
|
|||
DirtyRectangle * TempPtr;
|
||||
Entity TempEntity;
|
||||
int i;
|
||||
if (NumDirtyRectangles >= MAX-DIRTY-RECTANGLES) {
|
||||
if (NumDirtyRectangles >= MAX-DIRTY-RECTANGLES) {
|
||||
/* Too many dirty rectangles; just redraw the whole screen */
|
||||
DrawWholeScreen = 1;
|
||||
return;
|
||||
|
|
@ -332,53 +332,53 @@ void EraseEntities()
|
|||
#ifdef CHECK-OVERLAP
|
||||
/* Check for overlap with existing rectangles */
|
||||
TempPtr = DirtyHead.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)) {
|
||||
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
|
||||
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) {
|
||||
if (TempPtr->Left > pEntity->X) {
|
||||
/* 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;
|
||||
TempEntity.Y = max(pEntity->Y, TempPtr->Top);
|
||||
AddDirtyRect(&TempEntity,
|
||||
min(pEntity->Y + ImageHeight, TempPtr->Bottom) -
|
||||
TempEntity.X = pEntity->X;
|
||||
TempEntity.Y = max(pEntity->Y, TempPtr->Top);
|
||||
AddDirtyRect(&TempEntity,
|
||||
min(pEntity->Y + ImageHeight, TempPtr->Bottom) -
|
||||
TempEntity.Y,
|
||||
TempPtr->Left - pEntity->X);
|
||||
TempPtr->Left - pEntity->X);
|
||||
}
|
||||
/* Check for a nonoverlapped right portion */
|
||||
if (TempPtr->Right < (pEntity->X + ImageWidth)) {
|
||||
if (TempPtr->Right < (pEntity->X + ImageWidth)) {
|
||||
/* 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;
|
||||
TempEntity.Y = max(pEntity->Y, TempPtr->Top);
|
||||
AddDirtyRect(&TempEntity,
|
||||
min(pEntity->Y + ImageHeight, TempPtr->Bottom) -
|
||||
TempEntity.X = TempPtr->Right;
|
||||
TempEntity.Y = max(pEntity->Y, TempPtr->Top);
|
||||
AddDirtyRect(&TempEntity,
|
||||
min(pEntity->Y + ImageHeight, TempPtr->Bottom) -
|
||||
TempEntity.Y,
|
||||
(pEntity->X + ImageWidth) - TempPtr->Right);
|
||||
(pEntity->X + ImageWidth) - TempPtr->Right);
|
||||
}
|
||||
/* Check for a nonoverlapped top portion */
|
||||
if (TempPtr->Top > pEntity->Y) {
|
||||
if (TempPtr->Top > pEntity->Y) {
|
||||
/* There’s a top portion that’s not overlapped */
|
||||
TempEntity.X = pEntity->X;
|
||||
TempEntity.Y = pEntity->Y;
|
||||
AddDirtyRect(&TempEntity, TempPtr->Top - pEntity->Y, ImageWidth);
|
||||
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)) {
|
||||
if (TempPtr->Bottom < (pEntity->Y + ImageHeight)) {
|
||||
/* 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);
|
||||
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 */
|
||||
return;
|
||||
|
|
@ -389,22 +389,22 @@ void EraseEntities()
|
|||
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 */
|
||||
TempPtr = &DirtyHead;
|
||||
while (((DirtyRectangle *)TempPtr->Next)->Top < pEntity->Y) {
|
||||
TempPtr = TempPtr->Next;
|
||||
TempPtr = &DirtyHead;
|
||||
while (((DirtyRectangle *)TempPtr->Next)->Top < pEntity->Y) {
|
||||
TempPtr = TempPtr->Next;
|
||||
}
|
||||
while ((((DirtyRectangle *)TempPtr->Next)->Top == pEntity->Y) &&
|
||||
(((DirtyRectangle *)TempPtr->Next)->Left < pEntity->X)) {
|
||||
TempPtr = TempPtr->Next;
|
||||
while ((((DirtyRectangle *)TempPtr->Next)->Top == pEntity->Y) &&
|
||||
(((DirtyRectangle *)TempPtr->Next)->Left < pEntity->X)) {
|
||||
TempPtr = TempPtr->Next;
|
||||
}
|
||||
/* Set the rectangle and actually add it to the dirty list */
|
||||
DirtyPtr = &DirtyRectangles[NumDirtyRectangles++];
|
||||
DirtyPtr->Left = pEntity->X;
|
||||
DirtyPtr->Top = pEntity->Y;
|
||||
DirtyPtr->Right = pEntity->X + ImageWidth;
|
||||
DirtyPtr->Bottom = pEntity->Y + ImageHeight;
|
||||
DirtyPtr->Next = TempPtr->Next;
|
||||
TempPtr->Next = DirtyPtr;
|
||||
DirtyPtr = &DirtyRectangles[NumDirtyRectangles++];
|
||||
DirtyPtr->Left = pEntity->X;
|
||||
DirtyPtr->Top = pEntity->Y;
|
||||
DirtyPtr->Right = pEntity->X + ImageWidth;
|
||||
DirtyPtr->Bottom = pEntity->Y + ImageHeight;
|
||||
DirtyPtr->Next = TempPtr->Next;
|
||||
TempPtr->Next = DirtyPtr;
|
||||
}
|
||||
</PRE>
|
||||
<!-- END CODE //-->
|
||||
|
|
|
|||
Loading…
Reference in a new issue