client/tests/animation_initialization.c (1298B)
1 #include "recomp_types.h" 2 #include <assert.h> 3 4 void sub_25094C20(void); 5 void sub_25094C90(void); 6 static unsigned initialized; 7 static void initialize_mesh(void) 8 { 9 assert(MEM8(g_ecx + 0x83) == 0); 10 ++initialized; 11 g_esp += 8; 12 } 13 recomp_func_t recomp_lookup_manual(uint32_t address) { return NULL; } 14 recomp_func_t recomp_lookup_import(uint32_t address) { abort(); } 15 recomp_func_t recomp_lookup(uint32_t address) 16 { 17 assert(address == 0x25094d10); 18 return initialize_mesh; 19 } 20 21 static void test_new_mesh(recomp_func_t constructor, unsigned arguments) 22 { 23 memset((void *)ADDR(0x50000000), 0xa5, 0x100); 24 g_ecx = 0x50000000; 25 g_esp = 0x5000ff00; 26 memset((void *)ADDR(g_esp), 0, 64); 27 g_ebx = 111; g_esi = 222; g_edi = 333; g_ebp = 444; 28 initialized = 0; 29 30 constructor(); 31 32 assert(MEM8(0x50000083) == 0); 33 assert(initialized == 1); 34 assert(g_eax == 0x50000000); 35 assert(g_esp == 0x5000ff00 + arguments + 4); 36 assert(g_ebx == 111 && g_esi == 222 && g_edi == 333 && g_ebp == 444); 37 } 38 39 int main(void) 40 { 41 assert(guest_map("animation constructor fixture", 0x50000000, 0x10000)); 42 test_new_mesh(sub_25094C20, 24); 43 test_new_mesh(sub_25094C90, 28); 44 puts("animation initialization: both mesh constructors clear player control and preserve guest ABI"); 45 }