Kodewerx

Our culture has advanced beyond all that you could possibly comprehend with one hundred percent of your brain.
It is currently Sat May 04, 2024 11:06 am

All times are UTC - 8 hours [ DST ]


Forum rules





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Wed Apr 22, 2009 11:21 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
I finally got around to fixing that stupid Jesus Mode code. It's been broke since I made it. I only tested the thing in Kokiri forest as young link. Using it anywhere else made Link jump WAY up in the air when he hit the water. Annoying. Today I finally got around to looking at the code again to figure out WTF.

The original code did some fun FPU maths to approximate the correct "ground" coordinate based on the water level. As it turns out, the water level is always the same, no matter where you go: 32.0.

However, the ground level (ground's Y-coordinate) does not match. In Kokiri Forest, the code sets the coordinate to -12.0 which is perfect for walking on water in that area. In the Great Deku Tree, the Y-coordinate must be set to -896.0! Seriously, what the fuck?

After several hours trying to figure this thing out, I eventually came to realize that the water level doesn't change because it's the actual point of reference for the collision detection. Magically, right next to the ground level is the water level offset... I don't know what else to call it, but the closer that offset is to 0, the closer Link is to the water level. Basically what we want is that ... when it hits 0 (or below), we want to bump the ground level up so that the water level offset remains exactly at 0. Since I couldn't find any reliable way to convert the water level point of reference (or offset) to a proper ground coordinate, I decided the next best thing would be just adding the water level offset to the ground level when the water level offset is below 0. (Yeah, I also won't have any idea what the hell any of this means when I come back and reread it later.)

Anyway, that's all the new code does. If I'm lucky, it will also work as adult Link, but I'll never know until someone can test it. :x But here it is, in all its glory, and 8 lines shorter than the original. Hooray optimization and bug fixes++!

Except, it does have one bug I noticed. :( Exiting the Great Deku Tree makes Link jump a bit. I think that probably happens because you exit the Great Deku Tree at a position lower than the water level in the area (but this should not matter -- the water is in a totally different part of the map. This game is not like Mario 64, where the water level is the same everywhere in the map. The game engine is more advanced. It's actually the same game engine between the two games, just Zelda's is greatly updated... *sigh*) Maybe that can be fixed somehow, too. But it's going to add a few more lines to the code again, crap.

Code:
Jesus Mode v2.0
81021CC0 0800
81021CC2 00CC
81000330 3C08
81000332 801E
81000334 2508
81000336 AA30
81000338 1510
8100033A 000C
8100033C 3C08
8100033E 4200
81000340 4488
81000342 4000
81000344 8E08
81000346 0668
81000348 C50C
8100034A 002C
8100034C C604
8100034E 0084
81000350 4608
81000352 2280
81000354 460A
81000356 603E
81000358 4500
8100035A 0004
8100035C C608
8100035E 0080
81000360 4608
81000362 003E
81000364 4503
81000366 0001
81000368 4604
8100036A 4000
8100036C 0800
8100036E 8732
81000370 4602
81000372 003E

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 23, 2009 5:38 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
Based on how v2.0 works, it may take a few frames for the ground level to rise to the water level. :( If you jump off a ledge into very deep water, it may even take a few seconds? Can someone test it in Lake Hylia?

For v3.0, I should investigate the possibility of adding the water level offset to Link's Y-coordinate, and using that as the new ground level. If it works, it should be "perfect" with no frame delay, like v2.0 has. Also, I need to fix the bug that causes Link to jump when exiting the Great Deku Tree... ugh.

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 23, 2009 7:54 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
Bad news! When jumping into deep water with v2.0, it can take up to 5 seconds for the ground level to catch up to the water level. So Link will jump in the water and swim for a little bit and then gain Jesus-like powers and begin walking on water.

Good news! I was right! I can use Link's Y-coordinate instead of the current ground level to set the new ground level to the water level. Actually, I had to set it to Y-coordinate + 7.5. Go figure. But now the ground level will be set correctly within 3 frames of touching the water, no matter how deep the water is, and no matter what the real water level is.

While I was at it, I also found a simple solution to the jumping problem when moving between some areas (like exiting the Great Deku Tree, and entering Queen Ghoma's lair). The fix just involves checking the current ground level. If it's 0, ignore it...

And here's v3.0, probably going to be totally final. (Hooray! It's only two lines longer than the original code! And it actually works this time!)
Code:
Jesus Mode v3.0
81000330 3C08
81000332 801E
81000334 2508
81000336 AA30
81000338 1510
8100033A 0011
8100033C 8E08
8100033E 0080
81000340 1100
81000342 000F
81000344 3C08
81000346 4200
81000348 4488
8100034A 4000
8100034C 8E08
8100034E 0668
81000350 C50C
81000352 002C
81000354 C604
81000356 0084
81000358 4608
8100035A 2280
8100035C 460A
8100035E 603E
81000360 4500
81000362 0007
81000364 C608
81000366 0028
81000368 3C08
8100036A 40F0
8100036C 4488
8100036E 5000
81000370 460A
81000372 4200
81000374 4608
81000376 003E
81000378 4503
8100037A 0001
8100037C 4604
8100037E 4000
81000380 0800
81000382 8732
81000384 4602
81000386 003E

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 24, 2009 3:45 pm 
Offline
Kommunist
Kommunist

Joined: Sun Oct 01, 2006 11:05 pm
Posts: 68
Nice :)

This gives me even more info concerning the coordinate system and its behavior and interaction with other elements. Now, whenever I get around to hacking OoT again, it will be that much easier to toy with swimming everywhere.

_________________
I may be lazy, but I can...zzzZZZzzzZZZzzz...

GameHacking.org


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 08, 2009 6:13 am 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:46 pm
Posts: 2331
Location: *poof*
Title: The Mad Hacker
I enjoyed reading your post.

Jesus WIP
Image

Unfortunately, your post wasn't actually much help for Majora's Mask (though I was expecting it would be..).
That screenshot relies on only 2 pokes. Of course, with simplicity like that, there's like 200 side effects and it only works there.
I'll have to work that out. hahah

_________________
Image


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 08, 2009 5:05 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
Nice...

If you think it will help, I can try to dig up my notes from hacking the code for Ocarina of Time.

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 09, 2009 3:26 am 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:46 pm
Posts: 2331
Location: *poof*
Title: The Mad Hacker
Much appreciated, but I have it working now.
Though the original route I was taking will lead to swim anywhere and walk under water (with significantly fewer side-effects), it wasn't so great for Mr. Christ. So I found the water offset you spoke of directly next to the ground coord (which I stumbled on when I was screwing with the camera a couple weeks ago) just as you said it would be; The rest was easy.

But, because I'm hacking it emulated via Wii VC, the ASM tends to move wherever it pleases without any sign of a pointer. I wrote an asm routine (previously) to find and dump a pointer to such asm using a simple xor checksum of the target, provided the number of words it includes and a search range. It only updates the pointer when the routine has moved so there's no lag. (it costs ~15 lines but it also makes it region free, so... win?)

I just have to add that 7.5 now and I'll be finished. Because of the (unusually?) large amount of nop instructions in the game, there is exactly enough room to fit the modification into the programing (after sliding a few instructions around to close the gaps).

_________________
Image


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 09, 2009 4:26 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
Sounds reasonable. You're welcome to port the code to N64, as well. *hint* I probably won't do it.

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 09, 2009 5:12 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:46 pm
Posts: 2331
Location: *poof*
Title: The Mad Hacker
Meh. I don't have a working GS or any emulators so it's very unlikely I'll do it either.

Here's the asm from Majora's Mask as it is on the Wii, if it will make porting it easy for anyone interested.

54A5024E rlwinm r5,r5,0,9,7
90A30A54 stw r5,2644(r3)
7274FF79 andi. r20,r19,65401
80C300DC lwz r6,220(r3)
7CE64214 add r7,r6,r8
80A3015C lwz r5,348(r3)
90A70088 stw r5,136(r7) #writes to the current ground level (only one)
4800000C b 0x80ae4298
60000000 nop
60000000 nop
80E300DC lwz r7,220(r3)
7CE74838 and r7,r7,r9
7CE74214 add r7,r7,r8
B2870090 sth r20,144(r7)
48000008 b 0x80ae42b0
60000000 nop

stw r5,136(r7) is hijacked with the code:
Code:
lis r28,0x8000
addi r28,r28,0x3A2C   #just a free spot to add an enable/disable option
lfs f11,140(r7)    #offset to water
lfs f15,0x0(r28)   #(float) between -7.5 and 0. OR +2087 to disable the effect
mcrf cr4,cr0
fcmpo cr0,f11,f15   #offset vs -7.5
lfs f15,348(r3)    #real ground coord
ble 0x10   #if gt, touching water
  lfs f11,268(r7)   #link's current coord
  fcmpo cr0,f11,f15
  bge 0x8   #if link > ground, use link
fmr f11,f15
stfs f11,136(r7)
mcrf cr0,cr4
#return to hijacked +4

_________________
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group