66 lines
5.1 KiB
C
66 lines
5.1 KiB
C
/* Copied439900 through ordinary turn cap and437F90 velocity prefix.
|
|
Synthetic actor/friction/velocity/mouse; original Euler/trig helpers.
|
|
No game entrypoint, body, camera, jump state suffix or audio. */
|
|
#define main unused_grappler_main
|
|
#include "grappler_scalar_probe.c"
|
|
#undef main
|
|
typedef struct{float x,y,z,w;}Vec;
|
|
static uintptr_t game_table[0x390/4];static Vec velocity;static float friction;static int supported;
|
|
#define OF(o) (*(float*)(object+(o)))
|
|
#define GF(g,o) (*(float*)((g)+(o)))
|
|
static void TC missing(void*self){fprintf(stderr,"MISSING caller=%x self=%x\n",(unsigned)((unsigned char*)__builtin_return_address(0)-mapped+0x400000),(unsigned)self);require(0,"unexpected virtual");}
|
|
static Vec*TC get_velocity(void*self,Vec*out){(void)self;*out=velocity;return out;}
|
|
static void TC set_velocity(void*self,float x,float y,float z){(void)self;velocity=(Vec){x,y,z,0};}
|
|
static float TC get_friction(void*self){(void)self;return friction;}
|
|
static int TC get_supported(void*self){(void)self;return supported;}
|
|
static void mouse(short*x,short*y){*x=*y=0;}
|
|
static void setup(void){
|
|
map_source();const struct{uint32_t va,target;}rels[]={/* RELOCATIONS */};
|
|
for(unsigned i=0;i<sizeof(rels)/sizeof(rels[0]);i++){
|
|
uint32_t v;memcpy(&v,AT(rels[i].va),4);require(v==rels[i].target,"absolute operand");v=(uintptr_t)AT(v);memcpy(AT(rels[i].va),&v,4);
|
|
}
|
|
HMODULE dll=LoadLibraryA("Z:\\work\\game\\OMT2.dll");require(dll!=NULL,"copied OMT");
|
|
*(void**)AT(0x48d10c)=GetProcAddress(dll,"?global@OMediaCosSinTable@@2V1@A");require(*(void**)AT(0x48d10c)!=NULL,"original trig");
|
|
jump(AT(0x46a460),mouse);
|
|
const unsigned char input_return[]={0x5f,0x5e,0x5d,0x5b,0x83,0xc4,0x7c,0xc2,4,0};memcpy(AT(0x439db7),input_return,sizeof(input_return));
|
|
jump(AT(0x43812a),AT(0x4387a1));
|
|
for(unsigned i=0;i<sizeof(game_table)/4;i++)game_table[i]=(uintptr_t)missing;
|
|
game_table[0x218/4]=(uintptr_t)get_supported;game_table[0x248/4]=(uintptr_t)get_friction;
|
|
game_table[0x2bc/4]=(uintptr_t)get_velocity;game_table[0x2c4/4]=(uintptr_t)set_velocity;
|
|
game_table[0x328/4]=(uintptr_t)AT(0x4723f0);game_table[0x334/4]=(uintptr_t)AT(0x472480);game_table[0x38c/4]=(uintptr_t)AT(0x472b10);
|
|
}
|
|
static unsigned char*reset(void){memset(object,0,sizeof(object));unsigned char*g=object+0xc0;*(void**)g=game_table;memset(AT(0x509830),0,0x1d0);return g;}
|
|
static void input(const char*name,float speed,float turn,int latch,int up,int down,int left,int right,int ground,float maximum,float dt){
|
|
reset();OF(0x6c8)=speed;OF(0x6d4)=turn;OF(0x6bc)=30;OF(0x6c0)=35;OF(0x6c4)=maximum;object[0x6e6]=latch;*(short*)(object+0x7c4)=1;supported=ground;
|
|
*AT(0x50985e)=up;*AT(0x509860)=down;*AT(0x50985d)=left;*AT(0x50985f)=right;
|
|
((void(TC*)(void*,float))AT(0x439900))(object,dt);
|
|
printf("INPUT %s in=%.9g,%.9g,%d,%d,%d,%d,%d,%d,%.9g,%.9g out=%.9g,%.9g,%u\n",name,speed,turn,latch,up,down,left,right,ground,maximum,dt,OF(0x6c8),OF(0x6d4),object[0x6e6]);
|
|
}
|
|
static void apply(const char*name,float speed,float vx,float vy,float vz,float pitch,float yaw,float roll,float turn,float f,float dt){
|
|
unsigned char*g=reset();OF(0x6c8)=speed;OF(0x6d4)=turn;GF(g,0x224)=pitch;GF(g,0x228)=yaw;GF(g,0x22c)=roll;velocity=(Vec){vx,vy,vz,0};friction=f;
|
|
((void(TC*)(void*,float))AT(0x437f90))(object,dt);
|
|
printf("APPLY %s in=%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g out=%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g\n",name,speed,vx,vy,vz,pitch,yaw,roll,turn,f,dt,velocity.x,velocity.y,velocity.z,GF(g,0x224),GF(g,0x228),GF(g,0x22c),OF(0x6d8));
|
|
}
|
|
int main(void){
|
|
setup();
|
|
input("up",300,0,0,1,0,0,0,0,600,.1f);input("overspeed",700,0,0,1,0,0,0,0,600,.1f);
|
|
input("coast_high",600,0,0,0,0,0,0,0,600,.1f);input("coast_low",500,0,0,0,0,0,0,0,600,.1f);
|
|
input("coast_edge",600*.9090909361839294f,0,0,0,0,0,0,0,600,.1f);
|
|
input("down",300,0,0,0,1,0,0,0,600,.1f);input("back_to_zero",-10,0,0,0,1,0,0,0,600,.1f);
|
|
input("up_down",300,0,0,1,1,0,0,0,600,.1f);input("up_down_zero",0,0,0,1,1,0,0,0,600,.1f);
|
|
input("left",300,0,0,0,0,1,0,0,600,.1f);input("right",300,0,0,0,0,0,1,0,600,.1f);
|
|
input("both_turn",300,29,0,0,0,1,1,0,600,.1f);input("turn_cap",300,-29,0,0,0,0,1,0,600,.1f);
|
|
input("return",300,20,1,0,0,0,0,0,600,.1f);input("no_latch",300,20,0,0,0,0,0,0,600,.1f);input("return_cross",300,-5,1,0,0,0,0,0,600,.1f);
|
|
input("ground_up",300,0,0,1,0,0,0,1,600,.1f);input("ground_small",5,0,0,0,0,0,0,1,600,.1f);
|
|
input("ground_negative",-300,0,0,0,0,0,0,1,600,.1f);input("ground_down",300,0,0,0,1,0,0,1,600,.1f);
|
|
input("ground_up_down",0,0,0,1,1,0,0,1,600,.1f);input("tick",580,29,1,1,0,1,0,0,600,1.f/60);
|
|
apply("rest",300,0,0,0,0,0,0,30,.8f,.1f);apply("rising",300,0,10,0,0,0,0,30,.8f,.1f);
|
|
apply("falling",300,0,-10,0,0,90,0,-30,.8f,.1f);apply("forward",300,0,0,300,0,0,0,30,.8f,.1f);
|
|
apply("uphill",300,0,-10,300,30,45,0,30,.8f,.1f);apply("downhill",300,0,-10,300,330,45,0,30,.8f,.1f);
|
|
apply("roll",300,0,-10,300,0,45,30,30,.8f,.1f);apply("near_seam",300,0,1,0,0,359.5f,0,30,.8f,.1f);
|
|
apply("negative_euler",300,0,1,0,-3,-1,-2,30,.8f,.1f);apply("no_friction",300,0,1,0,0,0,0,30,0,.1f);
|
|
apply("reverse",-300,0,-10,-300,0,180,0,-20,.8f,.1f);apply("zero_scalar",0,0,-10,300,0,0,0,30,.8f,.1f);
|
|
apply("tick",600,10,-13,500,5,179,3,29,.8f,1.f/60);
|
|
puts("JIMMY_AIR_MOTION_COMPLETE");return 0;
|
|
}
|