Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communicate with a NES game running in an emulator

Tags:

emulation

I am thinking of creating an arcade machine for fun. Something like this one. I wonder if it's possible to get events from some game, e.g.Super Mario. Assume I finish a level and I want to get that event, with the score and some other data and perform some actions with that data. I am thinking of running the emulator in Windows. Did anybody work on something like this? Are there not too difficult ways to get events and data from old NES games? May be I should run not Windows, but some Linux for that? Well, please share your thoughts about how to do the software part of it.

like image 240
Sergei Basharov Avatar asked Feb 23 '23 11:02

Sergei Basharov


1 Answers

Modern emulators such as FCEUX make it possible to interact with the running ROM through Lua scripts (see example video). Using this API you could write a Lua script to:

  1. monitor a certain memory location
  2. wait for it to hold some special value (such as level_just_finished)
  3. read out the current score from memory
  4. do something with the score

In order to know which memory locations to check, you will either need to disassemble the ROM or run it through a debugger, or both. As for Super Mario Bros, there's already a commented disassembly available. The FCEUX emulator also has a built-in debugger/disassembler that you can use.

All of this takes a lot of effort and you would need to know Lua, 6502 assembly, and the inner workings of an NES. For your arcade machine, you might be better off just using an emulator such as UberNES, which automatically can track your highscore for many popular titles.

like image 84
Martin Avatar answered Mar 04 '23 06:03

Martin