include include/engine_lighting_core.inc AddLightSource PROC uses ebx ecx edx x:DWORD, y:DWORD, radius:DWORD, intensity:DWORD, lightType:DWORD, flags:DWORD, color:DWORD cmp x,2048 jae no_slot_avail cmp y,2048 jae no_slot_avail cmp radius,1 jb no_slot_avail cmp radius,2048 ja no_slot_avail cmp intensity,255 ja no_slot_avail cmp lightType,4 ja no_slot_avail mov eax,flags and eax,0FFFFFFF8h jnz no_slot_avail test color,0FF000000h jnz no_slot_avail mov ecx, 1 ; Slot 0 is reserved for player flashlight find_slot: cmp ecx, 14 jge no_slot_avail mov ebx, ecx imul ebx, sizeof LightSource add ebx, OFFSET lightSources test [ebx].LightSource.flags, LIGHT_FLAG_ACTIVE jz slot_found inc ecx jmp find_slot slot_found: mov eax, x mov [ebx].LightSource.x, eax mov eax, y mov [ebx].LightSource.y, eax mov eax, radius mov [ebx].LightSource.radius, eax mov eax, intensity mov [ebx].LightSource.intensity, eax mov [ebx].LightSource.curIntensity, eax mov eax, lightType mov [ebx].LightSource.lightType, eax mov eax, flags or eax, LIGHT_FLAG_ACTIVE mov [ebx].LightSource.flags, eax mov eax, color mov [ebx].LightSource.color, eax mov [ebx].LightSource.decaySpeed, 0 mov [ebx].LightSource.flickerPhase, 0 mov eax, ecx ret no_slot_avail: mov eax, -1 ret AddLightSource ENDP ; ------------------------------------------------------------------------------ ; SpawnExplosionLight: Triggers high-intensity fiery explosion light burst ; ------------------------------------------------------------------------------ SpawnExplosionLight PROC uses ebx x:DWORD, y:DWORD mov ebx, 15 * (sizeof LightSource) add ebx, OFFSET lightSources mov eax, x mov [ebx].LightSource.x, eax mov eax, y mov [ebx].LightSource.y, eax mov [ebx].LightSource.radius, 450 mov [ebx].LightSource.intensity, 255 mov [ebx].LightSource.curIntensity, 255 mov [ebx].LightSource.lightType, LIGHT_TYPE_BURST mov [ebx].LightSource.flags, LIGHT_FLAG_ACTIVE or LIGHT_FLAG_SHADOWS mov [ebx].LightSource.decaySpeed, 12 mov [ebx].LightSource.color, 00FFAA33h ; Warm fire tint ret SpawnExplosionLight ENDP ; ------------------------------------------------------------------------------ ; SpawnMuzzleFlashLight: Triggers momentary bright gunshot flash ; ------------------------------------------------------------------------------ SpawnMuzzleFlashLight PROC uses ebx x:DWORD, y:DWORD mov ebx, 14 * (sizeof LightSource) add ebx, OFFSET lightSources mov eax, x mov [ebx].LightSource.x, eax mov eax, y mov [ebx].LightSource.y, eax mov [ebx].LightSource.radius, 350 mov [ebx].LightSource.intensity, 240 mov [ebx].LightSource.curIntensity, 240 mov [ebx].LightSource.lightType, LIGHT_TYPE_BURST mov [ebx].LightSource.flags, LIGHT_FLAG_ACTIVE or LIGHT_FLAG_SHADOWS mov [ebx].LightSource.decaySpeed, 60 mov [ebx].LightSource.color, 00FFFFEEh ; White/yellow flare ret SpawnMuzzleFlashLight ENDP