Example #1
0
static TA_context* tactx_Alloc(void)
{
	TA_context* rv = 0;

#ifndef TARGET_NO_THREADS
   slock_lock(mtx_pool);
#endif
	if (ctx_pool.size())
	{
		rv = ctx_pool[ctx_pool.size()-1];
		ctx_pool.pop_back();
	}
#ifndef TARGET_NO_THREADS
   slock_unlock(mtx_pool);
#endif
	
	if (rv)
      return rv;

   rv = new TA_context();
   rv->Alloc();
   printf("new tactx\n");

	return rv;
}
Example #2
0
TA_context* read_frame(const char* file, u8* vram_ref) {
	
	FILE* fw = fopen(file, "rb");
	char id0[8] = { 0 };
	u32 t = 0;
	u32 t2 = 0;

	fread(id0, 1, 8, fw);

	if (memcmp(id0, "TAFRAME3", 8) != 0) {
		fclose(fw);
		return 0;
	}

	TA_context* ctx = tactx_Alloc();

	ctx->Reset();

	ctx->tad.Clear();

	fread(&ctx->rend.isRTT, 1, sizeof(ctx->rend.isRTT), fw);
	fread(&ctx->rend.isAutoSort, 1, sizeof(ctx->rend.isAutoSort), fw);
	fread(&ctx->rend.fb_X_CLIP.full, 1, sizeof(ctx->rend.fb_X_CLIP.full), fw);
	fread(&ctx->rend.fb_Y_CLIP.full, 1, sizeof(ctx->rend.fb_Y_CLIP.full), fw);

	fread(ctx->rend.global_param_op.head(), 1, sizeof(PolyParam), fw);
	fread(ctx->rend.verts.head(), 1, 4 * sizeof(Vertex), fw);

	fread(&t, 1, sizeof(t), fw);
	verify(t == VRAM_SIZE);

	vram.UnLockRegion(0, VRAM_SIZE);

	fread(&t2, 1, sizeof(t), fw);

	u8* gz_stream = (u8*)malloc(t2);
	fread(gz_stream, 1, t2, fw);
	uncompress(vram.data, (uLongf*)&t, gz_stream, t2);
	free(gz_stream);


	fread(&t, 1, sizeof(t), fw);
	fread(&t2, 1, sizeof(t), fw);
	gz_stream = (u8*)malloc(t2);
	fread(gz_stream, 1, t2, fw);
	uncompress(ctx->tad.thd_data, (uLongf*)&t, gz_stream, t2);
	free(gz_stream);

	ctx->tad.thd_data += t;
	fclose(fw);
    
    return ctx;
}
Example #3
0
TA_context* tactx_Alloc()
{
	TA_context* rv = 0;

	mtx_pool.Lock();
	if (ctx_pool.size())
	{
		rv = ctx_pool[ctx_pool.size()-1];
		ctx_pool.pop_back();
	}
	mtx_pool.Unlock();
	
	if (!rv)
	{
		rv = new TA_context();
		rv->Alloc();
		printf("new tactx\n");
	}

	return rv;
}