/*
  Name: Toolbox.h 
  Copyright: (c) 2008
  Author: Chris Evans
  Date: 12/12/08 18:02
  Description: Tubro C++ 2.01/BC++ 3.11 library
*/

#ifndef __toolbox_h
#define __toolbox_h

#define true  1
#define false 0

void _clrscr(void) {
     int i=0;
     for (i=0; i<25; i++) {
         printf("\n");
     }
}

int _stoi(char *s) { /* string to integer func */
int n, sign ;
	while( *s == ' ' || *s == '\n' || *s == '\t' ) s++ ;
	sign = 1 ;
	if( *s == '+' ) s++ ; else 
	if( *s == '-' ) { sign = -1 ; s++ ; }
	for( n=0 ; *s >= '0' && *s <= '9' ; s++ )  
      n = 10 * n + *s - '0' ;
return(sign * n); }

int center(int len, char *s) {
int i,l;
    l = (40 - (len / 2));
   	for (i=0;i<l;i++) printf(" ");
    printf("%s",s);
}

void fkeyb(void) {
     int q=0;
     while((q = getchar()) != '\n' && q != EOF);
}

void reboot(int warm) {
#ifndef _BLOODSHED
short FAR *bios_post = (short FAR *)0x00400072;
void (FAR * boot)(void) = (void (FAR *)())0xffff0000;
     if (warm==0x1234) *bios_post = 0x1234; else  *bios_post = 0;
     boot();
#endif     
}


#endif
