diff --git a/src/burn/drivers/capcom/cps.cpp b/src/burn/drivers/capcom/cps.cpp index cc586546e..4f33fbe67 100644 --- a/src/burn/drivers/capcom/cps.cpp +++ b/src/burn/drivers/capcom/cps.cpp @@ -61,16 +61,13 @@ static INT32 LoadUp(UINT8** pRom, INT32* pnRomLen, INT32 nNum) } // Load the rom - Rom = (UINT8*)malloc(ri.nLen); + Rom = (UINT8*)BurnMalloc(ri.nLen); if (Rom == NULL) { return 1; } if (BurnLoadRom(Rom,nNum,1)) { - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 1; } @@ -95,17 +92,14 @@ static INT32 LoadUpSplit(UINT8** pRom, INT32* pnRomLen, INT32 nNum) nTotalRomSize = nRomSize[0] + nRomSize[1] + nRomSize[2] + nRomSize[3]; if (!nTotalRomSize) return 1; - Rom = (UINT8*)malloc(nTotalRomSize); + Rom = (UINT8*)BurnMalloc(nTotalRomSize); if (Rom == NULL) return 1; INT32 Offset = 0; for (i = 0; i < 4; i++) { if (i > 0) Offset += nRomSize[i - 1]; if (BurnLoadRom(Rom + Offset, nNum + i, 1)) { - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 1; } } @@ -147,10 +141,7 @@ static INT32 CpsLoadOne(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShift) *((UINT32 *)pt) |= Pix; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -179,10 +170,7 @@ static INT32 CpsLoadOnePang(UINT8 *Tile,INT32 nNum,INT32 nWord,INT32 nShift) *((UINT32 *)pt) |= Pix; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -226,14 +214,8 @@ static INT32 CpsLoadOneHack160(UINT8 *Tile, INT32 nNum, INT32 nWord, INT32 nOffs *((UINT32 *)pt) |= Pix; } - if (Rom2) { - free(Rom2); - Rom2 = NULL; - } - if (Rom1) { - free(Rom1); - Rom1 = NULL; - } + BurnFree(Rom2); + BurnFree(Rom1); return 0; } @@ -273,10 +255,7 @@ static INT32 CpsLoadOneBootleg(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShif *((UINT32 *)pt) |= Pix; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -340,10 +319,7 @@ static INT32 CpsLoadOneBootlegType2(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 *((UINT32 *)pt) |= Pix; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -383,10 +359,7 @@ static INT32 CpsLoadOneSf2ebbl(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShif *((UINT32 *)pt) |= Pix; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -530,14 +503,8 @@ INT32 CpsLoadStars(UINT8* pStar, INT32 nStart) for (INT32 i = 0; i < 2; i++) { if (LoadUp(&pTemp[i], &nLen, nStart + (i << 1))) { - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); } } @@ -546,14 +513,8 @@ INT32 CpsLoadStars(UINT8* pStar, INT32 nStart) pStar[0x01000 + i] = pTemp[1][i << 1]; } - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); return 0; } @@ -565,14 +526,8 @@ INT32 CpsLoadStarsByte(UINT8* pStar, INT32 nStart) for (INT32 i = 0; i < 2; i++) { if (LoadUp(&pTemp[i], &nLen, nStart + (i * 4))) { - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); } } @@ -581,14 +536,8 @@ INT32 CpsLoadStarsByte(UINT8* pStar, INT32 nStart) pStar[0x01000 + i] = pTemp[1][i]; } - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); return 0; } @@ -600,14 +549,8 @@ INT32 CpsLoadStarsForgottnAlt(UINT8* pStar, INT32 nStart) for (INT32 i = 0; i < 2; i++) { if (LoadUp(&pTemp[i], &nLen, nStart + (i * 3))) { - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); } } @@ -616,14 +559,8 @@ INT32 CpsLoadStarsForgottnAlt(UINT8* pStar, INT32 nStart) pStar[0x01000 + i] = pTemp[1][i << 1]; } - if (pTemp[0]) { - free(pTemp[0]); - pTemp[0] = NULL; - } - if (pTemp[1]) { - free(pTemp[1]); - pTemp[1] = NULL; - } + BurnFree(pTemp[0]); + BurnFree(pTemp[1]); return 0; } @@ -676,16 +613,10 @@ static INT32 Cps2LoadOne(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShift) } nRomLen <<= 1; - Rom = (UINT8*)malloc(nRomLen); + Rom = (UINT8*)BurnMalloc(nRomLen); if (Rom == NULL) { - if (Rom2) { - free(Rom2); - Rom2 = NULL; - } - if (Rom3) { - free(Rom3); - Rom3 = NULL; - } + BurnFree(Rom2); + BurnFree(Rom3); return 1; } @@ -694,14 +625,8 @@ static INT32 Cps2LoadOne(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShift) Rom[(i << 1) + 1] = Rom2[i]; } - if (Rom2) { - free(Rom2); - Rom2 = NULL; - } - if (Rom3) { - free(Rom3); - Rom3 = NULL; - } + BurnFree(Rom2); + BurnFree(Rom3); } // Go through each section @@ -712,10 +637,7 @@ static INT32 Cps2LoadOne(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShift) pr += 0x80000; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -738,10 +660,7 @@ static INT32 Cps2LoadSplit(UINT8* Tile, INT32 nNum, INT32 nShift) pr += 0x80000; } - if (Rom) { - free(Rom); - Rom = NULL; - } + BurnFree(Rom); return 0; } @@ -994,7 +913,7 @@ INT32 CpsInit() } // Allocate Gfx, Rom and Z80 Roms - CpsGfx = (UINT8*)malloc(nMemLen); + CpsGfx = (UINT8*)BurnMalloc(nMemLen); if (CpsGfx == NULL) { return 1; } @@ -1078,14 +997,13 @@ INT32 CpsExit() Scroll3TileMask = 0; nCpsCodeLen = nCpsRomLen = nCpsGfxLen = nCpsZRomLen = nCpsQSamLen = nCpsAdLen = 0; - CpsCode = CpsRom = CpsZRom = CpsAd = CpsStar = NULL; + CpsRom = CpsZRom = CpsAd = CpsStar = NULL; CpsQSam = NULL; // All Memory is allocated to this (this is the only one we can free) - if (CpsGfx) { - free(CpsGfx); - CpsGfx = NULL; - } + BurnFree(CpsGfx); + + BurnFree(CpsCode); nCPS68KClockspeed = 0; Cps = 0; diff --git a/src/burn/drivers/capcom/cps2_crpt.cpp b/src/burn/drivers/capcom/cps2_crpt.cpp index 8741ef192..08b22c486 100644 --- a/src/burn/drivers/capcom/cps2_crpt.cpp +++ b/src/burn/drivers/capcom/cps2_crpt.cpp @@ -650,7 +650,7 @@ static void cps2_decrypt(const UINT32 *master_key, UINT32 upper_limit) #if 1 UINT16 *rom = (UINT16 *)CpsRom; UINT32 length = upper_limit; - CpsCode = (UINT8*)malloc(length); + CpsCode = (UINT8*)BurnMalloc(length); UINT16 *dec = (UINT16*)CpsCode; UINT32 i; #endif diff --git a/src/burn/drivers/capcom/cps_mem.cpp b/src/burn/drivers/capcom/cps_mem.cpp index 079163808..a25c4d1e5 100644 --- a/src/burn/drivers/capcom/cps_mem.cpp +++ b/src/burn/drivers/capcom/cps_mem.cpp @@ -68,7 +68,7 @@ static INT32 AllocateMemory() CpsMemIndex(); nLen = CpsMemEnd - (UINT8*)0; - if ((CpsMem = (UINT8*)malloc(nLen)) == NULL) { + if ((CpsMem = (UINT8*)BurnMalloc(nLen)) == NULL) { return 1; } @@ -333,10 +333,7 @@ INT32 CpsMemExit() #endif // Deallocate all used memory - if (CpsMem) { - free(CpsMem); - CpsMem = NULL; - } + BurnFree(CpsMem); return 0; } diff --git a/src/burn/drivers/capcom/cps_obj.cpp b/src/burn/drivers/capcom/cps_obj.cpp index bc2d7b902..dae9a3d5e 100644 --- a/src/burn/drivers/capcom/cps_obj.cpp +++ b/src/burn/drivers/capcom/cps_obj.cpp @@ -39,7 +39,7 @@ INT32 CpsObjInit() nFrameCount = 2; // CPS2 sprites lagged by 1 frame and double buffered // CPS1 sprites lagged by 1 frame - ObjMem = (UINT8*)malloc((nMax << 3) * nFrameCount); + ObjMem = (UINT8*)BurnMalloc((nMax << 3) * nFrameCount); if (ObjMem == NULL) { return 1; } @@ -68,10 +68,7 @@ INT32 CpsObjExit() of[i].nCount = 0; } - if (ObjMem) { - free(ObjMem); - ObjMem = NULL; - } + BurnFree(ObjMem); nFrameCount = 0; nMax = 0; diff --git a/src/burn/drivers/capcom/cps_pal.cpp b/src/burn/drivers/capcom/cps_pal.cpp index 3ec60d387..f1201c9ee 100644 --- a/src/burn/drivers/capcom/cps_pal.cpp +++ b/src/burn/drivers/capcom/cps_pal.cpp @@ -102,7 +102,7 @@ INT32 CpsPalInit() INT32 nLen = 0; nLen = 0x1000 * sizeof(UINT16); - CpsPalSrc = (UINT8*)malloc(nLen); + CpsPalSrc = (UINT8*)BurnMalloc(nLen); if (CpsPalSrc == NULL) { return 1; } @@ -110,7 +110,7 @@ INT32 CpsPalInit() // The star layer palettes are at the end of the normal palette, so double the size nLen = 0x1000 * sizeof(UINT32); - CpsPal = (UINT32*)malloc(nLen); + CpsPal = (UINT32*)BurnMalloc(nLen); if (CpsPal == NULL) { return 1; } @@ -133,14 +133,8 @@ INT32 CpsPalInit() INT32 CpsPalExit() { - if (CpsPal) { - free(CpsPal); - CpsPal = NULL; - } - if (CpsPalSrc) { - free(CpsPalSrc); - CpsPalSrc = NULL; - } + BurnFree(CpsPal); + BurnFree(CpsPalSrc); return 0; } diff --git a/src/burn/drivers/capcom/cps_run.cpp b/src/burn/drivers/capcom/cps_run.cpp index 6eb0933ba..2f07e22f7 100644 --- a/src/burn/drivers/capcom/cps_run.cpp +++ b/src/burn/drivers/capcom/cps_run.cpp @@ -40,7 +40,9 @@ static INT32 DrvReset() *((UINT16*)(CpsReg + 0x52)) = 0x0106; } + SekOpen(0); CpsMapObjectBanks(0); + SekClose(); nCpsCyclesExtra = 0; @@ -137,7 +139,7 @@ INT32 CpsRunExit() // Sound exit if (Cps == 2 || Cps1Qs == 1) QsndExit(); - if (Cps != 2 && Cps1Qs == 0) PsndExit(); + if (Cps != 2 && Cps1Qs == 0 && !Cps1Pic) PsndExit(); // Graphics exit CpsObjExit(); @@ -356,6 +358,7 @@ INT32 Cps2Frame() QsndNewFrame(); nCpsCycles = (INT32)(((INT64)nCPS68KClockspeed * nBurnCPUSpeedAdjust) / 0x0100); + SekOpen(0); SekSetCyclesScanline(nCpsCycles / 262); CpsRwGetInp(); // Update the input port values @@ -384,7 +387,6 @@ INT32 Cps2Frame() } ScheduleIRQ(); - SekOpen(0); SekIdle(nCpsCyclesExtra); if (nIrqCycles < nCpsCycles * nFirstLine / 0x0106) { diff --git a/src/burn/drivers/capcom/cps_rw.cpp b/src/burn/drivers/capcom/cps_rw.cpp index 7d440e7be..d95714fd3 100644 --- a/src/burn/drivers/capcom/cps_rw.cpp +++ b/src/burn/drivers/capcom/cps_rw.cpp @@ -188,7 +188,11 @@ static UINT8 CpsReadPort(const UINT32 ia) // CPS1 EEPROM read if (ia == 0xC007) { - return EEPROMRead(); + if (Cps1Qs) { + return EEPROMRead(); + } else { + return 0; + } } // Pang3 EEPROM diff --git a/src/burn/drivers/capcom/d_cps1.cpp b/src/burn/drivers/capcom/d_cps1.cpp index b24af3013..5973a5242 100644 --- a/src/burn/drivers/capcom/d_cps1.cpp +++ b/src/burn/drivers/capcom/d_cps1.cpp @@ -1450,7 +1450,7 @@ static struct BurnDIPInfo NTFODIPList[]= { // Defaults {0x12, 0xff, 0xff, 0x00, NULL }, - {0x13, 0xff, 0xff, 0x03, NULL }, + {0x13, 0xff, 0xff, 0x00, NULL }, {0x14, 0xff, 0xff, 0x60, NULL }, // Dip A @@ -10285,6 +10285,7 @@ static INT32 CaptcommbInit() CpsLayer1XOffs = -8; CpsLayer2XOffs = -11; CpsLayer3XOffs = -12; + CpsDrawSpritesInReverse = 1; nRet = DrvInit(); @@ -10411,7 +10412,7 @@ static INT32 DinopicInit() CpsLoadTilesBootleg(CpsGfx + 0x000000, 4); CpsLoadTilesBootleg(CpsGfx + 0x200000, 8); - BootlegSpriteRam = (UINT8*)malloc(0x2000); + BootlegSpriteRam = (UINT8*)BurnMalloc(0x2000); SekOpen(0); SekMapMemory(BootlegSpriteRam, 0x990000, 0x991FFF, SM_RAM); @@ -10438,7 +10439,7 @@ static INT32 DinohInit() static void DinohaCallback() { - UINT8 *TempRom = (UINT8*)malloc(0x200000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x200000); if (TempRom) { memcpy(TempRom, CpsRom, 0x200000); memset(CpsRom, 0, 0x200000); @@ -10446,8 +10447,7 @@ static void DinohaCallback() memcpy(CpsRom + 0x000000, TempRom + 0x080000, 0x80000); memcpy(CpsRom + 0x180000, TempRom + 0x100000, 0x80000); memcpy(CpsRom + 0x100000, TempRom + 0x180000, 0x80000); - free(TempRom); - TempRom = NULL; + BurnFree(TempRom); } // Patch Q-Sound Test ??? @@ -10482,7 +10482,7 @@ static INT32 DinohbInit() memset(CpsGfx, 0, nCpsGfxLen); CpsLoadTilesHack160(CpsGfx, 2); - BootlegSpriteRam = (UINT8*)malloc(0x2000); + BootlegSpriteRam = (UINT8*)BurnMalloc(0x2000); SekOpen(0); SekMapMemory(BootlegSpriteRam, 0x990000, 0x991FFF, SM_RAM); @@ -10720,7 +10720,7 @@ static INT32 Sf2jcInit() static void Sf2qp1Callback() { - UINT8 *TempRom = (UINT8*)malloc(0x100000); + UINT8 *TempRom = (UINT8*)BurnMalloc(0x100000); if (TempRom) { memcpy(TempRom, CpsRom, 0x100000); memset(CpsRom, 0, 0x100000); @@ -10728,8 +10728,7 @@ static void Sf2qp1Callback() memcpy(CpsRom + 0x0c0000, TempRom + 0x040000, 0x40000); memcpy(CpsRom + 0x080000, TempRom + 0x080000, 0x40000); memcpy(CpsRom + 0x040000, TempRom + 0x0c0000, 0x40000); - free(TempRom); - TempRom = NULL; + BurnFree(TempRom); } } @@ -11425,10 +11424,7 @@ static INT32 DrvExit() Cps1CallbackFunction = NULL; - if (BootlegSpriteRam) { - free(BootlegSpriteRam); - BootlegSpriteRam = NULL; - } + BurnFree(BootlegSpriteRam); return 0; } diff --git a/src/burn/drivers/capcom/ps_m.cpp b/src/burn/drivers/capcom/ps_m.cpp index 7dd7baf9f..9866f706a 100644 --- a/src/burn/drivers/capcom/ps_m.cpp +++ b/src/burn/drivers/capcom/ps_m.cpp @@ -25,7 +25,7 @@ INT32 PsmInit() // Allocate a buffer for the intermediate sound (between YM2151 and pBurnSoundOut) nMemLen = nBurnSoundLen * 2 * sizeof(INT16); - WaveBuf = (INT16*)malloc(nMemLen); + WaveBuf = (INT16*)BurnMalloc(nMemLen); if (WaveBuf == NULL) { PsmExit(); return 1; @@ -55,10 +55,7 @@ INT32 PsmExit() MSM6295Exit(0); - if (WaveBuf) { - free(WaveBuf); - WaveBuf = NULL; - } + BurnFree(WaveBuf); BurnYM2151Exit(); // Exit FM sound chip return 0; diff --git a/src/burn/drivers/capcom/ps_z.cpp b/src/burn/drivers/capcom/ps_z.cpp index 8e69a046e..38f51eb2c 100644 --- a/src/burn/drivers/capcom/ps_z.cpp +++ b/src/burn/drivers/capcom/ps_z.cpp @@ -134,7 +134,7 @@ INT32 PsndZInit() return 1; } - PsndZRam = (UINT8 *)malloc(0x800); + PsndZRam = (UINT8 *)BurnMalloc(0x800); if (PsndZRam == NULL) { return 1; } @@ -178,10 +178,7 @@ INT32 PsndZInit() INT32 PsndZExit() { - if (PsndZRam) { - free(PsndZRam); - PsndZRam = NULL; - } + BurnFree(PsndZRam); ZetExit(); return 0; diff --git a/src/burn/drivers/capcom/qs.cpp b/src/burn/drivers/capcom/qs.cpp index 87df99eb1..2b39c7761 100644 --- a/src/burn/drivers/capcom/qs.cpp +++ b/src/burn/drivers/capcom/qs.cpp @@ -39,28 +39,40 @@ INT32 QsndInit() nVolumeShift = 0; // These games are too soft at normal volumes - if (strncmp(BurnDrvGetTextA(DRV_NAME), "csclub", 6) == 0) { + if (strncmp(BurnDrvGetTextA(DRV_NAME), "csclub", 6) == 0) { nVolumeShift = -1; } -#if 0 + // These games are loud at normal volumes (no clipping) - if (strncmp(BurnDrvGetTextA(DRV_NAME), "1944", 4) == 0 || - strcmp( BurnDrvGetTextA(DRV_NAME), "dimahoo" ) == 0 || - strcmp( BurnDrvGetTextA(DRV_NAME), "gmahoo" ) == 0) + if (strncmp(BurnDrvGetTextA(DRV_NAME), "1944", 4) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "dimaho", 6) == 0 || + strcmp( BurnDrvGetTextA(DRV_NAME), "gmahou" ) == 0) { nVolumeShift = 1; } -#endif + // These games are too loud at normal volumes (no clipping) - if (strncmp(BurnDrvGetTextA(DRV_NAME), "sgemf", 5) == 0 || - strncmp(BurnDrvGetTextA(DRV_NAME), "pfght", 5) == 0 || - strncmp(BurnDrvGetTextA(DRV_NAME), "mpang", 5) == 0 || - strncmp(BurnDrvGetTextA(DRV_NAME), "spf2", 4) == 0 || - strncmp(BurnDrvGetTextA(DRV_NAME), "sfa2", 4) == 0 || - strncmp(BurnDrvGetTextA(DRV_NAME), "sfa2", 4) == 0) + if (strncmp(BurnDrvGetTextA(DRV_NAME), "sgemf", 5) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "progear", 7) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "pzloop2", 7) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "ringdest", 8) == 0 || + strcmp( BurnDrvGetTextA(DRV_NAME), "ringdstd" ) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "smbomb", 6) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "pfght", 5) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "mpang", 5) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "sfa2", 4) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "sfz2", 4) == 0) { nVolumeShift = 1; } + + // These games are too loud at normal volumes (no clipping) + if (strncmp(BurnDrvGetTextA(DRV_NAME), "gigawing", 8) == 0 || + strncmp(BurnDrvGetTextA(DRV_NAME), "spf2", 4) == 0) + { + nVolumeShift = 2; + } + // These games are too loud at normal volumes (clipping) if (strncmp(BurnDrvGetTextA(DRV_NAME), "19xx", 4) == 0 || strncmp(BurnDrvGetTextA(DRV_NAME), "ddtod", 5) == 0) @@ -75,8 +87,10 @@ INT32 QsndInit() void QsndReset() { + ZetOpen(0); BurnTimerReset(); BurnTimerSetRetrig(0, 1.0 / 252.0); + ZetClose(); nQsndCyclesExtra = 0; } diff --git a/src/burn/drivers/capcom/qs_c.cpp b/src/burn/drivers/capcom/qs_c.cpp index ac7d149e4..2c2dcfbb9 100644 --- a/src/burn/drivers/capcom/qs_c.cpp +++ b/src/burn/drivers/capcom/qs_c.cpp @@ -100,10 +100,7 @@ void QscExit() { nQscRate = 0; - if (Qs_s) { - free(Qs_s); - Qs_s = NULL; - } + BurnFree(Qs_s); Tams = -1; } @@ -264,12 +261,9 @@ INT32 QscUpdate(INT32 nEnd) } if (Tams < nLen) { - if (Qs_s) { - free(Qs_s); - Qs_s = NULL; - } + BurnFree(Qs_s); Tams = nLen; - Qs_s = (INT32*)malloc(sizeof(INT32) * 2 * Tams); + Qs_s = (INT32*)BurnMalloc(sizeof(INT32) * 2 * Tams); } memset(Qs_s, 0, nLen * 2 * sizeof(INT32));