MaiAT3PlusCoreDecoder::MaiAT3PlusCoreDecoder()
{

	MaiAT3PlusCoreDecoderJointChnInfo *joint_chn_info =
		(MaiAT3PlusCoreDecoderJointChnInfo*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderJointChnInfo));
	Mai_memset(joint_chn_info, 0, sizeof(MaiAT3PlusCoreDecoderJointChnInfo));

	MaiAT3PlusCoreDecoderChnACCTableInner *inner0 = 
		(MaiAT3PlusCoreDecoderChnACCTableInner*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCTableInner));
	Mai_memset(inner0, 0, sizeof(MaiAT3PlusCoreDecoderChnACCTableInner));
	MaiAT3PlusCoreDecoderChnACCTableInner *inner1 = 
		(MaiAT3PlusCoreDecoderChnACCTableInner*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCTableInner));
	Mai_memset(inner1, 0, sizeof(MaiAT3PlusCoreDecoderChnACCTableInner));

	for (Mai_I32 a0 = 0; a0 < 2; a0++)
	{
		chn_info[a0] = (MaiAT3PlusCoreDecoderChnInfo*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnInfo));
		Mai_memset(chn_info[a0], 0, sizeof(MaiAT3PlusCoreDecoderChnInfo));
		
		chn_info[a0]->chn_flag = a0;
		chn_info[a0]->joint_chn_info = joint_chn_info;

		chn_info[a0]->acc_data_old = 
			(MaiAT3PlusCoreDecoderChnACCData*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCData));
		Mai_memset(chn_info[a0]->acc_data_old, 0, sizeof(MaiAT3PlusCoreDecoderChnACCData));
		chn_info[a0]->acc_data_now = 
			(MaiAT3PlusCoreDecoderChnACCData*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCData));
		Mai_memset(chn_info[a0]->acc_data_now, 0, sizeof(MaiAT3PlusCoreDecoderChnACCData));

		chn_info[a0]->acc_table_old = 
			(MaiAT3PlusCoreDecoderChnACCTable*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCTable));
		Mai_memset(chn_info[a0]->acc_table_old, 0, sizeof(MaiAT3PlusCoreDecoderChnACCTable));
		chn_info[a0]->acc_table_old->inner = inner0;

		chn_info[a0]->acc_table_now = 
			(MaiAT3PlusCoreDecoderChnACCTable*)heap0.alloc(sizeof(MaiAT3PlusCoreDecoderChnACCTable));
		Mai_memset(chn_info[a0]->acc_table_now, 0, sizeof(MaiAT3PlusCoreDecoderChnACCTable));
		chn_info[a0]->acc_table_now->inner = inner1;

		chn_info[a0]->chn_ref = chn_info[0];
	}

	c900 = 3;
	
	for (Mai_I32 a0 = 0; a0 < 2; a0++)
	{
		for (Mai_I32 a1 = 0; a1 < 0x1000; a1++)
		{
			syn_buf[a0][a1] = 0.0f;
		}
	}

	for (Mai_I32 a0 = 0; a0 < 2; a0++)
	{
		for (Mai_I32 a1 = 0; a1 < 0x800; a1++)
		{
			kyou_buf[a0][a1] = 0.0f;
		}
	}
}
示例#2
0
MaiWaveOutWO::MaiWaveOutWO(Mai_U32 num_chn, Mai_U32 sam_rate, Mai_U32 bits_per_sam)
{
	is_stop = 0;
	
	//create sbuf
	sbuf_num = 0x80;
	sbuf_size = 0x2000;
	sbuf = heap0.alloc(sbuf_num * sbuf_size);
	sbuf_counter = 0;
	ppWaveHeader = (WAVEHDR *)heap0.alloc(sbuf_num * sizeof(WAVEHDR));

	WAVEFORMATEX wfx;
	Mai_memset(&wfx, 0, sizeof(wfx));

	wfx.wFormatTag = WAVE_FORMAT_PCM;
	wfx.nChannels = num_chn;
	wfx.nSamplesPerSec = sam_rate;
	wfx.wBitsPerSample = bits_per_sam;
	wfx.cbSize = 0;
	wfx.nBlockAlign = wfx.wBitsPerSample * wfx.nChannels / 8;  
	wfx.nAvgBytesPerSec = wfx.nChannels * wfx.nSamplesPerSec * wfx.wBitsPerSample / 8;

	::waveOutOpen(&p0, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL);

	for (Mai_U32 a0 = 0; a0 < sbuf_num; a0++)
	{
		memset(&ppWaveHeader[a0], 0, sizeof(WAVEHDR));
		ppWaveHeader[a0].dwLoops = 1;
		ppWaveHeader[a0].dwBufferLength = sbuf_size;
		ppWaveHeader[a0].lpData = (LPSTR)(sbuf + sbuf_size * a0);
		ppWaveHeader[a0].dwFlags = WHDR_DONE;
	}
}
Mai_Status MaiAT3PlusCoreDecoder::decodeACC2Main(MaiBitReader *mbr0, MaiAT3PlusCoreDecoderChnInfo **chn_infos, Mai_U32 chns)
{
	Mai_Status rs = 0;

	for (Mai_U32 a0 = 0; a0 < chns; a0++)
	{
		Mai_memset(chn_infos[a0]->acc_data_now->table,
			0,
			sizeof(chn_infos[a0]->acc_data_now->table)
			);

		Mai_U32 uk1b444 = mbr0->getWithI32Buffer(1);

		if (uk1b444)
		{
			chn_infos[a0]->uk1b450 = mbr0->getWithI32Buffer(4) + 1;
			Mai_U32 uk1b448 = mbr0->getWithI32Buffer(1);

			Mai_U32 uk1b44c = chn_infos[a0]->uk1b450;
			if (uk1b448) uk1b44c = mbr0->getWithI32Buffer(4) + 1;

			//call 478200
			if (rs = MAPCDSF_decodeACC2MainSub0(mbr0, chn_infos[a0]))
				break;

			//call 478270
			if (rs = MAPCDSF_decodeACC2MainSub1(mbr0, chn_infos[a0]))
				break;

			//call 478330
			if (rs = MAPCDSF_decodeACC2MainSub2(mbr0, chn_infos[a0]))
				break;

			if (uk1b448)
			{
				for (Mai_U32 b0 = chn_infos[a0]->uk1b450; b0 < uk1b44c; b0++)
				{
					chn_infos[a0]->acc_data_now->table[b0].num_acc = 
						chn_infos[a0]->acc_data_now->table[b0 - 1].num_acc;
					for (Mai_U32 b1 = 0; b1 < (Mai_U32)chn_infos[a0]->acc_data_now->table[b0].num_acc; b1++)
					{
						chn_infos[a0]->acc_data_now->table[b0].data1[b1] = 
							chn_infos[a0]->acc_data_now->table[b0 - 1].data1[b1];
						chn_infos[a0]->acc_data_now->table[b0].data0[b1] = 
							chn_infos[a0]->acc_data_now->table[b0 - 1].data0[b1];
					}
				}
			}
		}
		else
		{
			Mai_U32 uk1b44c = 0;
		}

	}

	return rs;
}
Mai_Status MaiAT3PlusCoreDecoder::decodeACC6Inner(MaiBitReader *mbr0, MaiAT3PlusCoreDecoderChnInfo **chn_infos, Mai_U32 chns)
{
	Mai_Status rs = 0;

	if (chns == 2)
	{
		Mai_memset(&chn_infos[0]->acc_table_now->inner->table_unk0, 0, sizeof(MaiAT3PlusCoreDecoderPackTable0));
		Mai_memset(&chn_infos[0]->acc_table_now->inner->table_unk1, 0, sizeof(MaiAT3PlusCoreDecoderPackTable0));
		Mai_memset(&chn_infos[0]->acc_table_now->inner->table_unk2, 0, sizeof(MaiAT3PlusCoreDecoderPackTable0));
	}

	for (Mai_U32 a0 = 0; a0 < chns; a0++)
	{
		Mai_memset(chn_infos[a0]->acc_table_now->table, 0, sizeof(chn_infos[a0]->acc_table_now->table));
		for (Mai_U32 a1 = 0; a1 < 0x10; a1++)
		{
			chn_infos[a0]->acc_table_now->table[a1].unk[7] = 0x20;
			chn_infos[a0]->acc_table_now->table[a1].unk[6] = 0;
		}
	}

	chn_infos[0]->acc_table_now->inner->ptr_to_use_now = 
			chn_infos[0]->acc_table_now->inner->data;

	chn_infos[0]->acc_table_now->inner->unk0 = 
		mbr0->getWithI32Buffer(1);

	if (chn_infos[0]->acc_table_now->inner->unk0)
	{
		chn_infos[0]->acc_table_now->inner->unk1 = 
			mbr0->getWithI32Buffer(1);

		chn_infos[0]->acc_table_now->inner->unk2 = 
			MAPCDSF_getHuffValue(&MAPCDSD_huff_table_global_11[0], mbr0)
			+ 1;

		if (chns == 2)
		{
			MAPCDSF_readPackTable0(mbr0, &chn_infos[0]->acc_table_now->inner->table_unk0, chn_infos[0]->acc_table_now->inner->unk2);
			MAPCDSF_readPackTable0(mbr0, &chn_infos[0]->acc_table_now->inner->table_unk2, chn_infos[0]->acc_table_now->inner->unk2);
			MAPCDSF_readPackTable0(mbr0, &chn_infos[0]->acc_table_now->inner->table_unk1, chn_infos[0]->acc_table_now->inner->unk2);
		}

		for (Mai_U32 a0 = 0; a0 < chns; a0++)
		{
			//call 477e60
			if (rs = MAPCDSF_decodeACC6InnerSub0(mbr0, chn_infos[a0]))
				break;
		}

		if (chns == 2)
		{
			for (Mai_I32 a0 = 0; a0 < chn_infos[0]->acc_table_now->inner->unk2; a0++)
			{
				if (chn_infos[0]->acc_table_now->inner->table_unk0.data[a0])
				{
					/*for (Mai_I32 a1 = 0; a1 < 0xA; a1++)
					{
						chn_infos[1]->acc_table_now->table[a0].unk[a1] = 
							chn_infos[0]->acc_table_now->table[a0].unk[a1];
						//memcpy?
					}*/
					Mai_memcpy(
						&chn_infos[1]->acc_table_now->table[a0],
						&chn_infos[0]->acc_table_now->table[a0],
						sizeof(MaiAT3PlusCoreDecoderChnACCTableTable));

					//left to right acc5 copy 0x10 + 0x28 * a0 0x4 add zumi
					//left to right acc5 copy 0x14 + 0x28 * a0 0x4 add zumi
					//left to right acc5 copy 0x18 + 0x28 * a0 0x4 add zumi
					//left to right acc5 copy 0x1C + 0x28 * a0 0x4 add zumi
				}
					
				if (chn_infos[0]->acc_table_now->inner->table_unk2.data[a0])
				{
					//swap?
					MaiAT3PlusCoreDecoderChnACCTableTable tmpbuf0;

					Mai_memcpy(
						&tmpbuf0,
						&chn_infos[1]->acc_table_now->table[a0],
						sizeof(MaiAT3PlusCoreDecoderChnACCTableTable));

					Mai_memcpy(
						&chn_infos[1]->acc_table_now->table[a0],
						&chn_infos[0]->acc_table_now->table[a0],
						sizeof(MaiAT3PlusCoreDecoderChnACCTableTable));

					Mai_memcpy(
						&chn_infos[0]->acc_table_now->table[a0],
						&tmpbuf0,
						sizeof(MaiAT3PlusCoreDecoderChnACCTableTable));
					/*
					Mai_I32 tmpbuf0[0xA];
					for (Mai_I32 a1 = 0; a1 < 0xA; a1++)
					{
						tmpbuf0[a1] = *(Mai_I32*)&infos.acc_struct_6_1.table0[a0 * 0x28 + a1 * 0x4];
					}
					for (Mai_I32 a1 = 0; a1 < 0xA; a1++)
					{
						*(Mai_I32*)&infos.acc_struct_6_1.table0[a0 * 0x28 + a1 * 0x4] = 
							*(Mai_I32*)&infos.acc_struct_6_0.table0[a0 * 0x28 + a1 * 0x4];
					}
					for (Mai_I32 a1 = 0; a1 < 0xA; a1++)
					{
						*(Mai_I32*)&infos.acc_struct_6_0.table0[a0 * 0x28 + a1 * 0x4] = 
							tmpbuf0[a1];
					}*/
				}
			}
		}


	}

	return rs;
}