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

Function emu_loadrom

src/lua-engine.cpp:634–684  ·  view source on GitHub ↗

emu.loadrom(string filename) Loads the rom from the directory relative to the lua script or from the absolute path. If the rom can't be loaded, loads the most recent one.

Source from the content-addressed store, hash-verified

632// Loads the rom from the directory relative to the lua script or from the absolute path.
633// If the rom can't be loaded, loads the most recent one.
634static int emu_loadrom(lua_State *L)
635{
636#ifdef __WIN_DRIVER__
637 const char* str = lua_tostring(L,1);
638
639 //special case: reload rom
640 if (!str) {
641 ReloadRom();
642 return 0;
643 }
644
645 const char *nameo2 = luaL_checkstring(L,1);
646 char nameo[2048];
647 strncpy(nameo, nameo2, sizeof(nameo));
648 if (!ALoad(nameo)) {
649 extern void LoadRecentRom(int slot);
650 LoadRecentRom(0);
651 }
652 if ( GameInfo )
653 {
654 //printf("Currently Loaded ROM: '%s'\n", GameInfo->filename );
655 lua_pushstring(L, GameInfo->filename);
656 return 1;
657 }
658 return 0;
659#elif defined(__QT_DRIVER__)
660 const char *nameo2 = luaL_checkstring(L,1);
661 std::string nameo;
662
663 nameo.assign( nameo2 );
664
665 LoadGameFromLua( nameo.c_str() );
666
667 //lua_cpcall(L, emu_wait_for_rom_load, NULL);
668 //printf("Attempting to Load ROM: '%s'\n", nameo );
669 //if (!LoadGame(nameo, true))
670 //{
671 // //printf("Failed to Load ROM: '%s'\n", nameo );
672 // reloadLastGame();
673 //}
674 if ( GameInfo )
675 {
676 //printf("Currently Loaded ROM: '%s'\n", GameInfo->filename );
677 lua_pushstring(L, GameInfo->filename);
678 return 1;
679 } else {
680 return 0;
681 }
682#endif
683 return 0;
684}
685
686// emu.exit()
687//

Callers

nothing calls this directly

Calls 5

ReloadRomFunction · 0.85
ALoadFunction · 0.85
LoadRecentRomFunction · 0.85
lua_pushstringFunction · 0.85
LoadGameFromLuaFunction · 0.85

Tested by

no test coverage detected