Mail Archives: djgpp/1995/08/21/20:18:30
I was trying the Fat DS program by J. Walker and modified it
to simply copy frame_buf (a 64,000 byte array) to video RAM.
I wanted some pixel noise on the screen so I added this:
int i,x,y;
unsigned char *adr;
for(i=0; i<2000; i++) {
y = rand()%200;
x = rand()%320;
adr = frame_buf + y*320 + x; /* mode 13 pixel calc */
*adr = rand()%256;
/* ... and then frame_buf gets blitted to VRAM */
}
What I got instead was randomly colored pixels spaced in a
very regular pattern, about six or eight pixels apart
on each scanline. Using srand() before rand() didn't
improve things much.
The random() function works fine, though. In Borland C,
rand() works just as well. Is djgpp rand() supposed to
be this way?
- Raw text -