1
0

render.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. LICENSE
  3. -------
  4. Copyright 2005 Nullsoft, Inc.
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice,
  11. this list of conditions and the following disclaimer in the documentation
  12. and/or other materials provided with the distribution.
  13. * Neither the name of Nullsoft nor the names of its contributors may be used to
  14. endorse or promote products derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  21. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. #include <windows.h>
  25. #include "render.h"
  26. #include "timing.h"
  27. #include "undo.h"
  28. #ifdef LASER
  29. C_LineListBase *g_laser_linelist;
  30. #endif
  31. C_RenderListClass *g_render_effects;
  32. C_RenderListClass *g_render_effects2;
  33. C_RenderTransitionClass *g_render_transition;
  34. C_RLibrary *g_render_library;
  35. int is_mmx(void) {
  36. DWORD retval1,retval2;
  37. __try {
  38. _asm {
  39. mov eax, 1 // set up CPUID to return processor version and features
  40. // 0 = vendor string, 1 = version info, 2 = cache info
  41. _emit 0x0f // code bytes = 0fh, 0a2h
  42. _emit 0xa2
  43. mov retval1, eax
  44. mov retval2, edx
  45. }
  46. } __except(EXCEPTION_EXECUTE_HANDLER) { retval1 = retval2= 0;}
  47. if (!retval1) return 0;
  48. return (retval2&0x800000)?1:0;
  49. }
  50. unsigned char g_blendtable[256][256];
  51. unsigned int const mmx_blend4_revn[2]={0xff00ff,0xff00ff};//{0x1000100,0x1000100}; <<- this is actually more correct, but we're going for consistency vs. the non-mmx ver-jf
  52. int const mmx_blendadj_mask[2] = { 0xff00ff,0xff00ff};
  53. int const mmx_blend4_zero=0;
  54. void Render_Init(HINSTANCE hDllInstance)
  55. {
  56. #ifdef LASER
  57. laser_connect();
  58. g_laser_linelist=createLineList();
  59. #endif
  60. timingInit();
  61. {
  62. int i,j;
  63. for (j=0;j<256;j++)
  64. for (i=0;i<256;i++)
  65. g_blendtable[i][j] = (unsigned char)((i / 255.0) * (float)j);
  66. }
  67. g_render_library=new C_RLibrary();
  68. g_render_effects=new C_RenderListClass(1);
  69. g_render_effects2=new C_RenderListClass(1);
  70. g_render_transition=new C_RenderTransitionClass();
  71. char INI_FILE[MAX_PATH];
  72. char *p=INI_FILE;
  73. GetModuleFileName(hDllInstance,INI_FILE,sizeof(INI_FILE));
  74. if (p[0]) while (p[1]) p++;
  75. while (p >= INI_FILE && *p != '\\') p--;
  76. #ifdef LASER
  77. strcpy(p,"\\vis_avs_laser.dat");
  78. #else
  79. strcpy(p,"\\vis_avs.dat");
  80. #endif
  81. extern int g_saved_preset_dirty;
  82. // clear the undo stack before loading a file.
  83. C_UndoStack::clear();
  84. g_render_effects->__LoadPreset(INI_FILE,1);
  85. // then add the new load to the undo stack but mark it clean if it is supposed to be
  86. C_UndoStack::saveundo();
  87. if (!g_saved_preset_dirty)
  88. {
  89. C_UndoStack::cleardirty();
  90. }
  91. }
  92. void Render_Quit(HINSTANCE hDllInstance)
  93. {
  94. if (g_render_transition) delete g_render_transition;
  95. g_render_transition=NULL;
  96. if (g_render_effects)
  97. {
  98. char INI_FILE[MAX_PATH];
  99. char *p=INI_FILE;
  100. GetModuleFileName(hDllInstance,INI_FILE,sizeof(INI_FILE));
  101. if (p[0]) while (p[1]) p++;
  102. while (p >= INI_FILE && *p != '\\') p--;
  103. #ifdef LASER
  104. strcpy(p,"\\vis_avs_laser.dat");
  105. #else
  106. strcpy(p,"\\vis_avs.dat");
  107. #endif
  108. g_render_effects->__SavePreset(INI_FILE);
  109. }
  110. if (g_render_effects) delete g_render_effects;
  111. g_render_effects=NULL;
  112. if (g_render_effects2) delete g_render_effects2;
  113. g_render_effects2=NULL;
  114. if (g_render_library) delete g_render_library;
  115. g_render_library=NULL;
  116. timingPrint();
  117. #ifdef LASER
  118. if (g_laser_linelist) delete g_laser_linelist;
  119. g_laser_linelist=0;
  120. laser_disconnect();
  121. #endif
  122. }