Moon jump ASM for 3d games

Started by Patedj, March 11, 2011, 05:52:38 AM

Previous topic - Next topic

Deathwolf

btw this works fine too:

28215000 00000800
C2006234 00000005
9421FFF0 91610008
3D608049 616B319C
C12B0000 918B0000
81610008 38210010
60000000 00000000
2A215000 00000800 <-- if not equal with 00000800
0449319C C1250004
E0000000 80008000
lolz

strakn

2A215000 00000800 <-- if not equal with 00000800

should it be 2A215001

then it will end the first if statement

Deathwolf

Quote from: strakn on March 14, 2011, 09:47:05 PM
2A215000 00000800 <-- if not equal with 00000800

should it be 2A215001

then it will end the first if statement

no 28 is 16 bit equal.
2A is 16 bit not equal.
lolz

Patedj

Alright I found the address. I worked out that the speed modifier that dcx2 has ported is just a couple 32 bytes after. Thank you dcx2!!

Registers[spoiler] CR:24000048  XER:00000000  CTR:00000000 DSIS:02400000
DAR:92B949C4 SRR0:80612A44 SRR1:0000B032   LR:80612A10
  r0:00000000   r1:80CA03D0   r2:8027E5E0   r3:808D2940
  r4:00000038   r5:00000000   r6:00000008   r7:806ECDC0
  r8:00000000   r9:00000004  r10:80CA03D0  r11:80CA0340
r12:0023F091  r13:8027D600  r14:00000000  r15:00000000
r16:00000000  r17:00000000  r18:00000000  r19:00000000
r20:00000000  r21:00000000  r22:00000000  r23:00000000
r24:92B947E0  r25:00000000  r26:80020000  r27:00000000
r28:806ECAD8  r29:808D3FA0  r30:806C21C0  r31:00000280

  f0:3FB0A3E8   f1:3FB0A3E8   f2:3F333333   f3:40051EC1
  f4:458FC245   f5:C2759E44   f6:BFBF62C0   f7:C5453000
  f8:C2759E44   f9:00000000  f10:42EA0000  f11:C36C6791
f12:00000000  f13:432F0000  f14:00000000  f15:00000000
f16:00000000  f17:00000000  f18:00000000  f19:00000000
f20:00000000  f21:00000000  f22:00000000  f23:00000000
f24:00000000  f25:00000000  f26:00000000  f27:00000000
f28:00000000  f29:00000000  f30:BFBF62C0  f31:3F800000[/spoiler]

