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

Function YM3812UpdateOne

src/Engine/Adlib/fmopl.cpp:1040–1097  ·  view source on GitHub ↗

---------- update one of chip ----------- */

Source from the content-addressed store, hash-verified

1038
1039/* ---------- update one of chip ----------- */
1040void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length, int stripe, float volume)
1041{
1042 int i;
1043 int data;
1044 OPLSAMPLE *buf = buffer;
1045 UINT32 amsCnt = OPL->amsCnt;
1046 UINT32 vibCnt = OPL->vibCnt;
1047 UINT8 rythm = OPL->rythm&0x20;
1048 OPL_CH *CH,*R_CH;
1049
1050 if( (void *)OPL != cur_chip ){
1051 cur_chip = (void *)OPL;
1052 /* channel pointers */
1053 S_CH = OPL->P_CH;
1054 E_CH = &S_CH[9];
1055 /* rythm slot */
1056 SLOT7_1 = &S_CH[7].SLOT[SLOT1];
1057 SLOT7_2 = &S_CH[7].SLOT[SLOT2];
1058 SLOT8_1 = &S_CH[8].SLOT[SLOT1];
1059 SLOT8_2 = &S_CH[8].SLOT[SLOT2];
1060 /* LFO state */
1061 amsIncr = OPL->amsIncr;
1062 vibIncr = OPL->vibIncr;
1063 ams_table = OPL->ams_table;
1064 vib_table = OPL->vib_table;
1065 }
1066 R_CH = rythm ? &S_CH[6] : E_CH;
1067 for( i=0; i < length ; i+=stripe )
1068 {
1069 /* channel A channel B channel C */
1070 /* LFO */
1071 ams = ams_table[(amsCnt+=amsIncr)>>AMS_SHIFT];
1072 vib = vib_table[(vibCnt+=vibIncr)>>VIB_SHIFT];
1073 outd[0] = 0;
1074 /* FM part */
1075 for(CH=S_CH ; CH < R_CH ; CH++)
1076 OPL_CALC_CH(CH);
1077 /* Rythm part */
1078 if(rythm)
1079 OPL_CALC_RH(S_CH);
1080 outd[0] *= volume;
1081 /* limit check */
1082 data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT );
1083 /* store to sound buffer */
1084 buf[i] = data >> OPL_OUTSB;
1085 }
1086
1087 OPL->amsCnt = amsCnt;
1088 OPL->vibCnt = vibCnt;
1089#ifdef OPL_OUTPUT_LOG
1090 if(opl_dbg_fp)
1091 {
1092 for(opl_dbg_chip=0;opl_dbg_chip<opl_dbg_maxchip;opl_dbg_chip++)
1093 if( opl_dbg_opl[opl_dbg_chip] == OPL) break;
1094 fprintf(opl_dbg_fp,"%c%c%c",0x20+opl_dbg_chip,length&0xff,length/256);
1095 }
1096#endif
1097}

Callers 1

playerMethod · 0.85

Calls 3

OPL_CALC_CHFunction · 0.85
OPL_CALC_RHFunction · 0.85
LimitFunction · 0.85

Tested by

no test coverage detected