MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / Y8950UpdateOne

Function Y8950UpdateOne

src/Engine/Adlib/fmopl.cpp:1102–1159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1100#if BUILD_Y8950
1101
1102void Y8950UpdateOne(FM_OPL *OPL, INT16 *buffer, int length)
1103{
1104 int i;
1105 int data;
1106 OPLSAMPLE *buf = buffer;
1107 UINT32 amsCnt = OPL->amsCnt;
1108 UINT32 vibCnt = OPL->vibCnt;
1109 UINT8 rythm = OPL->rythm&0x20;
1110 OPL_CH *CH,*R_CH;
1111 YM_DELTAT *DELTAT = OPL->deltat;
1112
1113 /* setup DELTA-T unit */
1114 YM_DELTAT_DECODE_PRESET(DELTAT);
1115
1116 if( (void *)OPL != cur_chip ){
1117 cur_chip = (void *)OPL;
1118 /* channel pointers */
1119 S_CH = OPL->P_CH;
1120 E_CH = &S_CH[9];
1121 /* rythm slot */
1122 SLOT7_1 = &S_CH[7].SLOT[SLOT1];
1123 SLOT7_2 = &S_CH[7].SLOT[SLOT2];
1124 SLOT8_1 = &S_CH[8].SLOT[SLOT1];
1125 SLOT8_2 = &S_CH[8].SLOT[SLOT2];
1126 /* LFO state */
1127 amsIncr = OPL->amsIncr;
1128 vibIncr = OPL->vibIncr;
1129 ams_table = OPL->ams_table;
1130 vib_table = OPL->vib_table;
1131 }
1132 R_CH = rythm ? &S_CH[6] : E_CH;
1133 for( i=0; i < length ; i++ )
1134 {
1135 /* channel A channel B channel C */
1136 /* LFO */
1137 ams = ams_table[(amsCnt+=amsIncr)>>AMS_SHIFT];
1138 vib = vib_table[(vibCnt+=vibIncr)>>VIB_SHIFT];
1139 outd[0] = 0;
1140 /* deltaT ADPCM */
1141 if( DELTAT->portstate )
1142 YM_DELTAT_ADPCM_CALC(DELTAT);
1143 /* FM part */
1144 for(CH=S_CH ; CH < R_CH ; CH++)
1145 OPL_CALC_CH(CH);
1146 /* Rythm part */
1147 if(rythm)
1148 OPL_CALC_RH(S_CH);
1149 /* limit check */
1150 data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT );
1151 /* store to sound buffer */
1152 buf[i] = data >> OPL_OUTSB;
1153 }
1154 OPL->amsCnt = amsCnt;
1155 OPL->vibCnt = vibCnt;
1156 /* deltaT START flag */
1157 if( !DELTAT->portstate )
1158 OPL->status &= 0xfe;
1159}

Callers

nothing calls this directly

Calls 3

OPL_CALC_CHFunction · 0.85
OPL_CALC_RHFunction · 0.85
LimitFunction · 0.85

Tested by

no test coverage detected