Extracting score from memory
Hi, I'm trying to make an RL agent for gameboy tennis. I need a way to get the score after each point. One method is by processing the pixel data but I thought it would be more efficient/reliable to read it directly from memory. I'm not really sure where to start. I've installed visualboyadvance-m which has a memory viewer but a lot of values change so no idea how to narrow it down. Any help would be appreciated.
17 Replies
This website has a lot of good info https://datacrystal.tcrf.net/wiki/Tetris_(Game_Boy)/RAM_map
Pyboy has a tetris game wrapper that may do this already as well
Finding a disassembly of the ROM would be likely helpful as well. Pokemon Red has really-well-documented disassemblies, which proved vital for success.
unfortunately tennis doesn't seem to be popular enough for someone to have posted a RAM map or made a wrapper
Oh my bad misread that as tetris
is this a lot of effort? I've been screen recording the memory as I play and I've identified some values that correlate with movement/winning games
obv that's prone to errors but this project is about RL algorithms so i'd rather not waste time on this stuff
finding the disassembly is minimal effort. disassembling yourself? that's maximal effort
i'm porting the atari 2600 game enduro to c. i found one disassembly, but it's only just the assembly itself. and it has been minimally edited. needless to say, 3000 lines of is difficult at best to utilize
amazing what fits into 3kb tho
Can you give me a brief overview of the steps needed
https://github.com/mattcurrie/mgbdis?origin=serp_auto
Disassemble with something like this
Then look through the assembly for variables related to score?
GitHub
GitHub - mattcurrie/mgbdis: Game Boy ROM disassembler with RGBDS co...
Game Boy ROM disassembler with RGBDS compatible output - mattcurrie/mgbdis
no clue. 😠maybe someone else here has better knowledge @Sky
It's a good start if you've already identified some memory areas. That's not the same as an actual disassembly.
Did you check out the memory scanner in the docs? https://docs.pyboy.dk/api/memory_scanner.html
If there's always something on the screen that tells you the score, you can also go that way
Not yet but looks helpful
The score appears and disappears after each point
And I doubt the scores are stored as 15/30/40 in memory
You can see this as an example https://github.com/Baekalfen/PyBoy/blob/8cf3f1f11dd34e6838174ac3680553bf962e4171/pyboy/plugins/game_wrapper_tetris.py#L94
You can copy the function from here https://github.com/Baekalfen/PyBoy/blob/8cf3f1f11dd34e6838174ac3680553bf962e4171/pyboy/plugins/base_plugin.py#L278
Unfortunately I never digged into using disassembling tools on gb, at most I relied on good old memory scanning. My x86 asm reversing period on games, ended like 13 years ago 😅
Forgot to say but I managed to find the memory address manually after not too long. It's 0xC0DD for player score and 0xC0DE for cpu. Also found out you can pause the game at any time to check score so I could have read it like in the Tetris example. Thanks all of you for your help.
you could say you found the C0DE
wonder if that was on purpose??