MCPcopy Create free account
hub / github.com/TASEmulators/fceux / NSF_init

Function NSF_init

src/nsf.cpp:330–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328};
329
330void NSF_init(void)
331{
332 doreset=1;
333
334 ResetCartMapping();
335 if(NSFHeader.SoundChip&4)
336 {
337 SetupCartPRGMapping(0,ExWRAM,32768+8192,1);
338 setprg32(0x6000,0);
339 setprg8(0xE000,4);
340 memset(ExWRAM,0x00,32768+8192);
341 SetWriteHandler(0x6000,0xDFFF,CartBW);
342 SetReadHandler(0x6000,0xFFFF,CartBR);
343 }
344 else
345 {
346 memset(ExWRAM,0x00,8192);
347 SetReadHandler(0x6000,0x7FFF,CartBR);
348 SetWriteHandler(0x6000,0x7FFF,CartBW);
349 SetupCartPRGMapping(0,NSFDATA,((NSFMaxBank+1)*4096),0);
350 SetupCartPRGMapping(1,ExWRAM,8192,1);
351 setprg8r(1,0x6000,0);
352 SetReadHandler(0x8000,0xFFFF,CartBR);
353 }
354
355 if(BSon)
356 {
357 int32 x;
358 for(x=0;x<8;x++)
359 {
360 if(NSFHeader.SoundChip&4 && x>=6)
361 BANKSET(0x6000+(x-6)*4096,NSFHeader.BankSwitch[x]);
362 BANKSET(0x8000+x*4096,NSFHeader.BankSwitch[x]);
363 }
364 }
365 else
366 {
367 int32 x;
368 for(x=(LoadAddr&0xF000);x<0x10000;x+=0x1000)
369 BANKSET(x,((x-(LoadAddr&0x7000))>>12));
370 }
371
372 SetReadHandler(0xFFFA,0xFFFD,NSFVectorRead);
373
374 SetWriteHandler(0x2000,0x3fff,0);
375 SetReadHandler(0x2000,0x37ff,0);
376 SetReadHandler(0x3836,0x3FFF,0);
377 SetReadHandler(0x3800,0x3835,NSFROMRead);
378
379 SetWriteHandler(0x5ff6,0x5fff,NSF_write);
380
381 SetWriteHandler(0x3ff0,0x3fff,NSF_write);
382 SetReadHandler(0x3ff0,0x3fff,NSF_read);
383
384
385 if(NSFHeader.SoundChip&1) {
386 NSFVRC6_Init();
387 } else if(NSFHeader.SoundChip&2) {

Callers 1

NSFGIFunction · 0.85

Calls 15

ResetCartMappingFunction · 0.85
SetupCartPRGMappingFunction · 0.85
setprg32Function · 0.85
setprg8Function · 0.85
SetWriteHandlerFunction · 0.85
SetReadHandlerFunction · 0.85
setprg8rFunction · 0.85
BANKSETFunction · 0.85
NSFVRC6_InitFunction · 0.85
NSFVRC7_InitFunction · 0.85
FDSSoundResetFunction · 0.85
NSFMMC5_InitFunction · 0.85

Tested by

no test coverage detected