Pre caching sprites

Completed patches for Keen4.
Post Reply
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Pre caching sprites

Post by levellass »

I figured people would need this; the game looks in a neat little table to see where to start/stop cacheing sprites used for a particular sprite, for example, Lindsey uses all the sprites between $145 and $148. Following is the table of cache starts/finnishes.

Code: Select all

###
#Sprite cache list:
###

%patch $306D2 $0082W #Keen Cache start
%patch $3072E $0134W #Keen cache end
%patch $3071E $00E4W #Soda cache end
%patch $306D4 $00E3W #Soda Cache start
%patch $306D6 $00E5W #Candybar Cache start
%patch $30720 $00E6W #Candybar cache end
%patch $306D8 $00E7W #Choc Cache start
%patch $30722 $00E8W #Choc cache end
%patch $306DA $00E9W #Jawbreaker Cache start
%patch $30724 $00EAW #Jawbreaker cache end
%patch $306DC $00EBW #Donut Cache start
%patch $30726 $00ECW #Donut cache end
%patch $306DF $00EDW #Icecream Cache start
%patch $30728 $00EEW #Icecream cache end
%patch $306E0 $00EFW #Flask Cache start
%patch $3072A $00F0W #Flask cache end
%patch $306E2 $00FBW #Raygun Cache start
%patch $3072C $00FCW #Raygun cache end
%patch $306E4 $00FEW #Got stuff Cache start
%patch $3071C $00E2W #Got stuff Cache end
%patch $306E6 $013BW #Slug Cache start
%patch $30730 $0144W #Slug cache end
%patch $306E8 $0145W #Mushroom Cache start
%patch $30732 $0148W #Mushroom cache end
%patch $306EA $0000W #Dart shooter Cache start
%patch $30734 $0000W #Dart shooter cache end
%patch $306EC $0149W #Lindsey Cache start
%patch $30736 $014CW #Lindsey cache end
%patch $306EE $014DW #Inchworm Cache start
%patch $30738 $0151W #Inchworm cache end
%patch $306F0 $0152W #Smirky Cache start
%patch $3073A $0163W #Smirky cache end
%patch $306F2 $0164W #Council Member Cache start
%patch $3073C $0169W #Council member cache end
%patch $306F4 $016FW #Blue bird Cache start
%patch $3073E $017BW #Blue bird cache end
%patch $306F6 $0184W #Mimrock Cache start
%patch $30740 $0193W #Mimrock cache end
%patch $306F8 $0194W #Dopefish Cache start
%patch $30742 $01A4W #Dopefish cache end
%patch $306FA $01A5W #Schoolfish Cache start
%patch $30744 $01A8W #Schoolfish cache end
%patch $306FC $01A9W #Arachnut Cache start
%patch $30746 $01ADW #Arachnut cache end
%patch $306FE $01BBW #Skypest Cache start
%patch $30748 $01C8W #Skypest cache end
%patch $30700 $01C9W #Wormouth Cache start
%patch $3074A $01D4W #Wormouth cache end
%patch $30702 $01D5W #Lick Cache start
%patch $3074C $01E3W #Lick cache end
%patch $30704 $01E4W #Airboard Cache start
%patch $3074E $01EAW #Airboard cache end
%patch $30706 $01EBW #Bounder Cache start
%patch $30750 $01F1W #Bounder cache end
%patch $30708 $01F2W #Cloud Cache start
%patch $30752 $01F6W #Cloud cache end
%patch $3070A $01F7W #Berkeloid Cache start
%patch $30754 $0206W #Berkeloid cache end
%patch $3070C $00F2W #Gems Cache start
%patch $30756 $00FAW #Gems cache end
%patch $3070E $017CW #Darts Cache start
%patch $30758 $0183W #Darts cache end
%patch $30710 $0135W #Keen swimming Cache start
%patch $3075A $013AW #Keen swimming cache end
%patch $30712 $01AFW #Sprite Cache start
%patch $3075C $01B7W #Sprite cache end
%patch $30714 $01B8W #Mine Cache start
%patch $3075E $01BAW #Mine cache end
%patch $30716 $0207W #MoonKeen Cache start
%patch $30760 $0208W #MoonKeen cache end
%patch $30718 $016AW #Egg Cache start
%patch $30762 $016EW #Egg cache end
Now, how do we use this? Let's say that we want to make the Bounder use the Poison slug frames, but we don't want to put any Poison slugs in.

First, we'll need to take the two entries for 'Bounder:

Code: Select all

%patch $30706  $EB $01 #Bounder Cache start
%patch $30750  $F1 $01 #Bounder cache end
These are sprites 367-373, what we *want* to make it use are those between 191-200. So we simply change the start to 191 and the end to 200: (Remember of course, sprite numbers used are 124 smaller than the values shown.)

Code: Select all

%patch $30706  $3B $01 #Bounder Cache start
%patch $30750  $44 $01 #Bounder cache end
We may now of course wish to make the Slugs use something harmless and unobtrusive, so we set both values to zero (Use no sprites at all)

Code: Select all

%patch $306E6  $00 $00 #Slug Cache start
%patch $30730  $00 $00 #Slug cache end

Now we can change the Bounder animations. (I used my extracter program to get these.)

Code: Select all

#Bounder 1
%patch $31D82 $EF $01 #Sprite l
%patch $31D84 $EF $01 #Sprite r
%patch $31D8C $14 $00 #Animation speed
#Bounder 2 [Keep bounding]
%patch $31DA0 $F0 $01 #Sprite l
%patch $31DA2 $F0 $01 #Sprite r
%patch $31DAA $14 $00 #Animation speed

