I fiddled around in your code a bit:
//
// includes.
//
#include <windows.h>
#include <string.h>
#include "tinyptc_ext.h"
#include "lib - graphics 2d 1-1.h"
extern unsigned char us64_pal[];
extern unsigned char us64_raw[];
//
// sub routines.
//
void bitmap_scroller( gfx_buffer *dest, anim_image *font );
//
// meet the globals.
//
static float start_pos=0.0f;
static int delay=0;
static int best_fit_wwidth=48;//640+128/64;
static char scroller[] = { " "
"HELLO THERE! IS THAT YOU CLYDE? GUESS WHAT CHUM? "
"I THINK IT'S WORKING THIS SCROLL OF MINE!! YIPPEEE!!!"
" "};
static int scroller_length=strlen( scroller );
static gfx_buffer *screen_buffer, *temp, *font_image, *scroll_buffer;
static anim_image *font_one;
int main()
{
//
// initializing.
//
screen_buffer=create_gfx_buffer( 640, 480 );
scroll_buffer=create_gfx_buffer( 640+64, 64 );
font_image=load_gfx_buffer( us64_raw, us64_pal, 512, 512 );
font_one=create_anim_images( font_image, 64,64,32,8,8);
delete_gfx_buffer (font_image);
set_graphics( "bItMaP sCrOlLeR", 640, 480 );
//
// main program loop.
//
while (1)
{
//
// clear screen.
//
clear_gfx_buffer(screen_buffer, 0);
bitmap_scroller( screen_buffer, font_one );
//
// render to the screen buffer.
//
ptc_update( &screen_buffer->pixels[0] );
}
delete_anim_image( font_one );
delete_gfx_buffer( screen_buffer );
}
void bitmap_scroller( gfx_buffer *dest, anim_image *font )
{
int curchar= 0;
int x= start_pos;
// find first character that's not outside the left border
while (scroller[curchar] && x+font->frame[scroller[curchar] - 32]->wwidth<0)
{
x+=font->frame[scroller[curchar] - 32]->wwidth;
curchar++;
}
// draw characters until right border reached
while (x<640 && scroller[curchar])
{
char c= scroller[curchar] - 32;
draw_gfx_buffer( dest, font->frame[c], x, 240 );
x+=font->frame[c]->wwidth;
curchar++;
}
start_pos-=1.0f;
}
It now keeps track of the pixel-position of the first character of the scroll-text on the screen.
Characters outside the left border of the screen are skipped, then characters are drawn until the right border of the screen is reached.
This has some potential for optimization if you happen to have a few megabytes of text.
Still misses wrapping when end of the text is reached.