r_scat.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. // alphachannel safe 11/21/99
  25. #include <windows.h>
  26. #include <commctrl.h>
  27. #include "r_defs.h"
  28. #include "resource.h"
  29. #include "timing.h"
  30. #include "../Agave/Language/api_language.h"
  31. #ifndef LASER
  32. #define C_THISCLASS C_ScatClass
  33. #define MOD_NAME "Trans / Scatter"
  34. class C_THISCLASS : public C_RBASE {
  35. protected:
  36. public:
  37. C_THISCLASS();
  38. virtual ~C_THISCLASS();
  39. virtual int render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h);
  40. virtual char *get_desc() { static char desc[128]; return (!desc[0]?WASABI_API_LNGSTRING_BUF(IDS_TRANS_SCATTER,desc,128):desc); }
  41. virtual HWND conf(HINSTANCE hInstance, HWND hwndParent);
  42. virtual void load_config(unsigned char *data, int len);
  43. virtual int save_config(unsigned char *data);
  44. int enabled;
  45. int fudgetable[512],ftw;
  46. };
  47. #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255
  48. #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
  49. void C_THISCLASS::load_config(unsigned char *data, int len)
  50. {
  51. int pos=0;
  52. if (len-pos >= 4) { enabled=GET_INT(); pos+=4; }
  53. }
  54. int C_THISCLASS::save_config(unsigned char *data)
  55. {
  56. int pos=0;
  57. PUT_INT(enabled); pos+=4;
  58. return pos;
  59. }
  60. C_THISCLASS::C_THISCLASS()
  61. {
  62. enabled=1;
  63. ftw=0;
  64. }
  65. C_THISCLASS::~C_THISCLASS()
  66. {
  67. }
  68. int C_THISCLASS::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
  69. {
  70. int l;
  71. if (!enabled) return 0;
  72. if (ftw != w)
  73. {
  74. int x;
  75. for (x = 0; x < 512; x ++)
  76. {
  77. int yp;
  78. int xp;
  79. xp=(x%8)-4;
  80. yp=(x/8)%8-4;
  81. if (xp<0) xp++;
  82. if (yp<0) yp++;
  83. fudgetable[x]=w*yp+xp;
  84. }
  85. ftw=w;
  86. }
  87. if (isBeat&0x80000000) return 0;
  88. l=w*4;
  89. while (l-- > 0) *fbout++=*framebuffer++;
  90. l=w*(h-8);
  91. while (l-- > 0)
  92. {
  93. *fbout++ = framebuffer[fudgetable[rand()&511]];
  94. framebuffer++;
  95. }
  96. l=w*4;
  97. while (l-- > 0) *fbout++=*framebuffer++;
  98. return 1;
  99. }
  100. C_RBASE *R_Scat(char *desc)
  101. {
  102. if (desc) { strcpy(desc,MOD_NAME); return NULL; }
  103. return (C_RBASE *) new C_THISCLASS();
  104. }
  105. static C_THISCLASS *g_this;
  106. static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  107. {
  108. switch (uMsg)
  109. {
  110. case WM_INITDIALOG:
  111. if (g_this->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
  112. return 1;
  113. case WM_COMMAND:
  114. if (LOWORD(wParam) == IDC_CHECK1)
  115. {
  116. if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1))
  117. g_this->enabled=1;
  118. else
  119. g_this->enabled=0;
  120. }
  121. return 0;
  122. }
  123. return 0;
  124. }
  125. HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
  126. {
  127. g_this = this;
  128. return WASABI_API_CREATEDIALOG(IDD_CFG_SCAT,hwndParent,g_DlgProc);
  129. }
  130. #else
  131. C_RBASE *R_Scat(char *desc)
  132. {return NULL; }
  133. #endif