#Bounder moving left/right 1
%patch $31DBE $EB $01 #Sprite l
%patch $31DC0 $ED $01 #Sprite r
%patch $31DC8 $14 $00 #Animation speed
#Bounder moving left/right 2
%patch $31DDC $EC $01 #Sprite l
%patch $31DDE $EF $01 #Sprite r
%patch $31DE6 $14 $00 #Animation speed

#Stunned Bounder in air
%patch $31DFA $EF $01 #Sprite l
%patch $31DFC $EF $01 #Sprite r
%patch $31E04 $00 $00 #Pause [Wait until hits ground]
#Stunned Bounder [Do nothing]
%patch $31E18 $F1 $01 #Sprite l
%patch $31E1A $F1 $01 #Sprite r
%patch $31E22 $00 $00 #Animation speed [None]

And now I have added a demo, can I get that soda animation now Xky? ;)
Last edited by levellass on Fri Jun 01, 2012 11:47 am, edited 2 times in total.
User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

Post by Shadow Master »

Whoah! Excellent!
Kdash
Posts: 405
Joined: Sat Feb 26, 2005 5:45 pm

Post by Kdash »

Great! This will help a lot of people...
User avatar
Flyingmouse
Posts: 104
Joined: Wed Aug 05, 2009 8:33 pm
Location: Procrastination

Post by Flyingmouse »

Sorry for the bump, but I didn't see anything about the wetsuit in any list. What is the code for this?

Edit: Never mind, I'm don't need this anymore.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

The wetsuit is unique in not HAVING a cache, but instead using only one frame, hard coded earlier in the code. Thus you CANNOT change its cache. This note has been added to the patch index for clarity.
User avatar
troublesomekeen
Posts: 223
Joined: Fri Feb 03, 2012 7:56 pm
Location: Shadowlands
Contact:

Post by troublesomekeen »

Sorry for the almost 3 year bump, but this is giving me some bugs. I'm trying to figure out how to patch Caches, and am not having much luck. During the course of my dabbling, I noticed that the Slug Start Cache listed here is exactly the same as the Mushroom Start Cache. Since no other Caches use the same patch code, I think this list has a mistake in it.

Code: Select all

%patch $306E6  $3B $01 #Slug Cache start
%patch $30730  $44 $01 #Slug cache end
%patch $306E6  $45 $01 #Mushroom Cache start
%patch $30732  $48 $01 #Mushroom cache end
See what I mean? $306E6 is used for both the Slug and Mushroom Cache Start. The patch code increases by increments of two.
$306D2
$306D4
$306D6
etc..
When we get to the "#Got stuff Cache start " the code is:
$306E4
But then both the Mushroom and the Slug Cache Start is
$306E6
and
$306E6
???
Shouldn't it be, based on the sequence,
$306E8
???
But the Dart shooter Cache start is already
$306E8
!!!
What's going on here?

EDIT: After another hour of puzzling, I decided that the so-called Dart Shooter has usurped the Mad Mushroom. The Slug Cache Start is indeed $306E6, and the Mad Mushroom Cache Start is $306E8. What in the blazing garg of all gargleness is a Dart Shooter anyway? Is that the weird green gun that sits on the ground of hangs from walls and ceiling firing darts, found in the pyramid levels? Why would a foreground tile need a cache? Aaaannnyywayyy, if the list went like this:

Code: Select all

%patch $306E6  $3B $01 #Slug Cache start
%patch $30730  $44 $01 #Slug cache end
%patch $306E8  $45 $01 #Mushroom Cache start
%patch $30732  $48 $01 #Mushroom cache end
then wouldn't everything else after the Mushroom Cache be off by 2? Am I going mad!?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Hah yes! This old patch does indeed have some bugs in it. The updated and actual list has been posted above. Indeed a few of the Keenwiki values were off as well, good thing you caught this! The error is the 'dart shooter' cache entry itself, on further investigation I am not actually sure what it is for. Fortunately, most of the entries are ok, only four or so are wrong.


The dart shooter is indeed a tile, but it shoots darts, which are sprites, and *these* need to be cached. (It is also possible to give the shooter a sprite, though it does not have one by default. Indeed, it can have two, one for sitting, one for shooting.)
User avatar
troublesomekeen
Posts: 223
Joined: Fri Feb 03, 2012 7:56 pm
Location: Shadowlands
Contact:

Post by troublesomekeen »

So old patches are formatted like this

Code: Select all

%patch $306D2  $82 $00 #Keen Cache start
While newer patches usually look like this

Code: Select all

%patch $306D2 $0082W #Keen Cache start
Gah, I don't know which format is easier to read. I've become used to the old way. Everything has a "W" on the end of it now. Quite fascinating.
Anyway, thanks for updating these. I was wonder why my caching wasn't catching. That explains it. It took me the longest time to understand exactly what "cache" is.
Interesting bit on the Dart Shooters.... I wonder if I can use it in a cool way...
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I have a program capable of swapping formats if you'd like. In simple terms:

$CD $AB = $ABCDW

It's usually used for two-byte values because it's slightly easier to edit; using decimal if you wanted to change a value from 75 to 150, the old format would need you to turn $75 $00 to $50 $01 while the new format requires you to change $0075W to $0150W. It may surprise, but some people have had some problems with the old system. (Such as 'It went slower! Yes I changed it to $50. I have to change the second one too?')
Post Reply