From 0ef6e5c8379adbf8badbc4728abe052ba92fa840 Mon Sep 17 00:00:00 2001 From: tomsons26 Date: Thu, 3 Apr 2025 14:51:05 +0300 Subject: [PATCH] [GEN][ZH] Partially cleans up WWLib (#581) --- .../Source/WWVegas/WW3D2/CMakeLists.txt | 4 - .../Source/WWVegas/WW3D2/assetmgr.cpp | 1 - .../Source/WWVegas/WW3D2/rendobj.cpp | 3 +- .../Source/WWVegas/WW3D2/texfcach.cpp | 906 ------ .../Libraries/Source/WWVegas/WW3D2/texfcach.h | 211 -- .../Source/WWVegas/WW3D2/textureloader.cpp | 1 - .../Libraries/Source/WWVegas/WW3D2/txt.cpp | 142 - .../Code/Libraries/Source/WWVegas/WW3D2/txt.h | 58 - .../Libraries/Source/WWVegas/WW3D2/ww3d.cpp | 1 - .../Libraries/Source/WWVegas/WWLib/BUFF.H | 2 +- .../Source/WWVegas/WWLib/CMakeLists.txt | 75 - .../Libraries/Source/WWVegas/WWLib/Convert.h | 173 - .../Libraries/Source/WWVegas/WWLib/FONT.H | 70 - .../Code/Libraries/Source/WWVegas/WWLib/IFF.H | 165 - .../Code/Libraries/Source/WWVegas/WWLib/INI.H | 3 - .../Code/Libraries/Source/WWVegas/WWLib/INT.H | 310 -- .../Code/Libraries/Source/WWVegas/WWLib/LCW.H | 57 - .../Libraries/Source/WWVegas/WWLib/MONO.H | 103 - .../Libraries/Source/WWVegas/WWLib/MONODRVR.H | 131 - .../Libraries/Source/WWVegas/WWLib/MPMATH.H | 165 - .../Libraries/Source/WWVegas/WWLib/PALETTE.H | 81 - .../Code/Libraries/Source/WWVegas/WWLib/PK.H | 99 - .../Code/Libraries/Source/WWVegas/WWLib/RGB.H | 95 - .../Code/Libraries/Source/WWVegas/WWLib/RLE.H | 63 - .../Libraries/Source/WWVegas/WWLib/RNDSTRAW.H | 93 - .../Libraries/Source/WWVegas/WWLib/Surface.h | 123 - .../Libraries/Source/WWVegas/WWLib/TagBlock.h | 278 -- .../Libraries/Source/WWVegas/WWLib/WATCOM.H | 118 - .../Source/WWVegas/WWLib/_convert.cpp | 46 - .../Libraries/Source/WWVegas/WWLib/_convert.h | 49 - .../Libraries/Source/WWVegas/WWLib/_mono.cpp | 47 - .../Libraries/Source/WWVegas/WWLib/_mono.h | 52 - .../Libraries/Source/WWVegas/WWLib/_timer.cpp | 51 - .../Libraries/Source/WWVegas/WWLib/_timer.h | 46 - .../Libraries/Source/WWVegas/WWLib/_xmouse.h | 56 - .../Libraries/Source/WWVegas/WWLib/blit.cpp | 415 --- .../Libraries/Source/WWVegas/WWLib/blit.h | 61 - .../Libraries/Source/WWVegas/WWLib/blitblit.h | 614 ---- .../Libraries/Source/WWVegas/WWLib/blitter.h | 94 - .../Source/WWVegas/WWLib/blowfish.cpp | 597 ---- .../Libraries/Source/WWVegas/WWLib/blowfish.h | 112 - .../Libraries/Source/WWVegas/WWLib/blowpipe.h | 83 - .../Libraries/Source/WWVegas/WWLib/blwstraw.h | 85 - .../Libraries/Source/WWVegas/WWLib/bool.h | 64 - .../Libraries/Source/WWVegas/WWLib/borlandc.h | 48 - .../Libraries/Source/WWVegas/WWLib/bsurface.h | 87 - .../Source/WWVegas/WWLib/convert.cpp | 266 -- .../Source/WWVegas/WWLib/cpudetect.cpp | 1 - .../Libraries/Source/WWVegas/WWLib/data.cpp | 325 -- .../Libraries/Source/WWVegas/WWLib/data.h | 56 - .../Libraries/Source/WWVegas/WWLib/ddraw.cpp | 646 ---- .../Code/Libraries/Source/WWVegas/WWLib/dib.h | 75 - .../Libraries/Source/WWVegas/WWLib/draw.h | 47 - .../Source/WWVegas/WWLib/dsurface.cpp | 931 ------ .../Libraries/Source/WWVegas/WWLib/dsurface.h | 205 -- .../Libraries/Source/WWVegas/WWLib/fixed.h | 220 -- .../Libraries/Source/WWVegas/WWLib/hsv.cpp | 191 -- .../Code/Libraries/Source/WWVegas/WWLib/hsv.h | 81 - .../Libraries/Source/WWVegas/WWLib/ini.cpp | 75 - .../Libraries/Source/WWVegas/WWLib/int.cpp | 53 - .../Source/WWVegas/WWLib/keyboard.cpp | 773 ----- .../Libraries/Source/WWVegas/WWLib/keyboard.h | 677 ---- .../Libraries/Source/WWVegas/WWLib/lcw.cpp | 444 --- .../Libraries/Source/WWVegas/WWLib/lcwpipe.h | 103 - .../Libraries/Source/WWVegas/WWLib/load.cpp | 112 - .../Libraries/Source/WWVegas/WWLib/misc.h | 173 - .../Source/WWVegas/WWLib/mixfile.cpp | 636 ---- .../Libraries/Source/WWVegas/WWLib/mixfile.h | 164 - .../Libraries/Source/WWVegas/WWLib/mono.cpp | 587 ---- .../Libraries/Source/WWVegas/WWLib/mpmath.cpp | 2776 ----------------- .../Source/WWVegas/WWLib/msgloop.cpp | 252 -- .../Libraries/Source/WWVegas/WWLib/msgloop.h | 59 - .../Libraries/Source/WWVegas/WWLib/obscure.h | 42 - .../Source/WWVegas/WWLib/palette.cpp | 268 -- .../Code/Libraries/Source/WWVegas/WWLib/pcx.H | 77 - .../Libraries/Source/WWVegas/WWLib/pcx.cpp | 168 - .../Libraries/Source/WWVegas/WWLib/pk.cpp | 368 --- .../Libraries/Source/WWVegas/WWLib/pkpipe.h | 135 - .../Libraries/Source/WWVegas/WWLib/pkstraw.h | 123 - .../Libraries/Source/WWVegas/WWLib/rc4.cpp | 89 - .../Code/Libraries/Source/WWVegas/WWLib/rc4.h | 66 - .../Libraries/Source/WWVegas/WWLib/rcfile.cpp | 129 - .../Libraries/Source/WWVegas/WWLib/rcfile.h | 95 - .../Libraries/Source/WWVegas/WWLib/rgb.cpp | 231 -- .../Libraries/Source/WWVegas/WWLib/rle.cpp | 262 -- .../Libraries/Source/WWVegas/WWLib/rlerle.h | 709 ----- .../Source/WWVegas/WWLib/rndstrng.cpp | 69 - .../Libraries/Source/WWVegas/WWLib/rndstrng.h | 70 - .../Code/Libraries/Source/WWVegas/WWLib/rng.h | 56 - .../Libraries/Source/WWVegas/WWLib/rsacrypt.h | 349 --- .../Source/WWVegas/WWLib/sampler.cpp | 264 -- .../Libraries/Source/WWVegas/WWLib/sampler.h | 133 - .../Libraries/Source/WWVegas/WWLib/search.h | 2 +- .../Libraries/Source/WWVegas/WWLib/sha.cpp | 328 -- .../Code/Libraries/Source/WWVegas/WWLib/sha.h | 195 -- .../Libraries/Source/WWVegas/WWLib/shapeset.h | 271 -- .../Libraries/Source/WWVegas/WWLib/shapipe.h | 64 - .../Libraries/Source/WWVegas/WWLib/shastraw.h | 71 - .../Libraries/Source/WWVegas/WWLib/smartptr.h | 71 - .../Source/WWVegas/WWLib/srandom.cpp | 197 -- .../Libraries/Source/WWVegas/WWLib/srandom.h | 67 - .../Code/Libraries/Source/WWVegas/WWLib/stl.h | 59 - .../Libraries/Source/WWVegas/WWLib/surfrect.h | 90 - .../Source/WWVegas/WWLib/tagblock.cpp | 651 ---- .../Libraries/Source/WWVegas/WWLib/timer.h | 689 ---- .../Libraries/Source/WWVegas/WWLib/trackwin.h | 89 - .../Libraries/Source/WWVegas/WWLib/trackxy.h | 69 - .../Libraries/Source/WWVegas/WWLib/visualc.h | 2 +- .../Libraries/Source/WWVegas/WWLib/win.cpp | 51 - .../Libraries/Source/WWVegas/WWLib/wwfont.cpp | 632 ---- .../Libraries/Source/WWVegas/WWLib/wwfont.h | 143 - .../Libraries/Source/WWVegas/WWLib/wwmouse.h | 242 -- .../Libraries/Source/WWVegas/WWLib/xmouse.h | 125 - .../Source/WWVegas/WWLib/xsurface.cpp | 903 ------ .../Libraries/Source/WWVegas/WWLib/xsurface.h | 132 - .../Code/Tools/WorldBuilder/src/wbview3d.cpp | 2 - .../Source/WWVegas/WW3D2/CMakeLists.txt | 4 - .../Source/WWVegas/WW3D2/assetmgr.cpp | 1 - .../Source/WWVegas/WW3D2/rendobj.cpp | 3 +- .../Source/WWVegas/WW3D2/texfcach.cpp | 906 ------ .../Libraries/Source/WWVegas/WW3D2/texfcach.h | 211 -- .../Source/WWVegas/WW3D2/textureloader.cpp | 1 - .../Source/WWVegas/WW3D2/texturethumbnail.cpp | 3 +- .../Libraries/Source/WWVegas/WW3D2/txt.cpp | 142 - .../Code/Libraries/Source/WWVegas/WW3D2/txt.h | 58 - .../Libraries/Source/WWVegas/WW3D2/ww3d.cpp | 1 - .../Libraries/Source/WWVegas/WWLib/BUFF.H | 2 +- .../Source/WWVegas/WWLib/CMakeLists.txt | 76 - .../Libraries/Source/WWVegas/WWLib/Convert.h | 173 - .../Libraries/Source/WWVegas/WWLib/FONT.H | 70 - .../Code/Libraries/Source/WWVegas/WWLib/IFF.H | 165 - .../Code/Libraries/Source/WWVegas/WWLib/INI.H | 3 - .../Code/Libraries/Source/WWVegas/WWLib/INT.H | 310 -- .../Code/Libraries/Source/WWVegas/WWLib/LCW.H | 57 - .../Libraries/Source/WWVegas/WWLib/MONO.H | 103 - .../Libraries/Source/WWVegas/WWLib/MONODRVR.H | 131 - .../Libraries/Source/WWVegas/WWLib/MPMATH.H | 165 - .../Libraries/Source/WWVegas/WWLib/PALETTE.H | 81 - .../Code/Libraries/Source/WWVegas/WWLib/PK.H | 99 - .../Code/Libraries/Source/WWVegas/WWLib/RGB.H | 95 - .../Code/Libraries/Source/WWVegas/WWLib/RLE.H | 63 - .../Libraries/Source/WWVegas/WWLib/RNDSTRAW.H | 93 - .../Libraries/Source/WWVegas/WWLib/Surface.h | 123 - .../Libraries/Source/WWVegas/WWLib/TagBlock.h | 278 -- .../Libraries/Source/WWVegas/WWLib/WATCOM.H | 118 - .../Source/WWVegas/WWLib/_convert.cpp | 46 - .../Libraries/Source/WWVegas/WWLib/_convert.h | 49 - .../Libraries/Source/WWVegas/WWLib/_mono.cpp | 47 - .../Libraries/Source/WWVegas/WWLib/_mono.h | 52 - .../Libraries/Source/WWVegas/WWLib/_timer.cpp | 51 - .../Libraries/Source/WWVegas/WWLib/_timer.h | 46 - .../Libraries/Source/WWVegas/WWLib/_xmouse.h | 56 - .../Libraries/Source/WWVegas/WWLib/blit.cpp | 415 --- .../Libraries/Source/WWVegas/WWLib/blit.h | 61 - .../Libraries/Source/WWVegas/WWLib/blitblit.h | 614 ---- .../Libraries/Source/WWVegas/WWLib/blitter.h | 94 - .../Source/WWVegas/WWLib/blowfish.cpp | 597 ---- .../Libraries/Source/WWVegas/WWLib/blowfish.h | 112 - .../Source/WWVegas/WWLib/blowpipe.cpp | 201 -- .../Libraries/Source/WWVegas/WWLib/blowpipe.h | 83 - .../Source/WWVegas/WWLib/blwstraw.cpp | 160 - .../Libraries/Source/WWVegas/WWLib/blwstraw.h | 85 - .../Libraries/Source/WWVegas/WWLib/bool.h | 64 - .../Libraries/Source/WWVegas/WWLib/borlandc.h | 48 - .../Libraries/Source/WWVegas/WWLib/bsurface.h | 87 - .../Source/WWVegas/WWLib/convert.cpp | 266 -- .../Source/WWVegas/WWLib/cpudetect.cpp | 1 - .../Libraries/Source/WWVegas/WWLib/data.cpp | 325 -- .../Libraries/Source/WWVegas/WWLib/data.h | 56 - .../Libraries/Source/WWVegas/WWLib/ddraw.cpp | 646 ---- .../Libraries/Source/WWVegas/WWLib/dib.cpp | 174 -- .../Code/Libraries/Source/WWVegas/WWLib/dib.h | 75 - .../Libraries/Source/WWVegas/WWLib/draw.cpp | 190 -- .../Libraries/Source/WWVegas/WWLib/draw.h | 47 - .../Source/WWVegas/WWLib/dsurface.cpp | 931 ------ .../Libraries/Source/WWVegas/WWLib/dsurface.h | 205 -- .../Libraries/Source/WWVegas/WWLib/fixed.cpp | 248 -- .../Libraries/Source/WWVegas/WWLib/fixed.h | 220 -- .../Libraries/Source/WWVegas/WWLib/hsv.cpp | 191 -- .../Code/Libraries/Source/WWVegas/WWLib/hsv.h | 81 - .../Libraries/Source/WWVegas/WWLib/ini.cpp | 75 - .../Libraries/Source/WWVegas/WWLib/int.cpp | 53 - .../Source/WWVegas/WWLib/keyboard.cpp | 773 ----- .../Libraries/Source/WWVegas/WWLib/keyboard.h | 677 ---- .../Libraries/Source/WWVegas/WWLib/lcw.cpp | 444 --- .../Source/WWVegas/WWLib/lcwpipe.cpp | 313 -- .../Libraries/Source/WWVegas/WWLib/lcwpipe.h | 103 - .../Libraries/Source/WWVegas/WWLib/load.cpp | 112 - .../Libraries/Source/WWVegas/WWLib/misc.h | 173 - .../Source/WWVegas/WWLib/mixfile.cpp | 699 ----- .../Libraries/Source/WWVegas/WWLib/mixfile.h | 166 - .../Libraries/Source/WWVegas/WWLib/mono.cpp | 587 ---- .../Libraries/Source/WWVegas/WWLib/mpmath.cpp | 2776 ----------------- .../Source/WWVegas/WWLib/msgloop.cpp | 254 -- .../Libraries/Source/WWVegas/WWLib/msgloop.h | 59 - .../Source/WWVegas/WWLib/obscure.cpp | 233 -- .../Libraries/Source/WWVegas/WWLib/obscure.h | 42 - .../Source/WWVegas/WWLib/palette.cpp | 268 -- .../Code/Libraries/Source/WWVegas/WWLib/pcx.H | 77 - .../Libraries/Source/WWVegas/WWLib/pcx.cpp | 168 - .../Libraries/Source/WWVegas/WWLib/pk.cpp | 368 --- .../Libraries/Source/WWVegas/WWLib/pkpipe.cpp | 288 -- .../Libraries/Source/WWVegas/WWLib/pkpipe.h | 135 - .../Source/WWVegas/WWLib/pkstraw.cpp | 304 -- .../Libraries/Source/WWVegas/WWLib/pkstraw.h | 123 - .../Libraries/Source/WWVegas/WWLib/point.cpp | 68 - .../Libraries/Source/WWVegas/WWLib/rc4.cpp | 257 -- .../Code/Libraries/Source/WWVegas/WWLib/rc4.h | 78 - .../Libraries/Source/WWVegas/WWLib/rcfile.cpp | 129 - .../Libraries/Source/WWVegas/WWLib/rcfile.h | 96 - .../Libraries/Source/WWVegas/WWLib/rgb.cpp | 231 -- .../Libraries/Source/WWVegas/WWLib/rle.cpp | 262 -- .../Libraries/Source/WWVegas/WWLib/rlerle.h | 709 ----- .../Source/WWVegas/WWLib/rndstraw.cpp | 320 -- .../Source/WWVegas/WWLib/rndstrng.cpp | 57 - .../Libraries/Source/WWVegas/WWLib/rndstrng.h | 67 - .../Code/Libraries/Source/WWVegas/WWLib/rng.h | 56 - .../Libraries/Source/WWVegas/WWLib/rsacrypt.h | 349 --- .../Source/WWVegas/WWLib/sampler.cpp | 264 -- .../Libraries/Source/WWVegas/WWLib/sampler.h | 134 - .../Libraries/Source/WWVegas/WWLib/search.h | 2 +- .../Libraries/Source/WWVegas/WWLib/sha.cpp | 328 -- .../Code/Libraries/Source/WWVegas/WWLib/sha.h | 195 -- .../Libraries/Source/WWVegas/WWLib/shapeset.h | 271 -- .../Source/WWVegas/WWLib/shapipe.cpp | 90 - .../Libraries/Source/WWVegas/WWLib/shapipe.h | 64 - .../Source/WWVegas/WWLib/shastraw.cpp | 98 - .../Libraries/Source/WWVegas/WWLib/shastraw.h | 71 - .../Libraries/Source/WWVegas/WWLib/smartptr.h | 71 - .../Source/WWVegas/WWLib/srandom.cpp | 219 -- .../Libraries/Source/WWVegas/WWLib/srandom.h | 67 - .../Code/Libraries/Source/WWVegas/WWLib/stl.h | 59 - .../Source/WWVegas/WWLib/surface.cpp | 39 - .../Libraries/Source/WWVegas/WWLib/surfrect.h | 90 - .../Source/WWVegas/WWLib/tagblock.cpp | 651 ---- .../Libraries/Source/WWVegas/WWLib/timer.h | 689 ---- .../Libraries/Source/WWVegas/WWLib/trackwin.h | 89 - .../Libraries/Source/WWVegas/WWLib/trackxy.h | 69 - .../Libraries/Source/WWVegas/WWLib/visualc.h | 2 +- .../Libraries/Source/WWVegas/WWLib/win.cpp | 51 - .../Libraries/Source/WWVegas/WWLib/wwfont.cpp | 632 ---- .../Libraries/Source/WWVegas/WWLib/wwfont.h | 143 - .../Source/WWVegas/WWLib/wwmouse.cpp | 1005 ------ .../Libraries/Source/WWVegas/WWLib/wwmouse.h | 242 -- .../Libraries/Source/WWVegas/WWLib/xmouse.h | 125 - .../Source/WWVegas/WWLib/xsurface.cpp | 903 ------ .../Libraries/Source/WWVegas/WWLib/xsurface.h | 132 - .../Code/Tools/WorldBuilder/src/wbview3d.cpp | 2 - 248 files changed, 10 insertions(+), 53809 deletions(-) delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/Convert.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/FONT.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/IFF.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/INT.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/LCW.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/MONO.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/PK.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/RGB.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/RLE.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/Surface.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blit.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blit.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blitblit.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blitter.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/bool.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/borlandc.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/bsurface.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/convert.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/data.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/data.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/dib.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/draw.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/fixed.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/int.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/load.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/misc.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/mono.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/obscure.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/palette.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/pk.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rle.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rlerle.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rng.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/sampler.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/sha.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/sha.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/shapeset.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/shapipe.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/shastraw.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/smartptr.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/srandom.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/stl.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/surfrect.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/timer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/trackwin.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/trackxy.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/win.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/xmouse.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Convert.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/FONT.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/IFF.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INT.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/LCW.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONO.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PK.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RGB.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RLE.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Surface.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitblit.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitter.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bool.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/borlandc.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bsurface.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/convert.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/int.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/load.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/misc.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mono.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/palette.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.H delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pk.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/point.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rle.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rlerle.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstraw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rng.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sampler.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapeset.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/smartptr.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/srandom.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/stl.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surface.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surfrect.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/timer.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackwin.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackxy.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/win.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xmouse.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.h diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index c11471914b1..1dbc638ea58 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -90,13 +90,11 @@ set(WW3D2_SRC streakRender.cpp stripoptimizer.cpp surfaceclass.cpp - texfcach.cpp texproject.cpp texture.cpp texturefilter.cpp textureloader.cpp texturethumbnail.cpp - txt.cpp vertmaterial.cpp visrasterizer.cpp w3d_dep.cpp @@ -202,13 +200,11 @@ set(WW3D2_SRC streakRender.h stripoptimizer.h surfaceclass.h - texfcach.h texproject.h texture.h texturefilter.h textureloader.h texturethumbnail.h - txt.h vertmaterial.h visrasterizer.h w3d_dep.h diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index 420454215dc..501891293ff 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -98,7 +98,6 @@ #include "distlod.h" #include "hlod.h" #include "agg_def.h" -#include "texfcach.h" #include "wwstring.h" #include "wwmemlog.h" #include "dazzle.h" diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp index 7122aa5f566..f8ee1fbb43a 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp @@ -71,8 +71,7 @@ #include "rendobj.h" #include "assetmgr.h" -#include "_mono.h" -#include "bsurface.h" +#include "win.h" #include "pot.h" #include "scene.h" #include "colmath.h" diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp deleted file mode 100644 index ea1a76c8f1d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp +++ /dev/null @@ -1,906 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/texfcach.cpp 5 8/24/01 3:23p Jani_p $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/texfcach.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 8/24/01 11:50a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * TextureFileCache::TextureFileCache -- Open cache. * - * ~TextureFileCache::TextureFileCache -- Shut down texture cache system. * - * TextureFileCache::Save_Texture -- Save the texture into the cache. * - * TextureFileCache::Load_Texture -- Load texture from cache into surface. * - * *TextureFileCache::_Create_File_Name -- Create a file name from prefix * - * *TextureFileCache::Load_Original_Texture_Surface -- Create the initial * - * *TextureFileCache::Open_Texture_Handle -- Set the TextureHandle and Header.. * - * TextureFileCache::Close_Texture_Handle -- Close the current texture so we can open anoth* - * TextureFileCache::Read_Texture -- Read in the texture into surface buffer. * - * *TextureFileCache::Create_First_Texture_As_Surface -- Load first texture into a surface. * - * *TextureFileCache::Find_Cached_Surface -- Search for a texture already cached. * - * TextureFileCache::Add_Cached_Surface -- Add a new cached texture. * - * *TFC::Get_Surface -- Load a texture reduced N times. * - * TextureFileCache::Reset_File -- virtual function to reset file and write out file. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifdef WW3D_DX8 -#include "texfcach.h" -#include "mutex.h" -#include "thread.h" -#include -#include "wwdebug.h" -#include "simplevec.h" -#include "wwstring.h" -#include "textureloader.h" -#include "texture.h" -#include "ffactory.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#ifdef _UNIX -#include "osdep.h" -#endif - -#define FILE_HEADER_NAME "Texture File Cache Header" - - -char *TextureFileCache::_FileNamePtr = NULL; -static int Instances=0; - -static CriticalSectionClass mutex(0); -static SimpleVecClass compression_buffer; - -const char BUFFER_OVERRUN_TEST_VALUE=((char)0x7d); - -static char* Get_Compression_Buffer(int size) -{ - compression_buffer.Uninitialised_Grow(size+1); - compression_buffer[size]=BUFFER_OVERRUN_TEST_VALUE; - return &(compression_buffer[0]); -} - -static void Verify_Compression_Buffer() -{ - WWASSERT(compression_buffer[compression_buffer.Length()-1]==BUFFER_OVERRUN_TEST_VALUE); -} - - -class Compressor -{ -public: - - static int Compress - ( - const unsigned char * in, - unsigned int in_len, - unsigned char * out, - unsigned int * out_len - ); - - static int Decompress - ( - const unsigned char * in, - unsigned int in_len, - unsigned char * out, - unsigned int * out_len - ); - -}; - -int Compressor::Compress( const unsigned char * in, unsigned int in_len, - unsigned char * out, unsigned int * out_len ) -{ - if (!in || !out || !out_len) - return FALSE; - - if (in_len <= 0) - return false; - - memcpy(out, in, in_len); - - *out_len = in_len; - - return TRUE; -} - -int Compressor::Decompress( const unsigned char * in, unsigned int in_len, - unsigned char * out, unsigned int * out_len ) -{ - if (!in || !out || !out_len) - return FALSE; - - if (in_len <= 0) - return false; - - memcpy(out, in, in_len); - - *out_len = in_len; - - return TRUE; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// TextureFileCache ///////////////////////////////////////////// - -/*********************************************************************************************** - * TextureFileCache::TextureFileCache -- Open cache. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/07/1999 SKB : Created. * - * 06/27/2000 SKB : added CachedSurfaces * - * 08/14/2000 : Check for revision number. * - *=============================================================================================*/ -TextureFileCache::TextureFileCache(const char *fileprefix): - File(_Create_File_Name(fileprefix)), - CurrentTexture(NULL), - TextureHandle(NULL), - Header(), - CachedSurfaces(), - Offsets(NULL), - NumCachedTextures(0) -{ - WWASSERT(!Instances); - Instances++; - - // This was allocated by _Create_File_Name() and need to go away now. - delete _FileNamePtr; - _FileNamePtr = NULL; - - memset(CachedSurfaces, 0, sizeof(CachedSurfaces)); - - bool reset = false; - TagBlockHandle *handle = File.Open_Tag(FILE_HEADER_NAME); - if (handle) { - FileHeader fileheader; - - // Read in header for others to use. - handle->Read(&fileheader, sizeof(fileheader)); - - if (fileheader.Version != FileHeader::TCF_VERSION) { - reset = true; - } - - // Close down handle. - delete handle; - } else { - reset = true; - } - - if (reset) { - Reset_File(); - } -} - -/*********************************************************************************************** - * *TextureFileCache::_Create_File_Name -- Create a file name from prefix passed in. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Caller of this function must free _FileNamePtr when done with it. * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -char *TextureFileCache::_Create_File_Name(const char *fileprefix) -{ - bool addpath = (*fileprefix != '\\' && fileprefix[1] != ':'); - - assert(!_FileNamePtr); - _FileNamePtr = W3DNEWARRAY char[strlen(fileprefix) + (addpath ? 256 : 6)]; - - char path[_MAX_PATH]; - if (addpath && _getcwd(path, _MAX_PATH )) { - sprintf(_FileNamePtr, "%s\\%s.tfc", path, fileprefix); - } else { - // Create a file name. - strcpy(_FileNamePtr, fileprefix); - strcat(_FileNamePtr, ".tfc"); - *_FileNamePtr = 0; - } - - return(_FileNamePtr); -} - - -/*********************************************************************************************** - * ~TextureFileCache::TextureFileCache -- Shut down texture cache system. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/07/1999 SKB : Created. * - *=============================================================================================*/ -TextureFileCache::~TextureFileCache() -{ - // Make sure we have shut down everything. - Close_Texture_Handle(); - - Instances--; - WWASSERT(!Instances); -} - - -/************************************************************************** - * TextureFileCache::Reset_File -- virtual function to reset file and wri * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/14/2000 : Created. * - *========================================================================*/ -void TextureFileCache::Reset_File() -{ - File.Reset_File(); - - TagBlockHandle *handle = File.Create_Tag(FILE_HEADER_NAME); - if (handle) { - FileHeader fileheader; - fileheader.Version = FileHeader::TCF_VERSION; - - // Read in header for others to use. - handle->Write(&fileheader, sizeof(fileheader)); - - // Close down handle. - delete handle; - } else { - assert(false); - } -} - -/*********************************************************************************************** - * TextureFileCache::Save_Texture -- Save the texture into the cache. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - * 06/27/2000 SKB : added Header.PixelFormat * - * 06/27/2000 SKB : changed cached textures to surfaces * - * 08/14/2000 : save file's datatime stamp. * - *=============================================================================================*/ -bool TextureFileCache::Save_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq, srColorSurfaceIFace& origsurface) -{ - CriticalSectionClass::LockClass m(mutex); - int idx; - unsigned lod; - - // Open up our new texture. - Open_Texture_Handle(texturename); - - // Create a new texture now. - TextureHandle = File.Create_Tag(texturename); - if (!TextureHandle) { - Close_Texture_Handle(); - return(false); - } - - // Setup the Header. - FileClass *asset=_TheFileFactory->Get_File(texturename); - WWASSERT( asset ); - asset->Open(); - Header.FileTime = asset->Get_Date_Time(); - Header.NumMipMaps = (mreq.smallLOD - mreq.largeLOD) + 1; - Header.LargestWidth = mreq.levels[mreq.largeLOD]->getWidth(); - Header.LargestHeight = mreq.levels[mreq.largeLOD]->getHeight(); - Header.SourceWidth = origsurface.getWidth(); - Header.SourceHeight = origsurface.getHeight(); - mreq.levels[mreq.largeLOD]->getPixelFormat(Header.PixelFormat); - origsurface.getPixelFormat(Header.SourcePixelFormat); - - _TheFileFactory->Return_File(asset); - asset=NULL; - - // Write it out. - TextureHandle->Write(&Header, sizeof(Header)); - - // Setup offset table. - Offsets = W3DNEWARRAY OffsetTableType[Header.NumMipMaps + 1]; - - // Write for now, but we will need to seek back to write final data. - int tableoffset = TextureHandle->Tell(); - TextureHandle->Write(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - // Now write out the textures. - for (idx = 0, lod = mreq.largeLOD; lod <= mreq.smallLOD; idx++, lod++) { - srColorSurface *surface = mreq.levels[lod]; - WWASSERT(surface->getDataPtr()); - - Offsets[idx].Offset = TextureHandle->Tell(); - Offsets[idx].Size = surface->getDataSize(); - - // Save data pointers so we don't need to read them from disk next time. - Add_Cached_Surface(surface); - - int compsize,retcode; - - int buf_size=surface->getDataSize(); - retcode = Compressor::Compress( (const unsigned char *) surface->getDataPtr(), - (unsigned int) surface->getDataSize(), - (unsigned char *) Get_Compression_Buffer(buf_size), - (unsigned *) &compsize); - - - // Lots-o-test to make sure that the compression did what we want. - assert(retcode == TRUE); - Verify_Compression_Buffer(); - - int readin = TextureHandle->Write(Get_Compression_Buffer(compsize), compsize); - assert(readin == compsize); - } - - int pos = TextureHandle->Seek(0, SEEK_END); - - // Set last one so we can get a compressed size of last texture. - Offsets[idx].Offset = TextureHandle->Tell(); - Offsets[idx].Size = 0; - - // Now write out header for good. - TextureHandle->Seek(tableoffset, SEEK_SET); - TextureHandle->Write(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - pos = TextureHandle->Seek(0, SEEK_END); - - // End write access so that it gets flushed out to disk. - TextureHandle->End_Write_Access(); - - return (true); -} - -/*********************************************************************************************** - * *TextureFileCache::Load_Original_Texture_Surface -- Create the initial surface that would * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Sureface is only needed to get default values. The texel data does not get filled in. * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Load_Original_Texture_Surface(const char *texturename) -{ - CriticalSectionClass::LockClass m(mutex); - if (Open_Texture_Handle(texturename)) { - // Create surface that we wish to return. - srColorSurfaceIFace *surface = W3DNEW srColorSurface(Header.SourcePixelFormat, Header.SourceWidth, Header.SourceHeight); - return(surface); - } - return(NULL); -} - -/*********************************************************************************************** - * *TFC::Get_Surface -- Load a texture reduced N times. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/2000 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Get_Surface(const char *texturename, unsigned int reduce_factor) -{ - CriticalSectionClass::LockClass m(mutex); - - // If we can't get a handle, then we can't load the texture. - if (!Open_Texture_Handle(texturename)) { - return(0); - } - - if (reduce_factor >= (unsigned int)(Header.NumMipMaps)) { - reduce_factor=Header.NumMipMaps-1; - } - - // Figure out the width and height of texture. - int width = Header.LargestWidth >> reduce_factor; - int height = Header.LargestHeight >> reduce_factor; - if (!width) width = 1; - if (!height) height = 1; - - // Create surface to return. - srColorSurface *surface = W3DNEW srColorSurface(Header.PixelFormat, width, height); - int size = Texture_Size(reduce_factor); - assert(size == surface->getDataSize()); - - // See if this texture is already in memory. - srColorSurface *cached = Find_Cached_Surface(size); - if (cached) { - assert(size == cached->getDataSize()); - memcpy(surface->getDataPtr(), cached->getDataPtr(), size); - } else { - // Cache pointer so if we need texture again, we will have a pointer to - // valid texture data instead of reading it from the file. - Add_Cached_Surface(surface); - - // Read texture in - note that Textures[lod] has to be set prior to this. - Read_Texture(reduce_factor, surface); - } - return(surface); -} - -/*********************************************************************************************** - * TextureFileCache::Load_Texture -- Load texture from cache into surface. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - * 06/02/1999 SKB : deal with texture requests larger then what is in cache. * - * 06/27/2000 SKB : changed cached textures to surfaces * - *=============================================================================================*/ -bool TextureFileCache::Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq) -{ - CriticalSectionClass::LockClass m(mutex); - // If we can't get a handle, then we can't load the texture. - if (!Open_Texture_Handle(texturename)) { - return(false); - } - - // NOTE: Mip maps that are saved in the cache are the first mip maps requested and created - // for a given texture name. If a user susequently requests mip maps of different - // sizes that are not in the cache, they will be created by use of surface copy functions. - // When this happens it is unfortunate because it indicates some sort of inefficiency. - // In code below I have put in comments 'A WASTE' to indicate what part of code deels with it. - int idx; - unsigned lod; - - // Get largest size of texture in file (idx) and what is required (lod). - int idxsize = Texture_Size(0); - int lodsize = -1; - - // Now skip any mip maps that we want but are not in the cache. (A WASTE). - for (lod = mreq.largeLOD; lod <= mreq.smallLOD; lod++) { - lodsize = mreq.levels[lod]->getDataSize(); - if (lodsize <= idxsize) { - break; - } - } - // make sure largeLOD <= smallLOD. - assert(lodsize != -1); - - // Skip past all mipmap levels that we do not want in the file. - for (idx = 0; idx < Header.NumMipMaps; idx++) { - idxsize = Texture_Size(idx); - if (idxsize <= lodsize) { - break; - } - } - - // Save off the first lod and what index it is. - unsigned firstlod = lod; - - // Now if we have in the file something that the texture needs, load it. (This is most desired.) - if (idxsize == lodsize) { - // Read in textures that we have and need. - while ((lod <= mreq.smallLOD) && (idx < Header.NumMipMaps)) { - srColorSurface *surface = mreq.levels[lod]; - int size = surface->getDataSize(); assert(Texture_Size(idx) == size); - - // See if we can find the texture already cached. - srColorSurface *cached = Find_Cached_Surface(size); - - // See if texture has already been read in. - if (cached) { - assert(size == cached->getDataSize()); - - // Copy data over using size of dest surface incase asserts disabled and sizes are not right. - memcpy(surface->getDataPtr(), cached->getDataPtr(), size); - } else { - // Cache pointer so if we need texture again, we will have a pointer to - // valid texture data instead of reading it from the file. - Add_Cached_Surface(surface); - - // Read texture in - note that Textures[lod] has to be set prior to this. - Read_Texture(idx, surface); - } - - idx++, lod++; - } - } - - // Save last lod. - unsigned lastlod = lod - 1; - - // largest surface loaded. - srColorSurfaceIFace *surface = NULL; - if (firstlod < lastlod) { - surface = mreq.levels[firstlod]; - surface->addReference(); - } - - // If user requested a texture larger then what we have saved, then - // we will have to scale it up for him. - // NOTE: This is normally not desired. It typically means the user is - // creating a texture larger then the original source - a waste. - if (mreq.largeLOD < firstlod) { - // If there has not been a surface loaded yet, then do so now. - if (!surface) { - surface = Create_First_Texture_As_Surface(mreq.levels[mreq.largeLOD]); - } - - // Now scale the largest mip map we had up to what user wants (ONCE AGAIN: A WASTE). - for (lod = mreq.largeLOD; lod <= firstlod; lod++) { - // Do a surface scale. - surface->copy(*mreq.levels[lod]); - } - } - - // Are there more smaller lod's that are not in the cache? - if (lastlod < mreq.smallLOD) { - // If there has not been a surface loaded yet, then do so now. - if (!surface) { - surface = Create_First_Texture_As_Surface(mreq.levels[mreq.largeLOD]); - } - - // Now scale the largest mip map we had up to what user wants (ONCE AGAIN: A WASTE). - for (lod = lastlod + 1; lod <= mreq.smallLOD; lod++) { - // Do a surface scale. - surface->copy(*mreq.levels[lod]); - } - } - - // Done with this one. - if (surface) { - surface->release(); - } - - return (true); -} - -/*********************************************************************************************** - * TextureFileCache::Read_Texture -- Read in the texture into surface buffer. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/01/1999 SKB : Created. * - * 06/27/2000 SKB : changed cached textures to surfaces * - *=============================================================================================*/ -void TextureFileCache::Read_Texture(int offsetidx, srColorSurface *surface) -{ - // Seek to correct spot. - TextureHandle->Seek(Offsets[offsetidx].Offset, SEEK_SET); - - // Figure out how much read in and make sure it is correct size. - int compsize = Compressed_Texture_Size(offsetidx); - - // Read in texture from cache. - int readin = TextureHandle->Read(Get_Compression_Buffer(compsize), compsize); - assert(readin == compsize); - - // Set values so we can assert if overrun. - Verify_Compression_Buffer(); - - // Decompress into texture pointer. - int retcode, decompsize; - retcode = Compressor::Decompress( (const unsigned char*) Get_Compression_Buffer(compsize), - (unsigned int) compsize, - (unsigned char*) surface->getDataPtr(), - (unsigned *) &decompsize); - - // Lots-o-test to make sure that the compression did what we want. - assert(retcode == TRUE); - assert(decompsize == Texture_Size(offsetidx)); - Verify_Compression_Buffer(); -} - -/*********************************************************************************************** - * *TextureFileCache::Create_First_Texture_As_Surface -- Load first texture into a surface. * - * * - * INPUT: * - * srColorSurfaceIFace *surfacetype - only used to create surface type we want. * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Create_First_Texture_As_Surface(srColorSurfaceIFace *surfacetype) -{ - srColorSurfaceIFace::PixelFormat pf; - - // Get our pixel format. - surfacetype->getPixelFormat(pf); - - // Create a surface we can load the largest texture into it - srColorSurface *surface = W3DNEW srColorSurface(pf, Header.LargestWidth, Header.LargestHeight); - assert(Texture_Size(0) == surface->getDataSize()); - - // Read in texture to our surface data.. - Read_Texture(0, surface); - - return(surface); -} - -/*********************************************************************************************** - * *TextureFileCache::Open_Texture_Handle -- Set the TextureHandle and Header.. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -bool TextureFileCache::Open_Texture_Handle(const char *fname) -{ - if (TextureHandle) { - assert(CurrentTexture); - if (!strcmpi(fname, CurrentTexture)) { - return(true); - } - // Wrong texture, close it down so we can open another. - Close_Texture_Handle(); - } - if (!CurrentTexture) { - CurrentTexture = strdup(fname); - } - - #if 0 - // If this is texture is newer then our texture file, reset file. - // This means that next time the texture cache file gets opened, all the - // previous textures will be loaded. - // SKB 8/14/2000 : Removed to put in better system below.. - RawFileClass asset(fname); - asset.Open(); - if (asset.Get_Date_Time() > File.Get_Date_Time()) { - Reset_File(); - } - #endif - - // See if we have the texture in the file cache yet. - TextureHandle = File.Open_Tag(fname); - if (TextureHandle) { - // Read in header for others to use. - TextureHandle->Read(&Header, sizeof(Header)); - - file_auto_ptr asset(_TheFileFactory, fname); - asset->Open(); - - // Make sure it is same file. - if (Header.FileTime != asset->Get_Date_Time()) { - - delete TextureHandle; - TextureHandle = NULL; - - Reset_File(); - return(false); - } - - // Load up the offset table. - Offsets = W3DNEWARRAY OffsetTableType[Header.NumMipMaps + 1]; - TextureHandle->Read(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - return(true); - } - - return(false); -} - -/*********************************************************************************************** - * TextureFileCache::Close_Texture_Handle -- Close the current texture so we can open another. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/01/1999 SKB : Created. * - *=============================================================================================*/ -void TextureFileCache::Close_Texture_Handle() -{ - if (CurrentTexture) { - free(CurrentTexture); - CurrentTexture = NULL; - - if (TextureHandle) { - delete TextureHandle; - TextureHandle = NULL; - } - while (NumCachedTextures--) { - assert(CachedSurfaces[NumCachedTextures]); - CachedSurfaces[NumCachedTextures]->release(); - CachedSurfaces[NumCachedTextures] = 0; - } - NumCachedTextures = 0; - - if (Offsets) { - delete[] Offsets; - Offsets = NULL; - } - } else { - assert(!CurrentTexture); - } -} - -/*********************************************************************************************** - * *TextureFileCache::Find_Cached_Surface -- Search for a texture already cached. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurface *TextureFileCache::Find_Cached_Surface(int size) -{ - // Search through each allocated record for the right size. - for (int idx = 0; idx < NumCachedTextures; idx++) { - if (CachedSurfaces[idx]->getDataSize() == size) { - return(CachedSurfaces[idx]); - } - } - return(NULL); -} - -/*********************************************************************************************** - * TextureFileCache::Add_Cached_Surface -- Add a new cached texture. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -void TextureFileCache::Add_Cached_Surface(srColorSurface *surface) -{ -// return; - assert(!Find_Cached_Surface(surface->getDataSize())); - - // If are cache is full, use the smallest one's space. - int surface_idx = -1; - if (NumCachedTextures == MAX_CACHED_SURFACES) { - // Make sure there are some cached textures. - // Assume first is smallest. - int smallsize = 0xfffffff; - int smallidx = -1; - - // Look for any others that might be smaller. - for (int idx = 0; idx < NumCachedTextures; idx++) { - int size = CachedSurfaces[idx]->getDataSize(); - if (size < smallsize) { - // Found one. - smallsize = size; - smallidx = idx; - } - } - surface_idx = smallidx; - CachedSurfaces[idx]->release(); - CachedSurfaces[idx] = 0; - } else { - // Use next slot in array. - assert(NumCachedTextures < MAX_CACHED_SURFACES); - surface_idx = NumCachedTextures; - NumCachedTextures++; - } - assert(surface_idx >= 0); - assert(!CachedSurfaces[surface_idx]); - - CachedSurfaces[surface_idx] = surface; - surface->addReference(); -} - - -bool TextureFileCache::Validate_Texture(const char* FileName) -{ - // The functions used in here are all thread safe so this function doesn't have to be mutex guarded - - if (!Texture_Exists(FileName)) { - if (!TextureLoader::Texture_File_Exists(FileName)) { - return false; - } - // We need to load the surface from the file first to determine the real size - srColorSurfaceIFace* TempSurfacePtr = ::Load_Surface(FileName); - if (!TempSurfacePtr) return false; - - int w=TempSurfacePtr->getWidth(); - srColorSurfaceIFace::PixelFormat pf; - TempSurfacePtr->getPixelFormat(pf); - - srTextureIFace::MultiRequest mr; - for (int cnt=0;cntcopy(*TempSurfacePtr); - w>>=1; - ++cnt; - if (!w) break; - } - mr.smallLOD=cnt-1; - mr.largeLOD=0; - Save_Texture(FileName, mr, *TempSurfacePtr); - TempSurfacePtr->release(); - TempSurfacePtr=0; - for (cnt=0;cntrelease(); - } - } - return true; -} - -int TextureFileCache::Texture_Exists(const char *fname) -{ - CriticalSectionClass::LockClass m(mutex); - return(File.Does_Tag_Exist(fname)); -} - -#endif // WW3D_DX8 \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h deleted file mode 100644 index 10f4adf8e0a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/texfcach.h 3 3/26/01 10:45a Jani_p $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/texfcach.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 3/23/01 11:15a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef TEXTFCACH_H -#define TEXTFCACH_H - -#include "always.h" - -#include -#include - -#ifdef WW3D_DX8 - -//#include - -class FileClass; -//class srColorSurfaceIFace; - -class TextureFileCache -{ - public: - TextureFileCache(const char *fileprefix); - virtual ~TextureFileCache(); - - virtual void Reset_File(); - - // Find texture in the cache. Returns TRUE if texture found inside of cache. - int Texture_Exists(const char *fname); - - // Create the initial surface that is based off of the original texture. - // The surface is not filled in with texels since we don't convert this. - // This will also set TextureHandle up. - srColorSurfaceIFace *Load_Original_Texture_Surface(const char *texturename); - - // Given a texture that has been loaded, save it in our file cache. - bool Save_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq, srColorSurfaceIFace& origsurface); - - // Load texture data from cache into a multirequest structure. - bool Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq); - //bool TextureFileCache::Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq); - - // Check that file is in cache, is not - load and save all mipmap levels - bool Validate_Texture(const char* texturename); - - // Load a surface from the file cache, null if does not exist. - srColorSurfaceIFace *Get_Surface(const char *texturename, unsigned int reduce_factor); - - protected: - struct FileHeader { - enum { - // Put in date when format is changed. - TCF_VERSION = 20000814, - }; - - // Will change whenever a new file version is made. - int Version; - }; - - // The file format for each texture is as follows: - // _TextureBlockHeader {...} - // int MipMap[0].Offset - // ... - // int MipMap[_TextureBlockHeader.NumMipMaps - 1].Offset - // int Offset of end of block to get size of last MipMap. - // rawdata MipMap[0] - // ... - // rawdata MipMap[_TextureBlockHeader.NumMipMaps - 1] - // End of BLock - - struct TextureBlockHeader - { - // Time data stamp of file. - unsigned long FileTime; - - // Number of mip maps in texture (including first one). - int NumMipMaps; - - // Dimensions of first mip map level saved. This is normally the same as - // Source* but can be different when certain texture creation methods are done. - int LargestWidth; - int LargestHeight; - - // Dimensions of original surface/art work. - int SourceWidth; - int SourceHeight; - - // This is the pixel format used to create the sources original surface. - srColorSurfaceIFace::PixelFormat SourcePixelFormat; - - // Pixel format that we have saved in. - srColorSurfaceIFace::PixelFormat PixelFormat; - - TextureBlockHeader():NumMipMaps(-1),SourceWidth(-1),SourceHeight(-1),LargestWidth(-1),LargestHeight(-1) {} - }; - - // Each texture has an offset into the file and it's size when uncompressed. - struct OffsetTableType - { - OffsetTableType() : Offset(0), Size (0) {} - - // Offset of texture in file. - int Offset; - - // Size (uncompressed) of texture. The size of the compressed texture - // is caclcuated by Texture_Size() below. - int Size; - }; - protected: - enum { - MAX_CACHED_SURFACES = srTextureIFace::MAX_LOD, - }; - - // Pointer to the low level file managment. TagBlockFile handles the seperation - // of the different 'texture files'. This class deals with each seperate 'texture file'. - TagBlockFile File; - - // Name of last texture loaded so we know if things need to be thrown away or not. - char *CurrentTexture; - - // Handle for current texture in cache. This is created by Open_Texture_Handle(). - TagBlockHandle *TextureHandle; - - // Header that has been loaded by Open_Texture_Handle(). - TextureBlockHeader Header; - - // The offset table is loaded into memory when the file is opened. - OffsetTableType *Offsets; - - // Cache pointers to data that has already been loaded for this texture. - srColorSurface * CachedSurfaces[MAX_CACHED_SURFACES]; - - // Number of cached textures we have. - int NumCachedTextures; - - protected: - // Buffer to compress into and decompress out of. -// static char *CompressionBuffer; -// static char *EOCompressionBuffer; - - // This keeps track of number of instances of the TextureFileCache. - // This way static variables are only freed when all instances have been deleted. -// static int Instances; - - // Access to previously cached textures so they do not have to be read off of disk. - void Add_Cached_Surface(srColorSurface *surface); - srColorSurface *Find_Cached_Surface(int size); - srColorSurface *Find_Smallest_Cached_Surface(); - - int Texture_Size(int lod) { - assert(Offsets); - assert(lod < Header.NumMipMaps); - return(Offsets[lod].Size); - } - - int Compressed_Texture_Size(int lod) { - assert(Offsets); - assert(lod < Header.NumMipMaps); - return(Offsets[lod + 1].Offset - Offsets[lod].Offset); - } - - bool Open_Texture_Handle(const char *texturename); - void Close_Texture_Handle(); - - void Read_Texture(int offsetidx, srColorSurface *surface); - srColorSurfaceIFace *Create_First_Texture_As_Surface(srColorSurfaceIFace *surftype); - - static char *_Create_File_Name(const char *fileprefix); - static char *_FileNamePtr; -}; - -#endif //WW3D_DX8 - - -#endif //TEXTFCACH_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp index 973d607f81e..83d8408f891 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp @@ -25,7 +25,6 @@ #include "wwstring.h" #include "bufffile.h" #include "ww3d.h" -#include "texfcach.h" #include "assetmgr.h" #include "dx8wrapper.h" #include "dx8caps.h" diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp deleted file mode 100644 index b993a93b6d1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include -#include -#include "pot.h" -#include "txt.h" -#include "bsurface.h" -#include "texture.h" -#include "FONT.H" -#include "nstrdup.h" - -TextTextureClass::TextTextureClass(void) : - TextureString(NULL), - Texture(NULL), - TextureSize(0), - ForegroundColor(0), - BackgroundColor(0), - Font(0), - Convert(0) -{ -} - -TextTextureClass::~TextTextureClass(void) -{ - REF_PTR_RELEASE(Texture); - - if (TextureString) { - delete[] TextureString; - } -} - -bool TextTextureClass::Is_Texture_Valid(FontClass &font, const char *str, int fore, int back, ConvertClass &conv) -{ - // if there is no texture at all then obviously it is not valid - if (!Texture) return false; - - // if all the parameters the texture was created with the last time are the same as the parameters the texture - // was created with this time then the texture is fine! - if (TextureString == str && Font == &font && Convert == &conv && ForegroundColor == fore && BackgroundColor == back) - return true; - - return false; -} - -bool TextTextureClass::Build_Texture(FontClass &font, const char *str, int fore, int back, ConvertClass &conv) -{ - static char default_font_palette[] = { - 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - - // right off determine if we need to rebuild the texture or the current texture - // is just fine. If we are rebuilding store of the properties of the texture - // we are building for next time. - if (Is_Texture_Valid(font, str, fore, back, conv)) { - return false; - } else { - if (TextureString) delete[] TextureString; - Font = &font; - TextureString = nstrdup(str); - Convert = &conv; - BackgroundColor = back; - ForegroundColor = fore; - } - - - default_font_palette[0] = back; - default_font_palette[1] = fore; - - // find the width and height of the text we want to display to the screen - // note that the width could be more than the max width of a texture - // so we must be prepared to break it down into blocks. Theoretically the - // height could be greater than the texture max but lets not be ridiculous - int fw = font.String_Pixel_Width(str)+1; - int fh = font.Get_Height()+1; - - // Note: we are currently printing the text into - // a rectangular buffer. We will later blit the text into a square buffer - // since some cards require square textures. - Rect rect(0,0,fw,fh); - BSurface bsurf(fw, fh, 1); - bsurf.Fill(0); - font.Print(str, bsurf, rect, TPoint2D(0,0), conv, (unsigned char *)default_font_palette); - - // figure out the size of the best texture which can hold the - // text we wrote. Since textures need to be assumed to be square - // the best size should be found by finding the rectangular surface - // area of the text, and creating a Power of Two sized square which - // can hold the data in the ractangular surface area. - float fsize = sqrt(fw * fh); - TextureSize = Find_POT(ceil(fsize)); - // If this is still not enough, quadruple area: - if ((TextureSize / fh) * TextureSize < fw) { - TextureSize *= 2; - } - - // we now need to create a westwood style surface out of the surrender surface - // so we can use all the westwood drawing primitives. Clear this surface to - // black (shouldn't need to do this I dont think) - BSurface bsurf2(TextureSize, TextureSize, 1); - bsurf2.Fill(0); - - // we need to calculate how many texture pot widths it takes - // to hold the width of our font. - int mw = (fw & (TextureSize - 1)) ? (fw / TextureSize)+1 : (fw /TextureSize); - - // now we need to blit the old surface into the new surface (effectively - // making the text in a square surface). - for (int lp = 0; lp < mw; lp ++) { - int blitw = MIN(fw - (TextureSize *lp), TextureSize); - int lp_tsize = lp * TextureSize; - Rect destrect(0,fh*lp,blitw,fh*lp+fh); - Rect srcrect(lp_tsize, 0, lp_tsize + blitw, fh); - /* original code - d->blit(0, fh * lp, *s, lp_tsize, 0, lp_tsize + blitw, fh); - */ - bsurf2.Blit_From(destrect,bsurf,srcrect); - } - - // Create texture without mip mapping - REF_PTR_RELEASE(Texture); - - // TODO: copy bsurf2 into texture - - return true; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.h deleted file mode 100644 index 71cda13a6ab..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/txt.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef TXT_H -#define TXT_H - -class FontClass; -class ConvertClass; -class TextureClass; -class TextTextureClass { - public: - TextTextureClass(void); - ~TextTextureClass(void); - - // function to rebuild the texture with the new parameters - bool Build_Texture(FontClass &font, const char *str, int fore, int back, ConvertClass &conv); - - // returns a pointer to the texture that we created - TextureClass *Get_Texture(void) {return Texture;} - - // accessor method for the size of the texture we created - int Get_Texture_Size(void) {return TextureSize;} - private: - // function to determine if the texture needs to be rebuilt based on its parameters - bool Is_Texture_Valid(FontClass &font, const char *str, int fore, int back, ConvertClass &conv); - - // all the parameters we need to remember to deterimine if the texture is changing - // (changing any of these means the texture needs to be rebuilt) - char *TextureString; - FontClass *Font; - ConvertClass *Convert; - int ForegroundColor; - int BackgroundColor; - - // pointer to the created texture if we have created it so far - TextureClass *Texture; - - // the size of the texture we created (created textures are square) - int TextureSize; - -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp index d251540576e..883a9f1e83e 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp @@ -85,7 +85,6 @@ #include "predlod.h" #include "camera.h" #include "scene.h" -#include "texfcach.h" #include "registry.h" #include "segline.h" #include "shader.h" diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/BUFF.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/BUFF.H index 05698195742..64418753798 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/BUFF.H +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/BUFF.H @@ -46,7 +46,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" /* diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt b/Generals/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt index 033f5cf07c4..a81aef267ab 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt @@ -1,80 +1,48 @@ # Set source files set(WWLIB_SRC - _convert.cpp - _mono.cpp b64pipe.cpp b64straw.cpp base64.cpp - blit.cpp - blowfish.cpp buff.cpp bufffile.cpp chunkio.cpp - convert.cpp cpudetect.cpp crc.cpp cstraw.cpp - data.cpp - ddraw.cpp - dsurface.cpp ffactory.cpp gcd_lcm.cpp hash.cpp - hsv.cpp ini.cpp - int.cpp jshell.cpp - keyboard.cpp LaunchWeb.cpp - lcw.cpp - load.cpp - mono.cpp - mpmath.cpp mpu.cpp - msgloop.cpp multilist.cpp mutex.cpp nstrdup.cpp - palette.cpp - pcx.cpp pipe.cpp - pk.cpp ramfile.cpp random.cpp rawfile.cpp - rc4.cpp - rcfile.cpp readline.cpp realcrc.cpp refcount.cpp registry.cpp - rgb.cpp - rle.cpp - rndstrng.cpp - sampler.cpp - sha.cpp slnode.cpp - srandom.cpp stimer.cpp straw.cpp strtok_r.cpp systimer.cpp - tagblock.cpp TARGA.CPP textfile.cpp thread.cpp trim.cpp vector.cpp widestring.cpp - win.cpp WWCOMUtil.cpp wwfile.cpp - wwfont.cpp wwstring.cpp xpipe.cpp xstraw.cpp - xsurface.cpp - _mono.h always.h argv.h b64pipe.h @@ -82,110 +50,67 @@ set(WWLIB_SRC base64.h binheap.h bittype.h - blit.h - blitter.h - bool.h - borlandc.h bound.h BSEARCH.H - bsurface.h BUFF.H bufffile.h CallbackHook.h chunkio.h - Convert.h cpudetect.h CRC.H cstraw.h - data.h - dsurface.h ffactory.h - FONT.H gcd_lcm.h hash.h hashcalc.h HASHLIST.H hashtemplate.h - IFF.H INDEX.H INI.H inisup.h - INT.H iostruct.h - keyboard.h LaunchWeb.h - LCW.H LISTNODE.H mempool.h - mixfile.h - MONO.H - MONODRVR.H - MPMATH.H MPU.H - msgloop.h multilist.h mutex.h Notify.h nstrdup.h ntree.h - PALETTE.H - pcx.H PIPE.H - PK.H Point.h RAMFILE.H RANDOM.H RAWFILE.H - rc4.h - rcfile.h readline.h realcrc.h ref_ptr.h - refcount.h registry.h - RGB.H - RLE.H - RNDSTRAW.H - rndstrng.h - rng.h - rsacrypt.h - sampler.h - sha.h - shapeset.h sharebuf.h Signaler.h simplevec.h SLIST.H SLNODE.H - srandom.h - stl.h STRAW.H strtok_r.h - Surface.h - surfrect.h systimer.h - TagBlock.h TARGA.H textfile.h thread.h - timer.h - trackwin.h trect.h trim.h uarray.h Vector.H verchk.h visualc.h - WATCOM.H widestring.h win.h WWCOMUtil.h WWFILE.H wwstring.h - xmouse.h XPIPE.H XSTRAW.H - xsurface.h ) # Targets to build. diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/Convert.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/Convert.h deleted file mode 100644 index 8979f5b774f..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/Convert.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/Convert.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef CONVERT_H -#define CONVERT_H - -#include "blitter.h" -#include "PALETTE.H" -#include "Surface.h" - -/* -** Flags used to fetch the appropriate blitter object. -*/ -typedef enum { - SHAPE_NORMAL = 0x0000, // Standard shape (which is transparent) - - SHAPE_WIN_REL = 0x0400, - - SHAPE_CENTER = 0x0200, // Coords are based on shape's center pt - - SHAPE_DARKEN = 0x0001, // Force all pixels to darken the destination. - SHAPE_TRANSLUCENT25 = 0x0002, // Translucent to destination (25%). - SHAPE_TRANSLUCENT50 = 0x0004, // Translucent to destination (50%). - SHAPE_TRANSLUCENT75 = 0x0006, // Translucent to destination (75%). - SHAPE_PREDATOR = 0x0008, // Predator effect - SHAPE_REMAP = 0x0010, // Simple remap - SHAPE_NOTRANS = 0x0020 // A non transparent but otherwise standard shape -} ShapeFlags_Type; - - -/* -** This class is the data that represents the marriage between a source art -** palette and a destination palette/pixel-format. Facilities provied by this -** class allow conversion from the source 8 bit pixel format to the correct -** screen pixel format. -** -** Although this class can convert one pixel at a time through the conversion -** function, the preferred way to convert pixels is through the translation -** table provided. This table consists of 256 entries. Each entry is either -** an 8 bit or 16 bit pixel in the correct screen-space format. Use the -** Bytes_Per_Pixel() function to determine how to index into this translation -** table. -** -** Expected use of this class would be to create separate objects of this class for -** every source art palette. For an 8 bit display, an additional object will be -** required for every additional palette set to the video DAC registers. It is -** presumed that one general best-case palette will be used. -*/ -class ConvertClass -{ - public: - ConvertClass(PaletteClass const & artpalette, PaletteClass const & screenpalette, Surface const & typicalsurface); - ~ConvertClass(void); - - /* - ** Convert from source pixel to dest screen pixel. - */ - int Convert_Pixel(int pixel) const { - if (BBP == 1) return(((unsigned char const *)Translator)[pixel]); - return(((unsigned short const *)Translator)[pixel]); - } - - /* - ** Fetch a blitter object to use according to the draw flags - ** specified. - */ - Blitter const * Blitter_From_Flags(ShapeFlags_Type flags) const; - RLEBlitter const * RLEBlitter_From_Flags(ShapeFlags_Type flags) const; - - /* - ** This returns the bytes per pixel. Use this to determine how to index - ** through the translation table. - */ - int Bytes_Per_Pixel(void) const {return(BBP);} - - /* - ** Fetches the translation table. Sometimes the provided blitter objects - ** won't suffice and manual access to the translation process is necessary. - */ - void const * Get_Translate_Table(void) const {return(Translator);} - - /* - ** Sets the dynamic remap table so that the remapping blitters will use - ** it without having to recreate the blitter objects. - */ - void Set_Remap(unsigned char const * remap) {RemapTable = remap;} - - protected: - /* - ** Bytes per pixel in screen format. - */ - int BBP; - - /* - ** These are the blitter objects used to handle all the draw styles that this - ** drawing dispatcher implements. - */ - Blitter * PlainBlitter; // No transparency (rarely used). - Blitter * TransBlitter; // Skips transparent pixels. - Blitter * ShadowBlitter; // Shadowizes the destination pixels. - Blitter * RemapBlitter; // Remaps source pixels then draws with transparency. - Blitter * Translucent1Blitter; // 25% translucent. - Blitter * Translucent2Blitter; // 50% translucent. - Blitter * Translucent3Blitter; // 75% translucent. - - /* - ** These are the RLE aware blitters to handle all drawing styles that may - ** be used by RLE compressed images. - */ - RLEBlitter * RLETransBlitter; // Skips transparent pixels. - RLEBlitter * RLEShadowBlitter; // Shadowizes the destination pixels. - RLEBlitter * RLERemapBlitter; // Remaps source pixels then draws with transparency. - RLEBlitter * RLETranslucent1Blitter; // 25% translucent. - RLEBlitter * RLETranslucent2Blitter; // 50% translucent. - RLEBlitter * RLETranslucent3Blitter; // 75% translucent. - - /* - ** This is a translation table pointer. All source artwork is in 8 bit format. - ** This table will translate this source pixel into a screen dependant pixel - ** format datum. - */ - void * Translator; - - /* - ** This will shade an 8 bit pixel to about 1/2 intensity. - */ - unsigned char * ShadowTable; - - /* - ** Remap table pointer used for blits that require remapping. This value - ** will change according to the draw parameter. The blitting routines keep track - ** of this member object and use it to determine the remap table to use. - */ - mutable unsigned char const * RemapTable; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/FONT.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/FONT.H deleted file mode 100644 index 58abbd3bb57..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/FONT.H +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/font.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:40p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef FONT_H -#define FONT_H - -#include "Convert.h" -#include "Point.h" -#include "trect.h" -#include - -class Surface; - -/* -** A font object represent the data that comprises the individual characters as well -** as drawing text in the font to a surface. This is an abstract base class that is to be -** derived into a concrete version. -*/ -class FontClass { - public: - virtual ~FontClass(void) {} - - virtual int Char_Pixel_Width(char c) const = 0; - virtual int String_Pixel_Width(char const * string) const = 0; - virtual int Get_Width(void) const = 0; - virtual int Get_Height(void) const = 0; - virtual Point2D Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & point, ConvertClass const & converter, unsigned char const * remap=NULL) const = 0; - - virtual int Set_XSpacing(int x) = 0; - virtual int Set_YSpacing(int y) = 0; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/IFF.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/IFF.H deleted file mode 100644 index 9b1948b7dbf..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/IFF.H +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/iff.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/23/99 1:46p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef IFF_H -#define IFF_H - -#ifndef _WINDOWS -#define __cdecl -#endif - -#include "BUFF.H" -#include - -#define LZW_SUPPORTED FALSE - -/*=========================================================================*/ -/* Iff and Load Picture system defines and enumerations */ -/*=========================================================================*/ - -#define MAKE_ID(a,b,c,d) ((long) ((long) d << 24) | ((long) c << 16) | ((long) b << 8) | (long)(a)) -#define IFFize_WORD(a) Reverse_Word(a) -#define IFFize_LONG(a) Reverse_Long(a) - - -//lint -strong(AJX,PicturePlaneType) -typedef enum { - BM_AMIGA, // Bit plane format (8K per bitplane). - BM_MCGA, // Byte per pixel format (64K). - - BM_DEFAULT=BM_MCGA // Default picture format. -} PicturePlaneType; - -/* -** This is the compression type code. This value is used in the compressed -** file header to indicate the method of compression used. Note that the -** LZW method may not be supported. -*/ -//lint -strong(AJX,CompressionType) -typedef enum { - NOCOMPRESS, // No compression (raw data). - LZW12, // LZW 12 bit codes. - LZW14, // LZW 14 bit codes. - HORIZONTAL, // Run length encoding (RLE). - LCW // Westwood proprietary compression. -} CompressionType; - -/* -** Compressed blocks of data must start with this header structure. -** Note that disk based compressed files have an additional two -** leading bytes that indicate the size of the entire file. -*/ -//lint -strong(AJX,CompHeaderType) -typedef struct { - char Method; // Compression method (CompressionType). - char pad; // Reserved pad byte (always 0). - long Size; // Size of the uncompressed data. - short Skip; // Number of bytes to skip before data. -} CompHeaderType; - - -/*=========================================================================*/ -/* The following prototypes are for the file: IFF.CPP */ -/*=========================================================================*/ - -int __cdecl Open_Iff_File(char const *filename); -void __cdecl Close_Iff_File(int fh); -unsigned long __cdecl Get_Iff_Chunk_Size(int fh, long id); -unsigned long __cdecl Read_Iff_Chunk(int fh, long id, void *buffer, unsigned long maxsize); -void __cdecl Write_Iff_Chunk(int file, long id, void *buffer, long length); - - -/*=========================================================================*/ -/* The following prototypes are for the file: LOADPICT.CPP */ -/*=========================================================================*/ - -//int __cdecl Load_Picture(char const *filename, BufferClass& scratchbuf, BufferClass& destbuf, unsigned char *palette=NULL, PicturePlaneType format=BM_DEFAULT); - - -/*=========================================================================*/ -/* The following prototypes are for the file: LOAD.CPP */ -/*=========================================================================*/ - -unsigned long __cdecl Load_Data(char const *name, void *ptr, unsigned long size); -unsigned long __cdecl Write_Data(char const *name, void *ptr, unsigned long size); -//void * __cdecl Load_Alloc_Data(char const *name, MemoryFlagType flags); -unsigned long __cdecl Load_Uncompress(char const *file, Buffer & uncomp_buff, Buffer & dest_buff, void *reserved_data=NULL); -unsigned long __cdecl Uncompress_Data(void const *src, void *dst); -void __cdecl Set_Uncomp_Buffer(int buffer_segment, int size_of_buffer); - -/*=========================================================================*/ -/* The following prototypes are for the file: WRITELBM.CPP */ -/*=========================================================================*/ - -//bool Write_LBM_File(int lbmhandle, BufferClass& buff, int bitplanes, unsigned char *palette); - - - -/*========================= Assembly Functions ============================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/*=========================================================================*/ -/* The following prototypes are for the file: PACK2PLN.ASM */ -/*=========================================================================*/ - -extern void __cdecl Pack_2_Plane(void *buffer, void * pageptr, int planebit); - -/*=========================================================================*/ -/* The following prototypes are for the file: LCWCOMP.ASM */ -/*=========================================================================*/ - -extern unsigned long __cdecl LCW_Compress(void *source, void *dest, unsigned long length); - -/*=========================================================================*/ -/* The following prototypes are for the file: LCWUNCMP.ASM */ -/*=========================================================================*/ - -extern unsigned long __cdecl LCW_Uncompress(void *source, void *dest, unsigned long length); - -#ifdef __cplusplus -} -#endif -/*=========================================================================*/ - - - -#endif //IFF_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/INI.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/INI.H index 83195230456..5c3bde13795 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/INI.H +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/INI.H @@ -49,7 +49,6 @@ //#include "straw.h" //#include "wwfile.h" -class PKey; class FileClass; class Straw; class Pipe; @@ -122,7 +121,6 @@ class INIClass { /* ** Get the various data types from the section and entry specified. */ - PKey Get_PKey(bool fast) const; bool Get_Bool(char const * section, char const * entry, bool defvalue=false) const; float Get_Float(char const * section, char const * entry, float defvalue=0.0) const; int Get_Hex(char const * section, char const * entry, int defvalue=0) const; @@ -148,7 +146,6 @@ class INIClass { bool Put_Float(char const * section, char const * entry, double number); bool Put_Hex(char const * section, char const * entry, int number); bool Put_Int(char const * section, char const * entry, int number, int format=0); - bool Put_PKey(PKey const & key); bool Put_String(char const * section, char const * entry, char const * string); bool Put_TextBlock(char const * section, char const * text); bool Put_UUBlock(char const * section, void const * block, int len); diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/INT.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/INT.H deleted file mode 100644 index 82ad59eb290..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/INT.H +++ /dev/null @@ -1,310 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/int.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef INT_H -#define INT_H - -#include "MPMATH.H" -#include "STRAW.H" -#include -#include -#include - -#ifdef __BORLANDC__ -#pragma warn -inl -#endif - -template struct RemainderTable; -template T Gcd(const T & a, const T & n); -#ifdef _UNIX - #define FN_TEMPLATE <> -#else - #define FN_TEMPLATE -#endif - - -template -class Int { - public: - - /* - ** Constructors and initializers. - */ - Int(void) {XMP_Init(®[0], 0, PRECISION);} - Int(unsigned long value) {XMP_Init(®[0], value, PRECISION);} - - void Randomize(Straw & rng, int bitcount) {XMP_Randomize(®[0], rng, bitcount, PRECISION);} - void Randomize(Straw & rng, const Int & minval, const Int & maxval) {XMP_Randomize_Bounded(®[0], rng, minval, maxval, PRECISION); reg[0] |= 1;} - - /* - ** Convenient conversion operators to get at the underlying array of - ** integers. Big number math is basically manipulation of arbitrary - ** length arrays. - */ - operator digit * () {return & reg[0];} - operator const digit * () const {return & reg[0];} - - /* - ** Array access operator (references bit position). Bit 0 is the first bit. - */ - bool operator[](unsigned bit) const {return(XMP_Test_Bit(®[0], bit));} - - /* - ** Unary operators. - */ - Int & operator ++ (void) {XMP_Inc(®[0], PRECISION);return(*this);} - Int & operator -- (void) {XMP_Dec(®[0], PRECISION);return(*this);} - int operator ! (void) const {return(XMP_Test_Eq_Int(®[0], 0, PRECISION));} - Int operator ~ (void) {XMP_Not(®[0], PRECISION);return(*this);} - Int operator - (void) const {Int a = *this;a.Negate();return (a);} - - /* - ** Attribute query functions. - */ - int ByteCount(void) const {return(XMP_Count_Bytes(®[0], PRECISION));} - int BitCount(void) const {return(XMP_Count_Bits(®[0], PRECISION));} - bool Is_Negative(void) const {return(XMP_Is_Negative(®[0], PRECISION));} - unsigned MaxBitPrecision() const {return PRECISION*(sizeof(unsigned long)*CHAR_BIT);} - bool IsSmallPrime(void) const {return(XMP_Is_Small_Prime(®[0], PRECISION));} - bool SmallDivisorsTest(void) const {return(XMP_Small_Divisors_Test(®[0], PRECISION));} - bool FermatTest(unsigned rounds) const {return(XMP_Fermat_Test(®[0], rounds, PRECISION));} - bool IsPrime(void) const {return(XMP_Is_Prime(®[0], PRECISION));} - bool RabinMillerTest(Straw & rng, unsigned int rounds) const {return(XMP_Rabin_Miller_Test(rng, ®[0], rounds, PRECISION));} - - /* - ** 'in-place' binary operators. - */ - Int & operator += (const Int & number) {Carry = XMP_Add(®[0], ®[0], number, 0, PRECISION);return(*this);} - Int & operator -= (const Int & number) {Borrow = XMP_Sub(®[0], ®[0], number, 0, PRECISION);return(*this);} - Int & operator *= (const Int & multiplier) {Remainder = *this;Error=XMP_Signed_Mult(®[0], Remainder, multiplier, PRECISION);return(*this);} - Int & operator /= (const Int & t) {*this = (*this) / t;return *this;} - Int & operator %= (const Int & t) {*this = (*this) % t;return *this;} - Int & operator <<= (int bits) {XMP_Shift_Left_Bits(®[0], bits, PRECISION);return *this;} - Int & operator >>= (int bits) {XMP_Shift_Right_Bits(®[0], bits, PRECISION);return *this;} - - /* - ** Mathematical binary operators. - */ - Int operator + (const Int & number) const {Int term;Carry = XMP_Add(term, ®[0], number, 0, PRECISION);return(term);} - Int operator + (unsigned short b) const {Int result;Carry=XMP_Add_Int(result, ®[0], b, 0, PRECISION);return(result);} - Int operator - (const Int & number) const {Int term;Borrow = XMP_Sub(term, ®[0], number, 0, PRECISION);return(term);} - Int operator - (unsigned short b) const {Int result;Borrow = XMP_Sub_Int(result, ®[0], b, 0, PRECISION);return(result);} - Int operator * (const Int & multiplier) const {Int result;Error=XMP_Signed_Mult(result, ®[0], multiplier, PRECISION);return result;} - Int operator * (unsigned short b) const {Int result;Error=XMP_Unsigned_Mult_Int(result, ®[0], b, PRECISION);return(result);} - Int operator / (const Int & divisor) const {Int quotient = *this;XMP_Signed_Div(Remainder, quotient, ®[0], divisor, PRECISION);return (quotient);} - Int operator / (unsigned long b) const {return(*this / Int(b));} - Int operator / (unsigned short divisor) const {Int quotient;Error=XMP_Unsigned_Div_Int(quotient, ®[0], divisor, PRECISION);return(quotient);} - Int operator % (const Int & divisor) const {Int remainder;XMP_Signed_Div(remainder, Remainder, ®[0], divisor, PRECISION);return(remainder);} - Int operator % (unsigned long b) const {return(*this % Int(b));} - unsigned short operator % (unsigned short divisor) const {return(XMP_Unsigned_Div_Int(Remainder, ®[0], divisor, PRECISION));} - - /* - ** Bitwise binary operators. - */ - Int operator >> (int bits) const {Int result = *this; XMP_Shift_Right_Bits(result, bits, PRECISION);return result;} - Int operator << (int bits) const {Int result = *this; XMP_Shift_Left_Bits(result, bits, PRECISION);return result;} - - /* - ** Comparison binary operators. - */ - int operator == (const Int &b) const {return (memcmp(®[0], &b.reg[0], (MAX_BIT_PRECISION/CHAR_BIT))==0);} - int operator != (const Int& b) const {return !(*this == b);} - int operator > (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) > 0);} - int operator >= (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) >= 0);} - int operator < (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) < 0);} - int operator <= (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) <= 0);} - - /* - ** Misc. mathematical and logical functions. - */ - void Negate(void) {XMP_Neg(®[0], PRECISION);} - Int Abs(void) {XMP_Abs(®[0], PRECISION);return(*this);} - - Int exp_b_mod_c(const Int & e, const Int & m) const { - Int result; - Error=XMP_Exponent_Mod(result, ®[0], e, m, PRECISION); - return result; - } - - void Set_Bit(int index) { XMP_Set_Bit(®[0], index); } - static Int Unsigned_Mult(Int const & multiplicand, Int const & multiplier) {Int product;Error=XMP_Unsigned_Mult(&product.reg[0], &multiplicand.reg[0], &multiplier.reg[0], PRECISION);return(product);} - static void Unsigned_Divide(Int & remainder, Int & quotient, const Int & dividend, const Int & divisor) {Error=XMP_Unsigned_Div(remainder, quotient, dividend, divisor, PRECISION);} - static void Signed_Divide(Int & remainder, Int & quotient, const Int & dividend, const Int & divisor) {XMP_Signed_Div(remainder, quotient, dividend, divisor, PRECISION);} - Int Inverse(const Int & modulus) const {Int result;XMP_Inverse_A_Mod_B(result, ®[0], modulus, PRECISION);return(result);} - - static Int Decode_ASCII(char const * string) {Int result;XMP_Decode_ASCII(string, result, PRECISION);return(result);} - - // Number (sign independand) inserted into buffer. - int Encode(unsigned char *output) const {return(XMP_Encode(output, ®[0], PRECISION));} - int Encode(unsigned char * output, unsigned length) const {return(XMP_Encode_Bounded(output, length, ®[0], PRECISION));} - void Signed_Decode(const unsigned char * from, int frombytes) {XMP_Signed_Decode(®[0], from, frombytes, PRECISION);} - void Unsigned_Decode(const unsigned char * from, int frombytes) {XMP_Unsigned_Decode(®[0], from, frombytes, PRECISION);} - - // encode Int using Distinguished Encoding Rules, returns size of output - int DEREncode(unsigned char * output) const {return(XMP_DER_Encode(®[0], output, PRECISION));} - void DERDecode(const unsigned char *input) {XMP_DER_Decode(®[0], input, PRECISION);} - - // Friend helper functions. - friend Int Gcd FN_TEMPLATE (const Int &, const Int &); - - - static int Error; - - // Carry result from last addition. - static bool Carry; - - // Borrow result from last subtraction. - static bool Borrow; - - // Remainder value from the various division routines. - static Int Remainder; - - digit reg[PRECISION]; - - friend struct RemainderTable< Int >; -}; - -template -struct RemainderTable -{ - RemainderTable(const T & p) : HasZeroEntry(false) - { - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - for (int i = 0; i < primesize; i++) { - table[i] = p % primetable[i]; - } - } - bool HasZero() const {return(HasZeroEntry);} - void Increment(unsigned short increment = 1) - { - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - HasZeroEntry = false; - for (int i = 0; i < primesize; i++) { - table[i] += increment; - while (table[i] >= primetable[i]) { - table[i] -= primetable[i]; - } - HasZeroEntry = (HasZeroEntry || !table[i]); - } - } - void Increment(const RemainderTable & rtQ) - { - HasZeroEntry = false; - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - for (int i = 0; i < primesize; i++) { - table[i] += rtQ.table[i]; - if (table[i] >= primetable[i]) { - table[i] -= primetable[i]; - } - HasZeroEntry = (HasZeroEntry || !table[i]); - } - } - bool HasZeroEntry; - unsigned short table[3511]; -}; - - - -template -T Gcd(const T & a, const T & n) -{ - T g[3]={n, a, 0UL}; - - unsigned int i = 1; - while (!!g[i%3]) { - g[(i+1)%3] = g[(i-1)%3] % g[i%3]; - i++; - } - return g[(i-1)%3]; -} - - - -#if defined(__WATCOMC__) -#pragma warning 604 9 -#pragma warning 595 9 -#endif - - -template -T Generate_Prime(Straw & rng, int pbits, T const *) -{ - T minQ = (T(1UL) << (unsigned short)(pbits-(unsigned short)2)); - T maxQ = ((T(1UL) << (unsigned short)(pbits-(unsigned short)1)) - (unsigned short)1); - - T q; - T p; - - do { - q.Randomize(rng, minQ, maxQ); - p = (q*2) + (unsigned short)1; - - RemainderTable rtQ(q); - RemainderTable rtP(p); - - while (rtQ.HasZero() || rtP.HasZero() || !q.IsPrime() || !p.IsPrime()) { - q += 2; - p += 4; - if (q > maxQ) break; - - rtQ.Increment(2); - rtP.Increment(4); - } - } while (q > maxQ); - - return(p); -} - - - - -#define UNITSIZE 32 -#define MAX_BIT_PRECISION 2048 -#define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) - - -typedef Int bignum; -typedef Int BigInt; - - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/LCW.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/LCW.H deleted file mode 100644 index 41340a6db54..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/LCW.H +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/lcw.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef LCW_H -#define LCW_H - -#ifdef _UNIX -#include "osdep.h" -#endif - -int LCW_Uncomp(void const * source, void * dest, unsigned long length=0); - -#ifdef _MSC_VER -int LCW_Comp(void const * source, void * dest, int length); -#else -extern "C" { -int __cdecl LCW_Comp(void const * source, void * dest, int length); -} -#endif - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/MONO.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/MONO.H deleted file mode 100644 index 36b0cf17213..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/MONO.H +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/mono.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:36p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MONO_H -#define MONO_H - -#include "win.h" - -class MonoClass { - public: - typedef enum MonoAttribute { - INVISIBLE=0x00, // Black on black. - UNDERLINE=0x01, // Underline. - BLINKING=0x90, // Blinking white on black. - NORMAL=0x02, // White on black. - INVERSE=0x70 // Black on white. - } MonoAttribute; - - MonoClass(void); - ~MonoClass(void); - - static void Enable(void) {Enabled = true;}; - static void Disable(void) {Enabled = false;}; - static bool Is_Enabled(void) {return Enabled;}; - - void Sub_Window(int x=0, int y=0, int w=80, int h=25); - void Fill_Attrib(int x, int y, int w, int h, MonoAttribute attrib); - void Clear(void); - void Set_Cursor(int x, int y); - void Print(char const *text); - void Print(int text); - void Printf(char const *text, ...); - void Printf(int text, ...); - void Text_Print(char const *text, int x, int y, MonoAttribute attrib=NORMAL); - void Text_Print(int text, int x, int y, MonoAttribute attrib=NORMAL); - void View(void); - void Scroll(int lines=1); - void Pan(int cols=1); - void Set_Default_Attribute(MonoAttribute attrib); - - /* - ** This merely makes a duplicate of the mono object into a newly created mono - ** object. - */ - MonoClass (MonoClass const &); - - static MonoClass * Current; - - private: - - /* - ** Handle of the mono page. - */ - HANDLE Handle; - - /* - ** If this is true, then monochrome output is allowed. It defaults to false - ** so that monochrome output must be explicitly enabled. - */ - static bool Enabled; - - MonoClass & operator = (MonoClass const & ); -}; - - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H deleted file mode 100644 index 1dcedafef1f..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/monodrvr.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifdef _MSC_VER -#pragma warning (push,3) -#endif - -#ifdef _WINDOWS -#include -#endif - -#ifdef _MSC_VER -#pragma warning (pop) -#endif - - -/* -** This is the identifier for the Monochrome Display Driver. -*/ -#define FILE_DEVICE_MONO 0x00008000 - -/* -** These are the IOCTL commands supported by the Monochrome Display Driver. -*/ -#define IOCTL_MONO_HELP_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x800, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_CLEAR_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x801, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_PRINT_RAW CTL_CODE(FILE_DEVICE_MONO, 0x802, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_CURSOR CTL_CODE(FILE_DEVICE_MONO, 0x803, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SCROLL CTL_CODE(FILE_DEVICE_MONO, 0x804, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_BRING_TO_TOP CTL_CODE(FILE_DEVICE_MONO, 0x805, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_ATTRIBUTE CTL_CODE(FILE_DEVICE_MONO, 0x806, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_PAN CTL_CODE(FILE_DEVICE_MONO, 0x807, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_LOCK CTL_CODE(FILE_DEVICE_MONO, 0x808, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_UNLOCK CTL_CODE(FILE_DEVICE_MONO, 0x809, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80A, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_RESET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80B, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80C, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_CLEAR_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80D, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_FILL_ATTRIB CTL_CODE(FILE_DEVICE_MONO, 0x80E, METHOD_BUFFERED, FILE_WRITE_DATA) - -/* -** These specify the various behavior flags available for the mono display driver. They -** default to being OFF (or FALSE). -*/ -typedef enum MonoFlagType -{ - MONOFLAG_WRAP, // Text will wrap to the next line when right margin is reached. - - MONOFLAG_COUNT // Used to indicate the number of mono flags available. -} MonoFlagType; - - -/* - Here is a "C" example of how to use the Monochrome Display Driver. - - -int main(int argc, char *argv[]) -{ - HANDLE handle; - - handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle != INVALID_HANDLE_VALUE) { - long retval; // Return code from IoControl functions. - unsigned short * pointer; // Working pointer to mono RAM. - union { - int X,Y; - } cursor; // Cursor positioning parameter info. - - // Prints a line of text to the screen [length of string is 13]. - WriteFile(handle, "Test Message\n", 13, &retval, NULL); - - // Fetches a pointer to the mono memory. - DeviceIoControl(handle, (DWORD)IOCTL_MONO_LOCK, NULL, 0, &pointer, sizeof(pointer), &retval, 0); - if (pointer != NULL) { - *pointer = 0x0721; // '!' character appears in upper left corner (attribute 0x07). - } - DeviceIoControl(handle, (DWORD)IOCTL_MONO_UNLOCK, NULL, 0, NULL, 0, &retval, 0); - - // Set cursor to column 5, row 10. - cursor.X = 5; - cursor.Y = 10; - DeviceIoControl(handle, (DWORD)IOCTL_MONO_SET_CURSOR, &cursor, sizeof(cursor), NULL, 0, &retval, 0); - - // Clear the screen. - DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &retval, 0); - - CloseHandle(handle); - } - - return 0; -} - -*/ - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H deleted file mode 100644 index 0a98f04d433..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/mpmath.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MPMATH_H -#define MPMATH_H - -#include "bool.h" - -//lint -e740 -e534 -e537 -e760 -//lint -d_LINT=1 - - -#include "STRAW.H" -#include - -#define UNITSIZE 32 -#define MAX_BIT_PRECISION 2048 -#define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) -#define signeddigit signed long -#define LOG_UNITSIZE 5 - -//#define digit unsigned long -typedef unsigned long digit; - -#define MPEXPORT - -#ifdef _MSC_VER -#pragma warning( disable : 4236) -#endif - -extern "C" { -extern int MPEXPORT XMP_Fetch_Prime_Size(void); -unsigned short const * MPEXPORT XMP_Fetch_Prime_Table(void); -int MPEXPORT XMP_Significance(const digit * r, int precision); -void MPEXPORT XMP_Inc(digit * r, int precision); -void MPEXPORT XMP_Dec(digit * r, int precision); -void MPEXPORT XMP_Neg(digit * r, int precision); -void MPEXPORT XMP_Abs(digit * r, int precision); -void MPEXPORT XMP_Shift_Right_Bits(digit * r1, int bits, int precision); -void MPEXPORT XMP_Shift_Left_Bits(digit * r1, int bits, int precision); -bool MPEXPORT XMP_Rotate_Left(digit * r1, bool carry, int precision); -void MPEXPORT XMP_Not(digit * digit_ptr, int precision); -int MPEXPORT XMP_Prepare_Modulus(const digit * n_modulus, int precision); -void MPEXPORT XMP_Init(digit * r, digit value, int precision); -unsigned MPEXPORT XMP_Count_Bits(const digit * r, int precision); -int MPEXPORT XMP_Count_Bytes(const digit * r, int precision); -void MPEXPORT XMP_Move(digit * dest, digit const * source, int precision); -int MPEXPORT XMP_Digits_To_Bits(int digits); -int MPEXPORT XMP_Compare(const digit * r1, const digit * r2, int precision); -int MPEXPORT XMP_Bits_To_Digits(int bits); -bool MPEXPORT XMP_Add(digit * result, const digit * r1, const digit * r2, bool carry, int precision); -bool MPEXPORT XMP_Add_Int(digit * result, const digit * r1, digit r2, bool carry, int precision); -bool MPEXPORT XMP_Test_Bit(const digit * r, unsigned bit); -void MPEXPORT XMP_Set_Bit(digit * r, unsigned bit); -digit MPEXPORT XMP_Bits_To_Mask(int bits); -bool MPEXPORT XMP_Is_Negative(const digit * r, int precision); -bool MPEXPORT XMP_Test_Eq_Int(digit const * r, int i, int p); -bool MPEXPORT XMP_Sub(digit * result, const digit * r1, const digit * r2, bool borrow, int precision); -bool MPEXPORT XMP_Sub_Int(digit * result, const digit * r1, unsigned short r2, bool borrow, int precision); -int MPEXPORT XMP_Unsigned_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -int MPEXPORT XMP_Unsigned_Mult_Int(digit * prod, const digit * multiplicand, short multiplier, int precision); -int MPEXPORT XMP_Signed_Mult_Int(digit * prod, const digit * multiplicand, signed short multiplier, int precision); -int MPEXPORT XMP_Signed_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -unsigned short MPEXPORT XMP_Unsigned_Div_Int(digit * quotient, digit const * dividend, unsigned short divisor, int precision); -int MPEXPORT XMP_Unsigned_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision); -void MPEXPORT XMP_Signed_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision); -int MPEXPORT XMP_Reciprocal(digit * quotient, const digit * divisor, int precision); -void MPEXPORT XMP_Decode_ASCII(char const * str, digit * mpn, int precision); -//void MPEXPORT xmp_single_mul(unsigned short * prod, unsigned short * multiplicand, unsigned short multiplier, int precision); -void MPEXPORT XMP_Double_Mul(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -//int MPEXPORT xmp_stage_modulus(const digit * n_modulus, int precision); -int MPEXPORT XMP_Mod_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -void MPEXPORT XMP_Mod_Mult_Clear(int precision); -int MPEXPORT XMP_Exponent_Mod(digit * expout, const digit * expin, const digit * exponent_ptr, const digit * modulus, int precision); -bool MPEXPORT XMP_Is_Small_Prime(const digit * candidate, int precision); -bool MPEXPORT XMP_Small_Divisors_Test(const digit * candidate, int precision); -bool MPEXPORT XMP_Fermat_Test(const digit * candidate_prime, unsigned rounds, int precision); -void MPEXPORT XMP_Inverse_A_Mod_B(digit * result, digit const * number, digit const * modulus, int precision); -void MPEXPORT XMP_Signed_Decode(digit * result, const unsigned char * from, int frombytes, int precision); -void MPEXPORT XMP_Unsigned_Decode(digit * result, const unsigned char * from, int frombytes, int precision); -unsigned MPEXPORT XMP_Encode(unsigned char * to, digit const * from, int precision); -unsigned MPEXPORT XMP_Encode_Bounded(unsigned char * to, unsigned tobytes, digit const * from, int precision); -void MPEXPORT XMP_Randomize(digit * result, Straw & rng, int nbits, int precision); -void MPEXPORT XMP_Randomize_Bounded(digit * result, Straw & rng, digit const * min, digit const * max, int precision); -bool MPEXPORT XMP_Is_Prime(digit const * prime, int precision); -bool MPEXPORT XMP_Rabin_Miller_Test(Straw & rng, digit const * w, int rounds, int precision); -int MPEXPORT XMP_DER_Length_Encode(unsigned long length, unsigned char * output); -int MPEXPORT XMP_DER_Encode(digit const * from, unsigned char * output, int precision); -void MPEXPORT XMP_DER_Decode(digit * result, unsigned char const * input, int precision); -} - - -inline int MPEXPORT XMP_Digits_To_Bits(int digits) -{ - return(digits << LOG_UNITSIZE); -} - - -inline int MPEXPORT XMP_Bits_To_Digits(int bits) -{ - return ((bits + (UNITSIZE-1)) / UNITSIZE); -} - - -inline digit MPEXPORT XMP_Bits_To_Mask(int bits) -{ - if (!bits) return(0); - return(1 << ((bits-1) % UNITSIZE)); -} - - -inline bool MPEXPORT XMP_Is_Negative(const digit * r, int precision) -{ - return((signeddigit) *(r + (precision-1)) < 0); -} - - -inline void MPEXPORT XMP_Set_Bit(digit * r, unsigned bit) -{ - r[bit >> LOG_UNITSIZE] |= ((digit)1 << (bit & (UNITSIZE-1))); -} - -inline bool MPEXPORT XMP_Test_Bit(const digit * r, unsigned bit) -{ - return ((r[bit >> LOG_UNITSIZE] & ((digit)1 << (bit & (UNITSIZE-1)))) != 0); -} - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H deleted file mode 100644 index 22f97424f50..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/PALETTE.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef PALETTE_H -#define PALETTE_H - -#include "RGB.H" - -/* -** The palette class is used to manipulate a palette as a whole. All 256 colors are -** represented by the palette class object. -*/ -class PaletteClass -{ - public: - enum { - COLOR_COUNT=256 // Number of color indices on the palette. - }; - - PaletteClass(void) {}; - PaletteClass(RGBClass const & rgb); - PaletteClass(unsigned char *binary_palette); - - RGBClass & operator[] (int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & operator[] (int index) const {return(Palette[index % COLOR_COUNT]);}; - RGBClass & Get_Color(int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & Get_Color(int index) const {return(Palette[index % COLOR_COUNT]);}; - int operator == (PaletteClass const & palette) const; - int operator != (PaletteClass const & palette) const {return(!(operator ==(palette)));}; - PaletteClass & operator = (PaletteClass const & palette); - operator const unsigned char * (void) const {return((const unsigned char *)&Palette[0]);}; - operator unsigned char * (void) {return((unsigned char *)&Palette[0]);}; - - void Adjust(int ratio); - void Adjust(int ratio, PaletteClass const & palette); - void Partial_Adjust(int ratio, char *lut); - void Partial_Adjust(int ratio, PaletteClass const & palette, char *lut); - int Closest_Color(RGBClass const & rgb) const; - - protected: - RGBClass Palette[COLOR_COUNT]; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/PK.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/PK.H deleted file mode 100644 index 54bc0572d66..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/PK.H +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/PK.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef PK_H -#define PK_H - -#ifndef STRAW_H -#include "STRAW.H" -#endif - -#include "INT.H" - -/* -** This class holds a public or private key used in Public Key Cryptography. It also serves -** as the conduit for encrypting/decrypting data using that key. Cryptography, using this -** method, has a couple of characteristics that affect how it is used. One, the process of -** encrypting/decrypting is very slow. This limits the effective quantity of data that can -** be processed. Two, the ciphertext is larger than the plaintext. This property generally -** limits its use to streaming data as opposed to random access data. The data is processed -** in blocks. The size of the ciphertext and plaintext blocks can be determined only from -** the key itself. -** -** A reasonable use of this technology would be to encrypt only critical data such as the -** password for a fast general purpose cryptographic algorithm. -*/ -class PKey -{ - public: - PKey(void) : Modulus(0), Exponent(0), BitPrecision(0) {} - PKey(void const * exponent, void const * modulus); // DER initialization. - - int Encrypt(void const * source, int slen, void * dest) const; - int Decrypt(void const * source, int slen, void * dest) const; - - static void Generate(Straw & random, int bits, PKey & fastkey, PKey & slowkey); - - int Plain_Block_Size(void) const {return((BitPrecision-1)/8);} - int Crypt_Block_Size(void) const {return(Plain_Block_Size()+1);} - int Block_Count(int plaintext_length) const {return((((plaintext_length-1)/Plain_Block_Size())+1));} - - int Encode_Modulus(void * buffer) const; - int Encode_Exponent(void * buffer) const; - - void Decode_Modulus(void * buffer); - void Decode_Exponent(void * buffer); - - static long Fast_Exponent(void) {return(65537L);} - -// private: - - // p*q - BigInt Modulus; - - // 65537 or - // inverse of (p-1)(q-1). - BigInt Exponent; - - // Maximum bits allowed for block. - int BitPrecision; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/RGB.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/RGB.H deleted file mode 100644 index 3b001a8298c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/RGB.H +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/RGB.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RGB_H -#define RGB_H - -class PaletteClass; -class HSVClass; - - -/* -** Each color entry is represented by this class. It holds the values for the color -** guns. The gun values are recorded in device dependant format, but the interface -** uses gun values from 0 to 255. -*/ -class RGBClass -{ - public: - RGBClass(void) : Red(0), Green(0), Blue(0) {} - RGBClass(unsigned char red, unsigned char green, unsigned char blue) : Red(red), Green(green), Blue(blue) {} - operator HSVClass (void) const; - RGBClass & operator = (RGBClass const & rgb) { - if (this == &rgb) return(*this); - - Red = rgb.Red; - Green = rgb.Green; - Blue = rgb.Blue; - return(*this); - } - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, RGBClass const & rgb); - int Difference(RGBClass const & rgb) const; - int Get_Red(void) const {return (Red);} - int Get_Green(void) const {return(Green);} - int Get_Blue(void) const {return(Blue);} - void Set_Red(unsigned char value) {Red = value;} - void Set_Green(unsigned char value) {Green = value;} - void Set_Blue(unsigned char value) {Blue = value;} - - private: - - friend class PaletteClass; - - /* - ** These hold the actual color gun values in machine independant scale. This - ** means the values range from 0 to 255. - */ - unsigned char Red; - unsigned char Green; - unsigned char Blue; -}; - -extern RGBClass const BlackColor; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/RLE.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/RLE.H deleted file mode 100644 index f228dc93441..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/RLE.H +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RLE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RLE_H -#define RLE_H - -/* -** This class will RLE compress and decompress arbitrary blocks of data. This RLE compression -** is geared to compressing only runs of 0 bytes. This makes it useful for sprite encoding. -*/ -class RLEEngine -{ - public: - - /* - ** Codec for arbitrary blocks. - */ - int Compress(void const * source, void * dest, int length) const; - int Decompress(void const * source, void * dest, int length) const; - - /* - ** Codec for length encoded blocks. This is useful for sprite storage. - */ - int Line_Compress(void const * source, void * dest, int length) const; - int Line_Decompress(void const * source, void * dest) const; -}; - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H deleted file mode 100644 index fbbe23fea70..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/RNDSTRAW.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNDSTRAW_H -#define RNDSTRAW_H - - -#include "RANDOM.H" -#include "STRAW.H" - -/* -** This is a straw terminator class. It will generate random numbers to fill the data request. -** Unlike regular straw terminators, this class will never run out of "data". -*/ -class RandomStraw : public Straw -{ - public: - RandomStraw(void); - virtual ~RandomStraw(void); - - virtual int Get(void * source, int slen); - - void Reset(void); - void Seed_Bit(int seed); - void Seed_Byte(char seed); - void Seed_Short(short seed); - void Seed_Long(long seed); - - int Seed_Bits_Needed(void) const; - - private: - /* - ** Counter of the number of seed bits stored to this random number - ** generator. - */ - int SeedBits; - - /* - ** The current random generator to use when fetching the next random - ** byte of data. - */ - int Current; - - /* - ** Array of generators. There must be at least 448 bits of random number seed - ** in order to be reasonably secure, however, using 1024 bits would be best. - */ - Random3Class Random[32]; - - void Scramble_Seed(void); - - RandomStraw(RandomStraw & rvalue); - RandomStraw & operator = (RandomStraw const & pipe); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/Surface.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/Surface.h deleted file mode 100644 index b4b53b6cd9a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/Surface.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/surface.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:40p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef SURFACE_H -#define SURFACE_H - -#include "Point.h" -#include "trect.h" - -/* -** This is an abstract interface class for a graphic surface. Graphic operations will use this -** interface to perform their function. The philosphy behind this interface is that it represents -** a small but useful set of functions. Emphasis is placed on supporting those functions which are -** likely to have hardware assist. -*/ -class Surface -{ - public: - Surface(int width, int height) : Width(width), Height(height) {} - virtual ~Surface(void) {}; - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false) = 0; - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false) = 0; - virtual bool Blit_From(Surface const & source, bool trans=false) = 0; - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color) = 0; - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) = 0; - virtual bool Fill(int color) = 0; - - /* - ** Fetches and stores a pixel to the display (pixel is in surface format). - */ - virtual bool Put_Pixel(Point2D const & point, int color) = 0; - virtual int Get_Pixel(Point2D const & point) const = 0; - - /* - ** Draws lines onto the surface. - */ - virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color) = 0; - virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color) = 0; - - /* - ** Draws rectangle onto the surface. - */ - virtual bool Draw_Rect(Rect const & rect, int color) = 0; - virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color) = 0; - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const = 0; - virtual bool Unlock(void) const = 0; - virtual bool Is_Locked(void) const = 0; - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const = 0; - virtual int Stride(void) const = 0; - virtual Rect Get_Rect(void) const {return(Rect(0, 0, Width, Height));} - virtual int Get_Width(void) const {return(Width);} - virtual int Get_Height(void) const {return(Height);} - - /* - ** Hack function to serve the purpose that RTTI was invented for, but since - ** the Watcom compiler doesn't support RTTI, we must resort to using this - ** alternative. - */ - virtual bool Is_Direct_Draw(void) const {return(false);} - - protected: - - /* - ** Records logical pixel dimensions of the surface. - */ - int Width; - int Height; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h deleted file mode 100644 index cff60a85f01..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h +++ /dev/null @@ -1,278 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /VSS_Sync/wwlib/tagblock.h 6 10/17/00 4:48p Vss_sync $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWLib * - * * - * $Archive:: /VSS_Sync/wwlib/tagblock.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef TAGBLOCK_H -#define TAGBLOCK_H - -#include "SLIST.H" -#include "CRC.H" -#include "RAWFILE.H" - -#include - -class TagBlockHandle; -class TagBlockIndex; - - ////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////// Start of TagBlockHandle/////////////////////////////////////// -// TagBlockFile: Enables a file to have named (tagged) variable size blocks. User can -// then open a block for reading. User may also create new blocks at the end of the -// file. There may only be one block open for writting, unlimited blocks can be open for -// reading. It can be thought of as a .MIX file that can have files added to it at any time. -// One problem is it is a Write Once/Read Many solution. -// -// Usage: All user access to a TagBlockFile is done through TagBlockHandle. -// A TagBlockHandle is created by TagBlockFile::Create_Tag() or Open_Tag(). It is destroyed -// by either TagBlockFile::Close_Tag() or you can just destroy the handle with delete(). -// -// - -class TagBlockFile : protected RawFileClass -{ - public: - ////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Public Member Functions /////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - - // Open up the tag file. It may or may not exist. - TagBlockFile(const char *fname); - virtual ~TagBlockFile(); - - // DANGEROUS!! Resets entire file and makes small - virtual void Reset_File(); - - // Creation of a Handle so block can be crated/writen/read. - // Use delete to destroy handle or use Close_Tag(). - // Open_Tag() returns NULL if tag not found. - // Create_Tag() returns NULL if tag already exists. - TagBlockHandle *Open_Tag(const char *tagname); - TagBlockHandle *Create_Tag(const char *tagname); - void Close_Tag(TagBlockHandle *handle); - - int Does_Tag_Exist(const char *tagname) { - return(Find_Block(tagname) != NULL); - } - - virtual unsigned long Get_Date_Time(void) { - return(FileTime); - } - - // Methods to figure an offset of the tag name and the data - // given the offset of the start of the block (BlockHeader).. - static int Calc_Tag_Offset(int blockoffset) { - return(blockoffset + sizeof(BlockHeader)); - } - static int Calc_Data_Offset(int blockoffset, const char *tagname) { - return(Calc_Tag_Offset(blockoffset) + strlen(tagname) + 1); - - } - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Supporting Structures ///////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - enum { - // Put in date when format is changed. - FILE_VERSION = 20000626, - MAX_TAG_NAME_SIZE = 1024, - }; - - // This is the header that is in both the IndexFile and the DataFile. - // They should be match except for the difference in the Version number as defined by enum. - struct FileHeader - { - FileHeader() {memset(this, 0, sizeof(*this));} - - // Version number to make sure that it we are compatable and also to - // verify that this is the file we think it is. - unsigned Version; - - // Number of blocks in file. - int NumBlocks; - - // This is how much data is actually valid in the file. There may be - // extra room at end of file if file size is preset or the file is corrupt. - int FileSize; - }; - - // Each block in the file has a header before it. - struct BlockHeader - { - BlockHeader() {memset(this, 0, sizeof(*this));} - BlockHeader(int index, int tagsize, int datasize):Index(index),TagSize(tagsize),DataSize(datasize) {} - BlockHeader(BlockHeader& bh) {memcpy(this, &bh, sizeof(BlockHeader));} - - // Used to verify file integrity. - int Index; - - // Size of tagname (including NULL) that follows this block. - int TagSize; - - // Size of block not including header. - int DataSize; - - // A variable length name (NULL terminated) follows this structure. - // The name is then followed by the Data. - - // The entire length of the block is sizeof(BlockHeader) + TagSize + DataSize. - }; - - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Member Data Fields //////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - - // This is the data at the start of the file. - FileHeader Header; - - // Only one handle has permission to write to the end of the file if any. - // This is a pointer to that handle. - TagBlockHandle *CreateHandle; - - // To help those stupid programmers from leaving open handles when - // this file is closed down. - int NumOpenHandles; - - // Last time file was written to before we opened it. - unsigned long FileTime; - - // Keep list of all blocks in file. This list is sorted by CRC value. - // TagBlockIndex is defined in TagBlock.cpp. - SList IndexList; - - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Protected Member Functions //////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - // Search for block given tag. - TagBlockIndex *Find_Block(const char *tagname); - - // Create an index that can be used for seaching. - TagBlockIndex *Create_Index(const char *tagname, int blockoffset); - - // Is this the handle that has creation priveledges? - int Handle_Can_Write(TagBlockHandle *handle) { - return(CreateHandle == handle); - } - - // Called only by ~TagBlockHandle! - void Destroy_Handle(TagBlockHandle *handle); - - // Stop write access - flushes data out but keeps handle available for reading. - int End_Write_Access(TagBlockHandle *handle); - - // Save the header when it has been updated. - void Save_Header() { - Seek(0, SEEK_SET); - Write(&Header, sizeof(Header)); - } - - void Empty_Index_List(); - - friend class TagBlockHandle; -}; - -///////////////////////////////////////// End of TagBlockFile ///////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// Start of TagBlockHandle///////////////////////////////////// -// All external access to the TagBlockFile is done through handles. -class TagBlockHandle -{ - public: - // Access functions. - int Write(const void *buf, int nbytes); - int Read(void *buf, int nbytes); - int Seek(int pos, int dir = SEEK_CUR); - - // Stop write access - flushes data out but keeps handle available for reading. - int End_Write_Access() { - return (File->End_Write_Access(this)); - } - - int Tell() { - return(Position); - } - - int Get_Data_Size() { - return(BlockHeader->DataSize); - } - - // User must call TagBlockFile::New_Handle() to create a TagBlockHandle object. - // User may call this delete to destry handle or - // he may call TagBlockFile::Close_Tag(). - ~TagBlockHandle(); - - private: - - // Pointer to parent file object. - TagBlockFile *File; - - // Pointer to index for aditional information. - TagBlockIndex *Index; - - // Keep header infomation in memory so that it can be updated. - TagBlockFile::BlockHeader *BlockHeader; - - // Current postion we are in the file. - int Position; - - private: - // User must call TagBlockFile::New_Handle() to create a TagBlockHandle object. - // The constructor is private so only TagBlockFile can create the handle. - // This is so that a handle will not be created if the TagBlock - // does not exist on a CREAD or if there was already a WRITE access granted. - // User needs to call detete to destroy the handle. - TagBlockHandle(TagBlockFile *tagfile, TagBlockIndex *tagindex, TagBlockFile::BlockHeader *blockheader); - friend class TagBlockFile; - - // Used to prevent TagBlockFile::Destroy_Handle() from being called - // except by this destructor. - static int _InDestructor; - - int Called_By_Destructor() { - return(_InDestructor); - } -}; - - -////////////////////////////////////// End of TagBlockHandle/////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#endif //TAGBLOCK_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H deleted file mode 100644 index 58e8cd07ff3..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H +++ /dev/null @@ -1,118 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/WATCOM.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:56a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(WATCOM_H) && defined(__WATCOMC__) -#define WATCOM_H - - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -// Turn all warnings into errors. -#pragma warning * 0 - -// Disables warning when "sizeof" is used on an object with virtual functions. -#pragma warning 549 9 - -// Disable the "Integral value may be truncated during assignment or initialization". -#pragma warning 389 9 - -// Allow constructing a temporary to be used as a parameter. -#pragma warning 604 9 - -// Disable the construct resolved as an expression warning. -#pragma warning 595 9 - -// Disable the strange "construct resolved as a declaration/type" warning. -#pragma warning 594 9 - -// Disable the "pre-compiled header file cannot be used" warning. -#pragma warning 698 9 - -// Disable the "temporary object used to initialize a non-constant reference" warning. -#pragma warning 665 9 - -// Disable the "pointer or reference truncated by cast. Cast is supposed to REMOVE warnings, not create them. -#pragma warning 579 9 - -// Disable the warning that suggests a null destructor be placed in class definition. -#pragma warning 656 9 - -// Disable the warning about moving empty constructors/destructors to the class declaration. -#pragma warning 657 9 - -// No virtual destructor is not an error in C&C. -#pragma warning 004 9 - -// Integral constant will be truncated warning is usually ok when dealing with bitfields. -#pragma warning 388 9 - -// Turns off unreferenced function parameter warning. -//#pragma off(unreferenced) - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -#if !defined(__BORLANDC__) -#define M_E 2.71828182845904523536 -#define M_LOG2E 1.44269504088896340736 -#define M_LOG10E 0.434294481903251827651 -#define M_LN2 0.693147180559945309417 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.785398163397448309616 -#define M_1_PI 0.318309886183790671538 -#define M_2_PI 0.636619772367581343076 -#define M_1_SQRTPI 0.564189583547756286948 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT_2 0.707106781186547524401 -#endif - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp deleted file mode 100644 index b05077cbba9..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/_Convert.cpp $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 2/10/98 4:20p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_convert.h" - -ConvertClass * VoxelDrawer = NULL; -ConvertClass * UnitDrawer = NULL; -ConvertClass * TerrainDrawer = NULL; -ConvertClass * AnimDrawer = NULL; -ConvertClass * NormalDrawer = NULL; -ConvertClass * IsometricDrawer = NULL; - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.h deleted file mode 100644 index 12ee46093bf..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_convert.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Convert.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _CONVERT_H -#define _CONVERT_H - -#include "Convert.h" - -extern ConvertClass * VoxelDrawer; -extern ConvertClass * UnitDrawer; -extern ConvertClass * TerrainDrawer; -extern ConvertClass * AnimDrawer; -extern ConvertClass * NormalDrawer; -extern ConvertClass * IsometricDrawer; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp deleted file mode 100644 index 2ea62eadc0b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_mono.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_mono.h" - - -/* -** This is the global (general purpose) mono object. It exists only for the convenience of -** debugging mono printing. -*/ -MonoClass Mono; - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.h deleted file mode 100644 index ba9790b95f3..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_mono.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/_mono.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:58a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef _MONO_H -#define _MONO_H - -#include "MONO.H" - - -/* -** This externs the global mono object. There can be only one. -*/ -extern MonoClass Mono; - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp deleted file mode 100644 index eab7fb98f63..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Timer.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_timer.h" - - -/*************************************************************************** -** Game frame timer (this is synced between processes). -*/ -CDTimerClass FrameTimer; - -/*************************************************************************** -** Tick Count global timer object. -*/ -TTimerClass TickCount = 0; - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.h deleted file mode 100644 index fd9116125fd..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_timer.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Timer.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _TIMER_H -#define _TIMER_H - -#include "stimer.h" -#include "timer.h" - -extern CDTimerClass FrameTimer; -extern TTimerClass TickCount; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h deleted file mode 100644 index efda67ffea3..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_xmouse.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _XMOUSE_H -#define _XMOUSE_H - -#include "xmouse.h" - -extern Mouse * MouseCursor; - - - -inline void Hide_Mouse(void) {MouseCursor->Hide_Mouse();} -inline void Show_Mouse(void) {MouseCursor->Show_Mouse();} -inline void Conditional_Hide_Mouse(Rect rect) {MouseCursor->Conditional_Hide_Mouse(rect);} -inline void Conditional_Show_Mouse(void) {MouseCursor->Conditional_Show_Mouse();} -inline int Get_Mouse_State(void) {return(MouseCursor->Get_Mouse_State());} -inline void Set_Mouse_Cursor(int hotx, int hoty, ShapeSet const * cursor, int shape) {MouseCursor->Set_Cursor(hotx, hoty, cursor, shape);} -inline int Get_Mouse_X(void) {return(MouseCursor->Get_Mouse_X());} -inline int Get_Mouse_Y(void) {return(MouseCursor->Get_Mouse_Y());} - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.cpp deleted file mode 100644 index 32504249a0a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/blit.cpp $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/15/99 10:13a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Bit_Blit -- Blit a block of pixels to the destination surface. * - * Bit_Blit -- Blits data to a surface w/ clipping. * - * Buffer_Size -- Determines size of buffer for given dimensions. * - * From_Buffer -- Copy graphic data from a buffer to a surface. * - * RLE_Blit -- Blits RLE compressed data without extra clipping. * - * RLE_Blit -- Blits a rectangle of RLE compressed data to a surface. * - * To_Buffer -- Copies a graphic region into a linear RAM buffer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blit.h" -#include "bsurface.h" -//#include "rle.h" -#include "xsurface.h" -//#include - - -/*********************************************************************************************** - * Buffer_Size -- Determines size of buffer for given dimensions. * - * * - * This routine will determine the byte size of a buffer if it were to hold the pixels * - * of the dimensions specified. It takes into account the bytes per pixel. * - * * - * INPUT: surface -- The surface to base the buffer size calculation upon. * - * * - * width -- Pixel width of a graphic region. * - * * - * height -- Pixel height of a graphic region. * - * * - * OUTPUT: Returns with the number of bytes such a region would consume if it were linearly * - * packed into a memory buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int Buffer_Size(Surface const & surface, int width, int height) -{ - return(width * height * surface.Bytes_Per_Pixel()); -} - - -/*********************************************************************************************** - * To_Buffer -- Copies a graphic region into a linear RAM buffer. * - * * - * This routine will copy the graphic rectangle specified, into a RAM buffer. The size of * - * the RAM buffer must be big enough to hold the pixel data. Use the Buffer_Size() function * - * to determine how big it must be. * - * * - * INPUT: surface -- The surface to copy the pixel data from. * - * * - * rect -- The graphic rectangle to copy from. * - * * - * buffer -- Reference to the buffer that will be filled with the pixel data. * - * * - * OUTPUT: bool; Was the data copy performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool To_Buffer(Surface const & surface, Rect const & rect, Buffer & buffer) -{ - if (!rect.Is_Valid()) return(false); - - BSurface from(rect.Width, rect.Height, surface.Bytes_Per_Pixel(), buffer); - return(from.Blit_From(Rect(0, 0, rect.Width, rect.Height), surface, rect)); -} - - -/*********************************************************************************************** - * From_Buffer -- Copy graphic data from a buffer to a surface. * - * * - * This routine will take pixel data and move it from the specified buffer and into the * - * surface rectangle specified. It is the counterpart routine of To_Buffer(). * - * * - * INPUT: surface -- The surface to store the pixel data to. * - * * - * rect -- The destination rectangle to store the pixel data to. * - * * - * buffer -- Reference to the buffer that contains the pixel data. * - * * - * OUTPUT: bool; Was the pixel data copy performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool From_Buffer(Surface & surface, Rect const & rect, Buffer const & buffer) -{ - if (!rect.Is_Valid()) return(false); - - BSurface from(rect.Width, rect.Height, surface.Bytes_Per_Pixel(), buffer); - return(surface.Blit_From(rect, from, Rect(0, 0, rect.Width, rect.Height))); -} - - - -/*********************************************************************************************** - * Bit_Blit -- Blits data to a surface w/ clipping. * - * * - * This routine will take source pixel data and blit it to the surface specified while * - * also performing clipping on both the source and the destination data. Typical users of * - * this routine would be to draw shape (sprite) data. * - * * - * INPUT: dest -- Destintaion surface rect. This specifies the destination surface and * - * any coordinate clipping rectangle. * - * * - * destrect -- The destination rectangle of the blit. The coordinates are relative * - * to the destination clipping rectangle. * - * * - * source -- Source surface rect. This specifies the source surface as well as any * - * clipping rectangle it may contain. * - * * - * srcrect -- The rectange, relative to the source clipping rectangle, that * - * specifies the source blit data. It is presumed that the dimensions of * - * the source rectangle are the same as the destination rectangle. * - * * - * blitter -- The blitter to use for moving the source pixels to the destination * - * surface. * - * * - * OUTPUT: bool; Was the blit performed even if it was for only a single pixel. Failure would * - * indicate that the blit was completely clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool Bit_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, Blitter const & blitter) -{ - return(Bit_Blit(dest, dest.Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, blitter)); -} - - -/*********************************************************************************************** - * Bit_Blit -- Blit a block of pixels to the destination surface. * - * * - * This routine will blit a block of pixels and perform clipping on the blit as controlled * - * by the clipping rectangles. * - * * - * INPUT: dest -- Surface to blit to. * - * * - * dcliprect-- The destination surface clipping rectangle. * - * * - * ddrect -- The destination rect of the blit. It is relative to the clipping * - * rectangle and will be clipped against same. * - * * - * source -- The source surface to blit from. * - * * - * scliprect-- The source surface clipping rectangle. * - * * - * ssrect -- The source rectangle of the blit. It is relative to the source * - * clipping rectangle and will be clipped against same. * - * * - * blitter -- The blitter to use for blitting of this rectangle. * - * * - * OUTPUT: bool; Was the blit performed? A 'false' return value would indicate that the * - * blit was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool Bit_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, Blitter const & blitter) -{ - Rect srect = ssrect; - Rect drect = ddrect; - bool overlapped = false; - void * dbuffer = NULL; - void * sbuffer = NULL; - - /* - ** Prepare for the blit by performing any clipping as well as fetching pointers into the - ** pixel buffers. If there were any errors, then this blit cannot be performed. - */ - if (!XSurface::Prep_For_Blit(dest, dcliprect, drect, source, scliprect, srect, overlapped, dbuffer, sbuffer)) { - return(false); - } - - /* - ** If there is no difference between the width and the stride of the source and - ** destination surfaces, then the copy can be performed as one huge copy operation. - ** This is the simplist case and the one that is performed with a full screen - ** blit. - */ - if (drect.Width * dest.Bytes_Per_Pixel() == dest.Stride() && dest.Stride() == source.Stride()) { - - int length = MIN(srect.Height*srect.Width, drect.Height*drect.Width); - if (overlapped) { - blitter.BlitBackward(dbuffer, sbuffer, length); - } else { - blitter.BlitForward(dbuffer, sbuffer, length); - } - - } else { - - /* - ** If the rectangles overlap, then the copy must proceed from the - ** last row to the first rather than the normal direction. - */ - int sstride = source.Stride(); - int dstride = dest.Stride(); - if (overlapped) { - sstride = -sstride; - dstride = -dstride; - sbuffer = ((char*)sbuffer) + (srect.Height-1) * source.Stride(); - dbuffer = ((char*)dbuffer) + (drect.Height-1) * dest.Stride(); - } - - /* - ** This perform a line-by-line pixel copy. - */ - int height = MIN(srect.Height, drect.Height); - if (overlapped) { - for (int y = 0; y < height; y++) { - blitter.BlitBackward(dbuffer, sbuffer, srect.Width); - dbuffer = (void*)(((char*)dbuffer) + dstride); - sbuffer = (void*)(((char*)sbuffer) + sstride); - } - } else { - for (int y = 0; y < height; y++) { - blitter.BlitForward(dbuffer, sbuffer, srect.Width); - dbuffer = (void*)(((char*)dbuffer) + dstride); - sbuffer = (void*)(((char*)sbuffer) + sstride); - } - } - } - - dest.Unlock(); - source.Unlock(); - - return(true); -} - - -/*********************************************************************************************** - * RLE_Blit -- Blits RLE compressed data without extra clipping. * - * * - * This routine will blit a rectangle of RLE compressed data to the specified surface. It * - * is functionally similar to the other RLE blit routine, but does not use any sub * - * clipping rectangles. The blit is naturally clipped to the edge of the destination * - * surface. * - * * - * INPUT: dest -- Reference to the destination surface. * - * * - * destrect -- The destination rectangle to draw the pixels to. * - * * - * source -- Reference to the source RLE surface data. * - * * - * sourcerect -- The source rectangle of from the RLE surface to blit from. * - * * - * blitter -- Reference to the blitter to perform the blit operation with. * - * * - * OUTPUT: bool; Was a blit performed? A 'false' value would mean that the blit has been * - * clipped into nothing. * - * * - * WARNINGS: The dimensions of the source and destination rectangles should be the same * - * until such time that the blitter can support scaling (as of this writing, it * - * cannot). * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool RLE_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, RLEBlitter const & blitter) -{ - return(RLE_Blit(dest, dest.Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, blitter)); -} - - -/*********************************************************************************************** - * RLE_Blit -- Blits a rectangle of RLE compressed data to a surface. * - * * - * This routine will blit a rectangle of REL compressed pixel data from a sprite to the * - * surface specified. Appropriate clipping and coordinate adjustments will occur as * - * controlled by the parameters. This is the workhorse RLE blit dispatcher routine. * - * * - * INPUT: dest -- The destination surface to blit to. * - * * - * dcliprect-- The clipping rectangle to use on the destination. Pixels won't be * - * drawn outside of this rectangle and the destination rect coordinates * - * are biased to this clipping rectange. * - * * - * ddrect -- The destination rectangle of the blit. The upper left coordinates are * - * biased to the destination clipping rectangle when blitted. Thus, * - * a dest X,Y position of 0,0 really means the upper left corner of the * - * destination clipping rectangle. * - * * - * source -- The source surface of the RLE compressed data. * - * * - * scliprect-- It is quite likely that this will be the full size of the source * - * surface. * - * * - * ssrect -- The source rectangle to blit from within the source surface. It * - * behaves similarly to the ddrect parameter, but for the source. The * - * width and height of this rectangle should match the width and height * - * of the ddrect parameter (scaling is not yet supported). * - * * - * blitter -- The blitter to use for this pixel copy. It must be an RLE blitter. * - * * - * OUTPUT: bool; Did the blit draw at least one pixel? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/24/1997 JLB : Created. * - *=============================================================================================*/ -bool RLE_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, RLEBlitter const & blitter) -{ - Rect srect = ssrect; // Desired source rect. - Rect drect = ddrect; // Desired destination rect. - - /* - ** Adjust the desired draw rectangles to account for clipping. This is where the desired rectangles - ** get clipped to the bounding rectangles of the surfaces. - */ - if (!Blit_Clip(drect, dcliprect, srect, scliprect)) { - return(false); - } - - /* - ** Determine the top and left skip margins. These require special handling - ** since the shape is compressed. - */ - int leftmargin = srect.X - scliprect.X; - int topmargin = srect.Y - scliprect.Y; - - void * dbuffer = dest.Lock(dcliprect.Top_Left() + drect.Top_Left()); -// void * dbuffer = dest.Lock(Point2D(dcliprect.X + drect.X, dcliprect.Y + drect.Y)); - if (dbuffer == NULL) return(false); - - /* - ** Lock the source pointer. This must always lock at location 0,0 since - ** normal pixel offset logic does not work for RLE compressed buffers. If there - ** is a pixel offset required, it is handled below. - */ - void * sbuffer = source.Lock(); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - /* - ** Skip any top margin lines. This must be manually performed on a line - ** by line basis because the length of each line is Variable. - */ - while (topmargin > 0) { - sbuffer = ((unsigned char *)sbuffer) + (*(unsigned short *)sbuffer); - topmargin--; - } - - /* - ** This perform a line-by-line pixel copy. - */ - int dstride = dest.Stride(); - int height = MIN(srect.Height, drect.Height); - for (int y = 0; y < height; y++) { - - /* - ** Blit the correct sub-portion to the destination surface. - */ - blitter.Blit(dbuffer, ((unsigned short *)sbuffer)+1, srect.Width, leftmargin); - - /* - ** Advance the source and dest pointers for the next line processing. - */ - sbuffer = ((unsigned char *)sbuffer) + (*(unsigned short *)sbuffer); - dbuffer = (void*)(((char*)dbuffer) + dstride); - } - - dest.Unlock(); - source.Unlock(); - - return(true); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.h deleted file mode 100644 index 31403dc9601..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blit.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/blit.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:49p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLIT_H -#define BLIT_H - -#include "blitter.h" -#include "BUFF.H" -#include "trect.h" -#include "Surface.h" - -bool Bit_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, Blitter const & blitter); -bool RLE_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, RLEBlitter const & blitter); - -//bool Bit_Blit(SurfaceRect & dest, Rect const & ddrect, SurfaceRect const & source, Rect const & ssrect, Blitter const & blitter); -//bool RLE_Blit(SurfaceRect & dest, Rect const & ddrect, SurfaceRect const & source, Rect const & ssrect, RLEBlitter const & blitter); - -bool Bit_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, Blitter const & blitter); -bool RLE_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, RLEBlitter const & blitter); - - -int Buffer_Size(Surface & surface, int width, int height); -bool To_Buffer(Surface const & surface, Rect const & rect, Buffer & buffer); -bool From_Buffer(Surface & surface, Rect const & rect, Buffer const & buffer); - - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blitblit.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blitblit.h deleted file mode 100644 index 2bb133022ad..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blitblit.h +++ /dev/null @@ -1,614 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/blitblit.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLITBLIT_H -#define BLITBLIT_H - - -/* -** This module contains the pixel-pushing blitter objects. These objects only -** serve one purpose. That is, to move pixels from one location to another. These -** are prime candidates for optimization since they are called frequently and -** loop greatly. -** -** The large variety of blitter objects is necessary because there is a rich -** set of pixel operations required by the game engine. Complicating this is that -** the game engine must support both 16 bit and 8 bit pixel formats. Some of these -** blitter objects are templates (this reduces the need for both 8 and 16 bit -** counterparts if the algorithm is constant between pixel formats). Also note -** that there are some assembly implementations where it seems appropriate. -** -** If the blitter object has "Xlat" in the name, then this means that the source -** pixel is 8 bit and the destination pixel is 16 bit (probably). This hybrid system -** allows the game artwork to be shared between the two pixel format displays. To -** accomplish this, a translation table is supplied to the blit operation so that -** the 8 bit pixel can be converted into the appropriate 16 bit destination pixel. -** If the destination surface is also 8 bit, then the translation table converts -** the pixel to the logical palette color index appropriate for the display. -*/ - - -#include "blitter.h" -#include -#include - - -/* -** Blits without translation and source and dest are same pixel format. Note that -** this uses the memcpy and memmove routines. The C library has optimized these for -** maximum performance. This includes alignment issues and performing REP MOVSD -** instruction. This might be further optimized by using MMX instructions. However, -** this blitter process is not often required by the game. -*/ -template -class BlitPlain : public Blitter { - public: - virtual void BlitForward(void * dest, void const * source, int length) const {memcpy(dest, source, length*sizeof(T));} - virtual void BlitBackward(void * dest, void const * source, int length) const {memmove(dest, source, length*sizeof(T));} -}; - - -/* -** Blits with transparency checking when and source and dest are same pixel format. -** This process is not often used. -*/ -template -class BlitTrans : public Blitter { - public: - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - T color = *(T const *)source; - source = ((T *)source) + 1; - if (color != 0) *((T *)dest) = color; - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} -}; - - -/* -** Blits when source 8 bits and dest is T. This process is typically used -** when loading screen bitmaps or perform other non-transparent image blitting. -** It is used fairly frequently and is a good candidate for optimization. -*/ -template -class BlitPlainXlat : public Blitter { - public: - BlitPlainXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - *((T *)dest) = TranslateTable[color]; - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit with transparency and dest is T. This process is used -** frequently by trees and other terrain objects. It is a good candidate for -** optimization. -*/ -template -class BlitTransXlat : public Blitter { - public: - BlitTransXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[color]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit, transparency check, then translate to pixel format T. This -** is occasionally used to render special remapping effects. Since the remap table is -** not doubly indirected, it is fixed to only using the remap table specified in the -** constructor. As such, it has limited value. -*/ -template -class BlitTransRemapXlat : public Blitter { - public: - BlitTransRemapXlat(unsigned char const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(RemapTable != NULL);assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[RemapTable[color]]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - unsigned char const * RemapTable; - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit with transparency then remap and dest is T. This is probably -** the most used blitter process. Units, infantry, buildings, and aircraft use this for -** their normal drawing needs. If any blitter process is to be optimized, this would be -** the one. Take note that the remapper table is doubly indirected. This allows a single -** blitter object to dynamically use alternate remap tables. -*/ -template -class BlitTransZRemapXlat : public Blitter { - public: - BlitTransZRemapXlat(unsigned char const * const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(RemapTable != NULL);assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - unsigned char const * rtable = *RemapTable; - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[rtable[color]]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - unsigned char const * const * RemapTable; - T const * TranslateTable; -}; - - -/* -** Algorithmic darkening of hicolor pixels controlled by the source pixels. The source -** pixels are examined only to determine if the destination pixel should be darkened. -** If the source pixel is transparent, then the dest pixel is skipped. The darkening -** algorithm works only for hicolor pixels. -*/ -template -class BlitTransDarken : public Blitter { - public: - BlitTransDarken(T mask) : Mask(mask) {} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = (T)((((*(T *)dest) >> 1) & Mask)); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T Mask; -}; - - -/* -** This will remap the destination pixels but under the control of the source pixels. -** Where the source pixel is not transparent, the dest pixel is remapped. This algorithm -** really only applies to lowcolor display. -*/ -template -class BlitTransRemapDest : public Blitter { - public: - BlitTransRemapDest(T const * remap) : RemapTable(remap) {} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = RemapTable[*((T *)dest)]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * RemapTable; -}; - - -/* -** This is similar to BlitTransDarken but instead of examining the source to determine what -** pixels should be darkened, every destination pixel is darkened. This means that the source -** pointer is unused. -*/ -template -class BlitDarken : public Blitter { - public: - BlitDarken(T mask) : Mask(mask) {} - virtual void BlitForward(void * dest, void const * , int length) const - { - for (int index = 0; index < length; index++) { - *((T *)dest) = (T)(((*(T *)dest) >> 1) & Mask); - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T Mask; -}; - - -/* -** This blitter performs 50% translucency as it draws. It is commonly used for animation -** effects and other stealth like images. It only works with hicolor pixels but is a good -** candidate for optimization. -*/ -template -class BlitTransLucent50 : public Blitter { - public: - BlitTransLucent50(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - *((T *)dest) = (T)((((*(T *)dest) >> 1) & Mask) + ((TranslateTable[color] >> 1) & Mask)); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 25% translucency as it draws. This effect is less than spectacular, -** but there are some uses for it. It only works with hicolor pixels. -*/ -template -class BlitTransLucent25 : public Blitter { - public: - BlitTransLucent25(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - T qsource = (T)(((TranslateTable[color] >> 2) & Mask)); - T qdest = (T)((((*(T *)dest) >> 2) & Mask)); - *((T *)dest) = (T)(qdest + qsource + qsource + qsource); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 75% translucency as it draws. This is quite useful for explosions and -** other gas animation effects. It only works with hicolor pixels and is a good candidate -** for optimization. -*/ -template -class BlitTransLucent75 : public Blitter { - public: - BlitTransLucent75(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - T qsource = (T)(((TranslateTable[color] >> 2) & Mask)); - T qdest = (T)(((*(T *)dest) >> 2) & Mask); - *((T *)dest) = (T)(qdest + qdest + qdest + qsource); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** Assembly versions of some of the templated blitter object functions. Borland and -** Visual C++ support a compatible inline-assembly formats. However, Borland compiler -** does not allow inline-assembly to be part of an inline function -- go figure. -** It will still compile, it just generates warning messages. -*/ -#if defined(_MSC_VER) - -inline void BlitTrans::BlitForward(void * dest, void const * source, int len) const -{ - __asm { - mov esi,[source] - mov edi,[dest] - mov ecx,[len] - dec edi - inc ecx - } -again: - __asm { - dec ecx - jz fini - mov al,[esi] - inc edi - inc esi - test al,al - jz again - mov [edi],al - jmp again - } -fini:; -} - - -inline void BlitTransXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * xlator = TranslateTable; - - __asm { - mov ebx,[xlator] - mov ecx,[len] - inc ecx - mov edi,[dest] - sub edi,2 - mov esi,[source] - xor eax,eax - } -again: - __asm { - dec ecx - jz over - add edi,2 - mov al,[esi] - inc esi - or al,al - jz again - mov dx,[ebx+eax*2] - mov [edi],dx - jmp again - } -over:; -} - - -inline void BlitTransRemapXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * translator = TranslateTable; - unsigned char const * remapper = RemapTable; - - __asm { - mov ecx,[len] - mov edi,[dest] - sub edi,2 - mov esi,[source] - mov ebx,[remapper] - mov edx,[translator] - xor eax,eax - } - - /* - ** This block is 11 cycles per pixel, if not transparent, and 5 - ** cycles per pixel, if transparent. - */ -again: - __asm { - dec ecx - jz over - add edi,2 - xor eax,eax - lodsb - or al,al - jz again - mov al,[ebx+eax] // First remap step (8 bit to 8 bit). - mov ax,[edx+eax*2] // Second remap step (8 bit to 16 bit). - mov [edi],ax - jmp again - } -over:; -} - - -inline void BlitTransZRemapXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * translator = TranslateTable; - unsigned char const * remapper = *RemapTable; - - __asm { - mov ecx,[len] - mov edi,[dest] - sub edi,2 - mov esi,[source] - mov ebx,[remapper] - mov edx,[translator] - xor eax,eax - } - - /* - ** This block is 11 cycles per pixel, if not transparent, and 5 - ** cycles per pixel, if transparent. - */ -again: - __asm { - dec ecx - jz over - add edi,2 - xor eax,eax - lodsb - or al,al - jz again - mov al,[ebx+eax] // First remap step (8 bit to 8 bit). - mov ax,[edx+eax*2] // Second remap step (8 bit to 16 bit). - mov [edi],ax - jmp again - } -over:; -} - - -inline void BlitPlainXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * remapper = TranslateTable; - __asm { - mov ebx,[remapper] - mov ecx,[len] - mov esi,[source] - mov edi,[dest] - sub edi,2 - } -again: - /* - ** This block processes pixels at 7 clocks per pixel. - */ - __asm { - xor eax,eax - add edi,2 - mov al,[esi] - inc esi - mov ax,[ebx+eax*2] - mov [edi],ax - dec ecx - jnz again - } -} - - -#endif - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blitter.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blitter.h deleted file mode 100644 index 34e7a2a1620..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blitter.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/blitter.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:48p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef BLITTER_H -#define BLITTER_H - -/* -** This is the interface class to the blitter object. The blitter object handles moving -** pixels. That's all it does. For every type of pixel translation, there should be a -** blitter object created that supports this interface. The blit blitting routines will -** call the appropriate method as the pixel are being processed. -*/ -class Blitter { - public: - - /* - ** Blits from source to dest (starts at first pixel). This is the preferred - ** method of pixel blitting and this routine will be called 99% of the time under - ** normal circumstances. - */ - virtual void BlitForward(void * dest, void const * source, int length) const = 0; - - /* - ** Copies the pixel in reverse order. This only required if the source and dest - ** pixel regions overlap in a certain way. This routine will rarely be called. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const = 0; - - /* - ** This routine calls the appropriate blit routine. A proper overlap check cannot - ** be performed by this routine because the pixel size information is not present. - ** as such, you should call the appropriate blit routine rather than letting this - ** routine perform the check and call. - */ - void Blit(void * dest, void const * source, int length) const {if (dest < source) BlitBackward(dest, source, length); else BlitForward(dest, source, length);} -}; - - -/* -** This is the blitter object interface for dealing with RLE compressed pixel data. For -** every type of RLE compressed blitter operation desired, there would be an object created -** that supports this interface. -*/ -class RLEBlitter { - public: - - /* - ** Blits from the RLE compressed source to the destination buffer. An optional - ** leading pixel skip value can be supplied when a sub-section of an RLE - ** compressed pixel sequence is desired. This is necessary because RLE decompression - ** must begin at the start of the compressed data sequence. - */ - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const = 0; -}; - - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp deleted file mode 100644 index 1fecba7b9c4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp +++ /dev/null @@ -1,597 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLOWFISH.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BlowfishEngine::Decrypt -- Decrypts data using blowfish algorithm. * - * BlowfishEngine::Encrypt -- Encrypt an arbitrary block of data. * - * BlowfishEngine::Process_Block -- Process a block of data using Blowfish algorithm. * - * BlowfishEngine::Sub_Key_Encrypt -- Encrypts a block for use in S-Box processing. * - * BlowfishEngine::Submit_Key -- Submit a key that will allow data processing. * - * BlowfishEngine::~BlowfishEngine -- Destructor for the Blowfish engine. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blowfish.h" -#include -#include - - -/* -** Byte order controlled long integer. This integer is constructed -** so that character 0 (C0) is the most significant byte of the -** integer. This is biased toward big endian architecture, but that -** just happens to be how the Blowfish algorithm was designed. -*/ -typedef union { - unsigned long Long; - struct { - unsigned char C3; - unsigned char C2; - unsigned char C1; - unsigned char C0; - } Char; -} Int; - - -/*********************************************************************************************** - * BlowfishEngine::~BlowfishEngine -- Destructor for the Blowfish engine. * - * * - * This destructor will clear out the s-box tables so that even if the memory for the * - * class remains, it will contain no compromising data. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -BlowfishEngine::~BlowfishEngine(void) -{ - if (IsKeyed) { - Submit_Key(NULL, 0); - } -} - - -/*********************************************************************************************** - * BlowfishEngine::Submit_Key -- Submit a key that will allow data processing. * - * * - * This routine must be called before any data can be encrypted or decrypted. This routine * - * need only be called when the key is to be changed or set for the first time. Once the * - * key has been set, the engine may be used to encrypt, decrypt, or both operations * - * indefinitely. The key must be 56 bytes or less in length. This is necessary because * - * any keys longer than that will not correctly affect the encryption process. * - * * - * If the key pointer is NULL, then the S-Box tables are reset to identity. This will * - * mask the previous key setting. Use this method to clear the engine after processing in * - * order to gain a measure of security. * - * * - * INPUT: key -- Pointer to the key data block. * - * * - * length -- The length of the submitted key. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is a time consuming process. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Submit_Key(void const * key, int length) -{ - assert(length <= MAX_KEY_LENGTH); - - /* - ** Initialize the permutation and S-Box tables to a known - ** constant value. - */ - memcpy(P_Encrypt, P_Init, sizeof(P_Init)); - memcpy(P_Decrypt, P_Init, sizeof(P_Init)); - memcpy(bf_S, S_Init, sizeof(S_Init)); - - /* - ** Validate parameters. - */ - if (key == 0 || length == 0) { - IsKeyed = false; - return; - } - - /* - ** Combine the key with the permutation table. Wrap the key - ** as many times as necessary to ensure that the entire - ** permutation table has been modified. The key is lifted - ** into a long by using endian independent means. - */ - int j = 0; - unsigned char const * key_ptr = (unsigned char const *)key; - unsigned long * p_ptr = &P_Encrypt[0]; - for (int index = 0; index < ROUNDS+2; index++) { - unsigned long data = 0; - - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - - *p_ptr++ ^= data; - } - - /* - ** The permutation table must be scrambled by means of the key. This - ** is how the key is factored into the encryption -- by merely altering - ** the permutation (and S-Box) tables. Because this transformation alters - ** the table data WHILE it is using the table data, the tables are - ** thoroughly obfuscated by this process. - */ - unsigned long left = 0x00000000L; - unsigned long right = 0x00000000L; - unsigned long * p_en = &P_Encrypt[0]; // Encryption table. - unsigned long * p_de = &P_Decrypt[ROUNDS+1]; // Decryption table. - for (int p_index = 0; p_index < ROUNDS+2; p_index += 2) { - Sub_Key_Encrypt(left, right); - - *p_en++ = left; - *p_en++ = right; - - *p_de-- = left; - *p_de-- = right; - } - - /* - ** Perform a similar transmutation to the S-Box tables. Also notice that the - ** working 64 bit number is carried into this process from the previous - ** operation. - */ - for (int sbox_index = 0; sbox_index < 4; sbox_index++) { - for (int ss_index = 0; ss_index < UCHAR_MAX+1; ss_index += 2) { - Sub_Key_Encrypt(left, right); - bf_S[sbox_index][ss_index] = left; - bf_S[sbox_index][ss_index + 1] = right; - } - } - - IsKeyed = true; -} - - -/*********************************************************************************************** - * BlowfishEngine::Encrypt -- Encrypt an arbitrary block of data. * - * * - * Use this routine to encrypt an arbitrary block of data. The block must be an even * - * multiple of 8 bytes. Any bytes left over will not be encrypted. The 8 byte requirement * - * is necessary because the underlying algorithm processes blocks in 8 byte chunks. * - * Partial blocks are unrecoverable and useless. * - * * - * INPUT: plaintext-- Pointer to the data block to be encrypted. * - * * - * length -- The length of the data block. * - * * - * cyphertext- Pointer to the output buffer that will hold the encrypted data. * - * * - * OUTPUT: Returns with the actual number of bytes encrypted. * - * * - * WARNINGS: You must submit the key before calling this routine. This will only encrypt * - * the plaintext in 8 byte increments. Modulo bytes left over are not processed. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -int BlowfishEngine::Encrypt(void const * plaintext, int length, void * cyphertext) -{ - if (plaintext == 0 || length == 0) { - return(0); - } - if (cyphertext == 0) cyphertext = (void *)plaintext; - - if (IsKeyed) { - - /* - ** Validate parameters. - */ - int blocks = length / BYTES_PER_BLOCK; - - /* - ** Process the buffer in 64 bit chunks. - */ - for (int index = 0; index < blocks; index++) { - Process_Block(plaintext, cyphertext, P_Encrypt); - plaintext = ((char *)plaintext) + BYTES_PER_BLOCK; - cyphertext = ((char *)cyphertext) + BYTES_PER_BLOCK; - } - int encrypted = blocks * BYTES_PER_BLOCK; - - /* - ** Copy over any trailing left over appendix bytes. - */ - if (encrypted < length) { - memmove(cyphertext, plaintext, length - encrypted); - } - - return(encrypted); - } - - /* - ** Non-keyed processing merely copies the data. - */ - if (plaintext != cyphertext) { - memmove(cyphertext, plaintext, length); - } - return(length); -} - - -/*********************************************************************************************** - * BlowfishEngine::Decrypt -- Decrypt an arbitrary block of data. * - * * - * Use this routine to decrypt an arbitrary block of data. The block must be an even * - * multiple of 8 bytes. Any bytes left over will not be decrypted. The 8 byte requirement * - * is necessary because the underlying algorithm processes blocks in 8 byte chunks. * - * Partial blocks are unrecoverable and useless. * - * * - * INPUT: cyphertext- Pointer to the data block to be decrypted. * - * * - * length -- The length of the data block. * - * * - * plaintext-- Pointer to the output buffer that will hold the decrypted data. * - * * - * OUTPUT: Returns with the actual number of bytes decrypted. * - * * - * WARNINGS: You must submit the key before calling this routine. This will only decrypt * - * the cyphertext in 8 byte increments. Modulo bytes left over are not processed. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -int BlowfishEngine::Decrypt(void const * cyphertext, int length, void * plaintext) -{ - if (cyphertext == 0 || length == 0) { - return(0); - } - if (plaintext == 0) plaintext = (void *)cyphertext; - - if (IsKeyed) { - - /* - ** Validate parameters. - */ - int blocks = length / BYTES_PER_BLOCK; - - /* - ** Process the buffer in 64 bit chunks. - */ - for (int index = 0; index < blocks; index++) { - Process_Block(cyphertext, plaintext, P_Decrypt); - cyphertext = ((char *)cyphertext) + BYTES_PER_BLOCK; - plaintext = ((char *)plaintext) + BYTES_PER_BLOCK; - } - int encrypted = blocks * BYTES_PER_BLOCK; - - /* - ** Copy over any trailing left over appendix bytes. - */ - if (encrypted < length) { - memmove(plaintext, cyphertext, length - encrypted); - } - - return(encrypted); - } - - /* - ** Non-keyed processing merely copies the data. - */ - if (plaintext != cyphertext) { - memmove(plaintext, cyphertext, length); - } - return(length); -} - - -/*********************************************************************************************** - * BlowfishEngine::Process_Block -- Process a block of data using Blowfish algorithm. * - * * - * This is the main processing routine for encryption and decryption. The algorithm * - * consists of a 16 round Feistal network and uses mathematics from different algebraic * - * groups (strengthens against differential cryptanalysis). The large S-Boxes and the * - * rounds strengthen it against linear cryptanalysis. * - * * - * INPUT: plaintext -- Pointer to the source text (it actually might be a pointer to * - * the cyphertext if this is called as a decryption process). * - * * - * cyphertext -- Pointer to the output buffer that will hold the processed block. * - * * - * ptable -- Pointer to the permutation table. This algorithm will encrypt * - * and decrypt using the same S-Box tables. The encryption control * - * is handled by the permutation table. * - * * - * OUTPUT: none * - * * - * WARNINGS: The source and destination buffers must be 8 bytes long. * - * * - * HISTORY: * - * 04/19/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Process_Block(void const * plaintext, void * cyphertext, unsigned long const * ptable) -{ - /* - ** Input the left and right halves of the source block such that - ** the byte order is constant regardless of the endian - ** persuasion of the current processor. The blowfish algorithm is - ** biased toward "big endian" architecture and some optimizations - ** could be done for big endian processors in that case. - */ - unsigned char const * source = (unsigned char const *)plaintext; - Int left; - left.Char.C0 = *source++; - left.Char.C1 = *source++; - left.Char.C2 = *source++; - left.Char.C3 = *source++; - - Int right; - right.Char.C0 = *source++; - right.Char.C1 = *source++; - right.Char.C2 = *source++; - right.Char.C3 = *source; - - /* - ** Perform all Feistal rounds on the block. This is the encryption/decryption - ** process. Since there is an exchange that occurs after each round, two - ** rounds are combined in this loop to avoid unnecessary exchanging. - */ - for (int index = 0; index < ROUNDS/2; index++) { - left.Long ^= *ptable++; - right.Long ^= ((( bf_S[0][left.Char.C0] + bf_S[1][left.Char.C1]) ^ bf_S[2][left.Char.C2]) + bf_S[3][left.Char.C3]); - right.Long ^= *ptable++; - left.Long ^= ((( bf_S[0][right.Char.C0] + bf_S[1][right.Char.C1]) ^ bf_S[2][right.Char.C2]) + bf_S[3][right.Char.C3]); - } - - /* - ** The final two longs in the permutation table are processed into the block. - ** The left and right halves are still reversed as a side effect of the last - ** round. - */ - left.Long ^= *ptable++; - right.Long ^= *ptable; - - /* - ** The final block data is output in endian architecture - ** independent format. Notice that the blocks are output as - ** right first and left second. This is to counteract the final - ** superfluous exchange that occurs as a side effect of the - ** encryption rounds. - */ - unsigned char * out = (unsigned char *)cyphertext; - *out++ = right.Char.C0; - *out++ = right.Char.C1; - *out++ = right.Char.C2; - *out++ = right.Char.C3; - - *out++ = left.Char.C0; - *out++ = left.Char.C1; - *out++ = left.Char.C2; - *out = left.Char.C3; -} - - -/*********************************************************************************************** - * BlowfishEngine::Sub_Key_Encrypt -- Encrypts a block for use in S-Box processing. * - * * - * This is the same as the normal process block function but it doesn't have the endian * - * fixup logic. Since this routine is only called for S-Box table generation and it is * - * known that the S-Box initial data is already in local machine endian format, the * - * byte order fixups are not needed. This also has a tendency to speed up S-Box generation * - * as well. * - * * - * INPUT: left -- The left half of the data block. * - * * - * right -- The right half of the data block. * - * * - * OUTPUT: none, but the processed block is stored back into the left and right half * - * integers. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 04/19/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Sub_Key_Encrypt(unsigned long & left, unsigned long & right) -{ - Int l; - l.Long = left; - - Int r; - r.Long = right; - - for (int index = 0; index < ROUNDS; index += 2) { - l.Long ^= P_Encrypt[index]; - r.Long ^= ((( bf_S[0][l.Char.C0] + bf_S[1][l.Char.C1]) ^ bf_S[2][l.Char.C2]) + bf_S[3][l.Char.C3]); - r.Long ^= P_Encrypt[index+1]; - l.Long ^= ((( bf_S[0][r.Char.C0] + bf_S[1][r.Char.C1]) ^ bf_S[2][r.Char.C2]) + bf_S[3][r.Char.C3]); - } - left = r.Long ^ P_Encrypt[ROUNDS+1]; - right = l.Long ^ P_Encrypt[ROUNDS]; -} - - -/* -** These tables have the bytes stored in machine endian format. Because of this, -** a special block cypher routine is needed when the sub-keys are generated. -** This is kludgier than it otherwise should be. However, storing these -** integers in machine independent format would be even more painful. -*/ - -unsigned long const BlowfishEngine::P_Init[BlowfishEngine::ROUNDS+2] = { - 0x243F6A88U,0x85A308D3U,0x13198A2EU,0x03707344U,0xA4093822U,0x299F31D0U,0x082EFA98U,0xEC4E6C89U, - 0x452821E6U,0x38D01377U,0xBE5466CFU,0x34E90C6CU,0xC0AC29B7U,0xC97C50DDU,0x3F84D5B5U,0xB5470917U, - 0x9216D5D9U,0x8979FB1BU -}; - -unsigned long const BlowfishEngine::S_Init[4][UCHAR_MAX+1] = { - { - 0xD1310BA6U,0x98DFB5ACU,0x2FFD72DBU,0xD01ADFB7U,0xB8E1AFEDU,0x6A267E96U,0xBA7C9045U,0xF12C7F99U, - 0x24A19947U,0xB3916CF7U,0x0801F2E2U,0x858EFC16U,0x636920D8U,0x71574E69U,0xA458FEA3U,0xF4933D7EU, - 0x0D95748FU,0x728EB658U,0x718BCD58U,0x82154AEEU,0x7B54A41DU,0xC25A59B5U,0x9C30D539U,0x2AF26013U, - 0xC5D1B023U,0x286085F0U,0xCA417918U,0xB8DB38EFU,0x8E79DCB0U,0x603A180EU,0x6C9E0E8BU,0xB01E8A3EU, - 0xD71577C1U,0xBD314B27U,0x78AF2FDAU,0x55605C60U,0xE65525F3U,0xAA55AB94U,0x57489862U,0x63E81440U, - 0x55CA396AU,0x2AAB10B6U,0xB4CC5C34U,0x1141E8CEU,0xA15486AFU,0x7C72E993U,0xB3EE1411U,0x636FBC2AU, - 0x2BA9C55DU,0x741831F6U,0xCE5C3E16U,0x9B87931EU,0xAFD6BA33U,0x6C24CF5CU,0x7A325381U,0x28958677U, - 0x3B8F4898U,0x6B4BB9AFU,0xC4BFE81BU,0x66282193U,0x61D809CCU,0xFB21A991U,0x487CAC60U,0x5DEC8032U, - 0xEF845D5DU,0xE98575B1U,0xDC262302U,0xEB651B88U,0x23893E81U,0xD396ACC5U,0x0F6D6FF3U,0x83F44239U, - 0x2E0B4482U,0xA4842004U,0x69C8F04AU,0x9E1F9B5EU,0x21C66842U,0xF6E96C9AU,0x670C9C61U,0xABD388F0U, - 0x6A51A0D2U,0xD8542F68U,0x960FA728U,0xAB5133A3U,0x6EEF0B6CU,0x137A3BE4U,0xBA3BF050U,0x7EFB2A98U, - 0xA1F1651DU,0x39AF0176U,0x66CA593EU,0x82430E88U,0x8CEE8619U,0x456F9FB4U,0x7D84A5C3U,0x3B8B5EBEU, - 0xE06F75D8U,0x85C12073U,0x401A449FU,0x56C16AA6U,0x4ED3AA62U,0x363F7706U,0x1BFEDF72U,0x429B023DU, - 0x37D0D724U,0xD00A1248U,0xDB0FEAD3U,0x49F1C09BU,0x075372C9U,0x80991B7BU,0x25D479D8U,0xF6E8DEF7U, - 0xE3FE501AU,0xB6794C3BU,0x976CE0BDU,0x04C006BAU,0xC1A94FB6U,0x409F60C4U,0x5E5C9EC2U,0x196A2463U, - 0x68FB6FAFU,0x3E6C53B5U,0x1339B2EBU,0x3B52EC6FU,0x6DFC511FU,0x9B30952CU,0xCC814544U,0xAF5EBD09U, - 0xBEE3D004U,0xDE334AFDU,0x660F2807U,0x192E4BB3U,0xC0CBA857U,0x45C8740FU,0xD20B5F39U,0xB9D3FBDBU, - 0x5579C0BDU,0x1A60320AU,0xD6A100C6U,0x402C7279U,0x679F25FEU,0xFB1FA3CCU,0x8EA5E9F8U,0xDB3222F8U, - 0x3C7516DFU,0xFD616B15U,0x2F501EC8U,0xAD0552ABU,0x323DB5FAU,0xFD238760U,0x53317B48U,0x3E00DF82U, - 0x9E5C57BBU,0xCA6F8CA0U,0x1A87562EU,0xDF1769DBU,0xD542A8F6U,0x287EFFC3U,0xAC6732C6U,0x8C4F5573U, - 0x695B27B0U,0xBBCA58C8U,0xE1FFA35DU,0xB8F011A0U,0x10FA3D98U,0xFD2183B8U,0x4AFCB56CU,0x2DD1D35BU, - 0x9A53E479U,0xB6F84565U,0xD28E49BCU,0x4BFB9790U,0xE1DDF2DAU,0xA4CB7E33U,0x62FB1341U,0xCEE4C6E8U, - 0xEF20CADAU,0x36774C01U,0xD07E9EFEU,0x2BF11FB4U,0x95DBDA4DU,0xAE909198U,0xEAAD8E71U,0x6B93D5A0U, - 0xD08ED1D0U,0xAFC725E0U,0x8E3C5B2FU,0x8E7594B7U,0x8FF6E2FBU,0xF2122B64U,0x8888B812U,0x900DF01CU, - 0x4FAD5EA0U,0x688FC31CU,0xD1CFF191U,0xB3A8C1ADU,0x2F2F2218U,0xBE0E1777U,0xEA752DFEU,0x8B021FA1U, - 0xE5A0CC0FU,0xB56F74E8U,0x18ACF3D6U,0xCE89E299U,0xB4A84FE0U,0xFD13E0B7U,0x7CC43B81U,0xD2ADA8D9U, - 0x165FA266U,0x80957705U,0x93CC7314U,0x211A1477U,0xE6AD2065U,0x77B5FA86U,0xC75442F5U,0xFB9D35CFU, - 0xEBCDAF0CU,0x7B3E89A0U,0xD6411BD3U,0xAE1E7E49U,0x00250E2DU,0x2071B35EU,0x226800BBU,0x57B8E0AFU, - 0x2464369BU,0xF009B91EU,0x5563911DU,0x59DFA6AAU,0x78C14389U,0xD95A537FU,0x207D5BA2U,0x02E5B9C5U, - 0x83260376U,0x6295CFA9U,0x11C81968U,0x4E734A41U,0xB3472DCAU,0x7B14A94AU,0x1B510052U,0x9A532915U, - 0xD60F573FU,0xBC9BC6E4U,0x2B60A476U,0x81E67400U,0x08BA6FB5U,0x571BE91FU,0xF296EC6BU,0x2A0DD915U, - 0xB6636521U,0xE7B9F9B6U,0xFF34052EU,0xC5855664U,0x53B02D5DU,0xA99F8FA1U,0x08BA4799U,0x6E85076AU, - },{ - 0x4B7A70E9U,0xB5B32944U,0xDB75092EU,0xC4192623U,0xAD6EA6B0U,0x49A7DF7DU,0x9CEE60B8U,0x8FEDB266U, - 0xECAA8C71U,0x699A17FFU,0x5664526CU,0xC2B19EE1U,0x193602A5U,0x75094C29U,0xA0591340U,0xE4183A3EU, - 0x3F54989AU,0x5B429D65U,0x6B8FE4D6U,0x99F73FD6U,0xA1D29C07U,0xEFE830F5U,0x4D2D38E6U,0xF0255DC1U, - 0x4CDD2086U,0x8470EB26U,0x6382E9C6U,0x021ECC5EU,0x09686B3FU,0x3EBAEFC9U,0x3C971814U,0x6B6A70A1U, - 0x687F3584U,0x52A0E286U,0xB79C5305U,0xAA500737U,0x3E07841CU,0x7FDEAE5CU,0x8E7D44ECU,0x5716F2B8U, - 0xB03ADA37U,0xF0500C0DU,0xF01C1F04U,0x0200B3FFU,0xAE0CF51AU,0x3CB574B2U,0x25837A58U,0xDC0921BDU, - 0xD19113F9U,0x7CA92FF6U,0x94324773U,0x22F54701U,0x3AE5E581U,0x37C2DADCU,0xC8B57634U,0x9AF3DDA7U, - 0xA9446146U,0x0FD0030EU,0xECC8C73EU,0xA4751E41U,0xE238CD99U,0x3BEA0E2FU,0x3280BBA1U,0x183EB331U, - 0x4E548B38U,0x4F6DB908U,0x6F420D03U,0xF60A04BFU,0x2CB81290U,0x24977C79U,0x5679B072U,0xBCAF89AFU, - 0xDE9A771FU,0xD9930810U,0xB38BAE12U,0xDCCF3F2EU,0x5512721FU,0x2E6B7124U,0x501ADDE6U,0x9F84CD87U, - 0x7A584718U,0x7408DA17U,0xBC9F9ABCU,0xE94B7D8CU,0xEC7AEC3AU,0xDB851DFAU,0x63094366U,0xC464C3D2U, - 0xEF1C1847U,0x3215D908U,0xDD433B37U,0x24C2BA16U,0x12A14D43U,0x2A65C451U,0x50940002U,0x133AE4DDU, - 0x71DFF89EU,0x10314E55U,0x81AC77D6U,0x5F11199BU,0x043556F1U,0xD7A3C76BU,0x3C11183BU,0x5924A509U, - 0xF28FE6EDU,0x97F1FBFAU,0x9EBABF2CU,0x1E153C6EU,0x86E34570U,0xEAE96FB1U,0x860E5E0AU,0x5A3E2AB3U, - 0x771FE71CU,0x4E3D06FAU,0x2965DCB9U,0x99E71D0FU,0x803E89D6U,0x5266C825U,0x2E4CC978U,0x9C10B36AU, - 0xC6150EBAU,0x94E2EA78U,0xA5FC3C53U,0x1E0A2DF4U,0xF2F74EA7U,0x361D2B3DU,0x1939260FU,0x19C27960U, - 0x5223A708U,0xF71312B6U,0xEBADFE6EU,0xEAC31F66U,0xE3BC4595U,0xA67BC883U,0xB17F37D1U,0x018CFF28U, - 0xC332DDEFU,0xBE6C5AA5U,0x65582185U,0x68AB9802U,0xEECEA50FU,0xDB2F953BU,0x2AEF7DADU,0x5B6E2F84U, - 0x1521B628U,0x29076170U,0xECDD4775U,0x619F1510U,0x13CCA830U,0xEB61BD96U,0x0334FE1EU,0xAA0363CFU, - 0xB5735C90U,0x4C70A239U,0xD59E9E0BU,0xCBAADE14U,0xEECC86BCU,0x60622CA7U,0x9CAB5CABU,0xB2F3846EU, - 0x648B1EAFU,0x19BDF0CAU,0xA02369B9U,0x655ABB50U,0x40685A32U,0x3C2AB4B3U,0x319EE9D5U,0xC021B8F7U, - 0x9B540B19U,0x875FA099U,0x95F7997EU,0x623D7DA8U,0xF837889AU,0x97E32D77U,0x11ED935FU,0x16681281U, - 0x0E358829U,0xC7E61FD6U,0x96DEDFA1U,0x7858BA99U,0x57F584A5U,0x1B227263U,0x9B83C3FFU,0x1AC24696U, - 0xCDB30AEBU,0x532E3054U,0x8FD948E4U,0x6DBC3128U,0x58EBF2EFU,0x34C6FFEAU,0xFE28ED61U,0xEE7C3C73U, - 0x5D4A14D9U,0xE864B7E3U,0x42105D14U,0x203E13E0U,0x45EEE2B6U,0xA3AAABEAU,0xDB6C4F15U,0xFACB4FD0U, - 0xC742F442U,0xEF6ABBB5U,0x654F3B1DU,0x41CD2105U,0xD81E799EU,0x86854DC7U,0xE44B476AU,0x3D816250U, - 0xCF62A1F2U,0x5B8D2646U,0xFC8883A0U,0xC1C7B6A3U,0x7F1524C3U,0x69CB7492U,0x47848A0BU,0x5692B285U, - 0x095BBF00U,0xAD19489DU,0x1462B174U,0x23820E00U,0x58428D2AU,0x0C55F5EAU,0x1DADF43EU,0x233F7061U, - 0x3372F092U,0x8D937E41U,0xD65FECF1U,0x6C223BDBU,0x7CDE3759U,0xCBEE7460U,0x4085F2A7U,0xCE77326EU, - 0xA6078084U,0x19F8509EU,0xE8EFD855U,0x61D99735U,0xA969A7AAU,0xC50C06C2U,0x5A04ABFCU,0x800BCADCU, - 0x9E447A2EU,0xC3453484U,0xFDD56705U,0x0E1E9EC9U,0xDB73DBD3U,0x105588CDU,0x675FDA79U,0xE3674340U, - 0xC5C43465U,0x713E38D8U,0x3D28F89EU,0xF16DFF20U,0x153E21E7U,0x8FB03D4AU,0xE6E39F2BU,0xDB83ADF7U, - },{ - 0xE93D5A68U,0x948140F7U,0xF64C261CU,0x94692934U,0x411520F7U,0x7602D4F7U,0xBCF46B2EU,0xD4A20068U, - 0xD4082471U,0x3320F46AU,0x43B7D4B7U,0x500061AFU,0x1E39F62EU,0x97244546U,0x14214F74U,0xBF8B8840U, - 0x4D95FC1DU,0x96B591AFU,0x70F4DDD3U,0x66A02F45U,0xBFBC09ECU,0x03BD9785U,0x7FAC6DD0U,0x31CB8504U, - 0x96EB27B3U,0x55FD3941U,0xDA2547E6U,0xABCA0A9AU,0x28507825U,0x530429F4U,0x0A2C86DAU,0xE9B66DFBU, - 0x68DC1462U,0xD7486900U,0x680EC0A4U,0x27A18DEEU,0x4F3FFEA2U,0xE887AD8CU,0xB58CE006U,0x7AF4D6B6U, - 0xAACE1E7CU,0xD3375FECU,0xCE78A399U,0x406B2A42U,0x20FE9E35U,0xD9F385B9U,0xEE39D7ABU,0x3B124E8BU, - 0x1DC9FAF7U,0x4B6D1856U,0x26A36631U,0xEAE397B2U,0x3A6EFA74U,0xDD5B4332U,0x6841E7F7U,0xCA7820FBU, - 0xFB0AF54EU,0xD8FEB397U,0x454056ACU,0xBA489527U,0x55533A3AU,0x20838D87U,0xFE6BA9B7U,0xD096954BU, - 0x55A867BCU,0xA1159A58U,0xCCA92963U,0x99E1DB33U,0xA62A4A56U,0x3F3125F9U,0x5EF47E1CU,0x9029317CU, - 0xFDF8E802U,0x04272F70U,0x80BB155CU,0x05282CE3U,0x95C11548U,0xE4C66D22U,0x48C1133FU,0xC70F86DCU, - 0x07F9C9EEU,0x41041F0FU,0x404779A4U,0x5D886E17U,0x325F51EBU,0xD59BC0D1U,0xF2BCC18FU,0x41113564U, - 0x257B7834U,0x602A9C60U,0xDFF8E8A3U,0x1F636C1BU,0x0E12B4C2U,0x02E1329EU,0xAF664FD1U,0xCAD18115U, - 0x6B2395E0U,0x333E92E1U,0x3B240B62U,0xEEBEB922U,0x85B2A20EU,0xE6BA0D99U,0xDE720C8CU,0x2DA2F728U, - 0xD0127845U,0x95B794FDU,0x647D0862U,0xE7CCF5F0U,0x5449A36FU,0x877D48FAU,0xC39DFD27U,0xF33E8D1EU, - 0x0A476341U,0x992EFF74U,0x3A6F6EABU,0xF4F8FD37U,0xA812DC60U,0xA1EBDDF8U,0x991BE14CU,0xDB6E6B0DU, - 0xC67B5510U,0x6D672C37U,0x2765D43BU,0xDCD0E804U,0xF1290DC7U,0xCC00FFA3U,0xB5390F92U,0x690FED0BU, - 0x667B9FFBU,0xCEDB7D9CU,0xA091CF0BU,0xD9155EA3U,0xBB132F88U,0x515BAD24U,0x7B9479BFU,0x763BD6EBU, - 0x37392EB3U,0xCC115979U,0x8026E297U,0xF42E312DU,0x6842ADA7U,0xC66A2B3BU,0x12754CCCU,0x782EF11CU, - 0x6A124237U,0xB79251E7U,0x06A1BBE6U,0x4BFB6350U,0x1A6B1018U,0x11CAEDFAU,0x3D25BDD8U,0xE2E1C3C9U, - 0x44421659U,0x0A121386U,0xD90CEC6EU,0xD5ABEA2AU,0x64AF674EU,0xDA86A85FU,0xBEBFE988U,0x64E4C3FEU, - 0x9DBC8057U,0xF0F7C086U,0x60787BF8U,0x6003604DU,0xD1FD8346U,0xF6381FB0U,0x7745AE04U,0xD736FCCCU, - 0x83426B33U,0xF01EAB71U,0xB0804187U,0x3C005E5FU,0x77A057BEU,0xBDE8AE24U,0x55464299U,0xBF582E61U, - 0x4E58F48FU,0xF2DDFDA2U,0xF474EF38U,0x8789BDC2U,0x5366F9C3U,0xC8B38E74U,0xB475F255U,0x46FCD9B9U, - 0x7AEB2661U,0x8B1DDF84U,0x846A0E79U,0x915F95E2U,0x466E598EU,0x20B45770U,0x8CD55591U,0xC902DE4CU, - 0xB90BACE1U,0xBB8205D0U,0x11A86248U,0x7574A99EU,0xB77F19B6U,0xE0A9DC09U,0x662D09A1U,0xC4324633U, - 0xE85A1F02U,0x09F0BE8CU,0x4A99A025U,0x1D6EFE10U,0x1AB93D1DU,0x0BA5A4DFU,0xA186F20FU,0x2868F169U, - 0xDCB7DA83U,0x573906FEU,0xA1E2CE9BU,0x4FCD7F52U,0x50115E01U,0xA70683FAU,0xA002B5C4U,0x0DE6D027U, - 0x9AF88C27U,0x773F8641U,0xC3604C06U,0x61A806B5U,0xF0177A28U,0xC0F586E0U,0x006058AAU,0x30DC7D62U, - 0x11E69ED7U,0x2338EA63U,0x53C2DD94U,0xC2C21634U,0xBBCBEE56U,0x90BCB6DEU,0xEBFC7DA1U,0xCE591D76U, - 0x6F05E409U,0x4B7C0188U,0x39720A3DU,0x7C927C24U,0x86E3725FU,0x724D9DB9U,0x1AC15BB4U,0xD39EB8FCU, - 0xED545578U,0x08FCA5B5U,0xD83D7CD3U,0x4DAD0FC4U,0x1E50EF5EU,0xB161E6F8U,0xA28514D9U,0x6C51133CU, - 0x6FD5C7E7U,0x56E14EC4U,0x362ABFCEU,0xDDC6C837U,0xD79A3234U,0x92638212U,0x670EFA8EU,0x406000E0U, - },{ - 0x3A39CE37U,0xD3FAF5CFU,0xABC27737U,0x5AC52D1BU,0x5CB0679EU,0x4FA33742U,0xD3822740U,0x99BC9BBEU, - 0xD5118E9DU,0xBF0F7315U,0xD62D1C7EU,0xC700C47BU,0xB78C1B6BU,0x21A19045U,0xB26EB1BEU,0x6A366EB4U, - 0x5748AB2FU,0xBC946E79U,0xC6A376D2U,0x6549C2C8U,0x530FF8EEU,0x468DDE7DU,0xD5730A1DU,0x4CD04DC6U, - 0x2939BBDBU,0xA9BA4650U,0xAC9526E8U,0xBE5EE304U,0xA1FAD5F0U,0x6A2D519AU,0x63EF8CE2U,0x9A86EE22U, - 0xC089C2B8U,0x43242EF6U,0xA51E03AAU,0x9CF2D0A4U,0x83C061BAU,0x9BE96A4DU,0x8FE51550U,0xBA645BD6U, - 0x2826A2F9U,0xA73A3AE1U,0x4BA99586U,0xEF5562E9U,0xC72FEFD3U,0xF752F7DAU,0x3F046F69U,0x77FA0A59U, - 0x80E4A915U,0x87B08601U,0x9B09E6ADU,0x3B3EE593U,0xE990FD5AU,0x9E34D797U,0x2CF0B7D9U,0x022B8B51U, - 0x96D5AC3AU,0x017DA67DU,0xD1CF3ED6U,0x7C7D2D28U,0x1F9F25CFU,0xADF2B89BU,0x5AD6B472U,0x5A88F54CU, - 0xE029AC71U,0xE019A5E6U,0x47B0ACFDU,0xED93FA9BU,0xE8D3C48DU,0x283B57CCU,0xF8D56629U,0x79132E28U, - 0x785F0191U,0xED756055U,0xF7960E44U,0xE3D35E8CU,0x15056DD4U,0x88F46DBAU,0x03A16125U,0x0564F0BDU, - 0xC3EB9E15U,0x3C9057A2U,0x97271AECU,0xA93A072AU,0x1B3F6D9BU,0x1E6321F5U,0xF59C66FBU,0x26DCF319U, - 0x7533D928U,0xB155FDF5U,0x03563482U,0x8ABA3CBBU,0x28517711U,0xC20AD9F8U,0xABCC5167U,0xCCAD925FU, - 0x4DE81751U,0x3830DC8EU,0x379D5862U,0x9320F991U,0xEA7A90C2U,0xFB3E7BCEU,0x5121CE64U,0x774FBE32U, - 0xA8B6E37EU,0xC3293D46U,0x48DE5369U,0x6413E680U,0xA2AE0810U,0xDD6DB224U,0x69852DFDU,0x09072166U, - 0xB39A460AU,0x6445C0DDU,0x586CDECFU,0x1C20C8AEU,0x5BBEF7DDU,0x1B588D40U,0xCCD2017FU,0x6BB4E3BBU, - 0xDDA26A7EU,0x3A59FF45U,0x3E350A44U,0xBCB4CDD5U,0x72EACEA8U,0xFA6484BBU,0x8D6612AEU,0xBF3C6F47U, - 0xD29BE463U,0x542F5D9EU,0xAEC2771BU,0xF64E6370U,0x740E0D8DU,0xE75B1357U,0xF8721671U,0xAF537D5DU, - 0x4040CB08U,0x4EB4E2CCU,0x34D2466AU,0x0115AF84U,0xE1B00428U,0x95983A1DU,0x06B89FB4U,0xCE6EA048U, - 0x6F3F3B82U,0x3520AB82U,0x011A1D4BU,0x277227F8U,0x611560B1U,0xE7933FDCU,0xBB3A792BU,0x344525BDU, - 0xA08839E1U,0x51CE794BU,0x2F32C9B7U,0xA01FBAC9U,0xE01CC87EU,0xBCC7D1F6U,0xCF0111C3U,0xA1E8AAC7U, - 0x1A908749U,0xD44FBD9AU,0xD0DADECBU,0xD50ADA38U,0x0339C32AU,0xC6913667U,0x8DF9317CU,0xE0B12B4FU, - 0xF79E59B7U,0x43F5BB3AU,0xF2D519FFU,0x27D9459CU,0xBF97222CU,0x15E6FC2AU,0x0F91FC71U,0x9B941525U, - 0xFAE59361U,0xCEB69CEBU,0xC2A86459U,0x12BAA8D1U,0xB6C1075EU,0xE3056A0CU,0x10D25065U,0xCB03A442U, - 0xE0EC6E0EU,0x1698DB3BU,0x4C98A0BEU,0x3278E964U,0x9F1F9532U,0xE0D392DFU,0xD3A0342BU,0x8971F21EU, - 0x1B0A7441U,0x4BA3348CU,0xC5BE7120U,0xC37632D8U,0xDF359F8DU,0x9B992F2EU,0xE60B6F47U,0x0FE3F11DU, - 0xE54CDA54U,0x1EDAD891U,0xCE6279CFU,0xCD3E7E6FU,0x1618B166U,0xFD2C1D05U,0x848FD2C5U,0xF6FB2299U, - 0xF523F357U,0xA6327623U,0x93A83531U,0x56CCCD02U,0xACF08162U,0x5A75EBB5U,0x6E163697U,0x88D273CCU, - 0xDE966292U,0x81B949D0U,0x4C50901BU,0x71C65614U,0xE6C6C7BDU,0x327A140AU,0x45E1D006U,0xC3F27B9AU, - 0xC9AA53FDU,0x62A80F00U,0xBB25BFE2U,0x35BDD2F6U,0x71126905U,0xB2040222U,0xB6CBCF7CU,0xCD769C2BU, - 0x53113EC0U,0x1640E3D3U,0x38ABBD60U,0x2547ADF0U,0xBA38209CU,0xF746CE76U,0x77AFA1C5U,0x20756060U, - 0x85CBFE4EU,0x8AE88DD8U,0x7AAAF9B0U,0x4CF9AA7EU,0x1948C25CU,0x02FB8A8CU,0x01C36AE4U,0xD6EBE1F9U, - 0x90D4F869U,0xA65CDEA0U,0x3F09252DU,0xC208E69FU,0xB74E6132U,0xCE77E25BU,0x578FDFE3U,0x3AC372E6U - } -}; - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.h deleted file mode 100644 index 388bd994214..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowfish.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLOWFISH.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLOWFISH_H -#define BLOWFISH_H - -#include - - -/* -** The "bool" integral type was defined by the C++ committee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - - -/* -** This engine will process data blocks by encryption and decryption. -** The "Blowfish" algorithm is in the public domain. It uses -** a Feistal network (similar to IDEA). It has no known -** weaknesses, but is still relatively new. Blowfish is particularly strong -** against brute force attacks. It is also quite strong against linear and -** differential cryptanalysis. Unlike public key encription, it is very -** fast at encryption, as far as cryptography goes. Its weakness is that -** it takes a relatively long time to set up with a new key (1/100th of -** a second on a P6-200). The time to set up a key is equivalent to -** encrypting 4240 bytes. -*/ -class BlowfishEngine { - public: - BlowfishEngine(void) : IsKeyed(false) {} - ~BlowfishEngine(void); - - void Submit_Key(void const * key, int length); - - int Encrypt(void const * plaintext, int length, void * cyphertext); - int Decrypt(void const * cyphertext, int length, void * plaintext); - - /* - ** This is the maximum key length supported. - */ - enum {MAX_KEY_LENGTH=56}; - - private: - bool IsKeyed; - - void Sub_Key_Encrypt(unsigned long & left, unsigned long & right); - - void Process_Block(void const * plaintext, void * cyphertext, unsigned long const * ptable); - void Initialize_Tables(void); - - enum { - ROUNDS = 16, // Feistal round count (16 is standard). - BYTES_PER_BLOCK=8 // The number of bytes in each cypher block (don't change). - }; - - /* - ** Initialization data for sub keys. The initial values are constant and - ** filled with a number generated from pi. Thus they are not random but - ** they don't hold a weak pattern either. - */ - static unsigned long const P_Init[ROUNDS+2]; - static unsigned long const S_Init[4][UCHAR_MAX+1]; - - /* - ** Permutation tables for encryption and decryption. - */ - unsigned long P_Encrypt[ROUNDS+2]; - unsigned long P_Decrypt[ROUNDS+2]; - - /* - ** S-Box tables (four). - */ - unsigned long bf_S[4][UCHAR_MAX+1]; -}; - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h deleted file mode 100644 index dca11d1b2d6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/blowpipe.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLOWPIPE_H -#define BLOWPIPE_H - -#include "PIPE.H" -#include "blowfish.h" - -/* -** Performs Blowfish encryption/decryption on the data stream that is piped -** through this class. -*/ -class BlowPipe : public Pipe -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - BlowPipe(CryptControl control) : BF(NULL), Counter(0), Control(control) {} - virtual ~BlowPipe(void) {delete BF;BF = NULL;} - virtual int Flush(void); - - virtual int Put(void const * source, int slen); - - // Submit key for blowfish engine. - void Key(void const * key, int length); - - protected: - /* - ** The Blowfish engine used for encryption/decryption. If this pointer is - ** NULL, then this indicates that the blowfish engine is not active and no - ** key has been submitted. All data would pass through this pipe unchanged - ** in that case. - */ - BlowfishEngine * BF; - - private: - char Buffer[8]; - int Counter; - CryptControl Control; - - BlowPipe(BlowPipe & rvalue); - BlowPipe & operator = (BlowPipe const & pipe); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h deleted file mode 100644 index 78601217461..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLWSTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLWSTRAW_H -#define BLWSTRAW_H - -#include "STRAW.H" -#include "blowfish.h" - - -/* -** Performs Blowfish encryption/decryption to the data that is drawn through this straw. The -** process is controlled by the key which must be submitted to the class before any data -** manipulation will occur. The Blowfish algorithm is symmetric, thus the same key is used -** for encryption as is for decryption. -*/ -class BlowStraw : public Straw -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - BlowStraw(CryptControl control) : BF(NULL), Counter(0), Control(control) {} - virtual ~BlowStraw(void) {delete BF;BF = NULL;} - - virtual int Get(void * source, int slen); - - // Submit key for blowfish engine. - void Key(void const * key, int length); - - protected: - /* - ** The Blowfish engine used for encryption/decryption. If this pointer is - ** NULL, then this indicates that the blowfish engine is not active and no - ** key has been submitted. All data would pass through this straw unchanged - ** in that case. - */ - BlowfishEngine * BF; - - private: - char Buffer[8]; - int Counter; - CryptControl Control; - - BlowStraw(BlowStraw & rvalue); - BlowStraw & operator = (BlowStraw const & straw); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/bool.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/bool.h deleted file mode 100644 index ff6e3e41674..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/bool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/bool.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/23/99 1:46p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(TRUE_FALSE_DEFINED) && !defined(__BORLANDC__) && (_MSC_VER < 1100) && !defined(__WATCOMC__) -#define TRUE_FALSE_DEFINED - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#ifdef _MSC_VER - -#include "yvals.h" -#define bool unsigned - -#elif defined(_UNIX) - -/////#define bool unsigned - -#else - -enum {false=0,true=1}; -typedef int bool; - -#endif - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/borlandc.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/borlandc.h deleted file mode 100644 index efde2536699..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/borlandc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/borlandc.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:57a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(BORLANDC_H) && defined(__BORLANDC__) -#define BORLANDC_H - -/* -** Funny, but there are no required overrides to make Borland C match C++ standards. This -** is because Borland C more closely matches the C++ standard than the other compilers. -*/ - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/bsurface.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/bsurface.h deleted file mode 100644 index 86507f42fc2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/bsurface.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/bsurface.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef BSURFACE_H -#define BSURFACE_H - -#include "BUFF.H" -#include "xsurface.h" - -/* -** This class handles a simple surface that exists in system RAM. -*/ -class BSurface : public XSurface -{ - public: - BSurface(int width, int height, int bbp, void * buffer=NULL) : - XSurface(width, height), - BBP(bbp), - Buff(buffer, width * height * bbp) - { - } - - /* - ** Gets and frees a direct pointer to the buffer. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const - { - XSurface::Lock(); - return(((char*)Buff.Get_Buffer()) + point.Y * Stride() + point.X * Bytes_Per_Pixel()); - } - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const {return(BBP);} - virtual int Stride(void) const {return(Get_Width() * BBP);} - - protected: - - /* - ** Recorded bytes per pixel (used when determining pixel positions). - */ - int BBP; - - /* - ** Tracks the buffer that this surface represents. - */ - Buffer Buff; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/convert.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/convert.cpp deleted file mode 100644 index f34c706973a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/convert.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/Convert.cpp $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 2/19/99 11:51a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blitblit.h" -#include "Convert.h" -#include "dsurface.h" -#include "hsv.h" -#include "rlerle.h" - - -ConvertClass::ConvertClass(PaletteClass const & artpalette, PaletteClass const & screenpalette, Surface const & surface) : - BBP(surface.Bytes_Per_Pixel()), - PlainBlitter(NULL), - TransBlitter(NULL), - ShadowBlitter(NULL), - RemapBlitter(NULL), - Translucent1Blitter(NULL), - Translucent2Blitter(NULL), - Translucent3Blitter(NULL), - RLETransBlitter(NULL), - RLEShadowBlitter(NULL), - RLERemapBlitter(NULL), - RLETranslucent1Blitter(NULL), - RLETranslucent2Blitter(NULL), - RLETranslucent3Blitter(NULL), - Translator(NULL), - ShadowTable(NULL), - RemapTable(NULL) -{ - /* - ** The draw data initialization is greatly dependant upon the pixel format - ** of the display surface. Check the pixel format and set the values accordingly. - */ - if (BBP == 1) { - - /* - ** Build the shadow table by creating a slightly darker version of - ** the color and then finding the closest match to it. - */ - ShadowTable = W3DNEWARRAY unsigned char [256]; - ShadowTable[0] = 0; - for (int shadow = 1; shadow < 256; shadow++) { - HSVClass hsv = artpalette[shadow]; - hsv.Set_Value((unsigned char)(hsv.Get_Value() / 2)); - ShadowTable[shadow] = (unsigned char)artpalette.Closest_Color(hsv); - } - - /* - ** The translator table is created by finding the closest color - ** in the display palette from each color in the source art - ** palette. - */ - unsigned char * trans = W3DNEWARRAY unsigned char [256]; - trans[0] = 0; - for (int index = 1; index < 256; index++) { - trans[index] = (unsigned char)screenpalette.Closest_Color(artpalette[index]); - } - Translator = (void *)trans; - - /* - ** Construct all the blitter objects necessary to support the functionality - ** required for the draw permutations. - */ - PlainBlitter = W3DNEW BlitPlainXlat((unsigned char const *)Translator); - TransBlitter = W3DNEW BlitTransXlat((unsigned char const *)Translator); - RemapBlitter = W3DNEW BlitTransZRemapXlat(&RemapTable, (unsigned char const *)Translator); - ShadowBlitter = W3DNEW BlitTransRemapDest(ShadowTable); - Translucent1Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - Translucent2Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - Translucent3Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - - /* - ** Create the RLE aware blitter objects. - */ - RLETransBlitter = W3DNEW RLEBlitTransXlat((unsigned char const *)Translator); - RLERemapBlitter = W3DNEW RLEBlitTransZRemapXlat(&RemapTable, (unsigned char const *)Translator); - RLEShadowBlitter = W3DNEW RLEBlitTransRemapDest(ShadowTable); - RLETranslucent1Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - RLETranslucent2Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - RLETranslucent3Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - - } else { - - /* - ** The hicolor translation table is constructed according to the pixel - ** format of the display and the source art palette. - */ - //assert(surface.Is_Direct_Draw()); - Translator = W3DNEWARRAY unsigned short [256]; - ((DSurface &)surface).Build_Remap_Table((unsigned short *)Translator, artpalette); - - /* - ** Fetch the pixel mask values to be used for the various algorithmic - ** pixel processing performed for hicolor displays. - */ - int maskhalf = ((DSurface &)surface).Get_Halfbright_Mask(); - int maskquarter = ((DSurface &)surface).Get_Quarterbright_Mask(); - - /* - ** Construct all the blitter objects necessary to support the functionality - ** required for the draw permutations. - */ - PlainBlitter = W3DNEW BlitPlainXlat((unsigned short const *)Translator); - TransBlitter = W3DNEW BlitTransXlat((unsigned short const *)Translator); - RemapBlitter = W3DNEW BlitTransZRemapXlat(&RemapTable, (unsigned short const *)Translator); - ShadowBlitter = W3DNEW BlitTransDarken((unsigned short)maskhalf); - Translucent1Blitter = W3DNEW BlitTransLucent75((unsigned short const *)Translator, (unsigned short)maskquarter); - Translucent2Blitter = W3DNEW BlitTransLucent50((unsigned short const *)Translator, (unsigned short)maskhalf); - Translucent3Blitter = W3DNEW BlitTransLucent25((unsigned short const *)Translator, (unsigned short)maskquarter); - - /* - ** Create the RLE aware blitter objects. - */ - RLETransBlitter = W3DNEW RLEBlitTransXlat((unsigned short const *)Translator); - RLERemapBlitter = W3DNEW RLEBlitTransZRemapXlat(&RemapTable, (unsigned short const *)Translator); - RLEShadowBlitter = W3DNEW RLEBlitTransDarken((unsigned short)maskhalf); - RLETranslucent1Blitter = W3DNEW RLEBlitTransLucent75((unsigned short const *)Translator, (unsigned short)maskquarter); - RLETranslucent2Blitter = W3DNEW RLEBlitTransLucent50((unsigned short const *)Translator, (unsigned short)maskhalf); - RLETranslucent3Blitter = W3DNEW RLEBlitTransLucent25((unsigned short const *)Translator, (unsigned short)maskquarter); - } -} - - -ConvertClass::~ConvertClass(void) -{ - delete PlainBlitter; - PlainBlitter = NULL; - - delete TransBlitter; - TransBlitter = NULL; - - delete ShadowBlitter; - ShadowBlitter = NULL; - - delete RemapBlitter; - RemapBlitter = NULL; - - delete Translucent1Blitter; - Translucent1Blitter = NULL; - - delete Translucent2Blitter; - Translucent2Blitter = NULL; - - delete Translucent3Blitter; - Translucent3Blitter = NULL; - - delete [] Translator; - Translator = NULL; - - delete [] ShadowTable; - ShadowTable = NULL; - - delete RLETransBlitter; - RLETransBlitter = NULL; - - delete RLEShadowBlitter; - RLEShadowBlitter = NULL; - - delete RLERemapBlitter; - RLERemapBlitter = NULL; - - delete RLETranslucent1Blitter; - RLETranslucent1Blitter = NULL; - - delete RLETranslucent2Blitter; - RLETranslucent2Blitter = NULL; - - delete RLETranslucent3Blitter; - RLETranslucent3Blitter = NULL; -} - - -Blitter const * ConvertClass::Blitter_From_Flags(ShapeFlags_Type flags) const -{ - if (flags & SHAPE_REMAP) return(RemapBlitter); - - /* - ** Quick check to see if this is a translucent operation. If so, then no - ** further examination of the flags is necessary. - */ - switch (flags & (SHAPE_TRANSLUCENT25 | SHAPE_TRANSLUCENT50 | SHAPE_TRANSLUCENT75)) { - case SHAPE_TRANSLUCENT25: - return(Translucent3Blitter); - - case SHAPE_TRANSLUCENT50: - return(Translucent2Blitter); - - case SHAPE_TRANSLUCENT75: - return(Translucent1Blitter); - } - - if (flags & SHAPE_DARKEN) return(ShadowBlitter); - - if (flags & SHAPE_NOTRANS) return(PlainBlitter); - - return(TransBlitter); -} - - -RLEBlitter const * ConvertClass::RLEBlitter_From_Flags(ShapeFlags_Type flags) const -{ - if (flags & SHAPE_REMAP) return(RLERemapBlitter); - - /* - ** Quick check to see if this is a translucent operation. If so, then no - ** further examination of the flags is necessary. - */ - switch (flags & (SHAPE_TRANSLUCENT25 | SHAPE_TRANSLUCENT50 | SHAPE_TRANSLUCENT75)) { - case SHAPE_TRANSLUCENT25: - return(RLETranslucent3Blitter); - - case SHAPE_TRANSLUCENT50: - return(RLETranslucent2Blitter); - - case SHAPE_TRANSLUCENT75: - return(RLETranslucent1Blitter); - } - - if (flags & SHAPE_DARKEN) return(RLEShadowBlitter); - - // This should be fixed to return the RLEPlainBlitter when one is available - // but if you need to use this in the mean time just don't RLE compress the - // shape (since it only compresses transparent pixels and the reason we compress - // them is so we can skip them easily.) - if (flags & SHAPE_NOTRANS) return(RLETransBlitter); - - return(RLETransBlitter); -} - - - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp index 822ff4c6ff9..bf17fbd5160 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp @@ -20,7 +20,6 @@ #include "wwstring.h" #include "wwdebug.h" #include "thread.h" -#include "MPU.H" #pragma warning (disable : 4201) // Nonstandard extension - nameless struct #include #include "systimer.h" diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/data.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/data.cpp deleted file mode 100644 index a1e3e0b8886..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/data.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/data.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/24/99 4:52p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Load_Alloc_Data -- Allocates a buffer and loads the file into it. * - * Load_Uncompress -- Loads and uncompresses data to a buffer. * - * Hires_Load -- Allocates memory for, and loads, a resolution dependant file. * - * Fetch_String -- Fetches a string resource. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "always.h" -#include "data.h" - - -/*********************************************************************************************** - * Load_Alloc_Data -- Allocates a buffer and loads the file into it. * - * * - * This is the C++ replacement for the Load_Alloc_Data function. It will allocate the * - * memory big enough to hold the file and then read the file into it. * - * * - * INPUT: file -- The file to read. * - * * - * mem -- The memory system to use for allocation. * - * * - * OUTPUT: Returns with a pointer to the allocated and filled memory block. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -void * Load_Alloc_Data(FileClass & file) -{ - void * ptr = NULL; - if (file.Is_Available()) { - long size = file.Size(); - - ptr = W3DNEWARRAY char[size]; - if (ptr != NULL) { - file.Read(ptr, size); - } - } - return(ptr); -} - - -/*********************************************************************************************** - * Load_Uncompress -- Loads and uncompresses data to a buffer. * - * * - * This is the C++ counterpart to the Load_Uncompress function. It will load the file * - * specified into the graphic buffer indicated and uncompress it. * - * * - * INPUT: file -- The file to load and uncompress. * - * * - * uncomp_buff -- The graphic buffer that initial loading will use. * - * * - * dest_buff -- The buffer that will hold the uncompressed data. * - * * - * reserved_data -- This is an optional pointer to a buffer that will hold any * - * reserved data the compressed file may contain. This is * - * typically a palette. * - * * - * OUTPUT: Returns with the size of the uncompressed data in the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -long Load_Uncompress(FileClass & file, Buffer & uncomp_buff, Buffer & dest_buff, void * reserved_data) -{ - unsigned short size; - void * sptr = uncomp_buff.Get_Buffer(); - void * dptr = dest_buff.Get_Buffer(); - int opened = false; - CompHeaderType header; - - /* - ** The file must be opened in order to be read from. If the file - ** isn't opened, then open it. Record this fact so that it can be - ** restored to its closed state at the end. - */ - if (!file.Is_Open()) { - if (!file.Open()) { - return(0); - } - opened = true; - } - - /* - ** Read in the size of the file (supposedly). - */ - file.Read(&size, sizeof(size)); - - /* - ** Read in the header block. This block contains the compression type - ** and skip data (among other things). - */ - file.Read(&header, sizeof(header)); - size -= (unsigned short)sizeof(header); - - /* - ** If there are skip bytes then they must be processed. Either read - ** them into the buffer provided or skip past them. No check is made - ** to ensure that the reserved data buffer is big enough (watch out!). - */ - if (header.Skip) { - size -= header.Skip; - if (reserved_data) { - file.Read(reserved_data, header.Skip); - } else { - file.Seek(header.Skip, SEEK_CUR); - } - header.Skip = 0; - } - - /* - ** Determine where is the proper place to load the data. If both buffers - ** specified are identical, then the data should be loaded at the end of - ** the buffer and decompressed at the beginning. - */ - if (uncomp_buff.Get_Buffer() == dest_buff.Get_Buffer()) { - sptr = (char *)sptr + uncomp_buff.Get_Size()-(size+sizeof(header)); - } - - /* - ** Read in the bulk of the data. - */ - memmove(sptr, &header, sizeof(header)); -// Mem_Copy(&header, sptr, sizeof(header)); - file.Read((char *)sptr + sizeof(header), size); - - /* - ** Decompress the data. - */ - size = (unsigned short) Uncompress_Data(sptr, dptr); - - /* - ** Close the file if necessary. - */ - if (opened) { - file.Close(); - } - return((long)size); -} - - -typedef struct SRecord { - int ID; // ID number of the string resource. - int TimeStamp; // 'Time' that this string was last requested. - char String[2048]; // Copy of string resource. - - SRecord(void) : ID(-1), TimeStamp(-1) {} -} SRecord; - - -/*********************************************************************************************** - * Fetch_String -- Fetches a string resource. * - * * - * Fetches a string resource and returns a pointer to its text. * - * * - * INPUT: id -- The ID number of the string resource to fetch. * - * * - * OUTPUT: Returns with a pointer to the actual text of the string resource. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/25/1996 JLB : Created. * - *=============================================================================================*/ -char const * Fetch_String(int id) -{ -#ifdef _UNIX - return(""); -#else - static SRecord _buffers[64]; - static int _time = 0; - - /* - ** Determine if the string ID requested is valid. If not then return an empty string pointer. - */ - if (id == -1 || id == TXT_NONE) return(""); - - /* - ** Adjust the 'time stamp' tracking value. This is an artificial value used merely to track - ** the relative age of the strings requested. - */ - _time = _time+1; - - /* - ** Check to see if the requested string has already been fetched into a buffer. If so, then - ** return a pointer to that string (update the time stamp as well). - */ - for (int index = 0; index < ARRAY_SIZE(_buffers); index++) { - if (_buffers[index].ID == id) { - _buffers[index].TimeStamp = _time; - return(_buffers[index].String); - } - } - - /* - ** Find a suitable buffer to hold the string to be fetched. The buffer should either be - ** empty or have the oldest fetched string. - */ - int oldest = -1; - int oldtime = -1; - for (int text = 0; text < ARRAY_SIZE(_buffers); text++) { - if (oldest == -1 || oldtime > _buffers[text].TimeStamp) { - oldest = text; - oldtime = _buffers[text].TimeStamp; - if (oldtime == -1 || _buffers[text].ID == -1) break; - } - } - - /* - ** A suitable buffer has been found so fetch the string resource and then return a pointer - ** to the string. - */ - char * stringptr = _buffers[oldest].String; - _buffers[oldest].ID = id; - _buffers[oldest].TimeStamp = _time; - if (LoadString(ProgramInstance, id, stringptr, sizeof(_buffers[oldest].String)) == 0) { - return(""); - } - stringptr[sizeof(_buffers[oldest].String)-1] = '\0'; - return(stringptr); -#endif -} - - -void const * Fetch_Resource(LPCSTR resname, LPCSTR restype) -{ -#ifdef _UNIX - return(NULL); -#else - /* - ** Fetch the program instance if it hasn't already been recorded. - */ -// if (ProgramInstance == 0) { -// ProgramInstance = GetModuleHandle("LANGUAGE"); -// } - - HRSRC handle = FindResource(ProgramInstance, resname, restype); - if (handle == NULL) { - return(NULL); - } - - HGLOBAL rhandle = LoadResource(ProgramInstance, handle); - if (rhandle == NULL) { - return(NULL); - } - - return(LockResource(rhandle)); -#endif -} - - -int Load_Picture(FileClass & file, Buffer & scratchbuf, Buffer & destbuf, unsigned char * palette, PicturePlaneType ) -{ - return(Load_Uncompress(file, scratchbuf, destbuf, palette ) / 8000); -} - - -/*********************************************************************************************** - * Hires_Load -- Allocates memory for, and loads, a resolution dependant file. * - * * - * * - * * - * INPUT: Name of file to load * - * * - * OUTPUT: Ptr to loaded file * - * * - * WARNINGS: Caller is responsible for releasing the memory allocated * - * * - * * - * HISTORY: * - * 5/13/96 3:20PM ST : Created * - *=============================================================================================*/ -void * Hires_Load(FileClass & file) -{ - int length; - void * return_ptr; - - if (file.Is_Available()) { - - length = file.Size(); - return_ptr = W3DNEWARRAY char[length]; - file.Read(return_ptr, length); - return (return_ptr); - - } else { - return (NULL); - } -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/data.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/data.h deleted file mode 100644 index 1f04b289975..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/data.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/data.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef DATA_H -#define DATA_H - -#include "BUFF.H" -#include "IFF.H" -#include "win.h" -#include "WWFILE.H" - -#define TXT_NONE 0 - -int Load_Picture(FileClass &file, Buffer & scratchbuf, Buffer & destbuf, unsigned char * palette, PicturePlaneType format); -void * Load_Alloc_Data(FileClass & file); -long Load_Uncompress(FileClass & file, Buffer & uncomp_buff, Buffer & dest_buff, void * reserved_data); -char const * Fetch_String(int id); -void const * Fetch_Resource(LPCSTR resname, LPCSTR restype); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp deleted file mode 100644 index 8d043779652..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/DDRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/15/98 11:05a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Set_Video_Mode -- Initializes Direct Draw and sets the required Video Mode * - * Process_DD_Result -- Does a message box based on the result of a DD command * - * Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object * - * Get_Free_Video_Memory -- returns amount of free video memory * - * Get_Video_Hardware_Caps -- returns bitmask of direct draw video hardware support * - * Wait_Vert_Blank -- Waits for the start (leading edge) of a vertical blank * - * Set_Palette -- set a direct draw palette * - * Check_Overlapped_Blit_Capability -- See if video driver supports blitting overlapped regions* - * Wait_Blit -- waits for the DirectDraw blitter to become idle * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "misc.h" -#include "dsurface.h" -#include "data.h" -#include "_timer.h" -#include -#include - - -LPDIRECTDRAW DirectDrawObject = NULL; // Pointer to the direct draw object -LPDIRECTDRAW2 DirectDraw2Interface = NULL; // Pointer to direct draw 2 interface - -static PALETTEENTRY PaletteEntries[256]; // 256 windows palette entries -static LPDIRECTDRAWPALETTE PalettePtr; // Pointer to direct draw palette object -static bool FirstPaletteSet = false; // Is this the first time 'Set_Palette' has been called? -LPDIRECTDRAWSURFACE PaletteSurface = NULL; -bool SurfacesRestored = false; -static bool CanVblankSync = true; - -unsigned char CurrentPalette[768]; -bool Debug_Windowed; - -int (*DirectDrawErrorHandler)(HRESULT error) = NULL; - -void Set_Palette(PaletteClass const & pal, int time, void (*callback)()) -{ - CDTimerClass timer = time; - PaletteClass original; - memcpy(&original, CurrentPalette, sizeof(CurrentPalette)); - PaletteClass newpal = pal; - - while (timer) { - - /* - ** Build an intermediate palette that is as close to the destination palette - ** as the current time is proportional to the ending time. - */ - PaletteClass palette = original; - int adjust = ((time - timer) * 256) / time; - adjust = MIN(adjust, 255); - palette.Adjust(adjust, newpal); - - /* - ** Remember the current time so that multiple palette sets within the same game - ** time tick won't occur. This is probably unnecessary since the palette setting - ** code, at the time of this writing, delays at least one game tick in the process - ** of setting the palette. - */ - int holdtime = timer; - - /* - ** Set the palette to this intermediate palette and then loop back - ** to calculate and set a new intermediate palette. - */ - Set_Palette((void*)&palette[0]); - - /* - ** If the callback routine was specified, then call it once per palette - ** setting loop. - */ - if (callback) { - callback(); - } - - /* - ** This loop ensures that the palette won't be set more than once per game tick. Setting - ** the palette more than once per game tick will have no effect since the calculation will - ** result in the same intermediate palette that was previously calculated. - */ - while (timer == holdtime && holdtime != 0) { - if (callback) callback(); - } - } - - /* - ** Ensure that the final palette exactly matches the requested - ** palette before exiting the fading routine. - */ - Set_Palette((void*)&newpal[0]); -} - - -/*********************************************************************************************** - * Process_DD_Result -- Does a message box based on the result of a DD command * - * * - * INPUT: HRESULT result - the result returned from the direct draw command * - * int display_ok_msg - should a message be displayed if command ok * * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 09/27/1995 PWG : Created. * - *=============================================================================================*/ -void Process_DD_Result(HRESULT result, int display_ok_msg) -{ -#ifdef _DEBUG - static struct { - HRESULT Error; - char const * Message; - } _errors[] = { - {DDERR_ALREADYINITIALIZED, "This object is already initialized"}, - {DDERR_BLTFASTCANTCLIP, "Return if a clipper object is attached to the source surface passed into a BltFast call."}, - {DDERR_CANNOTATTACHSURFACE, "This surface can not be attached to the requested surface."}, - {DDERR_CANNOTDETACHSURFACE, "This surface can not be detached from the requested surface."}, - {DDERR_CANTCREATEDC, "Windows can not create any more DCs"}, - {DDERR_CANTDUPLICATE, "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created."}, - {DDERR_CANTLOCKSURFACE, "Unable to lock surface because no driver exists which can supply a pointer to the surface."}, - {DDERR_CLIPPERISUSINGHWND, "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd."}, - {DDERR_COLORKEYNOTSET, "No src color key specified for this operation."}, - {DDERR_CURRENTLYNOTAVAIL, "Support is currently not available."}, - {DDERR_DIRECTDRAWALREADYCREATED, "A DirectDraw object representing this driver has already been created for this process."}, - {DDERR_EXCEPTION, "An exception was encountered while performing the requested operation."}, - {DDERR_EXCLUSIVEMODEALREADYSET, "An attempt was made to set the cooperative level when it was already set to exclusive."}, - {DDERR_GENERIC, "Generic failure."}, - {DDERR_HEIGHTALIGN, "Height of rectangle provided is not a multiple of reqd alignment."}, - {DDERR_HWNDALREADYSET, "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created."}, - {DDERR_HWNDSUBCLASSED, "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state."}, - {DDERR_IMPLICITLYCREATED, "This surface can not be restored because it is an implicitly created surface."}, - {DDERR_INCOMPATIBLEPRIMARY, "Unable to match primary surface creation request with existing primary surface."}, - {DDERR_INVALIDCAPS, "One or more of the caps bits passed to the callback are incorrect."}, - {DDERR_INVALIDCLIPLIST, "DirectDraw does not support the provided cliplist."}, - {DDERR_INVALIDDIRECTDRAWGUID, "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier."}, - {DDERR_INVALIDMODE, "DirectDraw does not support the requested mode."}, - {DDERR_INVALIDOBJECT, "DirectDraw received a pointer that was an invalid DIRECTDRAW object."}, - {DDERR_INVALIDPARAMS, "One or more of the parameters passed to the function are incorrect."}, - {DDERR_INVALIDPIXELFORMAT, "The pixel format was invalid as specified."}, - {DDERR_INVALIDPOSITION, "Returned when the position of the overlay on the destination is no longer legal for that destination."}, - {DDERR_INVALIDRECT, "Rectangle provided was invalid."}, - {DDERR_INVALIDSURFACETYPE, "The requested action could not be performed because the surface was of the wrong type."}, - {DDERR_LOCKEDSURFACES, "Operation could not be carried out because one or more surfaces are locked."}, - {DDERR_NO3D, "There is no 3D present."}, - {DDERR_NOALPHAHW, "Operation could not be carried out because there is no alpha accleration hardware present or available."}, -// {DDERR_NOANTITEARHW, "Operation could not be carried out because there is no hardware support for synchronizing blts to avoid tearing. "}, - {DDERR_NOBLTHW, "No blter hardware present."}, -// {DDERR_NOBLTQUEUEHW, "Operation could not be carried out because there is no hardware support for asynchronous blting."}, - {DDERR_NOCLIPLIST, "No cliplist available."}, - {DDERR_NOCLIPPERATTACHED, "No clipper object attached to surface object."}, - {DDERR_NOCOLORCONVHW, "Operation could not be carried out because there is no color conversion hardware present or available."}, - {DDERR_NOCOLORKEY, "Surface doesn't currently have a color key"}, - {DDERR_NOCOLORKEYHW, "Operation could not be carried out because there is no hardware support of the destination color key."}, - {DDERR_NOCOOPERATIVELEVELSET, "Create function called without DirectDraw object method SetCooperativeLevel being called."}, - {DDERR_NODC, "No DC was ever created for this surface."}, - {DDERR_NODDROPSHW, "No DirectDraw ROP hardware."}, - {DDERR_NODIRECTDRAWHW, "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware."}, - {DDERR_NODIRECTDRAWSUPPORT, "No DirectDraw support possible with current display driver."}, - {DDERR_NOEMULATION, "Software emulation not available."}, - {DDERR_NOEXCLUSIVEMODE, "Operation requires the application to have exclusive mode but the application does not have exclusive mode."}, - {DDERR_NOFLIPHW, "Flipping visible surfaces is not supported."}, - {DDERR_NOGDI, "There is no GDI present."}, - {DDERR_NOHWND, "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND."}, - {DDERR_NOMIRRORHW, "Operation could not be carried out because there is no hardware present or available."}, - {DDERR_NOOVERLAYDEST, "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination."}, - {DDERR_NOOVERLAYHW, "Operation could not be carried out because there is no overlay hardware present or available."}, - {DDERR_NOPALETTEATTACHED, "No palette object attached to this surface. "}, - {DDERR_NOPALETTEHW, "No hardware support for 16 or 256 color palettes."}, - {DDERR_NORASTEROPHW, "Operation could not be carried out because there is no appropriate raster op hardware present or available."}, - {DDERR_NOROTATIONHW, "Operation could not be carried out because there is no rotation hardware present or available."}, - {DDERR_NOSTRETCHHW, "Operation could not be carried out because there is no hardware support for stretching."}, - {DDERR_NOT4BITCOLOR, "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette."}, - {DDERR_NOT4BITCOLORINDEX, "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette."}, - {DDERR_NOT8BITCOLOR, "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color."}, - {DDERR_NOTAOVERLAYSURFACE, "Returned when an overlay member is called for a non-overlay surface."}, - {DDERR_NOTEXTUREHW, "Operation could not be carried out because there is no texture mapping hardware present or available."}, - {DDERR_NOTFLIPPABLE, "An attempt has been made to flip a surface that is not flippable."}, - {DDERR_NOTFOUND, "Requested item was not found."}, - {DDERR_NOTLOCKED, "Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted."}, - {DDERR_NOTPALETTIZED, "The surface being used is not a palette-based surface."}, - {DDERR_NOVSYNCHW, "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations."}, - {DDERR_NOZBUFFERHW, "Operation could not be carried out because there is no hardware support for zbuffer blting."}, - {DDERR_NOZOVERLAYHW, "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays."}, - {DDERR_OUTOFCAPS, "The hardware needed for the requested operation has already been allocated."}, - {DDERR_OUTOFMEMORY, "DirectDraw does not have enough memory to perform the operation."}, - {DDERR_OUTOFVIDEOMEMORY, "DirectDraw does not have enough memory to perform the operation."}, - {DDERR_OVERLAYCANTCLIP, "The hardware does not support clipped overlays."}, - {DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "Can only have ony color key active at one time for overlays."}, - {DDERR_OVERLAYNOTVISIBLE, "Returned when GetOverlayPosition is called on a hidden overlay."}, - {DDERR_PALETTEBUSY, "Access to this palette is being refused because the palette is already locked by another thread."}, - {DDERR_PRIMARYSURFACEALREADYEXISTS, "This process already has created a primary surface."}, - {DDERR_REGIONTOOSMALL, "Region passed to Clipper::GetClipList is too small."}, - {DDERR_SURFACEALREADYATTACHED, "This surface is already attached to the surface it is being attached to."}, - {DDERR_SURFACEALREADYDEPENDENT, "This surface is already a dependency of the surface it is being made a dependency of."}, - {DDERR_SURFACEBUSY, "Access to this surface is being refused because the surface is already locked by another thread."}, - {DDERR_SURFACEISOBSCURED, "Access to surface refused because the surface is obscured."}, - {DDERR_SURFACELOST, "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it."}, - {DDERR_SURFACENOTATTACHED, "The requested surface is not attached."}, - {DDERR_TOOBIGHEIGHT, "Height requested by DirectDraw is too large."}, - {DDERR_TOOBIGSIZE, "Size requested by DirectDraw is too large -- the individual height and width are OK."}, - {DDERR_TOOBIGWIDTH, "Width requested by DirectDraw is too large."}, - {DDERR_UNSUPPORTED, "Action not supported."}, - {DDERR_UNSUPPORTEDFORMAT, "FOURCC format requested is unsupported by DirectDraw."}, - {DDERR_UNSUPPORTEDMASK, "Bitmask in the pixel format requested is unsupported by DirectDraw."}, - {DDERR_VERTICALBLANKINPROGRESS, "Vertical blank is in progress."}, - {DDERR_WASSTILLDRAWING, "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete."}, - {DDERR_WRONGMODE, "This surface can not be restored because it was created in a different mode."}, - {DDERR_XALIGN, "Rectangle provided was not horizontally aligned on required boundary."} - }; -#endif - /* - ** If there iwas no error detected, then either bail out or display a message to - ** this effect as indicated by the "display_ok_msg" parameter. - */ - if (result == DD_OK) { - if (display_ok_msg) { - MessageBox(MainWindow, "Direct Draw operation processed without error", "Note", MB_OK); - } - return; - } - - if (DirectDrawErrorHandler) { - DirectDrawErrorHandler(result); - return; - } -#ifdef _DEBUG - /* - ** Scan for a matching error code and display the appropriate message. - */ - for (int index = 0; index < ARRAY_SIZE(_errors); index++) { - if (_errors[index].Error == result) { - MessageBox(MainWindow, _errors[index].Message, "Westwood Library Direct Draw Error", MB_ICONEXCLAMATION|MB_OK); - return; - } - } -#endif - - /* - ** Since it fell out of the above loop, this must be an unrecognized error code. - */ - char str[80]; - sprintf(str, "DDRAW.DLL Error code = %08X", result); - MessageBox(MainWindow, str, "Direct X", MB_ICONEXCLAMATION|MB_OK); -} - - -/*********************************************************************************************** - * Check_Overlapped_Blit_Capability -- See if video driver supports blitting overlapped regions* - * * - * We will check for this by drawing something to a video page and blitting it over itself. * - * If we end up with the top line repeating then overlapped region blits dont work. * - * * - * INPUT: Nothing * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 6/7/96 5:06PM ST : Created * - *=============================================================================================*/ -void Check_Overlapped_Blit_Capability(void) -{ -// OverlappedVideoBlits = false; - -#ifdef NEVER - /* - ** Assume we can until we find out otherwise - */ - OverlappedVideoBlits = true; - - GraphicBufferClass test_buffer; - - test_buffer.Init (64, 64, NULL, 0, (GBC_Enum)GBC_VIDEOMEM); - - test_buffer.Clear(); - - /* - ** Plot a pixel in the top left corner of the buffer. - */ - test_buffer.Put_Pixel(0, 0, 255); - - /* - ** Blit the buffer down by one line. If we end up with a vertical strip of pixel 255's then - ** overlapped blits dont work - */ - - test_buffer.Blit(test_buffer, 0, 0, 0, 1, test_buffer.Get_Width(), test_buffer.Get_Height()-1); - - if (test_buffer.Get_Pixel(0, 5) == 255) OverlappedVideoBlits = false; -#endif -} - - -void Prep_Direct_Draw(void) -{ - // - // If there is not currently a direct draw object then we need to define one. - // - if ( DirectDrawObject == NULL ) { - HRESULT result = DirectDrawCreate(NULL, &DirectDrawObject, NULL); - Process_DD_Result(result, false); - if (result == DD_OK) { - if (Debug_Windowed) { - result = DirectDrawObject->SetCooperativeLevel(MainWindow, DDSCL_NORMAL); - } else { - result = DirectDrawObject->SetCooperativeLevel(MainWindow, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - } - Process_DD_Result(result, false); - } - } -} - - - -/*********************************************************************************************** - * Set_Video_Mode -- Initializes Direct Draw and sets the required Video Mode * - * * - * INPUT: int width - the width of the video mode in pixels * - * int height - the height of the video mode in pixels * - * int bits_per_pixel - the number of bits per pixel the video mode supports * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 09/26/1995 PWG : Created. * - *=============================================================================================*/ -bool Set_Video_Mode(HWND , int w, int h, int bits_per_pixel) -{ - HRESULT result; - - Prep_Direct_Draw(); - - // - // Set the required display mode with 8 bits per pixel - // - //MessageBox(MainWindow, "In Set_Video_Mode. About to call call SetDisplayMode.","Note", MB_ICONEXCLAMATION|MB_OK); - result = DirectDrawObject->SetDisplayMode(w, h, bits_per_pixel); - if (result != DD_OK) { -// Process_DD_Result(result, false); - DirectDrawObject->Release(); - DirectDrawObject = NULL; - return(false); - } - - // - // Create a direct draw palette object - // - //MessageBox(MainWindow, "In Set_Video_Mode. About to call CreatePalette.","Note", MB_ICONEXCLAMATION|MB_OK); - result = DirectDrawObject->CreatePalette( DDPCAPS_8BIT | DDPCAPS_ALLOW256, &PaletteEntries[0], &PalettePtr, NULL); - Process_DD_Result(result, false); - if (result != DD_OK) { - return (false); - } - - Check_Overlapped_Blit_Capability(); - - //MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); -#if (0) - /* - ** Find out if DirectX 2 extensions are available - */ - result = DirectDrawObject->QueryInterface (IID_IDirectDraw2, (LPVOID*)&DirectDraw2Interface); - SystemToVideoBlits = false; - VideoToSystemBlits = false; - SystemToSystemBlits= false; - if (result != DD_OK) { - DirectDraw2Interface = NULL; - } else { - DDCAPS capabilities; - DDCAPS emulated_capabilities; - - memset ((char*)&capabilities, 0, sizeof(capabilities)); - memset ((char*)&emulated_capabilities, 0, sizeof(emulated_capabilities)); - capabilities.dwSize = sizeof (capabilities); - emulated_capabilities.dwSize = sizeof (emulated_capabilities); - - DirectDrawObject->GetCaps (&capabilities, &emulated_capabilities); - - if (capabilities.dwCaps & DDCAPS_CANBLTSYSMEM) { - SystemToVideoBlits = (capabilities.dwSVBCaps & DDCAPS_BLT) ? true : false; - VideoToSystemBlits = (capabilities.dwVSBCaps & DDCAPS_BLT) ? true : false; - SystemToSystemBlits = (capabilities.dwSSBCaps & DDCAPS_BLT) ? true : false; - } - } -#endif //(0) - - //MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); - - return (true); - -} - -/*********************************************************************************************** - * Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: * - * * - * HISTORY: * - * 09/26/1995 PWG : Created. * - *=============================================================================================*/ -void Reset_Video_Mode(void) -{ - HRESULT result; - - // - // If a direct draw object has been declared and a video mode has been set - // then reset the video mode and release the direct draw object. - // - if ( DirectDrawObject ) { - result = DirectDrawObject->RestoreDisplayMode(); - Process_DD_Result(result, false); - result = DirectDrawObject->Release(); - Process_DD_Result(result, false); - - DirectDrawObject = NULL; - } -} - - -/*********************************************************************************************** - * Get_Free_Video_Memory -- returns amount of free video memory * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: bytes of available video RAM * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 11/29/95 12:52PM ST : Created * - *=============================================================================================*/ -unsigned int Get_Free_Video_Memory(void) -{ - DDCAPS video_capabilities; - - if (DirectDrawObject) { - - video_capabilities.dwSize = sizeof (video_capabilities); - - if (DD_OK == DirectDrawObject->GetCaps (&video_capabilities, NULL)) { - char string [256]; - wsprintf (string, "In Get_Free_Video_Memory. About to return %d bytes",video_capabilities.dwVidMemFree); - return (video_capabilities.dwVidMemFree); - } - } - - return (0); -} - - -/*********************************************************************************************** - * Get_Video_Hardware_Caps -- returns bitmask of direct draw video hardware support * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: hardware flags * - * * - * WARNINGS: Must call Set_Video_Mode 1st to create the direct draw object * - * * - * HISTORY: * - * 1/12/96 9:14AM ST : Created * - *=============================================================================================*/ -unsigned Get_Video_Hardware_Capabilities(void) -{ - DDCAPS video_capabilities; - unsigned video; - - /* - ** Fail if the direct draw object has not been initialised - */ - if (!DirectDrawObject) return (0); - - /* - ** Get the capabilities of the direct draw object - */ - video_capabilities.dwSize = sizeof(video_capabilities); - //MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to call GetCaps","Note", MB_ICONEXCLAMATION|MB_OK); - HRESULT result = DirectDrawObject->GetCaps (&video_capabilities, NULL); - if (result != DD_OK) { - Process_DD_Result(result, false); - return (0); - } - - /* - ** Set flags to indicate the presence of the features we are interested in - */ - video = 0; - - /* Hardware blits supported? */ - if (video_capabilities.dwCaps & DDCAPS_BLT) video |= VIDEO_BLITTER; - - /* Hardware blits asyncronous? */ - if (video_capabilities.dwCaps & DDCAPS_BLTQUEUE) video |= VIDEO_BLITTER_ASYNC; - - /* Can palette changes be synced to vertical refresh? */ - if (video_capabilities.dwCaps & DDCAPS_PALETTEVSYNC) video |= VIDEO_SYNC_PALETTE; - - /* Is the video cards memory bank switched? */ - if (video_capabilities.dwCaps & DDCAPS_BANKSWITCHED) video |= VIDEO_BANK_SWITCHED; - - /* Can the blitter do filled rectangles? */ - if (video_capabilities.dwCaps & DDCAPS_BLTCOLORFILL) video |= VIDEO_COLOR_FILL; - - /* Is there no hardware assistance avaailable at all? */ - if (video_capabilities.dwCaps & DDCAPS_NOHARDWARE) video |= VIDEO_NO_HARDWARE_ASSIST; - - //MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); - return (video); -} - - -/*********************************************************************************************** - * Wait_Vert_Blank -- Waits for the start (leading edge) of a vertical blank * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Wait_Vert_Blank(void) -{ - if (CanVblankSync) { - HRESULT result = DirectDrawObject->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); - if (result == E_NOTIMPL) { - CanVblankSync = false; - return; - } - Process_DD_Result(result, false); - } -} - - -/*********************************************************************************************** - * Set_Palette -- set a direct draw palette * - * * - * * - * * - * INPUT: ptr to 768 rgb palette bytes * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 10/11/95 3:33PM ST : Created * - *=============================================================================================*/ -void Set_Palette(void const * palette) -{ - assert(palette != NULL); - - if (&CurrentPalette[0] != palette) { - memmove(CurrentPalette, palette, sizeof(CurrentPalette)); - } - - if (DirectDrawObject != NULL && PaletteSurface != NULL) { - unsigned char * palette_get = (unsigned char *)palette; - for (int index = 0; index < 256; index++) { - - int red = *palette_get++; - int green = *palette_get++; - int blue = *palette_get++; - - PaletteEntries[index].peRed = (unsigned char)red; - PaletteEntries[index].peGreen = (unsigned char)green; - PaletteEntries[index].peBlue = (unsigned char)blue; - } - - if (PalettePtr != NULL) { - if (!FirstPaletteSet) { - PaletteSurface->SetPalette(PalettePtr); - FirstPaletteSet = true; - } - - PalettePtr->SetEntries(0, 0, 256, &PaletteEntries[0]); - } - } -} - - -/*********************************************************************************************** - * Wait_Blit -- waits for the DirectDraw blitter to become idle * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 07-25-95 03:53pm ST : Created * - *=============================================================================================*/ -void Wait_Blit (void) -{ - HRESULT return_code; - - do { - return_code=PaletteSurface->GetBltStatus (DDGBS_ISBLTDONE); - } while (return_code != DD_OK && return_code != DDERR_SURFACELOST); -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/dib.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/dib.h deleted file mode 100644 index 1ee238ffb3c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/dib.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/dib.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/26/97 11:33a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DIB_H -#define DIB_H - -#include "always.h" -#include "bsurface.h" -#include "PALETTE.H" -#include "win.h" - - -class DIB8Class -{ -public: - - DIB8Class(HWND hwnd,int width, int height, PaletteClass & pal); - ~DIB8Class(void); - - HBITMAP Get_Handle() { return Handle; } - int Get_Width(void) { return Width; } - int Get_Height(void) { return Height; } - Surface & Get_Surface(void) { return *Surface; } - - void Clear(unsigned char color); - -private: - - bool IsZombie; // object constructor failed, its a living-dead object! - BITMAPINFO * Info; // info used in creating the dib + the palette. - HBITMAP Handle; // handle to the actual dib - unsigned char * Pixels; // address of memory containing the pixel data - int Width; // width of the dib - int Height; // height of the dib - unsigned char * PixelBase; // address of upper left pixel (this and DIBPitch abstract up/down DIBS) - int Pitch; // offset from DIBPixelBase to next row (can be negative for bottom-up DIBS) - - BSurface * Surface; // Bsurface wrapped around the pixel buffer. -}; - - -#endif /*DIB_H*/ \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/draw.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/draw.h deleted file mode 100644 index 0e67a56e750..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/draw.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Draw.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DRAW_H -#define DRAW_H - -#include "Convert.h" -#include "Point.h" -#include "shapeset.h" - -void Draw_Shape(Surface & surface, ConvertClass & convert, ShapeSet const * shapefile, int shapenum, Point2D const & point, Rect const & window, ShapeFlags_Type flags = SHAPE_NORMAL, unsigned char const * remap = NULL); -void Blit_Block(Surface & surface, ConvertClass & convert, Surface const & source, Rect const & sourcerect, Point2D const & point, Rect const & clipwindow, unsigned char const * remap = NULL, Blitter const * blitter = NULL); - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp deleted file mode 100644 index 7f80f5001ee..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp +++ /dev/null @@ -1,931 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/dsurface.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 6/23/00 2:26p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DSurface::Blit_From -- Blit from one surface to this one. * - * DSurface::Blit_From -- Blit graphic memory from one rectangle to another. * - * DSurface::Build_Hicolor_Pixel -- Construct a hicolor pixel according to the surface pixel * - * DSurface::Build_Remap_Table -- Build a highcolor remap table. * - * DSurface::Bytes_Per_Pixel -- Fetches the bytes per pixel of the surface. * - * DSurface::Create_Primary -- Creates a primary (visible) surface. * - * DSurface::DSurface -- Create a surface attached to specified DDraw Surface Object. * - * DSurface::DSurface -- Default constructor for surface object. * - * DSurface::DSurface -- Off screen direct draw surface constructor. * - * DSurface::Fill_Rect -- Fills a rectangle with clipping control. * - * DSurface::Fill_Rect -- This routine will fill the specified rectangle. * - * DSurface::Lock -- Fetches a working pointer into surface memory. * - * DSurface::Restore_Check -- Checks for and restores surface memory if necessary. * - * DSurface::Stride -- Fetches the bytes between rows. * - * DSurface::Unlock -- Unlock a previously locked surface. * - * DSurface::~DSurface -- Destructor for a direct draw surface object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "dsurface.h" -#include - -extern LPDIRECTDRAW DirectDrawObject; //pointer to direct draw object -extern LPDIRECTDRAWSURFACE PaletteSurface; - -/* -** Clipper object (for primary surface). -*/ -LPDIRECTDRAWCLIPPER DSurface::Clipper = NULL; - -int DSurface::RedRight = 0; -int DSurface::RedLeft = 0; -int DSurface::BlueRight = 0; -int DSurface::BlueLeft = 0; -int DSurface::GreenRight = 0; -int DSurface::GreenLeft = 0; - -unsigned short DSurface::HalfbrightMask = 0; -unsigned short DSurface::QuarterbrightMask = 0; -unsigned short DSurface::EighthbrightMask = 0; - -DDPIXELFORMAT DSurface::PixelFormat; - - -/*********************************************************************************************** - * DSurface::DSurface -- Off screen direct draw surface constructor. * - * * - * This constructor will create a Direct Draw enabled surface in video memory if possible. * - * Such a surface will be able to use hardware assist if possible. The surface created * - * is NOT visible. It only exists as a work surface and cannot be flipped to the visible * - * surface. It can only be blitted to the visible surface. * - * * - * INPUT: width -- The width of the surface to create. * - * * - * height -- The height of the surface to create. * - * * - * OUTPUT: none * - * * - * WARNINGS: The surface pixel format is the same as that of the visible display mode. It * - * is important to construct surfaces using this routine, only AFTER the display * - * mode has been set. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(int width, int height, bool system_memory, DDPIXELFORMAT *pixform) : - XSurface(width, height), - BytesPerPixel(0), - LockPtr(NULL), - IsPrimary(false), - IsVideoRam(false), - SurfacePtr(NULL), - Description(NULL), - DCUnlockCount(0) -{ - Description = W3DNEW DDSURFACEDESC; - if (Description != NULL) { - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - Description->dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - Description->dwWidth = width; - Description->dwHeight = height; - - Description->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - - if (system_memory == true) - Description->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; - - /* - ** Was a custom (non-display-depth) pixel format specified? - */ - if (pixform) - { - Description->ddpfPixelFormat=*pixform; - Description->dwFlags |= DDSD_PIXELFORMAT; - } - - - DirectDrawObject->CreateSurface(Description, &SurfacePtr, NULL); - - /* - ** Get a description of the surface that was just allocated. - */ - if (SurfacePtr != NULL) { - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - SurfacePtr->GetSurfaceDesc(Description); - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - IsVideoRam = ((Description->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) != 0); - - - /* - ** If this is a hicolor surface, then build the shift values for - ** building and extracting the colors from the hicolor pixel. - */ - if (BytesPerPixel == 2) { - int index; - int shift = Description->ddpfPixelFormat.dwRBitMask; - ThisRedRight = 0; - ThisRedLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - shift >>= 1; - ThisRedRight++; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - shift <<= 1; - ThisRedLeft++; - } - - shift = Description->ddpfPixelFormat.dwGBitMask; - ThisGreenRight = 0; - ThisGreenLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - ThisGreenRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - ThisGreenLeft++; - shift <<= 1; - } - - shift = Description->ddpfPixelFormat.dwBBitMask; - ThisBlueRight = 0; - ThisBlueLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - ThisBlueRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - ThisBlueLeft++; - shift <<= 1; - } - - } - } - } -} - - -/*********************************************************************************************** - * DSurface::~DSurface -- Destructor for a direct draw surface object. * - * * - * This will destruct (make invalid) the direct draw surface. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::~DSurface(void) -{ - /* - ** If this is the primary surface, then the clipper must be detached from - ** this surface and the clipper object deleted. - */ - if (IsPrimary && SurfacePtr != NULL && Clipper != NULL) { - SurfacePtr->SetClipper(NULL); - Clipper->Release(); - Clipper = NULL; - } - - /* - ** Delete the description of the surface. - */ - delete Description; - Description = NULL; - - if (SurfacePtr != NULL) { - SurfacePtr->Release(); - } - SurfacePtr = NULL; -} - - -/*********************************************************************************************** - * DSurface::DSurface -- Default constructor for surface object. * - * * - * This default constructor for a surface object should not be used. Although it properly * - * creates a non-functional surface, there is no use for such a surface. This default * - * constructor is provided for those rare cases where symatics require a default * - * constructor. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(void) : - BytesPerPixel(0), - LockPtr(NULL), - SurfacePtr(NULL), - Description(NULL), - DCUnlockCount(0) -{ - Description = W3DNEW DDSURFACEDESC; - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); -} - - - -/*********************************************************************************************** - * DSurface::GetDC -- Get the windows device context from our surface * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Any current locks will get unlocked while the DC is held * - * * - * HISTORY: * - * 06/21/2000 NAK : Created. * - *=============================================================================================*/ -HDC DSurface::GetDC(void) -{ - HDC hdc = NULL; - HRESULT hr; - - - // We have to remove all current locks to get the device context unfortunately... - while (LockCount) { - Unlock(); - DCUnlockCount++; - } - - - hr = SurfacePtr->GetDC(&hdc); - if (hr != DD_OK) - { - while(DCUnlockCount) // restore the lock state - { - Lock(); - DCUnlockCount--; - } - return(NULL); - } - - // GetDC() locks the surface internally, so we need to reflect that here - if (hr == DD_OK) { - LockCount++; - }else{ - hdc = NULL; - } - - return (hdc); -} - - -/*********************************************************************************************** - * DSurface::ReleaseDC -- Release the windows device context from our surface * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Restores any locks held before the call to GetDC() * - * * - * HISTORY: * - * 06/21/2000 NAK : Created. * - *=============================================================================================*/ -int DSurface::ReleaseDC(HDC hdc) -{ - HRESULT hr; - - hr = SurfacePtr->ReleaseDC(hdc); - assert(hr == DD_OK); - - // ReleaseDC() unlocks the surface internally, so we need to reflect that here. - if ((hr == DD_OK) && (LockCount > 0)) { - LockCount--; - } - - while(DCUnlockCount) // restore the lock state - { - Lock(); - DCUnlockCount--; - } - - return (1); -} - - - - -/*********************************************************************************************** - * DSurface::Create_Primary -- Creates a primary (visible) surface. * - * * - * This routine is used to create the surface object that represents the currently * - * visible display. The surface is not allocated, it is merely linked to the preexisting * - * surface that the Windows GDI is also currently using. * - * * - * INPUT: backsurface -- Optional pointer to specify where the backpage (flip enabled) * - * pointer will be placed. If this parameter is NULL, then no * - * back surface will be created. * - * * - * OUTPUT: Returns with a pointer to the primary surface. * - * * - * WARNINGS: There can be only one primary surface. If an additional call to this routine * - * is made, another surface pointer will be returned, but it will point to the * - * same surface as before. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface * DSurface::Create_Primary(DSurface ** backsurface1) -{ - DSurface * surface = W3DNEW DSurface(); - int backcount = (backsurface1 != NULL) ? 1 : 0; - - /* - ** Setup parameter for creating the primary surface. This will - ** always be the visible surface plus optional back buffers of identical - ** dimensions. - */ - surface->Description->dwFlags = DDSD_CAPS; - surface->Description->ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - if (backcount > 0) { - surface->Description->ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; - surface->Description->dwFlags |= DDSD_BACKBUFFERCOUNT; - surface->Description->dwBackBufferCount = backcount; - } - HRESULT result = DirectDrawObject->CreateSurface(surface->Description, &surface->SurfacePtr, NULL); - - /* - ** If the primary surface object was created, then fetch a pointer to the - ** back buffer if there is one present. - */ - if (result == DD_OK) { - if (backcount > 0) { - LPDIRECTDRAWSURFACE back; - DDSCAPS caps; - caps.dwCaps = DDSCAPS_BACKBUFFER; - result = surface->SurfacePtr->GetAttachedSurface(&caps, &back); - if (result == DD_OK) { - *backsurface1 = W3DNEW DSurface(back); - } - } - - /* - ** Get a description of the surface that was just allocated. - */ - memset(surface->Description, '\0', sizeof(DDSURFACEDESC)); - surface->Description->dwSize = sizeof(DDSURFACEDESC); - surface->SurfacePtr->GetSurfaceDesc(surface->Description); - surface->BytesPerPixel = (surface->Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - surface->IsPrimary = true; - -// surface->Window.Set(Rect(0, 0, surface->Description->dwWidth, surface->Description->dwHeight)); - surface->Width = surface->Description->dwWidth; - surface->Height = surface->Description->dwHeight; - PaletteSurface = surface->SurfacePtr; - - /* - ** Attach a clipper object to the surface so that it can cooperate - ** with the system GDI. This only comes into play if there are going - ** to be GDI graphical elements on top of the surface (normally this - ** isn't the case for full screen games). It doesn't hurt to attach - ** a clipper object anyway -- just in case. - */ - if (DirectDrawObject->CreateClipper(0, &Clipper, NULL) == DD_OK) { - if (Clipper->SetHWnd(0, GetActiveWindow()) == DD_OK) { - surface->SurfacePtr->SetClipper(Clipper); - } - } - - /* - ** Fetch the pixel format for the surface. - */ - memcpy(&PixelFormat, &surface->Description->ddpfPixelFormat, sizeof(DDPIXELFORMAT)); - - /* - ** If this is a hicolor surface, then build the shift values for - ** building and extracting the colors from the hicolor pixel. - */ - if (surface->Bytes_Per_Pixel() == 2) { - int index; - int shift = PixelFormat.dwRBitMask; - RedRight = 0; - RedLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - shift >>= 1; - RedRight++; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - shift <<= 1; - RedLeft++; - } - - shift = PixelFormat.dwGBitMask; - GreenRight = 0; - GreenLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - GreenRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - GreenLeft++; - shift <<= 1; - } - - shift = PixelFormat.dwBBitMask; - BlueRight = 0; - BlueLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - BlueRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - BlueLeft++; - shift <<= 1; - } - - - /* - ** Create the halfbright mask. - */ - HalfbrightMask = (unsigned short)Build_Hicolor_Pixel(127, 127, 127); - QuarterbrightMask = (unsigned short)Build_Hicolor_Pixel(63, 63, 63); - EighthbrightMask = (unsigned short)Build_Hicolor_Pixel(31, 31, 31); - } - - } else { - delete surface; - surface = NULL; - } - - return(surface); -} - - -/*********************************************************************************************** - * DSurface::DSurface -- Create a surface attached to specified DDraw Surface Object. * - * * - * If an existing Direct Draw Surface Object is available, use this constructor to create * - * a DSurface object that is attached to the surface specified. * - * * - * INPUT: surfaceptr -- Pointer to a preexisting Direct Draw Surface Object. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(LPDIRECTDRAWSURFACE surfaceptr) : - BytesPerPixel(0), - LockPtr(NULL), - SurfacePtr(surfaceptr), - Description(NULL) -{ - if (SurfacePtr != NULL) { - Description = W3DNEW DDSURFACEDESC; - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - HRESULT result = SurfacePtr->GetSurfaceDesc(Description); - if (result == DD_OK) { - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; -// Window.Set(Rect(0, 0, Description->dwWidth, Description->dwHeight)); - Width = Description->dwWidth; - Height = Description->dwHeight; - } - } -} - - -/*********************************************************************************************** - * DSurface::Bytes_Per_Pixel -- Fetches the bytes per pixel of the surface. * - * * - * This routine will return with the number of bytes that each pixel consumes. The value * - * is dependant upon the graphic mode of the display. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the bytes per pixel of the surface object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Bytes_Per_Pixel(void) const -{ - return(BytesPerPixel); -} - - -/*********************************************************************************************** - * DSurface::Stride -- Fetches the bytes between rows. * - * * - * This routine will return the number of bytes to add so that the pointer will be * - * positioned at the same column, but one row down the screen. This value may very well * - * NOT be equal to the width multiplied by the bytes per pixel. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the byte difference between subsequent pixel rows. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Stride(void) const -{ - return(Description->lPitch); -} - - -/*********************************************************************************************** - * DSurface::Lock -- Fetches a working pointer into surface memory. * - * * - * This routine will return with a pointer to the pixel at the location specified. In order * - * to directly manipulate surface memory, the surface memory must be mapped into the * - * program's logical address space. In addition, all blitter activity on the surface will * - * be suspended. Every call to Lock must be have a corresponding call to Unlock if the * - * pointer returned is not equal to NULL. * - * * - * INPUT: point -- Pixel coordinate to return a pointer to. * - * * - * OUTPUT: Returns with a pointer to the pixel specified. If the return value is NULL, then * - * the surface could not be locked and no call to Unlock should be performed. * - * * - * WARNINGS: It is important not to keep a surface locked indefinately since the blitter * - * will not be able to function. Due to the time that locking consumes, it is * - * also important to not perform unnecessarily frequent Lock calls. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -void * DSurface::Lock(Point2D point) const -{ - Restore_Check(); - if (LockCount == 0) { - DDSURFACEDESC desc; - memset(&desc, '\0', sizeof(desc)); - desc.dwSize = sizeof(desc); - HRESULT result = SurfacePtr->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL); - if (result != DD_OK) return(NULL); - memcpy(Description, &desc, sizeof(DDSURFACEDESC)); - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - LockPtr = Description->lpSurface; - } - XSurface::Lock(); - return(((char*)LockPtr) + point.Y * Stride() + point.X * Bytes_Per_Pixel()); -} - - -/*********************************************************************************************** - * DSurface::Unlock -- Unlock a previously locked surface. * - * * - * After a surface has been successfully locked, a call to the Unlock() function is * - * required. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Was the unlock successful? * - * * - * WARNINGS: Only pair a call to Unlock if the prior Lock actually returned a non-NULL * - * value. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Unlock(void) const -{ - Restore_Check(); - if (LockCount > 0) { - XSurface::Unlock(); - if (LockCount == 0) { - SurfacePtr->Unlock(LockPtr); - LockPtr = NULL; - } - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * DSurface::Restore_Check -- Checks for and restores surface memory if necessary. * - * * - * This routine will check to see if surface memory has been lost to the surface. If it * - * has, then the surface memory will be restored. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -void DSurface::Restore_Check(void) const -{ - if (SurfacePtr->IsLost() == DDERR_SURFACELOST) { - SurfacePtr->Restore(); - if (LockCount > 0 && SurfacePtr->IsLost() != DDERR_SURFACELOST) { - int oldlockcount = LockCount; - LockCount = 0; - Lock(); - LockCount++; - Unlock(); - LockCount = oldlockcount; - } - } -} - - -/*********************************************************************************************** - * DSurface::Blit_From -- Blit graphic memory from one rectangle to another. * - * * - * This routine will use the blitter (if possible) to blit a block of graphic memory from * - * one screen rectangle to another. If the rectangles do no match in size, scaling may * - * be performed. * - * * - * INPUT: destrect -- The destination rectangle. * - * * - * ssource -- The source surface to blit from. * - * * - * sourecrect -- The source rectangle. * - * * - * trans -- Should transparency checking be performed? * - * * - * OUTPUT: bool; Was the blit performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Blit_From(Rect const & destrect, Surface const & ssource, Rect const & sourcerect, bool trans) -{ - return(Blit_From(Get_Rect(), destrect, ssource, ssource.Get_Rect(), sourcerect, trans)); -} - - -/*********************************************************************************************** - * DSurface::Blit_From -- Blit from one surface to this one. * - * * - * Use this routine to blit a rectangle from the specified surface to this surface while * - * performing clipping upon the blit rectangles specified. * - * * - * INPUT: dcliprect -- The clipping rectangle to use for this surface. * - * * - * destrect -- The destination rectangle of the blit. The is relative to the * - * dcliprect parameter. * - * * - * ssource -- The source surface of the blit. * - * * - * scliprect -- The source clipping rectangle. * - * * - * sourcrect -- The source rectangle of the blit. This rectangle is relative to * - * the source clipping rectangle. * - * * - * trans -- Is this a transparent blit request? * - * * - * OUTPUT: bool; Was there a blit performed? A 'false' return value would indicate that the * - * blit was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & ssource, Rect const & scliprect, Rect const & sourcerect, bool trans) -{ - if (!dcliprect.Is_Valid() || !scliprect.Is_Valid() || !destrect.Is_Valid() || !sourcerect.Is_Valid()) return(false); - - /* - ** For non-direct draw surfaces, perform a manual blit operation. This is also - ** necessary if any of the surfaces are currently locked. It is also necessary if the - ** blit regions overlap and the blitter cannot handle overlapped regions. - ** - ** NOTE: Its legal to blit to a locked surface but not from a locked surface. - ** ST - 4/23/97 1:03AM - */ - if (!ssource.Is_Direct_Draw() || ((DSurface&)ssource).Is_Locked() || trans || Bytes_Per_Pixel() != ssource.Bytes_Per_Pixel()) { - return(XSurface::Blit_From(destrect, ssource, sourcerect, trans)); - } - - Restore_Check(); - DSurface const & source = (DSurface const &)ssource; - - Rect drect = destrect; - Rect srect = sourcerect; - Rect swindow = scliprect.Intersect(ssource.Get_Rect()); - Rect dwindow = dcliprect.Intersect(Get_Rect()); - if (Blit_Clip(drect, dwindow, srect, swindow)) { - RECT xdestrect; - xdestrect.left = drect.X+dwindow.X; - xdestrect.top = drect.Y+dwindow.Y; - xdestrect.right = drect.X+dwindow.X+drect.Width; - xdestrect.bottom = drect.Y+dwindow.Y+drect.Height; - - RECT xsrcrect; - xsrcrect.left = srect.X+swindow.X; - xsrcrect.top = srect.Y+swindow.Y; - xsrcrect.right = srect.X+swindow.X+srect.Width; - xsrcrect.bottom = srect.Y+swindow.Y+srect.Height; - - HRESULT result = SurfacePtr->Blt(&xdestrect, source.SurfacePtr, &xsrcrect, DDBLT_WAIT, NULL); - return(result == DD_OK); - } - return(false); -} - - -/*********************************************************************************************** - * DSurface::Fill_Rect -- This routine will fill the specified rectangle. * - * * - * This routine will fill the specified rectangle with a color. * - * * - * INPUT: fillrect -- The rectangle to fill. * - * * - * color -- The color to fill with. * - * * - * OUTPUT: bool; Was the fill performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Fill_Rect(Rect const & fillrect, int color) -{ - return(DSurface::Fill_Rect(Get_Rect(), fillrect, color)); -} - - -/*********************************************************************************************** - * DSurface::Fill_Rect -- Fills a rectangle with clipping control. * - * * - * This routine will fill a rectangle on this surface, but will clip the request against * - * a clipping rectangle first. * - * * - * INPUT: cliprect -- The clipping rectangle to use for this surface. * - * * - * fillrect -- The rectangle to fill with the specified color. The rectangle is * - * relative to the clipping rectangle. * - * * - * color -- The color (surface dependant format) to use when filling the rectangle * - * pixels. * - * * - * OUTPUT: bool; Was a fill operation performed? A 'false' return value would mean that the * - * fill request was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) -{ - if (!fillrect.Is_Valid()) return(false); - - /* - ** If the buffer is locked, then using the blitter to perform the fill is not possible. - ** In such a case, perform a manual fill of the region. - */ - if (Is_Locked()) { - return(XSurface::Fill_Rect(cliprect, fillrect, color)); - } - - Restore_Check(); - - /* - ** Ensure that the clipping rectangle is legal. - */ - Rect crect = cliprect.Intersect(Get_Rect()); - - /* - ** Bias the fill rect to the clipping rectangle. - */ - Rect frect = fillrect.Bias_To(cliprect); - - /* - ** Find the region that should be filled after being clipped by the - ** clipping rectangle. This could result in no fill operation being performed - ** if the desired fill rectangle has been completely clipped away. - */ - frect = frect.Intersect(crect); - if (!frect.Is_Valid()) return(false); - - RECT rect; - rect.left = frect.X; - rect.top = frect.Y; - rect.right = rect.left + frect.Width; - rect.bottom = rect.top + frect.Height; - - DDBLTFX fx; - memset(&fx, '\0', sizeof(fx)); - fx.dwSize = sizeof(fx); - fx.dwFillColor = color; - HRESULT result = SurfacePtr->Blt(&rect, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx); - return(result == DD_OK); -} - - -/*********************************************************************************************** - * DSurface::Build_Hicolor_Pixel -- Construct a hicolor pixel according to the surface pixel f * - * * - * This routine will construct a pixel according to the highcolor pixel format for this * - * surface. * - * * - * INPUT: red -- The red component of the color (0..255). * - * * - * green -- The green component of the color (0..255). * - * * - * blue -- The blue component of the color (0..255). * - * * - * OUTPUT: Returns with a screen format pixel number that most closesly matches the color * - * specified. * - * * - * WARNINGS: The return value is card dependant and only applies to hicolor displays. * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Build_Hicolor_Pixel(int red, int green, int blue) -{ - return(((red >> RedLeft) << RedRight) | ((green >> GreenLeft) << GreenRight) | ((blue >> BlueLeft) << BlueRight)); -} - - -/*********************************************************************************************** - * DSurface::Build_Remap_Table -- Build a highcolor remap table. * - * * - * This will build a complete hicolor remap table for the palette specified. This table * - * can then be used to quickly fetch a pixel that matches the color index of the palette. * - * * - * INPUT: table -- The location to store the hicolor table. The buffer must be 256*2 bytes * - * long. * - * * - * palette -- The palette to use to create the remap table. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -void DSurface::Build_Remap_Table(unsigned short * table, PaletteClass const & palette) -{ - assert(table != NULL); - - /* - ** Build the hicolor index table according to the palette. - */ - for (int index = 0; index < 256; index++) { - table[index] = (unsigned short)Build_Hicolor_Pixel(palette[index].Get_Red(), palette[index].Get_Green(), palette[index].Get_Blue()); - } -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.h deleted file mode 100644 index 2cd08c73935..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/dsurface.h +++ /dev/null @@ -1,205 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/dsurface.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 6/23/00 2:24p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DSURFACE_H -#define DSURFACE_H - -#include "PALETTE.H" -#include "win.h" -#include "xsurface.h" -#include - -/* -** This is a concrete surface class that is based on the DirectDraw -** API. -*/ -class DSurface : public XSurface -{ - typedef XSurface BASECLASS; - - public: - virtual ~DSurface(void); - - /* - ** Default constructor. - */ - DSurface(void); - - /* - ** Constructs a working surface (not visible). - */ - DSurface(int width, int height, bool system_memory = false, DDPIXELFORMAT *pixform=NULL); - - /* - ** Creates a surface from a previously created DirectDraw surface object. - */ - DSurface(LPDIRECTDRAWSURFACE surfaceptr); - - /* - ** Get/Release a windows device context from a DirectX surface - */ - HDC GetDC(void); - int ReleaseDC(HDC hdc); - - /* - ** Create a surface object that represents the currently visible screen. - */ - static DSurface * Create_Primary(DSurface ** backsurface1=NULL); - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Surface const & source, bool trans=false) {return(XSurface::Blit_From(source, trans));} - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color); - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color); - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const; - virtual bool Unlock(void) const; - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const; - virtual int Stride(void) const; - bool In_Video_Ram(void) const {return(IsVideoRam);} - - /* - ** Verifies that this is a direct draw enabled surface. - */ - virtual bool Is_Direct_Draw(void) const {return(true);} - - static int Build_Hicolor_Pixel(int red, int green, int blue); - static void Build_Remap_Table(unsigned short * table, PaletteClass const & palette); - static unsigned short Get_Halfbright_Mask(void) {return(HalfbrightMask);} - static unsigned short Get_Quarterbright_Mask(void) {return(QuarterbrightMask);} - static unsigned short Get_Eighthbright_Mask(void) {return(EighthbrightMask);} - - protected: - void Restore_Check(void) const; - - /* - ** Convenient copy of the bytes per pixel value to speed accessing it. It - ** gets accessed frequently. - */ - mutable int BytesPerPixel; - - /* - ** Lock count and pointer values. This is used to keep track of the levels - ** of locking the graphic data. This is only here because DirectDraw prohibits - ** the blitter from working on a surface that has been locked. - */ - mutable void * LockPtr; - - /* - ** If this surface object represents the one that is visible and associated - ** with the system GDI, then this flag will be true. - */ - bool IsPrimary; - - /* - ** Is this surface represented in video ram? - */ - bool IsVideoRam; - - /* - ** Direct draw specific data. - */ - LPDIRECTDRAWSURFACE SurfacePtr; - DDSURFACEDESC * Description; - - /* - ** Pointer to the clipper object that is attached to the primary - ** surface. - */ - static LPDIRECTDRAWCLIPPER Clipper; - - /* - ** Pixel format of primary surface. - */ - static DDPIXELFORMAT PixelFormat; - - /* - ** Shift values to extract the gun value from a hicolor pixel such that the - ** gun component is normalized to a byte value. - */ - static int RedRight; - static int RedLeft; - static int BlueRight; - static int BlueLeft; - static int GreenRight; - static int GreenLeft; - - public: - /* - ** Shift values specific to this surface (the above are for the primary surface) - */ - int ThisRedRight; - int ThisRedLeft; - int ThisBlueRight; - int ThisBlueLeft; - int ThisGreenRight; - int ThisGreenLeft; - - protected: - static unsigned short HalfbrightMask; - static unsigned short QuarterbrightMask; - static unsigned short EighthbrightMask; - - - /* - ** Number of locks we had to remove in order to get the device context... - */ - int DCUnlockCount; - - private: - /* - ** This prevents the creation of a surface in ways that are not - ** supported. - */ - DSurface(DSurface const & rvalue); - DSurface const operator = (DSurface const & rvalue); -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/fixed.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/fixed.h deleted file mode 100644 index bbdba0b1696..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/fixed.h +++ /dev/null @@ -1,220 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Library/FIXED.H 1 7/22/97 12:00p Greg_h $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * File Name : FIXED.H * - * * - * Programmer : Joe L. Bostic * - * * - * Start Date : 06/19/96 * - * * - * Last Update : June 19, 1996 [JLB] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef FIXED_H -#define FIXED_H - -#include "bool.h" -//#pragma warning 604 9 -//#pragma warning 595 9 - -/* -** This is a very simple fixed point class that functions like a regular integral type. However -** it is under certain restrictions. The whole part must not exceed 255. The fractional part is -** limited to an accuracy of 1/256. It cannot represent or properly handle negative values. It -** really isn't all that fast (if an FPU is guaranteed to be present than using "float" might be -** more efficient). It doesn't detect overflow or underflow in mathematical or bit-shift operations. -** -** Take careful note that the normal mathematical operators return integers and not fixed point -** values if either of the components is an integer. This is the normal C auto-upcasting rule -** as it would apply presuming that integers are considered to be of higher precision than -** fixed point numbers. This allows the result of these operators to generate values with greater -** magnitude than is normally possible if the result were coerced into a fixed point number. -** If the result should be fixed point, then ensure that both parameters are fixed point. -** -** Note that although integers are used as the parameters in the mathematical operators, this -** does not imply that negative parameters are supported. The use of integers is as a convenience -** to the programmer -- constant integers are presumed signed. If unsigned parameters were -** specified, then the compiler would have ambiguous conversion situation in the case of constant -** integers (e.g. 1, 10, 32, etc). This is most important for the constructor when dealing with the -** "0" parameter case. In that situation the compiler might interpret the "0" as a null pointer rather -** than an unsigned integer. There should be no adverse consequences of using signed integer parameters -** since the precision/magnitude of these integers far exceeds the fixed point component counterparts. -** -** Note that when integer values are returns from the arithmetic operators, the value is rounded -** to the nearest whole integer value. This differs from normal integer math that always rounds down. -*/ -class fixed -{ - public: - // The default constructor must not touch the data members in any way. - fixed(void) {} - - // Convenient constructor if numerator and denominator components are known. - fixed(int numerator, int denominator); - - // Conversion constructor to get fixed point from integer. - fixed(int value) {Data.Composite.Fraction = 0;Data.Composite.Whole = (unsigned char)value;} - - // Constructor if ASCII image of number is known. - fixed(char const * ascii); - - // Convert to integer when implicitly required. - operator unsigned (void) const {return(((unsigned)Data.Raw+(256/2)) / 256);} - - /* - ** The standard operators as they apply to in-place operation. - */ - fixed & operator *= (fixed const & rvalue) {Data.Raw = (unsigned short)(((int)Data.Raw * rvalue.Data.Raw) / 256);return(*this);} - fixed & operator *= (int rvalue) {Data.Raw = (unsigned short)(Data.Raw * rvalue);return(*this);} - fixed & operator /= (fixed const & rvalue) {if (rvalue.Data.Raw != 0 && rvalue.Data.Raw != 256) Data.Raw = (unsigned short)(((int)Data.Raw * 256) / rvalue);return(*this);} - fixed & operator /= (int rvalue) {if (rvalue) Data.Raw = (unsigned short)((unsigned)Data.Raw / rvalue);return(*this);} - fixed & operator += (fixed const & rvalue) {Data.Raw += rvalue.Data.Raw;return(*this);} - fixed & operator -= (fixed const & rvalue) {Data.Raw -= rvalue.Data.Raw;return(*this);} - - /* - ** The standard "My Dear Aunt Sally" operators. The integer versions of multiply - ** and divide are more efficient than using the fixed point counterparts. - */ -// const fixed operator * (fixed const & rvalue) const {return(fixed(*this) *= rvalue);} - const fixed operator * (fixed const & rvalue) const {fixed temp = *this;temp.Data.Raw = (unsigned short)(((int)temp.Data.Raw * (int)rvalue.Data.Raw) / 256);return(temp);} - const int operator * (int rvalue) const {return ((((unsigned)Data.Raw * rvalue) + (256/2)) / 256);} -// const fixed operator / (fixed const & rvalue) const {return(fixed(*this) /= rvalue);} - const fixed operator / (fixed const & rvalue) const {fixed temp = *this;if (rvalue.Data.Raw != 0 && rvalue.Data.Raw != 256) temp.Data.Raw = (unsigned short)(((int)temp.Data.Raw * 256) / rvalue.Data.Raw);return(temp);} - const int operator / (int rvalue) const {if (rvalue) return(((unsigned)Data.Raw+(256/2)) / ((unsigned)rvalue*256));return(*this);} -// const fixed operator + (fixed const & rvalue) const {return(fixed(*this) += rvalue);} - const fixed operator + (fixed const & rvalue) const {fixed temp = *this;temp += rvalue;return(temp);} - const int operator + (int rvalue) const {return((((unsigned)Data.Raw+(256/2))/256) + rvalue);} -// const fixed operator - (fixed const & rvalue) const {return(fixed(*this) -= rvalue);} - const fixed operator - (fixed const & rvalue) const {fixed temp = *this;temp -= rvalue;return(temp);} - const int operator - (int rvalue) const {return((((unsigned)Data.Raw+(256/2))/256) - rvalue);} - - /* - ** The Shift operators are more efficient than using multiplies or divides by power-of-2 numbers. - */ - fixed & operator >>= (unsigned rvalue) {Data.Raw >>= rvalue;return(*this);} - fixed & operator <<= (unsigned rvalue) {Data.Raw <<= rvalue;return(*this);} - const fixed operator >> (unsigned rvalue) const {fixed temp = *this;temp >>= rvalue;return(temp);} - const fixed operator << (unsigned rvalue) const {fixed temp = *this;temp <<= rvalue;return(temp);} - - /* - ** The full set of comparison operators. - */ - bool operator == (fixed const & rvalue) const {return(Data.Raw == rvalue.Data.Raw);} - bool operator != (fixed const & rvalue) const {return(Data.Raw != rvalue.Data.Raw);} - bool operator < (fixed const & rvalue) const {return(Data.Raw < rvalue.Data.Raw);} - bool operator > (fixed const & rvalue) const {return(Data.Raw > rvalue.Data.Raw);} - bool operator <= (fixed const & rvalue) const {return(Data.Raw <= rvalue.Data.Raw);} - bool operator >= (fixed const & rvalue) const {return(Data.Raw >= rvalue.Data.Raw);} - bool operator ! (void) const {return(Data.Raw == 0);} - - /* - ** Comparison to integers requires consideration of fractional component. - */ - bool operator < (int rvalue) const {return(Data.Raw < (rvalue*256));} - bool operator > (int rvalue) const {return(Data.Raw > (rvalue*256));} - bool operator <= (int rvalue) const {return(Data.Raw <= (rvalue*256));} - bool operator >= (int rvalue) const {return(Data.Raw >= (rvalue*256));} - bool operator == (int rvalue) const {return(Data.Raw == (rvalue*256));} - bool operator != (int rvalue) const {return(Data.Raw != (rvalue*256));} - - /* - ** Friend functions to handle the alternate positioning of fixed and integer parameters. - */ - friend const int operator * (int lvalue, fixed const & rvalue) {return(rvalue * lvalue);} - friend const int operator / (int lvalue, fixed const & rvalue) {if (rvalue.Data.Raw == 0 || rvalue.Data.Raw == 256) return (lvalue); return(((unsigned)(lvalue * 256)+(256/2)) / rvalue.Data.Raw);} - friend const int operator + (int lvalue, fixed const & rvalue) {return(rvalue + lvalue);} - friend const int operator - (int lvalue, fixed const & rvalue) {return((((lvalue*256) - rvalue.Data.Raw) + (256/2)) / 256);} - friend bool operator < (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) < rvalue.Data.Raw);} - friend bool operator > (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) > rvalue.Data.Raw);} - friend bool operator <= (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) <= rvalue.Data.Raw);} - friend bool operator >= (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) >= rvalue.Data.Raw);} - friend bool operator == (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) == rvalue.Data.Raw);} - friend bool operator != (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) != rvalue.Data.Raw);} - friend int operator *= (int & lvalue, fixed const & rvalue) {lvalue = lvalue * rvalue;return(lvalue);} - friend int operator /= (int & lvalue, fixed const & rvalue) {lvalue = lvalue / rvalue;return(lvalue);} - friend int operator += (int & lvalue, fixed const & rvalue) {lvalue = lvalue + rvalue;return(lvalue);} - friend int operator -= (int & lvalue, fixed const & rvalue) {lvalue = lvalue - rvalue;return(lvalue);} - - /* - ** Helper functions to handle simple and common operations on fixed point numbers. - */ - void Round_Up(void) {Data.Raw += (unsigned short)(256-1);Data.Composite.Fraction = 0;} - void Round_Down(void) {Data.Composite.Fraction = 0;} - void Round(void) {if (Data.Composite.Fraction >= 256/2) Round_Up();Round_Down();} - void Saturate(unsigned capvalue) {if (Data.Raw > (capvalue*256)) Data.Raw = (unsigned short)(capvalue*256);} - void Saturate(fixed const & capvalue) {if (*this > capvalue) *this = capvalue;} - void Sub_Saturate(unsigned capvalue) {if (Data.Raw >= (capvalue*256)) Data.Raw = (unsigned short)((capvalue*256)-1);} - void Sub_Saturate(fixed const & capvalue) {if (*this >= capvalue) Data.Raw = (unsigned short)(capvalue.Data.Raw-1);} - void Inverse(void) {*this = fixed(1) / *this;} - - /* - ** Friend helper functions that work in the typical C fashion of passing the object to - ** be processed as a parameter to the function. - */ - friend const fixed Round_Up(fixed const & value) {fixed temp = value; temp.Round_Up();return(temp);} - friend const fixed Round_Down(fixed const & value) {fixed temp = value; temp.Round_Down();return(temp);} - friend const fixed Round(fixed const & value) {fixed temp = value; temp.Round();return(temp);} - friend const fixed Saturate(fixed const & value, unsigned capvalue) {fixed temp = value;temp.Saturate(capvalue);return(temp);} - friend const fixed Saturate(fixed const & value, fixed const & capvalue) {fixed temp = value;temp.Saturate(capvalue);return(temp);} - friend const fixed Sub_Saturate(fixed const & value, unsigned capvalue) {fixed temp = value;temp.Sub_Saturate(capvalue);return(temp);} - friend const fixed Sub_Saturate(fixed const & value, fixed const & capvalue) {fixed temp = value;temp.Sub_Saturate(capvalue);return(temp);} - friend const fixed Inverse(fixed const & value) {fixed temp = value;temp.Inverse();return(temp);} - - /* - ** Conversion of the fixed point number into an ASCII string. - */ - int To_ASCII(char * buffer, int maxlen=-1) const; - char const * As_ASCII(void) const; - - /* - ** Helper constants that provide some convenient fixed point values. - */ - static const fixed _1_2; - static const fixed _1_3; - static const fixed _1_4; - static const fixed _3_4; - static const fixed _2_3; - - private: - union { - struct { -#ifdef BIG_ENDIAN - unsigned char Whole; - unsigned char Fraction; -#else - unsigned char Fraction; - unsigned char Whole; -#endif - } Composite; - unsigned short Raw; - } Data; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp deleted file mode 100644 index 7f72c9d28fe..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "hsv.h" -#include "RGB.H" - -HSVClass const HSVClass::BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * * - * This routine will adjust the HSV color object toward the color of the specified HSV * - * object. Typical users of this would be palette morphing or fading routines. * - * * - * INPUT: ratio -- The ratio to move the HSV object toward the color specified. A value * - * of zero means no movement at all. A value of 255 means move completely * - * toward the specified color (changed completely). * - * * - * hsv -- A reference to the color that the current HSV object is to change * - * toward. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -void HSVClass::Adjust(int ratio, HSVClass const & hsv) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = hsv.Get_Value() - Get_Value(); - Value = (unsigned char)(Get_Value() + (value * ratio) / 256); - - int saturation = hsv.Get_Saturation() - Get_Saturation(); - Saturation = (unsigned char)(Get_Saturation() + (saturation * ratio) / 256); - - int hue = hsv.Get_Hue() - Get_Hue(); - Hue = (unsigned char)(Get_Hue() + (hue * ratio) / 256); -} - - -/*********************************************************************************************** - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * * - * This routine will determine a color difference between two HSV objects. The difference * - * has no particular meaning other that larger numbers meaning greater difference. * - * * - * INPUT: hsv -- The other HSV object to compare this HSV object to. * - * * - * OUTPUT: Returns with a relative distance (in arbitrary units) between this HSV object and * - * the HSV object supplied. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -int HSVClass::Difference(HSVClass const & hsv) const -{ - int hue = (int)Hue - (int)hsv.Hue; - if (hue < 0) hue = -hue; - - int saturation = (int)Saturation - (int)hsv.Saturation; - if (saturation < 0) saturation = -saturation; - - int value = (int)Value - (int)hsv.Value; - if (value < 0) value = -value; - - return(hue*hue + saturation*saturation + value*value); -} - - -/*********************************************************************************************** - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * * - * This conversion operator will convert the HSV object into an RGB object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implied) of the RGBClass object that most closely * - * matches this HSVClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -HSVClass::operator RGBClass (void) const -{ - unsigned int i; // Integer part. - unsigned int f; // Fractional or remainder part. f/HSV_BASE gives fraction. - unsigned int tmp; // Temporary variable to help with calculations. - unsigned int values[7]; // Possible rgb values. Don't use zero. - - int hue = Get_Hue(); - int saturation = Get_Saturation(); - int value = Get_Value(); - int red, green, blue; - - - hue *= 6; - f = hue % 255; - - // Set up possible red, green and blue values. - values[1] = - values[2] = value; - - // - // The following lines of code change - // values[3] = (v * (255 - ( (s * f) / 255) )) / 255; - // values[4] = values[5] = (v * (255 - s)) / 255; - // values[6] = (v * (255 - (s * (255 - f)) / 255)) / 255; - // so that the are rounded divides. - // - - tmp = (saturation * f) / 255; - values[3] = (value * (255 - tmp)) / 255; - - values[4] = - values[5] = (value * (255 - saturation)) / 255; - - tmp = 255 - (saturation * (255 - f)) / 255; - values[6] = (value * tmp) / 255; - - - // This should not be rounded. - i = hue / 255; - - i += (i > 4) ? -4 : 2; - red = values[i]; - - i += (i > 4) ? -4 : 2; - blue = values[i]; - - i += (i > 4) ? -4 : 2; - green = values[i]; - - RGBClass rgb((unsigned char)red, (unsigned char)green, (unsigned char)blue); - return(rgb); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.h deleted file mode 100644 index ed57918d334..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/hsv.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef HSV_H -#define HSV_H - -class RGBClass; -class HSVClass; - -/* -** Each color entry is represented by this class. It holds the values for the color -** attributes. The values are recorded in a range from 0 to 255 with 255 being the -** maximum. -*/ -class HSVClass -{ - private: - static HSVClass const BlackColor; - - public: - HSVClass(void) : Hue(0), Saturation(0), Value(0) {}; - HSVClass(unsigned char hue, unsigned char saturation, unsigned char value) : - Hue(hue), - Saturation(saturation), - Value(value) - {}; - operator RGBClass (void) const; - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, HSVClass const & hsv); - int Difference(HSVClass const & hsv) const; - int Get_Hue(void) const {return(Hue);}; - int Get_Saturation(void) const {return(Saturation);}; - int Get_Value(void) const {return(Value);}; - void Set_Hue(unsigned char value) {Hue = value;} - void Set_Saturation(unsigned char value) {Saturation = value;} - void Set_Value(unsigned char value) {Value = value;} - - private: - unsigned char Hue; - unsigned char Saturation; - unsigned char Value; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/ini.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/ini.cpp index 76593fd855e..f557e0590ab 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -94,7 +94,6 @@ #include "inisup.h" #include "trect.h" #include "WWFILE.H" -#include "PK.H" #include "PIPE.H" #include "wwstring.h" @@ -1923,80 +1922,6 @@ INIEntry * INISection::Find_Entry(char const * entry) const } -/*********************************************************************************************** - * INIClass::Put_PKey -- Stores the key to the INI database. * - * * - * The key stored to the database will have both the exponent and modulus portions saved. * - * Since the fast key only requires the modulus, it is only necessary to save the slow * - * key to the database. However, storing the slow key stores the information necessary to * - * generate the fast and slow keys. Because public key encryption requires one key to be * - * completely secure, only store the fast key in situations where the INI database will * - * be made public. * - * * - * INPUT: key -- The key to store the INI database. * - * * - * OUTPUT: bool; Was the key stored to the database? * - * * - * WARNINGS: Store the fast key for public INI database availability. Store the slow key if * - * the INI database is secure. * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -bool INIClass::Put_PKey(PKey const & key) -{ - char buffer[512]; - - int len = key.Encode_Modulus(buffer); - Put_UUBlock("PublicKey", buffer, len); - - len = key.Encode_Exponent(buffer); - Put_UUBlock("PrivateKey", buffer, len); - return(true); -} - - -/*********************************************************************************************** - * INIClass::Get_PKey -- Fetch a key from the ini database. * - * * - * This routine will fetch the key from the INI database. The key fetched is controlled by * - * the parameter. There are two choices of key -- the fast or slow key. * - * * - * INPUT: fast -- Should the fast key be retrieved? The fast key has the advantage of * - * requiring only the modulus value. * - * * - * OUTPUT: Returns with the key retrieved. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -PKey INIClass::Get_PKey(bool fast) const -{ - PKey key; - char buffer[512]; - - /* - ** When retrieving the fast key, the exponent is a known constant. Don't parse the - ** exponent from the database. - */ - if (fast) { - BigInt exp = PKey::Fast_Exponent(); - exp.DEREncode((unsigned char *)buffer); - key.Decode_Exponent(buffer); - } else { - Get_UUBlock("PrivateKey", buffer, sizeof(buffer)); - key.Decode_Exponent(buffer); - } - - Get_UUBlock("PublicKey", buffer, sizeof(buffer)); - key.Decode_Modulus(buffer); - - return(key); -} - - /*********************************************************************************************** * INIClass::Strip_Comments -- Strips comments of the specified text line. * * * diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/int.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/int.cpp deleted file mode 100644 index a7ae62cc88c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/int.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/INT.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "INT.H" -#include "MPMATH.H" -#include "rng.h" - -int bignum::Error = 0; -bool bignum::Carry = false; -bool bignum::Borrow = false; -bignum bignum::Remainder; - - - -//BigInt Gcd(const BigInt & a, const BigInt & n); -#ifdef _MSC_VER -BigInt Generate_Prime(RandomNumberGenerator & rng, int pbits, BigInt const * dummy); -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp deleted file mode 100644 index 0fd047ef126..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp +++ /dev/null @@ -1,773 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/KEYBOARD.CPP $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/15/99 10:15a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * - * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * - * WWKeyboardClass::Clear -- Clears the keyboard buffer. * - * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * - * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * - * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages* - * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * - * WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels * - * WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars * - * WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels * - * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * - * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * - * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * - * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboar* - * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * - * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * - * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * - * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * - * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * - * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keybo* - * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_xmouse.h" -#include "keyboard.h" -//#include "mono.h" -#include "msgloop.h" - - -#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0])) - -void Stop_Execution (void) -{ -// __asm nop // Is this line needed? -} - - -/*********************************************************************************************** - * WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -WWKeyboardClass::WWKeyboardClass(void) : - MouseQX(0), - MouseQY(0), - Head(0), - Tail(0) -{ - memset(KeyState, '\0', sizeof(KeyState)); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * - * * - * INPUT: none * - * * - * OUTPUT: int - the key value that was pulled from buffer (includes bits) * * - * * - * WARNINGS: If the key was a mouse event MouseQX and MouseQY will be updated * - * * - * HISTORY: * - * 10/17/1995 PWG : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Buff_Get(void) -{ - while (!Check()) {} // wait for key in buffer - - unsigned short temp = Fetch_Element(); - if (Is_Mouse_Key(temp)) { - MouseQX = Fetch_Element(); - MouseQY = Fetch_Element(); - } - return(temp); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * - * * - * This checks the specified key code to see if it refers to the mouse buttons. * - * * - * INPUT: key -- The key to check. * - * * - * OUTPUT: bool; Is the key a mouse button key? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Mouse_Key(unsigned short key) -{ - key &= 0xFF; - return (key == VK_LBUTTON || key == VK_MBUTTON || key == VK_RBUTTON); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - * 09/24/1996 JLB : Converted to new style keyboard system. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Check(void) const -{ - ((WWKeyboardClass *)this)->Fill_Buffer_From_System(); - if (Is_Buffer_Empty()) return(false); - return(Peek_Element()); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * - * * - * INPUT: none * - * * - * OUTPUT: int - the meta key taken from the buffer. * - * * - * WARNINGS: This routine will not return until a keypress is received * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Get(void) -{ - while (!Check()) {} // wait for key in buffer - return (Buff_Get()); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * - * * - * INPUT: int - the key to insert into the buffer * - * * - * OUTPUT: bool - true if key is sucessfuly inserted. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put(unsigned short key) -{ - if (!Is_Buffer_Full()) { - Put_Element(key); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Key_Message(unsigned short vk_key, bool release) -{ - /* - ** Get the status of all of the different keyboard modifiers. Note, only pay attention - ** to numlock and caps lock if we are dealing with a key that is affected by them. Note - ** that we do not want to set the shift, ctrl and alt bits for Mouse keypresses as this - ** would be incompatible with the dos version. - */ - if (!Is_Mouse_Key(vk_key)) { - if (((GetKeyState(VK_SHIFT) & 0x8000) != 0) || - ((GetKeyState(VK_CAPITAL) & 0x0008) != 0) || - ((GetKeyState(VK_NUMLOCK) & 0x0008) != 0)) { - - vk_key |= WWKEY_SHIFT_BIT; - } - if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) { - vk_key |= WWKEY_CTRL_BIT; - } - if ((GetKeyState(VK_MENU) & 0x8000) != 0) { - vk_key |= WWKEY_ALT_BIT; - } - } - - if (release) { - vk_key |= WWKEY_RLS_BIT; - } - - /* - ** Finally use the put command to enter the key into the keyboard - ** system. - */ - return(Put(vk_key)); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer. * - * * - * This routine will store the mouse type event into the keyboard buffer. It also checks * - * to ensure that there is enough room in the buffer so that partial mouse events won't * - * be recorded. * - * * - * INPUT: vk_key -- The mouse key message itself. * - * * - * x,y -- The mouse coordinates at the time of the event. * - * * - * release -- Is this a mouse button release? * - * * - * OUTPUT: bool; Was the event stored sucessfully into the keyboard buffer? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/02/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release) -{ - if (Available_Buffer_Room() >= 3 && Is_Mouse_Key(vk_key)) { - Put_Key_Message(vk_key, release); - Put((unsigned short)x); - Put((unsigned short)y); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * - * * - * This routine will convert the key code specified into an ASCII value. This takes into * - * consideration the language and keyboard mapping of the host Windows system. * - * * - * INPUT: key -- The key code to convert into ASCII. * - * * - * OUTPUT: Returns with the key converted into ASCII. If the key has no ASCII equivalent, * - * then '\0' is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -char WWKeyboardClass::To_ASCII(unsigned short key) -{ - /* - ** Released keys never translate into an ASCII value. - */ - if (key & WWKEY_RLS_BIT) { - return('\0'); - } - - /* - ** Set the KeyState buffer to reflect the shift bits stored in the key value. - */ - if (key & WWKEY_SHIFT_BIT) { - KeyState[VK_SHIFT] = 0x80; - } - if (key & WWKEY_CTRL_BIT) { - KeyState[VK_CONTROL] = 0x80; - } - if (key & WWKEY_ALT_BIT) { - KeyState[VK_MENU] = 0x80; - } - - /* - ** Ask windows to translate the key into an ASCII equivalent. - */ - char buffer[10]; - int result; -// int result = 1; - int scancode; -// int scancode = 0; - - scancode = MapVirtualKey(key & 0xFF, 0); - result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); - - /* - ** Restore the KeyState buffer back to pristine condition. - */ - if (key & WWKEY_SHIFT_BIT) { - KeyState[VK_SHIFT] = 0; - } - if (key & WWKEY_CTRL_BIT) { - KeyState[VK_CONTROL] = 0; - } - if (key & WWKEY_ALT_BIT) { - KeyState[VK_MENU] = 0; - } - - /* - ** If Windows could not perform the translation as expected, then - ** return with a null ASCII value. - */ - if (result != 1) { - return('\0'); - } - - return(buffer[0]); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * - * * - * This routine will examine the key specified to see if it is currently being held down. * - * * - * INPUT: key -- The key to check. * - * * - * OUTPUT: bool; Is the specified key currently being held down? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Down(unsigned short key) -{ - return(GetAsyncKeyState(key & 0xFF) != 0); -} - - -//extern "C" { -// void __cdecl Stop_Execution (void); -//} - - -/*********************************************************************************************** - * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * - * * - * This routine will extract the next pending element in the keyboard queue. If there is * - * no element available, then NULL is returned. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the element extracted from the queue. An empty queue is signified * - * by a 0 return value. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Fetch_Element(void) -{ - unsigned short val = 0; - if (Head != Tail) { - val = Buffer[Head]; - - Head = (Head + 1) % ARRAY_SIZE(Buffer); - } - return(val); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * - * * - * This routine will examine and return with the next element in the keyboard buffer but * - * it will not alter or remove that element. Use this routine to see what is pending in * - * the keyboard queue. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the next element in the keyboard queue. If the keyboard buffer is * - * empty, then 0 is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Peek_Element(void) const -{ - if (!Is_Buffer_Empty()) { - return(Buffer[Head]); - } - return(0); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * - * * - * This will put one keyboard data element into the keyboard buffer. Typically, this data * - * is a key code, but it might be mouse coordinates. * - * * - * INPUT: val -- The data element to add to the keyboard buffer. * - * * - * OUTPUT: bool; Was the keyboard element added successfully? A failure would indicate that * - * the keyboard buffer is full. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Element(unsigned short val) -{ - if (!Is_Buffer_Full()) { - int temp = (Tail+1) % ARRAY_SIZE(Buffer); - Buffer[Tail] = val; - Tail = temp; - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * - * * - * This routine will examine the keyboard buffer to determine if it is completely * - * full of queued keyboard events. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the keyboard buffer completely full? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Buffer_Full(void) const -{ - if ((Tail + 1) % ARRAY_SIZE(Buffer) == Head) { - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * - * * - * This routine will examine the keyboard buffer to see if it contains no events at all. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the keyboard buffer currently without any pending events queued? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Buffer_Empty(void) const -{ - if (Head == Tail) { - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages. * - * * - * This routine will extract and process any windows messages in the windows message * - * queue. It is presumed that the normal message handler will call the keyboard * - * message processing function. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -void WWKeyboardClass::Fill_Buffer_From_System(void) -{ - if (!Is_Buffer_Full()) { - Windows_Message_Handler(); -// MSG msg; -// while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { -// if (!GetMessage( &msg, NULL, 0, 0 )) { -// return; -// } -// TranslateMessage(&msg); -// DispatchMessage(&msg); -// } - } -} - - -/*********************************************************************************************** - * WWKeyboardClass::Clear -- Clears the keyboard buffer. * - * * - * This routine will clear the keyboard buffer of all pending keyboard events. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -void WWKeyboardClass::Clear(void) -{ - /* - ** Extract any windows pending keyboard message events and then clear out the keyboard - ** buffer. - */ - Fill_Buffer_From_System(); - Head = Tail; - - /* - ** Perform a second clear to handle the rare case of the keyboard buffer being full and there - ** still remains keyboard related events in the windows message queue. - */ - Fill_Buffer_From_System(); - Head = Tail; -} - - -/*********************************************************************************************** - * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboard * - * * - * This routine will examine the Windows message specified. If the message relates to an * - * event that the keyboard input system needs to process, then it will be processed * - * accordingly. * - * * - * INPUT: window -- Handle to the window receiving the message. * - * * - * message -- The message number of this event. * - * * - * wParam -- The windows specific word parameter (meaning depends on message). * - * * - * lParam -- The windows specific long word parameter (meaning is message dependant)* - * * - * OUTPUT: bool; Was this keyboard message recognized and processed? A 'false' return value * - * means that the message should be processed normally. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LONG lParam) -{ - bool processed = false; - - POINT point; - point.x = LOWORD(lParam); - point.y = HIWORD(lParam); - ClientToScreen(window, &point); - int x = point.x; - int y = point.y; - - // Special conversion to game coordinates is needed here. - if (MouseCursor != NULL) MouseCursor->Convert_Coordinate(x, y); - - /* - ** Examine the message to see if it is one that should be processed. Only keyboard and - ** pertinant mouse messages are processed. - */ - switch (message) { - - /* - ** System key has been pressed. This is the normal keyboard event message. - */ - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - if (wParam == VK_SCROLL) { - Stop_Execution(); - } else { - Put_Key_Message((unsigned short)wParam); - } - processed = true; - break; - - /* - ** The key has been released. This is the normal key release message. - */ - case WM_SYSKEYUP: - case WM_KEYUP: - Put_Key_Message((unsigned short)wParam, true); - processed = true; - break; - - /* - ** Press of the left mouse button. - */ - case WM_LBUTTONDOWN: - Put_Mouse_Message(VK_LBUTTON, x, y); - processed = true; - break; - - /* - ** Release of the left mouse button. - */ - case WM_LBUTTONUP: - Put_Mouse_Message(VK_LBUTTON, x, y, true); - processed = true; - break; - - /* - ** Double click of the left mouse button. Fake this into being - ** just a rapid click of the left button twice. - */ - case WM_LBUTTONDBLCLK: - Put_Mouse_Message(VK_LBUTTON, x, y); - Put_Mouse_Message(VK_LBUTTON, x, y, true); - Put_Mouse_Message(VK_LBUTTON, x, y); - Put_Mouse_Message(VK_LBUTTON, x, y, true); - processed = true; - break; - - /* - ** Press of the middle mouse button. - */ - case WM_MBUTTONDOWN: - Put_Mouse_Message(VK_MBUTTON, x, y); - processed = true; - break; - - /* - ** Release of the middle mouse button. - */ - case WM_MBUTTONUP: - Put_Mouse_Message(VK_MBUTTON, x, y, true); - processed = true; - break; - - /* - ** Middle button double click gets translated into two - ** regular middle button clicks. - */ - case WM_MBUTTONDBLCLK: - Put_Mouse_Message(VK_MBUTTON, x, y); - Put_Mouse_Message(VK_MBUTTON, x, y, true); - Put_Mouse_Message(VK_MBUTTON, x, y); - Put_Mouse_Message(VK_MBUTTON, x, y, true); - processed = true; - break; - - /* - ** Right mouse button press. - */ - case WM_RBUTTONDOWN: - Put_Mouse_Message(VK_RBUTTON, x, y); - processed = true; - break; - - /* - ** Right mouse button release. - */ - case WM_RBUTTONUP: - Put_Mouse_Message(VK_RBUTTON, x, y, true); - processed = true; - break; - - /* - ** Translate a double click of the right button - ** into being just two regular right button clicks. - */ - case WM_RBUTTONDBLCLK: - Put_Mouse_Message(VK_RBUTTON, x, y); - Put_Mouse_Message(VK_RBUTTON, x, y, true); - Put_Mouse_Message(VK_RBUTTON, x, y); - Put_Mouse_Message(VK_RBUTTON, x, y, true); - processed = true; - break; - - /* - ** If the message is not pertinant to the keyboard system, - ** then do nothing. - */ - default: - break; - } - - /* - ** If this message has been processed, then pass it on to the system - ** directly. - */ - if (processed) { - DefWindowProc(window, message, wParam, lParam); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keyboa * - * * - * This examines the keyboard buffer queue and determine how many elements are available * - * for use before the buffer becomes full. Typical use of this would be when inserting * - * mouse events that require more than one element. Such an event must detect when there * - * would be insufficient room in the buffer and bail accordingly. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of elements that may be stored in to the keyboard buffer * - * before it becomes full and cannot accept any more elements. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/02/1996 JLB : Created. * - *=============================================================================================*/ -int WWKeyboardClass::Available_Buffer_Room(void) const -{ - int avail = 0; - if (Head == Tail) { - avail = ARRAY_SIZE(Buffer); - } - if (Head < Tail) { - avail = Tail - Head; - } - if (Head > Tail) { - avail = (Tail + ARRAY_SIZE(Buffer)) - Head; - } - return(avail); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.h deleted file mode 100644 index a764b6e1207..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/keyboard.h +++ /dev/null @@ -1,677 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/keyboard.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 9:03p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef KEY_H -#define KEY_H - - -#include "_xmouse.h" -#include "win.h" - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - - -typedef enum { - WWKEY_SHIFT_BIT = 0x100, - WWKEY_CTRL_BIT = 0x200, - WWKEY_ALT_BIT = 0x400, - WWKEY_RLS_BIT = 0x800, - WWKEY_VK_BIT = 0x1000, - WWKEY_DBL_BIT = 0x2000, - WWKEY_BTN_BIT = 0x8000 -} WWKey_Type; - - -class WWKeyboardClass -{ - public: - /* Define the base constructor and destructors for the class */ - WWKeyboardClass(); - - /* Define the functions which work with the Keyboard Class */ - unsigned short Check(void) const; - unsigned short Get(void); - bool Put(unsigned short key); - void Clear(void); - char To_ASCII(unsigned short num); - bool Down(unsigned short key); - - /* Define the main hook for the message processing loop. */ - bool Message_Handler(HWND hwnd, UINT message, UINT wParam, LONG lParam); - - /* Define the public access variables which are used with the */ - /* Keyboard Class. */ - int MouseQX; - int MouseQY; - - private: - - /* - ** This is a keyboard state array that is used to aid in translating - ** KN_ keys into KA_ keys. - */ - unsigned char KeyState[256]; - - /* - ** This is the circular keyboard holding buffer. It holds the VK key and - ** the current shift state at the time the key was added to the queue. - */ - unsigned short Buffer[256]; // buffer which holds actual keypresses - - unsigned short Buff_Get(void); - unsigned short Fetch_Element(void); - unsigned short Peek_Element(void) const; - bool Put_Element(unsigned short val); - bool Is_Buffer_Full(void) const; - bool Is_Buffer_Empty(void) const; - static bool Is_Mouse_Key(unsigned short key); - void Fill_Buffer_From_System(void); - bool Put_Key_Message(unsigned short vk_key, bool release = false); - bool Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release = false); - int Available_Buffer_Room(void) const; - - /* - ** These are the tracking pointers to maintain the - ** circular keyboard list. - */ - int Head; - int Tail; -}; - - - -#define VK_NONE 0x00 -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_CANCEL 0x03 -#define VK_MBUTTON 0x04 -#define VK_NONE_05 0x05 -#define VK_NONE_06 0x06 -#define VK_NONE_07 0x07 -#define VK_BACK 0x08 -#define VK_TAB 0x09 -#define VK_NONE_0A 0x0A -#define VK_NONE_0B 0x0B -#define VK_CLEAR 0x0C -#define VK_RETURN 0x0D -#define VK_NONE_0E 0x0E -#define VK_NONE_0F 0x0F -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 -#define VK_NONE_15 0x15 -#define VK_NONE_16 0x16 -#define VK_NONE_17 0x17 -#define VK_NONE_18 0x18 -#define VK_NONE_19 0x19 -#define VK_NONE_1A 0x1A -#define VK_ESCAPE 0x1B -#define VK_NONE_1C 0x1C -#define VK_NONE_1D 0x1D -#define VK_NONE_1E 0x1E -#define VK_NONE_1F 0x1F -#define VK_SPACE 0x20 -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SELECT 0x29 -#define VK_PRINT 0x2A -#define VK_EXECUTE 0x2B -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E -#define VK_HELP 0x2F -#define VK_0 0x30 -#define VK_1 0x31 -#define VK_2 0x32 -#define VK_3 0x33 -#define VK_4 0x34 -#define VK_5 0x35 -#define VK_6 0x36 -#define VK_7 0x37 -#define VK_8 0x38 -#define VK_9 0x39 -#define VK_NONE_3B 0x3B -#define VK_NONE_3C 0x3C -#define VK_NONE_3D 0x3D -#define VK_NONE_3E 0x3E -#define VK_NONE_3F 0x3F -#define VK_NONE_40 0x40 -#define VK_A 0x41 -#define VK_B 0x42 -#define VK_C 0x43 -#define VK_D 0x44 -#define VK_E 0x45 -#define VK_F 0x46 -#define VK_G 0x47 -#define VK_H 0x48 -#define VK_I 0x49 -#define VK_J 0x4A -#define VK_K 0x4B -#define VK_L 0x4C -#define VK_M 0x4D -#define VK_N 0x4E -#define VK_O 0x4F -#define VK_P 0x50 -#define VK_Q 0x51 -#define VK_R 0x52 -#define VK_S 0x53 -#define VK_T 0x54 -#define VK_U 0x55 -#define VK_V 0x56 -#define VK_W 0x57 -#define VK_X 0x58 -#define VK_Y 0x59 -#define VK_Z 0x5A -#define VK_NONE_5B 0x5B -#define VK_NONE_5C 0x5C -#define VK_NONE_5D 0x5D -#define VK_NONE_5E 0x5E -#define VK_NONE_5F 0x5F -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 -#define VK_MULTIPLY 0x6A -#define VK_ADD 0x6B -#define VK_SEPARATOR 0x6C -#define VK_SUBTRACT 0x6D -#define VK_DECIMAL 0x6E -#define VK_DIVIDE 0x6F -#define VK_F1 0x70 -#define VK_F2 0x71 -#define VK_F3 0x72 -#define VK_F4 0x73 -#define VK_F5 0x74 -#define VK_F6 0x75 -#define VK_F7 0x76 -#define VK_F8 0x77 -#define VK_F9 0x78 -#define VK_F10 0x79 -#define VK_F11 0x7A -#define VK_F12 0x7B -#define VK_F13 0x7C -#define VK_F14 0x7D -#define VK_F15 0x7E -#define VK_F16 0x7F -#define VK_F17 0x80 -#define VK_F18 0x81 -#define VK_F19 0x82 -#define VK_F20 0x83 -#define VK_F21 0x84 -#define VK_F22 0x85 -#define VK_F23 0x86 -#define VK_F24 0x87 -#define VK_NONE_88 0x88 -#define VK_NONE_89 0x89 -#define VK_NONE_8A 0x8A -#define VK_NONE_8B 0x8B -#define VK_NONE_8C 0x8C -#define VK_NONE_8D 0x8D -#define VK_NONE_8E 0x8E -#define VK_NONE_8F 0x8F -#define VK_NUMLOCK 0x90 -#define VK_SCROLL 0x91 -#define VK_NONE_92 0x92 -#define VK_NONE_93 0x93 -#define VK_NONE_94 0x94 -#define VK_NONE_95 0x95 -#define VK_NONE_96 0x96 -#define VK_NONE_97 0x97 -#define VK_NONE_98 0x98 -#define VK_NONE_99 0x99 -#define VK_NONE_9A 0x9A -#define VK_NONE_9B 0x9B -#define VK_NONE_9C 0x9C -#define VK_NONE_9D 0x9D -#define VK_NONE_9E 0x9E -#define VK_NONE_9F 0x9F -#define VK_NONE_A0 0xA0 -#define VK_NONE_A1 0xA1 -#define VK_NONE_A2 0xA2 -#define VK_NONE_A3 0xA3 -#define VK_NONE_A4 0xA4 -#define VK_NONE_A5 0xA5 -#define VK_NONE_A6 0xA6 -#define VK_NONE_A7 0xA7 -#define VK_NONE_A8 0xA8 -#define VK_NONE_A9 0xA9 -#define VK_NONE_AA 0xAA -#define VK_NONE_AB 0xAB -#define VK_NONE_AC 0xAC -#define VK_NONE_AD 0xAD -#define VK_NONE_AE 0xAE -#define VK_NONE_AF 0xAF -#define VK_NONE_B0 0xB0 -#define VK_NONE_B1 0xB1 -#define VK_NONE_B2 0xB2 -#define VK_NONE_B3 0xB3 -#define VK_NONE_B4 0xB4 -#define VK_NONE_B5 0xB5 -#define VK_NONE_B6 0xB6 -#define VK_NONE_B7 0xB7 -#define VK_NONE_B8 0xB8 -#define VK_NONE_B9 0xB9 -#define VK_NONE_BA 0xBA // ; -#define VK_NONE_BB 0xBB // = -#define VK_NONE_BC 0xBC // , -#define VK_NONE_BD 0xBD // - -#define VK_NONE_BE 0xBE // . -#define VK_NONE_BF 0xBF // / -#define VK_NONE_C0 0xC0 // ` -#define VK_NONE_C1 0xC1 -#define VK_NONE_C2 0xC2 -#define VK_NONE_C3 0xC3 -#define VK_NONE_C4 0xC4 -#define VK_NONE_C5 0xC5 -#define VK_NONE_C6 0xC6 -#define VK_NONE_C7 0xC7 -#define VK_NONE_C8 0xC8 -#define VK_NONE_C9 0xC9 -#define VK_NONE_CA 0xCA -#define VK_NONE_CB 0xCB -#define VK_NONE_CC 0xCC -#define VK_NONE_CD 0xCD -#define VK_NONE_CE 0xCE -#define VK_NONE_CF 0xCF -#define VK_NONE_D0 0xD0 -#define VK_NONE_D1 0xD1 -#define VK_NONE_D2 0xD2 -#define VK_NONE_D3 0xD3 -#define VK_NONE_D4 0xD4 -#define VK_NONE_D5 0xD5 -#define VK_NONE_D6 0xD6 -#define VK_NONE_D7 0xD7 -#define VK_NONE_D8 0xD8 -#define VK_NONE_D9 0xD9 -#define VK_NONE_DA 0xDA -#define VK_NONE_DB 0xDB // [ -#define VK_NONE_DC 0xDC // '\' -#define VK_NONE_DD 0xDD // ] -#define VK_NONE_DE 0xDE // ' -#define VK_NONE_DF 0xDF -#define VK_NONE_E0 0xE0 -#define VK_NONE_E1 0xE1 -#define VK_NONE_E2 0xE2 -#define VK_NONE_E3 0xE3 -#define VK_NONE_E4 0xE4 -#define VK_NONE_E5 0xE5 -#define VK_NONE_E6 0xE6 -#define VK_NONE_E7 0xE7 -#define VK_NONE_E8 0xE8 -#define VK_NONE_E9 0xE9 -#define VK_NONE_EA 0xEA -#define VK_NONE_EB 0xEB -#define VK_NONE_EC 0xEC -#define VK_NONE_ED 0xED -#define VK_NONE_EE 0xEE -#define VK_NONE_EF 0xEF -#define VK_NONE_F0 0xF0 -#define VK_NONE_F1 0xF1 -#define VK_NONE_F2 0xF2 -#define VK_NONE_F3 0xF3 -#define VK_NONE_F4 0xF4 -#define VK_NONE_F5 0xF5 -#define VK_NONE_F6 0xF6 -#define VK_NONE_F7 0xF7 -#define VK_NONE_F8 0xF8 -#define VK_NONE_F9 0xF9 -#define VK_NONE_FA 0xFA -#define VK_NONE_FB 0xFB -#define VK_NONE_FC 0xFC -#define VK_NONE_FD 0xFD -#define VK_NONE_FE 0xFE -#define VK_NONE_FF 0xFF - -#define VK_UPLEFT VK_HOME -#define VK_UPRIGHT VK_PRIOR -#define VK_DOWNLEFT VK_END -#define VK_DOWNRIGHT VK_NEXT -#define VK_ALT VK_MENU - -typedef enum KeyASCIIType { - // - // Define all the KA types as variations of the VK types. This is - // so the KA functions will work properly under windows 95. - // - KA_NONE = 0, - KA_MORE = 1, - KA_SETBKGDCOL = 2, - KA_SETFORECOL = 6, - KA_FORMFEED = 12, - KA_SPCTAB = 20, - KA_SETX = 25, - KA_SETY = 26, - - KA_SPACE = 32, /* */ - KA_EXCLAMATION, /* ! */ - KA_DQUOTE, /* " */ - KA_POUND, /* # */ - KA_DOLLAR, /* $ */ - KA_PERCENT, /* % */ - KA_AMPER, /* & */ - KA_SQUOTE, /* ' */ - KA_LPAREN, /* ( */ - KA_RPAREN, /* ) */ - KA_ASTERISK, /* * */ - KA_PLUS, /* + */ - KA_COMMA, /* , */ - KA_MINUS, /* - */ - KA_PERIOD, /* . */ - KA_SLASH, /* / */ - - KA_0, KA_1, KA_2, KA_3, KA_4, KA_5, KA_6, KA_7, KA_8, KA_9, - KA_COLON, /* : */ - KA_SEMICOLON, /* ; */ - KA_LESS_THAN, /* < */ - KA_EQUAL, /* = */ - KA_GREATER_THAN, /* > */ - KA_QUESTION, /* ? */ - - KA_AT, /* @ */ - KA_A, /* A */ - KA_B, /* B */ - KA_C, /* C */ - KA_D, /* D */ - KA_E, /* E */ - KA_F, /* F */ - KA_G, /* G */ - KA_H, /* H */ - KA_I, /* I */ - KA_J, /* J */ - KA_K, /* K */ - KA_L, /* L */ - KA_M, /* M */ - KA_N, /* N */ - KA_O, /* O */ - - KA_P, /* P */ - KA_Q, /* Q */ - KA_R, /* R */ - KA_S, /* S */ - KA_T, /* T */ - KA_U, /* U */ - KA_V, /* V */ - KA_W, /* W */ - KA_X, /* X */ - KA_Y, /* Y */ - KA_Z, /* Z */ - KA_LBRACKET, /* [ */ - KA_BACKSLASH, /* \ */ - KA_RBRACKET, /* ] */ - KA_CARROT, /* ^ */ - KA_UNDERLINE, /* _ */ - - KA_GRAVE, /* ` */ - KA_a, /* a */ - KA_b, /* b */ - KA_c, /* c */ - KA_d, /* d */ - KA_e, /* e */ - KA_f, /* f */ - KA_g, /* g */ - KA_h, /* h */ - KA_i, /* i */ - KA_j, /* j */ - KA_k, /* k */ - KA_l, /* l */ - KA_m, /* m */ - KA_n, /* n */ - KA_o, /* o */ - - KA_p, /* p */ - KA_q, /* q */ - KA_r, /* r */ - KA_s, /* s */ - KA_t, /* t */ - KA_u, /* u */ - KA_v, /* v */ - KA_w, /* w */ - KA_x, /* x */ - KA_y, /* y */ - KA_z, /* z */ - KA_LBRACE, /* { */ - KA_BAR, /* | */ - KA_RBRACE, /* ] */ - KA_TILDA, /* ~ */ - - KA_ESC = VK_ESCAPE, - KA_EXTEND = VK_ESCAPE, - KA_RETURN = VK_RETURN, - KA_BACKSPACE = VK_BACK, - KA_TAB = VK_TAB , - KA_DELETE = VK_DELETE, /* */ - KA_INSERT = VK_INSERT, /* */ - KA_PGDN = VK_NEXT, /* */ - KA_DOWNRIGHT = VK_NEXT, - KA_DOWN = VK_DOWN, /* */ - KA_END = VK_END, /* */ - KA_DOWNLEFT = VK_END, - KA_RIGHT = VK_RIGHT, /* */ - KA_KEYPAD5 = VK_SELECT, /* NUMERIC KEY PAD <5> */ - KA_LEFT = VK_LEFT, /* */ - KA_PGUP = VK_PRIOR, /* */ - KA_UPRIGHT = VK_PRIOR, - KA_UP = VK_UP, /* */ - KA_HOME = VK_HOME, /* */ - KA_UPLEFT = VK_HOME, - KA_F12 = VK_F12, - KA_F11 = VK_F11, - KA_F10 = VK_F10, - KA_F9 = VK_F9, - KA_F8 = VK_F8, - KA_F7 = VK_F7, - KA_F6 = VK_F6, - KA_F5 = VK_F5, - KA_F4 = VK_F4, - KA_F3 = VK_F3, - KA_F2 = VK_F2, - KA_F1 = VK_F1, - KA_LMOUSE = VK_LBUTTON, - KA_RMOUSE = VK_RBUTTON, - - KA_SHIFT_BIT = WWKEY_SHIFT_BIT, - KA_CTRL_BIT = WWKEY_CTRL_BIT, - KA_ALT_BIT = WWKEY_ALT_BIT, - KA_RLSE_BIT = WWKEY_RLS_BIT -} KeyASCIIType; - - -typedef enum KeyNumType { - KN_NONE = 0, - - KN_0 = VK_0, - KN_1 = VK_1, - KN_2 = VK_2, - KN_3 = VK_3, - KN_4 = VK_4, - KN_5 = VK_5, - KN_6 = VK_6, - KN_7 = VK_7, - KN_8 = VK_8, - KN_9 = VK_9, - KN_A = VK_A, - KN_B = VK_B, - KN_BACKSLASH = VK_NONE_DC, - KN_BACKSPACE = VK_BACK, - KN_C = VK_C, - KN_CAPSLOCK = VK_CAPITAL, - KN_CENTER = VK_CLEAR, - KN_COMMA = VK_NONE_BC, - KN_D = VK_D, - KN_DELETE = VK_DELETE, - KN_DOWN = VK_DOWN, - KN_DOWNLEFT = VK_END, - KN_DOWNRIGHT = VK_NEXT, - KN_E = VK_E, - KN_END = VK_END, - KN_EQUAL = VK_NONE_BB, - KN_ESC = VK_ESCAPE, - KN_E_DELETE = VK_DELETE, - KN_E_DOWN = VK_NUMPAD2, - KN_E_END = VK_NUMPAD1, - KN_E_HOME = VK_NUMPAD7, - KN_E_INSERT = VK_INSERT, - KN_E_LEFT = VK_NUMPAD4, - KN_E_PGDN = VK_NUMPAD3, - KN_E_PGUP = VK_NUMPAD9, - KN_E_RIGHT = VK_NUMPAD6, - KN_E_UP = VK_NUMPAD8, - KN_F = VK_F, - KN_F1 = VK_F1, - KN_F10 = VK_F10, - KN_F11 = VK_F11, - KN_F12 = VK_F12, - KN_F2 = VK_F2, - KN_F3 = VK_F3, - KN_F4 = VK_F4, - KN_F5 = VK_F5, - KN_F6 = VK_F6, - KN_F7 = VK_F7, - KN_F8 = VK_F8, - KN_F9 = VK_F9, - KN_G = VK_G, - KN_GRAVE = VK_NONE_C0, - KN_H = VK_H, - KN_HOME = VK_HOME, - KN_I = VK_I, - KN_INSERT = VK_INSERT, - KN_J = VK_J, - KN_K = VK_K, - KN_KEYPAD_ASTERISK= VK_MULTIPLY, - KN_KEYPAD_MINUS = VK_SUBTRACT, - KN_KEYPAD_PLUS = VK_ADD, - KN_KEYPAD_RETURN = VK_RETURN, - KN_KEYPAD_SLASH = VK_DIVIDE, - KN_L = VK_L, - KN_LALT = VK_MENU, - KN_LBRACKET = VK_NONE_DB, - KN_LCTRL = VK_CONTROL, - KN_LEFT = VK_LEFT, - KN_LMOUSE = VK_LBUTTON, - KN_LSHIFT = VK_SHIFT, - KN_M = VK_M, - KN_MINUS = VK_NONE_BD, - KN_N = VK_N, - KN_NUMLOCK = VK_NUMLOCK, - KN_O = VK_O, - KN_P = VK_P, - KN_PAUSE = VK_PAUSE, - KN_PERIOD = VK_NONE_BE, - KN_PGDN = VK_NEXT, - KN_PGUP = VK_PRIOR, - KN_PRNTSCRN = VK_PRINT, - KN_Q = VK_Q, - KN_R = VK_R, - KN_RALT = VK_MENU, - KN_RBRACKET = VK_NONE_DD, - KN_RCTRL = VK_CONTROL, - KN_RETURN = VK_RETURN, - KN_RIGHT = VK_RIGHT, - KN_RMOUSE = VK_RBUTTON, - KN_RSHIFT = VK_SHIFT, - KN_S = VK_S, - KN_SCROLLLOCK = VK_SCROLL, - KN_SEMICOLON = VK_NONE_BA, - KN_SLASH = VK_NONE_BF, - KN_SPACE = VK_SPACE, - KN_SQUOTE = VK_NONE_DE, - KN_T = VK_T, - KN_TAB = VK_TAB, - KN_U = VK_U, - KN_UP = VK_UP, - KN_UPLEFT = VK_HOME, - KN_UPRIGHT = VK_PRIOR, - KN_V = VK_V, - KN_W = VK_W, - KN_X = VK_X, - KN_Y = VK_Y, - KN_Z = VK_Z, - - KN_SHIFT_BIT = WWKEY_SHIFT_BIT, - KN_CTRL_BIT = WWKEY_CTRL_BIT, - KN_ALT_BIT = WWKEY_ALT_BIT, - KN_RLSE_BIT = WWKEY_RLS_BIT, - KN_BUTTON = WWKEY_BTN_BIT -} KeyNumType; - -/* -** Interface class to the keyboard. This insulates the game from library vagaries. Most -** notable being the return values are declared as "int" in the library whereas C&C -** expects it to be of KeyNumType. -*/ - -//lint -esym(1725,KeyboardClass::MouseQX,KeyboardClass::MouseQY) -struct KeyboardClass : public WWKeyboardClass -{ - /* - ** This flag is used to indicate whether the WW library has taken over - ** the keyboard or not. If not, then the normal console input - ** takes precedence. - */ - unsigned IsLibrary; - - KeyboardClass() : IsLibrary(true) {} - KeyNumType Get(void) {return ((KeyNumType)WWKeyboardClass::Get());}; - KeyNumType Check(void) {return ((KeyNumType)WWKeyboardClass::Check());}; - KeyASCIIType To_ASCII(KeyNumType key) {return((KeyASCIIType)WWKeyboardClass::To_ASCII((unsigned short)key));}; - void Clear(void) {WWKeyboardClass::Clear();}; - int Down(KeyNumType key) {return(WWKeyboardClass::Down((unsigned short)key));}; - - int Mouse_X(void) {return(Get_Mouse_X());}; - int Mouse_Y(void) {return(Get_Mouse_Y());}; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp deleted file mode 100644 index cc6c395c841..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/lcw.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * LCW_Comp -- Performes LCW compression on a block of data. * - * LCW_Uncomp -- Decompress an LCW encoded data block. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "LCW.H" - -/*************************************************************************** - * LCW_Uncomp -- Decompress an LCW encoded data block. * - * * - * Uncompress data to the following codes in the format b = byte, w = word * - * n = byte code pulled from compressed data. * - * * - * Command code, n |Description * - * ------------------------------------------------------------------------* - * n=0xxxyyyy,yyyyyyyy |short copy back y bytes and run x+3 from dest * - * n=10xxxxxx,n1,n2,...,nx+1|med length copy the next x+1 bytes from source* - * n=11xxxxxx,w1 |med copy from dest x+3 bytes from offset w1 * - * n=11111111,w1,w2 |long copy from dest w1 bytes from offset w2 * - * n=11111110,w1,b1 |long run of byte b1 for w1 bytes * - * n=10000000 |end of data reached * - * * - * * - * INPUT: * - * void * source ptr * - * void * destination ptr * - * unsigned long length of uncompressed data * - * * - * * - * OUTPUT: * - * unsigned long # of destination bytes written * - * * - * WARNINGS: * - * 3rd argument is dummy. It exists to provide cross-platform * - * compatibility. Note therefore that this implementation does not * - * check for corrupt source data by testing the uncompressed length. * - * * - * HISTORY: * - * 03/20/1995 IML : Created. * - *=========================================================================*/ -int LCW_Uncomp(void const * source, void * dest, unsigned long ) -{ - unsigned char * source_ptr, * dest_ptr, * copy_ptr; - unsigned char op_code, data; - unsigned count; - unsigned * word_dest_ptr; - unsigned word_data; - - /* Copy the source and destination ptrs. */ - source_ptr = (unsigned char*) source; - dest_ptr = (unsigned char*) dest; - - for (;;) { - - /* Read in the operation code. */ - op_code = *source_ptr++; - - if (!(op_code & 0x80)) { - - /* Do a short copy from destination. */ - count = (op_code >> 4) + 3; - copy_ptr = dest_ptr - ((unsigned) *source_ptr++ + (((unsigned) op_code & 0x0f) << 8)); - - while (count--) *dest_ptr++ = *copy_ptr++; - - } else { - - if (!(op_code & 0x40)) { - - if (op_code == 0x80) { - - /* Return # of destination bytes written. */ - return ((unsigned long) (dest_ptr - (unsigned char*) dest)); - - } else { - - /* Do a medium copy from source. */ - count = op_code & 0x3f; - - while (count--) *dest_ptr++ = *source_ptr++; - } - - } else { - - if (op_code == 0xfe) { - - /* Do a long run. */ - count = *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - word_data = data = *(source_ptr + 2); - word_data = (word_data << 24) + (word_data << 16) + (word_data << 8) + word_data; - source_ptr += 3; - - copy_ptr = dest_ptr + 4 - ((unsigned) dest_ptr & 0x3); - count -= (copy_ptr - dest_ptr); - while (dest_ptr < copy_ptr) *dest_ptr++ = data; - - word_dest_ptr = (unsigned*) dest_ptr; - - dest_ptr += (count & 0xfffffffc); - - while (word_dest_ptr < (unsigned*) dest_ptr) { - *word_dest_ptr = word_data; - *(word_dest_ptr + 1) = word_data; - word_dest_ptr += 2; - } - - copy_ptr = dest_ptr + (count & 0x3); - while (dest_ptr < copy_ptr) *dest_ptr++ = data; - - } else { - - if (op_code == 0xff) { - - /* Do a long copy from destination. */ - count = *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - copy_ptr = (unsigned char*) dest + *(source_ptr + 2) + ((unsigned) *(source_ptr + 3) << 8); - source_ptr += 4; - - while (count--) *dest_ptr++ = *copy_ptr++; - - } else { - - /* Do a medium copy from destination. */ - count = (op_code & 0x3f) + 3; - copy_ptr = (unsigned char*) dest + *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - source_ptr += 2; - - while (count--) *dest_ptr++ = *copy_ptr++; - } - } - } - } - } -} - - -#if defined(_MSC_VER) && defined(_M_IX86) - - -/*********************************************************************************************** - * LCW_Comp -- Performes LCW compression on a block of data. * - * * - * This routine will compress a block of data using the LCW compression method. LCW has * - * the primary characteristic of very fast uncompression at the expense of very slow * - * compression times. * - * * - * INPUT: source -- Pointer to the source data to compress. * - * * - * dest -- Pointer to the destination location to store the compressed data * - * to. * - * * - * datasize -- The size (in bytes) of the source data to compress. * - * * - * OUTPUT: Returns with the number of bytes of output data stored into the destination * - * buffer. * - * * - * WARNINGS: Be sure that the destination buffer is big enough. The maximum size required * - * for the destination buffer is (datasize + datasize/128). * - * * - * HISTORY: * - * 05/20/1997 JLB : Created. * - *=============================================================================================*/ -/*ARGSUSED*/ -int LCW_Comp(void const * source, void * dest, int datasize) -{ - int retval = 0; -#ifdef _WINDOWS - long inlen = 0; - long a1stdest = 0; - long a1stsrc = 0; - long lenoff = 0; - long ndest = 0; - long count = 0; - long matchoff = 0; - long end_of_data =0; -#ifdef _DEBUG - inlen = inlen; - a1stdest = a1stdest; - a1stsrc = a1stsrc; - lenoff = lenoff; - ndest = ndest; - count = count; - matchoff = matchoff; - end_of_data = end_of_data; -#endif - - __asm { - cld // make sure all string commands are forward - mov edi,[dest] - mov esi,[source] - mov edx,[datasize] // get length of data to compress - -// compress data to the following codes in the format b = byte, w = word -// n = byte code pulled from compressed data -// Bit field of n command description -// n=0xxxyyyy,yyyyyyyy short run back y bytes and run x+3 -// n=10xxxxxx,n1,n2,...,nx+1 med length copy the next x+1 bytes -// n=11xxxxxx,w1 med run run x+3 bytes from offset w1 -// n=11111111,w1,w2 long run run w1 bytes from offset w2 -// n=10000000 end end of data reached - - mov ebx,esi - add ebx,edx - mov [end_of_data],ebx - mov [inlen],1 //; set the in-length flag - mov [a1stdest],edi //; save original dest offset for size calc - mov [a1stsrc],esi //; save offset of first byte of data - mov [lenoff],edi //; save the offset of the legth of this len - sub eax,eax - mov al,081h //; the first byte is always a len - stosb //; write out a len of 1 - lodsb //; get the byte - stosb //; save it - } - -loopstart: - __asm { - mov [ndest],edi //; save offset of compressed data - mov edi,[a1stsrc] //; get the offset to the first byte of data - mov [count],1 //; set the count of run to 0 - } -searchloop: - __asm { - sub eax,eax - mov al,[esi] //; get the current byte of data - cmp al,[esi+64] - jne short notrunlength - - mov ebx,edi - - mov edi,esi - mov ecx,[end_of_data] - sub ecx,edi - repe scasb - dec edi - mov ecx,edi - sub ecx,esi - cmp ecx,65 - jb short notlongenough - - mov [inlen],0 //; clear the in-length flag -// mov [DWORD PTR inlen],0 //; clear the in-length flag - mov esi,edi - mov edi,[ndest] //; get the offset of our compressed data - - mov ah,al - mov al,0FEh - stosb - xchg ecx,eax - stosw - mov al,ch - stosb - - mov [ndest],edi //; save offset of compressed data - mov edi,ebx - jmp searchloop - } -notlongenough: - __asm { - mov edi,ebx - } -notrunlength: -oploop: - __asm { - mov ecx,esi //; get the address of the last byte +1 - sub ecx,edi //; get the total number of bytes left to comp - jz short searchdone - - repne scasb //; look for a match - jne short searchdone //; if we don't find one we're done - - mov ebx,[count] - mov ah,[esi+ebx-1] - cmp ah,[edi+ebx-2] - - jne oploop - - mov edx,esi //; save this spot for the next search - mov ebx,edi //; save this spot for the length calc - dec edi //; back up one for compare - mov ecx,[end_of_data] //; get the end of data - sub ecx,esi //; sub current source for max len - - repe cmpsb //; see how many bytes match - - jne short notend //; if found mismatch then di - bx = match count - - inc edi //; else cx = 0 and di + 1 - bx = match count - } -notend: - __asm { - mov esi,edx //; restore si - mov eax,edi //; get the dest - sub eax,ebx //; sub the start for total bytes that match - mov edi,ebx //; restore dest - cmp eax,[count] //; see if its better than before - jb searchloop //; if not keep looking - - mov [count],eax //; if so keep the count - dec ebx //; back it up for the actual match offset - mov [matchoff],ebx //; save the offset for later - jmp searchloop //; loop until we searched it all - } -searchdone: - __asm { - mov ecx,[count] //; get the count of the longest run - mov edi,[ndest] //; get the offset of our compressed data - cmp ecx,2 //; see if its not enough run to matter - jbe short lenin //; if its 0,1, or 2 its too small - - cmp ecx,10 //; if not, see if it would fit in a short - ja short medrun //; if not, see if its a medium run - - mov eax,esi //; if its short get the current address - sub eax,[matchoff] //; sub the offset of the match - cmp eax,0FFFh //; if its less than 12 bits its a short - ja short medrun //; if its not, its a medium - } -//shortrun: - __asm { - sub ebx,ebx - mov bl,cl //; get the length (3-10) - sub bl,3 //; sub 3 for a 3 bit number 0-7 - shl bl,4 //; shift it left 4 - add ah,bl //; add in the length for the high nibble - xchg ah,al //; reverse the bytes for a word store - jmp short srunnxt //; do the run fixup code - } -medrun: - __asm { - cmp ecx,64 //; see if its a short run - ja short longrun //; if not, oh well at least its long - - sub cl,3 //; back down 3 to keep it in 6 bits - or cl,0C0h //; the highest bits are always on - mov al,cl //; put it in al for the stosb - stosb //; store it - jmp short medrunnxt //; do the run fixup code - } -lenin: - __asm { - cmp [inlen],0 //; is it doing a length? -// cmp [DWORD PTR inlen],0 //; is it doing a length? - jnz short len //; if so, skip code - } -lenin1: - __asm { - mov [lenoff],edi //; save the length code offset - mov al,80h //; set the length to 0 - stosb //; save it - } -len: - __asm { - mov ebx,[lenoff] //; get the offset of the length code - cmp [ebx],0BFh //; see if its maxed out -// cmp [BYTE PTR ebx],0BFh //; see if its maxed out - je lenin1 //; if so put out a new len code - } -//stolen: - __asm { - inc [ebx] //; inc the count code -// inc [BYTE PTR ebx] //; inc the count code - lodsb //; get the byte - stosb //; store it - mov [inlen],1 //; we are now in a length so save it -// mov [DWORD PTR inlen],1 //; we are now in a length so save it - jmp short nxt //; do the next code - } -longrun: - __asm { - mov al,0ffh //; its a long so set a code of FF - stosb //; store it - - mov eax,[count] //; send out the count - stosw //; store it - } -medrunnxt: - __asm { - mov eax,[matchoff] //; get the offset - sub eax,[a1stsrc] //; make it relative tot he start of data - } -srunnxt: - __asm { - stosw //; store it - //; this code common to all runs - add esi,[count] //; add in the length of the run to the source - mov [inlen],0 //; set the in leght flag to false -// mov [DWORD PTR inlen],0 //; set the in leght flag to false - } -nxt: - __asm { - cmp esi,[end_of_data] //; see if we did the whole pic - jae short outofhere //; if so, cool! were done - - jmp loopstart - } -outofhere: - __asm { - mov ax,080h //; remember to send an end of data code - stosb //; store it - mov eax,edi //; get the last compressed address - sub eax,[a1stdest] //; sub the first for the compressed size - mov [retval],eax - } -#endif - return(retval); -} -#endif // defined(_MSC_VER) && defined(_M_IX86) - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h deleted file mode 100644 index a1a7b6f24db..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/LCWPIPE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef LCWPIPE_H -#define LCWPIPE_H - -#include "PIPE.H" - - -/* -** Performs LCW compression/decompression on the data stream that is piped through this -** class. The data is compressed in blocks so of small enough size to be compressed -** quickly and large enough size to get decent compression rates. -*/ -class LCWPipe : public Pipe -{ - public: - typedef enum CompControl { - COMPRESS, - DECOMPRESS - } CompControl; - - LCWPipe(CompControl, int blocksize=1024*8); - virtual ~LCWPipe(void); - - virtual int Flush(void); - virtual int Put(void const * source, int slen); - - private: - /* - ** This tells the pipe if it should be decompressing or compressing the data stream. - */ - CompControl Control; - - /* - ** The number of bytes accumulated into the staging buffer. - */ - int Counter; - - /* - ** Pointer to the working buffer that compression/decompression will use. - */ - char * Buffer; - char * Buffer2; - - /* - ** The working block size. Data will be compressed in chunks of this size. - */ - int BlockSize; - - /* - ** LCW compression requires a safety margin when decompressing over itself. This - ** margin is only for the worst case situation (very rare). - */ - int SafetyMargin; - - /* - ** Each block has a header of this format. - */ - struct { - unsigned short CompCount; // Size of data block (compressed). - unsigned short UncompCount; // Bytes of uncompressed data it represents. - } BlockHeader; - - LCWPipe(LCWPipe & rvalue); - LCWPipe & operator = (LCWPipe const & pipe); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/load.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/load.cpp deleted file mode 100644 index 829aef87470..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/load.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/LOAD.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Load_Uncompress -- Load and uncompress the given file. * - * Uncompress_Data -- Uncompress standard CPS buffer. * - * Load_Data -- Loads a data file from disk. * - * Load_Alloc_Data -- Loads and allocates buffer for a file. * - * Write_Data -- Writes a block of data as a file to disk. * - * Uncompress_Data -- Uncompresses data from one buffer to another. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "IFF.H" -#include "LCW.H" -#include - - -/*************************************************************************** - * Uncompress_Data -- Uncompresses data from one buffer to another. * - * * - * This routine takes data from a compressed file (sans the first two * - * size bytes) and uncompresses it to a destination buffer. The source * - * data MUST have the CompHeaderType at its start. * - * * - * INPUT: src -- Source compressed data pointer. * - * * - * dst -- Destination (paragraph aligned) pointer. * - * * - * OUTPUT: Returns with the size of the uncompressed data. * - * * - * WARNINGS: If LCW compression is used, the destination buffer must * - * be paragraph aligned. * - * * - * HISTORY: * - * 09/17/1993 JLB : Created. * - *=========================================================================*/ -unsigned long __cdecl Uncompress_Data(void const *src, void *dst) -{ - unsigned int skip; // Number of leading data to skip. - CompressionType method; // Compression method used. - unsigned long uncomp_size; - - if (!src || !dst) return(NULL); - - /* - ** Interpret the data block header structure to determine - ** compression method, size, and skip data amount. - */ - uncomp_size = ((CompHeaderType*)src)->Size; - #if(AMIGA) - uncomp_size = Reverse_Long(uncomp_size); - #endif - skip = ((CompHeaderType*)src)->Skip; - #if(AMIGA) - skip = Reverse_Word(skip); - #endif - method = (CompressionType) ((CompHeaderType*)src)->Method; - src = ((char*)src) + (long)sizeof(CompHeaderType) + (long)skip; -// src = Add_Long_To_Pointer((void *)src, (long)sizeof(CompHeaderType) + (long)skip); - - switch (method) { - - default: - case NOCOMPRESS: - memmove(dst, (void *) src, uncomp_size); -// Mem_Copy((void *) src, dst, uncomp_size); - break; - - case HORIZONTAL: - break; - - case LCW: - LCW_Uncomp((void *) src, (void *) dst, (unsigned long) uncomp_size); - break; - - } - - return(uncomp_size); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/misc.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/misc.h deleted file mode 100644 index 17e931b29a9..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/misc.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/MISC.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MISC_H -#define MISC_H - -#include "win.h" -#include "ddraw.h" - -extern unsigned char CurrentPalette[768]; -extern bool Debug_Windowed; - -extern LPDIRECTDRAWSURFACE PaletteSurface; - -/*========================= C++ Routines ==================================*/ - -/*=========================================================================*/ -/* The following prototypes are for the file: DDRAW.CPP */ -/*=========================================================================*/ -void Prep_Direct_Draw(void); -void Process_DD_Result(HRESULT result, int display_ok_msg); -bool Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel); -void Reset_Video_Mode(void); -unsigned Get_Free_Video_Memory(void); -void Wait_Blit(void); -unsigned Get_Video_Hardware_Capabilities(void); - -extern "C" void Wait_Vert_Blank(void); - -#include "PALETTE.H" - -void Set_Palette(PaletteClass const & pal, int time = 0, void (*callback)() = NULL); -void Set_Palette(void const * palette); - -/* -** Pointer to function to call if we detect a focus loss -*/ -//extern void (*Misc_Focus_Loss_Function)(void); -/* -** Pointer to function to call if we detect a surface restore -*/ -//extern void (*Misc_Focus_Restore_Function)(void); - -/* -** Function to call if we detect focus loss -*/ -extern void (*Audio_Focus_Loss_Function)(void); - - -/* - * Flags returned by Get_Video_Hardware_Capabilities - */ -/* Hardware blits supported? */ -#define VIDEO_BLITTER 1 - -/* Hardware blits asyncronous? */ -#define VIDEO_BLITTER_ASYNC 2 - -/* Can palette changes be synced to vertical refresh? */ -#define VIDEO_SYNC_PALETTE 4 - -/* Is the video cards memory bank switched? */ -#define VIDEO_BANK_SWITCHED 8 - -/* Can the blitter do filled rectangles? */ -#define VIDEO_COLOR_FILL 16 - -/* Is there no hardware assistance avaailable at all? */ -#define VIDEO_NO_HARDWARE_ASSIST 32 - -extern bool SurfacesRestored; - -/*=========================================================================*/ -/* The following variables are declared in: DDRAW.CPP */ -/*=========================================================================*/ -extern LPDIRECTDRAW DirectDrawObject; -extern LPDIRECTDRAW2 DirectDraw2Interface; -//extern HWND MainWindow; -//extern bool SystemToVideoBlits; -//extern bool VideoToSystemBlits; -//extern bool SystemToSystemBlits; -//extern bool OverlappedVideoBlits; // Can video driver blit overlapped regions? - -/*=========================================================================*/ -/* The following prototypes are for the file: EXIT.CPP */ -/* Prog_End Must be supplied by the user program in startup.cpp */ -/*=========================================================================*/ -void Prog_End(void); -//void __cdecl Exit(INT errorval, const char *message, ...); - -/*=========================================================================*/ -/* The following prototypes are for the file: DELAY.CPP */ -/*=========================================================================*/ -void Delay(int duration); -void Vsync(void); - - -/*========================= Assembly Routines ==============================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/*=========================================================================*/ -/* The following prototype is for the file: SHAKESCR.ASM */ -/*=========================================================================*/ - -void __cdecl Shake_Screen(int shakes); - -//void * Build_Fading_Table(PaletteClass const & palette, void * dest, int color, int frac); -//void * __cdecl Build_Fading_Table(void const *palette, void const *dest, long int color, long int frac); - -/*=========================================================================*/ -/* The following prototypes are for the file: DETPROC.ASM */ -/*=========================================================================*/ - -extern WORD __cdecl Processor(void); -extern WORD __cdecl Operating_System(void); - -extern int __cdecl Clip_Rect ( int * x , int * y , int * dw , int * dh , - int width , int height ) ; -extern int __cdecl Confine_Rect ( int * x , int * y , int dw , int dh , - int width , int height ) ; - - - -/*=========================================================================*/ -/* The following prototypes are for the file: OPSYS.ASM */ -/*=========================================================================*/ - -extern WORD OperationgSystem; - -#ifdef __cplusplus -} -#endif - -/*=========================================================================*/ - -#endif // MISC_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp deleted file mode 100644 index f3ab1ff4d92..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/wwlib/mixfile.cpp $* - * * - * $Author:: Patrick $* - * * - * $Modtime:: 8/06/01 3:01p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "mixfile.h" -#include "wwdebug.h" -#include "ffactory.h" -#include "WWFILE.H" -#include "realcrc.h" -#include "RAWFILE.H" -#include "win.h" -#include "bittype.h" - -/* -** -*/ -typedef struct -{ - char signature[4]; - long header_offset; - long names_offset; - -} MIXFILE_HEADER; - -typedef struct -{ - long file_count; - -} MIXFILE_DATA_HEADER; - - -/* -** -*/ -MixFileFactoryClass::MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory ) : - FileCount (0), - NamesOffset (0), - IsValid (false), - BaseOffset (0), - Factory (NULL), - IsModified (false) -{ -// WWDEBUG_SAY(( "MixFileFactory( %s )\n", mix_filename )); - MixFilename = mix_filename; - Factory = factory; - - // First, open the mix file - FileClass * file = factory->Get_File( mix_filename ); - -// WWASSERT( file ); - - if ( file && file->Is_Available() ) { - - file->Open(); - - IsValid = true; - - // - // Read the file header - // - MIXFILE_HEADER header = { 0 }; - IsValid = (file->Read( &header, sizeof( header ) ) == sizeof( header )); - - // - // Validate the file header - // - if ( IsValid ) { - IsValid = (::memcmp( header.signature, "MIX1", sizeof ( header.signature ) ) == 0); - } - - // - // Seek to the data start - // - FileCount = 0; - if ( IsValid ) { - file->Seek( header.header_offset, SEEK_SET ); - IsValid = ( file->Read( &FileCount, sizeof( FileCount ) ) == sizeof( FileCount ) ); - } - - // - // Read the array of data headers - // - if ( IsValid ) { - FileInfo.Resize( FileCount ); - int size = FileCount * sizeof( FileInfoStruct ); - IsValid = ( file->Read( &FileInfo[0], size ) == size ); - } - - // - // Check for success - // - if ( IsValid ) { - BaseOffset = 0; - NamesOffset = header.names_offset; - WWDEBUG_SAY(( "MixFileFactory( %s ) loaded successfully %d files\n", MixFilename, FileInfo.Length() )); - } else { - FileInfo.Resize(0); - } - - factory->Return_File( file ); - - } else { - WWDEBUG_SAY(( "MixFileFactory( %s ) FAILED\n", mix_filename )); - } -} - -MixFileFactoryClass::~MixFileFactoryClass( void ) -{ - FileInfo.Resize(0); -} - -bool MixFileFactoryClass::Build_Filename_List (DynamicVectorClass &list) -{ - if (IsValid == false) { - return false; - } - - bool retval = false; - - // - // Attempt to open the file - // - RawFileClass *file = (RawFileClass *)Factory->Get_File( MixFilename ); - if ( file != NULL && file->Open ( RawFileClass::READ ) ) { - - // - // Seek to the names offset header - // - file->Seek (NamesOffset, SEEK_SET); - retval = true; - - // - // Read the count of files - // - int file_count = 0; - if (file->Read( &file_count, sizeof( file_count) ) == sizeof( file_count )) { - - // - // Loop over each saved filename - // - bool keep_going = true; - for (int index = 0; index < file_count && keep_going; index ++) { - keep_going = false; - - // - // Get the length of the filename - // - uint8 name_len = 0; - if (file->Read( &name_len, sizeof( name_len ) ) == sizeof( name_len )) { - - // - // Read the filename - // - StringClass filename; - if (file->Read( filename.Get_Buffer( name_len ), name_len ) == name_len ) { - - // - // Add the filename to our list - // - list.Add( filename ); - keep_going = true; - } - } - } - } - - // - // Close the file - // - Factory->Return_File( file ); - } - - return retval; -} - -FileClass * MixFileFactoryClass::Get_File( char const *filename ) -{ - if ( FileInfo.Length() == 0 ) { - return NULL; - } -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s )\n", filename )); - - RawFileClass *file = NULL; - - // Create the key block that will be used to binary search for the file. - unsigned long crc = CRC_Stringi( filename ); - - // Binary search for the file in this mixfile. If it is found, then create the file - FileInfoStruct * info = NULL; - FileInfoStruct * base = &FileInfo[0]; - int stride = FileInfo.Length(); - while (stride > 0) { - int pivot = stride / 2; - FileInfoStruct * tryptr = base + pivot; - if (crc < tryptr->CRC) { - stride = pivot; - } else { - if (tryptr->CRC == crc) { - info = tryptr; - break; - } - base = tryptr + 1; - stride -= pivot + 1; - } - } - - if ( info != NULL) { -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) FOUND\n", filename )); - file = (RawFileClass *)Factory->Get_File( MixFilename ); - if ( file ) { - file->Bias( BaseOffset + info->Offset, info->Size ); - } -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) FOUND\n", filename )); - } else { -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) NOT FOUND\n", filename )); - } - - return file; -} - -void MixFileFactoryClass::Return_File( FileClass * file ) -{ - if ( file != NULL ) { - Factory->Return_File( file ); - } -} - - -/* -** -*/ -void -MixFileFactoryClass::Add_File (const char *full_path, const char *filename) -{ - AddInfoStruct info; - info.FullPath = full_path; - info.Filename = filename; - PendingAddFileList.Add (info); - IsModified = true; - return ; -} - - -/* -** -*/ -void -MixFileFactoryClass::Delete_File (const char *filename) -{ - // - // Remove this file (if it exists) from our filename list - // - for (int list_index = 0; list_index < FilenameList.Count (); list_index ++) { - if (FilenameList[list_index].Compare_No_Case (filename) == 0) { - FilenameList.Delete (list_index); - IsModified = true; - break; - } - } - - return ; -} - - -/* -** -*/ -void -MixFileFactoryClass::Flush_Changes (void) -{ - // - // Exit if there's nothing to do. - // - if (IsModified == false) { - return ; - } - - // - // Get the path of the mix file - // - char drive[_MAX_DRIVE] = { 0 }; - char dir[_MAX_DIR] = { 0 }; - ::_splitpath (MixFilename, drive, dir, NULL, NULL); - StringClass path = drive; - path += dir; - - // - // Try to find a temp filename - // - StringClass full_path; - if (Get_Temp_Filename (path, full_path)) { - MixFileCreator new_mix_file (full_path); - - // - // Add all the remaining files from our file set - // - int index = 0; - for (; index < FilenameList.Count (); index ++) { - StringClass &filename = FilenameList[index]; - - // - // Copy this file data to the mix file - // - FileClass *file_data = Get_File (filename); - if (file_data != NULL) { - file_data->Open (); - new_mix_file.Add_File (filename, file_data); - Return_File (file_data); - - // - // Remove this file from the pending list (if necessary) - // - for (int temp_index = 0; temp_index < PendingAddFileList.Count (); temp_index ++) { - if (filename.Compare_No_Case (PendingAddFileList[temp_index].Filename) == 0) { - PendingAddFileList.Delete (temp_index); - break; - } - } - } - } - - // - // Add the new files that are pending - // - for (index = 0; index < PendingAddFileList.Count (); index ++) { - new_mix_file.Add_File (PendingAddFileList[index].FullPath, PendingAddFileList[index].Filename); - } - } - - // - // Delete the old mix file and rename the new one - // - ::DeleteFile (MixFilename); - ::MoveFile (full_path, MixFilename); - - // - // Reset the lists - // - IsModified = false; - PendingAddFileList.Delete_All (); - return ; -} - - -/* -** -*/ -bool -MixFileFactoryClass::Get_Temp_Filename (const char *path, StringClass &full_path) -{ - bool retval = false; - - StringClass temp_path = path; - temp_path += "_tmpmix"; - - // - // Try to find a unique temp filename - // - for (int index = 0; index < 20; index ++) { - full_path.Format ("%s%.2d.dat", (const char *)temp_path, index + 1); - if (GetFileAttributes (full_path) == 0xFFFFFFFF) { - retval = true; - break; - } - } - - return retval; -} - - -/* -** -*/ -SimpleFileFactoryClass _SimpleFileFactory; - -MixFileCreator::MixFileCreator( const char * filename ) -{ - WWDEBUG_SAY(( "Creating Mix File %s\n", filename )); - - MixFile = _SimpleFileFactory.Get_File(filename); - if ( MixFile != NULL ) { - MixFile->Open( FileClass::WRITE ); - MixFile->Write( "MIX1", 4 ); - long header_offset = 0; - MixFile->Write( &header_offset, sizeof( header_offset ) ); - long names_offset = 0; - MixFile->Write( &names_offset, sizeof( names_offset ) ); - long unused = 0; - MixFile->Write( &unused, sizeof( unused ) ); - } -} - -int MixFileCreator::File_Info_Compare(const void * a, const void * b) -{ - unsigned int CRCA = ((FileInfoStruct*)a)->CRC; - unsigned int CRCB = ((FileInfoStruct*)b)->CRC; - if ( CRCA < CRCB ) return -1; - if ( CRCA > CRCB ) return 1; - return 0; -// return ((FileInfoStruct*)a)->CRC - ((FileInfoStruct*)b)->CRC; -} - -MixFileCreator::~MixFileCreator( void ) -{ - if ( MixFile != NULL ) { - - // Save Header Data - int header_offset = MixFile->Tell(); - - // Save file count - int i,num_files = FileInfo.Count(); - WWDEBUG_SAY(( "Closing with %d files\n", num_files )); - MixFile->Write( &num_files, sizeof( num_files ) ); - - if ( num_files > 1 ) { - qsort( &FileInfo[0], num_files, sizeof(FileInfo[0]), &File_Info_Compare); - } - - // Save file info (CRC, Offset, Size ) - for ( i = 0; i < num_files; i++ ) { - MixFile->Write( &FileInfo[i].CRC, 4 ); - MixFile->Write( &FileInfo[i].Offset, 4 ); - MixFile->Write( &FileInfo[i].Size, 4 ); -// WWDEBUG_SAY(( "Write CRC %08X\n", FileInfo[i].CRC )); - } - - // --------------------------------------- - - // Save Names Data - int names_offset = MixFile->Tell(); - - // Save file count - MixFile->Write( &num_files, sizeof( num_files ) ); - - // Save file info - for ( i = 0; i < num_files; i++ ) { - const char * filename = FileInfo[i].Filename; - int size = FileInfo[i].Filename.Get_Length()+1; - WWASSERT( size < 255 ); - unsigned char csize = size; - MixFile->Write( &csize, 1 ); - MixFile->Write( filename, size ); - } - - // --------------------------------------- - - MixFile->Seek( 4, SEEK_SET ); - - // Save header offset - WWDEBUG_SAY(( "Writing header offset %d (%08X)\n", header_offset, header_offset )); - MixFile->Write( &header_offset, sizeof( header_offset ) ); - - // Save names offset - WWDEBUG_SAY(( "Writing names offset %d (%08X)\n", names_offset, names_offset )); - MixFile->Write( &names_offset, sizeof( names_offset ) ); - - // --------------------------------------- - - MixFile->Close(); - - _SimpleFileFactory.Return_File(MixFile); - } -} - -void MixFileCreator::Add_File( const char * source_filename, const char * saved_filename ) -{ - if ( saved_filename == NULL ) { - saved_filename = source_filename; - } - - if ( MixFile != NULL ) { - - FileClass * file = _SimpleFileFactory.Get_File( source_filename ); - - if ( file && file->Is_Available() ) { - - file->Open(); - - MixFileCreator::FileInfoStruct info; - info.CRC = CRC_Stringi( saved_filename ); - info.Offset = MixFile->Tell(); - info.Size = file->Size(); - FileInfo.Add( info ); - FileInfo[ FileInfo.Count()-1 ].Filename = saved_filename; - - WWDEBUG_SAY(( "Saving File %s CRC %08X Offset %d (0x%08X) Size %d (0x%08X)\n", - saved_filename, info.CRC, info.Offset, info.Offset, info.Size, info.Size )); - - int size = file->Size(); - while ( size ) { - char buffer[ 4096 ]; - int amount = MIN( sizeof( buffer ), size ); - size -= amount; - file->Read( buffer, amount ); - if ( MixFile->Write( buffer, amount ) != amount ) { - WWDEBUG_SAY(( "Failed to write MixFile\n" )); - } - } - - // Pad the MixFile to make DWord Aligned - int offset = MixFile->Tell(); - offset = (8-(offset & 7)) & 7; - if ( offset != 0 ) { - char zeros[8] = {0,0,0,0,0,0,0,0}; - if ( MixFile->Write( zeros, offset ) != offset ) { - WWDEBUG_SAY(( "Failed to write padding\n" )); - } - } - - file->Close(); - _SimpleFileFactory.Return_File( file ); - - } else { - WWDEBUG_SAY(( "MixFileCreator::Failed to open \"%s\"\n", source_filename )); - } - } -} - - -void MixFileCreator::Add_File( const char * filename, FileClass *file ) -{ - if ( MixFile != NULL ) { - - MixFileCreator::FileInfoStruct info; - info.CRC = CRC_Stringi( filename ); - info.Offset = MixFile->Tell(); - info.Size = file->Size(); - FileInfo.Add( info ); - FileInfo[ FileInfo.Count()-1 ].Filename = filename; - - WWDEBUG_SAY(( "Saving File %s CRC %08X Offset %d (0x%08X) Size %d (0x%08X)\n", - filename, info.CRC, info.Offset, info.Offset, info.Size, info.Size )); - - int size = file->Size(); - while ( size ) { - char buffer[ 4096 ]; - int amount = MIN( sizeof( buffer ), size ); - size -= amount; - file->Read( buffer, amount ); - if ( MixFile->Write( buffer, amount ) != amount ) { - WWDEBUG_SAY(( "Failed to write MixFile\n" )); - } - } - - // Pad the MixFile to make DWord Aligned - int offset = MixFile->Tell(); - offset = (8-(offset & 7)) & 7; - if ( offset != 0 ) { - char zeros[8] = {0,0,0,0,0,0,0,0}; - if ( MixFile->Write( zeros, offset ) != offset ) { - WWDEBUG_SAY(( "Failed to write padding\n" )); - } - } - } - - return ; -} - - -/* -** -*/ -void Add_Files( const char * dir, MixFileCreator & mix ) -{ - BOOL bcontinue = TRUE; - HANDLE hfile_find; - WIN32_FIND_DATA find_info = {0}; - StringClass path; - path.Format( "data\\makemix\\%s*.*", dir ); - WWDEBUG_SAY(( "Adding files from %s\n", path )); - - for (hfile_find = ::FindFirstFile( path, &find_info); - (hfile_find != INVALID_HANDLE_VALUE) && bcontinue; - bcontinue = ::FindNextFile(hfile_find, &find_info)) { - if ( find_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { - if ( find_info.cFileName[0] != '.' ) { - StringClass path; - path.Format( "%s%s\\", dir, find_info.cFileName ); - Add_Files( path, mix ); - } - } else { - StringClass name; - name.Format( "%s%s", dir, find_info.cFileName ); - StringClass source; - source.Format( "makemix\\%s", name ); - mix.Add_File( source, name ); -// WWDEBUG_SAY(( "Adding file from %s %s\n", source, name )); - } - } -} - -void Setup_Mix_File( void ) -{ - _SimpleFileFactory.Set_Sub_Directory( "DATA\\" ); -// _SimpleFileFactory.Set_Strip_Path( true ); - - WWDEBUG_SAY(( "Mix File Create .....\n" )); - - { - MixFileCreator mix( "MAKEMIX.MIX" ); - Add_Files( "", mix ); - } - -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.h deleted file mode 100644 index a68200a4637..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/mixfile.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/wwlib/mixfile.h $* - * * - * $Author:: Patrick $* - * * - * $Modtime:: 8/06/01 3:14p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MIXFILE_H -#define MIXFILE_H - -#ifndef ALWAYS_H - #include "always.h" -#endif - -#ifndef FFACTORY_H - #include "ffactory.h" -#endif - -#ifndef WWSTRING_H - #include "wwstring.h" -#endif - -#include "Vector.H" - -class FileClass; - -/* -** -*/ -class MixFileFactoryClass : public FileFactoryClass { - -public: - MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory ); - ~MixFileFactoryClass( void ); - - // - // Inherited - // - virtual FileClass * Get_File( char const *filename ); - virtual void Return_File( FileClass *file ); - - // - // Filename access - // - bool Build_Filename_List (DynamicVectorClass &list); - bool Build_Internal_Filename_List (void) { return Build_Filename_List (FilenameList); } - void Get_Filename_List (DynamicVectorClass **list) { *list = &FilenameList; } - void Get_Filename_List (DynamicVectorClass &list) { list = FilenameList; } - - // - // Content control - // - void Add_File (const char *full_path, const char *filename); - void Delete_File (const char *filename); - void Flush_Changes (void); - - // - // Information - // - bool Is_Valid (void) const { return IsValid; } - -private: - - // - // Utility functions - // - bool Get_Temp_Filename (const char *path, StringClass &full_path); - - struct FileInfoStruct { - bool operator== (const FileInfoStruct &src) { return false; } - bool operator!= (const FileInfoStruct &src) { return true; } - - unsigned long CRC; // CRC code for embedded file. - unsigned long Offset; // Offset from start of data section. - unsigned long Size; // Size of data subfile. - }; - - struct AddInfoStruct { - bool operator== (const AddInfoStruct &src) { return false; } - bool operator!= (const AddInfoStruct &src) { return true; } - - StringClass FullPath; - StringClass Filename; - }; - - FileFactoryClass * Factory; - DynamicVectorClass FileInfo; - StringClass MixFilename; - int BaseOffset; - - int FileCount; - int NamesOffset; - bool IsValid; - DynamicVectorClass FilenameList; - - DynamicVectorClass PendingAddFileList; - bool IsModified; -}; - -/* -** -*/ -class MixFileCreator { - -public: - MixFileCreator( const char * filename ); - ~MixFileCreator( void ); - - void Add_File( const char * source_filename, const char * saved_filename = NULL ); - void Add_File( const char * filename, FileClass *file ); - -private: - - static int File_Info_Compare(const void * a, const void * b); - - struct FileInfoStruct { - bool operator== (const FileInfoStruct &src) { return false; } - bool operator!= (const FileInfoStruct &src) { return true; } - - unsigned long CRC; // CRC code for embedded file. - unsigned long Offset; // Offset from start of data section. - unsigned long Size; // Size of data subfile. - StringClass Filename; - }; - - DynamicVectorClass FileInfo; - FileClass * MixFile; -}; - -/* -** -*/ -void Setup_Mix_File( void ); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/mono.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/mono.cpp deleted file mode 100644 index e6d0a4c7c41..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/mono.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/mono.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MonoClass::Clear -- Clears the monochrome screen object. * - * MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. * - * MonoClass::Fill_Attrib -- Fill a block with specified attribute. * - * MonoClass::MonoClass -- The default constructor for monochrome screen object. * - * MonoClass::Pan -- Scroll the window right or left. * - * MonoClass::Print -- Prints the text string at the current cursor coordinates. * - * MonoClass::Print -- Simple print of text number. * - * MonoClass::Printf -- Prints a formatted string to the monochrome screen. * - * MonoClass::Printf -- Prints formatted text using text string number. * - * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. * - * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. * - * MonoClass::Sub_Window -- Partitions the mono screen into a sub-window. * - * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. * - * MonoClass::Text_Print -- Simple text printing from text number. * - * MonoClass::View -- Brings the mono object to the main display. * - * MonoClass::operator = -- Handles making one mono object have the same imagery as another. * - * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. * - * Mono_Clear_Screen -- Clear the currently visible monochrome page. * - * Mono_Draw_Rect -- Draws rectangle to monochrome screen. * - * Mono_Print -- Prints simple text to monochrome screen. * - * Mono_Printf -- Prints formatted text to visible page. * - * Mono_Text_Print -- Prints text to location specified. * - * Mono_X -- Fetches the X cursor position for current visible mono page. * - * Mono_Y -- Fetches the Y cursor position for current mono page. * - * MonoClass::Set_Default_Attribute -- Set the default attribute for this window. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "data.h" -#include "MONO.H" -#include "MONODRVR.H" -#include - - -/* -** Global flag to indicate whether mono output is enabled. If it is not enabled, -** then no mono output will occur. -*/ -bool MonoClass::Enabled = false; - - -/* -** This points to the current mono displayed screen. -*/ -MonoClass * MonoClass::Current; - - -/*********************************************************************************************** - * MonoClass::MonoClass -- The default constructor for monochrome screen object. * - * * - * This is the constructor for monochrome screen objects. It handles allocating a free * - * monochrome page. If there are no more pages available, then this is a big error. The * - * page allocated may not be the visible one. Call the View function in order to bring * - * it to the displayed page. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -MonoClass::MonoClass(void) : - Handle(INVALID_HANDLE_VALUE) -{ -#ifdef _WINDOWS - Handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (Current == NULL) { - Current = this; - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. * - * * - * This is the default destructor for a monochrome screen object. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -MonoClass::~MonoClass(void) -{ -#ifdef _WINDOWS - if (Handle != INVALID_HANDLE_VALUE) { - CloseHandle(Handle); - Handle = INVALID_HANDLE_VALUE; - } - if (Current == this) { - Current = NULL; - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Pan -- Scroll the window right or left. * - * * - * This routine will scroll the window to the right or left as indicated by the number of * - * rows. * - * * - * INPUT: cols -- The number of columns to pan the window. Positive numbers pan to the left * - * while negative numbers pan to the right. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/05/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Pan(int ) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_PAN, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Sub_Window -- Partitions the mono screen into a sub-window. * - * * - * This routine is used to partition the monochrome screen so that only a sub-window will * - * be processed. By using this, a separate rectangle of the screen can be cleared, * - * scrolled, panned, or printed into. * - * * - * INPUT: x,y -- The upper left corner of the new sub-window. * - * * - * w,h -- Dimensions of the sub-window specified in characters. * - * * - * OUTPUT: none * - * * - * WARNINGS: The parameters are clipped as necessary. * - * * - * HISTORY: * - * 06/05/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Sub_Window(int x, int y, int w, int h) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - struct subwindow { - int X,Y,W,H; - } subwindow; - unsigned long retval; - - subwindow.X = x; - subwindow.Y = y; - subwindow.W = w; - subwindow.H = h; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_WINDOW, &subwindow, sizeof(subwindow), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. * - * * - * Use this routine to set the monochrome's cursor position to the coordinates specified. * - * This is the normal way of controlling where the next Print or Printf will output the * - * text to. * - * * - * INPUT: x,y -- The coordinate to position the monochrome cursor. 0,0 is the upper left * - * corner. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Set_Cursor(int x, int y) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - struct { - int X,Y; - } cursor; - unsigned long retval; - - cursor.X = x; - cursor.Y = y; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_CURSOR, &cursor, sizeof(cursor), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Clear -- Clears the monochrome screen object. * - * * - * This routine will fill the monochrome screen object with spaces. It is clearing the * - * screen of data, making it free for output. The cursor is positioned at the upper left * - * corner of the screen by this routine. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Clear(void) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Fill_Attrib -- Fill a block with specified attribute. * - * * - * This routine will give the specified attribute to the characters within the block * - * but will not change the characters themselves. You can use this routine to change the * - * underline, blink, or inverse characteristics of text. * - * * - * INPUT: x,y -- The upper left coordinate of the region to change. * - * * - * w,h -- The dimensions of the region to change (in characters). * - * * - * attrib -- The attribute to fill into the region specified. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Fill_Attrib(int x, int y, int w, int h, MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - struct fillcontrol { - int X,Y,W,H,A; - } fillcontrol; - - - fillcontrol.X = x; - fillcontrol.Y = y; - fillcontrol.W = w; - fillcontrol.H = h; - fillcontrol.A = attrib; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_FILL_ATTRIB, &fillcontrol, sizeof(fillcontrol), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. * - * * - * Use this routine to scroll the monochrome screen up by the number of lines specified. * - * This routine is typically called by the printing functions so that the monochrome screen * - * behaves in the expected manner -- printing at the bottom of the screen scrolls it up * - * to make room for new text. * - * * - * INPUT: lines -- The number of lines to scroll the monochrome screen. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Scroll(int ) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SCROLL, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Printf -- Prints a formatted string to the monochrome screen. * - * * - * Use this routine to output a formatted string, using the standard formatting options, * - * to the monochrome screen object's current cursor position. * - * * - * INPUT: text -- Pointer to the text to print. * - * * - * ... -- Any optional parameters to supply in formatting the text. * - * * - * OUTPUT: none * - * * - * WARNINGS: The total formatted text length must not exceed 255 characters. * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Printf(char const *text, ...) -{ -#ifdef _WINDOWS - va_list va; - /* - ** The buffer object is placed at the end of the local variable list - ** so that if the sprintf happens to spill past the end, it isn't likely - ** to trash anything (important). The buffer is then manually truncated - ** to maximum allowed size before being printed. - */ - char buffer[256]; - - if ( !Enabled || (Handle == INVALID_HANDLE_VALUE) ) return; - - va_start(va, text); - vsprintf(buffer, text, va); - buffer[sizeof(buffer)-1] = '\0'; - - Print(buffer); - va_end(va); -#endif -} - - -/*********************************************************************************************** - * MonoClass::Printf -- Prints formatted text using text string number. * - * * - * This routine will take the given text string number and print the formatted text to * - * the monochrome screen. * - * * - * INPUT: text -- The text number to convert into real text (by way of external function). * - * * - * ... -- Additional parameters as needed. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Printf(int text, ...) -{ -#ifdef _WINDOWS - va_list va; - - /* - ** The buffer object is placed at the end of the local variable list - ** so that if the sprintf happens to spill past the end, it isn't likely - ** to trash anything (important). The buffer is then manually truncated - ** to maximum allowed size before being printed. - */ - char buffer[256]; - - if ( !Enabled || (Handle == INVALID_HANDLE_VALUE) ) return; - - va_start(va, text); - vsprintf(buffer, Fetch_String(text), va); - buffer[sizeof(buffer)-1] = '\0'; - - Print(buffer); - va_end(va); -#endif -} - - -/*********************************************************************************************** - * MonoClass::Print -- Prints the text string at the current cursor coordinates. * - * * - * Use this routine to output the specified text string at the monochrome object's current * - * text coordinate position. * - * * - * INPUT: ptr -- Pointer to the string to print. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Print(char const * ptr) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - WriteFile(Handle, ptr, strlen(ptr), &retval, NULL); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Set_Default_Attribute -- Set the default attribute for this window. * - * * - * This will change the default attribute to that specified. All future text will use * - * this new attribute. * - * * - * INPUT: attrib -- The attribute to make the current default. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 01/06/1997 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Set_Default_Attribute(MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_ATTRIBUTE, &attrib, 1, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. * - * * - * Use this routine to output text to the monochrome object at the X and Y coordinates * - * specified. * - * * - * INPUT: text -- Pointer to the text string to display. * - * * - * x,y -- The X and Y character coordinates to start the printing at. * - * * - * attrib-- Optional parameter that specifies what text attribute code to use. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Text_Print(char const *text, int x, int y, MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - - Set_Cursor(x, y); - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_ATTRIBUTE, &attrib, 1, NULL, 0, &retval, 0); - Print(text); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Text_Print -- Simple text printing from text number. * - * * - * This will print the text (represented by the text number) to the location on the * - * monochrome screen specified. * - * * - * INPUT: text -- The text number to print (converted to real text by external routine). * - * * - * x,y -- The coordinates to begin the printing at. * - * * - * attrib-- The character attribute to use while printing. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Text_Print(int text, int x, int y, MonoAttribute attrib) -{ - Text_Print(Fetch_String(text), x, y, attrib); -} - - -/*********************************************************************************************** - * MonoClass::Print -- Simple print of text number. * - * * - * Prints text represented by the text number specified. * - * * - * INPUT: text -- The text number to print (converted to real text by external routine). * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Print(int text) -{ - Print(Fetch_String(text)); -} - - -/*********************************************************************************************** - * MonoClass::View -- Brings the mono object to the main display. * - * * - * Use this routine to display the mono object on the monochrome screen. It is possible * - * that the mono object exists on some background screen memory. Calling this routine will * - * perform the necessary memory swapping to bring the data to the front. The mono object * - * that was currently being viewed is not destroyed by this function. It is merely moved * - * off to some background page. It can be treated normally, except that is just isn't * - * visible. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::View(void) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_BRING_TO_TOP, NULL, 0, NULL, 0, &retval, 0); - Current = this; - } -#endif -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp deleted file mode 100644 index ed6d6013349..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp +++ /dev/null @@ -1,2776 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/mpmath.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * _Byte_Precision -- Determines the number of bytes significant in long integer. * - * memrev -- Reverse the byte order of the buffer specified. * - * XMP_Abs -- Perform an absolute value on the specified MP number. * - * XMP_Add -- Add two MP numbers with a carry option. * - * XMP_Add_Int -- Add an integer to an MP number (with carry). * - * XMP_Compare -- Compare one MP number with another. * - * XMP_Count_Bits -- Count the total number of bits (precision) in MP number. * - * XMP_Count_Bytes -- Counts the number of precision bytes in MP number. * - * XMP_Dec -- Decrement the MP number by one. * - * XMP_Decode_ASCII -- Convert ASCII into an MP number. * - * XMP_DER_Decode -- Decode a DER number into an MP number. * - * XMP_DER_Encode -- Encode a number into a buffer using DER. * - * XMP_DER_Length_Encode -- Output the length of a DER block. * - * XMP_Double_Mul -- Double precision MP multiply. * - * XMP_Encode -- Encode MP number into buffer as compactly as possible. * - * XMP_Fermat_Test -- Performs Fermat's Little Theorem on an MP number. * - * XMP_Hybrid_Mul -- Special hybrid short multiply (with carry). * - * XMP_Inc -- Increment an MP number by one. * - * XMP_Init -- Initialize an MP number to a starting value. * - * XMP_Inverse_A_Mod_B -- Inverts and performs modulus on an MP number. * - * XMP_Is_Prime -- Determine if the specified MP number is prime. * - * XMP_Is_Small_Prime -- Determine if MP number is a small prime. * - * XMP_Mod_Mult -- Perform a multiply - modulus operation. * - * XMP_Mod_Mult_Clear -- Remove temporary values from memory. * - * XMP_Move -- Assign one MP number to another. * - * XMP_Neg -- Negate the specified MP number. * - * XMP_Not -- Perform bitwise NOT operation on MP number. * - * XMP_Prepare_Modulus -- Prepare globals for modulus operation. * - * XMP_Rabin_Miller_Test -- Performs the Rabin Miller test for primality. * - * XMP_Randomize -- Generate a random MP number between the boundaries specified. * - * XMP_Randomize -- Generate a random MP number. * - * XMP_Reciprocal -- Compute the reciprocal (inverse) of the MP number. * - * XMP_Rotate_Left -- Rotate specified MP number leftward. * - * XMP_Shift_Left_Bits -- Shifts the MP number left by the specified bit count. * - * XMP_Shift_Right_Bits -- Shift the MP number right by specified bit count. * - * XMP_Signed_Decode -- Decode a number as if it were signed. * - * XMP_Signed_Div -- Signed divide of one MP number into another. * - * XMP_Signed_Mult -- A signed multiply between two MP numbers. * - * XMP_Signed_Mult_Int -- Multiply an MP number by a signed simple integer. * - * XMP_Significance -- Fetch the precision (bytes) of the MP number. * - * XMP_Small_Divisors_Test -- Perform the small divisors test on an MP number. * - * XMP_Sub -- Subtract one MP number from another (with borrow). * - * XMP_Sub_Int -- Subtract an integer from an MP number (with borrow). * - * XMP_Unsigned_Decode -- Decode a number as if it were unsigned. * - * XMP_Unsigned_Div -- Unsigned divide of one MP number into another. * - * XMP_Unsigned_Div_Int -- Perform a short integer divide into an MP number. * - * XMP_Unsigned_Mult -- Multiply two unsigned MP numbers together. * - * XMP_Unsigned_Mult_Int -- Multiply an MP number by a simple integer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "MPMATH.H" -#include "win.h" -#include -#include -#include -#include -#include - - -extern unsigned short primeTable[3511]; - - - -#define UPPER_MOST_BIT 0x80000000L -#define SEMI_UPPER_MOST_BIT 0x8000 -#define SEMI_MASK ((unsigned short)~0) - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) -#endif - -#ifndef __BORLANDC__ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define _USERENTRY -#endif - - -// Misc functions. -void memrev(char * buffer, size_t length); -unsigned short mp_quo_digit(unsigned short * dividend); - - -unsigned short const * MPEXPORT XMP_Fetch_Prime_Table(void) -{ - return(primeTable); -} - - -int MPEXPORT XMP_Fetch_Prime_Size(void) -{ - return(ARRAY_SIZE(primeTable)); -} - - -bool MPEXPORT XMP_Test_Eq_Int(digit const * r, int i, int p) -{ - return( (*r == (digit)i ) && XMP_Significance(r,p) <= 1 ); -} - - - -/*********************************************************************************************** - * _Byte_Precision -- Determines the number of bytes significant in long integer. * - * * - * This utility routine will determine the number of precision bytes exist in the long * - * integer specified. There are some optimizations that can occur if the byte precision * - * is known. * - * * - * INPUT: value -- The value of the long integer that the byte precision will be calculated * - * for. * - * * - * OUTPUT: Returns with the number of bytes that the long integer requires (at a minimum) * - * to cover the precision of the integer. The minimum value will be 1, the maximum * - * will be 4. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -static int _Byte_Precision(unsigned long value) -{ - int byte_count; - for (byte_count = sizeof(value); byte_count; byte_count--) { - if (value >> ((byte_count-1)*8)) break; - } - return(byte_count); -} - - -/*********************************************************************************************** - * XMP_DER_Length_Encode -- Output the length of a DER block. * - * * - * This routine will output the length of the block using Distinguished Encoding Rules. * - * The rest of the block must be filled in as appropriate. For data blocks that are less * - * than 128 bytes long, the header consists of only one byte. Longer buffers lengths * - * can consume up to 5 bytes (depends on magnitude of the length value). * - * * - * INPUT: length -- The length of the data block to be output. * - * * - * output -- Pointer to the memory block that will be set up. * - * * - * OUTPUT: Returns with the number of bytes (header) that was used to store the length * - * value. Subsequent data must be placed after the header. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_DER_Length_Encode(unsigned long length, unsigned char * output) -{ - assert(output != NULL); - - int header_length = 0; - - if (length <= SCHAR_MAX) { - output[header_length++] = (unsigned char)length; - } else { - output[header_length++] = (unsigned char)(_Byte_Precision(length) | 0x80); - for (int byte_counter = _Byte_Precision(length); byte_counter; --byte_counter) { - output[header_length++] = (unsigned char)(length >> ((byte_counter-1)*8)); - } - } - return(header_length); -} - - -/*********************************************************************************************** - * XMP_DER_Encode -- Encode a number into a buffer using DER. * - * * - * This routine is used to encode a number into a buffer using Distinguished Encoding * - * Rules. The number of bytes used will be, typically, two bytes more than the number of * - * precision bytes in the number. * - * * - * INPUT: from -- Pointer to the multi-precision number. * - * * - * output -- Pointer to the buffer that will hold the DER encoded number. * - * * - * precision-- The precision of the multi-precision number. * - * * - * OUTPUT: Returns with the number of bytes used in the output buffer. * - * * - * WARNINGS: Make sure the buffer is big enough to hold the DER encoded number. For safety * - * make sure it is precision+6 bytes long. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_DER_Encode(digit const * from, unsigned char * output, int precision) -{ - assert(from != NULL); - assert(output != NULL); - assert(precision > 0); - - unsigned char buffer[MAX_UNIT_PRECISION*sizeof(digit)+1]; - int header_count = 0; - - unsigned number_count = XMP_Encode(buffer, from, precision); - - output[header_count++] = 0x02; - header_count += XMP_DER_Length_Encode(number_count, &output[header_count]); - memcpy(&output[header_count], buffer, number_count); - - return(header_count+number_count); -} - - -/*********************************************************************************************** - * XMP_DER_Decode -- Decode a DER number into an MP number. * - * * - * Use this routine to decode a Distinguished Encoding Rules number into a multi-precision * - * number. This is the counterpart function to the XMP_DER_Encode() function. * - * * - * INPUT: result -- The buffer the hold the result MP number. * - * * - * input -- Pointer to the DER encoded number. * - * * - * precision -- The precision of the MP number. This is the maximum precision the * - * DER number can be. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_DER_Decode(digit * result, unsigned char const * input, int precision) -{ - assert(result != NULL); - assert(input != NULL); - assert(precision > 0); - - if (*input++ == 0x02) { - unsigned byte_count; - - if ((*input & 0x80) == 0) { - byte_count = *input++; - } else { - int length = *input++ & 0x7f; - if (length > 2) return; - byte_count = *input++; - if (length > 1) byte_count = (byte_count << 8) | *input++; - } - if (byte_count <= (precision * sizeof(digit))) { - XMP_Signed_Decode(result, input, byte_count, precision); - } - } -} - - -/*********************************************************************************************** - * XMP_Encode_Bounded -- Encode MP number into buffer. * - * * - * This routine will encode an multi-precision number into a buffer of specified length. * - * The number of stored in "big endian" format with appropriate sign extension. * - * * - * INPUT: to -- Pointer to the buffer to place the number. * - * * - * tobytes -- The number of bytes to use in the destination buffer. * - * * - * from -- Pointer to the MP number to be encoded. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes placed into the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -unsigned MPEXPORT XMP_Encode_Bounded(unsigned char * to, unsigned tobytes, digit const * from, int precision) -{ - assert(to != NULL); - assert(from != NULL); - assert(tobytes > 0); - assert(precision > 0); - - unsigned frombytes = precision * sizeof(digit); - unsigned char filler = (unsigned char)(XMP_Is_Negative(from, precision) ? 0xff : 0); - - unsigned index; - for (index = 0; index < (tobytes-frombytes); index++) { - *to++ = filler; - } - - const unsigned char * fptr = ((const unsigned char *)from) + min(tobytes, frombytes); - for (index = 0; index < min(tobytes, frombytes); index++) { - *to++ = *--fptr; - } - - return(tobytes); -} - - -/*********************************************************************************************** - * XMP_Encode -- Encode MP number into buffer as compactly as possible. * - * * - * This routine will encode the MP number into the specified buffer. The number will be * - * encoded using the least number of bytes possible. * - * * - * INPUT: to -- The buffer to encode the MP number into. * - * * - * from -- Pointer to the MP number to be encoded. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes used in the destination buffer to hold the * - * encoded number. * - * * - * WARNINGS: Be sure the destination buffer is big enough to hold the encoded MP number. * - * A safe size would be the precision plus one. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -#ifdef __WATCOMC__ -#pragma warning 364 9 -#endif -unsigned MPEXPORT XMP_Encode(unsigned char * to, digit const * from, int precision) -{ - assert(to != NULL); - assert(from != NULL); - assert(precision > 0); - - bool is_negative = XMP_Is_Negative(from, precision); - unsigned char filler = (unsigned char)(is_negative ? 0xff : 0); - unsigned char * number_ptr; - - unsigned char * const end = (unsigned char *)from; - for (number_ptr = (unsigned char *)end + precision - 1; number_ptr > (unsigned char *)end; number_ptr--) { - if (*number_ptr != filler) break; - } - - unsigned index = 0; - if (((*number_ptr & 0x80) && !is_negative) || (!(*number_ptr & 0x80) && is_negative)) { - to[index++] = filler; - } - - to[index++] = *number_ptr; - - while (number_ptr != end) { - to[index++] = *--number_ptr; - } - return(index); -} - - -/*********************************************************************************************** - * XMP_Signed_Decode -- Decode a number as if it were signed. * - * * - * Use this routine to convert a coded number back into an MP number. The coded number * - * is presumed to be signed. * - * * - * INPUT: result -- Pointer to the buffer that will hold the decoded MP number. * - * * - * from -- Pointer to the encoded MP number. * - * * - * frombytes-- The number of bytes consumed by the encoded MP number. * - * * - * precision -- The precision of the MP number (maximum) of the result. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure that the precision is sufficient to hold the decoded MP number. * - * Otherwise, the result is undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Signed_Decode(digit * result, const unsigned char * from, int frombytes, int precision) -{ - assert(result != NULL); - assert(from != NULL); - assert(frombytes > 0); - assert(precision > 0); - - unsigned char filler = (unsigned char)((*from & 0x80) ? 0xff : 0); - - int fillcount = precision * sizeof(digit) - frombytes; - unsigned char * dest = (unsigned char *)&result[precision]; - - /* - ** Fill in any excess significant bytes. - */ - int index; - for (index = 0; index < fillcount; index++) { - *--dest = filler; - } - - /* - ** Move in the remaining bytes. - */ - for (index = 0; index < frombytes; index++) { - *--dest = *from++; - } -} - - -/*********************************************************************************************** - * XMP_Unsigned_Decode -- Decode a number as if it were unsigned. * - * * - * Use this routine to decode a MP number and treat it as if it were unsigned. * - * * - * INPUT: result -- Pointer to the buffer to hold the result MP number. * - * * - * from -- Pointer to the encoded MP number. * - * * - * frombytes-- The number of bytes in the encoded number. * - * * - * precision-- The precision of the result MP number -- maximum precision. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the result MP precision is sufficient to hold the decoded number or * - * else the result is undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Unsigned_Decode(digit * result, const unsigned char * from, int frombytes, int precision) -{ - assert(result != NULL); - assert(from != NULL); - assert(frombytes > 0); - assert(precision > 0); - - int fillcount = precision * sizeof(digit) - frombytes; - unsigned char * dest = (unsigned char *)&result[precision]; - - /* - ** Fill in any excess significant bytes. - */ - int index; - for (index = 0; index < fillcount; index++) { - *--dest = '\0'; - } - - /* - ** Move in the remaining bytes. - */ - for (index = 0; index < frombytes; index++) { - *--dest = *from++; - } -} - - -/*********************************************************************************************** - * XMP_Significance -- Fetch the precision (bytes) of the MP number. * - * * - * This routine will return with the precision of the MP number expressed as bytes. The * - * MP number is presumed unsigned. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- The precision of the MP number to examine. * - * * - * OUTPUT: Returns with the minimum number of bytes consumed by this MP number. * - * * - * WARNINGS: Passing a signed MP number to this routine will return an artificially greater * - * precision than it really is. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Significance(const digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - number += precision; - do { - number--; - if (*number) break; - precision--; - } while (precision); - return(precision); -} - - -/*********************************************************************************************** - * XMP_Inc -- Increment an MP number by one. * - * * - * This will increment the MP number by one. * - * * - * INPUT: number -- Pointer to the MP number to increment. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: If the number wraps around the maximum precision, the results are undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Inc(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - do { - *number = (*number) + 1; - if (*number != 0) break; - number++; - precision --; - } while (precision); -} - - -/*********************************************************************************************** - * XMP_Dec -- Decrement the MP number by one. * - * * - * Use this routine to decrement the specified MP number by one. * - * * - * INPUT: number -- Pointer to the MP number to decrement. * - * * - * precision-- The precision of the MP number to decrement. * - * * - * OUTPUT: none * - * * - * WARNINGS: If the number wraps below zero, the results are undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Dec(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - do { - *number -= 1; - if ((*number) != ~(digit)0) break; - number++; - precision--; - } while (precision); -} - - -/*********************************************************************************************** - * XMP_Neg -- Negate the specified MP number. * - * * - * This routine will negate (reverse sign) of the specified MP number. * - * * - * INPUT: number -- Pointer to the MP number to negate. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Neg(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - XMP_Not(number, precision); - XMP_Inc(number, precision); -} - - -/*********************************************************************************************** - * XMP_Abs -- Perform an absolute value on the specified MP number. * - * * - * This will perform the absolute value function on the specified MP number. That is, if * - * the MP number is negative, it will be transformed into a positive number. If the number * - * is already positive, then it will be left alone. * - * * - * INPUT: number -- Pointer to the MP number to ABS. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Abs(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - if (XMP_Is_Negative(number, precision)) { - XMP_Neg(number, precision); - } -} - - -/*********************************************************************************************** - * XMP_Shift_Right_Bits -- Shift the MP number right by specified bit count. * - * * - * Use this routine to perform a right shift of the MP number by the number of bits * - * specified. * - * * - * INPUT: number -- Pointer to the MP number to perform the shift upon. * - * * - * bits -- The number of bits to shift. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is an unsigned shift. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Shift_Right_Bits(digit * number, int bits, int precision) -{ - assert(number != NULL); - assert(bits >= 0); - assert(precision > 0); - - if (bits == 0) return; /* shift zero bits is a no-op */ - - /* - ** If the shift is by whole bytes, then the shift operation can - ** be performed very quickly. - */ - if (bits == UNITSIZE) { - number += precision; - digit carry = 0; - while (precision--) { - number--; - digit temp = *number; - *number = carry; - carry = temp; - } - return; - } - - /* - ** If the number of bits to shift is less than one byte, then the - ** shift operation is a relatively simple "ripple" effect through - ** the MP number buffer. - */ - if (bits < UNITSIZE) { - number += precision; - digit carry = 0; - digit bitmask = (1L << bits) - 1; - int unbits = UNITSIZE - bits; - - while (precision--) { - number--; - digit temp = *number & bitmask; - *number >>= bits; - *number |= carry << unbits; - carry = temp; - } - return; - } - - /* - ** General purpose slow right. - */ - int digits_to_shift = bits / UNITSIZE; - int bits_to_shift = bits % UNITSIZE; - - int index; - for (index = digits_to_shift; index < (precision-1); index++) { - *number = (*(number + digits_to_shift) >> bits_to_shift) | (*(number + (digits_to_shift + 1)) << (UNITSIZE - bits_to_shift)); - number++; - } - - if (digits_to_shift < precision) { - *number = (*(number + digits_to_shift) >> bits_to_shift); - number++; - } - - for (index= 0; index < min(digits_to_shift, precision); index++) { - *number++ = 0; - } -} - - -/*********************************************************************************************** - * XMP_Shift_Left_Bits -- Shifts the MP number left by the specified bit count. * - * * - * Use this routine to perform a left shift of the specified MP number. * - * * - * INPUT: number -- Pointer to the MP number to perform the shift operation on. * - * * - * bits -- The number of bits to shift the MP number leftward. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Shift_Left_Bits(digit * number, int bits, int precision) -{ - assert(number != NULL); - assert(bits >= 0); - assert(precision > 0); - - if (bits == 0) return; /* shift zero bits is a no-op */ - - /* - ** If the shift is by whole bytes, then the shift operation can - ** be performed very quickly. - */ - if (bits == UNITSIZE) { - digit carry = 0; - while (precision--) { - digit temp = *number; - *number = carry; - carry = temp; - number++; - } - return; - } - - /* - ** If the number of bits to shift is less than one byte, then the - ** shift operation is a relatively simple "ripple" effect through - ** the MP number buffer. - */ - if (bits < UNITSIZE) { - digit carry = 0; - digit bitmask = ~(((digit)-1) >> bits); - int unbits = UNITSIZE - bits; /* shift bits must be <= UNITSIZE */ - - while (precision--) { - digit temp = *number & bitmask; - *number = (*number << bits) | (carry >> unbits); - carry = temp; - number++; - } - return; - } - - /* - ** General purpose slow left; - */ - int digits_to_shift = bits / UNITSIZE; - int bits_to_shift = bits % UNITSIZE; - - int index; - number += precision-1; - for (index = digits_to_shift; index < (precision-1); index++) { - *number = (*(number - digits_to_shift) << bits_to_shift) | (*(number - (digits_to_shift + 1)) >> (UNITSIZE - bits_to_shift)); - number--; - } - - if (digits_to_shift < precision) { - *number = (*(number - digits_to_shift) << bits_to_shift); - number--; - } - - for (index = 0; index < min(digits_to_shift, precision); index++) { - *number-- = 0; - } -} - - -/*********************************************************************************************** - * XMP_Rotate_Left -- Rotate specified MP number leftward. * - * * - * This routine will rotate the MP number to the left by one bit. The rotation passes bits * - * through a "carry" bit position. The initial value of this "carry" bit is passed to the * - * routine and the final value is returned as the result. * - * * - * INPUT: number -- Pointer to the MP number to perform the left rotate upon. * - * * - * carry -- The initial value of the "carry" bit. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: Returns with the final value of the carry bit. This is the the bit value of the * - * upper most bit of the MP number prior to the rotate operation. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Rotate_Left(digit * number, bool carry, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - while (precision--) { - bool temp = ((*number & UPPER_MOST_BIT) != 0); - *number = (*number << 1); - if (carry) *number = *number + 1; - carry = temp; - number++; - } - return carry; -} - - -/*********************************************************************************************** - * XMP_Not -- Perform bitwise NOT operation on MP number. * - * * - * Perform a bitwise NOT operation. * - * * - * INPUT: number -- Pointer to the MP number to operate on. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Not(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - for (int index = 0; index < precision; index++) { - *number = ~(*number); - number++; - } -} - - -/*********************************************************************************************** - * XMP_Init -- Initialize an MP number to a starting value. * - * * - * This will initialize (assign) a number to an MP number. The initial value is limited * - * to the precision allowed by a DIGIT type. * - * * - * INPUT: number -- Pointer to the MP number to initialize. * - * * - * value -- Initial integer value to assign to the MP number. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Init(digit * number, digit value, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - memset(number, '\0', precision * sizeof(digit)); - *number = value; -} - - -/*********************************************************************************************** - * XMP_Count_Bits -- Count the total number of bits (precision) in MP number. * - * * - * This routine will count the maximum number of bits used by this MP number. The result * - * could be referred to as the "bit precision" of the MP number. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- The (digit) precision of the MP number. * - * * - * OUTPUT: Returns with the number of significant bits in the MP number. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -unsigned MPEXPORT XMP_Count_Bits(const digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - int sub_precision = XMP_Significance(number, precision); - if (!sub_precision) return(0); - int total_bit_count = XMP_Digits_To_Bits(sub_precision); - number += sub_precision-1; - digit high_bit_mask = UPPER_MOST_BIT; - - while (!((*number) & high_bit_mask)) { - high_bit_mask >>= 1; - total_bit_count--; - } - - return(total_bit_count); -} - - -/*********************************************************************************************** - * XMP_Count_Bytes -- Counts the number of precision bytes in MP number. * - * * - * This routine will scan the MP number and determine the number of bytes needed to * - * represent the MP number. Consider the result the "byte precision" of the number. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- Precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes required to represent the precision of the number.* - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Count_Bytes(const digit * number, int precision) -{ - unsigned char * ptr = (unsigned char *)number; - int count = 0; - for (unsigned index = 0; index < precision*sizeof(digit); index++) { - if (!*ptr) break; - count++; - ptr++; - } - return(count); -} - - -/*********************************************************************************************** - * XMP_Move -- Assign one MP number to another. * - * * - * This will move one MP number over the top of another. * - * * - * INPUT: dest -- Destination MP number (will get clobbered). * - * * - * source -- Source MP number. * - * * - * precision-- Precision of both MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Both MP numbers must have the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Move(digit * dest, digit const * source, int precision) -{ - memcpy(dest, source, precision * sizeof(digit)); -} - - -/*********************************************************************************************** - * XMP_Compare -- Compare one MP number with another. * - * * - * This routine will compare two MP numbers. It will return a value indicating which MP * - * number is greater or if they are equal. * - * * - * INPUT: left_number -- The left hand MP number. * - * * - * right_number-- The right hand MP number. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: Returns -1 if the left_number is less than the right_number. * - * Returns 1 if the left_number is greater than the right number. * - * Returns 0 if both numbers are identical. * - * * - * WARNINGS: Both numbers must have the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Compare(const digit * left_number, const digit * right_number, int precision) -{ - left_number += precision-1; - right_number += precision-1; - do { - if (*left_number < *right_number) return -1; - if (*left_number > *right_number) return 1; - left_number--; - right_number--; - precision--; - } while (precision); - return 0; -} - - -/*********************************************************************************************** - * XMP_Add -- Add two MP numbers with a carry option. * - * * - * Use this routine to add one MP number to another. There is an optional "carry" value * - * that (when true) will add an additional 1 to the result. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. This can be the * - * same value as the left_number or right_number pointers. * - * * - * left_number -- The left hand MP number. * - * * - * right_number-- The right hand MP number. * - * * - * carry -- Optional carry flag (typically this will be false). * - * * - * precision -- The precision of the numbers involved. * - * * - * OUTPUT: Returns with the carry flag after the addition. If the value is true then an * - * overflow occurred. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Add(digit * result, const digit * left_number, const digit * right_number, bool carry, int precision) -{ - while (precision--) { - digit term = *left_number + *right_number; - digit final = term + carry; - carry = (term < *left_number || (carry && final == 0)); - - right_number++; - left_number++; - *result++ = final; - } - return(carry); -} - - -/*********************************************************************************************** - * XMP_Add_Int -- Add an integer to an MP number (with carry). * - * * - * This routine will add an integer number to an MP number. There is an optional carry * - * parameter. If the carry flag is true, and additional 1 will be added to the result. * - * This routine is much faster than adding two MP numbers together. * - * * - * INPUT: result -- Pointer to the result MP number. This pointer can be the same as * - * the left_number parameter. * - * * - * left_number -- Pointer to the left hand MP number. * - * * - * right_number-- The integer number to add to the left hand number. * - * * - * carry -- Input carry flag. If this is true, then an additional one will be * - * added to the result. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: Returns with the result carry flag. A true value means the addition overflowed. * - * * - * WARNINGS: All MP numbers must share the same precision. Negative numbers are not * - * supported. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Add_Int(digit * result, const digit * left_number, digit right_number, bool carry, int precision) -{ - while (precision--) { - digit term = *left_number + right_number; - digit final = term + carry; - carry = (term < *left_number || (carry && final == 0)); - - right_number = 0; - left_number++; - *result++ = final; - } - return(carry); -} - - -/*********************************************************************************************** - * XMP_Sub -- Subtract one MP number from another (with borrow). * - * * - * This routine will subtract one MP number from another. There is an optional borrow * - * flag that can be specified. * - * * - * INPUT: result -- Pointer to the MP number that will hold the result. This pointer * - * can be the same as the left_number or right_number parameters. * - * * - * left_number -- The left hand number (value will be subtracted from this). * - * * - * right_number-- The right hand number (the value to subtract from the left number) * - * * - * borrow -- The optional borrow flag. If this flag is true, the an extra one * - * will be subtracted from the result. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: Returns with the borrow result flag. If the value is true, then an underflow * - * occurred during subtraction. * - * * - * WARNINGS: All MP numbers must share the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Sub(digit * result, const digit * left_number, const digit * right_number, bool borrow, int precision) -{ - const unsigned short * left_number_ptr = (const unsigned short *)left_number; - const unsigned short * right_number_ptr = (const unsigned short *)right_number; - unsigned short * result_ptr = (unsigned short *)result; - - precision *= 2; - while (precision--) { - digit x = (digit) *left_number_ptr - (digit) *right_number_ptr - (digit) borrow; - right_number_ptr++; - left_number_ptr++; - *result_ptr++ = (unsigned short)x; - borrow = (((1L << 16) & x) != 0L); - } - return (borrow); -} - - -/*********************************************************************************************** - * XMP_Sub_Int -- Subtract an integer from an MP number (with borrow). * - * * - * This will subtract an integer from the specified MP number. There is an optional borrow * - * flag available. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * left_number -- Pointer to the MP number that will be subtracted FROM. * - * * - * right_number-- The integer to subtract from the left hand number. * - * * - * borrow -- The optional borrow flag. If this value is true, then an extra one * - * will be subtracted from the result. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: Returns with the borrow flag of the result. If this value is true, then an * - * underflow occurred during subtraction. * - * * - * WARNINGS: The precision must be identical between the MP numbers involved. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Sub_Int(digit * result, const digit * left_number, unsigned short right_number, bool borrow, int precision) -{ - const unsigned short * left_number_ptr = (const unsigned short *)left_number; - unsigned short * result_ptr = (unsigned short *)result; - - precision *= 2; - while (precision--) { - digit x = (digit) *left_number_ptr - right_number - borrow; - left_number_ptr++; - *result_ptr++ = (unsigned short)x; - borrow = (((1L << 16) & x) != 0L); - - right_number = 0; - } - return (borrow); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Mult -- Multiply two unsigned MP numbers together. * - * * - * This routine will multiply two MP numbers together. The result will have the sum of the * - * significance of the two. * - * * - * INPUT: prod -- Pointer to the product MP buffer that will hold the result. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier MP number. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the product will fit within the precision of the result. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - XMP_Init(prod, 0, precision); - - /* - ** Multiplying by zero is always a zero product. - */ - if (XMP_Test_Eq_Int(multiplicand, 0, precision) || XMP_Test_Eq_Int(multiplier, 0, precision)) { - return 0; - } - - int total_bit_count = XMP_Count_Bits(multiplier, precision); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - int sub_precision = XMP_Bits_To_Digits(total_bit_count); - if (!sub_precision) return(0); - multiplier += sub_precision; - - while (total_bit_count--) { - XMP_Shift_Left_Bits(prod, 1, precision); - - if ((*(multiplier-1)) & high_bit_mask) { - XMP_Add(prod, prod, multiplicand, 0, precision); - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - multiplier--; - } - - } - return 0; -} - - -/*********************************************************************************************** - * XMP_Unsigned_Mult_Int -- Multiply an MP number by a simple integer. * - * * - * This is a very fast multiply since the multiplier is just an integer integral. * - * * - * INPUT: prod -- Pointer to the product MP number. * - * * - * multiplicand-- Pointer to the MP number that is the multiplicand. * - * * - * multiplier -- The integral integer that is the multiplier. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: The multiplier must fit in a signed integer (although it isn't a signed value). * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Mult_Int(digit * prod, const digit * multiplicand, short multiplier, int precision) -{ - const unsigned short * m2 = (const unsigned short *)multiplicand; - unsigned short * pr = (unsigned short *)prod; - unsigned long carry = 0; - for (int i = 0; i < precision*2; ++i) { - unsigned long p = (((unsigned long)multiplier) * *m2) + carry;; - *pr = (unsigned short) p; - carry = p >> 16; - m2++; - pr++; - } - - /* Add carry to the next higher word of product / dividend */ -// *pr += (unsigned short)carry; - return(0); -} - - -/*********************************************************************************************** - * XMP_Signed_Mult_Int -- Multiply an MP number by a signed simple integer. * - * * - * This will multiply the specified integer with the MP number. It is a much faster * - * multiply than when multiplying two MP numbers. * - * * - * INPUT: prod -- Pointer to the product MP number. * - * * - * multiplicand-- Pointer to the MP number that serves as the multiplicand. * - * * - * multiplier -- The simple integral integer used as the multiplier. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: The multiplier must fist within a signed short integer. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Signed_Mult_Int(digit * prod, const digit * multiplicand, signed short multiplier, int precision) -{ - if (XMP_Is_Negative(multiplicand, precision)) { - digit abs_multiplicand[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplicand, multiplicand, precision); - XMP_Neg(abs_multiplicand, precision); - - if (multiplier < 0) { - multiplier = (signed short)-multiplier; - - XMP_Unsigned_Mult_Int(prod, abs_multiplicand, multiplier, precision); - } else { - XMP_Unsigned_Mult_Int(prod, abs_multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } - } else { - if (multiplier < 0) { - multiplier = (signed short)-multiplier; - - XMP_Unsigned_Mult_Int(prod, multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } else { - XMP_Unsigned_Mult_Int(prod, multiplicand, multiplier, precision); - } - } - return(0); -} - - -/*********************************************************************************************** - * XMP_Signed_Mult -- A signed multiply between two MP numbers. * - * * - * This routine will perform a multiply between two signed MP numbers. * - * * - * INPUT: prod -- Pointer to the product MP number buffer. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier MP number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is not a very fast routine. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Signed_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - if (XMP_Is_Negative(multiplicand, precision)) { - digit abs_multiplicand[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplicand, multiplicand, precision); - XMP_Neg(abs_multiplicand, precision); - - if (XMP_Is_Negative(multiplier, precision)) { - digit abs_multiplier[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplier, multiplier, precision); - XMP_Neg(abs_multiplier, precision); - - XMP_Unsigned_Mult(prod, abs_multiplicand, abs_multiplier, precision); - } else { - XMP_Unsigned_Mult(prod, abs_multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } - } else { - if (XMP_Is_Negative(multiplier, precision)) { - digit abs_multiplier[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplier, multiplier, precision); - XMP_Neg(abs_multiplier, precision); - - XMP_Unsigned_Mult(prod, multiplicand, abs_multiplier, precision); - XMP_Neg(prod, precision); - } else { - XMP_Unsigned_Mult(prod, multiplicand, multiplier, precision); - } - } - return(0); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Div_Int -- Perform a short integer divide into an MP number. * - * * - * This routine performs a fast divide of the specified MP dividend by a simple * - * short integer. The division is an UNSIGNED division however. * - * * - * INPUT: quotient -- Pointer to the MP number buffer where the quotient will go. * - * * - * dividend -- Pointer to the MP number that serves as the dividend. * - * * - * divisor -- The simple signed short integer that serves as the divisor. * - * * - * precision -- The precision that is used by the MP numbers involved. * - * * - * OUTPUT: Returns with the remainder of the division. * - * * - * WARNINGS: This is an UNSIGNED divide even. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short MPEXPORT XMP_Unsigned_Div_Int(digit * quotient, digit const * dividend, unsigned short divisor, int precision) -{ - if (!divisor) return 0; /* zero divisor means divide error */ - - unsigned short remainder = 0; - - XMP_Init(quotient, 0, precision); - - int total_bit_count = XMP_Count_Bits(dividend, precision); - int digit_precision = XMP_Bits_To_Digits(total_bit_count); - digit const * dividend_ptr = dividend + (digit_precision-1); - - if (!digit_precision) return(0); - - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - digit * quotient_ptr = quotient + (digit_precision-1); - - while (total_bit_count--) { - remainder <<= 1; - - if ((*dividend_ptr) & high_bit_mask) remainder++; - - if (remainder >= divisor) { - remainder -= divisor; - *quotient_ptr |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - --dividend_ptr; - --quotient_ptr; - } - } - - return(remainder); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Div -- Unsigned divide of one MP number into another. * - * * - * This will perform the (dog slow) divide of one MP number into another. Because of the * - * slowness of this routine, both the quotient and the remainder are available as a * - * result of the operation. * - * * - * INPUT: remainder -- Pointer to the MP buffer that will hold the remainder of the divide.* - * * - * quotient -- Pointer to the MP buffer that will hold the quotient of the divide. * - * * - * dividend -- The MP dividend (numerator) number. * - * * - * divisor -- The MP divisor (denominator) number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is very slow. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision) -{ - // check for divide by zero. - if (XMP_Test_Eq_Int(divisor, 0, precision)) return(-1); - - XMP_Init(remainder, 0, precision); - XMP_Init(quotient, 0, precision); - - int total_bit_count = XMP_Count_Bits(dividend, precision); - int digit_precision = XMP_Bits_To_Digits(total_bit_count); - if (!digit_precision) return(0); - - digit const * dividend_ptr = dividend + (digit_precision-1); - digit * quotient_ptr = quotient + (digit_precision-1); - - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - while (total_bit_count--) { - XMP_Shift_Left_Bits(remainder, 1, precision); - - if (((*dividend_ptr) & high_bit_mask) != 0) { - XMP_Inc(remainder, precision); - } - - if (XMP_Compare(remainder, divisor, precision) >= 0) { - XMP_Sub(remainder, remainder, divisor, 0, precision); - *quotient_ptr |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - dividend_ptr--; - quotient_ptr--; - } - - } - return 0; -} - - -/*********************************************************************************************** - * XMP_Signed_Div -- Signed divide of one MP number into another. * - * * - * This will perform a signed divide (very very slow) of one MP number into another. * - * Because of the slow nature of this routine, both the quotient and the remainder are * - * available as results. * - * * - * INPUT: remainder -- Pointer to the buffer that will hold the remainder of the divide. * - * * - * quotient -- Pointer to the buffer that will hold the quotient of the divide. * - * * - * dividend -- The dividend (numerator) MP number. * - * * - * divisor -- The divisor (denominator) MP number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is very very slow. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Signed_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision) -{ - bool negative = false; - - digit scratch_dividend[MAX_UNIT_PRECISION]; - XMP_Move(scratch_dividend, dividend, precision); - - digit scratch_divisor[MAX_UNIT_PRECISION]; - XMP_Move(scratch_divisor, divisor, precision); - - if (XMP_Is_Negative(scratch_dividend, precision)) { - XMP_Neg(scratch_dividend, precision); - negative = !negative; - } - - if (XMP_Is_Negative(scratch_divisor, precision)) { - XMP_Neg(scratch_divisor, precision); - negative = !negative; - } - - XMP_Unsigned_Div(remainder, quotient, scratch_dividend, scratch_divisor, precision); - - if (negative) { - XMP_Neg(quotient, precision); - if (!XMP_Test_Eq_Int(remainder, 0, precision)) { - XMP_Dec(quotient, precision); - XMP_Neg(remainder, precision); - XMP_Add(remainder, remainder, scratch_divisor, 0, precision); - } - } -} - - -/*********************************************************************************************** - * XMP_Inverse_A_Mod_B -- Inverts and performs modulus on an MP number. * - * * - * This is a utility routine that will perform an inverse on the MP number and then * - * perform a modulus of that number by another MP number. There are some algorithms that * - * require this process. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * number -- The MP number that will be inverted then modulo-ized. * - * * - * modulus -- The MP number to modulus the first number by. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Inverse_A_Mod_B(digit * result, digit const * number, digit const * modulus, int precision) -{ - digit g[3][MAX_UNIT_PRECISION]; - XMP_Move(g[0], modulus, precision); - XMP_Move(g[1], number, precision); - - digit v[3][MAX_UNIT_PRECISION]; - XMP_Init(v[0], 0, precision); - XMP_Init(v[1], 1, precision); - - digit y[MAX_UNIT_PRECISION]; - - int i; - for (i = 1; !XMP_Test_Eq_Int(g[i%3], 0, precision); i++) { - XMP_Unsigned_Div(g[(i+1)%3], y, g[(i-1)%3], g[i%3], precision); - - XMP_Unsigned_Mult(result, v[i%3], y, precision); - XMP_Sub(v[(i+1)%3], v[(i-1)%3], result, 0, precision); - } - - if (XMP_Is_Negative(v[(i-1)%3], precision)) { - XMP_Add(v[(i-1)%3], v[(i-1)%3], modulus, 0, precision); - } - - XMP_Move(result, v[(i-1)%3], precision); -} - - -/*********************************************************************************************** - * XMP_Reciprocal -- Compute the reciprocal (inverse) of the MP number. * - * * - * Use this routine to determine the inverse of the specified MP number. The inverse is * - * defined as 1/number. * - * * - * INPUT: result -- Pointer to the result MP number buffer. * - * * - * number -- The number to be inverted. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Reciprocal(digit * quotient, const digit * divisor, int precision) -{ - digit remainder[MAX_UNIT_PRECISION]; - - if (XMP_Test_Eq_Int(divisor, 0, precision)) return -1; /* zero divisor means divide error */ - - XMP_Init(remainder, 0, precision); - XMP_Init(quotient, 0, precision); - - /* normalize and compute number of bits in quotient first */ - unsigned total_bit_count = XMP_Count_Bits(divisor, precision); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count + 1); /* bitmask within a single digit */ - int sub_precision = XMP_Bits_To_Digits(total_bit_count + 1); - - XMP_Set_Bit(remainder, total_bit_count - 1); - - /* rescale quotient to precision of divisor bits */ - quotient += sub_precision-1; - - while (total_bit_count--) { - XMP_Shift_Left_Bits(remainder, 1, precision); - if (XMP_Compare(remainder, divisor, precision) >= 0) { - XMP_Sub(remainder, remainder, divisor, 0, precision); - *quotient |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - quotient--; - } - } - - XMP_Init(remainder, 0, precision); - return 0; -} - - -/*********************************************************************************************** - * XMP_Decode_ASCII -- Convert ASCII into an MP number. * - * * - * This routine will convert a supplied ASCII string into an MP number. * - * * - * INPUT: str -- Pointer to the ASCII string that will be converted. * - * * - * mpn -- Pointer to the MP number buffer that will be initialized. * - * * - * precision -- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Decode_ASCII(char const * str, digit * mpn, int precision) -{ - /* - ** Initialize the multiprecision number to zero. From this point - ** onward, this object can be manipulated as a regular number. - ** This is, in fact, what is done as the ascii string is parsed - ** into a working number. - */ - XMP_Init(mpn, 0, precision); - - /* - ** No string or zero length is considered '0'. - */ - if (!str) return; - int i = strlen(str); - if (i == 0) return; - - unsigned short radix; /* base 2-16 */ - switch (toupper(str[i-1])) { /* classify radix select suffix character */ - case '.': - radix = 10; - break; - - case 'H': - radix = 16; - break; - - case 'O': - radix = 8; - break; - - case 'B': /* caution! 'b' is a hex digit! */ - radix = 2; - break; - - default: - radix = 10; - break; - } - - bool minus = (*str == '-'); - if (minus) str++; - - digit c; - while ((c = (unsigned char)*str++) != 0) { - if (c == ',') continue; /* allow commas in number */ - - /* - ** If not a hexadecimal (highest base) digit then it is - ** clearly the end of the processable string. Bail out - ** of the scan loop. - */ - if (!isxdigit((char)c)) break; - - /* - ** Convert the character into an integer number 0 through 15. - */ - if (isdigit((char)c)) { - c -= '0'; - } else { - c = (unsigned char)(toupper((char)c) - 'A') + 10; - } - - /* - ** If the integer digit is greater than the radix, then we - ** know that further processing should stop. This is the - ** end of the number string. - */ - if (c >= radix) break; /* scan terminated by any non-digit */ - - - XMP_Unsigned_Mult_Int(mpn, mpn, radix, precision); - XMP_Add_Int(mpn, mpn, c, 0, precision); - } - if (minus) { - XMP_Neg(mpn, precision); - } -} - - -/*********************************************************************************************** - * XMP_Hybrid_Mul -- Special hybrid short multiply (with carry). * - * * - * Multiply the single-word multiplier times the multiprecision integer * - * in multiplicand, accumulating result in prod. The resulting * - * multiprecision prod will be 1 word longer than the multiplicand. * - * multiplicand is double precision words long. We add into prod, so caller * - * should zero it out first. For best results, this time-critical * - * function should be implemented in assembly. * - * NOTE: Unlike other functions in the multiprecision arithmetic * - * library, both multiplicand and prod are pointing at the LSB, * - * regardless of byte order of the machine. On an 80x86, this makes * - * no difference. But if this assembly function is implemented * - * on a 680x0, it becomes important. * - * * - * Note that this has been modified from the previous version to allow * - * better support for Smith's modmult: * - * The final carry bit is added to the existing product * - * array, rather than simply stored. * - * * - * INPUT: prod -- Pointer to the product MP number buffer. * - * * - * multiplicand -- Pointer to the multiplicand MP number. * - * * - * multiplier -- The short integer used as the multiplier. * - * * - * precision -- The precision of the MP number used. * - * * - * OUTPUT: none * - * * - * WARNINGS: The carry (if any) is added into the integer one beyond the end of the * - * product buffer. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void XMP_Hybrid_Mul(unsigned short * prod, unsigned short * multiplicand, unsigned short multiplier, int precision) -{ - unsigned long carry = 0; - for (int i = 0; i < precision; ++i) { - unsigned long p = (unsigned long)multiplier * *multiplicand++; - p += *prod + carry; - *prod++ = (unsigned short) p; - carry = p >> 16; - } - - /* Add carry to the next higher word of product / dividend */ - *prod += (unsigned short) carry; -} - - -/*********************************************************************************************** - * XMP_Double_Mul -- Double precision MP multiply. * - * * - * This will perform a double precision multiply of MP numbers. This means that the product * - * will be twice the precision of the components. * - * * - * INPUT: prod -- Pointer to the result buffer. This buffer must be able to hold * - * double the precision specified. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier number. * - * * - * precision -- The precision of the two component MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the product buffer can hold a double precision number. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Double_Mul(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - /* - ** Clear out the double precision product buffer. - */ - XMP_Init(prod, 0, precision*2); - - const unsigned short * multiplier_ptr = (const unsigned short *) multiplier; - unsigned short * product_ptr = (unsigned short *) prod; - - // Multiply multiplicand by each word in multiplier, accumulating prod. - for (int i = 0; i < precision*2; ++i) { - XMP_Hybrid_Mul(product_ptr++, (unsigned short *)multiplicand, *multiplier_ptr++, precision*2); - } -} - - - -static int _modulus_shift; // number of bits for recip scaling -static unsigned short _reciprical_high_digit; // MSdigit of scaled recip -static unsigned short _reciprical_low_digit; // LSdigit of scaled recip - -static int _modulus_sub_precision; // length of modulus in MULTUNITs -static int _modulus_bit_count; // number of modulus significant bits -static digit _scratch_modulus[MAX_UNIT_PRECISION]; // modulus - -// The double precision modulus staging buffer. -static digit _double_staging_number[MAX_UNIT_PRECISION * 2 + 2]; - -// most significant digits of modulus. -static digit _mod_quotient[4]; -static digit _mod_divisor[4]; - - -/*********************************************************************************************** - * XMP_Prepare_Modulus -- Prepare globals for modulus operation. * - * * - * Calculate the reciprocal of modulus with a precision of two MULTUNITs. * - * Assumes that precision has already been adjusted to the * - * size of the modulus, plus SLOP_BITS. * - * * - * Note: This routine was designed to work with large values and * - * doesn't have the necessary testing or handling to work with a * - * modulus having less than three significant digits. For such cases, * - * the separate multiply and modulus routines can be used. * - * * - * INPUT: modulus -- Pointer to the modulus number. * - * * - * precision-- The precision of the modulus number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int XMP_Prepare_Modulus(const digit * n_modulus, int precision) -{ - XMP_Move(_scratch_modulus, n_modulus, precision); - - _modulus_bit_count = XMP_Count_Bits(_scratch_modulus, precision); - _modulus_sub_precision = (_modulus_bit_count + 16 - 1) / 16; - - /* - ** Keep 2*16 bits in _mod_divisor. - ** This will (normally) result in a reciprocal of 2*16+1 bits. - */ - int sub_precision = XMP_Significance(_scratch_modulus, precision); // significant digits in modulus - XMP_Move(_mod_divisor, &_scratch_modulus[sub_precision-2], 2); - _modulus_shift = XMP_Count_Bits(_mod_divisor, 2) - 2 * 16; - XMP_Shift_Right_Bits(_mod_divisor, _modulus_shift, 2); - - XMP_Reciprocal(_mod_quotient, _mod_divisor, 2); - XMP_Shift_Right_Bits(_mod_quotient, 1, 2); - - /* Reduce to: 0 < _modulus_shift <= 16 */ - _modulus_shift = ((_modulus_shift + (16 - 1)) % 16) + 1; - - /* round up */ - XMP_Inc(_mod_quotient, 2); - if (XMP_Count_Bits(_mod_quotient, 2) > 2 * 16) { - XMP_Shift_Right_Bits(_mod_quotient, 1, 2); - _modulus_shift--; /* now 0 <= _modulus_shift <= 16 */ - } - unsigned short * mpm = (unsigned short *) _mod_quotient; - _reciprical_low_digit = *mpm++; - _reciprical_high_digit = *mpm; - - return 0; -} - - -/*********************************************************************************************** - * XMP_Mod_Mult -- Perform a multiply - modulus operation. * - * * - * This routine will combine a multiply and a modulus operation. This takes advantage of * - * a tremendous speed advantage possible if these two processes are combined rather than * - * being performed separately. * - * * - * INPUT: prod -- Pointer to the MP buffer that will hold the result. * - * * - * multiplicand-- The number to multiply. * - * * - * multiplier -- The number to multiply by. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: The modulus must already have been prepared by the routine XMP_Prepare_Modulus. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Mod_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - XMP_Double_Mul(_double_staging_number, multiplicand, multiplier, precision); - - int double_precision = precision * 2 + 1; - - _double_staging_number[double_precision - 1] = 0; /* leading 0 digit */ - - /* - ** We now start working with MULTUNITs. - ** Determine the most significant MULTUNIT of the product so we don't - ** have to process leading zeros in our divide loop. - */ - int dmi = XMP_Significance(_double_staging_number, double_precision) * 2; // number of significant MULTUNITs in product - - if (dmi >= _modulus_sub_precision) { - - /* Make dividend negative. This allows the use of mp_single_mul to - ** "subtract" the product of the modulus and the trial divisor - ** by actually adding to a negative dividend. - ** The one's complement of the dividend is used, since it causes - ** a zero value to be represented as all ones. This facilitates - ** testing the result for possible overflow, since a sign bit - ** indicates that no adjustment is necessary, and we should not - ** attempt to adjust if the result of the addition is zero. - */ - XMP_Inc(_double_staging_number, double_precision); - XMP_Neg(_double_staging_number, double_precision); - - int nqd = dmi + 1 - _modulus_sub_precision; // number of quotient digits remaining to be generated - - /* Set msb, lsb, and normal ptrs of dividend */ - unsigned short * dmph = ((unsigned short *)_double_staging_number) + dmi + 1; // points to one higher than precision would indicate - unsigned short * dmpl = dmph - _modulus_sub_precision; - - /* - ** Divide loop. - ** Each iteration computes the next quotient MULTUNIT digit, then - ** multiplies the divisor (modulus) by the quotient digit and adds - ** it to the one's complement of the dividend (equivalent to - ** subtracting). If the product was greater than the remaining dividend, - ** we get a non-negative result, in which case we subtract off the - ** modulus to get the proper negative remainder. - */ - for (; nqd; nqd--) { - --dmph; - --dmpl; - - unsigned short q = mp_quo_digit(dmph); // trial quotient digit - if (q > 0) { - XMP_Hybrid_Mul(dmpl, (unsigned short *)_scratch_modulus, q, precision*2); - - /* Perform correction if q too large. - ** This rarely occurs. - */ - if (!(*dmph & SEMI_UPPER_MOST_BIT)) { - unsigned short * dmp = dmpl; - if (XMP_Sub((unsigned long *)dmp, (unsigned long *)dmp, _scratch_modulus, false, precision)) { - (*dmph)--; - } - } - } - } - - /* d contains the one's complement of the remainder. */ - XMP_Neg(_double_staging_number, precision); - XMP_Dec(_double_staging_number, precision); - } - - XMP_Move(prod, _double_staging_number, precision); - return (0); -} - - -/*********************************************************************************************** - * XMP_Mod_Mult_Clear -- Remove temporary values from memory. * - * * - * Smith's mp_modmult function leaves some internal arrays in memory, * - * so we have to call modmult_burn() at the end of mp_exponent_mod. * - * This is so that no cryptographically sensitive data is left in memory * - * after the program exits. * - * * - * INPUT: precision -- The precision of the numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Mod_Mult_Clear(int precision) -{ - XMP_Init(_scratch_modulus, 0, precision); - XMP_Init(_double_staging_number, 0, precision); - XMP_Init(_mod_quotient, 0, ARRAY_SIZE(_mod_quotient)); - XMP_Init(_mod_divisor, 0, ARRAY_SIZE(_mod_divisor)); - _modulus_shift = _modulus_bit_count = 0; - _reciprical_high_digit = _reciprical_low_digit = 0; - _modulus_sub_precision = /*mutemp =*/ 0; -} - - -/* -** The function mp_quo_digit is the heart of Smith's modulo reduction, -** which uses a form of long division. It computes a trial quotient -** "digit" (MULTUNIT-sized digit) by multiplying the three most -** significant MULTUNITs of the dividend by the two most significant -** MULTUNITs of the reciprocal of the modulus. Note that this function -** requires that 16 * 2 <= sizeof(unsigned long). -** -** An important part of this technique is that the quotient never be -** too small, although it may occasionally be too large. This was -** done to eliminate the need to check and correct for a remainder -** exceeding the divisor. It is easier to check for a negative -** remainder. The following technique rarely needs correction for -** MULTUNITs of at least 16 bits. -** -** The following routine has two implementations: -** -** Parameter: dividend - points to the most significant MULTUNIT -** of the dividend. Note that dividend actually contains the -** one's complement of the actual dividend value (see comments for -** XMP_Mod_Mult). -** -** Return: the trial quotient digit resulting from dividing the first -** three MULTUNITs at dividend by the upper two MULTUNITs of the -** modulus. -*/ -unsigned short mp_quo_digit(unsigned short * dividend) -{ - unsigned long q, q0, q1, q2; - - /* - * Compute the least significant product group. - * The last terms of q1 and q2 perform upward rounding, which is - * needed to guarantee that the result not be too small. - */ - q1 = (dividend[-2] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit + _reciprical_high_digit; - q2 = (dividend[-1] ^ SEMI_MASK) * (unsigned long) _reciprical_low_digit + (1L << 16); - q0 = (q1 >> 1) + (q2 >> 1) + 1; - - /* Compute the middle significant product group. */ - q1 = (dividend[-1] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit; - q2 = (dividend[0] ^ SEMI_MASK) * (unsigned long) _reciprical_low_digit; - q = (q0 >> 16) + (q1 >> 1) + (q2 >> 1) + 1; - - /* Compute the most significant term and add in the others */ - q = (q >> (16 - 2)) + (((dividend[0] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit) << 1); - q >>= _modulus_shift; - - /* Prevent overflow and then wipe out the intermediate results. */ - return (unsigned short) min(q, (unsigned long)(1L << 16) - 1); -} - - -/* -** Russian peasant combined exponentiation/modulo algorithm. -** Calls modmult instead of mult. -** Computes: expout = (expin**exponent) mod modulus -** WARNING: All the arguments must be less than the modulus! -*/ -int MPEXPORT XMP_Exponent_Mod(digit * expout, const digit * expin, const digit * exponent_ptr, const digit * modulus, int precision) -{ - digit product[MAX_UNIT_PRECISION]; - - XMP_Init(expout, 1, precision); - if (XMP_Test_Eq_Int(exponent_ptr, 0, precision)) { - if (XMP_Test_Eq_Int(expin, 0, precision)) { - return -1; /* 0 to the 0th power means return error */ - } - return 0; /* otherwise, zero exponent means expout is 1 */ - } - - if (XMP_Test_Eq_Int(modulus, 0, precision)) { - return -2; /* zero modulus means error */ - } - - if (XMP_Compare(expin, modulus, precision) >= 0) { - return -3; /* if expin >= modulus, return error */ - } - - if (XMP_Compare(exponent_ptr, modulus, precision) >= 0) { - return -4; /* if exponent >= modulus, return error */ - } - - /* set smallest optimum precision for this modulus */ - int limited_precision = XMP_Significance(modulus, precision); - - if (XMP_Prepare_Modulus(modulus, limited_precision)) { - return -5; /* unstageable modulus (STEWART algorithm) */ - } - - /* normalize and compute number of bits in exponent first */ -// int exp_precision = XMP_Significance(exponent_ptr, limited_precision); -// if (!exp_precision) return(0); -// int bits = XMP_Digits_To_Bits(exp_precision); -// exponent_ptr += (exp_precision-1); -// digit high_bit_mask = UPPER_MOST_BIT; -// while (! ((*exponent_ptr) & high_bit_mask)) { -// high_bit_mask >>= 1; -// bits--; -// } - - int total_bit_count = XMP_Count_Bits(exponent_ptr, limited_precision); - int sub_precision = XMP_Bits_To_Digits(total_bit_count); - if (!sub_precision) return(0); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - exponent_ptr += (sub_precision-1); - - /* We can "optimize out" the first modsquare and modmult: */ - total_bit_count--; /* We know for sure at this point that bits>0 */ - - XMP_Move(expout, expin, limited_precision); - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - exponent_ptr--; - } - - while (total_bit_count--) { - XMP_Mod_Mult(product, expout, expout, limited_precision); - - if (((*exponent_ptr) & high_bit_mask)) { - XMP_Mod_Mult(expout, product, expin, limited_precision); - } else { - XMP_Move(expout, product, limited_precision); - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - exponent_ptr--; - } - - } - - XMP_Init(product, 0, limited_precision); - XMP_Mod_Mult_Clear(limited_precision); /* ask mp_modmult to also burn its own evidence */ - - return 0; -} - - -/*********************************************************************************************** - * memrev -- Reverse the byte order of the buffer specified. * - * * - * This routine will reverse the byte order in the buffer specified. * - * * - * INPUT: buffer -- Pointer to the buffer that will be reversed. * - * * - * length -- The length of the buffer. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void memrev(char * buffer, size_t length) -{ - char * r2 = &(buffer[length - 1]); - while (buffer < r2) { - char b = *buffer; - *buffer++ = *r2; - *r2-- = b; - } -} - - -int _USERENTRY pfunc(const void * pkey, const void * base) -{ - if (*(unsigned short *)pkey < *(unsigned short *)base) return(-1); - if (*(unsigned short *)pkey > *(unsigned short *)base) return(1); - return(0); -} - - -/*********************************************************************************************** - * XMP_Is_Small_Prime -- Determine if MP number is a small prime. * - * * - * This routine will compare the MP number against all known small prime numbers. It will * - * return true if a match was found. * - * * - * INPUT: candidate -- Pointer to MP number that is to be tested. * - * * - * precision -- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the MP number a member of the small prime community? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Is_Small_Prime(const digit * candidate, int precision) -{ - /* - ** If the number is too large for comparison to the known small primes table, then - ** bail immediately. - */ - if (XMP_Significance(candidate, precision) > 1) return(false); - if (*candidate > primeTable[ARRAY_SIZE(primeTable)-1]) return false; - - unsigned long * ptr = (unsigned long *)bsearch(&candidate, &primeTable[0], ARRAY_SIZE(primeTable), sizeof(primeTable[0]), pfunc); - return(ptr != NULL); -} - - -/*********************************************************************************************** - * XMP_Small_Divisors_Test -- Perform the small divisors test on an MP number. * - * * - * This test for primality will divide an MP number by the set of small primes. If any of * - * these numbers divides evenly into the candidate number, then it is known that the * - * candidate is NOT prime. * - * * - * INPUT: candidate -- Pointer to the MP number that is to be tested. * - * * - * precision -- The precision of the MP number/ * - * * - * OUTPUT: bool; Did the MP number pass the small divisors test? * - * * - * WARNINGS: If the MP number passes, it doesn't mean that it is prime, just that is hasn't * - * yet been proven to be not prime. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Small_Divisors_Test(const digit * candidate, int precision) -{ - digit quotient[MAX_UNIT_PRECISION]; - - for (unsigned i = 0; i < ARRAY_SIZE(primeTable); i++) { - if (XMP_Unsigned_Div_Int(quotient, candidate, primeTable[i], precision) == 0) return(false); - } - return(true); -} - - -/*********************************************************************************************** - * XMP_Fermat_Test -- Performs Fermat's Little Theorem on an MP number. * - * * - * This is a more expensive but thorough test for primality. The aggressiveness of this * - * test can be controlled by the number of rounds specified. Four rounds is usually * - * sufficient. * - * * - * INPUT: candidate -- Pointer to the candidate MP number that is to be tested. * - * * - * rounds -- The number of rounds to test the MP number (keep it small). * - * * - * precision -- The precision of the MP number. * - * * - * OUTPUT: bool; Was the number not proven to be not prime. A FALSE means that it is not * - * prime. A TRUE means that it might be prime. * - * * - * WARNINGS: This takes a bit of time. The time it takes is directly controlled by the * - * number of rounds specified. Keep the number of rounds as small as possible. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Fermat_Test(const digit * candidate_prime, unsigned rounds, int precision) -{ - assert(rounds < ARRAY_SIZE(primeTable)); - - digit term[MAX_UNIT_PRECISION]; - XMP_Move(term, candidate_prime, precision); - XMP_Dec(term, precision); - - for (unsigned i = 0; i < rounds; i++) { - // if ((x**(p-1)) mod p) != 1, then p is not prime - digit result[MAX_UNIT_PRECISION]; - - digit small_prime[MAX_UNIT_PRECISION]; - XMP_Init(small_prime, primeTable[i], precision); - - XMP_Exponent_Mod(result, small_prime, term, candidate_prime, precision); - - if (!XMP_Test_Eq_Int(result, 1, precision)) return(false); - } - return(true); -} - - -/*********************************************************************************************** - * XMP_Rabin_Miller_Test -- Performs the Rabin Miller test for primality. * - * * - * This test for primality is even more expensive the Fermat's Little Theorem. It doesn't * - * prove that a number is prime, but it can prove that it is not prime. * - * * - * INPUT: rng -- Reference to to a random number generator. * - * * - * candidate-- Pointer to the candidate MP number that is to be tested. * - * * - * rounds -- The number of test rounds to perform. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the number not proven to be not prime? A FALSE means that the number is * - * not prime. A TRUE means that it might be. * - * * - * WARNINGS: This routine takes a long time. Use as few rounds as possible. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Rabin_Miller_Test(Straw & rng, digit const * w, int rounds, int precision) -{ - digit wminus1[MAX_UNIT_PRECISION]; - XMP_Sub_Int(wminus1, w, 1, 0, precision); - - unsigned maxbitprecision = precision * sizeof(digit) * 8; - unsigned a; - for (a = 0; a < maxbitprecision; a++) { - if (XMP_Test_Bit(wminus1, a)) { - break; - } - } - - digit m[MAX_UNIT_PRECISION]; - XMP_Move(m, wminus1, precision); - XMP_Shift_Right_Bits(wminus1, a, precision); - - for (int i = 0; i < rounds; i++) { - digit b[MAX_UNIT_PRECISION]; - digit temp[MAX_UNIT_PRECISION]; - XMP_Init(temp, 2, precision); - XMP_Randomize_Bounded(b, rng, temp, wminus1, precision); - - digit z[MAX_UNIT_PRECISION]; - XMP_Exponent_Mod(z, b, m, w, precision); - - if (XMP_Test_Eq_Int(z, 1, precision) || XMP_Compare(z, wminus1, precision) == 0) { - continue; // passes this round - } - - unsigned j; - for (j = 1; j < a; j++) { - digit t2[MAX_UNIT_PRECISION]; - XMP_Exponent_Mod(t2, z, temp, w, precision); - - if (XMP_Compare(t2, wminus1, precision) == 0) { - break; // passed this round - } - if (XMP_Test_Eq_Int(z, 1, precision)) { - return false; - } - } - if (j == a) { - return false; - } - } - return true; -} - - -/*********************************************************************************************** - * XMP_Randomize -- Generate a random MP number. * - * * - * This routine will generate a random MP number with the number of bits precision * - * specified. This is the starting point for generating large random prime numbers. It is * - * very important that the random number generated is truly random. * - * * - * INPUT: result -- Pointer to the buffer that will hold the MP number. * - * * - * rng -- Reference to a random number generator. * - * * - * total_bits-- The number of bits precision that the MP number must have. * - * * - * precision-- The precision of the MP number to be generated (maximum) * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Randomize(digit * result, Straw & rng, int total_bits, int precision) -{ - assert(XMP_Bits_To_Digits(total_bits) <= MAX_UNIT_PRECISION); - - total_bits = min(total_bits, precision * 32); - - unsigned nbytes = total_bits/8 + 1; - - XMP_Init(result, 0, precision); - rng.Get(result, nbytes); - - ((unsigned char *)result)[nbytes-1] &= (unsigned char)(~((~0) << (total_bits % 8))); -} - - -/*********************************************************************************************** - * XMP_Randomize -- Generate a random MP number between the boundaries specified. * - * * - * This routine will generate a random MP number but it will be bounded by the minimum * - * and maximum MP numbers specified. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * rng -- Reference to a random number generator to use. * - * * - * minval -- Minimum value allowed. * - * * - * maxval -- Maximum value allowed. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Randomize_Bounded(digit * result, Straw & rng, digit const * minval, digit const * maxval, int precision) -{ - digit range[MAX_UNIT_PRECISION]; - XMP_Sub(range, maxval, minval, 0, precision); - unsigned int bit_count = XMP_Count_Bits(range, precision); - do { - XMP_Randomize(result, rng, bit_count, precision); - } while (XMP_Compare(result, range, precision) > 0); - - XMP_Add(result, result, minval, 0, precision); -} - - -/*********************************************************************************************** - * XMP_Is_Prime -- Determine if the specified MP number is prime. * - * * - * This routine will perform some checks to try and determine if the specified MP number * - * is a prime number. The result of this test is not 100% conclusive, but it is pretty * - * darn close. * - * * - * INPUT: prime -- Pointer to a candidate number to test for primality. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the number not proven to be not prime? If FALSE, then the number is * - * not prime. If TRUE, then it might be. * - * * - * WARNINGS: This can take a very very very very very long time. Especially for the larger * - * numbers. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Is_Prime(digit const * prime, int precision) -{ - /* - ** Even numbers are ALWAYS not prime. - */ - if (!(*prime & 0x01)) return(false); - - /* - ** Compare the prime number against the exhaustive list of prime - ** numbers below 14 bits in size. If it finds a match, then - ** the number is a known prime. - */ - if (XMP_Is_Small_Prime(prime, precision)) return(true); - - /* - ** Perform the small divisors test. This is not exhaustive, but - ** will weed out a large percentage of non-prime numbers. - */ - if (!XMP_Small_Divisors_Test(prime, precision)) return(false); - - /* - ** Perform Fermat's Little Theorum on the candidate prime. Run - ** the theorum for several rounds to ensure a high degree of - ** confidence. - */ - if (!XMP_Fermat_Test(prime, 2, precision)) return(false); - - /* - ** If all of the above tests have not confirmed primality nor - ** confirmed non-primality, presume that the number must be prime. - */ - return(true); -} - - -/* -** Complete list of all prime numbers that are less than 32719 (inclusive). -*/ -unsigned short primeTable[3511] = { - 0x0002,0x0003,0x0005,0x0007,0x000B,0x000D,0x0011,0x0013,0x0017,0x001D,0x001F,0x0025,0x0029,0x002B,0x002F,0x0035, - 0x003B,0x003D,0x0043,0x0047,0x0049,0x004F,0x0053,0x0059,0x0061,0x0065,0x0067,0x006B,0x006D,0x0071,0x007F,0x0083, - 0x0089,0x008B,0x0095,0x0097,0x009D,0x00A3,0x00A7,0x00AD,0x00B3,0x00B5,0x00BF,0x00C1,0x00C5,0x00C7,0x00D3,0x00DF, - 0x00E3,0x00E5,0x00E9,0x00EF,0x00F1,0x00FB,0x0101,0x0107,0x010D,0x010F,0x0115,0x0119,0x011B,0x0125,0x0133,0x0137, - 0x0139,0x013D,0x014B,0x0151,0x015B,0x015D,0x0161,0x0167,0x016F,0x0175,0x017B,0x017F,0x0185,0x018D,0x0191,0x0199, - 0x01A3,0x01A5,0x01AF,0x01B1,0x01B7,0x01BB,0x01C1,0x01C9,0x01CD,0x01CF,0x01D3,0x01DF,0x01E7,0x01EB,0x01F3,0x01F7, - 0x01FD,0x0209,0x020B,0x021D,0x0223,0x022D,0x0233,0x0239,0x023B,0x0241,0x024B,0x0251,0x0257,0x0259,0x025F,0x0265, - 0x0269,0x026B,0x0277,0x0281,0x0283,0x0287,0x028D,0x0293,0x0295,0x02A1,0x02A5,0x02AB,0x02B3,0x02BD,0x02C5,0x02CF, - 0x02D7,0x02DD,0x02E3,0x02E7,0x02EF,0x02F5,0x02F9,0x0301,0x0305,0x0313,0x031D,0x0329,0x032B,0x0335,0x0337,0x033B, - 0x033D,0x0347,0x0355,0x0359,0x035B,0x035F,0x036D,0x0371,0x0373,0x0377,0x038B,0x038F,0x0397,0x03A1,0x03A9,0x03AD, - 0x03B3,0x03B9,0x03C7,0x03CB,0x03D1,0x03D7,0x03DF,0x03E5,0x03F1,0x03F5,0x03FB,0x03FD,0x0407,0x0409,0x040F,0x0419, - 0x041B,0x0425,0x0427,0x042D,0x043F,0x0443,0x0445,0x0449,0x044F,0x0455,0x045D,0x0463,0x0469,0x047F,0x0481,0x048B, - 0x0493,0x049D,0x04A3,0x04A9,0x04B1,0x04BD,0x04C1,0x04C7,0x04CD,0x04CF,0x04D5,0x04E1,0x04EB,0x04FD,0x04FF,0x0503, - 0x0509,0x050B,0x0511,0x0515,0x0517,0x051B,0x0527,0x0529,0x052F,0x0551,0x0557,0x055D,0x0565,0x0577,0x0581,0x058F, - 0x0593,0x0595,0x0599,0x059F,0x05A7,0x05AB,0x05AD,0x05B3,0x05BF,0x05C9,0x05CB,0x05CF,0x05D1,0x05D5,0x05DB,0x05E7, - 0x05F3,0x05FB,0x0607,0x060D,0x0611,0x0617,0x061F,0x0623,0x062B,0x062F,0x063D,0x0641,0x0647,0x0649,0x064D,0x0653, - 0x0655,0x065B,0x0665,0x0679,0x067F,0x0683,0x0685,0x069D,0x06A1,0x06A3,0x06AD,0x06B9,0x06BB,0x06C5,0x06CD,0x06D3, - 0x06D9,0x06DF,0x06F1,0x06F7,0x06FB,0x06FD,0x0709,0x0713,0x071F,0x0727,0x0737,0x0745,0x074B,0x074F,0x0751,0x0755, - 0x0757,0x0761,0x076D,0x0773,0x0779,0x078B,0x078D,0x079D,0x079F,0x07B5,0x07BB,0x07C3,0x07C9,0x07CD,0x07CF,0x07D3, - 0x07DB,0x07E1,0x07EB,0x07ED,0x07F7,0x0805,0x080F,0x0815,0x0821,0x0823,0x0827,0x0829,0x0833,0x083F,0x0841,0x0851, - 0x0853,0x0859,0x085D,0x085F,0x0869,0x0871,0x0883,0x089B,0x089F,0x08A5,0x08AD,0x08BD,0x08BF,0x08C3,0x08CB,0x08DB, - 0x08DD,0x08E1,0x08E9,0x08EF,0x08F5,0x08F9,0x0905,0x0907,0x091D,0x0923,0x0925,0x092B,0x092F,0x0935,0x0943,0x0949, - 0x094D,0x094F,0x0955,0x0959,0x095F,0x096B,0x0971,0x0977,0x0985,0x0989,0x098F,0x099B,0x09A3,0x09A9,0x09AD,0x09C7, - 0x09D9,0x09E3,0x09EB,0x09EF,0x09F5,0x09F7,0x09FD,0x0A13,0x0A1F,0x0A21,0x0A31,0x0A39,0x0A3D,0x0A49,0x0A57,0x0A61, - 0x0A63,0x0A67,0x0A6F,0x0A75,0x0A7B,0x0A7F,0x0A81,0x0A85,0x0A8B,0x0A93,0x0A97,0x0A99,0x0A9F,0x0AA9,0x0AAB,0x0AB5, - 0x0ABD,0x0AC1,0x0ACF,0x0AD9,0x0AE5,0x0AE7,0x0AED,0x0AF1,0x0AF3,0x0B03,0x0B11,0x0B15,0x0B1B,0x0B23,0x0B29,0x0B2D, - 0x0B3F,0x0B47,0x0B51,0x0B57,0x0B5D,0x0B65,0x0B6F,0x0B7B,0x0B89,0x0B8D,0x0B93,0x0B99,0x0B9B,0x0BB7,0x0BB9,0x0BC3, - 0x0BCB,0x0BCF,0x0BDD,0x0BE1,0x0BE9,0x0BF5,0x0BFB,0x0C07,0x0C0B,0x0C11,0x0C25,0x0C2F,0x0C31,0x0C41,0x0C5B,0x0C5F, - 0x0C61,0x0C6D,0x0C73,0x0C77,0x0C83,0x0C89,0x0C91,0x0C95,0x0C9D,0x0CB3,0x0CB5,0x0CB9,0x0CBB,0x0CC7,0x0CE3,0x0CE5, - 0x0CEB,0x0CF1,0x0CF7,0x0CFB,0x0D01,0x0D03,0x0D0F,0x0D13,0x0D1F,0x0D21,0x0D2B,0x0D2D,0x0D3D,0x0D3F,0x0D4F,0x0D55, - 0x0D69,0x0D79,0x0D81,0x0D85,0x0D87,0x0D8B,0x0D8D,0x0DA3,0x0DAB,0x0DB7,0x0DBD,0x0DC7,0x0DC9,0x0DCD,0x0DD3,0x0DD5, - 0x0DDB,0x0DE5,0x0DE7,0x0DF3,0x0DFD,0x0DFF,0x0E09,0x0E17,0x0E1D,0x0E21,0x0E27,0x0E2F,0x0E35,0x0E3B,0x0E4B,0x0E57, - 0x0E59,0x0E5D,0x0E6B,0x0E71,0x0E75,0x0E7D,0x0E87,0x0E8F,0x0E95,0x0E9B,0x0EB1,0x0EB7,0x0EB9,0x0EC3,0x0ED1,0x0ED5, - 0x0EDB,0x0EED,0x0EEF,0x0EF9,0x0F07,0x0F0B,0x0F0D,0x0F17,0x0F25,0x0F29,0x0F31,0x0F43,0x0F47,0x0F4D,0x0F4F,0x0F53, - 0x0F59,0x0F5B,0x0F67,0x0F6B,0x0F7F,0x0F95,0x0FA1,0x0FA3,0x0FA7,0x0FAD,0x0FB3,0x0FB5,0x0FBB,0x0FD1,0x0FD3,0x0FD9, - 0x0FE9,0x0FEF,0x0FFB,0x0FFD,0x1003,0x100F,0x101F,0x1021,0x1025,0x102B,0x1039,0x103D,0x103F,0x1051,0x1069,0x1073, - 0x1079,0x107B,0x1085,0x1087,0x1091,0x1093,0x109D,0x10A3,0x10A5,0x10AF,0x10B1,0x10BB,0x10C1,0x10C9,0x10E7,0x10F1, - 0x10F3,0x10FD,0x1105,0x110B,0x1115,0x1127,0x112D,0x1139,0x1145,0x1147,0x1159,0x115F,0x1163,0x1169,0x116F,0x1181, - 0x1183,0x118D,0x119B,0x11A1,0x11A5,0x11A7,0x11AB,0x11C3,0x11C5,0x11D1,0x11D7,0x11E7,0x11EF,0x11F5,0x11FB,0x120D, - 0x121D,0x121F,0x1223,0x1229,0x122B,0x1231,0x1237,0x1241,0x1247,0x1253,0x125F,0x1271,0x1273,0x1279,0x127D,0x128F, - 0x1297,0x12AF,0x12B3,0x12B5,0x12B9,0x12BF,0x12C1,0x12CD,0x12D1,0x12DF,0x12FD,0x1307,0x130D,0x1319,0x1327,0x132D, - 0x1337,0x1343,0x1345,0x1349,0x134F,0x1357,0x135D,0x1367,0x1369,0x136D,0x137B,0x1381,0x1387,0x138B,0x1391,0x1393, - 0x139D,0x139F,0x13AF,0x13BB,0x13C3,0x13D5,0x13D9,0x13DF,0x13EB,0x13ED,0x13F3,0x13F9,0x13FF,0x141B,0x1421,0x142F, - 0x1433,0x143B,0x1445,0x144D,0x1459,0x146B,0x146F,0x1471,0x1475,0x148D,0x1499,0x149F,0x14A1,0x14B1,0x14B7,0x14BD, - 0x14CB,0x14D5,0x14E3,0x14E7,0x1505,0x150B,0x1511,0x1517,0x151F,0x1525,0x1529,0x152B,0x1537,0x153D,0x1541,0x1543, - 0x1549,0x155F,0x1565,0x1567,0x156B,0x157D,0x157F,0x1583,0x158F,0x1591,0x1597,0x159B,0x15B5,0x15BB,0x15C1,0x15C5, - 0x15CD,0x15D7,0x15F7,0x1607,0x1609,0x160F,0x1613,0x1615,0x1619,0x161B,0x1625,0x1633,0x1639,0x163D,0x1645,0x164F, - 0x1655,0x1669,0x166D,0x166F,0x1675,0x1693,0x1697,0x169F,0x16A9,0x16AF,0x16B5,0x16BD,0x16C3,0x16CF,0x16D3,0x16D9, - 0x16DB,0x16E1,0x16E5,0x16EB,0x16ED,0x16F7,0x16F9,0x1709,0x170F,0x1723,0x1727,0x1733,0x1741,0x175D,0x1763,0x1777, - 0x177B,0x178D,0x1795,0x179B,0x179F,0x17A5,0x17B3,0x17B9,0x17BF,0x17C9,0x17CB,0x17D5,0x17E1,0x17E9,0x17F3,0x17F5, - 0x17FF,0x1807,0x1813,0x181D,0x1835,0x1837,0x183B,0x1843,0x1849,0x184D,0x1855,0x1867,0x1871,0x1877,0x187D,0x187F, - 0x1885,0x188F,0x189B,0x189D,0x18A7,0x18AD,0x18B3,0x18B9,0x18C1,0x18C7,0x18D1,0x18D7,0x18D9,0x18DF,0x18E5,0x18EB, - 0x18F5,0x18FD,0x1915,0x191B,0x1931,0x1933,0x1945,0x1949,0x1951,0x195B,0x1979,0x1981,0x1993,0x1997,0x1999,0x19A3, - 0x19A9,0x19AB,0x19B1,0x19B5,0x19C7,0x19CF,0x19DB,0x19ED,0x19FD,0x1A03,0x1A05,0x1A11,0x1A17,0x1A21,0x1A23,0x1A2D, - 0x1A2F,0x1A35,0x1A3F,0x1A4D,0x1A51,0x1A69,0x1A6B,0x1A7B,0x1A7D,0x1A87,0x1A89,0x1A93,0x1AA7,0x1AAB,0x1AAD,0x1AB1, - 0x1AB9,0x1AC9,0x1ACF,0x1AD5,0x1AD7,0x1AE3,0x1AF3,0x1AFB,0x1AFF,0x1B05,0x1B23,0x1B25,0x1B2F,0x1B31,0x1B37,0x1B3B, - 0x1B41,0x1B47,0x1B4F,0x1B55,0x1B59,0x1B65,0x1B6B,0x1B73,0x1B7F,0x1B83,0x1B91,0x1B9D,0x1BA7,0x1BBF,0x1BC5,0x1BD1, - 0x1BD7,0x1BD9,0x1BEF,0x1BF7,0x1C09,0x1C13,0x1C19,0x1C27,0x1C2B,0x1C2D,0x1C33,0x1C3D,0x1C45,0x1C4B,0x1C4F,0x1C55, - 0x1C73,0x1C81,0x1C8B,0x1C8D,0x1C99,0x1CA3,0x1CA5,0x1CB5,0x1CB7,0x1CC9,0x1CE1,0x1CF3,0x1CF9,0x1D09,0x1D1B,0x1D21, - 0x1D23,0x1D35,0x1D39,0x1D3F,0x1D41,0x1D4B,0x1D53,0x1D5D,0x1D63,0x1D69,0x1D71,0x1D75,0x1D7B,0x1D7D,0x1D87,0x1D89, - 0x1D95,0x1D99,0x1D9F,0x1DA5,0x1DA7,0x1DB3,0x1DB7,0x1DC5,0x1DD7,0x1DDB,0x1DE1,0x1DF5,0x1DF9,0x1E01,0x1E07,0x1E0B, - 0x1E13,0x1E17,0x1E25,0x1E2B,0x1E2F,0x1E3D,0x1E49,0x1E4D,0x1E4F,0x1E6D,0x1E71,0x1E89,0x1E8F,0x1E95,0x1EA1,0x1EAD, - 0x1EBB,0x1EC1,0x1EC5,0x1EC7,0x1ECB,0x1EDD,0x1EE3,0x1EEF,0x1EF7,0x1EFD,0x1F01,0x1F0D,0x1F0F,0x1F1B,0x1F39,0x1F49, - 0x1F4B,0x1F51,0x1F67,0x1F75,0x1F7B,0x1F85,0x1F91,0x1F97,0x1F99,0x1F9D,0x1FA5,0x1FAF,0x1FB5,0x1FBB,0x1FD3,0x1FE1, - 0x1FE7,0x1FEB,0x1FF3,0x1FFF,0x2011,0x201B,0x201D,0x2027,0x2029,0x202D,0x2033,0x2047,0x204D,0x2051,0x205F,0x2063, - 0x2065,0x2069,0x2077,0x207D,0x2089,0x20A1,0x20AB,0x20B1,0x20B9,0x20C3,0x20C5,0x20E3,0x20E7,0x20ED,0x20EF,0x20FB, - 0x20FF,0x210D,0x2113,0x2135,0x2141,0x2149,0x214F,0x2159,0x215B,0x215F,0x2173,0x217D,0x2185,0x2195,0x2197,0x21A1, - 0x21AF,0x21B3,0x21B5,0x21C1,0x21C7,0x21D7,0x21DD,0x21E5,0x21E9,0x21F1,0x21F5,0x21FB,0x2203,0x2209,0x220F,0x221B, - 0x2221,0x2225,0x222B,0x2231,0x2239,0x224B,0x224F,0x2263,0x2267,0x2273,0x2275,0x227F,0x2285,0x2287,0x2291,0x229D, - 0x229F,0x22A3,0x22B7,0x22BD,0x22DB,0x22E1,0x22E5,0x22ED,0x22F7,0x2303,0x2309,0x230B,0x2327,0x2329,0x232F,0x2333, - 0x2335,0x2345,0x2351,0x2353,0x2359,0x2363,0x236B,0x2383,0x238F,0x2395,0x23A7,0x23AD,0x23B1,0x23BF,0x23C5,0x23C9, - 0x23D5,0x23DD,0x23E3,0x23EF,0x23F3,0x23F9,0x2405,0x240B,0x2417,0x2419,0x2429,0x243D,0x2441,0x2443,0x244D,0x245F, - 0x2467,0x246B,0x2479,0x247D,0x247F,0x2485,0x249B,0x24A1,0x24AF,0x24B5,0x24BB,0x24C5,0x24CB,0x24CD,0x24D7,0x24D9, - 0x24DD,0x24DF,0x24F5,0x24F7,0x24FB,0x2501,0x2507,0x2513,0x2519,0x2527,0x2531,0x253D,0x2543,0x254B,0x254F,0x2573, - 0x2581,0x258D,0x2593,0x2597,0x259D,0x259F,0x25AB,0x25B1,0x25BD,0x25CD,0x25CF,0x25D9,0x25E1,0x25F7,0x25F9,0x2605, - 0x260B,0x260F,0x2615,0x2627,0x2629,0x2635,0x263B,0x263F,0x264B,0x2653,0x2659,0x2665,0x2669,0x266F,0x267B,0x2681, - 0x2683,0x268F,0x269B,0x269F,0x26AD,0x26B3,0x26C3,0x26C9,0x26CB,0x26D5,0x26DD,0x26EF,0x26F5,0x2717,0x2719,0x2735, - 0x2737,0x274D,0x2753,0x2755,0x275F,0x276B,0x276D,0x2773,0x2777,0x277F,0x2795,0x279B,0x279D,0x27A7,0x27AF,0x27B3, - 0x27B9,0x27C1,0x27C5,0x27D1,0x27E3,0x27EF,0x2803,0x2807,0x280D,0x2813,0x281B,0x281F,0x2821,0x2831,0x283D,0x283F, - 0x2849,0x2851,0x285B,0x285D,0x2861,0x2867,0x2875,0x2881,0x2897,0x289F,0x28BB,0x28BD,0x28C1,0x28D5,0x28D9,0x28DB, - 0x28DF,0x28ED,0x28F7,0x2903,0x2905,0x2911,0x2921,0x2923,0x293F,0x2947,0x295D,0x2965,0x2969,0x296F,0x2975,0x2983, - 0x2987,0x298F,0x299B,0x29A1,0x29A7,0x29AB,0x29BF,0x29C3,0x29D5,0x29D7,0x29E3,0x29E9,0x29ED,0x29F3,0x2A01,0x2A13, - 0x2A1D,0x2A25,0x2A2F,0x2A4F,0x2A55,0x2A5F,0x2A65,0x2A6B,0x2A6D,0x2A73,0x2A83,0x2A89,0x2A8B,0x2A97,0x2A9D,0x2AB9, - 0x2ABB,0x2AC5,0x2ACD,0x2ADD,0x2AE3,0x2AEB,0x2AF1,0x2AFB,0x2B13,0x2B27,0x2B31,0x2B33,0x2B3D,0x2B3F,0x2B4B,0x2B4F, - 0x2B55,0x2B69,0x2B6D,0x2B6F,0x2B7B,0x2B8D,0x2B97,0x2B99,0x2BA3,0x2BA5,0x2BA9,0x2BBD,0x2BCD,0x2BE7,0x2BEB,0x2BF3, - 0x2BF9,0x2BFD,0x2C09,0x2C0F,0x2C17,0x2C23,0x2C2F,0x2C35,0x2C39,0x2C41,0x2C57,0x2C59,0x2C69,0x2C77,0x2C81,0x2C87, - 0x2C93,0x2C9F,0x2CAD,0x2CB3,0x2CB7,0x2CCB,0x2CCF,0x2CDB,0x2CE1,0x2CE3,0x2CE9,0x2CEF,0x2CFF,0x2D07,0x2D1D,0x2D1F, - 0x2D3B,0x2D43,0x2D49,0x2D4D,0x2D61,0x2D65,0x2D71,0x2D89,0x2D9D,0x2DA1,0x2DA9,0x2DB3,0x2DB5,0x2DC5,0x2DC7,0x2DD3, - 0x2DDF,0x2E01,0x2E03,0x2E07,0x2E0D,0x2E19,0x2E1F,0x2E25,0x2E2D,0x2E33,0x2E37,0x2E39,0x2E3F,0x2E57,0x2E5B,0x2E6F, - 0x2E79,0x2E7F,0x2E85,0x2E93,0x2E97,0x2E9D,0x2EA3,0x2EA5,0x2EB1,0x2EB7,0x2EC1,0x2EC3,0x2ECD,0x2ED3,0x2EE7,0x2EEB, - 0x2F05,0x2F09,0x2F0B,0x2F11,0x2F27,0x2F29,0x2F41,0x2F45,0x2F4B,0x2F4D,0x2F51,0x2F57,0x2F6F,0x2F75,0x2F7D,0x2F81, - 0x2F83,0x2FA5,0x2FAB,0x2FB3,0x2FC3,0x2FCF,0x2FD1,0x2FDB,0x2FDD,0x2FE7,0x2FED,0x2FF5,0x2FF9,0x3001,0x300D,0x3023, - 0x3029,0x3037,0x303B,0x3055,0x3059,0x305B,0x3067,0x3071,0x3079,0x307D,0x3085,0x3091,0x3095,0x30A3,0x30A9,0x30B9, - 0x30BF,0x30C7,0x30CB,0x30D1,0x30D7,0x30DF,0x30E5,0x30EF,0x30FB,0x30FD,0x3103,0x3109,0x3119,0x3121,0x3127,0x312D, - 0x3139,0x3143,0x3145,0x314B,0x315D,0x3161,0x3167,0x316D,0x3173,0x317F,0x3191,0x3199,0x319F,0x31A9,0x31B1,0x31C3, - 0x31C7,0x31D5,0x31DB,0x31ED,0x31F7,0x31FF,0x3209,0x3215,0x3217,0x321D,0x3229,0x3235,0x3259,0x325D,0x3263,0x326B, - 0x326F,0x3275,0x3277,0x327B,0x328D,0x3299,0x329F,0x32A7,0x32AD,0x32B3,0x32B7,0x32C9,0x32CB,0x32CF,0x32D1,0x32E9, - 0x32ED,0x32F3,0x32F9,0x3307,0x3325,0x332B,0x332F,0x3335,0x3341,0x3347,0x335B,0x335F,0x3367,0x336B,0x3373,0x3379, - 0x337F,0x3383,0x33A1,0x33A3,0x33AD,0x33B9,0x33C1,0x33CB,0x33D3,0x33EB,0x33F1,0x33FD,0x3401,0x340F,0x3413,0x3419, - 0x341B,0x3437,0x3445,0x3455,0x3457,0x3463,0x3469,0x346D,0x3481,0x348B,0x3491,0x3497,0x349D,0x34A5,0x34AF,0x34BB, - 0x34C9,0x34D3,0x34E1,0x34F1,0x34FF,0x3509,0x3517,0x351D,0x352D,0x3533,0x353B,0x3541,0x3551,0x3565,0x356F,0x3571, - 0x3577,0x357B,0x357D,0x3581,0x358D,0x358F,0x3599,0x359B,0x35A1,0x35B7,0x35BD,0x35BF,0x35C3,0x35D5,0x35DD,0x35E7, - 0x35EF,0x3605,0x3607,0x3611,0x3623,0x3631,0x3635,0x3637,0x363B,0x364D,0x364F,0x3653,0x3659,0x3661,0x366B,0x366D, - 0x368B,0x368F,0x36AD,0x36AF,0x36B9,0x36BB,0x36CD,0x36D1,0x36E3,0x36E9,0x36F7,0x3701,0x3703,0x3707,0x371B,0x373F, - 0x3745,0x3749,0x374F,0x375D,0x3761,0x3775,0x377F,0x378D,0x37A3,0x37A9,0x37AB,0x37C9,0x37D5,0x37DF,0x37F1,0x37F3, - 0x37F7,0x3805,0x380B,0x3821,0x3833,0x3835,0x3841,0x3847,0x384B,0x3853,0x3857,0x385F,0x3865,0x386F,0x3871,0x387D, - 0x388F,0x3899,0x38A7,0x38B7,0x38C5,0x38C9,0x38CF,0x38D5,0x38D7,0x38DD,0x38E1,0x38E3,0x38FF,0x3901,0x391D,0x3923, - 0x3925,0x3929,0x392F,0x393D,0x3941,0x394D,0x395B,0x396B,0x3979,0x397D,0x3983,0x398B,0x3991,0x3995,0x399B,0x39A1, - 0x39A7,0x39AF,0x39B3,0x39BB,0x39BF,0x39CD,0x39DD,0x39E5,0x39EB,0x39EF,0x39FB,0x3A03,0x3A13,0x3A15,0x3A1F,0x3A27, - 0x3A2B,0x3A31,0x3A4B,0x3A51,0x3A5B,0x3A63,0x3A67,0x3A6D,0x3A79,0x3A87,0x3AA5,0x3AA9,0x3AB7,0x3ACD,0x3AD5,0x3AE1, - 0x3AE5,0x3AEB,0x3AF3,0x3AFD,0x3B03,0x3B11,0x3B1B,0x3B21,0x3B23,0x3B2D,0x3B39,0x3B45,0x3B53,0x3B59,0x3B5F,0x3B71, - 0x3B7B,0x3B81,0x3B89,0x3B9B,0x3B9F,0x3BA5,0x3BA7,0x3BAD,0x3BB7,0x3BB9,0x3BC3,0x3BCB,0x3BD1,0x3BD7,0x3BE1,0x3BE3, - 0x3BF5,0x3BFF,0x3C01,0x3C0D,0x3C11,0x3C17,0x3C1F,0x3C29,0x3C35,0x3C43,0x3C4F,0x3C53,0x3C5B,0x3C65,0x3C6B,0x3C71, - 0x3C85,0x3C89,0x3C97,0x3CA7,0x3CB5,0x3CBF,0x3CC7,0x3CD1,0x3CDD,0x3CDF,0x3CF1,0x3CF7,0x3D03,0x3D0D,0x3D19,0x3D1B, - 0x3D1F,0x3D21,0x3D2D,0x3D33,0x3D37,0x3D3F,0x3D43,0x3D6F,0x3D73,0x3D75,0x3D79,0x3D7B,0x3D85,0x3D91,0x3D97,0x3D9D, - 0x3DAB,0x3DAF,0x3DB5,0x3DBB,0x3DC1,0x3DC9,0x3DCF,0x3DF3,0x3E05,0x3E09,0x3E0F,0x3E11,0x3E1D,0x3E23,0x3E29,0x3E2F, - 0x3E33,0x3E41,0x3E57,0x3E63,0x3E65,0x3E77,0x3E81,0x3E87,0x3EA1,0x3EB9,0x3EBD,0x3EBF,0x3EC3,0x3EC5,0x3EC9,0x3ED7, - 0x3EDB,0x3EE1,0x3EE7,0x3EEF,0x3EFF,0x3F0B,0x3F0D,0x3F37,0x3F3B,0x3F3D,0x3F41,0x3F59,0x3F5F,0x3F65,0x3F67,0x3F79, - 0x3F7D,0x3F8B,0x3F91,0x3FAD,0x3FBF,0x3FCD,0x3FD3,0x3FDD,0x3FE9,0x3FEB,0x3FF1,0x3FFD,0x401B,0x4021,0x4025,0x402B, - 0x4031,0x403F,0x4043,0x4045,0x405D,0x4061,0x4067,0x406D,0x4087,0x4091,0x40A3,0x40A9,0x40B1,0x40B7,0x40BD,0x40DB, - 0x40DF,0x40EB,0x40F7,0x40F9,0x4109,0x410B,0x4111,0x4115,0x4121,0x4133,0x4135,0x413B,0x413F,0x4159,0x4165,0x416B, - 0x4177,0x417B,0x4193,0x41AB,0x41B7,0x41BD,0x41BF,0x41CB,0x41E7,0x41EF,0x41F3,0x41F9,0x4205,0x4207,0x4219,0x421F, - 0x4223,0x4229,0x422F,0x4243,0x4253,0x4255,0x425B,0x4261,0x4273,0x427D,0x4283,0x4285,0x4289,0x4291,0x4297,0x429D, - 0x42B5,0x42C5,0x42CB,0x42D3,0x42DD,0x42E3,0x42F1,0x4307,0x430F,0x431F,0x4325,0x4327,0x4333,0x4337,0x4339,0x434F, - 0x4357,0x4369,0x438B,0x438D,0x4393,0x43A5,0x43A9,0x43AF,0x43B5,0x43BD,0x43C7,0x43CF,0x43E1,0x43E7,0x43EB,0x43ED, - 0x43F1,0x43F9,0x4409,0x440B,0x4417,0x4423,0x4429,0x443B,0x443F,0x4445,0x444B,0x4451,0x4453,0x4459,0x4465,0x446F, - 0x4483,0x448F,0x44A1,0x44A5,0x44AB,0x44AD,0x44BD,0x44BF,0x44C9,0x44D7,0x44DB,0x44F9,0x44FB,0x4505,0x4511,0x4513, - 0x452B,0x4531,0x4541,0x4549,0x4553,0x4555,0x4561,0x4577,0x457D,0x457F,0x458F,0x45A3,0x45AD,0x45AF,0x45BB,0x45C7, - 0x45D9,0x45E3,0x45EF,0x45F5,0x45F7,0x4601,0x4603,0x4609,0x4613,0x4625,0x4627,0x4633,0x4639,0x463D,0x4643,0x4645, - 0x465D,0x4679,0x467B,0x467F,0x4681,0x468B,0x468D,0x469D,0x46A9,0x46B1,0x46C7,0x46C9,0x46CF,0x46D3,0x46D5,0x46DF, - 0x46E5,0x46F9,0x4705,0x470F,0x4717,0x4723,0x4729,0x472F,0x4735,0x4739,0x474B,0x474D,0x4751,0x475D,0x476F,0x4771, - 0x477D,0x4783,0x4787,0x4789,0x4799,0x47A5,0x47B1,0x47BF,0x47C3,0x47CB,0x47DD,0x47E1,0x47ED,0x47FB,0x4801,0x4807, - 0x480B,0x4813,0x4819,0x481D,0x4831,0x483D,0x4847,0x4855,0x4859,0x485B,0x486B,0x486D,0x4879,0x4897,0x489B,0x48A1, - 0x48B9,0x48CD,0x48E5,0x48EF,0x48F7,0x4903,0x490D,0x4919,0x491F,0x492B,0x4937,0x493D,0x4945,0x4955,0x4963,0x4969, - 0x496D,0x4973,0x4997,0x49AB,0x49B5,0x49D3,0x49DF,0x49E1,0x49E5,0x49E7,0x4A03,0x4A0F,0x4A1D,0x4A23,0x4A39,0x4A41, - 0x4A45,0x4A57,0x4A5D,0x4A6B,0x4A7D,0x4A81,0x4A87,0x4A89,0x4A8F,0x4AB1,0x4AC3,0x4AC5,0x4AD5,0x4ADB,0x4AED,0x4AEF, - 0x4B07,0x4B0B,0x4B0D,0x4B13,0x4B1F,0x4B25,0x4B31,0x4B3B,0x4B43,0x4B49,0x4B59,0x4B65,0x4B6D,0x4B77,0x4B85,0x4BAD, - 0x4BB3,0x4BB5,0x4BBB,0x4BBF,0x4BCB,0x4BD9,0x4BDD,0x4BDF,0x4BE3,0x4BE5,0x4BE9,0x4BF1,0x4BF7,0x4C01,0x4C07,0x4C0D, - 0x4C0F,0x4C15,0x4C1B,0x4C21,0x4C2D,0x4C33,0x4C4B,0x4C55,0x4C57,0x4C61,0x4C67,0x4C73,0x4C79,0x4C7F,0x4C8D,0x4C93, - 0x4C99,0x4CCD,0x4CE1,0x4CE7,0x4CF1,0x4CF3,0x4CFD,0x4D05,0x4D0F,0x4D1B,0x4D27,0x4D29,0x4D2F,0x4D33,0x4D41,0x4D51, - 0x4D59,0x4D65,0x4D6B,0x4D81,0x4D83,0x4D8D,0x4D95,0x4D9B,0x4DB1,0x4DB3,0x4DC9,0x4DCF,0x4DD7,0x4DE1,0x4DED,0x4DF9, - 0x4DFB,0x4E05,0x4E0B,0x4E17,0x4E19,0x4E1D,0x4E2B,0x4E35,0x4E37,0x4E3D,0x4E4F,0x4E53,0x4E5F,0x4E67,0x4E79,0x4E85, - 0x4E8B,0x4E91,0x4E95,0x4E9B,0x4EA1,0x4EAF,0x4EB3,0x4EB5,0x4EC1,0x4ECD,0x4ED1,0x4ED7,0x4EE9,0x4EFB,0x4F07,0x4F09, - 0x4F19,0x4F25,0x4F2D,0x4F3F,0x4F49,0x4F63,0x4F67,0x4F6D,0x4F75,0x4F7B,0x4F81,0x4F85,0x4F87,0x4F91,0x4FA5,0x4FA9, - 0x4FAF,0x4FB7,0x4FBB,0x4FCF,0x4FD9,0x4FDB,0x4FFD,0x4FFF,0x5003,0x501B,0x501D,0x5029,0x5035,0x503F,0x5045,0x5047, - 0x5053,0x5071,0x5077,0x5083,0x5093,0x509F,0x50A1,0x50B7,0x50C9,0x50D5,0x50E3,0x50ED,0x50EF,0x50FB,0x5107,0x510B, - 0x510D,0x5111,0x5117,0x5123,0x5125,0x5135,0x5147,0x5149,0x5171,0x5179,0x5189,0x518F,0x5197,0x51A1,0x51A3,0x51A7, - 0x51B9,0x51C1,0x51CB,0x51D3,0x51DF,0x51E3,0x51F5,0x51F7,0x5209,0x5213,0x5215,0x5219,0x521B,0x521F,0x5227,0x5243, - 0x5245,0x524B,0x5261,0x526D,0x5273,0x5281,0x5293,0x5297,0x529D,0x52A5,0x52AB,0x52B1,0x52BB,0x52C3,0x52C7,0x52C9, - 0x52DB,0x52E5,0x52EB,0x52FF,0x5315,0x531D,0x5323,0x5341,0x5345,0x5347,0x534B,0x535D,0x5363,0x5381,0x5383,0x5387, - 0x538F,0x5395,0x5399,0x539F,0x53AB,0x53B9,0x53DB,0x53E9,0x53EF,0x53F3,0x53F5,0x53FB,0x53FF,0x540D,0x5411,0x5413, - 0x5419,0x5435,0x5437,0x543B,0x5441,0x5449,0x5453,0x5455,0x545F,0x5461,0x546B,0x546D,0x5471,0x548F,0x5491,0x549D, - 0x54A9,0x54B3,0x54C5,0x54D1,0x54DF,0x54E9,0x54EB,0x54F7,0x54FD,0x5507,0x550D,0x551B,0x5527,0x552B,0x5539,0x553D, - 0x554F,0x5551,0x555B,0x5563,0x5567,0x556F,0x5579,0x5585,0x5597,0x55A9,0x55B1,0x55B7,0x55C9,0x55D9,0x55E7,0x55ED, - 0x55F3,0x55FD,0x560B,0x560F,0x5615,0x5617,0x5623,0x562F,0x5633,0x5639,0x563F,0x564B,0x564D,0x565D,0x565F,0x566B, - 0x5671,0x5675,0x5683,0x5689,0x568D,0x568F,0x569B,0x56AD,0x56B1,0x56D5,0x56E7,0x56F3,0x56FF,0x5701,0x5705,0x5707, - 0x570B,0x5713,0x571F,0x5723,0x5747,0x574D,0x575F,0x5761,0x576D,0x5777,0x577D,0x5789,0x57A1,0x57A9,0x57AF,0x57B5, - 0x57C5,0x57D1,0x57D3,0x57E5,0x57EF,0x5803,0x580D,0x580F,0x5815,0x5827,0x582B,0x582D,0x5855,0x585B,0x585D,0x586D, - 0x586F,0x5873,0x587B,0x588D,0x5897,0x58A3,0x58A9,0x58AB,0x58B5,0x58BD,0x58C1,0x58C7,0x58D3,0x58D5,0x58DF,0x58F1, - 0x58F9,0x58FF,0x5903,0x5917,0x591B,0x5921,0x5945,0x594B,0x594D,0x5957,0x595D,0x5975,0x597B,0x5989,0x5999,0x599F, - 0x59B1,0x59B3,0x59BD,0x59D1,0x59DB,0x59E3,0x59E9,0x59ED,0x59F3,0x59F5,0x59FF,0x5A01,0x5A0D,0x5A11,0x5A13,0x5A17, - 0x5A1F,0x5A29,0x5A2F,0x5A3B,0x5A4D,0x5A5B,0x5A67,0x5A77,0x5A7F,0x5A85,0x5A95,0x5A9D,0x5AA1,0x5AA3,0x5AA9,0x5ABB, - 0x5AD3,0x5AE5,0x5AEF,0x5AFB,0x5AFD,0x5B01,0x5B0F,0x5B19,0x5B1F,0x5B25,0x5B2B,0x5B3D,0x5B49,0x5B4B,0x5B67,0x5B79, - 0x5B87,0x5B97,0x5BA3,0x5BB1,0x5BC9,0x5BD5,0x5BEB,0x5BF1,0x5BF3,0x5BFD,0x5C05,0x5C09,0x5C0B,0x5C0F,0x5C1D,0x5C29, - 0x5C2F,0x5C33,0x5C39,0x5C47,0x5C4B,0x5C4D,0x5C51,0x5C6F,0x5C75,0x5C77,0x5C7D,0x5C87,0x5C89,0x5CA7,0x5CBD,0x5CBF, - 0x5CC3,0x5CC9,0x5CD1,0x5CD7,0x5CDD,0x5CED,0x5CF9,0x5D05,0x5D0B,0x5D13,0x5D17,0x5D19,0x5D31,0x5D3D,0x5D41,0x5D47, - 0x5D4F,0x5D55,0x5D5B,0x5D65,0x5D67,0x5D6D,0x5D79,0x5D95,0x5DA3,0x5DA9,0x5DAD,0x5DB9,0x5DC1,0x5DC7,0x5DD3,0x5DD7, - 0x5DDD,0x5DEB,0x5DF1,0x5DFD,0x5E07,0x5E0D,0x5E13,0x5E1B,0x5E21,0x5E27,0x5E2B,0x5E2D,0x5E31,0x5E39,0x5E45,0x5E49, - 0x5E57,0x5E69,0x5E73,0x5E75,0x5E85,0x5E8B,0x5E9F,0x5EA5,0x5EAF,0x5EB7,0x5EBB,0x5ED9,0x5EFD,0x5F09,0x5F11,0x5F27, - 0x5F33,0x5F35,0x5F3B,0x5F47,0x5F57,0x5F5D,0x5F63,0x5F65,0x5F77,0x5F7B,0x5F95,0x5F99,0x5FA1,0x5FB3,0x5FBD,0x5FC5, - 0x5FCF,0x5FD5,0x5FE3,0x5FE7,0x5FFB,0x6011,0x6023,0x602F,0x6037,0x6053,0x605F,0x6065,0x606B,0x6073,0x6079,0x6085, - 0x609D,0x60AD,0x60BB,0x60BF,0x60CD,0x60D9,0x60DF,0x60E9,0x60F5,0x6109,0x610F,0x6113,0x611B,0x612D,0x6139,0x614B, - 0x6155,0x6157,0x615B,0x616F,0x6179,0x6187,0x618B,0x6191,0x6193,0x619D,0x61B5,0x61C7,0x61C9,0x61CD,0x61E1,0x61F1, - 0x61FF,0x6209,0x6217,0x621D,0x6221,0x6227,0x623B,0x6241,0x624B,0x6251,0x6253,0x625F,0x6265,0x6283,0x628D,0x6295, - 0x629B,0x629F,0x62A5,0x62AD,0x62D5,0x62D7,0x62DB,0x62DD,0x62E9,0x62FB,0x62FF,0x6305,0x630D,0x6317,0x631D,0x632F, - 0x6341,0x6343,0x634F,0x635F,0x6367,0x636D,0x6371,0x6377,0x637D,0x637F,0x63B3,0x63C1,0x63C5,0x63D9,0x63E9,0x63EB, - 0x63EF,0x63F5,0x6401,0x6403,0x6409,0x6415,0x6421,0x6427,0x642B,0x6439,0x6443,0x6449,0x644F,0x645D,0x6467,0x6475, - 0x6485,0x648D,0x6493,0x649F,0x64A3,0x64AB,0x64C1,0x64C7,0x64C9,0x64DB,0x64F1,0x64F7,0x64F9,0x650B,0x6511,0x6521, - 0x652F,0x6539,0x653F,0x654B,0x654D,0x6553,0x6557,0x655F,0x6571,0x657D,0x658D,0x658F,0x6593,0x65A1,0x65A5,0x65AD, - 0x65B9,0x65C5,0x65E3,0x65F3,0x65FB,0x65FF,0x6601,0x6607,0x661D,0x6629,0x6631,0x663B,0x6641,0x6647,0x664D,0x665B, - 0x6661,0x6673,0x667D,0x6689,0x668B,0x6695,0x6697,0x669B,0x66B5,0x66B9,0x66C5,0x66CD,0x66D1,0x66E3,0x66EB,0x66F5, - 0x6703,0x6713,0x6719,0x671F,0x6727,0x6731,0x6737,0x673F,0x6745,0x6751,0x675B,0x676F,0x6779,0x6781,0x6785,0x6791, - 0x67AB,0x67BD,0x67C1,0x67CD,0x67DF,0x67E5,0x6803,0x6809,0x6811,0x6817,0x682D,0x6839,0x683B,0x683F,0x6845,0x684B, - 0x684D,0x6857,0x6859,0x685D,0x6863,0x6869,0x686B,0x6871,0x6887,0x6899,0x689F,0x68B1,0x68BD,0x68C5,0x68D1,0x68D7, - 0x68E1,0x68ED,0x68EF,0x68FF,0x6901,0x690B,0x690D,0x6917,0x6929,0x692F,0x6943,0x6947,0x6949,0x694F,0x6965,0x696B, - 0x6971,0x6983,0x6989,0x6997,0x69A3,0x69B3,0x69B5,0x69BB,0x69C1,0x69C5,0x69D3,0x69DF,0x69E3,0x69E5,0x69F7,0x6A07, - 0x6A2B,0x6A37,0x6A3D,0x6A4B,0x6A67,0x6A69,0x6A75,0x6A7B,0x6A87,0x6A8D,0x6A91,0x6A93,0x6AA3,0x6AC1,0x6AC9,0x6AE1, - 0x6AE7,0x6B05,0x6B0F,0x6B11,0x6B23,0x6B27,0x6B2D,0x6B39,0x6B41,0x6B57,0x6B59,0x6B5F,0x6B75,0x6B87,0x6B89,0x6B93, - 0x6B95,0x6B9F,0x6BBD,0x6BBF,0x6BDB,0x6BE1,0x6BEF,0x6BFF,0x6C05,0x6C19,0x6C29,0x6C2B,0x6C31,0x6C35,0x6C55,0x6C59, - 0x6C5B,0x6C5F,0x6C65,0x6C67,0x6C73,0x6C77,0x6C7D,0x6C83,0x6C8F,0x6C91,0x6C97,0x6C9B,0x6CA1,0x6CA9,0x6CAF,0x6CB3, - 0x6CC7,0x6CCB,0x6CEB,0x6CF5,0x6CFD,0x6D0D,0x6D0F,0x6D25,0x6D27,0x6D2B,0x6D31,0x6D39,0x6D3F,0x6D4F,0x6D5D,0x6D61, - 0x6D73,0x6D7B,0x6D7F,0x6D93,0x6D99,0x6DA5,0x6DB1,0x6DB7,0x6DC1,0x6DC3,0x6DCD,0x6DCF,0x6DDB,0x6DF7,0x6E03,0x6E15, - 0x6E17,0x6E29,0x6E33,0x6E3B,0x6E45,0x6E75,0x6E77,0x6E7B,0x6E81,0x6E89,0x6E93,0x6E95,0x6E9F,0x6EBD,0x6EBF,0x6EE3, - 0x6EE9,0x6EF3,0x6EF9,0x6EFB,0x6F0D,0x6F11,0x6F17,0x6F1F,0x6F2F,0x6F3D,0x6F4D,0x6F53,0x6F61,0x6F65,0x6F79,0x6F7D, - 0x6F83,0x6F85,0x6F8F,0x6F9B,0x6F9D,0x6FA3,0x6FAF,0x6FB5,0x6FBB,0x6FBF,0x6FCB,0x6FCD,0x6FD3,0x6FD7,0x6FE3,0x6FE9, - 0x6FF1,0x6FF5,0x6FF7,0x6FFD,0x700F,0x7019,0x701F,0x7027,0x7033,0x7039,0x704F,0x7051,0x7057,0x7063,0x7075,0x7079, - 0x7087,0x708D,0x7091,0x70A5,0x70AB,0x70BB,0x70C3,0x70C7,0x70CF,0x70E5,0x70ED,0x70F9,0x70FF,0x7105,0x7115,0x7121, - 0x7133,0x7151,0x7159,0x715D,0x715F,0x7163,0x7169,0x7183,0x7187,0x7195,0x71AD,0x71C3,0x71C9,0x71CB,0x71D1,0x71DB, - 0x71E1,0x71EF,0x71F5,0x71FB,0x7207,0x7211,0x7217,0x7219,0x7225,0x722F,0x723B,0x7243,0x7255,0x7267,0x7271,0x7277, - 0x727F,0x728F,0x7295,0x729B,0x72A3,0x72B3,0x72C7,0x72CB,0x72CD,0x72D7,0x72D9,0x72E3,0x72EF,0x72F5,0x72FD,0x7303, - 0x730D,0x7321,0x732B,0x733D,0x7357,0x735B,0x7361,0x737F,0x7381,0x7385,0x738D,0x7393,0x739F,0x73AB,0x73BD,0x73C1, - 0x73C9,0x73DF,0x73E5,0x73E7,0x73F3,0x7415,0x741B,0x742D,0x7439,0x743F,0x7441,0x745D,0x746B,0x747B,0x7489,0x748D, - 0x749B,0x74A7,0x74AB,0x74B1,0x74B7,0x74B9,0x74DD,0x74E1,0x74E7,0x74FB,0x7507,0x751F,0x7525,0x753B,0x753D,0x754D, - 0x755F,0x756B,0x7577,0x7589,0x758B,0x7591,0x7597,0x759D,0x75A1,0x75A7,0x75B5,0x75B9,0x75BB,0x75D1,0x75D9,0x75E5, - 0x75EB,0x75F5,0x75FB,0x7603,0x760F,0x7621,0x762D,0x7633,0x763D,0x763F,0x7655,0x7663,0x7669,0x766F,0x7673,0x7685, - 0x768B,0x769F,0x76B5,0x76B7,0x76C3,0x76DB,0x76DF,0x76F1,0x7703,0x7705,0x771B,0x771D,0x7721,0x772D,0x7735,0x7741, - 0x774B,0x7759,0x775D,0x775F,0x7771,0x7781,0x77A7,0x77AD,0x77B3,0x77B9,0x77C5,0x77CF,0x77D5,0x77E1,0x77E9,0x77EF, - 0x77F3,0x77F9,0x7807,0x7825,0x782B,0x7835,0x783D,0x7853,0x7859,0x7861,0x786D,0x7877,0x7879,0x7883,0x7885,0x788B, - 0x7895,0x7897,0x78A1,0x78AD,0x78BF,0x78D3,0x78D9,0x78DD,0x78E5,0x78FB,0x7901,0x7907,0x7925,0x792B,0x7939,0x793F, - 0x794B,0x7957,0x795D,0x7967,0x7969,0x7973,0x7991,0x7993,0x79A3,0x79AB,0x79AF,0x79B1,0x79B7,0x79C9,0x79CD,0x79CF, - 0x79D5,0x79D9,0x79F3,0x79F7,0x79FF,0x7A05,0x7A0F,0x7A11,0x7A15,0x7A1B,0x7A23,0x7A27,0x7A2D,0x7A4B,0x7A57,0x7A59, - 0x7A5F,0x7A65,0x7A69,0x7A7D,0x7A93,0x7A9B,0x7A9F,0x7AA1,0x7AA5,0x7AED,0x7AF5,0x7AF9,0x7B01,0x7B17,0x7B19,0x7B1D, - 0x7B2B,0x7B35,0x7B37,0x7B3B,0x7B4F,0x7B55,0x7B5F,0x7B71,0x7B77,0x7B8B,0x7B9B,0x7BA1,0x7BA9,0x7BAF,0x7BB3,0x7BC7, - 0x7BD3,0x7BE9,0x7BEB,0x7BEF,0x7BF1,0x7BFD,0x7C07,0x7C19,0x7C1B,0x7C31,0x7C37,0x7C49,0x7C67,0x7C69,0x7C73,0x7C81, - 0x7C8B,0x7C93,0x7CA3,0x7CD5,0x7CDB,0x7CE5,0x7CED,0x7CF7,0x7D03,0x7D09,0x7D1B,0x7D1D,0x7D33,0x7D39,0x7D3B,0x7D3F, - 0x7D45,0x7D4D,0x7D53,0x7D59,0x7D63,0x7D75,0x7D77,0x7D8D,0x7D8F,0x7D9F,0x7DAD,0x7DB7,0x7DBD,0x7DBF,0x7DCB,0x7DD5, - 0x7DE9,0x7DED,0x7DFB,0x7E01,0x7E05,0x7E29,0x7E2B,0x7E2F,0x7E35,0x7E41,0x7E43,0x7E47,0x7E55,0x7E61,0x7E67,0x7E6B, - 0x7E71,0x7E73,0x7E79,0x7E7D,0x7E91,0x7E9B,0x7E9D,0x7EA7,0x7EAD,0x7EB9,0x7EBB,0x7ED3,0x7EDF,0x7EEB,0x7EF1,0x7EF7, - 0x7EFB,0x7F13,0x7F15,0x7F19,0x7F31,0x7F33,0x7F39,0x7F3D,0x7F43,0x7F4B,0x7F5B,0x7F61,0x7F63,0x7F6D,0x7F79,0x7F87, - 0x7F8D,0x7FAF,0x7FB5,0x7FC3,0x7FC9,0x7FCD,0x7FCF -}; diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp deleted file mode 100644 index 0a2823c2f78..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/msgloop.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Add_Accelerator -- Adds a keyboard accelerator to the message handler. * - * Add_Modeless_Dialog -- Adds a modeless dialog box to the message handler. * - * Remove_Accelerator -- Removes an accelerator from the message processor. * - * Remove_Modeless_Dialog -- Removes the dialog box from the message tracking handler. * - * Windows_Message_Handler -- Handles windows message. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "Vector.H" -#include "win.h" - - -/* -** Tracks modeless dialog box messages by keeping a record of all active modeless dialog -** box handles and then determining if the windows message applies to the dialog box. If it -** does, then the default message handling should not be performed. -*/ -static DynamicVectorClass _ModelessDialogs; - - -/* -** Tracks windows accelerators with this structure. -*/ -struct AcceleratorTracker { - AcceleratorTracker(HWND window = NULL, HACCEL accelerator = NULL) : Accelerator(accelerator), Window(window) {} - - int operator == (AcceleratorTracker const & acc) const {return(Accelerator == acc.Accelerator && Window == acc.Window);} - int operator != (AcceleratorTracker const & acc) const {return(!(*this == acc));} - - HACCEL Accelerator; - HWND Window; -}; -static DynamicVectorClass _Accelerators; - - -/* -** In those cases where message intercept needs to occur but not for purposes -** of a modeless dialog box or a windows accelerator, then this is a function -** pointer to than message intercept handler. -*/ -bool (*Message_Intercept_Handler)(MSG &msg) = NULL; - - -/*********************************************************************************************** - * Windows_Message_Handler -- Handles windows message. * - * * - * This routine will take all messages that have accumulated in the message queue and * - * dispatch them to their respective recipients. When the message queue has been emptied, * - * then this routine will return. By using this routine, it is possible to have the main * - * program run in the main thread and yet still have it behave like a normal program as * - * far as message handling is concerned. To achieve this, this routine must be called on * - * a semi-frequent basis (a few times a second is plenty). * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Windows_Message_Handler(void) -{ - MSG msg; - - /* - ** Process windows messages until the message queue is exhuasted. - */ - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if (!GetMessage( &msg, NULL, 0, 0 )) { - return; - } - - /* - ** Pass the message through any loaded accelerators. If the message - ** was processed by an accelerator, then it doesn't need to be - ** processed by the normal message handling procedure. - */ - bool processed = false; - for (int aindex = 0; aindex < _Accelerators.Count(); aindex++) { - if (TranslateAccelerator(_Accelerators[aindex].Window, _Accelerators[aindex].Accelerator, &msg)) { - processed = true; - } - break; - } - if (processed) continue; - - /* - ** Pass the windows message through any modeless dialogs that may - ** be active. If one of the dialogs processes the message, then - ** it must not be processed by the normal window message handler. - */ - for (int index = 0; index < _ModelessDialogs.Count(); index++) { - if (IsDialogMessage(_ModelessDialogs[index], &msg)) { - processed = true; - break; - } - } - if (processed) continue; - - /* - ** If the message was not handled by any normal intercept handlers, then - ** submit the message to a custom message handler if one has been provided. - */ - if (Message_Intercept_Handler != NULL) { - processed = Message_Intercept_Handler(msg); - } - if (processed) continue; - - /* - ** If the message makes it to this point, then it must be a normal message. Process - ** it in the normal fashion. The message will appear in the window message handler - ** for the window that it was directed to. - */ - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - - -/*********************************************************************************************** - * Add_Modeless_Dialog -- Adds a modeless dialog box to the message handler. * - * * - * When a modeless dialog box becomes active, the messages processed by the main message * - * handler must be handled different. This routine is used to inform the message handler * - * that a dialog box is active and messages must be fed to it as appropriate. * - * * - * INPUT: dialog -- Handle to the modeless dialog box. * - * * - * OUTPUT: none * - * * - * WARNINGS: The modeless dialog box must be removed from the tracking system by calling * - * Remove_Modeless_Dialog. Failure to do so when the dialog is destroyed will * - * result in undefined behavior. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Add_Modeless_Dialog(HWND dialog) -{ - _ModelessDialogs.Add(dialog); -} - - -/*********************************************************************************************** - * Remove_Modeless_Dialog -- Removes the dialog box from the message tracking handler. * - * * - * This routine must be called when a modeless dialog is being removed. * - * * - * INPUT: dialog -- Handle to the modeless dialog that was previously submitted to * - * Add_Modeless_Dialog(). * - * * - * OUTPUT: none * - * * - * WARNINGS: Failure to call this routine will result in undefined behavior when the dialog * - * is destroyed. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Remove_Modeless_Dialog(HWND dialog) -{ - _ModelessDialogs.Delete(dialog); -} - - -/*********************************************************************************************** - * Add_Accelerator -- Adds a keyboard accelerator to the message handler. * - * * - * This routine will add a keyboard accelerator to the tracking process for the message * - * handler. If the incoming message is processed by an accelerator, then the normal * - * processing must be altered. By using this routine, the proper behavior of accelerators * - * is maintained. * - * * - * INPUT: window -- The window that the accelerator belongs to. Each accelerator must be * - * assigned to a window. * - * * - * accelerator -- The handler to the windows accelerator. * - * * - * OUTPUT: none * - * * - * WARNINGS: When the accelerator is no longer valid (or the controlling window as been * - * destroyed), the Remove_Accelerator function must be called. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Add_Accelerator(HWND window, HACCEL accelerator) -{ - _Accelerators.Add(AcceleratorTracker(window, accelerator)); -} - - -/*********************************************************************************************** - * Remove_Accelerator -- Removes an accelerator from the message processor. * - * * - * This routine must be called when the accelerator or the window it was attached to has * - * been destroyed. * - * * - * INPUT: accelerator -- The accelerator to remove from the tracking system. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine presumes that the accelerator will not be shared between windows. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Remove_Accelerator(HACCEL accelerator) -{ - for (int index = 0; index < _Accelerators.Count(); index++) { - if (_Accelerators[index].Accelerator == accelerator) { - _Accelerators.Delete(index); - break; - } - } -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.h deleted file mode 100644 index 8f9db7cc1ec..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/msgloop.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/msgloop.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MSGLOOP_H -#define MSGLOOP_H - -#include - -// Main message handler. -void Windows_Message_Handler(void); - -// Modeless dialog box support routines. -void Remove_Modeless_Dialog(HWND dialog); -void Add_Modeless_Dialog(HWND dialog); - -// Accelerator keys support routines. -void Add_Accelerator(HWND window, HACCEL accelerator); -void Remove_Accelerator(HACCEL accelerator); - -// General purpose message intercept handler. -extern bool (*Message_Intercept_Handler)(MSG &msg); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/obscure.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/obscure.h deleted file mode 100644 index 5acbc5aa5e4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/obscure.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Obscure.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef OBSCURE_H -#define OBSCURE_H - -long Obfuscate(char const * string); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/palette.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/palette.cpp deleted file mode 100644 index 3776cf7ffb4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/palette.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PALETTE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * PaletteClass::operator = -- Assignment operator for palette objects. * - * PaletteClass::operator == -- Equality operator for palette objects. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "PALETTE.H" -#include - - -/*********************************************************************************************** - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * * - * This constructor will fill the palette with the color specified. * - * * - * INPUT: rgb -- Reference to the color to fill the entire palette with. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass::PaletteClass(RGBClass const & rgb) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index] = rgb; - } -} - -PaletteClass::PaletteClass(unsigned char *binary_palette) -{ - memcpy(&Palette[0], binary_palette, sizeof(Palette)); -} - -/*********************************************************************************************** - * PaletteClass::operator == -- Equality operator for palette objects. * - * * - * This is the comparison for equality operator. It will compare palette objects to * - * determine if they are identical. * - * * - * INPUT: palette -- Reference to the palette to compare to this palette. * - * * - * OUTPUT: Are the two palettes identical? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::operator == (PaletteClass const & palette) const -{ - if (this == &palette) return(true); - return(memcmp(&Palette[0], &palette.Palette[0], sizeof(Palette)) == 0); -} - - -/*********************************************************************************************** - * PaletteClass::operator = -- Assignment operator for palette objects. * - * * - * This is the assignment operator for palette objects. Although the default C++ generated * - * assignment operator would function correctly, it would not check for self-assignment * - * and thus this routine can be faster. * - * * - * INPUT: palette -- Reference to that palette that will be copied into this palette. * - * * - * OUTPUT: Returns with a reference to the newly copied to palette. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass & PaletteClass::operator = (PaletteClass const & palette) -{ - if (this == &palette) return(*this); - - memcpy(&Palette[0], &palette.Palette[0], sizeof(Palette)); - return(*this); -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, BlackColor); - } -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio, PaletteClass const & palette) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, palette[index]); - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the specified parts of this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. The input lookup table is used to determine * - * which entries should fade and which should stay the same * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * lookup -- ptr to lookup table * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, BlackColor); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. The input lookup * - * table is used to determine which entries should fade and which should stay the same * - * * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * lookup -- ptr to lookup table * - * * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, PaletteClass const & palette, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, palette[index]); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * * - * This routine will examine the palette and return with the color index number for the * - * color that most closely matches the color specified. Remap operations rely heavily on * - * this routine to allow working with a constant palette. * - * * - * INPUT: rgb -- Reference to a color to search for in the current palette. * - * * - * OUTPUT: Returns with a color index value to most closely matches the specified color. * - * * - * WARNINGS: This routine will quite likely not find an exact match. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::Closest_Color(RGBClass const & rgb) const -{ - int closest = 0; - int value = -1; - - RGBClass const * ptr = &Palette[0]; - for (int index = 0; index < COLOR_COUNT; index++) { - int difference = rgb.Difference(*ptr++); - if (value == -1 || difference < value) { - value = difference; - closest = index; - } - } - return(closest); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.H b/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.H deleted file mode 100644 index c396bfdd865..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.H +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PCX.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PCX_H -#define PCX_H - -#include "bsurface.h" -#include "PALETTE.H" -#include "WWFILE.H" -#include - - -struct RGB { - unsigned char red; - unsigned char green; - unsigned char blue; -}; - -struct PCX_HEADER -{ - char id; - char version; - char encoding; - char pixelsize; - short x; - short y; - short width; - short height; - short xres; - short yres; - RGB ega_palette[16]; - char nothing; - char color_planes; - unsigned short byte_per_line; - short palette_type; - char filler[58]; -}; - - -Surface * Read_PCX_File(FileClass & file_handle, PaletteClass * palette= NULL, void * buff=NULL, long size=0); -//Surface * Read_PCX_File (char * name, Buffer & Buff, PaletteClass * palette= NULL) ; -bool Write_PCX_File(FileClass & file, Surface & pic, PaletteClass * palette); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp deleted file mode 100644 index c1d6f2c741f..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/PCX.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/28/98 12:06p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "pcx.H" -#include - - -/*************************************************************************** - * READ_PCX_FILE -- read a pcx file into a Graphic Buffer * - * * - * GraphicBufferClass* Read_PCX_File (char* name, char* palette,void *Buff, long size ); * - * * - * * - * INPUT: name is a NULL terminated string of the format [xxxx.pcx] * - * palette is optional, if palette != NULL the the color palette of * - * the pcx file will be place in the memory block pointed * - * by palette. * - * Buff is optional, if Buff == NULL a new memory Buffer * - * will be allocated, otherwise the file will be placed * - * at location pointed by Buffer; * - * Size is the size in bytes of the memory block pointed by Buff * - * is also optional; * * - * OUTPUT: on success a pointer to a GraphicBufferClass containing the * - * pcx file, NULL otherwise. * - * * - * WARNINGS: * - * Appears to be a comment-free zone * - * * - * HISTORY: * - * 05/03/1995 JRJ : Created. * - * 04/30/1996 ST : Tidied up and modified to use CCFileClass * - *=========================================================================*/ -#define POOL_SIZE 2048 -#define READ_CHAR() *file_ptr++ ; \ - if ( file_ptr >= & pool [ POOL_SIZE ] ) { \ - file_handle.Read (pool, POOL_SIZE ); \ - file_ptr = pool ; \ - } -#define READ_CHARx() *file_ptr++ ; \ - if ( file_ptr >= & pool [ POOL_SIZE ] ) { \ - file_handle.Read (pool, POOL_SIZE ); \ - } - - -Surface * Read_PCX_File(FileClass & file_handle, PaletteClass * palette, void * Buff, long Size) -{ - unsigned i, j; - unsigned rle; - unsigned color; - unsigned scan_pos; - char *file_ptr; - unsigned width; - unsigned height; - char *buffer; - PCX_HEADER header; - char pool [POOL_SIZE]; - BSurface * pic; - - if (!file_handle.Is_Available()) return (NULL); - - file_handle.Open(FileClass::READ); - - file_handle.Read (&header, sizeof (PCX_HEADER)); - - if (header.id != 10 && header.version != 5 && header.pixelsize != 8 ) return NULL ; - - width = header.width - header.x + 1; - height = header.height - header.y + 1; - - if (Buff != NULL) { - i = Size / width; - height = MIN ((int)(i - 1), (int)height); - Buffer b(Buff, Size); - pic = W3DNEW BSurface(width, height, 1, &b); - if (pic == NULL) return NULL ; - } else { - pic = W3DNEW BSurface(width, height, 1); - if (pic == NULL) return NULL ; - } - - buffer = (char *)pic->Lock(); - if (buffer != NULL) { - file_ptr = pool ; - file_handle.Read (pool, POOL_SIZE); - - if ( header.byte_per_line != width ) { - - i = 0; - rle = 0; - for ( scan_pos = j = 0 ; j < height ; j ++, scan_pos += width ) { - for ( i = 0 ; i < width ; ) { - rle = READ_CHAR (); - if ( rle > 192 ) { - rle -= 192 ; - color = READ_CHAR (); ; - memset ( buffer + scan_pos + i, color, rle ); - i += rle; - } else { - *(buffer+scan_pos + i++ ) = (char)rle; - } - } - } - - if ( i == width ) rle = READ_CHAR (); - if ( rle > 192 ) READ_CHARx(); - - } else { - - for ( i = 0 ; i < width * height ; ) { - rle = READ_CHAR (); - rle &= 0xff; - if ( rle > 192 ) { - rle -= 192 ; - color = READ_CHAR (); - memset ( buffer + i, color, rle ); - i += rle ; - } else { - *(buffer + i++) = (char)rle; - } - } - } - pic->Unlock(); - } - - if ( palette ) { - file_handle.Seek (- (256 * (int)sizeof(RGB)), SEEK_END ); - file_handle.Read (palette, 256L * sizeof ( RGB )); - } - - file_handle.Close(); - return pic; -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/pk.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/pk.cpp deleted file mode 100644 index 636a4bf36cd..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/pk.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PK.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PKey::Decode_Exponent -- Decodes the exponent back into the key. * - * PKey::Decode_Modulus -- Decodes the modulus value back into the key. * - * PKey::Decrypt -- Decrypt supplied cyphertext into its original plaintext. * - * PKey::Encode_Exponent -- Encode the exponent portion of the key into a buffer. * - * PKey::Encode_Modulus -- Encode the modulus portion of the key. * - * PKey::Encrypt -- Encrypt blocks of plaintext. * - * PKey::Generate -- Generate a public and private key. * - * PKey::PKey -- Construct a key using encoded strings. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "PK.H" -#include "RNDSTRAW.H" -#include - - -#if defined(__BORLANDC__) -extern BigInt Generate_Prime(Straw &, int, BigInt const *); -#endif - -#ifdef _MSC_VER -//BigInt Generate_Prime(Straw &, int, BigInt const *); -#endif - - -/*********************************************************************************************** - * PKey::PKey -- Construct a key using encoded strings. * - * * - * This constructor will construct a key based on the encoded strings supplied. * - * * - * INPUT: exponent -- The encoded string for the exponent portion of the key. * - * * - * modulus -- The encoded string for the modulus portion of the key. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -PKey::PKey(void const * exponent, void const * modulus) -{ - Modulus.DERDecode((unsigned char *)modulus); - Exponent.DERDecode((unsigned char *)exponent); - BitPrecision = Modulus.BitCount()-1; -} - - -/*********************************************************************************************** - * PKey::Encode_Modulus -- Encode the modulus portion of the key. * - * * - * This will store the modulus portion of the key into a buffer. The number of bytes * - * stored into the buffer depends on the value of the key. * - * * - * INPUT: buffer -- Pointer to the buffer that will hold the encoded modulus value. * - * * - * OUTPUT: Returns with the number of bytes stored to the buffer. * - * * - * WARNINGS: Be sure that the buffer can hold the encoded bytes. This is normally around the * - * same size as the Crypt_Block_Size() (plus a byte or two). * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encode_Modulus(void * buffer) const -{ - if (buffer == NULL) { - return(0); - } - return(Modulus.DEREncode((unsigned char *)buffer)); -} - - -/*********************************************************************************************** - * PKey::Encode_Exponent -- Encode the exponent portion of the key into a buffer. * - * * - * This routine will encode the exponent portion of the key. This is only necessary for the * - * slow key since the fast key always has an exponent of 65537. * - * * - * INPUT: buffer -- Pointer to the buffer that will be filled with the encoded exponent. * - * * - * OUTPUT: Returns with the nuber of bytes stored into the buffer. * - * * - * WARNINGS: Be sure the buffer is big enough to hold the encoded exponent. Usually this is * - * about the same size as the Crypt_Block_Size (plus a byte or two). * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encode_Exponent(void * buffer) const -{ - if (buffer == NULL) { - return(0); - } - return(Exponent.DEREncode((unsigned char *)buffer)); -} - - -/*********************************************************************************************** - * PKey::Decode_Modulus -- Decodes the modulus value back into the key. * - * * - * This is the counterpart to the Encode_Modulus() function. It will initialize the * - * modulus portion of the key with the encoded data supplied. * - * * - * INPUT: buffer -- Pointer to the buffer that holds the previously encoded modulus value. * - * * - * OUTPUT: void * - * * - * WARNINGS: void * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -void PKey::Decode_Modulus(void * buffer) -{ - Modulus.DERDecode((unsigned char *)buffer); - BitPrecision = Modulus.BitCount()-1; -} - - -/*********************************************************************************************** - * PKey::Decode_Exponent -- Decodes the exponent back into the key. * - * * - * This is the counterpart to the Encode_Exponent function. It will decode a previously * - * encoded exponent portion back into the key. * - * * - * INPUT: buffer -- Pointer to the buffer that holds the encoded exponent value. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -void PKey::Decode_Exponent(void * buffer) -{ - Exponent.DERDecode((unsigned char *)buffer); -} - - -/*********************************************************************************************** - * PKey::Generate -- Generate a public and private key. * - * * - * Public key cryptography relies on having two paired keys. The key used to encrypt * - * data must be decrypted by using the other key. Which key designated as the public or * - * private key is arbitrary. However, one is faster than the other. Use the faster key for * - * the more common operation. * - * * - * INPUT: random -- Reference to a source of random data. * - * * - * bits -- The number of bits to use for key generation. Use a number greater * - * than 16 but less than 2048. The ideal bit size is one that is evenly * - * divisible by 8 and then add one. Practical numbers range from 65 to * - * 1025 bits. * - * * - * fastkey -- Reference to the key that has fast encryption/decryption properties. * - * * - * slowkey -- Reference to the mate key of the other. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine can take a very long time. It can take MINUTES to generate a * - * 1024 bit key (even on a Pentium Pro 200Mghz machine). * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - * 07/10/1996 JLB : Must supply source of random data. * - *=============================================================================================*/ -void PKey::Generate(Straw & random, int bits, PKey & fastkey, PKey & slowkey) -{ - /* - ** Key generation consists of create a key pair and then testing the key - ** pair. If the test fails, then repeat the process. The test and repeat - ** method is required since the prime number generating process can't - ** guarantee the generation of a prime number -- it can only generate a - ** highly likely prime number. - */ - for (;;) { - /* - ** Generate the two random prime numbers. This is the longest - ** step. - */ - BigInt p = Generate_Prime(random, bits, &p); - BigInt q = Generate_Prime(random, bits, &q); - - /* - ** The exponent factors are easy to calculate from the prime numbers. - */ - BigInt e = Fast_Exponent(); - BigInt n = p * q; - BigInt pqmin = (p-(unsigned short)1)*(q-(unsigned short)1); - BigInt d = e.Inverse(pqmin); - - /* - ** Store the data into the key objects. Notice that the modulus is the - ** same for both the fast and slow keys. Also notice that the exponent for - ** the fast key is ALWAYS 65537. Given this, it is possible to economize the - ** fast key into being just the modulus and the slow key to being just the - ** exponent (presuming the slow key also has access to the fast key so that - ** it can get the modulus). - */ - fastkey.Exponent = e; - fastkey.Modulus = n; - fastkey.BitPrecision = n.BitCount()-1; - - slowkey.Exponent = d; - slowkey.Modulus = n; - slowkey.BitPrecision = fastkey.BitPrecision; - - /* - ** Test the keys by encrypting a block of random bytes. If it decrypts - ** correctly, then a valid key pair has been generated -- bail. - */ - char before[256]; - char after[256]; - - for (int index = 0; index < fastkey.Plain_Block_Size(); index++) { - before[index] = (char)rand(); - } - fastkey.Encrypt(before, fastkey.Plain_Block_Size(), after); - slowkey.Decrypt(after, slowkey.Crypt_Block_Size(), after); - - /* - ** Compare the pre and post processing buffer. A match indicates - ** a valid key pair. - */ - if (memcmp(before, after, fastkey.Plain_Block_Size()) == 0) break; - } -} - - -/*********************************************************************************************** - * PKey::Encrypt -- Encrypt blocks of plaintext. * - * * - * This routine will encrypt the supplied plaintext into cyphertext by processing the input * - * in block. The source is processed in whole blocks. Partial blocks are not supported by * - * public key cryptography. * - * * - * INPUT: source -- Pointer to the source plaintext that will be encrypted. * - * * - * length -- The length of the plaintext to encrypt. * - * * - * dest -- Pointer to the buffer that will hold the encrypted data. * - * * - * OUTPUT: Returns with the number of cypher text bytes placed into the destination buffer. * - * * - * WARNINGS: Be sure that the destination buffer is big enough to hold the output. * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encrypt(void const * source, int slen, void * dest) const -{ - int total = 0; - - /* - ** Encrypt the source data in full blocks. Partial blocks are not processed and are not - ** copied to the destination buffer. - */ - while (slen >= Plain_Block_Size()) { - - /* - ** Perform the encryption of the block. - */ - BigInt temp = 0; - memmove(&temp, source, Plain_Block_Size()); - temp = temp.exp_b_mod_c(Exponent, Modulus); - - /* - ** Move the cypher block to the destination. - */ - memmove(dest, &temp, Crypt_Block_Size()); - slen -= Plain_Block_Size(); - source = (char *)source + Plain_Block_Size(); - dest = (char *)dest + Crypt_Block_Size(); - total += Crypt_Block_Size(); - } - - return(total); -} - - -/*********************************************************************************************** - * PKey::Decrypt -- Decrypt supplied cyphertext into its original plaintext. * - * * - * This routine will process the supplied cyphertext by breaking it up into blocks and * - * then decrypting each block in turn. The block size is dependant upon the key. By NOT * - * embedding this information into the cypher data, it makes the encryption more secure. * - * * - * INPUT: source -- Pointer to the cypher text to be decrypted. * - * * - * length -- The number of cypher text bytes supplied to this routine. * - * * - * dest -- Pointer to the buffer to hold the plaintext. * - * * - * OUTPUT: Returns with the number of plaintext bytes output to the destination buffer. * - * * - * WARNINGS: Only whole blocks are processed. If the source has any partial block sized * - * data, then it will be left unprocessed. * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Decrypt(void const * source, int slen, void * dest) const -{ - int total = 0; - BigInt temp; - - /* - ** Decrypt the source data in full blocks. Partial blocks are not processed in any way. - */ - while (slen >= Crypt_Block_Size()) { - - /* - ** Perform the encryption. - */ - temp = 0; - memmove(&temp, source, Crypt_Block_Size()); - temp = temp.exp_b_mod_c(Exponent, Modulus); - - /* - ** Move the cypher block to the destination. - */ - memmove(dest, &temp, Plain_Block_Size()); - slen -= Crypt_Block_Size(); - source = (char *)source + Crypt_Block_Size(); - dest = (char *)dest + Plain_Block_Size(); - total += Plain_Block_Size(); - } - - return(total); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h deleted file mode 100644 index 52e11e9d1a6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/pkpipe.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PKPIPE_H -#define PKPIPE_H - -#include "blowpipe.h" -#include "PIPE.H" -#include "PK.H" -#include "RNDSTRAW.H" - - -/* -** This pipe will encrypt/decrypt the data stream. The data is encrypted by generating a -** symetric key that is then encrypted using the public key system. This symetric key is then -** used to encrypt the remaining data. -*/ -class PKPipe : public Pipe -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - PKPipe(CryptControl control, RandomStraw & rnd); - - virtual void Put_To(Pipe * pipe); - virtual void Put_To(Pipe & pipe) {Put_To(&pipe);} - - // Feed data through for processing. - virtual int Put(void const * source, int length); - - // Submit key for encryption/decryption. - void Key(PKey const * key); - - private: - enum { - BLOWFISH_KEY_SIZE=BlowfishEngine::MAX_KEY_LENGTH, - MAX_KEY_BLOCK_SIZE=256 // Maximum size of pk encrypted blowfish key. - }; - - /* - ** This flag indicates whether the PK (fetch blowfish key) phase is - ** in progress or not. - */ - bool IsGettingKey; - - /* - ** This is the random straw that is needed to generate the - ** blowfish key. - */ - RandomStraw & Rand; - - /* - ** This is the attached blowfish pipe. After the blowfish key has been - ** decrypted, then the PK processor goes dormant and the blowfish processor - ** takes over the data flow. - */ - BlowPipe BF; - - /* - ** Controls the method of processing the data stream. - */ - CryptControl Control; - - /* - ** Pointer to the key to use for encryption/decryption. The actual process - ** performed is controlled by the Control member. A key can be used for - ** either encryption or decryption -- it makes no difference. However, whichever - ** process is performed, the opposite process must be performed using the - ** other key. - */ - PKey const * CipherKey; - - /* - ** This is the staging buffer for the block of data. This block must be as large as - ** the largest possible key size or the largest blowfish key (whichever is greater). - */ - char Buffer[MAX_KEY_BLOCK_SIZE]; - - /* - ** The working counter that holds the number of bytes in the staging buffer. - */ - int Counter; - - /* - ** This records the number of bytes remaining in the current block. This - ** will be the number of bytes left to accumulate before the block can be - ** processed either for encryption or decryption. - */ - int BytesLeft; - - int Encrypted_Key_Length(void) const; - int Plain_Key_Length(void) const; - - PKPipe(PKPipe & rvalue); - PKPipe & operator = (PKPipe const & pipe); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h deleted file mode 100644 index 597a08bf850..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PKSTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PKSTRAW_H -#define PKSTRAW_H - -#include "blwstraw.h" -#include "PK.H" -#include "pkstraw.h" -#include "RNDSTRAW.H" - -class PKStraw : public Straw -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - PKStraw(CryptControl control, RandomStraw & rnd); - - virtual void Get_From(Straw * straw); - virtual void Get_From(Straw & straw) {Get_From(&straw);} - - virtual int Get(void * source, int slen); - - // Submit key to be used for encryption/decryption. - void Key(PKey const * key); - - private: - enum { - BLOWFISH_KEY_SIZE=BlowfishEngine::MAX_KEY_LENGTH, - MAX_KEY_BLOCK_SIZE=256 // Maximum size of pk encrypted blowfish key. - }; - - /* - ** This flag indicates whether the PK (fetch blowfish key) phase is - ** in progress or not. - */ - bool IsGettingKey; - - /* - ** This is the random straw that is needed to generate the - ** blowfish key. - */ - RandomStraw & Rand; - - /* - ** This is the attached blowfish pipe. After the blowfish key has been - ** decrypted, then the PK processor goes dormant and the blowfish processor - ** takes over the data flow. - */ - BlowStraw BF; - - /* - ** This control member tells what method (encryption or decryption) that should - ** be performed on the data stream. - */ - CryptControl Control; - - /* - ** Pointer to the key to use for encryption or decryption. If this pointer is NULL, then - ** the data passing through this segment will not be modified. - */ - PKey const * CipherKey; - - /* - ** This is the staging buffer for the block of data. This block must be as large as - ** the largest possible key size or the largest blowfish key size (whichever is - ** greater). - */ - char Buffer[256]; - - int Counter; - - /* - ** This records the number of bytes remaining in the current block. This - ** will be the number of bytes left to accumulate before the block can be - ** processed either for encryption or decryption. - */ - int BytesLeft; - - int Encrypted_Key_Length(void) const; - int Plain_Key_Length(void) const; - - PKStraw(PKStraw & rvalue); - PKStraw & operator = (PKStraw const & straw); -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp deleted file mode 100644 index 19d9347f2e7..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// -// rc4.cpp -// RC4 encryption / decryption -// -#include "rc4.h" -#include - -static unsigned char RC4_Temp_Byte; -#define RC4_SWAP_BYTE(a,b) RC4_Temp_Byte=a; a=b; b=RC4_Temp_Byte - -// -// Don't rely on this to zero the key -// -RC4Class::RC4Class() -{ - memset(Key.State, 0, 256); - Key.X=0; - Key.Y=0; -} - - -// -// Setup the encryption key. This must be called before you encrypt/decrypt! -// -void RC4Class::Prepare_Key(const unsigned char *key_data_ptr, int key_data_len) -{ - unsigned char index1; - unsigned char index2; - unsigned char *state; - int counter; - - state = &Key.State[0]; - for (counter = 0; counter < 256; counter++) - state[counter] = (unsigned char)counter; - Key.X = 0; - Key.Y = 0; - index1 = 0; - index2 = 0; - for (counter = 0; counter < 256; counter++) { - index2 = (unsigned char)(key_data_ptr[index1] + state[counter] + index2); - RC4_SWAP_BYTE(state[counter], state[index2]); - index1 = (unsigned char)((index1 + 1) % key_data_len); - } -} - - -// -// RC4 in standard mode. -// -// This will XOR the buffer with the RC4 stream (like a one time pad). -// -void RC4Class::RC4(unsigned char *buffer_ptr, int buffer_len) -{ - unsigned char x; - unsigned char y; - unsigned char *state; - int counter; - - x = Key.X; - y = Key.Y; - - state = &Key.State[0]; - for (counter = 0; counter < buffer_len; counter++) { - x++; - y = (unsigned char)(y + state[x]); - RC4_SWAP_BYTE(state[x], state[y]); - buffer_ptr[counter] ^= state[(state[x] + state[y]) & 255]; - } - Key.X = x; - Key.Y = y; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.h deleted file mode 100644 index bae5bd38584..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rc4.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef RC4_H -#define RC4_H - -// -// RC4.h - Implementation of RC4 encryption -// -// RC4 is a stream cypher. This means that it basically produces a stream of -// random bytes that you XOR with your data. Each key is somewhat like a -// one time pad. -// -// Just as you should never re-use a one time pad, you should never re-use a key. -// -// If you can't re-exchange a secret key before every message you could keep a -// partial secret key and then include the other part of the key in plaintext. -// The key would be the concatenation of the two parts of the key. -// - -class RC4Class -{ -public: - - RC4Class(); - - // - // Key length can be 0..256 bytes - // Key preparation takes about 0.015 Ms on a 1Ghz PC - // - void Prepare_Key(const unsigned char *key_data_ptr, int key_data_len); - - // - // In-place encryption. Call Prepare_Key first! - // Only a few clock cycles per byte (9 or so...) - // - void RC4(unsigned char *buffer_ptr, int buffer_len); - -private: - - struct RC4Key - { - unsigned char State[256]; - unsigned char X; - unsigned char Y; - }; - - RC4Key Key; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp deleted file mode 100644 index 7fbfe90299c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : wwlib * - * * - * $Archive:: /Commando/Code/wwlib/rcfile.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 7/09/99 1:37p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "rcfile.h" -#include - -const char * RESOURCE_FILE_TYPE_NAME = "File"; - - -ResourceFileClass::ResourceFileClass(HMODULE hmodule, char const *filename) : - ResourceName(NULL), - hModule(NULL), - FileBytes(NULL), - FilePtr(NULL), - EndOfFile(NULL) -{ - Set_Name(filename); - HRSRC hresource = FindResource(hmodule,ResourceName,RESOURCE_FILE_TYPE_NAME); - - if (hresource) { - HGLOBAL hglob = LoadResource(hmodule,hresource); - if (hglob) { - FileBytes = (unsigned char *)LockResource(hglob); - if (FileBytes) { - FilePtr = FileBytes; - EndOfFile = FileBytes + SizeofResource(hmodule,hresource); - } - } - } -} - -ResourceFileClass::~ResourceFileClass(void) -{ - if (ResourceName) - free(ResourceName); -} - -char const * ResourceFileClass::Set_Name(char const *filename) -{ - if (ResourceName) { - free(ResourceName); - ResourceName = NULL; - } - if (filename) { - ResourceName = strdup(filename); - } - return ResourceName; -} - -int ResourceFileClass::Read(void *buffer, int size) -{ - if (!FilePtr) return 0; - - if (FilePtr + size > EndOfFile) { - size = EndOfFile - FilePtr; - } - memcpy(buffer,FilePtr,size); - FilePtr += size; - return size; -} - -int ResourceFileClass::Seek(int pos, int dir) -{ - switch (dir) { - case SEEK_SET: - FilePtr = FileBytes + pos; - break; - - case SEEK_CUR: - FilePtr = FilePtr + pos; - break; - - case SEEK_END: - FilePtr = EndOfFile + pos; - break; - } - - if (FilePtr > EndOfFile) { - FilePtr = EndOfFile; - } - if (FilePtr < FileBytes) { - FilePtr = FileBytes; - } - - return FilePtr - FileBytes; -} - -int ResourceFileClass::Size(void) -{ - return EndOfFile - FileBytes; -} - -void ResourceFileClass::Error(int /*error*/, int /*canretry*/, char const * /*filename*/) -{ -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.h deleted file mode 100644 index f2344e6638b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rcfile.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : wwlib * - * * - * $Archive:: /Commando/Code/wwlib/rcfile.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 7/09/99 1:37p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RCFILE_H -#define RCFILE_H - -#include "always.h" -#include "WWFILE.H" -#include "win.h" - -/* -** ResourceFileClass -** This is a file class which allows you to read from a binary file that you have -** imported into your resources. Just import the file as a custom resource of the -** type "File". Replace the "id" of the resource with its filename (change -** IDR_FILE1 to "MyFile.w3d") and then you will be able to access it by using this -** class. -*/ -class ResourceFileClass : public FileClass -{ - public: - - ResourceFileClass(HMODULE hmodule, char const *filename); - virtual ~ResourceFileClass(void); - - virtual char const * File_Name(void) const { return ResourceName; } - virtual char const * Set_Name(char const *filename); - virtual int Create(void) { return false; } - virtual int Delete(void) { return false; } - virtual bool Is_Available(int /*forced=false*/) { return Is_Open (); } - virtual bool Is_Open(void) const { return (FileBytes != NULL); } - - virtual int Open(char const * /*fname*/, int /*rights=READ*/) { return Is_Open(); } - virtual int Open(int /*rights=READ*/) { return Is_Open(); } - - virtual int Read(void *buffer, int size); - virtual int Seek(int pos, int dir=SEEK_CUR); - virtual int Size(void); - virtual int Write(void const * /*buffer*/, int /*size*/) { return 0; } - virtual void Close(void) { } - virtual void Error(int error, int canretry = false, char const * filename=NULL); - - virtual unsigned char *Peek_Data(void) const { return FileBytes; } - - protected: - - char * ResourceName; - - HMODULE hModule; - - unsigned char * FileBytes; - unsigned char * FilePtr; - unsigned char * EndOfFile; - -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp deleted file mode 100644 index 29a60c48577..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RGB.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * RGBClass::Difference -- Determines the "distance" between two colors. * - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "hsv.h" -#include "PALETTE.H" -#include "RGB.H" - -RGBClass const BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * * - * This routine is used to modify an RGB value to proportionately match another RGB value * - * according to the ratio parameter specified. Typical use of this routine is in palette * - * fading from one palette to another or to black. * - * * - * INPUT: ratio -- The ration of transformation. This value is in the form of 0 to 255, * - * with 0 being no change, and 255 being 100% transformed into the * - * destination color. * - * * - * rgb -- Reference to the destination RGB color to transform this color into. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void RGBClass::Adjust(int ratio, RGBClass const & rgb) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = (int)rgb.Red - (int)Red; - Red = (unsigned char)((int)Red + (value * ratio) / 256); - - value = (int)rgb.Green - (int)Green; - Green = (unsigned char)((int)Green + (value * ratio) / 256); - - value = (int)rgb.Blue - (int)Blue; - Blue = (unsigned char)((int)Blue + (value * ratio) / 256); -} - - -/*********************************************************************************************** - * RGBClass::Difference -- Determines the "distance" between two colors. * - * * - * This routine is used to calculate a relative distance between two colors. The value is * - * relative only to itself and thus is useful only for determining the magnitude of * - * color difference rather than the nature of the color difference. Palette remapping * - * code uses this routine to find closest matches for colors. * - * * - * INPUT: rgb -- Reference to the color to be compared to this color. * - * * - * OUTPUT: Returns the difference between the two colors. The value returned is zero if the * - * colors exactly match. The greater the positive value the greater the difference * - * between the colors. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int RGBClass::Difference(RGBClass const & rgb) const -{ - int r = (int)Red - (int)rgb.Red; - if (r < 0) r = -r; - - int g = (int)Green - (int)rgb.Green; - if (g < 0) g = -g; - - int b = (int)Blue - (int)rgb.Blue; - if (b < 0) b = -b; - - /* - ** At first crack, the difference algorithm might be coded as the sum of the color differences - ** (or sum of the square of the color distances). However, this would not take advantage of the - ** fact that the human eye is most sensative to green, followed by the color blue. With this - ** thought in mind, the following difference algorithm is used. - */ - return(4*g + 3*b + 2*r); -} - - -/*********************************************************************************************** - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * * - * This conversion operator will convert an RGBClass object into an HSVClass object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implicit) to the HSVClass object that most closely * - * represents the RGBClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -RGBClass::operator HSVClass (void) const -{ - int hue; - int saturation; - int value; - - /* - ** Fetch working component values for the color guns. - */ - int red = Get_Red(); - int green = Get_Green(); - int blue = Get_Blue(); - - /* - ** The hue defaults to none. Only if there is a saturation value will the - ** hue be calculated. - */ - hue = 0; - - /* - ** Set the value (brightness) to match the brightest color gun. - */ - value = (red > green) ? red : green; - if (blue > value) value = blue; - - /* - ** Determine the amount of true white present in the color. This is the - ** minimum color gun value. The white component is used to determine - ** color saturation. - */ - int white = (red < green) ? red : green; - if (blue < white) white = blue; - - /* - ** Determine the saturation (intensity) of the color by comparing the - ** ratio of true white as a component of the overall color. The more - ** white component, the less saturation. - */ - saturation = 0; - if (value) { - saturation = ((value - white) * 255) / value; - } - - /* - ** If there is any saturation at all, then the hue must be calculated. The - ** hue is based on a six sided color wheel. - */ - if (saturation != 0) { - unsigned int tmp = value - white; - unsigned int r1 = ((value - red) * 255) / tmp; - unsigned int g1 = ((value - green) * 255) / tmp; - unsigned int b1 = ((value - blue) * 255) / tmp; - - // Find effect of second most predominant color. - // In which section of the hexagon of colors does the color lie? - if (value == red) { - if (white == green) { - tmp = 5 * 256 + b1; - } else { - tmp = 1 * 256 - g1; - } - } else { - if (value == green) { - if (white == blue) { - tmp = 1 * 256 + r1; - } else { - tmp = 3 * 256 - b1; - } - } else { - if (white == red) { - tmp = 3 * 256 + g1; - } else { - tmp = 5 * 256 - r1; - } - } - } - - // Divide by six and round. - hue = tmp / 6; - } - - HSVClass hsv((unsigned char)hue, (unsigned char)saturation, (unsigned char)value); - return(hsv); -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rle.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/rle.cpp deleted file mode 100644 index 565ad5699b1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rle.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/RLE.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/24/98 10:05a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RLEEngine::Compress -- Compresses a sequence of bytes. * - * RLEEngine::Decompress -- Decompress a sequence of RLE compressed bytes. * - * RLEEngine::Line_Compress -- Compress a line of data. * - * RLEEngine::Line_Decompress -- Decompresses a line-compressed RLE data sequence. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "RLE.H" -#include -#include - - -/*********************************************************************************************** - * RLEEngine::Compress -- Compresses a sequence of bytes. * - * * - * This routine will compress the sequence of bytes specified by using RLE compression. * - * * - * INPUT: source -- Pointer to the data to be compressed. * - * * - * dest -- Pointer to the buffer that will hold the compressed data. * - * * - * length -- The length of the data to compress. * - * * - * OUTPUT: Returns with the number of bytes long for the compressed data. * - * * - * WARNINGS: The compressed data may, in rare instances, be larger than the data it was * - * compressing. The worst case is 33% larger. Keep that in mind when supplying * - * the destination buffer to this routine. * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Compress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(length > 0); - - int outlen = 0; - unsigned char const * sptr = (unsigned char const *) source; - unsigned char * dptr = (unsigned char *)dest; - while (length > 0) { - - /* - ** Examine each source byte. If the byte is zero (transparent), then - ** it is recorded as a run. Otherwise it is output without translation. - */ - if (*sptr == '\0') { - - /* - ** Count the number of transparent pixels in this run. - */ - int runcount = 0; - while (sptr[runcount] == '\0' && runcount <= length) { - runcount++; - } - - /* - ** Limit the run to 255 characters maximum. - */ - runcount = MIN(runcount, 255); - if (dptr != NULL) { - *dptr++ = '\0'; - *dptr++ = (unsigned char)runcount; - } - outlen += 2; - sptr += runcount; - length -= runcount; - - } else { - - /* - ** Store the raw byte without any translation. - */ - if (dptr != NULL) { - *dptr++ = *sptr++; - } else { - sptr++; - } - outlen++; - length--; - } - } - - /* - ** Return with the number of compressed output bytes. - */ - return(outlen); -} - - -/*********************************************************************************************** - * RLEEngine::Line_Compress -- Compress a line of data. * - * * - * This routine will compress a sequence of bytes and store the length of the compressed * - * data at the beginning of the output buffer. By encoding the compressed size in this * - * fashion, it is possible to build a sequence of compressed bytes (such as with a sprite) * - * so that each sequence can be quickly traversed. * - * * - * INPUT: source -- Pointer to the source data to be compressed. * - * * - * dest -- Pointer to the destination buffer that will hold the length value and * - * the compressed data. * - * * - * length -- The number of source bytes to compress. * - * * - * OUTPUT: Returns with the number of bytes stored into the output buffer. * - * * - * WARNINGS: The output data could be larger than the source data by as much as 33% + 2 * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Line_Compress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(length > 0); - - /* - ** If an output buffer was specified, then the data is actually compressed - ** into the buffer. - */ - if (dest != NULL) { - unsigned short * sizeptr = (unsigned short *)dest; - int complen = Compress(source, sizeptr+1, length) + sizeof(short); - *sizeptr = (unsigned short)complen; - return(complen); - } - - /* - ** Since no output buffer was specifed, this call merely determins how - ** many bytes would be consumed in the output buffer. - */ - return(Compress(source, NULL, length) + sizeof(short)); -} - - -/*********************************************************************************************** - * RLEEngine::Decompress -- Decompress a sequence of RLE compressed bytes. * - * * - * This will decompress a sequence of RLE compressed bytes. * - * * - * INPUT: source -- Pointer to the RLE compressed data. * - * * - * dest -- Pointer to the buffer that will hold the uncompressed data. * - * * - * length -- The length of the source RLE data to process. * - * * - * OUTPUT: Returns with the actual number of bytes stored into the output buffer. * - * * - * WARNINGS: The output buffer must be large enough to hold the decompressed data. This * - * could be as much as 128 times larger than the source RLE data. * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Decompress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(dest != NULL); - assert(length > 0); - - unsigned char * dptr = (unsigned char *)dest; - unsigned char const * sptr = (unsigned char const *)source; - - /* - ** Process the RLE data normally. - */ - while (length > 0) { - - /* - ** Detect if a zero-run code is present. If so, then dump the desired - ** number of bytes. Otherwise output the pixel in untranslated form. - */ - unsigned char value = *sptr++; - length--; - if (value == '\0') { - int outlen = *sptr++; - length--; - while (outlen > 0) { - *dptr++ = '\0'; - outlen--; - } - - } else { - *dptr++ = value; - } - } - - /* - ** Return with the number of bytes stored into the output buffer. - */ - return(dptr - (unsigned char const *)dest); -} - - -/*********************************************************************************************** - * RLEEngine::Line_Decompress -- Decompresses a line-compressed RLE data sequence. * - * * - * This routine is the counterpart to Line_Compress. It will take a compressed line and * - * fully decompress it into the destination buffer. * - * * - * INPUT: source -- The pointer to the line compressed RLE data. * - * * - * dest -- Pointer to the destination buffer that will hold the decompressed * - * data. * - * * - * OUTPUT: Returns with the number of bytes stored into the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Line_Decompress(void const * source, void * dest) const -{ - assert(source != NULL); - assert(dest != NULL); - - unsigned short const * sptr = (unsigned short const *)source; - - int datalen = *sptr++; - - /* - ** Process the RLE data normally. - */ - return(Decompress(sptr, dest, datalen - sizeof(short))); -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rlerle.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rlerle.h deleted file mode 100644 index 23db02f8956..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rlerle.h +++ /dev/null @@ -1,709 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RLERLE.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RLERLE_H -#define RLERLE_H - -/* -** This class holds the RLE enabled blitter object definitions. There is a blitter object -** type for every kind of pixel operation required of RLE shapes. These are defined as -** templates to support the different destination pixel formats. -*/ - -#include "blitter.h" -#include -#include - - -/* -** This is a helper function that will skip N pixels in the RLE compressed source. This is -** necessary for clipping purposes. The return value represents the number of transparent -** pixels before actual pixel data starts when the RLE uncompression is resumed. -*/ -inline int Skip_Leading_Pixels(unsigned char const * & sptr, int skipper) -{ - /* - ** Skip leading pixels as requested. - */ - while (skipper > 0) { - if (*sptr++ == '\0') { - skipper -= *sptr++; - } else { - skipper--; - } - } - - /* - ** Return with then number of leading transparent pixels in the pixel stream - ** after the end of the skip process. This value must be tracked since the pixel - ** skip process may have ended in the middle of a transparent pixel run. - */ - return(-skipper); -} - - -/* -** Blits with transparency checking and translation to destination pixel format. -*/ -template -class RLEBlitTransXlat : public RLEBlitter { - public: - RLEBlitTransXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[value]; - length -= 1; - } - } - } - - private: - T const * TranslateTable; -}; - - -/* -** This blits RLE compressed pixels by first remapping through a 256 byte table and then -** translating the pixel to screen format. -*/ -template -class RLEBlitTransRemapXlat : public RLEBlitter { - public: - RLEBlitTransRemapXlat(unsigned char const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(TranslateTable != NULL);assert(RemapTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[RemapTable[value]]; - length -= 1; - } - } - } - - private: - unsigned char const * RemapTable; - T const * TranslateTable; -}; - - -/* -** This blits RLE compressed pixels by first remapping through a 256 byte table and then -** translating the pixel to screen format. The remapping table is doubly indirected so that -** it is possible to change the remapping table pointer without creating a separate blitter -** object. -*/ -template -class RLEBlitTransZRemapXlat : public RLEBlitter { - public: - RLEBlitTransZRemapXlat(unsigned char const * const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(TranslateTable != NULL);assert(RemapTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - unsigned char const * remapper = *RemapTable; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[remapper[value]]; - length -= 1; - } - } - } - - private: - unsigned char const * const * RemapTable; - T const * TranslateTable; -}; - - -/* -** This will remap the destination pixels but under the control of the source pixels. -** Where the source pixel is not transparent, the dest pixel is remapped. This algorithm -** really only applies to lowcolor display. -*/ -template -class RLEBlitTransRemapDest : public RLEBlitter { - public: - RLEBlitTransRemapDest(T const * remap) : RemapTable(remap) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = RemapTable[*dptr]; - length -= 1; - dptr++; - } - } - } - - private: - T const * RemapTable; -}; - - -/* -** Algorithmic darkening of hicolor pixels controlled by the source pixels. The source -** pixels are examined only to determine if the destination pixel should be darkened. -** If the source pixel is transparent, then the dest pixel is skipped. The darkening -** algorithm works only for hicolor pixels. -*/ -template -class RLEBlitTransDarken : public RLEBlitter { - public: - RLEBlitTransDarken(T mask) : Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = (T)((*dptr >> 1) & Mask); - length -= 1; - dptr++; - } - } - } - - private: - T Mask; -}; - - -/* -** This blitter performs 50% translucency as it draws. It is commonly used for animation -** effects and other stealth like images. It only works with hicolor pixels but is a good -** candidate for optimization. -*/ -template -class RLEBlitTransLucent50 : public RLEBlitter { - public: - RLEBlitTransLucent50(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = (T)((((*dptr) >> 1) & Mask) + ((TranslateTable[value] >> 1) & Mask)); - length -= 1; - dptr++; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 25% translucency as it draws. This effect is less than spectacular, -** but there are some uses for it. It only works with hicolor pixels. -*/ -template -class RLEBlitTransLucent25 : public RLEBlitter { - public: - RLEBlitTransLucent25(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - T qsource = (T)(((TranslateTable[value] >> 2) & Mask)); - T qdest = (T)(((*dptr) >> 2) & Mask); - *dptr++ = (T)(qdest + qsource + qsource + qsource); - length -= 1; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 75% translucency as it draws. This is quite useful for explosions and -** other gas animation effects. It only works with hicolor pixels and is a good candidate -** for optimization. -*/ -template -class RLEBlitTransLucent75 : public RLEBlitter { - public: - RLEBlitTransLucent75(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - T qsource = (T)(((TranslateTable[value] >> 2) & Mask)); - T qdest = (T)(((*dptr) >> 2) & Mask); - *dptr++ = (T)(qdest + qdest + qdest + qsource); - length -= 1; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -#if defined(_MSC_VER) -void RLEBlitTransZRemapXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned char const * remapper = *RemapTable; - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[remapper] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - mov edx,[transtable] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov al,[ebx+eax] - mov ax,[edx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - - -void RLEBlitTransRemapXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned char const * remapper = RemapTable; - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[remapper] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - mov edx,[transtable] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov al,[ebx+eax] - mov ax,[edx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - - -void RLEBlitTransXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[transtable] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov ax,[ebx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - -#endif - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp deleted file mode 100644 index 16b58b0f38b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/rndstrng.cpp $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 2/08/00 10:59a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "rndstrng.h" -#include "wwstring.h" - -/* -** -*/ -RandomStringClass::RandomStringClass( void ) -{ -} - -RandomStringClass::~RandomStringClass( void ) -{ - while ( Strings.Count() ) { - delete Strings[ 0 ]; - Strings.Delete( 0 ); - } -} - -void RandomStringClass::Add_String( const char * str ) -{ - StringClass * string = W3DNEW StringClass( str ); - Strings.Add( string ); -} - -const char * RandomStringClass::Get_String( void ) -{ - if ( Strings.Count() == 0 ) { - return NULL; - } - unsigned int index = Randomizer(); - index %= Strings.Count(); - return *Strings[index]; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h deleted file mode 100644 index afd079d9bd2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/rndstrng.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/03/99 2:26p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNDSTRNG_H -#define RNDSTRNG_H - -#include "Vector.H" -#include "RANDOM.H" - -class StringClass; - -/* -** -*/ -class RandomStringClass { - -public: - RandomStringClass( void ); - ~RandomStringClass( void ); - - // Add a string to the class. - // (future version may have a weight parameter) - void Add_String( const char * str ); - - // Get a random string from the class - const char * Get_String( void ); - -private: - DynamicVectorClass Strings; - Random2Class Randomizer; -}; - -#endif // RNDSTRNG_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rng.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rng.h deleted file mode 100644 index c9b3dd5dec1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rng.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/rng.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNG_H -#define RNG_H - -/* -** This is an abstract interface class for a random number generator. It serves only to -** provide random numbers. -*/ -class RandomNumberGenerator { - public: - virtual ~RandomNumberGenerator() {} - - virtual void Get_Block(void * output, unsigned int size) = 0; -}; - - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h deleted file mode 100644 index 5421c496df6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h +++ /dev/null @@ -1,349 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef RSACRYPT_H -#define RSACRYPT_H - -#include -#include - -//#define SIMPLE_AND_SLOW_RSA - -// Version identification string for OpenSSH identity files. -#define AUTHFILE_ID_STRING "SSH PRIVATE KEY FILE FORMAT 1.1\n" - -// -// RSACrypt - Implementation of RSA using the Int class from wwlib -// -// For key generation I suggest you use OpenSSH (http://www.openssh.com/) -// There is a utility called "ssh-keygen", call: -// -// ssh-keygen [-b bits] -// -// If you generate the file on a UNIX system, be sure and FTP it in BINARY MODE!!!! -// -// You can then use 'Load_SSH_Keyset' on the identity file it produces. -// -// Note: Make sure you leave the keyphrase blank for the SSH keyset. I don't support -// decrypting that file! -// -// Notation: -// Public keys: -// n = product of two primes, p & q (p & q must remain secret) -// e = relatively prime to (p-1)(q-1) -// -// Private keys: -// d = e^-1 mod ((p-1)(q-1)) // e^-1 = inverse of e -// -// Encrypting: -// cyphertext = m^e mod n -// -// Decrypting: -// message = cyphertext^d mod n -// -// Note: I use a trick involving the chinese remainder theorem to get a 3x speedup in decryption. -// It's well documented on the web so I won't get into detail here. -// -template -class RSACrypt -{ - public: - typedef Int Integer; - - RSACrypt() {} - ~RSACrypt() {} - - void Set_Public_Keys(const Integer &pub_n, const Integer &pub_e); - void Set_Keys(const Integer &pub_n, const Integer &pub_e, - const Integer &priv_d, const Integer &keygen_p, const Integer &keygen_q); - - void Get_Public_Keys(Integer &pub_n, Integer &pub_e) const; - void Get_Private_Key(Integer &priv_d) const; - void Get_Keygen_Keys(Integer &keygen_p, Integer &keygen_q) const; - - bool Load_SSH_Keyset(FileClass *file); - - void Encrypt(const Integer &plaintext, Integer &cyphertext) const; - void Decrypt(const Integer &cyphertext, Integer &plaintext) const; - - private: - bool Load_Bignum(FileClass *file, Integer &num); - - void Decryption_Setup(); // Do precomputation to speedup decryption - - Integer PublicN; - Integer PublicE; - - Integer PrivateD; - - Integer KeygenP; // Primes P & Q generated as part of the keyset - Integer KeygenQ; - - // Precomputed values that speed up encryption - Integer DmodPm1; // d mod p-1 - Integer DmodQm1; // d mod q-1 - - Integer RP; // RP = q^(p-1) mod n - Integer RQ; // RQ = p^(q-1) mod n; -}; - -// -// Set the two public keys: n & e -// -template -void RSACrypt::Set_Public_Keys(const Integer &pub_n, const Integer &pub_e) -{ - PublicN=pub_n; - PublicE=pub_e; -} - -// -// Set the public & private keys: n, e & d -// -template -void RSACrypt::Set_Keys(const Integer &pub_n, const Integer &pub_e, - const Integer &priv_d, const Integer &keygen_p, const Integer &keygen_q) -{ - PublicN=pub_n; - PublicE=pub_e; - PrivateD=priv_d; - - KeygenP=keygen_p; - KeygenQ=keygen_q; - - Decrtyption_Setup(); -} - -// -// Get the public keys -// -template -void RSACrypt::Get_Public_Keys(Integer &pub_n, Integer &pub_e) const -{ - pub_n=PublicN; - pub_e=PublicE; -} - -// -// Get the private key -// -template -void RSACrypt::Get_Private_Key(Integer &priv_d) const -{ - priv_d=PrivateD; -} - - -// -// Get the private numbers created during the keyset generation -// Private as in revealing these will reveal the private key! -// -template -void RSACrypt::Get_Keygen_Keys(Integer &keygen_p, Integer &keygen_q) const -{ - keygen_p=KeygenP; - keygen_q=KeygenQ; -} - - -// -// Load an RSA private keyset from an OpenSSH "identity" file. -// -template -bool RSACrypt::Load_SSH_Keyset(FileClass *file) -{ - assert(file); - if ( ! file) - return(false); - - bool retval=true; - unsigned char buffer[1024]; - - if ( ! file->Open()) - return(false); - - file->Read(buffer, strlen(AUTHFILE_ID_STRING)+1); - buffer[strlen(AUTHFILE_ID_STRING)]=0; // null term - - if (strcmp((char *)buffer, AUTHFILE_ID_STRING)) - return(false); - - unsigned char cypher_type; // keyfile encryption method - file->Read(&cypher_type, 1); - if (cypher_type != 0) - return(false); - - file->Read(buffer, 4); // reserved data - - file->Read(buffer, 4); // ignored - - retval=retval && Load_Bignum(file, PublicN); - retval=retval && Load_Bignum(file, PublicE); - if (!retval) - return(false); - - // comment string - int comment_length; - file->Read(&comment_length, 4); - comment_length=ntohl(comment_length); - - file->Read(buffer, comment_length); - - // post-decrypt check chars - file->Read(buffer, 4); - if ((buffer[0] != buffer[2]) || (buffer[1] != buffer[3])) - return(false); - - Integer q_inv_mod_p; // invserse of q mod p (we don't need this) - - retval=retval && Load_Bignum(file, PrivateD); - retval=retval && Load_Bignum(file, q_inv_mod_p); - retval=retval && Load_Bignum(file, KeygenP); - retval=retval && Load_Bignum(file, KeygenQ); - if (!retval) - return(false); - - // Any remaining bytes are padding - - Decryption_Setup(); - - return(true); -} - -// -// Precomputation for fast decryption -// -template -void RSACrypt::Decryption_Setup(void) -{ - Integer temp; - - // If p < q, swap p & q - if (KeygenP < KeygenQ) - { - temp=KeygenP; - KeygenP=KeygenQ; - KeygenQ=temp; - } - - assert(KeygenP > KeygenQ); - - // pm1 = p - 1 - Integer pm1(KeygenP); - --pm1; - - // pm1 = p - 1 - Integer qm1(KeygenQ); - --qm1; - - // DmodPm1 = d mod (p-1) - Integer::Unsigned_Divide(DmodPm1, temp, PrivateD, pm1); - assert(DmodPm1 < pm1); - - // DmodQm1 = d mod (q-1) - Integer::Unsigned_Divide(DmodQm1, temp, PrivateD, qm1); - assert(DmodQm1 < qm1); - - RP = KeygenQ.exp_b_mod_c(pm1, PublicN); - RQ = KeygenP.exp_b_mod_c(qm1, PublicN); -} - - -// -// RSA Encryption c = m^e mod n -// -template -void RSACrypt::Encrypt(const Integer &plaintext, Integer &cyphertext) const -{ - Integer m(plaintext); - cyphertext=m.exp_b_mod_c(PublicE, PublicN); -} - - -// -// RSA Decryption m = c^d mod n -// -template -void RSACrypt::Decrypt(const Integer &cyphertext, Integer &plaintext) const -{ -#ifdef SIMPLE_AND_SLOW_RSA - Integer c(cyphertext); - plaintext=c.exp_b_mod_c(PrivateD, PublicN); -#else - Integer temp; - - // Get a version of the cyphertext mod q & p - Integer cmp, cmq; - Integer::Unsigned_Divide(cmp, temp, cyphertext, KeygenP); - Integer::Unsigned_Divide(cmq, temp, cyphertext, KeygenQ); - - // mp = cmp ^ dmp mod p - Integer mp; - mp=cmp.exp_b_mod_c(DmodPm1, KeygenP); - - // mq = cmq ^ dmq mod q - Integer mq; - mq=cmq.exp_b_mod_c(DmodQm1, KeygenQ); - - - Integer sp, sq; - - //sp=mp * RP mod n; - //sq=mq * RQ mod n; - XMP_Prepare_Modulus(&PublicN.reg[0], PRECISION); - XMP_Mod_Mult(&sp.reg[0], &mp.reg[0], &RP.reg[0], PRECISION); - XMP_Mod_Mult(&sq.reg[0], &mq.reg[0], &RQ.reg[0], PRECISION); - XMP_Mod_Mult_Clear(PRECISION); - - plaintext = sp+sq; - if (plaintext >= PublicN) - plaintext-=PublicN; - -#endif -} - - -////////////////////////////////// Private Methods Below /////////////////////////////////// - -// -// Load a large number from the SSH keyset file -// -template -bool RSACrypt::Load_Bignum(FileClass *file, Integer &num) -{ - int readlen; - unsigned char buffer[1024]; - unsigned short int n_bits, n_bytes; - - readlen=file->Read(&n_bits, 2); // bits in network byte order - if (readlen != 2) - return(false); - n_bits=ntohs(n_bits); - n_bytes=(n_bits+7)/8; - - readlen=file->Read(buffer, n_bytes); - if (readlen != n_bytes) - return(false); - - num.Unsigned_Decode(buffer, n_bytes); - - return(true); -} - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp deleted file mode 100644 index 4cdb43980e6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Sampler * - * * - * $Archive:: /VSS_Sync/wwlib/sampler.cpp $* - * * - * Original Author:: Hector Yee * - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 10:25p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RandomSamplingClass::Sample -- Samples randomly over a hypercube using Mersenne Twister * - * RegularSamplingClass::Sample -- Samples over a regular hypergrid * - * StratifiedSamplingClass::Sample -- samples over a regular hypergrid with random offset * - * QMCSamplingClass::Sample -- Samples using the Halton sequence * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -// Use Random Sampling if you're not sure -// Use Regular Sampling if you're not concerned about bias -// Use Stratified Sampling if you want good results in low dimensions -// Use QMC if you want low discrepancy and you want reproduceablility - -#include "always.h" -#include "sampler.h" -#include "RANDOM.H" -#include -#include -#include - -Random4Class Random; - -RandomSamplingClass::RandomSamplingClass(unsigned int dimensions,unsigned char divisions): - SamplingClass(dimensions,divisions) -{ -} - -/*********************************************************************************************** - * RandomSamplingClass::Sample -- Samples randomly over a hypercube using Mersenne Twister * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/11/2001 hy : Created. * - *=============================================================================================*/ -void RandomSamplingClass::Sample(float *target) -{ - unsigned int i; - for (i=0; i. -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Sampler * - * * - * $Archive:: /VSS_Sync/wwlib/sampler.h $* - * * - * Original Author:: Hector Yee * - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 10:25p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -// 'function selected for automatic inline expansion'. Cool, but since we're treating -// warnings as errors, don't warn me about this! -#pragma warning(disable : 4711) - -// 'not inlined' -- the evil twin of the above warning. -#pragma warning(disable : 4710) - -#ifndef SAMPLER_H -#define SAMPLER_H - -class Random4Class; - -// This module contains sampling techniques that sample over multidimensional space -// Dimension is the length of the vector to sample -// Divisions is used to determine the number of strata to sample over -// In some samplers, e.g. regular grid, it will repeat after dimension*division calls -// to sample. A call to sample increments the internal state of the sampler. -// Hector Yee 6/11/01 - -// Abstract base class -// all these sampling algoriths modify a vector of length Dimensions -// they all return a value between 0..1 -// Hector Yee 6/11/01 -class SamplingClass -{ -public: - SamplingClass(unsigned int dimensions, unsigned char divisions): - Dimensions(dimensions), - Divisions(divisions) - {}; - virtual void Reset() {}; - virtual void Sample(float *target)=0; - virtual ~SamplingClass() {}; -protected: - unsigned int Dimensions; - unsigned char Divisions; -}; - -// Samples randomly in the dimensions using Mesenne Twister -// divisions ignored -// Hector Yee 6/11/01 -class RandomSamplingClass : public SamplingClass -{ -public: - RandomSamplingClass(unsigned int dimensions, unsigned char divisions=0); - virtual void Reset() {}; - virtual void Sample(float *target); -}; - -// samples over a regular hypergrid -// Hector Yee 6/11/01 -class RegularSamplingClass : public SamplingClass -{ -public: - RegularSamplingClass(unsigned int dimensions, unsigned char divisions=3); - virtual void Reset(); - virtual void Sample(float *target); - virtual ~RegularSamplingClass(); -protected: - unsigned char *index; -}; - -// samples over a regular hypergrid with random perturbations -// Hector Yee 6/11/01 -class StratifiedSamplingClass : public SamplingClass -{ -public: - StratifiedSamplingClass(unsigned int dimensions, unsigned char divisions=3); - virtual void Reset(); - virtual void Sample(float *target); - virtual ~StratifiedSamplingClass(); -protected: - unsigned char *index; -}; - -// samples using QuasiMonteCarlo -// divisions ignored -// based on the Halton-Hammersly sequence which is in turn based on the inverse radical function -// Hector Yee 6/11/01 -class QMCSamplingClass : public SamplingClass -{ -public: - QMCSamplingClass(unsigned int dimensions, unsigned char divisions=0); - virtual void Reset() {index=0;}; - virtual void Sample(float *target); -protected: - unsigned int index; -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/search.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/search.h index c505fe7add5..e6e37001141 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/search.h +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/search.h @@ -57,7 +57,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" #if !defined(__BORLANDC__) || !defined(_USERENTRY) diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.cpp deleted file mode 100644 index 7ce03565ad2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHA.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SHAEngine::Result -- Fetch the current digest. * - * SHAEngine::Hash -- Process an arbitrarily long data block. * - * SHAEngine::Process_Partial -- Helper routine to process any partially accumulated data blo* - * SHAEngine::Process_Block -- Process a full data block into the hash accumulator. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "sha.h" -#include -#include - - -#if !defined(__BORLANDC__) && !defined(min) -#define min(a, b) ((a)<(b))?(a):(b) -#endif - - -/*********************************************************************************************** - * SHAEngine::Process_Partial -- Helper routine to process any partially accumulated data bloc * - * * - * This routine will see if there is a partial block already accumulated in the holding * - * buffer. If so, then the data is fetched from the source such that a full buffer is * - * accumulated and then processed. If there is insufficient data to fill the buffer, then * - * it accumulates what data it can and then returns so that this routine can be called * - * again later. * - * * - * INPUT: data -- Reference to a pointer to the data. This pointer will be modified if * - * this routine consumes any of the data in the buffer. * - * * - * length-- Reference to the length of the data available. If this routine consumes * - * any of the data, then this length value will be modified. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Process_Partial(void const * & data, long & length) -{ - if (length == 0 || data == NULL) return; - - /* - ** If there is no partial buffer and the source is greater than - ** a source block size, then partial processing is unnecessary. - ** Bail out in this case. - */ - if (PartialCount == 0 && length >= SRC_BLOCK_SIZE) return; - - /* - ** Attach as many bytes as possible from the source data into - ** the staging buffer. - */ - int add_count = min((int)length, SRC_BLOCK_SIZE - PartialCount); - memcpy(&Partial[PartialCount], data, add_count); - data = ((char const *&)data) + add_count; - PartialCount += add_count; - length -= add_count; - - /* - ** If a full staging buffer has been accumulated, then process - ** the staging buffer and then bail. - */ - if (PartialCount == SRC_BLOCK_SIZE) { - Process_Block(&Partial[0], Acc); - Length += (long)SRC_BLOCK_SIZE; - PartialCount = 0; - } -} - - -/*********************************************************************************************** - * SHAEngine::Hash -- Process an arbitrarily long data block. * - * * - * This is the main access routine to the SHA engine. It will take the arbitrarily long * - * data block and process it. The hash value is accumulated with any previous calls to * - * this routine. * - * * - * INPUT: data -- Pointer to the data block to process. * - * * - * length -- The number of bytes to process. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Hash(void const * data, long length) -{ - IsCached = false; - - /* - ** Check for and handle any smaller-than-512bit blocks. This can - ** result in all of the source data submitted to this routine to be - ** consumed at this point. - */ - Process_Partial(data, length); - - /* - ** If there is no more source data to process, then bail. Speed reasons. - */ - if (length == 0) return; - - /* - ** First process all the whole blocks available in the source data. - */ - long blocks = (length / SRC_BLOCK_SIZE); - long const * source = (long const *)data; - for (int bcount = 0; bcount < blocks; bcount++) { - Process_Block(source, Acc); - Length += (long)SRC_BLOCK_SIZE; - source += SRC_BLOCK_SIZE/sizeof(long); - length -= (long)SRC_BLOCK_SIZE; - } - - /* - ** Process any remainder bytes. This data is stored in the source - ** accumulator buffer for future processing. - */ - data = source; - Process_Partial(data, length); -} - - -#define Reverse_LONG(a) ((a>>24)&0x000000FFL) | ((a>>8)&0x0000FF00L) | ((a<<8)&0x00FF0000L) | ((a<<24)&0xFF000000L) - - -/*********************************************************************************************** - * SHAEngine::Result -- Fetch the current digest. * - * * - * This routine will return the digest as it currently stands. * - * * - * INPUT: pointer -- Pointer to the buffer that will hold the digest -- 20 bytes. * - * * - * OUTPUT: Returns with the number of bytes copied into the buffer. This will always be * - * 20. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAEngine::Result(void * result) const -{ - /* - ** If the final hash result has already been calculated for the - ** current data state, then immediately return with the precalculated - ** value. - */ - if (IsCached) { - memcpy(result, &FinalResult, sizeof(FinalResult)); - } - - long length = Length + PartialCount; - int partialcount = PartialCount; - unsigned char partial[SRC_BLOCK_SIZE]; - memcpy(partial, Partial, sizeof(Partial)); - - /* - ** Cap the end of the source data stream with a 1 bit. - */ - partial[partialcount] = (unsigned char)0x80; - - /* - ** Determine if there is insufficient room to append the - ** data length number to the hash source. If not, then - ** fill out the rest of the accumulator and flush it to - ** the hash so that there will be room for the final - ** count value. - */ - SHADigest acc = Acc; - if ((SRC_BLOCK_SIZE - partialcount) < 9) { - if (partialcount+1 < SRC_BLOCK_SIZE) { - memset(&partial[partialcount+1], '\0', SRC_BLOCK_SIZE - (partialcount+1)); - } - Process_Block(&partial[0], acc); - partialcount = 0; - } else { - partialcount++; - } - - /* - ** Put the length of the source data as a 64 bit integer in the - ** last 8 bytes of the pseudo-source data. - */ - memset(&partial[partialcount], '\0', SRC_BLOCK_SIZE - partialcount); - *(long *)(&partial[SRC_BLOCK_SIZE-4]) = Reverse_LONG((length*8)); - Process_Block(&partial[0], acc); - - memcpy((char *)&FinalResult, &acc, sizeof(acc)); - for (int index = 0; index < sizeof(FinalResult)/sizeof(long); index++) { -// for (int index = 0; index < SRC_BLOCK_SIZE/sizeof(long); index++) { - (long &)FinalResult.Long[index] = Reverse_LONG(FinalResult.Long[index]); - } - (bool&)IsCached = true; - memcpy(result, &FinalResult, sizeof(FinalResult)); - return(sizeof(FinalResult)); -} - -/* -** This pragma to turn off the warning "Conversion may lose significant digits" is to -** work around a bug within the Borland compiler. It will give this warning when the -** _rotl() function is called but will NOT give the warning when the _lrotl() function -** is called even though they both have the same parameters and declaration attributes. -*/ -#ifdef __BORLANDC__ -#pragma warn -sig -#endif - -template -T _rotl(T X, int n) -{ - return(T)( ( X << n ) | ( (unsigned)X >> ((sizeof(T)*8) - n) ) ); -} -inline long _rotl(long X, int n) -{ - return(long)( ( X << n ) | ( (unsigned)X >> ((sizeof(long)*8) - n) ) ); -} - -inline unsigned long _rotl(unsigned long X, int n) -{ - return(unsigned long)( ( X << n ) | ( (unsigned)X >> ((sizeof(unsigned long)*8) - n) ) ); -} - -//unsigned long _RTLENTRY _rotl(unsigned long X, int n) -//{ -// return(unsigned long)( (unsigned long)( (unsigned long)( (unsigned long)X ) << (int)n ) | (unsigned long)( ((unsigned long) X ) >> ( (int)((int)(sizeof(long)*(long)8) - (long)n) ) ) ); -//} -void memrev(char * buffer, size_t length); - - -/*********************************************************************************************** - * SHAEngine::Process_Block -- Process a full data block into the hash accumulator. * - * * - * This helper routine is called when a full block of data is available for processing * - * into the hash. * - * * - * INPUT: source -- Pointer to the block of data to process. * - * * - * acc -- Reference to the hash accumulator that this hash step will be * - * accumulated into. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Process_Block(void const * source, SHADigest & acc) const -{ - /* - ** The hash is generated by performing operations on a - ** block of generated/seeded data. - */ - long block[PROC_BLOCK_SIZE/sizeof(long)]; - - /* - ** Expand the source data into a large 80 * 32bit buffer. This is the working - ** data that will be transformed by the secure hash algorithm. - */ - long const * data = (long const *)source; - int index; - for (index = 0; index < SRC_BLOCK_SIZE/sizeof(long); index++) { - block[index] = Reverse_LONG(data[index]); - } - - for (index = SRC_BLOCK_SIZE/sizeof(long); index < PROC_BLOCK_SIZE/sizeof(long); index++) { -// block[index] = _rotl(block[(index-3)&15] ^ block[(index-8)&15] ^ block[(index-14)&15] ^ block[(index-16)&15], 1); - block[index] = _rotl(block[index-3] ^ block[index-8] ^ block[index-14] ^ block[index-16], 1); - } - - /* - ** This is the core algorithm of the Secure Hash Algorithm. It is a block - ** transformation of 512 bit source data with a 2560 bit intermediate buffer. - */ - SHADigest alt = acc; - for (index = 0; index < PROC_BLOCK_SIZE/sizeof(long); index++) { - long temp = _rotl(alt.Long[0], 5) + Do_Function(index, alt.Long[1], alt.Long[2], alt.Long[3]) + alt.Long[4] + block[index] + Get_Constant(index); - alt.Long[4] = alt.Long[3]; - alt.Long[3] = alt.Long[2]; - alt.Long[2] = _rotl(alt.Long[1], 30); - alt.Long[1] = alt.Long[0]; - alt.Long[0] = temp; - } - acc.Long[0] += alt.Long[0]; - acc.Long[1] += alt.Long[1]; - acc.Long[2] += alt.Long[2]; - acc.Long[3] += alt.Long[3]; - acc.Long[4] += alt.Long[4]; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.h deleted file mode 100644 index 30a0d75671f..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/sha.h +++ /dev/null @@ -1,195 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHA.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHA_H -#define SHA_H - - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include -#include "always.h" -#include "bool.h" -#include -#include -#include - - -/* -** This implements the Secure Hash Algorithm. It is a cryptographically -** secure hash with no known weaknesses. It generates a 160 bit hash -** result given an arbitrary length data source. -*/ -class SHAEngine -{ - public: - SHAEngine(void) : IsCached(false), Length(0), PartialCount(0) { - Acc.Long[0] = (unsigned long)SA; - Acc.Long[1] = (unsigned long)SB; - Acc.Long[2] = (unsigned long)SC; - Acc.Long[3] = (unsigned long)SD; - Acc.Long[4] = (unsigned long)SE; - }; - - void Init(void) { - new ((void*)this) SHAEngine; - }; - - // Fetch result as if source data were to stop now. - int Result(void * result) const; - - void Hash(void const * data, long length); - - static int Digest_Size(void) {return(sizeof(SHADigest));} - - private: - - typedef union { - unsigned long Long[5]; - unsigned char Char[20]; - } SHADigest; - - /* - ** This holds the calculated final result. It is cached - ** here to avoid the overhead of recalculating it over - ** multiple sequential requests. - */ - bool IsCached; - SHADigest FinalResult; - - enum { - // These are the initial seeds to the block accumulators. - SA=0x67452301L, - SB=0xefcdab89L, - SC=0x98badcfeL, - SD=0x10325476L, - SE=0xc3d2e1f0L, - - // These are the constants used in the block transformation. - K1=0x5a827999L, // t=0..19 2^(1/2)/4 - K2=0x6ed9eba1L, // t=20..39 3^(1/2)/4 - K3=0x8f1bbcdcL, // t=40..59 5^(1/2)/4 - K4=0xca62c1d6L, // t=60..79 10^(1/2)/4 - - // Source data is grouped into blocks of this size. - SRC_BLOCK_SIZE=16*sizeof(long), - - // Internal processing data is grouped into blocks this size. - PROC_BLOCK_SIZE=80*sizeof(long) - }; - - long Get_Constant(int index) const { - if (index < 20) return K1; - if (index < 40) return K2; - if (index < 60) return K3; - return K4; - }; - - // Used for 0..19 - long Function1(long X, long Y, long Z) const { - return(Z ^ ( X & ( Y ^ Z ) ) ); - }; - - // Used for 20..39 - long Function2(long X, long Y, long Z) const { - return( X ^ Y ^ Z ); - }; - - // Used for 40..59 - long Function3(long X, long Y, long Z) const { - return( (X & Y) | (Z & (X | Y) ) ); - }; - - // Used for 60..79 - long Function4(long X, long Y, long Z) const { - return( X ^ Y ^ Z ); - }; - - long Do_Function(int index, long X, long Y, long Z) const { - if (index < 20) return Function1(X, Y, Z); - if (index < 40) return Function2(X, Y, Z); - if (index < 60) return Function3(X, Y, Z); - return Function4(X, Y, Z); - }; - - // Process a full source data block. - void Process_Block(void const * source, SHADigest & acc) const; - - // Processes a partially filled source accumulator buffer. - void Process_Partial(void const * & data, long & length); - - /* - ** This is the running accumulator values. These values - ** are updated by a block processing step that occurs - ** every 512 bits of source data. - */ - SHADigest Acc; - - /* - ** This is the running length of the source data - ** processed so far. This total is used to modify the - ** resulting hash value as if it were appended to the end - ** of the source data. - */ - long Length; - - /* - ** This holds any partial source block. Partial source blocks are - ** a consequence of submitting less than block sized data chunks - ** to the SHA Engine. - */ - int PartialCount; - char Partial[SRC_BLOCK_SIZE]; -}; - - -#define SHA_SOURCE1 "abc" -#define SHA_DIGEST1a "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" -#define SHA_DIGEST1b "\x01\x64\xB8\xA9\x14\xCD\x2A\x5E\x74\xC4\xF7\xFF\x08\x2C\x4D\x97\xF1\xED\xF8\x80" - - -#define SHA_SOURCE2 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" -#define SHA_DIGEST2a "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1" -#define SHA_DIGEST2b "\xD2\x51\x6E\xE1\xAC\xFA\x5B\xAF\x33\xDF\xC1\xC4\x71\xE4\x38\x44\x9E\xF1\x34\xC8" - -#define SHA_SOURCE3 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -#define SHA_DIGEST3a "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" -#define SHA_DIGEST3b "\x32\x32\xAF\xFA\x48\x62\x8A\x26\x65\x3B\x5A\xAA\x44\x54\x1F\xD9\x0D\x69\x06\x03" - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/shapeset.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/shapeset.h deleted file mode 100644 index bf340ed1dae..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/shapeset.h +++ /dev/null @@ -1,271 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/shapeset.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * ShapeSet::Fetch_Data -- Fetches pointer to raw shape data. * - * ShapeSet::Fetch_Rect -- Fetch the sub-rectangle of a shape. * - * ShapeSet::Is_Transparent -- Is the specified shape containing transparent pixels? * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHAPESET_H -#define SHAPESET_H - -#include "bool.h" -#include "trect.h" - -/* -** This is the header that appears at the beginning of the ShapeSet file. The header -** is a multiple of 8 bytes long to facilitate data alignment. The shape header is -** immediately followed by an N length array of ShapeRecord objects. The actual -** shape data follows this array. -*/ -class ShapeSet -{ - public: - /* - ** Fetch pointer to raw shape data (NULL if not present or empty). - */ - void * Get_Data(int shape) const; - - /* - ** Fetch sub-rectangle that the shape data represents. - */ - Rect Get_Rect(int shape) const; - - /* - ** Are there any transparent pixels within the shape? - */ - bool Is_Transparent(int shape) const; - - /* - ** Determines if the specified shape is RLE compressed. - */ - bool Is_RLE_Compressed(int shape) const; - - /* - ** Logical width of the shape set. - */ - int Get_Width(void) const {return(Width);} - - /* - ** Logical height of the shape set. - */ - int Get_Height(void) const {return(Height);} - - /* - ** Number of shapes in this shape set. - */ - int Get_Count(void) const{return(Count);} - - /* - ** Gets the raw data size for a particular shape. - */ - int Get_Size(int shape) const; - - protected: - /* - ** QShape information flags. - */ - short Flags; - - /* - ** The nominal width and height of the shape (in pixels). - */ - short Width; - short Height; - - /* - ** The total number of shapes in the file. - */ - short Count; - - /* - ** Each shape is represented by this structure. It appears in a linear array near the - ** beginning of the file. - */ - class ShapeRecord - { - public: - /* - ** The sub-offset (relative to logical 0,0 at upper left corner) for this - ** shape's data. - */ - short X; - short Y; - - /* - ** The dimensions of this shape's data. - */ - short Width; - short Height; - - /* - ** Flags that indicate some aspect of this particular shape image. - */ - short Flags; - enum { - SFLAG_TRANSPARENT=0x01, // Are there are any transparent pixels present? - SFLAG_RLE=0x02 // Is it RLE compressed? - }; - - - /* - ** Size of the data for this frame. - */ - short Size; - - /* - ** Offset from the start of the shape data file to where the first pixel - ** of this shape image data is located. - */ - long Data; - - bool Is_Transparent(void) const {return((Flags & SFLAG_TRANSPARENT) != 0);} - bool Is_RLE_Compressed(void) const {return((Flags & SFLAG_RLE) != 0);} - short Get_Size(void) const {return(Size);} - - void Flag_Transparent(void) {Flags |= SFLAG_TRANSPARENT;} - void Flag_RLE_Compressed(void) {Flags |= SFLAG_RLE;} - void Set_Size(short size) {Size = size;} - }; - - bool Is_Shape_Index_Valid(int index) const {return(unsigned(index) < unsigned(Count));} - - ShapeRecord const * Fetch_Record_Pointer(int shape) const - { - if (Is_Shape_Index_Valid(shape)) { - return((ShapeRecord const *)(((char *)this) + sizeof(ShapeSet) + sizeof(ShapeRecord) * shape)); - } - return(NULL); - } - - /* - ** Prevents a shape object from being constructed illegally. - */ - ShapeSet(void) {}; - ShapeSet(ShapeSet const & rvalue); - ShapeSet const & operator = (ShapeSet const & rvalue); -}; - - -/*********************************************************************************************** - * ShapeSet::Get_Data -- Fetches pointer to raw shape data. * - * * - * This routine will return a pointer to the shape data. The data is actually a sub- * - * rectangle within the logical shape rectangle. The sub-rectangle holds the non- * - * transparent pixels. This fact, as retrieved by the Fetch_Rect function must be used * - * for proper rendering of the shape. * - * * - * INPUT: shape -- The shape number to extract the pointer for. * - * * - * OUTPUT: Returns with a pointer to the raw shape data. If the shape does not exist in the * - * data file, the returned value will be NULL. If the shape contains no pixels, then * - * NULL is also returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline void * ShapeSet::Get_Data(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL && record->Data != 0) return(((char *)this) + record->Data); - return(NULL); -} - - -/*********************************************************************************************** - * ShapeSet::Get_Rect -- Fetch the sub-rectangle of a shape. * - * * - * This routine will fetch the sub-rectangle for a particular shape. This rectangle is * - * used to properly position the shape when rendering. * - * * - * INPUT: shape -- The shape number to fetch the rectangle for. * - * * - * OUTPUT: Returns with the rectangle of the shape number specified. * - * * - * WARNINGS: If the shape number is invalid or the shape has no pixels, the returned * - * rectangle will not pass the Is_Valid() test. * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline Rect ShapeSet::Get_Rect(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(Rect(record->X, record->Y, record->Width, record->Height)); - } - return(Rect(0,0,0,0)); -} - - -/*********************************************************************************************** - * ShapeSet::Is_Transparent -- Is the specified shape containing transparent pixels? * - * * - * This routine will check to see if the specified shape has any transparent pixels. If it * - * doesn't, then faster blitting code can be used. * - * * - * INPUT: shape -- The shape to examine. * - * * - * OUTPUT: bool; Does the shape contain any transparent pixels? The answer is also false if * - * the shape number is invalid. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline bool ShapeSet::Is_Transparent(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(record->Is_Transparent()); - } - return(false); -} - - -inline bool ShapeSet::Is_RLE_Compressed(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(record->Is_RLE_Compressed()); - } - return(false); -} - - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/shapipe.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/shapipe.h deleted file mode 100644 index a04301d5287..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/shapipe.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHAPIPE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHAPIPE_H -#define SHAPIPE_H - -#include "PIPE.H" -#include "sha.h" - -/* -** This class serves as a pipe that generates a Secure Hash from the data stream that flows -** through it. It doesn't modify the data stream in any fashion. -*/ -class SHAPipe : public Pipe -{ - public: - SHAPipe(void) {} - virtual int Put(void const * source, int slen); - - // Fetch the SHA hash value (stored in result buffer -- 20 bytes long). - int Result(void * result) const; - - protected: - SHAEngine SHA; - - private: - SHAPipe(SHAPipe & rvalue); - SHAPipe & operator = (SHAPipe const & pipe); -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/shastraw.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/shastraw.h deleted file mode 100644 index 1b9db6c3b2e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/shastraw.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHASTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHASTRAW_H -#define SHASTRAW_H - - -#include "sha.h" -#include "STRAW.H" - -/* -** This class serves as a straw that generates a Secure Hash from the data stream that flows -** through it. It doesn't modify the data stream in any fashion. -*/ -class SHAStraw : public Straw -{ - public: - SHAStraw(void) : IsDisabled(false) {} - virtual int Get(void * source, int slen); - - void Disable(void) {IsDisabled = true;} - void Enable(void) {IsDisabled = false;} - - // Fetch the SHA hash value (stored in result buffer -- 20 bytes long). - int Result(void * result) const; - - protected: - bool IsDisabled; - - SHAEngine SHA; - - private: - SHAStraw(SHAStraw & rvalue); - SHAStraw & operator = (SHAStraw const & straw); -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/smartptr.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/smartptr.h deleted file mode 100644 index 4d667edb3fe..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/smartptr.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SMARTPTR.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SMARTPTR_H -#define SMARTPTR_H - -#include "noinit.h" - -template -class SmartPtr -{ - public: - SmartPtr(NoInitClass const &) {} - SmartPtr(T * realptr = 0) : Pointer(realptr) {} - SmartPtr(SmartPtr const & rvalue) : Pointer(rvalue.Pointer) {} - ~SmartPtr(void) {Pointer = 0;} - - operator T * (void) const {return(Pointer);} - - operator long (void) const {return((long)Pointer);} - - bool Is_Valid(void) const {return(Pointer != 0);} - -// SmartPtr operator ++ (int) {assert(Pointer != 0);SmartPtr temp = *this;++Pointer;return(temp);} -// SmartPtr & operator ++ (void) {assert(Pointer != 0);++Pointer;return(*this);} -// SmartPtr operator -- (int) {assert(Pointer != 0);SmartPtr temp = *this;--Pointer;return(temp);} -// SmartPtr & operator -- (void) {assert(Pointer != 0);--Pointer;return(*this);} - - SmartPtr & operator = (SmartPtr const & rvalue) {Pointer = rvalue.Pointer;return(*this);} - T * operator -> (void) const {/*assert(Pointer != 0);*/return(Pointer);} - T & operator * (void) const {/*assert(Pointer != 0);*/return(*Pointer);} - - private: - T * Pointer; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp deleted file mode 100644 index 0544d4506ca..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// -// SecureRandomClass - Generate random values -// - -#pragma warning(disable : 4514) // unreferenced inline function removed.... - -#include "srandom.h" -#include -#include -#ifdef _UNIX -#include "osdep.h" -#else -#include "win.h" -#include -#endif -#include -#include -#include "sha.h" - -// Static class variables -unsigned char SecureRandomClass::Seeds[SecureRandomClass::SeedLength]; -bool SecureRandomClass::Initialized=false; -unsigned int SecureRandomClass::RandomCache[SecureRandomClass::SHADigestBytes / sizeof(unsigned int)]; -int SecureRandomClass::RandomCacheEntries=0; -unsigned int SecureRandomClass::Counter=0; -Random3Class SecureRandomClass::RandomHelper; - -SecureRandomClass::SecureRandomClass() -{ - if (Initialized == false) - { - Generate_Seed(); - Initialized=true; - } -} - -SecureRandomClass::~SecureRandomClass() -{ -} - - -// -// Add seed values to our pool of randomness -// -void SecureRandomClass::Add_Seeds(unsigned char *values, int length) -{ - for (int i=0; i=1; j--) - Seeds[j]=Seeds[j-1]; - Seeds[0]=uctemp; - } - - // We have a better seed pool now so trigger new random values - RandomCacheEntries=0; -} - -// -// Get a 32bit random value -// -unsigned long SecureRandomClass::Randval(void) -{ - if (RandomCacheEntries == 0) - { - SHAEngine sha; - char digest[SHADigestBytes]; // SHA produces a 20 byte hash - - sha.Hash(Seeds, SeedLength); - sha.Result(digest); - - memcpy(RandomCache, digest, SHADigestBytes); - RandomCacheEntries=(SHADigestBytes / sizeof(unsigned int)); - - unsigned int *int_seeds=(unsigned int *)Seeds; - int_seeds[0]^=Counter; // remove the last counter (double xor) - int_seeds[0]^=(Counter+1); // put the new counter in place - - int_seeds[(SeedLength/sizeof(int))-1]^=Counter; // remove the last counter (double xor) - int_seeds[(SeedLength/sizeof(int))-1]^=(Counter+1); // put the new counter in place - - Counter++; // increment counter - } - - unsigned long retval=RandomCache[--RandomCacheEntries]; - - // SHA doesn't have the best distribution properties in the world - // We'll XOR the result with the output of another random number - unsigned long helperval=RandomHelper(); - retval^=helperval; - - return(retval); -} - - - -/////////////////////////////// Private Methods /////////////////////////////////////// - - -// -// Seed the random number generator. -// The seed is what makes each run of random numbers unique. If an observer -// can guess your seed they can predict your random numbers. -// -// Note the use of XORs everywhere. The XOR of a good random number and a bad random -// number is still a good random number. -// -// Caution: Under windows this isn't nearly as safe as under UNIX! -// -void SecureRandomClass::Generate_Seed(void) -{ - int i; - - // Start with some garbage values - memset(Seeds, 0xAA, SeedLength); - - unsigned int *int_seeds=(unsigned int *)Seeds; - int int_seed_length=SeedLength/sizeof(unsigned int); - -#ifdef _UNIX - // - // On UNIX we've already got a great random number souce. - // This should be used only for a seed since it's slow. - // - FILE *in=fopen("/dev/random","r"); - if (in) - { - for (i=0; i. -*/ - -#ifndef SRANDOM_H -#define SRANDOM_H - -#include "RANDOM.H" // for the helper RNG - -// -// SecureRandomClass - Generate random values that are suitable for use in cryptographic -// applications (under UNIX at least). -// -// NOTE: The seed generation under windows isn't nearly as strong as under UNIX due to -// the lack of /dev/random. If you have a good random source you can call 'Add_Seeds' -// to improve the quality of the seed value. -// -// Currently the random seed generation under windows is piss-poor so make sure and call -// Add_Seeds with some interesting data if you're going to use this! -// -// The seed values should be unguessable by an outside viewer and the random values have -// good distribution properties. -// -class SecureRandomClass -{ -public: - SecureRandomClass(); - ~SecureRandomClass(); - - unsigned long Randval(); // get a 32 bit random value - - // Add randomness to the seed pool - void Add_Seeds(unsigned char *values, int length); - -private: - void Generate_Seed(void); // Generate the inital seed - - enum - { - SeedLength = 16, // bytes in random seed - SHADigestBytes = 20 // length of SHA hash - }; - - static bool Initialized; // has the seed been initialized? - static unsigned char Seeds[SeedLength]; // random seed values - static unsigned int RandomCache[SHADigestBytes / sizeof(unsigned int)]; - static int RandomCacheEntries; - static unsigned int Counter; - - static Random3Class RandomHelper; -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/stl.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/stl.h deleted file mode 100644 index 9ecf3fd367d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/stl.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/stl.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/05/00 6:17p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef STL_H -#define STL_H - -/* -** This header file includes the Standard Template Library Headers -** and disables certian warnings -*/ - -#if (_MSC_VER >= 1200) -#pragma warning(push,3) -#endif - -#include - -#if (_MSC_VER >= 1200) -#pragma warning(pop) -#endif - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/surfrect.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/surfrect.h deleted file mode 100644 index c3797480507..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/surfrect.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/surfrect.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SURFRECT_H -#define SURFRECT_H - -#ifdef NEVER - -#include "Surface.h" -#include "trect.h" -#include "Point.h" -#include - - -/* -** This class encapsulates a surface and a clipping rectangle. It is intended to be used as -** a convenience for certain operations that need both a surface and a rectangle. Be aware that -** all surfaces are imbued with a rectangle that is the full size of the surface. -*/ -class SurfaceRect { - public: - SurfaceRect(Surface * surfaceptr = NULL, Rect * rect = NULL) : SurfacePtr(surfaceptr), Point(0, 0) { - assert(SurfacePtr != NULL); - if (rect != NULL) Window = *rect; else Window = SurfacePtr->Get_Rect(); - } - SurfaceRect(Surface & surface, Rect * rect = NULL) : SurfacePtr(&surface), Point(0, 0) { - if (rect != NULL) Window = *rect; else Window = SurfacePtr->Get_Rect(); - } - SurfaceRect(Surface & surface, Rect const & rect) : SurfacePtr(&surface), Window(rect), Point(0, 0) {} - ~SurfaceRect(void) {}; - - /* - ** Pointer to the surface represented by this class. - */ - Surface * SurfacePtr; - - /* - ** Clipping rectangle window into the surface. - */ - Rect Window; - - /* - ** Tracking 2D coordinate into the surface. - */ - Point2D Point; - - private: - /* - ** Ensures that the copy constructor and assignment operator never - ** get created for this class. - */ - SurfaceRect(SurfaceRect const & rvalue); - SurfaceRect operator = (SurfaceRect const & rvalue); -}; - -#endif -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp deleted file mode 100644 index fda7eae3998..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp +++ /dev/null @@ -1,651 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /G/wwlib/tagblock.cpp 5 11/30/99 3:46p Scott_b $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWLib * - * * - * $Archive:: /G/wwlib/tagblock.cpp $* - * * - * $Author:: Scott_b $* - * * - * $Modtime:: 11/29/99 6:42p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * TagBlockFile::TagBlockFile -- Create/open tag file * - * TagBlockFile::~TagBlockFile -- Close down the tag file. * - * TagBlockFile::Create_Index -- Create a index into the IndexList sorted by CRC. * - * TagBlockFile::Find_Block -- Find block assocated with name. * - * TagBlockFile::Open_Tag -- Open an existing tag block. * - * TagBlockFile::Create_Tag -- Create a new tag at the end of the block. * - * TagBlockFile::Close_Tag -- Close the handle that Create or Open made. * - * TagBlockFile::Destroy_Handle -- Shut down a handle. * - * TagBlockFile::End_Write_Access -- Stop write access for handle - flushes data bug keeps ha* - * TagBlockFile::Reset_File -- Clear file so no blocks exist. * - * TagBlockFile::Empty_Index_List -- Clear out tag block list in memory * - *---------------------------------------------------------------------------------------------* - * TagBlockHandle::Write -- Write data to the block. * - * TagBlockHandle::Read -- Read from a tag block. * - * TagBlockHandle::Seek -- Seek within the file. * - * TagBlockHandle::~TagBlockHandle -- Destroy handle. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "TagBlock.h" -#include "realcrc.h" - -#include - -int TagBlockHandle::_InDestructor = 0; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////// Start of TagBlockIndex /////////////////////////////////////// -class TagBlockIndex -{ -public: - TagBlockIndex(const char *tagname, int blockoffset): - CRC(CRC_Stringi(tagname)), - BlockOffset(blockoffset), - DataOffset(TagBlockFile::Calc_Data_Offset(blockoffset, tagname)) - {} - - unsigned Get_CRC() { - return(CRC); - } - int Get_BlockOffset() { - return(BlockOffset); - } - int Get_TagOffset() { - return(TagBlockFile::Calc_Tag_Offset(BlockOffset)); - } - int Get_TagSize() { - return(DataOffset - Get_TagOffset()); - } - int Get_DataOffset() { - return(DataOffset); - } -private: - - // The index file is sorted by the CRC of the file name for - // quicker retrieval. The filename is saved in the texture file. - unsigned long CRC; - - // Start of the block - this is the start of TagBlockFile::BlockHeader. - int BlockOffset; - - // Offset of block inside of TagFile. - // This is first byte after header and TagName. - // It is actual data used by external methods. - int DataOffset; -}; - -///////////////////////////////////// End of TagBlockIndex ///////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////// Start of TagBlockHandle///////////////////////////////////////// - - -/*********************************************************************************************** - * RawFileClass -- Open up the tag file (it may not exist). * - * * - * INPUT: * - * const char *fname - name of file that is or wants to be a TagBlockFile. * - * * - * OUTPUT: * - * Will assume a file that has invalid data to be corrupt and will write over it. * - * So don't pass in a file that is not a tag file. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockFile::TagBlockFile(const char *fname): - RawFileClass(), - Header(), - CreateHandle(NULL), - NumOpenHandles(0), - IndexList() -{ - // Open file up, create it if it does not exist. - // Pass in name to Open function so that the file name will be strdup'd. - Open(fname, READ|WRITE); - - FileTime = RawFileClass::Get_Date_Time(); - - // Read in header so we can tell if it is proper file. - Read(&Header, sizeof(Header)); - - // See if there is any data in file (or was it just created?) - if (Header.Version == FILE_VERSION) { - TagBlockIndex *lasttag = NULL; - int curpos = sizeof(Header); - - // Loop through each block in file and create an in memory index for it. - int block; - for (block = 0; block < Header.NumBlocks; block++) { - BlockHeader blockheader; - - // Read in next header. - Seek(curpos, SEEK_SET); - Read(&blockheader, sizeof(blockheader)); - - // Make sure things are in order. - if (blockheader.Index == block) { - char tagname[MAX_TAG_NAME_SIZE]; - - // Read in tag name, this includes the NULL at end of string. - Read(tagname, blockheader.TagSize); - - // Create new tag index for fast retrievel. - lasttag = Create_Index(tagname, curpos); - - // Now get past the data. - curpos = Calc_Tag_Offset(curpos) + blockheader.TagSize + blockheader.DataSize; - } else { - break; - } - } - - // See if there is a difference between the header and actual data. - if ((curpos != Header.FileSize) || (block != Header.NumBlocks)) { - Header.NumBlocks = block; - Header.FileSize = curpos; - - // Start at begining of file and write out our new header. - Seek(0, SEEK_SET); - Write(&Header, sizeof(Header)); - } - - } else { - Reset_File(); - } -} - -/*********************************************************************************************** - * TagBlockFile::~TagBlockFile -- Close down the tag file. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Any TagBlockHandles that have not been deleted are now invalide but cannot be deleted.* - * You must delete any handles associated with this before closing the TagFile. * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockFile::~TagBlockFile() -{ - Empty_Index_List(); -} - -/*********************************************************************************************** - * TagBlockFile::Reset_File -- Clear file so no blocks exist. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/29/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Reset_File() -{ - Empty_Index_List(); - - // Save a clean header out. - Header.Version = FILE_VERSION; - Header.NumBlocks = 0; - Header.FileSize = sizeof(Header); - - Save_Header(); - - // Close, then open file so we get a new time stamp on it. - Close(); - Open(READ|WRITE); - - // Reget file creation time. - FileTime = RawFileClass::Get_Date_Time(); -} - -/*********************************************************************************************** - * *TagBlockFile::Open_Tag -- Open an existing tag block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle *TagBlockFile::Open_Tag(const char *tagname) -{ - // Find tag to open up. - TagBlockIndex *index = Find_Block(tagname); - if (!index) { - return(NULL); - } - - // Load up the block header information. - BlockHeader *blockheader = W3DNEW BlockHeader(); - Seek(index->Get_BlockOffset(), SEEK_SET); - Read(blockheader, sizeof(*blockheader)); - - // Now that we have all that we need, create the - TagBlockHandle *handle = W3DNEW TagBlockHandle(this, index, blockheader); - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles++; - - // Return with our new handle. - return(handle); -} - -/*********************************************************************************************** - * *TagBlockFile::Create_Tag -- Create a new tag at the end of the block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle *TagBlockFile::Create_Tag(const char *tagname) -{ - // Only allow one handle to be creating open at a time. - if (CreateHandle) { - return(NULL); - } - - // Create a new index that we can write too. - TagBlockIndex *index = Create_Index(tagname, Header.FileSize); - - // An index may not be created if a tag of the same name already exists. - if (!index) { - return(NULL); - } - - // Create a header. - // Use -1 for index to indecate that block is not yet written out competely. - BlockHeader *blockheader = W3DNEW BlockHeader(-1, index->Get_TagSize(), 0); - - // Write out the block header and the tag. - Seek(index->Get_BlockOffset(), SEEK_SET); - Write(blockheader, sizeof(*blockheader)); - Write(tagname, strlen(tagname) + 1); - - // Now that we have all that we need, create the - CreateHandle = W3DNEW TagBlockHandle(this, index, blockheader); - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles++; - - return(CreateHandle); -} - -/*********************************************************************************************** - * TagBlockFile::Close_Tag -- Close the handle that Create or Open made. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Close_Tag(TagBlockHandle *handle) -{ - delete handle; -} - -/*********************************************************************************************** - * TagBlockFile::Destroy_Handle -- Shut down a handle. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Destroy_Handle(TagBlockHandle *handle) -{ - // Make sure those sneaky programmers aren't trying to fool me. - assert(handle->Called_By_Destructor()); - - // If we had write access to handle, flush it out. - End_Write_Access(handle); - - // This was allocated by TagBlockFile::Create_Tag() or Open_Tag(). - delete handle->BlockHeader; - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles--; -} - -/*********************************************************************************************** - * TagBlockFile::End_Write_Access -- Stop write access for handle - flushes data bug keeps han * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockFile::End_Write_Access(TagBlockHandle *handle) -{ - // Make sure this handle is the proper one. - if (CreateHandle == handle) { - // Update file header and block header. - handle->BlockHeader->Index = Header.NumBlocks; - Header.NumBlocks++; - Header.FileSize = handle->Index->Get_DataOffset(); - Header.FileSize += handle->BlockHeader->DataSize; - - // Write both headers out. - Seek(handle->Index->Get_BlockOffset(), SEEK_SET); - Write(handle->BlockHeader, sizeof(*handle->BlockHeader)); - Save_Header(); - - // Don't allow writing with this handle anymore. - CreateHandle = NULL; - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * *TagBlockFile::Create_Index -- Create a index into the IndexList sorted by CRC. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockIndex *TagBlockFile::Create_Index(const char *tagname, int blockoffset) -{ - // Don't allow duplicate tags. - if (Find_Block(tagname)) { - return(NULL); - } - - TagBlockIndex *index; - index = W3DNEW TagBlockIndex(tagname, blockoffset); - - // Put it into the list. - if (IndexList.Is_Empty()) { - IndexList.Add_Head(index); - } else { - // Put in list sorted by CRC, smallest to largest. - SLNode *node = IndexList.Head(); - while (node) { - TagBlockIndex *cur = node->Data(); - if (index->Get_CRC() > cur->Get_CRC()) { - IndexList.Insert_Before(index, cur); - break; - } - node = node->Next(); - } - // If we did not find a place, then add at end of list. - if (!node) { - IndexList.Add_Tail(index); - } - } - return (index); -} - -/*********************************************************************************************** - * *TagBlockFile::Find_Block -- Find block assocated with name. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockIndex *TagBlockFile::Find_Block(const char *tagname) -{ - if (IndexList.Is_Empty()) { - return(NULL); - } - - unsigned long crc = CRC_Stringi(tagname); - - SLNode *node = IndexList.Head(); - while (node) { - TagBlockIndex *cur = node->Data(); - - // Did we find it? - if (cur->Get_CRC() == crc) { - // Now read from file to verify that it is the right name. - char name[MAX_TAG_NAME_SIZE]; - Seek(cur->Get_TagOffset(), SEEK_SET); - - // Read in the name. - Read(name, cur->Get_TagSize()); - - // Is it a match? - assert(name != NULL); - assert(tagname != NULL); - if (!strcmpi(name, tagname)) { - return(cur); - } - } - - // Are we out of range? - if (cur->Get_CRC() < crc) { - break; - } - - // Next in line please. - node = node->Next(); - } - - return(NULL); -} - - -/*********************************************************************************************** - * TagBlockFile::Empty_Index_List -- Clear out tag block list in memory * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/29/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Empty_Index_List() -{ - assert(!NumOpenHandles); - - // Get rid of index list in memory. - while (!IndexList.Is_Empty()) { - TagBlockIndex *index = IndexList.Remove_Head(); - delete index; - } - -} - - -///////////////////////////////////////// End of TagBlockFile ///////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// Start of TagBlockHandle///////////////////////////////////// - -/*********************************************************************************************** - * Position -- Create a handle for user to access the TagBlock. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle::TagBlockHandle(TagBlockFile *tagfile, TagBlockIndex *tagindex, TagBlockFile::BlockHeader *blockheader): - File(tagfile), - Index(tagindex), - BlockHeader(blockheader), - Position(0) -{ -} - -/*********************************************************************************************** - * TagBlockHandle::~TagBlockHandle -- Destroy handle. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle::~TagBlockHandle() -{ - _InDestructor++; - File->Destroy_Handle(this); - _InDestructor--; -} - -/*********************************************************************************************** - * TagBlockHandle::Write -- Write data to the block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Write(const void *buf, int nbytes) -{ - // Make sure this handle is the proper one. - if (!File->Handle_Can_Write(this)) { - return(-1); - } - - // Get to correct position to write out and write the buffer. - File->Seek(Index->Get_DataOffset() + Position, SEEK_SET); - nbytes = File->Write(buf, nbytes); - - // Advance the EOF marker for the block. - Position += nbytes; - if (Position > BlockHeader->DataSize) { - BlockHeader->DataSize = Position; - } - - // Return about written out. - return(nbytes); -} - -/*********************************************************************************************** - * TagBlockHandle::Read -- Read from a tag block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Read(void *buf, int nbytes) -{ - // Make sure user does not read past end of buffer. - if ((Position + nbytes) > BlockHeader->DataSize) { - nbytes = BlockHeader->DataSize - Position; - } - - // Get to correct position to write out and read in the buffer. - File->Seek(Index->Get_DataOffset() + Position, SEEK_SET); - nbytes = File->Read(buf, nbytes); - - // Adjust the read head. - Position += nbytes; - - // Tell user how much was read from the file. - return(nbytes); -} - -/*********************************************************************************************** - * TagBlockHandle::Seek -- Seek within the file. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Seek(int pos, int dir) -{ - switch (dir) { - case SEEK_CUR: - Position += pos; - break; - case SEEK_SET: - Position = pos; - break; - case SEEK_END: - Position = BlockHeader->DataSize + pos; - break; - } - return(Position); -} - -// EOF \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/timer.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/timer.h deleted file mode 100644 index c6ee9de76cf..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/timer.h +++ /dev/null @@ -1,689 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/timer.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 8:08p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BasicTimerClass::BasicTimerClass -- Constructor for basic timer class. * - * BasicTimerClass::operator () -- Function operator for timer object. * - * BasicTimerClass::operator long -- Conversion to long operator. * - * BasicTimerClass::~BasicTimerClass -- Destructor for basic timer object. * - * TTimerClass::Is_Active -- Checks to see if the timer is counting. * - * TTimerClass::Start -- Starts (resumes) a stopped timer. * - * TTimerClass::Stop -- Stops the current timer from incrementing. * - * TTimerClass::TTimerClass -- Constructor for timer class object. * - * TTimerClass::operator () -- Function operator for timer object. * - * TTimerClass::operator long -- Conversion operator for timer object. * - * CDTimerClass::CDTimerClass -- Constructor for count down timer. * - * CDTimerClass::Is_Active -- Checks to see if the timer object is active. * - * CDTimerClass::Start -- Starts (resumes) the count down timer. * - * CDTimerClass::Stop -- Stops (pauses) the count down timer. * - * CDTimerClass::operator () -- Function operator for the count down timer. * - * CDTimerClass::operator long -- Conversion to long operator function. * - * CDTimerClass::~CDTimerClass -- Destructor for the count down timer object. * - * TTimerClass::Value -- Returns with the current value of the timer. * - * CDTimerClass::Value -- Fetches the current value of the countdown timer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TIMER_H -#define TIMER_H - -#include "noinit.h" - -/* -** This is a timer class that watches a constant rate timer (specified by the parameter -** type class) and provides basic timer functionality. It is possible to set the start value -** WITHOUT damaging or otherwise affecting any other timer that may be built upon the same -** specified timer class object. Treat an object of this type as if it were a "magic" integral -** long that automatically advances at the speed of the timer class object controlling it. -*/ -// Let lint know that non-virtual destructor is OK for this class. -//lint -esym(1509,BasicTimerClass) -template -class BasicTimerClass { - public: - // Constructor allows assignment as if class was integral 'long' type. - BasicTimerClass(int set=0); - BasicTimerClass(NoInitClass const & ); - - virtual ~BasicTimerClass(void); - - // Fetch current value of timer. - int Value(void) const {return(Timer()-Started);} - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - protected: - T Timer; // Timer regulator (ticks at constant rate). - int Started; // Time started. -}; - - -template -inline BasicTimerClass::BasicTimerClass(NoInitClass const & ) -{ -}; - - -/*********************************************************************************************** - * BasicTimerClass::BasicTimerClass -- Constructor for basic timer class. * - * * - * This is the constructor for the basic timer class object. It sets the timer counting * - * up from zero at the rate of the controlling timer class object. * - * * - * INPUT: set -- Alternate initial start value for the counter. If not specified, then * - * the timer is assumed to start at zero and count upwards. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -//lint -esym(1403,BasicTimerClass::Timer) -//lint -esym(1403,BasicTimerClass::Timer) -template -inline BasicTimerClass::BasicTimerClass(int set) : - Started(Timer()-set) -{ -} - - -/*********************************************************************************************** - * BasicTimerClass::~BasicTimerClass -- Destructor for basic timer object. * - * * - * The destructor for the basic timer object doesn't have to do anything. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline BasicTimerClass::~BasicTimerClass(void) -{ -} - - -//template -//inline unsigned long BasicTimerClass::Value(void) const -//{ -// return(Timer()-Started); -//} - - -/*********************************************************************************************** - * BasicTimerClass::operator long -- Conversion to long operator. * - * * - * This conversion operator allows the basic timer object to function in much the same * - * manner as the integral "long" type. One can assign a long with a timer object and the * - * actual value of the timer is extracted from the object and used. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the timer value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline BasicTimerClass::operator int(void) const -{ - return(Timer()-Started); -} - - -/*********************************************************************************************** - * BasicTimerClass::operator () -- Function operator for timer object. * - * * - * This function operator allows the timer to also serve as the parameter type class for * - * additional timer objects. This allows one to instantiate a controlling timer class that * - * can control (e.g., turn on or off) all timers that are based upon it. * - * * - * INPUT: none * - * * - * OUTPUT: Returns the current timer value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int BasicTimerClass::operator () (void) const -{ - return(Timer()-Started); -} - - -/* -** This timer class functions similarly to the basic timer class. In addition to the -** normal timer operation, this class has the ability to be stopped and started at -** will. If you have no need to start or stop the timer, then use the basic timer -** class instead. -*/ -template -class TTimerClass : public BasicTimerClass -{ - using BasicTimerClass::Started; - using BasicTimerClass::Timer; - - public: - // Constructor allows assignment as if class was integral 'long' type. - TTimerClass(int set=0); - TTimerClass(NoInitClass const & x); - - ~TTimerClass(void) {}; - - // Fetches current value of timer. - int Value(void) const; - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - // Stops (pauses) the timer. - void Stop(void); - - // Starts (resumes) the timer. - void Start(void); - - // Queries whether the timer is currently active. - bool Is_Active(void) const; - - private: - int Accumulated; // Total accumulated ticks. -}; - - -template -inline TTimerClass::TTimerClass(NoInitClass const & x) : - BasicTimerClass(x) -{ -} - - -/*********************************************************************************************** - * TTimerClass::TTimerClass -- Constructor for timer class object. * - * * - * This is the constructor for the advanced timer class object. This object class can start * - * or stop the timer under user control. * - * * - * INPUT: set -- The initial value to set the timer to. If no value is specified, then * - * the timer is assumed to start from zero. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline TTimerClass::TTimerClass(int set) : - BasicTimerClass(set), - Accumulated(0) -{ -} - - -/*********************************************************************************************** - * TTimerClass::Value -- Returns with the current value of the timer. * - * * - * This routine will return with the current value of the timer. It takes into account * - * whether the timer has stopped or not so as to always return the correct value regardless * - * of that condition. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current value of the timer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int TTimerClass::Value(void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::operator long -- Conversion operator for timer object. * - * * - * This conversion operator allows this timer object to function as an "rvalue" of a "long" * - * type. This is consistent with the integral "long" value. It is possible to assign a * - * timer object to a long and have the long initialized with the current value of the * - * timer. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current time value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline TTimerClass::operator int(void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::operator () -- Function operator for timer object. * - * * - * This function operator for the timer class allows this timer class to be used as the * - * template parameter for other timer class objects. With this ability, one can control * - * several timers (e.g., start or stop them) by using a single controlling timer class * - * that other timers are instantiated from. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current time expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int TTimerClass::operator () (void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::Stop -- Stops the current timer from incrementing. * - * * - * This routine will stop (pause) the timer from further increments. To cause the timer * - * to begin anew, call the Start() function. * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -void TTimerClass::Stop(void) -{ - if (Started != -1) { - Accumulated += BasicTimerClass::Value(); - Started = -1; - } -} - - -/*********************************************************************************************** - * TTimerClass::Start -- Starts (resumes) a stopped timer. * - * * - * This routine will resume a timer that was previously stopped with the Stop() function. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void TTimerClass::Start(void) -{ - if (Started == -1) { - Started = Timer(); - } -} - - -/*********************************************************************************************** - * TTimerClass::Is_Active -- Checks to see if the timer is counting. * - * * - * Since this timer can be paused, this routine is used to examine the timer to see if it * - * is currently paused or active. If the timer is active, then the return value will be * - * true. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is this timer currently active? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline bool TTimerClass::Is_Active(void) const -{ - return(Started != -1); -} - - -/* -** This timer counts down from the specified (or constructed) value down towards zero. -** The countdown rate is controlled by the timer object specified. This timer object can -** be started or stopped. It can also be tested to see if it has expired or not. An expired -** count down timer is one that has value of zero. You can treat this class object as if it -** were an integral "magic" long that automatically counts down toward zero. -*/ -template -class CDTimerClass : public BasicTimerClass -{ - using BasicTimerClass::Started; - using BasicTimerClass::Timer; - - public: - // Constructor allows assignment as if class was integral 'long' type. - CDTimerClass(int set=0); - CDTimerClass(NoInitClass const & x); - - ~CDTimerClass(void); - - // Fetches current value of count down timer. - int Value(void) const; - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - // Stops (pauses) the timer. - void Stop(void); - - // Starts (resumes) the timer. - void Start(void); - - // Queries whether the timer is currently active. - bool Is_Active(void) const; - - private: - int DelayTime; // Ticks remaining before countdown timer expires. -}; - - -template -inline CDTimerClass::CDTimerClass(NoInitClass const & x) : - BasicTimerClass(x) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::CDTimerClass -- Constructor for count down timer. * - * * - * This is the constructor for the count down timer object. The optional starting value * - * can be used to initiate the timer. Because of this constructor it is possible to assign * - * a long to a count down timer object in order to begin the countdown process. * - * * - * INPUT: set -- The initial starting value for the countdown timer. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::CDTimerClass(int set) : - BasicTimerClass(0), - DelayTime(set) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::~CDTimerClass -- Destructor for the count down timer object. * - * * - * The destructor for the count down timer object does nothing. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::~CDTimerClass(void) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::Value -- Fetches the current value of the countdown timer. * - * * - * Use this routine to fetch the current value of the timer. It takes into consideration * - * whether the timer has been stopped or not. It returns the correct value regardless of * - * this condition. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the correct value of this count down timer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int CDTimerClass::Value(void) const -{ - int remain = DelayTime; - if (Started != -1) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::operator long -- Conversion to long operator function. * - * * - * This conversion operator allows the count down timer object to be used as if it were * - * a "magic" long that automatically counted downward at the controller class tick rate. * - * The count down object can be used in any place that an rvalue long could be used. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current count down time expressed in the form of a long value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::operator int(void) const -{ - int remain = DelayTime; - if (Started != 0xFFFFFFFFU) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::operator () -- Function operator for the count down timer. * - * * - * This is the function operator for the count down timer object. By supporting this * - * function operator, this class (or one derived from this class) could be used as the * - * controlling timer to the timer templates. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current count down time expressed in the form of a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int CDTimerClass::operator () (void) const -{ - int remain = DelayTime; - if (Started != -1) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::Stop -- Stops (pauses) the count down timer. * - * * - * This routine is used to stop (pause) the count down timer object. A timer object paused * - * in this fashion will be resumed by a call to Start() or by assigning a new count down * - * value to the timer. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void CDTimerClass::Stop(void) -{ - if (Started != -1) { - DelayTime = *this; - Started = -1; - } -} - - -/*********************************************************************************************** - * CDTimerClass::Start -- Starts (resumes) the count down timer. * - * * - * This routine is used to start (resume) the count down timer that was previously stopped * - * with the Stop() function. The timer will also resume when a new timer value is assigned. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void CDTimerClass::Start(void) -{ - if (Started == -1) { - Started = Timer(); - } -} - - -/*********************************************************************************************** - * CDTimerClass::Is_Active -- Checks to see if the timer object is active. * - * * - * Because the timer object counting can be stopped, this routine is used to determine * - * if the timer is currently paused or active. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the timer currently active? * - * * - * WARNINGS: Note that if the timer has counted down to zero, then it may be active, but * - * the value will, naturally, not change. * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline bool CDTimerClass::Is_Active(void) const -{ - return(Started != -1); -} - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/trackwin.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/trackwin.h deleted file mode 100644 index d2bd84c198b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/trackwin.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/trackwin.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TRACKWIN_H -#define TRACKWIN_H - - -#ifdef NEVER - -#include "trect.h" - -/* -** This class is used to keep track of a subwindow within a larger window. -*/ -class TrackWindow { - public: - TrackWindow(int width, int height) : Window(0, 0, width, height), FullWindow(0, 0, width, height) {} - - /* - ** Simple sub-window manipulation. - */ - void Set(Rect const & rect) {Window = rect;if (FullWindow.Width==0) FullWindow = rect;} - void Reset(void) {Window = Full_Rect();} - - /* - ** Query the sub-window data. - */ - int Get_X(void) const {return(Window.X);} - int Get_Y(void) const {return(Window.Y);} - int Get_Width(void) const {return(Window.Width);} - int Get_Height(void) const {return(Window.Height);} - Rect Get_Rect(void) const {return(Window);} - - /* - ** Query the full window data. - */ - int Full_Width(void) const {return(FullWindow.Width);} - int Full_Height(void) const {return(FullWindow.Height);} - Rect Full_Rect(void) const {return(FullWindow);} - - protected: - - /* - ** This is the sub-window dimensions. - */ - Rect Window; - - /* - ** This holds the full sized window. It is used for resetting the window - ** and for maximum window dimension clipping. - */ - Rect FullWindow; -}; -#endif - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/trackxy.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/trackxy.h deleted file mode 100644 index ce7a7870d1c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/trackxy.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/trackxy.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TRACKXY_H -#define TRACKXY_H - -#ifdef NEVER -/* -** This class is used to keep track of a "current XY location". The Surface class uses this, but -** it can be used for any such purpose. -*/ -class TrackXY { - public: - TrackXY(void) : X(0), Y(0) {} - - /* - ** It is often convenient to have a "current location" for a surface. The - ** use of this location is arbitrary and outside the scope of this class. - */ - void Set(int x, int y) {X = x;Y = y;} - int Get_X(void) const {return(X);} - int Get_Y(void) const {return(Y);} - - protected: - - /* - ** Keeps track of the current location on this surface. The use of this - ** current location is outside the scope of this class, but it can be quite - ** useful for other support functions. - */ - int X; - int Y; -}; -#endif - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/visualc.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/visualc.h index aec680e3f2d..5e76fe05cfd 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/visualc.h +++ b/Generals/Code/Libraries/Source/WWVegas/WWLib/visualc.h @@ -44,7 +44,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" /* diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/win.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/win.cpp deleted file mode 100644 index 045af3b374c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/win.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "always.h" -#include "win.h" -#include "wwdebug.h" - -HINSTANCE ProgramInstance; -HWND MainWindow; -bool GameInFocus = false; - -/*********************************************************************************************** - * Print_Win32Error -- Print the Win32 error message. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/21/01 DEL : Created. * - *=============================================================================================*/ -#ifdef _DEBUG -void __cdecl Print_Win32Error(unsigned long win32Error) -{ - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, win32Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, 0, NULL); - - WWDEBUG_SAY(((const char*)lpMsgBuf)); - LocalFree(lpMsgBuf); -} -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp deleted file mode 100644 index 093dc34f368..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/wwfont.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * WWFontClass::Print -- Print text to the surface specified. * - * WWFontClass::WWFontClass -- Constructor for a font class object. * - * WWFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. * - * WWFontClass::String_Pixel_Width -- Determines the width of the string in pixels. * - * WWFontClass::Raw_Width -- Fetch the raw width of a character. * - * WWFontClass::Raw_Height -- Fetch the height of the font. * - * WWFontClass::Get_Width -- Get normalized width of the nominal font character. * - * WWFontClass::Get_Height -- Fetch the normalized height of the nominal font character. * - * WWFontClass::Set_XSpacing -- Set the X spacing override value. * - * WWFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. * - * Set_Font_Data -- Allow font data to be set after construction. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_convert.h" -#include "wwfont.h" -//#include - - -#define FONTINFOMAXHEIGHT 4 -#define FONTINFOMAXWIDTH 5 - -#define FUDGEDIV 16 - - -/*********************************************************************************************** - * WWFontClass::WWFontClass -- Constructor for a font class object. * - * * - * This constructs a font object as it is based upon the font data output by the legacy * - * FONTMAKE.EXE utility. * - * * - * INPUT: fontdata -- Pointer to the data as output by the fontmake utility. * - * * - * isoutlined -- Is this font data available with outline pixels embedded? * - * * - * shadow -- Does the font data have shadow pixels embedded? * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -WWFontClass::WWFontClass(void const * fontdata, bool isoutlined, int shadow, ConvertClass *convert, unsigned char *remap) : - IsOutlinedData(isoutlined), - Shadow(shadow), - Converter(convert), - RemapPalette(remap), - FontXSpacing(0), - FontYSpacing(0) -{ - Set_Font_Data(fontdata); -} - -/*********************************************************************************************** - * Set_Font_Data -- Allow font data to be set after construction. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/24/2000 SKB : Created. * - *=============================================================================================*/ -void *WWFontClass::Set_Font_Data(void const * fontdata) -{ - void *old = (void *) FontData; - - FontData = (FontType *)fontdata; - if (FontData) { - Set_XSpacing(FontXSpacing); - Set_YSpacing(FontYSpacing); - } - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. * - * * - * This will return with the pixel width of the character specified. * - * * - * INPUT: c -- The character to determine the pixel width for. * - * * - * OUTPUT: Returns with the pixel width of the character. * - * * - * WARNINGS: The return width is the screen real estate width which may differ from the * - * actual pixels of the character. This difference is controlled by the font * - * X spacing. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Char_Pixel_Width(char c) const -{ - int raw = (*(((unsigned char *)FontData) + FontData->WidthBlockOffset + (unsigned char)c)); - raw += FontXSpacing; - return(raw); -} - - -/*********************************************************************************************** - * WWFontClass::String_Pixel_Width -- Determines the width of the string in pixels. * - * * - * This routine is used to determine how many pixels wide the string will be if it were * - * printed. * - * * - * INPUT: string -- The string to convert into its pixel width. * - * * - * OUTPUT: Returns with the number of pixels the string would span if it were printed. * - * * - * WARNINGS: This routine does not take into account clipping. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::String_Pixel_Width(char const * string) const -{ - if (string == NULL) return(0); - if (string[0] == 0) return 0; - - int largest = 0; // Largest recorded width of the string. - int width = 0; - while (*string) { - if (*string == '\r' || *string == '\n') { - string++; - largest = MAX(largest, width); - width = 0; - } else { - width += Char_Pixel_Width(*string++); // add each char's width - } - } - largest = MAX(largest, width); - return(largest); -} - - -/*********************************************************************************************** - * WWFontClass::Raw_Width -- Fetch the raw width of a character. * - * * - * This routine returns the nominal width of the font. This width is basically the width of * - * the widest character in the font. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the width of the widest character in the font. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Raw_Width(void) const -{ - return(*(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXWIDTH)); -} - - -/*********************************************************************************************** - * WWFontClass::Raw_Height -- Fetch the height of the font. * - * * - * This returns the height of the font without regard for any Y spacing offsets. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the height of the font. * - * * - * WARNINGS: All characters in the font have the same logical height even if they actually * - * consume less pixels. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Raw_Height(void) const -{ - return(*(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXHEIGHT)); -} - - -/*********************************************************************************************** - * WWFontClass::Get_Width -- Get normalized width of the nominal font character. * - * * - * This routine is used to fetch the width of the widest character in the font but the * - * width has been biased according to any X spacing override present. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the normalized width of the widest character in the font. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Get_Width(void) const -{ - return(Raw_Width() + ((FontXSpacing > 0) ? FontXSpacing : 0)); -} - - -/*********************************************************************************************** - * WWFontClass::Get_Height -- Fetch the normalized height of the nominal font character. * - * * - * This will return the height of the font but the returned height will be adjusted by any * - * Y spacing override present. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the height of the font normalized by any spacing overrides. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Get_Height(void) const -{ - return(Raw_Height() + ((FontYSpacing > 0) ? FontYSpacing : 0)); -} - - -/*********************************************************************************************** - * WWFontClass::Set_XSpacing -- Set the X spacing override value. * - * * - * Use this routine to control the horizontal spacing override for this font. If the value * - * is negative, the font becomes compressed. If the value is positive, then the font * - * becomes expanded. * - * * - * INPUT: x -- The X spacing override to use for this font. * - * * - * OUTPUT: Returns with the old X spacing override value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Set_XSpacing(int x) -{ - int old = FontXSpacing; - FontXSpacing = x; - if (IsOutlinedData) { - switch (Shadow) { - case 0: - FontXSpacing += -2; - break; - - case 1: - FontXSpacing += -1; - break; - - case 2: - FontXSpacing += -1; - break; - } - } - FontXSpacing += Get_Width() / FUDGEDIV; - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. * - * * - * Use this routine to control the "line spacing" of a font. If the Y spacing is negative * - * then the font becomes closer to the line above it. If value is positive, then more * - * space occurs between lines. * - * * - * INPUT: y -- The Y spacing override to use for this font. * - * * - * OUTPUT: Returns with the old Y spacing override value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Set_YSpacing(int y) -{ - int old = FontYSpacing; - FontYSpacing = y; - if (IsOutlinedData) { - switch (Shadow) { - case 0: - FontYSpacing += -2; - break; - - case 1: - FontYSpacing += -1; - break; - - case 2: - FontYSpacing += -1; - break; - } - } - FontYSpacing += Get_Height() / FUDGEDIV; - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Print -- Print text to the surface specified. * - * * - * This displays text to the surface specified and with the attributes specified. * - * * - * INPUT: string -- The string to display to the surface. * - * * - * surface -- The surface to display the text upon. * - * * - * cliprect -- The clipping rectangle that both clips the text and biases the print * - * location to. * - * * - * point -- The draw position for the upper left corner of the first character. * - * * - * convert -- The pixel convert object that is used to draw the correct colors to * - * the destination surface. * - * * - * remap -- Auxiliary remap table for font colors. * - * * - * OUTPUT: Returns with the point where the next print should begin if it is to smoothly * - * continue where this print operation left off. * - * * - * WARNINGS: There are two separate drawing routines; one for old fonts and one for new * - * fonts. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - * 06/20/1887 BNA : Modified to handle new fonts. * - * 01/24/2000 SKB : Updated from C&C to include BNA code. * - * 01/24/2000 SKB : put in call for Get_Remap_Palette * - * 01/24/2000 SKB : Put in call for get converer. * - *=============================================================================================*/ -Point2D WWFontClass::Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & drawpoint, ConvertClass const & convertref, unsigned char const * remap) const -{ - if (string == NULL) return(drawpoint); - - /* - ** Compute the surface relative coordinate for the print position. - */ - Point2D point = drawpoint; - int xpos = point.Bias_To(cliprect).X; -// int xpos = point.X + cliprect.X; - int ypos = point.Bias_To(cliprect).Y; -// int ypos = point.Y + cliprect.Y; - - int xspacing = FontXSpacing + Raw_Width()/FUDGEDIV; - int yspacing = FontYSpacing + Raw_Width()/FUDGEDIV; - - // This font palette assumes that the font will be used as defined by converter. - static unsigned char const fontpalette[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - if (RemapPalette) { - remap = RemapPalette; - } else if (!remap) { - remap = &fontpalette[0]; - } - - // If there is a convert supplied with the font, use it as priority. - ConvertClass const *converter = Converter; - if (!converter) { - converter = &convertref; - } - - /* - ** Verify that the clipping rectangle (if present) falls within the bounds of the surface. - */ -// Rect cliprect = surface->Get_Rect(); -// cliprect.X = 0; -// cliprect.Y = 0; - - /* - ** Trivially check to see if the print start position is outside the bounds of the clipping - ** rectangle. - */ - if (xpos >= cliprect.X+cliprect.Width || ypos >= cliprect.Y+cliprect.Height) { - return(drawpoint); - } - - /* - ** Check to see if access to the surface buffer is possible. - */ - void * buffer = surface.Lock(); - if (buffer != NULL) { - int startx = xpos; - unsigned char * fontwidth = ((unsigned char*)FontData) + FontData->WidthBlockOffset; - unsigned short * fontheight = (unsigned short*)(((unsigned char*)FontData) + FontData->HeightOffset); - unsigned short * fontoffset = (unsigned short*)(((unsigned char*)FontData) + FontData->OffsetBlockOffset); - int bbp = surface.Bytes_Per_Pixel(); - - /* - ** Process the whole string. Stop when the string reaches the right margin. - */ - while (*string != '\0') { - unsigned char c = *string++; - - /* - ** Certain control characters serve a formatting purpose. They merely - ** adjust the next draw position. - */ - if (c == '\r') { - xpos = startx; - ypos += Raw_Height() + ((yspacing > 0) ? yspacing : 0); - continue; - } - if (c == '\n') { - xpos = cliprect.X; - ypos += Raw_Height() + ((yspacing > 0) ? yspacing : 0); - continue; - } - - /* - ** Fetch working values for the character to display. These are used to - ** control the size of the character rectangle. - */ - int width = fontwidth[c]; - int dheight = fontheight[c] >> 8; - int firstrow = fontheight[c] & 0xFF; -// int height = dheight+firstrow; - - /* - ** Build the character rectangle (surface relative coordinates). - */ - Rect crect(xpos, ypos, width+((xspacing > 0) ? xspacing : 0), *(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXHEIGHT) + ((yspacing > 0) ? yspacing : 0)); - - /* - ** Check to see if any part of this character would appear within the clipping - ** rectangle. If not, then don't process this character. - */ - crect = crect.Intersect(cliprect); - if (crect.Is_Valid()) { - - /* - ** Fill the background of the character if the background - ** color is not transparent. - */ - if (remap[0] != 0) { - surface.Fill_Rect(crect, converter->Convert_Pixel(remap[0])); - } - - /* - ** Loop through all data rows of this character and output the row - ** data with clipping. - */ - if (FontData->FontCompress != (char) 2) { // if the font is the old style - unsigned char * dataptr = ((unsigned char *)FontData) + fontoffset[c]; - void * drawbuff = (void*)(((char*)buffer) + ((ypos + firstrow) * surface.Stride()) + xpos * bbp); - - for (int h = 0; h < dheight; h++) { - - /* - ** If the current row to be drawn falls below the clipping rectangle, then - ** no further drawing for this character is needed -- bail out. - */ - if (ypos + firstrow + h >= crect.Y + crect.Height) break; - - /* - ** If the current row to be drawn falls above the clipping rectangle, - ** then skip the row and advance the source data pointer as well. - */ - if (ypos + firstrow + h < crect.Y) { - drawbuff = (void*)(((char*)drawbuff) + surface.Stride()); - dataptr = dataptr + ((width+1)/2); - } else { - - /* - ** Process one row of character data. For simplicity reasons, just - ** loop through all pixels of this row and perform clipping at the - ** pixel level. - */ - int dx = xpos; - int workwidth = width; - while (workwidth > 0) { - - /* - ** Fetch the next two pixel values. Two pixel values must - ** be fetched at the same time since they are nibble packed. - */ - int c1 = remap[*dataptr & 0x0F]; - int c2 = remap[(*dataptr++ & 0xF0) >> 4]; - - /* - ** Draw the first pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c1 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c1); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c1); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - if (workwidth == 0) break; - - /* - ** Draw the second pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c2 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c2); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c2); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - } - - /* - ** Move the output pixel pointer to the next line down but at the - ** left margin of the character block. - */ - drawbuff = (void*)((((char*)drawbuff) - (width*bbp)) + surface.Stride()); - } - } - } else { - // the font is of the new type - unsigned char * dataptr = ((unsigned char *)FontData) + fontoffset[c] + FontData->DataBlockOffset; - void * drawbuff = (void*)(((char*)buffer) + ((ypos + firstrow) * surface.Stride()) + xpos * bbp); - - for (int h = 0; h < dheight; h++) { - - /* - ** If the current row to be drawn falls below the clipping rectangle, then - ** no further drawing for this character is needed -- bail out. - */ - if (ypos + firstrow + h >= crect.Y + crect.Height) break; - - /* - ** If the current row to be drawn falls above the clipping rectangle, - ** then skip the row and advance the source data pointer as well. - */ - if (ypos + firstrow + h < crect.Y) { - drawbuff = (void*)(((char*)drawbuff) + surface.Stride()); - dataptr = dataptr + width; - } else { - - /* - ** Process one row of character data. For simplicity reasons, just - ** loop through all pixels of this row and perform clipping at the - ** pixel level. - */ - int dx = xpos; - int workwidth = width; - while (workwidth > 0) { - - /* - ** Fetch the next pixel value. - */ - int c1 = remap[*dataptr++]; // no remapping - - /* - ** Draw the pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c1 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c1); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c1); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - } - - /* - ** Move the output pixel pointer to the next line down but at the - ** left margin of the character block. - */ - drawbuff = (void*)((((char*)drawbuff) - (width*bbp)) + surface.Stride()); - } - } - } - } - xpos += Char_Pixel_Width(c); -// xpos += width + xspacing; - } - - point = Point2D(xpos - cliprect.X, ypos - cliprect.Y); - surface.Unlock(); - } - return(point); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.h deleted file mode 100644 index 9760c4982bb..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwfont.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/wwfont.h $* - * * - * $Author:: Scott_b $* - * * - * $Modtime:: 4/21/00 1:03p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef WWFONT_H -#define WWFONT_H - -#include "FONT.H" -#include "Surface.h" - -class ConvertClass; - -/* -** This is a concrete font class object that is used to handle font data as generated by -** the legacy FONTMAKE.EXE utility. -*/ -class WWFontClass : public FontClass -{ - typedef FontClass BASECLASS; - - public: - WWFontClass(void const * fontdata, bool isoutlined=false, int shadow=0, ConvertClass *convert = 0, unsigned char *remap = 0); - virtual ~WWFontClass(void) {} - - void *Set_Font_Data(void const * fontdata); - void *Get_Font_Data() { - return((void *)FontData); - } - - // User can setup a palette to use for this font. - // If set, this will override all other colors (even fore and background colors). - // User should reset to default when done. - unsigned char *Set_Remap_Palette(unsigned char *palette) { - unsigned char *old = RemapPalette; - RemapPalette = palette; - return(old); - } - unsigned char *Get_Remap_Palette() const { - return(RemapPalette); - } - - ConvertClass *Set_Converter(ConvertClass *convert) { - ConvertClass *old = Converter; - Converter = convert; - return(old); - } - ConvertClass *Get_Converter() const { - return(Converter); - } - - virtual int Char_Pixel_Width(char c) const; - virtual int String_Pixel_Width(char const * string) const; - virtual int Get_Width(void) const; - virtual int Get_Height(void) const; - virtual Point2D Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & point, ConvertClass const & converter, unsigned char const * remap=NULL) const; - - virtual int Set_XSpacing(int x); - virtual int Set_YSpacing(int y); - - private: - - /* - ** Is the font an outline type font (with special outline - ** pixels in the source art)? - */ - bool IsOutlinedData; - - /* - ** Shadow type to use when displaying this font. The value only applies if the - ** font is equipped with outline data. - */ - int Shadow; - - /* - ** Override font X spacing value. - */ - int FontXSpacing; - - /* - ** Override font Y spacing value. - */ - int FontYSpacing; - - /* - ** Header structure of the font data file. - */ - typedef struct FontType { - unsigned short FontLength; - unsigned char FontCompress; - unsigned char FontDataBlocks; - unsigned short InfoBlockOffset; - unsigned short OffsetBlockOffset; - unsigned short WidthBlockOffset; - unsigned short DataBlockOffset; - unsigned short HeightOffset; - } FontType; - FontType const * FontData; - - - // Pointer to a font palette for the font. - unsigned char *RemapPalette; - - // Pointer to a converter. - ConvertClass *Converter; - - int Raw_Width(void) const; - int Raw_Height(void) const; -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h deleted file mode 100644 index 3f1459b7606..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h +++ /dev/null @@ -1,242 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/wwmouse.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 8/11/97 10:11a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef WW_MOUSE_H -#define WW_MOUSE_H - -#include "win.h" -#include "xmouse.h" - -class BSurface; - -/* -** Handles the mouse as it relates to the C&C game engine. It is expected that only -** one object of this type will be created during the lifetime of the game. -*/ -class WWMouseClass : public Mouse { - public: - /* - ** Private constructor. - */ - WWMouseClass(Surface * surfaceptr, HWND window); - virtual ~WWMouseClass(void); - - /* - ** Maintenance callback routine. - */ - void Process_Mouse(void); - - /* - ** Sets the game-drawn mouse imagery. - */ - virtual void Set_Cursor(int xhotspot, int yhotspot, ShapeSet const * cursor, int shape); - - /* - ** Controls visibility of the game-drawn mouse. - */ - virtual void Hide_Mouse(void); - virtual void Show_Mouse(void); - - /* - ** Takes control of and releases control of the mouse with - ** respect to the operating system. The mouse must be released - ** during operations with the operating system. When the mouse is - ** relased, it may move outside of the confining rectangle and its - ** shape is controlled by the operating sytem. - */ - virtual void Release_Mouse(void); - virtual void Capture_Mouse(void); - virtual bool Is_Captured(void) const {return(IsCaptured);} - - /* - ** Hide the mouse if it falls within this game screen region. - */ - virtual void Conditional_Hide_Mouse(Rect region); - virtual void Conditional_Show_Mouse(void); - - /* - ** Query about the mouse visiblity state and location. - */ - virtual int Get_Mouse_State(void) const; - virtual int Get_Mouse_X(void) const {return(MouseX);} - virtual int Get_Mouse_Y(void) const {return(MouseY);} - - /* - ** Set the mouse location. - */ - virtual void Set_Mouse_XY( int xpos, int ypos ); - - /* - ** The following two routines can be used to render the mouse onto an alternate - ** surface. - */ - virtual void Draw_Mouse(Surface * scr, bool issidebarsurface = false); - virtual void Erase_Mouse(Surface * scr, bool issidebarsurface = false); - //virtual void Draw_Mouse(Surface * scr); - //virtual void Erase_Mouse(Surface * scr); - - /* - ** Converts O/S screen coordinates into game coordinates. - */ - virtual void Convert_Coordinate(int & x, int & y) const; - - /* - ** Recalculate the confining rectangle from the window. - */ - void Calc_Confining_Rect(void); - - private: - - /* - ** Used to prevent conflict between the processing callback and - ** the normal mouse processing routines. The only potential conflict - ** would be with the maintenance callback routine. Since this callback - ** and the mouse class maintain a strict master/slave relationship, a - ** simple critial section flag is all that is needed. - */ - long Blocked; - - /* - ** Mouse hide/show state. If zero or greater, the mouse is visible. Otherwise - ** it is invisible. - */ - long MouseState; - - /* - ** If the mouse is being managed by this class (for the game), then this flag - ** will be true. When the mouse has been released to be managed by the operating - ** system, this flag will be false. However, this class will still track the mouse - ** position. - */ - bool IsCaptured; - - /* - ** This is the last recorded mouse position that it was drawn to. - */ - int MouseX; - int MouseY; - - /* - ** Points to the main display surface that the mouse will be drawn - ** to as it moves. - */ - Surface * SurfacePtr; - - /* - ** This is the window handle that is used to bind and bias the mouse - ** position and drawing procedures. - */ - HWND Window; - - /* - ** This specifies the rectangle that the game oriented mouse will be - ** confined to on the visible surface. If the mouse is manually drawn - ** on another surface, then this rectangle cooresponds to the hidden - ** surface area where the mouse is to be drawn. - */ - Rect ConfiningRect; - - /* - ** This specifies the mouse shape data. It records the shape set - ** data as well as the particular image contained within. - */ - ShapeSet const * MouseShape; - int ShapeNumber; - - /* - ** Specifies the hot spot where the image click maps to. This is an - ** offset from the upper left corner of the shape image. - */ - int MouseXHot; - int MouseYHot; - - /* - ** Holds the background image behind the mouse to be used for - ** restoring the surface pixels. - */ - BSurface * Background; - Rect SavedRegion; - - /* - ** This is the alternate mouse background buffer to be used when the - ** mouse is manually drawn to an alternate surface by the Draw_Mouse() - ** function. - */ - BSurface * Alternate; - Rect AltRegion; - - /* - ** This is another alternate buffer for drawing the mouse pointer across a second, adjoining - ** offscreen buffer. - */ - BSurface * SidebarAlternate; - Rect SidebarAltRegion; - - /* - ** Conditional hide mouse bounding rectangle and mouse state - ** flag. - */ - Rect ConditionalRect; - int ConditionalState; - - /* - ** Maintenance timer handle. - */ - MMRESULT TimerHandle; - - // Determines if there is valid mouse shape data available. - bool Is_Data_Valid(void) const; - bool Validate_Copy_Buffer(void); - - void Save_Background(void); - void Restore_Background(void); - - Rect Matching_Rect(void) const; - void Raw_Draw_Mouse(Surface * surface, int xoffset, int yoffset); - void Get_Bounded_Position(int & x, int & y) const; - void Update_Mouse_Position(int x, int y); - - void Low_Show_Mouse(void); - void Low_Hide_Mouse(void); - - void Block_Mouse(void) {InterlockedIncrement(&Blocked);/*Blocked++;*/} - void Unblock_Mouse(void) {InterlockedDecrement(&Blocked);/*Blocked--;*/} - bool Is_Blocked(void) const {return(Blocked != 0);} - - bool Is_Hidden(void) const {return(MouseState < 0);} -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/xmouse.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/xmouse.h deleted file mode 100644 index bde9cc0f01c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/xmouse.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/xmouse.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef XMOUSE_H -#define XMOUSE_H - -#include "trect.h" -class Surface; -class ShapeSet; - -/* -** This class manages the "mouse cursor". It presumes the mouse behaves in the traditional -** manner, but requires more manual management than a traditional mouse. -** -** The mouse interface is designed with the following requirements: -** -** 1> The interface (coordinate system) must be consistent with respect to the game user. -** This means that coordinate 0,0 is the upper left pixel of the drawable client area. -** -** 2> It must support arbitrary mouse cursor artwork size and hotspot positioning. Mouse shape -** animation should be a simple process of just changing the mouse shape. -** -** 3> The mouse must be able to break free of the game constraints where necessary in order -** to interface with the operating system. The transition should be easy to manage. -** -** 4> The game mouse "active" region may be a subset rectangle of the normal visible surface. -** This bounding requirement should be transparent to system's functionality. -** -** The system assumes that the sub-rectangle that binds the mouse to the visible surface will -** exactly match the dimensions of any hidden surface that the mouse may have occasion to be -** drawn upon. -*/ -class Mouse { - public: - virtual ~Mouse(void) {} - - /* - ** Sets the game-drawn mouse imagery. - */ - virtual void Set_Cursor(int xhotspot, int yhotspot, ShapeSet const * cursor, int shape) = 0; - - /* - ** Controls visibility of the game-drawn mouse. - */ - virtual void Hide_Mouse(void) = 0; - virtual void Show_Mouse(void) = 0; - - /* - ** Takes control of and releases control of the mouse with - ** respect to the operating system. The mouse must be released - ** during operations with the operating system. When the mouse is - ** relased, it may move outside of the confining rectangle and its - ** shape is controlled by the operating sytem. - */ - virtual void Release_Mouse(void) = 0; - virtual void Capture_Mouse(void) = 0; - virtual bool Is_Captured(void) const = 0; - - /* - ** Hide the mouse if it falls within this game screen region. - */ - virtual void Conditional_Hide_Mouse(Rect region) = 0; - virtual void Conditional_Show_Mouse(void) = 0; - - /* - ** Query about the mouse visiblity state and location. If the mouse - ** state is zero or greater, then the mouse is visible. - */ - virtual int Get_Mouse_State(void) const = 0; - virtual int Get_Mouse_X(void) const = 0; - virtual int Get_Mouse_Y(void) const = 0; - - /* - ** Set the mouse location. - */ - virtual void Set_Mouse_XY( int xpos, int ypos ) = 0; - - /* - ** The following two routines can be used to render the mouse onto an alternate - ** surface. - */ - virtual void Draw_Mouse(Surface * scr, bool issidebarsurface = false) = 0; - virtual void Erase_Mouse(Surface * scr, bool issidebarsurface = false) = 0; - //virtual void Erase_Mouse(Surface * scr) = 0; - - /* - ** Converts O/S screen coordinates into game coordinates. - */ - virtual void Convert_Coordinate(int & x, int & y) const = 0; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp b/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp deleted file mode 100644 index 0a5d1d7320e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp +++ /dev/null @@ -1,903 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/xsurface.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Blit_Clip -- Perform rectangle clipping in preparation for a blit. * - * XSurface::Blit_From -- Blit entire surface. * - * XSurface::Blit_From -- Blit from one surface to this one w/ clipping. * - * XSurface::Blit_From -- Blit one region to another. * - * XSurface::Blit_Plain -- Blit a plain rectangle from one surface to another. * - * XSurface::Blit_Trans -- Blit a rectangle with transparency checking. * - * XSurface::Draw_Line -- Draw a line and perform clipping. * - * XSurface::Draw_Line -- Draws a line upon the surface. * - * XSurface::Draw_Rect -- Draw a rectangle with an arbitrary clipping rectangle. * - * XSurface::Draw_Rect -- Draws a rectangle on the surface. * - * XSurface::Fill -- Fill the entire surface with the color specified. * - * XSurface::Fill_Rect -- Fill a rectangle but perform clipping on the fill. * - * XSurface::Fill_Rect -- Fills a rectangle with the color specified. * - * XSurface::Get_Pixel -- Fetches a pixel from the surface. * - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * XSurface::Put_Pixel -- Stores a pixel at the location specified. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blit.h" -#include "blitblit.h" -#include "bsurface.h" -#include "swap.h" -#include "xsurface.h" -//#include -#include - - -/*********************************************************************************************** - * XSurface::Draw_Line -- Draws a line upon the surface. * - * * - * This routine will draw a line on the surface between the points specified. * - * * - * INPUT: startpoint -- Pixel coordinate of one end point to the line. * - * * - * endpoint -- Pixel coordinate of the other end point to the line. * - * * - * color -- The color to draw the line with. * - * * - * OUTPUT: bool; Was the line drawn without error? * - * * - * WARNINGS: This routine is currently very brain-dead. It only draws vertical or * - * horizontal lines. It needs to be updated to handle any angle lines and should * - * perform line-clipping rather than point-pushing if the line intersects the * - * clipping rectangle. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color) -{ - return(XSurface::Draw_Line(Get_Rect(), startpoint, endpoint, color)); -} - - -/*********************************************************************************************** - * XSurface::Draw_Line -- Draw a line and perform clipping. * - * * - * Use this routine to draw a line on the surface but also clip the line draw against * - * an arbitrary sub-rectangle within the surface. * - * * - * INPUT: cliprect -- The clipping rectangle for this line draw. * - * * - * startpoint -- The starting point of the line draw. This point is relative to the * - * clipping rectangle. * - * * - * endpoint -- The ending point fo the line draw. This point is also relative to * - * the clipping rectangle. * - * * - * color -- The screen format color value to store for each pixel of the line. * - * * - * OUTPUT: bool; Was the line drawn? A 'false' return value would indicate that the line * - * was clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Line(Rect const & xcliprect, Point2D const & startpoint, Point2D const & endpoint, int color) -{ - /* - ** Ensure that the clipping rectangle is legal. - */ - Rect cliprect = xcliprect.Intersect(Get_Rect()); - - /* - ** High-speed working variables for the clipping rectangle and clipping operation. - */ - Point2D start = startpoint.Bias_To(cliprect); - Point2D end = endpoint.Bias_To(cliprect); - - /* - ** Build bits that indicate which end points lie outside the clipping rectangle. - ** Quick checks against these flag bits will speed the clipping process. - */ - enum { - OFF_TOP=0x01, - OFF_BOTTOM=0x02, - OFF_RIGHT=0x04, - OFF_LEFT=0x08 - }; - int sflag = 0; - int dflag = 0; - - if (start.X < cliprect.X) sflag |= OFF_LEFT; - if (start.Y < cliprect.Y) sflag |= OFF_TOP; - if (start.X >= cliprect.X+cliprect.Width) sflag |= OFF_RIGHT; - if (start.Y >= cliprect.Y+cliprect.Height) sflag |= OFF_BOTTOM; - if (end.X < cliprect.X) dflag |= OFF_LEFT; - if (end.Y < cliprect.Y) dflag |= OFF_TOP; - if (end.X >= cliprect.X+cliprect.Width) dflag |= OFF_RIGHT; - if (end.Y >= cliprect.Y+cliprect.Height) dflag |= OFF_BOTTOM; - - /* - ** Check to see if the line segment falls outside of the viewing rectangle. - */ - if ((sflag & dflag) != 0) return(false); - - /* - ** Clip the start point if necessary. This clipping should really check for - ** line intersect rather than pushing the end-point within bounds. - */ - if (sflag != 0) { - if (sflag & OFF_LEFT) start.X = cliprect.X; - if (sflag & OFF_RIGHT) start.X = cliprect.X+cliprect.Width-1; - if (sflag & OFF_TOP) start.Y = cliprect.Y; - if (sflag & OFF_BOTTOM) start.Y = cliprect.Y+cliprect.Height-1; - } - if (dflag != 0) { - if (dflag & OFF_LEFT) end.X = cliprect.X; - if (dflag & OFF_RIGHT) end.X = cliprect.X+cliprect.Width-1; - if (dflag & OFF_TOP) end.Y = cliprect.Y; - if (dflag & OFF_BOTTOM) end.Y = cliprect.Y+cliprect.Height-1; - } - - /* - ** Force the line segment to be either vertical or horizontal. This is because - ** we are not using brezenham's alogorithm (which we should be using instead here). - */ - if (start.X != end.X) start.Y = end.Y; - - /* - ** Ensure that the source point is always to the left and up - ** from the dest point. - */ - if (start.X > end.X || start.Y > end.Y) { - swap(start, end); - swap(sflag, dflag); - } - - int bbp = Bytes_Per_Pixel(); - void * buffer = Lock(start); - if (buffer != NULL) { - - if (start.Y == end.Y) { - if (bbp == 1) { - memset(buffer, color, (end.X-start.X)+1); - } else { - for (int x = 0; x <= end.X-start.X; x++) { - ((short *)buffer)[x] = (short)color; - } - } - } else { - for (int y = 0; y <= end.Y-start.Y; y++) { - if (bbp == 1) { - *(char*)buffer = (char)color; - } else { - *(short*)buffer = (short)color; - } - buffer = (void*)(((char*)buffer) + Stride()); - } - } - - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Draw_Rect -- Draws a rectangle on the surface. * - * * - * This routine will draw a line around the rectangle specified. The line will lie just * - * within the rectangle. * - * * - * INPUT: crect -- The rectangle dimensions to use. * - * * - * color -- The color to draw the rectangle. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Rect(Rect const & crect, int color) -{ - return(XSurface::Draw_Rect(Get_Rect(), crect, color)); -} - - -/*********************************************************************************************** - * XSurface::Draw_Rect -- Draw a rectangle with an arbitrary clipping rectangle. * - * * - * This routine will draw the rectangle but will also clip the draw against the clipping * - * rectangle provided. * - * * - * INPUT: cliprect -- The clipping rectangle to clip the draw against. * - * * - * rect -- The rectangle to draw. The coordinates are relative to the clipping * - * rectangle. * - * * - * color -- The color ot use for this rectangle draw. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Rect(Rect const & cliprect, Rect const & crect, int color) -{ - Point2D ul(crect.X, crect.Y); - Point2D ur(crect.X+crect.Width-1, crect.Y); - Point2D ll(crect.X, crect.Y+crect.Height-1); - Point2D lr(crect.X+crect.Width-1, crect.Y+crect.Height-1); - - Draw_Line(cliprect, ul, ur, color); - Draw_Line(cliprect, ul, ll, color); - Draw_Line(cliprect, ur, lr, color); - Draw_Line(cliprect, ll, lr, color); - return(true); -} - - -/*********************************************************************************************** - * XSurface::Get_Pixel -- Fetches a pixel from the surface. * - * * - * This routine will fetch a pixel element from the surface at the location specified. * - * * - * INPUT: point -- Coordinate to fetch the pixel from. * - * * - * OUTPUT: Returns with the pixel value at that coordinate. The interpretation of the return * - * value depends on the pixel format of the surface. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int XSurface::Get_Pixel(Point2D const & point) const -{ - int color = 0; - void * pointer = ((Surface*)this)->Lock(point); - if (pointer != NULL) { - if (Bytes_Per_Pixel() == 2) { - color = *((unsigned short*)pointer); - } else { - color = *((unsigned char*)pointer); - } - ((Surface*)this)->Unlock(); - } - return(color); -} - - -/*********************************************************************************************** - * XSurface::Put_Pixel -- Stores a pixel at the location specified. * - * * - * This routine will store a pixel at the coordinate specified on the surface. * - * * - * INPUT: point -- The coordinate to place the pixel at. * - * * - * color -- The pixel data to store. * - * * - * OUTPUT: bool; Was the pixel stored? * - * * - * WARNINGS: The color value specified is the raw pixel value that will be stored. The * - * format of this value is dependant upon the pixel format of the surface. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Put_Pixel(Point2D const & point, int color) -{ - void * pointer = Lock(point); - if (pointer != NULL) { - if (Bytes_Per_Pixel() == 2) { - *((unsigned short*)pointer) = (unsigned short)color; - } else { - *((unsigned char*)pointer) = (unsigned char)color; - } - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Fill_Rect -- Fills a rectangle with the color specified. * - * * - * This routine will fill the rectangle with a specified color. The rectangle filled will * - * be clipped appropriately. * - * * - * INPUT: fillrect -- The rectangle to fill. * - * * - * color -- The color to use when filling the rectangle. * - * * - * OUTPUT: bool; Was the rectangle filled without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill_Rect(Rect const & fillrect, int color) -{ - return(XSurface::Fill_Rect(fillrect, Get_Rect(), color)); -} - - -/*********************************************************************************************** - * XSurface::Fill_Rect -- Fill a rectangle but perform clipping on the fill. * - * * - * This will fill a rectangle of the specified dimensions. The fill request will be * - * clipped against the clipping rectangle provided. * - * * - * INPUT: cliprect -- The clipping rectangle to use for this fill. * - * * - * fillrect -- The rectangle to fill with the specified color. The rectangle is * - * relative to the clipping rectangle coordinates. * - * * - * color -- The screen format pixel value to draw with. * - * * - * OUTPUT: bool; Was the fill request carried out? A 'false' return value would indicate * - * that the fill was clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) -{ - if (!fillrect.Is_Valid()) return(false); - - /* - ** Ensure that the requested clipping rectangle is actually legal. - */ - Rect wrect = cliprect.Intersect(Get_Rect()); - - /* - ** Clip the rectangle to be filled against the clipping rectangle supplied. - */ - Rect crect = wrect.Intersect(fillrect.Bias_To(cliprect)); - if (!crect.Is_Valid()) return(false); - - void * buffer = Lock(crect.Top_Left()); - if (buffer != NULL) { - if (Bytes_Per_Pixel() == 1) { - for (int y = 0; y < crect.Height; y++) { - memset(buffer, color, crect.Width); - buffer = ((char *)buffer) + Stride(); - } - } else { - for (int y = 0; y < crect.Height; y++) { - for (int x = 0; x < crect.Width; x++) { - ((unsigned short*)buffer)[x] = (unsigned short)color; - } - buffer = ((char *)buffer) + Stride(); - } - } - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Fill -- Fill the entire surface with the color specified. * - * * - * The color specified will be filled into the entire surface area (but limited by the * - * surface's current window). * - * * - * INPUT: color -- The pixel value to use when filling the surface. * - * * - * OUTPUT: bool; Was the surface fill performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill(int color) -{ - return(Fill_Rect(Get_Rect(), Get_Rect(), color)); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit entire surface. * - * * - * This routine will blit the entire surface. * - * * - * INPUT: source -- Pointer to the source surface to blit from. * - * * - * trans -- Perform a transparency aware blit? * - * * - * OUTPUT: bool; Was the surface blit performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Surface const & source, bool trans) -{ - Rect drect = Get_Rect(); - drect.X = 0; - drect.Y = 0; - - Rect srect = source.Get_Rect(); - srect.X = 0; - srect.Y = 0; - bool result = Blit_From(drect, source, srect, trans); - - return(result); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit one region to another. * - * * - * Use this routine to copy one rectangle of pixel data to another. The pixels being * - * copied may be processed according to the parameters specified. * - * * - * INPUT: destrect -- The destination rectangle to bit to. * - * * - * source -- Pointer to the source surface to blit from. * - * * - * sourcerect -- The source rectangle to blit from. * - * * - * trans -- Should transparent pixels be scanned for an skipped? * - * * - * OUTPUT: bool; Was the blit operation performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans) -{ - return(XSurface::Blit_From(Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, trans)); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit from one surface to this one w/ clipping. * - * * - * This routine will blit a clipped rectangle from the specified surface to this one. * - * * - * INPUT: dcliprect -- The clipping rectangle to use for this (destination) surface. * - * * - * destrect -- The destanation rect of the blit. Coordinates are relative to the * - * destination clipping rectangle. * - * * - * source -- The source surface to blit from. * - * * - * scliprect -- The source clipping rectangle for the blit. * - * * - * sourcrect -- The source rectangle of the blit. The coordinates are relative to * - * the source clipping rectangle. * - * * - * trans -- Is this a transparent pixel aware blit request? * - * * - * OUTPUT: bool; Was a blit performed? A 'false' value would mean that the blit was clipped * - * away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans) -{ - Rect drect = destrect; - Rect srect = sourcerect; - - /* - ** Perform any clipping against the clipping rectangles. Proceed with the blit only - ** if there are pixels left unclipped. - */ - if (Blit_Clip(drect, dcliprect, srect, scliprect)) { - - if (trans) { - return(Blit_Trans(*this, drect, source, srect)); - } - return(Blit_Plain(*this, drect, source, srect)); - } - return(false); -} - - -/*********************************************************************************************** - * Blit_Clip -- Perform rectangle clipping in preparation for a blit. * - * * - * This routine will take a source rectangle and a source clipping window and intersect * - * these with a dest rectangle and a dest clipping window. The effect will be to alter * - * the source and dest rectangles so that they will stay within the clipping rectangles * - * imposed upon the source and destination surfaces. The process clips the rectangles * - * rather than displacing them when performing its adjustment. It is possible that one * - * or both rectangles are clipped into oblivion by this routine. This condition will be * - * flagged with the return value. * - * * - * INPUT: drect -- Reference to the destination rectangle (relative coordinates to the * - * destination window). This is both an input and output parameter. * - * * - * dwindow -- The destination window to clip the dest rect against. * - * * - * srect -- Reference to the source rectangle (relative to the source window). * - * This is both an input and output parameter. * - * * - * swindow -- The source window to clip the srect against. * - * * - * OUTPUT: bool; Was the clip performed and the srect and drect parameters still valid. * - * i.e., they represent at least one pixel that has not been clipped away. * - * * - * WARNINGS: The rectangles may be clipped into nothingness by this routine. Be sure to * - * check the return value for this condition and perform no blit operation in * - * that case. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool Blit_Clip(Rect & drect, Rect const & dwindow, Rect & srect, Rect const & swindow) -{ - /* - ** If the rectangles are of the same dimensions, then a coordinated clipping process is - ** possible. This results in an intelligent blit even if the source or destination - ** rectangles is partially outside the clipping rectangle. - */ - if (drect.Width == srect.Width && drect.Height == srect.Height) { - /* - ** Clip the left and top edges against the clipping window. - */ - if (drect.X < 0) { - srect.X += -drect.X; - srect.Width -= -drect.X; - drect.Width -= -drect.X; - drect.X = 0; - } - if (drect.Y < 0) { - srect.Y += -drect.Y; - srect.Height -= -drect.Y; - drect.Height -= -drect.Y; - drect.Y = 0; - } - - /* - ** Clip the right and bottom edges if they spill past the - ** clipping window boundaries. - */ - int rightspill = (drect.X+drect.Width) - dwindow.Width; - if (rightspill > 0) { - srect.Width -= rightspill; - drect.Width -= rightspill; - } - int bottomspill = (drect.Y+drect.Height) - dwindow.Height; - if (bottomspill > 0) { - srect.Height -= bottomspill; - drect.Height -= bottomspill; - } - - /* - ** Clip the left and top edges against the clipping - ** window. - */ - if (srect.X < 0) { - drect.X += -srect.X; - srect.Width -= -srect.X; - drect.Width -= -srect.X; - srect.X = 0; - } - if (srect.Y < 0) { - drect.Y += -srect.Y; - srect.Height -= -srect.Y; - drect.Height -= -srect.Y; - srect.Y = 0; - } - - /* - ** Clip the right and bottom edges agaist the clipping window. - */ - rightspill = (srect.X+srect.Width) - swindow.Width; - if (rightspill > 0) { - srect.Width -= rightspill; - drect.Width -= rightspill; - } - bottomspill = (srect.Y+srect.Height) - swindow.Height; - if (bottomspill > 0) { - srect.Height -= bottomspill; - drect.Height -= bottomspill; - } - - } else { - - /* - ** Since the rectangles are not of the same dimensions, scaling is presumed. Clipping - ** in such a case is merely a legality clip against the bounding rectangle. No coordinated - ** adjustments can occur. For best results, boundary clipping should be performed prior to - ** calling this routine. - */ - drect = drect.Intersect(dwindow); - srect = srect.Intersect(swindow); - } - - return(drect.Is_Valid() && srect.Is_Valid()); -} - - -/*********************************************************************************************** - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * * - * This performs the clipping operation required before a blit occurs. It examines the * - * source and destination coordinate constraints and performs clipping such that only * - * legal pixels will be blitted. As a consequence it can determine if the blit has been * - * completely clipped and thus can be skipped. * - * * - * INPUT: dest -- The destination surface rect for the blit. * - * * - * drect -- The rectangle within the destination surface rect for the blit. This * - * rectangle reference will be adjusted as necessary. * - * * - * source -- The source surface rect of the blit. * - * * - * srect -- The source rectangle within the source surface rect for the blit. * - * This rectangle reference will be adjusted as necessary. * - * * - * overlapped -- Output reference that stores the boolean answer to the question -- * - * are the blit rectangles overlapping on the same surface? * - * * - * dbuffer -- Output reference that stores a pointer to the locked destination * - * surface. It points to the upper left destination corner pixel. * - * * - * sbuffer -- Output reference that stores a pointer to the locked source surface. * - * It points to the upper left corner source pixel. * - * * - * OUTPUT: bool; Can the blit proceed since there is at least one pixel that has not been * - * clipped away? It can also fail if a lock could not be performed on the * - * source or destination surfaces. * - * * - * WARNINGS: The surfaces locked by this routine must be unlocked. If the return value is * - * 'true', then the surfaces must be unlocked. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Prep_For_Blit(Surface & dest, Rect & drect, Surface const & source, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer) -{ - return(XSurface::Prep_For_Blit(dest, dest.Get_Rect(), drect, source, source.Get_Rect(), srect, overlapped, dbuffer, sbuffer)); -#ifdef NEVER - overlapped = false; - dbuffer = NULL; - sbuffer = NULL; - - if (!drect.Is_Valid() || !srect.Is_Valid()) return(false); - - /* - ** Perform the clipping of the desired blit rectangles against the surface clipping - ** rectangles. If it happens that the blit is clipped into oblivion, then bail - ** immediately -- there is nothing left to do. - */ - Rect swindow = source.Get_Rect(); - Rect dwindow = dest.Get_Rect(); - if (!Blit_Clip(drect, dwindow, srect, swindow)) { - return(false); - } - - /* - ** Determine if the rectangles overlap such that a forward blit would - ** be prohibited. This only occurs if the source and destination refer to the - ** same surface and the rectangles overlap. - */ - overlapped = false; - if (&source == &dest && srect.Is_Overlapping(drect)) { - if (srect.Y < drect.Y || (srect.Y == drect.Y && srect.X < drect.X)) { - overlapped = true; - } - } - - /* - ** Fetch pointers to the source and dest upper left pixel. That is, the upper - ** left pixel of the source and dest sub-rectangles within each surface - ** respectively. - */ - dbuffer = dest.Lock(drect.Point()); - if (dbuffer == NULL) return(false); - sbuffer = ((Surface &)source).Lock(srect.Point()); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - return(true); -#endif -} - - -/*********************************************************************************************** - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * * - * This performs the clipping operation required before a blit occurs. It examines the * - * source and destination coordinate constraints and performs clipping such that only * - * legal pixels will be blitted. As a consequence it can determine if the blit has been * - * completely clipped and thus can be skipped. * - * * - * INPUT: dest -- The destination surface rect for the blit. * - * * - * dcliprect-- The destination clipping rectangle. * - * * - * drect -- The rectangle within the destination surface rect for the blit. This * - * rectangle reference will be adjusted as necessary. * - * * - * source -- The source surface rect of the blit. * - * * - * scliprect-- The source clipping rectangle. * - * * - * srect -- The source rectangle within the source surface rect for the blit. * - * This rectangle reference will be adjusted as necessary. * - * * - * overlapped -- Output reference that stores the boolean answer to the question -- * - * are the blit rectangles overlapping on the same surface? * - * * - * dbuffer -- Output reference that stores a pointer to the locked destination * - * surface. It points to the upper left destination corner pixel. * - * * - * sbuffer -- Output reference that stores a pointer to the locked source surface. * - * It points to the upper left corner source pixel. * - * * - * OUTPUT: bool; Can the blit proceed since there is at least one pixel that has not been * - * clipped away? It can also fail if a lock could not be performed on the * - * source or destination surfaces. * - * * - * WARNINGS: The surfaces locked by this routine must be unlocked. If the return value is * - * 'true', then the surfaces must be unlocked. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Prep_For_Blit(Surface & dest, Rect const & dcliprect, Rect & drect, Surface const & source, Rect const & scliprect, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer) -{ - overlapped = false; - dbuffer = NULL; - sbuffer = NULL; - - if (!drect.Is_Valid() || !dcliprect.Is_Valid() || !srect.Is_Valid() || !scliprect.Is_Valid()) return(false); - - /* - ** Perform the clipping of the desired blit rectangles against the surface clipping - ** rectangles. If it happens that the blit is clipped into oblivion, then bail - ** immediately -- there is nothing left to do. - */ - if (!Blit_Clip(drect, dcliprect, srect, scliprect)) { - return(false); - } - - /* - ** Determine if the rectangles overlap such that a forward blit would - ** be prohibited. This only occurs if the source and destination refer to the - ** same surface and the rectangles overlap. - */ - overlapped = false; - if (&source == &dest && srect.Is_Overlapping(drect)) { - if (srect.Y < drect.Y || (srect.Y == drect.Y && srect.X < drect.X)) { - overlapped = true; - } - } - - /* - ** Fetch pointers to the source and dest upper left pixel. That is, the upper - ** left pixel of the source and dest sub-rectangles within each surface - ** respectively. - */ - dbuffer = dest.Lock(dcliprect.Top_Left() + drect.Top_Left()); - if (dbuffer == NULL) return(false); - sbuffer = source.Lock(scliprect.Top_Left() + srect.Top_Left()); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - return(true); -} - - -/*********************************************************************************************** - * XSurface::Blit_Plain -- Blit a plain rectangle from one surface to another. * - * * - * This routine will perform a simple blit of a rectangle from one surface to another. * - * * - * INPUT: dest -- The destination surface for the blit. * - * * - * destrect -- The destination rectangle for the blit. * - * * - * source -- The source surface. * - * * - * sourcerect -- The rectangle in the source surface to blit from. * - * * - * OUTPUT: bool; Was the blit performed? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_Plain(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect) -{ - if (dest.Bytes_Per_Pixel() == 1) { - return(Bit_Blit(dest, destrect, source, sourcerect, BlitPlain())); - } - return(Bit_Blit(dest, destrect, source, sourcerect, BlitPlain())); -} - - -/*********************************************************************************************** - * XSurface::Blit_Trans -- Blit a rectangle with transparency checking. * - * * - * This routine will perform a simple blit of one rectangle to another on the surfaces * - * specified. * - * * - * INPUT: dest -- The destination surface. * - * * - * destrect -- The destination rectangle within the surface. * - * * - * source -- The source surface. * - * * - * sourcerect -- The source rectangle. * - * * - * OUTPUT: bool; Was the blit performed? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_Trans(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect) -{ - switch (dest.Bytes_Per_Pixel()) - { - case 1: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - case 2: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - case 4: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - default: - return(false); - } -} - - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.h b/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.h deleted file mode 100644 index f65098c460d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WWLib/xsurface.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/xsurface.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:01p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef XSURFACE_H -#define XSURFACE_H - -#include "Surface.h" - -/* -** This is a concrete (mostly) derived class that handles a surface. This layer presumes that -** pixels are compositied into a contiguous integral (usually a byte) linear array. The -** implemented routines do not use hardware assist. They are prime candidates to be converted -** to assembly language. -*/ -class XSurface : public Surface -{ - public: - XSurface(int width=0, int height=0) : Surface(width, height), LockCount(0) {} - virtual ~XSurface(void) {} - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Surface const & source, bool trans=false); - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color); - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color); - virtual bool Fill(int color); - - /* - ** Fetches and stores a pixel to the display (pixel is in surface format). - */ - virtual bool Put_Pixel(Point2D const & point, int color); - virtual int Get_Pixel(Point2D const & point) const; - - /* - ** Draws lines onto the surface. - */ - virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color); - virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color); - - /* - ** Draws rectangles onto the surface. - */ - virtual bool Draw_Rect(Rect const & rect, int color); - virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color); - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D = Point2D(0, 0)) const {LockCount++;return(NULL);} - virtual bool Unlock(void) const {LockCount--;return(true);} - virtual bool Is_Locked(void) const {return(LockCount != 0);} - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const = 0; - virtual int Stride(void) const = 0; - - /* - ** Hack function to serve the purpose that RTTI was invented for, but since - ** the Watcom compiler doesn't support RTTI, we must resort to using this - ** alternative. - */ - virtual bool Is_Direct_Draw(void) const {return(false);} - - /* - ** This routine is handy for preparing to perform some kind of manual blit - ** operation. - */ - static bool Prep_For_Blit(Surface & dest, Rect & drect, Surface const & source, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer); - static bool Prep_For_Blit(Surface & dest, Rect const & dcliprect, Rect & drect, Surface const & source, Rect const & scliprect, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer); - - /* - ** These are the exposed manual blit routines. They can be called directly if desired. - */ - static bool Blit_Trans(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect); - static bool Blit_Plain(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect); - - protected: - /* - ** Records the number of locks on this surface. - */ - mutable int LockCount; -}; - -bool Blit_Clip(Rect & drect, Rect const & dwindow, Rect & srect, Rect const & swindow); - - -#endif diff --git a/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp b/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp index 017c1b75070..a13609445d2 100644 --- a/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp @@ -30,7 +30,6 @@ #include "W3DDevice/GameClient/W3DAssetManager.h" #include "W3DDevice/GameClient/Module/W3DModelDraw.h" #include "agg_def.h" -#include "msgloop.h" #include "part_ldr.h" #include "rendobj.h" #include "hanim.h" @@ -58,7 +57,6 @@ #include "shattersystem.h" #include "light.h" #include "texproject.h" -#include "keyboard.h" #include "MapSettings.h" #include "predlod.h" #include "SelectMacrotexture.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index c4512a806d7..5313419aab0 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -95,13 +95,11 @@ set(WW3D2_SRC streakRender.cpp stripoptimizer.cpp surfaceclass.cpp - texfcach.cpp texproject.cpp texture.cpp texturefilter.cpp textureloader.cpp texturethumbnail.cpp - txt.cpp vertmaterial.cpp visrasterizer.cpp w3d_dep.cpp @@ -213,13 +211,11 @@ set(WW3D2_SRC streakRender.h stripoptimizer.h surfaceclass.h - texfcach.h texproject.h texture.h texturefilter.h textureloader.h texturethumbnail.h - txt.h vertmaterial.h visrasterizer.h w3d_dep.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index e11bacead8d..2544d8600ab 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -103,7 +103,6 @@ #include "distlod.h" #include "hlod.h" #include "agg_def.h" -#include "texfcach.h" #include "wwstring.h" #include "wwmemlog.h" #include "dazzle.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp index 70c334500d9..df22689ef6b 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp @@ -74,8 +74,7 @@ #include "rendobj.h" #include "assetmgr.h" -#include "_mono.h" -#include "bsurface.h" +#include "win.h" #include "pot.h" #include "scene.h" #include "colmath.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp deleted file mode 100644 index 331f1844357..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.cpp +++ /dev/null @@ -1,906 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/texfcach.cpp 5 8/24/01 3:23p Jani_p $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/texfcach.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 8/24/01 11:50a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * TextureFileCache::TextureFileCache -- Open cache. * - * ~TextureFileCache::TextureFileCache -- Shut down texture cache system. * - * TextureFileCache::Save_Texture -- Save the texture into the cache. * - * TextureFileCache::Load_Texture -- Load texture from cache into surface. * - * *TextureFileCache::_Create_File_Name -- Create a file name from prefix * - * *TextureFileCache::Load_Original_Texture_Surface -- Create the initial * - * *TextureFileCache::Open_Texture_Handle -- Set the TextureHandle and Header.. * - * TextureFileCache::Close_Texture_Handle -- Close the current texture so we can open anoth* - * TextureFileCache::Read_Texture -- Read in the texture into surface buffer. * - * *TextureFileCache::Create_First_Texture_As_Surface -- Load first texture into a surface. * - * *TextureFileCache::Find_Cached_Surface -- Search for a texture already cached. * - * TextureFileCache::Add_Cached_Surface -- Add a new cached texture. * - * *TFC::Get_Surface -- Load a texture reduced N times. * - * TextureFileCache::Reset_File -- virtual function to reset file and write out file. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifdef WW3D_DX8 -#include "texfcach.h" -#include "mutex.h" -#include "thread.h" -#include -#include "wwdebug.h" -#include "simplevec.h" -#include "wwstring.h" -#include "textureloader.h" -#include "texture.h" -#include "ffactory.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#ifdef _UNIX -#include "osdep.h" -#endif - -#define FILE_HEADER_NAME "Texture File Cache Header" - - -char *TextureFileCache::_FileNamePtr = NULL; -static int Instances=0; - -static CriticalSectionClass mutex(0); -static SimpleVecClass compression_buffer; - -const char BUFFER_OVERRUN_TEST_VALUE=((char)0x7d); - -static char* Get_Compression_Buffer(int size) -{ - compression_buffer.Uninitialised_Grow(size+1); - compression_buffer[size]=BUFFER_OVERRUN_TEST_VALUE; - return &(compression_buffer[0]); -} - -static void Verify_Compression_Buffer() -{ - WWASSERT(compression_buffer[compression_buffer.Length()-1]==BUFFER_OVERRUN_TEST_VALUE); -} - - -class Compressor -{ -public: - - static int Compress - ( - const unsigned char * in, - unsigned int in_len, - unsigned char * out, - unsigned int * out_len - ); - - static int Decompress - ( - const unsigned char * in, - unsigned int in_len, - unsigned char * out, - unsigned int * out_len - ); - -}; - -int Compressor::Compress( const unsigned char * in, unsigned int in_len, - unsigned char * out, unsigned int * out_len ) -{ - if (!in || !out || !out_len) - return FALSE; - - if (in_len <= 0) - return false; - - memcpy(out, in, in_len); - - *out_len = in_len; - - return TRUE; -} - -int Compressor::Decompress( const unsigned char * in, unsigned int in_len, - unsigned char * out, unsigned int * out_len ) -{ - if (!in || !out || !out_len) - return FALSE; - - if (in_len <= 0) - return false; - - memcpy(out, in, in_len); - - *out_len = in_len; - - return TRUE; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// TextureFileCache ///////////////////////////////////////////// - -/*********************************************************************************************** - * TextureFileCache::TextureFileCache -- Open cache. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/07/1999 SKB : Created. * - * 06/27/2000 SKB : added CachedSurfaces * - * 08/14/2000 : Check for revision number. * - *=============================================================================================*/ -TextureFileCache::TextureFileCache(const char *fileprefix): - File(_Create_File_Name(fileprefix)), - CurrentTexture(NULL), - TextureHandle(NULL), - Header(), - CachedSurfaces(), - Offsets(NULL), - NumCachedTextures(0) -{ - WWASSERT(!Instances); - Instances++; - - // This was allocated by _Create_File_Name() and need to go away now. - delete _FileNamePtr; - _FileNamePtr = NULL; - - memset(CachedSurfaces, 0, sizeof(CachedSurfaces)); - - bool reset = false; - TagBlockHandle *handle = File.Open_Tag(FILE_HEADER_NAME); - if (handle) { - FileHeader fileheader; - - // Read in header for others to use. - handle->Read(&fileheader, sizeof(fileheader)); - - if (fileheader.Version != FileHeader::TCF_VERSION) { - reset = true; - } - - // Close down handle. - delete handle; - } else { - reset = true; - } - - if (reset) { - Reset_File(); - } -} - -/*********************************************************************************************** - * *TextureFileCache::_Create_File_Name -- Create a file name from prefix passed in. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Caller of this function must free _FileNamePtr when done with it. * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -char *TextureFileCache::_Create_File_Name(const char *fileprefix) -{ - bool addpath = (*fileprefix != '\\' && fileprefix[1] != ':'); - - assert(!_FileNamePtr); - _FileNamePtr = W3DNEWARRAY char[strlen(fileprefix) + (addpath ? 256 : 6)]; - - char path[_MAX_PATH]; - if (addpath && _getcwd(path, _MAX_PATH )) { - sprintf(_FileNamePtr, "%s\\%s.tfc", path, fileprefix); - } else { - // Create a file name. - strcpy(_FileNamePtr, fileprefix); - strcat(_FileNamePtr, ".tfc"); - *_FileNamePtr = 0; - } - - return(_FileNamePtr); -} - - -/*********************************************************************************************** - * ~TextureFileCache::TextureFileCache -- Shut down texture cache system. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/07/1999 SKB : Created. * - *=============================================================================================*/ -TextureFileCache::~TextureFileCache() -{ - // Make sure we have shut down everything. - Close_Texture_Handle(); - - Instances--; - WWASSERT(!Instances); -} - - -/************************************************************************** - * TextureFileCache::Reset_File -- virtual function to reset file and wri * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/14/2000 : Created. * - *========================================================================*/ -void TextureFileCache::Reset_File() -{ - File.Reset_File(); - - TagBlockHandle *handle = File.Create_Tag(FILE_HEADER_NAME); - if (handle) { - FileHeader fileheader; - fileheader.Version = FileHeader::TCF_VERSION; - - // Read in header for others to use. - handle->Write(&fileheader, sizeof(fileheader)); - - // Close down handle. - delete handle; - } else { - assert(false); - } -} - -/*********************************************************************************************** - * TextureFileCache::Save_Texture -- Save the texture into the cache. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - * 06/27/2000 SKB : added Header.PixelFormat * - * 06/27/2000 SKB : changed cached textures to surfaces * - * 08/14/2000 : save file's datatime stamp. * - *=============================================================================================*/ -bool TextureFileCache::Save_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq, srColorSurfaceIFace& origsurface) -{ - CriticalSectionClass::LockClass m(mutex); - int idx; - unsigned lod; - - // Open up our new texture. - Open_Texture_Handle(texturename); - - // Create a new texture now. - TextureHandle = File.Create_Tag(texturename); - if (!TextureHandle) { - Close_Texture_Handle(); - return(false); - } - - // Setup the Header. - FileClass *asset=_TheFileFactory->Get_File(texturename); - WWASSERT( asset ); - asset->Open(); - Header.FileTime = asset->Get_Date_Time(); - Header.NumMipMaps = (mreq.smallLOD - mreq.largeLOD) + 1; - Header.LargestWidth = mreq.levels[mreq.largeLOD]->getWidth(); - Header.LargestHeight = mreq.levels[mreq.largeLOD]->getHeight(); - Header.SourceWidth = origsurface.getWidth(); - Header.SourceHeight = origsurface.getHeight(); - mreq.levels[mreq.largeLOD]->getPixelFormat(Header.PixelFormat); - origsurface.getPixelFormat(Header.SourcePixelFormat); - - _TheFileFactory->Return_File(asset); - asset=NULL; - - // Write it out. - TextureHandle->Write(&Header, sizeof(Header)); - - // Setup offset table. - Offsets = W3DNEWARRAY OffsetTableType[Header.NumMipMaps + 1]; - - // Write for now, but we will need to seek back to write final data. - int tableoffset = TextureHandle->Tell(); - TextureHandle->Write(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - // Now write out the textures. - for (idx = 0, lod = mreq.largeLOD; lod <= mreq.smallLOD; idx++, lod++) { - srColorSurface *surface = mreq.levels[lod]; - WWASSERT(surface->getDataPtr()); - - Offsets[idx].Offset = TextureHandle->Tell(); - Offsets[idx].Size = surface->getDataSize(); - - // Save data pointers so we don't need to read them from disk next time. - Add_Cached_Surface(surface); - - int compsize,retcode; - - int buf_size=surface->getDataSize(); - retcode = Compressor::Compress( (const unsigned char *) surface->getDataPtr(), - (unsigned int) surface->getDataSize(), - (unsigned char *) Get_Compression_Buffer(buf_size), - (unsigned *) &compsize); - - - // Lots-o-test to make sure that the compression did what we want. - assert(retcode == TRUE); - Verify_Compression_Buffer(); - - int readin = TextureHandle->Write(Get_Compression_Buffer(compsize), compsize); - assert(readin == compsize); - } - - int pos = TextureHandle->Seek(0, SEEK_END); - - // Set last one so we can get a compressed size of last texture. - Offsets[idx].Offset = TextureHandle->Tell(); - Offsets[idx].Size = 0; - - // Now write out header for good. - TextureHandle->Seek(tableoffset, SEEK_SET); - TextureHandle->Write(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - pos = TextureHandle->Seek(0, SEEK_END); - - // End write access so that it gets flushed out to disk. - TextureHandle->End_Write_Access(); - - return (true); -} - -/*********************************************************************************************** - * *TextureFileCache::Load_Original_Texture_Surface -- Create the initial surface that would * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Sureface is only needed to get default values. The texel data does not get filled in. * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Load_Original_Texture_Surface(const char *texturename) -{ - CriticalSectionClass::LockClass m(mutex); - if (Open_Texture_Handle(texturename)) { - // Create surface that we wish to return. - srColorSurfaceIFace *surface = W3DNEW srColorSurface(Header.SourcePixelFormat, Header.SourceWidth, Header.SourceHeight); - return(surface); - } - return(NULL); -} - -/*********************************************************************************************** - * *TFC::Get_Surface -- Load a texture reduced N times. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/26/2000 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Get_Surface(const char *texturename, unsigned int reduce_factor) -{ - CriticalSectionClass::LockClass m(mutex); - - // If we can't get a handle, then we can't load the texture. - if (!Open_Texture_Handle(texturename)) { - return(0); - } - - if (reduce_factor >= (unsigned int)(Header.NumMipMaps)) { - reduce_factor=Header.NumMipMaps-1; - } - - // Figure out the width and height of texture. - int width = Header.LargestWidth >> reduce_factor; - int height = Header.LargestHeight >> reduce_factor; - if (!width) width = 1; - if (!height) height = 1; - - // Create surface to return. - srColorSurface *surface = W3DNEW srColorSurface(Header.PixelFormat, width, height); - int size = Texture_Size(reduce_factor); - assert(size == surface->getDataSize()); - - // See if this texture is already in memory. - srColorSurface *cached = Find_Cached_Surface(size); - if (cached) { - assert(size == cached->getDataSize()); - memcpy(surface->getDataPtr(), cached->getDataPtr(), size); - } else { - // Cache pointer so if we need texture again, we will have a pointer to - // valid texture data instead of reading it from the file. - Add_Cached_Surface(surface); - - // Read texture in - note that Textures[lod] has to be set prior to this. - Read_Texture(reduce_factor, surface); - } - return(surface); -} - -/*********************************************************************************************** - * TextureFileCache::Load_Texture -- Load texture from cache into surface. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - * 06/02/1999 SKB : deal with texture requests larger then what is in cache. * - * 06/27/2000 SKB : changed cached textures to surfaces * - *=============================================================================================*/ -bool TextureFileCache::Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq) -{ - CriticalSectionClass::LockClass m(mutex); - // If we can't get a handle, then we can't load the texture. - if (!Open_Texture_Handle(texturename)) { - return(false); - } - - // NOTE: Mip maps that are saved in the cache are the first mip maps requested and created - // for a given texture name. If a user susequently requests mip maps of different - // sizes that are not in the cache, they will be created by use of surface copy functions. - // When this happens it is unfortunate because it indicates some sort of inefficiency. - // In code below I have put in comments 'A WASTE' to indicate what part of code deels with it. - int idx; - unsigned lod; - - // Get largest size of texture in file (idx) and what is required (lod). - int idxsize = Texture_Size(0); - int lodsize = -1; - - // Now skip any mip maps that we want but are not in the cache. (A WASTE). - for (lod = mreq.largeLOD; lod <= mreq.smallLOD; lod++) { - lodsize = mreq.levels[lod]->getDataSize(); - if (lodsize <= idxsize) { - break; - } - } - // make sure largeLOD <= smallLOD. - assert(lodsize != -1); - - // Skip past all mipmap levels that we do not want in the file. - for (idx = 0; idx < Header.NumMipMaps; idx++) { - idxsize = Texture_Size(idx); - if (idxsize <= lodsize) { - break; - } - } - - // Save off the first lod and what index it is. - unsigned firstlod = lod; - - // Now if we have in the file something that the texture needs, load it. (This is most desired.) - if (idxsize == lodsize) { - // Read in textures that we have and need. - while ((lod <= mreq.smallLOD) && (idx < Header.NumMipMaps)) { - srColorSurface *surface = mreq.levels[lod]; - int size = surface->getDataSize(); assert(Texture_Size(idx) == size); - - // See if we can find the texture already cached. - srColorSurface *cached = Find_Cached_Surface(size); - - // See if texture has already been read in. - if (cached) { - assert(size == cached->getDataSize()); - - // Copy data over using size of dest surface incase asserts disabled and sizes are not right. - memcpy(surface->getDataPtr(), cached->getDataPtr(), size); - } else { - // Cache pointer so if we need texture again, we will have a pointer to - // valid texture data instead of reading it from the file. - Add_Cached_Surface(surface); - - // Read texture in - note that Textures[lod] has to be set prior to this. - Read_Texture(idx, surface); - } - - idx++, lod++; - } - } - - // Save last lod. - unsigned lastlod = lod - 1; - - // largest surface loaded. - srColorSurfaceIFace *surface = NULL; - if (firstlod < lastlod) { - surface = mreq.levels[firstlod]; - surface->addReference(); - } - - // If user requested a texture larger then what we have saved, then - // we will have to scale it up for him. - // NOTE: This is normally not desired. It typically means the user is - // creating a texture larger then the original source - a waste. - if (mreq.largeLOD < firstlod) { - // If there has not been a surface loaded yet, then do so now. - if (!surface) { - surface = Create_First_Texture_As_Surface(mreq.levels[mreq.largeLOD]); - } - - // Now scale the largest mip map we had up to what user wants (ONCE AGAIN: A WASTE). - for (lod = mreq.largeLOD; lod <= firstlod; lod++) { - // Do a surface scale. - surface->copy(*mreq.levels[lod]); - } - } - - // Are there more smaller lod's that are not in the cache? - if (lastlod < mreq.smallLOD) { - // If there has not been a surface loaded yet, then do so now. - if (!surface) { - surface = Create_First_Texture_As_Surface(mreq.levels[mreq.largeLOD]); - } - - // Now scale the largest mip map we had up to what user wants (ONCE AGAIN: A WASTE). - for (lod = lastlod + 1; lod <= mreq.smallLOD; lod++) { - // Do a surface scale. - surface->copy(*mreq.levels[lod]); - } - } - - // Done with this one. - if (surface) { - surface->release(); - } - - return (true); -} - -/*********************************************************************************************** - * TextureFileCache::Read_Texture -- Read in the texture into surface buffer. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/01/1999 SKB : Created. * - * 06/27/2000 SKB : changed cached textures to surfaces * - *=============================================================================================*/ -void TextureFileCache::Read_Texture(int offsetidx, srColorSurface *surface) -{ - // Seek to correct spot. - TextureHandle->Seek(Offsets[offsetidx].Offset, SEEK_SET); - - // Figure out how much read in and make sure it is correct size. - int compsize = Compressed_Texture_Size(offsetidx); - - // Read in texture from cache. - int readin = TextureHandle->Read(Get_Compression_Buffer(compsize), compsize); - assert(readin == compsize); - - // Set values so we can assert if overrun. - Verify_Compression_Buffer(); - - // Decompress into texture pointer. - int retcode, decompsize; - retcode = Compressor::Decompress( (const unsigned char*) Get_Compression_Buffer(compsize), - (unsigned int) compsize, - (unsigned char*) surface->getDataPtr(), - (unsigned *) &decompsize); - - // Lots-o-test to make sure that the compression did what we want. - assert(retcode == TRUE); - assert(decompsize == Texture_Size(offsetidx)); - Verify_Compression_Buffer(); -} - -/*********************************************************************************************** - * *TextureFileCache::Create_First_Texture_As_Surface -- Load first texture into a surface. * - * * - * INPUT: * - * srColorSurfaceIFace *surfacetype - only used to create surface type we want. * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurfaceIFace *TextureFileCache::Create_First_Texture_As_Surface(srColorSurfaceIFace *surfacetype) -{ - srColorSurfaceIFace::PixelFormat pf; - - // Get our pixel format. - surfacetype->getPixelFormat(pf); - - // Create a surface we can load the largest texture into it - srColorSurface *surface = W3DNEW srColorSurface(pf, Header.LargestWidth, Header.LargestHeight); - assert(Texture_Size(0) == surface->getDataSize()); - - // Read in texture to our surface data.. - Read_Texture(0, surface); - - return(surface); -} - -/*********************************************************************************************** - * *TextureFileCache::Open_Texture_Handle -- Set the TextureHandle and Header.. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/13/1999 SKB : Created. * - *=============================================================================================*/ -bool TextureFileCache::Open_Texture_Handle(const char *fname) -{ - if (TextureHandle) { - assert(CurrentTexture); - if (!strcmpi(fname, CurrentTexture)) { - return(true); - } - // Wrong texture, close it down so we can open another. - Close_Texture_Handle(); - } - if (!CurrentTexture) { - CurrentTexture = strdup(fname); - } - - #if 0 - // If this is texture is newer then our texture file, reset file. - // This means that next time the texture cache file gets opened, all the - // previous textures will be loaded. - // SKB 8/14/2000 : Removed to put in better system below.. - RawFileClass asset(fname); - asset.Open(); - if (asset.Get_Date_Time() > File.Get_Date_Time()) { - Reset_File(); - } - #endif - - // See if we have the texture in the file cache yet. - TextureHandle = File.Open_Tag(fname); - if (TextureHandle) { - // Read in header for others to use. - TextureHandle->Read(&Header, sizeof(Header)); - - file_auto_ptr asset(_TheFileFactory, fname); - asset->Open(); - - // Make sure it is same file. - if (Header.FileTime != asset->Get_Date_Time()) { - - delete TextureHandle; - TextureHandle = NULL; - - Reset_File(); - return(false); - } - - // Load up the offset table. - Offsets = W3DNEWARRAY OffsetTableType[Header.NumMipMaps + 1]; - TextureHandle->Read(Offsets, sizeof(OffsetTableType) * (Header.NumMipMaps + 1)); - - return(true); - } - - return(false); -} - -/*********************************************************************************************** - * TextureFileCache::Close_Texture_Handle -- Close the current texture so we can open another. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/01/1999 SKB : Created. * - *=============================================================================================*/ -void TextureFileCache::Close_Texture_Handle() -{ - if (CurrentTexture) { - free(CurrentTexture); - CurrentTexture = NULL; - - if (TextureHandle) { - delete TextureHandle; - TextureHandle = NULL; - } - while (NumCachedTextures--) { - assert(CachedSurfaces[NumCachedTextures]); - CachedSurfaces[NumCachedTextures]->release(); - CachedSurfaces[NumCachedTextures] = 0; - } - NumCachedTextures = 0; - - if (Offsets) { - delete[] Offsets; - Offsets = NULL; - } - } else { - assert(!CurrentTexture); - } -} - -/*********************************************************************************************** - * *TextureFileCache::Find_Cached_Surface -- Search for a texture already cached. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -srColorSurface *TextureFileCache::Find_Cached_Surface(int size) -{ - // Search through each allocated record for the right size. - for (int idx = 0; idx < NumCachedTextures; idx++) { - if (CachedSurfaces[idx]->getDataSize() == size) { - return(CachedSurfaces[idx]); - } - } - return(NULL); -} - -/*********************************************************************************************** - * TextureFileCache::Add_Cached_Surface -- Add a new cached texture. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -void TextureFileCache::Add_Cached_Surface(srColorSurface *surface) -{ -// return; - assert(!Find_Cached_Surface(surface->getDataSize())); - - // If are cache is full, use the smallest one's space. - int surface_idx = -1; - if (NumCachedTextures == MAX_CACHED_SURFACES) { - // Make sure there are some cached textures. - // Assume first is smallest. - int smallsize = 0xfffffff; - int smallidx = -1; - - // Look for any others that might be smaller. - for (int idx = 0; idx < NumCachedTextures; idx++) { - int size = CachedSurfaces[idx]->getDataSize(); - if (size < smallsize) { - // Found one. - smallsize = size; - smallidx = idx; - } - } - surface_idx = smallidx; - CachedSurfaces[idx]->release(); - CachedSurfaces[idx] = 0; - } else { - // Use next slot in array. - assert(NumCachedTextures < MAX_CACHED_SURFACES); - surface_idx = NumCachedTextures; - NumCachedTextures++; - } - assert(surface_idx >= 0); - assert(!CachedSurfaces[surface_idx]); - - CachedSurfaces[surface_idx] = surface; - surface->addReference(); -} - - -bool TextureFileCache::Validate_Texture(const char* FileName) -{ - // The functions used in here are all thread safe so this function doesn't have to be mutex guarded - - if (!Texture_Exists(FileName)) { - if (!TextureLoader::Texture_File_Exists(FileName)) { - return false; - } - // We need to load the surface from the file first to determine the real size - srColorSurfaceIFace* TempSurfacePtr = ::Load_Surface(FileName); - if (!TempSurfacePtr) return false; - - int w=TempSurfacePtr->getWidth(); - srColorSurfaceIFace::PixelFormat pf; - TempSurfacePtr->getPixelFormat(pf); - - srTextureIFace::MultiRequest mr; - for (int cnt=0;cntcopy(*TempSurfacePtr); - w>>=1; - ++cnt; - if (!w) break; - } - mr.smallLOD=cnt-1; - mr.largeLOD=0; - Save_Texture(FileName, mr, *TempSurfacePtr); - TempSurfacePtr->release(); - TempSurfacePtr=0; - for (cnt=0;cntrelease(); - } - } - return true; -} - -int TextureFileCache::Texture_Exists(const char *fname) -{ - CriticalSectionClass::LockClass m(mutex); - return(File.Does_Tag_Exist(fname)); -} - -#endif // WW3D_DX8 \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h deleted file mode 100644 index d4d4e5a6661..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texfcach.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/texfcach.h 3 3/26/01 10:45a Jani_p $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/texfcach.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 3/23/01 11:15a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef TEXTFCACH_H -#define TEXTFCACH_H - -#include "always.h" - -#include -#include - -#ifdef WW3D_DX8 - -//#include - -class FileClass; -//class srColorSurfaceIFace; - -class TextureFileCache -{ - public: - TextureFileCache(const char *fileprefix); - virtual ~TextureFileCache(); - - virtual void Reset_File(); - - // Find texture in the cache. Returns TRUE if texture found inside of cache. - int Texture_Exists(const char *fname); - - // Create the initial surface that is based off of the original texture. - // The surface is not filled in with texels since we don't convert this. - // This will also set TextureHandle up. - srColorSurfaceIFace *Load_Original_Texture_Surface(const char *texturename); - - // Given a texture that has been loaded, save it in our file cache. - bool Save_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq, srColorSurfaceIFace& origsurface); - - // Load texture data from cache into a multirequest structure. - bool Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq); - //bool TextureFileCache::Load_Texture(const char *texturename, srTextureIFace::MultiRequest& mreq); - - // Check that file is in cache, is not - load and save all mipmap levels - bool Validate_Texture(const char* texturename); - - // Load a surface from the file cache, null if does not exist. - srColorSurfaceIFace *Get_Surface(const char *texturename, unsigned int reduce_factor); - - protected: - struct FileHeader { - enum { - // Put in date when format is changed. - TCF_VERSION = 20000814, - }; - - // Will change whenever a new file version is made. - int Version; - }; - - // The file format for each texture is as follows: - // _TextureBlockHeader {...} - // int MipMap[0].Offset - // ... - // int MipMap[_TextureBlockHeader.NumMipMaps - 1].Offset - // int Offset of end of block to get size of last MipMap. - // rawdata MipMap[0] - // ... - // rawdata MipMap[_TextureBlockHeader.NumMipMaps - 1] - // End of BLock - - struct TextureBlockHeader - { - // Time data stamp of file. - unsigned long FileTime; - - // Number of mip maps in texture (including first one). - int NumMipMaps; - - // Dimensions of first mip map level saved. This is normally the same as - // Source* but can be different when certain texture creation methods are done. - int LargestWidth; - int LargestHeight; - - // Dimensions of original surface/art work. - int SourceWidth; - int SourceHeight; - - // This is the pixel format used to create the sources original surface. - srColorSurfaceIFace::PixelFormat SourcePixelFormat; - - // Pixel format that we have saved in. - srColorSurfaceIFace::PixelFormat PixelFormat; - - TextureBlockHeader():NumMipMaps(-1),SourceWidth(-1),SourceHeight(-1),LargestWidth(-1),LargestHeight(-1) {} - }; - - // Each texture has an offset into the file and it's size when uncompressed. - struct OffsetTableType - { - OffsetTableType() : Offset(0), Size (0) {} - - // Offset of texture in file. - int Offset; - - // Size (uncompressed) of texture. The size of the compressed texture - // is caclcuated by Texture_Size() below. - int Size; - }; - protected: - enum { - MAX_CACHED_SURFACES = srTextureIFace::MAX_LOD, - }; - - // Pointer to the low level file managment. TagBlockFile handles the seperation - // of the different 'texture files'. This class deals with each seperate 'texture file'. - TagBlockFile File; - - // Name of last texture loaded so we know if things need to be thrown away or not. - char *CurrentTexture; - - // Handle for current texture in cache. This is created by Open_Texture_Handle(). - TagBlockHandle *TextureHandle; - - // Header that has been loaded by Open_Texture_Handle(). - TextureBlockHeader Header; - - // The offset table is loaded into memory when the file is opened. - OffsetTableType *Offsets; - - // Cache pointers to data that has already been loaded for this texture. - srColorSurface * CachedSurfaces[MAX_CACHED_SURFACES]; - - // Number of cached textures we have. - int NumCachedTextures; - - protected: - // Buffer to compress into and decompress out of. -// static char *CompressionBuffer; -// static char *EOCompressionBuffer; - - // This keeps track of number of instances of the TextureFileCache. - // This way static variables are only freed when all instances have been deleted. -// static int Instances; - - // Access to previously cached textures so they do not have to be read off of disk. - void Add_Cached_Surface(srColorSurface *surface); - srColorSurface *Find_Cached_Surface(int size); - srColorSurface *Find_Smallest_Cached_Surface(); - - int Texture_Size(int lod) { - assert(Offsets); - assert(lod < Header.NumMipMaps); - return(Offsets[lod].Size); - } - - int Compressed_Texture_Size(int lod) { - assert(Offsets); - assert(lod < Header.NumMipMaps); - return(Offsets[lod + 1].Offset - Offsets[lod].Offset); - } - - bool Open_Texture_Handle(const char *texturename); - void Close_Texture_Handle(); - - void Read_Texture(int offsetidx, srColorSurface *surface); - srColorSurfaceIFace *Create_First_Texture_As_Surface(srColorSurfaceIFace *surftype); - - static char *_Create_File_Name(const char *fileprefix); - static char *_FileNamePtr; -}; - -#endif //WW3D_DX8 - - -#endif //TEXTFCACH_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp index 3b7be4d870b..de38599c400 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp @@ -47,7 +47,6 @@ #include "wwstring.h" #include "bufffile.h" #include "ww3d.h" -#include "texfcach.h" #include "assetmgr.h" #include "dx8wrapper.h" #include "dx8caps.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp index bcbd7034bc5..890b880c41f 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp @@ -26,7 +26,6 @@ #include "bitmaphandler.h" #include "ffactory.h" #include "RAWFILE.H" -#include "mixfile.h" #include "wwprofile.h" #include @@ -261,6 +260,7 @@ ThumbnailClass::~ThumbnailClass() void ThumbnailManagerClass::Create_Thumbnails() { +#if 0 SimpleFileFactoryClass ff; // ff.Set_Sub_Directory("Data\\"); ff.Set_Sub_Directory("..\\data\\client\\mixfiles\\"); @@ -290,6 +290,7 @@ void ThumbnailManagerClass::Create_Thumbnails() } } _TheFileFactory=old_file_factory; +#endif } void ThumbnailManagerClass::Load() diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp deleted file mode 100644 index 978be86ff3a..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include -#include -#include "pot.h" -#include "txt.h" -#include "bsurface.h" -#include "texture.h" -#include "FONT.H" -#include "nstrdup.h" - -TextTextureClass::TextTextureClass(void) : - TextureString(NULL), - Texture(NULL), - TextureSize(0), - ForegroundColor(0), - BackgroundColor(0), - Font(0), - Convert(0) -{ -} - -TextTextureClass::~TextTextureClass(void) -{ - REF_PTR_RELEASE(Texture); - - if (TextureString) { - delete[] TextureString; - } -} - -bool TextTextureClass::Is_Texture_Valid(FontClass &font, const char *str, int fore, int back, ConvertClass &conv) -{ - // if there is no texture at all then obviously it is not valid - if (!Texture) return false; - - // if all the parameters the texture was created with the last time are the same as the parameters the texture - // was created with this time then the texture is fine! - if (TextureString == str && Font == &font && Convert == &conv && ForegroundColor == fore && BackgroundColor == back) - return true; - - return false; -} - -bool TextTextureClass::Build_Texture(FontClass &font, const char *str, int fore, int back, ConvertClass &conv) -{ - static char default_font_palette[] = { - 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - - // right off determine if we need to rebuild the texture or the current texture - // is just fine. If we are rebuilding store of the properties of the texture - // we are building for next time. - if (Is_Texture_Valid(font, str, fore, back, conv)) { - return false; - } else { - if (TextureString) delete[] TextureString; - Font = &font; - TextureString = nstrdup(str); - Convert = &conv; - BackgroundColor = back; - ForegroundColor = fore; - } - - - default_font_palette[0] = back; - default_font_palette[1] = fore; - - // find the width and height of the text we want to display to the screen - // note that the width could be more than the max width of a texture - // so we must be prepared to break it down into blocks. Theoretically the - // height could be greater than the texture max but lets not be ridiculous - int fw = font.String_Pixel_Width(str)+1; - int fh = font.Get_Height()+1; - - // Note: we are currently printing the text into - // a rectangular buffer. We will later blit the text into a square buffer - // since some cards require square textures. - Rect rect(0,0,fw,fh); - BSurface bsurf(fw, fh, 1); - bsurf.Fill(0); - font.Print(str, bsurf, rect, TPoint2D(0,0), conv, (unsigned char *)default_font_palette); - - // figure out the size of the best texture which can hold the - // text we wrote. Since textures need to be assumed to be square - // the best size should be found by finding the rectangular surface - // area of the text, and creating a Power of Two sized square which - // can hold the data in the ractangular surface area. - float fsize = sqrt(fw * fh); - TextureSize = Find_POT(ceil(fsize)); - // If this is still not enough, quadruple area: - if ((TextureSize / fh) * TextureSize < fw) { - TextureSize *= 2; - } - - // we now need to create a westwood style surface out of the surrender surface - // so we can use all the westwood drawing primitives. Clear this surface to - // black (shouldn't need to do this I dont think) - BSurface bsurf2(TextureSize, TextureSize, 1); - bsurf2.Fill(0); - - // we need to calculate how many texture pot widths it takes - // to hold the width of our font. - int mw = (fw & (TextureSize - 1)) ? (fw / TextureSize)+1 : (fw /TextureSize); - - // now we need to blit the old surface into the new surface (effectively - // making the text in a square surface). - for (int lp = 0; lp < mw; lp ++) { - int blitw = MIN(fw - (TextureSize *lp), TextureSize); - int lp_tsize = lp * TextureSize; - Rect destrect(0,fh*lp,blitw,fh*lp+fh); - Rect srcrect(lp_tsize, 0, lp_tsize + blitw, fh); - /* original code - d->blit(0, fh * lp, *s, lp_tsize, 0, lp_tsize + blitw, fh); - */ - bsurf2.Blit_From(destrect,bsurf,srcrect); - } - - // Create texture without mip mapping - REF_PTR_RELEASE(Texture); - - // TODO: copy bsurf2 into texture - - return true; -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.h deleted file mode 100644 index 6f3baf7ad6c..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/txt.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef TXT_H -#define TXT_H - -class FontClass; -class ConvertClass; -class TextureClass; -class TextTextureClass { - public: - TextTextureClass(void); - ~TextTextureClass(void); - - // function to rebuild the texture with the new parameters - bool Build_Texture(FontClass &font, const char *str, int fore, int back, ConvertClass &conv); - - // returns a pointer to the texture that we created - TextureClass *Get_Texture(void) {return Texture;} - - // accessor method for the size of the texture we created - int Get_Texture_Size(void) {return TextureSize;} - private: - // function to determine if the texture needs to be rebuilt based on its parameters - bool Is_Texture_Valid(FontClass &font, const char *str, int fore, int back, ConvertClass &conv); - - // all the parameters we need to remember to deterimine if the texture is changing - // (changing any of these means the texture needs to be rebuilt) - char *TextureString; - FontClass *Font; - ConvertClass *Convert; - int ForegroundColor; - int BackgroundColor; - - // pointer to the created texture if we have created it so far - TextureClass *Texture; - - // the size of the texture we created (created textures are square) - int TextureSize; - -}; - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp index 1d8fd502c7d..c4d4cc0efaf 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp @@ -88,7 +88,6 @@ #include "predlod.h" #include "camera.h" #include "scene.h" -#include "texfcach.h" #include "registry.h" #include "segline.h" #include "shader.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/BUFF.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/BUFF.H index eef196497d6..59ac28a2606 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/BUFF.H +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/BUFF.H @@ -46,7 +46,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" /* diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt index 31695d30146..5f0fb34cd1e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/CMakeLists.txt @@ -1,69 +1,40 @@ # Set source files set(WWLIB_SRC - _convert.cpp - _mono.cpp argv.cpp b64pipe.cpp b64straw.cpp base64.cpp - blit.cpp - blowfish.cpp buff.cpp bufffile.cpp chunkio.cpp - convert.cpp cpudetect.cpp crc.cpp cstraw.cpp - data.cpp - ddraw.cpp - dsurface.cpp Except.cpp FastAllocator.cpp ffactory.cpp gcd_lcm.cpp hash.cpp - hsv.cpp ini.cpp - int.cpp jshell.cpp - keyboard.cpp LaunchWeb.cpp - lcw.cpp - load.cpp - mixfile.cpp - mono.cpp - mpmath.cpp mpu.cpp - msgloop.cpp multilist.cpp mutex.cpp nstrdup.cpp - palette.cpp - pcx.cpp pipe.cpp - pk.cpp ramfile.cpp random.cpp rawfile.cpp - rc4.cpp - rcfile.cpp readline.cpp realcrc.cpp refcount.cpp registry.cpp - rgb.cpp - rle.cpp - rndstrng.cpp - sampler.cpp - sha.cpp slnode.cpp - srandom.cpp stimer.cpp straw.cpp strtok_r.cpp systimer.cpp - tagblock.cpp TARGA.CPP textfile.cpp tgatodxt.cpp @@ -72,15 +43,11 @@ set(WWLIB_SRC vector.cpp verchk.cpp widestring.cpp - win.cpp WWCOMUtil.cpp wwfile.cpp - wwfont.cpp wwstring.cpp xpipe.cpp xstraw.cpp - xsurface.cpp - _mono.h always.h argv.h b64pipe.h @@ -88,112 +55,69 @@ set(WWLIB_SRC base64.h binheap.h bittype.h - blit.h - blitter.h - bool.h - borlandc.h bound.h BSEARCH.H - bsurface.h BUFF.H bufffile.h CallbackHook.h chunkio.h - Convert.h cpudetect.h CRC.H cstraw.h - data.h - dsurface.h FastAllocator.h ffactory.h - FONT.H gcd_lcm.h hash.h hashcalc.h HASHLIST.H hashtemplate.h - IFF.H INDEX.H INI.H inisup.h - INT.H iostruct.h - keyboard.h LaunchWeb.h - LCW.H LISTNODE.H mempool.h - mixfile.h - MONO.H - MONODRVR.H - MPMATH.H MPU.H - msgloop.h multilist.h mutex.h notifier.h nstrdup.h ntree.h - PALETTE.H - pcx.H PIPE.H - PK.H Point.h RAMFILE.H RANDOM.H RAWFILE.H - rc4.h - rcfile.h readline.h realcrc.h ref_ptr.h - refcount.h registry.h - RGB.H - RLE.H - RNDSTRAW.H - rndstrng.h - rng.h - rsacrypt.h - sampler.h - sha.h - shapeset.h sharebuf.h Signaler.h simplevec.h SLIST.H SLNODE.H - srandom.h - stl.h STRAW.H strtok_r.h - Surface.h - surfrect.h systimer.h - TagBlock.h TARGA.H textfile.h tgatodxt.h thread.h - timer.h - trackwin.h trect.h trim.h uarray.h Vector.H verchk.h visualc.h - WATCOM.H widestring.h win.h WWCOMUtil.h WWFILE.H wwstring.h - xmouse.h XPIPE.H XSTRAW.H - xsurface.h ) # Targets to build. diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Convert.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Convert.h deleted file mode 100644 index 7cdc7aa76bb..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Convert.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/Convert.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef CONVERT_H -#define CONVERT_H - -#include "blitter.h" -#include "PALETTE.H" -#include "Surface.h" - -/* -** Flags used to fetch the appropriate blitter object. -*/ -typedef enum { - SHAPE_NORMAL = 0x0000, // Standard shape (which is transparent) - - SHAPE_WIN_REL = 0x0400, - - SHAPE_CENTER = 0x0200, // Coords are based on shape's center pt - - SHAPE_DARKEN = 0x0001, // Force all pixels to darken the destination. - SHAPE_TRANSLUCENT25 = 0x0002, // Translucent to destination (25%). - SHAPE_TRANSLUCENT50 = 0x0004, // Translucent to destination (50%). - SHAPE_TRANSLUCENT75 = 0x0006, // Translucent to destination (75%). - SHAPE_PREDATOR = 0x0008, // Predator effect - SHAPE_REMAP = 0x0010, // Simple remap - SHAPE_NOTRANS = 0x0020 // A non transparent but otherwise standard shape -} ShapeFlags_Type; - - -/* -** This class is the data that represents the marriage between a source art -** palette and a destination palette/pixel-format. Facilities provied by this -** class allow conversion from the source 8 bit pixel format to the correct -** screen pixel format. -** -** Although this class can convert one pixel at a time through the conversion -** function, the preferred way to convert pixels is through the translation -** table provided. This table consists of 256 entries. Each entry is either -** an 8 bit or 16 bit pixel in the correct screen-space format. Use the -** Bytes_Per_Pixel() function to determine how to index into this translation -** table. -** -** Expected use of this class would be to create separate objects of this class for -** every source art palette. For an 8 bit display, an additional object will be -** required for every additional palette set to the video DAC registers. It is -** presumed that one general best-case palette will be used. -*/ -class ConvertClass -{ - public: - ConvertClass(PaletteClass const & artpalette, PaletteClass const & screenpalette, Surface const & typicalsurface); - ~ConvertClass(void); - - /* - ** Convert from source pixel to dest screen pixel. - */ - int Convert_Pixel(int pixel) const { - if (BBP == 1) return(((unsigned char const *)Translator)[pixel]); - return(((unsigned short const *)Translator)[pixel]); - } - - /* - ** Fetch a blitter object to use according to the draw flags - ** specified. - */ - Blitter const * Blitter_From_Flags(ShapeFlags_Type flags) const; - RLEBlitter const * RLEBlitter_From_Flags(ShapeFlags_Type flags) const; - - /* - ** This returns the bytes per pixel. Use this to determine how to index - ** through the translation table. - */ - int Bytes_Per_Pixel(void) const {return(BBP);} - - /* - ** Fetches the translation table. Sometimes the provided blitter objects - ** won't suffice and manual access to the translation process is necessary. - */ - void const * Get_Translate_Table(void) const {return(Translator);} - - /* - ** Sets the dynamic remap table so that the remapping blitters will use - ** it without having to recreate the blitter objects. - */ - void Set_Remap(unsigned char const * remap) {RemapTable = remap;} - - protected: - /* - ** Bytes per pixel in screen format. - */ - int BBP; - - /* - ** These are the blitter objects used to handle all the draw styles that this - ** drawing dispatcher implements. - */ - Blitter * PlainBlitter; // No transparency (rarely used). - Blitter * TransBlitter; // Skips transparent pixels. - Blitter * ShadowBlitter; // Shadowizes the destination pixels. - Blitter * RemapBlitter; // Remaps source pixels then draws with transparency. - Blitter * Translucent1Blitter; // 25% translucent. - Blitter * Translucent2Blitter; // 50% translucent. - Blitter * Translucent3Blitter; // 75% translucent. - - /* - ** These are the RLE aware blitters to handle all drawing styles that may - ** be used by RLE compressed images. - */ - RLEBlitter * RLETransBlitter; // Skips transparent pixels. - RLEBlitter * RLEShadowBlitter; // Shadowizes the destination pixels. - RLEBlitter * RLERemapBlitter; // Remaps source pixels then draws with transparency. - RLEBlitter * RLETranslucent1Blitter; // 25% translucent. - RLEBlitter * RLETranslucent2Blitter; // 50% translucent. - RLEBlitter * RLETranslucent3Blitter; // 75% translucent. - - /* - ** This is a translation table pointer. All source artwork is in 8 bit format. - ** This table will translate this source pixel into a screen dependant pixel - ** format datum. - */ - void * Translator; - - /* - ** This will shade an 8 bit pixel to about 1/2 intensity. - */ - unsigned char * ShadowTable; - - /* - ** Remap table pointer used for blits that require remapping. This value - ** will change according to the draw parameter. The blitting routines keep track - ** of this member object and use it to determine the remap table to use. - */ - mutable unsigned char const * RemapTable; -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/FONT.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/FONT.H deleted file mode 100644 index a6cfe58ce92..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/FONT.H +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/font.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:40p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef FONT_H -#define FONT_H - -#include "Convert.h" -#include "Point.h" -#include "trect.h" -#include - -class Surface; - -/* -** A font object represent the data that comprises the individual characters as well -** as drawing text in the font to a surface. This is an abstract base class that is to be -** derived into a concrete version. -*/ -class FontClass { - public: - virtual ~FontClass(void) {} - - virtual int Char_Pixel_Width(char c) const = 0; - virtual int String_Pixel_Width(char const * string) const = 0; - virtual int Get_Width(void) const = 0; - virtual int Get_Height(void) const = 0; - virtual Point2D Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & point, ConvertClass const & converter, unsigned char const * remap=NULL) const = 0; - - virtual int Set_XSpacing(int x) = 0; - virtual int Set_YSpacing(int y) = 0; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/IFF.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/IFF.H deleted file mode 100644 index b79fe982842..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/IFF.H +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/iff.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/23/99 1:46p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef IFF_H -#define IFF_H - -#ifndef _WINDOWS -#define __cdecl -#endif - -#include "BUFF.H" -#include - -#define LZW_SUPPORTED FALSE - -/*=========================================================================*/ -/* Iff and Load Picture system defines and enumerations */ -/*=========================================================================*/ - -#define MAKE_ID(a,b,c,d) ((long) ((long) d << 24) | ((long) c << 16) | ((long) b << 8) | (long)(a)) -#define IFFize_WORD(a) Reverse_Word(a) -#define IFFize_LONG(a) Reverse_Long(a) - - -//lint -strong(AJX,PicturePlaneType) -typedef enum { - BM_AMIGA, // Bit plane format (8K per bitplane). - BM_MCGA, // Byte per pixel format (64K). - - BM_DEFAULT=BM_MCGA // Default picture format. -} PicturePlaneType; - -/* -** This is the compression type code. This value is used in the compressed -** file header to indicate the method of compression used. Note that the -** LZW method may not be supported. -*/ -//lint -strong(AJX,CompressionType) -typedef enum { - NOCOMPRESS, // No compression (raw data). - LZW12, // LZW 12 bit codes. - LZW14, // LZW 14 bit codes. - HORIZONTAL, // Run length encoding (RLE). - LCW // Westwood proprietary compression. -} CompressionType; - -/* -** Compressed blocks of data must start with this header structure. -** Note that disk based compressed files have an additional two -** leading bytes that indicate the size of the entire file. -*/ -//lint -strong(AJX,CompHeaderType) -typedef struct { - char Method; // Compression method (CompressionType). - char pad; // Reserved pad byte (always 0). - long Size; // Size of the uncompressed data. - short Skip; // Number of bytes to skip before data. -} CompHeaderType; - - -/*=========================================================================*/ -/* The following prototypes are for the file: IFF.CPP */ -/*=========================================================================*/ - -int __cdecl Open_Iff_File(char const *filename); -void __cdecl Close_Iff_File(int fh); -unsigned long __cdecl Get_Iff_Chunk_Size(int fh, long id); -unsigned long __cdecl Read_Iff_Chunk(int fh, long id, void *buffer, unsigned long maxsize); -void __cdecl Write_Iff_Chunk(int file, long id, void *buffer, long length); - - -/*=========================================================================*/ -/* The following prototypes are for the file: LOADPICT.CPP */ -/*=========================================================================*/ - -//int __cdecl Load_Picture(char const *filename, BufferClass& scratchbuf, BufferClass& destbuf, unsigned char *palette=NULL, PicturePlaneType format=BM_DEFAULT); - - -/*=========================================================================*/ -/* The following prototypes are for the file: LOAD.CPP */ -/*=========================================================================*/ - -unsigned long __cdecl Load_Data(char const *name, void *ptr, unsigned long size); -unsigned long __cdecl Write_Data(char const *name, void *ptr, unsigned long size); -//void * __cdecl Load_Alloc_Data(char const *name, MemoryFlagType flags); -unsigned long __cdecl Load_Uncompress(char const *file, Buffer & uncomp_buff, Buffer & dest_buff, void *reserved_data=NULL); -unsigned long __cdecl Uncompress_Data(void const *src, void *dst); -void __cdecl Set_Uncomp_Buffer(int buffer_segment, int size_of_buffer); - -/*=========================================================================*/ -/* The following prototypes are for the file: WRITELBM.CPP */ -/*=========================================================================*/ - -//bool Write_LBM_File(int lbmhandle, BufferClass& buff, int bitplanes, unsigned char *palette); - - - -/*========================= Assembly Functions ============================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/*=========================================================================*/ -/* The following prototypes are for the file: PACK2PLN.ASM */ -/*=========================================================================*/ - -extern void __cdecl Pack_2_Plane(void *buffer, void * pageptr, int planebit); - -/*=========================================================================*/ -/* The following prototypes are for the file: LCWCOMP.ASM */ -/*=========================================================================*/ - -extern unsigned long __cdecl LCW_Compress(void *source, void *dest, unsigned long length); - -/*=========================================================================*/ -/* The following prototypes are for the file: LCWUNCMP.ASM */ -/*=========================================================================*/ - -extern unsigned long __cdecl LCW_Uncompress(void *source, void *dest, unsigned long length); - -#ifdef __cplusplus -} -#endif -/*=========================================================================*/ - - - -#endif //IFF_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INI.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INI.H index 8cf65efc485..a59f1d32a16 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INI.H +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INI.H @@ -52,7 +52,6 @@ //#include "straw.h" //#include "wwfile.h" -class PKey; class FileClass; class Straw; class Pipe; @@ -141,7 +140,6 @@ class INIClass { /* ** Get the various data types from the section and entry specified. */ - PKey Get_PKey(bool fast) const; bool Get_Bool(char const * section, char const * entry, bool defvalue=false) const; float Get_Float(char const * section, char const * entry, float defvalue=0.0f) const; double Get_Double(char const * section, char const * entry, double defvalue=0.0) const; @@ -173,7 +171,6 @@ class INIClass { bool Put_Double(char const * section, char const * entry, double number); bool Put_Hex(char const * section, char const * entry, int number); bool Put_Int(char const * section, char const * entry, int number, int format=0); - bool Put_PKey(PKey const & key); bool Put_String(char const * section, char const * entry, char const * string); bool Put_TextBlock(char const * section, char const * text); bool Put_UUBlock(char const * section, void const * block, int len); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INT.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INT.H deleted file mode 100644 index fd78980b65b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/INT.H +++ /dev/null @@ -1,310 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/int.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef INT_H -#define INT_H - -#include "MPMATH.H" -#include "STRAW.H" -#include -#include -#include - -#ifdef __BORLANDC__ -#pragma warn -inl -#endif - -template struct RemainderTable; -template T Gcd(const T & a, const T & n); -#ifdef _UNIX - #define FN_TEMPLATE <> -#else - #define FN_TEMPLATE -#endif - - -template -class Int { - public: - - /* - ** Constructors and initializers. - */ - Int(void) {XMP_Init(®[0], 0, PRECISION);} - Int(unsigned long value) {XMP_Init(®[0], value, PRECISION);} - - void Randomize(Straw & rng, int bitcount) {XMP_Randomize(®[0], rng, bitcount, PRECISION);} - void Randomize(Straw & rng, const Int & minval, const Int & maxval) {XMP_Randomize_Bounded(®[0], rng, minval, maxval, PRECISION); reg[0] |= 1;} - - /* - ** Convenient conversion operators to get at the underlying array of - ** integers. Big number math is basically manipulation of arbitrary - ** length arrays. - */ - operator digit * () {return & reg[0];} - operator const digit * () const {return & reg[0];} - - /* - ** Array access operator (references bit position). Bit 0 is the first bit. - */ - bool operator[](unsigned bit) const {return(XMP_Test_Bit(®[0], bit));} - - /* - ** Unary operators. - */ - Int & operator ++ (void) {XMP_Inc(®[0], PRECISION);return(*this);} - Int & operator -- (void) {XMP_Dec(®[0], PRECISION);return(*this);} - int operator ! (void) const {return(XMP_Test_Eq_Int(®[0], 0, PRECISION));} - Int operator ~ (void) {XMP_Not(®[0], PRECISION);return(*this);} - Int operator - (void) const {Int a = *this;a.Negate();return (a);} - - /* - ** Attribute query functions. - */ - int ByteCount(void) const {return(XMP_Count_Bytes(®[0], PRECISION));} - int BitCount(void) const {return(XMP_Count_Bits(®[0], PRECISION));} - bool Is_Negative(void) const {return(XMP_Is_Negative(®[0], PRECISION));} - unsigned MaxBitPrecision() const {return PRECISION*(sizeof(unsigned long)*CHAR_BIT);} - bool IsSmallPrime(void) const {return(XMP_Is_Small_Prime(®[0], PRECISION));} - bool SmallDivisorsTest(void) const {return(XMP_Small_Divisors_Test(®[0], PRECISION));} - bool FermatTest(unsigned rounds) const {return(XMP_Fermat_Test(®[0], rounds, PRECISION));} - bool IsPrime(void) const {return(XMP_Is_Prime(®[0], PRECISION));} - bool RabinMillerTest(Straw & rng, unsigned int rounds) const {return(XMP_Rabin_Miller_Test(rng, ®[0], rounds, PRECISION));} - - /* - ** 'in-place' binary operators. - */ - Int & operator += (const Int & number) {Carry = XMP_Add(®[0], ®[0], number, 0, PRECISION);return(*this);} - Int & operator -= (const Int & number) {Borrow = XMP_Sub(®[0], ®[0], number, 0, PRECISION);return(*this);} - Int & operator *= (const Int & multiplier) {Remainder = *this;Error=XMP_Signed_Mult(®[0], Remainder, multiplier, PRECISION);return(*this);} - Int & operator /= (const Int & t) {*this = (*this) / t;return *this;} - Int & operator %= (const Int & t) {*this = (*this) % t;return *this;} - Int & operator <<= (int bits) {XMP_Shift_Left_Bits(®[0], bits, PRECISION);return *this;} - Int & operator >>= (int bits) {XMP_Shift_Right_Bits(®[0], bits, PRECISION);return *this;} - - /* - ** Mathematical binary operators. - */ - Int operator + (const Int & number) const {Int term;Carry = XMP_Add(term, ®[0], number, 0, PRECISION);return(term);} - Int operator + (unsigned short b) const {Int result;Carry=XMP_Add_Int(result, ®[0], b, 0, PRECISION);return(result);} - Int operator - (const Int & number) const {Int term;Borrow = XMP_Sub(term, ®[0], number, 0, PRECISION);return(term);} - Int operator - (unsigned short b) const {Int result;Borrow = XMP_Sub_Int(result, ®[0], b, 0, PRECISION);return(result);} - Int operator * (const Int & multiplier) const {Int result;Error=XMP_Signed_Mult(result, ®[0], multiplier, PRECISION);return result;} - Int operator * (unsigned short b) const {Int result;Error=XMP_Unsigned_Mult_Int(result, ®[0], b, PRECISION);return(result);} - Int operator / (const Int & divisor) const {Int quotient = *this;XMP_Signed_Div(Remainder, quotient, ®[0], divisor, PRECISION);return (quotient);} - Int operator / (unsigned long b) const {return(*this / Int(b));} - Int operator / (unsigned short divisor) const {Int quotient;Error=XMP_Unsigned_Div_Int(quotient, ®[0], divisor, PRECISION);return(quotient);} - Int operator % (const Int & divisor) const {Int remainder;XMP_Signed_Div(remainder, Remainder, ®[0], divisor, PRECISION);return(remainder);} - Int operator % (unsigned long b) const {return(*this % Int(b));} - unsigned short operator % (unsigned short divisor) const {return(XMP_Unsigned_Div_Int(Remainder, ®[0], divisor, PRECISION));} - - /* - ** Bitwise binary operators. - */ - Int operator >> (int bits) const {Int result = *this; XMP_Shift_Right_Bits(result, bits, PRECISION);return result;} - Int operator << (int bits) const {Int result = *this; XMP_Shift_Left_Bits(result, bits, PRECISION);return result;} - - /* - ** Comparison binary operators. - */ - int operator == (const Int &b) const {return (memcmp(®[0], &b.reg[0], (MAX_BIT_PRECISION/CHAR_BIT))==0);} - int operator != (const Int& b) const {return !(*this == b);} - int operator > (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) > 0);} - int operator >= (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) >= 0);} - int operator < (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) < 0);} - int operator <= (const Int & number) const {return(XMP_Compare(®[0], number, PRECISION) <= 0);} - - /* - ** Misc. mathematical and logical functions. - */ - void Negate(void) {XMP_Neg(®[0], PRECISION);} - Int Abs(void) {XMP_Abs(®[0], PRECISION);return(*this);} - - Int exp_b_mod_c(const Int & e, const Int & m) const { - Int result; - Error=XMP_Exponent_Mod(result, ®[0], e, m, PRECISION); - return result; - } - - void Set_Bit(int index) { XMP_Set_Bit(®[0], index); } - static Int Unsigned_Mult(Int const & multiplicand, Int const & multiplier) {Int product;Error=XMP_Unsigned_Mult(&product.reg[0], &multiplicand.reg[0], &multiplier.reg[0], PRECISION);return(product);} - static void Unsigned_Divide(Int & remainder, Int & quotient, const Int & dividend, const Int & divisor) {Error=XMP_Unsigned_Div(remainder, quotient, dividend, divisor, PRECISION);} - static void Signed_Divide(Int & remainder, Int & quotient, const Int & dividend, const Int & divisor) {XMP_Signed_Div(remainder, quotient, dividend, divisor, PRECISION);} - Int Inverse(const Int & modulus) const {Int result;XMP_Inverse_A_Mod_B(result, ®[0], modulus, PRECISION);return(result);} - - static Int Decode_ASCII(char const * string) {Int result;XMP_Decode_ASCII(string, result, PRECISION);return(result);} - - // Number (sign independand) inserted into buffer. - int Encode(unsigned char *output) const {return(XMP_Encode(output, ®[0], PRECISION));} - int Encode(unsigned char * output, unsigned length) const {return(XMP_Encode_Bounded(output, length, ®[0], PRECISION));} - void Signed_Decode(const unsigned char * from, int frombytes) {XMP_Signed_Decode(®[0], from, frombytes, PRECISION);} - void Unsigned_Decode(const unsigned char * from, int frombytes) {XMP_Unsigned_Decode(®[0], from, frombytes, PRECISION);} - - // encode Int using Distinguished Encoding Rules, returns size of output - int DEREncode(unsigned char * output) const {return(XMP_DER_Encode(®[0], output, PRECISION));} - void DERDecode(const unsigned char *input) {XMP_DER_Decode(®[0], input, PRECISION);} - - // Friend helper functions. - friend Int Gcd FN_TEMPLATE (const Int &, const Int &); - - - static int Error; - - // Carry result from last addition. - static bool Carry; - - // Borrow result from last subtraction. - static bool Borrow; - - // Remainder value from the various division routines. - static Int Remainder; - - digit reg[PRECISION]; - - friend struct RemainderTable< Int >; -}; - -template -struct RemainderTable -{ - RemainderTable(const T & p) : HasZeroEntry(false) - { - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - for (int i = 0; i < primesize; i++) { - table[i] = p % primetable[i]; - } - } - bool HasZero() const {return(HasZeroEntry);} - void Increment(unsigned short increment = 1) - { - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - HasZeroEntry = false; - for (int i = 0; i < primesize; i++) { - table[i] += increment; - while (table[i] >= primetable[i]) { - table[i] -= primetable[i]; - } - HasZeroEntry = (HasZeroEntry || !table[i]); - } - } - void Increment(const RemainderTable & rtQ) - { - HasZeroEntry = false; - int primesize = XMP_Fetch_Prime_Size(); - unsigned short const * primetable = XMP_Fetch_Prime_Table(); - for (int i = 0; i < primesize; i++) { - table[i] += rtQ.table[i]; - if (table[i] >= primetable[i]) { - table[i] -= primetable[i]; - } - HasZeroEntry = (HasZeroEntry || !table[i]); - } - } - bool HasZeroEntry; - unsigned short table[3511]; -}; - - - -template -T Gcd(const T & a, const T & n) -{ - T g[3]={n, a, 0UL}; - - unsigned int i = 1; - while (!!g[i%3]) { - g[(i+1)%3] = g[(i-1)%3] % g[i%3]; - i++; - } - return g[(i-1)%3]; -} - - - -#if defined(__WATCOMC__) -#pragma warning 604 9 -#pragma warning 595 9 -#endif - - -template -T Generate_Prime(Straw & rng, int pbits, T const *) -{ - T minQ = (T(1UL) << (unsigned short)(pbits-(unsigned short)2)); - T maxQ = ((T(1UL) << (unsigned short)(pbits-(unsigned short)1)) - (unsigned short)1); - - T q; - T p; - - do { - q.Randomize(rng, minQ, maxQ); - p = (q*2) + (unsigned short)1; - - RemainderTable rtQ(q); - RemainderTable rtP(p); - - while (rtQ.HasZero() || rtP.HasZero() || !q.IsPrime() || !p.IsPrime()) { - q += 2; - p += 4; - if (q > maxQ) break; - - rtQ.Increment(2); - rtP.Increment(4); - } - } while (q > maxQ); - - return(p); -} - - - - -#define UNITSIZE 32 -#define MAX_BIT_PRECISION 2048 -#define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) - - -typedef Int bignum; -typedef Int BigInt; - - -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/LCW.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/LCW.H deleted file mode 100644 index 6e8b5315f11..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/LCW.H +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/lcw.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef LCW_H -#define LCW_H - -#ifdef _UNIX -#include "osdep.h" -#endif - -int LCW_Uncomp(void const * source, void * dest, unsigned long length=0); - -#ifdef _MSC_VER -int LCW_Comp(void const * source, void * dest, int length); -#else -extern "C" { -int __cdecl LCW_Comp(void const * source, void * dest, int length); -} -#endif - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONO.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONO.H deleted file mode 100644 index e83e64e9a47..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONO.H +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/mono.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:36p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MONO_H -#define MONO_H - -#include "win.h" - -class MonoClass { - public: - typedef enum MonoAttribute { - INVISIBLE=0x00, // Black on black. - UNDERLINE=0x01, // Underline. - BLINKING=0x90, // Blinking white on black. - NORMAL=0x02, // White on black. - INVERSE=0x70 // Black on white. - } MonoAttribute; - - MonoClass(void); - ~MonoClass(void); - - static void Enable(void) {Enabled = true;}; - static void Disable(void) {Enabled = false;}; - static bool Is_Enabled(void) {return Enabled;}; - - void Sub_Window(int x=0, int y=0, int w=80, int h=25); - void Fill_Attrib(int x, int y, int w, int h, MonoAttribute attrib); - void Clear(void); - void Set_Cursor(int x, int y); - void Print(char const *text); - void Print(int text); - void Printf(char const *text, ...); - void Printf(int text, ...); - void Text_Print(char const *text, int x, int y, MonoAttribute attrib=NORMAL); - void Text_Print(int text, int x, int y, MonoAttribute attrib=NORMAL); - void View(void); - void Scroll(int lines=1); - void Pan(int cols=1); - void Set_Default_Attribute(MonoAttribute attrib); - - /* - ** This merely makes a duplicate of the mono object into a newly created mono - ** object. - */ - MonoClass (MonoClass const &); - - static MonoClass * Current; - - private: - - /* - ** Handle of the mono page. - */ - HANDLE Handle; - - /* - ** If this is true, then monochrome output is allowed. It defaults to false - ** so that monochrome output must be explicitly enabled. - */ - static bool Enabled; - - MonoClass & operator = (MonoClass const & ); -}; - - -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H deleted file mode 100644 index b2c1dda0cae..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MONODRVR.H +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/monodrvr.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifdef _MSC_VER -#pragma warning (push,3) -#endif - -#ifdef _WINDOWS -#include -#endif - -#ifdef _MSC_VER -#pragma warning (pop) -#endif - - -/* -** This is the identifier for the Monochrome Display Driver. -*/ -#define FILE_DEVICE_MONO 0x00008000 - -/* -** These are the IOCTL commands supported by the Monochrome Display Driver. -*/ -#define IOCTL_MONO_HELP_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x800, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_CLEAR_SCREEN CTL_CODE(FILE_DEVICE_MONO, 0x801, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_PRINT_RAW CTL_CODE(FILE_DEVICE_MONO, 0x802, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_CURSOR CTL_CODE(FILE_DEVICE_MONO, 0x803, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SCROLL CTL_CODE(FILE_DEVICE_MONO, 0x804, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_BRING_TO_TOP CTL_CODE(FILE_DEVICE_MONO, 0x805, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_ATTRIBUTE CTL_CODE(FILE_DEVICE_MONO, 0x806, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_PAN CTL_CODE(FILE_DEVICE_MONO, 0x807, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_LOCK CTL_CODE(FILE_DEVICE_MONO, 0x808, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_UNLOCK CTL_CODE(FILE_DEVICE_MONO, 0x809, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80A, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_RESET_WINDOW CTL_CODE(FILE_DEVICE_MONO, 0x80B, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_SET_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80C, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_CLEAR_FLAG CTL_CODE(FILE_DEVICE_MONO, 0x80D, METHOD_BUFFERED, FILE_WRITE_DATA) -#define IOCTL_MONO_FILL_ATTRIB CTL_CODE(FILE_DEVICE_MONO, 0x80E, METHOD_BUFFERED, FILE_WRITE_DATA) - -/* -** These specify the various behavior flags available for the mono display driver. They -** default to being OFF (or FALSE). -*/ -typedef enum MonoFlagType -{ - MONOFLAG_WRAP, // Text will wrap to the next line when right margin is reached. - - MONOFLAG_COUNT // Used to indicate the number of mono flags available. -} MonoFlagType; - - -/* - Here is a "C" example of how to use the Monochrome Display Driver. - - -int main(int argc, char *argv[]) -{ - HANDLE handle; - - handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle != INVALID_HANDLE_VALUE) { - long retval; // Return code from IoControl functions. - unsigned short * pointer; // Working pointer to mono RAM. - union { - int X,Y; - } cursor; // Cursor positioning parameter info. - - // Prints a line of text to the screen [length of string is 13]. - WriteFile(handle, "Test Message\n", 13, &retval, NULL); - - // Fetches a pointer to the mono memory. - DeviceIoControl(handle, (DWORD)IOCTL_MONO_LOCK, NULL, 0, &pointer, sizeof(pointer), &retval, 0); - if (pointer != NULL) { - *pointer = 0x0721; // '!' character appears in upper left corner (attribute 0x07). - } - DeviceIoControl(handle, (DWORD)IOCTL_MONO_UNLOCK, NULL, 0, NULL, 0, &retval, 0); - - // Set cursor to column 5, row 10. - cursor.X = 5; - cursor.Y = 10; - DeviceIoControl(handle, (DWORD)IOCTL_MONO_SET_CURSOR, &cursor, sizeof(cursor), NULL, 0, &retval, 0); - - // Clear the screen. - DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &retval, 0); - - CloseHandle(handle); - } - - return 0; -} - -*/ - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H deleted file mode 100644 index 97f29a75ed2..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/MPMATH.H +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/mpmath.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MPMATH_H -#define MPMATH_H - -#include "bool.h" - -//lint -e740 -e534 -e537 -e760 -//lint -d_LINT=1 - - -#include "STRAW.H" -#include - -#define UNITSIZE 32 -#define MAX_BIT_PRECISION 2048 -#define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) -#define signeddigit signed long -#define LOG_UNITSIZE 5 - -//#define digit unsigned long -typedef unsigned long digit; - -#define MPEXPORT - -#ifdef _MSC_VER -#pragma warning( disable : 4236) -#endif - -extern "C" { -extern int MPEXPORT XMP_Fetch_Prime_Size(void); -unsigned short const * MPEXPORT XMP_Fetch_Prime_Table(void); -int MPEXPORT XMP_Significance(const digit * r, int precision); -void MPEXPORT XMP_Inc(digit * r, int precision); -void MPEXPORT XMP_Dec(digit * r, int precision); -void MPEXPORT XMP_Neg(digit * r, int precision); -void MPEXPORT XMP_Abs(digit * r, int precision); -void MPEXPORT XMP_Shift_Right_Bits(digit * r1, int bits, int precision); -void MPEXPORT XMP_Shift_Left_Bits(digit * r1, int bits, int precision); -bool MPEXPORT XMP_Rotate_Left(digit * r1, bool carry, int precision); -void MPEXPORT XMP_Not(digit * digit_ptr, int precision); -int MPEXPORT XMP_Prepare_Modulus(const digit * n_modulus, int precision); -void MPEXPORT XMP_Init(digit * r, digit value, int precision); -unsigned MPEXPORT XMP_Count_Bits(const digit * r, int precision); -int MPEXPORT XMP_Count_Bytes(const digit * r, int precision); -void MPEXPORT XMP_Move(digit * dest, digit const * source, int precision); -int MPEXPORT XMP_Digits_To_Bits(int digits); -int MPEXPORT XMP_Compare(const digit * r1, const digit * r2, int precision); -int MPEXPORT XMP_Bits_To_Digits(int bits); -bool MPEXPORT XMP_Add(digit * result, const digit * r1, const digit * r2, bool carry, int precision); -bool MPEXPORT XMP_Add_Int(digit * result, const digit * r1, digit r2, bool carry, int precision); -bool MPEXPORT XMP_Test_Bit(const digit * r, unsigned bit); -void MPEXPORT XMP_Set_Bit(digit * r, unsigned bit); -digit MPEXPORT XMP_Bits_To_Mask(int bits); -bool MPEXPORT XMP_Is_Negative(const digit * r, int precision); -bool MPEXPORT XMP_Test_Eq_Int(digit const * r, int i, int p); -bool MPEXPORT XMP_Sub(digit * result, const digit * r1, const digit * r2, bool borrow, int precision); -bool MPEXPORT XMP_Sub_Int(digit * result, const digit * r1, unsigned short r2, bool borrow, int precision); -int MPEXPORT XMP_Unsigned_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -int MPEXPORT XMP_Unsigned_Mult_Int(digit * prod, const digit * multiplicand, short multiplier, int precision); -int MPEXPORT XMP_Signed_Mult_Int(digit * prod, const digit * multiplicand, signed short multiplier, int precision); -int MPEXPORT XMP_Signed_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -unsigned short MPEXPORT XMP_Unsigned_Div_Int(digit * quotient, digit const * dividend, unsigned short divisor, int precision); -int MPEXPORT XMP_Unsigned_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision); -void MPEXPORT XMP_Signed_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision); -int MPEXPORT XMP_Reciprocal(digit * quotient, const digit * divisor, int precision); -void MPEXPORT XMP_Decode_ASCII(char const * str, digit * mpn, int precision); -//void MPEXPORT xmp_single_mul(unsigned short * prod, unsigned short * multiplicand, unsigned short multiplier, int precision); -void MPEXPORT XMP_Double_Mul(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -//int MPEXPORT xmp_stage_modulus(const digit * n_modulus, int precision); -int MPEXPORT XMP_Mod_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision); -void MPEXPORT XMP_Mod_Mult_Clear(int precision); -int MPEXPORT XMP_Exponent_Mod(digit * expout, const digit * expin, const digit * exponent_ptr, const digit * modulus, int precision); -bool MPEXPORT XMP_Is_Small_Prime(const digit * candidate, int precision); -bool MPEXPORT XMP_Small_Divisors_Test(const digit * candidate, int precision); -bool MPEXPORT XMP_Fermat_Test(const digit * candidate_prime, unsigned rounds, int precision); -void MPEXPORT XMP_Inverse_A_Mod_B(digit * result, digit const * number, digit const * modulus, int precision); -void MPEXPORT XMP_Signed_Decode(digit * result, const unsigned char * from, int frombytes, int precision); -void MPEXPORT XMP_Unsigned_Decode(digit * result, const unsigned char * from, int frombytes, int precision); -unsigned MPEXPORT XMP_Encode(unsigned char * to, digit const * from, int precision); -unsigned MPEXPORT XMP_Encode_Bounded(unsigned char * to, unsigned tobytes, digit const * from, int precision); -void MPEXPORT XMP_Randomize(digit * result, Straw & rng, int nbits, int precision); -void MPEXPORT XMP_Randomize_Bounded(digit * result, Straw & rng, digit const * min, digit const * max, int precision); -bool MPEXPORT XMP_Is_Prime(digit const * prime, int precision); -bool MPEXPORT XMP_Rabin_Miller_Test(Straw & rng, digit const * w, int rounds, int precision); -int MPEXPORT XMP_DER_Length_Encode(unsigned long length, unsigned char * output); -int MPEXPORT XMP_DER_Encode(digit const * from, unsigned char * output, int precision); -void MPEXPORT XMP_DER_Decode(digit * result, unsigned char const * input, int precision); -} - - -inline int MPEXPORT XMP_Digits_To_Bits(int digits) -{ - return(digits << LOG_UNITSIZE); -} - - -inline int MPEXPORT XMP_Bits_To_Digits(int bits) -{ - return ((bits + (UNITSIZE-1)) / UNITSIZE); -} - - -inline digit MPEXPORT XMP_Bits_To_Mask(int bits) -{ - if (!bits) return(0); - return(1 << ((bits-1) % UNITSIZE)); -} - - -inline bool MPEXPORT XMP_Is_Negative(const digit * r, int precision) -{ - return((signeddigit) *(r + (precision-1)) < 0); -} - - -inline void MPEXPORT XMP_Set_Bit(digit * r, unsigned bit) -{ - r[bit >> LOG_UNITSIZE] |= ((digit)1 << (bit & (UNITSIZE-1))); -} - -inline bool MPEXPORT XMP_Test_Bit(const digit * r, unsigned bit) -{ - return ((r[bit >> LOG_UNITSIZE] & ((digit)1 << (bit & (UNITSIZE-1)))) != 0); -} - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H deleted file mode 100644 index f80c3574942..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PALETTE.H +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/PALETTE.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef PALETTE_H -#define PALETTE_H - -#include "RGB.H" - -/* -** The palette class is used to manipulate a palette as a whole. All 256 colors are -** represented by the palette class object. -*/ -class PaletteClass -{ - public: - enum { - COLOR_COUNT=256 // Number of color indices on the palette. - }; - - PaletteClass(void) {}; - PaletteClass(RGBClass const & rgb); - PaletteClass(unsigned char *binary_palette); - - RGBClass & operator[] (int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & operator[] (int index) const {return(Palette[index % COLOR_COUNT]);}; - RGBClass & Get_Color(int index) {return(Palette[index % COLOR_COUNT]);}; - RGBClass const & Get_Color(int index) const {return(Palette[index % COLOR_COUNT]);}; - int operator == (PaletteClass const & palette) const; - int operator != (PaletteClass const & palette) const {return(!(operator ==(palette)));}; - PaletteClass & operator = (PaletteClass const & palette); - operator const unsigned char * (void) const {return((const unsigned char *)&Palette[0]);}; - operator unsigned char * (void) {return((unsigned char *)&Palette[0]);}; - - void Adjust(int ratio); - void Adjust(int ratio, PaletteClass const & palette); - void Partial_Adjust(int ratio, char *lut); - void Partial_Adjust(int ratio, PaletteClass const & palette, char *lut); - int Closest_Color(RGBClass const & rgb) const; - - protected: - RGBClass Palette[COLOR_COUNT]; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PK.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PK.H deleted file mode 100644 index b50be81b48f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/PK.H +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/PK.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef PK_H -#define PK_H - -#ifndef STRAW_H -#include "STRAW.H" -#endif - -#include "INT.H" - -/* -** This class holds a public or private key used in Public Key Cryptography. It also serves -** as the conduit for encrypting/decrypting data using that key. Cryptography, using this -** method, has a couple of characteristics that affect how it is used. One, the process of -** encrypting/decrypting is very slow. This limits the effective quantity of data that can -** be processed. Two, the ciphertext is larger than the plaintext. This property generally -** limits its use to streaming data as opposed to random access data. The data is processed -** in blocks. The size of the ciphertext and plaintext blocks can be determined only from -** the key itself. -** -** A reasonable use of this technology would be to encrypt only critical data such as the -** password for a fast general purpose cryptographic algorithm. -*/ -class PKey -{ - public: - PKey(void) : Modulus(0), Exponent(0), BitPrecision(0) {} - PKey(void const * exponent, void const * modulus); // DER initialization. - - int Encrypt(void const * source, int slen, void * dest) const; - int Decrypt(void const * source, int slen, void * dest) const; - - static void Generate(Straw & random, int bits, PKey & fastkey, PKey & slowkey); - - int Plain_Block_Size(void) const {return((BitPrecision-1)/8);} - int Crypt_Block_Size(void) const {return(Plain_Block_Size()+1);} - int Block_Count(int plaintext_length) const {return((((plaintext_length-1)/Plain_Block_Size())+1));} - - int Encode_Modulus(void * buffer) const; - int Encode_Exponent(void * buffer) const; - - void Decode_Modulus(void * buffer); - void Decode_Exponent(void * buffer); - - static long Fast_Exponent(void) {return(65537L);} - -// private: - - // p*q - BigInt Modulus; - - // 65537 or - // inverse of (p-1)(q-1). - BigInt Exponent; - - // Maximum bits allowed for block. - int BitPrecision; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RGB.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RGB.H deleted file mode 100644 index b1c19a1e76c..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RGB.H +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/RGB.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RGB_H -#define RGB_H - -class PaletteClass; -class HSVClass; - - -/* -** Each color entry is represented by this class. It holds the values for the color -** guns. The gun values are recorded in device dependant format, but the interface -** uses gun values from 0 to 255. -*/ -class RGBClass -{ - public: - RGBClass(void) : Red(0), Green(0), Blue(0) {} - RGBClass(unsigned char red, unsigned char green, unsigned char blue) : Red(red), Green(green), Blue(blue) {} - operator HSVClass (void) const; - RGBClass & operator = (RGBClass const & rgb) { - if (this == &rgb) return(*this); - - Red = rgb.Red; - Green = rgb.Green; - Blue = rgb.Blue; - return(*this); - } - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, RGBClass const & rgb); - int Difference(RGBClass const & rgb) const; - int Get_Red(void) const {return (Red);} - int Get_Green(void) const {return(Green);} - int Get_Blue(void) const {return(Blue);} - void Set_Red(unsigned char value) {Red = value;} - void Set_Green(unsigned char value) {Green = value;} - void Set_Blue(unsigned char value) {Blue = value;} - - private: - - friend class PaletteClass; - - /* - ** These hold the actual color gun values in machine independant scale. This - ** means the values range from 0 to 255. - */ - unsigned char Red; - unsigned char Green; - unsigned char Blue; -}; - -extern RGBClass const BlackColor; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RLE.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RLE.H deleted file mode 100644 index 5ec81699f01..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RLE.H +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RLE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RLE_H -#define RLE_H - -/* -** This class will RLE compress and decompress arbitrary blocks of data. This RLE compression -** is geared to compressing only runs of 0 bytes. This makes it useful for sprite encoding. -*/ -class RLEEngine -{ - public: - - /* - ** Codec for arbitrary blocks. - */ - int Compress(void const * source, void * dest, int length) const; - int Decompress(void const * source, void * dest, int length) const; - - /* - ** Codec for length encoded blocks. This is useful for sprite storage. - */ - int Line_Compress(void const * source, void * dest, int length) const; - int Line_Decompress(void const * source, void * dest) const; -}; - -#endif - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H deleted file mode 100644 index 6e137890ce0..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/RNDSTRAW.H +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/RNDSTRAW.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNDSTRAW_H -#define RNDSTRAW_H - - -#include "RANDOM.H" -#include "STRAW.H" - -/* -** This is a straw terminator class. It will generate random numbers to fill the data request. -** Unlike regular straw terminators, this class will never run out of "data". -*/ -class RandomStraw : public Straw -{ - public: - RandomStraw(void); - virtual ~RandomStraw(void); - - virtual int Get(void * source, int slen); - - void Reset(void); - void Seed_Bit(int seed); - void Seed_Byte(char seed); - void Seed_Short(short seed); - void Seed_Long(long seed); - - int Seed_Bits_Needed(void) const; - - private: - /* - ** Counter of the number of seed bits stored to this random number - ** generator. - */ - int SeedBits; - - /* - ** The current random generator to use when fetching the next random - ** byte of data. - */ - int Current; - - /* - ** Array of generators. There must be at least 448 bits of random number seed - ** in order to be reasonably secure, however, using 1024 bits would be best. - */ - Random3Class Random[32]; - - void Scramble_Seed(void); - - RandomStraw(RandomStraw & rvalue); - RandomStraw & operator = (RandomStraw const & pipe); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Surface.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Surface.h deleted file mode 100644 index 4ff989c2191..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Surface.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/surface.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:40p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef SURFACE_H -#define SURFACE_H - -#include "Point.h" -#include "trect.h" - -/* -** This is an abstract interface class for a graphic surface. Graphic operations will use this -** interface to perform their function. The philosphy behind this interface is that it represents -** a small but useful set of functions. Emphasis is placed on supporting those functions which are -** likely to have hardware assist. -*/ -class Surface -{ - public: - Surface(int width, int height) : Width(width), Height(height) {} - virtual ~Surface(void) {}; - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false) = 0; - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false) = 0; - virtual bool Blit_From(Surface const & source, bool trans=false) = 0; - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color) = 0; - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) = 0; - virtual bool Fill(int color) = 0; - - /* - ** Fetches and stores a pixel to the display (pixel is in surface format). - */ - virtual bool Put_Pixel(Point2D const & point, int color) = 0; - virtual int Get_Pixel(Point2D const & point) const = 0; - - /* - ** Draws lines onto the surface. - */ - virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color) = 0; - virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color) = 0; - - /* - ** Draws rectangle onto the surface. - */ - virtual bool Draw_Rect(Rect const & rect, int color) = 0; - virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color) = 0; - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const = 0; - virtual bool Unlock(void) const = 0; - virtual bool Is_Locked(void) const = 0; - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const = 0; - virtual int Stride(void) const = 0; - virtual Rect Get_Rect(void) const {return(Rect(0, 0, Width, Height));} - virtual int Get_Width(void) const {return(Width);} - virtual int Get_Height(void) const {return(Height);} - - /* - ** Hack function to serve the purpose that RTTI was invented for, but since - ** the Watcom compiler doesn't support RTTI, we must resort to using this - ** alternative. - */ - virtual bool Is_Direct_Draw(void) const {return(false);} - - protected: - - /* - ** Records logical pixel dimensions of the surface. - */ - int Width; - int Height; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h deleted file mode 100644 index fb4773b55b8..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/TagBlock.h +++ /dev/null @@ -1,278 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /VSS_Sync/wwlib/tagblock.h 6 10/17/00 4:48p Vss_sync $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWLib * - * * - * $Archive:: /VSS_Sync/wwlib/tagblock.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef TAGBLOCK_H -#define TAGBLOCK_H - -#include "SLIST.H" -#include "CRC.H" -#include "RAWFILE.H" - -#include - -class TagBlockHandle; -class TagBlockIndex; - - ////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////// Start of TagBlockHandle/////////////////////////////////////// -// TagBlockFile: Enables a file to have named (tagged) variable size blocks. User can -// then open a block for reading. User may also create new blocks at the end of the -// file. There may only be one block open for writting, unlimited blocks can be open for -// reading. It can be thought of as a .MIX file that can have files added to it at any time. -// One problem is it is a Write Once/Read Many solution. -// -// Usage: All user access to a TagBlockFile is done through TagBlockHandle. -// A TagBlockHandle is created by TagBlockFile::Create_Tag() or Open_Tag(). It is destroyed -// by either TagBlockFile::Close_Tag() or you can just destroy the handle with delete(). -// -// - -class TagBlockFile : protected RawFileClass -{ - public: - ////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Public Member Functions /////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - - // Open up the tag file. It may or may not exist. - TagBlockFile(const char *fname); - virtual ~TagBlockFile(); - - // DANGEROUS!! Resets entire file and makes small - virtual void Reset_File(); - - // Creation of a Handle so block can be crated/writen/read. - // Use delete to destroy handle or use Close_Tag(). - // Open_Tag() returns NULL if tag not found. - // Create_Tag() returns NULL if tag already exists. - TagBlockHandle *Open_Tag(const char *tagname); - TagBlockHandle *Create_Tag(const char *tagname); - void Close_Tag(TagBlockHandle *handle); - - int Does_Tag_Exist(const char *tagname) { - return(Find_Block(tagname) != NULL); - } - - virtual unsigned long Get_Date_Time(void) { - return(FileTime); - } - - // Methods to figure an offset of the tag name and the data - // given the offset of the start of the block (BlockHeader).. - static int Calc_Tag_Offset(int blockoffset) { - return(blockoffset + sizeof(BlockHeader)); - } - static int Calc_Data_Offset(int blockoffset, const char *tagname) { - return(Calc_Tag_Offset(blockoffset) + strlen(tagname) + 1); - - } - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Supporting Structures ///////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - enum { - // Put in date when format is changed. - FILE_VERSION = 20000626, - MAX_TAG_NAME_SIZE = 1024, - }; - - // This is the header that is in both the IndexFile and the DataFile. - // They should be match except for the difference in the Version number as defined by enum. - struct FileHeader - { - FileHeader() {memset(this, 0, sizeof(*this));} - - // Version number to make sure that it we are compatable and also to - // verify that this is the file we think it is. - unsigned Version; - - // Number of blocks in file. - int NumBlocks; - - // This is how much data is actually valid in the file. There may be - // extra room at end of file if file size is preset or the file is corrupt. - int FileSize; - }; - - // Each block in the file has a header before it. - struct BlockHeader - { - BlockHeader() {memset(this, 0, sizeof(*this));} - BlockHeader(int index, int tagsize, int datasize):Index(index),TagSize(tagsize),DataSize(datasize) {} - BlockHeader(BlockHeader& bh) {memcpy(this, &bh, sizeof(BlockHeader));} - - // Used to verify file integrity. - int Index; - - // Size of tagname (including NULL) that follows this block. - int TagSize; - - // Size of block not including header. - int DataSize; - - // A variable length name (NULL terminated) follows this structure. - // The name is then followed by the Data. - - // The entire length of the block is sizeof(BlockHeader) + TagSize + DataSize. - }; - - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Member Data Fields //////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - - // This is the data at the start of the file. - FileHeader Header; - - // Only one handle has permission to write to the end of the file if any. - // This is a pointer to that handle. - TagBlockHandle *CreateHandle; - - // To help those stupid programmers from leaving open handles when - // this file is closed down. - int NumOpenHandles; - - // Last time file was written to before we opened it. - unsigned long FileTime; - - // Keep list of all blocks in file. This list is sorted by CRC value. - // TagBlockIndex is defined in TagBlock.cpp. - SList IndexList; - - protected: - /////////////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////// Protected Member Functions //////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////// - // Search for block given tag. - TagBlockIndex *Find_Block(const char *tagname); - - // Create an index that can be used for seaching. - TagBlockIndex *Create_Index(const char *tagname, int blockoffset); - - // Is this the handle that has creation priveledges? - int Handle_Can_Write(TagBlockHandle *handle) { - return(CreateHandle == handle); - } - - // Called only by ~TagBlockHandle! - void Destroy_Handle(TagBlockHandle *handle); - - // Stop write access - flushes data out but keeps handle available for reading. - int End_Write_Access(TagBlockHandle *handle); - - // Save the header when it has been updated. - void Save_Header() { - Seek(0, SEEK_SET); - Write(&Header, sizeof(Header)); - } - - void Empty_Index_List(); - - friend class TagBlockHandle; -}; - -///////////////////////////////////////// End of TagBlockFile ///////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// Start of TagBlockHandle///////////////////////////////////// -// All external access to the TagBlockFile is done through handles. -class TagBlockHandle -{ - public: - // Access functions. - int Write(const void *buf, int nbytes); - int Read(void *buf, int nbytes); - int Seek(int pos, int dir = SEEK_CUR); - - // Stop write access - flushes data out but keeps handle available for reading. - int End_Write_Access() { - return (File->End_Write_Access(this)); - } - - int Tell() { - return(Position); - } - - int Get_Data_Size() { - return(BlockHeader->DataSize); - } - - // User must call TagBlockFile::New_Handle() to create a TagBlockHandle object. - // User may call this delete to destry handle or - // he may call TagBlockFile::Close_Tag(). - ~TagBlockHandle(); - - private: - - // Pointer to parent file object. - TagBlockFile *File; - - // Pointer to index for aditional information. - TagBlockIndex *Index; - - // Keep header infomation in memory so that it can be updated. - TagBlockFile::BlockHeader *BlockHeader; - - // Current postion we are in the file. - int Position; - - private: - // User must call TagBlockFile::New_Handle() to create a TagBlockHandle object. - // The constructor is private so only TagBlockFile can create the handle. - // This is so that a handle will not be created if the TagBlock - // does not exist on a CREAD or if there was already a WRITE access granted. - // User needs to call detete to destroy the handle. - TagBlockHandle(TagBlockFile *tagfile, TagBlockIndex *tagindex, TagBlockFile::BlockHeader *blockheader); - friend class TagBlockFile; - - // Used to prevent TagBlockFile::Destroy_Handle() from being called - // except by this destructor. - static int _InDestructor; - - int Called_By_Destructor() { - return(_InDestructor); - } -}; - - -////////////////////////////////////// End of TagBlockHandle/////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#endif //TAGBLOCK_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H deleted file mode 100644 index 9c213932cde..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/WATCOM.H +++ /dev/null @@ -1,118 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/WATCOM.H $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:56a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(WATCOM_H) && defined(__WATCOMC__) -#define WATCOM_H - - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -// Turn all warnings into errors. -#pragma warning * 0 - -// Disables warning when "sizeof" is used on an object with virtual functions. -#pragma warning 549 9 - -// Disable the "Integral value may be truncated during assignment or initialization". -#pragma warning 389 9 - -// Allow constructing a temporary to be used as a parameter. -#pragma warning 604 9 - -// Disable the construct resolved as an expression warning. -#pragma warning 595 9 - -// Disable the strange "construct resolved as a declaration/type" warning. -#pragma warning 594 9 - -// Disable the "pre-compiled header file cannot be used" warning. -#pragma warning 698 9 - -// Disable the "temporary object used to initialize a non-constant reference" warning. -#pragma warning 665 9 - -// Disable the "pointer or reference truncated by cast. Cast is supposed to REMOVE warnings, not create them. -#pragma warning 579 9 - -// Disable the warning that suggests a null destructor be placed in class definition. -#pragma warning 656 9 - -// Disable the warning about moving empty constructors/destructors to the class declaration. -#pragma warning 657 9 - -// No virtual destructor is not an error in C&C. -#pragma warning 004 9 - -// Integral constant will be truncated warning is usually ok when dealing with bitfields. -#pragma warning 388 9 - -// Turns off unreferenced function parameter warning. -//#pragma off(unreferenced) - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - -#if !defined(__BORLANDC__) -#define M_E 2.71828182845904523536 -#define M_LOG2E 1.44269504088896340736 -#define M_LOG10E 0.434294481903251827651 -#define M_LN2 0.693147180559945309417 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.785398163397448309616 -#define M_1_PI 0.318309886183790671538 -#define M_2_PI 0.636619772367581343076 -#define M_1_SQRTPI 0.564189583547756286948 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT_2 0.707106781186547524401 -#endif - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp deleted file mode 100644 index 03db64e676b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/_Convert.cpp $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 2/10/98 4:20p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_convert.h" - -ConvertClass * VoxelDrawer = NULL; -ConvertClass * UnitDrawer = NULL; -ConvertClass * TerrainDrawer = NULL; -ConvertClass * AnimDrawer = NULL; -ConvertClass * NormalDrawer = NULL; -ConvertClass * IsometricDrawer = NULL; - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.h deleted file mode 100644 index c94f72a5d14..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_convert.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Convert.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _CONVERT_H -#define _CONVERT_H - -#include "Convert.h" - -extern ConvertClass * VoxelDrawer; -extern ConvertClass * UnitDrawer; -extern ConvertClass * TerrainDrawer; -extern ConvertClass * AnimDrawer; -extern ConvertClass * NormalDrawer; -extern ConvertClass * IsometricDrawer; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp deleted file mode 100644 index 29baf1698b8..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_mono.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_mono.h" - - -/* -** This is the global (general purpose) mono object. It exists only for the convenience of -** debugging mono printing. -*/ -MonoClass Mono; - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.h deleted file mode 100644 index 3d80325cc40..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_mono.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/_mono.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:58a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef _MONO_H -#define _MONO_H - -#include "MONO.H" - - -/* -** This externs the global mono object. There can be only one. -*/ -extern MonoClass Mono; - -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp deleted file mode 100644 index f532f1de608..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Timer.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_timer.h" - - -/*************************************************************************** -** Game frame timer (this is synced between processes). -*/ -CDTimerClass FrameTimer; - -/*************************************************************************** -** Tick Count global timer object. -*/ -TTimerClass TickCount = 0; - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.h deleted file mode 100644 index e14736a0b90..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_timer.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_Timer.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _TIMER_H -#define _TIMER_H - -#include "stimer.h" -#include "timer.h" - -extern CDTimerClass FrameTimer; -extern TTimerClass TickCount; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h deleted file mode 100644 index 47159a2378b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/_xmouse.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/_xmouse.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef _XMOUSE_H -#define _XMOUSE_H - -#include "xmouse.h" - -extern Mouse * MouseCursor; - - - -inline void Hide_Mouse(void) {MouseCursor->Hide_Mouse();} -inline void Show_Mouse(void) {MouseCursor->Show_Mouse();} -inline void Conditional_Hide_Mouse(Rect rect) {MouseCursor->Conditional_Hide_Mouse(rect);} -inline void Conditional_Show_Mouse(void) {MouseCursor->Conditional_Show_Mouse();} -inline int Get_Mouse_State(void) {return(MouseCursor->Get_Mouse_State());} -inline void Set_Mouse_Cursor(int hotx, int hoty, ShapeSet const * cursor, int shape) {MouseCursor->Set_Cursor(hotx, hoty, cursor, shape);} -inline int Get_Mouse_X(void) {return(MouseCursor->Get_Mouse_X());} -inline int Get_Mouse_Y(void) {return(MouseCursor->Get_Mouse_Y());} - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.cpp deleted file mode 100644 index 683d7dd4695..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/blit.cpp $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/15/99 10:13a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Bit_Blit -- Blit a block of pixels to the destination surface. * - * Bit_Blit -- Blits data to a surface w/ clipping. * - * Buffer_Size -- Determines size of buffer for given dimensions. * - * From_Buffer -- Copy graphic data from a buffer to a surface. * - * RLE_Blit -- Blits RLE compressed data without extra clipping. * - * RLE_Blit -- Blits a rectangle of RLE compressed data to a surface. * - * To_Buffer -- Copies a graphic region into a linear RAM buffer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blit.h" -#include "bsurface.h" -//#include "rle.h" -#include "xsurface.h" -//#include - - -/*********************************************************************************************** - * Buffer_Size -- Determines size of buffer for given dimensions. * - * * - * This routine will determine the byte size of a buffer if it were to hold the pixels * - * of the dimensions specified. It takes into account the bytes per pixel. * - * * - * INPUT: surface -- The surface to base the buffer size calculation upon. * - * * - * width -- Pixel width of a graphic region. * - * * - * height -- Pixel height of a graphic region. * - * * - * OUTPUT: Returns with the number of bytes such a region would consume if it were linearly * - * packed into a memory buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int Buffer_Size(Surface const & surface, int width, int height) -{ - return(width * height * surface.Bytes_Per_Pixel()); -} - - -/*********************************************************************************************** - * To_Buffer -- Copies a graphic region into a linear RAM buffer. * - * * - * This routine will copy the graphic rectangle specified, into a RAM buffer. The size of * - * the RAM buffer must be big enough to hold the pixel data. Use the Buffer_Size() function * - * to determine how big it must be. * - * * - * INPUT: surface -- The surface to copy the pixel data from. * - * * - * rect -- The graphic rectangle to copy from. * - * * - * buffer -- Reference to the buffer that will be filled with the pixel data. * - * * - * OUTPUT: bool; Was the data copy performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool To_Buffer(Surface const & surface, Rect const & rect, Buffer & buffer) -{ - if (!rect.Is_Valid()) return(false); - - BSurface from(rect.Width, rect.Height, surface.Bytes_Per_Pixel(), buffer); - return(from.Blit_From(Rect(0, 0, rect.Width, rect.Height), surface, rect)); -} - - -/*********************************************************************************************** - * From_Buffer -- Copy graphic data from a buffer to a surface. * - * * - * This routine will take pixel data and move it from the specified buffer and into the * - * surface rectangle specified. It is the counterpart routine of To_Buffer(). * - * * - * INPUT: surface -- The surface to store the pixel data to. * - * * - * rect -- The destination rectangle to store the pixel data to. * - * * - * buffer -- Reference to the buffer that contains the pixel data. * - * * - * OUTPUT: bool; Was the pixel data copy performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool From_Buffer(Surface & surface, Rect const & rect, Buffer const & buffer) -{ - if (!rect.Is_Valid()) return(false); - - BSurface from(rect.Width, rect.Height, surface.Bytes_Per_Pixel(), buffer); - return(surface.Blit_From(rect, from, Rect(0, 0, rect.Width, rect.Height))); -} - - - -/*********************************************************************************************** - * Bit_Blit -- Blits data to a surface w/ clipping. * - * * - * This routine will take source pixel data and blit it to the surface specified while * - * also performing clipping on both the source and the destination data. Typical users of * - * this routine would be to draw shape (sprite) data. * - * * - * INPUT: dest -- Destintaion surface rect. This specifies the destination surface and * - * any coordinate clipping rectangle. * - * * - * destrect -- The destination rectangle of the blit. The coordinates are relative * - * to the destination clipping rectangle. * - * * - * source -- Source surface rect. This specifies the source surface as well as any * - * clipping rectangle it may contain. * - * * - * srcrect -- The rectange, relative to the source clipping rectangle, that * - * specifies the source blit data. It is presumed that the dimensions of * - * the source rectangle are the same as the destination rectangle. * - * * - * blitter -- The blitter to use for moving the source pixels to the destination * - * surface. * - * * - * OUTPUT: bool; Was the blit performed even if it was for only a single pixel. Failure would * - * indicate that the blit was completely clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool Bit_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, Blitter const & blitter) -{ - return(Bit_Blit(dest, dest.Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, blitter)); -} - - -/*********************************************************************************************** - * Bit_Blit -- Blit a block of pixels to the destination surface. * - * * - * This routine will blit a block of pixels and perform clipping on the blit as controlled * - * by the clipping rectangles. * - * * - * INPUT: dest -- Surface to blit to. * - * * - * dcliprect-- The destination surface clipping rectangle. * - * * - * ddrect -- The destination rect of the blit. It is relative to the clipping * - * rectangle and will be clipped against same. * - * * - * source -- The source surface to blit from. * - * * - * scliprect-- The source surface clipping rectangle. * - * * - * ssrect -- The source rectangle of the blit. It is relative to the source * - * clipping rectangle and will be clipped against same. * - * * - * blitter -- The blitter to use for blitting of this rectangle. * - * * - * OUTPUT: bool; Was the blit performed? A 'false' return value would indicate that the * - * blit was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool Bit_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, Blitter const & blitter) -{ - Rect srect = ssrect; - Rect drect = ddrect; - bool overlapped = false; - void * dbuffer = NULL; - void * sbuffer = NULL; - - /* - ** Prepare for the blit by performing any clipping as well as fetching pointers into the - ** pixel buffers. If there were any errors, then this blit cannot be performed. - */ - if (!XSurface::Prep_For_Blit(dest, dcliprect, drect, source, scliprect, srect, overlapped, dbuffer, sbuffer)) { - return(false); - } - - /* - ** If there is no difference between the width and the stride of the source and - ** destination surfaces, then the copy can be performed as one huge copy operation. - ** This is the simplist case and the one that is performed with a full screen - ** blit. - */ - if (drect.Width * dest.Bytes_Per_Pixel() == dest.Stride() && dest.Stride() == source.Stride()) { - - int length = MIN(srect.Height*srect.Width, drect.Height*drect.Width); - if (overlapped) { - blitter.BlitBackward(dbuffer, sbuffer, length); - } else { - blitter.BlitForward(dbuffer, sbuffer, length); - } - - } else { - - /* - ** If the rectangles overlap, then the copy must proceed from the - ** last row to the first rather than the normal direction. - */ - int sstride = source.Stride(); - int dstride = dest.Stride(); - if (overlapped) { - sstride = -sstride; - dstride = -dstride; - sbuffer = ((char*)sbuffer) + (srect.Height-1) * source.Stride(); - dbuffer = ((char*)dbuffer) + (drect.Height-1) * dest.Stride(); - } - - /* - ** This perform a line-by-line pixel copy. - */ - int height = MIN(srect.Height, drect.Height); - if (overlapped) { - for (int y = 0; y < height; y++) { - blitter.BlitBackward(dbuffer, sbuffer, srect.Width); - dbuffer = (void*)(((char*)dbuffer) + dstride); - sbuffer = (void*)(((char*)sbuffer) + sstride); - } - } else { - for (int y = 0; y < height; y++) { - blitter.BlitForward(dbuffer, sbuffer, srect.Width); - dbuffer = (void*)(((char*)dbuffer) + dstride); - sbuffer = (void*)(((char*)sbuffer) + sstride); - } - } - } - - dest.Unlock(); - source.Unlock(); - - return(true); -} - - -/*********************************************************************************************** - * RLE_Blit -- Blits RLE compressed data without extra clipping. * - * * - * This routine will blit a rectangle of RLE compressed data to the specified surface. It * - * is functionally similar to the other RLE blit routine, but does not use any sub * - * clipping rectangles. The blit is naturally clipped to the edge of the destination * - * surface. * - * * - * INPUT: dest -- Reference to the destination surface. * - * * - * destrect -- The destination rectangle to draw the pixels to. * - * * - * source -- Reference to the source RLE surface data. * - * * - * sourcerect -- The source rectangle of from the RLE surface to blit from. * - * * - * blitter -- Reference to the blitter to perform the blit operation with. * - * * - * OUTPUT: bool; Was a blit performed? A 'false' value would mean that the blit has been * - * clipped into nothing. * - * * - * WARNINGS: The dimensions of the source and destination rectangles should be the same * - * until such time that the blitter can support scaling (as of this writing, it * - * cannot). * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool RLE_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, RLEBlitter const & blitter) -{ - return(RLE_Blit(dest, dest.Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, blitter)); -} - - -/*********************************************************************************************** - * RLE_Blit -- Blits a rectangle of RLE compressed data to a surface. * - * * - * This routine will blit a rectangle of REL compressed pixel data from a sprite to the * - * surface specified. Appropriate clipping and coordinate adjustments will occur as * - * controlled by the parameters. This is the workhorse RLE blit dispatcher routine. * - * * - * INPUT: dest -- The destination surface to blit to. * - * * - * dcliprect-- The clipping rectangle to use on the destination. Pixels won't be * - * drawn outside of this rectangle and the destination rect coordinates * - * are biased to this clipping rectange. * - * * - * ddrect -- The destination rectangle of the blit. The upper left coordinates are * - * biased to the destination clipping rectangle when blitted. Thus, * - * a dest X,Y position of 0,0 really means the upper left corner of the * - * destination clipping rectangle. * - * * - * source -- The source surface of the RLE compressed data. * - * * - * scliprect-- It is quite likely that this will be the full size of the source * - * surface. * - * * - * ssrect -- The source rectangle to blit from within the source surface. It * - * behaves similarly to the ddrect parameter, but for the source. The * - * width and height of this rectangle should match the width and height * - * of the ddrect parameter (scaling is not yet supported). * - * * - * blitter -- The blitter to use for this pixel copy. It must be an RLE blitter. * - * * - * OUTPUT: bool; Did the blit draw at least one pixel? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/24/1997 JLB : Created. * - *=============================================================================================*/ -bool RLE_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, RLEBlitter const & blitter) -{ - Rect srect = ssrect; // Desired source rect. - Rect drect = ddrect; // Desired destination rect. - - /* - ** Adjust the desired draw rectangles to account for clipping. This is where the desired rectangles - ** get clipped to the bounding rectangles of the surfaces. - */ - if (!Blit_Clip(drect, dcliprect, srect, scliprect)) { - return(false); - } - - /* - ** Determine the top and left skip margins. These require special handling - ** since the shape is compressed. - */ - int leftmargin = srect.X - scliprect.X; - int topmargin = srect.Y - scliprect.Y; - - void * dbuffer = dest.Lock(dcliprect.Top_Left() + drect.Top_Left()); -// void * dbuffer = dest.Lock(Point2D(dcliprect.X + drect.X, dcliprect.Y + drect.Y)); - if (dbuffer == NULL) return(false); - - /* - ** Lock the source pointer. This must always lock at location 0,0 since - ** normal pixel offset logic does not work for RLE compressed buffers. If there - ** is a pixel offset required, it is handled below. - */ - void * sbuffer = source.Lock(); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - /* - ** Skip any top margin lines. This must be manually performed on a line - ** by line basis because the length of each line is Variable. - */ - while (topmargin > 0) { - sbuffer = ((unsigned char *)sbuffer) + (*(unsigned short *)sbuffer); - topmargin--; - } - - /* - ** This perform a line-by-line pixel copy. - */ - int dstride = dest.Stride(); - int height = MIN(srect.Height, drect.Height); - for (int y = 0; y < height; y++) { - - /* - ** Blit the correct sub-portion to the destination surface. - */ - blitter.Blit(dbuffer, ((unsigned short *)sbuffer)+1, srect.Width, leftmargin); - - /* - ** Advance the source and dest pointers for the next line processing. - */ - sbuffer = ((unsigned char *)sbuffer) + (*(unsigned short *)sbuffer); - dbuffer = (void*)(((char*)dbuffer) + dstride); - } - - dest.Unlock(); - source.Unlock(); - - return(true); -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.h deleted file mode 100644 index dd3c507517b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blit.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/blit.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:49p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLIT_H -#define BLIT_H - -#include "blitter.h" -#include "BUFF.H" -#include "trect.h" -#include "Surface.h" - -bool Bit_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, Blitter const & blitter); -bool RLE_Blit(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect, RLEBlitter const & blitter); - -//bool Bit_Blit(SurfaceRect & dest, Rect const & ddrect, SurfaceRect const & source, Rect const & ssrect, Blitter const & blitter); -//bool RLE_Blit(SurfaceRect & dest, Rect const & ddrect, SurfaceRect const & source, Rect const & ssrect, RLEBlitter const & blitter); - -bool Bit_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, Blitter const & blitter); -bool RLE_Blit(Surface & dest, Rect const & dcliprect, Rect const & ddrect, Surface const & source, Rect const & scliprect, Rect const & ssrect, RLEBlitter const & blitter); - - -int Buffer_Size(Surface & surface, int width, int height); -bool To_Buffer(Surface const & surface, Rect const & rect, Buffer & buffer); -bool From_Buffer(Surface & surface, Rect const & rect, Buffer const & buffer); - - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitblit.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitblit.h deleted file mode 100644 index 2271db44a38..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitblit.h +++ /dev/null @@ -1,614 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/blitblit.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLITBLIT_H -#define BLITBLIT_H - - -/* -** This module contains the pixel-pushing blitter objects. These objects only -** serve one purpose. That is, to move pixels from one location to another. These -** are prime candidates for optimization since they are called frequently and -** loop greatly. -** -** The large variety of blitter objects is necessary because there is a rich -** set of pixel operations required by the game engine. Complicating this is that -** the game engine must support both 16 bit and 8 bit pixel formats. Some of these -** blitter objects are templates (this reduces the need for both 8 and 16 bit -** counterparts if the algorithm is constant between pixel formats). Also note -** that there are some assembly implementations where it seems appropriate. -** -** If the blitter object has "Xlat" in the name, then this means that the source -** pixel is 8 bit and the destination pixel is 16 bit (probably). This hybrid system -** allows the game artwork to be shared between the two pixel format displays. To -** accomplish this, a translation table is supplied to the blit operation so that -** the 8 bit pixel can be converted into the appropriate 16 bit destination pixel. -** If the destination surface is also 8 bit, then the translation table converts -** the pixel to the logical palette color index appropriate for the display. -*/ - - -#include "blitter.h" -#include -#include - - -/* -** Blits without translation and source and dest are same pixel format. Note that -** this uses the memcpy and memmove routines. The C library has optimized these for -** maximum performance. This includes alignment issues and performing REP MOVSD -** instruction. This might be further optimized by using MMX instructions. However, -** this blitter process is not often required by the game. -*/ -template -class BlitPlain : public Blitter { - public: - virtual void BlitForward(void * dest, void const * source, int length) const {memcpy(dest, source, length*sizeof(T));} - virtual void BlitBackward(void * dest, void const * source, int length) const {memmove(dest, source, length*sizeof(T));} -}; - - -/* -** Blits with transparency checking when and source and dest are same pixel format. -** This process is not often used. -*/ -template -class BlitTrans : public Blitter { - public: - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - T color = *(T const *)source; - source = ((T *)source) + 1; - if (color != 0) *((T *)dest) = color; - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} -}; - - -/* -** Blits when source 8 bits and dest is T. This process is typically used -** when loading screen bitmaps or perform other non-transparent image blitting. -** It is used fairly frequently and is a good candidate for optimization. -*/ -template -class BlitPlainXlat : public Blitter { - public: - BlitPlainXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - *((T *)dest) = TranslateTable[color]; - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit with transparency and dest is T. This process is used -** frequently by trees and other terrain objects. It is a good candidate for -** optimization. -*/ -template -class BlitTransXlat : public Blitter { - public: - BlitTransXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int len) const - { - for (int index = 0; index < len; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[color]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit, transparency check, then translate to pixel format T. This -** is occasionally used to render special remapping effects. Since the remap table is -** not doubly indirected, it is fixed to only using the remap table specified in the -** constructor. As such, it has limited value. -*/ -template -class BlitTransRemapXlat : public Blitter { - public: - BlitTransRemapXlat(unsigned char const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(RemapTable != NULL);assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[RemapTable[color]]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - unsigned char const * RemapTable; - T const * TranslateTable; -}; - - -/* -** Blits with source 8 bit with transparency then remap and dest is T. This is probably -** the most used blitter process. Units, infantry, buildings, and aircraft use this for -** their normal drawing needs. If any blitter process is to be optimized, this would be -** the one. Take note that the remapper table is doubly indirected. This allows a single -** blitter object to dynamically use alternate remap tables. -*/ -template -class BlitTransZRemapXlat : public Blitter { - public: - BlitTransZRemapXlat(unsigned char const * const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(RemapTable != NULL);assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - unsigned char const * rtable = *RemapTable; - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = TranslateTable[rtable[color]]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - unsigned char const * const * RemapTable; - T const * TranslateTable; -}; - - -/* -** Algorithmic darkening of hicolor pixels controlled by the source pixels. The source -** pixels are examined only to determine if the destination pixel should be darkened. -** If the source pixel is transparent, then the dest pixel is skipped. The darkening -** algorithm works only for hicolor pixels. -*/ -template -class BlitTransDarken : public Blitter { - public: - BlitTransDarken(T mask) : Mask(mask) {} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = (T)((((*(T *)dest) >> 1) & Mask)); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T Mask; -}; - - -/* -** This will remap the destination pixels but under the control of the source pixels. -** Where the source pixel is not transparent, the dest pixel is remapped. This algorithm -** really only applies to lowcolor display. -*/ -template -class BlitTransRemapDest : public Blitter { - public: - BlitTransRemapDest(T const * remap) : RemapTable(remap) {} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char const *)source)+1; - if (color != 0) { - *((T *)dest) = RemapTable[*((T *)dest)]; - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * RemapTable; -}; - - -/* -** This is similar to BlitTransDarken but instead of examining the source to determine what -** pixels should be darkened, every destination pixel is darkened. This means that the source -** pointer is unused. -*/ -template -class BlitDarken : public Blitter { - public: - BlitDarken(T mask) : Mask(mask) {} - virtual void BlitForward(void * dest, void const * , int length) const - { - for (int index = 0; index < length; index++) { - *((T *)dest) = (T)(((*(T *)dest) >> 1) & Mask); - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T Mask; -}; - - -/* -** This blitter performs 50% translucency as it draws. It is commonly used for animation -** effects and other stealth like images. It only works with hicolor pixels but is a good -** candidate for optimization. -*/ -template -class BlitTransLucent50 : public Blitter { - public: - BlitTransLucent50(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - *((T *)dest) = (T)((((*(T *)dest) >> 1) & Mask) + ((TranslateTable[color] >> 1) & Mask)); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 25% translucency as it draws. This effect is less than spectacular, -** but there are some uses for it. It only works with hicolor pixels. -*/ -template -class BlitTransLucent25 : public Blitter { - public: - BlitTransLucent25(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - T qsource = (T)(((TranslateTable[color] >> 2) & Mask)); - T qdest = (T)((((*(T *)dest) >> 2) & Mask)); - *((T *)dest) = (T)(qdest + qsource + qsource + qsource); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 75% translucency as it draws. This is quite useful for explosions and -** other gas animation effects. It only works with hicolor pixels and is a good candidate -** for optimization. -*/ -template -class BlitTransLucent75 : public Blitter { - public: - BlitTransLucent75(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {assert(TranslateTable != NULL);} - virtual void BlitForward(void * dest, void const * source, int length) const - { - for (int index = 0; index < length; index++) { - unsigned char color = *(unsigned char const *)source; - source = ((unsigned char *)source) + 1; - if (color != 0) { - T qsource = (T)(((TranslateTable[color] >> 2) & Mask)); - T qdest = (T)(((*(T *)dest) >> 2) & Mask); - *((T *)dest) = (T)(qdest + qdest + qdest + qsource); - } - dest = ((T *)dest) + 1; - } - } - - /* - ** The backward moving method will probably never be called in actual practice. - ** Implement in terms of the forward copying method until the need for this - ** version arrises. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const {BlitForward(dest, source, length);} - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** Assembly versions of some of the templated blitter object functions. Borland and -** Visual C++ support a compatible inline-assembly formats. However, Borland compiler -** does not allow inline-assembly to be part of an inline function -- go figure. -** It will still compile, it just generates warning messages. -*/ -#if defined(_MSC_VER) - -inline void BlitTrans::BlitForward(void * dest, void const * source, int len) const -{ - __asm { - mov esi,[source] - mov edi,[dest] - mov ecx,[len] - dec edi - inc ecx - } -again: - __asm { - dec ecx - jz fini - mov al,[esi] - inc edi - inc esi - test al,al - jz again - mov [edi],al - jmp again - } -fini:; -} - - -inline void BlitTransXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * xlator = TranslateTable; - - __asm { - mov ebx,[xlator] - mov ecx,[len] - inc ecx - mov edi,[dest] - sub edi,2 - mov esi,[source] - xor eax,eax - } -again: - __asm { - dec ecx - jz over - add edi,2 - mov al,[esi] - inc esi - or al,al - jz again - mov dx,[ebx+eax*2] - mov [edi],dx - jmp again - } -over:; -} - - -inline void BlitTransRemapXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * translator = TranslateTable; - unsigned char const * remapper = RemapTable; - - __asm { - mov ecx,[len] - mov edi,[dest] - sub edi,2 - mov esi,[source] - mov ebx,[remapper] - mov edx,[translator] - xor eax,eax - } - - /* - ** This block is 11 cycles per pixel, if not transparent, and 5 - ** cycles per pixel, if transparent. - */ -again: - __asm { - dec ecx - jz over - add edi,2 - xor eax,eax - lodsb - or al,al - jz again - mov al,[ebx+eax] // First remap step (8 bit to 8 bit). - mov ax,[edx+eax*2] // Second remap step (8 bit to 16 bit). - mov [edi],ax - jmp again - } -over:; -} - - -inline void BlitTransZRemapXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * translator = TranslateTable; - unsigned char const * remapper = *RemapTable; - - __asm { - mov ecx,[len] - mov edi,[dest] - sub edi,2 - mov esi,[source] - mov ebx,[remapper] - mov edx,[translator] - xor eax,eax - } - - /* - ** This block is 11 cycles per pixel, if not transparent, and 5 - ** cycles per pixel, if transparent. - */ -again: - __asm { - dec ecx - jz over - add edi,2 - xor eax,eax - lodsb - or al,al - jz again - mov al,[ebx+eax] // First remap step (8 bit to 8 bit). - mov ax,[edx+eax*2] // Second remap step (8 bit to 16 bit). - mov [edi],ax - jmp again - } -over:; -} - - -inline void BlitPlainXlat::BlitForward(void * dest, void const * source, int len) const -{ - unsigned short const * remapper = TranslateTable; - __asm { - mov ebx,[remapper] - mov ecx,[len] - mov esi,[source] - mov edi,[dest] - sub edi,2 - } -again: - /* - ** This block processes pixels at 7 clocks per pixel. - */ - __asm { - xor eax,eax - add edi,2 - mov al,[esi] - inc esi - mov ax,[ebx+eax*2] - mov [edi],ax - dec ecx - jnz again - } -} - - -#endif - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitter.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitter.h deleted file mode 100644 index a68f560c354..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blitter.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/blitter.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 7:48p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef BLITTER_H -#define BLITTER_H - -/* -** This is the interface class to the blitter object. The blitter object handles moving -** pixels. That's all it does. For every type of pixel translation, there should be a -** blitter object created that supports this interface. The blit blitting routines will -** call the appropriate method as the pixel are being processed. -*/ -class Blitter { - public: - - /* - ** Blits from source to dest (starts at first pixel). This is the preferred - ** method of pixel blitting and this routine will be called 99% of the time under - ** normal circumstances. - */ - virtual void BlitForward(void * dest, void const * source, int length) const = 0; - - /* - ** Copies the pixel in reverse order. This only required if the source and dest - ** pixel regions overlap in a certain way. This routine will rarely be called. - */ - virtual void BlitBackward(void * dest, void const * source, int length) const = 0; - - /* - ** This routine calls the appropriate blit routine. A proper overlap check cannot - ** be performed by this routine because the pixel size information is not present. - ** as such, you should call the appropriate blit routine rather than letting this - ** routine perform the check and call. - */ - void Blit(void * dest, void const * source, int length) const {if (dest < source) BlitBackward(dest, source, length); else BlitForward(dest, source, length);} -}; - - -/* -** This is the blitter object interface for dealing with RLE compressed pixel data. For -** every type of RLE compressed blitter operation desired, there would be an object created -** that supports this interface. -*/ -class RLEBlitter { - public: - - /* - ** Blits from the RLE compressed source to the destination buffer. An optional - ** leading pixel skip value can be supplied when a sub-section of an RLE - ** compressed pixel sequence is desired. This is necessary because RLE decompression - ** must begin at the start of the compressed data sequence. - */ - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const = 0; -}; - - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp deleted file mode 100644 index e6ea9dc34ec..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.cpp +++ /dev/null @@ -1,597 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLOWFISH.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BlowfishEngine::Decrypt -- Decrypts data using blowfish algorithm. * - * BlowfishEngine::Encrypt -- Encrypt an arbitrary block of data. * - * BlowfishEngine::Process_Block -- Process a block of data using Blowfish algorithm. * - * BlowfishEngine::Sub_Key_Encrypt -- Encrypts a block for use in S-Box processing. * - * BlowfishEngine::Submit_Key -- Submit a key that will allow data processing. * - * BlowfishEngine::~BlowfishEngine -- Destructor for the Blowfish engine. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blowfish.h" -#include -#include - - -/* -** Byte order controlled long integer. This integer is constructed -** so that character 0 (C0) is the most significant byte of the -** integer. This is biased toward big endian architecture, but that -** just happens to be how the Blowfish algorithm was designed. -*/ -typedef union { - unsigned long Long; - struct { - unsigned char C3; - unsigned char C2; - unsigned char C1; - unsigned char C0; - } Char; -} Int; - - -/*********************************************************************************************** - * BlowfishEngine::~BlowfishEngine -- Destructor for the Blowfish engine. * - * * - * This destructor will clear out the s-box tables so that even if the memory for the * - * class remains, it will contain no compromising data. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -BlowfishEngine::~BlowfishEngine(void) -{ - if (IsKeyed) { - Submit_Key(NULL, 0); - } -} - - -/*********************************************************************************************** - * BlowfishEngine::Submit_Key -- Submit a key that will allow data processing. * - * * - * This routine must be called before any data can be encrypted or decrypted. This routine * - * need only be called when the key is to be changed or set for the first time. Once the * - * key has been set, the engine may be used to encrypt, decrypt, or both operations * - * indefinitely. The key must be 56 bytes or less in length. This is necessary because * - * any keys longer than that will not correctly affect the encryption process. * - * * - * If the key pointer is NULL, then the S-Box tables are reset to identity. This will * - * mask the previous key setting. Use this method to clear the engine after processing in * - * order to gain a measure of security. * - * * - * INPUT: key -- Pointer to the key data block. * - * * - * length -- The length of the submitted key. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is a time consuming process. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Submit_Key(void const * key, int length) -{ - assert(length <= MAX_KEY_LENGTH); - - /* - ** Initialize the permutation and S-Box tables to a known - ** constant value. - */ - memcpy(P_Encrypt, P_Init, sizeof(P_Init)); - memcpy(P_Decrypt, P_Init, sizeof(P_Init)); - memcpy(bf_S, S_Init, sizeof(S_Init)); - - /* - ** Validate parameters. - */ - if (key == 0 || length == 0) { - IsKeyed = false; - return; - } - - /* - ** Combine the key with the permutation table. Wrap the key - ** as many times as necessary to ensure that the entire - ** permutation table has been modified. The key is lifted - ** into a long by using endian independent means. - */ - int j = 0; - unsigned char const * key_ptr = (unsigned char const *)key; - unsigned long * p_ptr = &P_Encrypt[0]; - for (int index = 0; index < ROUNDS+2; index++) { - unsigned long data = 0; - - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - data = (data << CHAR_BIT) | key_ptr[j++ % length]; - - *p_ptr++ ^= data; - } - - /* - ** The permutation table must be scrambled by means of the key. This - ** is how the key is factored into the encryption -- by merely altering - ** the permutation (and S-Box) tables. Because this transformation alters - ** the table data WHILE it is using the table data, the tables are - ** thoroughly obfuscated by this process. - */ - unsigned long left = 0x00000000L; - unsigned long right = 0x00000000L; - unsigned long * p_en = &P_Encrypt[0]; // Encryption table. - unsigned long * p_de = &P_Decrypt[ROUNDS+1]; // Decryption table. - for (int p_index = 0; p_index < ROUNDS+2; p_index += 2) { - Sub_Key_Encrypt(left, right); - - *p_en++ = left; - *p_en++ = right; - - *p_de-- = left; - *p_de-- = right; - } - - /* - ** Perform a similar transmutation to the S-Box tables. Also notice that the - ** working 64 bit number is carried into this process from the previous - ** operation. - */ - for (int sbox_index = 0; sbox_index < 4; sbox_index++) { - for (int ss_index = 0; ss_index < UCHAR_MAX+1; ss_index += 2) { - Sub_Key_Encrypt(left, right); - bf_S[sbox_index][ss_index] = left; - bf_S[sbox_index][ss_index + 1] = right; - } - } - - IsKeyed = true; -} - - -/*********************************************************************************************** - * BlowfishEngine::Encrypt -- Encrypt an arbitrary block of data. * - * * - * Use this routine to encrypt an arbitrary block of data. The block must be an even * - * multiple of 8 bytes. Any bytes left over will not be encrypted. The 8 byte requirement * - * is necessary because the underlying algorithm processes blocks in 8 byte chunks. * - * Partial blocks are unrecoverable and useless. * - * * - * INPUT: plaintext-- Pointer to the data block to be encrypted. * - * * - * length -- The length of the data block. * - * * - * cyphertext- Pointer to the output buffer that will hold the encrypted data. * - * * - * OUTPUT: Returns with the actual number of bytes encrypted. * - * * - * WARNINGS: You must submit the key before calling this routine. This will only encrypt * - * the plaintext in 8 byte increments. Modulo bytes left over are not processed. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -int BlowfishEngine::Encrypt(void const * plaintext, int length, void * cyphertext) -{ - if (plaintext == 0 || length == 0) { - return(0); - } - if (cyphertext == 0) cyphertext = (void *)plaintext; - - if (IsKeyed) { - - /* - ** Validate parameters. - */ - int blocks = length / BYTES_PER_BLOCK; - - /* - ** Process the buffer in 64 bit chunks. - */ - for (int index = 0; index < blocks; index++) { - Process_Block(plaintext, cyphertext, P_Encrypt); - plaintext = ((char *)plaintext) + BYTES_PER_BLOCK; - cyphertext = ((char *)cyphertext) + BYTES_PER_BLOCK; - } - int encrypted = blocks * BYTES_PER_BLOCK; - - /* - ** Copy over any trailing left over appendix bytes. - */ - if (encrypted < length) { - memmove(cyphertext, plaintext, length - encrypted); - } - - return(encrypted); - } - - /* - ** Non-keyed processing merely copies the data. - */ - if (plaintext != cyphertext) { - memmove(cyphertext, plaintext, length); - } - return(length); -} - - -/*********************************************************************************************** - * BlowfishEngine::Decrypt -- Decrypt an arbitrary block of data. * - * * - * Use this routine to decrypt an arbitrary block of data. The block must be an even * - * multiple of 8 bytes. Any bytes left over will not be decrypted. The 8 byte requirement * - * is necessary because the underlying algorithm processes blocks in 8 byte chunks. * - * Partial blocks are unrecoverable and useless. * - * * - * INPUT: cyphertext- Pointer to the data block to be decrypted. * - * * - * length -- The length of the data block. * - * * - * plaintext-- Pointer to the output buffer that will hold the decrypted data. * - * * - * OUTPUT: Returns with the actual number of bytes decrypted. * - * * - * WARNINGS: You must submit the key before calling this routine. This will only decrypt * - * the cyphertext in 8 byte increments. Modulo bytes left over are not processed. * - * * - * HISTORY: * - * 04/14/1996 JLB : Created. * - *=============================================================================================*/ -int BlowfishEngine::Decrypt(void const * cyphertext, int length, void * plaintext) -{ - if (cyphertext == 0 || length == 0) { - return(0); - } - if (plaintext == 0) plaintext = (void *)cyphertext; - - if (IsKeyed) { - - /* - ** Validate parameters. - */ - int blocks = length / BYTES_PER_BLOCK; - - /* - ** Process the buffer in 64 bit chunks. - */ - for (int index = 0; index < blocks; index++) { - Process_Block(cyphertext, plaintext, P_Decrypt); - cyphertext = ((char *)cyphertext) + BYTES_PER_BLOCK; - plaintext = ((char *)plaintext) + BYTES_PER_BLOCK; - } - int encrypted = blocks * BYTES_PER_BLOCK; - - /* - ** Copy over any trailing left over appendix bytes. - */ - if (encrypted < length) { - memmove(plaintext, cyphertext, length - encrypted); - } - - return(encrypted); - } - - /* - ** Non-keyed processing merely copies the data. - */ - if (plaintext != cyphertext) { - memmove(plaintext, cyphertext, length); - } - return(length); -} - - -/*********************************************************************************************** - * BlowfishEngine::Process_Block -- Process a block of data using Blowfish algorithm. * - * * - * This is the main processing routine for encryption and decryption. The algorithm * - * consists of a 16 round Feistal network and uses mathematics from different algebraic * - * groups (strengthens against differential cryptanalysis). The large S-Boxes and the * - * rounds strengthen it against linear cryptanalysis. * - * * - * INPUT: plaintext -- Pointer to the source text (it actually might be a pointer to * - * the cyphertext if this is called as a decryption process). * - * * - * cyphertext -- Pointer to the output buffer that will hold the processed block. * - * * - * ptable -- Pointer to the permutation table. This algorithm will encrypt * - * and decrypt using the same S-Box tables. The encryption control * - * is handled by the permutation table. * - * * - * OUTPUT: none * - * * - * WARNINGS: The source and destination buffers must be 8 bytes long. * - * * - * HISTORY: * - * 04/19/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Process_Block(void const * plaintext, void * cyphertext, unsigned long const * ptable) -{ - /* - ** Input the left and right halves of the source block such that - ** the byte order is constant regardless of the endian - ** persuasion of the current processor. The blowfish algorithm is - ** biased toward "big endian" architecture and some optimizations - ** could be done for big endian processors in that case. - */ - unsigned char const * source = (unsigned char const *)plaintext; - Int left; - left.Char.C0 = *source++; - left.Char.C1 = *source++; - left.Char.C2 = *source++; - left.Char.C3 = *source++; - - Int right; - right.Char.C0 = *source++; - right.Char.C1 = *source++; - right.Char.C2 = *source++; - right.Char.C3 = *source; - - /* - ** Perform all Feistal rounds on the block. This is the encryption/decryption - ** process. Since there is an exchange that occurs after each round, two - ** rounds are combined in this loop to avoid unnecessary exchanging. - */ - for (int index = 0; index < ROUNDS/2; index++) { - left.Long ^= *ptable++; - right.Long ^= ((( bf_S[0][left.Char.C0] + bf_S[1][left.Char.C1]) ^ bf_S[2][left.Char.C2]) + bf_S[3][left.Char.C3]); - right.Long ^= *ptable++; - left.Long ^= ((( bf_S[0][right.Char.C0] + bf_S[1][right.Char.C1]) ^ bf_S[2][right.Char.C2]) + bf_S[3][right.Char.C3]); - } - - /* - ** The final two longs in the permutation table are processed into the block. - ** The left and right halves are still reversed as a side effect of the last - ** round. - */ - left.Long ^= *ptable++; - right.Long ^= *ptable; - - /* - ** The final block data is output in endian architecture - ** independent format. Notice that the blocks are output as - ** right first and left second. This is to counteract the final - ** superfluous exchange that occurs as a side effect of the - ** encryption rounds. - */ - unsigned char * out = (unsigned char *)cyphertext; - *out++ = right.Char.C0; - *out++ = right.Char.C1; - *out++ = right.Char.C2; - *out++ = right.Char.C3; - - *out++ = left.Char.C0; - *out++ = left.Char.C1; - *out++ = left.Char.C2; - *out = left.Char.C3; -} - - -/*********************************************************************************************** - * BlowfishEngine::Sub_Key_Encrypt -- Encrypts a block for use in S-Box processing. * - * * - * This is the same as the normal process block function but it doesn't have the endian * - * fixup logic. Since this routine is only called for S-Box table generation and it is * - * known that the S-Box initial data is already in local machine endian format, the * - * byte order fixups are not needed. This also has a tendency to speed up S-Box generation * - * as well. * - * * - * INPUT: left -- The left half of the data block. * - * * - * right -- The right half of the data block. * - * * - * OUTPUT: none, but the processed block is stored back into the left and right half * - * integers. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 04/19/1996 JLB : Created. * - *=============================================================================================*/ -void BlowfishEngine::Sub_Key_Encrypt(unsigned long & left, unsigned long & right) -{ - Int l; - l.Long = left; - - Int r; - r.Long = right; - - for (int index = 0; index < ROUNDS; index += 2) { - l.Long ^= P_Encrypt[index]; - r.Long ^= ((( bf_S[0][l.Char.C0] + bf_S[1][l.Char.C1]) ^ bf_S[2][l.Char.C2]) + bf_S[3][l.Char.C3]); - r.Long ^= P_Encrypt[index+1]; - l.Long ^= ((( bf_S[0][r.Char.C0] + bf_S[1][r.Char.C1]) ^ bf_S[2][r.Char.C2]) + bf_S[3][r.Char.C3]); - } - left = r.Long ^ P_Encrypt[ROUNDS+1]; - right = l.Long ^ P_Encrypt[ROUNDS]; -} - - -/* -** These tables have the bytes stored in machine endian format. Because of this, -** a special block cypher routine is needed when the sub-keys are generated. -** This is kludgier than it otherwise should be. However, storing these -** integers in machine independent format would be even more painful. -*/ - -unsigned long const BlowfishEngine::P_Init[BlowfishEngine::ROUNDS+2] = { - 0x243F6A88U,0x85A308D3U,0x13198A2EU,0x03707344U,0xA4093822U,0x299F31D0U,0x082EFA98U,0xEC4E6C89U, - 0x452821E6U,0x38D01377U,0xBE5466CFU,0x34E90C6CU,0xC0AC29B7U,0xC97C50DDU,0x3F84D5B5U,0xB5470917U, - 0x9216D5D9U,0x8979FB1BU -}; - -unsigned long const BlowfishEngine::S_Init[4][UCHAR_MAX+1] = { - { - 0xD1310BA6U,0x98DFB5ACU,0x2FFD72DBU,0xD01ADFB7U,0xB8E1AFEDU,0x6A267E96U,0xBA7C9045U,0xF12C7F99U, - 0x24A19947U,0xB3916CF7U,0x0801F2E2U,0x858EFC16U,0x636920D8U,0x71574E69U,0xA458FEA3U,0xF4933D7EU, - 0x0D95748FU,0x728EB658U,0x718BCD58U,0x82154AEEU,0x7B54A41DU,0xC25A59B5U,0x9C30D539U,0x2AF26013U, - 0xC5D1B023U,0x286085F0U,0xCA417918U,0xB8DB38EFU,0x8E79DCB0U,0x603A180EU,0x6C9E0E8BU,0xB01E8A3EU, - 0xD71577C1U,0xBD314B27U,0x78AF2FDAU,0x55605C60U,0xE65525F3U,0xAA55AB94U,0x57489862U,0x63E81440U, - 0x55CA396AU,0x2AAB10B6U,0xB4CC5C34U,0x1141E8CEU,0xA15486AFU,0x7C72E993U,0xB3EE1411U,0x636FBC2AU, - 0x2BA9C55DU,0x741831F6U,0xCE5C3E16U,0x9B87931EU,0xAFD6BA33U,0x6C24CF5CU,0x7A325381U,0x28958677U, - 0x3B8F4898U,0x6B4BB9AFU,0xC4BFE81BU,0x66282193U,0x61D809CCU,0xFB21A991U,0x487CAC60U,0x5DEC8032U, - 0xEF845D5DU,0xE98575B1U,0xDC262302U,0xEB651B88U,0x23893E81U,0xD396ACC5U,0x0F6D6FF3U,0x83F44239U, - 0x2E0B4482U,0xA4842004U,0x69C8F04AU,0x9E1F9B5EU,0x21C66842U,0xF6E96C9AU,0x670C9C61U,0xABD388F0U, - 0x6A51A0D2U,0xD8542F68U,0x960FA728U,0xAB5133A3U,0x6EEF0B6CU,0x137A3BE4U,0xBA3BF050U,0x7EFB2A98U, - 0xA1F1651DU,0x39AF0176U,0x66CA593EU,0x82430E88U,0x8CEE8619U,0x456F9FB4U,0x7D84A5C3U,0x3B8B5EBEU, - 0xE06F75D8U,0x85C12073U,0x401A449FU,0x56C16AA6U,0x4ED3AA62U,0x363F7706U,0x1BFEDF72U,0x429B023DU, - 0x37D0D724U,0xD00A1248U,0xDB0FEAD3U,0x49F1C09BU,0x075372C9U,0x80991B7BU,0x25D479D8U,0xF6E8DEF7U, - 0xE3FE501AU,0xB6794C3BU,0x976CE0BDU,0x04C006BAU,0xC1A94FB6U,0x409F60C4U,0x5E5C9EC2U,0x196A2463U, - 0x68FB6FAFU,0x3E6C53B5U,0x1339B2EBU,0x3B52EC6FU,0x6DFC511FU,0x9B30952CU,0xCC814544U,0xAF5EBD09U, - 0xBEE3D004U,0xDE334AFDU,0x660F2807U,0x192E4BB3U,0xC0CBA857U,0x45C8740FU,0xD20B5F39U,0xB9D3FBDBU, - 0x5579C0BDU,0x1A60320AU,0xD6A100C6U,0x402C7279U,0x679F25FEU,0xFB1FA3CCU,0x8EA5E9F8U,0xDB3222F8U, - 0x3C7516DFU,0xFD616B15U,0x2F501EC8U,0xAD0552ABU,0x323DB5FAU,0xFD238760U,0x53317B48U,0x3E00DF82U, - 0x9E5C57BBU,0xCA6F8CA0U,0x1A87562EU,0xDF1769DBU,0xD542A8F6U,0x287EFFC3U,0xAC6732C6U,0x8C4F5573U, - 0x695B27B0U,0xBBCA58C8U,0xE1FFA35DU,0xB8F011A0U,0x10FA3D98U,0xFD2183B8U,0x4AFCB56CU,0x2DD1D35BU, - 0x9A53E479U,0xB6F84565U,0xD28E49BCU,0x4BFB9790U,0xE1DDF2DAU,0xA4CB7E33U,0x62FB1341U,0xCEE4C6E8U, - 0xEF20CADAU,0x36774C01U,0xD07E9EFEU,0x2BF11FB4U,0x95DBDA4DU,0xAE909198U,0xEAAD8E71U,0x6B93D5A0U, - 0xD08ED1D0U,0xAFC725E0U,0x8E3C5B2FU,0x8E7594B7U,0x8FF6E2FBU,0xF2122B64U,0x8888B812U,0x900DF01CU, - 0x4FAD5EA0U,0x688FC31CU,0xD1CFF191U,0xB3A8C1ADU,0x2F2F2218U,0xBE0E1777U,0xEA752DFEU,0x8B021FA1U, - 0xE5A0CC0FU,0xB56F74E8U,0x18ACF3D6U,0xCE89E299U,0xB4A84FE0U,0xFD13E0B7U,0x7CC43B81U,0xD2ADA8D9U, - 0x165FA266U,0x80957705U,0x93CC7314U,0x211A1477U,0xE6AD2065U,0x77B5FA86U,0xC75442F5U,0xFB9D35CFU, - 0xEBCDAF0CU,0x7B3E89A0U,0xD6411BD3U,0xAE1E7E49U,0x00250E2DU,0x2071B35EU,0x226800BBU,0x57B8E0AFU, - 0x2464369BU,0xF009B91EU,0x5563911DU,0x59DFA6AAU,0x78C14389U,0xD95A537FU,0x207D5BA2U,0x02E5B9C5U, - 0x83260376U,0x6295CFA9U,0x11C81968U,0x4E734A41U,0xB3472DCAU,0x7B14A94AU,0x1B510052U,0x9A532915U, - 0xD60F573FU,0xBC9BC6E4U,0x2B60A476U,0x81E67400U,0x08BA6FB5U,0x571BE91FU,0xF296EC6BU,0x2A0DD915U, - 0xB6636521U,0xE7B9F9B6U,0xFF34052EU,0xC5855664U,0x53B02D5DU,0xA99F8FA1U,0x08BA4799U,0x6E85076AU, - },{ - 0x4B7A70E9U,0xB5B32944U,0xDB75092EU,0xC4192623U,0xAD6EA6B0U,0x49A7DF7DU,0x9CEE60B8U,0x8FEDB266U, - 0xECAA8C71U,0x699A17FFU,0x5664526CU,0xC2B19EE1U,0x193602A5U,0x75094C29U,0xA0591340U,0xE4183A3EU, - 0x3F54989AU,0x5B429D65U,0x6B8FE4D6U,0x99F73FD6U,0xA1D29C07U,0xEFE830F5U,0x4D2D38E6U,0xF0255DC1U, - 0x4CDD2086U,0x8470EB26U,0x6382E9C6U,0x021ECC5EU,0x09686B3FU,0x3EBAEFC9U,0x3C971814U,0x6B6A70A1U, - 0x687F3584U,0x52A0E286U,0xB79C5305U,0xAA500737U,0x3E07841CU,0x7FDEAE5CU,0x8E7D44ECU,0x5716F2B8U, - 0xB03ADA37U,0xF0500C0DU,0xF01C1F04U,0x0200B3FFU,0xAE0CF51AU,0x3CB574B2U,0x25837A58U,0xDC0921BDU, - 0xD19113F9U,0x7CA92FF6U,0x94324773U,0x22F54701U,0x3AE5E581U,0x37C2DADCU,0xC8B57634U,0x9AF3DDA7U, - 0xA9446146U,0x0FD0030EU,0xECC8C73EU,0xA4751E41U,0xE238CD99U,0x3BEA0E2FU,0x3280BBA1U,0x183EB331U, - 0x4E548B38U,0x4F6DB908U,0x6F420D03U,0xF60A04BFU,0x2CB81290U,0x24977C79U,0x5679B072U,0xBCAF89AFU, - 0xDE9A771FU,0xD9930810U,0xB38BAE12U,0xDCCF3F2EU,0x5512721FU,0x2E6B7124U,0x501ADDE6U,0x9F84CD87U, - 0x7A584718U,0x7408DA17U,0xBC9F9ABCU,0xE94B7D8CU,0xEC7AEC3AU,0xDB851DFAU,0x63094366U,0xC464C3D2U, - 0xEF1C1847U,0x3215D908U,0xDD433B37U,0x24C2BA16U,0x12A14D43U,0x2A65C451U,0x50940002U,0x133AE4DDU, - 0x71DFF89EU,0x10314E55U,0x81AC77D6U,0x5F11199BU,0x043556F1U,0xD7A3C76BU,0x3C11183BU,0x5924A509U, - 0xF28FE6EDU,0x97F1FBFAU,0x9EBABF2CU,0x1E153C6EU,0x86E34570U,0xEAE96FB1U,0x860E5E0AU,0x5A3E2AB3U, - 0x771FE71CU,0x4E3D06FAU,0x2965DCB9U,0x99E71D0FU,0x803E89D6U,0x5266C825U,0x2E4CC978U,0x9C10B36AU, - 0xC6150EBAU,0x94E2EA78U,0xA5FC3C53U,0x1E0A2DF4U,0xF2F74EA7U,0x361D2B3DU,0x1939260FU,0x19C27960U, - 0x5223A708U,0xF71312B6U,0xEBADFE6EU,0xEAC31F66U,0xE3BC4595U,0xA67BC883U,0xB17F37D1U,0x018CFF28U, - 0xC332DDEFU,0xBE6C5AA5U,0x65582185U,0x68AB9802U,0xEECEA50FU,0xDB2F953BU,0x2AEF7DADU,0x5B6E2F84U, - 0x1521B628U,0x29076170U,0xECDD4775U,0x619F1510U,0x13CCA830U,0xEB61BD96U,0x0334FE1EU,0xAA0363CFU, - 0xB5735C90U,0x4C70A239U,0xD59E9E0BU,0xCBAADE14U,0xEECC86BCU,0x60622CA7U,0x9CAB5CABU,0xB2F3846EU, - 0x648B1EAFU,0x19BDF0CAU,0xA02369B9U,0x655ABB50U,0x40685A32U,0x3C2AB4B3U,0x319EE9D5U,0xC021B8F7U, - 0x9B540B19U,0x875FA099U,0x95F7997EU,0x623D7DA8U,0xF837889AU,0x97E32D77U,0x11ED935FU,0x16681281U, - 0x0E358829U,0xC7E61FD6U,0x96DEDFA1U,0x7858BA99U,0x57F584A5U,0x1B227263U,0x9B83C3FFU,0x1AC24696U, - 0xCDB30AEBU,0x532E3054U,0x8FD948E4U,0x6DBC3128U,0x58EBF2EFU,0x34C6FFEAU,0xFE28ED61U,0xEE7C3C73U, - 0x5D4A14D9U,0xE864B7E3U,0x42105D14U,0x203E13E0U,0x45EEE2B6U,0xA3AAABEAU,0xDB6C4F15U,0xFACB4FD0U, - 0xC742F442U,0xEF6ABBB5U,0x654F3B1DU,0x41CD2105U,0xD81E799EU,0x86854DC7U,0xE44B476AU,0x3D816250U, - 0xCF62A1F2U,0x5B8D2646U,0xFC8883A0U,0xC1C7B6A3U,0x7F1524C3U,0x69CB7492U,0x47848A0BU,0x5692B285U, - 0x095BBF00U,0xAD19489DU,0x1462B174U,0x23820E00U,0x58428D2AU,0x0C55F5EAU,0x1DADF43EU,0x233F7061U, - 0x3372F092U,0x8D937E41U,0xD65FECF1U,0x6C223BDBU,0x7CDE3759U,0xCBEE7460U,0x4085F2A7U,0xCE77326EU, - 0xA6078084U,0x19F8509EU,0xE8EFD855U,0x61D99735U,0xA969A7AAU,0xC50C06C2U,0x5A04ABFCU,0x800BCADCU, - 0x9E447A2EU,0xC3453484U,0xFDD56705U,0x0E1E9EC9U,0xDB73DBD3U,0x105588CDU,0x675FDA79U,0xE3674340U, - 0xC5C43465U,0x713E38D8U,0x3D28F89EU,0xF16DFF20U,0x153E21E7U,0x8FB03D4AU,0xE6E39F2BU,0xDB83ADF7U, - },{ - 0xE93D5A68U,0x948140F7U,0xF64C261CU,0x94692934U,0x411520F7U,0x7602D4F7U,0xBCF46B2EU,0xD4A20068U, - 0xD4082471U,0x3320F46AU,0x43B7D4B7U,0x500061AFU,0x1E39F62EU,0x97244546U,0x14214F74U,0xBF8B8840U, - 0x4D95FC1DU,0x96B591AFU,0x70F4DDD3U,0x66A02F45U,0xBFBC09ECU,0x03BD9785U,0x7FAC6DD0U,0x31CB8504U, - 0x96EB27B3U,0x55FD3941U,0xDA2547E6U,0xABCA0A9AU,0x28507825U,0x530429F4U,0x0A2C86DAU,0xE9B66DFBU, - 0x68DC1462U,0xD7486900U,0x680EC0A4U,0x27A18DEEU,0x4F3FFEA2U,0xE887AD8CU,0xB58CE006U,0x7AF4D6B6U, - 0xAACE1E7CU,0xD3375FECU,0xCE78A399U,0x406B2A42U,0x20FE9E35U,0xD9F385B9U,0xEE39D7ABU,0x3B124E8BU, - 0x1DC9FAF7U,0x4B6D1856U,0x26A36631U,0xEAE397B2U,0x3A6EFA74U,0xDD5B4332U,0x6841E7F7U,0xCA7820FBU, - 0xFB0AF54EU,0xD8FEB397U,0x454056ACU,0xBA489527U,0x55533A3AU,0x20838D87U,0xFE6BA9B7U,0xD096954BU, - 0x55A867BCU,0xA1159A58U,0xCCA92963U,0x99E1DB33U,0xA62A4A56U,0x3F3125F9U,0x5EF47E1CU,0x9029317CU, - 0xFDF8E802U,0x04272F70U,0x80BB155CU,0x05282CE3U,0x95C11548U,0xE4C66D22U,0x48C1133FU,0xC70F86DCU, - 0x07F9C9EEU,0x41041F0FU,0x404779A4U,0x5D886E17U,0x325F51EBU,0xD59BC0D1U,0xF2BCC18FU,0x41113564U, - 0x257B7834U,0x602A9C60U,0xDFF8E8A3U,0x1F636C1BU,0x0E12B4C2U,0x02E1329EU,0xAF664FD1U,0xCAD18115U, - 0x6B2395E0U,0x333E92E1U,0x3B240B62U,0xEEBEB922U,0x85B2A20EU,0xE6BA0D99U,0xDE720C8CU,0x2DA2F728U, - 0xD0127845U,0x95B794FDU,0x647D0862U,0xE7CCF5F0U,0x5449A36FU,0x877D48FAU,0xC39DFD27U,0xF33E8D1EU, - 0x0A476341U,0x992EFF74U,0x3A6F6EABU,0xF4F8FD37U,0xA812DC60U,0xA1EBDDF8U,0x991BE14CU,0xDB6E6B0DU, - 0xC67B5510U,0x6D672C37U,0x2765D43BU,0xDCD0E804U,0xF1290DC7U,0xCC00FFA3U,0xB5390F92U,0x690FED0BU, - 0x667B9FFBU,0xCEDB7D9CU,0xA091CF0BU,0xD9155EA3U,0xBB132F88U,0x515BAD24U,0x7B9479BFU,0x763BD6EBU, - 0x37392EB3U,0xCC115979U,0x8026E297U,0xF42E312DU,0x6842ADA7U,0xC66A2B3BU,0x12754CCCU,0x782EF11CU, - 0x6A124237U,0xB79251E7U,0x06A1BBE6U,0x4BFB6350U,0x1A6B1018U,0x11CAEDFAU,0x3D25BDD8U,0xE2E1C3C9U, - 0x44421659U,0x0A121386U,0xD90CEC6EU,0xD5ABEA2AU,0x64AF674EU,0xDA86A85FU,0xBEBFE988U,0x64E4C3FEU, - 0x9DBC8057U,0xF0F7C086U,0x60787BF8U,0x6003604DU,0xD1FD8346U,0xF6381FB0U,0x7745AE04U,0xD736FCCCU, - 0x83426B33U,0xF01EAB71U,0xB0804187U,0x3C005E5FU,0x77A057BEU,0xBDE8AE24U,0x55464299U,0xBF582E61U, - 0x4E58F48FU,0xF2DDFDA2U,0xF474EF38U,0x8789BDC2U,0x5366F9C3U,0xC8B38E74U,0xB475F255U,0x46FCD9B9U, - 0x7AEB2661U,0x8B1DDF84U,0x846A0E79U,0x915F95E2U,0x466E598EU,0x20B45770U,0x8CD55591U,0xC902DE4CU, - 0xB90BACE1U,0xBB8205D0U,0x11A86248U,0x7574A99EU,0xB77F19B6U,0xE0A9DC09U,0x662D09A1U,0xC4324633U, - 0xE85A1F02U,0x09F0BE8CU,0x4A99A025U,0x1D6EFE10U,0x1AB93D1DU,0x0BA5A4DFU,0xA186F20FU,0x2868F169U, - 0xDCB7DA83U,0x573906FEU,0xA1E2CE9BU,0x4FCD7F52U,0x50115E01U,0xA70683FAU,0xA002B5C4U,0x0DE6D027U, - 0x9AF88C27U,0x773F8641U,0xC3604C06U,0x61A806B5U,0xF0177A28U,0xC0F586E0U,0x006058AAU,0x30DC7D62U, - 0x11E69ED7U,0x2338EA63U,0x53C2DD94U,0xC2C21634U,0xBBCBEE56U,0x90BCB6DEU,0xEBFC7DA1U,0xCE591D76U, - 0x6F05E409U,0x4B7C0188U,0x39720A3DU,0x7C927C24U,0x86E3725FU,0x724D9DB9U,0x1AC15BB4U,0xD39EB8FCU, - 0xED545578U,0x08FCA5B5U,0xD83D7CD3U,0x4DAD0FC4U,0x1E50EF5EU,0xB161E6F8U,0xA28514D9U,0x6C51133CU, - 0x6FD5C7E7U,0x56E14EC4U,0x362ABFCEU,0xDDC6C837U,0xD79A3234U,0x92638212U,0x670EFA8EU,0x406000E0U, - },{ - 0x3A39CE37U,0xD3FAF5CFU,0xABC27737U,0x5AC52D1BU,0x5CB0679EU,0x4FA33742U,0xD3822740U,0x99BC9BBEU, - 0xD5118E9DU,0xBF0F7315U,0xD62D1C7EU,0xC700C47BU,0xB78C1B6BU,0x21A19045U,0xB26EB1BEU,0x6A366EB4U, - 0x5748AB2FU,0xBC946E79U,0xC6A376D2U,0x6549C2C8U,0x530FF8EEU,0x468DDE7DU,0xD5730A1DU,0x4CD04DC6U, - 0x2939BBDBU,0xA9BA4650U,0xAC9526E8U,0xBE5EE304U,0xA1FAD5F0U,0x6A2D519AU,0x63EF8CE2U,0x9A86EE22U, - 0xC089C2B8U,0x43242EF6U,0xA51E03AAU,0x9CF2D0A4U,0x83C061BAU,0x9BE96A4DU,0x8FE51550U,0xBA645BD6U, - 0x2826A2F9U,0xA73A3AE1U,0x4BA99586U,0xEF5562E9U,0xC72FEFD3U,0xF752F7DAU,0x3F046F69U,0x77FA0A59U, - 0x80E4A915U,0x87B08601U,0x9B09E6ADU,0x3B3EE593U,0xE990FD5AU,0x9E34D797U,0x2CF0B7D9U,0x022B8B51U, - 0x96D5AC3AU,0x017DA67DU,0xD1CF3ED6U,0x7C7D2D28U,0x1F9F25CFU,0xADF2B89BU,0x5AD6B472U,0x5A88F54CU, - 0xE029AC71U,0xE019A5E6U,0x47B0ACFDU,0xED93FA9BU,0xE8D3C48DU,0x283B57CCU,0xF8D56629U,0x79132E28U, - 0x785F0191U,0xED756055U,0xF7960E44U,0xE3D35E8CU,0x15056DD4U,0x88F46DBAU,0x03A16125U,0x0564F0BDU, - 0xC3EB9E15U,0x3C9057A2U,0x97271AECU,0xA93A072AU,0x1B3F6D9BU,0x1E6321F5U,0xF59C66FBU,0x26DCF319U, - 0x7533D928U,0xB155FDF5U,0x03563482U,0x8ABA3CBBU,0x28517711U,0xC20AD9F8U,0xABCC5167U,0xCCAD925FU, - 0x4DE81751U,0x3830DC8EU,0x379D5862U,0x9320F991U,0xEA7A90C2U,0xFB3E7BCEU,0x5121CE64U,0x774FBE32U, - 0xA8B6E37EU,0xC3293D46U,0x48DE5369U,0x6413E680U,0xA2AE0810U,0xDD6DB224U,0x69852DFDU,0x09072166U, - 0xB39A460AU,0x6445C0DDU,0x586CDECFU,0x1C20C8AEU,0x5BBEF7DDU,0x1B588D40U,0xCCD2017FU,0x6BB4E3BBU, - 0xDDA26A7EU,0x3A59FF45U,0x3E350A44U,0xBCB4CDD5U,0x72EACEA8U,0xFA6484BBU,0x8D6612AEU,0xBF3C6F47U, - 0xD29BE463U,0x542F5D9EU,0xAEC2771BU,0xF64E6370U,0x740E0D8DU,0xE75B1357U,0xF8721671U,0xAF537D5DU, - 0x4040CB08U,0x4EB4E2CCU,0x34D2466AU,0x0115AF84U,0xE1B00428U,0x95983A1DU,0x06B89FB4U,0xCE6EA048U, - 0x6F3F3B82U,0x3520AB82U,0x011A1D4BU,0x277227F8U,0x611560B1U,0xE7933FDCU,0xBB3A792BU,0x344525BDU, - 0xA08839E1U,0x51CE794BU,0x2F32C9B7U,0xA01FBAC9U,0xE01CC87EU,0xBCC7D1F6U,0xCF0111C3U,0xA1E8AAC7U, - 0x1A908749U,0xD44FBD9AU,0xD0DADECBU,0xD50ADA38U,0x0339C32AU,0xC6913667U,0x8DF9317CU,0xE0B12B4FU, - 0xF79E59B7U,0x43F5BB3AU,0xF2D519FFU,0x27D9459CU,0xBF97222CU,0x15E6FC2AU,0x0F91FC71U,0x9B941525U, - 0xFAE59361U,0xCEB69CEBU,0xC2A86459U,0x12BAA8D1U,0xB6C1075EU,0xE3056A0CU,0x10D25065U,0xCB03A442U, - 0xE0EC6E0EU,0x1698DB3BU,0x4C98A0BEU,0x3278E964U,0x9F1F9532U,0xE0D392DFU,0xD3A0342BU,0x8971F21EU, - 0x1B0A7441U,0x4BA3348CU,0xC5BE7120U,0xC37632D8U,0xDF359F8DU,0x9B992F2EU,0xE60B6F47U,0x0FE3F11DU, - 0xE54CDA54U,0x1EDAD891U,0xCE6279CFU,0xCD3E7E6FU,0x1618B166U,0xFD2C1D05U,0x848FD2C5U,0xF6FB2299U, - 0xF523F357U,0xA6327623U,0x93A83531U,0x56CCCD02U,0xACF08162U,0x5A75EBB5U,0x6E163697U,0x88D273CCU, - 0xDE966292U,0x81B949D0U,0x4C50901BU,0x71C65614U,0xE6C6C7BDU,0x327A140AU,0x45E1D006U,0xC3F27B9AU, - 0xC9AA53FDU,0x62A80F00U,0xBB25BFE2U,0x35BDD2F6U,0x71126905U,0xB2040222U,0xB6CBCF7CU,0xCD769C2BU, - 0x53113EC0U,0x1640E3D3U,0x38ABBD60U,0x2547ADF0U,0xBA38209CU,0xF746CE76U,0x77AFA1C5U,0x20756060U, - 0x85CBFE4EU,0x8AE88DD8U,0x7AAAF9B0U,0x4CF9AA7EU,0x1948C25CU,0x02FB8A8CU,0x01C36AE4U,0xD6EBE1F9U, - 0x90D4F869U,0xA65CDEA0U,0x3F09252DU,0xC208E69FU,0xB74E6132U,0xCE77E25BU,0x578FDFE3U,0x3AC372E6U - } -}; - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.h deleted file mode 100644 index 891e9d5bf16..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowfish.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLOWFISH.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLOWFISH_H -#define BLOWFISH_H - -#include - - -/* -** The "bool" integral type was defined by the C++ committee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - - -/* -** This engine will process data blocks by encryption and decryption. -** The "Blowfish" algorithm is in the public domain. It uses -** a Feistal network (similar to IDEA). It has no known -** weaknesses, but is still relatively new. Blowfish is particularly strong -** against brute force attacks. It is also quite strong against linear and -** differential cryptanalysis. Unlike public key encription, it is very -** fast at encryption, as far as cryptography goes. Its weakness is that -** it takes a relatively long time to set up with a new key (1/100th of -** a second on a P6-200). The time to set up a key is equivalent to -** encrypting 4240 bytes. -*/ -class BlowfishEngine { - public: - BlowfishEngine(void) : IsKeyed(false) {} - ~BlowfishEngine(void); - - void Submit_Key(void const * key, int length); - - int Encrypt(void const * plaintext, int length, void * cyphertext); - int Decrypt(void const * cyphertext, int length, void * plaintext); - - /* - ** This is the maximum key length supported. - */ - enum {MAX_KEY_LENGTH=56}; - - private: - bool IsKeyed; - - void Sub_Key_Encrypt(unsigned long & left, unsigned long & right); - - void Process_Block(void const * plaintext, void * cyphertext, unsigned long const * ptable); - void Initialize_Tables(void); - - enum { - ROUNDS = 16, // Feistal round count (16 is standard). - BYTES_PER_BLOCK=8 // The number of bytes in each cypher block (don't change). - }; - - /* - ** Initialization data for sub keys. The initial values are constant and - ** filled with a number generated from pi. Thus they are not random but - ** they don't hold a weak pattern either. - */ - static unsigned long const P_Init[ROUNDS+2]; - static unsigned long const S_Init[4][UCHAR_MAX+1]; - - /* - ** Permutation tables for encryption and decryption. - */ - unsigned long P_Encrypt[ROUNDS+2]; - unsigned long P_Decrypt[ROUNDS+2]; - - /* - ** S-Box tables (four). - */ - unsigned long bf_S[4][UCHAR_MAX+1]; -}; - -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.cpp deleted file mode 100644 index 553fc7f01c0..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLOWPIPE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BlowPipe::Flush -- Flushes any pending data out the pipe. * - * BlowPipe::Key -- Submit a key to the blowfish pipe handler. * - * BlowPipe::Put -- Submit a block of data for encrypt/decrypt. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blowpipe.h" -#include -#include - - -/*********************************************************************************************** - * BlowPipe::Flush -- Flushes any pending data out the pipe. * - * * - * If there is any pending data in the holding buffer, then this routine will force it to * - * be flushed out the end of the pipe. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the actual number of bytes output at the end final distant pipe * - * segment in the chain. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int BlowPipe::Flush(void) -{ - int total = 0; - if (Counter > 0 && BF != NULL) { - total += Pipe::Put(Buffer, Counter); - } - Counter = 0; - total += Pipe::Flush(); - return(total); -} - - -/*********************************************************************************************** - * BlowPipe::Put -- Submit a block of data for encrypt/decrypt. * - * * - * This will take the data block specified and process it before passing it on to the next * - * link in the pipe chain. A key must be submitted before this routine will actually perform* - * any processing. Prior to key submission, the data is passed through unchanged. * - * * - * INPUT: source -- Pointer to the buffer that contains the data to pass through. * - * * - * length -- The length of the data in the buffer. * - * * - * OUTPUT: Returns with then actual number of bytes output at the final distant end link in * - * the pipe chain. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int BlowPipe::Put(void const * source, int slen) -{ - if (source == NULL || slen < 1) { - return(Pipe::Put(source, slen)); - } - - /* - ** If there is no blowfish engine present, then merely pass the data through - ** unchanged in any way. - */ - if (BF == NULL) { - return(Pipe::Put(source, slen)); - } - - int total = 0; - - /* - ** If there is a partial block accumulated, then tag on the new data to - ** this block and process it if the block is full. Proceed with the bulk - ** processing if there are any left over bytes from this step. This step - ** can be skipped if there are no pending bytes in the buffer. - */ - if (Counter) { - int sublen = ((int)sizeof(Buffer)-Counter < slen) ? (sizeof(Buffer)-Counter) : slen; - memmove(&Buffer[Counter], source, sublen); - Counter += sublen; - source = ((char *)source) + sublen; - slen -= sublen; - - if (Counter == sizeof(Buffer)) { - if (Control == DECRYPT) { - BF->Decrypt(Buffer, sizeof(Buffer), Buffer); - } else { - BF->Encrypt(Buffer, sizeof(Buffer), Buffer); - } - total += Pipe::Put(Buffer, sizeof(Buffer)); - Counter = 0; - } - } - - /* - ** Process the input data in blocks until there is not enough - ** source data to fill a full block of data. - */ - while (slen >= sizeof(Buffer)) { - if (Control == DECRYPT) { - BF->Decrypt(source, sizeof(Buffer), Buffer); - } else { - BF->Encrypt(source, sizeof(Buffer), Buffer); - } - total += Pipe::Put(Buffer, sizeof(Buffer)); - source = ((char *)source) + sizeof(Buffer); - slen -= sizeof(Buffer); - } - - /* - ** If there are any left over bytes, then they must be less than the size of - ** the staging buffer. Store the bytes in the staging buffer for later - ** processing. - */ - if (slen > 0) { - memmove(Buffer, source, slen); - Counter = slen; - } - - /* - ** Return with the total number of bytes flushed out to the final end of the - ** pipe chain. - */ - return(total); -} - - -/*********************************************************************************************** - * BlowPipe::Key -- Submit a key to the blowfish pipe handler. * - * * - * This routine will take the key provided and use it to process the data that passes * - * through this pipe. Prior to a key being submitted, the data passes through the pipe * - * unchanged. * - * * - * INPUT: key -- Pointer to the key data to use. * - * * - * length-- The length of the key. The key length must not be greater than 56 bytes. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void BlowPipe::Key(void const * key, int length) -{ - /* - ** Create the blowfish engine if one isn't already present. - */ - if (BF == NULL) { - BF = new BlowfishEngine; - } - - assert(BF != NULL); - - if (BF != NULL) { - BF->Submit_Key(key, length); - } -} - - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h deleted file mode 100644 index 7cf07820b90..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blowpipe.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/blowpipe.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLOWPIPE_H -#define BLOWPIPE_H - -#include "PIPE.H" -#include "blowfish.h" - -/* -** Performs Blowfish encryption/decryption on the data stream that is piped -** through this class. -*/ -class BlowPipe : public Pipe -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - BlowPipe(CryptControl control) : BF(NULL), Counter(0), Control(control) {} - virtual ~BlowPipe(void) {delete BF;BF = NULL;} - virtual int Flush(void); - - virtual int Put(void const * source, int slen); - - // Submit key for blowfish engine. - void Key(void const * key, int length); - - protected: - /* - ** The Blowfish engine used for encryption/decryption. If this pointer is - ** NULL, then this indicates that the blowfish engine is not active and no - ** key has been submitted. All data would pass through this pipe unchanged - ** in that case. - */ - BlowfishEngine * BF; - - private: - char Buffer[8]; - int Counter; - CryptControl Control; - - BlowPipe(BlowPipe & rvalue); - BlowPipe & operator = (BlowPipe const & pipe); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.cpp deleted file mode 100644 index 24a97bbf7d6..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLWSTRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BlowStraw::Get -- Fetch a block of data from the straw. * - * BlowStraw::Key -- Submit a key to the Blowfish straw. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blwstraw.h" -#include -#include - - -/*********************************************************************************************** - * BlowStraw::Get -- Fetch a block of data from the straw. * - * * - * This routine will take a block of data from the straw and process it according to the * - * encrypt/decrypt flag and the key supplied. Prior to a key be supplied, the data passes * - * through this straw unchanged. * - * * - * INPUT: source -- Pointer to the buffer to hold the data being requested. * - * * - * length -- The length of the data being requested. * - * * - * OUTPUT: Returns with the actual number of bytes stored into the buffer. If the number * - * returned is less than the number requested, then this indicates that the data * - * source has been exhausted. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int BlowStraw::Get(void * source, int slen) -{ - /* - ** Verify the parameter for legality. - */ - if (source == NULL || slen <= 0) { - return(0); - } - - /* - ** If there is no blowfish engine present, then merely pass the data through - ** unchanged. - */ - if (BF == NULL) { - return(Straw::Get(source, slen)); - } - - int total = 0; - - while (slen > 0) { - - /* - ** If there are any left over bytes in the buffer, pass them - ** through first. - */ - if (Counter > 0) { - int sublen = (slen < Counter) ? slen : Counter; - memmove(source, &Buffer[sizeof(Buffer)-Counter], sublen); - Counter -= sublen; - source = ((char *)source) + sublen; - slen -= sublen; - total += sublen; - } - if (slen == 0) break; - - /* - ** Fetch and encrypt/decrypt the next block. - */ - int incount = Straw::Get(Buffer, sizeof(Buffer)); - if (incount == 0) break; - - /* - ** Only full blocks are processed. Partial blocks are - ** merely passed through unchanged. - */ - if (incount == sizeof(Buffer)) { - if (Control == DECRYPT) { - BF->Decrypt(Buffer, incount, Buffer); - } else { - BF->Encrypt(Buffer, incount, Buffer); - } - } else { - memmove(&Buffer[sizeof(Buffer)-incount], Buffer, incount); - } - Counter = incount; - } - - /* - ** Return with the total number of bytes placed into the buffer. - */ - return(total); -} - - -/*********************************************************************************************** - * BlowStraw::Key -- Submit a key to the Blowfish straw. * - * * - * This will take the key specified and use it to process the data that flows through this * - * straw segment. Prior to a key being submitted, the data will flow through unchanged. * - * * - * INPUT: key -- Pointer to the key to submit. * - * * - * length-- The length of the key. The length must not exceed 56 bytes. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void BlowStraw::Key(void const * key, int length) -{ - /* - ** Create the blowfish engine if one isn't already present. - */ - if (BF == NULL) { - BF = new BlowfishEngine; - } - - assert(BF != NULL); - - if (BF != NULL) { - BF->Submit_Key(key, length); - } -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h deleted file mode 100644 index fa8148d1c55..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/blwstraw.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/BLWSTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BLWSTRAW_H -#define BLWSTRAW_H - -#include "STRAW.H" -#include "blowfish.h" - - -/* -** Performs Blowfish encryption/decryption to the data that is drawn through this straw. The -** process is controlled by the key which must be submitted to the class before any data -** manipulation will occur. The Blowfish algorithm is symmetric, thus the same key is used -** for encryption as is for decryption. -*/ -class BlowStraw : public Straw -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - BlowStraw(CryptControl control) : BF(NULL), Counter(0), Control(control) {} - virtual ~BlowStraw(void) {delete BF;BF = NULL;} - - virtual int Get(void * source, int slen); - - // Submit key for blowfish engine. - void Key(void const * key, int length); - - protected: - /* - ** The Blowfish engine used for encryption/decryption. If this pointer is - ** NULL, then this indicates that the blowfish engine is not active and no - ** key has been submitted. All data would pass through this straw unchanged - ** in that case. - */ - BlowfishEngine * BF; - - private: - char Buffer[8]; - int Counter; - CryptControl Control; - - BlowStraw(BlowStraw & rvalue); - BlowStraw & operator = (BlowStraw const & straw); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bool.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bool.h deleted file mode 100644 index 29b35a64d77..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/bool.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/23/99 1:46p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(TRUE_FALSE_DEFINED) && !defined(__BORLANDC__) && (_MSC_VER < 1100) && !defined(__WATCOMC__) -#define TRUE_FALSE_DEFINED - -/********************************************************************** -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#ifdef _MSC_VER - -#include "yvals.h" -#define bool unsigned - -#elif defined(_UNIX) - -/////#define bool unsigned - -#else - -enum {false=0,true=1}; -typedef int bool; - -#endif - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/borlandc.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/borlandc.h deleted file mode 100644 index e1177d89950..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/borlandc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/borlandc.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:57a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if !defined(BORLANDC_H) && defined(__BORLANDC__) -#define BORLANDC_H - -/* -** Funny, but there are no required overrides to make Borland C match C++ standards. This -** is because Borland C more closely matches the C++ standard than the other compilers. -*/ - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bsurface.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bsurface.h deleted file mode 100644 index b4d3775156d..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/bsurface.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/bsurface.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef BSURFACE_H -#define BSURFACE_H - -#include "BUFF.H" -#include "xsurface.h" - -/* -** This class handles a simple surface that exists in system RAM. -*/ -class BSurface : public XSurface -{ - public: - BSurface(int width, int height, int bbp, void * buffer=NULL) : - XSurface(width, height), - BBP(bbp), - Buff(buffer, width * height * bbp) - { - } - - /* - ** Gets and frees a direct pointer to the buffer. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const - { - XSurface::Lock(); - return(((char*)Buff.Get_Buffer()) + point.Y * Stride() + point.X * Bytes_Per_Pixel()); - } - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const {return(BBP);} - virtual int Stride(void) const {return(Get_Width() * BBP);} - - protected: - - /* - ** Recorded bytes per pixel (used when determining pixel positions). - */ - int BBP; - - /* - ** Tracks the buffer that this surface represents. - */ - Buffer Buff; -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/convert.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/convert.cpp deleted file mode 100644 index af76cc1e919..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/convert.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/Convert.cpp $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 2/19/99 11:51a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blitblit.h" -#include "Convert.h" -#include "dsurface.h" -#include "hsv.h" -#include "rlerle.h" - - -ConvertClass::ConvertClass(PaletteClass const & artpalette, PaletteClass const & screenpalette, Surface const & surface) : - BBP(surface.Bytes_Per_Pixel()), - PlainBlitter(NULL), - TransBlitter(NULL), - ShadowBlitter(NULL), - RemapBlitter(NULL), - Translucent1Blitter(NULL), - Translucent2Blitter(NULL), - Translucent3Blitter(NULL), - RLETransBlitter(NULL), - RLEShadowBlitter(NULL), - RLERemapBlitter(NULL), - RLETranslucent1Blitter(NULL), - RLETranslucent2Blitter(NULL), - RLETranslucent3Blitter(NULL), - Translator(NULL), - ShadowTable(NULL), - RemapTable(NULL) -{ - /* - ** The draw data initialization is greatly dependant upon the pixel format - ** of the display surface. Check the pixel format and set the values accordingly. - */ - if (BBP == 1) { - - /* - ** Build the shadow table by creating a slightly darker version of - ** the color and then finding the closest match to it. - */ - ShadowTable = W3DNEWARRAY unsigned char [256]; - ShadowTable[0] = 0; - for (int shadow = 1; shadow < 256; shadow++) { - HSVClass hsv = artpalette[shadow]; - hsv.Set_Value((unsigned char)(hsv.Get_Value() / 2)); - ShadowTable[shadow] = (unsigned char)artpalette.Closest_Color(hsv); - } - - /* - ** The translator table is created by finding the closest color - ** in the display palette from each color in the source art - ** palette. - */ - unsigned char * trans = W3DNEWARRAY unsigned char [256]; - trans[0] = 0; - for (int index = 1; index < 256; index++) { - trans[index] = (unsigned char)screenpalette.Closest_Color(artpalette[index]); - } - Translator = (void *)trans; - - /* - ** Construct all the blitter objects necessary to support the functionality - ** required for the draw permutations. - */ - PlainBlitter = W3DNEW BlitPlainXlat((unsigned char const *)Translator); - TransBlitter = W3DNEW BlitTransXlat((unsigned char const *)Translator); - RemapBlitter = W3DNEW BlitTransZRemapXlat(&RemapTable, (unsigned char const *)Translator); - ShadowBlitter = W3DNEW BlitTransRemapDest(ShadowTable); - Translucent1Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - Translucent2Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - Translucent3Blitter = W3DNEW BlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - - /* - ** Create the RLE aware blitter objects. - */ - RLETransBlitter = W3DNEW RLEBlitTransXlat((unsigned char const *)Translator); - RLERemapBlitter = W3DNEW RLEBlitTransZRemapXlat(&RemapTable, (unsigned char const *)Translator); - RLEShadowBlitter = W3DNEW RLEBlitTransRemapDest(ShadowTable); - RLETranslucent1Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - RLETranslucent2Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - RLETranslucent3Blitter = W3DNEW RLEBlitTransRemapXlat(ShadowTable, (unsigned char const *)Translator); - - } else { - - /* - ** The hicolor translation table is constructed according to the pixel - ** format of the display and the source art palette. - */ - //assert(surface.Is_Direct_Draw()); - Translator = W3DNEWARRAY unsigned short [256]; - ((DSurface &)surface).Build_Remap_Table((unsigned short *)Translator, artpalette); - - /* - ** Fetch the pixel mask values to be used for the various algorithmic - ** pixel processing performed for hicolor displays. - */ - int maskhalf = ((DSurface &)surface).Get_Halfbright_Mask(); - int maskquarter = ((DSurface &)surface).Get_Quarterbright_Mask(); - - /* - ** Construct all the blitter objects necessary to support the functionality - ** required for the draw permutations. - */ - PlainBlitter = W3DNEW BlitPlainXlat((unsigned short const *)Translator); - TransBlitter = W3DNEW BlitTransXlat((unsigned short const *)Translator); - RemapBlitter = W3DNEW BlitTransZRemapXlat(&RemapTable, (unsigned short const *)Translator); - ShadowBlitter = W3DNEW BlitTransDarken((unsigned short)maskhalf); - Translucent1Blitter = W3DNEW BlitTransLucent75((unsigned short const *)Translator, (unsigned short)maskquarter); - Translucent2Blitter = W3DNEW BlitTransLucent50((unsigned short const *)Translator, (unsigned short)maskhalf); - Translucent3Blitter = W3DNEW BlitTransLucent25((unsigned short const *)Translator, (unsigned short)maskquarter); - - /* - ** Create the RLE aware blitter objects. - */ - RLETransBlitter = W3DNEW RLEBlitTransXlat((unsigned short const *)Translator); - RLERemapBlitter = W3DNEW RLEBlitTransZRemapXlat(&RemapTable, (unsigned short const *)Translator); - RLEShadowBlitter = W3DNEW RLEBlitTransDarken((unsigned short)maskhalf); - RLETranslucent1Blitter = W3DNEW RLEBlitTransLucent75((unsigned short const *)Translator, (unsigned short)maskquarter); - RLETranslucent2Blitter = W3DNEW RLEBlitTransLucent50((unsigned short const *)Translator, (unsigned short)maskhalf); - RLETranslucent3Blitter = W3DNEW RLEBlitTransLucent25((unsigned short const *)Translator, (unsigned short)maskquarter); - } -} - - -ConvertClass::~ConvertClass(void) -{ - delete PlainBlitter; - PlainBlitter = NULL; - - delete TransBlitter; - TransBlitter = NULL; - - delete ShadowBlitter; - ShadowBlitter = NULL; - - delete RemapBlitter; - RemapBlitter = NULL; - - delete Translucent1Blitter; - Translucent1Blitter = NULL; - - delete Translucent2Blitter; - Translucent2Blitter = NULL; - - delete Translucent3Blitter; - Translucent3Blitter = NULL; - - delete [] Translator; - Translator = NULL; - - delete [] ShadowTable; - ShadowTable = NULL; - - delete RLETransBlitter; - RLETransBlitter = NULL; - - delete RLEShadowBlitter; - RLEShadowBlitter = NULL; - - delete RLERemapBlitter; - RLERemapBlitter = NULL; - - delete RLETranslucent1Blitter; - RLETranslucent1Blitter = NULL; - - delete RLETranslucent2Blitter; - RLETranslucent2Blitter = NULL; - - delete RLETranslucent3Blitter; - RLETranslucent3Blitter = NULL; -} - - -Blitter const * ConvertClass::Blitter_From_Flags(ShapeFlags_Type flags) const -{ - if (flags & SHAPE_REMAP) return(RemapBlitter); - - /* - ** Quick check to see if this is a translucent operation. If so, then no - ** further examination of the flags is necessary. - */ - switch (flags & (SHAPE_TRANSLUCENT25 | SHAPE_TRANSLUCENT50 | SHAPE_TRANSLUCENT75)) { - case SHAPE_TRANSLUCENT25: - return(Translucent3Blitter); - - case SHAPE_TRANSLUCENT50: - return(Translucent2Blitter); - - case SHAPE_TRANSLUCENT75: - return(Translucent1Blitter); - } - - if (flags & SHAPE_DARKEN) return(ShadowBlitter); - - if (flags & SHAPE_NOTRANS) return(PlainBlitter); - - return(TransBlitter); -} - - -RLEBlitter const * ConvertClass::RLEBlitter_From_Flags(ShapeFlags_Type flags) const -{ - if (flags & SHAPE_REMAP) return(RLERemapBlitter); - - /* - ** Quick check to see if this is a translucent operation. If so, then no - ** further examination of the flags is necessary. - */ - switch (flags & (SHAPE_TRANSLUCENT25 | SHAPE_TRANSLUCENT50 | SHAPE_TRANSLUCENT75)) { - case SHAPE_TRANSLUCENT25: - return(RLETranslucent3Blitter); - - case SHAPE_TRANSLUCENT50: - return(RLETranslucent2Blitter); - - case SHAPE_TRANSLUCENT75: - return(RLETranslucent1Blitter); - } - - if (flags & SHAPE_DARKEN) return(RLEShadowBlitter); - - // This should be fixed to return the RLEPlainBlitter when one is available - // but if you need to use this in the mean time just don't RLE compress the - // shape (since it only compresses transparent pixels and the reason we compress - // them is so we can skip them easily.) - if (flags & SHAPE_NOTRANS) return(RLETransBlitter); - - return(RLETransBlitter); -} - - - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp index b4377e653ce..3dde46736b2 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/cpudetect.cpp @@ -20,7 +20,6 @@ #include "wwstring.h" #include "wwdebug.h" #include "thread.h" -#include "MPU.H" #pragma warning (disable : 4201) // Nonstandard extension - nameless struct #include #include "systimer.h" diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.cpp deleted file mode 100644 index 1acca7f8fae..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/data.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 9/24/99 4:52p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Load_Alloc_Data -- Allocates a buffer and loads the file into it. * - * Load_Uncompress -- Loads and uncompresses data to a buffer. * - * Hires_Load -- Allocates memory for, and loads, a resolution dependant file. * - * Fetch_String -- Fetches a string resource. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "always.h" -#include "data.h" - - -/*********************************************************************************************** - * Load_Alloc_Data -- Allocates a buffer and loads the file into it. * - * * - * This is the C++ replacement for the Load_Alloc_Data function. It will allocate the * - * memory big enough to hold the file and then read the file into it. * - * * - * INPUT: file -- The file to read. * - * * - * mem -- The memory system to use for allocation. * - * * - * OUTPUT: Returns with a pointer to the allocated and filled memory block. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -void * Load_Alloc_Data(FileClass & file) -{ - void * ptr = NULL; - if (file.Is_Available()) { - long size = file.Size(); - - ptr = W3DNEWARRAY char[size]; - if (ptr != NULL) { - file.Read(ptr, size); - } - } - return(ptr); -} - - -/*********************************************************************************************** - * Load_Uncompress -- Loads and uncompresses data to a buffer. * - * * - * This is the C++ counterpart to the Load_Uncompress function. It will load the file * - * specified into the graphic buffer indicated and uncompress it. * - * * - * INPUT: file -- The file to load and uncompress. * - * * - * uncomp_buff -- The graphic buffer that initial loading will use. * - * * - * dest_buff -- The buffer that will hold the uncompressed data. * - * * - * reserved_data -- This is an optional pointer to a buffer that will hold any * - * reserved data the compressed file may contain. This is * - * typically a palette. * - * * - * OUTPUT: Returns with the size of the uncompressed data in the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -long Load_Uncompress(FileClass & file, Buffer & uncomp_buff, Buffer & dest_buff, void * reserved_data) -{ - unsigned short size; - void * sptr = uncomp_buff.Get_Buffer(); - void * dptr = dest_buff.Get_Buffer(); - int opened = false; - CompHeaderType header; - - /* - ** The file must be opened in order to be read from. If the file - ** isn't opened, then open it. Record this fact so that it can be - ** restored to its closed state at the end. - */ - if (!file.Is_Open()) { - if (!file.Open()) { - return(0); - } - opened = true; - } - - /* - ** Read in the size of the file (supposedly). - */ - file.Read(&size, sizeof(size)); - - /* - ** Read in the header block. This block contains the compression type - ** and skip data (among other things). - */ - file.Read(&header, sizeof(header)); - size -= (unsigned short)sizeof(header); - - /* - ** If there are skip bytes then they must be processed. Either read - ** them into the buffer provided or skip past them. No check is made - ** to ensure that the reserved data buffer is big enough (watch out!). - */ - if (header.Skip) { - size -= header.Skip; - if (reserved_data) { - file.Read(reserved_data, header.Skip); - } else { - file.Seek(header.Skip, SEEK_CUR); - } - header.Skip = 0; - } - - /* - ** Determine where is the proper place to load the data. If both buffers - ** specified are identical, then the data should be loaded at the end of - ** the buffer and decompressed at the beginning. - */ - if (uncomp_buff.Get_Buffer() == dest_buff.Get_Buffer()) { - sptr = (char *)sptr + uncomp_buff.Get_Size()-(size+sizeof(header)); - } - - /* - ** Read in the bulk of the data. - */ - memmove(sptr, &header, sizeof(header)); -// Mem_Copy(&header, sptr, sizeof(header)); - file.Read((char *)sptr + sizeof(header), size); - - /* - ** Decompress the data. - */ - size = (unsigned short) Uncompress_Data(sptr, dptr); - - /* - ** Close the file if necessary. - */ - if (opened) { - file.Close(); - } - return((long)size); -} - - -typedef struct SRecord { - int ID; // ID number of the string resource. - int TimeStamp; // 'Time' that this string was last requested. - char String[2048]; // Copy of string resource. - - SRecord(void) : ID(-1), TimeStamp(-1) {} -} SRecord; - - -/*********************************************************************************************** - * Fetch_String -- Fetches a string resource. * - * * - * Fetches a string resource and returns a pointer to its text. * - * * - * INPUT: id -- The ID number of the string resource to fetch. * - * * - * OUTPUT: Returns with a pointer to the actual text of the string resource. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/25/1996 JLB : Created. * - *=============================================================================================*/ -char const * Fetch_String(int id) -{ -#ifdef _UNIX - return(""); -#else - static SRecord _buffers[64]; - static int _time = 0; - - /* - ** Determine if the string ID requested is valid. If not then return an empty string pointer. - */ - if (id == -1 || id == TXT_NONE) return(""); - - /* - ** Adjust the 'time stamp' tracking value. This is an artificial value used merely to track - ** the relative age of the strings requested. - */ - _time = _time+1; - - /* - ** Check to see if the requested string has already been fetched into a buffer. If so, then - ** return a pointer to that string (update the time stamp as well). - */ - for (int index = 0; index < ARRAY_SIZE(_buffers); index++) { - if (_buffers[index].ID == id) { - _buffers[index].TimeStamp = _time; - return(_buffers[index].String); - } - } - - /* - ** Find a suitable buffer to hold the string to be fetched. The buffer should either be - ** empty or have the oldest fetched string. - */ - int oldest = -1; - int oldtime = -1; - for (int text = 0; text < ARRAY_SIZE(_buffers); text++) { - if (oldest == -1 || oldtime > _buffers[text].TimeStamp) { - oldest = text; - oldtime = _buffers[text].TimeStamp; - if (oldtime == -1 || _buffers[text].ID == -1) break; - } - } - - /* - ** A suitable buffer has been found so fetch the string resource and then return a pointer - ** to the string. - */ - char * stringptr = _buffers[oldest].String; - _buffers[oldest].ID = id; - _buffers[oldest].TimeStamp = _time; - if (LoadString(ProgramInstance, id, stringptr, sizeof(_buffers[oldest].String)) == 0) { - return(""); - } - stringptr[sizeof(_buffers[oldest].String)-1] = '\0'; - return(stringptr); -#endif -} - - -void const * Fetch_Resource(LPCSTR resname, LPCSTR restype) -{ -#ifdef _UNIX - return(NULL); -#else - /* - ** Fetch the program instance if it hasn't already been recorded. - */ -// if (ProgramInstance == 0) { -// ProgramInstance = GetModuleHandle("LANGUAGE"); -// } - - HRSRC handle = FindResource(ProgramInstance, resname, restype); - if (handle == NULL) { - return(NULL); - } - - HGLOBAL rhandle = LoadResource(ProgramInstance, handle); - if (rhandle == NULL) { - return(NULL); - } - - return(LockResource(rhandle)); -#endif -} - - -int Load_Picture(FileClass & file, Buffer & scratchbuf, Buffer & destbuf, unsigned char * palette, PicturePlaneType ) -{ - return(Load_Uncompress(file, scratchbuf, destbuf, palette ) / 8000); -} - - -/*********************************************************************************************** - * Hires_Load -- Allocates memory for, and loads, a resolution dependant file. * - * * - * * - * * - * INPUT: Name of file to load * - * * - * OUTPUT: Ptr to loaded file * - * * - * WARNINGS: Caller is responsible for releasing the memory allocated * - * * - * * - * HISTORY: * - * 5/13/96 3:20PM ST : Created * - *=============================================================================================*/ -void * Hires_Load(FileClass & file) -{ - int length; - void * return_ptr; - - if (file.Is_Available()) { - - length = file.Size(); - return_ptr = W3DNEWARRAY char[length]; - file.Read(return_ptr, length); - return (return_ptr); - - } else { - return (NULL); - } -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.h deleted file mode 100644 index 2b534f74bb9..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/data.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/data.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef DATA_H -#define DATA_H - -#include "BUFF.H" -#include "IFF.H" -#include "win.h" -#include "WWFILE.H" - -#define TXT_NONE 0 - -int Load_Picture(FileClass &file, Buffer & scratchbuf, Buffer & destbuf, unsigned char * palette, PicturePlaneType format); -void * Load_Alloc_Data(FileClass & file); -long Load_Uncompress(FileClass & file, Buffer & uncomp_buff, Buffer & dest_buff, void * reserved_data); -char const * Fetch_String(int id); -void const * Fetch_Resource(LPCSTR resname, LPCSTR restype); - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp deleted file mode 100644 index f9ef36a9631..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ddraw.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/DDRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 10/15/98 11:05a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Set_Video_Mode -- Initializes Direct Draw and sets the required Video Mode * - * Process_DD_Result -- Does a message box based on the result of a DD command * - * Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object * - * Get_Free_Video_Memory -- returns amount of free video memory * - * Get_Video_Hardware_Caps -- returns bitmask of direct draw video hardware support * - * Wait_Vert_Blank -- Waits for the start (leading edge) of a vertical blank * - * Set_Palette -- set a direct draw palette * - * Check_Overlapped_Blit_Capability -- See if video driver supports blitting overlapped regions* - * Wait_Blit -- waits for the DirectDraw blitter to become idle * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "misc.h" -#include "dsurface.h" -#include "data.h" -#include "_timer.h" -#include -#include - - -LPDIRECTDRAW DirectDrawObject = NULL; // Pointer to the direct draw object -LPDIRECTDRAW2 DirectDraw2Interface = NULL; // Pointer to direct draw 2 interface - -static PALETTEENTRY PaletteEntries[256]; // 256 windows palette entries -static LPDIRECTDRAWPALETTE PalettePtr; // Pointer to direct draw palette object -static bool FirstPaletteSet = false; // Is this the first time 'Set_Palette' has been called? -LPDIRECTDRAWSURFACE PaletteSurface = NULL; -bool SurfacesRestored = false; -static bool CanVblankSync = true; - -unsigned char CurrentPalette[768]; -bool Debug_Windowed; - -int (*DirectDrawErrorHandler)(HRESULT error) = NULL; - -void Set_Palette(PaletteClass const & pal, int time, void (*callback)()) -{ - CDTimerClass timer = time; - PaletteClass original; - memcpy(&original, CurrentPalette, sizeof(CurrentPalette)); - PaletteClass newpal = pal; - - while (timer) { - - /* - ** Build an intermediate palette that is as close to the destination palette - ** as the current time is proportional to the ending time. - */ - PaletteClass palette = original; - int adjust = ((time - timer) * 256) / time; - adjust = MIN(adjust, 255); - palette.Adjust(adjust, newpal); - - /* - ** Remember the current time so that multiple palette sets within the same game - ** time tick won't occur. This is probably unnecessary since the palette setting - ** code, at the time of this writing, delays at least one game tick in the process - ** of setting the palette. - */ - int holdtime = timer; - - /* - ** Set the palette to this intermediate palette and then loop back - ** to calculate and set a new intermediate palette. - */ - Set_Palette((void*)&palette[0]); - - /* - ** If the callback routine was specified, then call it once per palette - ** setting loop. - */ - if (callback) { - callback(); - } - - /* - ** This loop ensures that the palette won't be set more than once per game tick. Setting - ** the palette more than once per game tick will have no effect since the calculation will - ** result in the same intermediate palette that was previously calculated. - */ - while (timer == holdtime && holdtime != 0) { - if (callback) callback(); - } - } - - /* - ** Ensure that the final palette exactly matches the requested - ** palette before exiting the fading routine. - */ - Set_Palette((void*)&newpal[0]); -} - - -/*********************************************************************************************** - * Process_DD_Result -- Does a message box based on the result of a DD command * - * * - * INPUT: HRESULT result - the result returned from the direct draw command * - * int display_ok_msg - should a message be displayed if command ok * * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 09/27/1995 PWG : Created. * - *=============================================================================================*/ -void Process_DD_Result(HRESULT result, int display_ok_msg) -{ -#ifdef _DEBUG - static struct { - HRESULT Error; - char const * Message; - } _errors[] = { - {DDERR_ALREADYINITIALIZED, "This object is already initialized"}, - {DDERR_BLTFASTCANTCLIP, "Return if a clipper object is attached to the source surface passed into a BltFast call."}, - {DDERR_CANNOTATTACHSURFACE, "This surface can not be attached to the requested surface."}, - {DDERR_CANNOTDETACHSURFACE, "This surface can not be detached from the requested surface."}, - {DDERR_CANTCREATEDC, "Windows can not create any more DCs"}, - {DDERR_CANTDUPLICATE, "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created."}, - {DDERR_CANTLOCKSURFACE, "Unable to lock surface because no driver exists which can supply a pointer to the surface."}, - {DDERR_CLIPPERISUSINGHWND, "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd."}, - {DDERR_COLORKEYNOTSET, "No src color key specified for this operation."}, - {DDERR_CURRENTLYNOTAVAIL, "Support is currently not available."}, - {DDERR_DIRECTDRAWALREADYCREATED, "A DirectDraw object representing this driver has already been created for this process."}, - {DDERR_EXCEPTION, "An exception was encountered while performing the requested operation."}, - {DDERR_EXCLUSIVEMODEALREADYSET, "An attempt was made to set the cooperative level when it was already set to exclusive."}, - {DDERR_GENERIC, "Generic failure."}, - {DDERR_HEIGHTALIGN, "Height of rectangle provided is not a multiple of reqd alignment."}, - {DDERR_HWNDALREADYSET, "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created."}, - {DDERR_HWNDSUBCLASSED, "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state."}, - {DDERR_IMPLICITLYCREATED, "This surface can not be restored because it is an implicitly created surface."}, - {DDERR_INCOMPATIBLEPRIMARY, "Unable to match primary surface creation request with existing primary surface."}, - {DDERR_INVALIDCAPS, "One or more of the caps bits passed to the callback are incorrect."}, - {DDERR_INVALIDCLIPLIST, "DirectDraw does not support the provided cliplist."}, - {DDERR_INVALIDDIRECTDRAWGUID, "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier."}, - {DDERR_INVALIDMODE, "DirectDraw does not support the requested mode."}, - {DDERR_INVALIDOBJECT, "DirectDraw received a pointer that was an invalid DIRECTDRAW object."}, - {DDERR_INVALIDPARAMS, "One or more of the parameters passed to the function are incorrect."}, - {DDERR_INVALIDPIXELFORMAT, "The pixel format was invalid as specified."}, - {DDERR_INVALIDPOSITION, "Returned when the position of the overlay on the destination is no longer legal for that destination."}, - {DDERR_INVALIDRECT, "Rectangle provided was invalid."}, - {DDERR_INVALIDSURFACETYPE, "The requested action could not be performed because the surface was of the wrong type."}, - {DDERR_LOCKEDSURFACES, "Operation could not be carried out because one or more surfaces are locked."}, - {DDERR_NO3D, "There is no 3D present."}, - {DDERR_NOALPHAHW, "Operation could not be carried out because there is no alpha accleration hardware present or available."}, -// {DDERR_NOANTITEARHW, "Operation could not be carried out because there is no hardware support for synchronizing blts to avoid tearing. "}, - {DDERR_NOBLTHW, "No blter hardware present."}, -// {DDERR_NOBLTQUEUEHW, "Operation could not be carried out because there is no hardware support for asynchronous blting."}, - {DDERR_NOCLIPLIST, "No cliplist available."}, - {DDERR_NOCLIPPERATTACHED, "No clipper object attached to surface object."}, - {DDERR_NOCOLORCONVHW, "Operation could not be carried out because there is no color conversion hardware present or available."}, - {DDERR_NOCOLORKEY, "Surface doesn't currently have a color key"}, - {DDERR_NOCOLORKEYHW, "Operation could not be carried out because there is no hardware support of the destination color key."}, - {DDERR_NOCOOPERATIVELEVELSET, "Create function called without DirectDraw object method SetCooperativeLevel being called."}, - {DDERR_NODC, "No DC was ever created for this surface."}, - {DDERR_NODDROPSHW, "No DirectDraw ROP hardware."}, - {DDERR_NODIRECTDRAWHW, "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware."}, - {DDERR_NODIRECTDRAWSUPPORT, "No DirectDraw support possible with current display driver."}, - {DDERR_NOEMULATION, "Software emulation not available."}, - {DDERR_NOEXCLUSIVEMODE, "Operation requires the application to have exclusive mode but the application does not have exclusive mode."}, - {DDERR_NOFLIPHW, "Flipping visible surfaces is not supported."}, - {DDERR_NOGDI, "There is no GDI present."}, - {DDERR_NOHWND, "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND."}, - {DDERR_NOMIRRORHW, "Operation could not be carried out because there is no hardware present or available."}, - {DDERR_NOOVERLAYDEST, "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination."}, - {DDERR_NOOVERLAYHW, "Operation could not be carried out because there is no overlay hardware present or available."}, - {DDERR_NOPALETTEATTACHED, "No palette object attached to this surface. "}, - {DDERR_NOPALETTEHW, "No hardware support for 16 or 256 color palettes."}, - {DDERR_NORASTEROPHW, "Operation could not be carried out because there is no appropriate raster op hardware present or available."}, - {DDERR_NOROTATIONHW, "Operation could not be carried out because there is no rotation hardware present or available."}, - {DDERR_NOSTRETCHHW, "Operation could not be carried out because there is no hardware support for stretching."}, - {DDERR_NOT4BITCOLOR, "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette."}, - {DDERR_NOT4BITCOLORINDEX, "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette."}, - {DDERR_NOT8BITCOLOR, "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color."}, - {DDERR_NOTAOVERLAYSURFACE, "Returned when an overlay member is called for a non-overlay surface."}, - {DDERR_NOTEXTUREHW, "Operation could not be carried out because there is no texture mapping hardware present or available."}, - {DDERR_NOTFLIPPABLE, "An attempt has been made to flip a surface that is not flippable."}, - {DDERR_NOTFOUND, "Requested item was not found."}, - {DDERR_NOTLOCKED, "Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted."}, - {DDERR_NOTPALETTIZED, "The surface being used is not a palette-based surface."}, - {DDERR_NOVSYNCHW, "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations."}, - {DDERR_NOZBUFFERHW, "Operation could not be carried out because there is no hardware support for zbuffer blting."}, - {DDERR_NOZOVERLAYHW, "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays."}, - {DDERR_OUTOFCAPS, "The hardware needed for the requested operation has already been allocated."}, - {DDERR_OUTOFMEMORY, "DirectDraw does not have enough memory to perform the operation."}, - {DDERR_OUTOFVIDEOMEMORY, "DirectDraw does not have enough memory to perform the operation."}, - {DDERR_OVERLAYCANTCLIP, "The hardware does not support clipped overlays."}, - {DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "Can only have ony color key active at one time for overlays."}, - {DDERR_OVERLAYNOTVISIBLE, "Returned when GetOverlayPosition is called on a hidden overlay."}, - {DDERR_PALETTEBUSY, "Access to this palette is being refused because the palette is already locked by another thread."}, - {DDERR_PRIMARYSURFACEALREADYEXISTS, "This process already has created a primary surface."}, - {DDERR_REGIONTOOSMALL, "Region passed to Clipper::GetClipList is too small."}, - {DDERR_SURFACEALREADYATTACHED, "This surface is already attached to the surface it is being attached to."}, - {DDERR_SURFACEALREADYDEPENDENT, "This surface is already a dependency of the surface it is being made a dependency of."}, - {DDERR_SURFACEBUSY, "Access to this surface is being refused because the surface is already locked by another thread."}, - {DDERR_SURFACEISOBSCURED, "Access to surface refused because the surface is obscured."}, - {DDERR_SURFACELOST, "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it."}, - {DDERR_SURFACENOTATTACHED, "The requested surface is not attached."}, - {DDERR_TOOBIGHEIGHT, "Height requested by DirectDraw is too large."}, - {DDERR_TOOBIGSIZE, "Size requested by DirectDraw is too large -- the individual height and width are OK."}, - {DDERR_TOOBIGWIDTH, "Width requested by DirectDraw is too large."}, - {DDERR_UNSUPPORTED, "Action not supported."}, - {DDERR_UNSUPPORTEDFORMAT, "FOURCC format requested is unsupported by DirectDraw."}, - {DDERR_UNSUPPORTEDMASK, "Bitmask in the pixel format requested is unsupported by DirectDraw."}, - {DDERR_VERTICALBLANKINPROGRESS, "Vertical blank is in progress."}, - {DDERR_WASSTILLDRAWING, "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete."}, - {DDERR_WRONGMODE, "This surface can not be restored because it was created in a different mode."}, - {DDERR_XALIGN, "Rectangle provided was not horizontally aligned on required boundary."} - }; -#endif - /* - ** If there iwas no error detected, then either bail out or display a message to - ** this effect as indicated by the "display_ok_msg" parameter. - */ - if (result == DD_OK) { - if (display_ok_msg) { - MessageBox(MainWindow, "Direct Draw operation processed without error", "Note", MB_OK); - } - return; - } - - if (DirectDrawErrorHandler) { - DirectDrawErrorHandler(result); - return; - } -#ifdef _DEBUG - /* - ** Scan for a matching error code and display the appropriate message. - */ - for (int index = 0; index < ARRAY_SIZE(_errors); index++) { - if (_errors[index].Error == result) { - MessageBox(MainWindow, _errors[index].Message, "Westwood Library Direct Draw Error", MB_ICONEXCLAMATION|MB_OK); - return; - } - } -#endif - - /* - ** Since it fell out of the above loop, this must be an unrecognized error code. - */ - char str[80]; - sprintf(str, "DDRAW.DLL Error code = %08X", result); - MessageBox(MainWindow, str, "Direct X", MB_ICONEXCLAMATION|MB_OK); -} - - -/*********************************************************************************************** - * Check_Overlapped_Blit_Capability -- See if video driver supports blitting overlapped regions* - * * - * We will check for this by drawing something to a video page and blitting it over itself. * - * If we end up with the top line repeating then overlapped region blits dont work. * - * * - * INPUT: Nothing * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 6/7/96 5:06PM ST : Created * - *=============================================================================================*/ -void Check_Overlapped_Blit_Capability(void) -{ -// OverlappedVideoBlits = false; - -#ifdef NEVER - /* - ** Assume we can until we find out otherwise - */ - OverlappedVideoBlits = true; - - GraphicBufferClass test_buffer; - - test_buffer.Init (64, 64, NULL, 0, (GBC_Enum)GBC_VIDEOMEM); - - test_buffer.Clear(); - - /* - ** Plot a pixel in the top left corner of the buffer. - */ - test_buffer.Put_Pixel(0, 0, 255); - - /* - ** Blit the buffer down by one line. If we end up with a vertical strip of pixel 255's then - ** overlapped blits dont work - */ - - test_buffer.Blit(test_buffer, 0, 0, 0, 1, test_buffer.Get_Width(), test_buffer.Get_Height()-1); - - if (test_buffer.Get_Pixel(0, 5) == 255) OverlappedVideoBlits = false; -#endif -} - - -void Prep_Direct_Draw(void) -{ - // - // If there is not currently a direct draw object then we need to define one. - // - if ( DirectDrawObject == NULL ) { - HRESULT result = DirectDrawCreate(NULL, &DirectDrawObject, NULL); - Process_DD_Result(result, false); - if (result == DD_OK) { - if (Debug_Windowed) { - result = DirectDrawObject->SetCooperativeLevel(MainWindow, DDSCL_NORMAL); - } else { - result = DirectDrawObject->SetCooperativeLevel(MainWindow, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); - } - Process_DD_Result(result, false); - } - } -} - - - -/*********************************************************************************************** - * Set_Video_Mode -- Initializes Direct Draw and sets the required Video Mode * - * * - * INPUT: int width - the width of the video mode in pixels * - * int height - the height of the video mode in pixels * - * int bits_per_pixel - the number of bits per pixel the video mode supports * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 09/26/1995 PWG : Created. * - *=============================================================================================*/ -bool Set_Video_Mode(HWND , int w, int h, int bits_per_pixel) -{ - HRESULT result; - - Prep_Direct_Draw(); - - // - // Set the required display mode with 8 bits per pixel - // - //MessageBox(MainWindow, "In Set_Video_Mode. About to call call SetDisplayMode.","Note", MB_ICONEXCLAMATION|MB_OK); - result = DirectDrawObject->SetDisplayMode(w, h, bits_per_pixel); - if (result != DD_OK) { -// Process_DD_Result(result, false); - DirectDrawObject->Release(); - DirectDrawObject = NULL; - return(false); - } - - // - // Create a direct draw palette object - // - //MessageBox(MainWindow, "In Set_Video_Mode. About to call CreatePalette.","Note", MB_ICONEXCLAMATION|MB_OK); - result = DirectDrawObject->CreatePalette( DDPCAPS_8BIT | DDPCAPS_ALLOW256, &PaletteEntries[0], &PalettePtr, NULL); - Process_DD_Result(result, false); - if (result != DD_OK) { - return (false); - } - - Check_Overlapped_Blit_Capability(); - - //MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); -#if (0) - /* - ** Find out if DirectX 2 extensions are available - */ - result = DirectDrawObject->QueryInterface (IID_IDirectDraw2, (LPVOID*)&DirectDraw2Interface); - SystemToVideoBlits = false; - VideoToSystemBlits = false; - SystemToSystemBlits= false; - if (result != DD_OK) { - DirectDraw2Interface = NULL; - } else { - DDCAPS capabilities; - DDCAPS emulated_capabilities; - - memset ((char*)&capabilities, 0, sizeof(capabilities)); - memset ((char*)&emulated_capabilities, 0, sizeof(emulated_capabilities)); - capabilities.dwSize = sizeof (capabilities); - emulated_capabilities.dwSize = sizeof (emulated_capabilities); - - DirectDrawObject->GetCaps (&capabilities, &emulated_capabilities); - - if (capabilities.dwCaps & DDCAPS_CANBLTSYSMEM) { - SystemToVideoBlits = (capabilities.dwSVBCaps & DDCAPS_BLT) ? true : false; - VideoToSystemBlits = (capabilities.dwVSBCaps & DDCAPS_BLT) ? true : false; - SystemToSystemBlits = (capabilities.dwSSBCaps & DDCAPS_BLT) ? true : false; - } - } -#endif //(0) - - //MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); - - return (true); - -} - -/*********************************************************************************************** - * Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: * - * * - * HISTORY: * - * 09/26/1995 PWG : Created. * - *=============================================================================================*/ -void Reset_Video_Mode(void) -{ - HRESULT result; - - // - // If a direct draw object has been declared and a video mode has been set - // then reset the video mode and release the direct draw object. - // - if ( DirectDrawObject ) { - result = DirectDrawObject->RestoreDisplayMode(); - Process_DD_Result(result, false); - result = DirectDrawObject->Release(); - Process_DD_Result(result, false); - - DirectDrawObject = NULL; - } -} - - -/*********************************************************************************************** - * Get_Free_Video_Memory -- returns amount of free video memory * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: bytes of available video RAM * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 11/29/95 12:52PM ST : Created * - *=============================================================================================*/ -unsigned int Get_Free_Video_Memory(void) -{ - DDCAPS video_capabilities; - - if (DirectDrawObject) { - - video_capabilities.dwSize = sizeof (video_capabilities); - - if (DD_OK == DirectDrawObject->GetCaps (&video_capabilities, NULL)) { - char string [256]; - wsprintf (string, "In Get_Free_Video_Memory. About to return %d bytes",video_capabilities.dwVidMemFree); - return (video_capabilities.dwVidMemFree); - } - } - - return (0); -} - - -/*********************************************************************************************** - * Get_Video_Hardware_Caps -- returns bitmask of direct draw video hardware support * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: hardware flags * - * * - * WARNINGS: Must call Set_Video_Mode 1st to create the direct draw object * - * * - * HISTORY: * - * 1/12/96 9:14AM ST : Created * - *=============================================================================================*/ -unsigned Get_Video_Hardware_Capabilities(void) -{ - DDCAPS video_capabilities; - unsigned video; - - /* - ** Fail if the direct draw object has not been initialised - */ - if (!DirectDrawObject) return (0); - - /* - ** Get the capabilities of the direct draw object - */ - video_capabilities.dwSize = sizeof(video_capabilities); - //MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to call GetCaps","Note", MB_ICONEXCLAMATION|MB_OK); - HRESULT result = DirectDrawObject->GetCaps (&video_capabilities, NULL); - if (result != DD_OK) { - Process_DD_Result(result, false); - return (0); - } - - /* - ** Set flags to indicate the presence of the features we are interested in - */ - video = 0; - - /* Hardware blits supported? */ - if (video_capabilities.dwCaps & DDCAPS_BLT) video |= VIDEO_BLITTER; - - /* Hardware blits asyncronous? */ - if (video_capabilities.dwCaps & DDCAPS_BLTQUEUE) video |= VIDEO_BLITTER_ASYNC; - - /* Can palette changes be synced to vertical refresh? */ - if (video_capabilities.dwCaps & DDCAPS_PALETTEVSYNC) video |= VIDEO_SYNC_PALETTE; - - /* Is the video cards memory bank switched? */ - if (video_capabilities.dwCaps & DDCAPS_BANKSWITCHED) video |= VIDEO_BANK_SWITCHED; - - /* Can the blitter do filled rectangles? */ - if (video_capabilities.dwCaps & DDCAPS_BLTCOLORFILL) video |= VIDEO_COLOR_FILL; - - /* Is there no hardware assistance avaailable at all? */ - if (video_capabilities.dwCaps & DDCAPS_NOHARDWARE) video |= VIDEO_NO_HARDWARE_ASSIST; - - //MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK); - return (video); -} - - -/*********************************************************************************************** - * Wait_Vert_Blank -- Waits for the start (leading edge) of a vertical blank * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void Wait_Vert_Blank(void) -{ - if (CanVblankSync) { - HRESULT result = DirectDrawObject->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); - if (result == E_NOTIMPL) { - CanVblankSync = false; - return; - } - Process_DD_Result(result, false); - } -} - - -/*********************************************************************************************** - * Set_Palette -- set a direct draw palette * - * * - * * - * * - * INPUT: ptr to 768 rgb palette bytes * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 10/11/95 3:33PM ST : Created * - *=============================================================================================*/ -void Set_Palette(void const * palette) -{ - assert(palette != NULL); - - if (&CurrentPalette[0] != palette) { - memmove(CurrentPalette, palette, sizeof(CurrentPalette)); - } - - if (DirectDrawObject != NULL && PaletteSurface != NULL) { - unsigned char * palette_get = (unsigned char *)palette; - for (int index = 0; index < 256; index++) { - - int red = *palette_get++; - int green = *palette_get++; - int blue = *palette_get++; - - PaletteEntries[index].peRed = (unsigned char)red; - PaletteEntries[index].peGreen = (unsigned char)green; - PaletteEntries[index].peBlue = (unsigned char)blue; - } - - if (PalettePtr != NULL) { - if (!FirstPaletteSet) { - PaletteSurface->SetPalette(PalettePtr); - FirstPaletteSet = true; - } - - PalettePtr->SetEntries(0, 0, 256, &PaletteEntries[0]); - } - } -} - - -/*********************************************************************************************** - * Wait_Blit -- waits for the DirectDraw blitter to become idle * - * * - * * - * * - * INPUT: Nothing * - * * - * OUTPUT: Nothing * - * * - * WARNINGS: None * - * * - * HISTORY: * - * 07-25-95 03:53pm ST : Created * - *=============================================================================================*/ -void Wait_Blit (void) -{ - HRESULT return_code; - - do { - return_code=PaletteSurface->GetBltStatus (DDGBS_ISBLTDONE); - } while (return_code != DD_OK && return_code != DDERR_SURFACELOST); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.cpp deleted file mode 100644 index 9338ef9a309..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/dib.cpp $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 3/29/99 5:11p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DIB8C::DIB8Class -- constructor * - * DIB8C::~DIB8Class -- destructor * - * DIB8C::Clear -- clears the DIB * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "dib.h" -#include - -/*********************************************************************************************** - * DIB8C::DIB8Class -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/18/1997 GH : Created. * - *=============================================================================================*/ -DIB8Class::DIB8Class(HWND hwnd,int width,int height,PaletteClass & pal): - IsZombie(false), - Info(NULL), - Handle(0), - Pixels(NULL), - Width(width), - Height(height), - PixelBase(NULL), - Pitch(NULL), - Surface(NULL) -{ - // Allocate a BITMAPINFO structure - Info = (BITMAPINFO *) new char [sizeof(BITMAPINFO) + 256*sizeof(RGBQUAD)]; - - if (Info == NULL) { - IsZombie = true; - return; - } - - // Describe the type of DIB we want. - Info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - Info->bmiHeader.biWidth = width; - Info->bmiHeader.biHeight = -height; //ask for a top-down dib. - Info->bmiHeader.biPlanes = 1; - Info->bmiHeader.biBitCount = 8; - Info->bmiHeader.biCompression = BI_RGB; - Info->bmiHeader.biSizeImage = 0; - Info->bmiHeader.biXPelsPerMeter = 0; - Info->bmiHeader.biYPelsPerMeter = 0; - Info->bmiHeader.biClrUsed = 256; - Info->bmiHeader.biClrImportant = 256; - - // Fill in the DIB's palette. - for (int i=0; i<256; i++) { - Info->bmiColors[i].rgbBlue = (unsigned char)pal[i].Get_Blue(); - Info->bmiColors[i].rgbGreen = (unsigned char)pal[i].Get_Green(); - Info->bmiColors[i].rgbRed = (unsigned char)pal[i].Get_Red(); - Info->bmiColors[i].rgbReserved = 0; - } - - // Create the DIB. - HDC hdc = GetDC(hwnd); - Handle = CreateDIBSection(hdc, Info, DIB_RGB_COLORS,(void**)&Pixels, NULL, 0); - ReleaseDC(hwnd, hdc); - - if (!Handle) { - IsZombie = true; - return; - } - - Width = Info->bmiHeader.biWidth; - Height = abs(Info->bmiHeader.biHeight); - Pitch = (Width + 3) & 0xfffffffC; - - // Check if the DIB is bottom-up or top-down. - // (it better be top-down, thats what I'm asking for!!!) - if (Info->bmiHeader.biHeight > 0) { - - // bottom-up DIB - PixelBase = (Pixels + (Height - 1) * Width); - Pitch = -Pitch; - - } else { - - // top-down DIB - PixelBase = Pixels; - Pitch = Pitch; - } - - // Now, wrap a BSurface around the DIB. - int surfwid = abs(Pitch); - Surface = new BSurface(surfwid,Height,1,Pixels); - - if (Surface == NULL) { - IsZombie = true; - return; - } -} - - -/*********************************************************************************************** - * DIB8C::~DIB8Class -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/18/1997 GH : Created. * - *=============================================================================================*/ -DIB8Class::~DIB8Class(void) -{ - if (Info) delete [] Info; - if (Handle) DeleteObject(Handle); - if (Surface) delete Surface; -} - - -/*********************************************************************************************** - * DIB8C::Clear -- clears the DIB * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/18/1997 GH : Created. * - *=============================================================================================*/ -void DIB8Class::Clear(unsigned char color) -{ - if (Pixels) { - memset(Pixels, color, Width*Height); - } -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.h deleted file mode 100644 index 729e453f6cc..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dib.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/dib.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/26/97 11:33a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DIB_H -#define DIB_H - -#include "always.h" -#include "bsurface.h" -#include "PALETTE.H" -#include "win.h" - - -class DIB8Class -{ -public: - - DIB8Class(HWND hwnd,int width, int height, PaletteClass & pal); - ~DIB8Class(void); - - HBITMAP Get_Handle() { return Handle; } - int Get_Width(void) { return Width; } - int Get_Height(void) { return Height; } - Surface & Get_Surface(void) { return *Surface; } - - void Clear(unsigned char color); - -private: - - bool IsZombie; // object constructor failed, its a living-dead object! - BITMAPINFO * Info; // info used in creating the dib + the palette. - HBITMAP Handle; // handle to the actual dib - unsigned char * Pixels; // address of memory containing the pixel data - int Width; // width of the dib - int Height; // height of the dib - unsigned char * PixelBase; // address of upper left pixel (this and DIBPitch abstract up/down DIBS) - int Pitch; // offset from DIBPixelBase to next row (can be negative for bottom-up DIBS) - - BSurface * Surface; // Bsurface wrapped around the pixel buffer. -}; - - -#endif /*DIB_H*/ \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.cpp deleted file mode 100644 index cbc5abb4b82..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Draw.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Blit_Block -- Blit a block of data to the surface. * - * Draw_Shape -- Draw a shape to the surface. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blit.h" -#include "blitblit.h" -#include "blitter.h" -#include "bsurface.h" -#include "draw.h" -#include "dsurface.h" -#include "hsv.h" -#include "rlerle.h" -#include "shapeset.h" - - -/*********************************************************************************************** - * Draw_Shape -- Draw a shape to the surface. * - * * - * This is the largely general purpose shape drawing routine for the game. All non-voxel * - * shape drawing will pass through this routine. * - * * - * INPUT: surface -- The destination surface for the draw. * - * * - * convert -- The converter to use for the pixel transformation. * - * * - * shapefile -- Pointer to the shapefile data block. * - * * - * shapenum -- The shape number within the shape file data block specified. * - * * - * point -- The draw point for this shape on the destination surface. This point * - * is relative to the clipping window. * - * * - * window -- The clipping window to use for this draw. * - * * - * flags -- Shape draw control flags. These flags are used to extract the * - * proper blitter from the converter object. * - * * - * remap -- Auxiliary remap table used for the draw process. House ownership can * - * be controlled with this parameter. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -void Draw_Shape(Surface & surface, ConvertClass & convert, ShapeSet const * shapefile, int shapenum, Point2D const & point, Rect const & window, ShapeFlags_Type flags, unsigned char const * remap) -{ - assert((flags & SHAPE_PREDATOR) == 0); // Not yet supported. - assert(shapefile != NULL); - assert(shapenum != -1); - - convert.Set_Remap(remap); - int x = point.X; - int y = point.Y; - Rect rect = shapefile->Get_Rect(shapenum); - void const * buffer = shapefile->Get_Data(shapenum); - int width = shapefile->Get_Width(); - int height = shapefile->Get_Height(); - BSurface const shape(rect.Width, rect.Height, 1, (void *)buffer); - - /* - ** Centered shapes must have their start position adjusted - ** according to their width and height. - */ - if (flags & SHAPE_CENTER) { - x -= width/2; - y -= height/2; - } - - /* - ** Factor the offset of the shape data (logical) into the draw - ** position. Since the actual embedded shape pixels have no - ** (transparent) offset, remove the offset coefficient. - */ - x += rect.X; - y += rect.Y; - rect.X = 0; - rect.Y = 0; - - /* - ** If the remap table supplied is not NULL, then set the remap flag so that - ** the appropriate blitter will be selected. - */ - if (remap != NULL) { - flags = ShapeFlags_Type(flags | SHAPE_REMAP); - } - - /* - ** Blit the pixels according to the flags specified and whether this is - ** an RLE compressed shape. RLE compression uses different blitter routines - ** than the normal method. - */ - if (shapefile->Is_RLE_Compressed(shapenum)) { - RLEBlitter const * blitter = convert.RLEBlitter_From_Flags(flags); - if (blitter != NULL) { - RLE_Blit(surface, window, Rect(x, y, rect.Width, rect.Height), shape, rect, rect, *blitter); - - } - } else { - Blitter const * blitter = convert.Blitter_From_Flags(flags); - if (blitter != NULL) { - Bit_Blit(surface, window, Rect(x, y, rect.Width, rect.Height), shape, shape.Get_Rect(), rect, *blitter); - } - } -} - - -/*********************************************************************************************** - * Blit_Block -- Blit a block of data to the surface. * - * * - * This function serves as a wrapper to the normal Bit_Blit function. It is used to control * - * the blitter according to remap parameter specified. * - * * - * INPUT: surface -- The destination surface of this blit. * - * * - * convert -- The convert class for pixel transformation. * - * * - * source -- The source surface to blit from. * - * * - * sourcerect -- The source rectangle within the source surface to blit from. * - * * - * point -- The draw point of this blit (upper left corner). * - * * - * window -- The clipping window for this blit. The destination rectangle is * - * relative to this clipping window. * - * * - * remap -- The remapping table pointer (optional) to be used for ownership * - * remapping control. * - * * - * blitter -- Preexisting blitter to use. If this parameter is NULL, then a blitter * - * object is created from the convert object supplied. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -void Blit_Block(Surface & surface, ConvertClass & convert, Surface const & source, Rect const & sourcerect, Point2D const & point, Rect const & window, unsigned char const * remap, Blitter const * blitter) -{ - convert.Set_Remap(remap); - - if (blitter == NULL) { - blitter = convert.Blitter_From_Flags((remap != NULL) ? SHAPE_REMAP : SHAPE_NORMAL); - } - - /* - ** Submit the image to the destination surface. - */ - Bit_Blit(surface, window, Rect(point.X, point.Y, sourcerect.Width, sourcerect.Height), source, source.Get_Rect(), sourcerect, *blitter); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.h deleted file mode 100644 index 7fe6c1bd97f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/draw.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Draw.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DRAW_H -#define DRAW_H - -#include "Convert.h" -#include "Point.h" -#include "shapeset.h" - -void Draw_Shape(Surface & surface, ConvertClass & convert, ShapeSet const * shapefile, int shapenum, Point2D const & point, Rect const & window, ShapeFlags_Type flags = SHAPE_NORMAL, unsigned char const * remap = NULL); -void Blit_Block(Surface & surface, ConvertClass & convert, Surface const & source, Rect const & sourcerect, Point2D const & point, Rect const & clipwindow, unsigned char const * remap = NULL, Blitter const * blitter = NULL); - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp deleted file mode 100644 index 35365621a24..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.cpp +++ /dev/null @@ -1,931 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/dsurface.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 6/23/00 2:26p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DSurface::Blit_From -- Blit from one surface to this one. * - * DSurface::Blit_From -- Blit graphic memory from one rectangle to another. * - * DSurface::Build_Hicolor_Pixel -- Construct a hicolor pixel according to the surface pixel * - * DSurface::Build_Remap_Table -- Build a highcolor remap table. * - * DSurface::Bytes_Per_Pixel -- Fetches the bytes per pixel of the surface. * - * DSurface::Create_Primary -- Creates a primary (visible) surface. * - * DSurface::DSurface -- Create a surface attached to specified DDraw Surface Object. * - * DSurface::DSurface -- Default constructor for surface object. * - * DSurface::DSurface -- Off screen direct draw surface constructor. * - * DSurface::Fill_Rect -- Fills a rectangle with clipping control. * - * DSurface::Fill_Rect -- This routine will fill the specified rectangle. * - * DSurface::Lock -- Fetches a working pointer into surface memory. * - * DSurface::Restore_Check -- Checks for and restores surface memory if necessary. * - * DSurface::Stride -- Fetches the bytes between rows. * - * DSurface::Unlock -- Unlock a previously locked surface. * - * DSurface::~DSurface -- Destructor for a direct draw surface object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "dsurface.h" -#include - -extern LPDIRECTDRAW DirectDrawObject; //pointer to direct draw object -extern LPDIRECTDRAWSURFACE PaletteSurface; - -/* -** Clipper object (for primary surface). -*/ -LPDIRECTDRAWCLIPPER DSurface::Clipper = NULL; - -int DSurface::RedRight = 0; -int DSurface::RedLeft = 0; -int DSurface::BlueRight = 0; -int DSurface::BlueLeft = 0; -int DSurface::GreenRight = 0; -int DSurface::GreenLeft = 0; - -unsigned short DSurface::HalfbrightMask = 0; -unsigned short DSurface::QuarterbrightMask = 0; -unsigned short DSurface::EighthbrightMask = 0; - -DDPIXELFORMAT DSurface::PixelFormat; - - -/*********************************************************************************************** - * DSurface::DSurface -- Off screen direct draw surface constructor. * - * * - * This constructor will create a Direct Draw enabled surface in video memory if possible. * - * Such a surface will be able to use hardware assist if possible. The surface created * - * is NOT visible. It only exists as a work surface and cannot be flipped to the visible * - * surface. It can only be blitted to the visible surface. * - * * - * INPUT: width -- The width of the surface to create. * - * * - * height -- The height of the surface to create. * - * * - * OUTPUT: none * - * * - * WARNINGS: The surface pixel format is the same as that of the visible display mode. It * - * is important to construct surfaces using this routine, only AFTER the display * - * mode has been set. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(int width, int height, bool system_memory, DDPIXELFORMAT *pixform) : - XSurface(width, height), - BytesPerPixel(0), - LockPtr(NULL), - IsPrimary(false), - IsVideoRam(false), - SurfacePtr(NULL), - Description(NULL), - DCUnlockCount(0) -{ - Description = W3DNEW DDSURFACEDESC; - if (Description != NULL) { - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - Description->dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - Description->dwWidth = width; - Description->dwHeight = height; - - Description->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - - if (system_memory == true) - Description->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; - - /* - ** Was a custom (non-display-depth) pixel format specified? - */ - if (pixform) - { - Description->ddpfPixelFormat=*pixform; - Description->dwFlags |= DDSD_PIXELFORMAT; - } - - - DirectDrawObject->CreateSurface(Description, &SurfacePtr, NULL); - - /* - ** Get a description of the surface that was just allocated. - */ - if (SurfacePtr != NULL) { - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - SurfacePtr->GetSurfaceDesc(Description); - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - IsVideoRam = ((Description->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) != 0); - - - /* - ** If this is a hicolor surface, then build the shift values for - ** building and extracting the colors from the hicolor pixel. - */ - if (BytesPerPixel == 2) { - int index; - int shift = Description->ddpfPixelFormat.dwRBitMask; - ThisRedRight = 0; - ThisRedLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - shift >>= 1; - ThisRedRight++; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - shift <<= 1; - ThisRedLeft++; - } - - shift = Description->ddpfPixelFormat.dwGBitMask; - ThisGreenRight = 0; - ThisGreenLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - ThisGreenRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - ThisGreenLeft++; - shift <<= 1; - } - - shift = Description->ddpfPixelFormat.dwBBitMask; - ThisBlueRight = 0; - ThisBlueLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - ThisBlueRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - ThisBlueLeft++; - shift <<= 1; - } - - } - } - } -} - - -/*********************************************************************************************** - * DSurface::~DSurface -- Destructor for a direct draw surface object. * - * * - * This will destruct (make invalid) the direct draw surface. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::~DSurface(void) -{ - /* - ** If this is the primary surface, then the clipper must be detached from - ** this surface and the clipper object deleted. - */ - if (IsPrimary && SurfacePtr != NULL && Clipper != NULL) { - SurfacePtr->SetClipper(NULL); - Clipper->Release(); - Clipper = NULL; - } - - /* - ** Delete the description of the surface. - */ - delete Description; - Description = NULL; - - if (SurfacePtr != NULL) { - SurfacePtr->Release(); - } - SurfacePtr = NULL; -} - - -/*********************************************************************************************** - * DSurface::DSurface -- Default constructor for surface object. * - * * - * This default constructor for a surface object should not be used. Although it properly * - * creates a non-functional surface, there is no use for such a surface. This default * - * constructor is provided for those rare cases where symatics require a default * - * constructor. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(void) : - BytesPerPixel(0), - LockPtr(NULL), - SurfacePtr(NULL), - Description(NULL), - DCUnlockCount(0) -{ - Description = W3DNEW DDSURFACEDESC; - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); -} - - - -/*********************************************************************************************** - * DSurface::GetDC -- Get the windows device context from our surface * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Any current locks will get unlocked while the DC is held * - * * - * HISTORY: * - * 06/21/2000 NAK : Created. * - *=============================================================================================*/ -HDC DSurface::GetDC(void) -{ - HDC hdc = NULL; - HRESULT hr; - - - // We have to remove all current locks to get the device context unfortunately... - while (LockCount) { - Unlock(); - DCUnlockCount++; - } - - - hr = SurfacePtr->GetDC(&hdc); - if (hr != DD_OK) - { - while(DCUnlockCount) // restore the lock state - { - Lock(); - DCUnlockCount--; - } - return(NULL); - } - - // GetDC() locks the surface internally, so we need to reflect that here - if (hr == DD_OK) { - LockCount++; - }else{ - hdc = NULL; - } - - return (hdc); -} - - -/*********************************************************************************************** - * DSurface::ReleaseDC -- Release the windows device context from our surface * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: Restores any locks held before the call to GetDC() * - * * - * HISTORY: * - * 06/21/2000 NAK : Created. * - *=============================================================================================*/ -int DSurface::ReleaseDC(HDC hdc) -{ - HRESULT hr; - - hr = SurfacePtr->ReleaseDC(hdc); - assert(hr == DD_OK); - - // ReleaseDC() unlocks the surface internally, so we need to reflect that here. - if ((hr == DD_OK) && (LockCount > 0)) { - LockCount--; - } - - while(DCUnlockCount) // restore the lock state - { - Lock(); - DCUnlockCount--; - } - - return (1); -} - - - - -/*********************************************************************************************** - * DSurface::Create_Primary -- Creates a primary (visible) surface. * - * * - * This routine is used to create the surface object that represents the currently * - * visible display. The surface is not allocated, it is merely linked to the preexisting * - * surface that the Windows GDI is also currently using. * - * * - * INPUT: backsurface -- Optional pointer to specify where the backpage (flip enabled) * - * pointer will be placed. If this parameter is NULL, then no * - * back surface will be created. * - * * - * OUTPUT: Returns with a pointer to the primary surface. * - * * - * WARNINGS: There can be only one primary surface. If an additional call to this routine * - * is made, another surface pointer will be returned, but it will point to the * - * same surface as before. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface * DSurface::Create_Primary(DSurface ** backsurface1) -{ - DSurface * surface = W3DNEW DSurface(); - int backcount = (backsurface1 != NULL) ? 1 : 0; - - /* - ** Setup parameter for creating the primary surface. This will - ** always be the visible surface plus optional back buffers of identical - ** dimensions. - */ - surface->Description->dwFlags = DDSD_CAPS; - surface->Description->ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - if (backcount > 0) { - surface->Description->ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX; - surface->Description->dwFlags |= DDSD_BACKBUFFERCOUNT; - surface->Description->dwBackBufferCount = backcount; - } - HRESULT result = DirectDrawObject->CreateSurface(surface->Description, &surface->SurfacePtr, NULL); - - /* - ** If the primary surface object was created, then fetch a pointer to the - ** back buffer if there is one present. - */ - if (result == DD_OK) { - if (backcount > 0) { - LPDIRECTDRAWSURFACE back; - DDSCAPS caps; - caps.dwCaps = DDSCAPS_BACKBUFFER; - result = surface->SurfacePtr->GetAttachedSurface(&caps, &back); - if (result == DD_OK) { - *backsurface1 = W3DNEW DSurface(back); - } - } - - /* - ** Get a description of the surface that was just allocated. - */ - memset(surface->Description, '\0', sizeof(DDSURFACEDESC)); - surface->Description->dwSize = sizeof(DDSURFACEDESC); - surface->SurfacePtr->GetSurfaceDesc(surface->Description); - surface->BytesPerPixel = (surface->Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - surface->IsPrimary = true; - -// surface->Window.Set(Rect(0, 0, surface->Description->dwWidth, surface->Description->dwHeight)); - surface->Width = surface->Description->dwWidth; - surface->Height = surface->Description->dwHeight; - PaletteSurface = surface->SurfacePtr; - - /* - ** Attach a clipper object to the surface so that it can cooperate - ** with the system GDI. This only comes into play if there are going - ** to be GDI graphical elements on top of the surface (normally this - ** isn't the case for full screen games). It doesn't hurt to attach - ** a clipper object anyway -- just in case. - */ - if (DirectDrawObject->CreateClipper(0, &Clipper, NULL) == DD_OK) { - if (Clipper->SetHWnd(0, GetActiveWindow()) == DD_OK) { - surface->SurfacePtr->SetClipper(Clipper); - } - } - - /* - ** Fetch the pixel format for the surface. - */ - memcpy(&PixelFormat, &surface->Description->ddpfPixelFormat, sizeof(DDPIXELFORMAT)); - - /* - ** If this is a hicolor surface, then build the shift values for - ** building and extracting the colors from the hicolor pixel. - */ - if (surface->Bytes_Per_Pixel() == 2) { - int index; - int shift = PixelFormat.dwRBitMask; - RedRight = 0; - RedLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - shift >>= 1; - RedRight++; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - shift <<= 1; - RedLeft++; - } - - shift = PixelFormat.dwGBitMask; - GreenRight = 0; - GreenLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - GreenRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - GreenLeft++; - shift <<= 1; - } - - shift = PixelFormat.dwBBitMask; - BlueRight = 0; - BlueLeft = 0; - for (index = 0; index < 16; index++) { - if (shift & 0x01) break; - BlueRight++; - shift >>= 1; - } - for (index = 0; index < 8; index++) { - if (shift & 0x80) break; - BlueLeft++; - shift <<= 1; - } - - - /* - ** Create the halfbright mask. - */ - HalfbrightMask = (unsigned short)Build_Hicolor_Pixel(127, 127, 127); - QuarterbrightMask = (unsigned short)Build_Hicolor_Pixel(63, 63, 63); - EighthbrightMask = (unsigned short)Build_Hicolor_Pixel(31, 31, 31); - } - - } else { - delete surface; - surface = NULL; - } - - return(surface); -} - - -/*********************************************************************************************** - * DSurface::DSurface -- Create a surface attached to specified DDraw Surface Object. * - * * - * If an existing Direct Draw Surface Object is available, use this constructor to create * - * a DSurface object that is attached to the surface specified. * - * * - * INPUT: surfaceptr -- Pointer to a preexisting Direct Draw Surface Object. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -DSurface::DSurface(LPDIRECTDRAWSURFACE surfaceptr) : - BytesPerPixel(0), - LockPtr(NULL), - SurfacePtr(surfaceptr), - Description(NULL) -{ - if (SurfacePtr != NULL) { - Description = W3DNEW DDSURFACEDESC; - memset(Description, '\0', sizeof(DDSURFACEDESC)); - Description->dwSize = sizeof(DDSURFACEDESC); - HRESULT result = SurfacePtr->GetSurfaceDesc(Description); - if (result == DD_OK) { - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; -// Window.Set(Rect(0, 0, Description->dwWidth, Description->dwHeight)); - Width = Description->dwWidth; - Height = Description->dwHeight; - } - } -} - - -/*********************************************************************************************** - * DSurface::Bytes_Per_Pixel -- Fetches the bytes per pixel of the surface. * - * * - * This routine will return with the number of bytes that each pixel consumes. The value * - * is dependant upon the graphic mode of the display. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the bytes per pixel of the surface object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Bytes_Per_Pixel(void) const -{ - return(BytesPerPixel); -} - - -/*********************************************************************************************** - * DSurface::Stride -- Fetches the bytes between rows. * - * * - * This routine will return the number of bytes to add so that the pointer will be * - * positioned at the same column, but one row down the screen. This value may very well * - * NOT be equal to the width multiplied by the bytes per pixel. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the byte difference between subsequent pixel rows. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Stride(void) const -{ - return(Description->lPitch); -} - - -/*********************************************************************************************** - * DSurface::Lock -- Fetches a working pointer into surface memory. * - * * - * This routine will return with a pointer to the pixel at the location specified. In order * - * to directly manipulate surface memory, the surface memory must be mapped into the * - * program's logical address space. In addition, all blitter activity on the surface will * - * be suspended. Every call to Lock must be have a corresponding call to Unlock if the * - * pointer returned is not equal to NULL. * - * * - * INPUT: point -- Pixel coordinate to return a pointer to. * - * * - * OUTPUT: Returns with a pointer to the pixel specified. If the return value is NULL, then * - * the surface could not be locked and no call to Unlock should be performed. * - * * - * WARNINGS: It is important not to keep a surface locked indefinately since the blitter * - * will not be able to function. Due to the time that locking consumes, it is * - * also important to not perform unnecessarily frequent Lock calls. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -void * DSurface::Lock(Point2D point) const -{ - Restore_Check(); - if (LockCount == 0) { - DDSURFACEDESC desc; - memset(&desc, '\0', sizeof(desc)); - desc.dwSize = sizeof(desc); - HRESULT result = SurfacePtr->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL); - if (result != DD_OK) return(NULL); - memcpy(Description, &desc, sizeof(DDSURFACEDESC)); - BytesPerPixel = (Description->ddpfPixelFormat.dwRGBBitCount+7)/8; - LockPtr = Description->lpSurface; - } - XSurface::Lock(); - return(((char*)LockPtr) + point.Y * Stride() + point.X * Bytes_Per_Pixel()); -} - - -/*********************************************************************************************** - * DSurface::Unlock -- Unlock a previously locked surface. * - * * - * After a surface has been successfully locked, a call to the Unlock() function is * - * required. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Was the unlock successful? * - * * - * WARNINGS: Only pair a call to Unlock if the prior Lock actually returned a non-NULL * - * value. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Unlock(void) const -{ - Restore_Check(); - if (LockCount > 0) { - XSurface::Unlock(); - if (LockCount == 0) { - SurfacePtr->Unlock(LockPtr); - LockPtr = NULL; - } - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * DSurface::Restore_Check -- Checks for and restores surface memory if necessary. * - * * - * This routine will check to see if surface memory has been lost to the surface. If it * - * has, then the surface memory will be restored. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -void DSurface::Restore_Check(void) const -{ - if (SurfacePtr->IsLost() == DDERR_SURFACELOST) { - SurfacePtr->Restore(); - if (LockCount > 0 && SurfacePtr->IsLost() != DDERR_SURFACELOST) { - int oldlockcount = LockCount; - LockCount = 0; - Lock(); - LockCount++; - Unlock(); - LockCount = oldlockcount; - } - } -} - - -/*********************************************************************************************** - * DSurface::Blit_From -- Blit graphic memory from one rectangle to another. * - * * - * This routine will use the blitter (if possible) to blit a block of graphic memory from * - * one screen rectangle to another. If the rectangles do no match in size, scaling may * - * be performed. * - * * - * INPUT: destrect -- The destination rectangle. * - * * - * ssource -- The source surface to blit from. * - * * - * sourecrect -- The source rectangle. * - * * - * trans -- Should transparency checking be performed? * - * * - * OUTPUT: bool; Was the blit performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Blit_From(Rect const & destrect, Surface const & ssource, Rect const & sourcerect, bool trans) -{ - return(Blit_From(Get_Rect(), destrect, ssource, ssource.Get_Rect(), sourcerect, trans)); -} - - -/*********************************************************************************************** - * DSurface::Blit_From -- Blit from one surface to this one. * - * * - * Use this routine to blit a rectangle from the specified surface to this surface while * - * performing clipping upon the blit rectangles specified. * - * * - * INPUT: dcliprect -- The clipping rectangle to use for this surface. * - * * - * destrect -- The destination rectangle of the blit. The is relative to the * - * dcliprect parameter. * - * * - * ssource -- The source surface of the blit. * - * * - * scliprect -- The source clipping rectangle. * - * * - * sourcrect -- The source rectangle of the blit. This rectangle is relative to * - * the source clipping rectangle. * - * * - * trans -- Is this a transparent blit request? * - * * - * OUTPUT: bool; Was there a blit performed? A 'false' return value would indicate that the * - * blit was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & ssource, Rect const & scliprect, Rect const & sourcerect, bool trans) -{ - if (!dcliprect.Is_Valid() || !scliprect.Is_Valid() || !destrect.Is_Valid() || !sourcerect.Is_Valid()) return(false); - - /* - ** For non-direct draw surfaces, perform a manual blit operation. This is also - ** necessary if any of the surfaces are currently locked. It is also necessary if the - ** blit regions overlap and the blitter cannot handle overlapped regions. - ** - ** NOTE: Its legal to blit to a locked surface but not from a locked surface. - ** ST - 4/23/97 1:03AM - */ - if (!ssource.Is_Direct_Draw() || ((DSurface&)ssource).Is_Locked() || trans || Bytes_Per_Pixel() != ssource.Bytes_Per_Pixel()) { - return(XSurface::Blit_From(destrect, ssource, sourcerect, trans)); - } - - Restore_Check(); - DSurface const & source = (DSurface const &)ssource; - - Rect drect = destrect; - Rect srect = sourcerect; - Rect swindow = scliprect.Intersect(ssource.Get_Rect()); - Rect dwindow = dcliprect.Intersect(Get_Rect()); - if (Blit_Clip(drect, dwindow, srect, swindow)) { - RECT xdestrect; - xdestrect.left = drect.X+dwindow.X; - xdestrect.top = drect.Y+dwindow.Y; - xdestrect.right = drect.X+dwindow.X+drect.Width; - xdestrect.bottom = drect.Y+dwindow.Y+drect.Height; - - RECT xsrcrect; - xsrcrect.left = srect.X+swindow.X; - xsrcrect.top = srect.Y+swindow.Y; - xsrcrect.right = srect.X+swindow.X+srect.Width; - xsrcrect.bottom = srect.Y+swindow.Y+srect.Height; - - HRESULT result = SurfacePtr->Blt(&xdestrect, source.SurfacePtr, &xsrcrect, DDBLT_WAIT, NULL); - return(result == DD_OK); - } - return(false); -} - - -/*********************************************************************************************** - * DSurface::Fill_Rect -- This routine will fill the specified rectangle. * - * * - * This routine will fill the specified rectangle with a color. * - * * - * INPUT: fillrect -- The rectangle to fill. * - * * - * color -- The color to fill with. * - * * - * OUTPUT: bool; Was the fill performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Fill_Rect(Rect const & fillrect, int color) -{ - return(DSurface::Fill_Rect(Get_Rect(), fillrect, color)); -} - - -/*********************************************************************************************** - * DSurface::Fill_Rect -- Fills a rectangle with clipping control. * - * * - * This routine will fill a rectangle on this surface, but will clip the request against * - * a clipping rectangle first. * - * * - * INPUT: cliprect -- The clipping rectangle to use for this surface. * - * * - * fillrect -- The rectangle to fill with the specified color. The rectangle is * - * relative to the clipping rectangle. * - * * - * color -- The color (surface dependant format) to use when filling the rectangle * - * pixels. * - * * - * OUTPUT: bool; Was a fill operation performed? A 'false' return value would mean that the * - * fill request was clipped into nothing. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool DSurface::Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) -{ - if (!fillrect.Is_Valid()) return(false); - - /* - ** If the buffer is locked, then using the blitter to perform the fill is not possible. - ** In such a case, perform a manual fill of the region. - */ - if (Is_Locked()) { - return(XSurface::Fill_Rect(cliprect, fillrect, color)); - } - - Restore_Check(); - - /* - ** Ensure that the clipping rectangle is legal. - */ - Rect crect = cliprect.Intersect(Get_Rect()); - - /* - ** Bias the fill rect to the clipping rectangle. - */ - Rect frect = fillrect.Bias_To(cliprect); - - /* - ** Find the region that should be filled after being clipped by the - ** clipping rectangle. This could result in no fill operation being performed - ** if the desired fill rectangle has been completely clipped away. - */ - frect = frect.Intersect(crect); - if (!frect.Is_Valid()) return(false); - - RECT rect; - rect.left = frect.X; - rect.top = frect.Y; - rect.right = rect.left + frect.Width; - rect.bottom = rect.top + frect.Height; - - DDBLTFX fx; - memset(&fx, '\0', sizeof(fx)); - fx.dwSize = sizeof(fx); - fx.dwFillColor = color; - HRESULT result = SurfacePtr->Blt(&rect, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx); - return(result == DD_OK); -} - - -/*********************************************************************************************** - * DSurface::Build_Hicolor_Pixel -- Construct a hicolor pixel according to the surface pixel f * - * * - * This routine will construct a pixel according to the highcolor pixel format for this * - * surface. * - * * - * INPUT: red -- The red component of the color (0..255). * - * * - * green -- The green component of the color (0..255). * - * * - * blue -- The blue component of the color (0..255). * - * * - * OUTPUT: Returns with a screen format pixel number that most closesly matches the color * - * specified. * - * * - * WARNINGS: The return value is card dependant and only applies to hicolor displays. * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -int DSurface::Build_Hicolor_Pixel(int red, int green, int blue) -{ - return(((red >> RedLeft) << RedRight) | ((green >> GreenLeft) << GreenRight) | ((blue >> BlueLeft) << BlueRight)); -} - - -/*********************************************************************************************** - * DSurface::Build_Remap_Table -- Build a highcolor remap table. * - * * - * This will build a complete hicolor remap table for the palette specified. This table * - * can then be used to quickly fetch a pixel that matches the color index of the palette. * - * * - * INPUT: table -- The location to store the hicolor table. The buffer must be 256*2 bytes * - * long. * - * * - * palette -- The palette to use to create the remap table. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -void DSurface::Build_Remap_Table(unsigned short * table, PaletteClass const & palette) -{ - assert(table != NULL); - - /* - ** Build the hicolor index table according to the palette. - */ - for (int index = 0; index < 256; index++) { - table[index] = (unsigned short)Build_Hicolor_Pixel(palette[index].Get_Red(), palette[index].Get_Green(), palette[index].Get_Blue()); - } -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.h deleted file mode 100644 index 13b16b8d0bd..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/dsurface.h +++ /dev/null @@ -1,205 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/dsurface.h $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 6/23/00 2:24p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DSURFACE_H -#define DSURFACE_H - -#include "PALETTE.H" -#include "win.h" -#include "xsurface.h" -#include - -/* -** This is a concrete surface class that is based on the DirectDraw -** API. -*/ -class DSurface : public XSurface -{ - typedef XSurface BASECLASS; - - public: - virtual ~DSurface(void); - - /* - ** Default constructor. - */ - DSurface(void); - - /* - ** Constructs a working surface (not visible). - */ - DSurface(int width, int height, bool system_memory = false, DDPIXELFORMAT *pixform=NULL); - - /* - ** Creates a surface from a previously created DirectDraw surface object. - */ - DSurface(LPDIRECTDRAWSURFACE surfaceptr); - - /* - ** Get/Release a windows device context from a DirectX surface - */ - HDC GetDC(void); - int ReleaseDC(HDC hdc); - - /* - ** Create a surface object that represents the currently visible screen. - */ - static DSurface * Create_Primary(DSurface ** backsurface1=NULL); - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Surface const & source, bool trans=false) {return(XSurface::Blit_From(source, trans));} - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color); - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color); - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D point = Point2D(0, 0)) const; - virtual bool Unlock(void) const; - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const; - virtual int Stride(void) const; - bool In_Video_Ram(void) const {return(IsVideoRam);} - - /* - ** Verifies that this is a direct draw enabled surface. - */ - virtual bool Is_Direct_Draw(void) const {return(true);} - - static int Build_Hicolor_Pixel(int red, int green, int blue); - static void Build_Remap_Table(unsigned short * table, PaletteClass const & palette); - static unsigned short Get_Halfbright_Mask(void) {return(HalfbrightMask);} - static unsigned short Get_Quarterbright_Mask(void) {return(QuarterbrightMask);} - static unsigned short Get_Eighthbright_Mask(void) {return(EighthbrightMask);} - - protected: - void Restore_Check(void) const; - - /* - ** Convenient copy of the bytes per pixel value to speed accessing it. It - ** gets accessed frequently. - */ - mutable int BytesPerPixel; - - /* - ** Lock count and pointer values. This is used to keep track of the levels - ** of locking the graphic data. This is only here because DirectDraw prohibits - ** the blitter from working on a surface that has been locked. - */ - mutable void * LockPtr; - - /* - ** If this surface object represents the one that is visible and associated - ** with the system GDI, then this flag will be true. - */ - bool IsPrimary; - - /* - ** Is this surface represented in video ram? - */ - bool IsVideoRam; - - /* - ** Direct draw specific data. - */ - LPDIRECTDRAWSURFACE SurfacePtr; - DDSURFACEDESC * Description; - - /* - ** Pointer to the clipper object that is attached to the primary - ** surface. - */ - static LPDIRECTDRAWCLIPPER Clipper; - - /* - ** Pixel format of primary surface. - */ - static DDPIXELFORMAT PixelFormat; - - /* - ** Shift values to extract the gun value from a hicolor pixel such that the - ** gun component is normalized to a byte value. - */ - static int RedRight; - static int RedLeft; - static int BlueRight; - static int BlueLeft; - static int GreenRight; - static int GreenLeft; - - public: - /* - ** Shift values specific to this surface (the above are for the primary surface) - */ - int ThisRedRight; - int ThisRedLeft; - int ThisBlueRight; - int ThisBlueLeft; - int ThisGreenRight; - int ThisGreenLeft; - - protected: - static unsigned short HalfbrightMask; - static unsigned short QuarterbrightMask; - static unsigned short EighthbrightMask; - - - /* - ** Number of locks we had to remove in order to get the device context... - */ - int DCUnlockCount; - - private: - /* - ** This prevents the creation of a surface in ways that are not - ** supported. - */ - DSurface(DSurface const & rvalue); - DSurface const operator = (DSurface const & rvalue); -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.cpp deleted file mode 100644 index f0824eb940e..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/Library/FIXED.CPP 2 10/05/98 3:30p Greg_h $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * File Name : FIXED.CPP * - * * - * Programmer : Joe L. Bostic * - * * - * Start Date : 06/20/96 * - * * - * Last Update : July 3, 1996 [JLB] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * fixed::As_ASCII -- Returns a pointer (static) of this number as an ASCII string. * - * fixed::To_ASCII -- Convert a fixed point number into an ASCII string. * - * fixed::fixed -- Constructor for fixed integral from ASCII initializer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "fixed.h" -#include -#include -#include -#include - - -/* -** These are some handy fixed point constants. Using these constants instead of manually -** constructing them is not only faster, but more readable. -*/ -const fixed fixed::_1_2(1, 2); // 1/2 -const fixed fixed::_1_3(1, 3); // 1/3 -const fixed fixed::_1_4(1, 4); // 1/4 -const fixed fixed::_3_4(3, 4); // 3/4 -const fixed fixed::_2_3(2, 3); // 2/3 - - -fixed::fixed(int numerator, int denominator) -{ - if (denominator == 0) { - Data.Raw = 0; - } else { - Data.Raw = (unsigned short)((unsigned)(numerator * 256) / (unsigned)denominator); - } -} - - -/*********************************************************************************************** - * fixed::fixed -- Constructor for fixed integral from ASCII initializer. * - * * - * This will parse the ASCII initialization string into a fixed point number. * - * The source string can be a conventional fixed point representation (e.g., "1.0", ".25") * - * or a percent value (e.g. "100%", "25%", "150%"). For percent values, the trailing "%" * - * is required. * - * * - * INPUT: ascii -- Pointer to the ascii source to translate into a fixed point number. * - * * - * OUTPUT: none * - * * - * WARNINGS: It is possible to specify an ASCII string that has more precision and * - * magnitude than can be represented by the fixed point number. In such a case, * - * the resulting value is undefined. * - * * - * HISTORY: * - * 06/20/1996 JLB : Created. * - *=============================================================================================*/ -fixed::fixed(char const * ascii) -{ - /* - ** If there is no valid pointer, then default to zero value. This takes care of any - ** compiler confusion that would call this routine when the programmer wanted the - ** integer parameter constructor to be called. - */ - if (ascii == NULL) { - Data.Raw = 0; - return; - } - - /* - ** The whole part (if any) always starts with the first legal characters. - */ - char const * wholepart = ascii; - - /* - ** Skip any leading white space. - */ - while (isspace(*ascii)) { - ascii++; - } - - /* - ** Determine if the number is expressed as a percentage. Detect this by - ** seeing if there is a trailing "%" character. - */ - char const * tptr = ascii; - while (isdigit(*tptr)) { - tptr++; - } - - /* - ** Percentage value is specified as a whole number but is presumed to be - ** divided by 100 to get mathematical fixed point percentage value. - */ - if (*tptr == '%') { - Data.Raw = (unsigned short)((atoi(ascii) * 256) / 100); - } else { - - Data.Composite.Whole = Data.Composite.Fraction = 0; - if (wholepart && *wholepart != '.') { - Data.Composite.Whole = (unsigned char)atoi(wholepart); - } - - char const * fracpart = strchr(ascii, '.'); - if (fracpart) fracpart++; - if (fracpart) { - int frac = atoi(fracpart); - -// int len = 0; - int base = 1; - char const * fptr = fracpart; - while (isdigit(*fptr)) { - fptr++; -// len++; - base *= 10; - } - - Data.Composite.Fraction = (unsigned char)((256 * frac) / base); - } - } -} - - -/*********************************************************************************************** - * fixed::To_ASCII -- Convert a fixed point number into an ASCII string. * - * * - * Use this routine to convert this fixed point number into an ASCII null terminated * - * string. This is the counterpart to the fixed point constructor that takes an ASCII * - * string. * - * * - * INPUT: buffer -- Pointer to the buffer to hold the fixed point ASCII string. * - * * - * maxlen -- The length of the buffer. * - * * - * OUTPUT: Returns with the number of characters placed in the buffer. The trailing null is * - * not counted in this total. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int fixed::To_ASCII(char * buffer, int maxlen) const -{ - if (buffer == NULL) return(0); - - /* - ** Determine the whole and fractional parts of the number. The fractional - ** part number is the value in 1000ths. - */ - int whole = Data.Composite.Whole; - int frac = ((int)Data.Composite.Fraction * 1000) / 256; - char tbuffer[32]; - - /* - ** If there number consists only of a whole part, then the number is simply - ** printed into the buffer. If there is a fractional part, then there - ** will be a decimal place followed by up to three digits of accuracy for the - ** fractional component. - */ - if (frac == 0) { - sprintf(tbuffer, "%d", whole); - } else { - sprintf(tbuffer, "%d.%02d", whole, frac); - - char * ptr = &tbuffer[strlen(tbuffer)-1]; - while (*ptr == '0') { - *ptr = '\0'; - ptr--; - } - } - - /* - ** If no maximum length to the output buffer was specified, then presume the - ** output buffer is just long enough to store the number and the trailing - ** zero. - */ - if (maxlen == -1) { - maxlen = strlen(tbuffer)+1; - } - - /* - ** Fill the output buffer with the ASCII number. - */ - strncpy(buffer, tbuffer, maxlen); - - /* - ** Return with the number of ASCII characters placed into the output buffer. - */ - int len = strlen(tbuffer); - if (len < maxlen-1) return(len); - return(maxlen-1); -} - - -/*********************************************************************************************** - * fixed::As_ASCII -- Returns a pointer (static) of this number as an ASCII string. * - * * - * This number will be converted into an ASCII string (using a static buffer) and the * - * string pointer will be returned. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a pointer to the ASCII representation of this fixed point number. * - * * - * WARNINGS: As with all static return pointers, the pointer is valid only until such time * - * as this routine is called again. * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -char const * fixed::As_ASCII(void) const -{ - static char buffer[32]; - - To_ASCII(buffer, sizeof(buffer)); - return(buffer); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.h deleted file mode 100644 index 3a7d6b1855d..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/fixed.h +++ /dev/null @@ -1,220 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Library/FIXED.H 1 7/22/97 12:00p Greg_h $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * File Name : FIXED.H * - * * - * Programmer : Joe L. Bostic * - * * - * Start Date : 06/19/96 * - * * - * Last Update : June 19, 1996 [JLB] * - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef FIXED_H -#define FIXED_H - -#include "bool.h" -//#pragma warning 604 9 -//#pragma warning 595 9 - -/* -** This is a very simple fixed point class that functions like a regular integral type. However -** it is under certain restrictions. The whole part must not exceed 255. The fractional part is -** limited to an accuracy of 1/256. It cannot represent or properly handle negative values. It -** really isn't all that fast (if an FPU is guaranteed to be present than using "float" might be -** more efficient). It doesn't detect overflow or underflow in mathematical or bit-shift operations. -** -** Take careful note that the normal mathematical operators return integers and not fixed point -** values if either of the components is an integer. This is the normal C auto-upcasting rule -** as it would apply presuming that integers are considered to be of higher precision than -** fixed point numbers. This allows the result of these operators to generate values with greater -** magnitude than is normally possible if the result were coerced into a fixed point number. -** If the result should be fixed point, then ensure that both parameters are fixed point. -** -** Note that although integers are used as the parameters in the mathematical operators, this -** does not imply that negative parameters are supported. The use of integers is as a convenience -** to the programmer -- constant integers are presumed signed. If unsigned parameters were -** specified, then the compiler would have ambiguous conversion situation in the case of constant -** integers (e.g. 1, 10, 32, etc). This is most important for the constructor when dealing with the -** "0" parameter case. In that situation the compiler might interpret the "0" as a null pointer rather -** than an unsigned integer. There should be no adverse consequences of using signed integer parameters -** since the precision/magnitude of these integers far exceeds the fixed point component counterparts. -** -** Note that when integer values are returns from the arithmetic operators, the value is rounded -** to the nearest whole integer value. This differs from normal integer math that always rounds down. -*/ -class fixed -{ - public: - // The default constructor must not touch the data members in any way. - fixed(void) {} - - // Convenient constructor if numerator and denominator components are known. - fixed(int numerator, int denominator); - - // Conversion constructor to get fixed point from integer. - fixed(int value) {Data.Composite.Fraction = 0;Data.Composite.Whole = (unsigned char)value;} - - // Constructor if ASCII image of number is known. - fixed(char const * ascii); - - // Convert to integer when implicitly required. - operator unsigned (void) const {return(((unsigned)Data.Raw+(256/2)) / 256);} - - /* - ** The standard operators as they apply to in-place operation. - */ - fixed & operator *= (fixed const & rvalue) {Data.Raw = (unsigned short)(((int)Data.Raw * rvalue.Data.Raw) / 256);return(*this);} - fixed & operator *= (int rvalue) {Data.Raw = (unsigned short)(Data.Raw * rvalue);return(*this);} - fixed & operator /= (fixed const & rvalue) {if (rvalue.Data.Raw != 0 && rvalue.Data.Raw != 256) Data.Raw = (unsigned short)(((int)Data.Raw * 256) / rvalue);return(*this);} - fixed & operator /= (int rvalue) {if (rvalue) Data.Raw = (unsigned short)((unsigned)Data.Raw / rvalue);return(*this);} - fixed & operator += (fixed const & rvalue) {Data.Raw += rvalue.Data.Raw;return(*this);} - fixed & operator -= (fixed const & rvalue) {Data.Raw -= rvalue.Data.Raw;return(*this);} - - /* - ** The standard "My Dear Aunt Sally" operators. The integer versions of multiply - ** and divide are more efficient than using the fixed point counterparts. - */ -// const fixed operator * (fixed const & rvalue) const {return(fixed(*this) *= rvalue);} - const fixed operator * (fixed const & rvalue) const {fixed temp = *this;temp.Data.Raw = (unsigned short)(((int)temp.Data.Raw * (int)rvalue.Data.Raw) / 256);return(temp);} - const int operator * (int rvalue) const {return ((((unsigned)Data.Raw * rvalue) + (256/2)) / 256);} -// const fixed operator / (fixed const & rvalue) const {return(fixed(*this) /= rvalue);} - const fixed operator / (fixed const & rvalue) const {fixed temp = *this;if (rvalue.Data.Raw != 0 && rvalue.Data.Raw != 256) temp.Data.Raw = (unsigned short)(((int)temp.Data.Raw * 256) / rvalue.Data.Raw);return(temp);} - const int operator / (int rvalue) const {if (rvalue) return(((unsigned)Data.Raw+(256/2)) / ((unsigned)rvalue*256));return(*this);} -// const fixed operator + (fixed const & rvalue) const {return(fixed(*this) += rvalue);} - const fixed operator + (fixed const & rvalue) const {fixed temp = *this;temp += rvalue;return(temp);} - const int operator + (int rvalue) const {return((((unsigned)Data.Raw+(256/2))/256) + rvalue);} -// const fixed operator - (fixed const & rvalue) const {return(fixed(*this) -= rvalue);} - const fixed operator - (fixed const & rvalue) const {fixed temp = *this;temp -= rvalue;return(temp);} - const int operator - (int rvalue) const {return((((unsigned)Data.Raw+(256/2))/256) - rvalue);} - - /* - ** The Shift operators are more efficient than using multiplies or divides by power-of-2 numbers. - */ - fixed & operator >>= (unsigned rvalue) {Data.Raw >>= rvalue;return(*this);} - fixed & operator <<= (unsigned rvalue) {Data.Raw <<= rvalue;return(*this);} - const fixed operator >> (unsigned rvalue) const {fixed temp = *this;temp >>= rvalue;return(temp);} - const fixed operator << (unsigned rvalue) const {fixed temp = *this;temp <<= rvalue;return(temp);} - - /* - ** The full set of comparison operators. - */ - bool operator == (fixed const & rvalue) const {return(Data.Raw == rvalue.Data.Raw);} - bool operator != (fixed const & rvalue) const {return(Data.Raw != rvalue.Data.Raw);} - bool operator < (fixed const & rvalue) const {return(Data.Raw < rvalue.Data.Raw);} - bool operator > (fixed const & rvalue) const {return(Data.Raw > rvalue.Data.Raw);} - bool operator <= (fixed const & rvalue) const {return(Data.Raw <= rvalue.Data.Raw);} - bool operator >= (fixed const & rvalue) const {return(Data.Raw >= rvalue.Data.Raw);} - bool operator ! (void) const {return(Data.Raw == 0);} - - /* - ** Comparison to integers requires consideration of fractional component. - */ - bool operator < (int rvalue) const {return(Data.Raw < (rvalue*256));} - bool operator > (int rvalue) const {return(Data.Raw > (rvalue*256));} - bool operator <= (int rvalue) const {return(Data.Raw <= (rvalue*256));} - bool operator >= (int rvalue) const {return(Data.Raw >= (rvalue*256));} - bool operator == (int rvalue) const {return(Data.Raw == (rvalue*256));} - bool operator != (int rvalue) const {return(Data.Raw != (rvalue*256));} - - /* - ** Friend functions to handle the alternate positioning of fixed and integer parameters. - */ - friend const int operator * (int lvalue, fixed const & rvalue) {return(rvalue * lvalue);} - friend const int operator / (int lvalue, fixed const & rvalue) {if (rvalue.Data.Raw == 0 || rvalue.Data.Raw == 256) return (lvalue); return(((unsigned)(lvalue * 256)+(256/2)) / rvalue.Data.Raw);} - friend const int operator + (int lvalue, fixed const & rvalue) {return(rvalue + lvalue);} - friend const int operator - (int lvalue, fixed const & rvalue) {return((((lvalue*256) - rvalue.Data.Raw) + (256/2)) / 256);} - friend bool operator < (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) < rvalue.Data.Raw);} - friend bool operator > (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) > rvalue.Data.Raw);} - friend bool operator <= (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) <= rvalue.Data.Raw);} - friend bool operator >= (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) >= rvalue.Data.Raw);} - friend bool operator == (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) == rvalue.Data.Raw);} - friend bool operator != (unsigned lvalue, fixed const & rvalue) {return((lvalue*256) != rvalue.Data.Raw);} - friend int operator *= (int & lvalue, fixed const & rvalue) {lvalue = lvalue * rvalue;return(lvalue);} - friend int operator /= (int & lvalue, fixed const & rvalue) {lvalue = lvalue / rvalue;return(lvalue);} - friend int operator += (int & lvalue, fixed const & rvalue) {lvalue = lvalue + rvalue;return(lvalue);} - friend int operator -= (int & lvalue, fixed const & rvalue) {lvalue = lvalue - rvalue;return(lvalue);} - - /* - ** Helper functions to handle simple and common operations on fixed point numbers. - */ - void Round_Up(void) {Data.Raw += (unsigned short)(256-1);Data.Composite.Fraction = 0;} - void Round_Down(void) {Data.Composite.Fraction = 0;} - void Round(void) {if (Data.Composite.Fraction >= 256/2) Round_Up();Round_Down();} - void Saturate(unsigned capvalue) {if (Data.Raw > (capvalue*256)) Data.Raw = (unsigned short)(capvalue*256);} - void Saturate(fixed const & capvalue) {if (*this > capvalue) *this = capvalue;} - void Sub_Saturate(unsigned capvalue) {if (Data.Raw >= (capvalue*256)) Data.Raw = (unsigned short)((capvalue*256)-1);} - void Sub_Saturate(fixed const & capvalue) {if (*this >= capvalue) Data.Raw = (unsigned short)(capvalue.Data.Raw-1);} - void Inverse(void) {*this = fixed(1) / *this;} - - /* - ** Friend helper functions that work in the typical C fashion of passing the object to - ** be processed as a parameter to the function. - */ - friend const fixed Round_Up(fixed const & value) {fixed temp = value; temp.Round_Up();return(temp);} - friend const fixed Round_Down(fixed const & value) {fixed temp = value; temp.Round_Down();return(temp);} - friend const fixed Round(fixed const & value) {fixed temp = value; temp.Round();return(temp);} - friend const fixed Saturate(fixed const & value, unsigned capvalue) {fixed temp = value;temp.Saturate(capvalue);return(temp);} - friend const fixed Saturate(fixed const & value, fixed const & capvalue) {fixed temp = value;temp.Saturate(capvalue);return(temp);} - friend const fixed Sub_Saturate(fixed const & value, unsigned capvalue) {fixed temp = value;temp.Sub_Saturate(capvalue);return(temp);} - friend const fixed Sub_Saturate(fixed const & value, fixed const & capvalue) {fixed temp = value;temp.Sub_Saturate(capvalue);return(temp);} - friend const fixed Inverse(fixed const & value) {fixed temp = value;temp.Inverse();return(temp);} - - /* - ** Conversion of the fixed point number into an ASCII string. - */ - int To_ASCII(char * buffer, int maxlen=-1) const; - char const * As_ASCII(void) const; - - /* - ** Helper constants that provide some convenient fixed point values. - */ - static const fixed _1_2; - static const fixed _1_3; - static const fixed _1_4; - static const fixed _3_4; - static const fixed _2_3; - - private: - union { - struct { -#ifdef BIG_ENDIAN - unsigned char Whole; - unsigned char Fraction; -#else - unsigned char Fraction; - unsigned char Whole; -#endif - } Composite; - unsigned short Raw; - } Data; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp deleted file mode 100644 index f307867e0c7..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "hsv.h" -#include "RGB.H" - -HSVClass const HSVClass::BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * HSVClass::Adjust -- Adjust an HSV color toward specified color. * - * * - * This routine will adjust the HSV color object toward the color of the specified HSV * - * object. Typical users of this would be palette morphing or fading routines. * - * * - * INPUT: ratio -- The ratio to move the HSV object toward the color specified. A value * - * of zero means no movement at all. A value of 255 means move completely * - * toward the specified color (changed completely). * - * * - * hsv -- A reference to the color that the current HSV object is to change * - * toward. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -void HSVClass::Adjust(int ratio, HSVClass const & hsv) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = hsv.Get_Value() - Get_Value(); - Value = (unsigned char)(Get_Value() + (value * ratio) / 256); - - int saturation = hsv.Get_Saturation() - Get_Saturation(); - Saturation = (unsigned char)(Get_Saturation() + (saturation * ratio) / 256); - - int hue = hsv.Get_Hue() - Get_Hue(); - Hue = (unsigned char)(Get_Hue() + (hue * ratio) / 256); -} - - -/*********************************************************************************************** - * HSVClass::Difference -- Finds the difference between two HSV color objects. * - * * - * This routine will determine a color difference between two HSV objects. The difference * - * has no particular meaning other that larger numbers meaning greater difference. * - * * - * INPUT: hsv -- The other HSV object to compare this HSV object to. * - * * - * OUTPUT: Returns with a relative distance (in arbitrary units) between this HSV object and * - * the HSV object supplied. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -int HSVClass::Difference(HSVClass const & hsv) const -{ - int hue = (int)Hue - (int)hsv.Hue; - if (hue < 0) hue = -hue; - - int saturation = (int)Saturation - (int)hsv.Saturation; - if (saturation < 0) saturation = -saturation; - - int value = (int)Value - (int)hsv.Value; - if (value < 0) value = -value; - - return(hue*hue + saturation*saturation + value*value); -} - - -/*********************************************************************************************** - * HSVClass::operator RGBClass -- Conversion operator for RGBClass object. * - * * - * This conversion operator will convert the HSV object into an RGB object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implied) of the RGBClass object that most closely * - * matches this HSVClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -HSVClass::operator RGBClass (void) const -{ - unsigned int i; // Integer part. - unsigned int f; // Fractional or remainder part. f/HSV_BASE gives fraction. - unsigned int tmp; // Temporary variable to help with calculations. - unsigned int values[7]; // Possible rgb values. Don't use zero. - - int hue = Get_Hue(); - int saturation = Get_Saturation(); - int value = Get_Value(); - int red, green, blue; - - - hue *= 6; - f = hue % 255; - - // Set up possible red, green and blue values. - values[1] = - values[2] = value; - - // - // The following lines of code change - // values[3] = (v * (255 - ( (s * f) / 255) )) / 255; - // values[4] = values[5] = (v * (255 - s)) / 255; - // values[6] = (v * (255 - (s * (255 - f)) / 255)) / 255; - // so that the are rounded divides. - // - - tmp = (saturation * f) / 255; - values[3] = (value * (255 - tmp)) / 255; - - values[4] = - values[5] = (value * (255 - saturation)) / 255; - - tmp = 255 - (saturation * (255 - f)) / 255; - values[6] = (value * tmp) / 255; - - - // This should not be rounded. - i = hue / 255; - - i += (i > 4) ? -4 : 2; - red = values[i]; - - i += (i > 4) ? -4 : 2; - blue = values[i]; - - i += (i > 4) ? -4 : 2; - green = values[i]; - - RGBClass rgb((unsigned char)red, (unsigned char)green, (unsigned char)blue); - return(rgb); -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.h deleted file mode 100644 index e7f8ae1056a..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/hsv.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/HSV.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef HSV_H -#define HSV_H - -class RGBClass; -class HSVClass; - -/* -** Each color entry is represented by this class. It holds the values for the color -** attributes. The values are recorded in a range from 0 to 255 with 255 being the -** maximum. -*/ -class HSVClass -{ - private: - static HSVClass const BlackColor; - - public: - HSVClass(void) : Hue(0), Saturation(0), Value(0) {}; - HSVClass(unsigned char hue, unsigned char saturation, unsigned char value) : - Hue(hue), - Saturation(saturation), - Value(value) - {}; - operator RGBClass (void) const; - - enum { - MAX_VALUE=255 - }; - - void Adjust(int ratio, HSVClass const & hsv); - int Difference(HSVClass const & hsv) const; - int Get_Hue(void) const {return(Hue);}; - int Get_Saturation(void) const {return(Saturation);}; - int Get_Value(void) const {return(Value);}; - void Set_Hue(unsigned char value) {Hue = value;} - void Set_Saturation(unsigned char value) {Saturation = value;} - void Set_Value(unsigned char value) {Value = value;} - - private: - unsigned char Hue; - unsigned char Saturation; - unsigned char Value; -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ini.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ini.cpp index 06103cbea9e..4f3f5ccb76e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -106,7 +106,6 @@ #include "inisup.h" #include "trect.h" #include "WWFILE.H" -#include "PK.H" #include "PIPE.H" #include "wwstring.h" #include "widestring.h" @@ -2214,80 +2213,6 @@ INIEntry * INISection::Find_Entry(char const * entry) const } -/*********************************************************************************************** - * INIClass::Put_PKey -- Stores the key to the INI database. * - * * - * The key stored to the database will have both the exponent and modulus portions saved. * - * Since the fast key only requires the modulus, it is only necessary to save the slow * - * key to the database. However, storing the slow key stores the information necessary to * - * generate the fast and slow keys. Because public key encryption requires one key to be * - * completely secure, only store the fast key in situations where the INI database will * - * be made public. * - * * - * INPUT: key -- The key to store the INI database. * - * * - * OUTPUT: bool; Was the key stored to the database? * - * * - * WARNINGS: Store the fast key for public INI database availability. Store the slow key if * - * the INI database is secure. * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -bool INIClass::Put_PKey(PKey const & key) -{ - char buffer[512]; - - int len = key.Encode_Modulus(buffer); - Put_UUBlock("PublicKey", buffer, len); - - len = key.Encode_Exponent(buffer); - Put_UUBlock("PrivateKey", buffer, len); - return(true); -} - - -/*********************************************************************************************** - * INIClass::Get_PKey -- Fetch a key from the ini database. * - * * - * This routine will fetch the key from the INI database. The key fetched is controlled by * - * the parameter. There are two choices of key -- the fast or slow key. * - * * - * INPUT: fast -- Should the fast key be retrieved? The fast key has the advantage of * - * requiring only the modulus value. * - * * - * OUTPUT: Returns with the key retrieved. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -PKey INIClass::Get_PKey(bool fast) const -{ - PKey key; - char buffer[512]; - - /* - ** When retrieving the fast key, the exponent is a known constant. Don't parse the - ** exponent from the database. - */ - if (fast) { - BigInt exp = PKey::Fast_Exponent(); - exp.DEREncode((unsigned char *)buffer); - key.Decode_Exponent(buffer); - } else { - Get_UUBlock("PrivateKey", buffer, sizeof(buffer)); - key.Decode_Exponent(buffer); - } - - Get_UUBlock("PublicKey", buffer, sizeof(buffer)); - key.Decode_Modulus(buffer); - - return(key); -} - - /*********************************************************************************************** * INIClass::Strip_Comments -- Strips comments of the specified text line. * * * diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/int.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/int.cpp deleted file mode 100644 index e4bd7f6e58f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/int.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/INT.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "INT.H" -#include "MPMATH.H" -#include "rng.h" - -int bignum::Error = 0; -bool bignum::Carry = false; -bool bignum::Borrow = false; -bignum bignum::Remainder; - - - -//BigInt Gcd(const BigInt & a, const BigInt & n); -#ifdef _MSC_VER -BigInt Generate_Prime(RandomNumberGenerator & rng, int pbits, BigInt const * dummy); -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp deleted file mode 100644 index 216f35501ec..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.cpp +++ /dev/null @@ -1,773 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/KEYBOARD.CPP $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/15/99 10:15a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * - * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * - * WWKeyboardClass::Clear -- Clears the keyboard buffer. * - * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * - * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * - * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages* - * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * - * WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels * - * WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars * - * WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels * - * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * - * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * - * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * - * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboar* - * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * - * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * - * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * - * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * - * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * - * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keybo* - * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_xmouse.h" -#include "keyboard.h" -//#include "mono.h" -#include "msgloop.h" - - -#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0])) - -void Stop_Execution (void) -{ -// __asm nop // Is this line needed? -} - - -/*********************************************************************************************** - * WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -WWKeyboardClass::WWKeyboardClass(void) : - MouseQX(0), - MouseQY(0), - Head(0), - Tail(0) -{ - memset(KeyState, '\0', sizeof(KeyState)); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * - * * - * INPUT: none * - * * - * OUTPUT: int - the key value that was pulled from buffer (includes bits) * * - * * - * WARNINGS: If the key was a mouse event MouseQX and MouseQY will be updated * - * * - * HISTORY: * - * 10/17/1995 PWG : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Buff_Get(void) -{ - while (!Check()) {} // wait for key in buffer - - unsigned short temp = Fetch_Element(); - if (Is_Mouse_Key(temp)) { - MouseQX = Fetch_Element(); - MouseQY = Fetch_Element(); - } - return(temp); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * - * * - * This checks the specified key code to see if it refers to the mouse buttons. * - * * - * INPUT: key -- The key to check. * - * * - * OUTPUT: bool; Is the key a mouse button key? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Mouse_Key(unsigned short key) -{ - key &= 0xFF; - return (key == VK_LBUTTON || key == VK_MBUTTON || key == VK_RBUTTON); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - * 09/24/1996 JLB : Converted to new style keyboard system. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Check(void) const -{ - ((WWKeyboardClass *)this)->Fill_Buffer_From_System(); - if (Is_Buffer_Empty()) return(false); - return(Peek_Element()); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * - * * - * INPUT: none * - * * - * OUTPUT: int - the meta key taken from the buffer. * - * * - * WARNINGS: This routine will not return until a keypress is received * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Get(void) -{ - while (!Check()) {} // wait for key in buffer - return (Buff_Get()); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * - * * - * INPUT: int - the key to insert into the buffer * - * * - * OUTPUT: bool - true if key is sucessfuly inserted. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put(unsigned short key) -{ - if (!Is_Buffer_Full()) { - Put_Element(key); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/16/1995 PWG : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Key_Message(unsigned short vk_key, bool release) -{ - /* - ** Get the status of all of the different keyboard modifiers. Note, only pay attention - ** to numlock and caps lock if we are dealing with a key that is affected by them. Note - ** that we do not want to set the shift, ctrl and alt bits for Mouse keypresses as this - ** would be incompatible with the dos version. - */ - if (!Is_Mouse_Key(vk_key)) { - if (((GetKeyState(VK_SHIFT) & 0x8000) != 0) || - ((GetKeyState(VK_CAPITAL) & 0x0008) != 0) || - ((GetKeyState(VK_NUMLOCK) & 0x0008) != 0)) { - - vk_key |= WWKEY_SHIFT_BIT; - } - if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) { - vk_key |= WWKEY_CTRL_BIT; - } - if ((GetKeyState(VK_MENU) & 0x8000) != 0) { - vk_key |= WWKEY_ALT_BIT; - } - } - - if (release) { - vk_key |= WWKEY_RLS_BIT; - } - - /* - ** Finally use the put command to enter the key into the keyboard - ** system. - */ - return(Put(vk_key)); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer. * - * * - * This routine will store the mouse type event into the keyboard buffer. It also checks * - * to ensure that there is enough room in the buffer so that partial mouse events won't * - * be recorded. * - * * - * INPUT: vk_key -- The mouse key message itself. * - * * - * x,y -- The mouse coordinates at the time of the event. * - * * - * release -- Is this a mouse button release? * - * * - * OUTPUT: bool; Was the event stored sucessfully into the keyboard buffer? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/02/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release) -{ - if (Available_Buffer_Room() >= 3 && Is_Mouse_Key(vk_key)) { - Put_Key_Message(vk_key, release); - Put((unsigned short)x); - Put((unsigned short)y); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * - * * - * This routine will convert the key code specified into an ASCII value. This takes into * - * consideration the language and keyboard mapping of the host Windows system. * - * * - * INPUT: key -- The key code to convert into ASCII. * - * * - * OUTPUT: Returns with the key converted into ASCII. If the key has no ASCII equivalent, * - * then '\0' is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -char WWKeyboardClass::To_ASCII(unsigned short key) -{ - /* - ** Released keys never translate into an ASCII value. - */ - if (key & WWKEY_RLS_BIT) { - return('\0'); - } - - /* - ** Set the KeyState buffer to reflect the shift bits stored in the key value. - */ - if (key & WWKEY_SHIFT_BIT) { - KeyState[VK_SHIFT] = 0x80; - } - if (key & WWKEY_CTRL_BIT) { - KeyState[VK_CONTROL] = 0x80; - } - if (key & WWKEY_ALT_BIT) { - KeyState[VK_MENU] = 0x80; - } - - /* - ** Ask windows to translate the key into an ASCII equivalent. - */ - char buffer[10]; - int result; -// int result = 1; - int scancode; -// int scancode = 0; - - scancode = MapVirtualKey(key & 0xFF, 0); - result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); - - /* - ** Restore the KeyState buffer back to pristine condition. - */ - if (key & WWKEY_SHIFT_BIT) { - KeyState[VK_SHIFT] = 0; - } - if (key & WWKEY_CTRL_BIT) { - KeyState[VK_CONTROL] = 0; - } - if (key & WWKEY_ALT_BIT) { - KeyState[VK_MENU] = 0; - } - - /* - ** If Windows could not perform the translation as expected, then - ** return with a null ASCII value. - */ - if (result != 1) { - return('\0'); - } - - return(buffer[0]); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * - * * - * This routine will examine the key specified to see if it is currently being held down. * - * * - * INPUT: key -- The key to check. * - * * - * OUTPUT: bool; Is the specified key currently being held down? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Down(unsigned short key) -{ - return(GetAsyncKeyState(key & 0xFF) != 0); -} - - -//extern "C" { -// void __cdecl Stop_Execution (void); -//} - - -/*********************************************************************************************** - * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * - * * - * This routine will extract the next pending element in the keyboard queue. If there is * - * no element available, then NULL is returned. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the element extracted from the queue. An empty queue is signified * - * by a 0 return value. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Fetch_Element(void) -{ - unsigned short val = 0; - if (Head != Tail) { - val = Buffer[Head]; - - Head = (Head + 1) % ARRAY_SIZE(Buffer); - } - return(val); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * - * * - * This routine will examine and return with the next element in the keyboard buffer but * - * it will not alter or remove that element. Use this routine to see what is pending in * - * the keyboard queue. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the next element in the keyboard queue. If the keyboard buffer is * - * empty, then 0 is returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short WWKeyboardClass::Peek_Element(void) const -{ - if (!Is_Buffer_Empty()) { - return(Buffer[Head]); - } - return(0); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * - * * - * This will put one keyboard data element into the keyboard buffer. Typically, this data * - * is a key code, but it might be mouse coordinates. * - * * - * INPUT: val -- The data element to add to the keyboard buffer. * - * * - * OUTPUT: bool; Was the keyboard element added successfully? A failure would indicate that * - * the keyboard buffer is full. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Put_Element(unsigned short val) -{ - if (!Is_Buffer_Full()) { - int temp = (Tail+1) % ARRAY_SIZE(Buffer); - Buffer[Tail] = val; - Tail = temp; - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * - * * - * This routine will examine the keyboard buffer to determine if it is completely * - * full of queued keyboard events. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the keyboard buffer completely full? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Buffer_Full(void) const -{ - if ((Tail + 1) % ARRAY_SIZE(Buffer) == Head) { - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * - * * - * This routine will examine the keyboard buffer to see if it contains no events at all. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the keyboard buffer currently without any pending events queued? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Is_Buffer_Empty(void) const -{ - if (Head == Tail) { - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages. * - * * - * This routine will extract and process any windows messages in the windows message * - * queue. It is presumed that the normal message handler will call the keyboard * - * message processing function. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -void WWKeyboardClass::Fill_Buffer_From_System(void) -{ - if (!Is_Buffer_Full()) { - Windows_Message_Handler(); -// MSG msg; -// while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { -// if (!GetMessage( &msg, NULL, 0, 0 )) { -// return; -// } -// TranslateMessage(&msg); -// DispatchMessage(&msg); -// } - } -} - - -/*********************************************************************************************** - * WWKeyboardClass::Clear -- Clears the keyboard buffer. * - * * - * This routine will clear the keyboard buffer of all pending keyboard events. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -void WWKeyboardClass::Clear(void) -{ - /* - ** Extract any windows pending keyboard message events and then clear out the keyboard - ** buffer. - */ - Fill_Buffer_From_System(); - Head = Tail; - - /* - ** Perform a second clear to handle the rare case of the keyboard buffer being full and there - ** still remains keyboard related events in the windows message queue. - */ - Fill_Buffer_From_System(); - Head = Tail; -} - - -/*********************************************************************************************** - * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboard * - * * - * This routine will examine the Windows message specified. If the message relates to an * - * event that the keyboard input system needs to process, then it will be processed * - * accordingly. * - * * - * INPUT: window -- Handle to the window receiving the message. * - * * - * message -- The message number of this event. * - * * - * wParam -- The windows specific word parameter (meaning depends on message). * - * * - * lParam -- The windows specific long word parameter (meaning is message dependant)* - * * - * OUTPUT: bool; Was this keyboard message recognized and processed? A 'false' return value * - * means that the message should be processed normally. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 09/30/1996 JLB : Created. * - *=============================================================================================*/ -bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LONG lParam) -{ - bool processed = false; - - POINT point; - point.x = LOWORD(lParam); - point.y = HIWORD(lParam); - ClientToScreen(window, &point); - int x = point.x; - int y = point.y; - - // Special conversion to game coordinates is needed here. - if (MouseCursor != NULL) MouseCursor->Convert_Coordinate(x, y); - - /* - ** Examine the message to see if it is one that should be processed. Only keyboard and - ** pertinant mouse messages are processed. - */ - switch (message) { - - /* - ** System key has been pressed. This is the normal keyboard event message. - */ - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - if (wParam == VK_SCROLL) { - Stop_Execution(); - } else { - Put_Key_Message((unsigned short)wParam); - } - processed = true; - break; - - /* - ** The key has been released. This is the normal key release message. - */ - case WM_SYSKEYUP: - case WM_KEYUP: - Put_Key_Message((unsigned short)wParam, true); - processed = true; - break; - - /* - ** Press of the left mouse button. - */ - case WM_LBUTTONDOWN: - Put_Mouse_Message(VK_LBUTTON, x, y); - processed = true; - break; - - /* - ** Release of the left mouse button. - */ - case WM_LBUTTONUP: - Put_Mouse_Message(VK_LBUTTON, x, y, true); - processed = true; - break; - - /* - ** Double click of the left mouse button. Fake this into being - ** just a rapid click of the left button twice. - */ - case WM_LBUTTONDBLCLK: - Put_Mouse_Message(VK_LBUTTON, x, y); - Put_Mouse_Message(VK_LBUTTON, x, y, true); - Put_Mouse_Message(VK_LBUTTON, x, y); - Put_Mouse_Message(VK_LBUTTON, x, y, true); - processed = true; - break; - - /* - ** Press of the middle mouse button. - */ - case WM_MBUTTONDOWN: - Put_Mouse_Message(VK_MBUTTON, x, y); - processed = true; - break; - - /* - ** Release of the middle mouse button. - */ - case WM_MBUTTONUP: - Put_Mouse_Message(VK_MBUTTON, x, y, true); - processed = true; - break; - - /* - ** Middle button double click gets translated into two - ** regular middle button clicks. - */ - case WM_MBUTTONDBLCLK: - Put_Mouse_Message(VK_MBUTTON, x, y); - Put_Mouse_Message(VK_MBUTTON, x, y, true); - Put_Mouse_Message(VK_MBUTTON, x, y); - Put_Mouse_Message(VK_MBUTTON, x, y, true); - processed = true; - break; - - /* - ** Right mouse button press. - */ - case WM_RBUTTONDOWN: - Put_Mouse_Message(VK_RBUTTON, x, y); - processed = true; - break; - - /* - ** Right mouse button release. - */ - case WM_RBUTTONUP: - Put_Mouse_Message(VK_RBUTTON, x, y, true); - processed = true; - break; - - /* - ** Translate a double click of the right button - ** into being just two regular right button clicks. - */ - case WM_RBUTTONDBLCLK: - Put_Mouse_Message(VK_RBUTTON, x, y); - Put_Mouse_Message(VK_RBUTTON, x, y, true); - Put_Mouse_Message(VK_RBUTTON, x, y); - Put_Mouse_Message(VK_RBUTTON, x, y, true); - processed = true; - break; - - /* - ** If the message is not pertinant to the keyboard system, - ** then do nothing. - */ - default: - break; - } - - /* - ** If this message has been processed, then pass it on to the system - ** directly. - */ - if (processed) { - DefWindowProc(window, message, wParam, lParam); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keyboa * - * * - * This examines the keyboard buffer queue and determine how many elements are available * - * for use before the buffer becomes full. Typical use of this would be when inserting * - * mouse events that require more than one element. Such an event must detect when there * - * would be insufficient room in the buffer and bail accordingly. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of elements that may be stored in to the keyboard buffer * - * before it becomes full and cannot accept any more elements. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 11/02/1996 JLB : Created. * - *=============================================================================================*/ -int WWKeyboardClass::Available_Buffer_Room(void) const -{ - int avail = 0; - if (Head == Tail) { - avail = ARRAY_SIZE(Buffer); - } - if (Head < Tail) { - avail = Tail - Head; - } - if (Head > Tail) { - avail = (Tail + ARRAY_SIZE(Buffer)) - Head; - } - return(avail); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.h deleted file mode 100644 index 47032dd1252..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/keyboard.h +++ /dev/null @@ -1,677 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/keyboard.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 9:03p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef KEY_H -#define KEY_H - - -#include "_xmouse.h" -#include "win.h" - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include "bool.h" - - -typedef enum { - WWKEY_SHIFT_BIT = 0x100, - WWKEY_CTRL_BIT = 0x200, - WWKEY_ALT_BIT = 0x400, - WWKEY_RLS_BIT = 0x800, - WWKEY_VK_BIT = 0x1000, - WWKEY_DBL_BIT = 0x2000, - WWKEY_BTN_BIT = 0x8000 -} WWKey_Type; - - -class WWKeyboardClass -{ - public: - /* Define the base constructor and destructors for the class */ - WWKeyboardClass(); - - /* Define the functions which work with the Keyboard Class */ - unsigned short Check(void) const; - unsigned short Get(void); - bool Put(unsigned short key); - void Clear(void); - char To_ASCII(unsigned short num); - bool Down(unsigned short key); - - /* Define the main hook for the message processing loop. */ - bool Message_Handler(HWND hwnd, UINT message, UINT wParam, LONG lParam); - - /* Define the public access variables which are used with the */ - /* Keyboard Class. */ - int MouseQX; - int MouseQY; - - private: - - /* - ** This is a keyboard state array that is used to aid in translating - ** KN_ keys into KA_ keys. - */ - unsigned char KeyState[256]; - - /* - ** This is the circular keyboard holding buffer. It holds the VK key and - ** the current shift state at the time the key was added to the queue. - */ - unsigned short Buffer[256]; // buffer which holds actual keypresses - - unsigned short Buff_Get(void); - unsigned short Fetch_Element(void); - unsigned short Peek_Element(void) const; - bool Put_Element(unsigned short val); - bool Is_Buffer_Full(void) const; - bool Is_Buffer_Empty(void) const; - static bool Is_Mouse_Key(unsigned short key); - void Fill_Buffer_From_System(void); - bool Put_Key_Message(unsigned short vk_key, bool release = false); - bool Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release = false); - int Available_Buffer_Room(void) const; - - /* - ** These are the tracking pointers to maintain the - ** circular keyboard list. - */ - int Head; - int Tail; -}; - - - -#define VK_NONE 0x00 -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_CANCEL 0x03 -#define VK_MBUTTON 0x04 -#define VK_NONE_05 0x05 -#define VK_NONE_06 0x06 -#define VK_NONE_07 0x07 -#define VK_BACK 0x08 -#define VK_TAB 0x09 -#define VK_NONE_0A 0x0A -#define VK_NONE_0B 0x0B -#define VK_CLEAR 0x0C -#define VK_RETURN 0x0D -#define VK_NONE_0E 0x0E -#define VK_NONE_0F 0x0F -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 -#define VK_NONE_15 0x15 -#define VK_NONE_16 0x16 -#define VK_NONE_17 0x17 -#define VK_NONE_18 0x18 -#define VK_NONE_19 0x19 -#define VK_NONE_1A 0x1A -#define VK_ESCAPE 0x1B -#define VK_NONE_1C 0x1C -#define VK_NONE_1D 0x1D -#define VK_NONE_1E 0x1E -#define VK_NONE_1F 0x1F -#define VK_SPACE 0x20 -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SELECT 0x29 -#define VK_PRINT 0x2A -#define VK_EXECUTE 0x2B -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E -#define VK_HELP 0x2F -#define VK_0 0x30 -#define VK_1 0x31 -#define VK_2 0x32 -#define VK_3 0x33 -#define VK_4 0x34 -#define VK_5 0x35 -#define VK_6 0x36 -#define VK_7 0x37 -#define VK_8 0x38 -#define VK_9 0x39 -#define VK_NONE_3B 0x3B -#define VK_NONE_3C 0x3C -#define VK_NONE_3D 0x3D -#define VK_NONE_3E 0x3E -#define VK_NONE_3F 0x3F -#define VK_NONE_40 0x40 -#define VK_A 0x41 -#define VK_B 0x42 -#define VK_C 0x43 -#define VK_D 0x44 -#define VK_E 0x45 -#define VK_F 0x46 -#define VK_G 0x47 -#define VK_H 0x48 -#define VK_I 0x49 -#define VK_J 0x4A -#define VK_K 0x4B -#define VK_L 0x4C -#define VK_M 0x4D -#define VK_N 0x4E -#define VK_O 0x4F -#define VK_P 0x50 -#define VK_Q 0x51 -#define VK_R 0x52 -#define VK_S 0x53 -#define VK_T 0x54 -#define VK_U 0x55 -#define VK_V 0x56 -#define VK_W 0x57 -#define VK_X 0x58 -#define VK_Y 0x59 -#define VK_Z 0x5A -#define VK_NONE_5B 0x5B -#define VK_NONE_5C 0x5C -#define VK_NONE_5D 0x5D -#define VK_NONE_5E 0x5E -#define VK_NONE_5F 0x5F -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 -#define VK_MULTIPLY 0x6A -#define VK_ADD 0x6B -#define VK_SEPARATOR 0x6C -#define VK_SUBTRACT 0x6D -#define VK_DECIMAL 0x6E -#define VK_DIVIDE 0x6F -#define VK_F1 0x70 -#define VK_F2 0x71 -#define VK_F3 0x72 -#define VK_F4 0x73 -#define VK_F5 0x74 -#define VK_F6 0x75 -#define VK_F7 0x76 -#define VK_F8 0x77 -#define VK_F9 0x78 -#define VK_F10 0x79 -#define VK_F11 0x7A -#define VK_F12 0x7B -#define VK_F13 0x7C -#define VK_F14 0x7D -#define VK_F15 0x7E -#define VK_F16 0x7F -#define VK_F17 0x80 -#define VK_F18 0x81 -#define VK_F19 0x82 -#define VK_F20 0x83 -#define VK_F21 0x84 -#define VK_F22 0x85 -#define VK_F23 0x86 -#define VK_F24 0x87 -#define VK_NONE_88 0x88 -#define VK_NONE_89 0x89 -#define VK_NONE_8A 0x8A -#define VK_NONE_8B 0x8B -#define VK_NONE_8C 0x8C -#define VK_NONE_8D 0x8D -#define VK_NONE_8E 0x8E -#define VK_NONE_8F 0x8F -#define VK_NUMLOCK 0x90 -#define VK_SCROLL 0x91 -#define VK_NONE_92 0x92 -#define VK_NONE_93 0x93 -#define VK_NONE_94 0x94 -#define VK_NONE_95 0x95 -#define VK_NONE_96 0x96 -#define VK_NONE_97 0x97 -#define VK_NONE_98 0x98 -#define VK_NONE_99 0x99 -#define VK_NONE_9A 0x9A -#define VK_NONE_9B 0x9B -#define VK_NONE_9C 0x9C -#define VK_NONE_9D 0x9D -#define VK_NONE_9E 0x9E -#define VK_NONE_9F 0x9F -#define VK_NONE_A0 0xA0 -#define VK_NONE_A1 0xA1 -#define VK_NONE_A2 0xA2 -#define VK_NONE_A3 0xA3 -#define VK_NONE_A4 0xA4 -#define VK_NONE_A5 0xA5 -#define VK_NONE_A6 0xA6 -#define VK_NONE_A7 0xA7 -#define VK_NONE_A8 0xA8 -#define VK_NONE_A9 0xA9 -#define VK_NONE_AA 0xAA -#define VK_NONE_AB 0xAB -#define VK_NONE_AC 0xAC -#define VK_NONE_AD 0xAD -#define VK_NONE_AE 0xAE -#define VK_NONE_AF 0xAF -#define VK_NONE_B0 0xB0 -#define VK_NONE_B1 0xB1 -#define VK_NONE_B2 0xB2 -#define VK_NONE_B3 0xB3 -#define VK_NONE_B4 0xB4 -#define VK_NONE_B5 0xB5 -#define VK_NONE_B6 0xB6 -#define VK_NONE_B7 0xB7 -#define VK_NONE_B8 0xB8 -#define VK_NONE_B9 0xB9 -#define VK_NONE_BA 0xBA // ; -#define VK_NONE_BB 0xBB // = -#define VK_NONE_BC 0xBC // , -#define VK_NONE_BD 0xBD // - -#define VK_NONE_BE 0xBE // . -#define VK_NONE_BF 0xBF // / -#define VK_NONE_C0 0xC0 // ` -#define VK_NONE_C1 0xC1 -#define VK_NONE_C2 0xC2 -#define VK_NONE_C3 0xC3 -#define VK_NONE_C4 0xC4 -#define VK_NONE_C5 0xC5 -#define VK_NONE_C6 0xC6 -#define VK_NONE_C7 0xC7 -#define VK_NONE_C8 0xC8 -#define VK_NONE_C9 0xC9 -#define VK_NONE_CA 0xCA -#define VK_NONE_CB 0xCB -#define VK_NONE_CC 0xCC -#define VK_NONE_CD 0xCD -#define VK_NONE_CE 0xCE -#define VK_NONE_CF 0xCF -#define VK_NONE_D0 0xD0 -#define VK_NONE_D1 0xD1 -#define VK_NONE_D2 0xD2 -#define VK_NONE_D3 0xD3 -#define VK_NONE_D4 0xD4 -#define VK_NONE_D5 0xD5 -#define VK_NONE_D6 0xD6 -#define VK_NONE_D7 0xD7 -#define VK_NONE_D8 0xD8 -#define VK_NONE_D9 0xD9 -#define VK_NONE_DA 0xDA -#define VK_NONE_DB 0xDB // [ -#define VK_NONE_DC 0xDC // '\' -#define VK_NONE_DD 0xDD // ] -#define VK_NONE_DE 0xDE // ' -#define VK_NONE_DF 0xDF -#define VK_NONE_E0 0xE0 -#define VK_NONE_E1 0xE1 -#define VK_NONE_E2 0xE2 -#define VK_NONE_E3 0xE3 -#define VK_NONE_E4 0xE4 -#define VK_NONE_E5 0xE5 -#define VK_NONE_E6 0xE6 -#define VK_NONE_E7 0xE7 -#define VK_NONE_E8 0xE8 -#define VK_NONE_E9 0xE9 -#define VK_NONE_EA 0xEA -#define VK_NONE_EB 0xEB -#define VK_NONE_EC 0xEC -#define VK_NONE_ED 0xED -#define VK_NONE_EE 0xEE -#define VK_NONE_EF 0xEF -#define VK_NONE_F0 0xF0 -#define VK_NONE_F1 0xF1 -#define VK_NONE_F2 0xF2 -#define VK_NONE_F3 0xF3 -#define VK_NONE_F4 0xF4 -#define VK_NONE_F5 0xF5 -#define VK_NONE_F6 0xF6 -#define VK_NONE_F7 0xF7 -#define VK_NONE_F8 0xF8 -#define VK_NONE_F9 0xF9 -#define VK_NONE_FA 0xFA -#define VK_NONE_FB 0xFB -#define VK_NONE_FC 0xFC -#define VK_NONE_FD 0xFD -#define VK_NONE_FE 0xFE -#define VK_NONE_FF 0xFF - -#define VK_UPLEFT VK_HOME -#define VK_UPRIGHT VK_PRIOR -#define VK_DOWNLEFT VK_END -#define VK_DOWNRIGHT VK_NEXT -#define VK_ALT VK_MENU - -typedef enum KeyASCIIType { - // - // Define all the KA types as variations of the VK types. This is - // so the KA functions will work properly under windows 95. - // - KA_NONE = 0, - KA_MORE = 1, - KA_SETBKGDCOL = 2, - KA_SETFORECOL = 6, - KA_FORMFEED = 12, - KA_SPCTAB = 20, - KA_SETX = 25, - KA_SETY = 26, - - KA_SPACE = 32, /* */ - KA_EXCLAMATION, /* ! */ - KA_DQUOTE, /* " */ - KA_POUND, /* # */ - KA_DOLLAR, /* $ */ - KA_PERCENT, /* % */ - KA_AMPER, /* & */ - KA_SQUOTE, /* ' */ - KA_LPAREN, /* ( */ - KA_RPAREN, /* ) */ - KA_ASTERISK, /* * */ - KA_PLUS, /* + */ - KA_COMMA, /* , */ - KA_MINUS, /* - */ - KA_PERIOD, /* . */ - KA_SLASH, /* / */ - - KA_0, KA_1, KA_2, KA_3, KA_4, KA_5, KA_6, KA_7, KA_8, KA_9, - KA_COLON, /* : */ - KA_SEMICOLON, /* ; */ - KA_LESS_THAN, /* < */ - KA_EQUAL, /* = */ - KA_GREATER_THAN, /* > */ - KA_QUESTION, /* ? */ - - KA_AT, /* @ */ - KA_A, /* A */ - KA_B, /* B */ - KA_C, /* C */ - KA_D, /* D */ - KA_E, /* E */ - KA_F, /* F */ - KA_G, /* G */ - KA_H, /* H */ - KA_I, /* I */ - KA_J, /* J */ - KA_K, /* K */ - KA_L, /* L */ - KA_M, /* M */ - KA_N, /* N */ - KA_O, /* O */ - - KA_P, /* P */ - KA_Q, /* Q */ - KA_R, /* R */ - KA_S, /* S */ - KA_T, /* T */ - KA_U, /* U */ - KA_V, /* V */ - KA_W, /* W */ - KA_X, /* X */ - KA_Y, /* Y */ - KA_Z, /* Z */ - KA_LBRACKET, /* [ */ - KA_BACKSLASH, /* \ */ - KA_RBRACKET, /* ] */ - KA_CARROT, /* ^ */ - KA_UNDERLINE, /* _ */ - - KA_GRAVE, /* ` */ - KA_a, /* a */ - KA_b, /* b */ - KA_c, /* c */ - KA_d, /* d */ - KA_e, /* e */ - KA_f, /* f */ - KA_g, /* g */ - KA_h, /* h */ - KA_i, /* i */ - KA_j, /* j */ - KA_k, /* k */ - KA_l, /* l */ - KA_m, /* m */ - KA_n, /* n */ - KA_o, /* o */ - - KA_p, /* p */ - KA_q, /* q */ - KA_r, /* r */ - KA_s, /* s */ - KA_t, /* t */ - KA_u, /* u */ - KA_v, /* v */ - KA_w, /* w */ - KA_x, /* x */ - KA_y, /* y */ - KA_z, /* z */ - KA_LBRACE, /* { */ - KA_BAR, /* | */ - KA_RBRACE, /* ] */ - KA_TILDA, /* ~ */ - - KA_ESC = VK_ESCAPE, - KA_EXTEND = VK_ESCAPE, - KA_RETURN = VK_RETURN, - KA_BACKSPACE = VK_BACK, - KA_TAB = VK_TAB , - KA_DELETE = VK_DELETE, /* */ - KA_INSERT = VK_INSERT, /* */ - KA_PGDN = VK_NEXT, /* */ - KA_DOWNRIGHT = VK_NEXT, - KA_DOWN = VK_DOWN, /* */ - KA_END = VK_END, /* */ - KA_DOWNLEFT = VK_END, - KA_RIGHT = VK_RIGHT, /* */ - KA_KEYPAD5 = VK_SELECT, /* NUMERIC KEY PAD <5> */ - KA_LEFT = VK_LEFT, /* */ - KA_PGUP = VK_PRIOR, /* */ - KA_UPRIGHT = VK_PRIOR, - KA_UP = VK_UP, /* */ - KA_HOME = VK_HOME, /* */ - KA_UPLEFT = VK_HOME, - KA_F12 = VK_F12, - KA_F11 = VK_F11, - KA_F10 = VK_F10, - KA_F9 = VK_F9, - KA_F8 = VK_F8, - KA_F7 = VK_F7, - KA_F6 = VK_F6, - KA_F5 = VK_F5, - KA_F4 = VK_F4, - KA_F3 = VK_F3, - KA_F2 = VK_F2, - KA_F1 = VK_F1, - KA_LMOUSE = VK_LBUTTON, - KA_RMOUSE = VK_RBUTTON, - - KA_SHIFT_BIT = WWKEY_SHIFT_BIT, - KA_CTRL_BIT = WWKEY_CTRL_BIT, - KA_ALT_BIT = WWKEY_ALT_BIT, - KA_RLSE_BIT = WWKEY_RLS_BIT -} KeyASCIIType; - - -typedef enum KeyNumType { - KN_NONE = 0, - - KN_0 = VK_0, - KN_1 = VK_1, - KN_2 = VK_2, - KN_3 = VK_3, - KN_4 = VK_4, - KN_5 = VK_5, - KN_6 = VK_6, - KN_7 = VK_7, - KN_8 = VK_8, - KN_9 = VK_9, - KN_A = VK_A, - KN_B = VK_B, - KN_BACKSLASH = VK_NONE_DC, - KN_BACKSPACE = VK_BACK, - KN_C = VK_C, - KN_CAPSLOCK = VK_CAPITAL, - KN_CENTER = VK_CLEAR, - KN_COMMA = VK_NONE_BC, - KN_D = VK_D, - KN_DELETE = VK_DELETE, - KN_DOWN = VK_DOWN, - KN_DOWNLEFT = VK_END, - KN_DOWNRIGHT = VK_NEXT, - KN_E = VK_E, - KN_END = VK_END, - KN_EQUAL = VK_NONE_BB, - KN_ESC = VK_ESCAPE, - KN_E_DELETE = VK_DELETE, - KN_E_DOWN = VK_NUMPAD2, - KN_E_END = VK_NUMPAD1, - KN_E_HOME = VK_NUMPAD7, - KN_E_INSERT = VK_INSERT, - KN_E_LEFT = VK_NUMPAD4, - KN_E_PGDN = VK_NUMPAD3, - KN_E_PGUP = VK_NUMPAD9, - KN_E_RIGHT = VK_NUMPAD6, - KN_E_UP = VK_NUMPAD8, - KN_F = VK_F, - KN_F1 = VK_F1, - KN_F10 = VK_F10, - KN_F11 = VK_F11, - KN_F12 = VK_F12, - KN_F2 = VK_F2, - KN_F3 = VK_F3, - KN_F4 = VK_F4, - KN_F5 = VK_F5, - KN_F6 = VK_F6, - KN_F7 = VK_F7, - KN_F8 = VK_F8, - KN_F9 = VK_F9, - KN_G = VK_G, - KN_GRAVE = VK_NONE_C0, - KN_H = VK_H, - KN_HOME = VK_HOME, - KN_I = VK_I, - KN_INSERT = VK_INSERT, - KN_J = VK_J, - KN_K = VK_K, - KN_KEYPAD_ASTERISK= VK_MULTIPLY, - KN_KEYPAD_MINUS = VK_SUBTRACT, - KN_KEYPAD_PLUS = VK_ADD, - KN_KEYPAD_RETURN = VK_RETURN, - KN_KEYPAD_SLASH = VK_DIVIDE, - KN_L = VK_L, - KN_LALT = VK_MENU, - KN_LBRACKET = VK_NONE_DB, - KN_LCTRL = VK_CONTROL, - KN_LEFT = VK_LEFT, - KN_LMOUSE = VK_LBUTTON, - KN_LSHIFT = VK_SHIFT, - KN_M = VK_M, - KN_MINUS = VK_NONE_BD, - KN_N = VK_N, - KN_NUMLOCK = VK_NUMLOCK, - KN_O = VK_O, - KN_P = VK_P, - KN_PAUSE = VK_PAUSE, - KN_PERIOD = VK_NONE_BE, - KN_PGDN = VK_NEXT, - KN_PGUP = VK_PRIOR, - KN_PRNTSCRN = VK_PRINT, - KN_Q = VK_Q, - KN_R = VK_R, - KN_RALT = VK_MENU, - KN_RBRACKET = VK_NONE_DD, - KN_RCTRL = VK_CONTROL, - KN_RETURN = VK_RETURN, - KN_RIGHT = VK_RIGHT, - KN_RMOUSE = VK_RBUTTON, - KN_RSHIFT = VK_SHIFT, - KN_S = VK_S, - KN_SCROLLLOCK = VK_SCROLL, - KN_SEMICOLON = VK_NONE_BA, - KN_SLASH = VK_NONE_BF, - KN_SPACE = VK_SPACE, - KN_SQUOTE = VK_NONE_DE, - KN_T = VK_T, - KN_TAB = VK_TAB, - KN_U = VK_U, - KN_UP = VK_UP, - KN_UPLEFT = VK_HOME, - KN_UPRIGHT = VK_PRIOR, - KN_V = VK_V, - KN_W = VK_W, - KN_X = VK_X, - KN_Y = VK_Y, - KN_Z = VK_Z, - - KN_SHIFT_BIT = WWKEY_SHIFT_BIT, - KN_CTRL_BIT = WWKEY_CTRL_BIT, - KN_ALT_BIT = WWKEY_ALT_BIT, - KN_RLSE_BIT = WWKEY_RLS_BIT, - KN_BUTTON = WWKEY_BTN_BIT -} KeyNumType; - -/* -** Interface class to the keyboard. This insulates the game from library vagaries. Most -** notable being the return values are declared as "int" in the library whereas C&C -** expects it to be of KeyNumType. -*/ - -//lint -esym(1725,KeyboardClass::MouseQX,KeyboardClass::MouseQY) -struct KeyboardClass : public WWKeyboardClass -{ - /* - ** This flag is used to indicate whether the WW library has taken over - ** the keyboard or not. If not, then the normal console input - ** takes precedence. - */ - unsigned IsLibrary; - - KeyboardClass() : IsLibrary(true) {} - KeyNumType Get(void) {return ((KeyNumType)WWKeyboardClass::Get());}; - KeyNumType Check(void) {return ((KeyNumType)WWKeyboardClass::Check());}; - KeyASCIIType To_ASCII(KeyNumType key) {return((KeyASCIIType)WWKeyboardClass::To_ASCII((unsigned short)key));}; - void Clear(void) {WWKeyboardClass::Clear();}; - int Down(KeyNumType key) {return(WWKeyboardClass::Down((unsigned short)key));}; - - int Mouse_X(void) {return(Get_Mouse_X());}; - int Mouse_Y(void) {return(Get_Mouse_Y());}; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp deleted file mode 100644 index 5cec32651fe..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcw.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/lcw.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * LCW_Comp -- Performes LCW compression on a block of data. * - * LCW_Uncomp -- Decompress an LCW encoded data block. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "LCW.H" - -/*************************************************************************** - * LCW_Uncomp -- Decompress an LCW encoded data block. * - * * - * Uncompress data to the following codes in the format b = byte, w = word * - * n = byte code pulled from compressed data. * - * * - * Command code, n |Description * - * ------------------------------------------------------------------------* - * n=0xxxyyyy,yyyyyyyy |short copy back y bytes and run x+3 from dest * - * n=10xxxxxx,n1,n2,...,nx+1|med length copy the next x+1 bytes from source* - * n=11xxxxxx,w1 |med copy from dest x+3 bytes from offset w1 * - * n=11111111,w1,w2 |long copy from dest w1 bytes from offset w2 * - * n=11111110,w1,b1 |long run of byte b1 for w1 bytes * - * n=10000000 |end of data reached * - * * - * * - * INPUT: * - * void * source ptr * - * void * destination ptr * - * unsigned long length of uncompressed data * - * * - * * - * OUTPUT: * - * unsigned long # of destination bytes written * - * * - * WARNINGS: * - * 3rd argument is dummy. It exists to provide cross-platform * - * compatibility. Note therefore that this implementation does not * - * check for corrupt source data by testing the uncompressed length. * - * * - * HISTORY: * - * 03/20/1995 IML : Created. * - *=========================================================================*/ -int LCW_Uncomp(void const * source, void * dest, unsigned long ) -{ - unsigned char * source_ptr, * dest_ptr, * copy_ptr; - unsigned char op_code, data; - unsigned count; - unsigned * word_dest_ptr; - unsigned word_data; - - /* Copy the source and destination ptrs. */ - source_ptr = (unsigned char*) source; - dest_ptr = (unsigned char*) dest; - - for (;;) { - - /* Read in the operation code. */ - op_code = *source_ptr++; - - if (!(op_code & 0x80)) { - - /* Do a short copy from destination. */ - count = (op_code >> 4) + 3; - copy_ptr = dest_ptr - ((unsigned) *source_ptr++ + (((unsigned) op_code & 0x0f) << 8)); - - while (count--) *dest_ptr++ = *copy_ptr++; - - } else { - - if (!(op_code & 0x40)) { - - if (op_code == 0x80) { - - /* Return # of destination bytes written. */ - return ((unsigned long) (dest_ptr - (unsigned char*) dest)); - - } else { - - /* Do a medium copy from source. */ - count = op_code & 0x3f; - - while (count--) *dest_ptr++ = *source_ptr++; - } - - } else { - - if (op_code == 0xfe) { - - /* Do a long run. */ - count = *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - word_data = data = *(source_ptr + 2); - word_data = (word_data << 24) + (word_data << 16) + (word_data << 8) + word_data; - source_ptr += 3; - - copy_ptr = dest_ptr + 4 - ((unsigned) dest_ptr & 0x3); - count -= (copy_ptr - dest_ptr); - while (dest_ptr < copy_ptr) *dest_ptr++ = data; - - word_dest_ptr = (unsigned*) dest_ptr; - - dest_ptr += (count & 0xfffffffc); - - while (word_dest_ptr < (unsigned*) dest_ptr) { - *word_dest_ptr = word_data; - *(word_dest_ptr + 1) = word_data; - word_dest_ptr += 2; - } - - copy_ptr = dest_ptr + (count & 0x3); - while (dest_ptr < copy_ptr) *dest_ptr++ = data; - - } else { - - if (op_code == 0xff) { - - /* Do a long copy from destination. */ - count = *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - copy_ptr = (unsigned char*) dest + *(source_ptr + 2) + ((unsigned) *(source_ptr + 3) << 8); - source_ptr += 4; - - while (count--) *dest_ptr++ = *copy_ptr++; - - } else { - - /* Do a medium copy from destination. */ - count = (op_code & 0x3f) + 3; - copy_ptr = (unsigned char*) dest + *source_ptr + ((unsigned) *(source_ptr + 1) << 8); - source_ptr += 2; - - while (count--) *dest_ptr++ = *copy_ptr++; - } - } - } - } - } -} - - -#if defined(_MSC_VER) && defined(_M_IX86) - - -/*********************************************************************************************** - * LCW_Comp -- Performes LCW compression on a block of data. * - * * - * This routine will compress a block of data using the LCW compression method. LCW has * - * the primary characteristic of very fast uncompression at the expense of very slow * - * compression times. * - * * - * INPUT: source -- Pointer to the source data to compress. * - * * - * dest -- Pointer to the destination location to store the compressed data * - * to. * - * * - * datasize -- The size (in bytes) of the source data to compress. * - * * - * OUTPUT: Returns with the number of bytes of output data stored into the destination * - * buffer. * - * * - * WARNINGS: Be sure that the destination buffer is big enough. The maximum size required * - * for the destination buffer is (datasize + datasize/128). * - * * - * HISTORY: * - * 05/20/1997 JLB : Created. * - *=============================================================================================*/ -/*ARGSUSED*/ -int LCW_Comp(void const * source, void * dest, int datasize) -{ - int retval = 0; -#ifdef _WINDOWS - long inlen = 0; - long a1stdest = 0; - long a1stsrc = 0; - long lenoff = 0; - long ndest = 0; - long count = 0; - long matchoff = 0; - long end_of_data =0; -#ifdef _DEBUG - inlen = inlen; - a1stdest = a1stdest; - a1stsrc = a1stsrc; - lenoff = lenoff; - ndest = ndest; - count = count; - matchoff = matchoff; - end_of_data = end_of_data; -#endif - - __asm { - cld // make sure all string commands are forward - mov edi,[dest] - mov esi,[source] - mov edx,[datasize] // get length of data to compress - -// compress data to the following codes in the format b = byte, w = word -// n = byte code pulled from compressed data -// Bit field of n command description -// n=0xxxyyyy,yyyyyyyy short run back y bytes and run x+3 -// n=10xxxxxx,n1,n2,...,nx+1 med length copy the next x+1 bytes -// n=11xxxxxx,w1 med run run x+3 bytes from offset w1 -// n=11111111,w1,w2 long run run w1 bytes from offset w2 -// n=10000000 end end of data reached - - mov ebx,esi - add ebx,edx - mov [end_of_data],ebx - mov [inlen],1 //; set the in-length flag - mov [a1stdest],edi //; save original dest offset for size calc - mov [a1stsrc],esi //; save offset of first byte of data - mov [lenoff],edi //; save the offset of the legth of this len - sub eax,eax - mov al,081h //; the first byte is always a len - stosb //; write out a len of 1 - lodsb //; get the byte - stosb //; save it - } - -loopstart: - __asm { - mov [ndest],edi //; save offset of compressed data - mov edi,[a1stsrc] //; get the offset to the first byte of data - mov [count],1 //; set the count of run to 0 - } -searchloop: - __asm { - sub eax,eax - mov al,[esi] //; get the current byte of data - cmp al,[esi+64] - jne short notrunlength - - mov ebx,edi - - mov edi,esi - mov ecx,[end_of_data] - sub ecx,edi - repe scasb - dec edi - mov ecx,edi - sub ecx,esi - cmp ecx,65 - jb short notlongenough - - mov [inlen],0 //; clear the in-length flag -// mov [DWORD PTR inlen],0 //; clear the in-length flag - mov esi,edi - mov edi,[ndest] //; get the offset of our compressed data - - mov ah,al - mov al,0FEh - stosb - xchg ecx,eax - stosw - mov al,ch - stosb - - mov [ndest],edi //; save offset of compressed data - mov edi,ebx - jmp searchloop - } -notlongenough: - __asm { - mov edi,ebx - } -notrunlength: -oploop: - __asm { - mov ecx,esi //; get the address of the last byte +1 - sub ecx,edi //; get the total number of bytes left to comp - jz short searchdone - - repne scasb //; look for a match - jne short searchdone //; if we don't find one we're done - - mov ebx,[count] - mov ah,[esi+ebx-1] - cmp ah,[edi+ebx-2] - - jne oploop - - mov edx,esi //; save this spot for the next search - mov ebx,edi //; save this spot for the length calc - dec edi //; back up one for compare - mov ecx,[end_of_data] //; get the end of data - sub ecx,esi //; sub current source for max len - - repe cmpsb //; see how many bytes match - - jne short notend //; if found mismatch then di - bx = match count - - inc edi //; else cx = 0 and di + 1 - bx = match count - } -notend: - __asm { - mov esi,edx //; restore si - mov eax,edi //; get the dest - sub eax,ebx //; sub the start for total bytes that match - mov edi,ebx //; restore dest - cmp eax,[count] //; see if its better than before - jb searchloop //; if not keep looking - - mov [count],eax //; if so keep the count - dec ebx //; back it up for the actual match offset - mov [matchoff],ebx //; save the offset for later - jmp searchloop //; loop until we searched it all - } -searchdone: - __asm { - mov ecx,[count] //; get the count of the longest run - mov edi,[ndest] //; get the offset of our compressed data - cmp ecx,2 //; see if its not enough run to matter - jbe short lenin //; if its 0,1, or 2 its too small - - cmp ecx,10 //; if not, see if it would fit in a short - ja short medrun //; if not, see if its a medium run - - mov eax,esi //; if its short get the current address - sub eax,[matchoff] //; sub the offset of the match - cmp eax,0FFFh //; if its less than 12 bits its a short - ja short medrun //; if its not, its a medium - } -//shortrun: - __asm { - sub ebx,ebx - mov bl,cl //; get the length (3-10) - sub bl,3 //; sub 3 for a 3 bit number 0-7 - shl bl,4 //; shift it left 4 - add ah,bl //; add in the length for the high nibble - xchg ah,al //; reverse the bytes for a word store - jmp short srunnxt //; do the run fixup code - } -medrun: - __asm { - cmp ecx,64 //; see if its a short run - ja short longrun //; if not, oh well at least its long - - sub cl,3 //; back down 3 to keep it in 6 bits - or cl,0C0h //; the highest bits are always on - mov al,cl //; put it in al for the stosb - stosb //; store it - jmp short medrunnxt //; do the run fixup code - } -lenin: - __asm { - cmp [inlen],0 //; is it doing a length? -// cmp [DWORD PTR inlen],0 //; is it doing a length? - jnz short len //; if so, skip code - } -lenin1: - __asm { - mov [lenoff],edi //; save the length code offset - mov al,80h //; set the length to 0 - stosb //; save it - } -len: - __asm { - mov ebx,[lenoff] //; get the offset of the length code - cmp [ebx],0BFh //; see if its maxed out -// cmp [BYTE PTR ebx],0BFh //; see if its maxed out - je lenin1 //; if so put out a new len code - } -//stolen: - __asm { - inc [ebx] //; inc the count code -// inc [BYTE PTR ebx] //; inc the count code - lodsb //; get the byte - stosb //; store it - mov [inlen],1 //; we are now in a length so save it -// mov [DWORD PTR inlen],1 //; we are now in a length so save it - jmp short nxt //; do the next code - } -longrun: - __asm { - mov al,0ffh //; its a long so set a code of FF - stosb //; store it - - mov eax,[count] //; send out the count - stosw //; store it - } -medrunnxt: - __asm { - mov eax,[matchoff] //; get the offset - sub eax,[a1stsrc] //; make it relative tot he start of data - } -srunnxt: - __asm { - stosw //; store it - //; this code common to all runs - add esi,[count] //; add in the length of the run to the source - mov [inlen],0 //; set the in leght flag to false -// mov [DWORD PTR inlen],0 //; set the in leght flag to false - } -nxt: - __asm { - cmp esi,[end_of_data] //; see if we did the whole pic - jae short outofhere //; if so, cool! were done - - jmp loopstart - } -outofhere: - __asm { - mov ax,080h //; remember to send an end of data code - stosb //; store it - mov eax,edi //; get the last compressed address - sub eax,[a1stdest] //; sub the first for the compressed size - mov [retval],eax - } -#endif - return(retval); -} -#endif // defined(_MSC_VER) && defined(_M_IX86) - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.cpp deleted file mode 100644 index 8c84761cd45..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/LCWPIPE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * LCWPipe::Flush -- Flushes any partially accumulated block. * - * LCWPipe::LCWPipe -- Constructor for the LCW processor pipe. * - * LCWPipe::Put -- Send some data through the LCW processor pipe. * - * LCWPipe::~LCWPipe -- Deconstructor for the LCW pipe object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "LCW.H" -#include "lcwpipe.h" -#include -#include - - -/*********************************************************************************************** - * LCWPipe::LCWPipe -- Constructor for the LCW processor pipe. * - * * - * This will initialize the LCWPipe object so that it is prepared for compression or * - * decompression as indicated. * - * * - * INPUT: decrypt -- Should decompression be performed? * - * * - * blocksize-- The size of the data blocks to process. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/04/1996 JLB : Created. * - *=============================================================================================*/ -LCWPipe::LCWPipe(CompControl control, int blocksize) : - Control(control), - Counter(0), - Buffer(NULL), - Buffer2(NULL), - BlockSize(blocksize) -{ - SafetyMargin = BlockSize/128+1; - Buffer = new char[BlockSize+SafetyMargin]; - Buffer2 = new char[BlockSize+SafetyMargin]; - BlockHeader.CompCount = 0xFFFF; -} - - -/*********************************************************************************************** - * LCWPipe::~LCWPipe -- Deconstructor for the LCW pipe object. * - * * - * This will free any buffers it may have allocated. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/04/1996 JLB : Created. * - *=============================================================================================*/ -LCWPipe::~LCWPipe(void) -{ - delete [] Buffer; - Buffer = NULL; - - delete [] Buffer2; - Buffer2 = NULL; -} - - -/*********************************************************************************************** - * LCWPipe::Put -- Send some data through the LCW processor pipe. * - * * - * This routine will take the data requested and process it (decompression or compression). * - * It does this by accumulating the necessary bytes to make a whole block. Then the block * - * is processed and the entire contents are flushed to the next pipe segment in the chain. * - * * - * INPUT: source -- Pointer to the data to be fed to this LCW processor. * - * * - * length -- The number of bytes received. * - * * - * OUTPUT: Returns with the actual number of bytes output at the far distant final link in * - * the pipe chain. * - * * - * WARNINGS: The compression process may be slow as well as consuming two buffers. * - * * - * HISTORY: * - * 07/04/1996 JLB : Created. * - *=============================================================================================*/ -int LCWPipe::Put(void const * source, int slen) -{ - if (source == NULL || slen < 1) { - return(Pipe::Put(source, slen)); - } - - assert(Buffer != NULL); - - int total = 0; - - /* - ** Copy as much as can fit into the buffer from the source data supplied. - */ - if (Control == DECOMPRESS) { - - while (slen > 0) { - - /* - ** First check to see if we are in the block header accumulation phase. - ** When a whole block header has been accumulated, only then will the regular - ** data processing begin for the block. - */ - if (BlockHeader.CompCount == 0xFFFF) { - int len = ((unsigned)slen < (sizeof(BlockHeader)-Counter)) ? slen : (sizeof(BlockHeader)-Counter); - memmove(&Buffer[Counter], source, len); - source = ((char *)source) + len; - slen -= len; - Counter += len; - - /* - ** A whole block header has been accumulated. Store it for safekeeping. - */ - if (Counter == sizeof(BlockHeader)) { - memmove(&BlockHeader, Buffer, sizeof(BlockHeader)); - Counter = 0; - } - } - - /* - ** Fill the buffer with compressed data until there is enough to make a whole - ** data block. - */ - if (slen > 0) { - int len = (slen < (BlockHeader.CompCount-Counter)) ? slen : (BlockHeader.CompCount-Counter); - - memmove(&Buffer[Counter], source, len); - slen -= len; - source = ((char *)source) + len; - Counter += len; - - /* - ** If an entire block has been accumulated, then uncompress it and feed it - ** through the pipe. - */ - if (Counter == BlockHeader.CompCount) { - LCW_Uncomp(Buffer, Buffer2); - total += Pipe::Put(Buffer2, BlockHeader.UncompCount); - Counter = 0; - BlockHeader.CompCount = 0xFFFF; - } - } - } - - } else { - - /* - ** If the buffer already contains some data, then any new data must be stored - ** into the staging buffer until a full set has been accumulated. - */ - if (Counter > 0) { - int tocopy = (slen < (BlockSize-Counter)) ? slen : (BlockSize-Counter); - memmove(&Buffer[Counter], source, tocopy); - source = ((char *)source) + tocopy; - slen -= tocopy; - Counter += tocopy; - - if (Counter == BlockSize) { - int len = LCW_Comp(Buffer, Buffer2, BlockSize); - - BlockHeader.CompCount = (unsigned short)len; - BlockHeader.UncompCount = (unsigned short)BlockSize; - total += Pipe::Put(&BlockHeader, sizeof(BlockHeader)); - total += Pipe::Put(Buffer2, len); - Counter = 0; - } - } - - /* - ** Process the source data in whole block chunks until there is insufficient - ** source data left for a whole data block. - */ - while (slen >= BlockSize) { - int len = LCW_Comp(source, Buffer2, BlockSize); - - source = ((char *)source) + BlockSize; - slen -= BlockSize; - - BlockHeader.CompCount = (unsigned short)len; - BlockHeader.UncompCount = (unsigned short)BlockSize; - total += Pipe::Put(&BlockHeader, sizeof(BlockHeader)); - total += Pipe::Put(Buffer2, len); - } - - /* - ** If there is any remaining data, then it is stored into the buffer - ** until a full data block has been accumulated. - */ - if (slen > 0) { - memmove(Buffer, source, slen); - Counter = slen; - } - } - - return(total); -} - - -/*********************************************************************************************** - * LCWPipe::Flush -- Flushes any partially accumulated block. * - * * - * This routine is called when any buffered data must be flushed out the pipe. For the * - * compression process, this will generate the sub-sized compressed block. For * - * decompression, this routine should not have any data in the buffer. In such a case, it * - * means that the data source was prematurely truncated. In such a case, just dump the * - * accumulated data through the pipe. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the actual number of data bytes output to the distant final link in * - * the pipe chain. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/04/1996 JLB : Created. * - *=============================================================================================*/ -int LCWPipe::Flush(void) -{ - assert(Buffer != NULL); - - int total = 0; - - /* - ** If there is accumulated data, then it must processed. - */ - if (Counter > 0) { - if (Control == DECOMPRESS) { - - /* - ** If the accumulated data is insufficient to make a block header, then - ** this means the data has been truncated. Just dump the data through - ** as if were already decompressed. - */ - if (BlockHeader.CompCount == 0xFFFF) { - total += Pipe::Put(Buffer, Counter); - Counter = 0; - } - - /* - ** There appears to be a partial block accumulated in the buffer. It would - ** be disastrous to try to decompress the data since there wouldn't be - ** the special end of data code that LCW decompression needs. In this - ** case, dump the data out as if it were already decompressed. - */ - if (Counter > 0) { - total += Pipe::Put(&BlockHeader, sizeof(BlockHeader)); - total += Pipe::Put(Buffer, Counter); - Counter = 0; - BlockHeader.CompCount = 0xFFFF; - } - - } else { - - /* - ** A partial block in the compression process is a normal occurrence. Just - ** compress the partial block and output normally. - */ - int len = LCW_Comp(Buffer, Buffer2, Counter); - - BlockHeader.CompCount = (unsigned short)len; - BlockHeader.UncompCount = (unsigned short)Counter; - total += Pipe::Put(&BlockHeader, sizeof(BlockHeader)); - total += Pipe::Put(Buffer2, len); - Counter = 0; - } - } - - total += Pipe::Flush(); - return(total); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h deleted file mode 100644 index 08a278829d8..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/lcwpipe.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/LCWPIPE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef LCWPIPE_H -#define LCWPIPE_H - -#include "PIPE.H" - - -/* -** Performs LCW compression/decompression on the data stream that is piped through this -** class. The data is compressed in blocks so of small enough size to be compressed -** quickly and large enough size to get decent compression rates. -*/ -class LCWPipe : public Pipe -{ - public: - typedef enum CompControl { - COMPRESS, - DECOMPRESS - } CompControl; - - LCWPipe(CompControl, int blocksize=1024*8); - virtual ~LCWPipe(void); - - virtual int Flush(void); - virtual int Put(void const * source, int slen); - - private: - /* - ** This tells the pipe if it should be decompressing or compressing the data stream. - */ - CompControl Control; - - /* - ** The number of bytes accumulated into the staging buffer. - */ - int Counter; - - /* - ** Pointer to the working buffer that compression/decompression will use. - */ - char * Buffer; - char * Buffer2; - - /* - ** The working block size. Data will be compressed in chunks of this size. - */ - int BlockSize; - - /* - ** LCW compression requires a safety margin when decompressing over itself. This - ** margin is only for the worst case situation (very rare). - */ - int SafetyMargin; - - /* - ** Each block has a header of this format. - */ - struct { - unsigned short CompCount; // Size of data block (compressed). - unsigned short UncompCount; // Bytes of uncompressed data it represents. - } BlockHeader; - - LCWPipe(LCWPipe & rvalue); - LCWPipe & operator = (LCWPipe const & pipe); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/load.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/load.cpp deleted file mode 100644 index 89315a7fe0c..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/load.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/LOAD.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Load_Uncompress -- Load and uncompress the given file. * - * Uncompress_Data -- Uncompress standard CPS buffer. * - * Load_Data -- Loads a data file from disk. * - * Load_Alloc_Data -- Loads and allocates buffer for a file. * - * Write_Data -- Writes a block of data as a file to disk. * - * Uncompress_Data -- Uncompresses data from one buffer to another. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "IFF.H" -#include "LCW.H" -#include - - -/*************************************************************************** - * Uncompress_Data -- Uncompresses data from one buffer to another. * - * * - * This routine takes data from a compressed file (sans the first two * - * size bytes) and uncompresses it to a destination buffer. The source * - * data MUST have the CompHeaderType at its start. * - * * - * INPUT: src -- Source compressed data pointer. * - * * - * dst -- Destination (paragraph aligned) pointer. * - * * - * OUTPUT: Returns with the size of the uncompressed data. * - * * - * WARNINGS: If LCW compression is used, the destination buffer must * - * be paragraph aligned. * - * * - * HISTORY: * - * 09/17/1993 JLB : Created. * - *=========================================================================*/ -unsigned long __cdecl Uncompress_Data(void const *src, void *dst) -{ - unsigned int skip; // Number of leading data to skip. - CompressionType method; // Compression method used. - unsigned long uncomp_size; - - if (!src || !dst) return(NULL); - - /* - ** Interpret the data block header structure to determine - ** compression method, size, and skip data amount. - */ - uncomp_size = ((CompHeaderType*)src)->Size; - #if(AMIGA) - uncomp_size = Reverse_Long(uncomp_size); - #endif - skip = ((CompHeaderType*)src)->Skip; - #if(AMIGA) - skip = Reverse_Word(skip); - #endif - method = (CompressionType) ((CompHeaderType*)src)->Method; - src = ((char*)src) + (long)sizeof(CompHeaderType) + (long)skip; -// src = Add_Long_To_Pointer((void *)src, (long)sizeof(CompHeaderType) + (long)skip); - - switch (method) { - - default: - case NOCOMPRESS: - memmove(dst, (void *) src, uncomp_size); -// Mem_Copy((void *) src, dst, uncomp_size); - break; - - case HORIZONTAL: - break; - - case LCW: - LCW_Uncomp((void *) src, (void *) dst, (unsigned long) uncomp_size); - break; - - } - - return(uncomp_size); -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/misc.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/misc.h deleted file mode 100644 index e20bdad9e3e..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/misc.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/MISC.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MISC_H -#define MISC_H - -#include "win.h" -#include "ddraw.h" - -extern unsigned char CurrentPalette[768]; -extern bool Debug_Windowed; - -extern LPDIRECTDRAWSURFACE PaletteSurface; - -/*========================= C++ Routines ==================================*/ - -/*=========================================================================*/ -/* The following prototypes are for the file: DDRAW.CPP */ -/*=========================================================================*/ -void Prep_Direct_Draw(void); -void Process_DD_Result(HRESULT result, int display_ok_msg); -bool Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel); -void Reset_Video_Mode(void); -unsigned Get_Free_Video_Memory(void); -void Wait_Blit(void); -unsigned Get_Video_Hardware_Capabilities(void); - -extern "C" void Wait_Vert_Blank(void); - -#include "PALETTE.H" - -void Set_Palette(PaletteClass const & pal, int time = 0, void (*callback)() = NULL); -void Set_Palette(void const * palette); - -/* -** Pointer to function to call if we detect a focus loss -*/ -//extern void (*Misc_Focus_Loss_Function)(void); -/* -** Pointer to function to call if we detect a surface restore -*/ -//extern void (*Misc_Focus_Restore_Function)(void); - -/* -** Function to call if we detect focus loss -*/ -extern void (*Audio_Focus_Loss_Function)(void); - - -/* - * Flags returned by Get_Video_Hardware_Capabilities - */ -/* Hardware blits supported? */ -#define VIDEO_BLITTER 1 - -/* Hardware blits asyncronous? */ -#define VIDEO_BLITTER_ASYNC 2 - -/* Can palette changes be synced to vertical refresh? */ -#define VIDEO_SYNC_PALETTE 4 - -/* Is the video cards memory bank switched? */ -#define VIDEO_BANK_SWITCHED 8 - -/* Can the blitter do filled rectangles? */ -#define VIDEO_COLOR_FILL 16 - -/* Is there no hardware assistance avaailable at all? */ -#define VIDEO_NO_HARDWARE_ASSIST 32 - -extern bool SurfacesRestored; - -/*=========================================================================*/ -/* The following variables are declared in: DDRAW.CPP */ -/*=========================================================================*/ -extern LPDIRECTDRAW DirectDrawObject; -extern LPDIRECTDRAW2 DirectDraw2Interface; -//extern HWND MainWindow; -//extern bool SystemToVideoBlits; -//extern bool VideoToSystemBlits; -//extern bool SystemToSystemBlits; -//extern bool OverlappedVideoBlits; // Can video driver blit overlapped regions? - -/*=========================================================================*/ -/* The following prototypes are for the file: EXIT.CPP */ -/* Prog_End Must be supplied by the user program in startup.cpp */ -/*=========================================================================*/ -void Prog_End(void); -//void __cdecl Exit(INT errorval, const char *message, ...); - -/*=========================================================================*/ -/* The following prototypes are for the file: DELAY.CPP */ -/*=========================================================================*/ -void Delay(int duration); -void Vsync(void); - - -/*========================= Assembly Routines ==============================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/*=========================================================================*/ -/* The following prototype is for the file: SHAKESCR.ASM */ -/*=========================================================================*/ - -void __cdecl Shake_Screen(int shakes); - -//void * Build_Fading_Table(PaletteClass const & palette, void * dest, int color, int frac); -//void * __cdecl Build_Fading_Table(void const *palette, void const *dest, long int color, long int frac); - -/*=========================================================================*/ -/* The following prototypes are for the file: DETPROC.ASM */ -/*=========================================================================*/ - -extern WORD __cdecl Processor(void); -extern WORD __cdecl Operating_System(void); - -extern int __cdecl Clip_Rect ( int * x , int * y , int * dw , int * dh , - int width , int height ) ; -extern int __cdecl Confine_Rect ( int * x , int * y , int dw , int dh , - int width , int height ) ; - - - -/*=========================================================================*/ -/* The following prototypes are for the file: OPSYS.ASM */ -/*=========================================================================*/ - -extern WORD OperationgSystem; - -#ifdef __cplusplus -} -#endif - -/*=========================================================================*/ - -#endif // MISC_H - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp deleted file mode 100644 index 9ec127eceda..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.cpp +++ /dev/null @@ -1,699 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/wwlib/mixfile.cpp $* - * * - * $Author:: Patrick $* - * * - * $Modtime:: 9/12/01 7:39p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "mixfile.h" -#include "wwdebug.h" -#include "ffactory.h" -#include "WWFILE.H" -#include "realcrc.h" -#include "RAWFILE.H" -#include "win.h" -#include "bittype.h" - -/* -** -*/ -typedef struct -{ - char signature[4]; - long header_offset; - long names_offset; - -} MIXFILE_HEADER; - -typedef struct -{ - long file_count; - -} MIXFILE_DATA_HEADER; - -struct FileOffsetStruct { - bool operator== (const FileOffsetStruct &src) { return false; } - bool operator!= (const FileOffsetStruct &src) { return true; } - - StringClass Filename; - unsigned long Offset; -}; - -/* -** -*/ -MixFileFactoryClass::MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory ) : - FileCount (0), - NamesOffset (0), - IsValid (false), - BaseOffset (0), - Factory (NULL), - IsModified (false) -{ -// WWDEBUG_SAY(( "MixFileFactory( %s )\n", mix_filename )); - MixFilename = mix_filename; - Factory = factory; - FilenameList.Set_Growth_Step (1000); - - // First, open the mix file - FileClass * file = factory->Get_File( mix_filename ); - -// WWASSERT( file ); - - if ( file && file->Is_Available() ) { - - file->Open(); - - IsValid = true; - - // - // Read the file header - // - MIXFILE_HEADER header = { 0 }; - IsValid = (file->Read( &header, sizeof( header ) ) == sizeof( header )); - - // - // Validate the file header - // - if ( IsValid ) { - IsValid = (::memcmp( header.signature, "MIX1", sizeof ( header.signature ) ) == 0); - } - - // - // Seek to the data start - // - FileCount = 0; - if ( IsValid ) { - file->Seek( header.header_offset, SEEK_SET ); - IsValid = ( file->Read( &FileCount, sizeof( FileCount ) ) == sizeof( FileCount ) ); - } - - // - // Read the array of data headers - // - if ( IsValid ) { - FileInfo.Resize( FileCount ); - int size = FileCount * sizeof( FileInfoStruct ); - IsValid = ( file->Read( &FileInfo[0], size ) == size ); - } - - // - // Check for success - // - if ( IsValid ) { - BaseOffset = 0; - NamesOffset = header.names_offset; - WWDEBUG_SAY(( "MixFileFactory( %s ) loaded successfully %d files\n", MixFilename, FileInfo.Length() )); - } else { - FileInfo.Resize(0); - } - - factory->Return_File( file ); - - } else { - WWDEBUG_SAY(( "MixFileFactory( %s ) FAILED\n", mix_filename )); - } -} - -MixFileFactoryClass::~MixFileFactoryClass( void ) -{ - FileInfo.Resize(0); -} - -bool MixFileFactoryClass::Build_Filename_List (DynamicVectorClass &list) -{ - if (IsValid == false) { - return false; - } - - bool retval = false; - - // - // Attempt to open the file - // - RawFileClass *file = (RawFileClass *)Factory->Get_File( MixFilename ); - if ( file != NULL && file->Open ( RawFileClass::READ ) ) { - - // - // Seek to the names offset header - // - file->Seek (NamesOffset, SEEK_SET); - retval = true; - - // - // Read the count of files - // - int file_count = 0; - if (file->Read( &file_count, sizeof( file_count) ) == sizeof( file_count )) { - - // - // Loop over each saved filename - // - bool keep_going = true; - for (int index = 0; index < file_count && keep_going; index ++) { - keep_going = false; - - // - // Get the length of the filename - // - uint8 name_len = 0; - if (file->Read( &name_len, sizeof( name_len ) ) == sizeof( name_len )) { - - // - // Read the filename - // - StringClass filename; - if (file->Read( filename.Get_Buffer( name_len ), name_len ) == name_len ) { - - // - // Add the filename to our list - // - list.Add( filename ); - keep_going = true; - } - } - } - } - - // - // Close the file - // - Factory->Return_File( file ); - } - - return retval; -} - -FileClass * MixFileFactoryClass::Get_File( char const *filename ) -{ - if ( FileInfo.Length() == 0 ) { - return NULL; - } -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s )\n", filename )); - - RawFileClass *file = NULL; - - // Create the key block that will be used to binary search for the file. - unsigned long crc = CRC_Stringi( filename ); - - // Binary search for the file in this mixfile. If it is found, then create the file - FileInfoStruct * info = NULL; - FileInfoStruct * base = &FileInfo[0]; - int stride = FileInfo.Length(); - while (stride > 0) { - int pivot = stride / 2; - FileInfoStruct * tryptr = base + pivot; - if (crc < tryptr->CRC) { - stride = pivot; - } else { - if (tryptr->CRC == crc) { - info = tryptr; - break; - } - base = tryptr + 1; - stride -= pivot + 1; - } - } - - if ( info != NULL) { -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) FOUND\n", filename )); - file = (RawFileClass *)Factory->Get_File( MixFilename ); - if ( file ) { - file->Bias( BaseOffset + info->Offset, info->Size ); - } -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) FOUND\n", filename )); - } else { -// WWDEBUG_SAY(( "MixFileFactoryClass::Get_File( %s ) NOT FOUND\n", filename )); - } - - return file; -} - -void MixFileFactoryClass::Return_File( FileClass * file ) -{ - if ( file != NULL ) { - Factory->Return_File( file ); - } -} - - -/* -** -*/ -void -MixFileFactoryClass::Add_File (const char *full_path, const char *filename) -{ - AddInfoStruct info; - info.FullPath = full_path; - info.Filename = filename; - PendingAddFileList.Add (info); - IsModified = true; - return ; -} - - -/* -** -*/ -void -MixFileFactoryClass::Delete_File (const char *filename) -{ - // - // Remove this file (if it exists) from our filename list - // - for (int list_index = 0; list_index < FilenameList.Count (); list_index ++) { - if (FilenameList[list_index].Compare_No_Case (filename) == 0) { - FilenameList.Delete (list_index); - IsModified = true; - break; - } - } - - return ; -} - - -/* -** -*/ -void -MixFileFactoryClass::Flush_Changes (void) -{ - // - // Exit if there's nothing to do. - // - if (IsModified == false) { - return ; - } - - // - // Get the path of the mix file - // - char drive[_MAX_DRIVE] = { 0 }; - char dir[_MAX_DIR] = { 0 }; - ::_splitpath (MixFilename, drive, dir, NULL, NULL); - StringClass path = drive; - path += dir; - - // - // Try to find a temp filename - // - StringClass full_path; - if (Get_Temp_Filename (path, full_path)) { - MixFileCreator new_mix_file (full_path); - - // - // Add all the remaining files from our file set - // - int index = 0; - for (; index < FilenameList.Count (); index ++) { - StringClass &filename = FilenameList[index]; - - // - // Copy this file data to the mix file - // - FileClass *file_data = Get_File (filename); - if (file_data != NULL) { - file_data->Open (); - new_mix_file.Add_File (filename, file_data); - Return_File (file_data); - - // - // Remove this file from the pending list (if necessary) - // - for (int temp_index = 0; temp_index < PendingAddFileList.Count (); temp_index ++) { - if (filename.Compare_No_Case (PendingAddFileList[temp_index].Filename) == 0) { - PendingAddFileList.Delete (temp_index); - break; - } - } - } - } - - // - // Add the new files that are pending - // - for (index = 0; index < PendingAddFileList.Count (); index ++) { - new_mix_file.Add_File (PendingAddFileList[index].FullPath, PendingAddFileList[index].Filename); - } - } - - // - // Delete the old mix file and rename the new one - // - ::DeleteFile (MixFilename); - ::MoveFile (full_path, MixFilename); - - // - // Reset the lists - // - IsModified = false; - PendingAddFileList.Delete_All (); - return ; -} - - -/* -** -*/ -bool -MixFileFactoryClass::Get_Temp_Filename (const char *path, StringClass &full_path) -{ - bool retval = false; - - StringClass temp_path = path; - temp_path += "_tmpmix"; - - // - // Try to find a unique temp filename - // - for (int index = 0; index < 20; index ++) { - full_path.Format ("%s%.2d.dat", (const char *)temp_path, index + 1); - if (GetFileAttributes (full_path) == 0xFFFFFFFF) { - retval = true; - break; - } - } - - return retval; -} - - -// -// Comparison function, used by Build_Ordered_Filename_List -// -int MixFileFactoryClass::File_Offset_Compare(const void * a, const void * b) -{ - unsigned int OffsetA = ((FileOffsetStruct*)a)->Offset; - unsigned int OffsetB = ((FileOffsetStruct*)b)->Offset; - if ( OffsetA < OffsetB ) return -1; - if ( OffsetA > OffsetB ) return 1; - return 0; -} - - -// -// Function builds a list of file names in the order that they are stored in the file -// -bool MixFileFactoryClass::Build_Ordered_Filename_List (DynamicVectorClass &list) -{ - if (IsValid == false) { - return false; - } - - // get list of filenames - DynamicVectorClass name_list; - if (!Build_Filename_List(name_list)) { - return false; - } - - // associate offset with each name and add to list - DynamicVectorClass local_file_info; - local_file_info.Resize( name_list.Count()); - int i = 0; - for (; i < name_list.Count(); ++i) { - // Here, we have to assume that the names in the list are in CRC order, just like FileInfo is. - FileOffsetStruct temp; - temp.Filename = name_list[i]; - temp.Offset = FileInfo[i].Offset; - local_file_info.Add( temp ); - } - - // sort name/offset by offset - if (local_file_info.Count() > 1) { - qsort( &local_file_info[0], local_file_info.Count(), sizeof(local_file_info[0]), &File_Offset_Compare); - } - - // add names to output parameter - list.Clear(); - list.Resize( name_list.Count()); - for (i = 0; i < local_file_info.Count(); ++i) { - list.Add(local_file_info[i].Filename); - } - - return true; -} - -/* -** -*/ -SimpleFileFactoryClass _SimpleFileFactory; - -MixFileCreator::MixFileCreator( const char * filename ) -{ - WWDEBUG_SAY(( "Creating Mix File %s\n", filename )); - - MixFile = _SimpleFileFactory.Get_File(filename); - if ( MixFile != NULL ) { - MixFile->Open( FileClass::WRITE ); - MixFile->Write( "MIX1", 4 ); - long header_offset = 0; - MixFile->Write( &header_offset, sizeof( header_offset ) ); - long names_offset = 0; - MixFile->Write( &names_offset, sizeof( names_offset ) ); - long unused = 0; - MixFile->Write( &unused, sizeof( unused ) ); - } -} - -int MixFileCreator::File_Info_Compare(const void * a, const void * b) -{ - unsigned int CRCA = ((FileInfoStruct*)a)->CRC; - unsigned int CRCB = ((FileInfoStruct*)b)->CRC; - if ( CRCA < CRCB ) return -1; - if ( CRCA > CRCB ) return 1; - return 0; -// return ((FileInfoStruct*)a)->CRC - ((FileInfoStruct*)b)->CRC; -} - -MixFileCreator::~MixFileCreator( void ) -{ - if ( MixFile != NULL ) { - - // Save Header Data - int header_offset = MixFile->Tell(); - - // Save file count - int i,num_files = FileInfo.Count(); - WWDEBUG_SAY(( "Closing with %d files\n", num_files )); - MixFile->Write( &num_files, sizeof( num_files ) ); - - if ( num_files > 1 ) { - qsort( &FileInfo[0], num_files, sizeof(FileInfo[0]), &File_Info_Compare); - } - - // Save file info (CRC, Offset, Size ) - for ( i = 0; i < num_files; i++ ) { - MixFile->Write( &FileInfo[i].CRC, 4 ); - MixFile->Write( &FileInfo[i].Offset, 4 ); - MixFile->Write( &FileInfo[i].Size, 4 ); -// WWDEBUG_SAY(( "Write CRC %08X\n", FileInfo[i].CRC )); - } - - // --------------------------------------- - - // Save Names Data - int names_offset = MixFile->Tell(); - - // Save file count - MixFile->Write( &num_files, sizeof( num_files ) ); - - // Save file info - for ( i = 0; i < num_files; i++ ) { - const char * filename = FileInfo[i].Filename; - int size = FileInfo[i].Filename.Get_Length()+1; - WWASSERT( size < 255 ); - unsigned char csize = size; - MixFile->Write( &csize, 1 ); - MixFile->Write( filename, size ); - } - - // --------------------------------------- - - MixFile->Seek( 4, SEEK_SET ); - - // Save header offset - WWDEBUG_SAY(( "Writing header offset %d (%08X)\n", header_offset, header_offset )); - MixFile->Write( &header_offset, sizeof( header_offset ) ); - - // Save names offset - WWDEBUG_SAY(( "Writing names offset %d (%08X)\n", names_offset, names_offset )); - MixFile->Write( &names_offset, sizeof( names_offset ) ); - - // --------------------------------------- - - MixFile->Close(); - - _SimpleFileFactory.Return_File(MixFile); - } -} - -void MixFileCreator::Add_File( const char * source_filename, const char * saved_filename ) -{ - if ( saved_filename == NULL ) { - saved_filename = source_filename; - } - - if ( MixFile != NULL ) { - - FileClass * file = _SimpleFileFactory.Get_File( source_filename ); - - if ( file && file->Is_Available() ) { - - file->Open(); - - MixFileCreator::FileInfoStruct info; - info.CRC = CRC_Stringi( saved_filename ); - info.Offset = MixFile->Tell(); - info.Size = file->Size(); - FileInfo.Add( info ); - FileInfo[ FileInfo.Count()-1 ].Filename = saved_filename; - - WWDEBUG_SAY(( "Saving File %s CRC %08X Offset %d (0x%08X) Size %d (0x%08X)\n", - saved_filename, info.CRC, info.Offset, info.Offset, info.Size, info.Size )); - - int size = file->Size(); - while ( size ) { - char buffer[ 4096 ]; - int amount = MIN( sizeof( buffer ), size ); - size -= amount; - file->Read( buffer, amount ); - if ( MixFile->Write( buffer, amount ) != amount ) { - WWDEBUG_SAY(( "Failed to write MixFile\n" )); - } - } - - // Pad the MixFile to make DWord Aligned - int offset = MixFile->Tell(); - offset = (8-(offset & 7)) & 7; - if ( offset != 0 ) { - char zeros[8] = {0,0,0,0,0,0,0,0}; - if ( MixFile->Write( zeros, offset ) != offset ) { - WWDEBUG_SAY(( "Failed to write padding\n" )); - } - } - - file->Close(); - _SimpleFileFactory.Return_File( file ); - - } else { - WWDEBUG_SAY(( "MixFileCreator::Failed to open \"%s\"\n", source_filename )); - } - } -} - - -void MixFileCreator::Add_File( const char * filename, FileClass *file ) -{ - if ( MixFile != NULL ) { - - MixFileCreator::FileInfoStruct info; - info.CRC = CRC_Stringi( filename ); - info.Offset = MixFile->Tell(); - info.Size = file->Size(); - FileInfo.Add( info ); - FileInfo[ FileInfo.Count()-1 ].Filename = filename; - - WWDEBUG_SAY(( "Saving File %s CRC %08X Offset %d (0x%08X) Size %d (0x%08X)\n", - filename, info.CRC, info.Offset, info.Offset, info.Size, info.Size )); - - int size = file->Size(); - while ( size ) { - char buffer[ 4096 ]; - int amount = MIN( sizeof( buffer ), size ); - size -= amount; - file->Read( buffer, amount ); - if ( MixFile->Write( buffer, amount ) != amount ) { - WWDEBUG_SAY(( "Failed to write MixFile\n" )); - } - } - - // Pad the MixFile to make DWord Aligned - int offset = MixFile->Tell(); - offset = (8-(offset & 7)) & 7; - if ( offset != 0 ) { - char zeros[8] = {0,0,0,0,0,0,0,0}; - if ( MixFile->Write( zeros, offset ) != offset ) { - WWDEBUG_SAY(( "Failed to write padding\n" )); - } - } - } - - return ; -} - - -/* -** -*/ -void Add_Files( const char * dir, MixFileCreator & mix ) -{ - BOOL bcontinue = TRUE; - HANDLE hfile_find; - WIN32_FIND_DATA find_info = {0}; - StringClass path; - path.Format( "data\\makemix\\%s*.*", dir ); - WWDEBUG_SAY(( "Adding files from %s\n", path )); - - for (hfile_find = ::FindFirstFile( path, &find_info); - (hfile_find != INVALID_HANDLE_VALUE) && bcontinue; - bcontinue = ::FindNextFile(hfile_find, &find_info)) { - if ( find_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { - if ( find_info.cFileName[0] != '.' ) { - StringClass path; - path.Format( "%s%s\\", dir, find_info.cFileName ); - Add_Files( path, mix ); - } - } else { - StringClass name; - name.Format( "%s%s", dir, find_info.cFileName ); - StringClass source; - source.Format( "makemix\\%s", name ); - mix.Add_File( source, name ); -// WWDEBUG_SAY(( "Adding file from %s %s\n", source, name )); - } - } -} - -void Setup_Mix_File( void ) -{ - _SimpleFileFactory.Set_Sub_Directory( "DATA\\" ); -// _SimpleFileFactory.Set_Strip_Path( true ); - - WWDEBUG_SAY(( "Mix File Create .....\n" )); - - { - MixFileCreator mix( "MAKEMIX.MIX" ); - Add_Files( "", mix ); - } - -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.h deleted file mode 100644 index e24a8c125b3..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mixfile.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/wwlib/mixfile.h $* - * * - * $Author:: Steve_t $* - * * - * $Modtime:: 9/07/01 5:29p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MIXFILE_H -#define MIXFILE_H - -#ifndef ALWAYS_H - #include "always.h" -#endif - -#ifndef FFACTORY_H - #include "ffactory.h" -#endif - -#ifndef WWSTRING_H - #include "wwstring.h" -#endif - -#include "Vector.H" - -class FileClass; - -/* -** -*/ -class MixFileFactoryClass : public FileFactoryClass { - -public: - MixFileFactoryClass( const char * mix_filename, FileFactoryClass * factory ); - virtual ~MixFileFactoryClass( void ); - - // - // Inherited - // - virtual FileClass * Get_File( char const *filename ); - virtual void Return_File( FileClass *file ); - - // - // Filename access - // - bool Build_Filename_List (DynamicVectorClass &list); - bool Build_Ordered_Filename_List (DynamicVectorClass &list); // ordered by offset in mixfile - bool Build_Internal_Filename_List (void) { return Build_Filename_List (FilenameList); } - void Get_Filename_List (DynamicVectorClass **list) { *list = &FilenameList; } - void Get_Filename_List (DynamicVectorClass &list) { list = FilenameList; } - - // - // Content control - // - void Add_File (const char *full_path, const char *filename); - void Delete_File (const char *filename); - void Flush_Changes (void); - - // - // Information - // - bool Is_Valid (void) const { return IsValid; } - -private: - - // - // Utility functions - // - bool Get_Temp_Filename (const char *path, StringClass &full_path); - static int File_Offset_Compare(const void * a, const void * b); - - struct FileInfoStruct { - bool operator== (const FileInfoStruct &src) { return false; } - bool operator!= (const FileInfoStruct &src) { return true; } - - unsigned long CRC; // CRC code for embedded file. - unsigned long Offset; // Offset from start of data section. - unsigned long Size; // Size of data subfile. - }; - - struct AddInfoStruct { - bool operator== (const AddInfoStruct &src) { return false; } - bool operator!= (const AddInfoStruct &src) { return true; } - - StringClass FullPath; - StringClass Filename; - }; - - FileFactoryClass * Factory; - DynamicVectorClass FileInfo; - StringClass MixFilename; - int BaseOffset; - - int FileCount; - int NamesOffset; - bool IsValid; - DynamicVectorClass FilenameList; - - DynamicVectorClass PendingAddFileList; - bool IsModified; -}; - -/* -** -*/ -class MixFileCreator { - -public: - MixFileCreator( const char * filename ); - ~MixFileCreator( void ); - - void Add_File( const char * source_filename, const char * saved_filename = NULL ); - void Add_File( const char * filename, FileClass *file ); - -private: - - static int File_Info_Compare(const void * a, const void * b); - - struct FileInfoStruct { - bool operator== (const FileInfoStruct &src) { return false; } - bool operator!= (const FileInfoStruct &src) { return true; } - - unsigned long CRC; // CRC code for embedded file. - unsigned long Offset; // Offset from start of data section. - unsigned long Size; // Size of data subfile. - StringClass Filename; - }; - - DynamicVectorClass FileInfo; - FileClass * MixFile; -}; - -/* -** -*/ -void Setup_Mix_File( void ); - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mono.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mono.cpp deleted file mode 100644 index 2c244822e3f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mono.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/mono.cpp $* - * * - * $Author:: Neal_k $* - * * - * $Modtime:: 10/04/99 10:25a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MonoClass::Clear -- Clears the monochrome screen object. * - * MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. * - * MonoClass::Fill_Attrib -- Fill a block with specified attribute. * - * MonoClass::MonoClass -- The default constructor for monochrome screen object. * - * MonoClass::Pan -- Scroll the window right or left. * - * MonoClass::Print -- Prints the text string at the current cursor coordinates. * - * MonoClass::Print -- Simple print of text number. * - * MonoClass::Printf -- Prints a formatted string to the monochrome screen. * - * MonoClass::Printf -- Prints formatted text using text string number. * - * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. * - * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. * - * MonoClass::Sub_Window -- Partitions the mono screen into a sub-window. * - * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. * - * MonoClass::Text_Print -- Simple text printing from text number. * - * MonoClass::View -- Brings the mono object to the main display. * - * MonoClass::operator = -- Handles making one mono object have the same imagery as another. * - * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. * - * Mono_Clear_Screen -- Clear the currently visible monochrome page. * - * Mono_Draw_Rect -- Draws rectangle to monochrome screen. * - * Mono_Print -- Prints simple text to monochrome screen. * - * Mono_Printf -- Prints formatted text to visible page. * - * Mono_Text_Print -- Prints text to location specified. * - * Mono_X -- Fetches the X cursor position for current visible mono page. * - * Mono_Y -- Fetches the Y cursor position for current mono page. * - * MonoClass::Set_Default_Attribute -- Set the default attribute for this window. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "data.h" -#include "MONO.H" -#include "MONODRVR.H" -#include - - -/* -** Global flag to indicate whether mono output is enabled. If it is not enabled, -** then no mono output will occur. -*/ -bool MonoClass::Enabled = false; - - -/* -** This points to the current mono displayed screen. -*/ -MonoClass * MonoClass::Current; - - -/*********************************************************************************************** - * MonoClass::MonoClass -- The default constructor for monochrome screen object. * - * * - * This is the constructor for monochrome screen objects. It handles allocating a free * - * monochrome page. If there are no more pages available, then this is a big error. The * - * page allocated may not be the visible one. Call the View function in order to bring * - * it to the displayed page. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -MonoClass::MonoClass(void) : - Handle(INVALID_HANDLE_VALUE) -{ -#ifdef _WINDOWS - Handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (Current == NULL) { - Current = this; - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::~MonoClass -- The default destructor for a monochrome screen object. * - * * - * This is the default destructor for a monochrome screen object. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -MonoClass::~MonoClass(void) -{ -#ifdef _WINDOWS - if (Handle != INVALID_HANDLE_VALUE) { - CloseHandle(Handle); - Handle = INVALID_HANDLE_VALUE; - } - if (Current == this) { - Current = NULL; - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Pan -- Scroll the window right or left. * - * * - * This routine will scroll the window to the right or left as indicated by the number of * - * rows. * - * * - * INPUT: cols -- The number of columns to pan the window. Positive numbers pan to the left * - * while negative numbers pan to the right. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/05/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Pan(int ) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_PAN, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Sub_Window -- Partitions the mono screen into a sub-window. * - * * - * This routine is used to partition the monochrome screen so that only a sub-window will * - * be processed. By using this, a separate rectangle of the screen can be cleared, * - * scrolled, panned, or printed into. * - * * - * INPUT: x,y -- The upper left corner of the new sub-window. * - * * - * w,h -- Dimensions of the sub-window specified in characters. * - * * - * OUTPUT: none * - * * - * WARNINGS: The parameters are clipped as necessary. * - * * - * HISTORY: * - * 06/05/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Sub_Window(int x, int y, int w, int h) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - struct subwindow { - int X,Y,W,H; - } subwindow; - unsigned long retval; - - subwindow.X = x; - subwindow.Y = y; - subwindow.W = w; - subwindow.H = h; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_WINDOW, &subwindow, sizeof(subwindow), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. * - * * - * Use this routine to set the monochrome's cursor position to the coordinates specified. * - * This is the normal way of controlling where the next Print or Printf will output the * - * text to. * - * * - * INPUT: x,y -- The coordinate to position the monochrome cursor. 0,0 is the upper left * - * corner. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Set_Cursor(int x, int y) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - struct { - int X,Y; - } cursor; - unsigned long retval; - - cursor.X = x; - cursor.Y = y; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_CURSOR, &cursor, sizeof(cursor), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Clear -- Clears the monochrome screen object. * - * * - * This routine will fill the monochrome screen object with spaces. It is clearing the * - * screen of data, making it free for output. The cursor is positioned at the upper left * - * corner of the screen by this routine. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Clear(void) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Fill_Attrib -- Fill a block with specified attribute. * - * * - * This routine will give the specified attribute to the characters within the block * - * but will not change the characters themselves. You can use this routine to change the * - * underline, blink, or inverse characteristics of text. * - * * - * INPUT: x,y -- The upper left coordinate of the region to change. * - * * - * w,h -- The dimensions of the region to change (in characters). * - * * - * attrib -- The attribute to fill into the region specified. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Fill_Attrib(int x, int y, int w, int h, MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - struct fillcontrol { - int X,Y,W,H,A; - } fillcontrol; - - - fillcontrol.X = x; - fillcontrol.Y = y; - fillcontrol.W = w; - fillcontrol.H = h; - fillcontrol.A = attrib; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_FILL_ATTRIB, &fillcontrol, sizeof(fillcontrol), NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. * - * * - * Use this routine to scroll the monochrome screen up by the number of lines specified. * - * This routine is typically called by the printing functions so that the monochrome screen * - * behaves in the expected manner -- printing at the bottom of the screen scrolls it up * - * to make room for new text. * - * * - * INPUT: lines -- The number of lines to scroll the monochrome screen. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Scroll(int ) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SCROLL, NULL, 0, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Printf -- Prints a formatted string to the monochrome screen. * - * * - * Use this routine to output a formatted string, using the standard formatting options, * - * to the monochrome screen object's current cursor position. * - * * - * INPUT: text -- Pointer to the text to print. * - * * - * ... -- Any optional parameters to supply in formatting the text. * - * * - * OUTPUT: none * - * * - * WARNINGS: The total formatted text length must not exceed 255 characters. * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Printf(char const *text, ...) -{ -#ifdef _WINDOWS - va_list va; - /* - ** The buffer object is placed at the end of the local variable list - ** so that if the sprintf happens to spill past the end, it isn't likely - ** to trash anything (important). The buffer is then manually truncated - ** to maximum allowed size before being printed. - */ - char buffer[256]; - - if ( !Enabled || (Handle == INVALID_HANDLE_VALUE) ) return; - - va_start(va, text); - vsprintf(buffer, text, va); - buffer[sizeof(buffer)-1] = '\0'; - - Print(buffer); - va_end(va); -#endif -} - - -/*********************************************************************************************** - * MonoClass::Printf -- Prints formatted text using text string number. * - * * - * This routine will take the given text string number and print the formatted text to * - * the monochrome screen. * - * * - * INPUT: text -- The text number to convert into real text (by way of external function). * - * * - * ... -- Additional parameters as needed. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Printf(int text, ...) -{ -#ifdef _WINDOWS - va_list va; - - /* - ** The buffer object is placed at the end of the local variable list - ** so that if the sprintf happens to spill past the end, it isn't likely - ** to trash anything (important). The buffer is then manually truncated - ** to maximum allowed size before being printed. - */ - char buffer[256]; - - if ( !Enabled || (Handle == INVALID_HANDLE_VALUE) ) return; - - va_start(va, text); - vsprintf(buffer, Fetch_String(text), va); - buffer[sizeof(buffer)-1] = '\0'; - - Print(buffer); - va_end(va); -#endif -} - - -/*********************************************************************************************** - * MonoClass::Print -- Prints the text string at the current cursor coordinates. * - * * - * Use this routine to output the specified text string at the monochrome object's current * - * text coordinate position. * - * * - * INPUT: ptr -- Pointer to the string to print. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Print(char const * ptr) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - WriteFile(Handle, ptr, strlen(ptr), &retval, NULL); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Set_Default_Attribute -- Set the default attribute for this window. * - * * - * This will change the default attribute to that specified. All future text will use * - * this new attribute. * - * * - * INPUT: attrib -- The attribute to make the current default. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 01/06/1997 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Set_Default_Attribute(MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_ATTRIBUTE, &attrib, 1, NULL, 0, &retval, 0); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. * - * * - * Use this routine to output text to the monochrome object at the X and Y coordinates * - * specified. * - * * - * INPUT: text -- Pointer to the text string to display. * - * * - * x,y -- The X and Y character coordinates to start the printing at. * - * * - * attrib-- Optional parameter that specifies what text attribute code to use. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::Text_Print(char const *text, int x, int y, MonoAttribute attrib) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - - Set_Cursor(x, y); - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_SET_ATTRIBUTE, &attrib, 1, NULL, 0, &retval, 0); - Print(text); - } -#endif -} - - -/*********************************************************************************************** - * MonoClass::Text_Print -- Simple text printing from text number. * - * * - * This will print the text (represented by the text number) to the location on the * - * monochrome screen specified. * - * * - * INPUT: text -- The text number to print (converted to real text by external routine). * - * * - * x,y -- The coordinates to begin the printing at. * - * * - * attrib-- The character attribute to use while printing. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Text_Print(int text, int x, int y, MonoAttribute attrib) -{ - Text_Print(Fetch_String(text), x, y, attrib); -} - - -/*********************************************************************************************** - * MonoClass::Print -- Simple print of text number. * - * * - * Prints text represented by the text number specified. * - * * - * INPUT: text -- The text number to print (converted to real text by external routine). * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 06/04/1996 JLB : Created. * - *=============================================================================================*/ -void MonoClass::Print(int text) -{ - Print(Fetch_String(text)); -} - - -/*********************************************************************************************** - * MonoClass::View -- Brings the mono object to the main display. * - * * - * Use this routine to display the mono object on the monochrome screen. It is possible * - * that the mono object exists on some background screen memory. Calling this routine will * - * perform the necessary memory swapping to bring the data to the front. The mono object * - * that was currently being viewed is not destroyed by this function. It is merely moved * - * off to some background page. It can be treated normally, except that is just isn't * - * visible. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 10/17/1994 JLB : Created. * - * 01/06/1997 JLB : Updated to WindowsNT style of mono output. * - *=============================================================================================*/ -void MonoClass::View(void) -{ -#ifdef _WINDOWS - if ( Enabled && (Handle != INVALID_HANDLE_VALUE) ) { - unsigned long retval; - DeviceIoControl(Handle, (DWORD)IOCTL_MONO_BRING_TO_TOP, NULL, 0, NULL, 0, &retval, 0); - Current = this; - } -#endif -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp deleted file mode 100644 index c41c9b5470a..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mpmath.cpp +++ /dev/null @@ -1,2776 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/mpmath.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 3/21/01 12:01p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * _Byte_Precision -- Determines the number of bytes significant in long integer. * - * memrev -- Reverse the byte order of the buffer specified. * - * XMP_Abs -- Perform an absolute value on the specified MP number. * - * XMP_Add -- Add two MP numbers with a carry option. * - * XMP_Add_Int -- Add an integer to an MP number (with carry). * - * XMP_Compare -- Compare one MP number with another. * - * XMP_Count_Bits -- Count the total number of bits (precision) in MP number. * - * XMP_Count_Bytes -- Counts the number of precision bytes in MP number. * - * XMP_Dec -- Decrement the MP number by one. * - * XMP_Decode_ASCII -- Convert ASCII into an MP number. * - * XMP_DER_Decode -- Decode a DER number into an MP number. * - * XMP_DER_Encode -- Encode a number into a buffer using DER. * - * XMP_DER_Length_Encode -- Output the length of a DER block. * - * XMP_Double_Mul -- Double precision MP multiply. * - * XMP_Encode -- Encode MP number into buffer as compactly as possible. * - * XMP_Fermat_Test -- Performs Fermat's Little Theorem on an MP number. * - * XMP_Hybrid_Mul -- Special hybrid short multiply (with carry). * - * XMP_Inc -- Increment an MP number by one. * - * XMP_Init -- Initialize an MP number to a starting value. * - * XMP_Inverse_A_Mod_B -- Inverts and performs modulus on an MP number. * - * XMP_Is_Prime -- Determine if the specified MP number is prime. * - * XMP_Is_Small_Prime -- Determine if MP number is a small prime. * - * XMP_Mod_Mult -- Perform a multiply - modulus operation. * - * XMP_Mod_Mult_Clear -- Remove temporary values from memory. * - * XMP_Move -- Assign one MP number to another. * - * XMP_Neg -- Negate the specified MP number. * - * XMP_Not -- Perform bitwise NOT operation on MP number. * - * XMP_Prepare_Modulus -- Prepare globals for modulus operation. * - * XMP_Rabin_Miller_Test -- Performs the Rabin Miller test for primality. * - * XMP_Randomize -- Generate a random MP number between the boundaries specified. * - * XMP_Randomize -- Generate a random MP number. * - * XMP_Reciprocal -- Compute the reciprocal (inverse) of the MP number. * - * XMP_Rotate_Left -- Rotate specified MP number leftward. * - * XMP_Shift_Left_Bits -- Shifts the MP number left by the specified bit count. * - * XMP_Shift_Right_Bits -- Shift the MP number right by specified bit count. * - * XMP_Signed_Decode -- Decode a number as if it were signed. * - * XMP_Signed_Div -- Signed divide of one MP number into another. * - * XMP_Signed_Mult -- A signed multiply between two MP numbers. * - * XMP_Signed_Mult_Int -- Multiply an MP number by a signed simple integer. * - * XMP_Significance -- Fetch the precision (bytes) of the MP number. * - * XMP_Small_Divisors_Test -- Perform the small divisors test on an MP number. * - * XMP_Sub -- Subtract one MP number from another (with borrow). * - * XMP_Sub_Int -- Subtract an integer from an MP number (with borrow). * - * XMP_Unsigned_Decode -- Decode a number as if it were unsigned. * - * XMP_Unsigned_Div -- Unsigned divide of one MP number into another. * - * XMP_Unsigned_Div_Int -- Perform a short integer divide into an MP number. * - * XMP_Unsigned_Mult -- Multiply two unsigned MP numbers together. * - * XMP_Unsigned_Mult_Int -- Multiply an MP number by a simple integer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "MPMATH.H" -#include "win.h" -#include -#include -#include -#include -#include - - -extern unsigned short primeTable[3511]; - - - -#define UPPER_MOST_BIT 0x80000000L -#define SEMI_UPPER_MOST_BIT 0x8000 -#define SEMI_MASK ((unsigned short)~0) - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) -#endif - -#ifndef __BORLANDC__ -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#define _USERENTRY -#endif - - -// Misc functions. -void memrev(char * buffer, size_t length); -unsigned short mp_quo_digit(unsigned short * dividend); - - -unsigned short const * MPEXPORT XMP_Fetch_Prime_Table(void) -{ - return(primeTable); -} - - -int MPEXPORT XMP_Fetch_Prime_Size(void) -{ - return(ARRAY_SIZE(primeTable)); -} - - -bool MPEXPORT XMP_Test_Eq_Int(digit const * r, int i, int p) -{ - return( (*r == (digit)i ) && XMP_Significance(r,p) <= 1 ); -} - - - -/*********************************************************************************************** - * _Byte_Precision -- Determines the number of bytes significant in long integer. * - * * - * This utility routine will determine the number of precision bytes exist in the long * - * integer specified. There are some optimizations that can occur if the byte precision * - * is known. * - * * - * INPUT: value -- The value of the long integer that the byte precision will be calculated * - * for. * - * * - * OUTPUT: Returns with the number of bytes that the long integer requires (at a minimum) * - * to cover the precision of the integer. The minimum value will be 1, the maximum * - * will be 4. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -static int _Byte_Precision(unsigned long value) -{ - int byte_count; - for (byte_count = sizeof(value); byte_count; byte_count--) { - if (value >> ((byte_count-1)*8)) break; - } - return(byte_count); -} - - -/*********************************************************************************************** - * XMP_DER_Length_Encode -- Output the length of a DER block. * - * * - * This routine will output the length of the block using Distinguished Encoding Rules. * - * The rest of the block must be filled in as appropriate. For data blocks that are less * - * than 128 bytes long, the header consists of only one byte. Longer buffers lengths * - * can consume up to 5 bytes (depends on magnitude of the length value). * - * * - * INPUT: length -- The length of the data block to be output. * - * * - * output -- Pointer to the memory block that will be set up. * - * * - * OUTPUT: Returns with the number of bytes (header) that was used to store the length * - * value. Subsequent data must be placed after the header. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_DER_Length_Encode(unsigned long length, unsigned char * output) -{ - assert(output != NULL); - - int header_length = 0; - - if (length <= SCHAR_MAX) { - output[header_length++] = (unsigned char)length; - } else { - output[header_length++] = (unsigned char)(_Byte_Precision(length) | 0x80); - for (int byte_counter = _Byte_Precision(length); byte_counter; --byte_counter) { - output[header_length++] = (unsigned char)(length >> ((byte_counter-1)*8)); - } - } - return(header_length); -} - - -/*********************************************************************************************** - * XMP_DER_Encode -- Encode a number into a buffer using DER. * - * * - * This routine is used to encode a number into a buffer using Distinguished Encoding * - * Rules. The number of bytes used will be, typically, two bytes more than the number of * - * precision bytes in the number. * - * * - * INPUT: from -- Pointer to the multi-precision number. * - * * - * output -- Pointer to the buffer that will hold the DER encoded number. * - * * - * precision-- The precision of the multi-precision number. * - * * - * OUTPUT: Returns with the number of bytes used in the output buffer. * - * * - * WARNINGS: Make sure the buffer is big enough to hold the DER encoded number. For safety * - * make sure it is precision+6 bytes long. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_DER_Encode(digit const * from, unsigned char * output, int precision) -{ - assert(from != NULL); - assert(output != NULL); - assert(precision > 0); - - unsigned char buffer[MAX_UNIT_PRECISION*sizeof(digit)+1]; - int header_count = 0; - - unsigned number_count = XMP_Encode(buffer, from, precision); - - output[header_count++] = 0x02; - header_count += XMP_DER_Length_Encode(number_count, &output[header_count]); - memcpy(&output[header_count], buffer, number_count); - - return(header_count+number_count); -} - - -/*********************************************************************************************** - * XMP_DER_Decode -- Decode a DER number into an MP number. * - * * - * Use this routine to decode a Distinguished Encoding Rules number into a multi-precision * - * number. This is the counterpart function to the XMP_DER_Encode() function. * - * * - * INPUT: result -- The buffer the hold the result MP number. * - * * - * input -- Pointer to the DER encoded number. * - * * - * precision -- The precision of the MP number. This is the maximum precision the * - * DER number can be. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_DER_Decode(digit * result, unsigned char const * input, int precision) -{ - assert(result != NULL); - assert(input != NULL); - assert(precision > 0); - - if (*input++ == 0x02) { - unsigned byte_count; - - if ((*input & 0x80) == 0) { - byte_count = *input++; - } else { - int length = *input++ & 0x7f; - if (length > 2) return; - byte_count = *input++; - if (length > 1) byte_count = (byte_count << 8) | *input++; - } - if (byte_count <= (precision * sizeof(digit))) { - XMP_Signed_Decode(result, input, byte_count, precision); - } - } -} - - -/*********************************************************************************************** - * XMP_Encode_Bounded -- Encode MP number into buffer. * - * * - * This routine will encode an multi-precision number into a buffer of specified length. * - * The number of stored in "big endian" format with appropriate sign extension. * - * * - * INPUT: to -- Pointer to the buffer to place the number. * - * * - * tobytes -- The number of bytes to use in the destination buffer. * - * * - * from -- Pointer to the MP number to be encoded. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes placed into the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -unsigned MPEXPORT XMP_Encode_Bounded(unsigned char * to, unsigned tobytes, digit const * from, int precision) -{ - assert(to != NULL); - assert(from != NULL); - assert(tobytes > 0); - assert(precision > 0); - - unsigned frombytes = precision * sizeof(digit); - unsigned char filler = (unsigned char)(XMP_Is_Negative(from, precision) ? 0xff : 0); - - unsigned index; - for (index = 0; index < (tobytes-frombytes); index++) { - *to++ = filler; - } - - const unsigned char * fptr = ((const unsigned char *)from) + min(tobytes, frombytes); - for (index = 0; index < min(tobytes, frombytes); index++) { - *to++ = *--fptr; - } - - return(tobytes); -} - - -/*********************************************************************************************** - * XMP_Encode -- Encode MP number into buffer as compactly as possible. * - * * - * This routine will encode the MP number into the specified buffer. The number will be * - * encoded using the least number of bytes possible. * - * * - * INPUT: to -- The buffer to encode the MP number into. * - * * - * from -- Pointer to the MP number to be encoded. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes used in the destination buffer to hold the * - * encoded number. * - * * - * WARNINGS: Be sure the destination buffer is big enough to hold the encoded MP number. * - * A safe size would be the precision plus one. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -#ifdef __WATCOMC__ -#pragma warning 364 9 -#endif -unsigned MPEXPORT XMP_Encode(unsigned char * to, digit const * from, int precision) -{ - assert(to != NULL); - assert(from != NULL); - assert(precision > 0); - - bool is_negative = XMP_Is_Negative(from, precision); - unsigned char filler = (unsigned char)(is_negative ? 0xff : 0); - unsigned char * number_ptr; - - unsigned char * const end = (unsigned char *)from; - for (number_ptr = (unsigned char *)end + precision - 1; number_ptr > (unsigned char *)end; number_ptr--) { - if (*number_ptr != filler) break; - } - - unsigned index = 0; - if (((*number_ptr & 0x80) && !is_negative) || (!(*number_ptr & 0x80) && is_negative)) { - to[index++] = filler; - } - - to[index++] = *number_ptr; - - while (number_ptr != end) { - to[index++] = *--number_ptr; - } - return(index); -} - - -/*********************************************************************************************** - * XMP_Signed_Decode -- Decode a number as if it were signed. * - * * - * Use this routine to convert a coded number back into an MP number. The coded number * - * is presumed to be signed. * - * * - * INPUT: result -- Pointer to the buffer that will hold the decoded MP number. * - * * - * from -- Pointer to the encoded MP number. * - * * - * frombytes-- The number of bytes consumed by the encoded MP number. * - * * - * precision -- The precision of the MP number (maximum) of the result. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure that the precision is sufficient to hold the decoded MP number. * - * Otherwise, the result is undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Signed_Decode(digit * result, const unsigned char * from, int frombytes, int precision) -{ - assert(result != NULL); - assert(from != NULL); - assert(frombytes > 0); - assert(precision > 0); - - unsigned char filler = (unsigned char)((*from & 0x80) ? 0xff : 0); - - int fillcount = precision * sizeof(digit) - frombytes; - unsigned char * dest = (unsigned char *)&result[precision]; - - /* - ** Fill in any excess significant bytes. - */ - int index; - for (index = 0; index < fillcount; index++) { - *--dest = filler; - } - - /* - ** Move in the remaining bytes. - */ - for (index = 0; index < frombytes; index++) { - *--dest = *from++; - } -} - - -/*********************************************************************************************** - * XMP_Unsigned_Decode -- Decode a number as if it were unsigned. * - * * - * Use this routine to decode a MP number and treat it as if it were unsigned. * - * * - * INPUT: result -- Pointer to the buffer to hold the result MP number. * - * * - * from -- Pointer to the encoded MP number. * - * * - * frombytes-- The number of bytes in the encoded number. * - * * - * precision-- The precision of the result MP number -- maximum precision. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the result MP precision is sufficient to hold the decoded number or * - * else the result is undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Unsigned_Decode(digit * result, const unsigned char * from, int frombytes, int precision) -{ - assert(result != NULL); - assert(from != NULL); - assert(frombytes > 0); - assert(precision > 0); - - int fillcount = precision * sizeof(digit) - frombytes; - unsigned char * dest = (unsigned char *)&result[precision]; - - /* - ** Fill in any excess significant bytes. - */ - int index; - for (index = 0; index < fillcount; index++) { - *--dest = '\0'; - } - - /* - ** Move in the remaining bytes. - */ - for (index = 0; index < frombytes; index++) { - *--dest = *from++; - } -} - - -/*********************************************************************************************** - * XMP_Significance -- Fetch the precision (bytes) of the MP number. * - * * - * This routine will return with the precision of the MP number expressed as bytes. The * - * MP number is presumed unsigned. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- The precision of the MP number to examine. * - * * - * OUTPUT: Returns with the minimum number of bytes consumed by this MP number. * - * * - * WARNINGS: Passing a signed MP number to this routine will return an artificially greater * - * precision than it really is. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Significance(const digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - number += precision; - do { - number--; - if (*number) break; - precision--; - } while (precision); - return(precision); -} - - -/*********************************************************************************************** - * XMP_Inc -- Increment an MP number by one. * - * * - * This will increment the MP number by one. * - * * - * INPUT: number -- Pointer to the MP number to increment. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: If the number wraps around the maximum precision, the results are undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Inc(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - do { - *number = (*number) + 1; - if (*number != 0) break; - number++; - precision --; - } while (precision); -} - - -/*********************************************************************************************** - * XMP_Dec -- Decrement the MP number by one. * - * * - * Use this routine to decrement the specified MP number by one. * - * * - * INPUT: number -- Pointer to the MP number to decrement. * - * * - * precision-- The precision of the MP number to decrement. * - * * - * OUTPUT: none * - * * - * WARNINGS: If the number wraps below zero, the results are undefined. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Dec(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - do { - *number -= 1; - if ((*number) != ~(digit)0) break; - number++; - precision--; - } while (precision); -} - - -/*********************************************************************************************** - * XMP_Neg -- Negate the specified MP number. * - * * - * This routine will negate (reverse sign) of the specified MP number. * - * * - * INPUT: number -- Pointer to the MP number to negate. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Neg(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - XMP_Not(number, precision); - XMP_Inc(number, precision); -} - - -/*********************************************************************************************** - * XMP_Abs -- Perform an absolute value on the specified MP number. * - * * - * This will perform the absolute value function on the specified MP number. That is, if * - * the MP number is negative, it will be transformed into a positive number. If the number * - * is already positive, then it will be left alone. * - * * - * INPUT: number -- Pointer to the MP number to ABS. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Abs(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - if (XMP_Is_Negative(number, precision)) { - XMP_Neg(number, precision); - } -} - - -/*********************************************************************************************** - * XMP_Shift_Right_Bits -- Shift the MP number right by specified bit count. * - * * - * Use this routine to perform a right shift of the MP number by the number of bits * - * specified. * - * * - * INPUT: number -- Pointer to the MP number to perform the shift upon. * - * * - * bits -- The number of bits to shift. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is an unsigned shift. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Shift_Right_Bits(digit * number, int bits, int precision) -{ - assert(number != NULL); - assert(bits >= 0); - assert(precision > 0); - - if (bits == 0) return; /* shift zero bits is a no-op */ - - /* - ** If the shift is by whole bytes, then the shift operation can - ** be performed very quickly. - */ - if (bits == UNITSIZE) { - number += precision; - digit carry = 0; - while (precision--) { - number--; - digit temp = *number; - *number = carry; - carry = temp; - } - return; - } - - /* - ** If the number of bits to shift is less than one byte, then the - ** shift operation is a relatively simple "ripple" effect through - ** the MP number buffer. - */ - if (bits < UNITSIZE) { - number += precision; - digit carry = 0; - digit bitmask = (1L << bits) - 1; - int unbits = UNITSIZE - bits; - - while (precision--) { - number--; - digit temp = *number & bitmask; - *number >>= bits; - *number |= carry << unbits; - carry = temp; - } - return; - } - - /* - ** General purpose slow right. - */ - int digits_to_shift = bits / UNITSIZE; - int bits_to_shift = bits % UNITSIZE; - - int index; - for (index = digits_to_shift; index < (precision-1); index++) { - *number = (*(number + digits_to_shift) >> bits_to_shift) | (*(number + (digits_to_shift + 1)) << (UNITSIZE - bits_to_shift)); - number++; - } - - if (digits_to_shift < precision) { - *number = (*(number + digits_to_shift) >> bits_to_shift); - number++; - } - - for (index= 0; index < min(digits_to_shift, precision); index++) { - *number++ = 0; - } -} - - -/*********************************************************************************************** - * XMP_Shift_Left_Bits -- Shifts the MP number left by the specified bit count. * - * * - * Use this routine to perform a left shift of the specified MP number. * - * * - * INPUT: number -- Pointer to the MP number to perform the shift operation on. * - * * - * bits -- The number of bits to shift the MP number leftward. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Shift_Left_Bits(digit * number, int bits, int precision) -{ - assert(number != NULL); - assert(bits >= 0); - assert(precision > 0); - - if (bits == 0) return; /* shift zero bits is a no-op */ - - /* - ** If the shift is by whole bytes, then the shift operation can - ** be performed very quickly. - */ - if (bits == UNITSIZE) { - digit carry = 0; - while (precision--) { - digit temp = *number; - *number = carry; - carry = temp; - number++; - } - return; - } - - /* - ** If the number of bits to shift is less than one byte, then the - ** shift operation is a relatively simple "ripple" effect through - ** the MP number buffer. - */ - if (bits < UNITSIZE) { - digit carry = 0; - digit bitmask = ~(((digit)-1) >> bits); - int unbits = UNITSIZE - bits; /* shift bits must be <= UNITSIZE */ - - while (precision--) { - digit temp = *number & bitmask; - *number = (*number << bits) | (carry >> unbits); - carry = temp; - number++; - } - return; - } - - /* - ** General purpose slow left; - */ - int digits_to_shift = bits / UNITSIZE; - int bits_to_shift = bits % UNITSIZE; - - int index; - number += precision-1; - for (index = digits_to_shift; index < (precision-1); index++) { - *number = (*(number - digits_to_shift) << bits_to_shift) | (*(number - (digits_to_shift + 1)) >> (UNITSIZE - bits_to_shift)); - number--; - } - - if (digits_to_shift < precision) { - *number = (*(number - digits_to_shift) << bits_to_shift); - number--; - } - - for (index = 0; index < min(digits_to_shift, precision); index++) { - *number-- = 0; - } -} - - -/*********************************************************************************************** - * XMP_Rotate_Left -- Rotate specified MP number leftward. * - * * - * This routine will rotate the MP number to the left by one bit. The rotation passes bits * - * through a "carry" bit position. The initial value of this "carry" bit is passed to the * - * routine and the final value is returned as the result. * - * * - * INPUT: number -- Pointer to the MP number to perform the left rotate upon. * - * * - * carry -- The initial value of the "carry" bit. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: Returns with the final value of the carry bit. This is the the bit value of the * - * upper most bit of the MP number prior to the rotate operation. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Rotate_Left(digit * number, bool carry, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - while (precision--) { - bool temp = ((*number & UPPER_MOST_BIT) != 0); - *number = (*number << 1); - if (carry) *number = *number + 1; - carry = temp; - number++; - } - return carry; -} - - -/*********************************************************************************************** - * XMP_Not -- Perform bitwise NOT operation on MP number. * - * * - * Perform a bitwise NOT operation. * - * * - * INPUT: number -- Pointer to the MP number to operate on. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Not(digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - for (int index = 0; index < precision; index++) { - *number = ~(*number); - number++; - } -} - - -/*********************************************************************************************** - * XMP_Init -- Initialize an MP number to a starting value. * - * * - * This will initialize (assign) a number to an MP number. The initial value is limited * - * to the precision allowed by a DIGIT type. * - * * - * INPUT: number -- Pointer to the MP number to initialize. * - * * - * value -- Initial integer value to assign to the MP number. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Init(digit * number, digit value, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - memset(number, '\0', precision * sizeof(digit)); - *number = value; -} - - -/*********************************************************************************************** - * XMP_Count_Bits -- Count the total number of bits (precision) in MP number. * - * * - * This routine will count the maximum number of bits used by this MP number. The result * - * could be referred to as the "bit precision" of the MP number. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- The (digit) precision of the MP number. * - * * - * OUTPUT: Returns with the number of significant bits in the MP number. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -unsigned MPEXPORT XMP_Count_Bits(const digit * number, int precision) -{ - assert(number != NULL); - assert(precision > 0); - - int sub_precision = XMP_Significance(number, precision); - if (!sub_precision) return(0); - int total_bit_count = XMP_Digits_To_Bits(sub_precision); - number += sub_precision-1; - digit high_bit_mask = UPPER_MOST_BIT; - - while (!((*number) & high_bit_mask)) { - high_bit_mask >>= 1; - total_bit_count--; - } - - return(total_bit_count); -} - - -/*********************************************************************************************** - * XMP_Count_Bytes -- Counts the number of precision bytes in MP number. * - * * - * This routine will scan the MP number and determine the number of bytes needed to * - * represent the MP number. Consider the result the "byte precision" of the number. * - * * - * INPUT: number -- Pointer to the MP number to examine. * - * * - * precision-- Precision of the MP number. * - * * - * OUTPUT: Returns with the number of bytes required to represent the precision of the number.* - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Count_Bytes(const digit * number, int precision) -{ - unsigned char * ptr = (unsigned char *)number; - int count = 0; - for (unsigned index = 0; index < precision*sizeof(digit); index++) { - if (!*ptr) break; - count++; - ptr++; - } - return(count); -} - - -/*********************************************************************************************** - * XMP_Move -- Assign one MP number to another. * - * * - * This will move one MP number over the top of another. * - * * - * INPUT: dest -- Destination MP number (will get clobbered). * - * * - * source -- Source MP number. * - * * - * precision-- Precision of both MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Both MP numbers must have the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Move(digit * dest, digit const * source, int precision) -{ - memcpy(dest, source, precision * sizeof(digit)); -} - - -/*********************************************************************************************** - * XMP_Compare -- Compare one MP number with another. * - * * - * This routine will compare two MP numbers. It will return a value indicating which MP * - * number is greater or if they are equal. * - * * - * INPUT: left_number -- The left hand MP number. * - * * - * right_number-- The right hand MP number. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: Returns -1 if the left_number is less than the right_number. * - * Returns 1 if the left_number is greater than the right number. * - * Returns 0 if both numbers are identical. * - * * - * WARNINGS: Both numbers must have the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Compare(const digit * left_number, const digit * right_number, int precision) -{ - left_number += precision-1; - right_number += precision-1; - do { - if (*left_number < *right_number) return -1; - if (*left_number > *right_number) return 1; - left_number--; - right_number--; - precision--; - } while (precision); - return 0; -} - - -/*********************************************************************************************** - * XMP_Add -- Add two MP numbers with a carry option. * - * * - * Use this routine to add one MP number to another. There is an optional "carry" value * - * that (when true) will add an additional 1 to the result. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. This can be the * - * same value as the left_number or right_number pointers. * - * * - * left_number -- The left hand MP number. * - * * - * right_number-- The right hand MP number. * - * * - * carry -- Optional carry flag (typically this will be false). * - * * - * precision -- The precision of the numbers involved. * - * * - * OUTPUT: Returns with the carry flag after the addition. If the value is true then an * - * overflow occurred. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Add(digit * result, const digit * left_number, const digit * right_number, bool carry, int precision) -{ - while (precision--) { - digit term = *left_number + *right_number; - digit final = term + carry; - carry = (term < *left_number || (carry && final == 0)); - - right_number++; - left_number++; - *result++ = final; - } - return(carry); -} - - -/*********************************************************************************************** - * XMP_Add_Int -- Add an integer to an MP number (with carry). * - * * - * This routine will add an integer number to an MP number. There is an optional carry * - * parameter. If the carry flag is true, and additional 1 will be added to the result. * - * This routine is much faster than adding two MP numbers together. * - * * - * INPUT: result -- Pointer to the result MP number. This pointer can be the same as * - * the left_number parameter. * - * * - * left_number -- Pointer to the left hand MP number. * - * * - * right_number-- The integer number to add to the left hand number. * - * * - * carry -- Input carry flag. If this is true, then an additional one will be * - * added to the result. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: Returns with the result carry flag. A true value means the addition overflowed. * - * * - * WARNINGS: All MP numbers must share the same precision. Negative numbers are not * - * supported. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Add_Int(digit * result, const digit * left_number, digit right_number, bool carry, int precision) -{ - while (precision--) { - digit term = *left_number + right_number; - digit final = term + carry; - carry = (term < *left_number || (carry && final == 0)); - - right_number = 0; - left_number++; - *result++ = final; - } - return(carry); -} - - -/*********************************************************************************************** - * XMP_Sub -- Subtract one MP number from another (with borrow). * - * * - * This routine will subtract one MP number from another. There is an optional borrow * - * flag that can be specified. * - * * - * INPUT: result -- Pointer to the MP number that will hold the result. This pointer * - * can be the same as the left_number or right_number parameters. * - * * - * left_number -- The left hand number (value will be subtracted from this). * - * * - * right_number-- The right hand number (the value to subtract from the left number) * - * * - * borrow -- The optional borrow flag. If this flag is true, the an extra one * - * will be subtracted from the result. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: Returns with the borrow result flag. If the value is true, then an underflow * - * occurred during subtraction. * - * * - * WARNINGS: All MP numbers must share the same precision. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Sub(digit * result, const digit * left_number, const digit * right_number, bool borrow, int precision) -{ - const unsigned short * left_number_ptr = (const unsigned short *)left_number; - const unsigned short * right_number_ptr = (const unsigned short *)right_number; - unsigned short * result_ptr = (unsigned short *)result; - - precision *= 2; - while (precision--) { - digit x = (digit) *left_number_ptr - (digit) *right_number_ptr - (digit) borrow; - right_number_ptr++; - left_number_ptr++; - *result_ptr++ = (unsigned short)x; - borrow = (((1L << 16) & x) != 0L); - } - return (borrow); -} - - -/*********************************************************************************************** - * XMP_Sub_Int -- Subtract an integer from an MP number (with borrow). * - * * - * This will subtract an integer from the specified MP number. There is an optional borrow * - * flag available. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * left_number -- Pointer to the MP number that will be subtracted FROM. * - * * - * right_number-- The integer to subtract from the left hand number. * - * * - * borrow -- The optional borrow flag. If this value is true, then an extra one * - * will be subtracted from the result. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: Returns with the borrow flag of the result. If this value is true, then an * - * underflow occurred during subtraction. * - * * - * WARNINGS: The precision must be identical between the MP numbers involved. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Sub_Int(digit * result, const digit * left_number, unsigned short right_number, bool borrow, int precision) -{ - const unsigned short * left_number_ptr = (const unsigned short *)left_number; - unsigned short * result_ptr = (unsigned short *)result; - - precision *= 2; - while (precision--) { - digit x = (digit) *left_number_ptr - right_number - borrow; - left_number_ptr++; - *result_ptr++ = (unsigned short)x; - borrow = (((1L << 16) & x) != 0L); - - right_number = 0; - } - return (borrow); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Mult -- Multiply two unsigned MP numbers together. * - * * - * This routine will multiply two MP numbers together. The result will have the sum of the * - * significance of the two. * - * * - * INPUT: prod -- Pointer to the product MP buffer that will hold the result. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier MP number. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the product will fit within the precision of the result. * - * * - * HISTORY: * - * 07/01/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - XMP_Init(prod, 0, precision); - - /* - ** Multiplying by zero is always a zero product. - */ - if (XMP_Test_Eq_Int(multiplicand, 0, precision) || XMP_Test_Eq_Int(multiplier, 0, precision)) { - return 0; - } - - int total_bit_count = XMP_Count_Bits(multiplier, precision); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - int sub_precision = XMP_Bits_To_Digits(total_bit_count); - if (!sub_precision) return(0); - multiplier += sub_precision; - - while (total_bit_count--) { - XMP_Shift_Left_Bits(prod, 1, precision); - - if ((*(multiplier-1)) & high_bit_mask) { - XMP_Add(prod, prod, multiplicand, 0, precision); - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - multiplier--; - } - - } - return 0; -} - - -/*********************************************************************************************** - * XMP_Unsigned_Mult_Int -- Multiply an MP number by a simple integer. * - * * - * This is a very fast multiply since the multiplier is just an integer integral. * - * * - * INPUT: prod -- Pointer to the product MP number. * - * * - * multiplicand-- Pointer to the MP number that is the multiplicand. * - * * - * multiplier -- The integral integer that is the multiplier. * - * * - * precision -- The precision of the MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: The multiplier must fit in a signed integer (although it isn't a signed value). * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Mult_Int(digit * prod, const digit * multiplicand, short multiplier, int precision) -{ - const unsigned short * m2 = (const unsigned short *)multiplicand; - unsigned short * pr = (unsigned short *)prod; - unsigned long carry = 0; - for (int i = 0; i < precision*2; ++i) { - unsigned long p = (((unsigned long)multiplier) * *m2) + carry;; - *pr = (unsigned short) p; - carry = p >> 16; - m2++; - pr++; - } - - /* Add carry to the next higher word of product / dividend */ -// *pr += (unsigned short)carry; - return(0); -} - - -/*********************************************************************************************** - * XMP_Signed_Mult_Int -- Multiply an MP number by a signed simple integer. * - * * - * This will multiply the specified integer with the MP number. It is a much faster * - * multiply than when multiplying two MP numbers. * - * * - * INPUT: prod -- Pointer to the product MP number. * - * * - * multiplicand-- Pointer to the MP number that serves as the multiplicand. * - * * - * multiplier -- The simple integral integer used as the multiplier. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: The multiplier must fist within a signed short integer. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Signed_Mult_Int(digit * prod, const digit * multiplicand, signed short multiplier, int precision) -{ - if (XMP_Is_Negative(multiplicand, precision)) { - digit abs_multiplicand[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplicand, multiplicand, precision); - XMP_Neg(abs_multiplicand, precision); - - if (multiplier < 0) { - multiplier = (signed short)-multiplier; - - XMP_Unsigned_Mult_Int(prod, abs_multiplicand, multiplier, precision); - } else { - XMP_Unsigned_Mult_Int(prod, abs_multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } - } else { - if (multiplier < 0) { - multiplier = (signed short)-multiplier; - - XMP_Unsigned_Mult_Int(prod, multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } else { - XMP_Unsigned_Mult_Int(prod, multiplicand, multiplier, precision); - } - } - return(0); -} - - -/*********************************************************************************************** - * XMP_Signed_Mult -- A signed multiply between two MP numbers. * - * * - * This routine will perform a multiply between two signed MP numbers. * - * * - * INPUT: prod -- Pointer to the product MP number buffer. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier MP number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is not a very fast routine. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Signed_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - if (XMP_Is_Negative(multiplicand, precision)) { - digit abs_multiplicand[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplicand, multiplicand, precision); - XMP_Neg(abs_multiplicand, precision); - - if (XMP_Is_Negative(multiplier, precision)) { - digit abs_multiplier[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplier, multiplier, precision); - XMP_Neg(abs_multiplier, precision); - - XMP_Unsigned_Mult(prod, abs_multiplicand, abs_multiplier, precision); - } else { - XMP_Unsigned_Mult(prod, abs_multiplicand, multiplier, precision); - XMP_Neg(prod, precision); - } - } else { - if (XMP_Is_Negative(multiplier, precision)) { - digit abs_multiplier[MAX_UNIT_PRECISION]; - XMP_Move(abs_multiplier, multiplier, precision); - XMP_Neg(abs_multiplier, precision); - - XMP_Unsigned_Mult(prod, multiplicand, abs_multiplier, precision); - XMP_Neg(prod, precision); - } else { - XMP_Unsigned_Mult(prod, multiplicand, multiplier, precision); - } - } - return(0); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Div_Int -- Perform a short integer divide into an MP number. * - * * - * This routine performs a fast divide of the specified MP dividend by a simple * - * short integer. The division is an UNSIGNED division however. * - * * - * INPUT: quotient -- Pointer to the MP number buffer where the quotient will go. * - * * - * dividend -- Pointer to the MP number that serves as the dividend. * - * * - * divisor -- The simple signed short integer that serves as the divisor. * - * * - * precision -- The precision that is used by the MP numbers involved. * - * * - * OUTPUT: Returns with the remainder of the division. * - * * - * WARNINGS: This is an UNSIGNED divide even. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -unsigned short MPEXPORT XMP_Unsigned_Div_Int(digit * quotient, digit const * dividend, unsigned short divisor, int precision) -{ - if (!divisor) return 0; /* zero divisor means divide error */ - - unsigned short remainder = 0; - - XMP_Init(quotient, 0, precision); - - int total_bit_count = XMP_Count_Bits(dividend, precision); - int digit_precision = XMP_Bits_To_Digits(total_bit_count); - digit const * dividend_ptr = dividend + (digit_precision-1); - - if (!digit_precision) return(0); - - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - digit * quotient_ptr = quotient + (digit_precision-1); - - while (total_bit_count--) { - remainder <<= 1; - - if ((*dividend_ptr) & high_bit_mask) remainder++; - - if (remainder >= divisor) { - remainder -= divisor; - *quotient_ptr |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - --dividend_ptr; - --quotient_ptr; - } - } - - return(remainder); -} - - -/*********************************************************************************************** - * XMP_Unsigned_Div -- Unsigned divide of one MP number into another. * - * * - * This will perform the (dog slow) divide of one MP number into another. Because of the * - * slowness of this routine, both the quotient and the remainder are available as a * - * result of the operation. * - * * - * INPUT: remainder -- Pointer to the MP buffer that will hold the remainder of the divide.* - * * - * quotient -- Pointer to the MP buffer that will hold the quotient of the divide. * - * * - * dividend -- The MP dividend (numerator) number. * - * * - * divisor -- The MP divisor (denominator) number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is very slow. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Unsigned_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision) -{ - // check for divide by zero. - if (XMP_Test_Eq_Int(divisor, 0, precision)) return(-1); - - XMP_Init(remainder, 0, precision); - XMP_Init(quotient, 0, precision); - - int total_bit_count = XMP_Count_Bits(dividend, precision); - int digit_precision = XMP_Bits_To_Digits(total_bit_count); - if (!digit_precision) return(0); - - digit const * dividend_ptr = dividend + (digit_precision-1); - digit * quotient_ptr = quotient + (digit_precision-1); - - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - while (total_bit_count--) { - XMP_Shift_Left_Bits(remainder, 1, precision); - - if (((*dividend_ptr) & high_bit_mask) != 0) { - XMP_Inc(remainder, precision); - } - - if (XMP_Compare(remainder, divisor, precision) >= 0) { - XMP_Sub(remainder, remainder, divisor, 0, precision); - *quotient_ptr |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - dividend_ptr--; - quotient_ptr--; - } - - } - return 0; -} - - -/*********************************************************************************************** - * XMP_Signed_Div -- Signed divide of one MP number into another. * - * * - * This will perform a signed divide (very very slow) of one MP number into another. * - * Because of the slow nature of this routine, both the quotient and the remainder are * - * available as results. * - * * - * INPUT: remainder -- Pointer to the buffer that will hold the remainder of the divide. * - * * - * quotient -- Pointer to the buffer that will hold the quotient of the divide. * - * * - * dividend -- The dividend (numerator) MP number. * - * * - * divisor -- The divisor (denominator) MP number. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: This is very very slow. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Signed_Div(digit * remainder, digit * quotient, digit const * dividend, digit const * divisor, int precision) -{ - bool negative = false; - - digit scratch_dividend[MAX_UNIT_PRECISION]; - XMP_Move(scratch_dividend, dividend, precision); - - digit scratch_divisor[MAX_UNIT_PRECISION]; - XMP_Move(scratch_divisor, divisor, precision); - - if (XMP_Is_Negative(scratch_dividend, precision)) { - XMP_Neg(scratch_dividend, precision); - negative = !negative; - } - - if (XMP_Is_Negative(scratch_divisor, precision)) { - XMP_Neg(scratch_divisor, precision); - negative = !negative; - } - - XMP_Unsigned_Div(remainder, quotient, scratch_dividend, scratch_divisor, precision); - - if (negative) { - XMP_Neg(quotient, precision); - if (!XMP_Test_Eq_Int(remainder, 0, precision)) { - XMP_Dec(quotient, precision); - XMP_Neg(remainder, precision); - XMP_Add(remainder, remainder, scratch_divisor, 0, precision); - } - } -} - - -/*********************************************************************************************** - * XMP_Inverse_A_Mod_B -- Inverts and performs modulus on an MP number. * - * * - * This is a utility routine that will perform an inverse on the MP number and then * - * perform a modulus of that number by another MP number. There are some algorithms that * - * require this process. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * number -- The MP number that will be inverted then modulo-ized. * - * * - * modulus -- The MP number to modulus the first number by. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Inverse_A_Mod_B(digit * result, digit const * number, digit const * modulus, int precision) -{ - digit g[3][MAX_UNIT_PRECISION]; - XMP_Move(g[0], modulus, precision); - XMP_Move(g[1], number, precision); - - digit v[3][MAX_UNIT_PRECISION]; - XMP_Init(v[0], 0, precision); - XMP_Init(v[1], 1, precision); - - digit y[MAX_UNIT_PRECISION]; - - int i; - for (i = 1; !XMP_Test_Eq_Int(g[i%3], 0, precision); i++) { - XMP_Unsigned_Div(g[(i+1)%3], y, g[(i-1)%3], g[i%3], precision); - - XMP_Unsigned_Mult(result, v[i%3], y, precision); - XMP_Sub(v[(i+1)%3], v[(i-1)%3], result, 0, precision); - } - - if (XMP_Is_Negative(v[(i-1)%3], precision)) { - XMP_Add(v[(i-1)%3], v[(i-1)%3], modulus, 0, precision); - } - - XMP_Move(result, v[(i-1)%3], precision); -} - - -/*********************************************************************************************** - * XMP_Reciprocal -- Compute the reciprocal (inverse) of the MP number. * - * * - * Use this routine to determine the inverse of the specified MP number. The inverse is * - * defined as 1/number. * - * * - * INPUT: result -- Pointer to the result MP number buffer. * - * * - * number -- The number to be inverted. * - * * - * precision-- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Reciprocal(digit * quotient, const digit * divisor, int precision) -{ - digit remainder[MAX_UNIT_PRECISION]; - - if (XMP_Test_Eq_Int(divisor, 0, precision)) return -1; /* zero divisor means divide error */ - - XMP_Init(remainder, 0, precision); - XMP_Init(quotient, 0, precision); - - /* normalize and compute number of bits in quotient first */ - unsigned total_bit_count = XMP_Count_Bits(divisor, precision); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count + 1); /* bitmask within a single digit */ - int sub_precision = XMP_Bits_To_Digits(total_bit_count + 1); - - XMP_Set_Bit(remainder, total_bit_count - 1); - - /* rescale quotient to precision of divisor bits */ - quotient += sub_precision-1; - - while (total_bit_count--) { - XMP_Shift_Left_Bits(remainder, 1, precision); - if (XMP_Compare(remainder, divisor, precision) >= 0) { - XMP_Sub(remainder, remainder, divisor, 0, precision); - *quotient |= high_bit_mask; - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - quotient--; - } - } - - XMP_Init(remainder, 0, precision); - return 0; -} - - -/*********************************************************************************************** - * XMP_Decode_ASCII -- Convert ASCII into an MP number. * - * * - * This routine will convert a supplied ASCII string into an MP number. * - * * - * INPUT: str -- Pointer to the ASCII string that will be converted. * - * * - * mpn -- Pointer to the MP number buffer that will be initialized. * - * * - * precision -- The precision of the MP number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Decode_ASCII(char const * str, digit * mpn, int precision) -{ - /* - ** Initialize the multiprecision number to zero. From this point - ** onward, this object can be manipulated as a regular number. - ** This is, in fact, what is done as the ascii string is parsed - ** into a working number. - */ - XMP_Init(mpn, 0, precision); - - /* - ** No string or zero length is considered '0'. - */ - if (!str) return; - int i = strlen(str); - if (i == 0) return; - - unsigned short radix; /* base 2-16 */ - switch (toupper(str[i-1])) { /* classify radix select suffix character */ - case '.': - radix = 10; - break; - - case 'H': - radix = 16; - break; - - case 'O': - radix = 8; - break; - - case 'B': /* caution! 'b' is a hex digit! */ - radix = 2; - break; - - default: - radix = 10; - break; - } - - bool minus = (*str == '-'); - if (minus) str++; - - digit c; - while ((c = (unsigned char)*str++) != 0) { - if (c == ',') continue; /* allow commas in number */ - - /* - ** If not a hexadecimal (highest base) digit then it is - ** clearly the end of the processable string. Bail out - ** of the scan loop. - */ - if (!isxdigit((char)c)) break; - - /* - ** Convert the character into an integer number 0 through 15. - */ - if (isdigit((char)c)) { - c -= '0'; - } else { - c = (unsigned char)(toupper((char)c) - 'A') + 10; - } - - /* - ** If the integer digit is greater than the radix, then we - ** know that further processing should stop. This is the - ** end of the number string. - */ - if (c >= radix) break; /* scan terminated by any non-digit */ - - - XMP_Unsigned_Mult_Int(mpn, mpn, radix, precision); - XMP_Add_Int(mpn, mpn, c, 0, precision); - } - if (minus) { - XMP_Neg(mpn, precision); - } -} - - -/*********************************************************************************************** - * XMP_Hybrid_Mul -- Special hybrid short multiply (with carry). * - * * - * Multiply the single-word multiplier times the multiprecision integer * - * in multiplicand, accumulating result in prod. The resulting * - * multiprecision prod will be 1 word longer than the multiplicand. * - * multiplicand is double precision words long. We add into prod, so caller * - * should zero it out first. For best results, this time-critical * - * function should be implemented in assembly. * - * NOTE: Unlike other functions in the multiprecision arithmetic * - * library, both multiplicand and prod are pointing at the LSB, * - * regardless of byte order of the machine. On an 80x86, this makes * - * no difference. But if this assembly function is implemented * - * on a 680x0, it becomes important. * - * * - * Note that this has been modified from the previous version to allow * - * better support for Smith's modmult: * - * The final carry bit is added to the existing product * - * array, rather than simply stored. * - * * - * INPUT: prod -- Pointer to the product MP number buffer. * - * * - * multiplicand -- Pointer to the multiplicand MP number. * - * * - * multiplier -- The short integer used as the multiplier. * - * * - * precision -- The precision of the MP number used. * - * * - * OUTPUT: none * - * * - * WARNINGS: The carry (if any) is added into the integer one beyond the end of the * - * product buffer. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void XMP_Hybrid_Mul(unsigned short * prod, unsigned short * multiplicand, unsigned short multiplier, int precision) -{ - unsigned long carry = 0; - for (int i = 0; i < precision; ++i) { - unsigned long p = (unsigned long)multiplier * *multiplicand++; - p += *prod + carry; - *prod++ = (unsigned short) p; - carry = p >> 16; - } - - /* Add carry to the next higher word of product / dividend */ - *prod += (unsigned short) carry; -} - - -/*********************************************************************************************** - * XMP_Double_Mul -- Double precision MP multiply. * - * * - * This will perform a double precision multiply of MP numbers. This means that the product * - * will be twice the precision of the components. * - * * - * INPUT: prod -- Pointer to the result buffer. This buffer must be able to hold * - * double the precision specified. * - * * - * multiplicand-- Pointer to the multiplicand MP number. * - * * - * multiplier -- Pointer to the multiplier number. * - * * - * precision -- The precision of the two component MP numbers. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure the product buffer can hold a double precision number. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Double_Mul(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - /* - ** Clear out the double precision product buffer. - */ - XMP_Init(prod, 0, precision*2); - - const unsigned short * multiplier_ptr = (const unsigned short *) multiplier; - unsigned short * product_ptr = (unsigned short *) prod; - - // Multiply multiplicand by each word in multiplier, accumulating prod. - for (int i = 0; i < precision*2; ++i) { - XMP_Hybrid_Mul(product_ptr++, (unsigned short *)multiplicand, *multiplier_ptr++, precision*2); - } -} - - - -static int _modulus_shift; // number of bits for recip scaling -static unsigned short _reciprical_high_digit; // MSdigit of scaled recip -static unsigned short _reciprical_low_digit; // LSdigit of scaled recip - -static int _modulus_sub_precision; // length of modulus in MULTUNITs -static int _modulus_bit_count; // number of modulus significant bits -static digit _scratch_modulus[MAX_UNIT_PRECISION]; // modulus - -// The double precision modulus staging buffer. -static digit _double_staging_number[MAX_UNIT_PRECISION * 2 + 2]; - -// most significant digits of modulus. -static digit _mod_quotient[4]; -static digit _mod_divisor[4]; - - -/*********************************************************************************************** - * XMP_Prepare_Modulus -- Prepare globals for modulus operation. * - * * - * Calculate the reciprocal of modulus with a precision of two MULTUNITs. * - * Assumes that precision has already been adjusted to the * - * size of the modulus, plus SLOP_BITS. * - * * - * Note: This routine was designed to work with large values and * - * doesn't have the necessary testing or handling to work with a * - * modulus having less than three significant digits. For such cases, * - * the separate multiply and modulus routines can be used. * - * * - * INPUT: modulus -- Pointer to the modulus number. * - * * - * precision-- The precision of the modulus number. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int XMP_Prepare_Modulus(const digit * n_modulus, int precision) -{ - XMP_Move(_scratch_modulus, n_modulus, precision); - - _modulus_bit_count = XMP_Count_Bits(_scratch_modulus, precision); - _modulus_sub_precision = (_modulus_bit_count + 16 - 1) / 16; - - /* - ** Keep 2*16 bits in _mod_divisor. - ** This will (normally) result in a reciprocal of 2*16+1 bits. - */ - int sub_precision = XMP_Significance(_scratch_modulus, precision); // significant digits in modulus - XMP_Move(_mod_divisor, &_scratch_modulus[sub_precision-2], 2); - _modulus_shift = XMP_Count_Bits(_mod_divisor, 2) - 2 * 16; - XMP_Shift_Right_Bits(_mod_divisor, _modulus_shift, 2); - - XMP_Reciprocal(_mod_quotient, _mod_divisor, 2); - XMP_Shift_Right_Bits(_mod_quotient, 1, 2); - - /* Reduce to: 0 < _modulus_shift <= 16 */ - _modulus_shift = ((_modulus_shift + (16 - 1)) % 16) + 1; - - /* round up */ - XMP_Inc(_mod_quotient, 2); - if (XMP_Count_Bits(_mod_quotient, 2) > 2 * 16) { - XMP_Shift_Right_Bits(_mod_quotient, 1, 2); - _modulus_shift--; /* now 0 <= _modulus_shift <= 16 */ - } - unsigned short * mpm = (unsigned short *) _mod_quotient; - _reciprical_low_digit = *mpm++; - _reciprical_high_digit = *mpm; - - return 0; -} - - -/*********************************************************************************************** - * XMP_Mod_Mult -- Perform a multiply - modulus operation. * - * * - * This routine will combine a multiply and a modulus operation. This takes advantage of * - * a tremendous speed advantage possible if these two processes are combined rather than * - * being performed separately. * - * * - * INPUT: prod -- Pointer to the MP buffer that will hold the result. * - * * - * multiplicand-- The number to multiply. * - * * - * multiplier -- The number to multiply by. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: The modulus must already have been prepared by the routine XMP_Prepare_Modulus. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -int MPEXPORT XMP_Mod_Mult(digit * prod, const digit * multiplicand, const digit * multiplier, int precision) -{ - XMP_Double_Mul(_double_staging_number, multiplicand, multiplier, precision); - - int double_precision = precision * 2 + 1; - - _double_staging_number[double_precision - 1] = 0; /* leading 0 digit */ - - /* - ** We now start working with MULTUNITs. - ** Determine the most significant MULTUNIT of the product so we don't - ** have to process leading zeros in our divide loop. - */ - int dmi = XMP_Significance(_double_staging_number, double_precision) * 2; // number of significant MULTUNITs in product - - if (dmi >= _modulus_sub_precision) { - - /* Make dividend negative. This allows the use of mp_single_mul to - ** "subtract" the product of the modulus and the trial divisor - ** by actually adding to a negative dividend. - ** The one's complement of the dividend is used, since it causes - ** a zero value to be represented as all ones. This facilitates - ** testing the result for possible overflow, since a sign bit - ** indicates that no adjustment is necessary, and we should not - ** attempt to adjust if the result of the addition is zero. - */ - XMP_Inc(_double_staging_number, double_precision); - XMP_Neg(_double_staging_number, double_precision); - - int nqd = dmi + 1 - _modulus_sub_precision; // number of quotient digits remaining to be generated - - /* Set msb, lsb, and normal ptrs of dividend */ - unsigned short * dmph = ((unsigned short *)_double_staging_number) + dmi + 1; // points to one higher than precision would indicate - unsigned short * dmpl = dmph - _modulus_sub_precision; - - /* - ** Divide loop. - ** Each iteration computes the next quotient MULTUNIT digit, then - ** multiplies the divisor (modulus) by the quotient digit and adds - ** it to the one's complement of the dividend (equivalent to - ** subtracting). If the product was greater than the remaining dividend, - ** we get a non-negative result, in which case we subtract off the - ** modulus to get the proper negative remainder. - */ - for (; nqd; nqd--) { - --dmph; - --dmpl; - - unsigned short q = mp_quo_digit(dmph); // trial quotient digit - if (q > 0) { - XMP_Hybrid_Mul(dmpl, (unsigned short *)_scratch_modulus, q, precision*2); - - /* Perform correction if q too large. - ** This rarely occurs. - */ - if (!(*dmph & SEMI_UPPER_MOST_BIT)) { - unsigned short * dmp = dmpl; - if (XMP_Sub((unsigned long *)dmp, (unsigned long *)dmp, _scratch_modulus, false, precision)) { - (*dmph)--; - } - } - } - } - - /* d contains the one's complement of the remainder. */ - XMP_Neg(_double_staging_number, precision); - XMP_Dec(_double_staging_number, precision); - } - - XMP_Move(prod, _double_staging_number, precision); - return (0); -} - - -/*********************************************************************************************** - * XMP_Mod_Mult_Clear -- Remove temporary values from memory. * - * * - * Smith's mp_modmult function leaves some internal arrays in memory, * - * so we have to call modmult_burn() at the end of mp_exponent_mod. * - * This is so that no cryptographically sensitive data is left in memory * - * after the program exits. * - * * - * INPUT: precision -- The precision of the numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Mod_Mult_Clear(int precision) -{ - XMP_Init(_scratch_modulus, 0, precision); - XMP_Init(_double_staging_number, 0, precision); - XMP_Init(_mod_quotient, 0, ARRAY_SIZE(_mod_quotient)); - XMP_Init(_mod_divisor, 0, ARRAY_SIZE(_mod_divisor)); - _modulus_shift = _modulus_bit_count = 0; - _reciprical_high_digit = _reciprical_low_digit = 0; - _modulus_sub_precision = /*mutemp =*/ 0; -} - - -/* -** The function mp_quo_digit is the heart of Smith's modulo reduction, -** which uses a form of long division. It computes a trial quotient -** "digit" (MULTUNIT-sized digit) by multiplying the three most -** significant MULTUNITs of the dividend by the two most significant -** MULTUNITs of the reciprocal of the modulus. Note that this function -** requires that 16 * 2 <= sizeof(unsigned long). -** -** An important part of this technique is that the quotient never be -** too small, although it may occasionally be too large. This was -** done to eliminate the need to check and correct for a remainder -** exceeding the divisor. It is easier to check for a negative -** remainder. The following technique rarely needs correction for -** MULTUNITs of at least 16 bits. -** -** The following routine has two implementations: -** -** Parameter: dividend - points to the most significant MULTUNIT -** of the dividend. Note that dividend actually contains the -** one's complement of the actual dividend value (see comments for -** XMP_Mod_Mult). -** -** Return: the trial quotient digit resulting from dividing the first -** three MULTUNITs at dividend by the upper two MULTUNITs of the -** modulus. -*/ -unsigned short mp_quo_digit(unsigned short * dividend) -{ - unsigned long q, q0, q1, q2; - - /* - * Compute the least significant product group. - * The last terms of q1 and q2 perform upward rounding, which is - * needed to guarantee that the result not be too small. - */ - q1 = (dividend[-2] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit + _reciprical_high_digit; - q2 = (dividend[-1] ^ SEMI_MASK) * (unsigned long) _reciprical_low_digit + (1L << 16); - q0 = (q1 >> 1) + (q2 >> 1) + 1; - - /* Compute the middle significant product group. */ - q1 = (dividend[-1] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit; - q2 = (dividend[0] ^ SEMI_MASK) * (unsigned long) _reciprical_low_digit; - q = (q0 >> 16) + (q1 >> 1) + (q2 >> 1) + 1; - - /* Compute the most significant term and add in the others */ - q = (q >> (16 - 2)) + (((dividend[0] ^ SEMI_MASK) * (unsigned long) _reciprical_high_digit) << 1); - q >>= _modulus_shift; - - /* Prevent overflow and then wipe out the intermediate results. */ - return (unsigned short) min(q, (unsigned long)(1L << 16) - 1); -} - - -/* -** Russian peasant combined exponentiation/modulo algorithm. -** Calls modmult instead of mult. -** Computes: expout = (expin**exponent) mod modulus -** WARNING: All the arguments must be less than the modulus! -*/ -int MPEXPORT XMP_Exponent_Mod(digit * expout, const digit * expin, const digit * exponent_ptr, const digit * modulus, int precision) -{ - digit product[MAX_UNIT_PRECISION]; - - XMP_Init(expout, 1, precision); - if (XMP_Test_Eq_Int(exponent_ptr, 0, precision)) { - if (XMP_Test_Eq_Int(expin, 0, precision)) { - return -1; /* 0 to the 0th power means return error */ - } - return 0; /* otherwise, zero exponent means expout is 1 */ - } - - if (XMP_Test_Eq_Int(modulus, 0, precision)) { - return -2; /* zero modulus means error */ - } - - if (XMP_Compare(expin, modulus, precision) >= 0) { - return -3; /* if expin >= modulus, return error */ - } - - if (XMP_Compare(exponent_ptr, modulus, precision) >= 0) { - return -4; /* if exponent >= modulus, return error */ - } - - /* set smallest optimum precision for this modulus */ - int limited_precision = XMP_Significance(modulus, precision); - - if (XMP_Prepare_Modulus(modulus, limited_precision)) { - return -5; /* unstageable modulus (STEWART algorithm) */ - } - - /* normalize and compute number of bits in exponent first */ -// int exp_precision = XMP_Significance(exponent_ptr, limited_precision); -// if (!exp_precision) return(0); -// int bits = XMP_Digits_To_Bits(exp_precision); -// exponent_ptr += (exp_precision-1); -// digit high_bit_mask = UPPER_MOST_BIT; -// while (! ((*exponent_ptr) & high_bit_mask)) { -// high_bit_mask >>= 1; -// bits--; -// } - - int total_bit_count = XMP_Count_Bits(exponent_ptr, limited_precision); - int sub_precision = XMP_Bits_To_Digits(total_bit_count); - if (!sub_precision) return(0); - digit high_bit_mask = XMP_Bits_To_Mask(total_bit_count); - exponent_ptr += (sub_precision-1); - - /* We can "optimize out" the first modsquare and modmult: */ - total_bit_count--; /* We know for sure at this point that bits>0 */ - - XMP_Move(expout, expin, limited_precision); - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - exponent_ptr--; - } - - while (total_bit_count--) { - XMP_Mod_Mult(product, expout, expout, limited_precision); - - if (((*exponent_ptr) & high_bit_mask)) { - XMP_Mod_Mult(expout, product, expin, limited_precision); - } else { - XMP_Move(expout, product, limited_precision); - } - - high_bit_mask >>= 1; - if (!high_bit_mask) { - high_bit_mask = UPPER_MOST_BIT; - exponent_ptr--; - } - - } - - XMP_Init(product, 0, limited_precision); - XMP_Mod_Mult_Clear(limited_precision); /* ask mp_modmult to also burn its own evidence */ - - return 0; -} - - -/*********************************************************************************************** - * memrev -- Reverse the byte order of the buffer specified. * - * * - * This routine will reverse the byte order in the buffer specified. * - * * - * INPUT: buffer -- Pointer to the buffer that will be reversed. * - * * - * length -- The length of the buffer. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void memrev(char * buffer, size_t length) -{ - char * r2 = &(buffer[length - 1]); - while (buffer < r2) { - char b = *buffer; - *buffer++ = *r2; - *r2-- = b; - } -} - - -int _USERENTRY pfunc(const void * pkey, const void * base) -{ - if (*(unsigned short *)pkey < *(unsigned short *)base) return(-1); - if (*(unsigned short *)pkey > *(unsigned short *)base) return(1); - return(0); -} - - -/*********************************************************************************************** - * XMP_Is_Small_Prime -- Determine if MP number is a small prime. * - * * - * This routine will compare the MP number against all known small prime numbers. It will * - * return true if a match was found. * - * * - * INPUT: candidate -- Pointer to MP number that is to be tested. * - * * - * precision -- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the MP number a member of the small prime community? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Is_Small_Prime(const digit * candidate, int precision) -{ - /* - ** If the number is too large for comparison to the known small primes table, then - ** bail immediately. - */ - if (XMP_Significance(candidate, precision) > 1) return(false); - if (*candidate > primeTable[ARRAY_SIZE(primeTable)-1]) return false; - - unsigned long * ptr = (unsigned long *)bsearch(&candidate, &primeTable[0], ARRAY_SIZE(primeTable), sizeof(primeTable[0]), pfunc); - return(ptr != NULL); -} - - -/*********************************************************************************************** - * XMP_Small_Divisors_Test -- Perform the small divisors test on an MP number. * - * * - * This test for primality will divide an MP number by the set of small primes. If any of * - * these numbers divides evenly into the candidate number, then it is known that the * - * candidate is NOT prime. * - * * - * INPUT: candidate -- Pointer to the MP number that is to be tested. * - * * - * precision -- The precision of the MP number/ * - * * - * OUTPUT: bool; Did the MP number pass the small divisors test? * - * * - * WARNINGS: If the MP number passes, it doesn't mean that it is prime, just that is hasn't * - * yet been proven to be not prime. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Small_Divisors_Test(const digit * candidate, int precision) -{ - digit quotient[MAX_UNIT_PRECISION]; - - for (unsigned i = 0; i < ARRAY_SIZE(primeTable); i++) { - if (XMP_Unsigned_Div_Int(quotient, candidate, primeTable[i], precision) == 0) return(false); - } - return(true); -} - - -/*********************************************************************************************** - * XMP_Fermat_Test -- Performs Fermat's Little Theorem on an MP number. * - * * - * This is a more expensive but thorough test for primality. The aggressiveness of this * - * test can be controlled by the number of rounds specified. Four rounds is usually * - * sufficient. * - * * - * INPUT: candidate -- Pointer to the candidate MP number that is to be tested. * - * * - * rounds -- The number of rounds to test the MP number (keep it small). * - * * - * precision -- The precision of the MP number. * - * * - * OUTPUT: bool; Was the number not proven to be not prime. A FALSE means that it is not * - * prime. A TRUE means that it might be prime. * - * * - * WARNINGS: This takes a bit of time. The time it takes is directly controlled by the * - * number of rounds specified. Keep the number of rounds as small as possible. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Fermat_Test(const digit * candidate_prime, unsigned rounds, int precision) -{ - assert(rounds < ARRAY_SIZE(primeTable)); - - digit term[MAX_UNIT_PRECISION]; - XMP_Move(term, candidate_prime, precision); - XMP_Dec(term, precision); - - for (unsigned i = 0; i < rounds; i++) { - // if ((x**(p-1)) mod p) != 1, then p is not prime - digit result[MAX_UNIT_PRECISION]; - - digit small_prime[MAX_UNIT_PRECISION]; - XMP_Init(small_prime, primeTable[i], precision); - - XMP_Exponent_Mod(result, small_prime, term, candidate_prime, precision); - - if (!XMP_Test_Eq_Int(result, 1, precision)) return(false); - } - return(true); -} - - -/*********************************************************************************************** - * XMP_Rabin_Miller_Test -- Performs the Rabin Miller test for primality. * - * * - * This test for primality is even more expensive the Fermat's Little Theorem. It doesn't * - * prove that a number is prime, but it can prove that it is not prime. * - * * - * INPUT: rng -- Reference to to a random number generator. * - * * - * candidate-- Pointer to the candidate MP number that is to be tested. * - * * - * rounds -- The number of test rounds to perform. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the number not proven to be not prime? A FALSE means that the number is * - * not prime. A TRUE means that it might be. * - * * - * WARNINGS: This routine takes a long time. Use as few rounds as possible. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Rabin_Miller_Test(Straw & rng, digit const * w, int rounds, int precision) -{ - digit wminus1[MAX_UNIT_PRECISION]; - XMP_Sub_Int(wminus1, w, 1, 0, precision); - - unsigned maxbitprecision = precision * sizeof(digit) * 8; - unsigned a; - for (a = 0; a < maxbitprecision; a++) { - if (XMP_Test_Bit(wminus1, a)) { - break; - } - } - - digit m[MAX_UNIT_PRECISION]; - XMP_Move(m, wminus1, precision); - XMP_Shift_Right_Bits(wminus1, a, precision); - - for (int i = 0; i < rounds; i++) { - digit b[MAX_UNIT_PRECISION]; - digit temp[MAX_UNIT_PRECISION]; - XMP_Init(temp, 2, precision); - XMP_Randomize_Bounded(b, rng, temp, wminus1, precision); - - digit z[MAX_UNIT_PRECISION]; - XMP_Exponent_Mod(z, b, m, w, precision); - - if (XMP_Test_Eq_Int(z, 1, precision) || XMP_Compare(z, wminus1, precision) == 0) { - continue; // passes this round - } - - unsigned j; - for (j = 1; j < a; j++) { - digit t2[MAX_UNIT_PRECISION]; - XMP_Exponent_Mod(t2, z, temp, w, precision); - - if (XMP_Compare(t2, wminus1, precision) == 0) { - break; // passed this round - } - if (XMP_Test_Eq_Int(z, 1, precision)) { - return false; - } - } - if (j == a) { - return false; - } - } - return true; -} - - -/*********************************************************************************************** - * XMP_Randomize -- Generate a random MP number. * - * * - * This routine will generate a random MP number with the number of bits precision * - * specified. This is the starting point for generating large random prime numbers. It is * - * very important that the random number generated is truly random. * - * * - * INPUT: result -- Pointer to the buffer that will hold the MP number. * - * * - * rng -- Reference to a random number generator. * - * * - * total_bits-- The number of bits precision that the MP number must have. * - * * - * precision-- The precision of the MP number to be generated (maximum) * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Randomize(digit * result, Straw & rng, int total_bits, int precision) -{ - assert(XMP_Bits_To_Digits(total_bits) <= MAX_UNIT_PRECISION); - - total_bits = min(total_bits, precision * 32); - - unsigned nbytes = total_bits/8 + 1; - - XMP_Init(result, 0, precision); - rng.Get(result, nbytes); - - ((unsigned char *)result)[nbytes-1] &= (unsigned char)(~((~0) << (total_bits % 8))); -} - - -/*********************************************************************************************** - * XMP_Randomize -- Generate a random MP number between the boundaries specified. * - * * - * This routine will generate a random MP number but it will be bounded by the minimum * - * and maximum MP numbers specified. * - * * - * INPUT: result -- Pointer to the MP buffer that will hold the result. * - * * - * rng -- Reference to a random number generator to use. * - * * - * minval -- Minimum value allowed. * - * * - * maxval -- Maximum value allowed. * - * * - * precision -- The precision of the MP numbers involved. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -void MPEXPORT XMP_Randomize_Bounded(digit * result, Straw & rng, digit const * minval, digit const * maxval, int precision) -{ - digit range[MAX_UNIT_PRECISION]; - XMP_Sub(range, maxval, minval, 0, precision); - unsigned int bit_count = XMP_Count_Bits(range, precision); - do { - XMP_Randomize(result, rng, bit_count, precision); - } while (XMP_Compare(result, range, precision) > 0); - - XMP_Add(result, result, minval, 0, precision); -} - - -/*********************************************************************************************** - * XMP_Is_Prime -- Determine if the specified MP number is prime. * - * * - * This routine will perform some checks to try and determine if the specified MP number * - * is a prime number. The result of this test is not 100% conclusive, but it is pretty * - * darn close. * - * * - * INPUT: prime -- Pointer to a candidate number to test for primality. * - * * - * precision-- The precision of the MP number specified. * - * * - * OUTPUT: bool; Was the number not proven to be not prime? If FALSE, then the number is * - * not prime. If TRUE, then it might be. * - * * - * WARNINGS: This can take a very very very very very long time. Especially for the larger * - * numbers. * - * * - * HISTORY: * - * 07/02/1996 JLB : Created. * - *=============================================================================================*/ -bool MPEXPORT XMP_Is_Prime(digit const * prime, int precision) -{ - /* - ** Even numbers are ALWAYS not prime. - */ - if (!(*prime & 0x01)) return(false); - - /* - ** Compare the prime number against the exhaustive list of prime - ** numbers below 14 bits in size. If it finds a match, then - ** the number is a known prime. - */ - if (XMP_Is_Small_Prime(prime, precision)) return(true); - - /* - ** Perform the small divisors test. This is not exhaustive, but - ** will weed out a large percentage of non-prime numbers. - */ - if (!XMP_Small_Divisors_Test(prime, precision)) return(false); - - /* - ** Perform Fermat's Little Theorum on the candidate prime. Run - ** the theorum for several rounds to ensure a high degree of - ** confidence. - */ - if (!XMP_Fermat_Test(prime, 2, precision)) return(false); - - /* - ** If all of the above tests have not confirmed primality nor - ** confirmed non-primality, presume that the number must be prime. - */ - return(true); -} - - -/* -** Complete list of all prime numbers that are less than 32719 (inclusive). -*/ -unsigned short primeTable[3511] = { - 0x0002,0x0003,0x0005,0x0007,0x000B,0x000D,0x0011,0x0013,0x0017,0x001D,0x001F,0x0025,0x0029,0x002B,0x002F,0x0035, - 0x003B,0x003D,0x0043,0x0047,0x0049,0x004F,0x0053,0x0059,0x0061,0x0065,0x0067,0x006B,0x006D,0x0071,0x007F,0x0083, - 0x0089,0x008B,0x0095,0x0097,0x009D,0x00A3,0x00A7,0x00AD,0x00B3,0x00B5,0x00BF,0x00C1,0x00C5,0x00C7,0x00D3,0x00DF, - 0x00E3,0x00E5,0x00E9,0x00EF,0x00F1,0x00FB,0x0101,0x0107,0x010D,0x010F,0x0115,0x0119,0x011B,0x0125,0x0133,0x0137, - 0x0139,0x013D,0x014B,0x0151,0x015B,0x015D,0x0161,0x0167,0x016F,0x0175,0x017B,0x017F,0x0185,0x018D,0x0191,0x0199, - 0x01A3,0x01A5,0x01AF,0x01B1,0x01B7,0x01BB,0x01C1,0x01C9,0x01CD,0x01CF,0x01D3,0x01DF,0x01E7,0x01EB,0x01F3,0x01F7, - 0x01FD,0x0209,0x020B,0x021D,0x0223,0x022D,0x0233,0x0239,0x023B,0x0241,0x024B,0x0251,0x0257,0x0259,0x025F,0x0265, - 0x0269,0x026B,0x0277,0x0281,0x0283,0x0287,0x028D,0x0293,0x0295,0x02A1,0x02A5,0x02AB,0x02B3,0x02BD,0x02C5,0x02CF, - 0x02D7,0x02DD,0x02E3,0x02E7,0x02EF,0x02F5,0x02F9,0x0301,0x0305,0x0313,0x031D,0x0329,0x032B,0x0335,0x0337,0x033B, - 0x033D,0x0347,0x0355,0x0359,0x035B,0x035F,0x036D,0x0371,0x0373,0x0377,0x038B,0x038F,0x0397,0x03A1,0x03A9,0x03AD, - 0x03B3,0x03B9,0x03C7,0x03CB,0x03D1,0x03D7,0x03DF,0x03E5,0x03F1,0x03F5,0x03FB,0x03FD,0x0407,0x0409,0x040F,0x0419, - 0x041B,0x0425,0x0427,0x042D,0x043F,0x0443,0x0445,0x0449,0x044F,0x0455,0x045D,0x0463,0x0469,0x047F,0x0481,0x048B, - 0x0493,0x049D,0x04A3,0x04A9,0x04B1,0x04BD,0x04C1,0x04C7,0x04CD,0x04CF,0x04D5,0x04E1,0x04EB,0x04FD,0x04FF,0x0503, - 0x0509,0x050B,0x0511,0x0515,0x0517,0x051B,0x0527,0x0529,0x052F,0x0551,0x0557,0x055D,0x0565,0x0577,0x0581,0x058F, - 0x0593,0x0595,0x0599,0x059F,0x05A7,0x05AB,0x05AD,0x05B3,0x05BF,0x05C9,0x05CB,0x05CF,0x05D1,0x05D5,0x05DB,0x05E7, - 0x05F3,0x05FB,0x0607,0x060D,0x0611,0x0617,0x061F,0x0623,0x062B,0x062F,0x063D,0x0641,0x0647,0x0649,0x064D,0x0653, - 0x0655,0x065B,0x0665,0x0679,0x067F,0x0683,0x0685,0x069D,0x06A1,0x06A3,0x06AD,0x06B9,0x06BB,0x06C5,0x06CD,0x06D3, - 0x06D9,0x06DF,0x06F1,0x06F7,0x06FB,0x06FD,0x0709,0x0713,0x071F,0x0727,0x0737,0x0745,0x074B,0x074F,0x0751,0x0755, - 0x0757,0x0761,0x076D,0x0773,0x0779,0x078B,0x078D,0x079D,0x079F,0x07B5,0x07BB,0x07C3,0x07C9,0x07CD,0x07CF,0x07D3, - 0x07DB,0x07E1,0x07EB,0x07ED,0x07F7,0x0805,0x080F,0x0815,0x0821,0x0823,0x0827,0x0829,0x0833,0x083F,0x0841,0x0851, - 0x0853,0x0859,0x085D,0x085F,0x0869,0x0871,0x0883,0x089B,0x089F,0x08A5,0x08AD,0x08BD,0x08BF,0x08C3,0x08CB,0x08DB, - 0x08DD,0x08E1,0x08E9,0x08EF,0x08F5,0x08F9,0x0905,0x0907,0x091D,0x0923,0x0925,0x092B,0x092F,0x0935,0x0943,0x0949, - 0x094D,0x094F,0x0955,0x0959,0x095F,0x096B,0x0971,0x0977,0x0985,0x0989,0x098F,0x099B,0x09A3,0x09A9,0x09AD,0x09C7, - 0x09D9,0x09E3,0x09EB,0x09EF,0x09F5,0x09F7,0x09FD,0x0A13,0x0A1F,0x0A21,0x0A31,0x0A39,0x0A3D,0x0A49,0x0A57,0x0A61, - 0x0A63,0x0A67,0x0A6F,0x0A75,0x0A7B,0x0A7F,0x0A81,0x0A85,0x0A8B,0x0A93,0x0A97,0x0A99,0x0A9F,0x0AA9,0x0AAB,0x0AB5, - 0x0ABD,0x0AC1,0x0ACF,0x0AD9,0x0AE5,0x0AE7,0x0AED,0x0AF1,0x0AF3,0x0B03,0x0B11,0x0B15,0x0B1B,0x0B23,0x0B29,0x0B2D, - 0x0B3F,0x0B47,0x0B51,0x0B57,0x0B5D,0x0B65,0x0B6F,0x0B7B,0x0B89,0x0B8D,0x0B93,0x0B99,0x0B9B,0x0BB7,0x0BB9,0x0BC3, - 0x0BCB,0x0BCF,0x0BDD,0x0BE1,0x0BE9,0x0BF5,0x0BFB,0x0C07,0x0C0B,0x0C11,0x0C25,0x0C2F,0x0C31,0x0C41,0x0C5B,0x0C5F, - 0x0C61,0x0C6D,0x0C73,0x0C77,0x0C83,0x0C89,0x0C91,0x0C95,0x0C9D,0x0CB3,0x0CB5,0x0CB9,0x0CBB,0x0CC7,0x0CE3,0x0CE5, - 0x0CEB,0x0CF1,0x0CF7,0x0CFB,0x0D01,0x0D03,0x0D0F,0x0D13,0x0D1F,0x0D21,0x0D2B,0x0D2D,0x0D3D,0x0D3F,0x0D4F,0x0D55, - 0x0D69,0x0D79,0x0D81,0x0D85,0x0D87,0x0D8B,0x0D8D,0x0DA3,0x0DAB,0x0DB7,0x0DBD,0x0DC7,0x0DC9,0x0DCD,0x0DD3,0x0DD5, - 0x0DDB,0x0DE5,0x0DE7,0x0DF3,0x0DFD,0x0DFF,0x0E09,0x0E17,0x0E1D,0x0E21,0x0E27,0x0E2F,0x0E35,0x0E3B,0x0E4B,0x0E57, - 0x0E59,0x0E5D,0x0E6B,0x0E71,0x0E75,0x0E7D,0x0E87,0x0E8F,0x0E95,0x0E9B,0x0EB1,0x0EB7,0x0EB9,0x0EC3,0x0ED1,0x0ED5, - 0x0EDB,0x0EED,0x0EEF,0x0EF9,0x0F07,0x0F0B,0x0F0D,0x0F17,0x0F25,0x0F29,0x0F31,0x0F43,0x0F47,0x0F4D,0x0F4F,0x0F53, - 0x0F59,0x0F5B,0x0F67,0x0F6B,0x0F7F,0x0F95,0x0FA1,0x0FA3,0x0FA7,0x0FAD,0x0FB3,0x0FB5,0x0FBB,0x0FD1,0x0FD3,0x0FD9, - 0x0FE9,0x0FEF,0x0FFB,0x0FFD,0x1003,0x100F,0x101F,0x1021,0x1025,0x102B,0x1039,0x103D,0x103F,0x1051,0x1069,0x1073, - 0x1079,0x107B,0x1085,0x1087,0x1091,0x1093,0x109D,0x10A3,0x10A5,0x10AF,0x10B1,0x10BB,0x10C1,0x10C9,0x10E7,0x10F1, - 0x10F3,0x10FD,0x1105,0x110B,0x1115,0x1127,0x112D,0x1139,0x1145,0x1147,0x1159,0x115F,0x1163,0x1169,0x116F,0x1181, - 0x1183,0x118D,0x119B,0x11A1,0x11A5,0x11A7,0x11AB,0x11C3,0x11C5,0x11D1,0x11D7,0x11E7,0x11EF,0x11F5,0x11FB,0x120D, - 0x121D,0x121F,0x1223,0x1229,0x122B,0x1231,0x1237,0x1241,0x1247,0x1253,0x125F,0x1271,0x1273,0x1279,0x127D,0x128F, - 0x1297,0x12AF,0x12B3,0x12B5,0x12B9,0x12BF,0x12C1,0x12CD,0x12D1,0x12DF,0x12FD,0x1307,0x130D,0x1319,0x1327,0x132D, - 0x1337,0x1343,0x1345,0x1349,0x134F,0x1357,0x135D,0x1367,0x1369,0x136D,0x137B,0x1381,0x1387,0x138B,0x1391,0x1393, - 0x139D,0x139F,0x13AF,0x13BB,0x13C3,0x13D5,0x13D9,0x13DF,0x13EB,0x13ED,0x13F3,0x13F9,0x13FF,0x141B,0x1421,0x142F, - 0x1433,0x143B,0x1445,0x144D,0x1459,0x146B,0x146F,0x1471,0x1475,0x148D,0x1499,0x149F,0x14A1,0x14B1,0x14B7,0x14BD, - 0x14CB,0x14D5,0x14E3,0x14E7,0x1505,0x150B,0x1511,0x1517,0x151F,0x1525,0x1529,0x152B,0x1537,0x153D,0x1541,0x1543, - 0x1549,0x155F,0x1565,0x1567,0x156B,0x157D,0x157F,0x1583,0x158F,0x1591,0x1597,0x159B,0x15B5,0x15BB,0x15C1,0x15C5, - 0x15CD,0x15D7,0x15F7,0x1607,0x1609,0x160F,0x1613,0x1615,0x1619,0x161B,0x1625,0x1633,0x1639,0x163D,0x1645,0x164F, - 0x1655,0x1669,0x166D,0x166F,0x1675,0x1693,0x1697,0x169F,0x16A9,0x16AF,0x16B5,0x16BD,0x16C3,0x16CF,0x16D3,0x16D9, - 0x16DB,0x16E1,0x16E5,0x16EB,0x16ED,0x16F7,0x16F9,0x1709,0x170F,0x1723,0x1727,0x1733,0x1741,0x175D,0x1763,0x1777, - 0x177B,0x178D,0x1795,0x179B,0x179F,0x17A5,0x17B3,0x17B9,0x17BF,0x17C9,0x17CB,0x17D5,0x17E1,0x17E9,0x17F3,0x17F5, - 0x17FF,0x1807,0x1813,0x181D,0x1835,0x1837,0x183B,0x1843,0x1849,0x184D,0x1855,0x1867,0x1871,0x1877,0x187D,0x187F, - 0x1885,0x188F,0x189B,0x189D,0x18A7,0x18AD,0x18B3,0x18B9,0x18C1,0x18C7,0x18D1,0x18D7,0x18D9,0x18DF,0x18E5,0x18EB, - 0x18F5,0x18FD,0x1915,0x191B,0x1931,0x1933,0x1945,0x1949,0x1951,0x195B,0x1979,0x1981,0x1993,0x1997,0x1999,0x19A3, - 0x19A9,0x19AB,0x19B1,0x19B5,0x19C7,0x19CF,0x19DB,0x19ED,0x19FD,0x1A03,0x1A05,0x1A11,0x1A17,0x1A21,0x1A23,0x1A2D, - 0x1A2F,0x1A35,0x1A3F,0x1A4D,0x1A51,0x1A69,0x1A6B,0x1A7B,0x1A7D,0x1A87,0x1A89,0x1A93,0x1AA7,0x1AAB,0x1AAD,0x1AB1, - 0x1AB9,0x1AC9,0x1ACF,0x1AD5,0x1AD7,0x1AE3,0x1AF3,0x1AFB,0x1AFF,0x1B05,0x1B23,0x1B25,0x1B2F,0x1B31,0x1B37,0x1B3B, - 0x1B41,0x1B47,0x1B4F,0x1B55,0x1B59,0x1B65,0x1B6B,0x1B73,0x1B7F,0x1B83,0x1B91,0x1B9D,0x1BA7,0x1BBF,0x1BC5,0x1BD1, - 0x1BD7,0x1BD9,0x1BEF,0x1BF7,0x1C09,0x1C13,0x1C19,0x1C27,0x1C2B,0x1C2D,0x1C33,0x1C3D,0x1C45,0x1C4B,0x1C4F,0x1C55, - 0x1C73,0x1C81,0x1C8B,0x1C8D,0x1C99,0x1CA3,0x1CA5,0x1CB5,0x1CB7,0x1CC9,0x1CE1,0x1CF3,0x1CF9,0x1D09,0x1D1B,0x1D21, - 0x1D23,0x1D35,0x1D39,0x1D3F,0x1D41,0x1D4B,0x1D53,0x1D5D,0x1D63,0x1D69,0x1D71,0x1D75,0x1D7B,0x1D7D,0x1D87,0x1D89, - 0x1D95,0x1D99,0x1D9F,0x1DA5,0x1DA7,0x1DB3,0x1DB7,0x1DC5,0x1DD7,0x1DDB,0x1DE1,0x1DF5,0x1DF9,0x1E01,0x1E07,0x1E0B, - 0x1E13,0x1E17,0x1E25,0x1E2B,0x1E2F,0x1E3D,0x1E49,0x1E4D,0x1E4F,0x1E6D,0x1E71,0x1E89,0x1E8F,0x1E95,0x1EA1,0x1EAD, - 0x1EBB,0x1EC1,0x1EC5,0x1EC7,0x1ECB,0x1EDD,0x1EE3,0x1EEF,0x1EF7,0x1EFD,0x1F01,0x1F0D,0x1F0F,0x1F1B,0x1F39,0x1F49, - 0x1F4B,0x1F51,0x1F67,0x1F75,0x1F7B,0x1F85,0x1F91,0x1F97,0x1F99,0x1F9D,0x1FA5,0x1FAF,0x1FB5,0x1FBB,0x1FD3,0x1FE1, - 0x1FE7,0x1FEB,0x1FF3,0x1FFF,0x2011,0x201B,0x201D,0x2027,0x2029,0x202D,0x2033,0x2047,0x204D,0x2051,0x205F,0x2063, - 0x2065,0x2069,0x2077,0x207D,0x2089,0x20A1,0x20AB,0x20B1,0x20B9,0x20C3,0x20C5,0x20E3,0x20E7,0x20ED,0x20EF,0x20FB, - 0x20FF,0x210D,0x2113,0x2135,0x2141,0x2149,0x214F,0x2159,0x215B,0x215F,0x2173,0x217D,0x2185,0x2195,0x2197,0x21A1, - 0x21AF,0x21B3,0x21B5,0x21C1,0x21C7,0x21D7,0x21DD,0x21E5,0x21E9,0x21F1,0x21F5,0x21FB,0x2203,0x2209,0x220F,0x221B, - 0x2221,0x2225,0x222B,0x2231,0x2239,0x224B,0x224F,0x2263,0x2267,0x2273,0x2275,0x227F,0x2285,0x2287,0x2291,0x229D, - 0x229F,0x22A3,0x22B7,0x22BD,0x22DB,0x22E1,0x22E5,0x22ED,0x22F7,0x2303,0x2309,0x230B,0x2327,0x2329,0x232F,0x2333, - 0x2335,0x2345,0x2351,0x2353,0x2359,0x2363,0x236B,0x2383,0x238F,0x2395,0x23A7,0x23AD,0x23B1,0x23BF,0x23C5,0x23C9, - 0x23D5,0x23DD,0x23E3,0x23EF,0x23F3,0x23F9,0x2405,0x240B,0x2417,0x2419,0x2429,0x243D,0x2441,0x2443,0x244D,0x245F, - 0x2467,0x246B,0x2479,0x247D,0x247F,0x2485,0x249B,0x24A1,0x24AF,0x24B5,0x24BB,0x24C5,0x24CB,0x24CD,0x24D7,0x24D9, - 0x24DD,0x24DF,0x24F5,0x24F7,0x24FB,0x2501,0x2507,0x2513,0x2519,0x2527,0x2531,0x253D,0x2543,0x254B,0x254F,0x2573, - 0x2581,0x258D,0x2593,0x2597,0x259D,0x259F,0x25AB,0x25B1,0x25BD,0x25CD,0x25CF,0x25D9,0x25E1,0x25F7,0x25F9,0x2605, - 0x260B,0x260F,0x2615,0x2627,0x2629,0x2635,0x263B,0x263F,0x264B,0x2653,0x2659,0x2665,0x2669,0x266F,0x267B,0x2681, - 0x2683,0x268F,0x269B,0x269F,0x26AD,0x26B3,0x26C3,0x26C9,0x26CB,0x26D5,0x26DD,0x26EF,0x26F5,0x2717,0x2719,0x2735, - 0x2737,0x274D,0x2753,0x2755,0x275F,0x276B,0x276D,0x2773,0x2777,0x277F,0x2795,0x279B,0x279D,0x27A7,0x27AF,0x27B3, - 0x27B9,0x27C1,0x27C5,0x27D1,0x27E3,0x27EF,0x2803,0x2807,0x280D,0x2813,0x281B,0x281F,0x2821,0x2831,0x283D,0x283F, - 0x2849,0x2851,0x285B,0x285D,0x2861,0x2867,0x2875,0x2881,0x2897,0x289F,0x28BB,0x28BD,0x28C1,0x28D5,0x28D9,0x28DB, - 0x28DF,0x28ED,0x28F7,0x2903,0x2905,0x2911,0x2921,0x2923,0x293F,0x2947,0x295D,0x2965,0x2969,0x296F,0x2975,0x2983, - 0x2987,0x298F,0x299B,0x29A1,0x29A7,0x29AB,0x29BF,0x29C3,0x29D5,0x29D7,0x29E3,0x29E9,0x29ED,0x29F3,0x2A01,0x2A13, - 0x2A1D,0x2A25,0x2A2F,0x2A4F,0x2A55,0x2A5F,0x2A65,0x2A6B,0x2A6D,0x2A73,0x2A83,0x2A89,0x2A8B,0x2A97,0x2A9D,0x2AB9, - 0x2ABB,0x2AC5,0x2ACD,0x2ADD,0x2AE3,0x2AEB,0x2AF1,0x2AFB,0x2B13,0x2B27,0x2B31,0x2B33,0x2B3D,0x2B3F,0x2B4B,0x2B4F, - 0x2B55,0x2B69,0x2B6D,0x2B6F,0x2B7B,0x2B8D,0x2B97,0x2B99,0x2BA3,0x2BA5,0x2BA9,0x2BBD,0x2BCD,0x2BE7,0x2BEB,0x2BF3, - 0x2BF9,0x2BFD,0x2C09,0x2C0F,0x2C17,0x2C23,0x2C2F,0x2C35,0x2C39,0x2C41,0x2C57,0x2C59,0x2C69,0x2C77,0x2C81,0x2C87, - 0x2C93,0x2C9F,0x2CAD,0x2CB3,0x2CB7,0x2CCB,0x2CCF,0x2CDB,0x2CE1,0x2CE3,0x2CE9,0x2CEF,0x2CFF,0x2D07,0x2D1D,0x2D1F, - 0x2D3B,0x2D43,0x2D49,0x2D4D,0x2D61,0x2D65,0x2D71,0x2D89,0x2D9D,0x2DA1,0x2DA9,0x2DB3,0x2DB5,0x2DC5,0x2DC7,0x2DD3, - 0x2DDF,0x2E01,0x2E03,0x2E07,0x2E0D,0x2E19,0x2E1F,0x2E25,0x2E2D,0x2E33,0x2E37,0x2E39,0x2E3F,0x2E57,0x2E5B,0x2E6F, - 0x2E79,0x2E7F,0x2E85,0x2E93,0x2E97,0x2E9D,0x2EA3,0x2EA5,0x2EB1,0x2EB7,0x2EC1,0x2EC3,0x2ECD,0x2ED3,0x2EE7,0x2EEB, - 0x2F05,0x2F09,0x2F0B,0x2F11,0x2F27,0x2F29,0x2F41,0x2F45,0x2F4B,0x2F4D,0x2F51,0x2F57,0x2F6F,0x2F75,0x2F7D,0x2F81, - 0x2F83,0x2FA5,0x2FAB,0x2FB3,0x2FC3,0x2FCF,0x2FD1,0x2FDB,0x2FDD,0x2FE7,0x2FED,0x2FF5,0x2FF9,0x3001,0x300D,0x3023, - 0x3029,0x3037,0x303B,0x3055,0x3059,0x305B,0x3067,0x3071,0x3079,0x307D,0x3085,0x3091,0x3095,0x30A3,0x30A9,0x30B9, - 0x30BF,0x30C7,0x30CB,0x30D1,0x30D7,0x30DF,0x30E5,0x30EF,0x30FB,0x30FD,0x3103,0x3109,0x3119,0x3121,0x3127,0x312D, - 0x3139,0x3143,0x3145,0x314B,0x315D,0x3161,0x3167,0x316D,0x3173,0x317F,0x3191,0x3199,0x319F,0x31A9,0x31B1,0x31C3, - 0x31C7,0x31D5,0x31DB,0x31ED,0x31F7,0x31FF,0x3209,0x3215,0x3217,0x321D,0x3229,0x3235,0x3259,0x325D,0x3263,0x326B, - 0x326F,0x3275,0x3277,0x327B,0x328D,0x3299,0x329F,0x32A7,0x32AD,0x32B3,0x32B7,0x32C9,0x32CB,0x32CF,0x32D1,0x32E9, - 0x32ED,0x32F3,0x32F9,0x3307,0x3325,0x332B,0x332F,0x3335,0x3341,0x3347,0x335B,0x335F,0x3367,0x336B,0x3373,0x3379, - 0x337F,0x3383,0x33A1,0x33A3,0x33AD,0x33B9,0x33C1,0x33CB,0x33D3,0x33EB,0x33F1,0x33FD,0x3401,0x340F,0x3413,0x3419, - 0x341B,0x3437,0x3445,0x3455,0x3457,0x3463,0x3469,0x346D,0x3481,0x348B,0x3491,0x3497,0x349D,0x34A5,0x34AF,0x34BB, - 0x34C9,0x34D3,0x34E1,0x34F1,0x34FF,0x3509,0x3517,0x351D,0x352D,0x3533,0x353B,0x3541,0x3551,0x3565,0x356F,0x3571, - 0x3577,0x357B,0x357D,0x3581,0x358D,0x358F,0x3599,0x359B,0x35A1,0x35B7,0x35BD,0x35BF,0x35C3,0x35D5,0x35DD,0x35E7, - 0x35EF,0x3605,0x3607,0x3611,0x3623,0x3631,0x3635,0x3637,0x363B,0x364D,0x364F,0x3653,0x3659,0x3661,0x366B,0x366D, - 0x368B,0x368F,0x36AD,0x36AF,0x36B9,0x36BB,0x36CD,0x36D1,0x36E3,0x36E9,0x36F7,0x3701,0x3703,0x3707,0x371B,0x373F, - 0x3745,0x3749,0x374F,0x375D,0x3761,0x3775,0x377F,0x378D,0x37A3,0x37A9,0x37AB,0x37C9,0x37D5,0x37DF,0x37F1,0x37F3, - 0x37F7,0x3805,0x380B,0x3821,0x3833,0x3835,0x3841,0x3847,0x384B,0x3853,0x3857,0x385F,0x3865,0x386F,0x3871,0x387D, - 0x388F,0x3899,0x38A7,0x38B7,0x38C5,0x38C9,0x38CF,0x38D5,0x38D7,0x38DD,0x38E1,0x38E3,0x38FF,0x3901,0x391D,0x3923, - 0x3925,0x3929,0x392F,0x393D,0x3941,0x394D,0x395B,0x396B,0x3979,0x397D,0x3983,0x398B,0x3991,0x3995,0x399B,0x39A1, - 0x39A7,0x39AF,0x39B3,0x39BB,0x39BF,0x39CD,0x39DD,0x39E5,0x39EB,0x39EF,0x39FB,0x3A03,0x3A13,0x3A15,0x3A1F,0x3A27, - 0x3A2B,0x3A31,0x3A4B,0x3A51,0x3A5B,0x3A63,0x3A67,0x3A6D,0x3A79,0x3A87,0x3AA5,0x3AA9,0x3AB7,0x3ACD,0x3AD5,0x3AE1, - 0x3AE5,0x3AEB,0x3AF3,0x3AFD,0x3B03,0x3B11,0x3B1B,0x3B21,0x3B23,0x3B2D,0x3B39,0x3B45,0x3B53,0x3B59,0x3B5F,0x3B71, - 0x3B7B,0x3B81,0x3B89,0x3B9B,0x3B9F,0x3BA5,0x3BA7,0x3BAD,0x3BB7,0x3BB9,0x3BC3,0x3BCB,0x3BD1,0x3BD7,0x3BE1,0x3BE3, - 0x3BF5,0x3BFF,0x3C01,0x3C0D,0x3C11,0x3C17,0x3C1F,0x3C29,0x3C35,0x3C43,0x3C4F,0x3C53,0x3C5B,0x3C65,0x3C6B,0x3C71, - 0x3C85,0x3C89,0x3C97,0x3CA7,0x3CB5,0x3CBF,0x3CC7,0x3CD1,0x3CDD,0x3CDF,0x3CF1,0x3CF7,0x3D03,0x3D0D,0x3D19,0x3D1B, - 0x3D1F,0x3D21,0x3D2D,0x3D33,0x3D37,0x3D3F,0x3D43,0x3D6F,0x3D73,0x3D75,0x3D79,0x3D7B,0x3D85,0x3D91,0x3D97,0x3D9D, - 0x3DAB,0x3DAF,0x3DB5,0x3DBB,0x3DC1,0x3DC9,0x3DCF,0x3DF3,0x3E05,0x3E09,0x3E0F,0x3E11,0x3E1D,0x3E23,0x3E29,0x3E2F, - 0x3E33,0x3E41,0x3E57,0x3E63,0x3E65,0x3E77,0x3E81,0x3E87,0x3EA1,0x3EB9,0x3EBD,0x3EBF,0x3EC3,0x3EC5,0x3EC9,0x3ED7, - 0x3EDB,0x3EE1,0x3EE7,0x3EEF,0x3EFF,0x3F0B,0x3F0D,0x3F37,0x3F3B,0x3F3D,0x3F41,0x3F59,0x3F5F,0x3F65,0x3F67,0x3F79, - 0x3F7D,0x3F8B,0x3F91,0x3FAD,0x3FBF,0x3FCD,0x3FD3,0x3FDD,0x3FE9,0x3FEB,0x3FF1,0x3FFD,0x401B,0x4021,0x4025,0x402B, - 0x4031,0x403F,0x4043,0x4045,0x405D,0x4061,0x4067,0x406D,0x4087,0x4091,0x40A3,0x40A9,0x40B1,0x40B7,0x40BD,0x40DB, - 0x40DF,0x40EB,0x40F7,0x40F9,0x4109,0x410B,0x4111,0x4115,0x4121,0x4133,0x4135,0x413B,0x413F,0x4159,0x4165,0x416B, - 0x4177,0x417B,0x4193,0x41AB,0x41B7,0x41BD,0x41BF,0x41CB,0x41E7,0x41EF,0x41F3,0x41F9,0x4205,0x4207,0x4219,0x421F, - 0x4223,0x4229,0x422F,0x4243,0x4253,0x4255,0x425B,0x4261,0x4273,0x427D,0x4283,0x4285,0x4289,0x4291,0x4297,0x429D, - 0x42B5,0x42C5,0x42CB,0x42D3,0x42DD,0x42E3,0x42F1,0x4307,0x430F,0x431F,0x4325,0x4327,0x4333,0x4337,0x4339,0x434F, - 0x4357,0x4369,0x438B,0x438D,0x4393,0x43A5,0x43A9,0x43AF,0x43B5,0x43BD,0x43C7,0x43CF,0x43E1,0x43E7,0x43EB,0x43ED, - 0x43F1,0x43F9,0x4409,0x440B,0x4417,0x4423,0x4429,0x443B,0x443F,0x4445,0x444B,0x4451,0x4453,0x4459,0x4465,0x446F, - 0x4483,0x448F,0x44A1,0x44A5,0x44AB,0x44AD,0x44BD,0x44BF,0x44C9,0x44D7,0x44DB,0x44F9,0x44FB,0x4505,0x4511,0x4513, - 0x452B,0x4531,0x4541,0x4549,0x4553,0x4555,0x4561,0x4577,0x457D,0x457F,0x458F,0x45A3,0x45AD,0x45AF,0x45BB,0x45C7, - 0x45D9,0x45E3,0x45EF,0x45F5,0x45F7,0x4601,0x4603,0x4609,0x4613,0x4625,0x4627,0x4633,0x4639,0x463D,0x4643,0x4645, - 0x465D,0x4679,0x467B,0x467F,0x4681,0x468B,0x468D,0x469D,0x46A9,0x46B1,0x46C7,0x46C9,0x46CF,0x46D3,0x46D5,0x46DF, - 0x46E5,0x46F9,0x4705,0x470F,0x4717,0x4723,0x4729,0x472F,0x4735,0x4739,0x474B,0x474D,0x4751,0x475D,0x476F,0x4771, - 0x477D,0x4783,0x4787,0x4789,0x4799,0x47A5,0x47B1,0x47BF,0x47C3,0x47CB,0x47DD,0x47E1,0x47ED,0x47FB,0x4801,0x4807, - 0x480B,0x4813,0x4819,0x481D,0x4831,0x483D,0x4847,0x4855,0x4859,0x485B,0x486B,0x486D,0x4879,0x4897,0x489B,0x48A1, - 0x48B9,0x48CD,0x48E5,0x48EF,0x48F7,0x4903,0x490D,0x4919,0x491F,0x492B,0x4937,0x493D,0x4945,0x4955,0x4963,0x4969, - 0x496D,0x4973,0x4997,0x49AB,0x49B5,0x49D3,0x49DF,0x49E1,0x49E5,0x49E7,0x4A03,0x4A0F,0x4A1D,0x4A23,0x4A39,0x4A41, - 0x4A45,0x4A57,0x4A5D,0x4A6B,0x4A7D,0x4A81,0x4A87,0x4A89,0x4A8F,0x4AB1,0x4AC3,0x4AC5,0x4AD5,0x4ADB,0x4AED,0x4AEF, - 0x4B07,0x4B0B,0x4B0D,0x4B13,0x4B1F,0x4B25,0x4B31,0x4B3B,0x4B43,0x4B49,0x4B59,0x4B65,0x4B6D,0x4B77,0x4B85,0x4BAD, - 0x4BB3,0x4BB5,0x4BBB,0x4BBF,0x4BCB,0x4BD9,0x4BDD,0x4BDF,0x4BE3,0x4BE5,0x4BE9,0x4BF1,0x4BF7,0x4C01,0x4C07,0x4C0D, - 0x4C0F,0x4C15,0x4C1B,0x4C21,0x4C2D,0x4C33,0x4C4B,0x4C55,0x4C57,0x4C61,0x4C67,0x4C73,0x4C79,0x4C7F,0x4C8D,0x4C93, - 0x4C99,0x4CCD,0x4CE1,0x4CE7,0x4CF1,0x4CF3,0x4CFD,0x4D05,0x4D0F,0x4D1B,0x4D27,0x4D29,0x4D2F,0x4D33,0x4D41,0x4D51, - 0x4D59,0x4D65,0x4D6B,0x4D81,0x4D83,0x4D8D,0x4D95,0x4D9B,0x4DB1,0x4DB3,0x4DC9,0x4DCF,0x4DD7,0x4DE1,0x4DED,0x4DF9, - 0x4DFB,0x4E05,0x4E0B,0x4E17,0x4E19,0x4E1D,0x4E2B,0x4E35,0x4E37,0x4E3D,0x4E4F,0x4E53,0x4E5F,0x4E67,0x4E79,0x4E85, - 0x4E8B,0x4E91,0x4E95,0x4E9B,0x4EA1,0x4EAF,0x4EB3,0x4EB5,0x4EC1,0x4ECD,0x4ED1,0x4ED7,0x4EE9,0x4EFB,0x4F07,0x4F09, - 0x4F19,0x4F25,0x4F2D,0x4F3F,0x4F49,0x4F63,0x4F67,0x4F6D,0x4F75,0x4F7B,0x4F81,0x4F85,0x4F87,0x4F91,0x4FA5,0x4FA9, - 0x4FAF,0x4FB7,0x4FBB,0x4FCF,0x4FD9,0x4FDB,0x4FFD,0x4FFF,0x5003,0x501B,0x501D,0x5029,0x5035,0x503F,0x5045,0x5047, - 0x5053,0x5071,0x5077,0x5083,0x5093,0x509F,0x50A1,0x50B7,0x50C9,0x50D5,0x50E3,0x50ED,0x50EF,0x50FB,0x5107,0x510B, - 0x510D,0x5111,0x5117,0x5123,0x5125,0x5135,0x5147,0x5149,0x5171,0x5179,0x5189,0x518F,0x5197,0x51A1,0x51A3,0x51A7, - 0x51B9,0x51C1,0x51CB,0x51D3,0x51DF,0x51E3,0x51F5,0x51F7,0x5209,0x5213,0x5215,0x5219,0x521B,0x521F,0x5227,0x5243, - 0x5245,0x524B,0x5261,0x526D,0x5273,0x5281,0x5293,0x5297,0x529D,0x52A5,0x52AB,0x52B1,0x52BB,0x52C3,0x52C7,0x52C9, - 0x52DB,0x52E5,0x52EB,0x52FF,0x5315,0x531D,0x5323,0x5341,0x5345,0x5347,0x534B,0x535D,0x5363,0x5381,0x5383,0x5387, - 0x538F,0x5395,0x5399,0x539F,0x53AB,0x53B9,0x53DB,0x53E9,0x53EF,0x53F3,0x53F5,0x53FB,0x53FF,0x540D,0x5411,0x5413, - 0x5419,0x5435,0x5437,0x543B,0x5441,0x5449,0x5453,0x5455,0x545F,0x5461,0x546B,0x546D,0x5471,0x548F,0x5491,0x549D, - 0x54A9,0x54B3,0x54C5,0x54D1,0x54DF,0x54E9,0x54EB,0x54F7,0x54FD,0x5507,0x550D,0x551B,0x5527,0x552B,0x5539,0x553D, - 0x554F,0x5551,0x555B,0x5563,0x5567,0x556F,0x5579,0x5585,0x5597,0x55A9,0x55B1,0x55B7,0x55C9,0x55D9,0x55E7,0x55ED, - 0x55F3,0x55FD,0x560B,0x560F,0x5615,0x5617,0x5623,0x562F,0x5633,0x5639,0x563F,0x564B,0x564D,0x565D,0x565F,0x566B, - 0x5671,0x5675,0x5683,0x5689,0x568D,0x568F,0x569B,0x56AD,0x56B1,0x56D5,0x56E7,0x56F3,0x56FF,0x5701,0x5705,0x5707, - 0x570B,0x5713,0x571F,0x5723,0x5747,0x574D,0x575F,0x5761,0x576D,0x5777,0x577D,0x5789,0x57A1,0x57A9,0x57AF,0x57B5, - 0x57C5,0x57D1,0x57D3,0x57E5,0x57EF,0x5803,0x580D,0x580F,0x5815,0x5827,0x582B,0x582D,0x5855,0x585B,0x585D,0x586D, - 0x586F,0x5873,0x587B,0x588D,0x5897,0x58A3,0x58A9,0x58AB,0x58B5,0x58BD,0x58C1,0x58C7,0x58D3,0x58D5,0x58DF,0x58F1, - 0x58F9,0x58FF,0x5903,0x5917,0x591B,0x5921,0x5945,0x594B,0x594D,0x5957,0x595D,0x5975,0x597B,0x5989,0x5999,0x599F, - 0x59B1,0x59B3,0x59BD,0x59D1,0x59DB,0x59E3,0x59E9,0x59ED,0x59F3,0x59F5,0x59FF,0x5A01,0x5A0D,0x5A11,0x5A13,0x5A17, - 0x5A1F,0x5A29,0x5A2F,0x5A3B,0x5A4D,0x5A5B,0x5A67,0x5A77,0x5A7F,0x5A85,0x5A95,0x5A9D,0x5AA1,0x5AA3,0x5AA9,0x5ABB, - 0x5AD3,0x5AE5,0x5AEF,0x5AFB,0x5AFD,0x5B01,0x5B0F,0x5B19,0x5B1F,0x5B25,0x5B2B,0x5B3D,0x5B49,0x5B4B,0x5B67,0x5B79, - 0x5B87,0x5B97,0x5BA3,0x5BB1,0x5BC9,0x5BD5,0x5BEB,0x5BF1,0x5BF3,0x5BFD,0x5C05,0x5C09,0x5C0B,0x5C0F,0x5C1D,0x5C29, - 0x5C2F,0x5C33,0x5C39,0x5C47,0x5C4B,0x5C4D,0x5C51,0x5C6F,0x5C75,0x5C77,0x5C7D,0x5C87,0x5C89,0x5CA7,0x5CBD,0x5CBF, - 0x5CC3,0x5CC9,0x5CD1,0x5CD7,0x5CDD,0x5CED,0x5CF9,0x5D05,0x5D0B,0x5D13,0x5D17,0x5D19,0x5D31,0x5D3D,0x5D41,0x5D47, - 0x5D4F,0x5D55,0x5D5B,0x5D65,0x5D67,0x5D6D,0x5D79,0x5D95,0x5DA3,0x5DA9,0x5DAD,0x5DB9,0x5DC1,0x5DC7,0x5DD3,0x5DD7, - 0x5DDD,0x5DEB,0x5DF1,0x5DFD,0x5E07,0x5E0D,0x5E13,0x5E1B,0x5E21,0x5E27,0x5E2B,0x5E2D,0x5E31,0x5E39,0x5E45,0x5E49, - 0x5E57,0x5E69,0x5E73,0x5E75,0x5E85,0x5E8B,0x5E9F,0x5EA5,0x5EAF,0x5EB7,0x5EBB,0x5ED9,0x5EFD,0x5F09,0x5F11,0x5F27, - 0x5F33,0x5F35,0x5F3B,0x5F47,0x5F57,0x5F5D,0x5F63,0x5F65,0x5F77,0x5F7B,0x5F95,0x5F99,0x5FA1,0x5FB3,0x5FBD,0x5FC5, - 0x5FCF,0x5FD5,0x5FE3,0x5FE7,0x5FFB,0x6011,0x6023,0x602F,0x6037,0x6053,0x605F,0x6065,0x606B,0x6073,0x6079,0x6085, - 0x609D,0x60AD,0x60BB,0x60BF,0x60CD,0x60D9,0x60DF,0x60E9,0x60F5,0x6109,0x610F,0x6113,0x611B,0x612D,0x6139,0x614B, - 0x6155,0x6157,0x615B,0x616F,0x6179,0x6187,0x618B,0x6191,0x6193,0x619D,0x61B5,0x61C7,0x61C9,0x61CD,0x61E1,0x61F1, - 0x61FF,0x6209,0x6217,0x621D,0x6221,0x6227,0x623B,0x6241,0x624B,0x6251,0x6253,0x625F,0x6265,0x6283,0x628D,0x6295, - 0x629B,0x629F,0x62A5,0x62AD,0x62D5,0x62D7,0x62DB,0x62DD,0x62E9,0x62FB,0x62FF,0x6305,0x630D,0x6317,0x631D,0x632F, - 0x6341,0x6343,0x634F,0x635F,0x6367,0x636D,0x6371,0x6377,0x637D,0x637F,0x63B3,0x63C1,0x63C5,0x63D9,0x63E9,0x63EB, - 0x63EF,0x63F5,0x6401,0x6403,0x6409,0x6415,0x6421,0x6427,0x642B,0x6439,0x6443,0x6449,0x644F,0x645D,0x6467,0x6475, - 0x6485,0x648D,0x6493,0x649F,0x64A3,0x64AB,0x64C1,0x64C7,0x64C9,0x64DB,0x64F1,0x64F7,0x64F9,0x650B,0x6511,0x6521, - 0x652F,0x6539,0x653F,0x654B,0x654D,0x6553,0x6557,0x655F,0x6571,0x657D,0x658D,0x658F,0x6593,0x65A1,0x65A5,0x65AD, - 0x65B9,0x65C5,0x65E3,0x65F3,0x65FB,0x65FF,0x6601,0x6607,0x661D,0x6629,0x6631,0x663B,0x6641,0x6647,0x664D,0x665B, - 0x6661,0x6673,0x667D,0x6689,0x668B,0x6695,0x6697,0x669B,0x66B5,0x66B9,0x66C5,0x66CD,0x66D1,0x66E3,0x66EB,0x66F5, - 0x6703,0x6713,0x6719,0x671F,0x6727,0x6731,0x6737,0x673F,0x6745,0x6751,0x675B,0x676F,0x6779,0x6781,0x6785,0x6791, - 0x67AB,0x67BD,0x67C1,0x67CD,0x67DF,0x67E5,0x6803,0x6809,0x6811,0x6817,0x682D,0x6839,0x683B,0x683F,0x6845,0x684B, - 0x684D,0x6857,0x6859,0x685D,0x6863,0x6869,0x686B,0x6871,0x6887,0x6899,0x689F,0x68B1,0x68BD,0x68C5,0x68D1,0x68D7, - 0x68E1,0x68ED,0x68EF,0x68FF,0x6901,0x690B,0x690D,0x6917,0x6929,0x692F,0x6943,0x6947,0x6949,0x694F,0x6965,0x696B, - 0x6971,0x6983,0x6989,0x6997,0x69A3,0x69B3,0x69B5,0x69BB,0x69C1,0x69C5,0x69D3,0x69DF,0x69E3,0x69E5,0x69F7,0x6A07, - 0x6A2B,0x6A37,0x6A3D,0x6A4B,0x6A67,0x6A69,0x6A75,0x6A7B,0x6A87,0x6A8D,0x6A91,0x6A93,0x6AA3,0x6AC1,0x6AC9,0x6AE1, - 0x6AE7,0x6B05,0x6B0F,0x6B11,0x6B23,0x6B27,0x6B2D,0x6B39,0x6B41,0x6B57,0x6B59,0x6B5F,0x6B75,0x6B87,0x6B89,0x6B93, - 0x6B95,0x6B9F,0x6BBD,0x6BBF,0x6BDB,0x6BE1,0x6BEF,0x6BFF,0x6C05,0x6C19,0x6C29,0x6C2B,0x6C31,0x6C35,0x6C55,0x6C59, - 0x6C5B,0x6C5F,0x6C65,0x6C67,0x6C73,0x6C77,0x6C7D,0x6C83,0x6C8F,0x6C91,0x6C97,0x6C9B,0x6CA1,0x6CA9,0x6CAF,0x6CB3, - 0x6CC7,0x6CCB,0x6CEB,0x6CF5,0x6CFD,0x6D0D,0x6D0F,0x6D25,0x6D27,0x6D2B,0x6D31,0x6D39,0x6D3F,0x6D4F,0x6D5D,0x6D61, - 0x6D73,0x6D7B,0x6D7F,0x6D93,0x6D99,0x6DA5,0x6DB1,0x6DB7,0x6DC1,0x6DC3,0x6DCD,0x6DCF,0x6DDB,0x6DF7,0x6E03,0x6E15, - 0x6E17,0x6E29,0x6E33,0x6E3B,0x6E45,0x6E75,0x6E77,0x6E7B,0x6E81,0x6E89,0x6E93,0x6E95,0x6E9F,0x6EBD,0x6EBF,0x6EE3, - 0x6EE9,0x6EF3,0x6EF9,0x6EFB,0x6F0D,0x6F11,0x6F17,0x6F1F,0x6F2F,0x6F3D,0x6F4D,0x6F53,0x6F61,0x6F65,0x6F79,0x6F7D, - 0x6F83,0x6F85,0x6F8F,0x6F9B,0x6F9D,0x6FA3,0x6FAF,0x6FB5,0x6FBB,0x6FBF,0x6FCB,0x6FCD,0x6FD3,0x6FD7,0x6FE3,0x6FE9, - 0x6FF1,0x6FF5,0x6FF7,0x6FFD,0x700F,0x7019,0x701F,0x7027,0x7033,0x7039,0x704F,0x7051,0x7057,0x7063,0x7075,0x7079, - 0x7087,0x708D,0x7091,0x70A5,0x70AB,0x70BB,0x70C3,0x70C7,0x70CF,0x70E5,0x70ED,0x70F9,0x70FF,0x7105,0x7115,0x7121, - 0x7133,0x7151,0x7159,0x715D,0x715F,0x7163,0x7169,0x7183,0x7187,0x7195,0x71AD,0x71C3,0x71C9,0x71CB,0x71D1,0x71DB, - 0x71E1,0x71EF,0x71F5,0x71FB,0x7207,0x7211,0x7217,0x7219,0x7225,0x722F,0x723B,0x7243,0x7255,0x7267,0x7271,0x7277, - 0x727F,0x728F,0x7295,0x729B,0x72A3,0x72B3,0x72C7,0x72CB,0x72CD,0x72D7,0x72D9,0x72E3,0x72EF,0x72F5,0x72FD,0x7303, - 0x730D,0x7321,0x732B,0x733D,0x7357,0x735B,0x7361,0x737F,0x7381,0x7385,0x738D,0x7393,0x739F,0x73AB,0x73BD,0x73C1, - 0x73C9,0x73DF,0x73E5,0x73E7,0x73F3,0x7415,0x741B,0x742D,0x7439,0x743F,0x7441,0x745D,0x746B,0x747B,0x7489,0x748D, - 0x749B,0x74A7,0x74AB,0x74B1,0x74B7,0x74B9,0x74DD,0x74E1,0x74E7,0x74FB,0x7507,0x751F,0x7525,0x753B,0x753D,0x754D, - 0x755F,0x756B,0x7577,0x7589,0x758B,0x7591,0x7597,0x759D,0x75A1,0x75A7,0x75B5,0x75B9,0x75BB,0x75D1,0x75D9,0x75E5, - 0x75EB,0x75F5,0x75FB,0x7603,0x760F,0x7621,0x762D,0x7633,0x763D,0x763F,0x7655,0x7663,0x7669,0x766F,0x7673,0x7685, - 0x768B,0x769F,0x76B5,0x76B7,0x76C3,0x76DB,0x76DF,0x76F1,0x7703,0x7705,0x771B,0x771D,0x7721,0x772D,0x7735,0x7741, - 0x774B,0x7759,0x775D,0x775F,0x7771,0x7781,0x77A7,0x77AD,0x77B3,0x77B9,0x77C5,0x77CF,0x77D5,0x77E1,0x77E9,0x77EF, - 0x77F3,0x77F9,0x7807,0x7825,0x782B,0x7835,0x783D,0x7853,0x7859,0x7861,0x786D,0x7877,0x7879,0x7883,0x7885,0x788B, - 0x7895,0x7897,0x78A1,0x78AD,0x78BF,0x78D3,0x78D9,0x78DD,0x78E5,0x78FB,0x7901,0x7907,0x7925,0x792B,0x7939,0x793F, - 0x794B,0x7957,0x795D,0x7967,0x7969,0x7973,0x7991,0x7993,0x79A3,0x79AB,0x79AF,0x79B1,0x79B7,0x79C9,0x79CD,0x79CF, - 0x79D5,0x79D9,0x79F3,0x79F7,0x79FF,0x7A05,0x7A0F,0x7A11,0x7A15,0x7A1B,0x7A23,0x7A27,0x7A2D,0x7A4B,0x7A57,0x7A59, - 0x7A5F,0x7A65,0x7A69,0x7A7D,0x7A93,0x7A9B,0x7A9F,0x7AA1,0x7AA5,0x7AED,0x7AF5,0x7AF9,0x7B01,0x7B17,0x7B19,0x7B1D, - 0x7B2B,0x7B35,0x7B37,0x7B3B,0x7B4F,0x7B55,0x7B5F,0x7B71,0x7B77,0x7B8B,0x7B9B,0x7BA1,0x7BA9,0x7BAF,0x7BB3,0x7BC7, - 0x7BD3,0x7BE9,0x7BEB,0x7BEF,0x7BF1,0x7BFD,0x7C07,0x7C19,0x7C1B,0x7C31,0x7C37,0x7C49,0x7C67,0x7C69,0x7C73,0x7C81, - 0x7C8B,0x7C93,0x7CA3,0x7CD5,0x7CDB,0x7CE5,0x7CED,0x7CF7,0x7D03,0x7D09,0x7D1B,0x7D1D,0x7D33,0x7D39,0x7D3B,0x7D3F, - 0x7D45,0x7D4D,0x7D53,0x7D59,0x7D63,0x7D75,0x7D77,0x7D8D,0x7D8F,0x7D9F,0x7DAD,0x7DB7,0x7DBD,0x7DBF,0x7DCB,0x7DD5, - 0x7DE9,0x7DED,0x7DFB,0x7E01,0x7E05,0x7E29,0x7E2B,0x7E2F,0x7E35,0x7E41,0x7E43,0x7E47,0x7E55,0x7E61,0x7E67,0x7E6B, - 0x7E71,0x7E73,0x7E79,0x7E7D,0x7E91,0x7E9B,0x7E9D,0x7EA7,0x7EAD,0x7EB9,0x7EBB,0x7ED3,0x7EDF,0x7EEB,0x7EF1,0x7EF7, - 0x7EFB,0x7F13,0x7F15,0x7F19,0x7F31,0x7F33,0x7F39,0x7F3D,0x7F43,0x7F4B,0x7F5B,0x7F61,0x7F63,0x7F6D,0x7F79,0x7F87, - 0x7F8D,0x7FAF,0x7FB5,0x7FC3,0x7FC9,0x7FCD,0x7FCF -}; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp deleted file mode 100644 index 948807b5655..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/msgloop.cpp $* - * * - * $Author:: Steve_t $* - * * - * $Modtime:: 2/05/02 1:17p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Add_Accelerator -- Adds a keyboard accelerator to the message handler. * - * Add_Modeless_Dialog -- Adds a modeless dialog box to the message handler. * - * Remove_Accelerator -- Removes an accelerator from the message processor. * - * Remove_Modeless_Dialog -- Removes the dialog box from the message tracking handler. * - * Windows_Message_Handler -- Handles windows message. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "Vector.H" -#include "win.h" - - -/* -** Tracks modeless dialog box messages by keeping a record of all active modeless dialog -** box handles and then determining if the windows message applies to the dialog box. If it -** does, then the default message handling should not be performed. -*/ -static DynamicVectorClass _ModelessDialogs; - - -/* -** Tracks windows accelerators with this structure. -*/ -struct AcceleratorTracker { - AcceleratorTracker(HWND window = NULL, HACCEL accelerator = NULL) : Accelerator(accelerator), Window(window) {} - - int operator == (AcceleratorTracker const & acc) const {return(Accelerator == acc.Accelerator && Window == acc.Window);} - int operator != (AcceleratorTracker const & acc) const {return(!(*this == acc));} - - HACCEL Accelerator; - HWND Window; -}; -static DynamicVectorClass _Accelerators; - - -/* -** In those cases where message intercept needs to occur but not for purposes -** of a modeless dialog box or a windows accelerator, then this is a function -** pointer to than message intercept handler. -*/ -bool (*Message_Intercept_Handler)(MSG &msg) = NULL; - - -/*********************************************************************************************** - * Windows_Message_Handler -- Handles windows message. * - * * - * This routine will take all messages that have accumulated in the message queue and * - * dispatch them to their respective recipients. When the message queue has been emptied, * - * then this routine will return. By using this routine, it is possible to have the main * - * program run in the main thread and yet still have it behave like a normal program as * - * far as message handling is concerned. To achieve this, this routine must be called on * - * a semi-frequent basis (a few times a second is plenty). * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Windows_Message_Handler(void) -{ - MSG msg; - - /* - ** Process windows messages until the message queue is exhuasted. - */ - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if (!GetMessage( &msg, NULL, 0, 0 )) { - return; - } - - /* - ** Pass the message through any loaded accelerators. If the message - ** was processed by an accelerator, then it doesn't need to be - ** processed by the normal message handling procedure. - */ - bool processed = false; - for (int aindex = 0; aindex < _Accelerators.Count(); aindex++) { - if (_Accelerators[aindex].Window) { - if (TranslateAccelerator(_Accelerators[aindex].Window, _Accelerators[aindex].Accelerator, &msg)) { - processed = true; - } - } - break; - } - if (processed) continue; - - /* - ** Pass the windows message through any modeless dialogs that may - ** be active. If one of the dialogs processes the message, then - ** it must not be processed by the normal window message handler. - */ - for (int index = 0; index < _ModelessDialogs.Count(); index++) { - if (IsDialogMessage(_ModelessDialogs[index], &msg)) { - processed = true; - break; - } - } - if (processed) continue; - - /* - ** If the message was not handled by any normal intercept handlers, then - ** submit the message to a custom message handler if one has been provided. - */ - if (Message_Intercept_Handler != NULL) { - processed = Message_Intercept_Handler(msg); - } - if (processed) continue; - - /* - ** If the message makes it to this point, then it must be a normal message. Process - ** it in the normal fashion. The message will appear in the window message handler - ** for the window that it was directed to. - */ - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - - -/*********************************************************************************************** - * Add_Modeless_Dialog -- Adds a modeless dialog box to the message handler. * - * * - * When a modeless dialog box becomes active, the messages processed by the main message * - * handler must be handled different. This routine is used to inform the message handler * - * that a dialog box is active and messages must be fed to it as appropriate. * - * * - * INPUT: dialog -- Handle to the modeless dialog box. * - * * - * OUTPUT: none * - * * - * WARNINGS: The modeless dialog box must be removed from the tracking system by calling * - * Remove_Modeless_Dialog. Failure to do so when the dialog is destroyed will * - * result in undefined behavior. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Add_Modeless_Dialog(HWND dialog) -{ - _ModelessDialogs.Add(dialog); -} - - -/*********************************************************************************************** - * Remove_Modeless_Dialog -- Removes the dialog box from the message tracking handler. * - * * - * This routine must be called when a modeless dialog is being removed. * - * * - * INPUT: dialog -- Handle to the modeless dialog that was previously submitted to * - * Add_Modeless_Dialog(). * - * * - * OUTPUT: none * - * * - * WARNINGS: Failure to call this routine will result in undefined behavior when the dialog * - * is destroyed. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Remove_Modeless_Dialog(HWND dialog) -{ - _ModelessDialogs.Delete(dialog); -} - - -/*********************************************************************************************** - * Add_Accelerator -- Adds a keyboard accelerator to the message handler. * - * * - * This routine will add a keyboard accelerator to the tracking process for the message * - * handler. If the incoming message is processed by an accelerator, then the normal * - * processing must be altered. By using this routine, the proper behavior of accelerators * - * is maintained. * - * * - * INPUT: window -- The window that the accelerator belongs to. Each accelerator must be * - * assigned to a window. * - * * - * accelerator -- The handler to the windows accelerator. * - * * - * OUTPUT: none * - * * - * WARNINGS: When the accelerator is no longer valid (or the controlling window as been * - * destroyed), the Remove_Accelerator function must be called. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Add_Accelerator(HWND window, HACCEL accelerator) -{ - _Accelerators.Add(AcceleratorTracker(window, accelerator)); -} - - -/*********************************************************************************************** - * Remove_Accelerator -- Removes an accelerator from the message processor. * - * * - * This routine must be called when the accelerator or the window it was attached to has * - * been destroyed. * - * * - * INPUT: accelerator -- The accelerator to remove from the tracking system. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine presumes that the accelerator will not be shared between windows. * - * * - * HISTORY: * - * 05/17/1997 JLB : Created. * - *=============================================================================================*/ -void Remove_Accelerator(HACCEL accelerator) -{ - for (int index = 0; index < _Accelerators.Count(); index++) { - if (_Accelerators[index].Accelerator == accelerator) { - _Accelerators.Delete(index); - break; - } - } -} \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.h deleted file mode 100644 index 1afc62782b7..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/msgloop.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/msgloop.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 11:59a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef MSGLOOP_H -#define MSGLOOP_H - -#include - -// Main message handler. -void Windows_Message_Handler(void); - -// Modeless dialog box support routines. -void Remove_Modeless_Dialog(HWND dialog); -void Add_Modeless_Dialog(HWND dialog); - -// Accelerator keys support routines. -void Add_Accelerator(HWND window, HACCEL accelerator); -void Remove_Accelerator(HACCEL accelerator); - -// General purpose message intercept handler. -extern bool (*Message_Intercept_Handler)(MSG &msg); - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.cpp deleted file mode 100644 index a4a53119357..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Obscure.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Obfuscate -- Sufficiently transform parameter to thwart casual hackers. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "CRC.H" -#include "obscure.h" -#include -#include - -/*********************************************************************************************** - * Obfuscate -- Sufficiently transform parameter to thwart casual hackers. * - * * - * This routine borrows from CRC and PGP technology to sufficiently alter the parameter * - * in order to make it difficult to reverse engineer the key phrase. This is designed to * - * be used for hidden game options that will be released at a later time over Westwood's * - * Web page or through magazine hint articles. * - * * - * This algorithm is cryptographically categorized as a "one way hash". * - * * - * Since this is a one way transformation, it becomes much more difficult to reverse * - * engineer the pass phrase even if the resultant pass code is known. This has an added * - * benefit of making this algorithm immune to traditional cryptographic attacks. * - * * - * The largest strength of this transformation algorithm lies in the restriction on the * - * source vector being legal ASCII uppercase characters. This restriction alone makes even * - * a simple CRC transformation practically impossible to reverse engineer. This algorithm * - * uses far more than a simple CRC transformation to achieve added strength from advanced * - * attack methods. * - * * - * INPUT: string -- Pointer to the key phrase that will be transformed into a code. * - * * - * OUTPUT: Returns with the code that the key phrase is translated into. * - * * - * WARNINGS: A zero length pass phrase results in a 0x00000000 result code. * - * * - * HISTORY: * - * 08/19/1995 JLB : Created. * - *=============================================================================================*/ -long Obfuscate(char const * string) -{ - char buffer[128]; - - if (!string) return(0); - memset(buffer, '\xA5', sizeof(buffer)); - - /* - ** Copy key phrase into a working buffer. This hides any transformation done - ** to the string. - */ - strncpy(buffer, string, sizeof(buffer)); - buffer[sizeof(buffer)-1] = '\0'; - int length = strlen(buffer); - - /* - ** Only upper case letters are significant. - */ - strupr(buffer); - - /* - ** Ensure that only visible ASCII characters compose the key phrase. This - ** discourages the direct forced illegal character input method of attack. - */ - for (int index = 0; index < length; index++) { - if (!isgraph(buffer[index])) { - buffer[index] = (char)('A' + (index%26)); - } - } - - /* - ** Increase the strength of even short pass phrases by extending the - ** length to be at least a minimum number of characters. This helps prevent - ** a weak pass phrase from compromising the obfuscation process. This - ** process also forces the key phrase to be an even multiple of four. - ** This is necessary to support the cypher process that occurs later. - */ - if (length < 16 || (length & 0x03)) { - int maxlen = 16; - if (((length+3) & 0x00FC) > maxlen) { - maxlen = ((length+3) & 0x00FC); - } - int index; - for (index = length; index < maxlen; index++) { - buffer[index] = (char)('A' + ((('?' ^ buffer[index-length]) + index) % 26)); - } - length = index; - buffer[length] = '\0'; - } - - /* - ** Transform the buffer into a number. This transformation is character - ** order dependant. - */ - long code = CRCEngine()(buffer, length); - - /* - ** Record a copy of this initial transformation to be used in a later - ** self referential transformation. - */ - long copy = code; - - /* - ** Reverse the character string and combine with the previous transformation. - ** This doubles the workload of trying to reverse engineer the CRC calculation. - */ - strrev(buffer); - code ^= CRCEngine()(buffer, length); - - /* - ** Perform a self referential transformation. This makes a reverse engineering - ** by using a cause and effect attack more difficult. - */ - code = code ^ copy; - - /* - ** Unroll and combine the code value into the pass phrase and then perform - ** another self referential transformation. Although this is a trivial cypher - ** process, it gives the sophisticated hacker false hope since the strong - ** cypher process occurs later. - */ - strrev(buffer); // Restore original string order. - for (int index2 = 0; index2 < length; index2++) { - code ^= (unsigned char)buffer[index2]; - unsigned char temp = (unsigned char)code; - buffer[index2] ^= temp; - code >>= 8; - code |= (((long)temp)<<24); - } - - /* - ** Introduce loss into the vector. This strengthens the key against traditional - ** cryptographic attack engines. Since this also weakens the key against - ** unconventional attacks, the loss is limited to less than 10%. - */ - for (int index3 = 0; index3 < length; index3++) { - static unsigned char _lossbits[] = {0x00,0x08,0x00,0x20,0x00,0x04,0x10,0x00}; - static unsigned char _addbits[] = {0x10,0x00,0x00,0x80,0x40,0x00,0x00,0x04}; - - buffer[index3] |= _addbits[index3 % (sizeof(_addbits)/sizeof(_addbits[0]))]; - buffer[index3] &= (char)(~_lossbits[index3 % (sizeof(_lossbits)/sizeof(_lossbits[0]))]); - } - - /* - ** Perform a general cypher transformation on the vector - ** and use the vector itself as the cypher key. This is a variation on the - ** cypher process used in PGP. It is a very strong cypher process with no known - ** weaknesses. However, in this case, the cypher key is the vector itself and this - ** opens up a weakness against attacks that have access to this transformation - ** algorithm. The sheer workload of reversing this transformation should be enough - ** to discourage even the most determined hackers. - */ - for (int index4 = 0; index4 < length; index4 += 4) { - short key1 = buffer[index4]; - short key2 = buffer[index4+1]; - short key3 = buffer[index4+2]; - short key4 = buffer[index4+3]; - short val1 = key1; - short val2 = key2; - short val3 = key3; - short val4 = key4; - - val1 *= key1; - val2 += key2; - val3 += key3; - val4 *= key4; - - short s3 = val3; - val3 ^= val1; - val3 *= key1; - short s2 = val2; - val2 ^= val4; - val2 += val3; - val2 *= key3; - val3 += val2; - - val1 ^= val2; - val4 ^= val3; - - val2 ^= s3; - val3 ^= s2; - - buffer[index4] = val1; - buffer[index4+1] = val2; - buffer[index4+2] = val3; - buffer[index4+3] = val4; - } - - /* - ** Convert this final vector into a cypher key code to be - ** returned by this routine. - */ - code = CRCEngine()(buffer, length); - - /* - ** Return the final code value. - */ - return(code); -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.h deleted file mode 100644 index cb4c6c0ff09..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/obscure.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Obscure.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef OBSCURE_H -#define OBSCURE_H - -long Obfuscate(char const * string); - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/palette.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/palette.cpp deleted file mode 100644 index 12cbd1e0b29..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/palette.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PALETTE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * PaletteClass::operator = -- Assignment operator for palette objects. * - * PaletteClass::operator == -- Equality operator for palette objects. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "PALETTE.H" -#include - - -/*********************************************************************************************** - * PaletteClass::PaletteClass -- Constructor that fills palette with color specified. * - * * - * This constructor will fill the palette with the color specified. * - * * - * INPUT: rgb -- Reference to the color to fill the entire palette with. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass::PaletteClass(RGBClass const & rgb) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index] = rgb; - } -} - -PaletteClass::PaletteClass(unsigned char *binary_palette) -{ - memcpy(&Palette[0], binary_palette, sizeof(Palette)); -} - -/*********************************************************************************************** - * PaletteClass::operator == -- Equality operator for palette objects. * - * * - * This is the comparison for equality operator. It will compare palette objects to * - * determine if they are identical. * - * * - * INPUT: palette -- Reference to the palette to compare to this palette. * - * * - * OUTPUT: Are the two palettes identical? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::operator == (PaletteClass const & palette) const -{ - if (this == &palette) return(true); - return(memcmp(&Palette[0], &palette.Palette[0], sizeof(Palette)) == 0); -} - - -/*********************************************************************************************** - * PaletteClass::operator = -- Assignment operator for palette objects. * - * * - * This is the assignment operator for palette objects. Although the default C++ generated * - * assignment operator would function correctly, it would not check for self-assignment * - * and thus this routine can be faster. * - * * - * INPUT: palette -- Reference to that palette that will be copied into this palette. * - * * - * OUTPUT: Returns with a reference to the newly copied to palette. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -PaletteClass & PaletteClass::operator = (PaletteClass const & palette) -{ - if (this == &palette) return(*this); - - memcpy(&Palette[0], &palette.Palette[0], sizeof(Palette)); - return(*this); -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, BlackColor); - } -} - - -/*********************************************************************************************** - * PaletteClass::Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Adjust(int ratio, PaletteClass const & palette) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - Palette[index].Adjust(ratio, palette[index]); - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the specified parts of this palette toward black. * - * * - * This routine is used to adjust this palette toward black. Typical use of this routine * - * is when fading the palette to black. The input lookup table is used to determine * - * which entries should fade and which should stay the same * - * * - * INPUT: ratio -- The ratio to fade this palette to black. 0 means no fading at all. 255 * - * means 100% faded to black. * - * * - * lookup -- ptr to lookup table * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine doesn't actually set the palette to the video card. Use the Set() * - * function to achieve that purpose. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, BlackColor); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Partial_Adjust -- Adjusts the palette toward another palette. * - * * - * This routine is used to adjust a palette toward a destination palette by the ratio * - * specified. This is primarily used by the palette fading routines. The input lookup * - * table is used to determine which entries should fade and which should stay the same * - * * - * * - * INPUT: palette -- Reference to the destination palette. * - * * - * ratio -- The ratio to adjust this palette toward the destination palette. A * - * value of 0 means no adjustment at all. A value of 255 means 100% * - * adjustment. * - * * - * lookup -- ptr to lookup table * - * * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void PaletteClass::Partial_Adjust(int ratio, PaletteClass const & palette, char *lut) -{ - for (int index = 0; index < COLOR_COUNT; index++) { - if (lut[index]) { - Palette[index].Adjust(ratio, palette[index]); - } - } -} - - -/*********************************************************************************************** - * PaletteClass::Closest_Color -- Finds closest match to color specified. * - * * - * This routine will examine the palette and return with the color index number for the * - * color that most closely matches the color specified. Remap operations rely heavily on * - * this routine to allow working with a constant palette. * - * * - * INPUT: rgb -- Reference to a color to search for in the current palette. * - * * - * OUTPUT: Returns with a color index value to most closely matches the specified color. * - * * - * WARNINGS: This routine will quite likely not find an exact match. * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int PaletteClass::Closest_Color(RGBClass const & rgb) const -{ - int closest = 0; - int value = -1; - - RGBClass const * ptr = &Palette[0]; - for (int index = 0; index < COLOR_COUNT; index++) { - int difference = rgb.Difference(*ptr++); - if (value == -1 || difference < value) { - value = difference; - closest = index; - } - } - return(closest); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.H b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.H deleted file mode 100644 index a94af2561a9..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.H +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PCX.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PCX_H -#define PCX_H - -#include "bsurface.h" -#include "PALETTE.H" -#include "WWFILE.H" -#include - - -struct RGB { - unsigned char red; - unsigned char green; - unsigned char blue; -}; - -struct PCX_HEADER -{ - char id; - char version; - char encoding; - char pixelsize; - short x; - short y; - short width; - short height; - short xres; - short yres; - RGB ega_palette[16]; - char nothing; - char color_planes; - unsigned short byte_per_line; - short palette_type; - char filler[58]; -}; - - -Surface * Read_PCX_File(FileClass & file_handle, PaletteClass * palette= NULL, void * buff=NULL, long size=0); -//Surface * Read_PCX_File (char * name, Buffer & Buff, PaletteClass * palette= NULL) ; -bool Write_PCX_File(FileClass & file, Surface & pic, PaletteClass * palette); - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp deleted file mode 100644 index 2f02055bb83..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pcx.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/PCX.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/28/98 12:06p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "pcx.H" -#include - - -/*************************************************************************** - * READ_PCX_FILE -- read a pcx file into a Graphic Buffer * - * * - * GraphicBufferClass* Read_PCX_File (char* name, char* palette,void *Buff, long size ); * - * * - * * - * INPUT: name is a NULL terminated string of the format [xxxx.pcx] * - * palette is optional, if palette != NULL the the color palette of * - * the pcx file will be place in the memory block pointed * - * by palette. * - * Buff is optional, if Buff == NULL a new memory Buffer * - * will be allocated, otherwise the file will be placed * - * at location pointed by Buffer; * - * Size is the size in bytes of the memory block pointed by Buff * - * is also optional; * * - * OUTPUT: on success a pointer to a GraphicBufferClass containing the * - * pcx file, NULL otherwise. * - * * - * WARNINGS: * - * Appears to be a comment-free zone * - * * - * HISTORY: * - * 05/03/1995 JRJ : Created. * - * 04/30/1996 ST : Tidied up and modified to use CCFileClass * - *=========================================================================*/ -#define POOL_SIZE 2048 -#define READ_CHAR() *file_ptr++ ; \ - if ( file_ptr >= & pool [ POOL_SIZE ] ) { \ - file_handle.Read (pool, POOL_SIZE ); \ - file_ptr = pool ; \ - } -#define READ_CHARx() *file_ptr++ ; \ - if ( file_ptr >= & pool [ POOL_SIZE ] ) { \ - file_handle.Read (pool, POOL_SIZE ); \ - } - - -Surface * Read_PCX_File(FileClass & file_handle, PaletteClass * palette, void * Buff, long Size) -{ - unsigned i, j; - unsigned rle; - unsigned color; - unsigned scan_pos; - char *file_ptr; - unsigned width; - unsigned height; - char *buffer; - PCX_HEADER header; - char pool [POOL_SIZE]; - BSurface * pic; - - if (!file_handle.Is_Available()) return (NULL); - - file_handle.Open(FileClass::READ); - - file_handle.Read (&header, sizeof (PCX_HEADER)); - - if (header.id != 10 && header.version != 5 && header.pixelsize != 8 ) return NULL ; - - width = header.width - header.x + 1; - height = header.height - header.y + 1; - - if (Buff != NULL) { - i = Size / width; - height = MIN ((int)(i - 1), (int)height); - Buffer b(Buff, Size); - pic = W3DNEW BSurface(width, height, 1, &b); - if (pic == NULL) return NULL ; - } else { - pic = W3DNEW BSurface(width, height, 1); - if (pic == NULL) return NULL ; - } - - buffer = (char *)pic->Lock(); - if (buffer != NULL) { - file_ptr = pool ; - file_handle.Read (pool, POOL_SIZE); - - if ( header.byte_per_line != width ) { - - i = 0; - rle = 0; - for ( scan_pos = j = 0 ; j < height ; j ++, scan_pos += width ) { - for ( i = 0 ; i < width ; ) { - rle = READ_CHAR (); - if ( rle > 192 ) { - rle -= 192 ; - color = READ_CHAR (); ; - memset ( buffer + scan_pos + i, color, rle ); - i += rle; - } else { - *(buffer+scan_pos + i++ ) = (char)rle; - } - } - } - - if ( i == width ) rle = READ_CHAR (); - if ( rle > 192 ) READ_CHARx(); - - } else { - - for ( i = 0 ; i < width * height ; ) { - rle = READ_CHAR (); - rle &= 0xff; - if ( rle > 192 ) { - rle -= 192 ; - color = READ_CHAR (); - memset ( buffer + i, color, rle ); - i += rle ; - } else { - *(buffer + i++) = (char)rle; - } - } - } - pic->Unlock(); - } - - if ( palette ) { - file_handle.Seek (- (256 * (int)sizeof(RGB)), SEEK_END ); - file_handle.Read (palette, 256L * sizeof ( RGB )); - } - - file_handle.Close(); - return pic; -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pk.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pk.cpp deleted file mode 100644 index aea87aa9514..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pk.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PK.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PKey::Decode_Exponent -- Decodes the exponent back into the key. * - * PKey::Decode_Modulus -- Decodes the modulus value back into the key. * - * PKey::Decrypt -- Decrypt supplied cyphertext into its original plaintext. * - * PKey::Encode_Exponent -- Encode the exponent portion of the key into a buffer. * - * PKey::Encode_Modulus -- Encode the modulus portion of the key. * - * PKey::Encrypt -- Encrypt blocks of plaintext. * - * PKey::Generate -- Generate a public and private key. * - * PKey::PKey -- Construct a key using encoded strings. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "PK.H" -#include "RNDSTRAW.H" -#include - - -#if defined(__BORLANDC__) -extern BigInt Generate_Prime(Straw &, int, BigInt const *); -#endif - -#ifdef _MSC_VER -//BigInt Generate_Prime(Straw &, int, BigInt const *); -#endif - - -/*********************************************************************************************** - * PKey::PKey -- Construct a key using encoded strings. * - * * - * This constructor will construct a key based on the encoded strings supplied. * - * * - * INPUT: exponent -- The encoded string for the exponent portion of the key. * - * * - * modulus -- The encoded string for the modulus portion of the key. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -PKey::PKey(void const * exponent, void const * modulus) -{ - Modulus.DERDecode((unsigned char *)modulus); - Exponent.DERDecode((unsigned char *)exponent); - BitPrecision = Modulus.BitCount()-1; -} - - -/*********************************************************************************************** - * PKey::Encode_Modulus -- Encode the modulus portion of the key. * - * * - * This will store the modulus portion of the key into a buffer. The number of bytes * - * stored into the buffer depends on the value of the key. * - * * - * INPUT: buffer -- Pointer to the buffer that will hold the encoded modulus value. * - * * - * OUTPUT: Returns with the number of bytes stored to the buffer. * - * * - * WARNINGS: Be sure that the buffer can hold the encoded bytes. This is normally around the * - * same size as the Crypt_Block_Size() (plus a byte or two). * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encode_Modulus(void * buffer) const -{ - if (buffer == NULL) { - return(0); - } - return(Modulus.DEREncode((unsigned char *)buffer)); -} - - -/*********************************************************************************************** - * PKey::Encode_Exponent -- Encode the exponent portion of the key into a buffer. * - * * - * This routine will encode the exponent portion of the key. This is only necessary for the * - * slow key since the fast key always has an exponent of 65537. * - * * - * INPUT: buffer -- Pointer to the buffer that will be filled with the encoded exponent. * - * * - * OUTPUT: Returns with the nuber of bytes stored into the buffer. * - * * - * WARNINGS: Be sure the buffer is big enough to hold the encoded exponent. Usually this is * - * about the same size as the Crypt_Block_Size (plus a byte or two). * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encode_Exponent(void * buffer) const -{ - if (buffer == NULL) { - return(0); - } - return(Exponent.DEREncode((unsigned char *)buffer)); -} - - -/*********************************************************************************************** - * PKey::Decode_Modulus -- Decodes the modulus value back into the key. * - * * - * This is the counterpart to the Encode_Modulus() function. It will initialize the * - * modulus portion of the key with the encoded data supplied. * - * * - * INPUT: buffer -- Pointer to the buffer that holds the previously encoded modulus value. * - * * - * OUTPUT: void * - * * - * WARNINGS: void * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -void PKey::Decode_Modulus(void * buffer) -{ - Modulus.DERDecode((unsigned char *)buffer); - BitPrecision = Modulus.BitCount()-1; -} - - -/*********************************************************************************************** - * PKey::Decode_Exponent -- Decodes the exponent back into the key. * - * * - * This is the counterpart to the Encode_Exponent function. It will decode a previously * - * encoded exponent portion back into the key. * - * * - * INPUT: buffer -- Pointer to the buffer that holds the encoded exponent value. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -void PKey::Decode_Exponent(void * buffer) -{ - Exponent.DERDecode((unsigned char *)buffer); -} - - -/*********************************************************************************************** - * PKey::Generate -- Generate a public and private key. * - * * - * Public key cryptography relies on having two paired keys. The key used to encrypt * - * data must be decrypted by using the other key. Which key designated as the public or * - * private key is arbitrary. However, one is faster than the other. Use the faster key for * - * the more common operation. * - * * - * INPUT: random -- Reference to a source of random data. * - * * - * bits -- The number of bits to use for key generation. Use a number greater * - * than 16 but less than 2048. The ideal bit size is one that is evenly * - * divisible by 8 and then add one. Practical numbers range from 65 to * - * 1025 bits. * - * * - * fastkey -- Reference to the key that has fast encryption/decryption properties. * - * * - * slowkey -- Reference to the mate key of the other. * - * * - * OUTPUT: none * - * * - * WARNINGS: This routine can take a very long time. It can take MINUTES to generate a * - * 1024 bit key (even on a Pentium Pro 200Mghz machine). * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - * 07/10/1996 JLB : Must supply source of random data. * - *=============================================================================================*/ -void PKey::Generate(Straw & random, int bits, PKey & fastkey, PKey & slowkey) -{ - /* - ** Key generation consists of create a key pair and then testing the key - ** pair. If the test fails, then repeat the process. The test and repeat - ** method is required since the prime number generating process can't - ** guarantee the generation of a prime number -- it can only generate a - ** highly likely prime number. - */ - for (;;) { - /* - ** Generate the two random prime numbers. This is the longest - ** step. - */ - BigInt p = Generate_Prime(random, bits, &p); - BigInt q = Generate_Prime(random, bits, &q); - - /* - ** The exponent factors are easy to calculate from the prime numbers. - */ - BigInt e = Fast_Exponent(); - BigInt n = p * q; - BigInt pqmin = (p-(unsigned short)1)*(q-(unsigned short)1); - BigInt d = e.Inverse(pqmin); - - /* - ** Store the data into the key objects. Notice that the modulus is the - ** same for both the fast and slow keys. Also notice that the exponent for - ** the fast key is ALWAYS 65537. Given this, it is possible to economize the - ** fast key into being just the modulus and the slow key to being just the - ** exponent (presuming the slow key also has access to the fast key so that - ** it can get the modulus). - */ - fastkey.Exponent = e; - fastkey.Modulus = n; - fastkey.BitPrecision = n.BitCount()-1; - - slowkey.Exponent = d; - slowkey.Modulus = n; - slowkey.BitPrecision = fastkey.BitPrecision; - - /* - ** Test the keys by encrypting a block of random bytes. If it decrypts - ** correctly, then a valid key pair has been generated -- bail. - */ - char before[256]; - char after[256]; - - for (int index = 0; index < fastkey.Plain_Block_Size(); index++) { - before[index] = (char)rand(); - } - fastkey.Encrypt(before, fastkey.Plain_Block_Size(), after); - slowkey.Decrypt(after, slowkey.Crypt_Block_Size(), after); - - /* - ** Compare the pre and post processing buffer. A match indicates - ** a valid key pair. - */ - if (memcmp(before, after, fastkey.Plain_Block_Size()) == 0) break; - } -} - - -/*********************************************************************************************** - * PKey::Encrypt -- Encrypt blocks of plaintext. * - * * - * This routine will encrypt the supplied plaintext into cyphertext by processing the input * - * in block. The source is processed in whole blocks. Partial blocks are not supported by * - * public key cryptography. * - * * - * INPUT: source -- Pointer to the source plaintext that will be encrypted. * - * * - * length -- The length of the plaintext to encrypt. * - * * - * dest -- Pointer to the buffer that will hold the encrypted data. * - * * - * OUTPUT: Returns with the number of cypher text bytes placed into the destination buffer. * - * * - * WARNINGS: Be sure that the destination buffer is big enough to hold the output. * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Encrypt(void const * source, int slen, void * dest) const -{ - int total = 0; - - /* - ** Encrypt the source data in full blocks. Partial blocks are not processed and are not - ** copied to the destination buffer. - */ - while (slen >= Plain_Block_Size()) { - - /* - ** Perform the encryption of the block. - */ - BigInt temp = 0; - memmove(&temp, source, Plain_Block_Size()); - temp = temp.exp_b_mod_c(Exponent, Modulus); - - /* - ** Move the cypher block to the destination. - */ - memmove(dest, &temp, Crypt_Block_Size()); - slen -= Plain_Block_Size(); - source = (char *)source + Plain_Block_Size(); - dest = (char *)dest + Crypt_Block_Size(); - total += Crypt_Block_Size(); - } - - return(total); -} - - -/*********************************************************************************************** - * PKey::Decrypt -- Decrypt supplied cyphertext into its original plaintext. * - * * - * This routine will process the supplied cyphertext by breaking it up into blocks and * - * then decrypting each block in turn. The block size is dependant upon the key. By NOT * - * embedding this information into the cypher data, it makes the encryption more secure. * - * * - * INPUT: source -- Pointer to the cypher text to be decrypted. * - * * - * length -- The number of cypher text bytes supplied to this routine. * - * * - * dest -- Pointer to the buffer to hold the plaintext. * - * * - * OUTPUT: Returns with the number of plaintext bytes output to the destination buffer. * - * * - * WARNINGS: Only whole blocks are processed. If the source has any partial block sized * - * data, then it will be left unprocessed. * - * * - * HISTORY: * - * 07/05/1996 JLB : Created. * - *=============================================================================================*/ -int PKey::Decrypt(void const * source, int slen, void * dest) const -{ - int total = 0; - BigInt temp; - - /* - ** Decrypt the source data in full blocks. Partial blocks are not processed in any way. - */ - while (slen >= Crypt_Block_Size()) { - - /* - ** Perform the encryption. - */ - temp = 0; - memmove(&temp, source, Crypt_Block_Size()); - temp = temp.exp_b_mod_c(Exponent, Modulus); - - /* - ** Move the cypher block to the destination. - */ - memmove(dest, &temp, Plain_Block_Size()); - slen -= Crypt_Block_Size(); - source = (char *)source + Crypt_Block_Size(); - dest = (char *)dest + Plain_Block_Size(); - total += Plain_Block_Size(); - } - - return(total); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.cpp deleted file mode 100644 index 75ebc147806..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PKPIPE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PKPipe::Encrypted_Key_Length -- Fetch the encrypted key length. * - * PKPipe::Key -- Submit a key to enable processing of data flow. * - * PKPipe::PKPipe -- Constructor for the public key pipe object. * - * PKPipe::Plain_Key_Length -- Returns the number of bytes to encrypt key. * - * PKPipe::Put -- Submit data to the pipe for processing. * - * PKPipe::Put_To -- Chains one pipe to another. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "pkpipe.h" -#include - - -/*********************************************************************************************** - * PKPipe::PKPipe -- Constructor for the public key pipe object. * - * * - * This will construct the public key pipe object. * - * * - * INPUT: control -- The method used to process the data flow (encrypt or decrypt). * - * * - * rnd -- Reference to a random number generate used to create the internal * - * blowfish key. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -PKPipe::PKPipe(CryptControl control, RandomStraw & rnd) : - IsGettingKey(true), - Rand(rnd), - BF((control == ENCRYPT) ? BlowPipe::ENCRYPT : BlowPipe::DECRYPT), - Control(control), - CipherKey(NULL), - Counter(0), - BytesLeft(0) -{ -} - - -/*********************************************************************************************** - * PKPipe::Put_To -- Chains one pipe to another. * - * * - * This handles linking of one pipe to this pipe. Data will flow from this PKPipe to the * - * pipe segment specified. Special handling is done so that piping actually flows to the * - * embedded blowfish pipe and then flows to the designated pipe. * - * * - * INPUT: pipe -- Pointer to the pipe that this pipe segment is to send data to. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/12/1996 JLB : Created. * - *=============================================================================================*/ -void PKPipe::Put_To(Pipe * pipe) -{ - if (BF.ChainTo != pipe) { - if (pipe != NULL && pipe->ChainFrom != NULL) { - pipe->ChainFrom->Put_To(NULL); - pipe->ChainFrom = NULL; - } - - if (BF.ChainTo != NULL) { - BF.ChainTo->ChainFrom = NULL; - } - BF.ChainTo = pipe; - if (pipe != NULL) { - pipe->ChainFrom = &BF; - } - BF.ChainFrom = this; - ChainTo = &BF; - } -} - - -/*********************************************************************************************** - * PKPipe::Key -- Submit a key to enable processing of data flow. * - * * - * This routine must be called with a valid key pointer in order for encryption/description * - * to be performed on the data stream. Prior to calling this routine or after calling this * - * routine with a NULL pointer, the data stream will pass through this pipe without * - * modification. * - * * - * INPUT: key -- Pointer to the key to use for processing. Pass NULL if process is to be * - * terminated. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/07/1996 JLB : Created. * - *=============================================================================================*/ -void PKPipe::Key(PKey const * key) -{ - if (key == NULL) { - Flush(); - IsGettingKey = false; - } - CipherKey = key; - - if (CipherKey != NULL) { - IsGettingKey = true; - if (Control == DECRYPT) { - Counter = BytesLeft = Encrypted_Key_Length(); - } - } -} - - -/*********************************************************************************************** - * PKPipe::Put -- Submit data to the pipe for processing. * - * * - * This routine (if processing as been enabled by a previous key submission) will * - * encrypt or decrypt the data stream that passes through it. When encrypting, the data * - * stream will increase in size by about 10% (bit it varies according to the key used). * - * * - * INPUT: source -- Pointer to the data to be submitted to the pipe stream. * - * * - * length -- The number of bytes submitted. * - * * - * OUTPUT: Returns with the actual number of byte output at the final end of the pipe. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/07/1996 JLB : Created. * - *=============================================================================================*/ -int PKPipe::Put(void const * source, int length) -{ - /* - ** If the parameter seem illegal, then pass the pipe request to the - ** next pipe in the chain and let them deal with it. - */ - if (source == NULL || length < 1 || CipherKey == NULL) { - return(Pipe::Put(source, length)); - } - - int total = 0; - - /* - ** Perform a special process if the this is the first part of the data flow. The special - ** key must be processed first. After this initial key processing, the rest of the data flow - ** is processed by the blowfish pipe and ignored by the PKPipe. - */ - if (IsGettingKey) { - - /* - ** When encrypting, first make the key block and then pass the data through the - ** normal blowfish processor. - */ - if (Control == ENCRYPT) { - - /* - ** Generate the largest blowfish key possible. - */ - char buffer[MAX_KEY_BLOCK_SIZE]; - memset(buffer, '\0', sizeof(buffer)); - Rand.Get(buffer, BLOWFISH_KEY_SIZE); - - /* - ** Encrypt the blowfish key (along with any necessary pad bytes). - */ - int didput = CipherKey->Encrypt(buffer, Plain_Key_Length(), Buffer); - total += Pipe::Put(Buffer, didput); - BF.Key(buffer, BLOWFISH_KEY_SIZE); - - IsGettingKey = false; - - } else { - - /* - ** First try to accumulate a full key. - */ - int toget = (BytesLeft < length) ? BytesLeft : length; - memmove(&Buffer[Counter-BytesLeft], source, toget); - length -= toget; - BytesLeft -= toget; - source = (char *)source + toget; - - /* - ** If a full key has been accumulated, then decrypt it and feed the - ** key to the blowfish engine. - */ - if (BytesLeft == 0) { - char buffer[MAX_KEY_BLOCK_SIZE]; - CipherKey->Decrypt(Buffer, Counter, buffer); - BF.Key(buffer, BLOWFISH_KEY_SIZE); - - IsGettingKey = false; - } - } - } - - /* - ** If there are any remaining bytes to pipe through, then - ** pipe them through now -- they will be processed by the - ** blowfish engine. - */ - total += Pipe::Put(source, length); - return(total); -} - - -/*********************************************************************************************** - * PKPipe::Encrypted_Key_Length -- Fetch the encrypted key length. * - * * - * This returns the total number of bytes (after encryption) that the blowfish key will * - * consume. It should be possible to get a block of this size, then pass it to the * - * public key decrypter and the result will be the full blowfish key. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of bytes that the encrypted blowfish key required. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -int PKPipe::Encrypted_Key_Length(void) const -{ - if (CipherKey == NULL) return(0); - return(CipherKey->Block_Count(BLOWFISH_KEY_SIZE) * CipherKey->Crypt_Block_Size()); -} - - -/*********************************************************************************************** - * PKPipe::Plain_Key_Length -- Returns the number of bytes to encrypt key. * - * * - * This is the number of plain (unencrypted) bytes that the blowfish key will take up. This * - * is actually the number of plain blocks minimum that can contain the full blowfish * - * key. The public key cryptography system encrypts in whole blocks only. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the total number of bytes that will contain the full blowfish key * - * and still be an even block size for the public key cryptography process. * - * * - * WARNINGS: This value is probably be larger than the actual blowfish key length. * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -int PKPipe::Plain_Key_Length(void) const -{ - if (CipherKey == NULL) return(0); - return(CipherKey->Block_Count(BLOWFISH_KEY_SIZE) * CipherKey->Plain_Block_Size()); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h deleted file mode 100644 index 49f0462214f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkpipe.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/pkpipe.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PKPIPE_H -#define PKPIPE_H - -#include "blowpipe.h" -#include "PIPE.H" -#include "PK.H" -#include "RNDSTRAW.H" - - -/* -** This pipe will encrypt/decrypt the data stream. The data is encrypted by generating a -** symetric key that is then encrypted using the public key system. This symetric key is then -** used to encrypt the remaining data. -*/ -class PKPipe : public Pipe -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - PKPipe(CryptControl control, RandomStraw & rnd); - - virtual void Put_To(Pipe * pipe); - virtual void Put_To(Pipe & pipe) {Put_To(&pipe);} - - // Feed data through for processing. - virtual int Put(void const * source, int length); - - // Submit key for encryption/decryption. - void Key(PKey const * key); - - private: - enum { - BLOWFISH_KEY_SIZE=BlowfishEngine::MAX_KEY_LENGTH, - MAX_KEY_BLOCK_SIZE=256 // Maximum size of pk encrypted blowfish key. - }; - - /* - ** This flag indicates whether the PK (fetch blowfish key) phase is - ** in progress or not. - */ - bool IsGettingKey; - - /* - ** This is the random straw that is needed to generate the - ** blowfish key. - */ - RandomStraw & Rand; - - /* - ** This is the attached blowfish pipe. After the blowfish key has been - ** decrypted, then the PK processor goes dormant and the blowfish processor - ** takes over the data flow. - */ - BlowPipe BF; - - /* - ** Controls the method of processing the data stream. - */ - CryptControl Control; - - /* - ** Pointer to the key to use for encryption/decryption. The actual process - ** performed is controlled by the Control member. A key can be used for - ** either encryption or decryption -- it makes no difference. However, whichever - ** process is performed, the opposite process must be performed using the - ** other key. - */ - PKey const * CipherKey; - - /* - ** This is the staging buffer for the block of data. This block must be as large as - ** the largest possible key size or the largest blowfish key (whichever is greater). - */ - char Buffer[MAX_KEY_BLOCK_SIZE]; - - /* - ** The working counter that holds the number of bytes in the staging buffer. - */ - int Counter; - - /* - ** This records the number of bytes remaining in the current block. This - ** will be the number of bytes left to accumulate before the block can be - ** processed either for encryption or decryption. - */ - int BytesLeft; - - int Encrypted_Key_Length(void) const; - int Plain_Key_Length(void) const; - - PKPipe(PKPipe & rvalue); - PKPipe & operator = (PKPipe const & pipe); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.cpp deleted file mode 100644 index 06060e009f2..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PKSTRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PKStraw::Encrypted_Key_Length -- Fetch the encrypted key length. * - * PKStraw::Get -- Fetch data and process it accordingly. * - * PKStraw::Get_From -- Chains one straw to another. * - * PKStraw::Key -- Assign a key to the cipher process straw. * - * PKStraw::PKStraw -- Initialize the public key straw object. * - * PKStraw::Plain_Key_Length -- Returns the number of bytes to encrypt key. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blwstraw.h" -#include "pkstraw.h" -#include "RNDSTRAW.H" -#include - - -/*********************************************************************************************** - * PKStraw::PKStraw -- Initialize the public key straw object. * - * * - * This constructs the public key straw object. The operation to perform (encrypt or * - * decrypt) as well as a random number generator must be provided. * - * * - * INPUT: control -- What operation to perform on the data. Pass in either ENCRYPT or * - * DECRYPT. * - * * - * rnd -- Reference to a random number straw that is used internally to * - * generate the sub-key. The final strength of the cipher depends on * - * quality of this random number generator. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -PKStraw::PKStraw(CryptControl control, RandomStraw & rnd) : - IsGettingKey(true), - Rand(rnd), - BF((control == ENCRYPT) ? BlowStraw::ENCRYPT : BlowStraw::DECRYPT), - Control(control), - CipherKey(NULL), - Counter(0), - BytesLeft(0) -{ - Straw::Get_From(BF); -} - - -/*********************************************************************************************** - * PKStraw::Get_From -- Chains one straw to another. * - * * - * This routine handles the special case of this straw object in that there is an * - * embedded blowfish straw segment. It must be chained on correctly. * - * * - * INPUT: straw -- Pointer to the straw segment that this segment is to receive data from. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -void PKStraw::Get_From(Straw * straw) -{ - if (BF.ChainTo != straw) { - if (straw != NULL && straw->ChainFrom != NULL) { - straw->ChainFrom->Get_From(NULL); - straw->ChainFrom = NULL; - } - - if (BF.ChainTo != NULL) { - BF.ChainTo->ChainFrom = NULL; - } - - BF.ChainTo = straw; - BF.ChainFrom = this; - ChainTo = &BF; - if (BF.ChainTo != NULL) { - BF.ChainTo->ChainFrom = this; - } - } -} - - - -/*********************************************************************************************** - * PKStraw::Key -- Assign a key to the cipher process straw. * - * * - * This routine will assign the key (or NULL if the current key is to be removed) to the * - * cipher stream process. When a key has been assigned, encryption or decryption will * - * take place. In the absence (NULL key pointer) of a key, the data passes through * - * unchanged. * - * * - * INPUT: key -- Pointer to the key to assign to the stream. If the key pointer is NULL, * - * then this causes the cipher stream to stop processing the data and will * - * pass the data through unchanged. * - * * - * OUTPUT: none * - * * - * WARNINGS: Be sure that the key passed to this routine is the opposite key to that used * - * to process the stream originally (when decrypting). * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -void PKStraw::Key(PKey const * key) -{ - CipherKey = key; - if (key != NULL) { - IsGettingKey = true; - } - Counter = 0; - BytesLeft = 0; -} - - -/*********************************************************************************************** - * PKStraw::Get -- Fetch data and process it accordingly. * - * * - * This routine will fetch the number of bytes requested. If a valid key has been assigned * - * to this stream, then the data will be processed as it passes through. * - * * - * INPUT: source -- Pointer to the buffer that will hold the requested data. * - * * - * length -- The number of data bytes requested. * - * * - * OUTPUT: Returns with the actual number of data bytes stored to the destination buffer. If * - * this number is less than that requested, then it indicates that the data source * - * has been exhausted. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/08/1996 JLB : Created. * - *=============================================================================================*/ -int PKStraw::Get(void * source, int length) -{ - /* - ** If the parameters seem invalid, then pass the request on so that someone - ** else can deal with it. - */ - if (source == NULL || length < 1 || CipherKey == NULL) { - return(Straw::Get(source, length)); - } - - int total = 0; - - /* - ** The first part of the data flow must process the special key. After the special - ** key has been processed, the data flows through this straw without direct - ** modification (the blowfish straw will process the data). - */ - if (IsGettingKey) { - - if (Control == DECRYPT) { - - /* - ** Retrieve the pk encrypted blowfish key block. - */ - char cbuffer[MAX_KEY_BLOCK_SIZE]; - int got = Straw::Get(cbuffer, Encrypted_Key_Length()); - - /* - ** If the entire key block could not be retrieved, then this indicates - ** a major data flow error -- just return with no action performed. - */ - if (got != Encrypted_Key_Length()) return(0); - - /* - ** Decrypt the blowfish key and then activate the blowfish straw - ** with that key. - */ - CipherKey->Decrypt(cbuffer, got, Buffer); - BF.Key(Buffer, BLOWFISH_KEY_SIZE); - - } else { - - /* - ** Generate the blowfish key by using random numbers. - */ - char buffer[MAX_KEY_BLOCK_SIZE]; - memset(buffer, '\0', sizeof(buffer)); - Rand.Get(buffer, BLOWFISH_KEY_SIZE); - - /* - ** Encrypt the blowfish key (along with any necessary pad bytes). - */ - Counter = BytesLeft = CipherKey->Encrypt(buffer, Plain_Key_Length(), Buffer); - BF.Key(buffer, BLOWFISH_KEY_SIZE); - } - - /* - ** The first phase of getting the special key has been accomplished. Now, all - ** subsequent data is passed (unmodified) though this straw segment. The blowfish - ** straw takes over the compression/decompression from this point forward. - */ - IsGettingKey = false; - } - - /* - ** If there are any pending bytes in the buffer, then pass - ** these on first. The only time this should be is when the blowfish - ** key has first been generated. - */ - if (BytesLeft > 0) { - int tocopy = (length < BytesLeft) ? length : BytesLeft; - memmove(source, &Buffer[Counter-BytesLeft], tocopy); - source = (char *)source + tocopy; - BytesLeft -= tocopy; - length -= tocopy; - total += tocopy; - } - - /* - ** Any requested bytes that haven't been satisfied are copied over now by - ** drawing the data through the blowfish engine. The blowfish engine happens - ** to be linked to the chain so a normal Get() operation is sufficient. - */ - total += Straw::Get(source, length); - - return(total); -} - - -/*********************************************************************************************** - * PKStraw::Encrypted_Key_Length -- Fetch the encrypted key length. * - * * - * This returns the total number of bytes (after encryption) that the blowfish key will * - * consume. It should be possible to get a block of this size, then pass it to the * - * public key decrypter and the result will be the full blowfish key. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of bytes that the encrypted blowfish key required. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -int PKStraw::Encrypted_Key_Length(void) const -{ - if (CipherKey == NULL) return(0); - return(CipherKey->Block_Count(BLOWFISH_KEY_SIZE) * CipherKey->Crypt_Block_Size()); -} - - -/*********************************************************************************************** - * PKStraw::Plain_Key_Length -- Returns the number of bytes to encrypt key. * - * * - * This is the number of plain (unencrypted) bytes that the blowfish key will take up. This * - * is actually the number of plain blocks minimum that can contain the full blowfish * - * key. The public key cryptography system encrypts in whole blocks only. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the total number of bytes that will contain the full blowfish key * - * and still be an even block size for the public key cryptography process. * - * * - * WARNINGS: This value is probably be larger than the actual blowfish key length. * - * * - * HISTORY: * - * 07/11/1996 JLB : Created. * - *=============================================================================================*/ -int PKStraw::Plain_Key_Length(void) const -{ - if (CipherKey == NULL) return(0); - return(CipherKey->Block_Count(BLOWFISH_KEY_SIZE) * CipherKey->Plain_Block_Size()); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h deleted file mode 100644 index da806a795ce..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/pkstraw.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/PKSTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PKSTRAW_H -#define PKSTRAW_H - -#include "blwstraw.h" -#include "PK.H" -#include "pkstraw.h" -#include "RNDSTRAW.H" - -class PKStraw : public Straw -{ - public: - typedef enum CryptControl { - ENCRYPT, - DECRYPT - } CryptControl; - - PKStraw(CryptControl control, RandomStraw & rnd); - - virtual void Get_From(Straw * straw); - virtual void Get_From(Straw & straw) {Get_From(&straw);} - - virtual int Get(void * source, int slen); - - // Submit key to be used for encryption/decryption. - void Key(PKey const * key); - - private: - enum { - BLOWFISH_KEY_SIZE=BlowfishEngine::MAX_KEY_LENGTH, - MAX_KEY_BLOCK_SIZE=256 // Maximum size of pk encrypted blowfish key. - }; - - /* - ** This flag indicates whether the PK (fetch blowfish key) phase is - ** in progress or not. - */ - bool IsGettingKey; - - /* - ** This is the random straw that is needed to generate the - ** blowfish key. - */ - RandomStraw & Rand; - - /* - ** This is the attached blowfish pipe. After the blowfish key has been - ** decrypted, then the PK processor goes dormant and the blowfish processor - ** takes over the data flow. - */ - BlowStraw BF; - - /* - ** This control member tells what method (encryption or decryption) that should - ** be performed on the data stream. - */ - CryptControl Control; - - /* - ** Pointer to the key to use for encryption or decryption. If this pointer is NULL, then - ** the data passing through this segment will not be modified. - */ - PKey const * CipherKey; - - /* - ** This is the staging buffer for the block of data. This block must be as large as - ** the largest possible key size or the largest blowfish key size (whichever is - ** greater). - */ - char Buffer[256]; - - int Counter; - - /* - ** This records the number of bytes remaining in the current block. This - ** will be the number of bytes left to accumulate before the block can be - ** processed either for encryption or decryption. - */ - int BytesLeft; - - int Encrypted_Key_Length(void) const; - int Plain_Key_Length(void) const; - - PKStraw(PKStraw & rvalue); - PKStraw & operator = (PKStraw const & straw); -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/point.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/point.cpp deleted file mode 100644 index 66fdf16a7b3..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/point.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/Point.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Point2D::Bias_To -- Bias a point into a rectangle. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifdef NEVER - - -#include "always.h" -#include "Point.h" -#include "rect.h" - - -/*********************************************************************************************** - * Point2D::Bias_To -- Bias a point into a rectangle. * - * * - * It is often necessary to take a point that is relative to a rectangle and derive a * - * point that is no longer relative to the rectangle coordiates, yet still have it refer * - * to the same location. * - * * - * INPUT: rect -- The rectangle to bias this point against. * - * * - * OUTPUT: Returns with a point in the rectangles coordinate space but still referring to the * - * same location. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -Point2D const Point2D::Bias_To(Rect const & rect) const -{ - return(Point2D(X + rect.X, Y + rect.Y)); -} - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp deleted file mode 100644 index 6d73ced6390..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// -// rc4.cpp -// RC4 encryption / decryption -// -#include "rc4.h" -#include -#include - -static unsigned char RC4_Temp_Byte; -#define RC4_SWAP_BYTE(a,b) RC4_Temp_Byte=a; a=b; b=RC4_Temp_Byte - -// -// Used to init the key state vector in key setup -// -static unsigned char RC4_Table_Init[]={ - 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, - 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, - 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, - 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, - 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, - 230, 231, 232, 233, 234, - 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, - 250, 251, 252, 253, 254, - 255 -}; - - - - - -// -// Don't rely on this to zero the key -// -RC4Class::RC4Class() -{ - memset(Key.State, 0, 256); - Key.X=0; - Key.Y=0; -} - - - -// -// Setup the encryption key. This must be called before you encrypt/decrypt! -// -void RC4Class::Prepare_Key(const unsigned char *key_data_ptr, int key_data_len) -{ - switch(key_data_len) { - case 8: - Prepare_Key_8bytes(key_data_ptr); - break; - - case 16: - Prepare_Key_16bytes(key_data_ptr); - break; - - default: - { - unsigned char index1; - unsigned char index2; - unsigned char *state; - unsigned short counter; - - state = &Key.State[0]; - memcpy(state, RC4_Table_Init, 256); - - Key.X = 0; - Key.Y = 0; - index1 = 0; - index2 = 0; - for (counter = 0; counter < 256; counter++) { - index2 = (key_data_ptr[index1] + state[counter] + index2); - RC4_SWAP_BYTE(state[counter], state[index2]); - index1 = (unsigned char)((index1 + 1) % key_data_len); - } - } - } // switch -} - - -void RC4Class::Print_State(void) { - unsigned char *state; - state = &Key.State[0]; - for (int i=0; i<256; i+=5) { - printf(" %3d %3d %3d %3d %3d\n",state[i], state[i+1], state[i+2], state[i+3], state[i+4]); - } - printf("X = %d Y = %d\n\n",Key.X,Key.Y); -} - - - -// -// RC4 in standard mode. -// -// This will XOR the buffer with the RC4 stream (like a one time pad). -// -void RC4Class::RC4(unsigned char *buffer_ptr, int buffer_len) -{ - unsigned char x; - unsigned char y; - unsigned char *state; - unsigned char *buffer_end=buffer_ptr+buffer_len; - unsigned char *buffer_cur=buffer_ptr; - - x = Key.X; - y = Key.Y; - - state = &Key.State[0]; - while(buffer_cur != buffer_end) { - x++; - y = (unsigned char)(y + state[x]); - RC4_SWAP_BYTE(state[x], state[y]); - *buffer_cur ^= state[(state[x] + state[y]) & 255]; - ++buffer_cur; - } - - Key.X = x; - Key.Y = y; -} - - - - -// -// Copy state & key -// -RC4Class &RC4Class::operator=(const RC4Class &other) { - if (this == &other) - return(*this); - - Key.X=other.Key.X; - Key.Y=other.Key.Y; - memcpy(Key.State, other.Key.State, 256); - - return(*this); -} - - - -//////////////////////////// private methods //////////////////////////// - - - -// -// Setup the encryption key. This must be called before you encrypt/decrypt! -// This version assumes the key len is 8 bytes (64 bits). -// -void RC4Class::Prepare_Key_8bytes(const unsigned char *key_data_ptr) -{ - unsigned char index1; - unsigned char index2; - unsigned char *state; - unsigned short counter; - - state = &Key.State[0]; - memcpy(state, RC4_Table_Init, 256); - - Key.X = 0; - Key.Y = 0; - index1 = 0; - index2 = 0; - for (counter = 0; counter < 256; counter++) { - index2 = (unsigned char)(key_data_ptr[index1] + state[counter] + index2); - RC4_SWAP_BYTE(state[counter], state[index2]); - ++index1; - index1 &= 0x07; - } -} - - - -// -// Setup the encryption key. This must be called before you encrypt/decrypt! -// This version assumes the key len is 16 bytes (128 bits). -// -void RC4Class::Prepare_Key_16bytes(const unsigned char *key_data_ptr) -{ - unsigned char index1; - unsigned char index2; - unsigned char *state; - unsigned short counter; - - state = &Key.State[0]; - memcpy(state, RC4_Table_Init, 256); - - Key.X = 0; - Key.Y = 0; - index1 = 0; - index2 = 0; - for (counter = 0; counter < 256; counter++) { - index2 = (unsigned char)(key_data_ptr[index1] + state[counter] + index2); - RC4_SWAP_BYTE(state[counter], state[index2]); - ++index1; - index1 &= 0x0F; - } -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.h deleted file mode 100644 index 7d20383881d..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rc4.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef RC4_H -#define RC4_H - -// -// RC4.h - Implementation of RC4 encryption -// -// RC4 is a stream cypher. This means that it basically produces a stream of -// random bytes that you XOR with your data. Each key is somewhat like a -// one time pad. -// -// Just as you should never re-use a one time pad, you should never re-use a key. -// -// If you can't re-exchange a secret key before every message you could keep a -// partial secret key and then include the other part of the key in plaintext. -// The key would be the concatenation of the two parts of the key. -// - -class RC4Class -{ -public: - - RC4Class(); - - // - // Key length can be 0..256 bytes - // Key preparation takes about 0.015 Ms on a 1Ghz PC - // It's 3x faster if your keylen is 8 or 16 bytes! - // - void Prepare_Key(const unsigned char *key_data_ptr, int key_data_len); - - // - // In-place encryption. Call Prepare_Key first! - // Only a few clock cycles per byte (9 or so...) - // - void RC4(unsigned char *buffer_ptr, int buffer_len); - - - // - // Copy state & key - // - RC4Class &operator=(const RC4Class &other); - - - void Print_State(void); - -private: - void Prepare_Key_16bytes(const unsigned char *key_data_ptr); - void Prepare_Key_8bytes(const unsigned char *key_data_ptr); - - struct RC4Key - { - unsigned char State[256]; - unsigned char X; - unsigned char Y; - }; - - RC4Key Key; -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp deleted file mode 100644 index 83e3d520ea0..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : wwlib * - * * - * $Archive:: /Commando/Code/wwlib/rcfile.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 7/09/99 1:37p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "rcfile.h" -#include - -const char * RESOURCE_FILE_TYPE_NAME = "File"; - - -ResourceFileClass::ResourceFileClass(HMODULE hmodule, char const *filename) : - ResourceName(NULL), - hModule(NULL), - FileBytes(NULL), - FilePtr(NULL), - EndOfFile(NULL) -{ - Set_Name(filename); - HRSRC hresource = FindResource(hmodule,ResourceName,RESOURCE_FILE_TYPE_NAME); - - if (hresource) { - HGLOBAL hglob = LoadResource(hmodule,hresource); - if (hglob) { - FileBytes = (unsigned char *)LockResource(hglob); - if (FileBytes) { - FilePtr = FileBytes; - EndOfFile = FileBytes + SizeofResource(hmodule,hresource); - } - } - } -} - -ResourceFileClass::~ResourceFileClass(void) -{ - if (ResourceName) - free(ResourceName); -} - -char const * ResourceFileClass::Set_Name(char const *filename) -{ - if (ResourceName) { - free(ResourceName); - ResourceName = NULL; - } - if (filename) { - ResourceName = strdup(filename); - } - return ResourceName; -} - -int ResourceFileClass::Read(void *buffer, int size) -{ - if (!FilePtr) return 0; - - if (FilePtr + size > EndOfFile) { - size = EndOfFile - FilePtr; - } - memcpy(buffer,FilePtr,size); - FilePtr += size; - return size; -} - -int ResourceFileClass::Seek(int pos, int dir) -{ - switch (dir) { - case SEEK_SET: - FilePtr = FileBytes + pos; - break; - - case SEEK_CUR: - FilePtr = FilePtr + pos; - break; - - case SEEK_END: - FilePtr = EndOfFile + pos; - break; - } - - if (FilePtr > EndOfFile) { - FilePtr = EndOfFile; - } - if (FilePtr < FileBytes) { - FilePtr = FileBytes; - } - - return FilePtr - FileBytes; -} - -int ResourceFileClass::Size(void) -{ - return EndOfFile - FileBytes; -} - -void ResourceFileClass::Error(int /*error*/, int /*canretry*/, char const * /*filename*/) -{ -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.h deleted file mode 100644 index 510c455651c..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rcfile.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : wwlib * - * * - * $Archive:: /Commando/Code/wwlib/rcfile.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/02/01 1:21p $* - * * - * $Revision:: 8 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RCFILE_H -#define RCFILE_H - -#include "always.h" -#include "WWFILE.H" -#include "win.h" - -/* -** ResourceFileClass -** This is a file class which allows you to read from a binary file that you have -** imported into your resources. Just import the file as a custom resource of the -** type "File". Replace the "id" of the resource with its filename (change -** IDR_FILE1 to "MyFile.w3d") and then you will be able to access it by using this -** class. -*/ -class ResourceFileClass : public FileClass -{ - public: - - ResourceFileClass(HMODULE hmodule, char const *filename); - virtual ~ResourceFileClass(void); - - virtual char const * File_Name(void) const { return ResourceName; } - virtual char const * Set_Name(char const *filename); - virtual int Create(void) { return false; } - virtual int Delete(void) { return false; } - virtual bool Is_Available(int /*forced=false*/) { return Is_Open (); } - virtual bool Is_Open(void) const { return (FileBytes != NULL); } - - virtual int Open(char const * /*fname*/, int /*rights=READ*/) { return Is_Open(); } - virtual int Open(int /*rights=READ*/) { return Is_Open(); } - - virtual int Read(void *buffer, int size); - virtual int Seek(int pos, int dir=SEEK_CUR); - virtual int Size(void); - virtual int Write(void const * /*buffer*/, int /*size*/) { return 0; } - virtual void Close(void) { } - virtual void Error(int error, int canretry = false, char const * filename=NULL); - virtual void Bias(int start, int length=-1) {} - - virtual unsigned char *Peek_Data(void) const { return FileBytes; } - - protected: - - char * ResourceName; - - HMODULE hModule; - - unsigned char * FileBytes; - unsigned char * FilePtr; - unsigned char * EndOfFile; - -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp deleted file mode 100644 index 82ec147a2b1..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rgb.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RGB.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * RGBClass::Difference -- Determines the "distance" between two colors. * - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "hsv.h" -#include "PALETTE.H" -#include "RGB.H" - -RGBClass const BlackColor(0, 0, 0); - - -/*********************************************************************************************** - * RGBClass::Adjust -- Adjust one RGB value toward another. * - * * - * This routine is used to modify an RGB value to proportionately match another RGB value * - * according to the ratio parameter specified. Typical use of this routine is in palette * - * fading from one palette to another or to black. * - * * - * INPUT: ratio -- The ration of transformation. This value is in the form of 0 to 255, * - * with 0 being no change, and 255 being 100% transformed into the * - * destination color. * - * * - * rgb -- Reference to the destination RGB color to transform this color into. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -void RGBClass::Adjust(int ratio, RGBClass const & rgb) -{ - /* - ** Ratio conversion is limited to 0 through 100%. This is - ** the range of 0 to 255. - */ - ratio &= 0x00FF; - - - /* - ** Adjust the color guns by the ratio specified toward the - ** destination color. - */ - int value = (int)rgb.Red - (int)Red; - Red = (unsigned char)((int)Red + (value * ratio) / 256); - - value = (int)rgb.Green - (int)Green; - Green = (unsigned char)((int)Green + (value * ratio) / 256); - - value = (int)rgb.Blue - (int)Blue; - Blue = (unsigned char)((int)Blue + (value * ratio) / 256); -} - - -/*********************************************************************************************** - * RGBClass::Difference -- Determines the "distance" between two colors. * - * * - * This routine is used to calculate a relative distance between two colors. The value is * - * relative only to itself and thus is useful only for determining the magnitude of * - * color difference rather than the nature of the color difference. Palette remapping * - * code uses this routine to find closest matches for colors. * - * * - * INPUT: rgb -- Reference to the color to be compared to this color. * - * * - * OUTPUT: Returns the difference between the two colors. The value returned is zero if the * - * colors exactly match. The greater the positive value the greater the difference * - * between the colors. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 12/02/1995 JLB : Created. * - *=============================================================================================*/ -int RGBClass::Difference(RGBClass const & rgb) const -{ - int r = (int)Red - (int)rgb.Red; - if (r < 0) r = -r; - - int g = (int)Green - (int)rgb.Green; - if (g < 0) g = -g; - - int b = (int)Blue - (int)rgb.Blue; - if (b < 0) b = -b; - - /* - ** At first crack, the difference algorithm might be coded as the sum of the color differences - ** (or sum of the square of the color distances). However, this would not take advantage of the - ** fact that the human eye is most sensative to green, followed by the color blue. With this - ** thought in mind, the following difference algorithm is used. - */ - return(4*g + 3*b + 2*r); -} - - -/*********************************************************************************************** - * RGBClass::operator HSVClass -- Conversion operator for RGB to HSV object. * - * * - * This conversion operator will convert an RGBClass object into an HSVClass object. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with a reference (implicit) to the HSVClass object that most closely * - * represents the RGBClass object. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/20/1996 JLB : Created. * - *=============================================================================================*/ -RGBClass::operator HSVClass (void) const -{ - int hue; - int saturation; - int value; - - /* - ** Fetch working component values for the color guns. - */ - int red = Get_Red(); - int green = Get_Green(); - int blue = Get_Blue(); - - /* - ** The hue defaults to none. Only if there is a saturation value will the - ** hue be calculated. - */ - hue = 0; - - /* - ** Set the value (brightness) to match the brightest color gun. - */ - value = (red > green) ? red : green; - if (blue > value) value = blue; - - /* - ** Determine the amount of true white present in the color. This is the - ** minimum color gun value. The white component is used to determine - ** color saturation. - */ - int white = (red < green) ? red : green; - if (blue < white) white = blue; - - /* - ** Determine the saturation (intensity) of the color by comparing the - ** ratio of true white as a component of the overall color. The more - ** white component, the less saturation. - */ - saturation = 0; - if (value) { - saturation = ((value - white) * 255) / value; - } - - /* - ** If there is any saturation at all, then the hue must be calculated. The - ** hue is based on a six sided color wheel. - */ - if (saturation != 0) { - unsigned int tmp = value - white; - unsigned int r1 = ((value - red) * 255) / tmp; - unsigned int g1 = ((value - green) * 255) / tmp; - unsigned int b1 = ((value - blue) * 255) / tmp; - - // Find effect of second most predominant color. - // In which section of the hexagon of colors does the color lie? - if (value == red) { - if (white == green) { - tmp = 5 * 256 + b1; - } else { - tmp = 1 * 256 - g1; - } - } else { - if (value == green) { - if (white == blue) { - tmp = 1 * 256 + r1; - } else { - tmp = 3 * 256 - b1; - } - } else { - if (white == red) { - tmp = 3 * 256 + g1; - } else { - tmp = 5 * 256 - r1; - } - } - } - - // Divide by six and round. - hue = tmp / 6; - } - - HSVClass hsv((unsigned char)hue, (unsigned char)saturation, (unsigned char)value); - return(hsv); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rle.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rle.cpp deleted file mode 100644 index b6ad99b6313..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rle.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/RLE.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 9/24/98 10:05a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RLEEngine::Compress -- Compresses a sequence of bytes. * - * RLEEngine::Decompress -- Decompress a sequence of RLE compressed bytes. * - * RLEEngine::Line_Compress -- Compress a line of data. * - * RLEEngine::Line_Decompress -- Decompresses a line-compressed RLE data sequence. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "RLE.H" -#include -#include - - -/*********************************************************************************************** - * RLEEngine::Compress -- Compresses a sequence of bytes. * - * * - * This routine will compress the sequence of bytes specified by using RLE compression. * - * * - * INPUT: source -- Pointer to the data to be compressed. * - * * - * dest -- Pointer to the buffer that will hold the compressed data. * - * * - * length -- The length of the data to compress. * - * * - * OUTPUT: Returns with the number of bytes long for the compressed data. * - * * - * WARNINGS: The compressed data may, in rare instances, be larger than the data it was * - * compressing. The worst case is 33% larger. Keep that in mind when supplying * - * the destination buffer to this routine. * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Compress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(length > 0); - - int outlen = 0; - unsigned char const * sptr = (unsigned char const *) source; - unsigned char * dptr = (unsigned char *)dest; - while (length > 0) { - - /* - ** Examine each source byte. If the byte is zero (transparent), then - ** it is recorded as a run. Otherwise it is output without translation. - */ - if (*sptr == '\0') { - - /* - ** Count the number of transparent pixels in this run. - */ - int runcount = 0; - while (sptr[runcount] == '\0' && runcount <= length) { - runcount++; - } - - /* - ** Limit the run to 255 characters maximum. - */ - runcount = MIN(runcount, 255); - if (dptr != NULL) { - *dptr++ = '\0'; - *dptr++ = (unsigned char)runcount; - } - outlen += 2; - sptr += runcount; - length -= runcount; - - } else { - - /* - ** Store the raw byte without any translation. - */ - if (dptr != NULL) { - *dptr++ = *sptr++; - } else { - sptr++; - } - outlen++; - length--; - } - } - - /* - ** Return with the number of compressed output bytes. - */ - return(outlen); -} - - -/*********************************************************************************************** - * RLEEngine::Line_Compress -- Compress a line of data. * - * * - * This routine will compress a sequence of bytes and store the length of the compressed * - * data at the beginning of the output buffer. By encoding the compressed size in this * - * fashion, it is possible to build a sequence of compressed bytes (such as with a sprite) * - * so that each sequence can be quickly traversed. * - * * - * INPUT: source -- Pointer to the source data to be compressed. * - * * - * dest -- Pointer to the destination buffer that will hold the length value and * - * the compressed data. * - * * - * length -- The number of source bytes to compress. * - * * - * OUTPUT: Returns with the number of bytes stored into the output buffer. * - * * - * WARNINGS: The output data could be larger than the source data by as much as 33% + 2 * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Line_Compress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(length > 0); - - /* - ** If an output buffer was specified, then the data is actually compressed - ** into the buffer. - */ - if (dest != NULL) { - unsigned short * sizeptr = (unsigned short *)dest; - int complen = Compress(source, sizeptr+1, length) + sizeof(short); - *sizeptr = (unsigned short)complen; - return(complen); - } - - /* - ** Since no output buffer was specifed, this call merely determins how - ** many bytes would be consumed in the output buffer. - */ - return(Compress(source, NULL, length) + sizeof(short)); -} - - -/*********************************************************************************************** - * RLEEngine::Decompress -- Decompress a sequence of RLE compressed bytes. * - * * - * This will decompress a sequence of RLE compressed bytes. * - * * - * INPUT: source -- Pointer to the RLE compressed data. * - * * - * dest -- Pointer to the buffer that will hold the uncompressed data. * - * * - * length -- The length of the source RLE data to process. * - * * - * OUTPUT: Returns with the actual number of bytes stored into the output buffer. * - * * - * WARNINGS: The output buffer must be large enough to hold the decompressed data. This * - * could be as much as 128 times larger than the source RLE data. * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Decompress(void const * source, void * dest, int length) const -{ - assert(source != NULL); - assert(dest != NULL); - assert(length > 0); - - unsigned char * dptr = (unsigned char *)dest; - unsigned char const * sptr = (unsigned char const *)source; - - /* - ** Process the RLE data normally. - */ - while (length > 0) { - - /* - ** Detect if a zero-run code is present. If so, then dump the desired - ** number of bytes. Otherwise output the pixel in untranslated form. - */ - unsigned char value = *sptr++; - length--; - if (value == '\0') { - int outlen = *sptr++; - length--; - while (outlen > 0) { - *dptr++ = '\0'; - outlen--; - } - - } else { - *dptr++ = value; - } - } - - /* - ** Return with the number of bytes stored into the output buffer. - */ - return(dptr - (unsigned char const *)dest); -} - - -/*********************************************************************************************** - * RLEEngine::Line_Decompress -- Decompresses a line-compressed RLE data sequence. * - * * - * This routine is the counterpart to Line_Compress. It will take a compressed line and * - * fully decompress it into the destination buffer. * - * * - * INPUT: source -- The pointer to the line compressed RLE data. * - * * - * dest -- Pointer to the destination buffer that will hold the decompressed * - * data. * - * * - * OUTPUT: Returns with the number of bytes stored into the destination buffer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 04/17/1997 JLB : Created. * - *=============================================================================================*/ -int RLEEngine::Line_Decompress(void const * source, void * dest) const -{ - assert(source != NULL); - assert(dest != NULL); - - unsigned short const * sptr = (unsigned short const *)source; - - int datalen = *sptr++; - - /* - ** Process the RLE data normally. - */ - return(Decompress(sptr, dest, datalen - sizeof(short))); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rlerle.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rlerle.h deleted file mode 100644 index 5244409224b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rlerle.h +++ /dev/null @@ -1,709 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RLERLE.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RLERLE_H -#define RLERLE_H - -/* -** This class holds the RLE enabled blitter object definitions. There is a blitter object -** type for every kind of pixel operation required of RLE shapes. These are defined as -** templates to support the different destination pixel formats. -*/ - -#include "blitter.h" -#include -#include - - -/* -** This is a helper function that will skip N pixels in the RLE compressed source. This is -** necessary for clipping purposes. The return value represents the number of transparent -** pixels before actual pixel data starts when the RLE uncompression is resumed. -*/ -inline int Skip_Leading_Pixels(unsigned char const * & sptr, int skipper) -{ - /* - ** Skip leading pixels as requested. - */ - while (skipper > 0) { - if (*sptr++ == '\0') { - skipper -= *sptr++; - } else { - skipper--; - } - } - - /* - ** Return with then number of leading transparent pixels in the pixel stream - ** after the end of the skip process. This value must be tracked since the pixel - ** skip process may have ended in the middle of a transparent pixel run. - */ - return(-skipper); -} - - -/* -** Blits with transparency checking and translation to destination pixel format. -*/ -template -class RLEBlitTransXlat : public RLEBlitter { - public: - RLEBlitTransXlat(T const * translator) : TranslateTable(translator) {assert(TranslateTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[value]; - length -= 1; - } - } - } - - private: - T const * TranslateTable; -}; - - -/* -** This blits RLE compressed pixels by first remapping through a 256 byte table and then -** translating the pixel to screen format. -*/ -template -class RLEBlitTransRemapXlat : public RLEBlitter { - public: - RLEBlitTransRemapXlat(unsigned char const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(TranslateTable != NULL);assert(RemapTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[RemapTable[value]]; - length -= 1; - } - } - } - - private: - unsigned char const * RemapTable; - T const * TranslateTable; -}; - - -/* -** This blits RLE compressed pixels by first remapping through a 256 byte table and then -** translating the pixel to screen format. The remapping table is doubly indirected so that -** it is possible to change the remapping table pointer without creating a separate blitter -** object. -*/ -template -class RLEBlitTransZRemapXlat : public RLEBlitter { - public: - RLEBlitTransZRemapXlat(unsigned char const * const * remapper, T const * translator) : RemapTable(remapper), TranslateTable(translator) {assert(TranslateTable != NULL);assert(RemapTable != NULL);} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - unsigned char const * remapper = *RemapTable; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr++ = TranslateTable[remapper[value]]; - length -= 1; - } - } - } - - private: - unsigned char const * const * RemapTable; - T const * TranslateTable; -}; - - -/* -** This will remap the destination pixels but under the control of the source pixels. -** Where the source pixel is not transparent, the dest pixel is remapped. This algorithm -** really only applies to lowcolor display. -*/ -template -class RLEBlitTransRemapDest : public RLEBlitter { - public: - RLEBlitTransRemapDest(T const * remap) : RemapTable(remap) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = RemapTable[*dptr]; - length -= 1; - dptr++; - } - } - } - - private: - T const * RemapTable; -}; - - -/* -** Algorithmic darkening of hicolor pixels controlled by the source pixels. The source -** pixels are examined only to determine if the destination pixel should be darkened. -** If the source pixel is transparent, then the dest pixel is skipped. The darkening -** algorithm works only for hicolor pixels. -*/ -template -class RLEBlitTransDarken : public RLEBlitter { - public: - RLEBlitTransDarken(T mask) : Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = (T)((*dptr >> 1) & Mask); - length -= 1; - dptr++; - } - } - } - - private: - T Mask; -}; - - -/* -** This blitter performs 50% translucency as it draws. It is commonly used for animation -** effects and other stealth like images. It only works with hicolor pixels but is a good -** candidate for optimization. -*/ -template -class RLEBlitTransLucent50 : public RLEBlitter { - public: - RLEBlitTransLucent50(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - *dptr = (T)((((*dptr) >> 1) & Mask) + ((TranslateTable[value] >> 1) & Mask)); - length -= 1; - dptr++; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 25% translucency as it draws. This effect is less than spectacular, -** but there are some uses for it. It only works with hicolor pixels. -*/ -template -class RLEBlitTransLucent25 : public RLEBlitter { - public: - RLEBlitTransLucent25(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - T qsource = (T)(((TranslateTable[value] >> 2) & Mask)); - T qdest = (T)(((*dptr) >> 2) & Mask); - *dptr++ = (T)(qdest + qsource + qsource + qsource); - length -= 1; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -/* -** This blitter performs 75% translucency as it draws. This is quite useful for explosions and -** other gas animation effects. It only works with hicolor pixels and is a good candidate -** for optimization. -*/ -template -class RLEBlitTransLucent75 : public RLEBlitter { - public: - RLEBlitTransLucent75(T const * translator, T mask) : TranslateTable(translator), Mask(mask) {} - - virtual void Blit(void * dest, void const * source, int length, int leadskip=0) const - { - unsigned char const * sptr = (unsigned char const *)source; - T * dptr = (T *)dest; - - /* - ** Skip any leading pixels as requested. - */ - if (leadskip > 0) { - int transcount = Skip_Leading_Pixels(sptr, leadskip); - dptr += transcount; - length -= transcount; - } - - /* - ** Uncompress and store the pixel stream until the length has been - ** exhausted. - */ - while (length > 0) { - unsigned char value = *sptr++; - if (value == '\0') { - value = *sptr++; - length -= value; - dptr += value; - } else { - T qsource = (T)(((TranslateTable[value] >> 2) & Mask)); - T qdest = (T)(((*dptr) >> 2) & Mask); - *dptr++ = (T)(qdest + qdest + qdest + qsource); - length -= 1; - } - } - } - - private: - T const * TranslateTable; - T Mask; -}; - - -#if defined(_MSC_VER) -void RLEBlitTransZRemapXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned char const * remapper = *RemapTable; - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[remapper] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - mov edx,[transtable] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov al,[ebx+eax] - mov ax,[edx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - - -void RLEBlitTransRemapXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned char const * remapper = RemapTable; - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[remapper] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - mov edx,[transtable] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov al,[ebx+eax] - mov ax,[edx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - - -void RLEBlitTransXlat::Blit(void * dest, void const * source, int len, int leadskip) const -{ - unsigned short const * transtable = TranslateTable; - - /* - ** Set up the working registers for the blit operation. - */ - __asm { - mov ecx,[len] - mov edi,[dest] - mov esi,[source] - mov ebx,[transtable] - mov edx,[leadskip] - xor eax,eax - } - - /* - ** Skip leading pixels by analyzing the RLE data until the entire - ** requested skip pixel count has been processed. This could result in - ** unprocessed transparent pixels if it ended up in the middle of - ** a transparent pixel run. This is handled in the next block. - */ -moreskip: - __asm { - test edx,edx - jle nomoreskip - dec edx - lodsb - test al,al - jnz moreskip - lodsb - sub edx,eax - inc edx - jmp moreskip - } -nomoreskip: - - /* - ** Handle any left over transparent pixels that would be part of - ** a transparent pixel run that occurs at the end of the leading - ** pixel skip process. - */ - __asm { - neg edx - sub ecx,edx // Account for any left over transparent pixels - lea edi,[edi+edx*2] - } - - /* - ** Output the pixel data to the destination. - */ -moredata: - __asm { - xor eax,eax - or ecx,ecx - jle fini - lodsb - test al,al - jz transparent - mov ax,[ebx+eax*2] - dec ecx - stosw - jmp moredata - } - - /* - ** A transparent pixel run just causes the destination pointer - ** and length count to be adjusted by the length of the run. - */ -transparent: - __asm { - lodsb - lea edi,[edi+eax*2] - sub ecx,eax - jmp moredata - } - -fini:; -} - -#endif - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstraw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstraw.cpp deleted file mode 100644 index 103bf508152..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstraw.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/RNDSTRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RandomStraw::Get -- Fetch random data. * - * RandomStraw::RandomStraw -- Constructor for the random straw class. * - * RandomStraw::Reset -- Reset the data to known initial state. * - * RandomStraw::Scramble_Seed -- Masks any coorelation between the seed bits. * - * RandomStraw::Seed_Bit -- Add a random bit to the accumulated seed value. * - * RandomStraw::Seed_Bits_Needed -- Fetches the number of seed bits needed. * - * RandomStraw::Seed_Byte -- Submit 8 bits to the random number seed. * - * RandomStraw::Seed_Long -- Submit 32 bits to the random number seed. * - * RandomStraw::Seed_Short -- Submit 16 bits to the random number seed. * - * RandomStraw::~RandomStraw -- Destructor for random straw class. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "RNDSTRAW.H" -#include "sha.h" -#include -#include - - -/*********************************************************************************************** - * RandomStraw::RandomStraw -- Constructor for the random straw class. * - * * - * This will initialize the random straw into a known state. The initial state is useless * - * for cryptographic purposes. It must be seeded before it should be used. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -RandomStraw::RandomStraw(void) : - SeedBits(0), - Current(0) -{ - Reset(); -} - - -/*********************************************************************************************** - * RandomStraw::~RandomStraw -- Destructor for random straw class. * - * * - * This destructor will clear out the seed data so that there won't be any sensitive * - * information left over in the memory this object occupied. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -RandomStraw::~RandomStraw(void) -{ - Reset(); -} - - -/*********************************************************************************************** - * RandomStraw::Reset -- Reset the data to known initial state. * - * * - * This routine is functionally equivalent to performing an placement new on the object. It * - * clears out all the seed data. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: You must reseed it before fetching random numbers. * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Reset(void) -{ - SeedBits = 0; - Current = 0; - memset(Random, '\0', sizeof(Random)); -} - - -/*********************************************************************************************** - * RandomStraw::Seed_Bits_Needed -- Fetches the number of seed bits needed. * - * * - * This routine is used when seeding the random straw. Keep feeding random bits to this * - * class until the Seed_Bits_Needed value returns zero. Random bits should be gathered from * - * sources external to the immediate program. Examples would be the system clock (good for * - * a few bits), the delay between player keystrokes (good for a few bits per keystroke), * - * etc. When gathering random bits from integers, use the low order bits (since they * - * characteristically are less predictable and more 'random' than the others). * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the number of bits required in order to fully seed this random * - * number generator. * - * * - * WARNINGS: Even if this routine returns zero, you are still allowed and encouraged to feed * - * more random bits when the opportunity arrises. * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -int RandomStraw::Seed_Bits_Needed(void) const -{ - const int total = sizeof(Random) * CHAR_BIT; - if (SeedBits < total) { - return(total - SeedBits); - } - return(0); -} - - -/*********************************************************************************************** - * RandomStraw::Seed_Bit -- Add a random bit to the accumulated seed value. * - * * - * This routine should be called to feed a single random bit to the random straw object. * - * You must feed as many bits as requested by the Seed_Bits_Needed() function. Submitting * - * additional bits is not only allowed, but encouraged. * - * * - * INPUT: seed -- The bit (lowest order bit) to feed to the random number seed. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Seed_Bit(int seed) -{ - char * ptr = ((char *)&Random[0]) + ((SeedBits / CHAR_BIT) % sizeof(Random)); - char frac = (char)(1 << (SeedBits & (CHAR_BIT-1))); - - if (seed & 0x01) { - *ptr ^= frac; - } - SeedBits++; - - if (SeedBits == (sizeof(Random) * CHAR_BIT)) { - Scramble_Seed(); - } -} - - -/*********************************************************************************************** - * RandomStraw::Seed_Byte -- Submit 8 bits to the random number seed. * - * * - * This will submit 8 bits (as specified) to the random number seed. * - * * - * INPUT: seed -- The seed bits to submit. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Seed_Byte(char seed) -{ - for (int index = 0; index < CHAR_BIT; index++) { - Seed_Bit(seed); - seed >>= 1; - } -} - - -/*********************************************************************************************** - * RandomStraw::Seed_Short -- Submit 16 bits to the random number seed. * - * * - * This will submit 16 bits to the accumulated seed. * - * * - * INPUT: seed -- The 16 bits to submit to the seed. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Seed_Short(short seed) -{ - for (int index = 0; index < (sizeof(seed)*CHAR_BIT); index++) { - Seed_Bit(seed); - seed >>= 1; - } -} - - -/*********************************************************************************************** - * RandomStraw::Seed_Long -- Submit 32 bits to the random number seed. * - * * - * This will submit a full 32 bits to the accumulated seed value. * - * * - * INPUT: seed -- The 32 bits to submit. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Seed_Long(long seed) -{ - for (int index = 0; index < (sizeof(seed)*CHAR_BIT); index++) { - Seed_Bit(seed); - seed >>= 1; - } -} - - -/*********************************************************************************************** - * RandomStraw::Scramble_Seed -- Masks any coorelation between the seed bits. * - * * - * This routine is called when a full set of seed bits has been accumulated. It will take * - * the existing seed and scramble the bits. An effective way of doing this is to use the * - * Secure Hash Algorithm. It is necessary to have this routine because there might be * - * some coorelation in the seed bits. Even more important is that this routine will result * - * in every bit of the seed having a scrambling effect on every other bit. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/10/1996 JLB : Created. * - *=============================================================================================*/ -void RandomStraw::Scramble_Seed(void) -{ - SHAEngine sha; - - for (int index = 0; index < sizeof(Random); index++) { - char digest[20]; - - sha.Hash(&Random[0], sizeof(Random)); - sha.Result(digest); - - int tocopy = sizeof(digest) < (sizeof(Random)-index) ? sizeof(digest) : (sizeof(Random)-index); - memmove(((char *)&Random[0]) + index, digest, tocopy); - } -} - - -/*********************************************************************************************** - * RandomStraw::Get -- Fetch random data. * - * * - * This routine will fetch random data and store it into the buffer specified. * - * * - * INPUT: source -- Pointer to the buffer to fill with random data. * - * * - * length -- The number of bytes to store into the buffer. * - * * - * OUTPUT: Returns with the actual number of bytes stored into the buffer. This will always * - * be the number of bytes requested since random numbers are unexhaustible. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/04/1996 JLB : Created. * - * 07/10/1996 JLB : Revamped to make cryptographically secure. * - *=============================================================================================*/ -int RandomStraw::Get(void * source, int slen) -{ - if (source == NULL || slen < 1) { - return(Straw::Get(source, slen)); - } - - int total = 0; - while (slen > 0) { - *(char *)source = (char)(Random[Current++]()); - Current = Current % (sizeof(Random) / sizeof(Random[0])); - source = (char*)source + sizeof(char); - slen--; - total++; - } - return(total); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp deleted file mode 100644 index 9e75bda53ce..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/rndstrng.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 9/01/01 11:05a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "rndstrng.h" -#include "wwstring.h" - -/* -** -*/ - -void RandomStringClass::Add_String( const char * str ) -{ - Strings.Add( str ); -} - -const char * RandomStringClass::Get_String( void ) -{ - if ( Strings.Count() == 0 ) { - return NULL; - } - unsigned int index = Randomizer(); - index %= Strings.Count(); - return Strings[index]; -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h deleted file mode 100644 index 0906fa365af..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rndstrng.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/rndstrng.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 9/01/01 11:03a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNDSTRNG_H -#define RNDSTRNG_H - -#include "Vector.H" -#include "RANDOM.H" - -class StringClass; - -/* -** -*/ -class RandomStringClass { - -public: - // Add a string to the class. - // (future version may have a weight parameter) - void Add_String( const char * str ); - - // Get a random string from the class - const char * Get_String( void ); - -private: - DynamicVectorClass Strings; - Random2Class Randomizer; -}; - -#endif // RNDSTRNG_H - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rng.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rng.h deleted file mode 100644 index f0371174413..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rng.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/rng.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:00p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef RNG_H -#define RNG_H - -/* -** This is an abstract interface class for a random number generator. It serves only to -** provide random numbers. -*/ -class RandomNumberGenerator { - public: - virtual ~RandomNumberGenerator() {} - - virtual void Get_Block(void * output, unsigned int size) = 0; -}; - - -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h deleted file mode 100644 index e6cc08c51a2..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/rsacrypt.h +++ /dev/null @@ -1,349 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef RSACRYPT_H -#define RSACRYPT_H - -#include -#include - -//#define SIMPLE_AND_SLOW_RSA - -// Version identification string for OpenSSH identity files. -#define AUTHFILE_ID_STRING "SSH PRIVATE KEY FILE FORMAT 1.1\n" - -// -// RSACrypt - Implementation of RSA using the Int class from wwlib -// -// For key generation I suggest you use OpenSSH (http://www.openssh.com/) -// There is a utility called "ssh-keygen", call: -// -// ssh-keygen [-b bits] -// -// If you generate the file on a UNIX system, be sure and FTP it in BINARY MODE!!!! -// -// You can then use 'Load_SSH_Keyset' on the identity file it produces. -// -// Note: Make sure you leave the keyphrase blank for the SSH keyset. I don't support -// decrypting that file! -// -// Notation: -// Public keys: -// n = product of two primes, p & q (p & q must remain secret) -// e = relatively prime to (p-1)(q-1) -// -// Private keys: -// d = e^-1 mod ((p-1)(q-1)) // e^-1 = inverse of e -// -// Encrypting: -// cyphertext = m^e mod n -// -// Decrypting: -// message = cyphertext^d mod n -// -// Note: I use a trick involving the chinese remainder theorem to get a 3x speedup in decryption. -// It's well documented on the web so I won't get into detail here. -// -template -class RSACrypt -{ - public: - typedef Int Integer; - - RSACrypt() {} - ~RSACrypt() {} - - void Set_Public_Keys(const Integer &pub_n, const Integer &pub_e); - void Set_Keys(const Integer &pub_n, const Integer &pub_e, - const Integer &priv_d, const Integer &keygen_p, const Integer &keygen_q); - - void Get_Public_Keys(Integer &pub_n, Integer &pub_e) const; - void Get_Private_Key(Integer &priv_d) const; - void Get_Keygen_Keys(Integer &keygen_p, Integer &keygen_q) const; - - bool Load_SSH_Keyset(FileClass *file); - - void Encrypt(const Integer &plaintext, Integer &cyphertext) const; - void Decrypt(const Integer &cyphertext, Integer &plaintext) const; - - private: - bool Load_Bignum(FileClass *file, Integer &num); - - void Decryption_Setup(); // Do precomputation to speedup decryption - - Integer PublicN; - Integer PublicE; - - Integer PrivateD; - - Integer KeygenP; // Primes P & Q generated as part of the keyset - Integer KeygenQ; - - // Precomputed values that speed up encryption - Integer DmodPm1; // d mod p-1 - Integer DmodQm1; // d mod q-1 - - Integer RP; // RP = q^(p-1) mod n - Integer RQ; // RQ = p^(q-1) mod n; -}; - -// -// Set the two public keys: n & e -// -template -void RSACrypt::Set_Public_Keys(const Integer &pub_n, const Integer &pub_e) -{ - PublicN=pub_n; - PublicE=pub_e; -} - -// -// Set the public & private keys: n, e & d -// -template -void RSACrypt::Set_Keys(const Integer &pub_n, const Integer &pub_e, - const Integer &priv_d, const Integer &keygen_p, const Integer &keygen_q) -{ - PublicN=pub_n; - PublicE=pub_e; - PrivateD=priv_d; - - KeygenP=keygen_p; - KeygenQ=keygen_q; - - Decrtyption_Setup(); -} - -// -// Get the public keys -// -template -void RSACrypt::Get_Public_Keys(Integer &pub_n, Integer &pub_e) const -{ - pub_n=PublicN; - pub_e=PublicE; -} - -// -// Get the private key -// -template -void RSACrypt::Get_Private_Key(Integer &priv_d) const -{ - priv_d=PrivateD; -} - - -// -// Get the private numbers created during the keyset generation -// Private as in revealing these will reveal the private key! -// -template -void RSACrypt::Get_Keygen_Keys(Integer &keygen_p, Integer &keygen_q) const -{ - keygen_p=KeygenP; - keygen_q=KeygenQ; -} - - -// -// Load an RSA private keyset from an OpenSSH "identity" file. -// -template -bool RSACrypt::Load_SSH_Keyset(FileClass *file) -{ - assert(file); - if ( ! file) - return(false); - - bool retval=true; - unsigned char buffer[1024]; - - if ( ! file->Open()) - return(false); - - file->Read(buffer, strlen(AUTHFILE_ID_STRING)+1); - buffer[strlen(AUTHFILE_ID_STRING)]=0; // null term - - if (strcmp((char *)buffer, AUTHFILE_ID_STRING)) - return(false); - - unsigned char cypher_type; // keyfile encryption method - file->Read(&cypher_type, 1); - if (cypher_type != 0) - return(false); - - file->Read(buffer, 4); // reserved data - - file->Read(buffer, 4); // ignored - - retval=retval && Load_Bignum(file, PublicN); - retval=retval && Load_Bignum(file, PublicE); - if (!retval) - return(false); - - // comment string - int comment_length; - file->Read(&comment_length, 4); - comment_length=ntohl(comment_length); - - file->Read(buffer, comment_length); - - // post-decrypt check chars - file->Read(buffer, 4); - if ((buffer[0] != buffer[2]) || (buffer[1] != buffer[3])) - return(false); - - Integer q_inv_mod_p; // invserse of q mod p (we don't need this) - - retval=retval && Load_Bignum(file, PrivateD); - retval=retval && Load_Bignum(file, q_inv_mod_p); - retval=retval && Load_Bignum(file, KeygenP); - retval=retval && Load_Bignum(file, KeygenQ); - if (!retval) - return(false); - - // Any remaining bytes are padding - - Decryption_Setup(); - - return(true); -} - -// -// Precomputation for fast decryption -// -template -void RSACrypt::Decryption_Setup(void) -{ - Integer temp; - - // If p < q, swap p & q - if (KeygenP < KeygenQ) - { - temp=KeygenP; - KeygenP=KeygenQ; - KeygenQ=temp; - } - - assert(KeygenP > KeygenQ); - - // pm1 = p - 1 - Integer pm1(KeygenP); - --pm1; - - // pm1 = p - 1 - Integer qm1(KeygenQ); - --qm1; - - // DmodPm1 = d mod (p-1) - Integer::Unsigned_Divide(DmodPm1, temp, PrivateD, pm1); - assert(DmodPm1 < pm1); - - // DmodQm1 = d mod (q-1) - Integer::Unsigned_Divide(DmodQm1, temp, PrivateD, qm1); - assert(DmodQm1 < qm1); - - RP = KeygenQ.exp_b_mod_c(pm1, PublicN); - RQ = KeygenP.exp_b_mod_c(qm1, PublicN); -} - - -// -// RSA Encryption c = m^e mod n -// -template -void RSACrypt::Encrypt(const Integer &plaintext, Integer &cyphertext) const -{ - Integer m(plaintext); - cyphertext=m.exp_b_mod_c(PublicE, PublicN); -} - - -// -// RSA Decryption m = c^d mod n -// -template -void RSACrypt::Decrypt(const Integer &cyphertext, Integer &plaintext) const -{ -#ifdef SIMPLE_AND_SLOW_RSA - Integer c(cyphertext); - plaintext=c.exp_b_mod_c(PrivateD, PublicN); -#else - Integer temp; - - // Get a version of the cyphertext mod q & p - Integer cmp, cmq; - Integer::Unsigned_Divide(cmp, temp, cyphertext, KeygenP); - Integer::Unsigned_Divide(cmq, temp, cyphertext, KeygenQ); - - // mp = cmp ^ dmp mod p - Integer mp; - mp=cmp.exp_b_mod_c(DmodPm1, KeygenP); - - // mq = cmq ^ dmq mod q - Integer mq; - mq=cmq.exp_b_mod_c(DmodQm1, KeygenQ); - - - Integer sp, sq; - - //sp=mp * RP mod n; - //sq=mq * RQ mod n; - XMP_Prepare_Modulus(&PublicN.reg[0], PRECISION); - XMP_Mod_Mult(&sp.reg[0], &mp.reg[0], &RP.reg[0], PRECISION); - XMP_Mod_Mult(&sq.reg[0], &mq.reg[0], &RQ.reg[0], PRECISION); - XMP_Mod_Mult_Clear(PRECISION); - - plaintext = sp+sq; - if (plaintext >= PublicN) - plaintext-=PublicN; - -#endif -} - - -////////////////////////////////// Private Methods Below /////////////////////////////////// - -// -// Load a large number from the SSH keyset file -// -template -bool RSACrypt::Load_Bignum(FileClass *file, Integer &num) -{ - int readlen; - unsigned char buffer[1024]; - unsigned short int n_bits, n_bytes; - - readlen=file->Read(&n_bits, 2); // bits in network byte order - if (readlen != 2) - return(false); - n_bits=ntohs(n_bits); - n_bytes=(n_bits+7)/8; - - readlen=file->Read(buffer, n_bytes); - if (readlen != n_bytes) - return(false); - - num.Unsigned_Decode(buffer, n_bytes); - - return(true); -} - - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp deleted file mode 100644 index 8e135b74a09..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sampler.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Sampler * - * * - * $Archive:: /VSS_Sync/wwlib/sampler.cpp $* - * * - * Original Author:: Hector Yee * - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 10:25p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RandomSamplingClass::Sample -- Samples randomly over a hypercube using Mersenne Twister * - * RegularSamplingClass::Sample -- Samples over a regular hypergrid * - * StratifiedSamplingClass::Sample -- samples over a regular hypergrid with random offset * - * QMCSamplingClass::Sample -- Samples using the Halton sequence * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -// Use Random Sampling if you're not sure -// Use Regular Sampling if you're not concerned about bias -// Use Stratified Sampling if you want good results in low dimensions -// Use QMC if you want low discrepancy and you want reproduceablility - -#include "always.h" -#include "sampler.h" -#include "RANDOM.H" -#include -#include -#include - -Random4Class Random; - -RandomSamplingClass::RandomSamplingClass(unsigned int dimensions,unsigned char divisions): - SamplingClass(dimensions,divisions) -{ -} - -/*********************************************************************************************** - * RandomSamplingClass::Sample -- Samples randomly over a hypercube using Mersenne Twister * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/11/2001 hy : Created. * - *=============================================================================================*/ -void RandomSamplingClass::Sample(float *target) -{ - unsigned int i; - for (i=0; i. -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Sampler * - * * - * $Archive:: /VSS_Sync/wwlib/sampler.h $* - * * - * Original Author:: Hector Yee * - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 10:25p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -// 'function selected for automatic inline expansion'. Cool, but since we're treating -// warnings as errors, don't warn me about this! -#pragma warning(disable : 4711) - -// 'not inlined' -- the evil twin of the above warning. -#pragma warning(disable : 4710) - -#ifndef SAMPLER_H -#define SAMPLER_H - -class Random4Class; - -// This module contains sampling techniques that sample over multidimensional space -// Dimension is the length of the vector to sample -// Divisions is used to determine the number of strata to sample over -// In some samplers, e.g. regular grid, it will repeat after dimension*division calls -// to sample. A call to sample increments the internal state of the sampler. -// Hector Yee 6/11/01 - -// Abstract base class -// all these sampling algoriths modify a vector of length Dimensions -// they all return a value between 0..1 -// Hector Yee 6/11/01 -class SamplingClass -{ -public: - SamplingClass(unsigned int dimensions, unsigned char divisions): - Dimensions(dimensions), - Divisions(divisions) - {}; - virtual void Reset() {}; - virtual void Sample(float *target)=0; - virtual ~SamplingClass() {}; -protected: - unsigned int Dimensions; - unsigned char Divisions; -}; - -// Samples randomly in the dimensions using Mesenne Twister -// divisions ignored -// Hector Yee 6/11/01 -class RandomSamplingClass : public SamplingClass -{ -public: - RandomSamplingClass(unsigned int dimensions, unsigned char divisions=0); - virtual void Reset() {}; - virtual void Sample(float *target); -}; - -// samples over a regular hypergrid -// Hector Yee 6/11/01 -class RegularSamplingClass : public SamplingClass -{ -public: - RegularSamplingClass(unsigned int dimensions, unsigned char divisions=3); - virtual void Reset(); - virtual void Sample(float *target); - virtual ~RegularSamplingClass(); -protected: - unsigned char *index; -}; - -// samples over a regular hypergrid with random perturbations -// Hector Yee 6/11/01 -class StratifiedSamplingClass : public SamplingClass -{ -public: - StratifiedSamplingClass(unsigned int dimensions, unsigned char divisions=3); - virtual void Reset(); - virtual void Sample(float *target); - virtual ~StratifiedSamplingClass(); -protected: - unsigned char *index; -}; - -// samples using QuasiMonteCarlo -// divisions ignored -// based on the Halton-Hammersly sequence which is in turn based on the inverse radical function -// Hector Yee 6/11/01 -class QMCSamplingClass : public SamplingClass -{ -public: - QMCSamplingClass(unsigned int dimensions, unsigned char divisions=0); - virtual void Reset() {index=0;}; - virtual void Sample(float *target); - void Set_Offset(unsigned int offset) { index=offset; } -protected: - unsigned int index; -}; - - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/search.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/search.h index 3469cf9c25f..f981a48d05c 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/search.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/search.h @@ -57,7 +57,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" #if !defined(__BORLANDC__) || !defined(_USERENTRY) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.cpp deleted file mode 100644 index 7f4a4a1b110..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHA.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SHAEngine::Result -- Fetch the current digest. * - * SHAEngine::Hash -- Process an arbitrarily long data block. * - * SHAEngine::Process_Partial -- Helper routine to process any partially accumulated data blo* - * SHAEngine::Process_Block -- Process a full data block into the hash accumulator. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "sha.h" -#include -#include - - -#if !defined(__BORLANDC__) && !defined(min) -#define min(a, b) ((a)<(b))?(a):(b) -#endif - - -/*********************************************************************************************** - * SHAEngine::Process_Partial -- Helper routine to process any partially accumulated data bloc * - * * - * This routine will see if there is a partial block already accumulated in the holding * - * buffer. If so, then the data is fetched from the source such that a full buffer is * - * accumulated and then processed. If there is insufficient data to fill the buffer, then * - * it accumulates what data it can and then returns so that this routine can be called * - * again later. * - * * - * INPUT: data -- Reference to a pointer to the data. This pointer will be modified if * - * this routine consumes any of the data in the buffer. * - * * - * length-- Reference to the length of the data available. If this routine consumes * - * any of the data, then this length value will be modified. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Process_Partial(void const * & data, long & length) -{ - if (length == 0 || data == NULL) return; - - /* - ** If there is no partial buffer and the source is greater than - ** a source block size, then partial processing is unnecessary. - ** Bail out in this case. - */ - if (PartialCount == 0 && length >= SRC_BLOCK_SIZE) return; - - /* - ** Attach as many bytes as possible from the source data into - ** the staging buffer. - */ - int add_count = min((int)length, SRC_BLOCK_SIZE - PartialCount); - memcpy(&Partial[PartialCount], data, add_count); - data = ((char const *&)data) + add_count; - PartialCount += add_count; - length -= add_count; - - /* - ** If a full staging buffer has been accumulated, then process - ** the staging buffer and then bail. - */ - if (PartialCount == SRC_BLOCK_SIZE) { - Process_Block(&Partial[0], Acc); - Length += (long)SRC_BLOCK_SIZE; - PartialCount = 0; - } -} - - -/*********************************************************************************************** - * SHAEngine::Hash -- Process an arbitrarily long data block. * - * * - * This is the main access routine to the SHA engine. It will take the arbitrarily long * - * data block and process it. The hash value is accumulated with any previous calls to * - * this routine. * - * * - * INPUT: data -- Pointer to the data block to process. * - * * - * length -- The number of bytes to process. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Hash(void const * data, long length) -{ - IsCached = false; - - /* - ** Check for and handle any smaller-than-512bit blocks. This can - ** result in all of the source data submitted to this routine to be - ** consumed at this point. - */ - Process_Partial(data, length); - - /* - ** If there is no more source data to process, then bail. Speed reasons. - */ - if (length == 0) return; - - /* - ** First process all the whole blocks available in the source data. - */ - long blocks = (length / SRC_BLOCK_SIZE); - long const * source = (long const *)data; - for (int bcount = 0; bcount < blocks; bcount++) { - Process_Block(source, Acc); - Length += (long)SRC_BLOCK_SIZE; - source += SRC_BLOCK_SIZE/sizeof(long); - length -= (long)SRC_BLOCK_SIZE; - } - - /* - ** Process any remainder bytes. This data is stored in the source - ** accumulator buffer for future processing. - */ - data = source; - Process_Partial(data, length); -} - - -#define Reverse_LONG(a) ((a>>24)&0x000000FFL) | ((a>>8)&0x0000FF00L) | ((a<<8)&0x00FF0000L) | ((a<<24)&0xFF000000L) - - -/*********************************************************************************************** - * SHAEngine::Result -- Fetch the current digest. * - * * - * This routine will return the digest as it currently stands. * - * * - * INPUT: pointer -- Pointer to the buffer that will hold the digest -- 20 bytes. * - * * - * OUTPUT: Returns with the number of bytes copied into the buffer. This will always be * - * 20. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAEngine::Result(void * result) const -{ - /* - ** If the final hash result has already been calculated for the - ** current data state, then immediately return with the precalculated - ** value. - */ - if (IsCached) { - memcpy(result, &FinalResult, sizeof(FinalResult)); - } - - long length = Length + PartialCount; - int partialcount = PartialCount; - unsigned char partial[SRC_BLOCK_SIZE]; - memcpy(partial, Partial, sizeof(Partial)); - - /* - ** Cap the end of the source data stream with a 1 bit. - */ - partial[partialcount] = (unsigned char)0x80; - - /* - ** Determine if there is insufficient room to append the - ** data length number to the hash source. If not, then - ** fill out the rest of the accumulator and flush it to - ** the hash so that there will be room for the final - ** count value. - */ - SHADigest acc = Acc; - if ((SRC_BLOCK_SIZE - partialcount) < 9) { - if (partialcount+1 < SRC_BLOCK_SIZE) { - memset(&partial[partialcount+1], '\0', SRC_BLOCK_SIZE - (partialcount+1)); - } - Process_Block(&partial[0], acc); - partialcount = 0; - } else { - partialcount++; - } - - /* - ** Put the length of the source data as a 64 bit integer in the - ** last 8 bytes of the pseudo-source data. - */ - memset(&partial[partialcount], '\0', SRC_BLOCK_SIZE - partialcount); - *(long *)(&partial[SRC_BLOCK_SIZE-4]) = Reverse_LONG((length*8)); - Process_Block(&partial[0], acc); - - memcpy((char *)&FinalResult, &acc, sizeof(acc)); - for (int index = 0; index < sizeof(FinalResult)/sizeof(long); index++) { -// for (int index = 0; index < SRC_BLOCK_SIZE/sizeof(long); index++) { - (long &)FinalResult.Long[index] = Reverse_LONG(FinalResult.Long[index]); - } - (bool&)IsCached = true; - memcpy(result, &FinalResult, sizeof(FinalResult)); - return(sizeof(FinalResult)); -} - -/* -** This pragma to turn off the warning "Conversion may lose significant digits" is to -** work around a bug within the Borland compiler. It will give this warning when the -** _rotl() function is called but will NOT give the warning when the _lrotl() function -** is called even though they both have the same parameters and declaration attributes. -*/ -#ifdef __BORLANDC__ -#pragma warn -sig -#endif - -template -T _rotl(T X, int n) -{ - return(T)( ( X << n ) | ( (unsigned)X >> ((sizeof(T)*8) - n) ) ); -} -inline long _rotl(long X, int n) -{ - return(long)( ( X << n ) | ( (unsigned)X >> ((sizeof(long)*8) - n) ) ); -} - -inline unsigned long _rotl(unsigned long X, int n) -{ - return(unsigned long)( ( X << n ) | ( (unsigned)X >> ((sizeof(unsigned long)*8) - n) ) ); -} - -//unsigned long _RTLENTRY _rotl(unsigned long X, int n) -//{ -// return(unsigned long)( (unsigned long)( (unsigned long)( (unsigned long)X ) << (int)n ) | (unsigned long)( ((unsigned long) X ) >> ( (int)((int)(sizeof(long)*(long)8) - (long)n) ) ) ); -//} -void memrev(char * buffer, size_t length); - - -/*********************************************************************************************** - * SHAEngine::Process_Block -- Process a full data block into the hash accumulator. * - * * - * This helper routine is called when a full block of data is available for processing * - * into the hash. * - * * - * INPUT: source -- Pointer to the block of data to process. * - * * - * acc -- Reference to the hash accumulator that this hash step will be * - * accumulated into. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -void SHAEngine::Process_Block(void const * source, SHADigest & acc) const -{ - /* - ** The hash is generated by performing operations on a - ** block of generated/seeded data. - */ - long block[PROC_BLOCK_SIZE/sizeof(long)]; - - /* - ** Expand the source data into a large 80 * 32bit buffer. This is the working - ** data that will be transformed by the secure hash algorithm. - */ - long const * data = (long const *)source; - int index; - for (index = 0; index < SRC_BLOCK_SIZE/sizeof(long); index++) { - block[index] = Reverse_LONG(data[index]); - } - - for (index = SRC_BLOCK_SIZE/sizeof(long); index < PROC_BLOCK_SIZE/sizeof(long); index++) { -// block[index] = _rotl(block[(index-3)&15] ^ block[(index-8)&15] ^ block[(index-14)&15] ^ block[(index-16)&15], 1); - block[index] = _rotl(block[index-3] ^ block[index-8] ^ block[index-14] ^ block[index-16], 1); - } - - /* - ** This is the core algorithm of the Secure Hash Algorithm. It is a block - ** transformation of 512 bit source data with a 2560 bit intermediate buffer. - */ - SHADigest alt = acc; - for (index = 0; index < PROC_BLOCK_SIZE/sizeof(long); index++) { - long temp = _rotl(alt.Long[0], 5) + Do_Function(index, alt.Long[1], alt.Long[2], alt.Long[3]) + alt.Long[4] + block[index] + Get_Constant(index); - alt.Long[4] = alt.Long[3]; - alt.Long[3] = alt.Long[2]; - alt.Long[2] = _rotl(alt.Long[1], 30); - alt.Long[1] = alt.Long[0]; - alt.Long[0] = temp; - } - acc.Long[0] += alt.Long[0]; - acc.Long[1] += alt.Long[1]; - acc.Long[2] += alt.Long[2]; - acc.Long[3] += alt.Long[3]; - acc.Long[4] += alt.Long[4]; -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.h deleted file mode 100644 index d48cc6a89eb..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/sha.h +++ /dev/null @@ -1,195 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHA.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHA_H -#define SHA_H - - -/* -** The "bool" integral type was defined by the C++ comittee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#include -#include "always.h" -#include "bool.h" -#include -#include -#include - - -/* -** This implements the Secure Hash Algorithm. It is a cryptographically -** secure hash with no known weaknesses. It generates a 160 bit hash -** result given an arbitrary length data source. -*/ -class SHAEngine -{ - public: - SHAEngine(void) : IsCached(false), Length(0), PartialCount(0) { - Acc.Long[0] = (unsigned long)SA; - Acc.Long[1] = (unsigned long)SB; - Acc.Long[2] = (unsigned long)SC; - Acc.Long[3] = (unsigned long)SD; - Acc.Long[4] = (unsigned long)SE; - }; - - void Init(void) { - new ((void*)this) SHAEngine; - }; - - // Fetch result as if source data were to stop now. - int Result(void * result) const; - - void Hash(void const * data, long length); - - static int Digest_Size(void) {return(sizeof(SHADigest));} - - private: - - typedef union { - unsigned long Long[5]; - unsigned char Char[20]; - } SHADigest; - - /* - ** This holds the calculated final result. It is cached - ** here to avoid the overhead of recalculating it over - ** multiple sequential requests. - */ - bool IsCached; - SHADigest FinalResult; - - enum { - // These are the initial seeds to the block accumulators. - SA=0x67452301L, - SB=0xefcdab89L, - SC=0x98badcfeL, - SD=0x10325476L, - SE=0xc3d2e1f0L, - - // These are the constants used in the block transformation. - K1=0x5a827999L, // t=0..19 2^(1/2)/4 - K2=0x6ed9eba1L, // t=20..39 3^(1/2)/4 - K3=0x8f1bbcdcL, // t=40..59 5^(1/2)/4 - K4=0xca62c1d6L, // t=60..79 10^(1/2)/4 - - // Source data is grouped into blocks of this size. - SRC_BLOCK_SIZE=16*sizeof(long), - - // Internal processing data is grouped into blocks this size. - PROC_BLOCK_SIZE=80*sizeof(long) - }; - - long Get_Constant(int index) const { - if (index < 20) return K1; - if (index < 40) return K2; - if (index < 60) return K3; - return K4; - }; - - // Used for 0..19 - long Function1(long X, long Y, long Z) const { - return(Z ^ ( X & ( Y ^ Z ) ) ); - }; - - // Used for 20..39 - long Function2(long X, long Y, long Z) const { - return( X ^ Y ^ Z ); - }; - - // Used for 40..59 - long Function3(long X, long Y, long Z) const { - return( (X & Y) | (Z & (X | Y) ) ); - }; - - // Used for 60..79 - long Function4(long X, long Y, long Z) const { - return( X ^ Y ^ Z ); - }; - - long Do_Function(int index, long X, long Y, long Z) const { - if (index < 20) return Function1(X, Y, Z); - if (index < 40) return Function2(X, Y, Z); - if (index < 60) return Function3(X, Y, Z); - return Function4(X, Y, Z); - }; - - // Process a full source data block. - void Process_Block(void const * source, SHADigest & acc) const; - - // Processes a partially filled source accumulator buffer. - void Process_Partial(void const * & data, long & length); - - /* - ** This is the running accumulator values. These values - ** are updated by a block processing step that occurs - ** every 512 bits of source data. - */ - SHADigest Acc; - - /* - ** This is the running length of the source data - ** processed so far. This total is used to modify the - ** resulting hash value as if it were appended to the end - ** of the source data. - */ - long Length; - - /* - ** This holds any partial source block. Partial source blocks are - ** a consequence of submitting less than block sized data chunks - ** to the SHA Engine. - */ - int PartialCount; - char Partial[SRC_BLOCK_SIZE]; -}; - - -#define SHA_SOURCE1 "abc" -#define SHA_DIGEST1a "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" -#define SHA_DIGEST1b "\x01\x64\xB8\xA9\x14\xCD\x2A\x5E\x74\xC4\xF7\xFF\x08\x2C\x4D\x97\xF1\xED\xF8\x80" - - -#define SHA_SOURCE2 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" -#define SHA_DIGEST2a "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1" -#define SHA_DIGEST2b "\xD2\x51\x6E\xE1\xAC\xFA\x5B\xAF\x33\xDF\xC1\xC4\x71\xE4\x38\x44\x9E\xF1\x34\xC8" - -#define SHA_SOURCE3 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -#define SHA_DIGEST3a "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F" -#define SHA_DIGEST3b "\x32\x32\xAF\xFA\x48\x62\x8A\x26\x65\x3B\x5A\xAA\x44\x54\x1F\xD9\x0D\x69\x06\x03" - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapeset.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapeset.h deleted file mode 100644 index 2754f2ebedd..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapeset.h +++ /dev/null @@ -1,271 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/shapeset.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * ShapeSet::Fetch_Data -- Fetches pointer to raw shape data. * - * ShapeSet::Fetch_Rect -- Fetch the sub-rectangle of a shape. * - * ShapeSet::Is_Transparent -- Is the specified shape containing transparent pixels? * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHAPESET_H -#define SHAPESET_H - -#include "bool.h" -#include "trect.h" - -/* -** This is the header that appears at the beginning of the ShapeSet file. The header -** is a multiple of 8 bytes long to facilitate data alignment. The shape header is -** immediately followed by an N length array of ShapeRecord objects. The actual -** shape data follows this array. -*/ -class ShapeSet -{ - public: - /* - ** Fetch pointer to raw shape data (NULL if not present or empty). - */ - void * Get_Data(int shape) const; - - /* - ** Fetch sub-rectangle that the shape data represents. - */ - Rect Get_Rect(int shape) const; - - /* - ** Are there any transparent pixels within the shape? - */ - bool Is_Transparent(int shape) const; - - /* - ** Determines if the specified shape is RLE compressed. - */ - bool Is_RLE_Compressed(int shape) const; - - /* - ** Logical width of the shape set. - */ - int Get_Width(void) const {return(Width);} - - /* - ** Logical height of the shape set. - */ - int Get_Height(void) const {return(Height);} - - /* - ** Number of shapes in this shape set. - */ - int Get_Count(void) const{return(Count);} - - /* - ** Gets the raw data size for a particular shape. - */ - int Get_Size(int shape) const; - - protected: - /* - ** QShape information flags. - */ - short Flags; - - /* - ** The nominal width and height of the shape (in pixels). - */ - short Width; - short Height; - - /* - ** The total number of shapes in the file. - */ - short Count; - - /* - ** Each shape is represented by this structure. It appears in a linear array near the - ** beginning of the file. - */ - class ShapeRecord - { - public: - /* - ** The sub-offset (relative to logical 0,0 at upper left corner) for this - ** shape's data. - */ - short X; - short Y; - - /* - ** The dimensions of this shape's data. - */ - short Width; - short Height; - - /* - ** Flags that indicate some aspect of this particular shape image. - */ - short Flags; - enum { - SFLAG_TRANSPARENT=0x01, // Are there are any transparent pixels present? - SFLAG_RLE=0x02 // Is it RLE compressed? - }; - - - /* - ** Size of the data for this frame. - */ - short Size; - - /* - ** Offset from the start of the shape data file to where the first pixel - ** of this shape image data is located. - */ - long Data; - - bool Is_Transparent(void) const {return((Flags & SFLAG_TRANSPARENT) != 0);} - bool Is_RLE_Compressed(void) const {return((Flags & SFLAG_RLE) != 0);} - short Get_Size(void) const {return(Size);} - - void Flag_Transparent(void) {Flags |= SFLAG_TRANSPARENT;} - void Flag_RLE_Compressed(void) {Flags |= SFLAG_RLE;} - void Set_Size(short size) {Size = size;} - }; - - bool Is_Shape_Index_Valid(int index) const {return(unsigned(index) < unsigned(Count));} - - ShapeRecord const * Fetch_Record_Pointer(int shape) const - { - if (Is_Shape_Index_Valid(shape)) { - return((ShapeRecord const *)(((char *)this) + sizeof(ShapeSet) + sizeof(ShapeRecord) * shape)); - } - return(NULL); - } - - /* - ** Prevents a shape object from being constructed illegally. - */ - ShapeSet(void) {}; - ShapeSet(ShapeSet const & rvalue); - ShapeSet const & operator = (ShapeSet const & rvalue); -}; - - -/*********************************************************************************************** - * ShapeSet::Get_Data -- Fetches pointer to raw shape data. * - * * - * This routine will return a pointer to the shape data. The data is actually a sub- * - * rectangle within the logical shape rectangle. The sub-rectangle holds the non- * - * transparent pixels. This fact, as retrieved by the Fetch_Rect function must be used * - * for proper rendering of the shape. * - * * - * INPUT: shape -- The shape number to extract the pointer for. * - * * - * OUTPUT: Returns with a pointer to the raw shape data. If the shape does not exist in the * - * data file, the returned value will be NULL. If the shape contains no pixels, then * - * NULL is also returned. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline void * ShapeSet::Get_Data(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL && record->Data != 0) return(((char *)this) + record->Data); - return(NULL); -} - - -/*********************************************************************************************** - * ShapeSet::Get_Rect -- Fetch the sub-rectangle of a shape. * - * * - * This routine will fetch the sub-rectangle for a particular shape. This rectangle is * - * used to properly position the shape when rendering. * - * * - * INPUT: shape -- The shape number to fetch the rectangle for. * - * * - * OUTPUT: Returns with the rectangle of the shape number specified. * - * * - * WARNINGS: If the shape number is invalid or the shape has no pixels, the returned * - * rectangle will not pass the Is_Valid() test. * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline Rect ShapeSet::Get_Rect(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(Rect(record->X, record->Y, record->Width, record->Height)); - } - return(Rect(0,0,0,0)); -} - - -/*********************************************************************************************** - * ShapeSet::Is_Transparent -- Is the specified shape containing transparent pixels? * - * * - * This routine will check to see if the specified shape has any transparent pixels. If it * - * doesn't, then faster blitting code can be used. * - * * - * INPUT: shape -- The shape to examine. * - * * - * OUTPUT: bool; Does the shape contain any transparent pixels? The answer is also false if * - * the shape number is invalid. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/26/1997 JLB : Created. * - *=============================================================================================*/ -inline bool ShapeSet::Is_Transparent(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(record->Is_Transparent()); - } - return(false); -} - - -inline bool ShapeSet::Is_RLE_Compressed(int shape) const -{ - ShapeRecord const * record = Fetch_Record_Pointer(shape); - if (record != NULL) { - return(record->Is_RLE_Compressed()); - } - return(false); -} - - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.cpp deleted file mode 100644 index cbbb6892afc..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHAPIPE.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SHAPipe::Result -- Fetches the current SHA value. * - * SHAPipe::Put -- Pass data through the pipe, but use it to build a SHA digest. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "shapipe.h" - - -/*********************************************************************************************** - * SHAPipe::Put -- Pass data through the pipe, but use it to build a SHA digest. * - * * - * This pipe segment will not modify the data, but it will examine the data and use it when * - * building a SHA digest. * - * * - * INPUT: source -- Pointer to the data to flow through the pipe. * - * * - * length -- The number of bytes to submit. * - * * - * OUTPUT: Returns with the actual number of bytes output at the distant final end of the * - * pipe chain. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAPipe::Put(void const * source, int slen) -{ - SHA.Hash(source, slen); - return(Pipe::Put(source, slen)); -} - - -/*********************************************************************************************** - * SHAPipe::Result -- Fetches the current SHA value. * - * * - * This routine will return the SHA digest for the data that has passed through this * - * link in the pipe chain. It is a non-destructive read. * - * * - * INPUT: result -- Pointer to the buffer to hold the SHA digest. This buffer must be * - * 20 bytes long. * - * * - * OUTPUT: Returns with the number of bytes copied into the buffer. This will be 20. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAPipe::Result(void * result) const -{ - return(SHA.Result(result)); -} - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.h deleted file mode 100644 index f080081bfcd..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shapipe.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHAPIPE.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHAPIPE_H -#define SHAPIPE_H - -#include "PIPE.H" -#include "sha.h" - -/* -** This class serves as a pipe that generates a Secure Hash from the data stream that flows -** through it. It doesn't modify the data stream in any fashion. -*/ -class SHAPipe : public Pipe -{ - public: - SHAPipe(void) {} - virtual int Put(void const * source, int slen); - - // Fetch the SHA hash value (stored in result buffer -- 20 bytes long). - int Result(void * result) const; - - protected: - SHAEngine SHA; - - private: - SHAPipe(SHAPipe & rvalue); - SHAPipe & operator = (SHAPipe const & pipe); -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.cpp deleted file mode 100644 index 641dee7b476..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHASTRAW.CPP $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SHAStraw::Get -- Fetch data from the straw and process the SHA with the data. * - * SHAStraw::Result -- Fetches the current SHA digest. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "always.h" -#include "shastraw.h" - - -/*********************************************************************************************** - * SHAStraw::Get -- Fetch data from the straw and process the SHA with the data. * - * * - * This routine will fetch the requested data and as it passes through this straw it will * - * submit it to the SHA processor. The data that passes through is unmodified by this * - * straw segment. * - * * - * INPUT: source -- Pointer to the buffer that will hold the requested data. * - * * - * length -- The length of the data requested. * - * * - * OUTPUT: Returns with the number of bytes stored in the buffer. If this number is less * - * than the number requested, then this indicates that the data stream has been * - * exhausted. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAStraw::Get(void * source, int slen) -{ - if (source == NULL || slen < 1) { - return(0); - } - - int counter = Straw::Get(source, slen); - if (!IsDisabled) { - SHA.Hash(source, counter); - } - return(counter); -} - - -/*********************************************************************************************** - * SHAStraw::Result -- Fetches the current SHA digest. * - * * - * Use this routine to fetch the current SHA digest from the straw. It will return the * - * digest of the data that has passed through this straw segment. * - * * - * INPUT: result -- Pointer to the buffer to hold the message digest. The buffer must be * - * 20 bytes long. * - * * - * OUTPUT: Returns with the number of bytes stored into the digest buffer. This will always * - * be 20. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/03/1996 JLB : Created. * - *=============================================================================================*/ -int SHAStraw::Result(void * result) const -{ - return(SHA.Result(result)); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.h deleted file mode 100644 index d216989f4ca..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/shastraw.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SHASTRAW.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SHASTRAW_H -#define SHASTRAW_H - - -#include "sha.h" -#include "STRAW.H" - -/* -** This class serves as a straw that generates a Secure Hash from the data stream that flows -** through it. It doesn't modify the data stream in any fashion. -*/ -class SHAStraw : public Straw -{ - public: - SHAStraw(void) : IsDisabled(false) {} - virtual int Get(void * source, int slen); - - void Disable(void) {IsDisabled = true;} - void Enable(void) {IsDisabled = false;} - - // Fetch the SHA hash value (stored in result buffer -- 20 bytes long). - int Result(void * result) const; - - protected: - bool IsDisabled; - - SHAEngine SHA; - - private: - SHAStraw(SHAStraw & rvalue); - SHAStraw & operator = (SHAStraw const & straw); -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/smartptr.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/smartptr.h deleted file mode 100644 index d8b743ca246..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/smartptr.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/SMARTPTR.H $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SMARTPTR_H -#define SMARTPTR_H - -#include "noinit.h" - -template -class SmartPtr -{ - public: - SmartPtr(NoInitClass const &) {} - SmartPtr(T * realptr = 0) : Pointer(realptr) {} - SmartPtr(SmartPtr const & rvalue) : Pointer(rvalue.Pointer) {} - ~SmartPtr(void) {Pointer = 0;} - - operator T * (void) const {return(Pointer);} - - operator long (void) const {return((long)Pointer);} - - bool Is_Valid(void) const {return(Pointer != 0);} - -// SmartPtr operator ++ (int) {assert(Pointer != 0);SmartPtr temp = *this;++Pointer;return(temp);} -// SmartPtr & operator ++ (void) {assert(Pointer != 0);++Pointer;return(*this);} -// SmartPtr operator -- (int) {assert(Pointer != 0);SmartPtr temp = *this;--Pointer;return(temp);} -// SmartPtr & operator -- (void) {assert(Pointer != 0);--Pointer;return(*this);} - - SmartPtr & operator = (SmartPtr const & rvalue) {Pointer = rvalue.Pointer;return(*this);} - T * operator -> (void) const {/*assert(Pointer != 0);*/return(Pointer);} - T & operator * (void) const {/*assert(Pointer != 0);*/return(*Pointer);} - - private: - T * Pointer; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp deleted file mode 100644 index f96e0d04835..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/srandom.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// -// SecureRandomClass - Generate random values -// - -#pragma warning(disable : 4514) // unreferenced inline function removed.... - -#include "srandom.h" -#include -#include -#ifdef _UNIX -#include "osdep.h" -#include -#include - -extern "C" { - int sysinfo(struct sysinfo *info); -} - -#else - -#include "win.h" -#include -#endif -#include -#include -#include "sha.h" - -// Static class variables -unsigned char SecureRandomClass::Seeds[SecureRandomClass::SeedLength]; -bool SecureRandomClass::Initialized=false; -unsigned int SecureRandomClass::RandomCache[SecureRandomClass::SHADigestBytes / sizeof(unsigned int)]; -int SecureRandomClass::RandomCacheEntries=0; -unsigned int SecureRandomClass::Counter=0; -Random3Class SecureRandomClass::RandomHelper; - -SecureRandomClass::SecureRandomClass() -{ - if (Initialized == false) - { - Generate_Seed(); - Initialized=true; - } -} - -SecureRandomClass::~SecureRandomClass() -{ -} - - -// -// Add seed values to our pool of randomness -// -void SecureRandomClass::Add_Seeds(unsigned char *values, int length) -{ - for (int i=0; i=1; j--) - Seeds[j]=Seeds[j-1]; - Seeds[0]=uctemp; - } - - // We have a better seed pool now so trigger new random values - RandomCacheEntries=0; -} - -// -// Get a 32bit random value -// -unsigned long SecureRandomClass::Randval(void) -{ - if (RandomCacheEntries == 0) - { - SHAEngine sha; - char digest[SHADigestBytes]; // SHA produces a 20 byte hash - - sha.Hash(Seeds, SeedLength); - sha.Result(digest); - - memcpy(RandomCache, digest, SHADigestBytes); - RandomCacheEntries=(SHADigestBytes / sizeof(unsigned int)); - - unsigned int *int_seeds=(unsigned int *)Seeds; - int_seeds[0]^=Counter; // remove the last counter (double xor) - int_seeds[0]^=(Counter+1); // put the new counter in place - - int_seeds[(SeedLength/sizeof(int))-1]^=Counter; // remove the last counter (double xor) - int_seeds[(SeedLength/sizeof(int))-1]^=(Counter+1); // put the new counter in place - - Counter++; // increment counter - } - - unsigned long retval=RandomCache[--RandomCacheEntries]; - - // SHA doesn't have the best distribution properties in the world - // We'll XOR the result with the output of another random number - unsigned long helperval=RandomHelper(); - retval^=helperval; - - return(retval); -} - - - -/////////////////////////////// Private Methods /////////////////////////////////////// - -// -// Seed the random number generator. -// The seed is what makes each run of random numbers unique. If an observer -// can guess your seed they can predict your random numbers. -// -// Note the use of XORs everywhere. The XOR of a good random number and a bad random -// number is still a good random number. -// -// Caution: Under windows this isn't nearly as safe as under UNIX! -// -void SecureRandomClass::Generate_Seed(void) -{ - int i; - - // Start with some garbage values - memset(Seeds, 0xAA, SeedLength); - - unsigned int *int_seeds=(unsigned int *)Seeds; - int int_seed_length=SeedLength/sizeof(unsigned int); - -#ifdef _USE_DEV_RANDOM - // - // On UNIX we've already got a great random number souce. - // This should be used only for a seed since it's slow. - // - FILE *in=fopen("/dev/random","r"); - if (in) - { - for (i=0; i. -*/ - -#ifndef SRANDOM_H -#define SRANDOM_H - -#include "RANDOM.H" // for the helper RNG - -// -// SecureRandomClass - Generate random values that are suitable for use in cryptographic -// applications (under UNIX at least). -// -// NOTE: The seed generation under windows isn't nearly as strong as under UNIX due to -// the lack of /dev/random. If you have a good random source you can call 'Add_Seeds' -// to improve the quality of the seed value. -// -// Currently the random seed generation under windows is piss-poor so make sure and call -// Add_Seeds with some interesting data if you're going to use this! -// -// The seed values should be unguessable by an outside viewer and the random values have -// good distribution properties. -// -class SecureRandomClass -{ -public: - SecureRandomClass(); - ~SecureRandomClass(); - - unsigned long Randval(); // get a 32 bit random value - - // Add randomness to the seed pool - void Add_Seeds(unsigned char *values, int length); - -private: - void Generate_Seed(void); // Generate the inital seed - - enum - { - SeedLength = 16, // bytes in random seed - SHADigestBytes = 20 // length of SHA hash - }; - - static bool Initialized; // has the seed been initialized? - static unsigned char Seeds[SeedLength]; // random seed values - static unsigned int RandomCache[SHADigestBytes / sizeof(unsigned int)]; - static int RandomCacheEntries; - static unsigned int Counter; - - static Random3Class RandomHelper; -}; - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/stl.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/stl.h deleted file mode 100644 index 3cf83170279..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/stl.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/stl.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/05/00 6:17p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef STL_H -#define STL_H - -/* -** This header file includes the Standard Template Library Headers -** and disables certian warnings -*/ - -#if (_MSC_VER >= 1200) -#pragma warning(push,3) -#endif - -#include - -#if (_MSC_VER >= 1200) -#pragma warning(pop) -#endif - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surface.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surface.cpp deleted file mode 100644 index 3a2c0141eed..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surface.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/surface.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "Surface.h" - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surfrect.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surfrect.h deleted file mode 100644 index 6895ba1d6d4..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/surfrect.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/surfrect.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SURFRECT_H -#define SURFRECT_H - -#ifdef NEVER - -#include "Surface.h" -#include "trect.h" -#include "Point.h" -#include - - -/* -** This class encapsulates a surface and a clipping rectangle. It is intended to be used as -** a convenience for certain operations that need both a surface and a rectangle. Be aware that -** all surfaces are imbued with a rectangle that is the full size of the surface. -*/ -class SurfaceRect { - public: - SurfaceRect(Surface * surfaceptr = NULL, Rect * rect = NULL) : SurfacePtr(surfaceptr), Point(0, 0) { - assert(SurfacePtr != NULL); - if (rect != NULL) Window = *rect; else Window = SurfacePtr->Get_Rect(); - } - SurfaceRect(Surface & surface, Rect * rect = NULL) : SurfacePtr(&surface), Point(0, 0) { - if (rect != NULL) Window = *rect; else Window = SurfacePtr->Get_Rect(); - } - SurfaceRect(Surface & surface, Rect const & rect) : SurfacePtr(&surface), Window(rect), Point(0, 0) {} - ~SurfaceRect(void) {}; - - /* - ** Pointer to the surface represented by this class. - */ - Surface * SurfacePtr; - - /* - ** Clipping rectangle window into the surface. - */ - Rect Window; - - /* - ** Tracking 2D coordinate into the surface. - */ - Point2D Point; - - private: - /* - ** Ensures that the copy constructor and assignment operator never - ** get created for this class. - */ - SurfaceRect(SurfaceRect const & rvalue); - SurfaceRect operator = (SurfaceRect const & rvalue); -}; - -#endif -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp deleted file mode 100644 index 943065e4d37..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/tagblock.cpp +++ /dev/null @@ -1,651 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /G/wwlib/tagblock.cpp 5 11/30/99 3:46p Scott_b $ */ -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : WWLib * - * * - * $Archive:: /G/wwlib/tagblock.cpp $* - * * - * $Author:: Scott_b $* - * * - * $Modtime:: 11/29/99 6:42p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * TagBlockFile::TagBlockFile -- Create/open tag file * - * TagBlockFile::~TagBlockFile -- Close down the tag file. * - * TagBlockFile::Create_Index -- Create a index into the IndexList sorted by CRC. * - * TagBlockFile::Find_Block -- Find block assocated with name. * - * TagBlockFile::Open_Tag -- Open an existing tag block. * - * TagBlockFile::Create_Tag -- Create a new tag at the end of the block. * - * TagBlockFile::Close_Tag -- Close the handle that Create or Open made. * - * TagBlockFile::Destroy_Handle -- Shut down a handle. * - * TagBlockFile::End_Write_Access -- Stop write access for handle - flushes data bug keeps ha* - * TagBlockFile::Reset_File -- Clear file so no blocks exist. * - * TagBlockFile::Empty_Index_List -- Clear out tag block list in memory * - *---------------------------------------------------------------------------------------------* - * TagBlockHandle::Write -- Write data to the block. * - * TagBlockHandle::Read -- Read from a tag block. * - * TagBlockHandle::Seek -- Seek within the file. * - * TagBlockHandle::~TagBlockHandle -- Destroy handle. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "TagBlock.h" -#include "realcrc.h" - -#include - -int TagBlockHandle::_InDestructor = 0; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////// Start of TagBlockIndex /////////////////////////////////////// -class TagBlockIndex -{ -public: - TagBlockIndex(const char *tagname, int blockoffset): - CRC(CRC_Stringi(tagname)), - BlockOffset(blockoffset), - DataOffset(TagBlockFile::Calc_Data_Offset(blockoffset, tagname)) - {} - - unsigned Get_CRC() { - return(CRC); - } - int Get_BlockOffset() { - return(BlockOffset); - } - int Get_TagOffset() { - return(TagBlockFile::Calc_Tag_Offset(BlockOffset)); - } - int Get_TagSize() { - return(DataOffset - Get_TagOffset()); - } - int Get_DataOffset() { - return(DataOffset); - } -private: - - // The index file is sorted by the CRC of the file name for - // quicker retrieval. The filename is saved in the texture file. - unsigned long CRC; - - // Start of the block - this is the start of TagBlockFile::BlockHeader. - int BlockOffset; - - // Offset of block inside of TagFile. - // This is first byte after header and TagName. - // It is actual data used by external methods. - int DataOffset; -}; - -///////////////////////////////////// End of TagBlockIndex ///////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////// Start of TagBlockHandle///////////////////////////////////////// - - -/*********************************************************************************************** - * RawFileClass -- Open up the tag file (it may not exist). * - * * - * INPUT: * - * const char *fname - name of file that is or wants to be a TagBlockFile. * - * * - * OUTPUT: * - * Will assume a file that has invalid data to be corrupt and will write over it. * - * So don't pass in a file that is not a tag file. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockFile::TagBlockFile(const char *fname): - RawFileClass(), - Header(), - CreateHandle(NULL), - NumOpenHandles(0), - IndexList() -{ - // Open file up, create it if it does not exist. - // Pass in name to Open function so that the file name will be strdup'd. - Open(fname, READ|WRITE); - - FileTime = RawFileClass::Get_Date_Time(); - - // Read in header so we can tell if it is proper file. - Read(&Header, sizeof(Header)); - - // See if there is any data in file (or was it just created?) - if (Header.Version == FILE_VERSION) { - TagBlockIndex *lasttag = NULL; - int curpos = sizeof(Header); - - // Loop through each block in file and create an in memory index for it. - int block; - for (block = 0; block < Header.NumBlocks; block++) { - BlockHeader blockheader; - - // Read in next header. - Seek(curpos, SEEK_SET); - Read(&blockheader, sizeof(blockheader)); - - // Make sure things are in order. - if (blockheader.Index == block) { - char tagname[MAX_TAG_NAME_SIZE]; - - // Read in tag name, this includes the NULL at end of string. - Read(tagname, blockheader.TagSize); - - // Create new tag index for fast retrievel. - lasttag = Create_Index(tagname, curpos); - - // Now get past the data. - curpos = Calc_Tag_Offset(curpos) + blockheader.TagSize + blockheader.DataSize; - } else { - break; - } - } - - // See if there is a difference between the header and actual data. - if ((curpos != Header.FileSize) || (block != Header.NumBlocks)) { - Header.NumBlocks = block; - Header.FileSize = curpos; - - // Start at begining of file and write out our new header. - Seek(0, SEEK_SET); - Write(&Header, sizeof(Header)); - } - - } else { - Reset_File(); - } -} - -/*********************************************************************************************** - * TagBlockFile::~TagBlockFile -- Close down the tag file. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Any TagBlockHandles that have not been deleted are now invalide but cannot be deleted.* - * You must delete any handles associated with this before closing the TagFile. * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockFile::~TagBlockFile() -{ - Empty_Index_List(); -} - -/*********************************************************************************************** - * TagBlockFile::Reset_File -- Clear file so no blocks exist. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/29/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Reset_File() -{ - Empty_Index_List(); - - // Save a clean header out. - Header.Version = FILE_VERSION; - Header.NumBlocks = 0; - Header.FileSize = sizeof(Header); - - Save_Header(); - - // Close, then open file so we get a new time stamp on it. - Close(); - Open(READ|WRITE); - - // Reget file creation time. - FileTime = RawFileClass::Get_Date_Time(); -} - -/*********************************************************************************************** - * *TagBlockFile::Open_Tag -- Open an existing tag block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle *TagBlockFile::Open_Tag(const char *tagname) -{ - // Find tag to open up. - TagBlockIndex *index = Find_Block(tagname); - if (!index) { - return(NULL); - } - - // Load up the block header information. - BlockHeader *blockheader = W3DNEW BlockHeader(); - Seek(index->Get_BlockOffset(), SEEK_SET); - Read(blockheader, sizeof(*blockheader)); - - // Now that we have all that we need, create the - TagBlockHandle *handle = W3DNEW TagBlockHandle(this, index, blockheader); - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles++; - - // Return with our new handle. - return(handle); -} - -/*********************************************************************************************** - * *TagBlockFile::Create_Tag -- Create a new tag at the end of the block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle *TagBlockFile::Create_Tag(const char *tagname) -{ - // Only allow one handle to be creating open at a time. - if (CreateHandle) { - return(NULL); - } - - // Create a new index that we can write too. - TagBlockIndex *index = Create_Index(tagname, Header.FileSize); - - // An index may not be created if a tag of the same name already exists. - if (!index) { - return(NULL); - } - - // Create a header. - // Use -1 for index to indecate that block is not yet written out competely. - BlockHeader *blockheader = W3DNEW BlockHeader(-1, index->Get_TagSize(), 0); - - // Write out the block header and the tag. - Seek(index->Get_BlockOffset(), SEEK_SET); - Write(blockheader, sizeof(*blockheader)); - Write(tagname, strlen(tagname) + 1); - - // Now that we have all that we need, create the - CreateHandle = W3DNEW TagBlockHandle(this, index, blockheader); - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles++; - - return(CreateHandle); -} - -/*********************************************************************************************** - * TagBlockFile::Close_Tag -- Close the handle that Create or Open made. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Close_Tag(TagBlockHandle *handle) -{ - delete handle; -} - -/*********************************************************************************************** - * TagBlockFile::Destroy_Handle -- Shut down a handle. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Destroy_Handle(TagBlockHandle *handle) -{ - // Make sure those sneaky programmers aren't trying to fool me. - assert(handle->Called_By_Destructor()); - - // If we had write access to handle, flush it out. - End_Write_Access(handle); - - // This was allocated by TagBlockFile::Create_Tag() or Open_Tag(). - delete handle->BlockHeader; - - // Keep track of how many handles there are so we can assert if they are not all shut down. - NumOpenHandles--; -} - -/*********************************************************************************************** - * TagBlockFile::End_Write_Access -- Stop write access for handle - flushes data bug keeps han * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/02/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockFile::End_Write_Access(TagBlockHandle *handle) -{ - // Make sure this handle is the proper one. - if (CreateHandle == handle) { - // Update file header and block header. - handle->BlockHeader->Index = Header.NumBlocks; - Header.NumBlocks++; - Header.FileSize = handle->Index->Get_DataOffset(); - Header.FileSize += handle->BlockHeader->DataSize; - - // Write both headers out. - Seek(handle->Index->Get_BlockOffset(), SEEK_SET); - Write(handle->BlockHeader, sizeof(*handle->BlockHeader)); - Save_Header(); - - // Don't allow writing with this handle anymore. - CreateHandle = NULL; - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * *TagBlockFile::Create_Index -- Create a index into the IndexList sorted by CRC. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockIndex *TagBlockFile::Create_Index(const char *tagname, int blockoffset) -{ - // Don't allow duplicate tags. - if (Find_Block(tagname)) { - return(NULL); - } - - TagBlockIndex *index; - index = W3DNEW TagBlockIndex(tagname, blockoffset); - - // Put it into the list. - if (IndexList.Is_Empty()) { - IndexList.Add_Head(index); - } else { - // Put in list sorted by CRC, smallest to largest. - SLNode *node = IndexList.Head(); - while (node) { - TagBlockIndex *cur = node->Data(); - if (index->Get_CRC() > cur->Get_CRC()) { - IndexList.Insert_Before(index, cur); - break; - } - node = node->Next(); - } - // If we did not find a place, then add at end of list. - if (!node) { - IndexList.Add_Tail(index); - } - } - return (index); -} - -/*********************************************************************************************** - * *TagBlockFile::Find_Block -- Find block assocated with name. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/11/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockIndex *TagBlockFile::Find_Block(const char *tagname) -{ - if (IndexList.Is_Empty()) { - return(NULL); - } - - unsigned long crc = CRC_Stringi(tagname); - - SLNode *node = IndexList.Head(); - while (node) { - TagBlockIndex *cur = node->Data(); - - // Did we find it? - if (cur->Get_CRC() == crc) { - // Now read from file to verify that it is the right name. - char name[MAX_TAG_NAME_SIZE]; - Seek(cur->Get_TagOffset(), SEEK_SET); - - // Read in the name. - Read(name, cur->Get_TagSize()); - - // Is it a match? - assert(name != NULL); - assert(tagname != NULL); - if (!strcmpi(name, tagname)) { - return(cur); - } - } - - // Are we out of range? - if (cur->Get_CRC() < crc) { - break; - } - - // Next in line please. - node = node->Next(); - } - - return(NULL); -} - - -/*********************************************************************************************** - * TagBlockFile::Empty_Index_List -- Clear out tag block list in memory * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/29/1999 SKB : Created. * - *=============================================================================================*/ -void TagBlockFile::Empty_Index_List() -{ - assert(!NumOpenHandles); - - // Get rid of index list in memory. - while (!IndexList.Is_Empty()) { - TagBlockIndex *index = IndexList.Remove_Head(); - delete index; - } - -} - - -///////////////////////////////////////// End of TagBlockFile ///////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// Start of TagBlockHandle///////////////////////////////////// - -/*********************************************************************************************** - * Position -- Create a handle for user to access the TagBlock. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle::TagBlockHandle(TagBlockFile *tagfile, TagBlockIndex *tagindex, TagBlockFile::BlockHeader *blockheader): - File(tagfile), - Index(tagindex), - BlockHeader(blockheader), - Position(0) -{ -} - -/*********************************************************************************************** - * TagBlockHandle::~TagBlockHandle -- Destroy handle. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -TagBlockHandle::~TagBlockHandle() -{ - _InDestructor++; - File->Destroy_Handle(this); - _InDestructor--; -} - -/*********************************************************************************************** - * TagBlockHandle::Write -- Write data to the block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Write(const void *buf, int nbytes) -{ - // Make sure this handle is the proper one. - if (!File->Handle_Can_Write(this)) { - return(-1); - } - - // Get to correct position to write out and write the buffer. - File->Seek(Index->Get_DataOffset() + Position, SEEK_SET); - nbytes = File->Write(buf, nbytes); - - // Advance the EOF marker for the block. - Position += nbytes; - if (Position > BlockHeader->DataSize) { - BlockHeader->DataSize = Position; - } - - // Return about written out. - return(nbytes); -} - -/*********************************************************************************************** - * TagBlockHandle::Read -- Read from a tag block. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Read(void *buf, int nbytes) -{ - // Make sure user does not read past end of buffer. - if ((Position + nbytes) > BlockHeader->DataSize) { - nbytes = BlockHeader->DataSize - Position; - } - - // Get to correct position to write out and read in the buffer. - File->Seek(Index->Get_DataOffset() + Position, SEEK_SET); - nbytes = File->Read(buf, nbytes); - - // Adjust the read head. - Position += nbytes; - - // Tell user how much was read from the file. - return(nbytes); -} - -/*********************************************************************************************** - * TagBlockHandle::Seek -- Seek within the file. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 05/12/1999 SKB : Created. * - *=============================================================================================*/ -int TagBlockHandle::Seek(int pos, int dir) -{ - switch (dir) { - case SEEK_CUR: - Position += pos; - break; - case SEEK_SET: - Position = pos; - break; - case SEEK_END: - Position = BlockHeader->DataSize + pos; - break; - } - return(Position); -} - -// EOF \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/timer.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/timer.h deleted file mode 100644 index d54a90a3197..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/timer.h +++ /dev/null @@ -1,689 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/timer.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 5/04/01 8:08p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * BasicTimerClass::BasicTimerClass -- Constructor for basic timer class. * - * BasicTimerClass::operator () -- Function operator for timer object. * - * BasicTimerClass::operator long -- Conversion to long operator. * - * BasicTimerClass::~BasicTimerClass -- Destructor for basic timer object. * - * TTimerClass::Is_Active -- Checks to see if the timer is counting. * - * TTimerClass::Start -- Starts (resumes) a stopped timer. * - * TTimerClass::Stop -- Stops the current timer from incrementing. * - * TTimerClass::TTimerClass -- Constructor for timer class object. * - * TTimerClass::operator () -- Function operator for timer object. * - * TTimerClass::operator long -- Conversion operator for timer object. * - * CDTimerClass::CDTimerClass -- Constructor for count down timer. * - * CDTimerClass::Is_Active -- Checks to see if the timer object is active. * - * CDTimerClass::Start -- Starts (resumes) the count down timer. * - * CDTimerClass::Stop -- Stops (pauses) the count down timer. * - * CDTimerClass::operator () -- Function operator for the count down timer. * - * CDTimerClass::operator long -- Conversion to long operator function. * - * CDTimerClass::~CDTimerClass -- Destructor for the count down timer object. * - * TTimerClass::Value -- Returns with the current value of the timer. * - * CDTimerClass::Value -- Fetches the current value of the countdown timer. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TIMER_H -#define TIMER_H - -#include "noinit.h" - -/* -** This is a timer class that watches a constant rate timer (specified by the parameter -** type class) and provides basic timer functionality. It is possible to set the start value -** WITHOUT damaging or otherwise affecting any other timer that may be built upon the same -** specified timer class object. Treat an object of this type as if it were a "magic" integral -** long that automatically advances at the speed of the timer class object controlling it. -*/ -// Let lint know that non-virtual destructor is OK for this class. -//lint -esym(1509,BasicTimerClass) -template -class BasicTimerClass { - public: - // Constructor allows assignment as if class was integral 'long' type. - BasicTimerClass(int set=0); - BasicTimerClass(NoInitClass const & ); - - virtual ~BasicTimerClass(void); - - // Fetch current value of timer. - int Value(void) const {return(Timer()-Started);} - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - protected: - T Timer; // Timer regulator (ticks at constant rate). - int Started; // Time started. -}; - - -template -inline BasicTimerClass::BasicTimerClass(NoInitClass const & ) -{ -}; - - -/*********************************************************************************************** - * BasicTimerClass::BasicTimerClass -- Constructor for basic timer class. * - * * - * This is the constructor for the basic timer class object. It sets the timer counting * - * up from zero at the rate of the controlling timer class object. * - * * - * INPUT: set -- Alternate initial start value for the counter. If not specified, then * - * the timer is assumed to start at zero and count upwards. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -//lint -esym(1403,BasicTimerClass::Timer) -//lint -esym(1403,BasicTimerClass::Timer) -template -inline BasicTimerClass::BasicTimerClass(int set) : - Started(Timer()-set) -{ -} - - -/*********************************************************************************************** - * BasicTimerClass::~BasicTimerClass -- Destructor for basic timer object. * - * * - * The destructor for the basic timer object doesn't have to do anything. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline BasicTimerClass::~BasicTimerClass(void) -{ -} - - -//template -//inline unsigned long BasicTimerClass::Value(void) const -//{ -// return(Timer()-Started); -//} - - -/*********************************************************************************************** - * BasicTimerClass::operator long -- Conversion to long operator. * - * * - * This conversion operator allows the basic timer object to function in much the same * - * manner as the integral "long" type. One can assign a long with a timer object and the * - * actual value of the timer is extracted from the object and used. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the timer value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline BasicTimerClass::operator int(void) const -{ - return(Timer()-Started); -} - - -/*********************************************************************************************** - * BasicTimerClass::operator () -- Function operator for timer object. * - * * - * This function operator allows the timer to also serve as the parameter type class for * - * additional timer objects. This allows one to instantiate a controlling timer class that * - * can control (e.g., turn on or off) all timers that are based upon it. * - * * - * INPUT: none * - * * - * OUTPUT: Returns the current timer value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int BasicTimerClass::operator () (void) const -{ - return(Timer()-Started); -} - - -/* -** This timer class functions similarly to the basic timer class. In addition to the -** normal timer operation, this class has the ability to be stopped and started at -** will. If you have no need to start or stop the timer, then use the basic timer -** class instead. -*/ -template -class TTimerClass : public BasicTimerClass -{ - using BasicTimerClass::Started; - using BasicTimerClass::Timer; - - public: - // Constructor allows assignment as if class was integral 'long' type. - TTimerClass(int set=0); - TTimerClass(NoInitClass const & x); - - ~TTimerClass(void) {}; - - // Fetches current value of timer. - int Value(void) const; - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - // Stops (pauses) the timer. - void Stop(void); - - // Starts (resumes) the timer. - void Start(void); - - // Queries whether the timer is currently active. - bool Is_Active(void) const; - - private: - int Accumulated; // Total accumulated ticks. -}; - - -template -inline TTimerClass::TTimerClass(NoInitClass const & x) : - BasicTimerClass(x) -{ -} - - -/*********************************************************************************************** - * TTimerClass::TTimerClass -- Constructor for timer class object. * - * * - * This is the constructor for the advanced timer class object. This object class can start * - * or stop the timer under user control. * - * * - * INPUT: set -- The initial value to set the timer to. If no value is specified, then * - * the timer is assumed to start from zero. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline TTimerClass::TTimerClass(int set) : - BasicTimerClass(set), - Accumulated(0) -{ -} - - -/*********************************************************************************************** - * TTimerClass::Value -- Returns with the current value of the timer. * - * * - * This routine will return with the current value of the timer. It takes into account * - * whether the timer has stopped or not so as to always return the correct value regardless * - * of that condition. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current value of the timer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int TTimerClass::Value(void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::operator long -- Conversion operator for timer object. * - * * - * This conversion operator allows this timer object to function as an "rvalue" of a "long" * - * type. This is consistent with the integral "long" value. It is possible to assign a * - * timer object to a long and have the long initialized with the current value of the * - * timer. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current time value expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline TTimerClass::operator int(void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::operator () -- Function operator for timer object. * - * * - * This function operator for the timer class allows this timer class to be used as the * - * template parameter for other timer class objects. With this ability, one can control * - * several timers (e.g., start or stop them) by using a single controlling timer class * - * that other timers are instantiated from. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current time expressed as a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int TTimerClass::operator () (void) const -{ - int value = Accumulated; - if (Started != -1) { - value += BasicTimerClass::Value(); - } - return(value); -} - - -/*********************************************************************************************** - * TTimerClass::Stop -- Stops the current timer from incrementing. * - * * - * This routine will stop (pause) the timer from further increments. To cause the timer * - * to begin anew, call the Start() function. * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 02/05/1996 JLB : Created. * - *=============================================================================================*/ -template -void TTimerClass::Stop(void) -{ - if (Started != -1) { - Accumulated += BasicTimerClass::Value(); - Started = -1; - } -} - - -/*********************************************************************************************** - * TTimerClass::Start -- Starts (resumes) a stopped timer. * - * * - * This routine will resume a timer that was previously stopped with the Stop() function. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void TTimerClass::Start(void) -{ - if (Started == -1) { - Started = Timer(); - } -} - - -/*********************************************************************************************** - * TTimerClass::Is_Active -- Checks to see if the timer is counting. * - * * - * Since this timer can be paused, this routine is used to examine the timer to see if it * - * is currently paused or active. If the timer is active, then the return value will be * - * true. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is this timer currently active? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline bool TTimerClass::Is_Active(void) const -{ - return(Started != -1); -} - - -/* -** This timer counts down from the specified (or constructed) value down towards zero. -** The countdown rate is controlled by the timer object specified. This timer object can -** be started or stopped. It can also be tested to see if it has expired or not. An expired -** count down timer is one that has value of zero. You can treat this class object as if it -** were an integral "magic" long that automatically counts down toward zero. -*/ -template -class CDTimerClass : public BasicTimerClass -{ - using BasicTimerClass::Started; - using BasicTimerClass::Timer; - - public: - // Constructor allows assignment as if class was integral 'long' type. - CDTimerClass(int set=0); - CDTimerClass(NoInitClass const & x); - - ~CDTimerClass(void); - - // Fetches current value of count down timer. - int Value(void) const; - - // Conversion operator to allow consistent treatment with integral types. - operator int(void) const; - - // Function operator to allow timer object definition to be cascaded. - int operator () (void) const; - - // Stops (pauses) the timer. - void Stop(void); - - // Starts (resumes) the timer. - void Start(void); - - // Queries whether the timer is currently active. - bool Is_Active(void) const; - - private: - int DelayTime; // Ticks remaining before countdown timer expires. -}; - - -template -inline CDTimerClass::CDTimerClass(NoInitClass const & x) : - BasicTimerClass(x) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::CDTimerClass -- Constructor for count down timer. * - * * - * This is the constructor for the count down timer object. The optional starting value * - * can be used to initiate the timer. Because of this constructor it is possible to assign * - * a long to a count down timer object in order to begin the countdown process. * - * * - * INPUT: set -- The initial starting value for the countdown timer. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::CDTimerClass(int set) : - BasicTimerClass(0), - DelayTime(set) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::~CDTimerClass -- Destructor for the count down timer object. * - * * - * The destructor for the count down timer object does nothing. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::~CDTimerClass(void) -{ -} - - -/*********************************************************************************************** - * CDTimerClass::Value -- Fetches the current value of the countdown timer. * - * * - * Use this routine to fetch the current value of the timer. It takes into consideration * - * whether the timer has been stopped or not. It returns the correct value regardless of * - * this condition. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the correct value of this count down timer. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 07/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int CDTimerClass::Value(void) const -{ - int remain = DelayTime; - if (Started != -1) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::operator long -- Conversion to long operator function. * - * * - * This conversion operator allows the count down timer object to be used as if it were * - * a "magic" long that automatically counted downward at the controller class tick rate. * - * The count down object can be used in any place that an rvalue long could be used. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current count down time expressed in the form of a long value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline CDTimerClass::operator int(void) const -{ - int remain = DelayTime; - if (Started != 0xFFFFFFFFU) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::operator () -- Function operator for the count down timer. * - * * - * This is the function operator for the count down timer object. By supporting this * - * function operator, this class (or one derived from this class) could be used as the * - * controlling timer to the timer templates. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current count down time expressed in the form of a long. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline int CDTimerClass::operator () (void) const -{ - int remain = DelayTime; - if (Started != -1) { - int value = BasicTimerClass::Value(); - if (value < remain) { - return(remain - value); - } else { - return(0); - } - } - return(remain); -} - - -/*********************************************************************************************** - * CDTimerClass::Stop -- Stops (pauses) the count down timer. * - * * - * This routine is used to stop (pause) the count down timer object. A timer object paused * - * in this fashion will be resumed by a call to Start() or by assigning a new count down * - * value to the timer. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void CDTimerClass::Stop(void) -{ - if (Started != -1) { - DelayTime = *this; - Started = -1; - } -} - - -/*********************************************************************************************** - * CDTimerClass::Start -- Starts (resumes) the count down timer. * - * * - * This routine is used to start (resume) the count down timer that was previously stopped * - * with the Stop() function. The timer will also resume when a new timer value is assigned. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -void CDTimerClass::Start(void) -{ - if (Started == -1) { - Started = Timer(); - } -} - - -/*********************************************************************************************** - * CDTimerClass::Is_Active -- Checks to see if the timer object is active. * - * * - * Because the timer object counting can be stopped, this routine is used to determine * - * if the timer is currently paused or active. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the timer currently active? * - * * - * WARNINGS: Note that if the timer has counted down to zero, then it may be active, but * - * the value will, naturally, not change. * - * * - * HISTORY: * - * 02/06/1996 JLB : Created. * - *=============================================================================================*/ -template -inline bool CDTimerClass::Is_Active(void) const -{ - return(Started != -1); -} - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackwin.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackwin.h deleted file mode 100644 index bea4fd289bd..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackwin.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/trackwin.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TRACKWIN_H -#define TRACKWIN_H - - -#ifdef NEVER - -#include "trect.h" - -/* -** This class is used to keep track of a subwindow within a larger window. -*/ -class TrackWindow { - public: - TrackWindow(int width, int height) : Window(0, 0, width, height), FullWindow(0, 0, width, height) {} - - /* - ** Simple sub-window manipulation. - */ - void Set(Rect const & rect) {Window = rect;if (FullWindow.Width==0) FullWindow = rect;} - void Reset(void) {Window = Full_Rect();} - - /* - ** Query the sub-window data. - */ - int Get_X(void) const {return(Window.X);} - int Get_Y(void) const {return(Window.Y);} - int Get_Width(void) const {return(Window.Width);} - int Get_Height(void) const {return(Window.Height);} - Rect Get_Rect(void) const {return(Window);} - - /* - ** Query the full window data. - */ - int Full_Width(void) const {return(FullWindow.Width);} - int Full_Height(void) const {return(FullWindow.Height);} - Rect Full_Rect(void) const {return(FullWindow);} - - protected: - - /* - ** This is the sub-window dimensions. - */ - Rect Window; - - /* - ** This holds the full sized window. It is used for resetting the window - ** and for maximum window dimension clipping. - */ - Rect FullWindow; -}; -#endif - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackxy.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackxy.h deleted file mode 100644 index 701e6794f85..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/trackxy.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Library/trackxy.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 7/22/97 11:37a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TRACKXY_H -#define TRACKXY_H - -#ifdef NEVER -/* -** This class is used to keep track of a "current XY location". The Surface class uses this, but -** it can be used for any such purpose. -*/ -class TrackXY { - public: - TrackXY(void) : X(0), Y(0) {} - - /* - ** It is often convenient to have a "current location" for a surface. The - ** use of this location is arbitrary and outside the scope of this class. - */ - void Set(int x, int y) {X = x;Y = y;} - int Get_X(void) const {return(X);} - int Get_Y(void) const {return(Y);} - - protected: - - /* - ** Keeps track of the current location on this surface. The use of this - ** current location is outside the scope of this class, but it can be quite - ** useful for other support functions. - */ - int X; - int Y; -}; -#endif - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/visualc.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/visualc.h index 3adace55276..81db127d706 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/visualc.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/visualc.h @@ -44,7 +44,7 @@ ** November of '94. Until the compiler supports this, use the following ** definition. */ -#include "bool.h" +//#include "bool.h" /* diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/win.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/win.cpp deleted file mode 100644 index 05fbc80a58b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/win.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "always.h" -#include "win.h" -#include "wwdebug.h" - -HINSTANCE ProgramInstance; -HWND MainWindow; -bool GameInFocus = false; - -/*********************************************************************************************** - * Print_Win32Error -- Print the Win32 error message. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/21/01 DEL : Created. * - *=============================================================================================*/ -#ifdef _DEBUG -void __cdecl Print_Win32Error(unsigned long win32Error) -{ - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, win32Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, 0, NULL); - - WWDEBUG_SAY(("Win32 Error: %s\n", (const char*)lpMsgBuf)); - LocalFree(lpMsgBuf); -} -#endif - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp deleted file mode 100644 index cbe3c788d0f..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.cpp +++ /dev/null @@ -1,632 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/wwfont.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * WWFontClass::Print -- Print text to the surface specified. * - * WWFontClass::WWFontClass -- Constructor for a font class object. * - * WWFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. * - * WWFontClass::String_Pixel_Width -- Determines the width of the string in pixels. * - * WWFontClass::Raw_Width -- Fetch the raw width of a character. * - * WWFontClass::Raw_Height -- Fetch the height of the font. * - * WWFontClass::Get_Width -- Get normalized width of the nominal font character. * - * WWFontClass::Get_Height -- Fetch the normalized height of the nominal font character. * - * WWFontClass::Set_XSpacing -- Set the X spacing override value. * - * WWFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. * - * Set_Font_Data -- Allow font data to be set after construction. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_convert.h" -#include "wwfont.h" -//#include - - -#define FONTINFOMAXHEIGHT 4 -#define FONTINFOMAXWIDTH 5 - -#define FUDGEDIV 16 - - -/*********************************************************************************************** - * WWFontClass::WWFontClass -- Constructor for a font class object. * - * * - * This constructs a font object as it is based upon the font data output by the legacy * - * FONTMAKE.EXE utility. * - * * - * INPUT: fontdata -- Pointer to the data as output by the fontmake utility. * - * * - * isoutlined -- Is this font data available with outline pixels embedded? * - * * - * shadow -- Does the font data have shadow pixels embedded? * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -WWFontClass::WWFontClass(void const * fontdata, bool isoutlined, int shadow, ConvertClass *convert, unsigned char *remap) : - IsOutlinedData(isoutlined), - Shadow(shadow), - Converter(convert), - RemapPalette(remap), - FontXSpacing(0), - FontYSpacing(0) -{ - Set_Font_Data(fontdata); -} - -/*********************************************************************************************** - * Set_Font_Data -- Allow font data to be set after construction. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/24/2000 SKB : Created. * - *=============================================================================================*/ -void *WWFontClass::Set_Font_Data(void const * fontdata) -{ - void *old = (void *) FontData; - - FontData = (FontType *)fontdata; - if (FontData) { - Set_XSpacing(FontXSpacing); - Set_YSpacing(FontYSpacing); - } - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. * - * * - * This will return with the pixel width of the character specified. * - * * - * INPUT: c -- The character to determine the pixel width for. * - * * - * OUTPUT: Returns with the pixel width of the character. * - * * - * WARNINGS: The return width is the screen real estate width which may differ from the * - * actual pixels of the character. This difference is controlled by the font * - * X spacing. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Char_Pixel_Width(char c) const -{ - int raw = (*(((unsigned char *)FontData) + FontData->WidthBlockOffset + (unsigned char)c)); - raw += FontXSpacing; - return(raw); -} - - -/*********************************************************************************************** - * WWFontClass::String_Pixel_Width -- Determines the width of the string in pixels. * - * * - * This routine is used to determine how many pixels wide the string will be if it were * - * printed. * - * * - * INPUT: string -- The string to convert into its pixel width. * - * * - * OUTPUT: Returns with the number of pixels the string would span if it were printed. * - * * - * WARNINGS: This routine does not take into account clipping. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::String_Pixel_Width(char const * string) const -{ - if (string == NULL) return(0); - if (string[0] == 0) return 0; - - int largest = 0; // Largest recorded width of the string. - int width = 0; - while (*string) { - if (*string == '\r' || *string == '\n') { - string++; - largest = MAX(largest, width); - width = 0; - } else { - width += Char_Pixel_Width(*string++); // add each char's width - } - } - largest = MAX(largest, width); - return(largest); -} - - -/*********************************************************************************************** - * WWFontClass::Raw_Width -- Fetch the raw width of a character. * - * * - * This routine returns the nominal width of the font. This width is basically the width of * - * the widest character in the font. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the width of the widest character in the font. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Raw_Width(void) const -{ - return(*(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXWIDTH)); -} - - -/*********************************************************************************************** - * WWFontClass::Raw_Height -- Fetch the height of the font. * - * * - * This returns the height of the font without regard for any Y spacing offsets. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the height of the font. * - * * - * WARNINGS: All characters in the font have the same logical height even if they actually * - * consume less pixels. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Raw_Height(void) const -{ - return(*(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXHEIGHT)); -} - - -/*********************************************************************************************** - * WWFontClass::Get_Width -- Get normalized width of the nominal font character. * - * * - * This routine is used to fetch the width of the widest character in the font but the * - * width has been biased according to any X spacing override present. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the normalized width of the widest character in the font. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Get_Width(void) const -{ - return(Raw_Width() + ((FontXSpacing > 0) ? FontXSpacing : 0)); -} - - -/*********************************************************************************************** - * WWFontClass::Get_Height -- Fetch the normalized height of the nominal font character. * - * * - * This will return the height of the font but the returned height will be adjusted by any * - * Y spacing override present. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the height of the font normalized by any spacing overrides. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Get_Height(void) const -{ - return(Raw_Height() + ((FontYSpacing > 0) ? FontYSpacing : 0)); -} - - -/*********************************************************************************************** - * WWFontClass::Set_XSpacing -- Set the X spacing override value. * - * * - * Use this routine to control the horizontal spacing override for this font. If the value * - * is negative, the font becomes compressed. If the value is positive, then the font * - * becomes expanded. * - * * - * INPUT: x -- The X spacing override to use for this font. * - * * - * OUTPUT: Returns with the old X spacing override value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Set_XSpacing(int x) -{ - int old = FontXSpacing; - FontXSpacing = x; - if (IsOutlinedData) { - switch (Shadow) { - case 0: - FontXSpacing += -2; - break; - - case 1: - FontXSpacing += -1; - break; - - case 2: - FontXSpacing += -1; - break; - } - } - FontXSpacing += Get_Width() / FUDGEDIV; - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. * - * * - * Use this routine to control the "line spacing" of a font. If the Y spacing is negative * - * then the font becomes closer to the line above it. If value is positive, then more * - * space occurs between lines. * - * * - * INPUT: y -- The Y spacing override to use for this font. * - * * - * OUTPUT: Returns with the old Y spacing override value. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - *=============================================================================================*/ -int WWFontClass::Set_YSpacing(int y) -{ - int old = FontYSpacing; - FontYSpacing = y; - if (IsOutlinedData) { - switch (Shadow) { - case 0: - FontYSpacing += -2; - break; - - case 1: - FontYSpacing += -1; - break; - - case 2: - FontYSpacing += -1; - break; - } - } - FontYSpacing += Get_Height() / FUDGEDIV; - return(old); -} - - -/*********************************************************************************************** - * WWFontClass::Print -- Print text to the surface specified. * - * * - * This displays text to the surface specified and with the attributes specified. * - * * - * INPUT: string -- The string to display to the surface. * - * * - * surface -- The surface to display the text upon. * - * * - * cliprect -- The clipping rectangle that both clips the text and biases the print * - * location to. * - * * - * point -- The draw position for the upper left corner of the first character. * - * * - * convert -- The pixel convert object that is used to draw the correct colors to * - * the destination surface. * - * * - * remap -- Auxiliary remap table for font colors. * - * * - * OUTPUT: Returns with the point where the next print should begin if it is to smoothly * - * continue where this print operation left off. * - * * - * WARNINGS: There are two separate drawing routines; one for old fonts and one for new * - * fonts. * - * * - * HISTORY: * - * 05/26/1997 JLB : Created. * - * 06/20/1887 BNA : Modified to handle new fonts. * - * 01/24/2000 SKB : Updated from C&C to include BNA code. * - * 01/24/2000 SKB : put in call for Get_Remap_Palette * - * 01/24/2000 SKB : Put in call for get converer. * - *=============================================================================================*/ -Point2D WWFontClass::Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & drawpoint, ConvertClass const & convertref, unsigned char const * remap) const -{ - if (string == NULL) return(drawpoint); - - /* - ** Compute the surface relative coordinate for the print position. - */ - Point2D point = drawpoint; - int xpos = point.Bias_To(cliprect).X; -// int xpos = point.X + cliprect.X; - int ypos = point.Bias_To(cliprect).Y; -// int ypos = point.Y + cliprect.Y; - - int xspacing = FontXSpacing + Raw_Width()/FUDGEDIV; - int yspacing = FontYSpacing + Raw_Width()/FUDGEDIV; - - // This font palette assumes that the font will be used as defined by converter. - static unsigned char const fontpalette[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - if (RemapPalette) { - remap = RemapPalette; - } else if (!remap) { - remap = &fontpalette[0]; - } - - // If there is a convert supplied with the font, use it as priority. - ConvertClass const *converter = Converter; - if (!converter) { - converter = &convertref; - } - - /* - ** Verify that the clipping rectangle (if present) falls within the bounds of the surface. - */ -// Rect cliprect = surface->Get_Rect(); -// cliprect.X = 0; -// cliprect.Y = 0; - - /* - ** Trivially check to see if the print start position is outside the bounds of the clipping - ** rectangle. - */ - if (xpos >= cliprect.X+cliprect.Width || ypos >= cliprect.Y+cliprect.Height) { - return(drawpoint); - } - - /* - ** Check to see if access to the surface buffer is possible. - */ - void * buffer = surface.Lock(); - if (buffer != NULL) { - int startx = xpos; - unsigned char * fontwidth = ((unsigned char*)FontData) + FontData->WidthBlockOffset; - unsigned short * fontheight = (unsigned short*)(((unsigned char*)FontData) + FontData->HeightOffset); - unsigned short * fontoffset = (unsigned short*)(((unsigned char*)FontData) + FontData->OffsetBlockOffset); - int bbp = surface.Bytes_Per_Pixel(); - - /* - ** Process the whole string. Stop when the string reaches the right margin. - */ - while (*string != '\0') { - unsigned char c = *string++; - - /* - ** Certain control characters serve a formatting purpose. They merely - ** adjust the next draw position. - */ - if (c == '\r') { - xpos = startx; - ypos += Raw_Height() + ((yspacing > 0) ? yspacing : 0); - continue; - } - if (c == '\n') { - xpos = cliprect.X; - ypos += Raw_Height() + ((yspacing > 0) ? yspacing : 0); - continue; - } - - /* - ** Fetch working values for the character to display. These are used to - ** control the size of the character rectangle. - */ - int width = fontwidth[c]; - int dheight = fontheight[c] >> 8; - int firstrow = fontheight[c] & 0xFF; -// int height = dheight+firstrow; - - /* - ** Build the character rectangle (surface relative coordinates). - */ - Rect crect(xpos, ypos, width+((xspacing > 0) ? xspacing : 0), *(((unsigned char *)FontData) + FontData->InfoBlockOffset + FONTINFOMAXHEIGHT) + ((yspacing > 0) ? yspacing : 0)); - - /* - ** Check to see if any part of this character would appear within the clipping - ** rectangle. If not, then don't process this character. - */ - crect = crect.Intersect(cliprect); - if (crect.Is_Valid()) { - - /* - ** Fill the background of the character if the background - ** color is not transparent. - */ - if (remap[0] != 0) { - surface.Fill_Rect(crect, converter->Convert_Pixel(remap[0])); - } - - /* - ** Loop through all data rows of this character and output the row - ** data with clipping. - */ - if (FontData->FontCompress != (char) 2) { // if the font is the old style - unsigned char * dataptr = ((unsigned char *)FontData) + fontoffset[c]; - void * drawbuff = (void*)(((char*)buffer) + ((ypos + firstrow) * surface.Stride()) + xpos * bbp); - - for (int h = 0; h < dheight; h++) { - - /* - ** If the current row to be drawn falls below the clipping rectangle, then - ** no further drawing for this character is needed -- bail out. - */ - if (ypos + firstrow + h >= crect.Y + crect.Height) break; - - /* - ** If the current row to be drawn falls above the clipping rectangle, - ** then skip the row and advance the source data pointer as well. - */ - if (ypos + firstrow + h < crect.Y) { - drawbuff = (void*)(((char*)drawbuff) + surface.Stride()); - dataptr = dataptr + ((width+1)/2); - } else { - - /* - ** Process one row of character data. For simplicity reasons, just - ** loop through all pixels of this row and perform clipping at the - ** pixel level. - */ - int dx = xpos; - int workwidth = width; - while (workwidth > 0) { - - /* - ** Fetch the next two pixel values. Two pixel values must - ** be fetched at the same time since they are nibble packed. - */ - int c1 = remap[*dataptr & 0x0F]; - int c2 = remap[(*dataptr++ & 0xF0) >> 4]; - - /* - ** Draw the first pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c1 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c1); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c1); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - if (workwidth == 0) break; - - /* - ** Draw the second pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c2 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c2); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c2); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - } - - /* - ** Move the output pixel pointer to the next line down but at the - ** left margin of the character block. - */ - drawbuff = (void*)((((char*)drawbuff) - (width*bbp)) + surface.Stride()); - } - } - } else { - // the font is of the new type - unsigned char * dataptr = ((unsigned char *)FontData) + fontoffset[c] + FontData->DataBlockOffset; - void * drawbuff = (void*)(((char*)buffer) + ((ypos + firstrow) * surface.Stride()) + xpos * bbp); - - for (int h = 0; h < dheight; h++) { - - /* - ** If the current row to be drawn falls below the clipping rectangle, then - ** no further drawing for this character is needed -- bail out. - */ - if (ypos + firstrow + h >= crect.Y + crect.Height) break; - - /* - ** If the current row to be drawn falls above the clipping rectangle, - ** then skip the row and advance the source data pointer as well. - */ - if (ypos + firstrow + h < crect.Y) { - drawbuff = (void*)(((char*)drawbuff) + surface.Stride()); - dataptr = dataptr + width; - } else { - - /* - ** Process one row of character data. For simplicity reasons, just - ** loop through all pixels of this row and perform clipping at the - ** pixel level. - */ - int dx = xpos; - int workwidth = width; - while (workwidth > 0) { - - /* - ** Fetch the next pixel value. - */ - int c1 = remap[*dataptr++]; // no remapping - - /* - ** Draw the pixel if it falls within the clipping - ** rectangle and is not transparent. - */ - if (dx >= cliprect.X && dx < cliprect.X+cliprect.Width) { - if (c1 != 0) { - if (bbp == 2) { - *(short *)drawbuff = (short)converter->Convert_Pixel(c1); - } else { - *(char *)drawbuff = (char)converter->Convert_Pixel(c1); - } - } - } - dx += 1; - drawbuff = ((char*)drawbuff) + bbp; - workwidth -= 1; - } - - /* - ** Move the output pixel pointer to the next line down but at the - ** left margin of the character block. - */ - drawbuff = (void*)((((char*)drawbuff) - (width*bbp)) + surface.Stride()); - } - } - } - } - xpos += Char_Pixel_Width(c); -// xpos += width + xspacing; - } - - point = Point2D(xpos - cliprect.X, ypos - cliprect.Y); - surface.Unlock(); - } - return(point); -} diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.h deleted file mode 100644 index ebba0d4362e..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwfont.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/wwfont.h $* - * * - * $Author:: Scott_b $* - * * - * $Modtime:: 4/21/00 1:03p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef WWFONT_H -#define WWFONT_H - -#include "FONT.H" -#include "Surface.h" - -class ConvertClass; - -/* -** This is a concrete font class object that is used to handle font data as generated by -** the legacy FONTMAKE.EXE utility. -*/ -class WWFontClass : public FontClass -{ - typedef FontClass BASECLASS; - - public: - WWFontClass(void const * fontdata, bool isoutlined=false, int shadow=0, ConvertClass *convert = 0, unsigned char *remap = 0); - virtual ~WWFontClass(void) {} - - void *Set_Font_Data(void const * fontdata); - void *Get_Font_Data() { - return((void *)FontData); - } - - // User can setup a palette to use for this font. - // If set, this will override all other colors (even fore and background colors). - // User should reset to default when done. - unsigned char *Set_Remap_Palette(unsigned char *palette) { - unsigned char *old = RemapPalette; - RemapPalette = palette; - return(old); - } - unsigned char *Get_Remap_Palette() const { - return(RemapPalette); - } - - ConvertClass *Set_Converter(ConvertClass *convert) { - ConvertClass *old = Converter; - Converter = convert; - return(old); - } - ConvertClass *Get_Converter() const { - return(Converter); - } - - virtual int Char_Pixel_Width(char c) const; - virtual int String_Pixel_Width(char const * string) const; - virtual int Get_Width(void) const; - virtual int Get_Height(void) const; - virtual Point2D Print(char const * string, Surface & surface, Rect const & cliprect, Point2D const & point, ConvertClass const & converter, unsigned char const * remap=NULL) const; - - virtual int Set_XSpacing(int x); - virtual int Set_YSpacing(int y); - - private: - - /* - ** Is the font an outline type font (with special outline - ** pixels in the source art)? - */ - bool IsOutlinedData; - - /* - ** Shadow type to use when displaying this font. The value only applies if the - ** font is equipped with outline data. - */ - int Shadow; - - /* - ** Override font X spacing value. - */ - int FontXSpacing; - - /* - ** Override font Y spacing value. - */ - int FontYSpacing; - - /* - ** Header structure of the font data file. - */ - typedef struct FontType { - unsigned short FontLength; - unsigned char FontCompress; - unsigned char FontDataBlocks; - unsigned short InfoBlockOffset; - unsigned short OffsetBlockOffset; - unsigned short WidthBlockOffset; - unsigned short DataBlockOffset; - unsigned short HeightOffset; - } FontType; - FontType const * FontData; - - - // Pointer to a font palette for the font. - unsigned char *RemapPalette; - - // Pointer to a converter. - ConvertClass *Converter; - - int Raw_Width(void) const; - int Raw_Height(void) const; -}; - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.cpp deleted file mode 100644 index ad254c4fc95..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.cpp +++ /dev/null @@ -1,1005 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/wwmouse.cpp $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 8/11/97 10:14a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Callback_Process_Mouse -- Mouse O/S callback function. * - * WWMouseClass::WWMouseClass -- Constructor for mouse handler object. * - * WWMouseClass::~WWMouseClass -- Destructor for mouse handler object. * - * WWMouseClass::Get_Mouse_State -- Fetch the current mouse visibility state. * - * WWMouseClass::Set_Cursor -- Set the mouse cursor shape. * - * WWMouseClass::Is_Data_Valid -- Determines if there is valid shape image data. * - * WWMouseClass::Validate_Copy_Buffer -- Checks for and validates the background copy buffer.* - * WWMouseClass::Matching_Rect -- Finds rectangle of current cursor position & size. * - * WWMouseClass::Save_Background -- Saves the background to a copy buffer. * - * WWMouseClass::Restore_Background -- Restores the image back where it came from. * - * WWMouseClass::Draw_Mouse -- Manually draw the mouse to the surface specified. * - * WWMouseClass::Erase_Mouse -- Restores the surface after a Draw_Mouse call. * - * WWMouseClass::Raw_Draw_Mouse -- Draws the mouse to the surface specified. * - * WWMouseClass::Low_Show_Mouse -- Shows the mouse and saves the background. * - * WWMouseClass::Low_Hide_Mouse -- Restores the surface image in order to hide the mouse. * - * WWMouseClass::Show_Mouse -- Shows the mouse on the visible surface. * - * WWMouseClass::Hide_Mouse -- Hides the mouse from the visible surface. * - * WWMouseClass::Capture_Mouse -- Capture the mouse into the mouse handler region. * - * WWMouseClass::Release_Mouse -- Release the mouse back to the O/S. * - * WWMouseClass::Conditional_Hide_Mouse -- Hides the mouse if it would overlap the region spe* - * WWMouseClass::Conditional_Show_Mouse -- Releases the mouse hiding region tracking. * - * WWMouseClass::Convert_Coordinate -- Convert an O/S coordinate into a logical coordinate. * - * WWMouseClass::Get_Bounded_Position -- Fetches the mouse position from the O/S. * - * WWMouseClass::Update_Mouse_Position -- Updates the mouse position to match that specified.* - * WWMouseClass::Process_Mouse -- Mouse processing callback routine. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "_convert.h" -#include "_mono.h" -#include "blit.h" -#include "bsurface.h" -#include "draw.h" -#include "shapeset.h" -#include "Surface.h" -#include "win.h" -#include "wwmouse.h" -#include - - -/* -** Persistant mouse object pointer that is used to facilitate access to the mouse -** handler object outside of the context of a member function. This will be set to the -** mouse object most recently created. -*/ -static WWMouseClass * _MousePtr = NULL; - - -/*********************************************************************************************** - * Callback_Process_Mouse -- Mouse O/S callback function. * - * * - * This routine is called periodically by the operating system. It handles updating the * - * mouse cursor position to match the mouse movement. * - * * - * INPUT: n/a * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void CALLBACK Callback_Process_Mouse( UINT, UINT, DWORD, DWORD, DWORD ) -{ - if (_MousePtr != NULL) { - _MousePtr->Process_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::WWMouseClass -- Constructor for mouse handler object. * - * * - * This is the constructor for the mouse handler object. It is assigned to a surface and * - * given a confining rectangle. The mouse begins in a non-captured state. * - * * - * INPUT: surfaceptr -- Pointer to the visible display surface that will show the mouse. * - * * - * confine -- The confining rectangle within the visible surface. The mouse * - * coordinates are bound to this rectangle. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -WWMouseClass::WWMouseClass(Surface * surfaceptr, HWND window) : - Blocked(false), - MouseState(-1), - IsCaptured(false), - MouseX(0), - MouseY(0), - SurfacePtr(surfaceptr), - Window(window), - MouseShape(NULL), - ShapeNumber(0), - MouseXHot(0), - MouseYHot(0), - Background(NULL), - Alternate(NULL), - SidebarAlternate(NULL), - ConditionalRect(0,0,0,0), - ConditionalState(-1), - TimerHandle(0) -{ - _MousePtr = this; - TimerHandle = timeSetEvent(1000/60, 1, Callback_Process_Mouse, 0, TIME_PERIODIC); - Calc_Confining_Rect(); - MouseXHot = ConfiningRect.X + (ConfiningRect.Width/2); - MouseYHot = ConfiningRect.Y + (ConfiningRect.Height/2); -} - - -/*********************************************************************************************** - * WWMouseClass::~WWMouseClass -- Destructor for mouse handler object. * - * * - * This will remove the mouse handler object from being processed. It returns the mouse * - * back to O/S control. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -WWMouseClass::~WWMouseClass(void) -{ - if (TimerHandle != 0) { - timeKillEvent(TimerHandle); - _MousePtr = NULL; - } - - delete Background; - Background = NULL; - - delete Alternate; - Alternate = NULL; - delete SidebarAlternate; - SidebarAlternate = NULL; -} - - -void WWMouseClass::Calc_Confining_Rect(void) -{ - RECT rect; - GetClientRect(Window, &rect); - - POINT point; - point.x = rect.left; - point.y = rect.top; - ClientToScreen(Window, &point); - - POINT lr; - lr.x = rect.right; - lr.y = rect.bottom; - ClientToScreen(Window, &lr); - - ConfiningRect = Rect(point.x, point.y, lr.x-point.x, lr.y-point.y); -// ConfiningRect = Rect(point.x, point.y, lr.x-point.x+1, lr.y-point.y+1); -} - - -/*********************************************************************************************** - * WWMouseClass::Get_Mouse_State -- Fetch the current mouse visibility state. * - * * - * This routine is used to retrieve the current mouse state as it relates to visiblity. * - * By using this routine it is possible to determine if the mouse is visible. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the current mouse visibility state. If the return value is less than * - * 0 (i.e., negative), then the mouse is hidden. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -int WWMouseClass::Get_Mouse_State(void) const -{ - if (!Is_Captured()) { - ShowCursor(FALSE); - int state = ShowCursor(TRUE); - return(state); - } - return(MouseState); -} - - -/*********************************************************************************************** - * WWMouseClass::Set_Cursor -- Set the mouse cursor shape. * - * * - * This routine sets the mouse cursor image and hot-spot. The shape only applies to the * - * mouse when it is captured (the normal case). Repeated calls to this routine is used * - * to give the mouse animation. * - * * - * INPUT: xhotspot, yhotspot -- The X,Y offset from the upper left corner of the shape * - * that specifies the hot-spot of the image. Positive values * - * are right and down from the upper left corner. * - * * - * cursor -- Pointer to the shape data. * - * * - * shape -- The shape number to use within the shape data set specified. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Set_Cursor(int xhotspot, int yhotspot, ShapeSet const * cursor, int shape) -{ - if (cursor != NULL) { - if (Is_Captured()) { - Block_Mouse(); - if (!Is_Hidden()) Low_Hide_Mouse(); - MouseShape = cursor; - ShapeNumber = shape; - MouseXHot = xhotspot; - MouseYHot = yhotspot; - if (!Is_Hidden()) Low_Show_Mouse(); - Unblock_Mouse(); - } else { - MouseShape = cursor; - ShapeNumber = shape; - MouseXHot = xhotspot; - MouseYHot = yhotspot; - } - } -} - - -/*********************************************************************************************** - * WWMouseClass::Is_Data_Valid -- Determines if there is valid shape image data. * - * * - * This routine does a simple check to determine if the shape handler has been supplied * - * a pointer to shape imagery. Any internal routine that requires the data to be present * - * should call this routine to be sure it actually is. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Has a shape image data pointer been supplied to this mouse handler? * - * * - * WARNINGS: When the mouse object is first created, no image data has been assigned. The * - * Set_Cursor must be called before this routine will return TRUE. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -bool WWMouseClass::Is_Data_Valid(void) const -{ - if (MouseShape != NULL) { - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * WWMouseClass::Validate_Copy_Buffer -- Checks for and validates the background copy buffer. * - * * - * This routine checks and allocates if necessary a buffer that is big enough to hold the * - * background image under the mouse. Whenever the background buffer is needed, this routine * - * should be called to ensure that it is valid. * - * * - * INPUT: none * - * * - * OUTPUT: bool; Is the buffer valid? * - * * - * WARNINGS: This routine might fail if there was insufficient memory. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -bool WWMouseClass::Validate_Copy_Buffer(void) -{ - if (Is_Data_Valid()) { - - /* - ** If there is a background buffer already allocated, then verify that - ** it is large enough for the current shape data. If not, then free the - ** buffer and reallocate it at the larger size. - */ - if (Background != NULL) { - if (MouseShape->Get_Width() > Background->Get_Width() || - MouseShape->Get_Height() > Background->Get_Height()) { - - delete Background; - Background = NULL; - } - } - if (Alternate != NULL) { - if (MouseShape->Get_Width() > Alternate->Get_Width() || - MouseShape->Get_Height() > Alternate->Get_Height()) { - - delete Alternate; - Alternate = NULL; - } - } - if (SidebarAlternate != NULL) { - if (MouseShape->Get_Width() > SidebarAlternate->Get_Width() || - MouseShape->Get_Height() > SidebarAlternate->Get_Height()) { - - delete SidebarAlternate; - SidebarAlternate = NULL; - } - } - - /* - ** Allocate a new background buffer if necessary. This must be big enough to - ** hold the largest sized shape from the currently assigned shape set data. - */ - if (Background == NULL) { - Background = new BSurface(MouseShape->Get_Width(), MouseShape->Get_Height(), SurfacePtr->Bytes_Per_Pixel()); - } - if (Alternate == NULL) { - Alternate = new BSurface(MouseShape->Get_Width(), MouseShape->Get_Height(), SurfacePtr->Bytes_Per_Pixel()); - } - if (SidebarAlternate == NULL) { - SidebarAlternate = new BSurface(MouseShape->Get_Width(), MouseShape->Get_Height(), SurfacePtr->Bytes_Per_Pixel()); - } - - return(Background != NULL && Alternate != NULL && SidebarAlternate != NULL); - } - return(false); -} - - -/*********************************************************************************************** - * WWMouseClass::Matching_Rect -- Finds rectangle of current cursor position & size. * - * * - * This routine will return the logical rectangle that exactly encloses the cursor. This * - * routine is typically used when drawing the cursor and manipulating the background buffer * - * under it. * - * * - * INPUT: none * - * * - * OUTPUT: Returns with the rectangle that surrounds the cursor. * - * * - * WARNINGS: The rectangle is in logical coordinates. It may have to be biased to O/S * - * coordinates if necessary. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -Rect WWMouseClass::Matching_Rect(void) const -{ - Rect rect; - if (Is_Data_Valid()) { - ((WWMouseClass *)this)->Block_Mouse(); - - /* - ** Build the rectangle that the mouse shape will consume. - */ - rect = MouseShape->Get_Rect(ShapeNumber); - rect.X += MouseX - MouseXHot; - rect.Y += MouseY - MouseYHot; - - ((WWMouseClass *)this)->Unblock_Mouse(); - } - return(rect); -} - - -/*********************************************************************************************** - * WWMouseClass::Save_Background -- Saves the background to a copy buffer. * - * * - * This routine will save the region under the mouse (or where the mouse would appear at) * - * to a copy buffer. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: The previous contents of the copy buffer will be overwritten by this routine. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Save_Background(void) -{ - if (Validate_Copy_Buffer()) { - - /* - ** Build the rectangle that the mouse shape will consume. - */ - SavedRegion = Matching_Rect(); - - Rect rect = SavedRegion; - rect.X += ConfiningRect.X; - rect.Y += ConfiningRect.Y; - - /* - ** Blit the background from the surface to the holding buffer. - */ -// Rect old = SurfacePtr->Get_Rect(); -// SurfacePtr->Window.Reset(); - Background->Blit_From(Rect(0, 0, rect.Width, rect.Height), *SurfacePtr, rect); -// SurfacePtr->Window.Set(old); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Restore_Background -- Restores the image back where it came from. * - * * - * This is the counterpart routine to the Save_Background function. It will restore the * - * image from the copy buffer back to the screen where it came from. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Restore_Background(void) -{ - if (SavedRegion.Is_Valid()) { - - Rect rect = SavedRegion; - rect.X += ConfiningRect.X; - rect.Y += ConfiningRect.Y; - - /* - ** Blit the background from the holding buffer to the surface. - */ -// Rect old = SurfacePtr->Get_Rect(); -// SurfacePtr->Window.Reset(); - SurfacePtr->Blit_From(rect, *Background, Rect(0, 0, rect.Width, rect.Height)); -// SurfacePtr->Window.Set(old); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Draw_Mouse -- Manually draw the mouse to the surface specified. * - * * - * This is a kludge function that can be used to reduce mouse flicker. Normally the mouse * - * must be hidden before an image is copied to the visible surface. By drawing the mouse * - * in the correct position on the source image prior to the copy, the mouse doesn't need * - * to be hidden and no mouse flicker occurs. This routine handles this manual draw process. * - * * - * INPUT: surface -- Pointer to the surface that the mouse will be drawn to. * - * * - * OUTPUT: none * - * * - * WARNINGS: The destination surface is presumed to be the exact dimensions of the bouding * - * rectangle specified in the mouse constructor. The call to Erase_Mouse must * - * occur as soon as possible since the mouse is frozen until it is called. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Draw_Mouse(Surface * surface, bool issidebarsurface) -{ - - BSurface *savesurface; - Rect *savedregion; - int xoffset; - int yoffset; - - if (issidebarsurface){ - xoffset = -480; - yoffset = 0; - savesurface = SidebarAlternate; - savedregion = &SidebarAltRegion; - }else{ - xoffset = 0; - yoffset = 0; - savesurface = Alternate; - savedregion = &AltRegion; - } - - if (!Is_Hidden() && surface != NULL && surface != SurfacePtr && savesurface != NULL) { - Block_Mouse(); - - /* - ** Blit the background from the surface to the holding buffer. - */ - //Rect old = surface->Window.Get_Rect(); - //surface->Window.Reset(); - *savedregion = SavedRegion; - savedregion->X += xoffset; - savedregion->Y += yoffset; - savesurface->Blit_From(Rect(0, 0, savedregion->Width, savedregion->Height), *surface, *savedregion); - if (issidebarsurface){ - if (savedregion->X < 0 && -savedregion->X < Background->Get_Width()){ - Background->Blit_From(Rect(-savedregion->X, 0, savedregion->Width, savedregion->Height), - *surface, Rect(0,savedregion->Y, savedregion->Width, savedregion->Height)); - } - }else{ - Background->Blit_From(Rect(0, 0, savedregion->Width, savedregion->Height), *surface, *savedregion); - } - //surface->Window.Set(old); - Raw_Draw_Mouse(surface, xoffset, yoffset); - Unblock_Mouse(); - } else { - savedregion->Width = 0; - } -} - - -/*********************************************************************************************** - * WWMouseClass::Erase_Mouse -- Restores the surface after a Draw_Mouse call. * - * * - * This is the counterpart routine to Draw_Mouse. It will restore the specified surface * - * back to its original state. The mouse is frozen between the calls to Draw_Mouse and * - * Erase_Mouse, so it is imperative to call this routine at the first legal opportunity. * - * * - * INPUT: surface -- Pointer to the surface that the mouse was previously drawn to. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Erase_Mouse(Surface * surface, bool issidebarsurface) -{ - if (!Is_Hidden() && surface != NULL && surface != SurfacePtr && Alternate != NULL && SidebarAlternate != NULL) { - - BSurface *savesurface; - Rect savedregion; - - if (issidebarsurface){ - savesurface = SidebarAlternate; - savedregion = SidebarAltRegion; - }else{ - savesurface = Alternate; - savedregion = AltRegion; - } - - /* - ** Blit the background from the holding buffer to the surface. - */ - Block_Mouse(); - //Rect old = surface->Window.Get_Rect(); - //surface->Window.Reset(); - surface->Blit_From(savedregion, *savesurface, Rect(0, 0, savedregion.Width, savedregion.Height)); - //surface->Window.Set(old); - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Raw_Draw_Mouse -- Draws the mouse to the surface specified. * - * * - * This will draw the mouse image to the surface specified. It does not do any checking * - * except to make sure that the mouse image data is nominally valid. * - * * - * INPUT: surface -- The surface to draw the mouse upon. * - * * - * OUTPUT: none * - * * - * WARNINGS: The background is not preserved by this routine. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Raw_Draw_Mouse(Surface * surface, int xoffset, int yoffset) -{ - if (Is_Data_Valid() && surface != NULL) { - - /* - ** Determine the rectangle that the mouse will be drawn - ** to. - */ - - Rect rect = SavedRegion; - rect.X += xoffset; - rect.Y += yoffset; -// if (surface == SurfacePtr) { -// rect.X += ConfiningRect.X; -// rect.Y += ConfiningRect.Y; -// } - -// Rect old = surface->Get_Rect(); -// surface->Window.Reset(); - BSurface mdata(rect.Width, rect.Height, 1, MouseShape->Get_Data(ShapeNumber)); - - if (surface == SurfacePtr) { - Blit_Block(*surface, *NormalDrawer, mdata, Rect(0, 0, rect.Width, rect.Height), Point2D(rect.X, rect.Y), ConfiningRect); - } else { - Blit_Block(*surface, *NormalDrawer, mdata, Rect(0, 0, rect.Width, rect.Height), Point2D(rect.X, rect.Y), surface->Get_Rect()); - } - - //surface->Window.Set(old); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Low_Show_Mouse -- Shows the mouse and saves the background. * - * * - * This routine will save the background and then draw the mouse to the visible surface. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Low_Show_Mouse(void) -{ - Block_Mouse(); - Save_Background(); - Raw_Draw_Mouse(SurfacePtr, 0, 0); - Unblock_Mouse(); -} - - -/*********************************************************************************************** - * WWMouseClass::Low_Hide_Mouse -- Restores the surface image in order to hide the mouse. * - * * - * This routine will hide the mouse on the visible surface. It does this by restoring the * - * pixels under where the mouse was previously drawn. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Low_Hide_Mouse(void) -{ - Block_Mouse(); - Restore_Background(); - Unblock_Mouse(); -} - - -/*********************************************************************************************** - * WWMouseClass::Show_Mouse -- Shows the mouse on the visible surface. * - * * - * This routine is called when the mouse can be shown on the visible surface. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Show_Mouse(void) -{ - if (!Is_Captured()) { - ShowCursor(TRUE); - } else { - Block_Mouse(); - InterlockedIncrement(&MouseState); - if (MouseState == 0) { - Low_Show_Mouse(); - } - assert(MouseState != 1); - if (MouseState > 0) MouseState = 0; - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Hide_Mouse -- Hides the mouse from the visible surface. * - * * - * This routine is called when the mouse is desired to be hidden from the visible surface. * - * Typically, this must occur if the pixels where the mouse is located will be accessed. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Hide_Mouse(void) -{ - if (!Is_Captured()) { - ShowCursor(FALSE); - } else { - Block_Mouse(); - InterlockedDecrement(&MouseState); - if (MouseState == -1) { - Low_Hide_Mouse(); - } - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Capture_Mouse -- Capture the mouse into the mouse handler region. * - * * - * This routine will confine the mouse to the confining rectangle and take over drawing * - * of the mouse image from the operating system. The typical state is to keep the mouse * - * captured throughout the lifetime of the owning program. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Capture_Mouse(void) -{ - if (this != NULL && !Is_Captured()) { - Block_Mouse(); - while (ShowCursor(FALSE) > -1) {} - while (ShowCursor(TRUE) < -1) {} - Hide_Mouse(); - IsCaptured = true; - - Show_Mouse(); - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Release_Mouse -- Release the mouse back to the O/S. * - * * - * This is the counterpart routine to Capture_Mouse. This routine will return the drawing * - * and movement controls back to the operating system. Although the mouse will probably * - * be able to roam outside the confining rectangle, the coordinates returned by this class * - * are clipped to the confining rectangle anyway. This gives the impression that the mouse * - * is still at a legal position. The presumption is that the mouse needs to be released to * - * the O/S for reasons outside of the game itself. As such, the shouldn't detect any * - * illegal mouse position. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: All mouse shape changes won't be relected while the mouse is released. The O/S * - * handles drawing the mouse in that case. * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Release_Mouse(void) -{ - if (this != NULL && Is_Captured()) { - Block_Mouse(); - Hide_Mouse(); - IsCaptured = false; - while (ShowCursor(FALSE) > -1) {} - while (ShowCursor(TRUE) < -1) {} - Show_Mouse(); - - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Conditional_Hide_Mouse -- Hides the mouse if it would overlap the region spec * - * * - * This routine will hide the mouse if it lies within the region specified or if it moves * - * within the region. * - * * - * INPUT: rect -- The rectangle that the mouse should not be drawn within. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Conditional_Hide_Mouse(Rect ) -{ - Hide_Mouse(); -} - - -/*********************************************************************************************** - * WWMouseClass::Conditional_Show_Mouse -- Releases the mouse hiding region tracking. * - * * - * This routine will release the region hiding tracking that was set up with a previous * - * call to Conditional_Hide_Mouse(). * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Conditional_Show_Mouse(void) -{ - Show_Mouse(); -} - - -/*********************************************************************************************** - * WWMouseClass::Convert_Coordinate -- Convert an O/S coordinate into a logical coordinate. * - * * - * Sometimes you come across system mouse coordinates and they need to be converted into * - * game logical coordinates. This routine will perform this function. * - * * - * INPUT: x,y -- Reference to the coordinates that will be converted into game logical * - * coordinates. * - * * - * OUTPUT: none * - * * - * WARNINGS: The coordinates will be bound as well as transformed by the confining rectangle.* - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Convert_Coordinate(int & x, int & y) const -{ - /* - ** Convert the mouse position to legal bounds. - */ - x -= ConfiningRect.X; - y -= ConfiningRect.Y; - if (x < 0) x = 0; - if (y < 0) y = 0; - if (x >= ConfiningRect.Width) x = ConfiningRect.Width-1; - if (y >= ConfiningRect.Height) y = ConfiningRect.Height-1; -} - - -/*********************************************************************************************** - * WWMouseClass::Get_Bounded_Position -- Fetches the mouse position from the O/S. * - * * - * Fetches the mouse coordinates from the O/S and converts them into logical coordinates. * - * * - * INPUT: x,y -- Reference to the coordinates that will be set by this routine. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Get_Bounded_Position(int & x, int & y) const -{ - /* - ** Get the mouse's current real cursor position - */ - POINT pt; - GetCursorPos(&pt); // get the current cursor position - x = pt.x; - y = pt.y; - Convert_Coordinate(x, y); -} - - -/*********************************************************************************************** - * WWMouseClass::Update_Mouse_Position -- Updates the mouse position to match that specified. * - * * - * This routine will update the mouse to match the position speicifed. * - * * - * INPUT: x,y -- The coordinates to position the mouse (hot spot). The coordinates are * - * specified as logical not O/S relative. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Update_Mouse_Position(int x, int y) -{ - /* - ** If the desired position is not the same as the current - ** position, then hide the mouse, reposition it, then show - ** the mouse. - */ - Block_Mouse(); - if (x != MouseX || y != MouseY) { - if (Is_Captured() && !Is_Hidden()) Low_Hide_Mouse(); - MouseX = x; - MouseY = y; - if (Is_Captured() && !Is_Hidden()) Low_Show_Mouse(); - } - Unblock_Mouse(); -} - - -/*********************************************************************************************** - * WWMouseClass::Process_Mouse -- Mouse processing callback routine. * - * * - * This routine should be called periodically (recommended 15 times per second). It will * - * examine the operating system mouse position and then update the visible mouse to match. * - * * - * INPUT: none * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 03/10/1997 JLB : Created. * - *=============================================================================================*/ -void WWMouseClass::Process_Mouse(void) -{ - if (!Is_Blocked()) { - Block_Mouse(); - - /* - ** Fetch and update the mouse position. - */ - int x; - int y; - Get_Bounded_Position(x, y); - Update_Mouse_Position(x, y); - Unblock_Mouse(); - } -} - - -/*********************************************************************************************** - * WWMouseClass::Set_Mouse_XY -- Sets the cursor position * - * * - * This routine will convert the position passed into screen coordinates and tell Windows * - * to position the mouse cursor there * - * * - * INPUT: x and y in game coordinates * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 08/11/1997 BG : Created. * - *=============================================================================================*/ -void WWMouseClass::Set_Mouse_XY( int x, int y ) -{ - if (x < 0) x = 0; // clamp to game coordinates - if (y < 0) y = 0; - if (x >= ConfiningRect.Width) x = ConfiningRect.Width-1; - if (y >= ConfiningRect.Height) y = ConfiningRect.Height-1; - - x += ConfiningRect.X; // convert to screen coordinates - y += ConfiningRect.Y; - - SetCursorPos( x, y ); // set the current cursor position -} - - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h deleted file mode 100644 index db04825eafa..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/wwmouse.h +++ /dev/null @@ -1,242 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/Library/wwmouse.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 8/11/97 10:11a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef WW_MOUSE_H -#define WW_MOUSE_H - -#include "win.h" -#include "xmouse.h" - -class BSurface; - -/* -** Handles the mouse as it relates to the C&C game engine. It is expected that only -** one object of this type will be created during the lifetime of the game. -*/ -class WWMouseClass : public Mouse { - public: - /* - ** Private constructor. - */ - WWMouseClass(Surface * surfaceptr, HWND window); - virtual ~WWMouseClass(void); - - /* - ** Maintenance callback routine. - */ - void Process_Mouse(void); - - /* - ** Sets the game-drawn mouse imagery. - */ - virtual void Set_Cursor(int xhotspot, int yhotspot, ShapeSet const * cursor, int shape); - - /* - ** Controls visibility of the game-drawn mouse. - */ - virtual void Hide_Mouse(void); - virtual void Show_Mouse(void); - - /* - ** Takes control of and releases control of the mouse with - ** respect to the operating system. The mouse must be released - ** during operations with the operating system. When the mouse is - ** relased, it may move outside of the confining rectangle and its - ** shape is controlled by the operating sytem. - */ - virtual void Release_Mouse(void); - virtual void Capture_Mouse(void); - virtual bool Is_Captured(void) const {return(IsCaptured);} - - /* - ** Hide the mouse if it falls within this game screen region. - */ - virtual void Conditional_Hide_Mouse(Rect region); - virtual void Conditional_Show_Mouse(void); - - /* - ** Query about the mouse visiblity state and location. - */ - virtual int Get_Mouse_State(void) const; - virtual int Get_Mouse_X(void) const {return(MouseX);} - virtual int Get_Mouse_Y(void) const {return(MouseY);} - - /* - ** Set the mouse location. - */ - virtual void Set_Mouse_XY( int xpos, int ypos ); - - /* - ** The following two routines can be used to render the mouse onto an alternate - ** surface. - */ - virtual void Draw_Mouse(Surface * scr, bool issidebarsurface = false); - virtual void Erase_Mouse(Surface * scr, bool issidebarsurface = false); - //virtual void Draw_Mouse(Surface * scr); - //virtual void Erase_Mouse(Surface * scr); - - /* - ** Converts O/S screen coordinates into game coordinates. - */ - virtual void Convert_Coordinate(int & x, int & y) const; - - /* - ** Recalculate the confining rectangle from the window. - */ - void Calc_Confining_Rect(void); - - private: - - /* - ** Used to prevent conflict between the processing callback and - ** the normal mouse processing routines. The only potential conflict - ** would be with the maintenance callback routine. Since this callback - ** and the mouse class maintain a strict master/slave relationship, a - ** simple critial section flag is all that is needed. - */ - long Blocked; - - /* - ** Mouse hide/show state. If zero or greater, the mouse is visible. Otherwise - ** it is invisible. - */ - long MouseState; - - /* - ** If the mouse is being managed by this class (for the game), then this flag - ** will be true. When the mouse has been released to be managed by the operating - ** system, this flag will be false. However, this class will still track the mouse - ** position. - */ - bool IsCaptured; - - /* - ** This is the last recorded mouse position that it was drawn to. - */ - int MouseX; - int MouseY; - - /* - ** Points to the main display surface that the mouse will be drawn - ** to as it moves. - */ - Surface * SurfacePtr; - - /* - ** This is the window handle that is used to bind and bias the mouse - ** position and drawing procedures. - */ - HWND Window; - - /* - ** This specifies the rectangle that the game oriented mouse will be - ** confined to on the visible surface. If the mouse is manually drawn - ** on another surface, then this rectangle cooresponds to the hidden - ** surface area where the mouse is to be drawn. - */ - Rect ConfiningRect; - - /* - ** This specifies the mouse shape data. It records the shape set - ** data as well as the particular image contained within. - */ - ShapeSet const * MouseShape; - int ShapeNumber; - - /* - ** Specifies the hot spot where the image click maps to. This is an - ** offset from the upper left corner of the shape image. - */ - int MouseXHot; - int MouseYHot; - - /* - ** Holds the background image behind the mouse to be used for - ** restoring the surface pixels. - */ - BSurface * Background; - Rect SavedRegion; - - /* - ** This is the alternate mouse background buffer to be used when the - ** mouse is manually drawn to an alternate surface by the Draw_Mouse() - ** function. - */ - BSurface * Alternate; - Rect AltRegion; - - /* - ** This is another alternate buffer for drawing the mouse pointer across a second, adjoining - ** offscreen buffer. - */ - BSurface * SidebarAlternate; - Rect SidebarAltRegion; - - /* - ** Conditional hide mouse bounding rectangle and mouse state - ** flag. - */ - Rect ConditionalRect; - int ConditionalState; - - /* - ** Maintenance timer handle. - */ - MMRESULT TimerHandle; - - // Determines if there is valid mouse shape data available. - bool Is_Data_Valid(void) const; - bool Validate_Copy_Buffer(void); - - void Save_Background(void); - void Restore_Background(void); - - Rect Matching_Rect(void) const; - void Raw_Draw_Mouse(Surface * surface, int xoffset, int yoffset); - void Get_Bounded_Position(int & x, int & y) const; - void Update_Mouse_Position(int x, int y); - - void Low_Show_Mouse(void); - void Low_Hide_Mouse(void); - - void Block_Mouse(void) {InterlockedIncrement(&Blocked);/*Blocked++;*/} - void Unblock_Mouse(void) {InterlockedDecrement(&Blocked);/*Blocked--;*/} - bool Is_Blocked(void) const {return(Blocked != 0);} - - bool Is_Hidden(void) const {return(MouseState < 0);} -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xmouse.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xmouse.h deleted file mode 100644 index 75818258355..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xmouse.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /Commando/Code/wwlib/xmouse.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 11/28/00 2:44p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef XMOUSE_H -#define XMOUSE_H - -#include "trect.h" -class Surface; -class ShapeSet; - -/* -** This class manages the "mouse cursor". It presumes the mouse behaves in the traditional -** manner, but requires more manual management than a traditional mouse. -** -** The mouse interface is designed with the following requirements: -** -** 1> The interface (coordinate system) must be consistent with respect to the game user. -** This means that coordinate 0,0 is the upper left pixel of the drawable client area. -** -** 2> It must support arbitrary mouse cursor artwork size and hotspot positioning. Mouse shape -** animation should be a simple process of just changing the mouse shape. -** -** 3> The mouse must be able to break free of the game constraints where necessary in order -** to interface with the operating system. The transition should be easy to manage. -** -** 4> The game mouse "active" region may be a subset rectangle of the normal visible surface. -** This bounding requirement should be transparent to system's functionality. -** -** The system assumes that the sub-rectangle that binds the mouse to the visible surface will -** exactly match the dimensions of any hidden surface that the mouse may have occasion to be -** drawn upon. -*/ -class Mouse { - public: - virtual ~Mouse(void) {} - - /* - ** Sets the game-drawn mouse imagery. - */ - virtual void Set_Cursor(int xhotspot, int yhotspot, ShapeSet const * cursor, int shape) = 0; - - /* - ** Controls visibility of the game-drawn mouse. - */ - virtual void Hide_Mouse(void) = 0; - virtual void Show_Mouse(void) = 0; - - /* - ** Takes control of and releases control of the mouse with - ** respect to the operating system. The mouse must be released - ** during operations with the operating system. When the mouse is - ** relased, it may move outside of the confining rectangle and its - ** shape is controlled by the operating sytem. - */ - virtual void Release_Mouse(void) = 0; - virtual void Capture_Mouse(void) = 0; - virtual bool Is_Captured(void) const = 0; - - /* - ** Hide the mouse if it falls within this game screen region. - */ - virtual void Conditional_Hide_Mouse(Rect region) = 0; - virtual void Conditional_Show_Mouse(void) = 0; - - /* - ** Query about the mouse visiblity state and location. If the mouse - ** state is zero or greater, then the mouse is visible. - */ - virtual int Get_Mouse_State(void) const = 0; - virtual int Get_Mouse_X(void) const = 0; - virtual int Get_Mouse_Y(void) const = 0; - - /* - ** Set the mouse location. - */ - virtual void Set_Mouse_XY( int xpos, int ypos ) = 0; - - /* - ** The following two routines can be used to render the mouse onto an alternate - ** surface. - */ - virtual void Draw_Mouse(Surface * scr, bool issidebarsurface = false) = 0; - virtual void Erase_Mouse(Surface * scr, bool issidebarsurface = false) = 0; - //virtual void Erase_Mouse(Surface * scr) = 0; - - /* - ** Converts O/S screen coordinates into game coordinates. - */ - virtual void Convert_Coordinate(int & x, int & y) const = 0; -}; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp deleted file mode 100644 index 1912e519a81..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.cpp +++ /dev/null @@ -1,903 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /VSS_Sync/wwlib/xsurface.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 10/16/00 11:42a $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Blit_Clip -- Perform rectangle clipping in preparation for a blit. * - * XSurface::Blit_From -- Blit entire surface. * - * XSurface::Blit_From -- Blit from one surface to this one w/ clipping. * - * XSurface::Blit_From -- Blit one region to another. * - * XSurface::Blit_Plain -- Blit a plain rectangle from one surface to another. * - * XSurface::Blit_Trans -- Blit a rectangle with transparency checking. * - * XSurface::Draw_Line -- Draw a line and perform clipping. * - * XSurface::Draw_Line -- Draws a line upon the surface. * - * XSurface::Draw_Rect -- Draw a rectangle with an arbitrary clipping rectangle. * - * XSurface::Draw_Rect -- Draws a rectangle on the surface. * - * XSurface::Fill -- Fill the entire surface with the color specified. * - * XSurface::Fill_Rect -- Fill a rectangle but perform clipping on the fill. * - * XSurface::Fill_Rect -- Fills a rectangle with the color specified. * - * XSurface::Get_Pixel -- Fetches a pixel from the surface. * - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * XSurface::Put_Pixel -- Stores a pixel at the location specified. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "always.h" -#include "blit.h" -#include "blitblit.h" -#include "bsurface.h" -#include "swap.h" -#include "xsurface.h" -//#include -#include - - -/*********************************************************************************************** - * XSurface::Draw_Line -- Draws a line upon the surface. * - * * - * This routine will draw a line on the surface between the points specified. * - * * - * INPUT: startpoint -- Pixel coordinate of one end point to the line. * - * * - * endpoint -- Pixel coordinate of the other end point to the line. * - * * - * color -- The color to draw the line with. * - * * - * OUTPUT: bool; Was the line drawn without error? * - * * - * WARNINGS: This routine is currently very brain-dead. It only draws vertical or * - * horizontal lines. It needs to be updated to handle any angle lines and should * - * perform line-clipping rather than point-pushing if the line intersects the * - * clipping rectangle. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color) -{ - return(XSurface::Draw_Line(Get_Rect(), startpoint, endpoint, color)); -} - - -/*********************************************************************************************** - * XSurface::Draw_Line -- Draw a line and perform clipping. * - * * - * Use this routine to draw a line on the surface but also clip the line draw against * - * an arbitrary sub-rectangle within the surface. * - * * - * INPUT: cliprect -- The clipping rectangle for this line draw. * - * * - * startpoint -- The starting point of the line draw. This point is relative to the * - * clipping rectangle. * - * * - * endpoint -- The ending point fo the line draw. This point is also relative to * - * the clipping rectangle. * - * * - * color -- The screen format color value to store for each pixel of the line. * - * * - * OUTPUT: bool; Was the line drawn? A 'false' return value would indicate that the line * - * was clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Line(Rect const & xcliprect, Point2D const & startpoint, Point2D const & endpoint, int color) -{ - /* - ** Ensure that the clipping rectangle is legal. - */ - Rect cliprect = xcliprect.Intersect(Get_Rect()); - - /* - ** High-speed working variables for the clipping rectangle and clipping operation. - */ - Point2D start = startpoint.Bias_To(cliprect); - Point2D end = endpoint.Bias_To(cliprect); - - /* - ** Build bits that indicate which end points lie outside the clipping rectangle. - ** Quick checks against these flag bits will speed the clipping process. - */ - enum { - OFF_TOP=0x01, - OFF_BOTTOM=0x02, - OFF_RIGHT=0x04, - OFF_LEFT=0x08 - }; - int sflag = 0; - int dflag = 0; - - if (start.X < cliprect.X) sflag |= OFF_LEFT; - if (start.Y < cliprect.Y) sflag |= OFF_TOP; - if (start.X >= cliprect.X+cliprect.Width) sflag |= OFF_RIGHT; - if (start.Y >= cliprect.Y+cliprect.Height) sflag |= OFF_BOTTOM; - if (end.X < cliprect.X) dflag |= OFF_LEFT; - if (end.Y < cliprect.Y) dflag |= OFF_TOP; - if (end.X >= cliprect.X+cliprect.Width) dflag |= OFF_RIGHT; - if (end.Y >= cliprect.Y+cliprect.Height) dflag |= OFF_BOTTOM; - - /* - ** Check to see if the line segment falls outside of the viewing rectangle. - */ - if ((sflag & dflag) != 0) return(false); - - /* - ** Clip the start point if necessary. This clipping should really check for - ** line intersect rather than pushing the end-point within bounds. - */ - if (sflag != 0) { - if (sflag & OFF_LEFT) start.X = cliprect.X; - if (sflag & OFF_RIGHT) start.X = cliprect.X+cliprect.Width-1; - if (sflag & OFF_TOP) start.Y = cliprect.Y; - if (sflag & OFF_BOTTOM) start.Y = cliprect.Y+cliprect.Height-1; - } - if (dflag != 0) { - if (dflag & OFF_LEFT) end.X = cliprect.X; - if (dflag & OFF_RIGHT) end.X = cliprect.X+cliprect.Width-1; - if (dflag & OFF_TOP) end.Y = cliprect.Y; - if (dflag & OFF_BOTTOM) end.Y = cliprect.Y+cliprect.Height-1; - } - - /* - ** Force the line segment to be either vertical or horizontal. This is because - ** we are not using brezenham's alogorithm (which we should be using instead here). - */ - if (start.X != end.X) start.Y = end.Y; - - /* - ** Ensure that the source point is always to the left and up - ** from the dest point. - */ - if (start.X > end.X || start.Y > end.Y) { - swap(start, end); - swap(sflag, dflag); - } - - int bbp = Bytes_Per_Pixel(); - void * buffer = Lock(start); - if (buffer != NULL) { - - if (start.Y == end.Y) { - if (bbp == 1) { - memset(buffer, color, (end.X-start.X)+1); - } else { - for (int x = 0; x <= end.X-start.X; x++) { - ((short *)buffer)[x] = (short)color; - } - } - } else { - for (int y = 0; y <= end.Y-start.Y; y++) { - if (bbp == 1) { - *(char*)buffer = (char)color; - } else { - *(short*)buffer = (short)color; - } - buffer = (void*)(((char*)buffer) + Stride()); - } - } - - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Draw_Rect -- Draws a rectangle on the surface. * - * * - * This routine will draw a line around the rectangle specified. The line will lie just * - * within the rectangle. * - * * - * INPUT: crect -- The rectangle dimensions to use. * - * * - * color -- The color to draw the rectangle. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Rect(Rect const & crect, int color) -{ - return(XSurface::Draw_Rect(Get_Rect(), crect, color)); -} - - -/*********************************************************************************************** - * XSurface::Draw_Rect -- Draw a rectangle with an arbitrary clipping rectangle. * - * * - * This routine will draw the rectangle but will also clip the draw against the clipping * - * rectangle provided. * - * * - * INPUT: cliprect -- The clipping rectangle to clip the draw against. * - * * - * rect -- The rectangle to draw. The coordinates are relative to the clipping * - * rectangle. * - * * - * color -- The color ot use for this rectangle draw. * - * * - * OUTPUT: none * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Draw_Rect(Rect const & cliprect, Rect const & crect, int color) -{ - Point2D ul(crect.X, crect.Y); - Point2D ur(crect.X+crect.Width-1, crect.Y); - Point2D ll(crect.X, crect.Y+crect.Height-1); - Point2D lr(crect.X+crect.Width-1, crect.Y+crect.Height-1); - - Draw_Line(cliprect, ul, ur, color); - Draw_Line(cliprect, ul, ll, color); - Draw_Line(cliprect, ur, lr, color); - Draw_Line(cliprect, ll, lr, color); - return(true); -} - - -/*********************************************************************************************** - * XSurface::Get_Pixel -- Fetches a pixel from the surface. * - * * - * This routine will fetch a pixel element from the surface at the location specified. * - * * - * INPUT: point -- Coordinate to fetch the pixel from. * - * * - * OUTPUT: Returns with the pixel value at that coordinate. The interpretation of the return * - * value depends on the pixel format of the surface. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -int XSurface::Get_Pixel(Point2D const & point) const -{ - int color = 0; - void * pointer = ((Surface*)this)->Lock(point); - if (pointer != NULL) { - if (Bytes_Per_Pixel() == 2) { - color = *((unsigned short*)pointer); - } else { - color = *((unsigned char*)pointer); - } - ((Surface*)this)->Unlock(); - } - return(color); -} - - -/*********************************************************************************************** - * XSurface::Put_Pixel -- Stores a pixel at the location specified. * - * * - * This routine will store a pixel at the coordinate specified on the surface. * - * * - * INPUT: point -- The coordinate to place the pixel at. * - * * - * color -- The pixel data to store. * - * * - * OUTPUT: bool; Was the pixel stored? * - * * - * WARNINGS: The color value specified is the raw pixel value that will be stored. The * - * format of this value is dependant upon the pixel format of the surface. * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Put_Pixel(Point2D const & point, int color) -{ - void * pointer = Lock(point); - if (pointer != NULL) { - if (Bytes_Per_Pixel() == 2) { - *((unsigned short*)pointer) = (unsigned short)color; - } else { - *((unsigned char*)pointer) = (unsigned char)color; - } - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Fill_Rect -- Fills a rectangle with the color specified. * - * * - * This routine will fill the rectangle with a specified color. The rectangle filled will * - * be clipped appropriately. * - * * - * INPUT: fillrect -- The rectangle to fill. * - * * - * color -- The color to use when filling the rectangle. * - * * - * OUTPUT: bool; Was the rectangle filled without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill_Rect(Rect const & fillrect, int color) -{ - return(XSurface::Fill_Rect(fillrect, Get_Rect(), color)); -} - - -/*********************************************************************************************** - * XSurface::Fill_Rect -- Fill a rectangle but perform clipping on the fill. * - * * - * This will fill a rectangle of the specified dimensions. The fill request will be * - * clipped against the clipping rectangle provided. * - * * - * INPUT: cliprect -- The clipping rectangle to use for this fill. * - * * - * fillrect -- The rectangle to fill with the specified color. The rectangle is * - * relative to the clipping rectangle coordinates. * - * * - * color -- The screen format pixel value to draw with. * - * * - * OUTPUT: bool; Was the fill request carried out? A 'false' return value would indicate * - * that the fill was clipped away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) -{ - if (!fillrect.Is_Valid()) return(false); - - /* - ** Ensure that the requested clipping rectangle is actually legal. - */ - Rect wrect = cliprect.Intersect(Get_Rect()); - - /* - ** Clip the rectangle to be filled against the clipping rectangle supplied. - */ - Rect crect = wrect.Intersect(fillrect.Bias_To(cliprect)); - if (!crect.Is_Valid()) return(false); - - void * buffer = Lock(crect.Top_Left()); - if (buffer != NULL) { - if (Bytes_Per_Pixel() == 1) { - for (int y = 0; y < crect.Height; y++) { - memset(buffer, color, crect.Width); - buffer = ((char *)buffer) + Stride(); - } - } else { - for (int y = 0; y < crect.Height; y++) { - for (int x = 0; x < crect.Width; x++) { - ((unsigned short*)buffer)[x] = (unsigned short)color; - } - buffer = ((char *)buffer) + Stride(); - } - } - Unlock(); - return(true); - } - return(false); -} - - -/*********************************************************************************************** - * XSurface::Fill -- Fill the entire surface with the color specified. * - * * - * The color specified will be filled into the entire surface area (but limited by the * - * surface's current window). * - * * - * INPUT: color -- The pixel value to use when filling the surface. * - * * - * OUTPUT: bool; Was the surface fill performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Fill(int color) -{ - return(Fill_Rect(Get_Rect(), Get_Rect(), color)); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit entire surface. * - * * - * This routine will blit the entire surface. * - * * - * INPUT: source -- Pointer to the source surface to blit from. * - * * - * trans -- Perform a transparency aware blit? * - * * - * OUTPUT: bool; Was the surface blit performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Surface const & source, bool trans) -{ - Rect drect = Get_Rect(); - drect.X = 0; - drect.Y = 0; - - Rect srect = source.Get_Rect(); - srect.X = 0; - srect.Y = 0; - bool result = Blit_From(drect, source, srect, trans); - - return(result); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit one region to another. * - * * - * Use this routine to copy one rectangle of pixel data to another. The pixels being * - * copied may be processed according to the parameters specified. * - * * - * INPUT: destrect -- The destination rectangle to bit to. * - * * - * source -- Pointer to the source surface to blit from. * - * * - * sourcerect -- The source rectangle to blit from. * - * * - * trans -- Should transparent pixels be scanned for an skipped? * - * * - * OUTPUT: bool; Was the blit operation performed without error? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 02/07/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans) -{ - return(XSurface::Blit_From(Get_Rect(), destrect, source, source.Get_Rect(), sourcerect, trans)); -} - - -/*********************************************************************************************** - * XSurface::Blit_From -- Blit from one surface to this one w/ clipping. * - * * - * This routine will blit a clipped rectangle from the specified surface to this one. * - * * - * INPUT: dcliprect -- The clipping rectangle to use for this (destination) surface. * - * * - * destrect -- The destanation rect of the blit. Coordinates are relative to the * - * destination clipping rectangle. * - * * - * source -- The source surface to blit from. * - * * - * scliprect -- The source clipping rectangle for the blit. * - * * - * sourcrect -- The source rectangle of the blit. The coordinates are relative to * - * the source clipping rectangle. * - * * - * trans -- Is this a transparent pixel aware blit request? * - * * - * OUTPUT: bool; Was a blit performed? A 'false' value would mean that the blit was clipped * - * away. * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/27/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans) -{ - Rect drect = destrect; - Rect srect = sourcerect; - - /* - ** Perform any clipping against the clipping rectangles. Proceed with the blit only - ** if there are pixels left unclipped. - */ - if (Blit_Clip(drect, dcliprect, srect, scliprect)) { - - if (trans) { - return(Blit_Trans(*this, drect, source, srect)); - } - return(Blit_Plain(*this, drect, source, srect)); - } - return(false); -} - - -/*********************************************************************************************** - * Blit_Clip -- Perform rectangle clipping in preparation for a blit. * - * * - * This routine will take a source rectangle and a source clipping window and intersect * - * these with a dest rectangle and a dest clipping window. The effect will be to alter * - * the source and dest rectangles so that they will stay within the clipping rectangles * - * imposed upon the source and destination surfaces. The process clips the rectangles * - * rather than displacing them when performing its adjustment. It is possible that one * - * or both rectangles are clipped into oblivion by this routine. This condition will be * - * flagged with the return value. * - * * - * INPUT: drect -- Reference to the destination rectangle (relative coordinates to the * - * destination window). This is both an input and output parameter. * - * * - * dwindow -- The destination window to clip the dest rect against. * - * * - * srect -- Reference to the source rectangle (relative to the source window). * - * This is both an input and output parameter. * - * * - * swindow -- The source window to clip the srect against. * - * * - * OUTPUT: bool; Was the clip performed and the srect and drect parameters still valid. * - * i.e., they represent at least one pixel that has not been clipped away. * - * * - * WARNINGS: The rectangles may be clipped into nothingness by this routine. Be sure to * - * check the return value for this condition and perform no blit operation in * - * that case. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool Blit_Clip(Rect & drect, Rect const & dwindow, Rect & srect, Rect const & swindow) -{ - /* - ** If the rectangles are of the same dimensions, then a coordinated clipping process is - ** possible. This results in an intelligent blit even if the source or destination - ** rectangles is partially outside the clipping rectangle. - */ - if (drect.Width == srect.Width && drect.Height == srect.Height) { - /* - ** Clip the left and top edges against the clipping window. - */ - if (drect.X < 0) { - srect.X += -drect.X; - srect.Width -= -drect.X; - drect.Width -= -drect.X; - drect.X = 0; - } - if (drect.Y < 0) { - srect.Y += -drect.Y; - srect.Height -= -drect.Y; - drect.Height -= -drect.Y; - drect.Y = 0; - } - - /* - ** Clip the right and bottom edges if they spill past the - ** clipping window boundaries. - */ - int rightspill = (drect.X+drect.Width) - dwindow.Width; - if (rightspill > 0) { - srect.Width -= rightspill; - drect.Width -= rightspill; - } - int bottomspill = (drect.Y+drect.Height) - dwindow.Height; - if (bottomspill > 0) { - srect.Height -= bottomspill; - drect.Height -= bottomspill; - } - - /* - ** Clip the left and top edges against the clipping - ** window. - */ - if (srect.X < 0) { - drect.X += -srect.X; - srect.Width -= -srect.X; - drect.Width -= -srect.X; - srect.X = 0; - } - if (srect.Y < 0) { - drect.Y += -srect.Y; - srect.Height -= -srect.Y; - drect.Height -= -srect.Y; - srect.Y = 0; - } - - /* - ** Clip the right and bottom edges agaist the clipping window. - */ - rightspill = (srect.X+srect.Width) - swindow.Width; - if (rightspill > 0) { - srect.Width -= rightspill; - drect.Width -= rightspill; - } - bottomspill = (srect.Y+srect.Height) - swindow.Height; - if (bottomspill > 0) { - srect.Height -= bottomspill; - drect.Height -= bottomspill; - } - - } else { - - /* - ** Since the rectangles are not of the same dimensions, scaling is presumed. Clipping - ** in such a case is merely a legality clip against the bounding rectangle. No coordinated - ** adjustments can occur. For best results, boundary clipping should be performed prior to - ** calling this routine. - */ - drect = drect.Intersect(dwindow); - srect = srect.Intersect(swindow); - } - - return(drect.Is_Valid() && srect.Is_Valid()); -} - - -/*********************************************************************************************** - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * * - * This performs the clipping operation required before a blit occurs. It examines the * - * source and destination coordinate constraints and performs clipping such that only * - * legal pixels will be blitted. As a consequence it can determine if the blit has been * - * completely clipped and thus can be skipped. * - * * - * INPUT: dest -- The destination surface rect for the blit. * - * * - * drect -- The rectangle within the destination surface rect for the blit. This * - * rectangle reference will be adjusted as necessary. * - * * - * source -- The source surface rect of the blit. * - * * - * srect -- The source rectangle within the source surface rect for the blit. * - * This rectangle reference will be adjusted as necessary. * - * * - * overlapped -- Output reference that stores the boolean answer to the question -- * - * are the blit rectangles overlapping on the same surface? * - * * - * dbuffer -- Output reference that stores a pointer to the locked destination * - * surface. It points to the upper left destination corner pixel. * - * * - * sbuffer -- Output reference that stores a pointer to the locked source surface. * - * It points to the upper left corner source pixel. * - * * - * OUTPUT: bool; Can the blit proceed since there is at least one pixel that has not been * - * clipped away? It can also fail if a lock could not be performed on the * - * source or destination surfaces. * - * * - * WARNINGS: The surfaces locked by this routine must be unlocked. If the return value is * - * 'true', then the surfaces must be unlocked. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Prep_For_Blit(Surface & dest, Rect & drect, Surface const & source, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer) -{ - return(XSurface::Prep_For_Blit(dest, dest.Get_Rect(), drect, source, source.Get_Rect(), srect, overlapped, dbuffer, sbuffer)); -#ifdef NEVER - overlapped = false; - dbuffer = NULL; - sbuffer = NULL; - - if (!drect.Is_Valid() || !srect.Is_Valid()) return(false); - - /* - ** Perform the clipping of the desired blit rectangles against the surface clipping - ** rectangles. If it happens that the blit is clipped into oblivion, then bail - ** immediately -- there is nothing left to do. - */ - Rect swindow = source.Get_Rect(); - Rect dwindow = dest.Get_Rect(); - if (!Blit_Clip(drect, dwindow, srect, swindow)) { - return(false); - } - - /* - ** Determine if the rectangles overlap such that a forward blit would - ** be prohibited. This only occurs if the source and destination refer to the - ** same surface and the rectangles overlap. - */ - overlapped = false; - if (&source == &dest && srect.Is_Overlapping(drect)) { - if (srect.Y < drect.Y || (srect.Y == drect.Y && srect.X < drect.X)) { - overlapped = true; - } - } - - /* - ** Fetch pointers to the source and dest upper left pixel. That is, the upper - ** left pixel of the source and dest sub-rectangles within each surface - ** respectively. - */ - dbuffer = dest.Lock(drect.Point()); - if (dbuffer == NULL) return(false); - sbuffer = ((Surface &)source).Lock(srect.Point()); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - return(true); -#endif -} - - -/*********************************************************************************************** - * XSurface::Prep_For_Blit -- Clips and prepares pointers for a blit operation. * - * * - * This performs the clipping operation required before a blit occurs. It examines the * - * source and destination coordinate constraints and performs clipping such that only * - * legal pixels will be blitted. As a consequence it can determine if the blit has been * - * completely clipped and thus can be skipped. * - * * - * INPUT: dest -- The destination surface rect for the blit. * - * * - * dcliprect-- The destination clipping rectangle. * - * * - * drect -- The rectangle within the destination surface rect for the blit. This * - * rectangle reference will be adjusted as necessary. * - * * - * source -- The source surface rect of the blit. * - * * - * scliprect-- The source clipping rectangle. * - * * - * srect -- The source rectangle within the source surface rect for the blit. * - * This rectangle reference will be adjusted as necessary. * - * * - * overlapped -- Output reference that stores the boolean answer to the question -- * - * are the blit rectangles overlapping on the same surface? * - * * - * dbuffer -- Output reference that stores a pointer to the locked destination * - * surface. It points to the upper left destination corner pixel. * - * * - * sbuffer -- Output reference that stores a pointer to the locked source surface. * - * It points to the upper left corner source pixel. * - * * - * OUTPUT: bool; Can the blit proceed since there is at least one pixel that has not been * - * clipped away? It can also fail if a lock could not be performed on the * - * source or destination surfaces. * - * * - * WARNINGS: The surfaces locked by this routine must be unlocked. If the return value is * - * 'true', then the surfaces must be unlocked. * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Prep_For_Blit(Surface & dest, Rect const & dcliprect, Rect & drect, Surface const & source, Rect const & scliprect, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer) -{ - overlapped = false; - dbuffer = NULL; - sbuffer = NULL; - - if (!drect.Is_Valid() || !dcliprect.Is_Valid() || !srect.Is_Valid() || !scliprect.Is_Valid()) return(false); - - /* - ** Perform the clipping of the desired blit rectangles against the surface clipping - ** rectangles. If it happens that the blit is clipped into oblivion, then bail - ** immediately -- there is nothing left to do. - */ - if (!Blit_Clip(drect, dcliprect, srect, scliprect)) { - return(false); - } - - /* - ** Determine if the rectangles overlap such that a forward blit would - ** be prohibited. This only occurs if the source and destination refer to the - ** same surface and the rectangles overlap. - */ - overlapped = false; - if (&source == &dest && srect.Is_Overlapping(drect)) { - if (srect.Y < drect.Y || (srect.Y == drect.Y && srect.X < drect.X)) { - overlapped = true; - } - } - - /* - ** Fetch pointers to the source and dest upper left pixel. That is, the upper - ** left pixel of the source and dest sub-rectangles within each surface - ** respectively. - */ - dbuffer = dest.Lock(dcliprect.Top_Left() + drect.Top_Left()); - if (dbuffer == NULL) return(false); - sbuffer = source.Lock(scliprect.Top_Left() + srect.Top_Left()); - if (sbuffer == NULL) { - dest.Unlock(); - return(false); - } - - return(true); -} - - -/*********************************************************************************************** - * XSurface::Blit_Plain -- Blit a plain rectangle from one surface to another. * - * * - * This routine will perform a simple blit of a rectangle from one surface to another. * - * * - * INPUT: dest -- The destination surface for the blit. * - * * - * destrect -- The destination rectangle for the blit. * - * * - * source -- The source surface. * - * * - * sourcerect -- The rectangle in the source surface to blit from. * - * * - * OUTPUT: bool; Was the blit performed? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_Plain(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect) -{ - if (dest.Bytes_Per_Pixel() == 1) { - return(Bit_Blit(dest, destrect, source, sourcerect, BlitPlain())); - } - return(Bit_Blit(dest, destrect, source, sourcerect, BlitPlain())); -} - - -/*********************************************************************************************** - * XSurface::Blit_Trans -- Blit a rectangle with transparency checking. * - * * - * This routine will perform a simple blit of one rectangle to another on the surfaces * - * specified. * - * * - * INPUT: dest -- The destination surface. * - * * - * destrect -- The destination rectangle within the surface. * - * * - * source -- The source surface. * - * * - * sourcerect -- The source rectangle. * - * * - * OUTPUT: bool; Was the blit performed? * - * * - * WARNINGS: none * - * * - * HISTORY: * - * 05/19/1997 JLB : Created. * - *=============================================================================================*/ -bool XSurface::Blit_Trans(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect) -{ - switch (dest.Bytes_Per_Pixel()) - { - case 1: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - case 2: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - case 4: - return(Bit_Blit(dest, destrect, source, sourcerect, BlitTrans())); - default: - return(false); - } -} - - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.h deleted file mode 100644 index 57c578009f3..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/xsurface.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** - *********************************************************************************************** - * * - * Project Name : Command & Conquer * - * * - * $Archive:: /G/wwlib/xsurface.h $* - * * - * $Author:: Eric_c $* - * * - * $Modtime:: 4/02/99 12:01p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef XSURFACE_H -#define XSURFACE_H - -#include "Surface.h" - -/* -** This is a concrete (mostly) derived class that handles a surface. This layer presumes that -** pixels are compositied into a contiguous integral (usually a byte) linear array. The -** implemented routines do not use hardware assist. They are prime candidates to be converted -** to assembly language. -*/ -class XSurface : public Surface -{ - public: - XSurface(int width=0, int height=0) : Surface(width, height), LockCount(0) {} - virtual ~XSurface(void) {} - - /* - ** Copies regions from one surface to another. - */ - virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false); - virtual bool Blit_From(Surface const & source, bool trans=false); - - /* - ** Fills a region with a constant color. - */ - virtual bool Fill_Rect(Rect const & rect, int color); - virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color); - virtual bool Fill(int color); - - /* - ** Fetches and stores a pixel to the display (pixel is in surface format). - */ - virtual bool Put_Pixel(Point2D const & point, int color); - virtual int Get_Pixel(Point2D const & point) const; - - /* - ** Draws lines onto the surface. - */ - virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color); - virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color); - - /* - ** Draws rectangles onto the surface. - */ - virtual bool Draw_Rect(Rect const & rect, int color); - virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color); - - /* - ** Gets and frees a direct pointer to the video memory. - */ - virtual void * Lock(Point2D = Point2D(0, 0)) const {LockCount++;return(NULL);} - virtual bool Unlock(void) const {LockCount--;return(true);} - virtual bool Is_Locked(void) const {return(LockCount != 0);} - - /* - ** Queries information about the surface. - */ - virtual int Bytes_Per_Pixel(void) const = 0; - virtual int Stride(void) const = 0; - - /* - ** Hack function to serve the purpose that RTTI was invented for, but since - ** the Watcom compiler doesn't support RTTI, we must resort to using this - ** alternative. - */ - virtual bool Is_Direct_Draw(void) const {return(false);} - - /* - ** This routine is handy for preparing to perform some kind of manual blit - ** operation. - */ - static bool Prep_For_Blit(Surface & dest, Rect & drect, Surface const & source, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer); - static bool Prep_For_Blit(Surface & dest, Rect const & dcliprect, Rect & drect, Surface const & source, Rect const & scliprect, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer); - - /* - ** These are the exposed manual blit routines. They can be called directly if desired. - */ - static bool Blit_Trans(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect); - static bool Blit_Plain(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect); - - protected: - /* - ** Records the number of locks on this surface. - */ - mutable int LockCount; -}; - -bool Blit_Clip(Rect & drect, Rect const & dwindow, Rect & srect, Rect const & swindow); - - -#endif diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp index 503b79f2798..6ae830f5ec3 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp @@ -30,7 +30,6 @@ #include "W3DDevice/GameClient/W3DAssetManager.h" #include "W3DDevice/GameClient/Module/W3DModelDraw.h" #include "agg_def.h" -#include "msgloop.h" #include "part_ldr.h" #include "rendobj.h" #include "hanim.h" @@ -58,7 +57,6 @@ #include "shattersystem.h" #include "light.h" #include "texproject.h" -#include "keyboard.h" #include "MapSettings.h" #include "predlod.h" #include "SelectMacrotexture.h"