/* Program: DROP.C Author : Kim Moser Date : 02/01/89 System : IBM PC, Borland Turbo-C 2.0 Descrip: "Drops" text on screen. Usage : DROP Hardware required: IBM PC or compatible with color or monochrome card. Compiler: Borland's Turbo C 2.0 Compiler settings: Linker settings: o Graphics library: ON */ /************************************************************************** Screen I/O identifiers **************************************************************************/ #define MAXROW 25 /* Width and height of screen [in characters]; may be changed if video card supports more rows and/or columns */ /* Types for screen I/O: */ typedef unsigned char scrnbyte; typedef struct scrnchar { scrnbyte ch, at; /* Character and its attribute [on screen] */ }; typedef unsigned int scrncoord; typedef unsigned short int color; typedef struct scrnchar far *vid_addr; /* Must be FAR because video memory is in a different data segment */ /* @@@ NOT USED static scrncoord curx=1, cury=1; /* Cursor coordinates for write() procedures */ */ #define COLOR 0xB8000000L #define MONO 0xB0000000L unsigned char far *CRT_MODE = (unsigned char far *) 0x00400049L; /* BIOS video mode number */ unsigned int far *CRT_COL = (unsigned int far *) 0x0040004AL; /* Pointer to number of columns */ vid_addr SCREEN = (vid_addr) COLOR; /* Default */ #define xytoadr(x,y) ((scrncoord) ( (y-1)* *CRT_COL + (x-1) ) ) /* scrncoord xytoadr( x, y ) scrncoord x, y; /* Returns offset from (0,0), of location (x,y) on screen, according to screen width and height #defined */ { return (scrncoord) ( (y-1)* *CRT_COL + (x-1) ); } */ struct scrnchar *peeksc( x, y, c ) /* Sets c-> to char and color at (x,y) [offset from 1,1] */ scrncoord x,y; struct scrnchar *c; { register vid_addr scrn = (vid_addr) (SCREEN + xytoadr(x,y)); *c = *scrn; /* Copy from video to mem */ return c; /* Return pointer */ } void writeat( x, y, ch ) scrncoord x,y; char ch; { register vid_addr scrn = (vid_addr) (SCREEN + xytoadr(x,y)); scrn->ch = ch; } void writeatsc( x, y, c ) /* Writes scrnchar pointed to by 'c' at (x,y) [offset from 1,1] */ scrncoord x,y; struct scrnchar *c; { register vid_addr scrn = (vid_addr) (SCREEN + xytoadr(x,y)); *scrn = *c; /* Copy from mem to vid */ } void main(void) { register scrncoord x,y; struct scrnchar c; register char some; /* Initialization: */ SCREEN = ((*CRT_MODE==7) ? (vid_addr) MONO : (vid_addr) COLOR ); do { some = 0; for (x=1; x<=*CRT_COL; x++) { for (y=MAXROW; y>1; y--) if ( (peeksc(x,y,&c)->ch) == ' ' ) if ( (peeksc(x,y-1,&c)->ch) != ' ' ) { writeatsc( x, y, &c ); writeat( x, y-1, ' ' ); some = 1; } } } while (some); }