News:

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

Main Menu

Underwater issue when altering the game gravity

Started by Vener, March 03, 2019, 02:58:17 PM

Previous topic - Next topic

Vener

Hello there !

The idea :

Using vanilla gravity physical propertys only when i am in Ceres , Or if gravity suit is equiped . Otherwise , the gravity is changed to something 'heavier' .

So what i've done :



(08:1EB9): dw #0005 (basic jump height)(vanilla is #0004)

dw called at :
(08:1905): 

   JSR  LowJump gravity   

LowJump gravity:

    LDA $079F     AD 9F 07 (region nb)
    CMP #0006    C9 06 00 (ceres)
    BNE               D0 04*
**LDA,x $9EB9  BD B9 9E (to -> #0004)
    RTS               60

*  LDA $09A2    AD A2 09 (equiped items)
    BIT #0020    89 20 00 (gravity suit) 
    BNE              D0 F4**               
    LDA,x           BD 28 F9 (to -> #0005)
    RTS              60

    dw                0500

________________

(08:1EC5): dw #0008 (hi jump height)(vanilla = #0006)

dw called at :
(08:1913):

   JSR  HighJump gravity

HighJump gravity:

    LDA $079F      AD 9F 07 (region nb)
    CMP #0006     C9 06 00 (ceres)
    BNE                D0 04*
**LDA,x $9EC5    BD C5 9E (to -> #0006)
    RTS                 60

* LDA $09A2       AD A2 09 (equiped items)
   BIT #0020       89 20 00 (gravity suit) 
   BNE                 D0 F4**               
   LDA,x              BD 42 F9 (to -> #0008)
   RTS                 60

   dw                  08 00

________________

(08:1EA1): dw #2E50 (planete gravity, falling speed , etc ...)(vanilla = #1C00)

dw called at :
(08:1C7B):
   
   JSR  Zebes gravity

Zebes gravity:

    LDA $079F     AD 9F 07 (region nb)
    CMP #0006    C9 06 00 (ceres)
    BNE               D0 04*
**LDA $9EA1     AD A1 9E (to -> #1C00)
    RTS               60

*  LDA $09A2    AD A2 09 (equiped items)
    BIT #0020    89 20 00 (gravity suit) 
    BNE              D0 F4**               
    LDA              AD 5C F9 (to -> #2E50)
    RTS              60

    dw               50 2E

________________

(08:110C): CMP #0008 (falling speed)(vanilla = #0005)

   JSR  Falling speed             
   BEQ             F0 16
   NOPx3         EA EA EA

Falling speed:

    LDA $079F     AD 9F 07 (region nb)
    CMP #0006    C9 06 00 (ceres)
    BNE               D0 07*
**LDA $0B2E     AD 2E 0B                 
    CMP #0005    C9 05 00 (#0005)         
    RTS               60               
                                             
*  LDA $09A2    AD A2 09 (equiped items)
    BIT #0020    89 20 00 (gravity suit) 
    BNE              D0 F1**             
    LDA $0B2E    AD 2E 0B
    CMP #0008    C9 08 00 (#0008)
    RTS               60

________________

(08:1EF5): dw #0003 (bomb jump height)(vanilla = #0002)

dw called at :
(08:1A6A):

   JSR  Bomb jump heights

Bomb jump heights:

    LDA $079F      AD 9F 07 (region nb)
    CMP #0006     C9 06 00 (ceres)
    BNE                D0 04*
**LDA,x $9EF5    BD F5 9E (to -> #0002)
    RTS                60

*  LDA $09A2      AD A2 09 (equiped items)
    BIT #0020      89 20 00 (gravity suit) 
    BNE                D0 F4**               
    LDA,x             BD AA F9 (to -> dw #0003)
    RTS                60

    dw                 03 00


So i do this , and everything work as i want , but if i go in the water , i can't jump anymore , as if the gravity was reduced to 0 , and i'm perma stucked on the ground ... unless i equipe gravity suit .

So i'm really embarassed with this problem because i can't test and adjuste plateforme/grappling blocks/etc heights in all the underwater rooms .

And sorry for the typing , i never got Xkas working on my PC , so since all those years , i always work and write codes in hex  :eyeroll:

caauyjdp

#1
The main problem with this is that you're forgetting X(it's used as index) when handling the "jump height" hijacks. In water X will be 2, and your value "table" is only one entry long, so most likely it returns 0x9FAD which is part of your "LDA $079F     AD 9F 07 (region nb)".
You need to define a full 3x dw table instead of just

    dw                0500
   dw                  08 00


P.S. If you haven't already, I recommend glancing at relevant parts of http://patrickjohnston.org/ASM/ROM%20data/Super%20Metroid/Bank%20$90.asm

Vener

Okay , now i got it and it works fine . The 3 words stands for air/water/lava .

Thanks man , i'd never found this without you  :wink: