scrolling across screen in C
Joseph C McDonald
HyperDriven at cup.portal.com
Wed Feb 1 16:24:37 AEST 1989
Hello all,
I am a beginner/intermediate C'er. The following is a small project
I am working on for the IBM PC. My objective is to have a line of text
continually scrolling across the bottem of the screen. I wanted to
use the clock interrupt to do this but was having problems so I took the
interrrupt calling scheme out of the loop for now. I just want to get the
routine working properly. My problem is that after it reaches the beginning
of the screen (I want it to scroll from right to left) it starts over again
this is not what I wanted. I wanted the tail of the message to keep on
scrolling across while the beginning started at the last col again.
I don't know how well I am explaining myself, but I will post the
little segment of code that I have.
/* mess.c */
#include <stdio.h>
#include <dos.h>
typedef unsigned char screen_t[25][80][2];
screen_t far *screen;
void mess() {
int base=79; /* this is the last column of the screen */
int i=0; /* counter */
int j=0; /* counter */
char buffer[80] =
"this is a test of the awsome capability of this system ";
char temp[80];
for (j=0;j<=80;j++) temp[j]='\0'; /* initialize array */
for (j=0;j<strlen(buffer);j++) {
strncpy(temp,buffer,j);
for(i=0;i<strlen(temp);i++) {
(*screen)[23][base+i][0] = temp[i];
} /* end for */
if ((base+i)==1) {
base=79;
}else{
base--; } /* end if */
} /* end for */
} /* end mess() */
main() {
int i=0;
screen=(unsigned char far *)0xb0000000; /* this is for mono */
/* use 0xb80000000 for color */
printf("hit any key to start the message\n");
getch();
for (i=0;i<10;i++) {
mess(); }
}
------------------------------------------------
sometimes i think i think sometimes i think ...
Joseph McDonald
More information about the Comp.lang.c
mailing list