News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM][ASM] X/Y movement/position.

Started by dewhi100, May 31, 2017, 12:11:44 AM

Previous topic - Next topic

dewhi100

1. Why is Samus' Y velocity unsigned? She always ends up coming back down to the ground so I'm not quite sure what's good with all that.

1a. Can I make it signed?

2. Her X/Y speed and position are read from/written to about 40 different times each in the ROM (estimate from a cursory search). Does anyone know where they are assigned for the final time?

3. Any reason known that these values are changed this much? I get a few times, but forty? Really?

4. All I really want to do is to make Samus' X and Y velocity affect her positioning differently in different situations. Such as: X velocity moves Samus in the -X direction; or moves her in the Y direction. Is there any good point in code to futz with the velocity values? One would think that the velocities would be assigned for the last time before being used to affect positioning... but after doing some searching I am a little concerned. Any tips?

dewhi100

I've been looking through PJ's excellent bank disassembly, and found the Samus movement stuff in bank 90. Notably, the routines for moving her up, down, left, and right. As a test, I tried replacing all the calls for moving right with calls to move left. Doesn't work. She moves normally. I know my changes are in effect, because I can get the game to freeze if I put a loop in instead.

I'm also a little suspicious about these routines for a different reason. The left and right movement routines are different lengths and with differing structures. I can see how up/down would be different, but why would horizontal movement be more complicated in one direction?

Due to my changes, nowhere in the ROM am I calling rightward movement. Yet, she moves right.  :stern:

Here are the left and right movement routines, from the bank disassembly:
[spoiler]

;;; Move Samus left $12.$14 pixels with all the checks ;;;
$909350 08          PHP
$909351 C2 30       REP #$30
$909353 A5 12       LDA $12    [$7E:0012]
$909355 49 FF FF    EOR #$FFFF
$909358 85 12       STA $12    [$7E:0012]
$90935A A5 14       LDA $14    [$7E:0014]
$90935C 49 FF FF    EOR #$FFFF
$90935F 1A          INC A
$909360 85 14       STA $14    [$7E:0014]
$909362 D0 02       BNE $02    [$9366]
$909364 E6 12       INC $12    [$7E:0012]

$909366 22 F0 A8 A0 JSL $A0A8F0[$A0:A8F0]
$90936A 8D D0 0D    STA $0DD0  [$7E:0DD0]
$90936D AA          TAX
$90936E F0 0C       BEQ $0C    [$937C]
$909370 20 CE E5    JSR $E5CE  [$90:E5CE]
$909373 20 42 98    JSR $9842  [$90:9842]
$909376 22 F4 87 94 JSL $9487F4[$94:87F4]
$90937A 28          PLP
$90937B 60          RTS

$90937C A5 12       LDA $12    [$7E:0012]
$90937E 49 FF FF    EOR #$FFFF
$909381 85 12       STA $12    [$7E:0012]
$909383 A5 14       LDA $14    [$7E:0014]
$909385 49 FF FF    EOR #$FFFF
$909388 1A          INC A
$909389 85 14       STA $14    [$7E:0014]
$90938B D0 02       BNE $02    [$938F]
$90938D E6 12       INC $12    [$7E:0012]

$90938F 22 1E 97 94 JSL $94971E[$94:971E]
$909393 A5 14       LDA $14    [$7E:0014]
$909395 8D AC 0D    STA $0DAC  [$7E:0DAC]
$909398 A5 12       LDA $12    [$7E:0012]
$90939A 8D AA 0D    STA $0DAA  [$7E:0DAA]
$90939D AD 02 0B    LDA $0B02  [$7E:0B02]
$9093A0 89 01 00    BIT #$0001
$9093A3 F0 03       BEQ $03    [$93A8]
$9093A5 9C D0 0D    STZ $0DD0  [$7E:0DD0]

$9093A8 20 CE E5    JSR $E5CE  [$90:E5CE]
$9093AB 22 F4 87 94 JSL $9487F4[$94:87F4]
$9093AF 28          PLP
$9093B0 60          RTS


;;; Move Samus right $12.$14 pixels with all the checks ;;;
$9093B1 08          PHP
$9093B2 C2 30       REP #$30
$9093B4 22 F0 A8 A0 JSL $A0A8F0[$A0:A8F0]
$9093B8 8D D0 0D    STA $0DD0  [$7E:0DD0]
$9093BB AA          TAX
$9093BC F0 0C       BEQ $0C    [$93CA]
$9093BE 20 CE E5    JSR $E5CE  [$90:E5CE]
$9093C1 20 26 98    JSR $9826  [$90:9826]
$9093C4 22 F4 87 94 JSL $9487F4[$94:87F4]
$9093C8 28          PLP
$9093C9 60          RTS

$9093CA 22 1E 97 94 JSL $94971E[$94:971E]
$9093CE A5 14       LDA $14    [$7E:0014]
$9093D0 8D B0 0D    STA $0DB0  [$7E:0DB0]
$9093D3 A5 12       LDA $12    [$7E:0012]
$9093D5 8D AE 0D    STA $0DAE  [$7E:0DAE]
$9093D8 AD 02 0B    LDA $0B02  [$7E:0B02]
$9093DB 89 01 00    BIT #$0001
$9093DE D0 03       BNE $03    [$93E3]
$9093E0 9C D0 0D    STZ $0DD0  [$7E:0DD0]

$9093E3 20 CE E5    JSR $E5CE  [$90:E5CE]
$9093E6 22 F4 87 94 JSL $9487F4[$94:87F4]
$9093EA 28          PLP
$9093EB 60          RTS

[/spoiler]