Path: chuka.playstation.co.uk!news From: Nick Slaven Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Scrolling backgrounds Date: Wed, 08 Jul 1998 22:35:54 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 104 Message-ID: <35A3E63A.AC9E437C@compuserve.com> References: <6nvfvm$9o1@chuka.playstation.co.uk> NNTP-Posting-Host: ld06-164.lon.compuserve.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Mark Green wrote: > > I am trying to create a 2D scrolling cloud-type background that is > automatically generated by an algorithm. I have the algorithm to generate > the next line to be scrolled on given the previous line, but I am having > some problem making the scrolling itself happen. > It would seem to make sense that I should hold the background somewhere > in video RAM, scroll and update it there then copy it to the frame buffer. > Unfortunately this seems to be very inefficient (requiring two full-screen > blits per frame, one to scroll the buffer and another to copy it to the frame > buffer) and will not work with the non-blocking operations anyway since the > scroll must be assured complete before the copy can take place. > I am sure that there is a more efficient way of doing this type of thing > but it is eluding me at the moment :) Can anyoone give me any pointers? Have you considered using the BG16 stuff, I've got this working with a scrolling background image (which just happens to be some clouds hence the name sky!). heres the code // BG16 uses its own work area, gpupacket area not used (this equation is on // page 142 of the green book #define worksize (((BG_FRAME_X/16+1)*(BG_FRAME_X/16+1+1)*6+4)*2+2) GsBG BGSky; GsMAP mapSky; GsCELL cellSky[128]; u_short indexSky[16][32]; u_long workSky[worksize]; void LoadSky(void) { u_short tpage,cba; GsIMAGE Im; int i,j,y,x; tpage=LoadTexture(TX_SKY,&Im); cba=GetClut(Im.cx,Im.cy); // chop the loaded tim into 16 pixel chunks for(i=0,y=0;y<128;y+=16) for(x=0;x<256;x+=16,i++) { cellSky[i].u = x; cellSky[i].v = y; cellSky[i].cba = cba; cellSky[i].tpage= tpage; } for(y=0,i=0,j=64;y<16;y++) for(x=0;x<32;x++) { if(y<4) { if(x<16) indexSky[y][x]=i++; else indexSky[y][x]=j++; } else indexSky[y][x]=0xffff; } mapSky.cellw = 16; mapSky.cellh = 16; mapSky.ncellw= 32; mapSky.ncellh= 16; mapSky.base = cellSky; mapSky.index = &indexSky[0][0]; BGSky.attribute=1<<27|1<<24; BGSky.x=BG_ORG_X; BGSky.y=BG_ORG_Y; BGSky.w=BG_FRAME_X; BGSky.h=BG_FRAME_X; BGSky.scrollx=0; BGSky.scrolly=0; BGSky.r=127; BGSky.g=127; BGSky.b=127; BGSky.map=&mapSky; BGSky.scalex=ONE; BGSky.scaley=ONE; BGSky.rotate=0; GsInitFixBg16(&BGSky,workSky); } void DrawSky(void) { BGSky.scrollx++; GsSortFixBg16(&BGSky,workSky,&WorldOT[activeBuff],(1<