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

The Bounder kills Keen

Post by XkyRauh »

Hooray for being able to patch segments! :)

Code: Select all

#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
It all worked smoothly enough for me in my playtest... of note is that during the Bounder's "standard" shot code, three different variables are set to 0. I've overwritten this section of code with our new "collide with Keen" check; please be sure to report any abnormalities this may have caused. :) I'm not entirely clear what the three zeroed out variables do!
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Damn you Andy! You said it was $9A, not $75! No wonder my stuff didn't work!

Good on you Xky, those variables just change a few of the sprite's integers; it's not a problem, unless you start having trouble with those knocked out stars.

My approach to this was to replace the Bounder's code with that of the flaming lick, it would've worked too had I been given correct advice! (Glare!)
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

levellass wrote:Damn you Andy! You said it was $9A, not $75! No wonder my stuff didn't work! ... (Glare!)
:-)

To be fair, I was talking about call far when I said $9A, which you can also see in the patch above:

Code: Select all

#Patch in the "Kill Keen" subroutine, and close out the code 
%patch $11148 $9A $0B8013E9RL $5F $5E $5D $CB
There are two common call opcodes, and 12 common jump opcodes (at least 7 rarer ones):

Code: Select all

# I'll use 00 for all addresses
# Except for $9A (CALL FAR), all addresses are relative to the next instruction

$E8 $0000       CALL: Call near
$9A $00000000   CALL FAR: Call far; address is absolute

$72 $00      JB: Jump if below
$73 $00      JAE: Jump if above or equal
$74 $00      JE: Jump if equal
$76 $00      JBE: Jump if below or equal
$77 $00      JA: Jump if above
$7C $00      JL: Jump if less
$7D $00      JGE: Jump if greater or equal
$7E $00      JLE: Jump if less or equal
$7F $00      JG: Jump if greater
$75 $00      JNE: Jump if not equal
$EB $00      JMP: Jump short
$E9 $0000    JMP: Jump near
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

For our education, the difference between a JUMP near and a CALL near is that the JUMP is relative (something like +30, or -10) while the CALL is specific (go to line 04AB, or 011F), correct?

...Your comment in the post above says that "all are RELATIVE except call far." What would the difference between CALL near and JUMP near be, then? :$
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

XkyRauh wrote:For our education, the difference between a JUMP near and a CALL near is that the JUMP is relative (something like +30, or -10) while the CALL is specific (go to line 04AB, or 011F), correct?
Incorrect; the CALL near address is also relative.
What would the difference between CALL near and JUMP near be, then? :$
A CALL instruction saves the return address onto the stack, so the corresponding RET instruction knows what address to return to. (and if there's isn't a corresponding RET instruction in the called function, you can be sure there'll be a crash fairly quickly).

In general you'll find that CALL is used to call other functions, whereas the various jump instructions are used within a single function, though there may be a few exceptions.

Incidentally, when you're looking at the disassembly, you'll find that although the bytes making up the address for a CALL near or a jump instruction are relative, the disassembled code will show the actual destination address as computed by the disassembler, for example:

Code: Select all

A.0000 EB 00    JMP 0002
A.0002 ...
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

All this is needless complication, Intel really knew how to inbreed their functions if you ask me.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

Not at all; it's the difference between GOTO and GOSUB. :) That is, if I'm understanding it right. Thanks, Andy!
User avatar
ckguy
Posts: 465
Joined: Tue Oct 14, 2003 11:20 am
Location: Wakefield, RI, US
Contact:

Post by ckguy »

XkyRauh wrote:Not at all; it's the difference between GOTO and GOSUB. :) That is, if I'm understanding it right. Thanks, Andy!
Ah yes, the BASIC analogies to stuff ... they're always great.
levellass wrote:All this is needless complication, Intel really knew how to inbreed their functions if you ask me.
Ah yes, LLa's opinions on stuff ... they're always great.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

CK Guy posted
Ah yes, elitist posts that don't contribute much... they're always great. :(

I know BASIC is a "beginner" language and all, but comparison is a great method of communicating information. Saying that something "tastes like chicken" is often a whole lot more informative than saying "it's a juicy, tender, soft meaty flavor" and the like.

I'm probably overreacting.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I was talking about the 'if less than, greater than, equal to OR greater than' seriously, too much information. Maybe I'm stupid, or maybe I preferred the old languages, that used combinations of simple, easy to remember functions. I like the fact that you can combine AND, OR NOT and such gates in neat little arrays to complete any function you desire.

Do we really need all those jumps? Whoever was in charge of that was a manager, I just know it.
User avatar
ckguy
Posts: 465
Joined: Tue Oct 14, 2003 11:20 am
Location: Wakefield, RI, US
Contact:

Post by ckguy »

Shit. I feel like an asshole now. (Go ahead and censor my post. I don't know how else to say it.)

I honestly did not mean to sound elitist in that post, though I realize now that's of course how it sounded. I don't care if you think it's overreacting; I'm glad you said something.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

levellass wrote:I was talking about the 'if less than, greater than, equal to OR greater than' seriously, too much information. ... Do we really need all those jumps? Whoever was in charge of that was a manager, I just know it.
Just to clarify: since a 16-bit integer can be signed (-32768 to 32767) or unsigned (0 to 65535), there are separate sets of jumps for each. The below/above pairs are used if two unsigned integers are compared, and the greater/less pairs are used if two signed integers are compared.

As for the remaining variety, way back when the first x86 processors were designed it actually made a lot of sense to have more instructions; since clock speeds were so slow, you could have smaller (and hence faster) code by using a single instruction to do the jump you needed.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Hmmmn, I keep having problems with this patch; for some reason the 'remove shot' part causes a whole string of animations to appear until an uncached sprite is found. I have to use my version:

Code: Select all

%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 
I've had this problem before with some of my collision patches, but I can't for the life of me remember what caused it; has anyone else had this glitch?
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

Post by XkyRauh »

There's a subroutine that removes the sprite in question... before it comes up, the sprite has to be pushed, and then the subroutine (call_far whereever) has to be called. Chances are you didn't push the sprite. I encountered it a few times, when I was trying to find a way around our lack of call_far before the new CK4Patch.

CKGuy: Don't sweat it. :) It's water under the bridge.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Explain sprite pushing; will my patch have the same error? I dislike uncertainty.

And CK Guy, Xky is right, we've all passed a lot of water in our time.
Post Reply