<commit_before>* TapTracker                                                       :TOC_4_gh:
   - [[#about][About]]
   - [[#building-taptracker][Building TapTracker]]
   - [[#running-taptracker][Running TapTracker]]
   - [[#screenshots][Screenshots]]
   - [[#to-do-list][To-do list]]
   - [[#appendix][Appendix]]
     - [[#useful-ram-addresses][Useful RAM Addresses]]
     - [[#block-indices][Block Indices]]
     - [[#tgm2p-states][TGM2P States]]
       - [[#m-roll-flags][M-Roll Flags]]
       - [[#internal-state][Internal State]]
       - [[#game-mode][Game Mode]]

** About
This project aims to log various game data (and inputs) during a game of [[https://en.wikipedia.org/wiki/Tetris:_The_Grand_Master][Tetris: The Grandmaster 2 Plus]] (TGM2p/TGM2+/TAP) when run in an emulator ([[http://mamedev.org/][MAME]]). TapTracker runs alongside the emulator and performs its logging in real-time. This is linux-only for now.

[[https://github.com/sanford1/BlockTracker][BlockTracker]] was my first attempt at this. It was done by interacting with [[https://github.com/scanmem/scanmem][scanmem]] as a child process. Ultimately, this meant every time I started up the game, I had to probe for the memory address holding level data (not unlike someone using [[http://www.cheatengine.org/][cheat-engine]]) then pass the proper memory addresses to BlockTracker. Along the way I wrote quite possibly the worst code I've ever written. Despite being such a small program, it wasn't too pleasant for me to look at and maintain. (There was one upside though: this method was game-agnostic; I could probe any TGM-style game for level data).

In contrast, TapTracker takes a more direct route by modifying a [[https://github.com/sanford1/shmupmametgm/][TGM-specific version of MAME]] to output relevant data. You can also build TapTracker MAME like so:

#+BEGIN_SRC sh
git clone https://github.com/sanford1/shmupmametgm.git
make SUBTARGET=tgm NOWERROR=1
#+END_SRC

The patch uses debug functions in MAME, so debug functionality must be enabled with =-debug= or the =-c= switch (enables the cheat engine).

** Building TapTracker

After cloning this repository, retrieve all the submodules:

#+BEGIN_SRC sh
  git submodule update --init --recursive
#+END_SRC

Building this project requires [[https://www.python.org/][python]], [[https://martine.github.io/ninja/][ninja]], and [[http://www.glfw.org/][glfw]]:

#+BEGIN_SRC sh
  python bootstrap.py
  ninja
#+END_SRC

** Running TapTracker

TapTracker no longer runs shmupmametgm as a child process, but TapTracker must be run /after/ shmupmametgm has started. For now, TapTracker only logs stats for player 1.<commit_msg>Fixed outdated information in README<commit_after>* TapTracker                                                       :TOC_4_gh:
   - [[#about][About]]
   - [[#building-taptracker][Building TapTracker]]
   - [[#running-taptracker][Running TapTracker]]
   - [[#screenshots][Screenshots]]
   - [[#to-do-list][To-do list]]
   - [[#appendix][Appendix]]
     - [[#useful-ram-addresses][Useful RAM Addresses]]
     - [[#block-indices][Block Indices]]
     - [[#tgm2p-states][TGM2P States]]
       - [[#m-roll-flags][M-Roll Flags]]
       - [[#internal-state][Internal State]]
       - [[#game-mode][Game Mode]]

** About
This project aims to log various game data (and inputs) during a game of [[https://en.wikipedia.org/wiki/Tetris:_The_Grand_Master][Tetris: The Grandmaster 2 Plus]] (TGM2p/TGM2+/TAP) when run in an emulator ([[http://mamedev.org/][MAME]]). TapTracker runs alongside the emulator and performs its logging in real-time. This is linux-only for now.

[[https://github.com/sanford1/BlockTracker][BlockTracker]] was my first attempt at this. It was done by interacting with [[https://github.com/scanmem/scanmem][scanmem]] as a child process. Ultimately, this meant every time I started up the game, I had to probe for the memory address holding level data (not unlike someone using [[http://www.cheatengine.org/][cheat-engine]]) then pass the proper memory addresses to BlockTracker. Along the way I wrote quite possibly the worst code I've ever written. Despite being such a small program, it wasn't too pleasant for me to look at and maintain. (There was one upside though: this method was game-agnostic; I could probe any TGM-style game for level data).

In contrast, TapTracker takes a more direct route by modifying a [[https://github.com/sanford1/shmupmametgm/][TGM-specific version of MAME]] to output relevant data. You can also build TapTracker MAME like so:

#+BEGIN_SRC sh
git clone https://github.com/sanford1/shmupmametgm.git
make SUBTARGET=tgm NOWERROR=1
#+END_SRC

** Building TapTracker

After cloning this repository, retrieve all the submodules:

#+BEGIN_SRC sh
  git submodule update --init --recursive
#+END_SRC

Building this project requires [[https://www.python.org/][python]], [[https://martine.github.io/ninja/][ninja]], and [[http://www.glfw.org/][glfw]]:

#+BEGIN_SRC sh
  python bootstrap.py
  ninja
#+END_SRC

** Running TapTracker

TapTracker no longer runs shmupmametgm as a child process, but TapTracker must be run /after/ shmupmametgm has started. For now, TapTracker only logs stats for player 1. You must also [[https://github.com/sanford1/shmupmametgm/#taptracker][enable TapTracker]] in /modded/ shmupmametgm with the =-taptracker= switch or the correct option in your mame.ini.
{'fraction_non_alphanumeric': 0.12065439672801637, 'fraction_numerical': 0.0042758877114705334, 'mean_word_length': 3.9722735674676524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 15, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5156836', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1604, 'n_words': 575}