📄 ymclass.cpp
字号:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File name: ymclass.cpp
// This file define the functions of base module YM
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "ymclass.h"
/////////////////////////////////////////////////////////////////////
void CYm::yminit()
{
for(int i=0;i<128;i++)board_ym[i]=0;
ym_begin=YM_NONE_SAMPLE;
}//void CYm::yminit()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CYm::selection()
{
if((select_byte1[0]==select_byte1[1])||(select_byte1[0]==select_byte1[2]))
{
selected_byte1=select_byte1[0];
return(1);
}//if(select_byte1[0]==select_byte1[1])
else if(select_byte1[1]==select_byte1[2])
{
selected_byte1=select_byte1[1];
return(1);
}//if(select_byte1[1]==select_byte1[2])
else return(0);
}//int CYm::selection()
int CYm::Get8Ym(int address,int orderno)
{
int code_conv[4]={YM14,YM24,YM34,YM44};
outportb(hardwareset[C3724].address+1,address+code_conv[orderno]);
for(int i=0;i<WAIT2US;i++);
return(inportb(hardwareset[C3724].address)&0xff);
}//int CYm::Get8Ym(int address,int orderno)
void CYm::boradymget()
{
int i;
int ym_board_add[16]={YMB0,YMB1,YMB2,YMB3,YMB4,YMB5,YMB6,YMB7};
int ym_board_no; //cycle varible for board and group
unsigned int temp1,temp2;
unsigned int temp3,temp4;
unsigned int read_data;
temp1=datasource.board_ym;
temp2=temp1/32;
if(temp1>(temp2*32))temp2++;
if(temp2>4)return;
for(i=0;i<8;i++)ym_old_bit_value[i]=ym_new_bit_value[i];
for(ym_board_no=0;ym_board_no<temp2;ym_board_no++)
{
for(temp3=0;temp3<2;temp3++)
{
for(i=0;i<3;i++)
{
read_data=Get8Ym(ym_board_add[ym_board_no],temp3*2+1);
read_data=~read_data;
read_data&=0xff;
select_byte1[i]=read_data;
}//for(i=0;i<3;i++)
if(selection())
{
temp4=selected_byte1&0xff;
temp4<<=0x08;
}//if(selection())
else temp4=ym_new_bit_value[ym_board_no*2+temp3]&0xff00;
for(i=0;i<3;i++)
{
read_data=Get8Ym(ym_board_add[ym_board_no],temp3*2);
read_data=~read_data;
read_data&=0xff;
select_byte1[i]=read_data;
}//for(i=0;i<3;i++)
if(selection())temp4+=selected_byte1&0xff;
else temp4+=ym_new_bit_value[ym_board_no*2+temp3]&0xff;
ym_new_bit_value[ym_board_no*2+temp3]=temp4;
}//for(temp3=0;temp3<2;temp3++)
}//for(ym_board_no=0;ym_board_no<temp2;ym_board_no++)
if(ym_begin==YM_NONE_SAMPLE)ym_begin=YM_FIRST_SAMPLE;
else if(ym_begin==YM_FIRST_SAMPLE)ym_begin=YM_SECOND_SAMPLE;
}//void CYm::boradymget()
void CYm::boardymdeal()
{
int i,j;
unsigned int test=0x01;
unsigned int test1;
unsigned int temp1,temp2;
unsigned int new_bit_ym,old_bit_ym;
boradymget();
temp1=datasource.board_ym;
temp2=temp1/16;
if(temp1>(temp2*16))temp2++;
if(temp2>8)return;
for(i=0;i<temp2;i++)
{
new_bit_ym=ym_new_bit_value[i];
old_bit_ym=ym_old_bit_value[i];
for(j=0;j<16;j++)
{
test1=test;
test1<<=j;
if(!(ym_info.ym_set_bit[i]&test1))
{
if(new_bit_ym&test1)
{
if(ym_begin==YM_SECOND_SAMPLE)
{
if(!(old_bit_ym&test1))
{
if(board_ym[j+i*16]>=0xffffffff)board_ym[j+i*16]=0;
else board_ym[j+i*16]++;
}//if(!(old_bit_ym&test1))
}//if(ym_begin==YM_SECOND_SAMPLE)
else
if(ym_begin==YM_FIRST_SAMPLE)
{
if(board_ym[j+i*16]>=0xffffffff)board_ym[j+i*16]=0;
else board_ym[j+i*16]++;
}//if(ym_begin==YM_FIRST_SAMPLE)
}//if(new_bit_ym&test1)
}//if(!(ym_info.ym_set_bit[i]&test1))
}//for(j=0;j<16;j++)
}//for(i=0;i<temp2;i++)
}//void CYm::boardymdeal()
void CYm::ymdeal()
{
int i,j;
unsigned int test=0x01;
unsigned int test1;
unsigned int temp1,temp2;
unsigned long temp_ym[128]; //for save board ym
if(datasource.total_ym>128)return;
// boardymdeal();
for(i=0;i<datasource.board_ym;i++)temp_ym[i]=board_ym[i];
for(i=0;i<datasource.port_ym;i++)temp_ym[i+datasource.board_ym]=gport_ym[i];
for(i=0;i<(128-datasource.board_ym-datasource.port_ym);i++)
temp_ym[i+datasource.board_ym+datasource.port_ym]=0x00;
for(i=0;i<datasource.total_ym;i++)
{
test1=test;
temp1=i/16;
temp2=i-temp1*16;
test1<<=temp2;
if(!(ym_info.ym_set_bit[temp1]&test1))ym_info.ym_value[i]=temp_ym[i];
if((ym_sequence[0][0]==4096)&&(ym_sequence[1][0]==4096))
sport_ym[i]=ym_info.ym_value[i];
else
if((ym_sequence[i][0]!=2048)&&(ym_sequence[i][0]<=128))
sport_ym[ym_sequence[i][0]]=ym_info.ym_value[i];
}//for(i=0;i<datasource.total_ym;i++)
}//void CYm::ymdeal()
//////////////////////////////////////////////////////////////////////////////////////
//The end of ymclass.cpp
//////////////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -