+ int str_length;
+ for( str_length=0; str_length<len; str_length++ )
+ if( !str[str_length] )
+ return str_length;
+
+ return str_length;
+}
+
+/* Print the string(max length:len) centered into buf (has width:width) */
+VG_STATIC void highscore_strc( char *buf, const char *str, int len, int width )
+{
+ int str_length = highscore_strlen( str, len ),
+ offs = (width-str_length)/2;
+
+ for( int i=0; i<str_length; i++ )
+ {
+ int j=i+offs;
+
+ if( j >= width )
+ return;
+
+ buf[j] = str[i];
+ }
+}
+
+/* Print the string(max length:len) left aligned into buf */
+VG_STATIC void highscore_strl( char *buf, const char *str, int len )
+{
+ for( int i=0; i<len; i++ )
+ {
+ if( !str[i] )
+ return;
+
+ buf[i] = str[i];
+ }
+}
+
+/* Print the string (max length:len) right aligned into buf (has width:width) */
+VG_STATIC void highscore_strr( char *buf, const char *str, int len, int width )
+{
+ int str_length = highscore_strlen( str, len );
+
+ for( int i=0; i<len; i++ )
+ {
+ if( !str[i] )
+ return;
+
+ buf[width-str_length+i] = str[i];
+ }
+}
+
+/* Print integer (padded with: alt), right aligned into buf(width: len) */
+VG_STATIC void highscore_intr( char *buf, int value, int len, char alt )
+{
+ int i=0;
+ while(value)
+ {
+ if( i>=len )
+ return;
+
+ buf[ len-1 - (i ++) ] = '0' + (value % 10);
+ value /= 10;
+ }
+
+ for( ;i<len; i ++ )
+ buf[ len-1 - i ] = alt;
+}
+
+/* Print integer into buffer with max length len */
+VG_STATIC void highscore_intl( char *buf, int value, int len )
+{
+ char temp[32];
+
+ int i=0;
+ while(value)
+ {
+ if( i>=len )
+ break;
+
+ temp[ i ++ ] = '0' + (value % 10);
+ value /= 10;
+ }
+
+ if( i>len )
+ i = len;
+
+ for( int j=0; j<i; j ++ )
+ {
+ buf[j] = temp[ i-1-j ];
+ }
+}
+
+/* Clear buffer with length using clr character */
+VG_STATIC void highscore_clear( char *buf, char clr, int length )
+{
+ for( int i=0; i<length; i++ )
+ buf[i] = clr;
+}
+
+/*
+ Megapark Green
+--------------------------
+ #| Player | Time | Pts
+ 1|aaaabbbbcc 5:23.32 30000
+ 2| jef 0:20.34 10000
+ 3|aaabbbcccl 2:30.45 20000
+ 4|
+ 5|
+ 6|
+ 7|
+ 8|
+ 9|
+10|
+*/
+
+/* Generate a highscores board in text form, the width is always 27. Buffer
+ * must be (count+3)*27 in size. */
+VG_STATIC void highscores_board_generate( char *buf, u32 id, u32 count )
+{
+ int w=27;
+ highscore_clear( buf, ' ', (count+3)*w );
+
+ struct track_info *inf = &track_infos[id];