1
0

ld32.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. #ifdef LASER
  25. #include <windows.h>
  26. #include "ld32.h"
  27. static HINSTANCE hDll;
  28. LONG (WINAPI *_LoadPalette)(LPSTR ColorFilename, LPLONG RETURN_LDStatus);
  29. LONG (WINAPI *_WritePoint)(LONG PointNumber, PTSTRUCT *SUPPLY_PtStruct);
  30. LONG (WINAPI *_InitialQMCheck)(LPLONG RETURN_LDStatus);
  31. LONG (WINAPI *_DisplayUpdate)(void);
  32. LONG (WINAPI *_DisplayBufferStatus)(LONG *RETURN_BufferIsFree, LONG *RETURN_CurrentOutputPoints);
  33. LONG (WINAPI *_DisplayFrame)(LONG Frame);
  34. LONG (WINAPI *_WriteFrameEx)(FRAMESTRUCTEX *SUPPLY_FrameStruct, PTSTRUCT *SUPPLY_PointArray);
  35. LONG (WINAPI *_SetWorkingScanners)(LONG Scanner);
  36. LONG (WINAPI *_SetWorkingTracks)(LONG Track);
  37. LONG (WINAPI *_SetWorkingFrame)(LONG FrameNumber);
  38. LONG (WINAPI *_BeginSessionEx)(LPLONG RETURN_Version, LPLONG RETURN_MaxFrames, LPLONG RETURN_MaxPoints, LPLONG RETURN_MaxBuffer, LPLONG RETURN_UndoFrames, LPLONG RETURN_LDStatus);
  39. LONG (WINAPI *_DisplayFlags)(LONG Flags);
  40. LONG (WINAPI *_EndSession)(void);
  41. LONG (WINAPI *_GetLDDLLModuleUsage)(LPLONG ModuleUsage);
  42. LONG (WINAPI *_ResetLD)(void); //Updates all track variables
  43. LONG (WINAPI *_ReadProjectionZone)(LONG ZoneNumber, PROJECTIONZONE *RETURN_PZ);
  44. LONG (WINAPI *_OpenLDCommWindow)(void);
  45. LONG (WINAPI *_DisplayProjectionZones)(long ProjectionZoneCode);
  46. LONG WINAPI InitialQMCheck(LPLONG RETURN_LDStatus)
  47. {
  48. hDll=LoadLibrary("ld2000.dll");
  49. if (!hDll)
  50. {
  51. // printf("LD2000: error loading DLL\n");
  52. *RETURN_LDStatus=1;
  53. return 1;
  54. }
  55. #define RETR(x) *((void**)&_##x)=(void*)GetProcAddress(hDll,#x); if (!_##x) { FreeLibrary(hDll); hDll=0; *RETURN_LDStatus=1; return 1; }
  56. // \
  57. // if (!_##x) printf("LD2000: error loading DLL: " #x "\n");
  58. RETR(ReadProjectionZone);
  59. RETR(InitialQMCheck);
  60. RETR(DisplayUpdate);
  61. RETR(DisplayBufferStatus);
  62. RETR(DisplayFrame);
  63. RETR(WriteFrameEx);
  64. RETR(WritePoint);
  65. RETR(SetWorkingScanners);
  66. RETR(LoadPalette);
  67. RETR(SetWorkingTracks);
  68. RETR(SetWorkingFrame);
  69. RETR(EndSession);
  70. RETR(BeginSessionEx);
  71. RETR(DisplayFlags);
  72. RETR(ResetLD);
  73. RETR(OpenLDCommWindow);
  74. RETR(GetLDDLLModuleUsage);
  75. RETR(DisplayProjectionZones);
  76. return _InitialQMCheck(RETURN_LDStatus);
  77. }
  78. LONG WINAPI DisplayProjectionZones(long ProjectionZoneCode)
  79. {
  80. return _DisplayProjectionZones(ProjectionZoneCode);
  81. }
  82. LONG WINAPI ReadProjectionZone(LONG ZoneNumber, PROJECTIONZONE *RETURN_PZ)
  83. {
  84. if (!hDll||!_ReadProjectionZone) return 1;
  85. return _ReadProjectionZone(ZoneNumber,RETURN_PZ);
  86. }
  87. LONG WINAPI DisplayBufferStatus(LONG *RETURN_BufferIsFree, LONG *RETURN_CurrentOutputPoints)
  88. {
  89. return _DisplayBufferStatus(RETURN_BufferIsFree,RETURN_CurrentOutputPoints);
  90. }
  91. LONG WINAPI DisplayUpdate(void)
  92. {
  93. return _DisplayUpdate();
  94. }
  95. LONG WINAPI DisplayFrame(LONG Frame)
  96. {
  97. return _DisplayFrame(Frame);
  98. }
  99. LONG WINAPI WriteFrameEx(FRAMESTRUCTEX *SUPPLY_FrameStruct, PTSTRUCT *SUPPLY_PointArray)
  100. {
  101. return _WriteFrameEx(SUPPLY_FrameStruct,SUPPLY_PointArray);
  102. }
  103. LONG WINAPI SetWorkingScanners(LONG Scanner)
  104. {
  105. return _SetWorkingScanners(Scanner);
  106. }
  107. LONG WINAPI SetWorkingTracks(LONG Track)
  108. {
  109. return _SetWorkingTracks(Track);
  110. }
  111. LONG WINAPI SetWorkingFrame(LONG FrameNumber)
  112. {
  113. return _SetWorkingFrame(FrameNumber);
  114. }
  115. LONG WINAPI OpenLDCommWindow(void)
  116. {
  117. return _OpenLDCommWindow();
  118. }
  119. LONG WINAPI EndSession(void)
  120. {
  121. return _EndSession();
  122. }
  123. LONG WINAPI LoadPalette(LPSTR ColorFilename, LPLONG RETURN_LDStatus)
  124. {
  125. return _LoadPalette(ColorFilename,RETURN_LDStatus);
  126. }
  127. LONG WINAPI WritePoint(LONG PointNumber, PTSTRUCT *SUPPLY_PtStruct)
  128. {
  129. return _WritePoint(PointNumber,SUPPLY_PtStruct);
  130. }
  131. LONG WINAPI GetLDDLLModuleUsage(LPLONG ModuleUsage)
  132. {
  133. return _GetLDDLLModuleUsage(ModuleUsage);
  134. }
  135. LONG WINAPI ResetLD()
  136. {
  137. return _ResetLD();
  138. }
  139. LONG WINAPI BeginSessionEx(LPLONG RETURN_Version, LPLONG RETURN_MaxFrames, LPLONG RETURN_MaxPoints, LPLONG RETURN_MaxBuffer, LPLONG RETURN_UndoFrames, LPLONG RETURN_LDStatus)
  140. {
  141. return _BeginSessionEx(
  142. RETURN_Version, RETURN_MaxFrames,
  143. RETURN_MaxPoints, RETURN_MaxBuffer,
  144. RETURN_UndoFrames,RETURN_LDStatus);
  145. }
  146. LONG WINAPI DisplayFlags(LONG Flags)
  147. {
  148. return _DisplayFlags(Flags);
  149. }
  150. void LaserQuit()
  151. {
  152. if (hDll) FreeLibrary(hDll);
  153. hDll=0;
  154. _InitialQMCheck=0;
  155. }
  156. #endif