Path: chuka.playstation.co.uk!news From: Alex Herbert Newsgroups: scee.yaroze.programming.2d_graphics,scee.yaroze.beginners,scea.yaroze.programming.2d_graphics Subject: Re: Need help with arrays Date: Tue, 18 Aug 1998 19:16:33 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 61 Message-ID: <35D9C501.C08B393A@ndirect.co.uk> References: <6rcfhe$l2e4@chuka.playstation.co.uk> Reply-To: aherbert@ndirect.co.uk NNTP-Posting-Host: dialin2-50.ndirect.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Xref: chuka.playstation.co.uk scee.yaroze.programming.2d_graphics:516 scee.yaroze.beginners:505 scea.yaroze.programming.2d_graphics:399 Chris Searle wrote: > Hi, I've got an array, u_long line[640], and want to copy a random 320 > chunks to a two-dimensional array here some source: > > #include > #include > #include > > u_long scr[240][320]; > u_long line[640]; > > main() { > RECT screen; > short counter; > > SetVideoMode(MODE_PAL); > GsInitGraph(320, 240, 4, 0, 0); > GsDefDispBuff(0, 0, 0, 0); > > screen.x = screen.y = 0; > screen.h = 240; > screen.w = 320; > > for( counter = 0; counter < 640; counter++) { > if(rand()%2) line[counter] = (1<<15) + (31<<10) + (31<<5) + 31; //set > pixels to > else line[counter] = (1<<15); //black > or white > } // setup first array > > while(1) { > VSync(0); > > for(counter = 0; counter < 240; counter++) { //This part > doesn't work > memcpy( scr+(counter*320), line+(rand()%320), 640 ); //copy 640 bytes > (320 int's) > } > > LoadImage( &screen, *scr ); > > DrawSync(0); > GsSwapDispBuff(); > } // end while > > ResetGraph(0); > } // end main > > This is a simple programming question but I do need some help. > > Cheers Not sure exactly what you're trying to do here, but your scr[] array should probably be u_short, as each screen pixel is 16-bit. u_long is 32. Herbs