The Bounder kills Keen

Completed patches for Keen4.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

Ugh. I'm not even sure how to describe it... basically, you have to make sure you PUSH the variables involved with the subroutine right before the subroutine gets called with the CALL_FAR.

If you want to do a GOSUB CheckBounderCollision(bounder, object), you have to make sure you make ax = bounder, bx= object, push ax, push bx, and then call_far CheckBounderCollision.

I'm not even sure that's completely correct--it's just what I've observed, looking through the code. Every time you want to run a subroutine, you've gotta make sure to tell the code what variable to use the subroutine ON first. :)

Edit: Chances are the reason you're having a problem with your code is that you're not PUSHing the variable involved... you're just calling the routine, which is running with whatever unrelated value is in there at the time.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

No, I'm having trouble with *your* code, not mine, but the problems with your code are erratic, I still don't understand what's wrong, but it seems to be something to do with the 'Keen's shot smash subroutine'

I can see what you mean, but it doesn't seem to be the problem, though again, I have no idea, all I can do is observe.

Oh and while I'm at this, does anyone know what differences there are between the 'jump if above' and 'jump if larger' kind of jumps? Are they used say, for different kinds of variable?
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

levellass wrote:does anyone know what differences there are between the 'jump if above' and 'jump if larger' kind of jumps? Are they used say, for different kinds of variable?
The greater/less jumps are for signed integers (-32768 to 32767 in the case of a 16-bit integer), while the above/below jumps are for unsigned integers (0 to 65535).
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

LL: You're having problems with the patch posted at the start of this thread? What happens?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Whenever I use this the 'Keen's shot hit' animation runs through all of its frames, but doesn't stop, showing me various Keen animations before finding an uncached sprite and causing the game to crash. I'm not sure why, but for me this 'works' only on medium and hard difficulties. (THe killing Keen part works fine as far as I can tell.)
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

That's really weird--it works identically on all three difficulties for me. I'd say go back and make sure you're not patching multiple things in the same area, or to double-check your TED5 enemy placement... but I'm really not sure.

Could you email me your .PAT file, so I could look at what all you're doing? I doubt I'd be able to figure it out, but I don't have any sprite cycling happening on my end.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

This is the full text of my .PAT file:

Code: Select all

%ext ck4

#Let's make the Bounder kill Keen
#Change the collision check from "is it a shot?" to "is it Keen?" (03 to 02)
%patch $11145 $02
#Change the amount to skip if it's NOT a 'hit' (skip over relevant code)
%patch $11146 $75 $09
#Patch in the "Kill Keen" subroutine, and close out the code
%patch $11148 $9A $0B8013E9RL $5F $5E $5D $CB
#New collision check: "is it a shot?" (03) and If not, skip XX bytes.
%patch $11151 $83 $3D $03 $75 $23 $90

%patch $33234 "Id Software - '91" $00
%patch $33274 "     D           " $00
%patch $332B4 "Jason Blochowiak " $00
%patch $332F4 "Adrian Carmack   " $00
%patch $33334 "John Carmack     " $00
%patch $33374 "Tom Hall         " $00
%patch $333B4 "John Romero      " $00

%end

I always test patches in isolation on a normal copy of Keen 4 before adding them to any mod and retesting. I can get you a video of the error if you like.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

I'm getting the same error, now, on a clean copy of 4. Looking through my own patch file, I don't SEE anything that's changed, so this is a mystery to me, but I'm working on it.

Edit: Okay, I've gotta start from square one with this patch. Dang. I wonder why it works with mine just fine? :(

Alright, long story short, when the Bounder is killed, three variables [si+38, 40, and 42] are set to 0. I was gambling that those changes weren't crucial to the Bounder's death routine, and stuffed in a quickie little "Are we hitting Keen? Kill him! If not, move on" check (took 14 of the 15 bytes that the 3 variables-to-zero code used)... and on my version, with new/changed sprites and whatever, it works great. On core Keen4? Weird sprite cycling errors. I've got no idea why; I don't have any other patches affecting the Bounder in my book.

