Match Jimmy controller arithmetic and facing to original probes
This commit is contained in:
1 parent
42ea2b8cd5
commit
0e2f426d42
60 files changed
+6027
-48
No files matched your search
@@ -0,0 +1,82 @@
|
||||
/* Copied43915D keyboard scalar suffix and complete437C40 ground apply.
|
||||
Synthetic actor/support/animation, original vector/trig, no game entrypoint. */
|
||||
#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[0x440/4],outer_table[0x180/4];
|
||||
static Vec velocity,root_position;static unsigned char polygon[64];static int supported,has_polygon;
|
||||
#define OF(o) (*(float*)(object+(o)))
|
||||
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 Vec*TC get_root(void*self,Vec*out){(void)self;*out=root_position;return out;}
|
||||
static Vec*TC point(void*self,Vec*out,float x,float y,float z){
|
||||
Vec*r=((Vec*(TC*)(void*,Vec*,float,float,float))AT(0x472b10))(self,out,x,y,z);r->x+=root_position.x;r->y+=root_position.y;r->z+=root_position.z;return r;
|
||||
}
|
||||
static float TC friction(void*self){(void)self;return .8f;}
|
||||
static int TC support(void*self){(void)self;return supported;}
|
||||
static void*TC support_polygon(void*self){(void)self;return has_polygon?polygon:NULL;}
|
||||
static void TC destination(void*self,float x,float y,float z){unsigned char*g=self;*(float*)(g+0x274)=x;*(float*)(g+0x278)=y;*(float*)(g+0x27c)=z;}
|
||||
static void TC animate(void*self,void*name){(void)self;(void)name;}
|
||||
static void*input_entry(void){
|
||||
unsigned char*c=VirtualAlloc(NULL,256,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE),*p=c;
|
||||
emit_byte(&p,0x53);emit_byte(&p,0x55);emit_byte(&p,0x56);emit_byte(&p,0x57);
|
||||
emit_byte(&p,0x81);emit_byte(&p,0xec);word(&p,0x90);
|
||||
emit_byte(&p,0xbd);word(&p,(uintptr_t)object); /*ebp complete*/
|
||||
emit_byte(&p,0x31);emit_byte(&p,0xff); /*edi=0*/
|
||||
emit_byte(&p,0xba);word(&p,1);emit_byte(&p,0x31);emit_byte(&p,0xf6); /*edx=1,esi=0*/
|
||||
emit_byte(&p,0xbb);word(&p,(uintptr_t)(object+0x9bc));
|
||||
const int slots[]={0x14,0x18,0x1c};
|
||||
for(int i=0;i<3;i++){emit_byte(&p,0xc7);emit_byte(&p,0x44);emit_byte(&p,0x24);emit_byte(&p,slots[i]);word(&p,0);}
|
||||
jump(p,AT(0x43915d));p+=5;unsigned char*end=p;
|
||||
emit_byte(&p,0x81);emit_byte(&p,0xc4);word(&p,0x90);emit_byte(&p,0x5f);emit_byte(&p,0x5e);emit_byte(&p,0x5d);emit_byte(&p,0x5b);emit_byte(&p,0xc3);
|
||||
jump(AT(0x4395cf),end);return c;
|
||||
}
|
||||
static void setup(void){
|
||||
map_source();const struct{uint32_t at,target;}reloc[]={/* RELOCATIONS */};
|
||||
for(unsigned i=0;i<sizeof(reloc)/sizeof(reloc[0]);i++){uint32_t v;memcpy(&v,AT(reloc[i].at),4);require(v==reloc[i].target,"absolute operand");v=(uintptr_t)AT(v);memcpy(AT(reloc[i].at),&v,4);}
|
||||
HMODULE dll=LoadLibraryA("Z:\\work\\game\\OMT2.dll");require(dll!=NULL,"copied OMT2");
|
||||
*(void**)AT(0x48d104)=GetProcAddress(dll,"?quick_magnitude@OMedia3DVector@@QBEMXZ");
|
||||
*(void**)AT(0x48d108)=GetProcAddress(dll,"?angles@OMedia3DVector@@QAEXAAF0@Z");
|
||||
*(void**)AT(0x48d10c)=GetProcAddress(dll,"?global@OMediaCosSinTable@@2V1@A");
|
||||
require(*(void**)AT(0x48d104)&&*(void**)AT(0x48d108)&&*(void**)AT(0x48d10c),"OMT vector exports");
|
||||
game_table[0x2bc/4]=(uintptr_t)get_velocity;game_table[0x2c4/4]=(uintptr_t)set_velocity;
|
||||
game_table[0x310/4]=(uintptr_t)get_root;game_table[0x384/4]=(uintptr_t)point;
|
||||
game_table[0x334/4]=(uintptr_t)AT(0x472480);game_table[0x328/4]=(uintptr_t)AT(0x4723f0);game_table[0x38c/4]=(uintptr_t)AT(0x472b10);
|
||||
game_table[0x248/4]=(uintptr_t)friction;game_table[0x218/4]=(uintptr_t)support;game_table[0x338/4]=(uintptr_t)support_polygon;game_table[0x36c/4]=(uintptr_t)destination;
|
||||
outer_table[0x150/4]=(uintptr_t)animate;
|
||||
}
|
||||
static void reset(void){
|
||||
memset(object,0,sizeof(object));*(void**)object=outer_table;*(void**)(object+0xc0)=game_table;
|
||||
memset(AT(0x509830),0,0x1d0);*(short*)AT(0x4f0588)=-1;*AT(0x4f83e0)=0;*(void**)AT(0x5099e4)=object;
|
||||
OF(0x6bc)=30;OF(0x6c0)=35;OF(0x6c4)=600;root_position=(Vec){0,0,0,1};
|
||||
memset(polygon,0,sizeof(polygon));*(float*)(polygon+12)=1;
|
||||
}
|
||||
static void input_case(const char*name,void(*run)(void),float speed,int up,int down,int left,int right,float yaw,float hold,int latch){
|
||||
reset();OF(0x6c8)=speed;OF(0xc0+0x228)=yaw;OF(0x830)=hold;object[0x828]=latch;object[0x850]=down;
|
||||
*AT(0x50985e)=up;*AT(0x50985d)=left;*AT(0x50985f)=right;run();
|
||||
printf("INPUT %s in=%.9g,%d,%d,%d,%d,%.9g,%.9g,%d out=%.9g,%.9g,%.9g,%u\n",name,speed,up,down,left,right,yaw,hold,latch,OF(0x6c8),OF(0x870),OF(0xc0+0x278),object[0x828]);
|
||||
}
|
||||
static void apply_case(const char*name,float speed,Vec v,float pitch,float yaw,float roll,float turn,float side,int support_in,int poly,float dt){
|
||||
reset();velocity=v;OF(0x6c8)=speed;OF(0xc0+0x224)=pitch;OF(0xc0+0x228)=yaw;OF(0xc0+0x22c)=roll;OF(0x6d4)=turn;OF(0x870)=side;supported=support_in;has_polygon=poly;
|
||||
((void(TC*)(void*,float))AT(0x437c40))(object,dt);
|
||||
printf("APPLY %s in=%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%d,%d,%.9g out=%.9g,%.9g,%.9g,%.9g\n",name,speed,v.x,v.y,v.z,pitch,yaw,roll,turn,side,support_in,poly,dt,velocity.x,velocity.y,velocity.z,OF(0xc0+0x228));
|
||||
}
|
||||
int main(void){
|
||||
setup();void(*input)(void)=input_entry();
|
||||
input_case("up",input,0,1,0,0,0,90,0,0);input_case("left",input,0,0,0,1,0,90,0,0);input_case("right",input,0,0,0,0,1,90,0,0);
|
||||
input_case("upleft",input,100,1,0,1,0,90,0,0);input_case("upright",input,100,1,0,0,1,90,0,0);input_case("bothturn",input,100,1,0,1,1,90,0,0);
|
||||
input_case("back",input,0,0,1,0,0,90,0,0);input_case("all",input,100,1,1,1,1,90,0,0);input_case("release",input,100,0,0,0,0,90,0,0);
|
||||
input_case("negative",input,-20,0,0,0,0,90,0,0);input_case("cross",input,20,0,0,0,0,90,0,0);
|
||||
input_case("overcap",input,700,1,0,0,0,90,0,0);input_case("turnovercap",input,700,1,0,1,0,90,0,0);
|
||||
input_case("backcap",input,-299,0,1,0,0,90,0,0);input_case("backequal",input,0,0,1,0,0,90,1.5f,0);input_case("backturn",input,0,0,1,0,0,90,1.51f,0);input_case("latched",input,0,0,1,1,0,90,2,1);
|
||||
apply_case("rest",300,(Vec){0,0,0,0},0,0,0,0,0,0,0,.1f);
|
||||
apply_case("stationaryturn",300,(Vec){0,0,0,0},0,0,0,20,0,0,0,.1f);
|
||||
apply_case("side",300,(Vec){0,0,0,0},0,0,0,0,-1000,0,0,.1f);
|
||||
apply_case("turn",300,(Vec){1,0,0,0},0,0,0,20,0,0,0,.1f);
|
||||
apply_case("tilt",300,(Vec){0,13,1,0},30,45,20,0,0,0,0,.1f);
|
||||
apply_case("ground",300,(Vec){0,13,1,0},0,0,0,0,0,1,1,.1f);
|
||||
apply_case("ground_nopoly",300,(Vec){0,13,1,0},0,0,0,0,0,1,0,.1f);
|
||||
apply_case("fall",300,(Vec){0,-13,1,0},0,0,0,0,0,0,1,.1f);
|
||||
puts("JIMMY_GROUND_COMPLETE");return 0;
|
||||
}
|
||||
Reference in new issue
Block a user