The IMPROVED Gravity Patch

Completed patches for Keen1.
Post Reply
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

The IMPROVED Gravity Patch

Post by lemm »

EDIT: Sep. 2, 2009. Now it modifies the actual gravity.

Code: Select all

%ext ck1
%version 1.31

%patch $2C37 $03	  #acceleration

%patch $2C3C $C8 $00   #max gravity
%patch $2C44 $C8 $00


%end
Last edited by lemm on Wed Sep 02, 2009 2:57 pm, edited 1 time in total.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Very juicy! I didn't think the level had a y-variable! Now all we need is to be able to change gravity on certain levels.

EDIT: You should also indicate if your patches are incompatible with others you have made. (For example the custom palette patch is incompatible with the status box patch, if I recall.)
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

Post by lemm »

You get a buggy zero-gravity if you replace the relevant line with:

Code: Select all

%patch $55F1 $B8 $F780W		# mov ax, $0000W
However, every time a sprite hits the ground, it jumps, and sprites get stuck on the ceiling, similar to how they get stuck on the wall if the "breeze" is too strong, even if their maximum speed is faster than the breeze.[/code]
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

That's interesting; I wonder why? I do know some sprites have a zero speed if they hit tiles (This results in the Vorticons sometimes getting 'stuck' in a wall.
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Hmm, maybe there's a loop that detects the ground by checking where Keen would theoretically fall next using the current velocity, and then subtracts from that value until it's not inside a tile? I don't know anything about how the game handles gravity, but this is a possible scenario.

At any rate there's evidently something else that needs to be patched besides a gravitational constant.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Well, I do know that the gravity/falling is separate from checking for floors/ceilings, since I've turned off the gravity for various sprites. (Or at least a small subroutine that when unpatched,, makes them fall.) so who knows? This is getting interesting.
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

The IMPROVED, ERROR FREE gravity patch

Post by lemm »

UPDATE: look at the original post. This was actually an incredibly easy patch :p


What I was doing before was altering the map-positions of all sprites AFTER the collision detection etc had been calculated, so that's why the game was screwing up. This patch just modifies the acceleration and the maximum speed. In fact the gravitational constant WAS the only thing that needed patching ;-).


Levellass, you are right, there are two subroutines. This patch modifies the relatively straightforward do_fall() subroutine (0x2C2A). The other subroutine is check_keen_ground() (3f8b), which does the tile collisions by calling another subroutine and is horribly complicated and probably not a good idea to mess with.

There is also a check_ceiling() (0x3365), but I think this just deals with checking the invisible map ceiling as I don't see any references to the tile data.

Finally, if you are wondering about the game loop, I am starting another thread right now in K:V discussion.
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Sveet. Applause to thee!
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

Hmm, any idea on how to do this for specific sprites? I managed it with the gargs recently, with similar issues that you described with the previous version of this patch. But I don't quite recall how.
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

Post by lemm »

At the end of each think function for that sprite, right before the call to do_fall(), add a value to ds:8240, which is the y_velocity for the current sprite being modified.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Lem, Check_Ceiling does indeed push Keen down if he tries to exit non-map levels through the top. If you remove the push-down-ness of it, Keen dies by falling off the top of the level. Lol.

I have kept the breeze patch, but also added this new gravity patch; oddly enough it's been stumbled on before, by me, LL and Andy while trying to do other things. (I KNEW I recognized that line!) But this is the first time something functioning has been made.

Spleen: If you get precise patches, post them here!
Post Reply