#include #include #include #include /************************************************************************* * Stream Macros *************************************************************************/ #define MaxStreams 10 #define MAX_STREAM_LEN 50 #define MIN_SPEED 5 #define DELAY_INTERVAL 20 /************************************************************************* * Screen Macros *************************************************************************/ #define SCR_WIDTH 80 #define SCR_HEIGHT 25 char far *ScrPtr=(char far *) 0xB8000000L; #define ScrChar(row,col) *(ScrPtr + ((row) * SCR_WIDTH * 2) + ((col) * 2)) #define ScrClr(row,col) *(ScrPtr + ((row) * SCR_WIDTH * 2) + ((col) * 2) + 1) /************************************************************************* * Color Streams Definition *************************************************************************/ #define COLOR_BACKGROUND 0x00 #define COLOR_FIRST_CHAR 0x20 #define COLOR_STREAM 0x02 #define COLOR_NORMAL 0x07 typedef struct { char Active; int Row, StartPos, EndPos; int Length; char Speed,DelayCount; char Data[MAX_STREAM_LEN]; } Stream; static Stream MatrixStreams[SCR_WIDTH]; static unsigned char StreamCount; /************************************************************************* * Matrix Streams Macro Shorthands *************************************************************************/ #define StreamActive MatrixStreams[StreamID].Active #define StreamRow MatrixStreams[StreamID].Row #define StreamStartPos MatrixStreams[StreamID].StartPos #define StreamEndPos MatrixStreams[StreamID].EndPos #define StreamLength MatrixStreams[StreamID].Length #define StreamSpeed MatrixStreams[StreamID].Speed #define StreamDelayCount MatrixStreams[StreamID].DelayCount #define StreamData MatrixStreams[StreamID].Data void InitializeStream (unsigned char StreamID) { int i; if (StreamID < SCR_WIDTH) { StreamActive = 0; StreamRow = 0; StreamStartPos = 0; StreamEndPos = 0; StreamLength = 0; StreamSpeed = 0; StreamDelayCount = 0; for (i=0; i= 0)) { start = StreamRow; if (start > SCR_HEIGHT) { start = SCR_HEIGHT; } for (i = start, pos = StreamStartPos; (i >= 0) && (pos <= StreamEndPos); i--, pos++) { ScrChar(i, StreamID) = StreamData[pos]; if ((StreamRow <= SCR_HEIGHT) && (pos == StreamStartPos)) { ScrClr(i, StreamID) = COLOR_FIRST_CHAR; } else { ScrClr(i, StreamID) = COLOR_STREAM; } } /* Clear the rest of the column */ for ( ; i>-1; i--) { ScrClr(i, StreamID) = COLOR_BACKGROUND; } } } void DeleteStream (unsigned char StreamID) { if ((StreamID < SCR_WIDTH) && (StreamActive == 1)) { StreamCount--; InitializeStream(StreamID); } } void UpdateStream (unsigned char StreamID) { if ((StreamID < SCR_WIDTH) && (StreamActive == 1)) { if (StreamDelayCount < StreamSpeed) { StreamDelayCount++; } else { StreamDelayCount = 0; StreamRow++; if (StreamRow <= 0) { StreamStartPos = 0; StreamEndPos = 0; } else if (StreamRow < SCR_HEIGHT) { StreamEndPos++; } else if (StreamRow == SCR_HEIGHT) { StreamStartPos = 1; StreamEndPos = SCR_HEIGHT + 1; } else { StreamStartPos++; StreamEndPos++; if (StreamStartPos >= StreamLength) { StreamStartPos = StreamLength-1; } if (StreamEndPos >= StreamLength) { StreamEndPos = StreamLength-1; } if ((StreamRow - StreamLength) >= SCR_HEIGHT) { DeleteStream(StreamID); } } } } } void CreateStream (unsigned char StreamID) { int i; if ((StreamID < SCR_WIDTH) & (StreamActive == 0)) { StreamCount++; InitializeStream(StreamID); StreamActive=1; StreamRow = 0 - random(SCR_HEIGHT); StreamLength = random(MAX_STREAM_LEN) + 1; StreamSpeed = random(MIN_SPEED); for (i=0; i SCR_WIDTH)) { MaxStreamCount = MaxStreams; } /* Initialize Streams */ StreamCount = 0; for (i=0; i