88#include " JSystem/JAudio2/JASCalc.h"
99#include " JSystem/JAudio2/JASDrumSet.h"
1010#include " JSystem/JAudio2/JASHeapCtrl.h"
11+ #include " JSystem/JAudio2/JASChannel.h"
1112#include " JSystem/JKernel/JKRSolidHeap.h"
1213#include " JSystem/JSupport/JSupport.h"
1314
@@ -27,10 +28,11 @@ JASBasicBank* JASBNKParser::createBasicBank(void const* stream, JKRHeap* heap) {
2728 }
2829
2930 u32 free_size = heap->getFreeSize ();
31+
32+ TFileHeader* filep = (TFileHeader*)stream;
33+ JUT_ASSERT (59 , filep->id == ' IBNK' );
3034 JASBasicBank* bank = NULL ;
31-
32- TFileHeader* header = (TFileHeader*)stream;
33- switch (header->mVersion ) {
35+ switch (filep->mVersion ) {
3436 case 0 :
3537 bank = Ver0::createBasicBank (stream, heap);
3638 break ;
@@ -165,14 +167,12 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
165167
166168/* 80299A3C-80299E68 29437C 042C+00 1/1 0/0 0/0 .text
167169 * createBasicBank__Q212JASBNKParser4Ver0FPCvP7JKRHeap */
168- // NONMATCHING
169170JASBasicBank* JASBNKParser::Ver0::createBasicBank (void const * stream, JKRHeap* heap) {
170- THeader const * header = (THeader*)stream;
171-
172171 if (heap == NULL ) {
173172 heap = JASDram;
174173 }
175-
174+
175+ THeader const * header = (THeader*)stream;
176176 JASBasicBank* bank = new (heap, 0 ) JASBasicBank ();
177177 if (bank == NULL ) {
178178 return NULL ;
@@ -181,94 +181,101 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
181181 bank->newInstTable (0x80 , heap);
182182
183183 for (int i = 0 ; i < 0x80 ; i++) {
184- TInst* tinst = header->mOffsets .mInstOffset [i].ptr (stream );
184+ TInst* tinst = header->mOffsets .mInstOffset [i].ptr (header );
185185 if (tinst != NULL ) {
186- JASBasicInst* inst = new (heap, 0 ) JASBasicInst ();
187- inst->setVolume (tinst->mVolume );
188- inst->setPitch (tinst->mPitch );
186+ JASBasicInst* instp = new (heap, 0 ) JASBasicInst ();
187+ JUT_ASSERT (368 , instp != 0 );
188+ instp->setVolume (tinst->mVolume );
189+ instp->setPitch (tinst->mPitch );
189190
190191 int osc_idx = 0 ;
191192 for (int j = 0 ; j < 2 ; j++) {
192- TOsc* tosc = tinst->mOscOffset [j].ptr (stream );
193+ TOsc* tosc = tinst->mOscOffset [j].ptr (header );
193194 if (tosc != NULL ) {
194- JASOscillator::Data* osc_data = findOscPtr (bank, header, tosc);
195- if (osc_data != NULL ) {
196- inst ->setOsc (osc_idx, osc_data );
195+ JASOscillator::Data* osc = findOscPtr (bank, header, tosc);
196+ if (osc != NULL ) {
197+ instp ->setOsc (osc_idx, osc );
197198 } else {
198- osc_data = new (heap, 0 ) JASOscillator::Data ();
199- osc_data-> mTarget = tosc-> mTarget ;
200- osc_data-> _04 = tosc->field_0x4 ;
201- u32 size ;
199+ osc = new (heap, 0 ) JASOscillator::Data ();
200+ JUT_ASSERT ( 386 , osc != 0 ) ;
201+ osc-> mTarget = tosc->mTarget ;
202+ osc-> _04 = tosc-> field_0x4 ;
202203
203- JASOscillator::Point* points = tosc->mPointOffset .ptr (stream );
204+ JASOscillator::Point* points = tosc->mPointOffset .ptr (header );
204205 if (points != NULL ) {
205- size = getOscTableEndPtr (points) - points;
206+ const JASOscillator::Point* endPtr = getOscTableEndPtr (points);
207+ int size = endPtr - points;
206208 JASOscillator::Point* table = new (heap, 0 ) JASOscillator::Point[size];
209+ JUT_ASSERT (396 , table != 0 );
207210 JASCalc::bcopy (points, table, size * sizeof (JASOscillator::Point));
208- osc_data ->mTable = table;
211+ osc ->mTable = table;
209212 } else {
210- osc_data ->mTable = NULL ;
213+ osc ->mTable = NULL ;
211214 }
212215
213- points = tosc->field_0xc .ptr (stream );
216+ points = tosc->field_0xc .ptr (header );
214217 if (points != NULL ) {
215- size = getOscTableEndPtr (points) - points;
218+ const JASOscillator::Point* endPtr = getOscTableEndPtr (points);
219+ int size = endPtr - points;
216220 JASOscillator::Point* table = new (heap, 0 ) JASOscillator::Point[size];
221+ JUT_ASSERT (409 , table != 0 );
217222 JASCalc::bcopy (points, table, size * sizeof (JASOscillator::Point));
218- osc_data ->_0C = table;
223+ osc ->_0C = table;
219224 } else {
220- osc_data ->_0C = NULL ;
225+ osc ->_0C = NULL ;
221226 }
222227
223- osc_data ->mScale = tosc->mScale ;
224- osc_data ->_14 = tosc->field_0x14 ;
225- inst ->setOsc (osc_idx, osc_data );
228+ osc ->mScale = tosc->mScale ;
229+ osc ->_14 = tosc->field_0x14 ;
230+ instp ->setOsc (osc_idx, osc );
226231 }
227232
228233 osc_idx++;
229234 }
230235 }
231236
232- inst ->setKeyRegionCount (tinst->mKeyRegionCount , heap);
237+ instp ->setKeyRegionCount (tinst->mKeyRegionCount , heap);
233238 for (int j = 0 ; j < tinst->mKeyRegionCount ; j++) {
234- JASBasicInst::TKeymap* keymap = inst ->getKeyRegion (j);
235- TKeymap* tkeymap = tinst->mKeymapOffset [j].ptr (stream );
239+ JASBasicInst::TKeymap* keymap = instp ->getKeyRegion (j);
240+ TKeymap* tkeymap = tinst->mKeymapOffset [j].ptr (header );
236241 keymap->setHighKey (tkeymap->mHighKey );
237- TVmap* tvmap = tkeymap->mVmapOffset .ptr (stream );
242+ TVmap* tvmap = tkeymap->mVmapOffset .ptr (header );
238243 keymap->field_0x4 = JSULoHalf (tvmap->field_0x4 );
239244 keymap->field_0x8 = tvmap->field_0x8 ;
240245 keymap->field_0xc = tvmap->field_0xc ;
241246 }
242247
243- bank->setInst (i, inst );
248+ bank->setInst (i, instp );
244249 }
245250 }
246251
247252 for (int i = 0 ; i < 12 ; i++) {
248- TPerc* tperc = header->mOffsets .mPercOffset [i].ptr (stream );
253+ TPerc* tperc = header->mOffsets .mPercOffset [i].ptr (header );
249254 if (tperc != NULL ) {
250- JASDrumSet* drumset = new (heap, 0 ) JASDrumSet ();
251- drumset->newPercArray (0x80 , heap);
255+ JASDrumSet* setp = new (heap, 0 ) JASDrumSet ();
256+ JUT_ASSERT (509 , setp != 0 );
257+ setp->newPercArray (0x80 , heap);
252258
253259 for (int j = 0 ; j < 0x80 ; j++) {
254- TPmap* tpmap = tperc->mPmapOffset [j].ptr (stream );
260+ TPmap* tpmap = tperc->mPmapOffset [j].ptr (header );
255261 if (tpmap != NULL ) {
256- JASDrumSet::TPerc* perc = new (heap, 0 ) JASDrumSet::TPerc ();
257- perc->setVolume (tpmap->mVolume );
258- perc->setPitch (tpmap->mPitch );
262+ JASDrumSet::TPerc* percp = new (heap, 0 ) JASDrumSet::TPerc ();
263+ JUT_ASSERT (519 , percp);
264+ percp->setVolume (tpmap->mVolume );
265+ percp->setPitch (tpmap->mPitch );
259266 if (tperc->mMagic == ' PER2' ) {
260- perc ->setPan (tperc->mPan [j] / 127 .0f );
261- perc ->setRelease (tperc->mRelease [j]);
267+ percp ->setPan (tperc->mPan [j] / 127 .0f );
268+ percp ->setRelease (tperc->mRelease [j]);
262269 }
263- TVmap* vmap = tpmap->mVmapOffset .ptr (stream );
264- perc ->field_0xe = JSULoHalf (vmap->field_0x4 );
265- perc ->field_0x10 = vmap->field_0x8 ;
266- perc ->field_0x14 = vmap->field_0xc ;
267- drumset ->setPerc (j, perc );
270+ TVmap* vmap = tpmap->mVmapOffset .ptr (header );
271+ percp ->field_0xe = JSULoHalf (vmap->field_0x4 );
272+ percp ->field_0x10 = vmap->field_0x8 ;
273+ percp ->field_0x14 = vmap->field_0xc ;
274+ setp ->setPerc (j, percp );
268275 }
269276 }
270277
271- bank->setInst (i + 0xe4 , drumset );
278+ bank->setInst (i + 0xe4 , setp );
272279 }
273280 }
274281
0 commit comments