Ejemplo n.º 1
0
void Init()
{
	fntMain = font_LoadFromFile( GetResource( "font.zfi" ) );

	texTiles = tex_LoadFromFile( GetResource( "tiles.png" ) );
	tex_SetFrameSize( &texTiles, 32, 32 );

	// RU: Инициализация тайлов размером 32x32. Параметр Count указывает на количество тайлов по X и Y. Массив Tiles содержит кадры для каждого тайла.
	// EN: Initialization of tiles with size 32x32. Parameter Count set amount of tiles on X and Y. Array Tiles contains frames for every tile.
	map.Size.W  = 32;
	map.Size.H  = 32;
	map.Count.X = 25;
	map.Count.Y = 19;
	map.Tiles = (int**)malloc( sizeof( int* ) * map.Count.X );
	// RU: Заполняем карту "травой", 19 кадр.
	// EN: Fill the map by "grass", 19 frame.
	for ( int i = 0; i < map.Count.X; i++ )
	{
		map.Tiles[ i ] = (int*)malloc( sizeof( int ) * map.Count.Y );
		for ( int j = 0; j < map.Count.Y; j++ )
			map.Tiles[ i ][ j ] = 19;
	}

	// RU: Загружаем карту из бинарного файла.
	// EN: Load map from binary file.
	zglTFile f;
	file_Open( &f, GetResource( "ground.map" ), FOM_OPENR );
	for ( int i = 0; i < map.Count.X; i++ )
		file_Read( f, &map.Tiles[ i ][ 0 ], map.Count.Y * sizeof( int ) );
	file_Close( &f );
}
Ejemplo n.º 2
0
void Media_Tests(void)
{
	int i ;
	int j ;
	int k ;
	int l ;
	int m , handle ;
	unsigned char sector[512] ;
	gfx_Cls() ;
	putstr("Media Tests") ;
	printf("Media Tests\n") ;
	file_Unmount() ;    // just to test this and media_Init
	i = media_Init() ;
	if (i == 0)
	{
		printf("Please insert the uSD card") ;
		while (i = 0)
		{
			printf(".") ;
			i = media_Init() ;
		}
	}

	printf("First RAW sector=%d\n", rawbase) ;
	trymount() ;

	handle = file_Open("gfx2demo.gci", 'r') ;
	file_Seek(handle, 0x49, 0x5800) ;   // location of large unicorn file
	i = 128 * 128 * 13 * 2 + 8 ;     // size of large unicorn file
	l = (i / 512) + 1 ;
	// we assume here that the raw partition is big enough to write this, could
	k = rawbase ;
	m = 1 ;
	while (i != 0)
	{
		printf("Copying sector %d of %d\r", m, l) ;
		j = min(512, i) ;
		file_Read(sector, j, handle) ;
		media_SetSector(k >> 16, k & 0xFFFF) ;
		k++ ;
		media_WrSector(sector) ;
		i -= j ;
		m++ ;
	}
	file_Close(handle) ;
	media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ;
	media_Image(0,0) ;
	media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ;
	media_Video(0,128) ;

	media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ;
	media_WriteByte(0x11) ;
	media_WriteWord(0x2233) ;
	media_Flush() ;            // should write 0xFF over the rest of the sector
	media_SetSector(rawbase >> 16, rawbase & 0xFFFF) ;
	printf("\n%2.2x %4.4x %4.4x\n",media_ReadByte(), media_ReadWord(), media_ReadWord());
}
Ejemplo n.º 3
0
int kernel_Init(const char *name)
{
    printf("Engine Initializing V %d.%d.%d\n", K_VERS_1, K_VERS_2, K_VERS_3);

    if(mem_Init())
    {
		printf("\tFailed to load memory manager\n");
		return 1;
	}

    kernel_Set_Defaults();
    kernel_SetPaths();

    if(file_Init(kernel_GetPath("PTH_FileLog")))
	{
		printf("\tFailed to load file manager\n");
		return 1;
	}

    #ifndef NO_LOG
    kernel_Main.log = file_Open(kernel_GetPath("PTH_Log"), "w");

    if(kernel_Main.log == NULL)
    {
        printf("\nKernel log failed to load.\n");
        return 1;
    }
    #endif

    #ifdef NO_LOG
    printf("File logging disabled.\n");
    #endif

    file_Log(ker_Log(), 1, "Engine: %d.%d.%d\n", K_VERS_1, K_VERS_2, K_VERS_3);

	mth_FillAngles();

	srand((unsigned int)time(NULL));

    if(kernel_Init_SDL())
        return 1;

    SDL_WM_SetCaption(name, name);

	ker_Report_Video();

	surf_Init(kernel_GetPath("PTH_Textures"));

	if(control_Init(kernel_Main.control_Flags))
	{
		printf("\tFailed to load controls\n");
		return 1;
	}

	if(font_Init(kernel_GetPath("PTH_Fonts")))
	{
		return 1;
	}

	font_Load("Arial.ttf", 11, 1);
	font_Load("Arial.ttf", 13, 1);

	if(kernel_Setup_BaseState())
	{
	    printf("\tFailed to set up kernel gamestate\n");
        return 1;
	}

    puts("Complete");
	return 0;
}
Ejemplo n.º 4
0
void FAT_Tests(void)
{
	int i ;
	int j ;
	int k , handle;
	WORD w1, w2 ;
	unsigned char wks[255] ;
	unsigned char bytes[20] ;
	datar data ;
	gfx_Cls() ;
	printf("FAT Tests\n") ;
	putstr("FAT Tests\n") ;
	printf("File Error= %d\n", file_Error()) ;
	printf("uSD has %d Files\n", file_Count("*.*")) ;
	file_Dir("*.dat") ;     // should this get returned!? FindFirst and next certainly should, both need to be manual as they need "to(buffer)"

	if (file_Exists(testdat))
		file_Erase(testdat) ;
	handle = file_Open(testdat, 'w') ;
	printf("Handle= %d\n",handle) ;
	// write some stuff to uSD
	file_PutC('a', handle) ;
	file_PutW(1234, handle) ;
	file_PutS("This is a Test", handle) ;
	file_Close(handle) ;

	handle = file_Open(testdat, 'r') ;
	printf("Handle= %d\n",handle) ;
	// read it back and dump to screen
	printf("%c\n",file_GetC(handle)) ;
	printf("%d\n",file_GetW(handle)) ;
	i = file_GetS(wks, 100, handle) ;
	printf("Length=%d, String=""%s""\n", i, wks) ;

	file_Rewind(handle) ;
	i = file_Read(bytes, 10, handle) ;
	printf("Bytes read= %d Data=", i) ;
	for (j = 0; j <= i-1; j++)
		printf("%2.2x ", bytes[j]) ;
	i = file_Tell(handle, &w1, &w2) ;
	printf("\nFile pointer= %d\n", (w1 << 16) + w2) ;
	i = file_Size(handle, &w1, &w2) ;
	printf("File size=%d\n", (w1 << 16) + w2) ;

	file_Close(handle) ;
	file_Erase(testdat) ;

	handle = file_Open(testdat, 'w') ;
	printf("Handle=%d\n",handle) ;
	for(i = 1; i <= 50; i++)
	{
		data.recnum = i ;
		k = i % 20 ;
		for (j = 0; j <= 4; j++)
		{
			data.values[j] = atoz[k+j] ;
			data.idx = atoz[rand() % 27] ;
		}
		file_Write(sizeof(data), &data, handle) ;
	}
	file_Close(handle) ;
	handle = file_Open(testdat, 'r') ;
	file_Index(handle, sizeof(data) >> 16, sizeof(data) & 0xFFFF, 5) ;
	i = file_Read(&data, sizeof(data), handle) ;
	printf("%d %c %c %c %c %c %c\n", data.recnum, data.values[0],data.values[1],data.values[2],data.values[3],data.values[4], data.idx) ;
	file_Seek(handle, 0, 10*sizeof(data)) ;
	i = file_Read(&data, sizeof(data), handle) ;
	printf("%d %c %c %c %c %c %c\n", data.recnum, data.values[0],data.values[1],data.values[2],data.values[3],data.values[4], data.idx) ;
	file_Close(handle) ;
	file_Erase(testdat) ;


	file_FindFirstRet("*.dat", wks) ;
	printf(wks) ;
	printf("\n") ;
	file_FindNextRet(wks) ;
	printf(wks) ;
	printf("\n") ;

	handle = file_Open(testdat, 'w') ;
	printf("Handle=%d\n",handle) ;
	i = sizeof(Image) ;
	k = 0 ;
	while (i != 0)
	{
		j = min(512, i) ;
		file_Write(j, &Image[k], handle) ;
		i -= j ;
		k += j ;
	}
	file_Close(handle) ;
	gfx_Cls() ;
	handle = file_Open(testdat, 'r') ;
	file_Image(0,0,handle) ;
	file_Close(handle) ;
	gfx_MoveTo(40,10) ;
	putstr("4D Logo") ;

	file_Erase(testdat) ;
	handle = file_Open(testdat, 'w') ;
	printf("Handle=%d", handle) ;
	file_ScreenCapture(0,0,100,32, handle) ;
	file_Close(handle) ;

	handle = file_Open(testdat, 'r') ;
	file_Image(0,40,handle) ;
	file_Rewind(handle) ;
	file_Image(0,80,handle) ;
	file_Rewind(handle) ;
	file_Image(0,120,handle) ;
	file_Close(handle) ;
	file_Erase(testdat) ;
}
Ejemplo n.º 5
0
void MainWindow::on_actionOpen_triggered()
{
    file_Open();
}