/* corner.c (c10.c) - Don Yang (uguu.org) Push all characters towards a random corner of the screen. 11/21/99 */ /* System globals */ volatile int far *clock = (int far *)0x0040006c; /* BIOS clock */ int far *screen = (int far *)0xb8000000; /* Video memory */ int buffer[2048]; /* SCreen buffer */ int far WaitLoop[] = { /* Synchronization loop */ /* xor ax, ax 31 c0 mov es, ax 8e c0 mov bx, 046ch bb 6c 04 es: 26 mov dx, [bx] 8b 17 loop: es: 26 cmp dx, [bx] 3b 17 je loop 74 fb retf cb */ 0xc031, 0xc08e, 0x6cbb, 0x2604, 0x178b, 0x3b26, 0x7417, 0xcbfb}; int (far *sync)(int); /* General globals */ int seed; /* Generator seed */ int x, y, dx, dy, lx, ly; /* Loop counters */ int px[2048], py[2048], pc = 0; /* Particles */ int pi[2048]; int m; /* Status flags */ void main(void) { /* Initialize */ seed = *clock; /* >0 */ sync = WaitLoop; /* Collect particles */ if( seed & 1 ) { y = 24; dy = -1; ly = -1; } else { y = 0; dy = 1; ly = 25; } for(; y != ly; y += dy) /* -1 */ { if( seed & 2 ) { x = 79; dx = -1; lx = -1; } else { x = 0; dx = 1; lx = 80; } for(; x != lx; x += dx) /* -2 */ { if( (screen[y * 80 + x] & 0xff) > 32 ) { px[pc] = x; py[pc] = y; pi[pc++] = screen[y * 80 + x]; } } } for(x = 0; x < 2000; x++) /* -3 */ buffer[x] = 0; for(x = 0; x < pc; x++) /* -4 */ buffer[py[x] * 80 + px[x]] = pi[x]; /* Main loop */ do /* -5 */ { /* Animate particles */ for(m = lx = 0; lx < pc; lx++) /* -6 */ { x = px[lx] - dx; y = py[lx] - dy; x = (x >= 0 && x < 80) /* -8 */ ? x : px[lx]; y = (y >= 0 && y < 25) /* -9 */ ? y : py[lx]; if( !buffer[y * 80 + x] ) { buffer[py[lx] * (m = 80) + px[lx]] = 0; buffer[(py[lx] = y) * m + (px[lx] = x)] = pi[lx]; } } /* Draw particles */ sync(0); for(x = 0; x < 2000; x++) /* -7 */ screen[x] = buffer[x]; } while( m ); }