Refactor mednafen.cpp