Now, to change your sprites! :)
First, find out the sprite number of the sprite you wanna use in place of whatever existing sprite there is. You get this number by looking through your Keen4 directory and noting the filename. For example, Keen facing right while standing is 4SPR0006, while a Berkeloid facing left about to throw a fireball is 4SPR0387. That number at the end is your sprite number. Keen would be 6, the Berkeloid woudl be 387. We'll use the Berkeloid for this example.
Take your sprite number (387) and add 124 to it, (511,) then convert this new number to HEX (1FF). Turn this into a 2-byte word (01FF = $FF $01) and make note of that.
Next, open your Keen4 disassembly, and open that Actions.doc file. Scroll down and find the action(s) you want to replace. In this example, we'll mess with the Poison Slug. Looking at it, you'll see something like this:
Code: Select all
ACTION slug_actions[] = {
/* Slug moving routine */
/* AZ.2012 */
{ 320, 315, 0, 0,
1, 8, 64, 0,
NULL, K:03EA, G:1847,
&slug_actions[A_SLUG_MOVE+1]
},
/* AZ.2030 */
{ 321, 316, 0, 0,
1, 8, 64, 0,
K:0369, K:03EA, G:1847,
&slug_actions[A_SLUG_MOVE]
},
More importantly, we're given two numbers: For the first of the frames of the walk animation, they're 320 and 315. The first, 320, is the sprite number for the Slug moving Left (we can confirm this by doing 320-124=196, which is indeed the "Slug moving left" sprite in our Keen4 folder) ...and the second, 315, is the Slug moving Right. We're gonna patch those numbers to our new ones.
But we need an address!!
See that AZ.2012 up there? Take the 2012 part, and Add 2EE70 in HEX ( 30E82)... that's your patch for facing left, and the value two bytes later (30E84) will be your patch for facing right.
In this example, to conclude, we'll make the left-moving Poison Slug use the "Berkeloid pausing to throw while facing left" frame (#387) for the first of its two-frame walk animation:
Code: Select all
%patch $30E82 $FF $01
Also, most importantly, YOU MUST PRE-CACHE YOUR SPRITES. I had to test this example at the Island of Fire, because it has Berkeloids and Slugs in the same place.
Maybe someone else can figure out precaching, to help alleviate this burden. :)
Here's the patch I used while testing this:
Code: Select all
#Poison Slugs, when stunned, look like Berkeloids about to fire Left.
%patch $30EDC $FF $01 #stun type A facing L
%patch $30EDE $FF $01 #stun type A facing R
%patch $30EFA $FF $01 #stun type B facing L
%patch $30EFC $FF $01 #stun type B facing R
Code: Select all
ACTION slug_actions[] = {
/* Slug moving routine */
/* AZ.2012 */
{ 320, 315, 0, 0,
1, 8, 64, 0,
NULL, K:03EA, G:1847,
&slug_actions[A_SLUG_MOVE+1]
},
/* AZ.2030 */
{ 321, 316, 0, 0,
1, 8, 64, 0,
K:0369, K:03EA, G:1847,
&slug_actions[A_SLUG_MOVE]
},
Start with the HEX address we'd need to change the animations (in this case, 30E82 for L, 30E84 for R) and add 10 (0A in HEX) to it. So to change the duration for that first walk frame, we'd patch to 30E8C.
The easiest way to think about this is that each of the commands between commas is a two-byte word. So starting at location 30E82, we have:
320, 315, 0, 0,
1, 8, 64, 0,
So in the HEX, it would look like
$20 $03 $15 03 $00 $00 $00 $00
$01 $00 $08 $00 $64 $00 $00 $00
Which is why we add 10 (0A) to the starting location.
For reference, the length of time Keen spends looking up into the sky during his idle sequence is 30, while the time he spends reading his book (before turning the page) is 300. :)
So, to make that Slug spend more time crawling, we'd patch:
Code: Select all
%patch $30E8C $16 $00 #Slug animation speed, frame 1 (default $08 $00)
%patch $30EAA $10 $00 #Slug animation speed, frame 2 (default $08 $00)