Can't find Function So I simply copied everything below the register and a couple before in the dissasembly:
[spoiler]
80612A04:  38C00008   li   r6,8
80612A08:  4CC63182   crclr   6,6
80612A0C:  4BF51545   bl   0x80563f50
80612A10:  801801C0   lwz   r0,448(r24)
80612A14:  C07801E4   lfs   f3,484(r24)
80612A18:  540007BD   rlwinm.   r0,r0,0,30,30
80612A1C:  D0780374   stfs   f3,884(r24)
80612A20:  40820028   bne-   0x80612a48
80612A24:  3C60808D   lis   r3,-32627
80612A28:  C05E0084   lfs   f2,132(r30)
80612A2C:  38632940   addi   r3,r3,10560
80612A30:  C01801DC   lfs   f0,476(r24)
80612A34:  C0230010   lfs   f1,16(r3)
80612A38:  EC220072   fmuls   f1,f2,f1
80612A3C:  EC230828   fsubs   f1,f3,f1
80612A40:  EC01002A   fadds   f0,f1,f0
80612A44:  D01801E4   stfs   f0,484(r24)
80612A48:  C07E0000   lfs   f3,0(r30)
80612A4C:  3C60808D   lis   r3,-32627
80612A50:  D07801DC   stfs   f3,476(r24)
80612A54:  38632940   addi   r3,r3,10560
80612A58:  809800A4   lwz   r4,164(r24)
80612A5C:  C05801E4   lfs   f2,484(r24)
80612A60:  C0230010   lfs   f1,16(r3)
80612A64:  C0040004   lfs   f0,4(r4)
80612A68:  EC220072   fmuls   f1,f2,f1
80612A6C:  EC3F0072   fmuls   f1,f31,f1
80612A70:  EC00082A   fadds   f0,f0,f1
80612A74:  D0040004   stfs   f0,4(r4)
80612A78:  807800A4   lwz   r3,164(r24)
80612A7C:  C01801E0   lfs   f0,480(r24)
80612A80:  C0230004   lfs   f1,4(r3)
80612A84:  FC000840   fcmpo   cr0,f0,f1
80612A88:  4C411382   cror   2,1,2
80612A8C:  40820074   bne-   0x80612b00
80612A90:  C0180384   lfs   f0,900(r24)
80612A94:  FC000840   fcmpo   cr0,f0,f1
80612A98:  4C401382   cror   2,0,2
80612A9C:  4082000C   bne-   0x80612aa8
80612AA0:  D07801E4   stfs   f3,484(r24)
80612AA4:  48000014   b   0x80612ab8
80612AA8:  C03801E4   lfs   f1,484(r24)
80612AAC:  C01E00CC   lfs   f0,204(r30)
80612AB0:  EC010032   fmuls   f0,f1,f0
80612AB4:  D01801E4   stfs   f0,484(r24)
80612AB8:  807800A4   lwz   r3,164(r24)
80612ABC:  C01801E0   lfs   f0,480(r24)
80612AC0:  D0030004   stfs   f0,4(r3)
80612AC4:  80180358   lwz   r0,856(r24)
80612AC8:  2C000000   cmpwi   r0,0
80612ACC:  41820024   beq-   0x80612af0
80612AD0:  80180350   lwz   r0,848(r24)
80612AD4:  2C000000   cmpwi   r0,0
80612AD8:  41820018   beq-   0x80612af0
80612ADC:  807800A4   lwz   r3,164(r24)
80612AE0:  C0180354   lfs   f0,852(r24)
80612AE4:  C0230004   lfs   f1,4(r3)
80612AE8:  FC010000   fcmpu   cr0,f1,f0
80612AEC:  41820014   beq-   0x80612b00
80612AF0:  C03801E4   lfs   f1,484(r24)
80612AF4:  C01E00D0   lfs   f0,208(r30)
80612AF8:  EC010032   fmuls   f0,f1,f0
80612AFC:  D01801E4   stfs   f0,484(r24)
80612B00:  C03801E4   lfs   f1,484(r24)
80612B04:  C01E0000   lfs   f0,0(r30)
80612B08:  FC010040   fcmpo   cr0,f1,f0
80612B0C:  40800010   bge-   0x80612b1c
80612B10:  C01E00D4   lfs   f0,212(r30)
80612B14:  EC010032   fmuls   f0,f1,f0
80612B18:  D01801E4   stfs   f0,484(r24)
80612B1C:  881801C4   lbz   r0,452(r24)
80612B20:  28000001   cmplwi   r0,1
80612B24:  40820010   bne-   0x80612b34
80612B28:  881801C5   lbz   r0,453(r24)
80612B2C:  28000046   cmplwi   r0,70
80612B30:  41820024   beq-   0x80612b54[/spoiler]


You can pm me, I've got time for your troubles.

Patedj

#34
I'm putting the first version in
04612A3C EC230828
28215000 00000C00
C2612A3C 00000001
EC23082A 00000000
E0000000 80008000

next version implies a new stack.
ASM:address: no matter where I put it it doesn't seem to work.
stwu r1,-16(r1)
stw r11,8(r1)
lis r11, 0x8061
ori r11, r11, 0x2A3C
lis r12, 0xBDCC
ori r12,r12,0xCCCD
lfs f3,0(r12)
fadds f1,f3,f1
lwz r11,8(r1)
addi r1,r1,16
nop
i did this because I wanted the moon jump to be smoother (slower) so I thought a smaller f3 would do the trick.
You can pm me, I've got time for your troubles.

dcx2

lis r12, 0xBDCC
ori r12,r12,0xCCCD
lfs f3,0(r12)

Will crash

0xBDCCCCCD is not a valid pointer.  lfs doesn't work that way.  It will load the 4 bytes at the address into the specified float register.  That's why you need the bl trick - you need an area of memory where you can load your float from.

Deathwolf

Quote from: dcx2 on March 19, 2011, 04:59:39 PM
lis r12, 0xBDCC
ori r12,r12,0xCCCD
lfs f3,0(r12)

Will crash

