#include #include /************************************************************************* * 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 0x0A #define COLOR_STREAM 0x02 #define COLOR_NORMAL 0x07 /************************************************************************* * Stream Macros *************************************************************************/ #define MaxStreams 80 #define MAX_STREAM_LEN SCR_HEIGHT #define MIN_SPEED 5 #define DELAY_INTERVAL 100 #define ERASE_ODDS 3 #define StreamWrite 1 #define StreamErase 0 typedef struct { char Active; int Row, Pos; int Length; char Type; 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 StreamPos MatrixStreams[StreamID].Pos #define StreamLength MatrixStreams[StreamID].Length #define StreamData MatrixStreams[StreamID].Data #define StreamType MatrixStreams[StreamID].Type void InitializeStream (unsigned char StreamID) { int i; if (StreamID < SCR_WIDTH) { StreamActive = 0; StreamRow = 0; StreamPos = 0; StreamLength = 0; StreamType = StreamErase; for (i=0; i 0) { ScrClr(StreamRow-1, StreamID) = COLOR_STREAM; } if (StreamPos < StreamLength) { ScrChar(StreamRow, StreamID) = StreamData[StreamPos]; ScrClr(StreamRow, StreamID) = COLOR_FIRST_CHAR; } else { StreamRow = SCR_HEIGHT; } } else { ScrClr(StreamRow - 1, 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)) { StreamRow++; if (StreamRow <= SCR_HEIGHT) { StreamPos++; } else { DeleteStream(StreamID); } } } void CreateStream (unsigned char StreamID) { int i; if ((StreamID < SCR_WIDTH) & (StreamActive == 0)) { StreamCount++; InitializeStream(StreamID); StreamActive=1; StreamRow = random(SCR_HEIGHT); StreamLength = random(MAX_STREAM_LEN - StreamRow) + 1; StreamType = (rand() % ERASE_ODDS == 0) ? StreamErase : StreamWrite; for (i=0; i SCR_WIDTH)) { MaxStreamCount = MaxStreams; } /* Initialize Streams */ StreamCount = 0; for (i=0; i