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

Function PowerNES

src/fceu.cpp:1008–1068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006}
1007
1008void PowerNES(void) {
1009 FCEUMOV_AddCommand(FCEUNPCMD_POWER);
1010 if (!GameInfo) return;
1011
1012 //reseed random, unless we're in a movie
1013 extern int disableBatteryLoading;
1014 if(FCEUMOV_Mode(MOVIEMODE_INACTIVE) && !disableBatteryLoading)
1015 {
1016 RAMInitSeed = rand() ^ (u32)xoroshiro128plus_next();
1017 }
1018
1019 //always reseed the PRNG with the current seed, for deterministic results (for that seed)
1020 xoroshiro128plus_seed(RAMInitSeed);
1021
1022 FCEU_CheatResetRAM();
1023 FCEU_CheatAddRAM(2, 0, RAM);
1024
1025 FCEU_GeniePower();
1026
1027 FCEU_MemoryRand(RAM, 0x800);
1028
1029 SetReadHandler(0x0000, 0xFFFF, ANull);
1030 SetWriteHandler(0x0000, 0xFFFF, BNull);
1031
1032 SetReadHandler(0, 0x7FF, ARAML);
1033 SetWriteHandler(0, 0x7FF, BRAML);
1034
1035 SetReadHandler(0x800, 0x1FFF, ARAMH); // Part of a little
1036 SetWriteHandler(0x800, 0x1FFF, BRAMH); //hack for a small speed boost.
1037
1038 InitializeInput();
1039 FCEUSND_Power();
1040 FCEUPPU_Power();
1041
1042 //Have the external game hardware "powered" after the internal NES stuff. Needed for the NSF code and VS System code.
1043 GameInterface(GI_POWER);
1044 if (GameInfo->type == GIT_VSUNI)
1045 FCEU_VSUniPower();
1046
1047 //if we are in a movie, then reset the saveram
1048 extern int disableBatteryLoading;
1049 if (disableBatteryLoading)
1050 GameInterface(GI_RESETSAVE);
1051
1052 timestampbase = 0;
1053 X6502_Power();
1054#ifdef __WIN_DRIVER__
1055 ResetDebugStatisticsCounters();
1056#endif
1057 FCEU_PowerCheats();
1058 LagCounterReset();
1059 // clear back buffer
1060 extern uint8 *XBackBuf;
1061 memset(XBackBuf, 0, 256 * 256);
1062
1063#ifdef __WIN_DRIVER__
1064 Update_RAM_Search(); // Update_RAM_Watch() is also called.
1065#endif

Callers 4

FCEUI_LoadGameVirtualFunction · 0.85
FCEU_DoSimpleCommandFunction · 0.85
poweronFunction · 0.85
FCEUMOV_AddInputStateFunction · 0.85

Calls 15

FCEUMOV_AddCommandFunction · 0.85
FCEUMOV_ModeFunction · 0.85
xoroshiro128plus_nextFunction · 0.85
xoroshiro128plus_seedFunction · 0.85
FCEU_CheatResetRAMFunction · 0.85
FCEU_CheatAddRAMFunction · 0.85
FCEU_GeniePowerFunction · 0.85
FCEU_MemoryRandFunction · 0.85
SetReadHandlerFunction · 0.85
SetWriteHandlerFunction · 0.85
InitializeInputFunction · 0.85
FCEUSND_PowerFunction · 0.85

Tested by

no test coverage detected