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_0009e22b and FUN_0009e61a are called in the program by what is thought to be sound effect or MIDI-related code.

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

FUN_0009e7e2
PUSH EBX
PUSH ECX
PUSH EDX
PUSH ESI
PUSH EDI
PUSH EBP
MOV EBP,ESP
SUB ESP,0x8
MOV dword ptr [EBP + local_20],EAX
MOV EAX,dword ptr [EBP + local_20]
MOV [DAT_0018b5b8],EAX = FFFFFFFFh
MOV EAX,dword ptr [EBP + local_20]
PUSH EAX
CALL FUN_000a3c53
ADD ESP,0x4
MOV dword ptr [EBP + local_1c],0x0
MOV EAX,dword ptr [EBP + local_1c]
LEAVE
EDI
ESI
EDX
ECX
EBX
RET

FUN_000a3c53
PUSH EBP
MOV EBP,ESP
PUSH ESI
PUSH EDI
PUSH EBX
PUSH ECX
PUSH FS
PUSH GS
PUSH ES
CMP dword ptr [DAT_0018b418],0x0
JZ LAB_000a3c8e
NOP
NOP
NOP
NOP
MOV DX,0x21
IN AL,DX
AL,0x1
OUT DX,AL
MOV DX,0x43
MOV AL,0x36
OUT DX,AL
MOV DX,0x40
MOV EAX,dword ptr [EBP + Stack[0x4]]
OUT DX,AL
MOV AL,AH
OUT DX,AL
MOV DX,0x21
IN AL,DX
AND AL,0xfe
OUT DX,AL
LAB_000a3c8e
POP ES
POP GS
POP FS
POP ECX
POP EBX
POP EDI
POP ESI
POP EBP
RET

FUN_000a3d54
PUSH EBP
MOV EBP,ESP
PUSH ESI
PUSH EDI
PUSH EBX
PUSH ECX
PUSH FS
PUSH GS
PUSH ES
CMP dword ptr [DAT_0018b418],0x0
JZ LAB_000a3d75
NOP
NOP
NOP
NOP
MOV DX,0x21
IN AL,DX
OR AL,0x1
OUT DX,AL
LAB_000a3d75
POP ES
POP GS
POP FS
POP ECX
POP EBX
POP EDI
POP ESI
POP EBP
RET

FUN_000a3d80
PUSH EBP
MOV EBP,ESP
PUSH ESI
PUSH EDI
PUSH EBX
PUSH ECX
PUSH FS
PUSH GS
PUSH ES
CMP dword ptr [DAT_0018b418],0x0
JZ LAB_000a3da1
NOP
NOP
NOP
NOP
MOV DX,0x21
IN AL,DX
AND AL,0xfe
OUT DX,AL
LAB_000a3da1
POP ES
POP GS
POP FS
POP ECX
POP EBX
POP EDI
POP ESI
POP EBP
RET

__break
INT3

FUN_0009e61a
PUSH EBX
PUSH ECX
PUSH EDX
PUSH ESI
PUSH EDI
PUSH EBP
MOV EBP,ESP
SUB ESP,0x10
MOV dword ptr [EBP + local_28],EAX
MOV dword ptr [EBP + local_20],0x0
MOV EAX,dword ptr [EBP + local_28]
SHL EAX,0x2
MOV dword ptr [EAX + DAT_0018b5bc],0x0
MOV dword ptr [EBP + local_24],0x0
LAB_0009e649
CMP dword ptr [EBP + local_24],0x10
JC LAB_0009e659
JMP LAB_0009e69e
LAB_0009e651
MOV EAX,dword ptr [EBP + local_24]
INC dword ptr [EBP + local_24]
JMP LAB_0009e649
LAB_0009e659
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
CMP dword ptr [EAX + DAT_0018b5bc],0x0
JZ LAB_0009e69c
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
MOV EAX,dword ptr [EAX + DAT_0018b5fc]
CMP EAX,dword ptr [EBP + local_20]
JBE LAB_0009e68b
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
CMP dword ptr [EAX + DAT_0018b5fc],0xff00
JNZ LAB_0009e68d
LAB_0009e68b
JMP LAB_0009e69c
LAB_0009e68d
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
MOV EAX,dword ptr [EAX + DAT_0018b5fc]
MOV dword ptr [EBP + local_20],EAX
LAB_0009e69c
JMP LAB_0009e651
LAB_0009e69e
CMP dword ptr [EBP + local_20],0x0
JZ LAB_0009e6b5
XOR EDX,EDX
MOV EAX,DAT_001234dc
DIV dword ptr [EBP + local_20]
CALL FUN_0009e7e2
JMP LAB_0009e6bf
LAB_0009e6b5
MOV EAX,0xffff
CALL FUN_0009e7e2
LAB_0009e6bf
TEST byte ptr [DAT_0018b5b4],0x1
JZ LAB_0009e6cd
CALL FUN_000a3d54
LAB_0009e6cd
MOV dword ptr [EBP + local_24],0x0
LAB_0009e6d4
CMP dword ptr [EBP + local_24],0x10
JC LAB_0009e6e7
JMP LAB_0009e799
LAB_0009e6df
MOV EAX,dword ptr [EBP + local_24]
INC dword ptr [EBP + local_24]
JMP LAB_0009e6d4
LAB_0009e6e7
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
CMP dword ptr [EAX + DAT_0018b5bc],0x0
JZ LAB_0009e794
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
CMP dword ptr [EAX + DAT_0018b5fc],0xff00
JNZ LAB_0009e752
CMP dword ptr [DAT_0018b5b8],0xffff
JNZ LAB_0009e72a
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
MOV dword ptr [EAX + DAT_0018b63c],__break
JMP LAB_0009e750
LAB_0009e72a
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_0009e750
JMP LAB_0009e784
LAB_0009e752
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]
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_0009e784
MOV EAX,dword ptr [EBP + local_24]
SHL EAX,0x2
MOV dword ptr [EAX + DAT_0018b67c],0x0
LAB_0009e794
JMP LAB_0009e6df
LAB_0009e799
TEST byte ptr [DAT_0018b5b4],0x1
JZ LAB_0009e7a7
CALL FUN_000a3d80
LAB_0009e7a7
MOV dword ptr [EBP + local_1c],0x0
MOV EAX,dword ptr [EBP + local_1c]
LEAVE
POP EDI
POP ESI
POP EDX
POP ECX
POP EBX
RET