Category : C Source Code
Archive   : SCROLL2.ZIP
Filename : SCROLL.C

Output of file : SCROLL.C contained in archive : SCROLL2.ZIP
// This is a simple program to demonstrate one way to scroll a page
// up or down using mode X.

// To compile it use large model and link with xlib06l.lib, one idea
// to make things speed up is to modify the page flip routine source
// and remove all loops (I believe there are two). This can make the
// difference between 30fps and 60fps!!

// Enjoy.

#include "xlib_all.h"

#define FARPTR(x) (MK_FP(FP_SEG(x),FP_OFF(x)))

void load_pallete(void);
void load_mapsprites(void);
void put_map(int);

char far * Sprite[1]; // Sprite table
int counter; // Global counter
char buff[5000]; // Temporary buffer for loading sprites

char far * // from xlib6
AllocatedSprite(int width, int height, int logical_width, char far * bitmap)
char far * result;
int size;
result = farmalloc((width * height * 7) / 2 + 25);
if (result == 0) {printf("\n out of memory \n");exit(0);}
size = x_compile_bitmap_32(logical_width, bitmap, result);
return farrealloc(result, size);

void load_pallete() // load pallete from raw file
FILE *k;
int i;
unsigned char r,g,b;
k = fopen("mac.pal","rb");
for (i=0; i<256; i++){
r = fgetc(k);
g = fgetc(k);
b = fgetc(k);

void load_mapsprites()
FILE *k;
int i,l;
unsigned char c;
for (l=0; l<=0; l++){ // loop for the number of sprites to load
for (i=0; i<4; i++)
fgetc(k); // strip size header
for (i=2;i<18;i++) // make first line all 0's -- why? I dont know it just works better, expirimentation is great!!
buff[i] = 0;
for (i=18;i<274;i++) // actually read spite data
buff[i] = fgetc(k);
buff[0] = 16; // set up sizes for compilation
buff[1] = 17;
Sprite[l] = AllocatedSprite(buff[0], buff[1], 80,FARPTR(buff)); // compile it

void put_map(int i)
register int k,j,r;
r = (16 - (i % 16))+16; // compute offset of tiles to screen
for (j=0;j<21;j++)
for (k=0;k<16;k++)
x_put_cbitmap((j << 4),(k<<4)+r,HiddenPageOffs,Sprite[0]);

struct time begin,end;
int i=0;
load_mapsprites(); // load sprite(s)
free(buff); // free sprite buffer
x_set_mode(1,320); // set X mode
load_pallete(); // load pallete
x_set_tripplebuffer(798); // set up triple buffer
gettime(&begin); // get start time
do { // loop
put_map(i++); // draw a page
x_page_flip(0,32); // look at page just drawn
counter++; // inc global counter
} while (!kbhit()); // until anykey hit
gettime(&end); // get end time
x_text_mode(); // exit X mode
printf("number of frames = %d\n",counter); // figure it all out
printf("begin time = %d - %d - %d\n",begin.ti_min,begin.ti_sec,begin.ti_hund);
printf("end time = %d - %d - %d\n",end.ti_min,end.ti_sec,end.ti_hund);
printf("frame rate = %d\n",

  3 Responses to “Category : C Source Code
Archive   : SCROLL2.ZIP
Filename : SCROLL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: