bool levelClass::setNextLevel()
{
    if(++numberLevel > maxLevel || goodLevel() == false)
        return true;
    else
        return false;
}
bool levelClass::setNumberLevel(int val)
{
    numberLevel = val;
    if(numberLevel > maxLevel || goodLevel() == false)
        return true;
    else
        return false;
}
int main(void)
{
	FILE *fp;
	unsigned char levelBuf[READ_LEVEL_DATA_SIZE];
	unsigned char *levelData;
	int curLevel = 0;
	int readSize= 0, isGood = 1;
	unsigned long curPos = MAP_START_POSITION;
	unsigned long dspPos = curPos;
	
	if((fp = fopen(FILE_NAME, "rb")) ==NULL) {
		printf("Open file \"%s\" failed !\n", FILE_NAME);
		return 1;
	}
	
	if(fseek(fp, curPos, SEEK_SET) != 0) {
		printf("Fseek error ! @%d\n", __LINE__);
		fclose(fp);
		return 1;
	}

	dumpTitle();

	printf("var %s = [\n", DATA_VAR_NAME);	

	while(
#ifndef START_ALL_ISGOOD	
		   isGood &&
#endif
		   curLevel < MAX_LEVEL && 
	       (readSize = fread(levelBuf, sizeof(char), READ_LEVEL_DATA_SIZE, fp)) ==  READ_LEVEL_DATA_SIZE 
	){
		levelData = levelBuf;	
#ifdef START_GOOD_BYTE
		unsigned char startByte = *(levelData++);
		
		switch(startByte) {
		case START_SKIP_BYTE1:
#ifdef START_SKIP_BYTE2			
		case START_SKIP_BYTE2:
#endif			
#ifdef START_SKIP_BYTE3
		case START_SKIP_BYTE3:
#endif			
#ifdef START_SKIP_BYTE4
		case START_SKIP_BYTE4:
#endif			
			//printf("SKIP0 - %x\n", dspPos);
			break;
		case 0:	 //good if not allzero
			if(allZero(levelData)){
				//printf("SKIP1 - %x\n", dspPos);
				break;
			}
#ifdef START_ALL_ISGOOD			
		default:	
#endif		
		case START_GOOD_BYTE:
#endif	       
			if((isGood = goodLevel(levelData))) {
				//dumpLevel(++curLevel, levelData);
				//printf("%x", dspPos);
				dumpLevel4JavaScript(++curLevel, levelData);
			}
#ifdef START_GOOD_BYTE
			break;
#ifndef START_ALL_ISGOOD
		default:
			isGood = 0;
			printf("%x", dspPos);
			break;
#endif			
		}
#endif	
		dspPos += READ_LEVEL_DATA_SIZE;
	}
	printf("];\n");
	
	fclose(fp);	
}