Xref: news-dnh.mv.net comp.os.msdos.djgpp:405 Newsgroups: comp.os.msdos.djgpp Path: news-dnh.mv.net!mv!news.sprintlink.net!howland.reston.ans.net!news.starnet.net!wupost!news.utdallas.edu!corpgate!bcarh189.bnr.ca!nott!cunews!freenet.carleton.ca!FreeNet.Carleton.CA!ao950 From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Subject: Screen Scrolling Snafu (heeeeeeeelp) Sender: ao950 AT freenet2 DOT carleton DOT ca (Paul Derbyshire) Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Organization: The National Capital FreeNet Date: Fri, 16 Jun 1995 00:54:13 GMT Lines: 115 To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp Yeah, it's me again. I must have an older, bug-ridden version or something... I have source code for a very rapid, direct-memory-copying screen scrolling routine. (As direct as it can be in protected mode..>!) It works fine when the scroll involves copying the memory to a higher address, but not when copying to a lower one. When copying to a lower one it almost works, but the top one fifth or so of the screen behaves very strangely. The scroll uses a buffer; 64000 bytes are copied from screen into the buffer at (buffer+1000+scroll) where scroll is dx+320*dy (320x200). Then 64000 bytes are copied from buffer+1000 to screen. If scroll is negative the problem occurs. I have checked and rechecked all the pointer operations and math, and I have concluded that the problem lies with the compiler and how it handles the assignment operation that does the memory copying. The source code follows for a short program that scrolls a field of random pixels and slowly changes the scroll, as though a camera were flying in a circle over a landscape of random dots. #include #include #define SETMODE 0 #define VIDEO_INT 0x10 #define G320x200x256 19 #define TEXT_COLOR 3 #define PUTPIXEL(x,y,c) *(video+(x)+(y)*320)=(c) struct the_screen { unsigned char pixel[320][240]; unsigned char overflows[2000]; }; void hsetmode (char mode); void scroll (int scrollstep); struct the_screen *screen = (struct the_screen *)0xD0000000; char *video = (char *)0xD0000000; struct the_screen vbuffer; struct the_screen *vbuf = &vbuffer; char *vb2 = (char *)&vbuffer+1000; void main (void) { int x,y; int x1,y1; int x2,y2; int i,j; int scrs; int dx[16]={-6,-5,-4,-3, 0, 3, 4, 5, 6, 5, 4, 3, 0,-3,-4,-5}; int dy[16]={ 0,-3,-4,-5,-6,-5,-4,-3, 0, 3, 4, 5, 6, 5, 4, 3}; unsigned char color; hsetmode (G320x200x256); for (x=0; x<320; x++) { for (y=0; y<200; y++) { color=rand()/128; PUTPIXEL(x,y,color); } } for (i=0; i<16; i++) { scrs=dy[i]*320+dx[i]; y1=(dy[i]<0) ? 200+dy[i] : 0; y2=(dy[i]<0) ? 200 : dy[i]; x1=(dx[i]<0) ? 320+dx[i] : 0; x2=(dx[i]<0) ? 320 : dx[i]; for (j=0; j<40; j++) { scroll (scrs); for (x=x1; x