Rev 1 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 18 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "depth.h" |
1 | #include "depth.h" |
2 | 2 | ||
3 | #include " |
3 | #include "brender.h" |
4 | #include "displays.h" |
4 | #include "displays.h" |
5 | #include "errors.h" |
5 | #include "errors.h" |
6 | #include "globvars.h" |
6 | #include "globvars.h" |
7 | #include "globvrkm.h" |
7 | #include "globvrkm.h" |
8 | #include "globvrpb.h" |
8 | #include "globvrpb.h" |
Line 337... | Line 337... | ||
337 | gHorizon_material = BrMaterialLoad(the_path); |
337 | gHorizon_material = BrMaterialLoad(the_path); |
338 | if (gHorizon_material == NULL) { |
338 | if (gHorizon_material == NULL) { |
339 | FatalError(kFatalError_FindSkyMaterial_S, "HORIZON.MAT"); // 2nd argument added |
339 | FatalError(kFatalError_FindSkyMaterial_S, "HORIZON.MAT"); // 2nd argument added |
340 | } |
340 | } |
341 | gHorizon_material->index_blend = BrPixelmapAllocate(BR_PMT_INDEX_8, 256, 256, NULL, 0); |
341 | gHorizon_material->index_blend = BrPixelmapAllocate(BR_PMT_INDEX_8, 256, 256, NULL, 0); |
342 | - | ||
343 | // HACK: moved below loop |
- | |
344 |
|
342 | BrTableAdd(gHorizon_material->index_blend); |
345 | for (i = 0; i < 256; i++) { |
343 | for (i = 0; i < 256; i++) { |
346 | for (j = 0; j < 256; j++) { |
344 | for (j = 0; j < 256; j++) { |
347 | *((tU8*)gHorizon_material->index_blend->pixels + 256 * i + j) = j; |
345 | *((tU8*)gHorizon_material->index_blend->pixels + 256 * i + j) = j; |
348 | } |
346 | } |
349 | } |
347 | } |
350 | // HACK: this should be above the for loop. Haven't been able to figure out how this is working in OG, as changes made to the pixelmap |
- | |
351 | // don't update the stored copy without calling `BrTableUpdate`. |
- | |
352 | BrTableAdd(gHorizon_material->index_blend); |
- | |
353 | - | ||
354 | gHorizon_material->flags |= BR_MATF_PERSPECTIVE; |
348 | gHorizon_material->flags |= BR_MATF_PERSPECTIVE; |
355 | BrMaterialAdd(gHorizon_material); |
349 | BrMaterialAdd(gHorizon_material); |
356 | gForward_sky_model = CreateHorizonModel(gCamera); |
350 | gForward_sky_model = CreateHorizonModel(gCamera); |
357 | gRearview_sky_model = CreateHorizonModel(gRearview_camera); |
351 | gRearview_sky_model = CreateHorizonModel(gRearview_camera); |
358 | BrModelAdd(gForward_sky_model); |
352 | BrModelAdd(gForward_sky_model); |
Line 579... | Line 573... | ||
579 | gProgram_state.current_depth_effect.end); |
573 | gProgram_state.current_depth_effect.end); |
580 | } |
574 | } |
581 | 575 | ||
582 | // IDA: void __usercall DepthEffect(br_pixelmap *pRender_buffer@<EAX>, br_pixelmap *pDepth_buffer@<EDX>, br_actor *pCamera@<EBX>, br_matrix34 *pCamera_to_world@<ECX>) |
576 | // IDA: void __usercall DepthEffect(br_pixelmap *pRender_buffer@<EAX>, br_pixelmap *pDepth_buffer@<EDX>, br_actor *pCamera@<EBX>, br_matrix34 *pCamera_to_world@<ECX>) |
583 | void DepthEffect(br_pixelmap* pRender_buffer, br_pixelmap* pDepth_buffer, br_actor* pCamera, br_matrix34* pCamera_to_world) { |
577 | void DepthEffect(br_pixelmap* pRender_buffer, br_pixelmap* pDepth_buffer, br_actor* pCamera, br_matrix34* pCamera_to_world) { |
584 | LOG_TRACE("(%p, %p, %p, %p)", pRender_buffer, pDepth_buffer, pCamera, pCamera_to_world); |
578 | LOG_TRACE("(%p, %p, %p, %p)", pRender_buffer, pDepth_buffer, pCamera, pCamera_to_world); |
585 | 579 | ||
586 | if (gProgram_state.current_depth_effect.type == eDepth_effect_darkness) { |
580 | if (gProgram_state.current_depth_effect.type == eDepth_effect_darkness) { |
587 | DoDepthCue(pRender_buffer, pDepth_buffer); |
581 | DoDepthCue(pRender_buffer, pDepth_buffer); |
588 | } |
582 | } |
589 | if (gProgram_state.current_depth_effect.type == eDepth_effect_fog) { |
583 | if (gProgram_state.current_depth_effect.type == eDepth_effect_fog) { |
Line 739... | Line 733... | ||
739 | gProgram_state.default_depth_effect.end = gProgram_state.current_depth_effect.end; |
733 | gProgram_state.default_depth_effect.end = gProgram_state.current_depth_effect.end; |
740 | } |
734 | } |
741 | 735 | ||
742 | // IDA: void __cdecl AssertYons() |
736 | // IDA: void __cdecl AssertYons() |
743 | void AssertYons(void) { |
737 | void AssertYons(void) { |
744 | br_camera* camera_ptr; |
738 | br_camera* camera_ptr; |
745 | int i; |
739 | int i; |
746 | LOG_TRACE("()"); |
740 | LOG_TRACE("()"); |
747 | 741 | ||
748 | for (i = 0; i < COUNT_OF(gCamera_list); ++i) { |
742 | for (i = 0; i < COUNT_OF(gCamera_list); ++i) { |
749 | camera_ptr = gCamera_list[i]->type_data; |
743 | camera_ptr = gCamera_list[i]->type_data; |
Line 822... | Line 816... | ||
822 | camera_ptr->field_of_view += 0x1c7; // 2.4993896484375 degrees |
816 | camera_ptr->field_of_view += 0x1c7; // 2.4993896484375 degrees |
823 | if (camera_ptr->field_of_view > 0x78e3) { // 169.9969482421875 degrees |
817 | if (camera_ptr->field_of_view > 0x78e3) { // 169.9969482421875 degrees |
824 | camera_ptr->field_of_view = 0x78e3; |
818 | camera_ptr->field_of_view = 0x78e3; |
825 | } |
819 | } |
826 | #ifdef DETHRACE_FIX_BUGS |
820 | #ifdef DETHRACE_FIX_BUGS |
827 | sprintf(s, "Camera angle increased to %f", (float) |
821 | sprintf(s, "Camera angle increased to %f", (float)BrAngleToDegree(camera_ptr->field_of_view)); |
828 | #else |
822 | #else |
829 | sprintf(s, "Camera angle increased to %d", gProgram_state.current_depth_effect.end); |
823 | sprintf(s, "Camera angle increased to %d", gProgram_state.current_depth_effect.end); |
830 | #endif |
824 | #endif |
831 | NewTextHeadupSlot(4, 0, 500, -1, s); |
825 | NewTextHeadupSlot(4, 0, 500, -1, s); |
832 | } |
826 | } |
Line 844... | Line 838... | ||
844 | camera_ptr->field_of_view -= 0x1c7; // 2.4993896484375 degrees |
838 | camera_ptr->field_of_view -= 0x1c7; // 2.4993896484375 degrees |
845 | if (camera_ptr->field_of_view < 0x71c) { // 9.99755859375 degrees |
839 | if (camera_ptr->field_of_view < 0x71c) { // 9.99755859375 degrees |
846 | camera_ptr->field_of_view = 0x71c; |
840 | camera_ptr->field_of_view = 0x71c; |
847 | } |
841 | } |
848 | #ifdef DETHRACE_FIX_BUGS |
842 | #ifdef DETHRACE_FIX_BUGS |
849 | sprintf(s, "Camera angle decreased to %f", (float) |
843 | sprintf(s, "Camera angle decreased to %f", (float)BrAngleToDegree(camera_ptr->field_of_view)); |
850 | #else |
844 | #else |
851 | sprintf(s, "Camera angle decreased to %d", gProgram_state.current_depth_effect.end); |
845 | sprintf(s, "Camera angle decreased to %d", gProgram_state.current_depth_effect.end); |
852 | #endif |
846 | #endif |
853 | NewTextHeadupSlot(4, 0, 500, -1, s); |
847 | NewTextHeadupSlot(4, 0, 500, -1, s); |
854 | } |
848 | } |
Line 900... | Line 894... | ||
900 | BrMaterialUpdate(gHorizon_material, -1); |
894 | BrMaterialUpdate(gHorizon_material, -1); |
901 | } |
895 | } |
902 | } |
896 | } |
903 | } |
897 | } |
904 | gSky_on = pOn; |
898 | gSky_on = pOn; |
905 | } |
899 | } |
906 | 900 | ||
907 | // IDA: void __cdecl ToggleSkyQuietly() |
901 | // IDA: void __cdecl ToggleSkyQuietly() |
908 | void ToggleSkyQuietly(void) { |
902 | void ToggleSkyQuietly(void) { |
909 | br_pixelmap* temp; |
903 | br_pixelmap* temp; |
910 | LOG_TRACE("()"); |
904 | LOG_TRACE("()"); |
Line 922... | Line 916... | ||
922 | } |
916 | } |
923 | 917 | ||
924 | // IDA: void __cdecl ToggleSky() |
918 | // IDA: void __cdecl ToggleSky() |
925 | void ToggleSky(void) { |
919 | void ToggleSky(void) { |
926 | LOG_TRACE("()"); |
920 | LOG_TRACE("()"); |
- | 921 | ||
927 |
|
922 | SetSkyTextureOn(!GetSkyTextureOn()); |
- | 923 | if (gProgram_state.current_depth_effect.sky_texture != NULL) { |
|
- | 924 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_SkyTextureOn)); |
|
- | 925 | } else if (gSwap_sky_texture != NULL) { |
|
- | 926 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_SkyTextureOff)); |
|
- | 927 | } else { |
|
- | 928 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_ThereIsNoSkyTextureForThisRace)); |
|
- | 929 | } |
|
928 | } |
930 | } |
929 | 931 | ||
930 | // IDA: int __cdecl GetDepthCueingOn() |
932 | // IDA: int __cdecl GetDepthCueingOn() |
931 | int GetDepthCueingOn(void) { |
933 | int GetDepthCueingOn(void) { |
932 | LOG_TRACE("()"); |
934 | LOG_TRACE("()"); |
933 | return gDepth_cueing_on; |
935 | return gDepth_cueing_on; |
934 | } |
936 | } |
935 | 937 | ||
936 | // IDA: void __usercall SetDepthCueingOn(int pOn@<EAX>) |
938 | // IDA: void __usercall SetDepthCueingOn(int pOn@<EAX>) |
937 | void SetDepthCueingOn(int pOn) { |
939 | void SetDepthCueingOn(int pOn) { |
938 | LOG_TRACE("(%d)", pOn); |
940 | LOG_TRACE("(%d)", pOn); |
939 | if (pOn != gDepth_cueing_on && gHorizon_material) { |
941 | if (pOn != gDepth_cueing_on && gHorizon_material) { |
940 | InstantDepthChange(gSwap_depth_effect_type, gProgram_state.current_depth_effect.sky_texture, gSwap_depth_effect_start, gSwap_depth_effect_end); |
942 | InstantDepthChange(gSwap_depth_effect_type, gProgram_state.current_depth_effect.sky_texture, gSwap_depth_effect_start, gSwap_depth_effect_end); |
Line 966... | Line 968... | ||
966 | } |
968 | } |
967 | 969 | ||
968 | // IDA: void __cdecl ToggleDepthCueing() |
970 | // IDA: void __cdecl ToggleDepthCueing() |
969 | void ToggleDepthCueing(void) { |
971 | void ToggleDepthCueing(void) { |
970 | LOG_TRACE("()"); |
972 | LOG_TRACE("()"); |
- | 973 | ||
- | 974 | SetDepthCueingOn(!GetDepthCueingOn()); |
|
- | 975 | if (gProgram_state.current_depth_effect.type != eDepth_effect_none) { |
|
- | 976 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_DepthCueingOn)); |
|
- | 977 | } else if (gSwap_depth_effect_type != eDepth_effect_none) { |
|
- | 978 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_DepthCueingOff)); |
|
971 |
|
979 | } else { |
- | 980 | NewTextHeadupSlot(4, 0, 2000, -4, GetMiscString(kMiscString_ThereIsNoDepthCueingForThisRace)); |
|
- | 981 | } |
|
972 | } |
982 | } |
973 | 983 | ||
974 | // IDA: void __cdecl ChangeDepthEffect() |
984 | // IDA: void __cdecl ChangeDepthEffect() |
975 | void ChangeDepthEffect(void) { |
985 | void ChangeDepthEffect(void) { |
976 | //br_scalar x1; // Pierre-Marie Baty -- unused variable |
986 | //br_scalar x1; // Pierre-Marie Baty -- unused variable |
Line 980... | Line 990... | ||
980 | //br_scalar z1; // Pierre-Marie Baty -- unused variable |
990 | //br_scalar z1; // Pierre-Marie Baty -- unused variable |
981 | //br_scalar z2; // Pierre-Marie Baty -- unused variable |
991 | //br_scalar z2; // Pierre-Marie Baty -- unused variable |
982 | //br_scalar distance; // Pierre-Marie Baty -- unused variable |
992 | //br_scalar distance; // Pierre-Marie Baty -- unused variable |
983 | //tSpecial_volume* special_volume; // Pierre-Marie Baty -- unused variable |
993 | //tSpecial_volume* special_volume; // Pierre-Marie Baty -- unused variable |
984 | LOG_TRACE("()"); |
994 | LOG_TRACE("()"); |
- | 995 | ||
- | 996 | gProgram_state.current_depth_effect.type = gProgram_state.default_depth_effect.type; |
|
- | 997 | gProgram_state.current_depth_effect.sky_texture = gProgram_state.default_depth_effect.sky_texture; |
|
- | 998 | gProgram_state.current_depth_effect.start = gProgram_state.default_depth_effect.start; |
|
985 |
|
999 | gProgram_state.current_depth_effect.end = gProgram_state.default_depth_effect.end; |
986 | } |
1000 | } |
987 | 1001 | ||
988 | // IDA: void __cdecl MungeForwardSky() |
1002 | // IDA: void __cdecl MungeForwardSky() |
989 | void MungeForwardSky(void) { |
1003 | void MungeForwardSky(void) { |
990 | LOG_TRACE("()"); |
1004 | LOG_TRACE("()"); |