When MIDI code triggers a synthesizer, it's similar to a piano roll triggering a player piano. In both cases, music written by a human is programmed to be played by a machine. Whenever a human creates an original fixed work (the code is fixed on the game cartridge), it's protected by copyright. In order to record, remix, or repurpose the NES/MIDI melodies or themes, copyright law requires that you get permission from the composition's owner -- either Nintendo, the game company, or in rare situations, the composer. Unless the music has been released on CD or authorized downloads such as MP3s, you would not use the compulsory mechanical license used for cover songs because that only applies to compositions that have been released on sound recordings (not video games or movies). Sample licensing usually includes two licenses, one for the composition, the other for the recorded performance. You wouldn't need the license for the recorded performance (aka the master recording).
What if you don't get permission? Failing to acquire permission won't matter if the copyright owner never learns of your use (a good possibility unless your track goes viral). And even if the owner does learn of your work, the owner may not want to hassle you for financial or publicity reasons. The owner may be most likely to care if you use your music in a video game or movie.
Permission may not be needed. Authorization is not needed if your sampling is excused as a fair use, determined by the four fair use factors. Your use differs from the original purpose of the music -- to enhance the gameplay experience. So, that's transformative (and in your favor). Another fair use factor is how much material you have used. The less you sample, the less you loop, and the less that the song is built around the loop, the stronger the fair use argument. Still, as we always warn: Fair use can only be used as a defense to copyright infringement. That is, you must already be in court. Also, permission might not be necessary if the MIDI composition is not original (for example based on folk music) or is so simple the pattern is considered an essential building block of music composition (for example, the arpeggio associated with boogie-woogie piano). Again, like fair use, these are defenses raised at trial.