0xBDCCCCCD is not a valid pointer.  lfs doesn't work that way.  It will load the 4 bytes at the address into the specified float register.  That's why you need the bl trick - you need an area of memory where you can load your float from.

Why lfs? lwz or stw works the same way  :-\
BTW How does this work?  :eek:

stwu r1,-16(r1)
stw r11,8(r1)
lis r11, 0x8061
ori r11, r11, 0x2A3C
lis r12, 0xBDCC
ori r12,r12,0xCCCD
lfs f3,0(r12)
fadds f1,f3,f1
lwz r11,8(r1)
addi r1,r1,16
nop

Why are you loading into an address? You already have a hook address at the begining of C2?! I think this doesn't work. Please correct me if I'm wrong but I already tried this and nothing happened.
lolz

Patedj

#37
I forgot to store it into a float. It was 12am and my brain shut down I went to bed after that. I did think of that float trick though, so thanks dcx2 I'm glad I was right. It's always nice getting confirmation!

so the bl trick is the same as what dcx2 taught me for eldar saga's moon jump.
http://wiird.l0nk.org/forum/index.php/topic,7858.msg66288.html#msg66288
IE:
[spoiler]4E00000C 00000000 # put a pointer to the float in po
ASM here               # hook that constantly adds float to Y axis
14000000 00000000 # make hook add 0.0
283CB80A BFFF4000 # if holding C
14000000 42C80000 # make hook add 100.0
E0000000 80008000 # terminator
ASM:bl NO_DATA
.float 14
NO_DATA:
mflr r12
lfs f0,0(r12)
lfs f26,448(r1)
fadds f26,f0,f26
stfs f26,448(r1)
[/spoiler]

Here it is for Okami. But has to be revised b/c it doesn't work, the avatar vanishes.
[spoiler]code:
4E00000C 00000000
C2612A44 00000004
48000009 3F800000
7D8802A6 C06C0000
C01801E4 EC00182A
D01801E4 00000000

14000000 00000000
28215000 00000C00
14000000 42C80000
E0000000 80008000

asm:(address 80612A3C :stfs f0,484(r24) )
bl NO_DATA
.float 14
NO_DATA:
mflr r12
lfs f3,0(r12)
lfs f0,484(r24)
fadds f0,f0,f3
stfs f0,484(r24)
[/spoiler]
You can pm me, I've got time for your troubles.

dcx2

lfd = load float double-precision.  double = 8 bytes.

lfs = load float single-precision.  single = 4 bytes

You're mixing lfd (load float double), fadds (float add single), and stfs (store float single).  This may or may not cause problems, I'm not 100% sure.

Patedj

Quote from: dcx2 on March 19, 2011, 11:02:40 PM
lfd = load float double-precision.  double = 8 bytes.

lfs = load float single-precision.  single = 4 bytes

You're mixing lfd (load float double), fadds (float add single), and stfs (store float single).  This may or may not cause problems, I'm not 100% sure.
Ha! Of course!
see edited version below. Bolded areas are revised.
You can pm me, I've got time for your troubles.

Patedj

#40
There's one thing that I'd like to mention, this makes him fly, not moon jump. How do I go about converting the code for a moon jump instead dcx2?

making a negative float would work no?
Yes it did!!
YAY! My first working 3d Moon Jump code

Moon Jump Okami v3
4E00000C 00000000
C2612A44 00000004
48000009 3E800000  ----> changing this float value will change the avatar's place in space
7D8802A6 C06C0000
C01801E4 EC00182A
D01801E4 00000000
14000000 BF800000  ---> negative float to stick him on the ground
28215000 00000800
14000000 3E800000 ---->  changing this float value will accelerate/decelerate the jump
E0000000 80008000

What's bolded is recommended
You can pm me, I've got time for your troubles.

Deathwolf

bl NO_DATA
.float 14
NO_DATA:
mflr r12
lfs f3,0(r12)
lfs f0,484(r24)
fadds f0,f0,f3
stfs f0,484(r24)

what does the bl NO_DATA do? is it something like THE_END ?
lolz

Patedj

This is a way to easily calculate the branch that is needed.

so this branch will not execute the data underneath the NO_DATA: section
You can pm me, I've got time for your troubles.

Deathwolf

#43
is it a if-instruction? what does it actually do? execute if equal?
lolz

Patedj

#44
Edit: Exactly! It's a conditional branch.
You can pm me, I've got time for your troubles.