Since we need to leave those variable changes intact, the only other solution we've got is to dip into the "Is Keen standing on us?" code, which is later in the Bounder's sequence. I'm gonna do some down-and-dirty "GOTO" work to try and get this working. Wish me luck :)

Edit2: CALL NEAR and RET ($C3) aren't doing the trick. Keen's just killing himself.

Edit3: Son of a gun! I can't get this to work. Yet. Gimme 'nother few days. I spent 3 hours on it today, no luck.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Well, my patch seems to work well enough, so I don't need this; though sadly while it safely avoids the setting problems, it doesn't make it jump into the air if shot right. (Actually, there's a way around this too, but who needs it?)

Those variables are annoying though; I'm looking into the shot code at what the hell they do, have you had anything that suggests clipping and those boundary boxes? I have.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

Why don't you post your patch, so we can have it as an alternative. I'll have a new patch just as soon as I can figure out how to get the JUMP NEARs to cooperate. I tried doing it with a CALL NEAR, which worked fine, except shooting the Bounder killed Keen, not the Bounder! :O I spent a while fudging it, but got nowhere. I need to learn how the E9 and E8 and EB work better.

I think the three variables being set to 0 are indeed the clipping, and the stand-on-top-able-ness of the Bounder. :) Not sure, though. I'm never as good at figuring this stuff out as I think I am.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I did post it, many, many replies ago, you even asked if I was having some problems with it. It's larger, though more compact than yours, so I guess it's easy to miss. Here is is again:

Code: Select all

#Bounder kills Keen, can be shot:
%patch $11138 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $09
              $9A $0B8013E9RL $5F $5E $5D $CB $83 $3D $03 $75 $18 $C7 $44 $16
              $00 $00 $C7 $44 $06 $01 $00 $B8 $A8 $2F $50 $57 $56 $9A $09DC1695RL
              $83 $C4 $06 $5F $5E $5D $CB
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

That's really elegant. May I ask how you decided on those specific changes?

The original shot-Bounder code sets 3E, 40, and 42 to 0000, then pushes di, calls a subroutine, pushes si and calls sub305.

By comparison, your shot-Bounder code sets 16 to 0, 06 to 1, then pushes di and si and calls sub305.

You completely skipped a subroutine, and didn't set any of the 3 variables to zero... what are you bypassing, and why does it work? :O
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

The original shot Bounder code, apart from having code telling it to jump in the air when shot, also sets 3E, 42 and 40 to 0 because the stunned Bounder is essentially 'inert' it isn't supposed to interact with anything and having these three variables set to 0 ties up all the lose ends, the Bounder will now sit there until the level is done.

What I did was make the stunned Bounder behave like any ordinary sprite. I had to make sure the game knows it's stunned (For those little stars to appear.) but otherwise the Bounder could get back up and start animating, *if* you gave it an animation speed and new action to use. While not as 'clean' as what the game does, from our viewpoint it doesn't matter. This same code can be used for any (Well most) other sprites to overwrite their shot behaviors, but I think if too many appear in the level problems may ensue.
User avatar
Flyingmouse
Posts: 104
Joined: Wed Aug 05, 2009 8:33 pm
Location: Procrastination

Post by Flyingmouse »

The game won't even open due to the "$0B8013E9RL" being called a numeric error. Any idea what's wrong?
Mink
Posts: 192
Joined: Sat Nov 03, 2007 4:08 pm
Location: Providence, RI, US

Post by Mink »

Flyingmouse wrote:The game won't even open due to the "$0B8013E9RL" being called a numeric error. Any idea what's wrong?
Are you using adurdin's most recent version of CKPatch, which can handle patching relative addresses? If not, you can download it here: http://files.keenmodding.org/ckpatch-0.10.0.zip
Post Reply