I will provide you disassembly from a computer game that runs in MS-DOS. The game was…
- User
I will provide you disassembly from a computer game that runs in MS-DOS. The game was written in C with a Watcom compiler. Some library function calls are already identified. Explain the functions I give to you and suggest names and C-language function signatures for them, including which parameters map to which registers or stack values. Also suggest names for global values if you have enough context to do so.
FUN_0009e2bb PUSH ECX PUSH ESI PUSH EDI PUSH EBP MOV EBP,ESP SUB ESP,0x20 MOV dword ptr [EBP + local_30],EAX MOV dword ptr [EBP + local_2c],EDX MOV dword ptr [EBP + local_28],EBX MOV dword ptr [EBP + local_1c],0x0 MOV dword ptr [EBP + local_24],0x0 LAB_0009e2de CMP dword ptr [EBP + local_24],0x10 JC LAB_0009e2ee JMP LAB_0009e2fd LAB_0009e2e6 MOV EAX,dword ptr [EBP + local_24] INC dword ptr [EBP + local_24] JMP LAB_0009e2de LAB_0009e2ee MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 CMP dword ptr [EAX + DAT_0018b5bc],0x0 JNZ LAB_0009e2e6 LAB_0009e2fd CMP dword ptr [EBP + local_24],0x10 JC LAB_0009e30f MOV dword ptr [EBP + local_14],0xb JMP LAB_0009e4a7 LAB_0009e30f TEST byte ptr [DAT_0018b5b4],0x1 JZ LAB_0009e31d CALL FUN_000a3d54 LAB_0009e31d MOV EAX,dword ptr [EBP + local_24] MOV dword ptr [EBP + local_20],EAX MOV EDX,dword ptr [EBP + local_24] SHL EDX,0x2 MOV EAX,dword ptr [EBP + local_2c] MOV dword ptr [EDX + DAT_0018b5bc],EAX MOV EDX,dword ptr [EBP + local_24] SHL EDX,0x2 MOV EAX,dword ptr [EBP + local_30] MOV dword ptr [EDX + DAT_0018b5fc],EAX XOR EDX,EDX MOV EAX,DAT_001234dc DIV dword ptr [EBP + local_30] CMP EAX,dword ptr [DAT_0018b5b8] JNC LAB_0009e380 XOR EDX,EDX MOV EAX,DAT_001234dc DIV dword ptr [EBP + local_30] CALL FUN_0009e7e2 MOV ECX,dword ptr [DAT_0018b5b8] SHL ECX,0x10 XOR EDX,EDX MOV EAX,DAT_001234dc DIV dword ptr [EBP + local_30] MOV EBX,EAX XOR EDX,EDX MOV EAX,ECX DIV EBX MOV dword ptr [EBP + local_1c],EAX LAB_0009e380 MOV dword ptr [EBP + local_24],0x0 LAB_0009e387 CMP dword ptr [EBP + local_24],0x10 JC LAB_0009e39a JMP LAB_0009e48a LAB_0009e392 MOV EAX,dword ptr [EBP + local_24] INC dword ptr [EBP + local_24] JMP LAB_0009e387 LAB_0009e39a MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 CMP dword ptr [EAX + DAT_0018b5bc],0x0 JZ LAB_0009e485 MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 CMP dword ptr [EAX + DAT_0018b5fc],0xff00 JNZ LAB_0009e405 CMP dword ptr [DAT_0018b5b8],0xffff JNZ LAB_0009e3dd MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV dword ptr [EAX + DAT_0018b63c],__break JMP LAB_0009e403 LAB_0009e3dd XOR EDX,EDX MOV EAX,DAT_001234dc DIV dword ptr [DAT_0018b5b8] MOV EBX,EAX XOR EDX,EDX MOV EAX,DAT_00123333 DIV EBX MOV EBX,EAX MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV dword ptr [EAX + DAT_0018b63c],EBX LAB_0009e403 JMP LAB_0009e437 LAB_0009e405 MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV ECX,dword ptr [EAX + DAT_0018b5fc] SHL ECX,0x10 XOR EDX,EDX MOV EAX,DAT_001234dc DIV dword ptr [DAT_0018b5b8] = FFFFFFFFh MOV EBX,EAX XOR EDX,EDX MOV EAX,ECX DIV EBX MOV EBX,EAX MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV dword ptr [EAX + DAT_0018b63c],EBX LAB_0009e437 CMP dword ptr [EBP + local_1c],0x0 JZ LAB_0009e485 MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV EDX,dword ptr [EBP + local_1c] AND EDX,0xffff MOV EAX,dword ptr [EAX + DAT_0018b67c] IMUL EAX,EDX SHR EAX,0x10 MOV dword ptr [EBP + local_18],EAX MOV EAX,dword ptr [EBP + local_24] SHL EAX,0x2 MOV EDX,dword ptr [EBP + local_1c] SHR EDX,0x10 MOV EAX,dword ptr [EAX + DAT_0018b67c] IMUL EAX,EDX SHR EAX,0x10 ADD dword ptr [EBP + local_18],EAX MOV EDX,dword ptr [EBP + local_24] SHL EDX,0x2 MOV EAX,dword ptr [EBP + local_18] MOV dword ptr [EDX + DAT_0018b67c],EAX LAB_0009e485 JMP LAB_0009e392 LAB_0009e48a TEST byte ptr [DAT_0018b5b4],0x1 JZ LAB_0009e498 CALL FUN_000a3d80 LAB_0009e498 MOV EAX,dword ptr [EBP + local_20] MOV EDX,dword ptr [EBP + local_28] MOV dword ptr [EDX],EAX MOV dword ptr [EBP + local_14],0x0 LAB_0009e4a7 MOV EAX,dword ptr [EBP + local_14] LEAVE POP EDI POP ESI POP ECX RET
- Assistant
The disassembly provided corresponds to the following C functions:
- FUN_0009e2bb: This function appears to manage a list of game objects represented by an array of size 0x10 (16). It receives as input the object's properties stored in EAX, EDX, and EBX registers, and returns the index of the object in the list. It may also work with the initialization of a timer and modify the object's properties based on the timer value.
Proposed function name:
int addObject(int prop1, int prop2, int prop3, int *index)where prop1, prop2 and prop3 are EAX, EDX and EBX respectively and index is [EBP + local_28].- FUN_0009e7e2: This function takes an integer value as input, saves it as a global value and makes a call to another function (0x000a3c53) passing the input value as a parameter.
Proposed function name:
void saveAndCall(int value)where value is stored at [EBP + local_20]. - User
- Assistant
The disassembled function, FUN_0009e61a, is related to the previous functions you mentioned, and it appears to manage sound or MIDI with a list of objects (with a size of 0x10). The function receives an input parameter representing the object's property, stored in EAX, initializes a timer (using the functions FUN_0009e7e2, FUN_000a3d54, and FUN_000a3d80), and processes the list of objects to modify or reset their properties.
Considering the knowledge of previous functions, there is no need to revise the last answer.
Proposed function name and signature for FUN_0009e61a:
int processSoundObjects(int property)where property is stored at [EBP + local_28].