MAME's cheatinit is just like ye olden C64/Amiga Action Replay and Final Cartridge days.
Scan the RAM, die once in the game, scan again for decreased values, repeat until just one address left.
Then patch that address for unlimited lives.
Scan the RAM, die once in the game, scan again for decreased values, repeat until just one address left.
Then patch that address for unlimited lives.