@@ -937,15 +937,15 @@ int SNDAEMSI_updateplayer(AemsDef::PLAYERSTATE *pplayerstate) {
937937 pplayerstate -> settings .prevplaycontrol [0 ] = outputplaystate ;
938938 }
939939 if (outputplaystate == 1 && pplayerstate -> settings .sampletype < 0 ) {
940+ outputplaystate = 0 ;
941+ } else {
942+ if (outputplaystate == 1 ) {
943+ outputplaystate = SNDAEMSplayerupdatefn [pplayerstate -> settings .sampletype ](pplayerstate );
944+ }
945+ if (pplayerstate -> settings .sampletype & 0x80 ) {
940946 outputplaystate = 0 ;
941- } else {
942- if (outputplaystate == 1 ) {
943- outputplaystate = SNDAEMSplayerupdatefn [pplayerstate -> settings .sampletype ](pplayerstate );
944- }
945- if (pplayerstate -> settings .sampletype & 0x80 ) {
946- outputplaystate = 0 ;
947- }
948947 }
948+ }
949949
950950 return outputplaystate ;
951951}
@@ -1222,10 +1222,6 @@ void SNDAEMSI_restore() {
12221222 SNDSYS_leavecritical ();
12231223}
12241224
1225- #ifdef __cplusplus
1226- extern "C" {
1227- #endif
1228-
12291225int SNDAEMS_removemodulebank (int mbhandle ) {
12301226 if (sndaems .logremovemodulebank != NULL ) {
12311227 sndaems .logremovemodulebank ();
@@ -1289,10 +1285,6 @@ int SNDAEMS_removemodulebank(int mbhandle) {
12891285 return -8 ;
12901286}
12911287
1292- #ifdef __cplusplus
1293- }
1294- #endif
1295-
12961288int SNDAEMSI_stopmodulebanks () {
12971289 SNDSYS_entercritical ();
12981290
@@ -1369,19 +1361,28 @@ void SNDAEMSI_resolvemodulebank(
13691361 firstbank = sndaems .modulebank .IsEmpty ();
13701362 sndaems .modulebank .Push (& pModuleBank -> ln );
13711363
1372- intptr_t funcfixupdelta = reinterpret_cast < char * > (pfuncfixupheader ) - reinterpret_cast < char * > (pModuleBank );
1364+ int funcfixupdelta = reinterpret_cast < char * > (pfuncfixupheader ) - reinterpret_cast < char * > (pModuleBank );
13731365
1374- for (i = 0 ; i < pfuncfixupheader -> numfixups ; i ++ ) {
1375- unsigned short * addr_hi = reinterpret_cast < unsigned short * > (
1376- reinterpret_cast < char * > (pModuleBank ) + pfuncfixupheader -> fixup [i ]
1377- );
1378- unsigned short * addr_lo = addr_hi + 2 ;
1379- unsigned int comp_func = (* addr_hi << 16 ) | * addr_lo ;
1380- unsigned short * pfuncentry = reinterpret_cast < unsigned short * > (
1381- & sndaemsfuncs [comp_func ]
1382- );
1383- * addr_hi = pfuncentry [0 ];
1384- * addr_lo = pfuncentry [1 ];
1366+ i = 0 ;
1367+ if (i < pfuncfixupheader -> numfixups ) {
1368+ unsigned short * funcbase = reinterpret_cast < unsigned short * > (sndaemsfuncs );
1369+ do {
1370+ unsigned short * addr_hi = reinterpret_cast < unsigned short * > (
1371+ reinterpret_cast < char * > (pModuleBank ) + pfuncfixupheader -> fixup [i ]
1372+ );
1373+ unsigned short * addr_lo = addr_hi + 2 ;
1374+ unsigned int comp_func = (* addr_hi << 16 ) | * addr_lo ;
1375+ // TODO remove these variables
1376+ unsigned int func_offset = comp_func * sizeof (unsigned int );
1377+ unsigned short entry_hi = * reinterpret_cast < unsigned short * > (
1378+ reinterpret_cast < unsigned int > (funcbase ) + func_offset
1379+ );
1380+ func_offset += reinterpret_cast < unsigned int > (funcbase );
1381+ * addr_hi = entry_hi ;
1382+ unsigned short * pfuncentry = reinterpret_cast < unsigned short * > (func_offset );
1383+ * addr_lo = pfuncentry [1 ];
1384+ i ++ ;
1385+ } while (i < pfuncfixupheader -> numfixups );
13851386 }
13861387
13871388 pFakeModuleBankStart = reinterpret_cast < char * > (pModuleBank ) + funcfixupdelta - pModuleBank -> funcfixupoffset ;
0 commit comments