News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Question about making a Kirby randomizer  (Read 1042 times)

GateGuy

  • Newbie
  • *
  • Posts: 1
    • View Profile
Question about making a Kirby randomizer
« on: June 07, 2020, 12:18:00 am »
I'm working on my first randomizer (Kirby and the Amazing Mirror) and I'm trying to find the memory addresses for which enemies give which abilities. The existing randomizers for other Kirby games have documentation that give the enemy ability addresses (like this one https://github.com/aquova/KNDL-Rando/blob/master/docs/aquova_kndl_notes.txt for Nightmare in Dream Land), but how would they have found those addresses in the first place? I've tried using the disassembler and memory viewer in VBA-M and I found the address that indicates the ability that's currently in Kirby's mouth, so where should I go from there? It would be great if I could find the address that this ability came from, but I haven't been able to figure it out.

FAST6191

  • Hero Member
  • *****
  • Posts: 2894
    • View Profile
Re: Question about making a Kirby randomizer
« Reply #1 on: June 07, 2020, 10:19:47 am »
If you already have whatever is in his mouth then surely you would just set a break on write to that and grab something else, whatever wrote to that might still be in RAM rather than a ROM read but it is one step closer to a ROM address if it is.

PolishedTurd

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Re: Question about making a Kirby randomizer
« Reply #2 on: June 07, 2020, 06:12:06 pm »
The way this generally works, there is a number that corresponds to each type of enemy, and it is used as an index into an array. The contents of the array at that index will indicate what power will be granted. I'm not certain that's how this game is set up, but that's the general approach. A variant I've seen in one of the Batman games is to index the enemy attributes by what sequence they appear, not by what type they are, but that seems contrary to how Kirby works.

As Fast6191 suggested, if you set a write breakpoint on the register containing Kirby's power, you will see what is being written into it. If you do a trace to that breakpoint (or, less reliably, scroll up in the symbolic debugger), you will see how the value being written is chosen. In general, it will either be a lookup (offset from a memory location) or some conditional logic (if enemy # is A, power is B). Of course, you will need to build the list of values for powers and the values for each enemy type, and then you can describe the relationship between them numerically, which is what your program will ultimately do.