It is now possible to write sprite behaviours in C. No more going through the trouble assembly to program our sprites. For this mod at least, I hope that some people with C knowledge will use this, because I sure as hell don't want to write 15 sprites worth of behaviours in assembly =).
Anyways, here is a slightly less sloppy example of the default garg movement code in C:
Code: Select all
#include "keen1.h";
extern Sprite temp_sprite;
extern long int tick_count;
extern int sprite_sync;
extern int compute_sprite_delta(void);
extern void do_fall(void);
extern int get_random(void);
extern void think_4_garg_look(void);
void garg_move() {
if (temp_sprite.vel_y == 0 && temp_sprite.vel_x > -220 && temp_sprite.vel_x < 220) {
if (get_random() < sprite_sync) {
temp_sprite.think_ptr = think_4_garg_look;
temp_sprite.var_c = 0;
}
}
if (temp_sprite.vel_x > 0)
temp_sprite.frame = 0x40;
else
temp_sprite.frame = 0x42;
temp_sprite.frame += (int)(tick_count >> 4 & 1);
do_fall();
int csd = compute_sprite_delta();
if (csd & 4)
temp_sprite.vel_x = 0xffc4;
if (csd & 1)
temp_sprite.vel_x = 0x3C;
if (csd & 2)
temp_sprite.var_c = 0;
else {
int l = temp_sprite.vel_x;
int m = (l & 0xFFFF) ^ (l >> 16);
m -= (l >> 16);
if (m == 0xDC && temp_sprite.var_c == 0) {
temp_sprite.var_c = 1;
temp_sprite.vel_y = 0xFF38;
}
}
return;
}
Here is a bare bones package if you want to try out writing stuff in C. It's still missing a few header files and the help is incomplete, but it contains a walkthrough to guide you through the process of making the garg code. You don't need any other patches to do the walkthrough.
There is one .zip; just dump all the contents into a keen v1.31 directory with ck1patch and follow the instructions. You need winXP.
http://www.mediafire.com/?tnimtdzk1mt
EDIT 2:
Slightly more user friendly. There is no need for hex-editing of object files anymore. Instead, run fixobj <object.obj> 0x#### , where 0x#### is the starting offset of your function, and then link. (It's in the instructions.)
http://www.mediafire.com/?ancwbdgyyym