Ice canon help

Request patches for Keens 1-3.
Post Reply
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Ice canon help

Post by levellass »

Now I've been poking about the Ice Cannon code in Keen 1, and I think I've found what differentiates the various cubes from one another:

Code: Select all

#List of cube types, start and length
%patch $2102 $2149W  $81 $44 $0004W $10 $83 $54 $0006W

The first word says where the list of types can be found. This list is a collection of locations where the actual code can be found for each icecube:

Code: Select all

#Cube behavior list
%patch $2148 $00 $2104W  $2119W  $2125W  $2131W

This is easy to modify, changing the location of the list allows me to slot it anywhere I like and potentially make many more types of icecube.

The second word is how long the list is, in words, the third what sprite number the icecubes start at. (Thus cubes are sprites 6, 7, 8 and 9.) Modifying *those* I can make as many or as few different cube types as I want and have space for.

HOWEVER; when I alter these two words... nothing changes. If I mess up the code, the game crashes, but entering insane values for the 2nd and 3rd word seems to have no effect at all. Is this something wrong with my patch setup? If not, why aren't these two values doing what I KNOW they must? Can anyone explain?
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

Basically, you've gone too far. The patch at $2102 is leaking into the first jump table target. Those values are offsets into the sprite structure (X position to be exact).
Here's my take on that patch:

Code: Select all

#cube type
%patch $20D6 $000FW
#length of jump table
%patch $20F6 $0003W
#address of jump table
%patch $2102 $2149W
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

When I dump my executable and take a look see at it I get $000F at $20D6, that patch has been correct for years. $2102 is also fine. However $20F6 is $5E $0C, which doesn't look right.

Also the cube type doesn't affect what sprite number placed in the level becomes an icecannon; $0006 looks like the right value.


$20FA\$03 works however. So this leaves me with the question, where is the sprite number thingy?
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

Sorry about $20F6, $20FA is definitely what I meant to post.

I'm not sure what you mean by cube type. I'm looking at the disassembly of the entire cube spawning routine, and there's no such thing. They are only given different initial velocities, after which they all execute the same code.

If you meant cannon types, that's handled by the level load routine.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Yes.

Somewhere there must be a variable that says 'This cannon is type 1, this one type 2...' and it should be based on the value of the sprite placed in the level (Sprite value 6 makes a canon of type 1, 7 is 2, etc...)
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

That's done in the level_init routine. As written you can easily change two of the sub-type numbers:

Code: Select all

%patch $1698 $0001W
%patch $16A6 $0002W
Type 0 is a special case, I think it would be necessary to to patch $168A to jump to a routine elsewhere.
To change the sprite plane ids:

Code: Select all

%patch $1636 $09 #Type 0
%patch $163D $07 #Type 1
%patch $1642 $08 #Type 2
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

*Thinks*


Right, so those sub-type things, how they relate to say the Yorp's code at $1680? I take it that they simply take the sprite value and go 'This is Ice Cannon type...'? I am curious why only sprites up tot he Tank robot are listed at $1709.

The type 0 thing is easy enough to fix; it's just using a shortcut and my sprite spawning patch does some pretty heavy rearranging.


Now how do these sprite plane ids work? I must admit I am not too sure what I would be changing there.
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

If by "relate to" you mean how does the code vary, cannons take an additional parameter containing the sub-type, which must be pushed on the stack first. (The patches I've posted change the constant that is loaded into ax, which is then pushed to the stack.) Of course, it also calls a different function than the yorp does.

I really can't say why the cannons aren't set by the jump table at $1709, that's just the way it was done. The sprite plane IDs above 5 are all special cased.

The sprite plane IDs are the IDs sprites have in level editors, such as 1 = yorp, 255 = Keen, etc. I don't know why they would need to be changed, I just included them for completeness. The way the code works, you could only change the cannons to something greater than 6.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

This solves my problems and sets me towards making an easier to edit version of the code. Many thanks for your assistance sir!
Post Reply