Post subject: Question about character positions relative to camera
Player (244)
Joined: 8/6/2006
Posts: 784
Location: Connecticut, USA
My question pertains to the memory addresses that handle where the character (or enemies, for that matter) appear on the screen, relative to the boundaries of the camera. In two games that I've looked at (Disney's Aladdin and Earthworm Jim), these addresses are fairly easy to find, they're right near each other and they don't act strange or anything. I've been experimenting with drawing pixels at their positions with lua. The problem arose after I drew the pixel. Basically, when the character is more or less centered in the screen, the position values read something like x = ~170 and y = ~400 (very similar values in both games). The lua script lines up the pixel perfectly with the x value, but using 400 for a y value for the pixel draws it wayyy off screen. After some messing around, it seems that this value of 400 is about 240 pixels off the mark (i.e. subtracting 240 from the y value and then using this new value for the pixel's y position gets it right about where it should be). Basically, I'm trying to gain some intuition as to why the game does this and possible fixes for my script (so that I don't have to estimate). I'm not even sure where the pixel is supposed to end up (probably either the true center of the character or the bottom center). Again, either game has the same issues. EDIT: So I was looking at that value of "about 240 pixels" and realized that it's pretty close to 255 or 0xFF, which makes more sense. Subtracting this value from the mentioned addresses puts the pixel almost right in the middle of the sprite. I'm probably on the right track here.
Player (142)
Joined: 7/16/2009
Posts: 686
It's probably a signed value that you're reading as an unsigned value, or the other way around.
Player (244)
Joined: 8/6/2006
Posts: 784
Location: Connecticut, USA
Whether the value was signed or not wasn't the problem, but this suggestion actually clued me into the obvious: I was looking at the values as 2 bytes, when I should have been looking at them as one. Oops. Thanks though, this helped me figure it out!
Player (36)
Joined: 9/9/2006
Posts: 388
So does this mean you could potentially using your LUA script, "Camhack" ala the Sonic videos? Could you give this a try and post some screenshots? Otherwise I don't get why you're making a LUA script draw a screen when the emulator already does this.
A whisper in the wind~~
Player (142)
Joined: 7/16/2009
Posts: 686
He was trying to draw information about the character at the characters position. However, the characters position is stored in the RAM as his position in the level, not on screen. To get, say, the characters x-position on the screen, you'd need to get the characters absolute x-position and subtract from that the screens x-position.